@azure/synapse-artifacts 1.0.0-beta.4 → 1.0.0-beta.8

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 (170) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +6 -4
  3. package/dist/index.js +18462 -16154
  4. package/dist/index.js.map +1 -1
  5. package/dist-esm/src/artifactsClient.js +20 -15
  6. package/dist-esm/src/artifactsClient.js.map +1 -1
  7. package/dist-esm/src/artifactsClientContext.js +14 -37
  8. package/dist-esm/src/artifactsClientContext.js.map +1 -1
  9. package/dist-esm/src/index.js +1 -2
  10. package/dist-esm/src/index.js.map +1 -1
  11. package/dist-esm/src/lroImpl.js +25 -0
  12. package/dist-esm/src/lroImpl.js.map +1 -0
  13. package/dist-esm/src/models/index.js +767 -1
  14. package/dist-esm/src/models/index.js.map +1 -1
  15. package/dist-esm/src/models/mappers.js +8083 -7446
  16. package/dist-esm/src/models/mappers.js.map +1 -1
  17. package/dist-esm/src/models/parameters.js +259 -165
  18. package/dist-esm/src/models/parameters.js.map +1 -1
  19. package/dist-esm/src/operations/bigDataPools.js +38 -50
  20. package/dist-esm/src/operations/bigDataPools.js.map +1 -1
  21. package/dist-esm/src/operations/dataFlowDebugSession.js +165 -153
  22. package/dist-esm/src/operations/dataFlowDebugSession.js.map +1 -1
  23. package/dist-esm/src/operations/dataFlowOperations.js +433 -0
  24. package/dist-esm/src/operations/dataFlowOperations.js.map +1 -0
  25. package/dist-esm/src/operations/datasetOperations.js +433 -0
  26. package/dist-esm/src/operations/datasetOperations.js.map +1 -0
  27. package/dist-esm/src/operations/index.js +19 -14
  28. package/dist-esm/src/operations/index.js.map +1 -1
  29. package/dist-esm/src/operations/integrationRuntimes.js +38 -50
  30. package/dist-esm/src/operations/integrationRuntimes.js.map +1 -1
  31. package/dist-esm/src/operations/kqlScriptOperations.js +303 -0
  32. package/dist-esm/src/operations/kqlScriptOperations.js.map +1 -0
  33. package/dist-esm/src/operations/kqlScripts.js +150 -0
  34. package/dist-esm/src/operations/kqlScripts.js.map +1 -0
  35. package/dist-esm/src/operations/library.js +222 -194
  36. package/dist-esm/src/operations/library.js.map +1 -1
  37. package/dist-esm/src/operations/linkedServiceOperations.js +434 -0
  38. package/dist-esm/src/operations/linkedServiceOperations.js.map +1 -0
  39. package/dist-esm/src/operations/metastore.js +182 -0
  40. package/dist-esm/src/operations/metastore.js.map +1 -0
  41. package/dist-esm/src/operations/notebookOperationResult.js +64 -0
  42. package/dist-esm/src/operations/notebookOperationResult.js.map +1 -0
  43. package/dist-esm/src/operations/notebookOperations.js +558 -0
  44. package/dist-esm/src/operations/notebookOperations.js.map +1 -0
  45. package/dist-esm/src/operations/pipelineOperations.js +479 -0
  46. package/dist-esm/src/operations/pipelineOperations.js.map +1 -0
  47. package/dist-esm/src/operations/pipelineRunOperations.js +185 -0
  48. package/dist-esm/src/operations/pipelineRunOperations.js.map +1 -0
  49. package/dist-esm/src/operations/sparkConfigurationOperations.js +434 -0
  50. package/dist-esm/src/operations/sparkConfigurationOperations.js.map +1 -0
  51. package/dist-esm/src/operations/sparkJobDefinitionOperations.js +602 -0
  52. package/dist-esm/src/operations/sparkJobDefinitionOperations.js.map +1 -0
  53. package/dist-esm/src/operations/sqlPools.js +38 -50
  54. package/dist-esm/src/operations/sqlPools.js.map +1 -1
  55. package/dist-esm/src/operations/sqlScriptOperations.js +434 -0
  56. package/dist-esm/src/operations/sqlScriptOperations.js.map +1 -0
  57. package/dist-esm/src/operations/triggerOperations.js +705 -0
  58. package/dist-esm/src/operations/triggerOperations.js.map +1 -0
  59. package/dist-esm/src/operations/triggerRunOperations.js +147 -0
  60. package/dist-esm/src/operations/triggerRunOperations.js.map +1 -0
  61. package/dist-esm/src/operations/workspaceGitRepoManagement.js +26 -29
  62. package/dist-esm/src/operations/workspaceGitRepoManagement.js.map +1 -1
  63. package/dist-esm/src/operations/workspaceOperations.js +62 -0
  64. package/dist-esm/src/operations/workspaceOperations.js.map +1 -0
  65. package/dist-esm/src/operationsInterfaces/bigDataPools.js.map +1 -1
  66. package/dist-esm/src/operationsInterfaces/dataFlowDebugSession.js +1 -1
  67. package/dist-esm/src/operationsInterfaces/dataFlowDebugSession.js.map +1 -1
  68. package/dist-esm/src/operationsInterfaces/{dataset.js → dataFlowOperations.js} +2 -2
  69. package/dist-esm/src/operationsInterfaces/dataFlowOperations.js.map +1 -0
  70. package/dist-esm/src/operationsInterfaces/{pipelineRun.js → datasetOperations.js} +1 -1
  71. package/dist-esm/src/operationsInterfaces/datasetOperations.js.map +1 -0
  72. package/dist-esm/src/operationsInterfaces/index.js +19 -14
  73. package/dist-esm/src/operationsInterfaces/index.js.map +1 -1
  74. package/dist-esm/src/operationsInterfaces/integrationRuntimes.js.map +1 -1
  75. package/dist-esm/src/operationsInterfaces/kqlScriptOperations.js +9 -0
  76. package/dist-esm/src/operationsInterfaces/kqlScriptOperations.js.map +1 -0
  77. package/dist-esm/src/operationsInterfaces/{triggerRun.js → kqlScripts.js} +1 -1
  78. package/dist-esm/src/operationsInterfaces/kqlScripts.js.map +1 -0
  79. package/dist-esm/src/operationsInterfaces/library.js +1 -1
  80. package/dist-esm/src/operationsInterfaces/library.js.map +1 -1
  81. package/dist-esm/src/operationsInterfaces/linkedServiceOperations.js +9 -0
  82. package/dist-esm/src/operationsInterfaces/linkedServiceOperations.js.map +1 -0
  83. package/dist-esm/src/operationsInterfaces/{workspace.js → metastore.js} +1 -1
  84. package/dist-esm/src/operationsInterfaces/metastore.js.map +1 -0
  85. package/dist-esm/src/operationsInterfaces/notebookOperationResult.js +9 -0
  86. package/dist-esm/src/operationsInterfaces/notebookOperationResult.js.map +1 -0
  87. package/dist-esm/src/operationsInterfaces/notebookOperations.js +9 -0
  88. package/dist-esm/src/operationsInterfaces/notebookOperations.js.map +1 -0
  89. package/dist-esm/src/operationsInterfaces/pipelineOperations.js +9 -0
  90. package/dist-esm/src/operationsInterfaces/pipelineOperations.js.map +1 -0
  91. package/dist-esm/src/operationsInterfaces/pipelineRunOperations.js +9 -0
  92. package/dist-esm/src/operationsInterfaces/pipelineRunOperations.js.map +1 -0
  93. package/dist-esm/src/operationsInterfaces/{dataFlow.js → sparkConfigurationOperations.js} +2 -2
  94. package/dist-esm/src/operationsInterfaces/sparkConfigurationOperations.js.map +1 -0
  95. package/dist-esm/src/operationsInterfaces/sparkJobDefinitionOperations.js +9 -0
  96. package/dist-esm/src/operationsInterfaces/sparkJobDefinitionOperations.js.map +1 -0
  97. package/dist-esm/src/operationsInterfaces/sqlPools.js.map +1 -1
  98. package/dist-esm/src/operationsInterfaces/sqlScriptOperations.js +9 -0
  99. package/dist-esm/src/operationsInterfaces/sqlScriptOperations.js.map +1 -0
  100. package/dist-esm/src/operationsInterfaces/triggerOperations.js +9 -0
  101. package/dist-esm/src/operationsInterfaces/triggerOperations.js.map +1 -0
  102. package/dist-esm/src/operationsInterfaces/triggerRunOperations.js +9 -0
  103. package/dist-esm/src/operationsInterfaces/triggerRunOperations.js.map +1 -0
  104. package/dist-esm/src/operationsInterfaces/workspaceOperations.js +9 -0
  105. package/dist-esm/src/operationsInterfaces/workspaceOperations.js.map +1 -0
  106. package/package.json +20 -30
  107. package/types/synapse-artifacts.d.ts +2037 -1319
  108. package/dist-esm/src/lro/azureAsyncOperationStrategy.js +0 -149
  109. package/dist-esm/src/lro/azureAsyncOperationStrategy.js.map +0 -1
  110. package/dist-esm/src/lro/bodyPollingStrategy.js +0 -45
  111. package/dist-esm/src/lro/bodyPollingStrategy.js.map +0 -1
  112. package/dist-esm/src/lro/constants.js +0 -9
  113. package/dist-esm/src/lro/constants.js.map +0 -1
  114. package/dist-esm/src/lro/index.js +0 -15
  115. package/dist-esm/src/lro/index.js.map +0 -1
  116. package/dist-esm/src/lro/locationStrategy.js +0 -54
  117. package/dist-esm/src/lro/locationStrategy.js.map +0 -1
  118. package/dist-esm/src/lro/lroPolicy.js +0 -32
  119. package/dist-esm/src/lro/lroPolicy.js.map +0 -1
  120. package/dist-esm/src/lro/lroPoller.js +0 -74
  121. package/dist-esm/src/lro/lroPoller.js.map +0 -1
  122. package/dist-esm/src/lro/models.js +0 -9
  123. package/dist-esm/src/lro/models.js.map +0 -1
  124. package/dist-esm/src/lro/operation.js +0 -72
  125. package/dist-esm/src/lro/operation.js.map +0 -1
  126. package/dist-esm/src/lro/passthroughStrategy.js +0 -27
  127. package/dist-esm/src/lro/passthroughStrategy.js.map +0 -1
  128. package/dist-esm/src/lro/requestUtils.js +0 -82
  129. package/dist-esm/src/lro/requestUtils.js.map +0 -1
  130. package/dist-esm/src/operations/dataFlow.js +0 -391
  131. package/dist-esm/src/operations/dataFlow.js.map +0 -1
  132. package/dist-esm/src/operations/dataset.js +0 -391
  133. package/dist-esm/src/operations/dataset.js.map +0 -1
  134. package/dist-esm/src/operations/linkedService.js +0 -392
  135. package/dist-esm/src/operations/linkedService.js.map +0 -1
  136. package/dist-esm/src/operations/notebook.js +0 -527
  137. package/dist-esm/src/operations/notebook.js.map +0 -1
  138. package/dist-esm/src/operations/pipeline.js +0 -443
  139. package/dist-esm/src/operations/pipeline.js.map +0 -1
  140. package/dist-esm/src/operations/pipelineRun.js +0 -208
  141. package/dist-esm/src/operations/pipelineRun.js.map +0 -1
  142. package/dist-esm/src/operations/sparkJobDefinition.js +0 -520
  143. package/dist-esm/src/operations/sparkJobDefinition.js.map +0 -1
  144. package/dist-esm/src/operations/sqlScript.js +0 -392
  145. package/dist-esm/src/operations/sqlScript.js.map +0 -1
  146. package/dist-esm/src/operations/trigger.js +0 -609
  147. package/dist-esm/src/operations/trigger.js.map +0 -1
  148. package/dist-esm/src/operations/triggerRun.js +0 -160
  149. package/dist-esm/src/operations/triggerRun.js.map +0 -1
  150. package/dist-esm/src/operations/workspace.js +0 -68
  151. package/dist-esm/src/operations/workspace.js.map +0 -1
  152. package/dist-esm/src/operationsInterfaces/dataFlow.js.map +0 -1
  153. package/dist-esm/src/operationsInterfaces/dataset.js.map +0 -1
  154. package/dist-esm/src/operationsInterfaces/linkedService.js +0 -9
  155. package/dist-esm/src/operationsInterfaces/linkedService.js.map +0 -1
  156. package/dist-esm/src/operationsInterfaces/notebook.js +0 -9
  157. package/dist-esm/src/operationsInterfaces/notebook.js.map +0 -1
  158. package/dist-esm/src/operationsInterfaces/pipeline.js +0 -9
  159. package/dist-esm/src/operationsInterfaces/pipeline.js.map +0 -1
  160. package/dist-esm/src/operationsInterfaces/pipelineRun.js.map +0 -1
  161. package/dist-esm/src/operationsInterfaces/sparkJobDefinition.js +0 -9
  162. package/dist-esm/src/operationsInterfaces/sparkJobDefinition.js.map +0 -1
  163. package/dist-esm/src/operationsInterfaces/sqlScript.js +0 -9
  164. package/dist-esm/src/operationsInterfaces/sqlScript.js.map +0 -1
  165. package/dist-esm/src/operationsInterfaces/trigger.js +0 -9
  166. package/dist-esm/src/operationsInterfaces/trigger.js.map +0 -1
  167. package/dist-esm/src/operationsInterfaces/triggerRun.js.map +0 -1
  168. package/dist-esm/src/operationsInterfaces/workspace.js.map +0 -1
  169. package/dist-esm/src/utils/constants.js +0 -9
  170. package/dist-esm/src/utils/constants.js.map +0 -1
@@ -1,149 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter, __rest } from "tslib";
9
- import { LROSYM } from "./models";
10
- import { terminalStates } from "./constants";
11
- export function createAzureAsyncOperationStrategy(initialOperation, sendOperationFn, finalStateVia) {
12
- const lroData = initialOperation.result._response[LROSYM];
13
- if (!lroData) {
14
- throw new Error("Expected lroData to be defined for Azure-AsyncOperation strategy");
15
- }
16
- let currentOperation = initialOperation;
17
- let lastKnownPollingUrl = lroData.azureAsyncOperation || lroData.operationLocation;
18
- return {
19
- isTerminal: () => {
20
- const currentResult = currentOperation.result._response[LROSYM];
21
- if (!currentResult) {
22
- throw new Error("Expected lroData to determine terminal status");
23
- }
24
- if (currentOperation === initialOperation) {
25
- // Azure-AsyncOperations don't need to check for terminal state
26
- // on originalOperation result, always need to poll
27
- return false;
28
- }
29
- const { status = "succeeded" } = currentResult;
30
- return terminalStates.includes(status.toLowerCase());
31
- },
32
- sendFinalRequest: () => __awaiter(this, void 0, void 0, function* () {
33
- if (!initialOperation.result._response[LROSYM]) {
34
- throw new Error("Expected lroData to determine terminal status");
35
- }
36
- if (!currentOperation.result._response[LROSYM]) {
37
- throw new Error("Expected lroData to determine terminal status");
38
- }
39
- const initialOperationResult = initialOperation.result._response[LROSYM];
40
- const currentOperationResult = currentOperation.result._response[LROSYM];
41
- if (!shouldPerformFinalGet(initialOperationResult, currentOperationResult)) {
42
- return currentOperation;
43
- }
44
- if ((initialOperationResult === null || initialOperationResult === void 0 ? void 0 : initialOperationResult.requestMethod) === "PUT") {
45
- currentOperation = yield sendFinalGet(initialOperation, sendOperationFn);
46
- return currentOperation;
47
- }
48
- if (initialOperationResult === null || initialOperationResult === void 0 ? void 0 : initialOperationResult.location) {
49
- switch (finalStateVia) {
50
- case "original-uri":
51
- currentOperation = yield sendFinalGet(initialOperation, sendOperationFn);
52
- return currentOperation;
53
- case "azure-async-operation":
54
- return currentOperation;
55
- case "location":
56
- default:
57
- const location = initialOperationResult.location || (currentOperationResult === null || currentOperationResult === void 0 ? void 0 : currentOperationResult.location);
58
- if (!location) {
59
- throw new Error("Couldn't determine final GET URL from location");
60
- }
61
- return yield sendFinalGet(initialOperation, sendOperationFn, location);
62
- }
63
- }
64
- // All other cases return the last operation
65
- return currentOperation;
66
- }),
67
- poll: () => __awaiter(this, void 0, void 0, function* () {
68
- var _a, _b;
69
- if (!lastKnownPollingUrl) {
70
- throw new Error("Unable to determine polling url");
71
- }
72
- const pollingArgs = currentOperation.args;
73
- // Make sure we don't send any body to the get request
74
- const _c = currentOperation.spec, { requestBody, responses } = _c, restSpec = __rest(_c, ["requestBody", "responses"]);
75
- const pollingSpec = Object.assign(Object.assign({}, restSpec), { responses: getCompositeMappers(responses), httpMethod: "GET", path: lastKnownPollingUrl });
76
- const result = yield sendOperationFn(pollingArgs, pollingSpec);
77
- // Update latest polling url
78
- lastKnownPollingUrl =
79
- ((_a = result._response[LROSYM]) === null || _a === void 0 ? void 0 : _a.azureAsyncOperation) ||
80
- ((_b = result._response[LROSYM]) === null || _b === void 0 ? void 0 : _b.operationLocation) ||
81
- lastKnownPollingUrl;
82
- // Update lastOperation result
83
- currentOperation = {
84
- args: pollingArgs,
85
- spec: pollingSpec,
86
- result
87
- };
88
- return currentOperation;
89
- })
90
- };
91
- }
92
- /**
93
- * Polling calls will always return a status object i.e. {"status": "success"}
94
- * these intermediate responses are not described in the swagger so we need to
95
- * pass custom mappers at runtime.
96
- * This function replaces all the existing mappers to be able to deserialize a status object
97
- * @param responses Original set of responses defined in the operation
98
- */
99
- function getCompositeMappers(responses) {
100
- return Object.keys(responses).reduce((acc, statusCode) => {
101
- return Object.assign(Object.assign({}, acc), { [statusCode]: Object.assign(Object.assign({}, responses[statusCode]), { bodyMapper: {
102
- type: {
103
- name: "Composite",
104
- modelProperties: {
105
- status: {
106
- serializedName: "status",
107
- type: {
108
- name: "String"
109
- }
110
- }
111
- }
112
- }
113
- } }) });
114
- }, {});
115
- }
116
- function shouldPerformFinalGet(initialResult, currentResult) {
117
- const { status } = currentResult || {};
118
- const { requestMethod: initialRequestMethod, location } = initialResult || {};
119
- if (status && status.toLowerCase() !== "succeeded") {
120
- return false;
121
- }
122
- if (initialRequestMethod === "DELETE") {
123
- return false;
124
- }
125
- if (initialRequestMethod !== "PUT" && !location) {
126
- return false;
127
- }
128
- return true;
129
- }
130
- function sendFinalGet(initialOperation, sendOperationFn, path) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- // Make sure we don't send any body to the get request
133
- const _a = initialOperation.spec, { requestBody } = _a, restSpec = __rest(_a, ["requestBody"]);
134
- const finalGetSpec = Object.assign(Object.assign({}, restSpec), { httpMethod: "GET" });
135
- // Send final GET request to the Original URL
136
- const spec = Object.assign(Object.assign({}, finalGetSpec), (path && { path }));
137
- let operationArgs = initialOperation.args;
138
- if (operationArgs.options) {
139
- operationArgs.options.shouldDeserialize = true;
140
- }
141
- const finalResult = yield sendOperationFn(initialOperation.args, spec);
142
- return {
143
- args: initialOperation.args,
144
- spec,
145
- result: finalResult
146
- };
147
- });
148
- }
149
- //# sourceMappingURL=azureAsyncOperationStrategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"azureAsyncOperationStrategy.js","sourceRoot":"","sources":["../../../src/lro/azureAsyncOperationStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EAML,MAAM,EACP,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,UAAU,iCAAiC,CAC/C,gBAA2C,EAC3C,eAAyC,EACzC,aAA6B;IAE7B,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;KACrF;IAED,IAAI,gBAAgB,GAAG,gBAAgB,CAAC;IACxC,IAAI,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAEnF,OAAO;QACL,UAAU,EAAE,GAAG,EAAE;YACf,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAEhE,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;aAClE;YAED,IAAI,gBAAgB,KAAK,gBAAgB,EAAE;gBACzC,+DAA+D;gBAC/D,mDAAmD;gBACnD,OAAO,KAAK,CAAC;aACd;YAED,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC;YAC/C,OAAO,cAAc,CAA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F,IAAI,aAAa,GAAuB,gBAAgB,CAAC,IAAI,CAAC;QAC9D,IAAI,aAAa,CAAC,OAAO,EAAE;YACzB,aAAa,CAAC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;SAChD;QAED,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAEvE,OAAO;YACL,IAAI,EAAE,gBAAgB,CAAC,IAAI;YAC3B,IAAI;YACJ,MAAM,EAAE,WAAW;SACpB,CAAC;IACJ,CAAC;CAAA","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport {\n LROStrategy,\n BaseResult,\n LROOperationStep,\n LROResponseInfo,\n FinalStateVia,\n LROSYM\n} from \"./models\";\nimport { OperationSpec, OperationArguments, OperationResponse } from \"@azure/core-http\";\nimport { terminalStates } from \"./constants\";\nimport { SendOperationFn } from \".\";\n\nexport function createAzureAsyncOperationStrategy<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>,\n sendOperationFn: SendOperationFn<TResult>,\n finalStateVia?: FinalStateVia\n): LROStrategy<TResult> {\n const lroData = initialOperation.result._response[LROSYM];\n if (!lroData) {\n throw new Error(\"Expected lroData to be defined for Azure-AsyncOperation strategy\");\n }\n\n let currentOperation = initialOperation;\n let lastKnownPollingUrl = lroData.azureAsyncOperation || lroData.operationLocation;\n\n return {\n isTerminal: () => {\n const currentResult = currentOperation.result._response[LROSYM];\n\n if (!currentResult) {\n throw new Error(\"Expected lroData to determine terminal status\");\n }\n\n if (currentOperation === initialOperation) {\n // Azure-AsyncOperations don't need to check for terminal state\n // on originalOperation result, always need to poll\n return false;\n }\n\n const { status = \"succeeded\" } = currentResult;\n return terminalStates.includes(status.toLowerCase());\n },\n sendFinalRequest: async () => {\n if (!initialOperation.result._response[LROSYM]) {\n throw new Error(\"Expected lroData to determine terminal status\");\n }\n\n if (!currentOperation.result._response[LROSYM]) {\n throw new Error(\"Expected lroData to determine terminal status\");\n }\n\n const initialOperationResult = initialOperation.result._response[LROSYM];\n const currentOperationResult = currentOperation.result._response[LROSYM];\n\n if (!shouldPerformFinalGet(initialOperationResult, currentOperationResult)) {\n return currentOperation;\n }\n\n if (initialOperationResult?.requestMethod === \"PUT\") {\n currentOperation = await sendFinalGet(initialOperation, sendOperationFn);\n\n return currentOperation;\n }\n\n if (initialOperationResult?.location) {\n switch (finalStateVia) {\n case \"original-uri\":\n currentOperation = await sendFinalGet(initialOperation, sendOperationFn);\n return currentOperation;\n\n case \"azure-async-operation\":\n return currentOperation;\n case \"location\":\n default:\n const location = initialOperationResult.location || currentOperationResult?.location;\n\n if (!location) {\n throw new Error(\"Couldn't determine final GET URL from location\");\n }\n\n return await sendFinalGet(initialOperation, sendOperationFn, location);\n }\n }\n\n // All other cases return the last operation\n return currentOperation;\n },\n poll: async () => {\n if (!lastKnownPollingUrl) {\n throw new Error(\"Unable to determine polling url\");\n }\n\n const pollingArgs = currentOperation.args;\n // Make sure we don't send any body to the get request\n const { requestBody, responses, ...restSpec } = currentOperation.spec;\n\n const pollingSpec: OperationSpec = {\n ...restSpec,\n responses: getCompositeMappers(responses),\n httpMethod: \"GET\",\n path: lastKnownPollingUrl\n };\n\n const result = await sendOperationFn(pollingArgs, pollingSpec);\n\n // Update latest polling url\n lastKnownPollingUrl =\n result._response[LROSYM]?.azureAsyncOperation ||\n result._response[LROSYM]?.operationLocation ||\n lastKnownPollingUrl;\n\n // Update lastOperation result\n currentOperation = {\n args: pollingArgs,\n spec: pollingSpec,\n result\n };\n\n return currentOperation;\n }\n };\n}\n\n/**\n * Polling calls will always return a status object i.e. {\"status\": \"success\"}\n * these intermediate responses are not described in the swagger so we need to\n * pass custom mappers at runtime.\n * This function replaces all the existing mappers to be able to deserialize a status object\n * @param responses Original set of responses defined in the operation\n */\nfunction getCompositeMappers(responses: {\n [responseCode: string]: OperationResponse;\n}): {\n [responseCode: string]: OperationResponse;\n} {\n return Object.keys(responses).reduce((acc, statusCode) => {\n return {\n ...acc,\n [statusCode]: {\n ...responses[statusCode],\n bodyMapper: {\n type: {\n name: \"Composite\",\n modelProperties: {\n status: {\n serializedName: \"status\",\n type: {\n name: \"String\"\n }\n }\n }\n }\n }\n }\n };\n }, {} as { [responseCode: string]: OperationResponse });\n}\n\nfunction shouldPerformFinalGet(initialResult?: LROResponseInfo, currentResult?: LROResponseInfo) {\n const { status } = currentResult || {};\n const { requestMethod: initialRequestMethod, location } = initialResult || {};\n if (status && status.toLowerCase() !== \"succeeded\") {\n return false;\n }\n\n if (initialRequestMethod === \"DELETE\") {\n return false;\n }\n\n if (initialRequestMethod !== \"PUT\" && !location) {\n return false;\n }\n\n return true;\n}\n\nasync function sendFinalGet<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>,\n sendOperationFn: SendOperationFn<TResult>,\n path?: string\n): Promise<LROOperationStep<TResult>> {\n // Make sure we don't send any body to the get request\n const { requestBody, ...restSpec } = initialOperation.spec;\n const finalGetSpec: OperationSpec = {\n ...restSpec,\n httpMethod: \"GET\"\n };\n\n // Send final GET request to the Original URL\n const spec = {\n ...finalGetSpec,\n ...(path && { path })\n };\n\n let operationArgs: OperationArguments = initialOperation.args;\n if (operationArgs.options) {\n operationArgs.options.shouldDeserialize = true;\n }\n\n const finalResult = await sendOperationFn(initialOperation.args, spec);\n\n return {\n args: initialOperation.args,\n spec,\n result: finalResult\n };\n}\n"]}
@@ -1,45 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter, __rest } from "tslib";
9
- import { LROSYM } from "./models";
10
- import { terminalStates } from "./constants";
11
- /**
12
- * Creates a polling strategy based on BodyPolling which uses the provisioning state
13
- * from the result to determine the current operation state
14
- */
15
- export function createBodyPollingStrategy(initialOperation, sendOperation) {
16
- if (!initialOperation.result._response[LROSYM]) {
17
- throw new Error("Expected lroData to be defined for BodyPolling strategy");
18
- }
19
- let currentOperation = initialOperation;
20
- return {
21
- isTerminal: () => {
22
- const currentResult = currentOperation.result._response[LROSYM];
23
- if (!currentResult) {
24
- throw new Error("Expected lroData to determine terminal status");
25
- }
26
- const { provisioningState = "succeeded" } = currentResult;
27
- // If provisioning state is missing, default to Success
28
- return terminalStates.includes(provisioningState.toLowerCase());
29
- },
30
- sendFinalRequest: () => {
31
- // BodyPolling doesn't require a final get so return the lastOperation
32
- return Promise.resolve(currentOperation);
33
- },
34
- poll: () => __awaiter(this, void 0, void 0, function* () {
35
- // When doing BodyPolling, we need to poll to the original url with a
36
- // GET http method
37
- const _a = initialOperation.spec, { requestBody } = _a, restSpec = __rest(_a, ["requestBody"]);
38
- const pollingSpec = Object.assign(Object.assign({}, restSpec), { httpMethod: "GET" });
39
- // Execute the polling operation
40
- initialOperation.result = yield sendOperation(initialOperation.args, pollingSpec);
41
- return initialOperation;
42
- })
43
- };
44
- }
45
- //# sourceMappingURL=bodyPollingStrategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bodyPollingStrategy.js","sourceRoot":"","sources":["../../../src/lro/bodyPollingStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EAA6C,MAAM,EAAE,MAAM,UAAU,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,gBAA2C,EAC3C,aAAuC;IAEvC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE;QAC9C,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;IAED,IAAI,gBAAgB,GAAG,gBAAgB,CAAC;IAExC,OAAO;QACL,UAAU,EAAE,GAAG,EAAE;YACf,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAChE,IAAI,CAAC,aAAa,EAAE;gBAClB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;aAClE;YAED,MAAM,EAAE,iBAAiB,GAAG,WAAW,EAAE,GAAG,aAAa,CAAC;YAC1D,uDAAuD;YAEvD,OAAO,cAAc,CAAC,QAAQ,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,gBAAgB,EAAE,GAAG,EAAE;YACrB,sEAAsE;YACtE,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,EAAE,GAAS,EAAE;YACf,qEAAqE;YACrE,kBAAkB;YAClB,MAAM,KAA+B,gBAAgB,CAAC,IAAI,EAApD,EAAE,WAAW,OAAuC,EAAlC,QAAQ,cAA1B,eAA4B,CAAwB,CAAC;YAC3D,MAAM,WAAW,mCAEZ,QAAQ,KACX,UAAU,EAAE,KAAK,GAClB,CAAC;YAEF,gCAAgC;YAChC,gBAAgB,CAAC,MAAM,GAAG,MAAM,aAAa,CAAC,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAClF,OAAO,gBAAgB,CAAC;QAC1B,CAAC,CAAA;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { LROStrategy, BaseResult, LROOperationStep, LROSYM } from \"./models\";\nimport { OperationSpec } from \"@azure/core-http\";\nimport { terminalStates } from \"./constants\";\nimport { SendOperationFn } from \"./lroPoller\";\n\n/**\n * Creates a polling strategy based on BodyPolling which uses the provisioning state\n * from the result to determine the current operation state\n */\nexport function createBodyPollingStrategy<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>,\n sendOperation: SendOperationFn<TResult>\n): LROStrategy<TResult> {\n if (!initialOperation.result._response[LROSYM]) {\n throw new Error(\"Expected lroData to be defined for BodyPolling strategy\");\n }\n\n let currentOperation = initialOperation;\n\n return {\n isTerminal: () => {\n const currentResult = currentOperation.result._response[LROSYM];\n if (!currentResult) {\n throw new Error(\"Expected lroData to determine terminal status\");\n }\n\n const { provisioningState = \"succeeded\" } = currentResult;\n // If provisioning state is missing, default to Success\n\n return terminalStates.includes(provisioningState.toLowerCase());\n },\n sendFinalRequest: () => {\n // BodyPolling doesn't require a final get so return the lastOperation\n return Promise.resolve(currentOperation);\n },\n poll: async () => {\n // When doing BodyPolling, we need to poll to the original url with a\n // GET http method\n const { requestBody, ...restSpec } = initialOperation.spec;\n const pollingSpec: OperationSpec = {\n // Make sure we don't send any body to the get request\n ...restSpec,\n httpMethod: \"GET\"\n };\n\n // Execute the polling operation\n initialOperation.result = await sendOperation(initialOperation.args, pollingSpec);\n return initialOperation;\n }\n };\n}\n"]}
@@ -1,9 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- export const terminalStates = ["succeeded", "failed", "canceled", "cancelled"];
9
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lro/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nexport const terminalStates = [\"succeeded\", \"failed\", \"canceled\", \"cancelled\"];\n"]}
@@ -1,15 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- export { shouldDeserializeLRO } from "./requestUtils";
9
- export { createBodyPollingStrategy } from "./bodyPollingStrategy";
10
- export { terminalStates } from "./constants";
11
- export { lroPolicy } from "./lroPolicy";
12
- export { LROPoller } from "./lroPoller";
13
- export { makeOperation } from "./operation";
14
- export * from "./locationStrategy";
15
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lro/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAqC,MAAM,aAAa,CAAC;AAS3E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,cAAc,oBAAoB,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nexport { shouldDeserializeLRO } from \"./requestUtils\";\nexport { createBodyPollingStrategy } from \"./bodyPollingStrategy\";\nexport { terminalStates } from \"./constants\";\nexport { lroPolicy } from \"./lroPolicy\";\nexport { LROPoller, LROPollerOptions, SendOperationFn } from \"./lroPoller\";\nexport {\n LROResponseInfo,\n BaseResult,\n LROOperationStep,\n LROOperationState,\n LROStrategy,\n LROOperation\n} from \"./models\";\nexport { makeOperation } from \"./operation\";\nexport * from \"./locationStrategy\";\n"]}
@@ -1,54 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter, __rest } from "tslib";
9
- import { LROSYM } from "./models";
10
- export function createLocationStrategy(initialOperation, sendOperationFn) {
11
- const lroData = initialOperation.result._response[LROSYM];
12
- if (!lroData) {
13
- throw new Error("Expected lroData to be defined for Azure-AsyncOperation strategy");
14
- }
15
- let currentOperation = initialOperation;
16
- let lastKnownPollingUrl = lroData.location;
17
- return {
18
- isTerminal: () => {
19
- const currentResult = currentOperation.result._response[LROSYM];
20
- if (!currentResult) {
21
- throw new Error("Expected lroData to determine terminal status");
22
- }
23
- if (currentOperation === initialOperation) {
24
- return false;
25
- }
26
- if (currentResult.statusCode === 202) {
27
- return false;
28
- }
29
- return true;
30
- },
31
- sendFinalRequest: () => Promise.resolve(currentOperation),
32
- poll: () => __awaiter(this, void 0, void 0, function* () {
33
- var _a;
34
- if (!lastKnownPollingUrl) {
35
- throw new Error("Unable to determine polling url");
36
- }
37
- const pollingArgs = currentOperation.args;
38
- // Make sure we don't send any body to the get request
39
- const _b = currentOperation.spec, { requestBody } = _b, restSpec = __rest(_b, ["requestBody"]);
40
- const pollingSpec = Object.assign(Object.assign({}, restSpec), { httpMethod: "GET", path: lastKnownPollingUrl });
41
- const result = yield sendOperationFn(pollingArgs, pollingSpec);
42
- // Update latest polling url
43
- lastKnownPollingUrl = ((_a = result._response[LROSYM]) === null || _a === void 0 ? void 0 : _a.location) || lastKnownPollingUrl;
44
- // Update lastOperation result
45
- currentOperation = {
46
- args: pollingArgs,
47
- spec: pollingSpec,
48
- result
49
- };
50
- return currentOperation;
51
- })
52
- };
53
- }
54
- //# sourceMappingURL=locationStrategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"locationStrategy.js","sourceRo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U,EAAE,KAAK,EACjB,IAAI,EAAE,mBAAmB,GAC1B,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAE/D,4BAA4B;YAC5B,mBAAmB,GAAG,CAAA,MAAA,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,0CAAE,QAAQ,KAAI,mBAAmB,CAAC;YAEhF,8BAA8B;YAC9B,gBAAgB,GAAG;gBACjB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,WAAW;gBACjB,MAAM;aACP,CAAC;YAEF,OAAO,gBAAgB,CAAC;QAC1B,CAAC,CAAA;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { BaseResult, LROOperationStep, LROStrategy, LROSYM } from \"./models\";\nimport { SendOperationFn } from \"./lroPoller\";\nimport { OperationSpec } from \"@azure/core-http\";\n\nexport function createLocationStrategy<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>,\n sendOperationFn: SendOperationFn<TResult>\n): LROStrategy<TResult> {\n const lroData = initialOperation.result._response[LROSYM];\n if (!lroData) {\n throw new Error(\"Expected lroData to be defined for Azure-AsyncOperation strategy\");\n }\n\n let currentOperation = initialOperation;\n let lastKnownPollingUrl = lroData.location;\n\n return {\n isTerminal: () => {\n const currentResult = currentOperation.result._response[LROSYM];\n if (!currentResult) {\n throw new Error(\"Expected lroData to determine terminal status\");\n }\n\n if (currentOperation === initialOperation) {\n return false;\n }\n\n if (currentResult.statusCode === 202) {\n return false;\n }\n\n return true;\n },\n sendFinalRequest: () => Promise.resolve(currentOperation),\n poll: async () => {\n if (!lastKnownPollingUrl) {\n throw new Error(\"Unable to determine polling url\");\n }\n\n const pollingArgs = currentOperation.args;\n // Make sure we don't send any body to the get request\n const { requestBody, ...restSpec } = currentOperation.spec;\n const pollingSpec: OperationSpec = {\n ...restSpec,\n httpMethod: \"GET\",\n path: lastKnownPollingUrl\n };\n\n const result = await sendOperationFn(pollingArgs, pollingSpec);\n\n // Update latest polling url\n lastKnownPollingUrl = result._response[LROSYM]?.location || lastKnownPollingUrl;\n\n // Update lastOperation result\n currentOperation = {\n args: pollingArgs,\n spec: pollingSpec,\n result\n };\n\n return currentOperation;\n }\n };\n}\n"]}
@@ -1,32 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter } from "tslib";
9
- import { BaseRequestPolicy } from "@azure/core-http";
10
- import { LROSYM } from "./models";
11
- import { getLROData } from "./requestUtils";
12
- export function lroPolicy() {
13
- return {
14
- create: (nextPolicy, options) => {
15
- return new LROPolicy(nextPolicy, options);
16
- }
17
- };
18
- }
19
- class LROPolicy extends BaseRequestPolicy {
20
- constructor(nextPolicy, options) {
21
- super(nextPolicy, options);
22
- }
23
- sendRequest(webResource) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- let result = yield this._nextPolicy.sendRequest(webResource);
26
- const _lroData = getLROData(result);
27
- result[LROSYM] = _lroData;
28
- return result;
29
- });
30
- }
31
- }
32
- //# sourceMappingURL=lroPolicy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lroPolicy.js","sourceRoot":"","sources":["../../../src/lro/lroPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAEH,OAAO,EAGL,iBAAiB,EAGlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAwB,MAAM,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAE,EAAE;YACnE,OAAO,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAU,SAAQ,iBAAiB;IACvC,YAAY,UAAyB,EAAE,OAA6B;QAClE,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;IAEY,WAAW,CAAC,WAAwB;;YAC/C,IAAI,MAAM,GAAyB,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YACnF,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;YAEpC,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;YAE1B,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport {\n RequestPolicy,\n RequestPolicyOptions,\n BaseRequestPolicy,\n HttpOperationResponse,\n WebResource\n} from \"@azure/core-http\";\nimport { LROOperationResponse, LROSYM } from \"./models\";\nimport { getLROData } from \"./requestUtils\";\n\nexport function lroPolicy() {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new LROPolicy(nextPolicy, options);\n }\n };\n}\n\nclass LROPolicy extends BaseRequestPolicy {\n constructor(nextPolicy: RequestPolicy, options: RequestPolicyOptions) {\n super(nextPolicy, options);\n }\n\n public async sendRequest(webResource: WebResource): Promise<HttpOperationResponse> {\n let result: LROOperationResponse = await this._nextPolicy.sendRequest(webResource);\n const _lroData = getLROData(result);\n\n result[LROSYM] = _lroData;\n\n return result;\n }\n}\n"]}
@@ -1,74 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { Poller } from "@azure/core-lro";
9
- import { delay, RestError } from "@azure/core-http";
10
- import { LROSYM } from "./models";
11
- import { makeOperation } from "./operation";
12
- import { createBodyPollingStrategy } from "./bodyPollingStrategy";
13
- import { createAzureAsyncOperationStrategy } from "./azureAsyncOperationStrategy";
14
- import { createLocationStrategy } from "./locationStrategy";
15
- import { createPassthroughStrategy } from "./passthroughStrategy";
16
- export class LROPoller extends Poller {
17
- constructor({ initialOperationArguments, initialOperationResult, initialOperationSpec, sendOperation, finalStateVia, intervalInMs = 2000 }) {
18
- const initialOperation = {
19
- args: initialOperationArguments,
20
- spec: initialOperationSpec,
21
- result: initialOperationResult
22
- };
23
- const pollingStrategy = getPollingStrategy(initialOperation, sendOperation, finalStateVia);
24
- const state = {
25
- // Initial operation will become the last operation
26
- initialOperation,
27
- lastOperation: initialOperation,
28
- pollingStrategy,
29
- finalStateVia
30
- };
31
- const operation = makeOperation(state);
32
- super(operation);
33
- this.intervalInMs = intervalInMs;
34
- }
35
- /**
36
- * The method used by the poller to wait before attempting to update its operation.
37
- */
38
- delay() {
39
- return delay(this.intervalInMs);
40
- }
41
- }
42
- /**
43
- * This function determines which strategy to use based on the response from
44
- * the last operation executed, this last operation can be an initial operation
45
- * or a polling operation. The 3 possible strategies are described below:
46
- *
47
- * A) Azure-AsyncOperation or Operation-Location
48
- * B) Location
49
- * C) BodyPolling (provisioningState)
50
- * - This strategy is used when:
51
- * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location
52
- * - Last operation method is PUT
53
- */
54
- function getPollingStrategy(initialOperation, sendOperationFn, finalStateVia) {
55
- const lroData = initialOperation.result._response[LROSYM];
56
- if (!lroData) {
57
- const error = new RestError("Service response doesn't include the required LRO data to continue polling");
58
- error.statusCode = initialOperation.result._response.status;
59
- error.response = initialOperation.result._response;
60
- throw error;
61
- }
62
- if (lroData.azureAsyncOperation || lroData.operationLocation) {
63
- return createAzureAsyncOperationStrategy(initialOperation, sendOperationFn, finalStateVia);
64
- }
65
- if (lroData.location) {
66
- return createLocationStrategy(initialOperation, sendOperationFn);
67
- }
68
- if (["PUT", "PATCH"].includes(lroData.requestMethod || "")) {
69
- return createBodyPollingStrategy(initialOperation, sendOperationFn);
70
- }
71
- // Default strategy is just a passthrough returning the initial operation
72
- return createPassthroughStrategy(initialOperation);
73
- }
74
- //# sourceMappingURL=lroPoller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lroPoller.js","sourceRoot":"","sources":["../../../src/lro/lroPoller.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAqC,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAkE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,iCAAiC,EAAE,MAAM,+BAA+B,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAkClE,MAAM,OAAO,SAAsC,SAAQ,MAG1D;IAGC,YAAY,EACV,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,YAAY,GAAG,IAAI,EACO;QAC1B,MAAM,gBAAgB,GAAG;YACvB,IAAI,EAAE,yBAAyB;YAC/B,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,sBAAsB;SAC/B,CAAC;QAEF,MAAM,eAAe,GAAG,kBAAkB,CAAC,gBAAgB,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;QAE3F,MAAM,KAAK,GAA+B;YACxC,mDAAmD;YACnD,gBAAgB;YAChB,aAAa,EAA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) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { Poller } from \"@azure/core-lro\";\nimport { OperationSpec, OperationArguments, delay, RestError } from \"@azure/core-http\";\nimport { BaseResult, LROOperationState, LROOperationStep, FinalStateVia, LROSYM } from \"./models\";\nimport { makeOperation } from \"./operation\";\nimport { createBodyPollingStrategy } from \"./bodyPollingStrategy\";\nimport { createAzureAsyncOperationStrategy } from \"./azureAsyncOperationStrategy\";\nimport { createLocationStrategy } from \"./locationStrategy\";\nimport { createPassthroughStrategy } from \"./passthroughStrategy\";\n\nexport type SendOperationFn<TResult extends BaseResult> = (\n args: OperationArguments,\n spec: OperationSpec\n) => Promise<TResult>;\n\nexport interface LROPollerOptions<TResult extends BaseResult> {\n /**\n * Defines how much time the poller is going to wait before making a new request to the service.\n */\n intervalInMs?: number;\n /**\n * Arguments used to send the initial operation\n */\n initialOperationArguments: OperationArguments;\n /**\n * Operation spec provided for the initial operation\n */\n initialOperationSpec: OperationSpec;\n /**\n * Result from the initial operation\n */\n initialOperationResult: TResult;\n /**\n * Function to execute an operation based on an operation spec and arguments\n */\n sendOperation: SendOperationFn<TResult>;\n /**\n * Optional information on where to poll. When not defined it defaults to \"Location\"\n */\n finalStateVia?: FinalStateVia;\n}\n\nexport class LROPoller<TResult extends BaseResult> extends Poller<\n LROOperationState<TResult>,\n TResult\n> {\n private intervalInMs: number;\n\n constructor({\n initialOperationArguments,\n initialOperationResult,\n initialOperationSpec,\n sendOperation,\n finalStateVia,\n intervalInMs = 2000\n }: LROPollerOptions<TResult>) {\n const initialOperation = {\n args: initialOperationArguments,\n spec: initialOperationSpec,\n result: initialOperationResult\n };\n\n const pollingStrategy = getPollingStrategy(initialOperation, sendOperation, finalStateVia);\n\n const state: LROOperationState<TResult> = {\n // Initial operation will become the last operation\n initialOperation,\n lastOperation: initialOperation,\n pollingStrategy,\n finalStateVia\n };\n\n const operation = makeOperation(state);\n super(operation);\n\n this.intervalInMs = intervalInMs;\n }\n\n /**\n * The method used by the poller to wait before attempting to update its operation.\n */\n delay(): Promise<void> {\n return delay(this.intervalInMs);\n }\n}\n\n/**\n * This function determines which strategy to use based on the response from\n * the last operation executed, this last operation can be an initial operation\n * or a polling operation. The 3 possible strategies are described below:\n *\n * A) Azure-AsyncOperation or Operation-Location\n * B) Location\n * C) BodyPolling (provisioningState)\n * - This strategy is used when:\n * - Response doesn't contain any of the following headers Location, Azure-AsyncOperation or Operation-Location\n * - Last operation method is PUT\n */\nfunction getPollingStrategy<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>,\n sendOperationFn: SendOperationFn<TResult>,\n finalStateVia?: FinalStateVia\n) {\n const lroData = initialOperation.result._response[LROSYM];\n\n if (!lroData) {\n const error = new RestError(\n \"Service response doesn't include the required LRO data to continue polling\"\n );\n error.statusCode = initialOperation.result._response.status;\n error.response = initialOperation.result._response;\n throw error;\n }\n\n if (lroData.azureAsyncOperation || lroData.operationLocation) {\n return createAzureAsyncOperationStrategy(initialOperation, sendOperationFn, finalStateVia);\n }\n\n if (lroData.location) {\n return createLocationStrategy(initialOperation, sendOperationFn);\n }\n\n if ([\"PUT\", \"PATCH\"].includes(lroData.requestMethod || \"\")) {\n return createBodyPollingStrategy(initialOperation, sendOperationFn);\n }\n\n // Default strategy is just a passthrough returning the initial operation\n return createPassthroughStrategy(initialOperation);\n}\n"]}
@@ -1,9 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- export const LROSYM = Symbol("LROData");
9
- //# sourceMappingURL=models.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/lro/models.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport {\n OperationArguments,\n OperationSpec,\n RestResponse,\n HttpMethods,\n HttpOperationResponse\n} from \"@azure/core-http\";\nimport { PollOperationState, PollOperation } from \"@azure/core-lro\";\nexport const LROSYM = Symbol(\"LROData\");\n\nexport type FinalStateVia = \"azure-async-operation\" | \"location\" | \"original-uri\";\n\nexport interface LROResponseInfo {\n requestMethod: HttpMethods;\n statusCode: number;\n isInitialRequest?: boolean;\n azureAsyncOperation?: string;\n operationLocation?: string;\n location?: string;\n provisioningState?: string;\n status?: string;\n}\n\n/**\n * Extended operation response for LROs\n */\nexport type LROOperationResponse = HttpOperationResponse & {\n /**\n * Symbol that contains LRO details\n */\n [LROSYM]?: LROResponseInfo;\n};\n\nexport interface BaseResult extends RestResponse {\n /**\n * The underlying HTTP response containing both raw and deserialized response data.\n */\n _response: LROOperationResponse;\n}\n\nexport interface LROOperationStep<TResult extends BaseResult> {\n args: OperationArguments;\n spec: OperationSpec;\n result: TResult;\n}\n\nexport interface LROOperationState<TResult extends BaseResult> extends PollOperationState<TResult> {\n lastOperation: LROOperationStep<TResult>;\n initialOperation: LROOperationStep<TResult>;\n pollingStrategy: LROStrategy<TResult>;\n finalStateVia?: FinalStateVia;\n}\n\nexport interface LROStrategy<TResult extends BaseResult> {\n isTerminal: () => boolean;\n sendFinalRequest: () => Promise<LROOperationStep<TResult>>;\n poll: () => Promise<LROOperationStep<TResult>>;\n}\n\nexport type LROOperation<TResult extends BaseResult> = PollOperation<\n LROOperationState<TResult>,\n TResult\n>;\n"]}
@@ -1,72 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter } from "tslib";
9
- import { LROSYM } from "./models";
10
- /**
11
- * Creates a copy of the operation from a given State
12
- */
13
- export function makeOperation(state) {
14
- return {
15
- state: Object.assign({}, state),
16
- update,
17
- cancel,
18
- toString: function () {
19
- return JSON.stringify(this.state);
20
- }
21
- };
22
- }
23
- /**
24
- * General update function for LROPoller, the general process is as follows
25
- * 1. Check initial operation result to determine the strategy to use
26
- * - Strategies: Location, Azure-AsyncOperation, Original Uri
27
- * 2. Check if the operation result has a terminal state
28
- * - Terminal state will be determined by each strategy
29
- * 2.1 If it is terminal state Check if a final GET request is required, if so
30
- * send final GET request and return result from operation. If no final GET
31
- * is required, just return the result from operation.
32
- * - Determining what to call for final request is responsibility of each strategy
33
- * 2.2 If it is not terminal state, call the polling operation call it and go to step 1
34
- * - Determining what to call for polling is responsibility of each strategy
35
- * - Strategies will always use the latest URI for polling if provided otherwise
36
- * the last known one
37
- */
38
- function update() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const state = Object.assign({}, this.state);
41
- const { sendFinalRequest, poll, isTerminal } = state.pollingStrategy;
42
- const currentResponse = state.lastOperation;
43
- const currentLroData = currentResponse.result._response[LROSYM];
44
- if (!currentLroData) {
45
- throw new Error("Expected lroData to be defined for updating LRO operation");
46
- }
47
- if (state.result) {
48
- state.isCompleted = true;
49
- return makeOperation(state);
50
- }
51
- // Check if last result is terminal
52
- if (isTerminal()) {
53
- state.lastOperation = yield sendFinalRequest();
54
- state.result = state.lastOperation.result;
55
- }
56
- else {
57
- state.lastOperation = yield poll();
58
- }
59
- // Return operation
60
- return makeOperation(state);
61
- });
62
- }
63
- /**
64
- * Swagger doesn't support defining a cancel operation, we'll just mark
65
- * the operation state as cancelled
66
- */
67
- function cancel() {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- return makeOperation(Object.assign(Object.assign({}, this.state), { isCancelled: true }));
70
- });
71
- }
72
- //# sourceMappingURL=operation.js.map
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AAA;AAED;;;GAGG;AACH,SAAe,MAAM;;QAGnB,OAAO,aAAa,iCAAM,IAAI,CAAC,KAAK,KAAE,WAAW,EAAE,IAAI,IAAG,CAAC;IAC7D,CAAC;CAAA","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { BaseResult, LROOperationState, LROOperation, LROSYM } from \"./models\";\n\n/**\n * Creates a copy of the operation from a given State\n */\nexport function makeOperation<TResult extends BaseResult>(\n state: LROOperationState<TResult>\n): LROOperation<TResult> {\n return {\n state: { ...state },\n update,\n cancel,\n toString: function(this: LROOperation<TResult>) {\n return JSON.stringify(this.state);\n }\n };\n}\n\n/**\n * General update function for LROPoller, the general process is as follows\n * 1. Check initial operation result to determine the strategy to use\n * - Strategies: Location, Azure-AsyncOperation, Original Uri\n * 2. Check if the operation result has a terminal state\n * - Terminal state will be determined by each strategy\n * 2.1 If it is terminal state Check if a final GET request is required, if so\n * send final GET request and return result from operation. If no final GET\n * is required, just return the result from operation.\n * - Determining what to call for final request is responsibility of each strategy\n * 2.2 If it is not terminal state, call the polling operation call it and go to step 1\n * - Determining what to call for polling is responsibility of each strategy\n * - Strategies will always use the latest URI for polling if provided otherwise\n * the last known one\n */\nasync function update<TResult extends BaseResult>(\n this: LROOperation<TResult>\n): Promise<LROOperation<TResult>> {\n const state = { ...this.state };\n\n const { sendFinalRequest, poll, isTerminal } = state.pollingStrategy;\n const currentResponse = state.lastOperation;\n const currentLroData = currentResponse.result._response[LROSYM];\n\n if (!currentLroData) {\n throw new Error(\"Expected lroData to be defined for updating LRO operation\");\n }\n\n if (state.result) {\n state.isCompleted = true;\n return makeOperation(state);\n }\n\n // Check if last result is terminal\n if (isTerminal()) {\n state.lastOperation = await sendFinalRequest();\n state.result = state.lastOperation.result;\n } else {\n state.lastOperation = await poll();\n }\n\n // Return operation\n return makeOperation(state);\n}\n\n/**\n * Swagger doesn't support defining a cancel operation, we'll just mark\n * the operation state as cancelled\n */\nasync function cancel<TResult extends BaseResult>(\n this: LROOperation<TResult>\n): Promise<LROOperation<TResult>> {\n return makeOperation({ ...this.state, isCancelled: true });\n}\n"]}
@@ -1,27 +0,0 @@
1
- /*
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * Code generated by Microsoft (R) AutoRest Code Generator.
6
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
- */
8
- import { __awaiter } from "tslib";
9
- /**
10
- * Creates a polling strategy based on BodyPolling which uses the provisioning state
11
- * from the result to determine the current operation state
12
- */
13
- export function createPassthroughStrategy(initialOperation) {
14
- return {
15
- isTerminal: () => {
16
- return true;
17
- },
18
- sendFinalRequest: () => {
19
- // BodyPolling doesn't require a final get so return the lastOperation
20
- return Promise.resolve(initialOperation);
21
- },
22
- poll: () => __awaiter(this, void 0, void 0, function* () {
23
- throw new Error("Passthrough strategy should never poll");
24
- })
25
- };
26
- }
27
- //# sourceMappingURL=passthroughStrategy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passthroughStrategy.js","sourceRoot":"","sources":["../../../src/lro/passthroughStrategy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;AAIH;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,gBAA2C;IAE3C,OAAO;QACL,UAAU,EAAE,GAAG,EAAE;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACD,gBAAgB,EAAE,GAAG,EAAE;YACrB,sEAAsE;YACtE,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,EAAE,GAAS,EAAE;YACf,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC,CAAA;KACF,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * Code generated by Microsoft (R) AutoRest Code Generator.\n * Changes may cause incorrect behavior and will be lost if the code is regenerated.\n */\n\nimport { LROStrategy, BaseResult, LROOperationStep } from \"./models\";\n\n/**\n * Creates a polling strategy based on BodyPolling which uses the provisioning state\n * from the result to determine the current operation state\n */\nexport function createPassthroughStrategy<TResult extends BaseResult>(\n initialOperation: LROOperationStep<TResult>\n): LROStrategy<TResult> {\n return {\n isTerminal: () => {\n return true;\n },\n sendFinalRequest: () => {\n // BodyPolling doesn't require a final get so return the lastOperation\n return Promise.resolve(initialOperation);\n },\n poll: async () => {\n throw new Error(\"Passthrough strategy should never poll\");\n }\n };\n}\n"]}