@azure/maps-common 1.0.0-alpha.20220930.2 → 1.0.0-beta.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.
- package/dist/index.js +32 -77
- package/dist/index.js.map +1 -1
- package/dist-esm/models/index.js +1 -1
- package/dist-esm/models/index.js.map +1 -1
- package/dist-esm/models/lro.js +34 -0
- package/dist-esm/models/lro.js.map +1 -0
- package/package.json +6 -5
- package/types/3.1/models/index.d.ts +1 -1
- package/types/3.1/models/lro.d.ts +22 -0
- package/types/latest/models/index.d.ts +1 -1
- package/types/latest/models/index.d.ts.map +1 -1
- package/types/latest/models/lro.d.ts +22 -0
- package/types/latest/models/lro.d.ts.map +1 -0
- package/dist-esm/models/pollers.js +0 -80
- package/dist-esm/models/pollers.js.map +0 -1
- package/types/3.1/models/pollers.d.ts +0 -25
- package/types/latest/models/pollers.d.ts +0 -25
- package/types/latest/models/pollers.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -48,87 +48,42 @@ function createMapsClientIdPolicy(mapsClientId) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// Copyright (c) Microsoft Corporation.
|
|
52
|
-
// Licensed under the MIT license.
|
|
53
51
|
/**
|
|
54
|
-
*
|
|
52
|
+
* Extract several fields of the response to the rawResponse
|
|
53
|
+
*
|
|
54
|
+
* @param getResponse - A async function that actually call the backend API.
|
|
55
|
+
* @param options - The options for the getResponse callback
|
|
56
|
+
* @returns A promise for the API call.
|
|
55
57
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
state.error = internalState.error;
|
|
82
|
-
}
|
|
83
|
-
if (internalState.result) {
|
|
84
|
-
state.result = this.mapper(internalState.result);
|
|
85
|
-
}
|
|
86
|
-
callback(state);
|
|
87
|
-
};
|
|
88
|
-
return this.internalPoller.onProgress(internalCallback);
|
|
89
|
-
}
|
|
90
|
-
isDone() {
|
|
91
|
-
return this.internalPoller.isDone();
|
|
92
|
-
}
|
|
93
|
-
stopPolling() {
|
|
94
|
-
this.internalPoller.stopPolling();
|
|
95
|
-
}
|
|
96
|
-
isStopped() {
|
|
97
|
-
return this.internalPoller.isStopped();
|
|
98
|
-
}
|
|
99
|
-
getOperationState() {
|
|
100
|
-
const internalState = this.internalPoller.getOperationState();
|
|
101
|
-
const state = {};
|
|
102
|
-
if (internalState.isStarted) {
|
|
103
|
-
state.isStarted = internalState.isStarted;
|
|
104
|
-
}
|
|
105
|
-
if (internalState.isCompleted) {
|
|
106
|
-
state.isCompleted = internalState.isCompleted;
|
|
107
|
-
}
|
|
108
|
-
if (internalState.isCancelled) {
|
|
109
|
-
state.isCancelled = internalState.isCancelled;
|
|
110
|
-
}
|
|
111
|
-
if (internalState.error) {
|
|
112
|
-
state.error = internalState.error;
|
|
113
|
-
}
|
|
114
|
-
if (internalState.result) {
|
|
115
|
-
state.result = this.mapper(internalState.result);
|
|
116
|
-
}
|
|
117
|
-
return state;
|
|
118
|
-
}
|
|
119
|
-
getResult() {
|
|
120
|
-
const result = this.internalPoller.getResult();
|
|
121
|
-
if (result) {
|
|
122
|
-
return this.mapper(result);
|
|
123
|
-
}
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
toString() {
|
|
127
|
-
return this.internalPoller.toString();
|
|
128
|
-
}
|
|
58
|
+
async function getRawResponse(getResponse, options) {
|
|
59
|
+
const { onResponse } = options || {};
|
|
60
|
+
let rawResponse;
|
|
61
|
+
const flatResponse = await getResponse(Object.assign(Object.assign({}, options), { onResponse: (response, flatResponseParam) => {
|
|
62
|
+
rawResponse = response;
|
|
63
|
+
onResponse === null || onResponse === void 0 ? void 0 : onResponse(response, flatResponseParam);
|
|
64
|
+
} }));
|
|
65
|
+
return {
|
|
66
|
+
flatResponse,
|
|
67
|
+
rawResponse: {
|
|
68
|
+
statusCode: rawResponse.status,
|
|
69
|
+
headers: rawResponse.headers.toJSON(),
|
|
70
|
+
body: rawResponse.parsedBody,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.
|
|
76
|
+
*
|
|
77
|
+
* @param settings - The settings of the poll request, including client, options and the spec
|
|
78
|
+
* @returns A callback that accept the path as input and return the promise of Lro response.
|
|
79
|
+
*/
|
|
80
|
+
function createSendPollRequest(settings) {
|
|
81
|
+
const { client, options, spec } = settings;
|
|
82
|
+
return async (path) => getRawResponse((paramOptions) => client.sendOperationRequest({ options: paramOptions }, Object.assign({ path }, spec)), options);
|
|
129
83
|
}
|
|
130
84
|
|
|
131
|
-
exports.BatchPollerProxy = BatchPollerProxy;
|
|
132
85
|
exports.createAzureMapsKeyCredentialPolicy = createAzureMapsKeyCredentialPolicy;
|
|
133
86
|
exports.createMapsClientIdPolicy = createMapsClientIdPolicy;
|
|
87
|
+
exports.createSendPollRequest = createSendPollRequest;
|
|
88
|
+
exports.getRawResponse = getRawResponse;
|
|
134
89
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/credential/createAzureMapsKeyCredentialPolicy.ts","../src/credential/createMapsClientIdPolicy.ts","../src/models/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/credential/createAzureMapsKeyCredentialPolicy.ts","../src/credential/createMapsClientIdPolicy.ts","../src/models/lro.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { KeyCredential } from \"@azure/core-auth\";\n\nconst API_KEY_HEADER_NAME = \"subscription-key\";\n\n/**\n * The programmatic identifier of the mapsAzureKeyCredentialPolicy.\n */\nconst azureMapsKeyCredentialPolicyName = \"mapsAzureKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Azure Maps\n */\nexport function createAzureMapsKeyCredentialPolicy(\n azureKeyCredential: KeyCredential\n): PipelinePolicy {\n return {\n name: azureMapsKeyCredentialPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!request.headers.has(API_KEY_HEADER_NAME)) {\n request.headers.set(API_KEY_HEADER_NAME, azureKeyCredential.key);\n }\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\nconst MAPS_CLIENT_ID_HEADER_NAME = \"x-ms-client-id\";\n\n/**\n * The programmatic identifier of the mapsTokenCredentialPolicy.\n */\nconst mapsClientIdPolicyName = \"mapsClientIdPolicy\";\n\n/**\n * Create an HTTP pipeline policy to add x-ms-client-id header\n * for `TokenCredential` based authentication for Azure Maps\n */\nexport function createMapsClientIdPolicy(mapsClientId: string): PipelinePolicy {\n return {\n name: mapsClientIdPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (!request.headers.has(MAPS_CLIENT_ID_HEADER_NAME)) {\n request.headers.set(MAPS_CLIENT_ID_HEADER_NAME, mapsClientId);\n }\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n ServiceClient,\n} from \"@azure/core-client\";\nimport { LroResponse } from \"@azure/core-lro\";\n\n/**\n * Extract several fields of the response to the rawResponse\n *\n * @param getResponse - A async function that actually call the backend API.\n * @param options - The options for the getResponse callback\n * @returns A promise for the API call.\n */\nexport async function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response, flatResponseParam) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n },\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody,\n },\n };\n}\n\n/**\n * Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.\n *\n * @param settings - The settings of the poll request, including client, options and the spec\n * @returns A callback that accept the path as input and return the promise of Lro response.\n */\nexport function createSendPollRequest<\n TOptions extends OperationOptions,\n TClient extends ServiceClient\n>(settings: {\n client: TClient;\n options: TOptions;\n spec: OperationSpec;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, spec } = settings;\n return async (path: string) =>\n getRawResponse(\n (paramOptions) => client.sendOperationRequest({ options: paramOptions }, { path, ...spec }),\n options\n );\n}\n"],"names":[],"mappings":";;;;AAAA;AACA;AAUA,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C;;AAEG;AACH,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAExE;;;AAGG;AACG,SAAU,kCAAkC,CAChD,kBAAiC,EAAA;IAEjC,OAAO;AACL,QAAA,IAAI,EAAE,gCAAgC;AACtC,QAAA,MAAM,WAAW,CAAC,OAAwB,EAAE,IAAiB,EAAA;YAC3D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;gBAC7C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,GAAG,CAAC,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C9B,SAAA;KACF,CAAC;AACJ,CAAC;AAED;;;;;AAKG;AACG,SAAU,qBAAqB,CAGnC,QAID,EAAA;IACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AAC3C,IAAA,OAAO,OAAO,IAAY,KACxB,cAAc,CACZ,CAAC,YAAY,KAAK,MAAM,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAA,MAAA,CAAA,MAAA,CAAA,EAAI,IAAI,EAAA,EAAK,IAAI,CAAA,CAAG,EAC3F,OAAO,CACR,CAAC;AACN;;;;;;;"}
|
package/dist-esm/models/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport * from \"./geojsons\";\nexport * from \"./models\";\nexport * from \"./lro\";\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract several fields of the response to the rawResponse
|
|
3
|
+
*
|
|
4
|
+
* @param getResponse - A async function that actually call the backend API.
|
|
5
|
+
* @param options - The options for the getResponse callback
|
|
6
|
+
* @returns A promise for the API call.
|
|
7
|
+
*/
|
|
8
|
+
export async function getRawResponse(getResponse, options) {
|
|
9
|
+
const { onResponse } = options || {};
|
|
10
|
+
let rawResponse;
|
|
11
|
+
const flatResponse = await getResponse(Object.assign(Object.assign({}, options), { onResponse: (response, flatResponseParam) => {
|
|
12
|
+
rawResponse = response;
|
|
13
|
+
onResponse === null || onResponse === void 0 ? void 0 : onResponse(response, flatResponseParam);
|
|
14
|
+
} }));
|
|
15
|
+
return {
|
|
16
|
+
flatResponse,
|
|
17
|
+
rawResponse: {
|
|
18
|
+
statusCode: rawResponse.status,
|
|
19
|
+
headers: rawResponse.headers.toJSON(),
|
|
20
|
+
body: rawResponse.parsedBody,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.
|
|
26
|
+
*
|
|
27
|
+
* @param settings - The settings of the poll request, including client, options and the spec
|
|
28
|
+
* @returns A callback that accept the path as input and return the promise of Lro response.
|
|
29
|
+
*/
|
|
30
|
+
export function createSendPollRequest(settings) {
|
|
31
|
+
const { client, options, spec } = settings;
|
|
32
|
+
return async (path) => getRawResponse((paramOptions) => client.sendOperationRequest({ options: paramOptions }, Object.assign({ path }, spec)), options);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=lro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro.js","sourceRoot":"","sources":["../../src/models/lro.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,WAAsD,EACtD,OAAiB;IAEjB,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACrC,IAAI,WAAkC,CAAC;IACvC,MAAM,YAAY,GAAG,MAAM,WAAW,iCACjC,OAAO,KACV,UAAU,EAAE,CAAC,QAAQ,EAAE,iBAAiB,EAAE,EAAE;YAC1C,WAAW,GAAG,QAAQ,CAAC;YACvB,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAC5C,CAAC,IACD,CAAC;IACH,OAAO;QACL,YAAY;QACZ,WAAW,EAAE;YACX,UAAU,EAAE,WAAY,CAAC,MAAM;YAC/B,OAAO,EAAE,WAAY,CAAC,OAAO,CAAC,MAAM,EAAE;YACtC,IAAI,EAAE,WAAY,CAAC,UAAU;SAC9B;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAGnC,QAID;IACC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;IAC3C,OAAO,KAAK,EAAE,IAAY,EAAE,EAAE,CAC5B,cAAc,CACZ,CAAC,YAAY,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAI,IAAI,IAAK,IAAI,EAAG,EAC3F,OAAO,CACR,CAAC;AACN,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport {\n FullOperationResponse,\n OperationOptions,\n OperationSpec,\n ServiceClient,\n} from \"@azure/core-client\";\nimport { LroResponse } from \"@azure/core-lro\";\n\n/**\n * Extract several fields of the response to the rawResponse\n *\n * @param getResponse - A async function that actually call the backend API.\n * @param options - The options for the getResponse callback\n * @returns A promise for the API call.\n */\nexport async function getRawResponse<TOptions extends OperationOptions, TResponse>(\n getResponse: (options: TOptions) => Promise<TResponse>,\n options: TOptions\n): Promise<LroResponse<TResponse>> {\n const { onResponse } = options || {};\n let rawResponse: FullOperationResponse;\n const flatResponse = await getResponse({\n ...options,\n onResponse: (response, flatResponseParam) => {\n rawResponse = response;\n onResponse?.(response, flatResponseParam);\n },\n });\n return {\n flatResponse,\n rawResponse: {\n statusCode: rawResponse!.status,\n headers: rawResponse!.headers.toJSON(),\n body: rawResponse!.parsedBody,\n },\n };\n}\n\n/**\n * Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.\n *\n * @param settings - The settings of the poll request, including client, options and the spec\n * @returns A callback that accept the path as input and return the promise of Lro response.\n */\nexport function createSendPollRequest<\n TOptions extends OperationOptions,\n TClient extends ServiceClient\n>(settings: {\n client: TClient;\n options: TOptions;\n spec: OperationSpec;\n}): (path: string) => Promise<LroResponse<unknown>> {\n const { client, options, spec } = settings;\n return async (path: string) =>\n getRawResponse(\n (paramOptions) => client.sendOperationRequest({ options: paramOptions }, { path, ...spec }),\n options\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/maps-common",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
4
|
"description": "An internal shared package for Azure Maps TypeScript SDK",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -74,12 +74,13 @@
|
|
|
74
74
|
"@azure/abort-controller": "^1.0.0",
|
|
75
75
|
"@azure/core-auth": "^1.3.0",
|
|
76
76
|
"@azure/core-lro": "^2.2.0",
|
|
77
|
-
"@azure/core-rest-pipeline": "^1.1.0"
|
|
77
|
+
"@azure/core-rest-pipeline": "^1.1.0",
|
|
78
|
+
"@azure/core-client": "^1.0.0"
|
|
78
79
|
},
|
|
79
80
|
"devDependencies": {
|
|
80
|
-
"@azure/test-utils": "
|
|
81
|
-
"@azure/eslint-plugin-azure-sdk": "
|
|
82
|
-
"@azure/dev-tool": "
|
|
81
|
+
"@azure/test-utils": "^1.0.0",
|
|
82
|
+
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
|
83
|
+
"@azure/dev-tool": "^1.0.0",
|
|
83
84
|
"@microsoft/api-extractor": "7.18.11",
|
|
84
85
|
"downlevel-dts": "^0.8.0",
|
|
85
86
|
"eslint": "^8.0.0",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OperationOptions, OperationSpec, ServiceClient } from "@azure/core-client";
|
|
2
|
+
import { LroResponse } from "@azure/core-lro";
|
|
3
|
+
/**
|
|
4
|
+
* Extract several fields of the response to the rawResponse
|
|
5
|
+
*
|
|
6
|
+
* @param getResponse - A async function that actually call the backend API.
|
|
7
|
+
* @param options - The options for the getResponse callback
|
|
8
|
+
* @returns A promise for the API call.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRawResponse<TOptions extends OperationOptions, TResponse>(getResponse: (options: TOptions) => Promise<TResponse>, options: TOptions): Promise<LroResponse<TResponse>>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.
|
|
13
|
+
*
|
|
14
|
+
* @param settings - The settings of the poll request, including client, options and the spec
|
|
15
|
+
* @returns A callback that accept the path as input and return the promise of Lro response.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSendPollRequest<TOptions extends OperationOptions, TClient extends ServiceClient>(settings: {
|
|
18
|
+
client: TClient;
|
|
19
|
+
options: TOptions;
|
|
20
|
+
spec: OperationSpec;
|
|
21
|
+
}): (path: string) => Promise<LroResponse<unknown>>;
|
|
22
|
+
//# sourceMappingURL=lro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OperationOptions, OperationSpec, ServiceClient } from "@azure/core-client";
|
|
2
|
+
import { LroResponse } from "@azure/core-lro";
|
|
3
|
+
/**
|
|
4
|
+
* Extract several fields of the response to the rawResponse
|
|
5
|
+
*
|
|
6
|
+
* @param getResponse - A async function that actually call the backend API.
|
|
7
|
+
* @param options - The options for the getResponse callback
|
|
8
|
+
* @returns A promise for the API call.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRawResponse<TOptions extends OperationOptions, TResponse>(getResponse: (options: TOptions) => Promise<TResponse>, options: TOptions): Promise<LroResponse<TResponse>>;
|
|
11
|
+
/**
|
|
12
|
+
* Helper function to create a method that can be passed to sendPollRequest in createHttpPoller.
|
|
13
|
+
*
|
|
14
|
+
* @param settings - The settings of the poll request, including client, options and the spec
|
|
15
|
+
* @returns A callback that accept the path as input and return the promise of Lro response.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createSendPollRequest<TOptions extends OperationOptions, TClient extends ServiceClient>(settings: {
|
|
18
|
+
client: TClient;
|
|
19
|
+
options: TOptions;
|
|
20
|
+
spec: OperationSpec;
|
|
21
|
+
}): (path: string) => Promise<LroResponse<unknown>>;
|
|
22
|
+
//# sourceMappingURL=lro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro.d.ts","sourceRoot":"","sources":["../../../src/models/lro.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,QAAQ,SAAS,gBAAgB,EAAE,SAAS,EAC/E,WAAW,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,SAAS,CAAC,EACtD,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAkBjC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,SAAS,gBAAgB,EACjC,OAAO,SAAS,aAAa,EAC7B,QAAQ,EAAE;IACV,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAOlD"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT license.
|
|
3
|
-
/**
|
|
4
|
-
* Batch operation poller proxy
|
|
5
|
-
*/
|
|
6
|
-
export class BatchPollerProxy {
|
|
7
|
-
constructor(internalPoller, mapper) {
|
|
8
|
-
this.internalPoller = internalPoller;
|
|
9
|
-
this.mapper = mapper;
|
|
10
|
-
}
|
|
11
|
-
async poll(options = {}) {
|
|
12
|
-
await this.internalPoller.poll(options);
|
|
13
|
-
}
|
|
14
|
-
async pollUntilDone() {
|
|
15
|
-
const result = await this.internalPoller.pollUntilDone();
|
|
16
|
-
return this.mapper(result);
|
|
17
|
-
}
|
|
18
|
-
onProgress(callback) {
|
|
19
|
-
const internalCallback = (internalState) => {
|
|
20
|
-
const state = {};
|
|
21
|
-
if (internalState.isStarted) {
|
|
22
|
-
state.isStarted = internalState.isStarted;
|
|
23
|
-
}
|
|
24
|
-
if (internalState.isCompleted) {
|
|
25
|
-
state.isCompleted = internalState.isCompleted;
|
|
26
|
-
}
|
|
27
|
-
if (internalState.isCancelled) {
|
|
28
|
-
state.isCancelled = internalState.isCancelled;
|
|
29
|
-
}
|
|
30
|
-
if (internalState.error) {
|
|
31
|
-
state.error = internalState.error;
|
|
32
|
-
}
|
|
33
|
-
if (internalState.result) {
|
|
34
|
-
state.result = this.mapper(internalState.result);
|
|
35
|
-
}
|
|
36
|
-
callback(state);
|
|
37
|
-
};
|
|
38
|
-
return this.internalPoller.onProgress(internalCallback);
|
|
39
|
-
}
|
|
40
|
-
isDone() {
|
|
41
|
-
return this.internalPoller.isDone();
|
|
42
|
-
}
|
|
43
|
-
stopPolling() {
|
|
44
|
-
this.internalPoller.stopPolling();
|
|
45
|
-
}
|
|
46
|
-
isStopped() {
|
|
47
|
-
return this.internalPoller.isStopped();
|
|
48
|
-
}
|
|
49
|
-
getOperationState() {
|
|
50
|
-
const internalState = this.internalPoller.getOperationState();
|
|
51
|
-
const state = {};
|
|
52
|
-
if (internalState.isStarted) {
|
|
53
|
-
state.isStarted = internalState.isStarted;
|
|
54
|
-
}
|
|
55
|
-
if (internalState.isCompleted) {
|
|
56
|
-
state.isCompleted = internalState.isCompleted;
|
|
57
|
-
}
|
|
58
|
-
if (internalState.isCancelled) {
|
|
59
|
-
state.isCancelled = internalState.isCancelled;
|
|
60
|
-
}
|
|
61
|
-
if (internalState.error) {
|
|
62
|
-
state.error = internalState.error;
|
|
63
|
-
}
|
|
64
|
-
if (internalState.result) {
|
|
65
|
-
state.result = this.mapper(internalState.result);
|
|
66
|
-
}
|
|
67
|
-
return state;
|
|
68
|
-
}
|
|
69
|
-
getResult() {
|
|
70
|
-
const result = this.internalPoller.getResult();
|
|
71
|
-
if (result) {
|
|
72
|
-
return this.mapper(result);
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
toString() {
|
|
77
|
-
return this.internalPoller.toString();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=pollers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pollers.js","sourceRoot":"","sources":["../../src/models/pollers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAG3B,YACU,cAGP,EACO,MAAmD;QAJnD,mBAAc,GAAd,cAAc,CAGrB;QACO,WAAM,GAAN,MAAM,CAA6C;IAC1D,CAAC;IAEG,KAAK,CAAC,IAAI,CAAC,UAA6C,EAAE;QAC/D,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,aAAa;QACxB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;QACzD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAEM,UAAU,CAAC,QAA2D;QAC3E,MAAM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C,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;SAC/C;QACD,IAAI,aAAa,CAAC,WAAW,EAAE;YAC7B,KAAK,CAAC,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC;SAC/C;QACD,IAAI,aAAa,CAAC,KAAK,EAAE;YACvB,KAAK,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;SACnC;QACD,IAAI,aAAa,CAAC,MAAM,EAAE;YACxB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAClD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,SAAS;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QAC/C,IAAI,MAAM,EAAE;YACV,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAC5B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;IACxC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CancelOnProgress, PollOperationState, PollerLike } from \"@azure/core-lro\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\n\n/** Batch operation poller interface */\nexport interface BatchPoller<TBatchResult>\n extends Omit<PollerLike<PollOperationState<TBatchResult>, TBatchResult>, \"cancelOperation\"> {}\n\n/**\n * Batch operation poller proxy\n */\nexport class BatchPollerProxy<TBatchResult, TInternalBatchResult>\n implements BatchPoller<TBatchResult>\n{\n constructor(\n private internalPoller: PollerLike<\n PollOperationState<TInternalBatchResult>,\n TInternalBatchResult\n >,\n private mapper: (res: TInternalBatchResult) => TBatchResult\n ) {}\n\n public async poll(options: { abortSignal?: AbortSignalLike } = {}): Promise<void> {\n await this.internalPoller.poll(options);\n }\n\n public async pollUntilDone(): Promise<TBatchResult> {\n const result = await this.internalPoller.pollUntilDone();\n return this.mapper(result);\n }\n\n public onProgress(callback: (state: PollOperationState<TBatchResult>) => void): CancelOnProgress {\n const internalCallback = (internalState: PollOperationState<TInternalBatchResult>): void => {\n const state: PollOperationState<TBatchResult> = {};\n if (internalState.isStarted) {\n state.isStarted = internalState.isStarted;\n }\n if (internalState.isCompleted) {\n state.isCompleted = internalState.isCompleted;\n }\n if (internalState.isCancelled) {\n state.isCancelled = internalState.isCancelled;\n }\n if (internalState.error) {\n state.error = internalState.error;\n }\n if (internalState.result) {\n state.result = this.mapper(internalState.result);\n }\n callback(state);\n };\n return this.internalPoller.onProgress(internalCallback);\n }\n\n public isDone(): boolean {\n return this.internalPoller.isDone();\n }\n\n public stopPolling(): void {\n this.internalPoller.stopPolling();\n }\n\n public isStopped(): boolean {\n return this.internalPoller.isStopped();\n }\n\n public getOperationState(): PollOperationState<TBatchResult> {\n const internalState = this.internalPoller.getOperationState();\n const state: PollOperationState<TBatchResult> = {};\n if (internalState.isStarted) {\n state.isStarted = internalState.isStarted;\n }\n if (internalState.isCompleted) {\n state.isCompleted = internalState.isCompleted;\n }\n if (internalState.isCancelled) {\n state.isCancelled = internalState.isCancelled;\n }\n if (internalState.error) {\n state.error = internalState.error;\n }\n if (internalState.result) {\n state.result = this.mapper(internalState.result);\n }\n return state;\n }\n\n public getResult(): TBatchResult | undefined {\n const result = this.internalPoller.getResult();\n if (result) {\n return this.mapper(result);\n }\n return undefined;\n }\n\n public toString(): string {\n return this.internalPoller.toString();\n }\n}\n"]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CancelOnProgress, PollOperationState, PollerLike } from "@azure/core-lro";
|
|
2
|
-
import { AbortSignalLike } from "@azure/abort-controller";
|
|
3
|
-
/** Batch operation poller interface */
|
|
4
|
-
export interface BatchPoller<TBatchResult> extends Pick<PollerLike<PollOperationState<TBatchResult>, TBatchResult>, Exclude<keyof PollerLike<PollOperationState<TBatchResult>, TBatchResult>, "cancelOperation">> {
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Batch operation poller proxy
|
|
8
|
-
*/
|
|
9
|
-
export declare class BatchPollerProxy<TBatchResult, TInternalBatchResult> implements BatchPoller<TBatchResult> {
|
|
10
|
-
private internalPoller;
|
|
11
|
-
private mapper;
|
|
12
|
-
constructor(internalPoller: PollerLike<PollOperationState<TInternalBatchResult>, TInternalBatchResult>, mapper: (res: TInternalBatchResult) => TBatchResult);
|
|
13
|
-
poll(options?: {
|
|
14
|
-
abortSignal?: AbortSignalLike;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
pollUntilDone(): Promise<TBatchResult>;
|
|
17
|
-
onProgress(callback: (state: PollOperationState<TBatchResult>) => void): CancelOnProgress;
|
|
18
|
-
isDone(): boolean;
|
|
19
|
-
stopPolling(): void;
|
|
20
|
-
isStopped(): boolean;
|
|
21
|
-
getOperationState(): PollOperationState<TBatchResult>;
|
|
22
|
-
getResult(): TBatchResult | undefined;
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=pollers.d.ts.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { CancelOnProgress, PollOperationState, PollerLike } from "@azure/core-lro";
|
|
2
|
-
import { AbortSignalLike } from "@azure/abort-controller";
|
|
3
|
-
/** Batch operation poller interface */
|
|
4
|
-
export interface BatchPoller<TBatchResult> extends Omit<PollerLike<PollOperationState<TBatchResult>, TBatchResult>, "cancelOperation"> {
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Batch operation poller proxy
|
|
8
|
-
*/
|
|
9
|
-
export declare class BatchPollerProxy<TBatchResult, TInternalBatchResult> implements BatchPoller<TBatchResult> {
|
|
10
|
-
private internalPoller;
|
|
11
|
-
private mapper;
|
|
12
|
-
constructor(internalPoller: PollerLike<PollOperationState<TInternalBatchResult>, TInternalBatchResult>, mapper: (res: TInternalBatchResult) => TBatchResult);
|
|
13
|
-
poll(options?: {
|
|
14
|
-
abortSignal?: AbortSignalLike;
|
|
15
|
-
}): Promise<void>;
|
|
16
|
-
pollUntilDone(): Promise<TBatchResult>;
|
|
17
|
-
onProgress(callback: (state: PollOperationState<TBatchResult>) => void): CancelOnProgress;
|
|
18
|
-
isDone(): boolean;
|
|
19
|
-
stopPolling(): void;
|
|
20
|
-
isStopped(): boolean;
|
|
21
|
-
getOperationState(): PollOperationState<TBatchResult>;
|
|
22
|
-
getResult(): TBatchResult | undefined;
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=pollers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pollers.d.ts","sourceRoot":"","sources":["../../../src/models/pollers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,uCAAuC;AACvC,MAAM,WAAW,WAAW,CAAC,YAAY,CACvC,SAAQ,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAAG;AAEhG;;GAEG;AACH,qBAAa,gBAAgB,CAAC,YAAY,EAAE,oBAAoB,CAC9D,YAAW,WAAW,CAAC,YAAY,CAAC;IAGlC,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,MAAM;gBAJN,cAAc,EAAE,UAAU,CAChC,kBAAkB,CAAC,oBAAoB,CAAC,EACxC,oBAAoB,CACrB,EACO,MAAM,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,YAAY;IAGhD,IAAI,CAAC,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,eAAe,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC;IAK5C,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,YAAY,CAAC,KAAK,IAAI,GAAG,gBAAgB;IAuBzF,MAAM,IAAI,OAAO;IAIjB,WAAW,IAAI,IAAI;IAInB,SAAS,IAAI,OAAO;IAIpB,iBAAiB,IAAI,kBAAkB,CAAC,YAAY,CAAC;IAqBrD,SAAS,IAAI,YAAY,GAAG,SAAS;IAQrC,QAAQ,IAAI,MAAM;CAG1B"}
|