private async getStatusInternal()

in src/durableClient/DurableClient.ts [720:840]


    private async getStatusInternal(
        options: GetStatusInternalOptions,
        continuationToken?: string,
        prevData?: unknown[]
    ): Promise<AxiosResponse> {
        let requestUrl: string;
        if (this.clientData.rpcBaseUrl) {
            // Fast local RPC path
            let path = new URL(`instances/${options.instanceId || ""}`, this.clientData.rpcBaseUrl)
                .href;
            const query: string[] = [];
            if (options.taskHubName) {
                query.push(`taskHub=${options.taskHubName}`);
            }
            if (options.connectionName) {
                query.push(`connection=${options.connectionName}`);
            }
            if (options.showHistory) {
                query.push(`showHistory=${options.showHistory}`);
            }
            if (options.showHistoryOutput) {
                query.push(`showHistoryOutput=${options.showHistoryOutput}`);
            }
            if (options.showInput) {
                query.push(`showInput=${options.showInput}`);
            }
            if (options.createdTimeFrom) {
                query.push(`createdTimeFrom=${options.createdTimeFrom.toISOString()}`);
            }
            if (options.createdTimeTo) {
                query.push(`createdTimeTo=${options.createdTimeTo.toISOString()}`);
            }
            if (options.runtimeStatus && options.runtimeStatus.length > 0) {
                const statusList: string = options.runtimeStatus
                    .map((value) => value.toString())
                    .join(",");
                query.push(`runtimeStatus=${statusList}`);
            }

            if (query.length > 0) {
                path += "?" + query.join("&");
            }

            requestUrl = new URL(path, this.clientData.rpcBaseUrl).href;
        } else {
            // Legacy app frontend code path
            const template = this.clientData.managementUrls.statusQueryGetUri;
            const idPlaceholder = this.clientData.managementUrls.id;

            requestUrl = template.replace(
                idPlaceholder,
                typeof options.instanceId === "string" ? options.instanceId : ""
            );
            if (options.taskHubName) {
                requestUrl = requestUrl.replace(this.clientData.taskHubName, options.taskHubName);
            }
            if (options.connectionName) {
                requestUrl = requestUrl.replace(
                    /(connection=)([\w]+)/gi,
                    "$1" + options.connectionName
                );
            }
            if (options.showHistory) {
                requestUrl += `&${this.showHistoryQueryKey}=${options.showHistory}`;
            }
            if (options.showHistoryOutput) {
                requestUrl += `&${this.showHistoryOutputQueryKey}=${options.showHistoryOutput}`;
            }
            if (options.createdTimeFrom) {
                requestUrl += `&${
                    this.createdTimeFromQueryKey
                }=${options.createdTimeFrom.toISOString()}`;
            }
            if (options.createdTimeTo) {
                requestUrl += `&${
                    this.createdTimeToQueryKey
                }=${options.createdTimeTo.toISOString()}`;
            }
            if (options.runtimeStatus && options.runtimeStatus.length > 0) {
                const statusesString = options.runtimeStatus
                    .map((value) => value.toString())
                    .reduce((acc, curr, i) => {
                        return acc + (i > 0 ? "," : "") + curr;
                    });

                requestUrl += `&${this.runtimeStatusQueryKey}=${statusesString}`;
            }
            if (typeof options.showInput === "boolean") {
                requestUrl += `&${this.showInputQueryKey}=${options.showInput}`;
            }
        }

        // If a continuation token is provided, we add it to the request's header
        let axiosConfig = undefined;
        if (continuationToken) {
            axiosConfig = {
                headers: {
                    "x-ms-continuation-token": continuationToken,
                },
            };
        }

        // We call the getStatus endpoint and construct a promise callback to handle the recursion
        // This assumes that, so long as continuation tokens are found, that the http response status
        // can be safely ignored (either 200 or 202).
        const response = this.axiosInstance.get(requestUrl, axiosConfig).then((httpResponse) => {
            // Aggregate results so far
            const headers = httpResponse.headers;
            if (prevData) {
                httpResponse.data = prevData.concat(httpResponse.data);
            }
            // If a new continuation token is found, recurse. Otherwise, return the results
            const token = headers["x-ms-continuation-token"];
            if (token) {
                return this.getStatusInternal(options, token, httpResponse.data);
            }
            return httpResponse;
        });

        return response;
    }