@azure-tools/typespec-azure-core 0.59.0-dev.6 → 0.59.0-dev.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.
- package/dist/src/decorators/final-location.d.ts +10 -0
- package/dist/src/decorators/final-location.d.ts.map +1 -0
- package/dist/src/decorators/final-location.js +25 -0
- package/dist/src/decorators/final-location.js.map +1 -0
- package/dist/src/decorators/final-operation.d.ts +4 -0
- package/dist/src/decorators/final-operation.d.ts.map +1 -0
- package/dist/src/decorators/final-operation.js +15 -0
- package/dist/src/decorators/final-operation.js.map +1 -0
- package/dist/src/decorators/foundations/omit-key-properties.d.ts +3 -0
- package/dist/src/decorators/foundations/omit-key-properties.d.ts.map +1 -0
- package/dist/src/decorators/foundations/omit-key-properties.js +10 -0
- package/dist/src/decorators/foundations/omit-key-properties.js.map +1 -0
- package/dist/src/decorators/lro-error-result.d.ts +18 -0
- package/dist/src/decorators/lro-error-result.d.ts.map +1 -0
- package/dist/src/decorators/lro-error-result.js +42 -0
- package/dist/src/decorators/lro-error-result.js.map +1 -0
- package/dist/src/decorators/lro-result.d.ts +18 -0
- package/dist/src/decorators/lro-result.d.ts.map +1 -0
- package/dist/src/decorators/lro-result.js +44 -0
- package/dist/src/decorators/lro-result.js.map +1 -0
- package/dist/src/decorators/lro-status.d.ts +18 -3
- package/dist/src/decorators/lro-status.d.ts.map +1 -1
- package/dist/src/decorators/lro-status.js +39 -0
- package/dist/src/decorators/lro-status.js.map +1 -1
- package/dist/src/decorators/lro-status.test.js +1 -1
- package/dist/src/decorators/lro-status.test.js.map +1 -1
- package/dist/src/decorators/operation-link.d.ts +34 -0
- package/dist/src/decorators/operation-link.d.ts.map +1 -0
- package/dist/src/decorators/operation-link.js +44 -0
- package/dist/src/decorators/operation-link.js.map +1 -0
- package/dist/src/decorators/operation-links.test.d.ts +2 -0
- package/dist/src/decorators/operation-links.test.d.ts.map +1 -0
- package/dist/src/decorators/operation-links.test.js +171 -0
- package/dist/src/decorators/operation-links.test.js.map +1 -0
- package/dist/src/decorators/polling-location.d.ts +36 -0
- package/dist/src/decorators/polling-location.d.ts.map +1 -0
- package/dist/src/decorators/polling-location.js +103 -0
- package/dist/src/decorators/polling-location.js.map +1 -0
- package/dist/src/decorators/polling-operation-parameter.d.ts +5 -0
- package/dist/src/decorators/polling-operation-parameter.d.ts.map +1 -0
- package/dist/src/decorators/polling-operation-parameter.js +19 -0
- package/dist/src/decorators/polling-operation-parameter.js.map +1 -0
- package/dist/src/decorators/polling-operation.d.ts +4 -0
- package/dist/src/decorators/polling-operation.d.ts.map +1 -0
- package/dist/src/decorators/polling-operation.js +54 -0
- package/dist/src/decorators/polling-operation.js.map +1 -0
- package/dist/src/decorators/polling-operation.test.d.ts +2 -0
- package/dist/src/decorators/polling-operation.test.d.ts.map +1 -0
- package/dist/src/decorators/polling-operation.test.js +50 -0
- package/dist/src/decorators/polling-operation.test.js.map +1 -0
- package/dist/src/decorators/preview-version.test.js +1 -1
- package/dist/src/decorators/preview-version.test.js.map +1 -1
- package/dist/src/decorators/private/arm-resource-identifier-config.d.ts +18 -0
- package/dist/src/decorators/private/arm-resource-identifier-config.d.ts.map +1 -0
- package/dist/src/decorators/private/arm-resource-identifier-config.js +22 -0
- package/dist/src/decorators/private/arm-resource-identifier-config.js.map +1 -0
- package/dist/src/decorators/private/default-final-state-via.d.ts +3 -0
- package/dist/src/decorators/private/default-final-state-via.d.ts.map +1 -0
- package/dist/src/decorators/private/default-final-state-via.js +43 -0
- package/dist/src/decorators/private/default-final-state-via.js.map +1 -0
- package/dist/src/decorators/private/embedding-vector.d.ts +13 -0
- package/dist/src/decorators/private/embedding-vector.d.ts.map +1 -0
- package/dist/src/decorators/private/embedding-vector.js +18 -0
- package/dist/src/decorators/private/embedding-vector.js.map +1 -0
- package/dist/src/decorators/private/ensure-resource-type.d.ts +5 -0
- package/dist/src/decorators/private/ensure-resource-type.d.ts.map +1 -0
- package/dist/src/decorators/private/ensure-resource-type.js +49 -0
- package/dist/src/decorators/private/ensure-resource-type.js.map +1 -0
- package/dist/src/decorators/private/ensure-verb.d.ts +5 -0
- package/dist/src/decorators/private/ensure-verb.d.ts.map +1 -0
- package/dist/src/decorators/private/ensure-verb.js +28 -0
- package/dist/src/decorators/private/ensure-verb.js.map +1 -0
- package/dist/src/decorators/private/needs-route.d.ts +5 -0
- package/dist/src/decorators/private/needs-route.d.ts.map +1 -0
- package/dist/src/decorators/private/needs-route.js +25 -0
- package/dist/src/decorators/private/needs-route.js.map +1 -0
- package/dist/src/decorators/private/parameterized-next-link-config.d.ts +6 -0
- package/dist/src/decorators/private/parameterized-next-link-config.d.ts.map +1 -0
- package/dist/src/decorators/private/parameterized-next-link-config.js +13 -0
- package/dist/src/decorators/private/parameterized-next-link-config.js.map +1 -0
- package/dist/src/decorators/private/spread-custom-parameters.d.ts +3 -0
- package/dist/src/decorators/private/spread-custom-parameters.d.ts.map +1 -0
- package/dist/src/decorators/private/spread-custom-parameters.js +19 -0
- package/dist/src/decorators/private/spread-custom-parameters.js.map +1 -0
- package/dist/src/decorators/private/spread-custom-response-properties.d.ts +3 -0
- package/dist/src/decorators/private/spread-custom-response-properties.d.ts.map +1 -0
- package/dist/src/decorators/private/spread-custom-response-properties.js +19 -0
- package/dist/src/decorators/private/spread-custom-response-properties.js.map +1 -0
- package/dist/src/decorators/use-final-state-via.d.ts +9 -0
- package/dist/src/decorators/use-final-state-via.d.ts.map +1 -0
- package/dist/src/decorators/use-final-state-via.js +56 -0
- package/dist/src/decorators/use-final-state-via.js.map +1 -0
- package/dist/src/decorators/use-final-state-via.test.d.ts +2 -0
- package/dist/src/decorators/use-final-state-via.test.d.ts.map +1 -0
- package/dist/src/decorators/use-final-state-via.test.js +61 -0
- package/dist/src/decorators/use-final-state-via.test.js.map +1 -0
- package/dist/src/decorators.d.ts +2 -167
- package/dist/src/decorators.d.ts.map +1 -1
- package/dist/src/decorators.js +3 -727
- package/dist/src/decorators.js.map +1 -1
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +17 -2
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +6 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/lro-helpers.d.ts +3 -13
- package/dist/src/lro-helpers.d.ts.map +1 -1
- package/dist/src/lro-helpers.js +12 -21
- package/dist/src/lro-helpers.js.map +1 -1
- package/dist/src/lro-info.d.ts +5 -4
- package/dist/src/lro-info.d.ts.map +1 -1
- package/dist/src/lro-info.js +37 -14
- package/dist/src/lro-info.js.map +1 -1
- package/dist/src/rules/lro-polling-operation.js +1 -1
- package/dist/src/rules/lro-polling-operation.js.map +1 -1
- package/dist/src/rules/no-explicit-routes-resource-ops.js +1 -1
- package/dist/src/rules/no-explicit-routes-resource-ops.js.map +1 -1
- package/dist/src/state/final-state.d.ts +14 -0
- package/dist/src/state/final-state.d.ts.map +1 -0
- package/dist/src/state/final-state.js +79 -0
- package/dist/src/state/final-state.js.map +1 -0
- package/dist/src/tsp-index.js +20 -1
- package/dist/src/tsp-index.js.map +1 -1
- package/dist/src/validate.d.ts +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +2 -1
- package/dist/src/validate.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IntrinsicType, type Model, type ModelProperty } from "@typespec/compiler";
|
|
2
|
+
import type { FinalLocationDecorator } from "../../generated-defs/Azure.Core.js";
|
|
3
|
+
export declare const getFinalLocationValue: (program: import("@typespec/compiler").Program, type: ModelProperty) => IntrinsicType | Model | undefined, setFinalLocationValue: (program: import("@typespec/compiler").Program, type: ModelProperty, value: IntrinsicType | Model) => void;
|
|
4
|
+
export declare const
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if the property is marked with @finalLocation.
|
|
7
|
+
*/
|
|
8
|
+
isFinalLocation: (program: import("@typespec/compiler").Program, type: ModelProperty) => boolean, markFinalLocationProperty: (program: import("@typespec/compiler").Program, type: ModelProperty) => void;
|
|
9
|
+
export declare const $finalLocation: FinalLocationDecorator;
|
|
10
|
+
//# sourceMappingURL=final-location.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final-location.d.ts","sourceRoot":"","sources":["../../../src/decorators/final-location.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EAEnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAGjF,eAAO,MAAO,qBAAqB,6GAAE,qBAAqB,4GAGhB,CAAC;AAE3C,eAAO;AACL;;GAEG;AACH,eAAe,mFACf,yBAAyB,8EAC4C,CAAC;AAExE,eAAO,MAAM,cAAc,EAAE,sBAiB5B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isNeverType, isVoidType, } from "@typespec/compiler";
|
|
2
|
+
import { useStateMap, useStateSet } from "@typespec/compiler/utils";
|
|
3
|
+
import { AzureCoreStateKeys } from "../lib.js";
|
|
4
|
+
export const [getFinalLocationValue, setFinalLocationValue] = useStateMap(AzureCoreStateKeys.finalLocationResults);
|
|
5
|
+
export const [
|
|
6
|
+
/**
|
|
7
|
+
* Returns `true` if the property is marked with @finalLocation.
|
|
8
|
+
*/
|
|
9
|
+
isFinalLocation, markFinalLocationProperty,] = useStateSet(AzureCoreStateKeys.finalLocationResults);
|
|
10
|
+
export const $finalLocation = (context, entity, finalResult) => {
|
|
11
|
+
const { program } = context;
|
|
12
|
+
if (finalResult !== undefined && isNeverType(finalResult))
|
|
13
|
+
return;
|
|
14
|
+
markFinalLocationProperty(program, entity);
|
|
15
|
+
switch (finalResult?.kind) {
|
|
16
|
+
case "Model":
|
|
17
|
+
setFinalLocationValue(program, entity, finalResult);
|
|
18
|
+
break;
|
|
19
|
+
case "Intrinsic":
|
|
20
|
+
if (isVoidType(finalResult)) {
|
|
21
|
+
setFinalLocationValue(program, entity, finalResult);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=final-location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final-location.js","sourceRoot":"","sources":["../../../src/decorators/final-location.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,GAMX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,MAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,GAAG,WAAW,CAGvE,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM;AACX;;GAEG;AACH,eAAe,EACf,yBAAyB,EAC1B,GAAG,WAAW,CAAgB,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,cAAc,GAA2B,CACpD,OAAyB,EACzB,MAAqB,EACrB,WAAkB,EAClB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,WAAW,CAAC;QAAE,OAAO;IAClE,yBAAyB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3C,QAAQ,WAAW,EAAE,IAAI,EAAE,CAAC;QAC1B,KAAK,OAAO;YACV,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YACpD,MAAM;QACR,KAAK,WAAW;YACd,IAAI,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC5B,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YACtD,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final-operation.d.ts","sourceRoot":"","sources":["../../../src/decorators/final-operation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAIlF,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,eAAO,MAAM,eAAe,EAAE,uBAgB7B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { reportDiagnostic } from "../lib.js";
|
|
2
|
+
import { $operationLink, getOperationLink } from "./operation-link.js";
|
|
3
|
+
export const FinalOperationKey = "final";
|
|
4
|
+
export const $finalOperation = (context, entity, linkedOperation, parameters) => {
|
|
5
|
+
const { program } = context;
|
|
6
|
+
context.call($operationLink, entity, linkedOperation, FinalOperationKey, parameters);
|
|
7
|
+
const operationDetails = getOperationLink(program, entity, FinalOperationKey);
|
|
8
|
+
if (operationDetails === undefined || operationDetails.result === undefined) {
|
|
9
|
+
reportDiagnostic(context.program, {
|
|
10
|
+
code: "invalid-final-operation",
|
|
11
|
+
target: entity,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=final-operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"final-operation.js","sourceRoot":"","sources":["../../../src/decorators/final-operation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAA4B,CACtD,OAAyB,EACzB,MAAiB,EACjB,eAA0B,EAC1B,UAAiB,EACjB,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;IAErF,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9E,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5E,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE;YAChC,IAAI,EAAE,yBAAyB;YAC/B,MAAM,EAAE,MAAM;SACf,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit-key-properties.d.ts","sourceRoot":"","sources":["../../../../src/decorators/foundations/omit-key-properties.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mDAAmD,CAAC;AAEpG,eAAO,MAAM,kBAAkB,EAAE,0BAUhC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isKey } from "@typespec/compiler";
|
|
2
|
+
export const $omitKeyProperties = (context, entity) => {
|
|
3
|
+
// Delete any key properties from the model
|
|
4
|
+
for (const [key, prop] of entity.properties) {
|
|
5
|
+
if (isKey(context.program, prop)) {
|
|
6
|
+
entity.properties.delete(key);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=omit-key-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omit-key-properties.js","sourceRoot":"","sources":["../../../../src/decorators/foundations/omit-key-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqC,MAAM,oBAAoB,CAAC;AAG9E,MAAM,CAAC,MAAM,kBAAkB,GAA+B,CAC5D,OAAyB,EACzB,MAAa,EACb,EAAE;IACF,2CAA2C;IAC3C,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAC5C,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Diagnostic, type Model, type ModelProperty, type Program } from "@typespec/compiler";
|
|
2
|
+
import type { LroErrorResultDecorator } from "../../generated-defs/Azure.Core.js";
|
|
3
|
+
export declare const
|
|
4
|
+
/**
|
|
5
|
+
* Returns `true` if that property was annotated with the `@lroErrorResult` decorator.
|
|
6
|
+
*/
|
|
7
|
+
isLroErrorResultProperty: (program: Program, type: ModelProperty) => boolean, markLroErrorResultProperty: (program: Program, type: ModelProperty) => void,
|
|
8
|
+
/** {@inheritdoc LroErrorResultDecorator} */
|
|
9
|
+
$lroErrorResult: LroErrorResultDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the error result property from a StatusMonitor
|
|
12
|
+
* @param program The program to process.
|
|
13
|
+
* @param entity The StatusMonitor model to process.
|
|
14
|
+
* @param useDefault Use the default error property if no other
|
|
15
|
+
* property is marked. (defaults to true)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getLroErrorResult(program: Program, entity: Model, useDefault?: boolean): [ModelProperty | undefined, readonly Diagnostic[]];
|
|
18
|
+
//# sourceMappingURL=lro-error-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro-error-result.d.ts","sourceRoot":"","sources":["../../../src/decorators/lro-error-result.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,OAAO,EAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAIlF,eAAO;AACL;;GAEG;AACH,wBAAwB,sDACxB,0BAA0B;AAC1B,4CAA4C;AAC5C,eAAe,yBACoE,CAAC;AAEtF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,KAAK,EACb,UAAU,GAAE,OAAc,GACzB,CAAC,aAAa,GAAG,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC,CA0BpD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createDiagnosticCollector, walkPropertiesInherited, } from "@typespec/compiler";
|
|
2
|
+
import { AzureCoreStateKeys, createDiagnostic } from "../lib.js";
|
|
3
|
+
import { createMarkerDecorator } from "./utils.js";
|
|
4
|
+
export const [
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if that property was annotated with the `@lroErrorResult` decorator.
|
|
7
|
+
*/
|
|
8
|
+
isLroErrorResultProperty, markLroErrorResultProperty,
|
|
9
|
+
/** {@inheritdoc LroErrorResultDecorator} */
|
|
10
|
+
$lroErrorResult,] = createMarkerDecorator(AzureCoreStateKeys.lroErrorResult);
|
|
11
|
+
/**
|
|
12
|
+
* Gets the error result property from a StatusMonitor
|
|
13
|
+
* @param program The program to process.
|
|
14
|
+
* @param entity The StatusMonitor model to process.
|
|
15
|
+
* @param useDefault Use the default error property if no other
|
|
16
|
+
* property is marked. (defaults to true)
|
|
17
|
+
*/
|
|
18
|
+
export function getLroErrorResult(program, entity, useDefault = true) {
|
|
19
|
+
const diagnostics = createDiagnosticCollector();
|
|
20
|
+
let count = 0;
|
|
21
|
+
let resultProperty = undefined;
|
|
22
|
+
let defaultProperty = undefined;
|
|
23
|
+
for (const prop of walkPropertiesInherited(entity)) {
|
|
24
|
+
if (isLroErrorResultProperty(program, prop)) {
|
|
25
|
+
resultProperty = prop;
|
|
26
|
+
count++;
|
|
27
|
+
}
|
|
28
|
+
if (prop.name.toLowerCase() === "error")
|
|
29
|
+
defaultProperty = prop;
|
|
30
|
+
}
|
|
31
|
+
if (count > 1) {
|
|
32
|
+
diagnostics.add(createDiagnostic({
|
|
33
|
+
code: "lro-status-monitor-invalid-result-property",
|
|
34
|
+
target: entity,
|
|
35
|
+
format: { resultType: "error", decorator: "@lroErrorResult" },
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
if (resultProperty === undefined && useDefault)
|
|
39
|
+
resultProperty = defaultProperty;
|
|
40
|
+
return diagnostics.wrap(resultProperty);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=lro-error-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro-error-result.js","sourceRoot":"","sources":["../../../src/decorators/lro-error-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM;AACX;;GAEG;AACH,wBAAwB,EACxB,0BAA0B;AAC1B,4CAA4C;AAC5C,eAAe,EAChB,GAAG,qBAAqB,CAA0B,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAEtF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAgB,EAChB,MAAa,EACb,aAAsB,IAAI;IAE1B,MAAM,WAAW,GAAG,yBAAyB,EAAE,CAAC;IAChD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,cAAc,GAA8B,SAAS,CAAC;IAC1D,IAAI,eAAe,GAA8B,SAAS,CAAC;IAC3D,KAAK,MAAM,IAAI,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YAC5C,cAAc,GAAG,IAAI,CAAC;YACtB,KAAK,EAAE,CAAC;QACV,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO;YAAE,eAAe,GAAG,IAAI,CAAC;IAClE,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,WAAW,CAAC,GAAG,CACb,gBAAgB,CAAC;YACf,IAAI,EAAE,4CAA4C;YAClD,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE;SAC9D,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,KAAK,SAAS,IAAI,UAAU;QAAE,cAAc,GAAG,eAAe,CAAC;IACjF,OAAO,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Diagnostic, type Model, type ModelProperty, type Program } from "@typespec/compiler";
|
|
2
|
+
import type { LroResultDecorator } from "../../generated-defs/Azure.Core.js";
|
|
3
|
+
export declare const
|
|
4
|
+
/**
|
|
5
|
+
* Returns `true` if that property was annotated with the `@lroResult` decorator.
|
|
6
|
+
*/
|
|
7
|
+
isLroResultProperty: (program: Program, type: ModelProperty) => boolean, markLroResultProperty: (program: Program, type: ModelProperty) => void,
|
|
8
|
+
/** {@inheritdoc LroResultDecorator} */
|
|
9
|
+
$lroResult: LroResultDecorator;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the logical result property from a StatusMonitor
|
|
12
|
+
* @param program The program to process.
|
|
13
|
+
* @param entity The StatusMonitor model to process.
|
|
14
|
+
* @param useDefault Use the default result property if no other
|
|
15
|
+
* property is marked. (defaults to true)
|
|
16
|
+
*/
|
|
17
|
+
export declare function getLroResult(program: Program, entity: Model, useDefault?: boolean): [ModelProperty | undefined, readonly Diagnostic[]];
|
|
18
|
+
//# sourceMappingURL=lro-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro-result.d.ts","sourceRoot":"","sources":["../../../src/decorators/lro-result.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,OAAO,EAIb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAI7E,eAAO;AACL;;GAEG;AACH,mBAAmB,sDACnB,qBAAqB;AACrB,uCAAuC;AACvC,UAAU,oBAC+D,CAAC;AAE5E;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,KAAK,EACb,UAAU,GAAE,OAAc,GACzB,CAAC,aAAa,GAAG,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC,CA2BpD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createDiagnosticCollector, isNeverType, walkPropertiesInherited, } from "@typespec/compiler";
|
|
2
|
+
import { AzureCoreStateKeys, createDiagnostic } from "../lib.js";
|
|
3
|
+
import { createMarkerDecorator } from "./utils.js";
|
|
4
|
+
export const [
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` if that property was annotated with the `@lroResult` decorator.
|
|
7
|
+
*/
|
|
8
|
+
isLroResultProperty, markLroResultProperty,
|
|
9
|
+
/** {@inheritdoc LroResultDecorator} */
|
|
10
|
+
$lroResult,] = createMarkerDecorator(AzureCoreStateKeys.lroResult);
|
|
11
|
+
/**
|
|
12
|
+
* Gets the logical result property from a StatusMonitor
|
|
13
|
+
* @param program The program to process.
|
|
14
|
+
* @param entity The StatusMonitor model to process.
|
|
15
|
+
* @param useDefault Use the default result property if no other
|
|
16
|
+
* property is marked. (defaults to true)
|
|
17
|
+
*/
|
|
18
|
+
export function getLroResult(program, entity, useDefault = true) {
|
|
19
|
+
const diagnostics = createDiagnosticCollector();
|
|
20
|
+
let count = 0;
|
|
21
|
+
let resultProperty = undefined;
|
|
22
|
+
let defaultProperty = undefined;
|
|
23
|
+
for (const prop of walkPropertiesInherited(entity)) {
|
|
24
|
+
if (isLroResultProperty(program, prop)) {
|
|
25
|
+
resultProperty = prop;
|
|
26
|
+
count++;
|
|
27
|
+
}
|
|
28
|
+
if (prop.name.toLowerCase() === "result")
|
|
29
|
+
defaultProperty = prop;
|
|
30
|
+
}
|
|
31
|
+
if (count > 1) {
|
|
32
|
+
diagnostics.add(createDiagnostic({
|
|
33
|
+
code: "lro-status-monitor-invalid-result-property",
|
|
34
|
+
target: entity,
|
|
35
|
+
format: { resultType: "result", decorator: "@lroResult" },
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
if (resultProperty === undefined && useDefault)
|
|
39
|
+
resultProperty = defaultProperty;
|
|
40
|
+
if (resultProperty && isNeverType(resultProperty.type))
|
|
41
|
+
resultProperty = undefined;
|
|
42
|
+
return diagnostics.wrap(resultProperty);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=lro-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lro-result.js","sourceRoot":"","sources":["../../../src/decorators/lro-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,yBAAyB,EACzB,WAAW,EACX,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM;AACX;;GAEG;AACH,mBAAmB,EACnB,qBAAqB;AACrB,uCAAuC;AACvC,UAAU,EACX,GAAG,qBAAqB,CAAqB,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,OAAgB,EAChB,MAAa,EACb,aAAsB,IAAI;IAE1B,MAAM,WAAW,GAAG,yBAAyB,EAAE,CAAC;IAChD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,cAAc,GAA8B,SAAS,CAAC;IAC1D,IAAI,eAAe,GAA8B,SAAS,CAAC;IAC3D,KAAK,MAAM,IAAI,IAAI,uBAAuB,CAAC,MAAM,CAAC,EAAE,CAAC;QACnD,IAAI,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC;YACvC,cAAc,GAAG,IAAI,CAAC;YACtB,KAAK,EAAE,CAAC;QACV,CAAC;QAED,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,QAAQ;YAAE,eAAe,GAAG,IAAI,CAAC;IACnE,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,WAAW,CAAC,GAAG,CACb,gBAAgB,CAAC;YACf,IAAI,EAAE,4CAA4C;YAClD,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE;SAC1D,CAAC,CACH,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,KAAK,SAAS,IAAI,UAAU;QAAE,cAAc,GAAG,eAAe,CAAC;IACjF,IAAI,cAAc,IAAI,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC;QAAE,cAAc,GAAG,SAAS,CAAC;IACnF,OAAO,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
import { type Diagnostic, type Enum, type ModelProperty, type Program, type Type, type Union } from "@typespec/compiler";
|
|
1
|
+
import { type Diagnostic, type Enum, type Model, type ModelProperty, type Program, type Type, type Union } from "@typespec/compiler";
|
|
2
2
|
import type { LroStatusDecorator } from "../../generated-defs/Azure.Core.js";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Provides the names of terminal long-running operation states plus any
|
|
5
|
+
* additional states defined for the operation.
|
|
6
|
+
**/
|
|
7
|
+
export interface LongRunningStates {
|
|
8
|
+
succeededState: string[];
|
|
9
|
+
failedState: string[];
|
|
10
|
+
canceledState: string[];
|
|
11
|
+
states: string[];
|
|
12
|
+
}
|
|
4
13
|
declare const
|
|
5
14
|
/**
|
|
6
15
|
* Returns the `LongRunningStates` associated with `entity`.
|
|
7
16
|
*/
|
|
8
|
-
getLongRunningStates: (program: Program, type:
|
|
17
|
+
getLongRunningStates: (program: Program, type: Enum | Union | ModelProperty) => LongRunningStates | undefined;
|
|
9
18
|
export { getLongRunningStates };
|
|
10
19
|
export declare const $lroStatus: LroStatusDecorator;
|
|
20
|
+
/**
|
|
21
|
+
* Return the property that contains the lro status
|
|
22
|
+
* @param program The program to process
|
|
23
|
+
* @param target The model to check for lro status
|
|
24
|
+
*/
|
|
25
|
+
export declare function findLroStatusProperty(program: Program, target: Model): ModelProperty | undefined;
|
|
11
26
|
export declare function extractLroStates(program: Program, entity: Type): [LongRunningStates | undefined, readonly Diagnostic[]];
|
|
12
27
|
//# sourceMappingURL=lro-status.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lro-status.d.ts","sourceRoot":"","sources":["../../../src/decorators/lro-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,IAAI,EAET,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,KAAK,EAEX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"lro-status.d.ts","sourceRoot":"","sources":["../../../src/decorators/lro-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,IAAI,EAET,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,KAAK,EAEX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAO7E;;;IAGI;AACJ,MAAM,WAAW,iBAAiB;IAEhC,cAAc,EAAE,MAAM,EAAE,CAAC;IAGzB,WAAW,EAAE,MAAM,EAAE,CAAC;IAGtB,aAAa,EAAE,MAAM,EAAE,CAAC;IAGxB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,QAAA;AACE;;GAEG;AACH,oBAAoB,yFAEwE,CAAC;AAE/F,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,eAAO,MAAM,UAAU,EAAE,kBASxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,GAAG,aAAa,GAAG,SAAS,CAkChG;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,IAAI,GACX,CAAC,iBAAiB,GAAG,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC,CAuDxD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createDiagnosticCollector, } from "@typespec/compiler";
|
|
2
2
|
import { useStateMap } from "@typespec/compiler/utils";
|
|
3
3
|
import { AzureCoreStateKeys, createDiagnostic } from "../lib.js";
|
|
4
|
+
import { getAllProperties } from "../utils.js";
|
|
4
5
|
import { isLroCanceledState } from "./lro-cancelled.js";
|
|
5
6
|
import { isLroFailedState } from "./lro-failed.js";
|
|
6
7
|
import { isLroSucceededState } from "./lro-succeeded.js";
|
|
@@ -18,6 +19,44 @@ export const $lroStatus = (context, entity) => {
|
|
|
18
19
|
setLroStatus(context.program, entity, states);
|
|
19
20
|
}
|
|
20
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Return the property that contains the lro status
|
|
24
|
+
* @param program The program to process
|
|
25
|
+
* @param target The model to check for lro status
|
|
26
|
+
*/
|
|
27
|
+
export function findLroStatusProperty(program, target) {
|
|
28
|
+
function getProvisioningState(props) {
|
|
29
|
+
let innerProps = undefined;
|
|
30
|
+
let result = undefined;
|
|
31
|
+
const innerProperty = props.get("properties");
|
|
32
|
+
result = props.get("provisioningState");
|
|
33
|
+
if (result === undefined &&
|
|
34
|
+
innerProperty !== undefined &&
|
|
35
|
+
innerProperty.type?.kind === "Model") {
|
|
36
|
+
innerProps = getAllProperties(innerProperty.type);
|
|
37
|
+
result = innerProps.get("provisioningState");
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
const props = getAllProperties(target);
|
|
42
|
+
for (const [_, prop] of props.entries()) {
|
|
43
|
+
let values = getLongRunningStates(program, prop);
|
|
44
|
+
if (values !== undefined)
|
|
45
|
+
return prop;
|
|
46
|
+
if (prop.type.kind === "Enum" || prop.type.kind === "Union") {
|
|
47
|
+
values = getLongRunningStates(program, prop.type);
|
|
48
|
+
if (values !== undefined)
|
|
49
|
+
return prop;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const statusProp = props.get("status") ?? getProvisioningState(props);
|
|
53
|
+
if (statusProp) {
|
|
54
|
+
const [states, _] = extractLroStates(program, statusProp);
|
|
55
|
+
if (states !== undefined)
|
|
56
|
+
return statusProp;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
21
60
|
export function extractLroStates(program, entity) {
|
|
22
61
|
const result = {
|
|
23
62
|
states: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lro-status.js","sourceRoot":"","sources":["../../../src/decorators/lro-status.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,
|
|
1
|
+
{"version":3,"file":"lro-status.js","sourceRoot":"","sources":["../../../src/decorators/lro-status.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAY1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,C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,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;oBAC7C,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;gBAC9D,CAAC;YACH,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACnC,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,CAAC;YAC1E,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAChE,4CAA4C;gBAC5C,SAAS;YACX,CAAC;iBAAM,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACpC,WAAW,CAAC,GAAG,CACb,gBAAgB,CAAC;oBACf,IAAI,EAAE,6BAA6B;oBACnC,MAAM,EAAE,MAAM;oBACd,MAAM,EAAE;wBACN,IAAI,EAAE,MAAM,CAAC,IAAI;qBAClB;iBACF,CAAC,CACH,CAAC;gBAEF,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACrC,CAAC;iBAAM,CAAC;gBACN,aAAa,CACX,OAAO,EACP,cAAc,EACd,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAC9D,OAAO,CACR,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO;AACT,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Tester } from "#test/test-host.js";
|
|
1
2
|
import { expectDiagnostics, t } from "@typespec/compiler/testing";
|
|
2
3
|
import { deepStrictEqual } from "assert";
|
|
3
4
|
import { it } from "vitest";
|
|
4
|
-
import { Tester } from "../../test/test-host.js";
|
|
5
5
|
import { getLongRunningStates } from "./lro-status.js";
|
|
6
6
|
it("emits diagnostic if used on wrong type", async () => {
|
|
7
7
|
const diagnostics = await Tester.diagnose(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lro-status.test.js","sourceRoot":"","sources":["../../../src/decorators/lro-status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"lro-status.test.js","sourceRoot":"","sources":["../../../src/decorators/lro-status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,CAAC,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;IACtD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;GAMzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,EAAE;QAC7B;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACL,qGAAqG;SACxG;QACD;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACL,qGAAqG;SACxG;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;IACrE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC;;;;;;;;GAQzC,CAAC,CAAC;IAEH,iBAAiB,CAAC,WAAW,EAAE;QAC7B;YACE,IAAI,EAAE,mEAAmE;YACzE,OAAO,EAAE,sDAAsD;SAChE;QACD;YACE,IAAI,EAAE,8DAA8D;YACpE,OAAO,EAAE,8CAA8C;SACxD;QACD;YACE,IAAI,EAAE,qDAAqD;YAC3D,OAAO,EAAE,6DAA6D;SAC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EAAE,UAAU,EAAE,OAAO,CAAC;KACrD,CAAC,CAAC;IAEH,eAAe,CAAC,oBAAoB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE;QAC9D,cAAc,EAAE,CAAC,QAAQ,CAAC;QAC1B,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,aAAa,EAAE,CAAC,SAAS,CAAC;QAC1B,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC;KACvD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;IAC7D,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;;YAEvD,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;;;;;;GAMpC,CAAC,CAAC;IAEH,eAAe,CAAC,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE;QAC/D,cAAc,EAAE,CAAC,WAAW,CAAC;QAC7B,WAAW,EAAE,CAAC,QAAQ,CAAC;QACvB,aAAa,EAAE,CAAC,UAAU,CAAC;QAC3B,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC;KACrD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ModelProperty, Operation, Program, Type } from "@typespec/compiler";
|
|
2
|
+
import type { OperationLinkDecorator } from "../../generated-defs/Azure.Core.js";
|
|
3
|
+
import { type PropertyMap, type ResultInfo } from "../lro-info.js";
|
|
4
|
+
/**
|
|
5
|
+
* Custom polling
|
|
6
|
+
* Represents a property or header that provides a Uri linking to another operation
|
|
7
|
+
*/
|
|
8
|
+
export interface OperationLink {
|
|
9
|
+
kind: "link";
|
|
10
|
+
/** Indicates whether the link is in the response header or response body */
|
|
11
|
+
location: "ResponseHeader" | "ResponseBody" | "Self";
|
|
12
|
+
/** The property that contains the link */
|
|
13
|
+
property: ModelProperty;
|
|
14
|
+
}
|
|
15
|
+
export interface OperationLinkMetadata {
|
|
16
|
+
parameters?: Type;
|
|
17
|
+
linkedOperation: Operation;
|
|
18
|
+
linkType: string;
|
|
19
|
+
link?: OperationLink;
|
|
20
|
+
parameterMap?: Map<string, PropertyMap>;
|
|
21
|
+
result?: ResultInfo;
|
|
22
|
+
}
|
|
23
|
+
declare const
|
|
24
|
+
/**
|
|
25
|
+
* Returns the collection of `OperationLinkMetadata` for a given operation, if any, or undefined.
|
|
26
|
+
*/
|
|
27
|
+
getOperationLinks: (program: Program, type: Operation) => Map<string, OperationLinkMetadata> | undefined;
|
|
28
|
+
export { getOperationLinks };
|
|
29
|
+
export declare const $operationLink: OperationLinkDecorator;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the `OperationLinkMetadata` for a given operation and link type, or undefined.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getOperationLink(program: Program, entity: Operation, linkType: string): OperationLinkMetadata | undefined;
|
|
34
|
+
//# sourceMappingURL=operation-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-link.d.ts","sourceRoot":"","sources":["../../../src/decorators/operation-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEpG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAExF;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,QAAQ,EAAE,gBAAgB,GAAG,cAAc,GAAG,MAAM,CAAC;IACrD,0CAA0C;IAC1C,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,eAAe,EAAE,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACxC,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,QAAA;AACE;;GAEG;AACH,iBAAiB,uFAE6E,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,eAAO,MAAM,cAAc,EAAE,sBAoC5B,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,GACf,qBAAqB,GAAG,SAAS,CAMnC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useStateMap } from "@typespec/compiler/utils";
|
|
2
|
+
import { AzureCoreStateKeys } from "../lib.js";
|
|
3
|
+
import { getLroOperationInfo } from "../lro-info.js";
|
|
4
|
+
const [
|
|
5
|
+
/**
|
|
6
|
+
* Returns the collection of `OperationLinkMetadata` for a given operation, if any, or undefined.
|
|
7
|
+
*/
|
|
8
|
+
getOperationLinks, setOperationLinks,] = useStateMap(AzureCoreStateKeys.operationLink);
|
|
9
|
+
export { getOperationLinks };
|
|
10
|
+
export const $operationLink = (context, entity, linkedOperation, linkType, parameters) => {
|
|
11
|
+
if (parameters && parameters.kind !== "Model") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const { program } = context;
|
|
15
|
+
const [operationInfo, diagnostics] = getLroOperationInfo(program, entity, linkedOperation, linkType, parameters);
|
|
16
|
+
if (diagnostics.length > 0) {
|
|
17
|
+
program.reportDiagnostics(diagnostics);
|
|
18
|
+
}
|
|
19
|
+
// An operation may have many operationLinks, so treat them as a collection
|
|
20
|
+
let items = getOperationLinks(program, entity);
|
|
21
|
+
if (items === undefined) {
|
|
22
|
+
items = new Map();
|
|
23
|
+
}
|
|
24
|
+
items.set(linkType, {
|
|
25
|
+
parameters: parameters,
|
|
26
|
+
linkedOperation: linkedOperation,
|
|
27
|
+
linkType: linkType,
|
|
28
|
+
link: operationInfo?.getOperationLink(),
|
|
29
|
+
parameterMap: operationInfo?.getInvocationInfo()?.parameterMap,
|
|
30
|
+
result: operationInfo?.getResultInfo(),
|
|
31
|
+
});
|
|
32
|
+
setOperationLinks(context.program, entity, items);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Returns the `OperationLinkMetadata` for a given operation and link type, or undefined.
|
|
36
|
+
*/
|
|
37
|
+
export function getOperationLink(program, entity, linkType) {
|
|
38
|
+
const items = getOperationLinks(program, entity);
|
|
39
|
+
if (items !== undefined) {
|
|
40
|
+
return items.get(linkType);
|
|
41
|
+
}
|
|
42
|
+
return items;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=operation-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-link.js","sourceRoot":"","sources":["../../../src/decorators/operation-link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAqC,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAwBxF,MAAM;AACJ;;GAEG;AACH,iBAAiB,EACjB,iBAAiB,EAClB,GAAG,WAAW,CAAgD,kBAAkB,CAAC,aAAa,CAAC,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAE7B,MAAM,CAAC,MAAM,cAAc,GAA2B,CACpD,OAAyB,EACzB,MAAiB,EACjB,eAA0B,EAC1B,QAAgB,EAChB,UAAiB,EACjB,EAAE;IACF,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE,CA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Root":"","sources":["../../../src/decorators/operation-links.test.ts"],"names":[],"mappings":""}
|