@azure-rest/iot-device-update 1.1.1-alpha.20250718.1 → 1.1.1-alpha.20250730.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/browser/deviceUpdate.js +13 -11
  2. package/dist/browser/deviceUpdate.js.map +1 -1
  3. package/dist/browser/isUnexpected.js +4 -5
  4. package/dist/browser/isUnexpected.js.map +1 -1
  5. package/dist/browser/paginateHelper.js +43 -73
  6. package/dist/browser/paginateHelper.js.map +1 -1
  7. package/dist/browser/pollingHelper.js +11 -8
  8. package/dist/browser/pollingHelper.js.map +1 -1
  9. package/dist/commonjs/deviceUpdate.js +13 -11
  10. package/dist/commonjs/deviceUpdate.js.map +1 -1
  11. package/dist/commonjs/isUnexpected.js +4 -5
  12. package/dist/commonjs/isUnexpected.js.map +1 -1
  13. package/dist/commonjs/paginateHelper.js +43 -73
  14. package/dist/commonjs/paginateHelper.js.map +1 -1
  15. package/dist/commonjs/pollingHelper.js +11 -8
  16. package/dist/commonjs/pollingHelper.js.map +1 -1
  17. package/dist/commonjs/tsdoc-metadata.json +11 -11
  18. package/dist/esm/deviceUpdate.js +13 -11
  19. package/dist/esm/deviceUpdate.js.map +1 -1
  20. package/dist/esm/isUnexpected.js +4 -5
  21. package/dist/esm/isUnexpected.js.map +1 -1
  22. package/dist/esm/paginateHelper.js +43 -73
  23. package/dist/esm/paginateHelper.js.map +1 -1
  24. package/dist/esm/pollingHelper.js +11 -8
  25. package/dist/esm/pollingHelper.js.map +1 -1
  26. package/dist/react-native/deviceUpdate.js +13 -11
  27. package/dist/react-native/deviceUpdate.js.map +1 -1
  28. package/dist/react-native/isUnexpected.js +4 -5
  29. package/dist/react-native/isUnexpected.js.map +1 -1
  30. package/dist/react-native/paginateHelper.js +43 -73
  31. package/dist/react-native/paginateHelper.js.map +1 -1
  32. package/dist/react-native/pollingHelper.js +11 -8
  33. package/dist/react-native/pollingHelper.js.map +1 -1
  34. package/package.json +2 -2
  35. package/review/iot-device-update-node.api.md +2211 -2211
@@ -1 +1 @@
1
- {"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAoEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,eAAwB,EACxB,UAAqE,EAAE;;IAEvE,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,MAAM,GAA8B;QACxC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,sGAAsG;YACtG,2FAA2F;YAC3F,6BAA6B;YAC7B,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,IAAY,EAAE,WAA+C,EAAE,EAAE;YACvF,sEAAsE;YACtE,4EAA4E;YAC5E,0JAA0J;YAC1J,+GAA+G;YAC/G,SAAS,aAAa;gBACpB,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YACD,MAAM,gBAAgB,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAAC;YAClD,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC;YAC3C,IAAI,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO,EAAE,CAAC;gBAC9B,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;iBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;gBAChC,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE;oBACzD,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;YACL,CAAC;YACD,IAAI,QAAQ,CAAC;YACb,IAAI,CAAC;gBACH,QAAQ,GAA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AC,CAAC;QACL,CAAC;QACD,WAAW;YACT,eAAe,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;QACD,UAAU,EAAE,UAAU,CAAC,UAAU;QACjC,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,QAAiB;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,uDAAuD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,kCACN,QAAQ,KACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI,GACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n} from \"@azure/core-lro\";\nimport { createHttpPoller } from \"@azure/core-lro\";\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<TState extends OperationState<TResult>, TResult> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n\n /**\n * Returns true if the poller is stopped.\n * @deprecated Use abortSignal status to track this instead.\n */\n isStopped(): boolean;\n}\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {},\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n const abortController = new AbortController();\n const poller: RunningOperation<TResult> = {\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path: string, pollOptions?: { abortSignal?: AbortSignalLike }) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = pollOptions?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] = initialResponse.request.url;\n return lroResponse;\n },\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return abortController.signal.aborted;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState,\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted,\n };\n return simplePoller;\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult,\n): OperationResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"pollingHelper.js","sourceRoot":"","sources":["../../src/pollingHelper.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAoEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,eAAwB,EACxB,UAAqE,EAAE;IAEvE,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,MAAM,GAA8B;QACxC,kBAAkB,EAAE,KAAK,IAAI,EAAE;YAC7B,sGAAsG;YACtG,2FAA2F;YAC3F,6BAA6B;YAC7B,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;QACzC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,IAAY,EAAE,WAA+C,EAAE,EAAE;YACvF,sEAAsE;YACtE,4EAA4E;YAC5E,0JAA0J;YAC1J,+GAA+G;YAC/G,SAAS,aAAa;gBACpB,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;YACD,MAAM,gBAAgB,GAAG,WAAW,EAAE,WAAW,CAAC;YAClD,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC;YAC3C,IAAI,gBAAgB,EAAE,OAAO,EAAE,CAAC;gBAC9B,eAAe,CAAC,KAAK,EAAE,CAAC;YAC1B,CAAC;iBAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;gBAChC,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE;oBACzD,IAAI,EAAE,IAAI;iBACX,CAAC,CAAC;YACL,CAAC;YACD,IAAI,QAAQ,CAAC;YACb,IAAI,CAAC;gBACH,QAAQ,GAAG,MAAM,MAAM;qBACpB,aAAa,CAAC,IAAI,IAAI,eAAe,CAA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AAI,EAAE,UAAU,CAAC,IAAI;QACrB,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,SAAS,EAAE,UAAU,CAAC,SAAS;KAChC,CAAC;IACF,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CACrB,QAAiB;IAEjB,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,SAAS,CAAC,uDAAuD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAChG,CAAC;IAED,OAAO;QACL,YAAY,EAAE,QAAQ;QACtB,WAAW,EAAE;YACX,GAAG,QAAQ;YACX,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5C,IAAI,EAAE,QAAQ,CAAC,IAAI;SACpB;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport type {\n CancelOnProgress,\n CreateHttpPollerOptions,\n RunningOperation,\n OperationResponse,\n OperationState,\n} from \"@azure/core-lro\";\nimport { createHttpPoller } from \"@azure/core-lro\";\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<TState extends OperationState<TResult>, TResult> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: { abortSignal?: AbortSignalLike }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n\n /**\n * Returns true if the poller is stopped.\n * @deprecated Use abortSignal status to track this instead.\n */\n isStopped(): boolean;\n}\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {},\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n const abortController = new AbortController();\n const poller: RunningOperation<TResult> = {\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (path: string, pollOptions?: { abortSignal?: AbortSignalLike }) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = pollOptions?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true,\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] = initialResponse.request.url;\n return lroResponse;\n },\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return abortController.signal.aborted;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\",\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState,\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted,\n };\n return simplePoller;\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult,\n): OperationResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body,\n },\n };\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.default = createClient;
6
- const tslib_1 = require("tslib");
7
6
  const core_client_1 = require("@azure-rest/core-client");
8
7
  const logger_js_1 = require("./logger.js");
9
8
  /**
@@ -12,21 +11,24 @@ const logger_js_1 = require("./logger.js");
12
11
  * @param credentials - uniquely identify client credential
13
12
  * @param options - the parameter for all optional parameters
14
13
  */
15
- function createClient(endpoint, credentials, _a = {}) {
16
- var _b, _c, _d, _e, _f, _g;
17
- var { apiVersion = "2022-10-01" } = _a, options = tslib_1.__rest(_a, ["apiVersion"]);
18
- const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://${endpoint}`;
14
+ function createClient(endpoint, credentials, { apiVersion = "2022-10-01", ...options } = {}) {
15
+ const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://${endpoint}`;
19
16
  const userAgentInfo = `azsdk-js-iot-device-update-rest/1.1.0`;
20
17
  const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
21
18
  ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
22
19
  : `${userAgentInfo}`;
23
- options = Object.assign(Object.assign({}, options), { userAgentOptions: {
20
+ options = {
21
+ ...options,
22
+ userAgentOptions: {
24
23
  userAgentPrefix,
25
- }, loggingOptions: {
26
- logger: (_e = (_d = options.loggingOptions) === null || _d === void 0 ? void 0 : _d.logger) !== null && _e !== void 0 ? _e : logger_js_1.logger.info,
27
- }, credentials: {
28
- scopes: (_g = (_f = options.credentials) === null || _f === void 0 ? void 0 : _f.scopes) !== null && _g !== void 0 ? _g : ["https://api.adu.microsoft.com/.default"],
29
- } });
24
+ },
25
+ loggingOptions: {
26
+ logger: options.loggingOptions?.logger ?? logger_js_1.logger.info,
27
+ },
28
+ credentials: {
29
+ scopes: options.credentials?.scopes ?? ["https://api.adu.microsoft.com/.default"],
30
+ },
31
+ };
30
32
  const client = (0, core_client_1.getClient)(endpointUrl, credentials, options);
31
33
  client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
32
34
  client.pipeline.addPolicy({
@@ -1 +1 @@
1
- {"version":3,"file":"deviceUpdate.js","sourceRoot":"","sources":["../../src/deviceUpdate.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAoBlC,+BA2CC;;AA5DD,yDAAoD;AACpD,2CAAqC;AAUrC;;;;;GAKG;AACH,SAAwB,YAAY,CAClC,QAAgB,EAChB,WAA4B,EAC5B,KAAuE,EAAE;;QAAzE,EAAE,UAAU,GAAG,YAAY,OAA8C,EAAzC,OAAO,sBAAvC,cAAyC,CAAF;IAEvC,MAAM,WAAW,GAAG,MAAA,MAAA,OAAO,CAAC,QAAQ,mCAAI,OAAO,CAAC,OAAO,mCAAI,WAAW,QAAQ,EAAE,CAAC;IACjF,MAAM,aAAa,GAAG,uCAAuC,CAAC;IAC9D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,mCACF,OAAO,KACV,gBAAgB,EAAE;YAChB,eAAe;SAChB,EACD,cAAc,EAAE;YACd,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,cAAc,0CAAE,MAAM,mCAAI,kBAAM,CAAC,IAAI;SACtD,EACD,WAAW,EAAE;YACX,MAAM,EAAE,MAAA,MAAA,OAAO,CAAC,WAAW,0CAAE,MAAM,mCAAI,CAAC,wCAAwC,CAAC;SAClF,GACF,CAAC;IACF,MAAM,MAAM,GAAG,IAAA,uBAAS,EAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAuB,CAAC;IAElF,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { DeviceUpdateClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface DeviceUpdateClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DeviceUpdateClient`\n * @param endpoint - The Device Update for IoT Hub account endpoint (hostname only, no protocol).\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credentials: TokenCredential,\n { apiVersion = \"2022-10-01\", ...options }: DeviceUpdateClientOptions = {},\n): DeviceUpdateClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://${endpoint}`;\n const userAgentInfo = `azsdk-js-iot-device-update-rest/1.1.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://api.adu.microsoft.com/.default\"],\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DeviceUpdateClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
1
+ {"version":3,"file":"deviceUpdate.js","sourceRoot":"","sources":["../../src/deviceUpdate.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAoBlC,+BA2CC;AA5DD,yDAAoD;AACpD,2CAAqC;AAUrC;;;;;GAKG;AACH,SAAwB,YAAY,CAClC,QAAgB,EAChB,WAA4B,EAC5B,EAAE,UAAU,GAAG,YAAY,EAAE,GAAG,OAAO,KAAgC,EAAE;IAEzE,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,WAAW,QAAQ,EAAE,CAAC;IACjF,MAAM,aAAa,GAAG,uCAAuC,CAAC;IAC9D,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,g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IT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport { getClient } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport type { TokenCredential } from \"@azure/core-auth\";\nimport type { DeviceUpdateClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface DeviceUpdateClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `DeviceUpdateClient`\n * @param endpoint - The Device Update for IoT Hub account endpoint (hostname only, no protocol).\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n endpoint: string,\n credentials: TokenCredential,\n { apiVersion = \"2022-10-01\", ...options }: DeviceUpdateClientOptions = {},\n): DeviceUpdateClient {\n const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://${endpoint}`;\n const userAgentInfo = `azsdk-js-iot-device-update-rest/1.1.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n scopes: options.credentials?.scopes ?? [\"https://api.adu.microsoft.com/.default\"],\n },\n };\n const client = getClient(endpointUrl, credentials, options) as DeviceUpdateClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
@@ -72,7 +72,7 @@ const responseMap = {
72
72
  };
73
73
  function isUnexpected(response) {
74
74
  const lroOriginal = response.headers["x-ms-original-url"];
75
- const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
75
+ const url = new URL(lroOriginal ?? response.request.url);
76
76
  const method = response.request.method;
77
77
  let pathDetails = responseMap[`${method} ${url.pathname}`];
78
78
  if (!pathDetails) {
@@ -81,7 +81,6 @@ function isUnexpected(response) {
81
81
  return !pathDetails.includes(response.status);
82
82
  }
83
83
  function getParametrizedPathSuccess(method, path) {
84
- var _a, _b, _c, _d;
85
84
  const pathParts = path.split("/");
86
85
  // Traverse list to match the longest candidate
87
86
  // matchedLen: the length of candidate path
@@ -100,13 +99,13 @@ function getParametrizedPathSuccess(method, path) {
100
99
  // track if we have found a match to return the values found.
101
100
  let found = true;
102
101
  for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
103
- if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
104
- const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
102
+ if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) {
103
+ const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
105
104
  // If the current part of the candidate is a "template" part
106
105
  // Try to use the suffix of pattern to match the path
107
106
  // {guid} ==> $
108
107
  // {guid}:export ==> :export$
109
- const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
108
+ const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
110
109
  if (!isMatched) {
111
110
  found = false;
112
111
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":";AAAA,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poration.\n// Licensed under the MIT License.\n\nimport type {\n DeviceUpdateListUpdates200Response,\n DeviceUpdateListUpdatesDefaultResponse,\n DeviceUpdateImportUpdate200Response,\n DeviceUpdateImportUpdate202Response,\n DeviceUpdateImportUpdateDefaultResponse,\n DeviceUpdateGetUpdate200Response,\n DeviceUpdateGetUpdate304Response,\n DeviceUpdateGetUpdateDefaultResponse,\n DeviceUpdateDeleteUpdate202Response,\n DeviceUpdateDeleteUpdateDefaultResponse,\n DeviceUpdateListProviders200Response,\n DeviceUpdateListProvidersDefaultResponse,\n DeviceUpdateListNames200Response,\n DeviceUpdateListNamesDefaultResponse,\n DeviceUpdateListVersions200Response,\n DeviceUpdateListVersionsDefaultResponse,\n DeviceUpdateListFiles200Response,\n DeviceUpdateListFilesDefaultResponse,\n DeviceUpdateGetFile200Response,\n DeviceUpdateGetFile304Response,\n DeviceUpdateGetFileDefaultResponse,\n DeviceUpdateListOperationStatuses200Response,\n DeviceUpdateListOperationStatusesDefaultResponse,\n DeviceUpdateGetOperationStatus200Response,\n DeviceUpdateGetOperationStatus304Response,\n DeviceUpdateGetOperationStatusDefaultResponse,\n DeviceManagementListDeviceClasses200Response,\n DeviceManagementListDeviceClassesDefaultResponse,\n DeviceManagementGetDeviceClass200Response,\n DeviceManagementGetDeviceClassDefaultResponse,\n DeviceManagementUpdateDeviceClass200Response,\n DeviceManagementUpdateDeviceClassDefaultResponse,\n DeviceManagementDeleteDeviceClass204Response,\n DeviceManagementDeleteDeviceClassDefaultResponse,\n DeviceManagementListInstallableUpdatesForDeviceClass200Response,\n DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse,\n DeviceManagementListDevices200Response,\n DeviceManagementListDevicesDefaultResponse,\n DeviceManagementImportDevices202Response,\n DeviceManagementImportDevicesDefaultResponse,\n DeviceManagementGetDevice200Response,\n DeviceManagementGetDeviceDefaultResponse,\n DeviceManagementGetDeviceModule200Response,\n DeviceManagementGetDeviceModuleDefaultResponse,\n DeviceManagementGetUpdateCompliance200Response,\n DeviceManagementGetUpdateComplianceDefaultResponse,\n DeviceManagementListGroups200Response,\n DeviceManagementListGroupsDefaultResponse,\n DeviceManagementGetGroup200Response,\n DeviceManagementGetGroupDefaultResponse,\n DeviceManagementDeleteGroup204Response,\n DeviceManagementDeleteGroupDefaultResponse,\n DeviceManagementGetUpdateComplianceForGroup200Response,\n DeviceManagementGetUpdateComplianceForGroupDefaultResponse,\n DeviceManagementListBestUpdatesForGroup200Response,\n DeviceManagementListBestUpdatesForGroupDefaultResponse,\n DeviceManagementListDeploymentsForGroup200Response,\n DeviceManagementListDeploymentsForGroupDefaultResponse,\n DeviceManagementGetDeployment200Response,\n DeviceManagementGetDeploymentDefaultResponse,\n DeviceManagementCreateOrUpdateDeployment200Response,\n DeviceManagementCreateOrUpdateDeploymentDefaultResponse,\n DeviceManagementDeleteDeployment204Response,\n DeviceManagementDeleteDeploymentDefaultResponse,\n DeviceManagementGetDeploymentStatus200Response,\n DeviceManagementGetDeploymentStatusDefaultResponse,\n DeviceManagementListDeviceClassSubgroupsForGroup200Response,\n DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse,\n DeviceManagementGetDeviceClassSubgroup200Response,\n DeviceManagementGetDeviceClassSubgroupDefaultResponse,\n DeviceManagementDeleteDeviceClassSubgroup204Response,\n DeviceManagementDeleteDeviceClassSubgroupDefaultResponse,\n DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response,\n DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse,\n DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response,\n DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse,\n DeviceManagementListDeploymentsForDeviceClassSubgroup200Response,\n DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse,\n DeviceManagementGetDeploymentForDeviceClassSubgroup200Response,\n DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse,\n DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response,\n DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse,\n DeviceManagementStopDeployment200Response,\n DeviceManagementStopDeploymentDefaultResponse,\n DeviceManagementRetryDeployment200Response,\n DeviceManagementRetryDeploymentDefaultResponse,\n DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response,\n DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse,\n DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response,\n DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse,\n DeviceManagementGetOperationStatus200Response,\n DeviceManagementGetOperationStatus304Response,\n DeviceManagementGetOperationStatusDefaultResponse,\n DeviceManagementListOperationStatuses200Response,\n DeviceManagementListOperationStatusesDefaultResponse,\n DeviceManagementStartLogCollection201Response,\n DeviceManagementStartLogCollectionDefaultResponse,\n DeviceManagementGetLogCollection200Response,\n DeviceManagementGetLogCollectionDefaultResponse,\n DeviceManagementListLogCollections200Response,\n DeviceManagementListLogCollectionsDefaultResponse,\n DeviceManagementGetLogCollectionDetailedStatus200Response,\n DeviceManagementGetLogCollectionDetailedStatusDefaultResponse,\n DeviceManagementListHealthOfDevices200Response,\n DeviceManagementListHealthOfDevicesDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /deviceUpdate/{instanceId}/updates\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates:import\": [\"200\", \"202\"],\n \"POST /deviceUpdate/{instanceId}/updates:import\": [\"200\", \"202\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}\": [\n \"200\",\n \"304\",\n ],\n \"DELETE /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}\":\n [\"202\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}\":\n [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/updates/operations\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/operations/{operationId}\": [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"200\"],\n \"PATCH /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}/installableUpdates\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/devices\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/devices:import\": [\"202\"],\n \"POST /deviceUpdate/{instanceId}/management/devices:import\": [\"202\"],\n \"GET /deviceUpdate/{instanceId}/management/devices/{deviceId}\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/updateCompliance\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}\": [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/updateCompliance\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/bestUpdates\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\"200\"],\n \"PUT /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\n \"204\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}\":\n [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}\":\n [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/updateCompliance\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/bestUpdates\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}\":\n [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}\":\n [\"204\"],\n \"POST /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:cancel\":\n [\"200\"],\n \"POST /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:retry\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/status\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/devicestates\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/operations/{operationId}\": [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/management/operations\": [\"200\"],\n \"PUT /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}\": [\n \"201\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/deviceHealth\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DeviceUpdateListUpdates200Response | DeviceUpdateListUpdatesDefaultResponse,\n): response is DeviceUpdateListUpdatesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateImportUpdate200Response\n | DeviceUpdateImportUpdate202Response\n | DeviceUpdateImportUpdateDefaultResponse,\n): response is DeviceUpdateImportUpdateDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetUpdate200Response\n | DeviceUpdateGetUpdate304Response\n | DeviceUpdateGetUpdateDefaultResponse,\n): response is DeviceUpdateGetUpdateDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateDeleteUpdate202Response | DeviceUpdateDeleteUpdateDefaultResponse,\n): response is DeviceUpdateDeleteUpdateDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListProviders200Response | DeviceUpdateListProvidersDefaultResponse,\n): response is DeviceUpdateListProvidersDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListNames200Response | DeviceUpdateListNamesDefaultResponse,\n): response is DeviceUpdateListNamesDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListVersions200Response | DeviceUpdateListVersionsDefaultResponse,\n): response is DeviceUpdateListVersionsDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListFiles200Response | DeviceUpdateListFilesDefaultResponse,\n): response is DeviceUpdateListFilesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetFile200Response\n | DeviceUpdateGetFile304Response\n | DeviceUpdateGetFileDefaultResponse,\n): response is DeviceUpdateGetFileDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateListOperationStatuses200Response\n | DeviceUpdateListOperationStatusesDefaultResponse,\n): response is DeviceUpdateListOperationStatusesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetOperationStatus200Response\n | DeviceUpdateGetOperationStatus304Response\n | DeviceUpdateGetOperationStatusDefaultResponse,\n): response is DeviceUpdateGetOperationStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceClasses200Response\n | DeviceManagementListDeviceClassesDefaultResponse,\n): response is DeviceManagementListDeviceClassesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClass200Response\n | DeviceManagementGetDeviceClassDefaultResponse,\n): response is DeviceManagementGetDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementUpdateDeviceClass200Response\n | DeviceManagementUpdateDeviceClassDefaultResponse,\n): response is DeviceManagementUpdateDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeviceClass204Response\n | DeviceManagementDeleteDeviceClassDefaultResponse,\n): response is DeviceManagementDeleteDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListInstallableUpdatesForDeviceClass200Response\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse,\n): response is DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementListDevices200Response | DeviceManagementListDevicesDefaultResponse,\n): response is DeviceManagementListDevicesDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementImportDevices202Response | DeviceManagementImportDevicesDefaultResponse,\n): response is DeviceManagementImportDevicesDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetDevice200Response | DeviceManagementGetDeviceDefaultResponse,\n): response is DeviceManagementGetDeviceDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceModule200Response\n | DeviceManagementGetDeviceModuleDefaultResponse,\n): response is DeviceManagementGetDeviceModuleDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetUpdateCompliance200Response\n | DeviceManagementGetUpdateComplianceDefaultResponse,\n): response is DeviceManagementGetUpdateComplianceDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementListGroups200Response | DeviceManagementListGroupsDefaultResponse,\n): response is DeviceManagementListGroupsDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetGroup200Response | DeviceManagementGetGroupDefaultResponse,\n): response is DeviceManagementGetGroupDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementDeleteGroup204Response | DeviceManagementDeleteGroupDefaultResponse,\n): response is DeviceManagementDeleteGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetUpdateComplianceForGroup200Response\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse,\n): response is DeviceManagementGetUpdateComplianceForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListBestUpdatesForGroup200Response\n | DeviceManagementListBestUpdatesForGroupDefaultResponse,\n): response is DeviceManagementListBestUpdatesForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeploymentsForGroup200Response\n | DeviceManagementListDeploymentsForGroupDefaultResponse,\n): response is DeviceManagementListDeploymentsForGroupDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetDeployment200Response | DeviceManagementGetDeploymentDefaultResponse,\n): response is DeviceManagementGetDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementCreateOrUpdateDeployment200Response\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse,\n): response is DeviceManagementCreateOrUpdateDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeployment204Response\n | DeviceManagementDeleteDeploymentDefaultResponse,\n): response is DeviceManagementDeleteDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeploymentStatus200Response\n | DeviceManagementGetDeploymentStatusDefaultResponse,\n): response is DeviceManagementGetDeploymentStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceClassSubgroupsForGroup200Response\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse,\n): response is DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroup200Response\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementDeleteDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeploymentsForDeviceClassSubgroup200Response\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeploymentForDeviceClassSubgroup200Response\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementStopDeployment200Response\n | DeviceManagementStopDeploymentDefaultResponse,\n): response is DeviceManagementStopDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementRetryDeployment200Response\n | DeviceManagementRetryDeploymentDefaultResponse,\n): response is DeviceManagementRetryDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse,\n): response is DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetOperationStatus200Response\n | DeviceManagementGetOperationStatus304Response\n | DeviceManagementGetOperationStatusDefaultResponse,\n): response is DeviceManagementGetOperationStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListOperationStatuses200Response\n | DeviceManagementListOperationStatusesDefaultResponse,\n): response is DeviceManagementListOperationStatusesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementStartLogCollection201Response\n | DeviceManagementStartLogCollectionDefaultResponse,\n): response is DeviceManagementStartLogCollectionDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetLogCollection200Response\n | DeviceManagementGetLogCollectionDefaultResponse,\n): response is DeviceManagementGetLogCollectionDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListLogCollections200Response\n | DeviceManagementListLogCollectionsDefaultResponse,\n): response is DeviceManagementListLogCollectionsDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetLogCollectionDetailedStatus200Response\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse,\n): response is DeviceManagementGetLogCollectionDetailedStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListHealthOfDevices200Response\n | DeviceManagementListHealthOfDevicesDefaultResponse,\n): response is DeviceManagementListHealthOfDevicesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateListUpdates200Response\n | DeviceUpdateListUpdatesDefaultResponse\n | DeviceUpdateImportUpdate200Response\n | DeviceUpdateImportUpdate202Response\n | DeviceUpdateImportUpdateDefaultResponse\n | DeviceUpdateGetUpdate200Response\n | DeviceUpdateGetUpdate304Response\n | DeviceUpdateGetUpdateDefaultResponse\n | DeviceUpdateDeleteUpdate202Response\n | DeviceUpdateDeleteUpdateDefaultResponse\n | DeviceUpdateListProviders200Response\n | DeviceUpdateListProvidersDefaultResponse\n | DeviceUpdateListNames200Response\n | DeviceUpdateListNamesDefaultResponse\n | DeviceUpdateListVersions200Response\n | DeviceUpdateListVersionsDefaultResponse\n | DeviceUpdateListFiles200Response\n | DeviceUpdateListFilesDefaultResponse\n | DeviceUpdateGetFile200Response\n | DeviceUpdateGetFile304Response\n | DeviceUpdateGetFileDefaultResponse\n | DeviceUpdateListOperationStatuses200Response\n | DeviceUpdateListOperationStatusesDefaultResponse\n | DeviceUpdateGetOperationStatus200Response\n | DeviceUpdateGetOperationStatus304Response\n | DeviceUpdateGetOperationStatusDefaultResponse\n | DeviceManagementListDeviceClasses200Response\n | DeviceManagementListDeviceClassesDefaultResponse\n | DeviceManagementGetDeviceClass200Response\n | DeviceManagementGetDeviceClassDefaultResponse\n | DeviceManagementUpdateDeviceClass200Response\n | DeviceManagementUpdateDeviceClassDefaultResponse\n | DeviceManagementDeleteDeviceClass204Response\n | DeviceManagementDeleteDeviceClassDefaultResponse\n | DeviceManagementListInstallableUpdatesForDeviceClass200Response\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse\n | DeviceManagementListDevices200Response\n | DeviceManagementListDevicesDefaultResponse\n | DeviceManagementImportDevices202Response\n | DeviceManagementImportDevicesDefaultResponse\n | DeviceManagementGetDevice200Response\n | DeviceManagementGetDeviceDefaultResponse\n | DeviceManagementGetDeviceModule200Response\n | DeviceManagementGetDeviceModuleDefaultResponse\n | DeviceManagementGetUpdateCompliance200Response\n | DeviceManagementGetUpdateComplianceDefaultResponse\n | DeviceManagementListGroups200Response\n | DeviceManagementListGroupsDefaultResponse\n | DeviceManagementGetGroup200Response\n | DeviceManagementGetGroupDefaultResponse\n | DeviceManagementDeleteGroup204Response\n | DeviceManagementDeleteGroupDefaultResponse\n | DeviceManagementGetUpdateComplianceForGroup200Response\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse\n | DeviceManagementListBestUpdatesForGroup200Response\n | DeviceManagementListBestUpdatesForGroupDefaultResponse\n | DeviceManagementListDeploymentsForGroup200Response\n | DeviceManagementListDeploymentsForGroupDefaultResponse\n | DeviceManagementGetDeployment200Response\n | DeviceManagementGetDeploymentDefaultResponse\n | DeviceManagementCreateOrUpdateDeployment200Response\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse\n | DeviceManagementDeleteDeployment204Response\n | DeviceManagementDeleteDeploymentDefaultResponse\n | DeviceManagementGetDeploymentStatus200Response\n | DeviceManagementGetDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceClassSubgroupsForGroup200Response\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroup200Response\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse\n | DeviceManagementListDeploymentsForDeviceClassSubgroup200Response\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeploymentForDeviceClassSubgroup200Response\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementStopDeployment200Response\n | DeviceManagementStopDeploymentDefaultResponse\n | DeviceManagementRetryDeployment200Response\n | DeviceManagementRetryDeploymentDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse\n | DeviceManagementGetOperationStatus200Response\n | DeviceManagementGetOperationStatus304Response\n | DeviceManagementGetOperationStatusDefaultResponse\n | DeviceManagementListOperationStatuses200Response\n | DeviceManagementListOperationStatusesDefaultResponse\n | DeviceManagementStartLogCollection201Response\n | DeviceManagementStartLogCollectionDefaultResponse\n | DeviceManagementGetLogCollection200Response\n | DeviceManagementGetLogCollectionDefaultResponse\n | DeviceManagementListLogCollections200Response\n | DeviceManagementListLogCollectionsDefaultResponse\n | DeviceManagementGetLogCollectionDetailedStatus200Response\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse\n | DeviceManagementListHealthOfDevices200Response\n | DeviceManagementListHealthOfDevicesDefaultResponse,\n): response is\n | DeviceUpdateListUpdatesDefaultResponse\n | DeviceUpdateImportUpdateDefaultResponse\n | DeviceUpdateGetUpdateDefaultResponse\n | DeviceUpdateDeleteUpdateDefaultResponse\n | DeviceUpdateListProvidersDefaultResponse\n | DeviceUpdateListNamesDefaultResponse\n | DeviceUpdateListVersionsDefaultResponse\n | DeviceUpdateListFilesDefaultResponse\n | DeviceUpdateGetFileDefaultResponse\n | DeviceUpdateListOperationStatusesDefaultResponse\n | DeviceUpdateGetOperationStatusDefaultResponse\n | DeviceManagementListDeviceClassesDefaultResponse\n | DeviceManagementGetDeviceClassDefaultResponse\n | DeviceManagementUpdateDeviceClassDefaultResponse\n | DeviceManagementDeleteDeviceClassDefaultResponse\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse\n | DeviceManagementListDevicesDefaultResponse\n | DeviceManagementImportDevicesDefaultResponse\n | DeviceManagementGetDeviceDefaultResponse\n | DeviceManagementGetDeviceModuleDefaultResponse\n | DeviceManagementGetUpdateComplianceDefaultResponse\n | DeviceManagementListGroupsDefaultResponse\n | DeviceManagementGetGroupDefaultResponse\n | DeviceManagementDeleteGroupDefaultResponse\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse\n | DeviceManagementListBestUpdatesForGroupDefaultResponse\n | DeviceManagementListDeploymentsForGroupDefaultResponse\n | DeviceManagementGetDeploymentDefaultResponse\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse\n | DeviceManagementDeleteDeploymentDefaultResponse\n | DeviceManagementGetDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementStopDeploymentDefaultResponse\n | DeviceManagementRetryDeploymentDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse\n | DeviceManagementGetOperationStatusDefaultResponse\n | DeviceManagementListOperationStatusesDefaultResponse\n | DeviceManagementStartLogCollectionDefaultResponse\n | DeviceManagementGetLogCollectionDefaultResponse\n | DeviceManagementListLogCollectionsDefaultResponse\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse\n | DeviceManagementListHealthOfDevicesDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../src/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAsalC,oCAsKC;AA9dD,MAAM,WAAW,GAA6B;IAC5C,wCAAwC,EAAE,CAAC,KAAK,CAAC;IACjD,+CAA+C,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC/D,gDAAgD,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAChE,6FAA6F,EAAE;QAC7F,KAAK;QACL,KAAK;KACN;IACD,gGAAgG,EAC9F,CAAC,KAAK,CAAC;IACT,kDAAkD,EAAE,CAAC,KAAK,CAAC;IAC3D,mEAAmE,EAAE,CAAC,KAAK,CAAC;IAC5E,mFAAmF,EAAE,CAAC,KAAK,CAAC;IAC5F,mGAAmG,EACjG,CAAC,KAAK,CAAC;IACT,4GAA4G,EAC1G,CAAC,KAAK,EAAE,KAAK,CAAC;IAChB,mDAAmD,EAAE,CAAC,KAAK,CAAC;IAC5D,iEAAiE,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IACjF,yDAAyD,EAAE,CAAC,KAAK,CAAC;IAClE,yEAAyE,EAAE,CAAC,KAAK,CAAC;IAClF,2EAA2E,EAAE,CAAC,KAAK,CAAC;IACpF,4EAA4E,EAAE,CAAC,KAAK,CAAC;IACrF,4FAA4F,EAAE;QAC5F,KAAK;KACN;IACD,mDAAmD,EAAE,CAAC,KAAK,CAAC;IAC5D,0DAA0D,EAAE,CAAC,KAAK,CAAC;IACnE,2DAA2D,EAAE,CAAC,KAAK,CAAC;IACpE,8DAA8D,EAAE,CAAC,KAAK,CAAC;IACvE,iFAAiF,EAAE,CAAC,KAAK,CAAC;IAC1F,4DAA4D,EAAE,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MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n DeviceUpdateListUpdates200Response,\n DeviceUpdateListUpdatesDefaultResponse,\n DeviceUpdateImportUpdate200Response,\n DeviceUpdateImportUpdate202Response,\n DeviceUpdateImportUpdateDefaultResponse,\n DeviceUpdateGetUpdate200Response,\n DeviceUpdateGetUpdate304Response,\n DeviceUpdateGetUpdateDefaultResponse,\n DeviceUpdateDeleteUpdate202Response,\n DeviceUpdateDeleteUpdateDefaultResponse,\n DeviceUpdateListProviders200Response,\n DeviceUpdateListProvidersDefaultResponse,\n DeviceUpdateListNames200Response,\n DeviceUpdateListNamesDefaultResponse,\n DeviceUpdateListVersions200Response,\n DeviceUpdateListVersionsDefaultResponse,\n DeviceUpdateListFiles200Response,\n DeviceUpdateListFilesDefaultResponse,\n DeviceUpdateGetFile200Response,\n DeviceUpdateGetFile304Response,\n DeviceUpdateGetFileDefaultResponse,\n DeviceUpdateListOperationStatuses200Response,\n DeviceUpdateListOperationStatusesDefaultResponse,\n DeviceUpdateGetOperationStatus200Response,\n DeviceUpdateGetOperationStatus304Response,\n DeviceUpdateGetOperationStatusDefaultResponse,\n DeviceManagementListDeviceClasses200Response,\n DeviceManagementListDeviceClassesDefaultResponse,\n DeviceManagementGetDeviceClass200Response,\n DeviceManagementGetDeviceClassDefaultResponse,\n DeviceManagementUpdateDeviceClass200Response,\n DeviceManagementUpdateDeviceClassDefaultResponse,\n DeviceManagementDeleteDeviceClass204Response,\n DeviceManagementDeleteDeviceClassDefaultResponse,\n DeviceManagementListInstallableUpdatesForDeviceClass200Response,\n DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse,\n DeviceManagementListDevices200Response,\n DeviceManagementListDevicesDefaultResponse,\n DeviceManagementImportDevices202Response,\n DeviceManagementImportDevicesDefaultResponse,\n DeviceManagementGetDevice200Response,\n DeviceManagementGetDeviceDefaultResponse,\n DeviceManagementGetDeviceModule200Response,\n DeviceManagementGetDeviceModuleDefaultResponse,\n DeviceManagementGetUpdateCompliance200Response,\n DeviceManagementGetUpdateComplianceDefaultResponse,\n DeviceManagementListGroups200Response,\n DeviceManagementListGroupsDefaultResponse,\n DeviceManagementGetGroup200Response,\n DeviceManagementGetGroupDefaultResponse,\n DeviceManagementDeleteGroup204Response,\n DeviceManagementDeleteGroupDefaultResponse,\n DeviceManagementGetUpdateComplianceForGroup200Response,\n DeviceManagementGetUpdateComplianceForGroupDefaultResponse,\n DeviceManagementListBestUpdatesForGroup200Response,\n DeviceManagementListBestUpdatesForGroupDefaultResponse,\n DeviceManagementListDeploymentsForGroup200Response,\n DeviceManagementListDeploymentsForGroupDefaultResponse,\n DeviceManagementGetDeployment200Response,\n DeviceManagementGetDeploymentDefaultResponse,\n DeviceManagementCreateOrUpdateDeployment200Response,\n DeviceManagementCreateOrUpdateDeploymentDefaultResponse,\n DeviceManagementDeleteDeployment204Response,\n DeviceManagementDeleteDeploymentDefaultResponse,\n DeviceManagementGetDeploymentStatus200Response,\n DeviceManagementGetDeploymentStatusDefaultResponse,\n DeviceManagementListDeviceClassSubgroupsForGroup200Response,\n DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse,\n DeviceManagementGetDeviceClassSubgroup200Response,\n DeviceManagementGetDeviceClassSubgroupDefaultResponse,\n DeviceManagementDeleteDeviceClassSubgroup204Response,\n DeviceManagementDeleteDeviceClassSubgroupDefaultResponse,\n DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response,\n DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse,\n DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response,\n DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse,\n DeviceManagementListDeploymentsForDeviceClassSubgroup200Response,\n DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse,\n DeviceManagementGetDeploymentForDeviceClassSubgroup200Response,\n DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse,\n DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response,\n DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse,\n DeviceManagementStopDeployment200Response,\n DeviceManagementStopDeploymentDefaultResponse,\n DeviceManagementRetryDeployment200Response,\n DeviceManagementRetryDeploymentDefaultResponse,\n DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response,\n DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse,\n DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response,\n DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse,\n DeviceManagementGetOperationStatus200Response,\n DeviceManagementGetOperationStatus304Response,\n DeviceManagementGetOperationStatusDefaultResponse,\n DeviceManagementListOperationStatuses200Response,\n DeviceManagementListOperationStatusesDefaultResponse,\n DeviceManagementStartLogCollection201Response,\n DeviceManagementStartLogCollectionDefaultResponse,\n DeviceManagementGetLogCollection200Response,\n DeviceManagementGetLogCollectionDefaultResponse,\n DeviceManagementListLogCollections200Response,\n DeviceManagementListLogCollectionsDefaultResponse,\n DeviceManagementGetLogCollectionDetailedStatus200Response,\n DeviceManagementGetLogCollectionDetailedStatusDefaultResponse,\n DeviceManagementListHealthOfDevices200Response,\n DeviceManagementListHealthOfDevicesDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /deviceUpdate/{instanceId}/updates\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates:import\": [\"200\", \"202\"],\n \"POST /deviceUpdate/{instanceId}/updates:import\": [\"200\", \"202\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}\": [\n \"200\",\n \"304\",\n ],\n \"DELETE /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}\":\n [\"202\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/providers/{provider}/names/{name}/versions/{version}/files/{fileId}\":\n [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/updates/operations\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/updates/operations/{operationId}\": [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"200\"],\n \"PATCH /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}\": [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceClasses/{deviceClassId}/installableUpdates\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/devices\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/devices:import\": [\"202\"],\n \"POST /deviceUpdate/{instanceId}/management/devices:import\": [\"202\"],\n \"GET /deviceUpdate/{instanceId}/management/devices/{deviceId}\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/devices/{deviceId}/modules/{moduleId}\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/updateCompliance\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}\": [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/updateCompliance\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/bestUpdates\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\"200\"],\n \"PUT /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}\": [\n \"204\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deployments/{deploymentId}/status\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}\":\n [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}\":\n [\"204\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/updateCompliance\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/bestUpdates\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}\":\n [\"200\"],\n \"DELETE /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}\":\n [\"204\"],\n \"POST /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:cancel\":\n [\"200\"],\n \"POST /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}:retry\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/status\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/groups/{groupId}/deviceClassSubgroups/{deviceClassId}/deployments/{deploymentId}/devicestates\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/operations/{operationId}\": [\"200\", \"304\"],\n \"GET /deviceUpdate/{instanceId}/management/operations\": [\"200\"],\n \"PUT /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}\": [\n \"201\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}\": [\n \"200\",\n ],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections\": [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/logCollections/{operationId}/detailedStatus\":\n [\"200\"],\n \"GET /deviceUpdate/{instanceId}/management/deviceDiagnostics/deviceHealth\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: DeviceUpdateListUpdates200Response | DeviceUpdateListUpdatesDefaultResponse,\n): response is DeviceUpdateListUpdatesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateImportUpdate200Response\n | DeviceUpdateImportUpdate202Response\n | DeviceUpdateImportUpdateDefaultResponse,\n): response is DeviceUpdateImportUpdateDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetUpdate200Response\n | DeviceUpdateGetUpdate304Response\n | DeviceUpdateGetUpdateDefaultResponse,\n): response is DeviceUpdateGetUpdateDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateDeleteUpdate202Response | DeviceUpdateDeleteUpdateDefaultResponse,\n): response is DeviceUpdateDeleteUpdateDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListProviders200Response | DeviceUpdateListProvidersDefaultResponse,\n): response is DeviceUpdateListProvidersDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListNames200Response | DeviceUpdateListNamesDefaultResponse,\n): response is DeviceUpdateListNamesDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListVersions200Response | DeviceUpdateListVersionsDefaultResponse,\n): response is DeviceUpdateListVersionsDefaultResponse;\nexport function isUnexpected(\n response: DeviceUpdateListFiles200Response | DeviceUpdateListFilesDefaultResponse,\n): response is DeviceUpdateListFilesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetFile200Response\n | DeviceUpdateGetFile304Response\n | DeviceUpdateGetFileDefaultResponse,\n): response is DeviceUpdateGetFileDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateListOperationStatuses200Response\n | DeviceUpdateListOperationStatusesDefaultResponse,\n): response is DeviceUpdateListOperationStatusesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateGetOperationStatus200Response\n | DeviceUpdateGetOperationStatus304Response\n | DeviceUpdateGetOperationStatusDefaultResponse,\n): response is DeviceUpdateGetOperationStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceClasses200Response\n | DeviceManagementListDeviceClassesDefaultResponse,\n): response is DeviceManagementListDeviceClassesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClass200Response\n | DeviceManagementGetDeviceClassDefaultResponse,\n): response is DeviceManagementGetDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementUpdateDeviceClass200Response\n | DeviceManagementUpdateDeviceClassDefaultResponse,\n): response is DeviceManagementUpdateDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeviceClass204Response\n | DeviceManagementDeleteDeviceClassDefaultResponse,\n): response is DeviceManagementDeleteDeviceClassDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListInstallableUpdatesForDeviceClass200Response\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse,\n): response is DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementListDevices200Response | DeviceManagementListDevicesDefaultResponse,\n): response is DeviceManagementListDevicesDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementImportDevices202Response | DeviceManagementImportDevicesDefaultResponse,\n): response is DeviceManagementImportDevicesDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetDevice200Response | DeviceManagementGetDeviceDefaultResponse,\n): response is DeviceManagementGetDeviceDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceModule200Response\n | DeviceManagementGetDeviceModuleDefaultResponse,\n): response is DeviceManagementGetDeviceModuleDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetUpdateCompliance200Response\n | DeviceManagementGetUpdateComplianceDefaultResponse,\n): response is DeviceManagementGetUpdateComplianceDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementListGroups200Response | DeviceManagementListGroupsDefaultResponse,\n): response is DeviceManagementListGroupsDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetGroup200Response | DeviceManagementGetGroupDefaultResponse,\n): response is DeviceManagementGetGroupDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementDeleteGroup204Response | DeviceManagementDeleteGroupDefaultResponse,\n): response is DeviceManagementDeleteGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetUpdateComplianceForGroup200Response\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse,\n): response is DeviceManagementGetUpdateComplianceForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListBestUpdatesForGroup200Response\n | DeviceManagementListBestUpdatesForGroupDefaultResponse,\n): response is DeviceManagementListBestUpdatesForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeploymentsForGroup200Response\n | DeviceManagementListDeploymentsForGroupDefaultResponse,\n): response is DeviceManagementListDeploymentsForGroupDefaultResponse;\nexport function isUnexpected(\n response: DeviceManagementGetDeployment200Response | DeviceManagementGetDeploymentDefaultResponse,\n): response is DeviceManagementGetDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementCreateOrUpdateDeployment200Response\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse,\n): response is DeviceManagementCreateOrUpdateDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeployment204Response\n | DeviceManagementDeleteDeploymentDefaultResponse,\n): response is DeviceManagementDeleteDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeploymentStatus200Response\n | DeviceManagementGetDeploymentStatusDefaultResponse,\n): response is DeviceManagementGetDeploymentStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceClassSubgroupsForGroup200Response\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse,\n): response is DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroup200Response\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementDeleteDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeploymentsForDeviceClassSubgroup200Response\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeploymentForDeviceClassSubgroup200Response\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse,\n): response is DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementStopDeployment200Response\n | DeviceManagementStopDeploymentDefaultResponse,\n): response is DeviceManagementStopDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementRetryDeployment200Response\n | DeviceManagementRetryDeploymentDefaultResponse,\n): response is DeviceManagementRetryDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse,\n): response is DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse,\n): response is DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetOperationStatus200Response\n | DeviceManagementGetOperationStatus304Response\n | DeviceManagementGetOperationStatusDefaultResponse,\n): response is DeviceManagementGetOperationStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListOperationStatuses200Response\n | DeviceManagementListOperationStatusesDefaultResponse,\n): response is DeviceManagementListOperationStatusesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementStartLogCollection201Response\n | DeviceManagementStartLogCollectionDefaultResponse,\n): response is DeviceManagementStartLogCollectionDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetLogCollection200Response\n | DeviceManagementGetLogCollectionDefaultResponse,\n): response is DeviceManagementGetLogCollectionDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListLogCollections200Response\n | DeviceManagementListLogCollectionsDefaultResponse,\n): response is DeviceManagementListLogCollectionsDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementGetLogCollectionDetailedStatus200Response\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse,\n): response is DeviceManagementGetLogCollectionDetailedStatusDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceManagementListHealthOfDevices200Response\n | DeviceManagementListHealthOfDevicesDefaultResponse,\n): response is DeviceManagementListHealthOfDevicesDefaultResponse;\nexport function isUnexpected(\n response:\n | DeviceUpdateListUpdates200Response\n | DeviceUpdateListUpdatesDefaultResponse\n | DeviceUpdateImportUpdate200Response\n | DeviceUpdateImportUpdate202Response\n | DeviceUpdateImportUpdateDefaultResponse\n | DeviceUpdateGetUpdate200Response\n | DeviceUpdateGetUpdate304Response\n | DeviceUpdateGetUpdateDefaultResponse\n | DeviceUpdateDeleteUpdate202Response\n | DeviceUpdateDeleteUpdateDefaultResponse\n | DeviceUpdateListProviders200Response\n | DeviceUpdateListProvidersDefaultResponse\n | DeviceUpdateListNames200Response\n | DeviceUpdateListNamesDefaultResponse\n | DeviceUpdateListVersions200Response\n | DeviceUpdateListVersionsDefaultResponse\n | DeviceUpdateListFiles200Response\n | DeviceUpdateListFilesDefaultResponse\n | DeviceUpdateGetFile200Response\n | DeviceUpdateGetFile304Response\n | DeviceUpdateGetFileDefaultResponse\n | DeviceUpdateListOperationStatuses200Response\n | DeviceUpdateListOperationStatusesDefaultResponse\n | DeviceUpdateGetOperationStatus200Response\n | DeviceUpdateGetOperationStatus304Response\n | DeviceUpdateGetOperationStatusDefaultResponse\n | DeviceManagementListDeviceClasses200Response\n | DeviceManagementListDeviceClassesDefaultResponse\n | DeviceManagementGetDeviceClass200Response\n | DeviceManagementGetDeviceClassDefaultResponse\n | DeviceManagementUpdateDeviceClass200Response\n | DeviceManagementUpdateDeviceClassDefaultResponse\n | DeviceManagementDeleteDeviceClass204Response\n | DeviceManagementDeleteDeviceClassDefaultResponse\n | DeviceManagementListInstallableUpdatesForDeviceClass200Response\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse\n | DeviceManagementListDevices200Response\n | DeviceManagementListDevicesDefaultResponse\n | DeviceManagementImportDevices202Response\n | DeviceManagementImportDevicesDefaultResponse\n | DeviceManagementGetDevice200Response\n | DeviceManagementGetDeviceDefaultResponse\n | DeviceManagementGetDeviceModule200Response\n | DeviceManagementGetDeviceModuleDefaultResponse\n | DeviceManagementGetUpdateCompliance200Response\n | DeviceManagementGetUpdateComplianceDefaultResponse\n | DeviceManagementListGroups200Response\n | DeviceManagementListGroupsDefaultResponse\n | DeviceManagementGetGroup200Response\n | DeviceManagementGetGroupDefaultResponse\n | DeviceManagementDeleteGroup204Response\n | DeviceManagementDeleteGroupDefaultResponse\n | DeviceManagementGetUpdateComplianceForGroup200Response\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse\n | DeviceManagementListBestUpdatesForGroup200Response\n | DeviceManagementListBestUpdatesForGroupDefaultResponse\n | DeviceManagementListDeploymentsForGroup200Response\n | DeviceManagementListDeploymentsForGroupDefaultResponse\n | DeviceManagementGetDeployment200Response\n | DeviceManagementGetDeploymentDefaultResponse\n | DeviceManagementCreateOrUpdateDeployment200Response\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse\n | DeviceManagementDeleteDeployment204Response\n | DeviceManagementDeleteDeploymentDefaultResponse\n | DeviceManagementGetDeploymentStatus200Response\n | DeviceManagementGetDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceClassSubgroupsForGroup200Response\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroup200Response\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupUpdateCompliance200Response\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroup200Response\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse\n | DeviceManagementListDeploymentsForDeviceClassSubgroup200Response\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeploymentForDeviceClassSubgroup200Response\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroup204Response\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementStopDeployment200Response\n | DeviceManagementStopDeploymentDefaultResponse\n | DeviceManagementRetryDeployment200Response\n | DeviceManagementRetryDeploymentDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatus200Response\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeployment200Response\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse\n | DeviceManagementGetOperationStatus200Response\n | DeviceManagementGetOperationStatus304Response\n | DeviceManagementGetOperationStatusDefaultResponse\n | DeviceManagementListOperationStatuses200Response\n | DeviceManagementListOperationStatusesDefaultResponse\n | DeviceManagementStartLogCollection201Response\n | DeviceManagementStartLogCollectionDefaultResponse\n | DeviceManagementGetLogCollection200Response\n | DeviceManagementGetLogCollectionDefaultResponse\n | DeviceManagementListLogCollections200Response\n | DeviceManagementListLogCollectionsDefaultResponse\n | DeviceManagementGetLogCollectionDetailedStatus200Response\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse\n | DeviceManagementListHealthOfDevices200Response\n | DeviceManagementListHealthOfDevicesDefaultResponse,\n): response is\n | DeviceUpdateListUpdatesDefaultResponse\n | DeviceUpdateImportUpdateDefaultResponse\n | DeviceUpdateGetUpdateDefaultResponse\n | DeviceUpdateDeleteUpdateDefaultResponse\n | DeviceUpdateListProvidersDefaultResponse\n | DeviceUpdateListNamesDefaultResponse\n | DeviceUpdateListVersionsDefaultResponse\n | DeviceUpdateListFilesDefaultResponse\n | DeviceUpdateGetFileDefaultResponse\n | DeviceUpdateListOperationStatusesDefaultResponse\n | DeviceUpdateGetOperationStatusDefaultResponse\n | DeviceManagementListDeviceClassesDefaultResponse\n | DeviceManagementGetDeviceClassDefaultResponse\n | DeviceManagementUpdateDeviceClassDefaultResponse\n | DeviceManagementDeleteDeviceClassDefaultResponse\n | DeviceManagementListInstallableUpdatesForDeviceClassDefaultResponse\n | DeviceManagementListDevicesDefaultResponse\n | DeviceManagementImportDevicesDefaultResponse\n | DeviceManagementGetDeviceDefaultResponse\n | DeviceManagementGetDeviceModuleDefaultResponse\n | DeviceManagementGetUpdateComplianceDefaultResponse\n | DeviceManagementListGroupsDefaultResponse\n | DeviceManagementGetGroupDefaultResponse\n | DeviceManagementDeleteGroupDefaultResponse\n | DeviceManagementGetUpdateComplianceForGroupDefaultResponse\n | DeviceManagementListBestUpdatesForGroupDefaultResponse\n | DeviceManagementListDeploymentsForGroupDefaultResponse\n | DeviceManagementGetDeploymentDefaultResponse\n | DeviceManagementCreateOrUpdateDeploymentDefaultResponse\n | DeviceManagementDeleteDeploymentDefaultResponse\n | DeviceManagementGetDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceClassSubgroupsForGroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupUpdateComplianceDefaultResponse\n | DeviceManagementGetBestUpdatesForDeviceClassSubgroupDefaultResponse\n | DeviceManagementListDeploymentsForDeviceClassSubgroupDefaultResponse\n | DeviceManagementGetDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementDeleteDeploymentForDeviceClassSubgroupDefaultResponse\n | DeviceManagementStopDeploymentDefaultResponse\n | DeviceManagementRetryDeploymentDefaultResponse\n | DeviceManagementGetDeviceClassSubgroupDeploymentStatusDefaultResponse\n | DeviceManagementListDeviceStatesForDeviceClassSubgroupDeploymentDefaultResponse\n | DeviceManagementGetOperationStatusDefaultResponse\n | DeviceManagementListOperationStatusesDefaultResponse\n | DeviceManagementStartLogCollectionDefaultResponse\n | DeviceManagementGetLogCollectionDefaultResponse\n | DeviceManagementListLogCollectionsDefaultResponse\n | DeviceManagementGetLogCollectionDetailedStatusDefaultResponse\n | DeviceManagementListHealthOfDevicesDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\",\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  // Licensed under the MIT License.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.paginate = paginate;
6
- const tslib_1 = require("tslib");
7
6
  const core_client_1 = require("@azure-rest/core-client");
8
7
  /**
9
8
  * returns an async iterator that iterates over results. It also has a `byPage`
@@ -13,7 +12,6 @@ const core_client_1 = require("@azure-rest/core-client");
13
12
  * @returns a paged async iterator that iterates over results.
14
13
  */
15
14
  function getPagedAsyncIterator(pagedResult) {
16
- var _a;
17
15
  const iter = getItemAsyncIterator(pagedResult);
18
16
  return {
19
17
  next() {
@@ -22,85 +20,57 @@ function getPagedAsyncIterator(pagedResult) {
22
20
  [Symbol.asyncIterator]() {
23
21
  return this;
24
22
  },
25
- byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
26
- const { continuationToken } = settings !== null && settings !== void 0 ? settings : {};
27
- return getPageAsyncIterator(pagedResult, {
28
- pageLink: continuationToken,
29
- });
30
- }),
23
+ byPage: pagedResult?.byPage ??
24
+ ((settings) => {
25
+ const { continuationToken } = settings ?? {};
26
+ return getPageAsyncIterator(pagedResult, {
27
+ pageLink: continuationToken,
28
+ });
29
+ }),
31
30
  };
32
31
  }
33
- function getItemAsyncIterator(pagedResult) {
34
- return tslib_1.__asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
35
- var _a, e_1, _b, _c, _d, e_2, _e, _f;
36
- const pages = getPageAsyncIterator(pagedResult);
37
- const firstVal = yield tslib_1.__await(pages.next());
38
- // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
39
- if (!Array.isArray(firstVal.value)) {
40
- // can extract elements from this page
41
- const { toElements } = pagedResult;
42
- if (toElements) {
43
- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(firstVal.value))));
44
- try {
45
- for (var _g = true, pages_1 = tslib_1.__asyncValues(pages), pages_1_1; pages_1_1 = yield tslib_1.__await(pages_1.next()), _a = pages_1_1.done, !_a; _g = true) {
46
- _c = pages_1_1.value;
47
- _g = false;
48
- const page = _c;
49
- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(toElements(page))));
50
- }
51
- }
52
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
53
- finally {
54
- try {
55
- if (!_g && !_a && (_b = pages_1.return)) yield tslib_1.__await(_b.call(pages_1));
56
- }
57
- finally { if (e_1) throw e_1.error; }
58
- }
59
- }
60
- else {
61
- yield yield tslib_1.__await(firstVal.value);
62
- // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
63
- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(pages)));
32
+ async function* getItemAsyncIterator(pagedResult) {
33
+ const pages = getPageAsyncIterator(pagedResult);
34
+ const firstVal = await pages.next();
35
+ // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
36
+ if (!Array.isArray(firstVal.value)) {
37
+ // can extract elements from this page
38
+ const { toElements } = pagedResult;
39
+ if (toElements) {
40
+ yield* toElements(firstVal.value);
41
+ for await (const page of pages) {
42
+ yield* toElements(page);
64
43
  }
65
44
  }
66
45
  else {
67
- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(firstVal.value)));
68
- try {
69
- for (var _h = true, pages_2 = tslib_1.__asyncValues(pages), pages_2_1; pages_2_1 = yield tslib_1.__await(pages_2.next()), _d = pages_2_1.done, !_d; _h = true) {
70
- _f = pages_2_1.value;
71
- _h = false;
72
- const page = _f;
73
- // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
74
- // it must be the case that `TPage = TElement[]`
75
- yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
76
- }
77
- }
78
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
79
- finally {
80
- try {
81
- if (!_h && !_d && (_e = pages_2.return)) yield tslib_1.__await(_e.call(pages_2));
82
- }
83
- finally { if (e_2) throw e_2.error; }
84
- }
46
+ yield firstVal.value;
47
+ // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
48
+ yield* pages;
49
+ }
50
+ }
51
+ else {
52
+ yield* firstVal.value;
53
+ for await (const page of pages) {
54
+ // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
55
+ // it must be the case that `TPage = TElement[]`
56
+ yield* page;
85
57
  }
86
- });
58
+ }
87
59
  }
88
- function getPageAsyncIterator(pagedResult_1) {
89
- return tslib_1.__asyncGenerator(this, arguments, function* getPageAsyncIterator_1(pagedResult, options = {}) {
90
- const { pageLink } = options;
91
- let response = yield tslib_1.__await(pagedResult.getPage(pageLink !== null && pageLink !== void 0 ? pageLink : pagedResult.firstPageLink));
60
+ async function* getPageAsyncIterator(pagedResult, options = {}) {
61
+ const { pageLink } = options;
62
+ let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
63
+ if (!response) {
64
+ return;
65
+ }
66
+ yield response.page;
67
+ while (response.nextPageLink) {
68
+ response = await pagedResult.getPage(response.nextPageLink);
92
69
  if (!response) {
93
- return yield tslib_1.__await(void 0);
70
+ return;
94
71
  }
95
- yield yield tslib_1.__await(response.page);
96
- while (response.nextPageLink) {
97
- response = yield tslib_1.__await(pagedResult.getPage(response.nextPageLink));
98
- if (!response) {
99
- return yield tslib_1.__await(void 0);
100
- }
101
- yield yield tslib_1.__await(response.page);
102
- }
103
- });
72
+ yield response.page;
73
+ }
104
74
  }
105
75
  /**
106
76
  * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
@@ -156,7 +126,7 @@ function getElements(body, itemName) {
156
126
  if (!Array.isArray(value)) {
157
127
  throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
158
128
  }
159
- return value !== null && value !== void 0 ? value : [];
129
+ return value ?? [];
160
130
  }
161
131
  /**
162
132
  * Checks if a request failed
@@ -1 +1 @@
1
- {"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA2LlC,4BA8BC;;AAtND,yDAA0D;AAE1D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAM5B,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,mCAClB,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC;YAC7C,OAAO,oBAAoB,CAAC,WAAW,EAAE;gBACvC,QAAQ,EAAE,iBAAiD;aAC5D,CAAC,CAAC;QACL,CAAC,CAA2E;KAC/E,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAClC,WAAqD;;;QAErD,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,sBAAM,KAAK,CAAC,IAAI,EAAE,CAAA,CAAC;QACpC,6FAA6F;QAC7F,IAAI,CAAC,KAAK,CAAC,O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AAC,MAAM,EAAE,EACjE,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Client, PathUncheckedResponse } from \"@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nfunction getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string,\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n (((settings?: PageSettings) => {\n const { continuationToken } = settings ?? {};\n return getPageAsyncIterator(pagedResult, {\n pageLink: continuationToken as unknown as TLink | undefined,\n });\n }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator<TPage>),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n // can extract elements from this page\n const { toElements } = pagedResult;\n if (toElements) {\n yield* toElements(firstVal.value) as TElement[];\n for await (const page of pages) {\n yield* toElements(page) as TElement[];\n }\n } else {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n }\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n options: {\n pageLink?: TLink;\n } = {},\n): AsyncIterableIterator<TPage> {\n const { pageLink } = options;\n let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n }\n}\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n}\n\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<TElement>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\ninterface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (pageLink: TLink) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>;\n /**\n * a function to implement the `byPage` method on the paged async iterator.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n\n /**\n * A function to extract elements from a page.\n */\n toElements?: (page: TPage) => unknown[];\n}\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (pageLink: string) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"paginateHelper.js","sourceRoot":"","sources":["../../src/paginateHelper.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA2LlC,4BA8BC;AAtND,yDAA0D;AAE1D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAM5B,WAAqD;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EACJ,WAAW,EAAE,MAAM;YAClB,CAAC,CAAC,QAAuB,EAAE,EAAE;gBAC5B,MAAM,EAAE,iBAAiB,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAC;gBAC7C,OAAO,oBAAoB,CAAC,WAAW,EAAE;oBAC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@azure-rest/core-client\";\nimport { createRestError } from \"@azure-rest/core-client\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nfunction getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string,\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n (((settings?: PageSettings) => {\n const { continuationToken } = settings ?? {};\n return getPageAsyncIterator(pagedResult, {\n pageLink: continuationToken as unknown as TLink | undefined,\n });\n }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator<TPage>),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n // can extract elements from this page\n const { toElements } = pagedResult;\n if (toElements) {\n yield* toElements(firstVal.value) as TElement[];\n for await (const page of pages) {\n yield* toElements(page) as TElement[];\n }\n } else {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n }\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n options: {\n pageLink?: TLink;\n } = {},\n): AsyncIterableIterator<TPage> {\n const { pageLink } = options;\n let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink);\n if (!response) {\n return;\n }\n yield response.page;\n }\n}\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n}\n\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<TElement>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\ninterface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (pageLink: TLink) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>;\n /**\n * a function to implement the `byPage` method on the paged async iterator.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n\n /**\n * A function to extract elements from a page.\n */\n toElements?: (page: TPage) => unknown[];\n}\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (pageLink: string) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends {\n body: { value?: infer TPage };\n}\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {},\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n const itemName = \"value\";\n const nextLinkName = \"nextLink\";\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink,\n };\n },\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`,\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\"200\", \"201\", \"202\", \"203\", \"204\", \"205\", \"206\", \"207\", \"208\", \"226\"];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response,\n );\n }\n}\n"]}