@azure-tools/typespec-azure-resource-manager 0.31.0-dev.3 → 0.31.0-dev.5
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/namespace.d.ts +2 -2
- package/dist/src/namespace.d.ts.map +1 -1
- package/dist/src/namespace.js +1 -4
- package/dist/src/namespace.js.map +1 -1
- package/dist/src/operations.d.ts +9 -9
- package/dist/src/operations.d.ts.map +1 -1
- package/dist/src/operations.js +1 -39
- package/dist/src/operations.js.map +1 -1
- package/dist/src/private.decorators.d.ts +64 -0
- package/dist/src/private.decorators.d.ts.map +1 -0
- package/dist/src/private.decorators.js +274 -0
- package/dist/src/private.decorators.js.map +1 -0
- package/dist/src/resource.d.ts +11 -27
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/resource.js +6 -197
- package/dist/src/resource.js.map +1 -1
- package/dist/src/rules/core-operations.js +1 -1
- package/dist/src/rules/core-operations.js.map +1 -1
- package/dist/src/rules/operations-interface-missing.js +1 -1
- package/dist/src/rules/operations-interface-missing.js.map +1 -1
- package/lib/arm.foundations.tsp +1 -0
- package/lib/arm.tsp +1 -1
- package/lib/decorators.tsp +57 -1
- package/lib/interfaces.tsp +3 -2
- package/lib/models.tsp +5 -4
- package/lib/operations.tsp +2 -2
- package/lib/parameters.tsp +1 -0
- package/lib/private.decorators.tsp +70 -0
- package/lib/responses.tsp +1 -0
- package/package.json +1 -1
- package/dist/src/internal.d.ts +0 -44
- package/dist/src/internal.d.ts.map +0 -1
- package/dist/src/internal.js +0 -133
- package/dist/src/internal.js.map +0 -1
package/dist/src/namespace.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { DecoratorContext, Model, Namespace, Program
|
|
1
|
+
import { DecoratorContext, Model, Namespace, Program } from "@typespec/compiler";
|
|
2
2
|
/**
|
|
3
3
|
* `@armProviderNamespace` sets the ARM provider namespace.
|
|
4
4
|
* @param {DecoratorContext} context DecoratorContext object
|
|
5
5
|
* @param {type} entity Target of the decorator. Must be `namespace` type
|
|
6
6
|
* @param {string} armProviderNamespace Provider namespace
|
|
7
7
|
*/
|
|
8
|
-
export declare function $armProviderNamespace(context: DecoratorContext, entity:
|
|
8
|
+
export declare function $armProviderNamespace(context: DecoratorContext, entity: Namespace, armProviderNamespace?: string): void;
|
|
9
9
|
/**
|
|
10
10
|
* Get the ARM provider namespace for a given entity
|
|
11
11
|
* @param {Program} program
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAEhB,KAAK,EAEL,SAAS,EAET,OAAO,
|
|
1
|
+
{"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAEhB,KAAK,EAEL,SAAS,EAET,OAAO,EACR,MAAM,oBAAoB,CAAC;AAS5B;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,oBAAoB,CAAC,EAAE,MAAM,QAmF9B;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,GAAG,KAAK,GACxB,MAAM,GAAG,SAAS,CAepB"}
|
package/dist/src/namespace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __unsupported_enable_checkStandardOperations } from "@azure-tools/typespec-azure-core";
|
|
2
|
-
import { addService, getNamespaceFullName,
|
|
2
|
+
import { addService, getNamespaceFullName, } from "@typespec/compiler";
|
|
3
3
|
import * as http from "@typespec/http";
|
|
4
4
|
import { getAuthentication, setAuthentication, setRouteOptionsForNamespace } from "@typespec/http";
|
|
5
5
|
import { getResourceTypeForKeyParam } from "@typespec/rest";
|
|
@@ -14,9 +14,6 @@ const armProviderNamespacesKey = createStateSymbol("armProviderNamespaces");
|
|
|
14
14
|
*/
|
|
15
15
|
export function $armProviderNamespace(context, entity, armProviderNamespace) {
|
|
16
16
|
const { program } = context;
|
|
17
|
-
if (!validateDecoratorTarget(context, entity, "@armProviderNamespace", "Namespace")) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
17
|
if (program.stateMap(armProviderNamespacesKey).size > 0) {
|
|
21
18
|
reportDiagnostic(program, {
|
|
22
19
|
code: "single-arm-provider",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4CAA4C,EAAE,MAAM,kCAAkC,CAAC;AAChG,OAAO,EACL,UAAU,EAEV,oBAAoB,
|
|
1
|
+
{"version":3,"file":"namespace.js","sourceRoot":"","sources":["../../src/namespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4CAA4C,EAAE,MAAM,kCAAkC,CAAC;AAChG,OAAO,EACL,UAAU,EAEV,oBAAoB,GAMrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAyB,EACzB,MAAiB,EACjB,oBAA6B;IAE7B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,IAAI,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC,IAAI,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MAAM,EAAE;QAC3C,gBAAgB,EAAE;YAChB,mEAAmE;YACnE,sBAAsB;YACtB,gBAAgB,EAAE,CAAC,SAAoB,EAAE,KAAoB,EAAE,EAAE;gBAC/D,MAAM,iBAAiB,GAAG,0BAA0B,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACrE,IAAI,iBAAiB,EAAE;oBACrB,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;oBACzE,IAAI,YAAY,EAAE;wBAChB,OAAO;4BACL,gBAAgB,EAAE,YAAY;4BAC9B,0BAA0B,EAAE,IAAI;yBACjC,CAAC;qBACH;iBACF;gBAED,sDAAsD;gBACtD,OAAO,SAAS,CAAC;YACnB,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAgB,EAChB,MAAyB;IAEzB,IAAI,gBAAgB,GAClB,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;IAE1D,IAAI,oBAAwC,CAAC;IAC7C,OAAO,gBAAgB,EAAE;QACvB,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACxF,IAAI,oBAAoB,EAAE;YACxB,OAAO,oBAAoB,CAAC;SAC7B;QAED,gBAAgB,GAAG,gBAAgB,CAAC,SAAS,CAAC;KAC/C;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/src/operations.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecoratorContext, Model, Operation, Program
|
|
1
|
+
import { DecoratorContext, Model, Operation, Program } from "@typespec/compiler";
|
|
2
2
|
import { HttpOperation } from "@typespec/http";
|
|
3
3
|
export type ArmLifecycleOperationKind = "read" | "createOrUpdate" | "update" | "delete";
|
|
4
4
|
export type ArmOperationKind = ArmLifecycleOperationKind | "list" | "action";
|
|
@@ -28,14 +28,14 @@ interface ArmResourceOperationData {
|
|
|
28
28
|
operationGroup: string;
|
|
29
29
|
}
|
|
30
30
|
export declare function resolveResourceOperations(program: Program, resourceType: Model): ArmResourceOperations;
|
|
31
|
-
export declare function $armResourceRead(context: DecoratorContext, target:
|
|
32
|
-
export declare function $armResourceCreateOrUpdate(context: DecoratorContext, target:
|
|
33
|
-
export declare function $armResourceUpdate(context: DecoratorContext, target:
|
|
34
|
-
export declare function $armResourceDelete(context: DecoratorContext, target:
|
|
35
|
-
export declare function $armResourceList(context: DecoratorContext, target:
|
|
36
|
-
export declare function $armRenameListByOperation(context: DecoratorContext, entity:
|
|
37
|
-
export declare function $armResourceAction(context: DecoratorContext, target:
|
|
38
|
-
export declare function $armResourceCollectionAction(context: DecoratorContext, target:
|
|
31
|
+
export declare function $armResourceRead(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
32
|
+
export declare function $armResourceCreateOrUpdate(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
33
|
+
export declare function $armResourceUpdate(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
34
|
+
export declare function $armResourceDelete(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
35
|
+
export declare function $armResourceList(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
36
|
+
export declare function $armRenameListByOperation(context: DecoratorContext, entity: Operation, resourceType: Model, parentTypeName?: string, parentFriendlyTypeName?: string): void;
|
|
37
|
+
export declare function $armResourceAction(context: DecoratorContext, target: Operation, resourceType: Model): void;
|
|
38
|
+
export declare function $armResourceCollectionAction(context: DecoratorContext, target: Operation): void;
|
|
39
39
|
export declare function isArmCollectionAction(program: Program, target: Operation): boolean;
|
|
40
40
|
export {};
|
|
41
41
|
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEhB,KAAK,EACL,SAAS,EACT,OAAO,
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAEhB,KAAK,EACL,SAAS,EACT,OAAO,EACR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAKjE,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxF,MAAM,MAAM,gBAAgB,GAAG,yBAAyB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7E,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,sBAAsB,CAAC;IAClC,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE,CAAC;IAC/C,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE,CAAC;CAClD;AAED,UAAU,wBAAwB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AA+CD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,KAAK,GAClB,qBAAqB,CAYvB;AA2BD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QAGpB;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QASpB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QAGpB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QAGpB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QAkBpB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,sBAAsB,CAAC,EAAE,MAAM,QAyChC;AAkBD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,KAAK,QA0BpB;AASD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,QAExF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAElF"}
|
package/dist/src/operations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $doc, ignoreDiagnostics,
|
|
1
|
+
import { $doc, ignoreDiagnostics, } from "@typespec/compiler";
|
|
2
2
|
import { getHttpOperation } from "@typespec/http";
|
|
3
3
|
import { $actionSegment, getActionSegment, getParentResource, getSegment } from "@typespec/rest";
|
|
4
4
|
import { createStateSymbol, reportDiagnostic } from "./lib.js";
|
|
@@ -35,15 +35,6 @@ export function resolveResourceOperations(program, resourceType) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
function setResourceLifecycleOperation(context, target, resourceType, kind, decoratorName) {
|
|
38
|
-
// If the properties type is a template parameter, this must be a templated type
|
|
39
|
-
if (resourceType.kind === "TemplateParameter") {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (!validateDecoratorTarget(context, target, decoratorName, "Operation") ||
|
|
43
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
44
|
-
!validateDecoratorParamType(context.program, target, resourceType, "Model")) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
38
|
// Only register methods from non-templated interface types
|
|
48
39
|
if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
|
|
49
40
|
return;
|
|
@@ -72,15 +63,6 @@ export function $armResourceDelete(context, target, resourceType) {
|
|
|
72
63
|
setResourceLifecycleOperation(context, target, resourceType, "delete", "@armResourceDelete");
|
|
73
64
|
}
|
|
74
65
|
export function $armResourceList(context, target, resourceType) {
|
|
75
|
-
// If the properties type is a template parameter, this must be a templated type
|
|
76
|
-
if (resourceType.kind === "TemplateParameter") {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (!validateDecoratorTarget(context, target, "@armResourceList", "Operation") ||
|
|
80
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
81
|
-
!validateDecoratorParamType(context.program, target, resourceType, "Model")) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
66
|
// Only register methods from non-templated interface types
|
|
85
67
|
if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
|
|
86
68
|
return;
|
|
@@ -98,15 +80,6 @@ export function $armResourceList(context, target, resourceType) {
|
|
|
98
80
|
}
|
|
99
81
|
export function $armRenameListByOperation(context, entity, resourceType, parentTypeName, parentFriendlyTypeName) {
|
|
100
82
|
const { program } = context;
|
|
101
|
-
if (resourceType.kind === "TemplateParameter") {
|
|
102
|
-
// Don't execute when this decorator is being applied within a templated interface
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (!validateDecoratorTarget(context, entity, "@armRenameListByOperation", "Operation") ||
|
|
106
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
107
|
-
!validateDecoratorParamType(program, entity, resourceType, "Model")) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
83
|
if (parentTypeName === undefined ||
|
|
111
84
|
parentTypeName === "" ||
|
|
112
85
|
parentFriendlyTypeName === undefined ||
|
|
@@ -151,15 +124,6 @@ function getArmParentName(program, resource) {
|
|
|
151
124
|
export function $armResourceAction(context, target, resourceType) {
|
|
152
125
|
var _a;
|
|
153
126
|
const { program } = context;
|
|
154
|
-
// If the properties type is a template parameter, this must be a templated type
|
|
155
|
-
if (resourceType.kind === "TemplateParameter") {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (!validateDecoratorTarget(context, target, "@armResourceAction", "Operation") ||
|
|
159
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
160
|
-
!validateDecoratorParamType(program, target, resourceType, "Model")) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
127
|
// Only register methods from non-templated interface types
|
|
164
128
|
if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
|
|
165
129
|
return;
|
|
@@ -187,8 +151,6 @@ function uncapitalize(name) {
|
|
|
187
151
|
return name[0].toLowerCase() + name.substring(1);
|
|
188
152
|
}
|
|
189
153
|
export function $armResourceCollectionAction(context, target) {
|
|
190
|
-
if (!validateDecoratorTarget(context, target, "@armResourceCollectionAction", "Operation"))
|
|
191
|
-
return;
|
|
192
154
|
context.program.stateMap(armResourceCollectionActionKey).set(target, true);
|
|
193
155
|
}
|
|
194
156
|
export function isArmCollectionAction(program, target) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,iBAAiB,
|
|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,mCAAI,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACjF,IAAI,CAAC,OAAO,EAAE;QACZ,2DAA2D;QAC3D,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;KACjE;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,IAAI,IAAI,KAAK,EAAE,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,OAAyB,EAAE,MAAiB;IACvF,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB,EAAE,MAAiB;IACvE,OAAO,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { DecoratorContext, Interface, Model, ModelProperty, Operation, Program, Tuple } from "@typespec/compiler";
|
|
2
|
+
import { ArmResourceDetails } from "./resource.js";
|
|
3
|
+
export declare const namespace = "Azure.ResourceManager.Private";
|
|
4
|
+
export declare function $omitIfEmpty(context: DecoratorContext, entity: Model, propertyName: string): void;
|
|
5
|
+
export declare function $resourceBaseParametersOf(context: DecoratorContext, entity: Model, resourceType: Model): void;
|
|
6
|
+
export declare function $resourceParameterBaseFor(context: DecoratorContext, entity: ModelProperty, values: Tuple): void;
|
|
7
|
+
export declare function getResourceParameterBases(program: Program, property: ModelProperty): string[] | undefined;
|
|
8
|
+
export declare function isResourceParameterBaseFor(program: Program, property: ModelProperty, resourceBaseType: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Refer an model property to be a common ARM parameter
|
|
11
|
+
* @param {DecoratorContext} context DecoratorContext object
|
|
12
|
+
* @param {Type} entity Decorator target type. Must be `Model`
|
|
13
|
+
* @param {string?} definitionName Optional definition name
|
|
14
|
+
* @param {string?} version Optional version
|
|
15
|
+
* @param {string?} referenceFile Optional common file path
|
|
16
|
+
* @returns void
|
|
17
|
+
*/
|
|
18
|
+
export declare function $armCommonParameter(context: DecoratorContext, entity: ModelProperty, parameterName?: string, version?: string, referenceFile?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Using ARM common definition for a Model
|
|
21
|
+
* @param {DecoratorContext} context DecoratorContext object
|
|
22
|
+
* @param {Type} entity Decorator target type. Must be `Model`
|
|
23
|
+
* @param {string?} definitionName Optional definition name
|
|
24
|
+
* @param {string?} version Optional version
|
|
25
|
+
* @param {string?} referenceFile Optional common file path
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
export declare function $armCommonDefinition(context: DecoratorContext, entity: Model, definitionName?: string, version?: string, referenceFile?: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* This decorator dynamically assigns the serviceNamespace from the containing
|
|
31
|
+
* namespace to the string literal value of the path parameter to which this
|
|
32
|
+
* decorator is applied. Its purpose is to dynamically insert the provider
|
|
33
|
+
* namespace (e.g. 'Microsoft.CodeSigning') into the path parameter list.
|
|
34
|
+
* @param {DecoratorContext} context DecoratorContext
|
|
35
|
+
* @param {Type} target Target of this decorator. Must be a string `ModelProperty`.
|
|
36
|
+
* @param {Type} resourceType Must be a `Model`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function $assignProviderNameValue(context: DecoratorContext, target: ModelProperty, resourceType: Model): void;
|
|
39
|
+
/**
|
|
40
|
+
* Update the ARM provider namespace for a given entity.
|
|
41
|
+
* @param {DecoratorContext} context DecoratorContext
|
|
42
|
+
* @param {Type} entity Entity to set namespace. Must be a `Operation`.
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
export declare function $armUpdateProviderNamespace(context: DecoratorContext, entity: Operation): void;
|
|
46
|
+
/**
|
|
47
|
+
* Check if an interface is extending the Azure.ResourceManager.Operations interface.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isArmOperationsListInterface(program: Program, type: Interface): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* This decorator is used to identify ARM resource types and extract their
|
|
52
|
+
* metadata. It is *not* meant to be used directly by a spec author, it instead
|
|
53
|
+
* gets implicitly applied when the spec author defines a model type in this form:
|
|
54
|
+
*
|
|
55
|
+
* `model Server is TrackedResource<ServerProperties>;`
|
|
56
|
+
*
|
|
57
|
+
* The `TrackedResource<T>` type (and other associated base types) use the @armResource
|
|
58
|
+
* decorator, so it also gets applied to the type which absorbs the `TrackedResource<T>`
|
|
59
|
+
* definition by using the `is` keyword.
|
|
60
|
+
*/
|
|
61
|
+
export declare function $armResourceInternal(context: DecoratorContext, resourceType: Model, propertiesType: Model): void;
|
|
62
|
+
export declare function listArmResources(program: Program): ArmResourceDetails[];
|
|
63
|
+
export declare function getArmResource(program: Program, resourceType: Model): ArmResourceDetails | undefined;
|
|
64
|
+
//# sourceMappingURL=private.decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private.decorators.d.ts","sourceRoot":"","sources":["../../src/private.decorators.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,aAAa,EACb,SAAS,EACT,OAAO,EAEP,KAAK,EAGN,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,kBAAkB,EAKnB,MAAM,eAAe,CAAC;AAEvB,eAAO,MAAM,SAAS,kCAAkC,CAAC;AAEzD,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,QAU1F;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE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AAE,KAAK,QAiFtB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,EAAE,CAEvE;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,KAAK,GAClB,kBAAkB,GAAG,SAAS,CAEhC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { $useRef } from "@azure-tools/typespec-autorest";
|
|
2
|
+
import { $visibility, getKeyName, getTypeName, } from "@typespec/compiler";
|
|
3
|
+
import { getSegment } from "@typespec/rest";
|
|
4
|
+
import { createStateSymbol, reportDiagnostic } from "./lib.js";
|
|
5
|
+
import { getArmProviderNamespace } from "./namespace.js";
|
|
6
|
+
import { getArmResourceKind, getResourceBaseType, resolveResourceBaseType, } from "./resource.js";
|
|
7
|
+
export const namespace = "Azure.ResourceManager.Private";
|
|
8
|
+
export function $omitIfEmpty(context, entity, propertyName) {
|
|
9
|
+
const modelProp = getProperty(entity, propertyName);
|
|
10
|
+
if (modelProp &&
|
|
11
|
+
modelProp.type.kind === "Model" &&
|
|
12
|
+
!hasProperty(context.program, modelProp.type)) {
|
|
13
|
+
entity.properties.delete(propertyName);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function $resourceBaseParametersOf(context, entity, resourceType) {
|
|
17
|
+
const targetResourceBaseType = getResourceBaseType(context.program, resourceType);
|
|
18
|
+
const removedProperties = [];
|
|
19
|
+
for (const [propertyName, property] of entity.properties) {
|
|
20
|
+
if (!isResourceParameterBaseForInternal(context.program, property, targetResourceBaseType))
|
|
21
|
+
removedProperties.push(propertyName);
|
|
22
|
+
}
|
|
23
|
+
for (const removedProperty of removedProperties) {
|
|
24
|
+
entity.properties.delete(removedProperty);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const parameterBaseTypesKey = createStateSymbol("parameterBaseTypesKey");
|
|
28
|
+
export function $resourceParameterBaseFor(context, entity, values) {
|
|
29
|
+
const resolvedValues = [];
|
|
30
|
+
for (const value of values.values) {
|
|
31
|
+
if (value.kind !== "EnumMember") {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
resolvedValues.push(value.name);
|
|
35
|
+
}
|
|
36
|
+
context.program.stateMap(parameterBaseTypesKey).set(entity, resolvedValues);
|
|
37
|
+
}
|
|
38
|
+
export function getResourceParameterBases(program, property) {
|
|
39
|
+
return program.stateMap(parameterBaseTypesKey).get(property);
|
|
40
|
+
}
|
|
41
|
+
export function isResourceParameterBaseFor(program, property, resourceBaseType) {
|
|
42
|
+
return isResourceParameterBaseForInternal(program, property, resolveResourceBaseType(resourceBaseType));
|
|
43
|
+
}
|
|
44
|
+
function isResourceParameterBaseForInternal(program, property, resolvedBaseType) {
|
|
45
|
+
const resourceBases = getResourceParameterBases(program, property);
|
|
46
|
+
if (resourceBases !== undefined) {
|
|
47
|
+
for (const rawType of resourceBases) {
|
|
48
|
+
if (resolveResourceBaseType(rawType) === resolvedBaseType)
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Refer an model property to be a common ARM parameter
|
|
56
|
+
* @param {DecoratorContext} context DecoratorContext object
|
|
57
|
+
* @param {Type} entity Decorator target type. Must be `Model`
|
|
58
|
+
* @param {string?} definitionName Optional definition name
|
|
59
|
+
* @param {string?} version Optional version
|
|
60
|
+
* @param {string?} referenceFile Optional common file path
|
|
61
|
+
* @returns void
|
|
62
|
+
*/
|
|
63
|
+
export function $armCommonParameter(context, entity, parameterName, version, referenceFile) {
|
|
64
|
+
// Use the name of the model type if not specified
|
|
65
|
+
if (!parameterName) {
|
|
66
|
+
parameterName = entity.name;
|
|
67
|
+
}
|
|
68
|
+
const basePath = getArmTypesPath(context.program).trim();
|
|
69
|
+
// for backward compatibility, skip if we are trying to access a non-default file and emit the type
|
|
70
|
+
if ((version || referenceFile) && basePath.endsWith(".json"))
|
|
71
|
+
return;
|
|
72
|
+
if (!version)
|
|
73
|
+
version = "v3";
|
|
74
|
+
if (!referenceFile)
|
|
75
|
+
referenceFile = "types.json";
|
|
76
|
+
const path = basePath.endsWith(".json")
|
|
77
|
+
? `${basePath}#/parameters/${parameterName}`
|
|
78
|
+
: `${basePath}/${version}/${referenceFile}#/parameters/${parameterName}`;
|
|
79
|
+
context.call($useRef, entity, path);
|
|
80
|
+
}
|
|
81
|
+
function getArmTypesPath(program) {
|
|
82
|
+
return program.getOption("arm-types-path") || "{arm-types-dir}";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Using ARM common definition for a Model
|
|
86
|
+
* @param {DecoratorContext} context DecoratorContext object
|
|
87
|
+
* @param {Type} entity Decorator target type. Must be `Model`
|
|
88
|
+
* @param {string?} definitionName Optional definition name
|
|
89
|
+
* @param {string?} version Optional version
|
|
90
|
+
* @param {string?} referenceFile Optional common file path
|
|
91
|
+
* @returns {void}
|
|
92
|
+
*/
|
|
93
|
+
export function $armCommonDefinition(context, entity, definitionName, version, referenceFile) {
|
|
94
|
+
// Use the name of the model type if not specified
|
|
95
|
+
if (!definitionName) {
|
|
96
|
+
definitionName = entity.name;
|
|
97
|
+
}
|
|
98
|
+
const basePath = getArmTypesPath(context.program).trim();
|
|
99
|
+
// for backward compatibility, skip if we are trying to access a non-default file and emit the type
|
|
100
|
+
if ((version || referenceFile) && basePath.endsWith(".json"))
|
|
101
|
+
return;
|
|
102
|
+
if (!version)
|
|
103
|
+
version = "v3";
|
|
104
|
+
if (!referenceFile)
|
|
105
|
+
referenceFile = "types.json";
|
|
106
|
+
const path = basePath.endsWith(".json")
|
|
107
|
+
? `${basePath}#/definitions/${definitionName}`
|
|
108
|
+
: `${basePath}/${version}/${referenceFile}#/definitions/${definitionName}`;
|
|
109
|
+
context.call($useRef, entity, path);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* This decorator dynamically assigns the serviceNamespace from the containing
|
|
113
|
+
* namespace to the string literal value of the path parameter to which this
|
|
114
|
+
* decorator is applied. Its purpose is to dynamically insert the provider
|
|
115
|
+
* namespace (e.g. 'Microsoft.CodeSigning') into the path parameter list.
|
|
116
|
+
* @param {DecoratorContext} context DecoratorContext
|
|
117
|
+
* @param {Type} target Target of this decorator. Must be a string `ModelProperty`.
|
|
118
|
+
* @param {Type} resourceType Must be a `Model`.
|
|
119
|
+
*/
|
|
120
|
+
export function $assignProviderNameValue(context, target, resourceType) {
|
|
121
|
+
const { program } = context;
|
|
122
|
+
const armProviderNamespace = getArmProviderNamespace(program, resourceType);
|
|
123
|
+
if (armProviderNamespace) {
|
|
124
|
+
target.type.value = armProviderNamespace;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Update the ARM provider namespace for a given entity.
|
|
129
|
+
* @param {DecoratorContext} context DecoratorContext
|
|
130
|
+
* @param {Type} entity Entity to set namespace. Must be a `Operation`.
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
export function $armUpdateProviderNamespace(context, entity) {
|
|
134
|
+
const { program } = context;
|
|
135
|
+
const operation = entity;
|
|
136
|
+
const opInterface = operation.interface;
|
|
137
|
+
if (opInterface && opInterface.namespace) {
|
|
138
|
+
const armProviderNamespace = getArmProviderNamespace(program, opInterface.namespace);
|
|
139
|
+
if (armProviderNamespace) {
|
|
140
|
+
// Set the namespace constant on the 'provider' parameter
|
|
141
|
+
const providerParam = operation.parameters.properties.get("provider");
|
|
142
|
+
if (providerParam) {
|
|
143
|
+
if (providerParam.type.kind !== "String") {
|
|
144
|
+
reportDiagnostic(program, {
|
|
145
|
+
code: "decorator-param-wrong-type",
|
|
146
|
+
messageId: "armUpdateProviderNamespace",
|
|
147
|
+
target: providerParam,
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
providerParam.type.value = armProviderNamespace;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Check if an interface is extending the Azure.ResourceManager.Operations interface.
|
|
158
|
+
*/
|
|
159
|
+
export function isArmOperationsListInterface(program, type) {
|
|
160
|
+
if (type.name !== "Operations") {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
const listOperation = type.operations.get("list");
|
|
164
|
+
if (listOperation) {
|
|
165
|
+
if (getSegment(program, listOperation) === "operations") {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const armResourcesKey = createStateSymbol("armResources");
|
|
172
|
+
/**
|
|
173
|
+
* This decorator is used to identify ARM resource types and extract their
|
|
174
|
+
* metadata. It is *not* meant to be used directly by a spec author, it instead
|
|
175
|
+
* gets implicitly applied when the spec author defines a model type in this form:
|
|
176
|
+
*
|
|
177
|
+
* `model Server is TrackedResource<ServerProperties>;`
|
|
178
|
+
*
|
|
179
|
+
* The `TrackedResource<T>` type (and other associated base types) use the @armResource
|
|
180
|
+
* decorator, so it also gets applied to the type which absorbs the `TrackedResource<T>`
|
|
181
|
+
* definition by using the `is` keyword.
|
|
182
|
+
*/
|
|
183
|
+
export function $armResourceInternal(context, resourceType, propertiesType) {
|
|
184
|
+
const { program } = context;
|
|
185
|
+
if (resourceType.namespace && getTypeName(resourceType.namespace) === "Azure.ResourceManager") {
|
|
186
|
+
// The @armResource decorator will be evaluated on instantiations of
|
|
187
|
+
// base templated resource types like TrackedResource<SomeResource>,
|
|
188
|
+
// so ignore in that case.
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
// The global namespace has an empty string as name
|
|
192
|
+
if (!resourceType.namespace || resourceType.namespace.name === "") {
|
|
193
|
+
reportDiagnostic(program, {
|
|
194
|
+
code: "decorator-in-namespace",
|
|
195
|
+
format: { decoratorName: "armResource" },
|
|
196
|
+
target: resourceType,
|
|
197
|
+
});
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
// Locate the ARM namespace in the namespace hierarchy
|
|
201
|
+
const armProviderNamespace = getArmProviderNamespace(program, resourceType.namespace);
|
|
202
|
+
if (!armProviderNamespace) {
|
|
203
|
+
reportDiagnostic(program, { code: "arm-resource-missing-arm-namespace", target: resourceType });
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
// Ensure the resource type has defined a name property that has a segment
|
|
207
|
+
const nameProperty = resourceType.properties.get("name");
|
|
208
|
+
if (!nameProperty) {
|
|
209
|
+
reportDiagnostic(program, { code: "arm-resource-missing-name-property", target: resourceType });
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
// Set the name property to be read only
|
|
213
|
+
context.call($visibility, nameProperty, "read");
|
|
214
|
+
const keyName = getKeyName(program, nameProperty);
|
|
215
|
+
if (!keyName) {
|
|
216
|
+
reportDiagnostic(program, {
|
|
217
|
+
code: "arm-resource-missing-name-key-decorator",
|
|
218
|
+
target: resourceType,
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const collectionName = getSegment(program, nameProperty);
|
|
223
|
+
if (!collectionName) {
|
|
224
|
+
reportDiagnostic(program, {
|
|
225
|
+
code: "arm-resource-missing-name-segment-decorator",
|
|
226
|
+
target: resourceType,
|
|
227
|
+
});
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const kind = getArmResourceKind(resourceType);
|
|
231
|
+
if (!kind) {
|
|
232
|
+
reportDiagnostic(program, {
|
|
233
|
+
code: "arm-resource-invalid-base-type",
|
|
234
|
+
target: resourceType,
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
const armResourceDetails = {
|
|
239
|
+
name: resourceType.name,
|
|
240
|
+
kind,
|
|
241
|
+
typespecType: resourceType,
|
|
242
|
+
collectionName,
|
|
243
|
+
keyName,
|
|
244
|
+
armProviderNamespace: armProviderNamespace !== null && armProviderNamespace !== void 0 ? armProviderNamespace : "",
|
|
245
|
+
operations: {
|
|
246
|
+
lifecycle: {},
|
|
247
|
+
lists: {},
|
|
248
|
+
actions: {},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
program.stateMap(armResourcesKey).set(resourceType, armResourceDetails);
|
|
252
|
+
}
|
|
253
|
+
export function listArmResources(program) {
|
|
254
|
+
return [...program.stateMap(armResourcesKey).values()];
|
|
255
|
+
}
|
|
256
|
+
export function getArmResource(program, resourceType) {
|
|
257
|
+
return program.stateMap(armResourcesKey).get(resourceType);
|
|
258
|
+
}
|
|
259
|
+
function getProperty(model, propertyName) {
|
|
260
|
+
var _a;
|
|
261
|
+
let returnProperty = (_a = model.properties) === null || _a === void 0 ? void 0 : _a.get(propertyName);
|
|
262
|
+
if (!returnProperty && model.baseModel) {
|
|
263
|
+
returnProperty = getProperty(model.baseModel, propertyName);
|
|
264
|
+
}
|
|
265
|
+
return returnProperty;
|
|
266
|
+
}
|
|
267
|
+
function hasProperty(program, model) {
|
|
268
|
+
if (model.properties.size > 0)
|
|
269
|
+
return true;
|
|
270
|
+
if (model.baseModel)
|
|
271
|
+
return hasProperty(program, model.baseModel);
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=private.decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private.decorators.js","sourceRoot":"","sources":["../../src/private.decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EACL,WAAW,EASX,UAAU,EACV,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAGL,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,SAAS,GAAG,+BA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,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAgB;IAC/C,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,YAAmB;IAEnB,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,WAAW,CAAC,KAAY,EAAE,YAAoB;;IACrD,IAAI,cAAc,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,SAAS,EAAE;QACtC,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;KAC7D;IAED,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,WAAW,CAAC,OAAgB,EAAE,KAAY;IACjD,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,KAAK,CAAC,SAAS;QAAE,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAClE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/src/resource.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecoratorContext, Model,
|
|
1
|
+
import { DecoratorContext, Interface, Model, Operation, Program } from "@typespec/compiler";
|
|
2
2
|
import { ArmResourceOperations } from "./operations.js";
|
|
3
3
|
export type ArmResourceKind = "Tracked" | "Proxy" | "Extension";
|
|
4
4
|
/**
|
|
@@ -25,21 +25,9 @@ export interface ArmResourceDetails extends ArmResourceDetailsBase {
|
|
|
25
25
|
* so that operation route details are certain to be present.
|
|
26
26
|
*/
|
|
27
27
|
export declare function getArmResources(program: Program): ArmResourceDetails[];
|
|
28
|
-
export
|
|
28
|
+
export { getArmResource } from "./private.decorators.js";
|
|
29
29
|
export declare function getArmResourceInfo(program: Program, resourceType: Model): ArmResourceDetails | undefined;
|
|
30
30
|
export declare function getArmResourceKind(resourceType: Model): ArmResourceKind | undefined;
|
|
31
|
-
/**
|
|
32
|
-
* This decorator is used to identify ARM resource types and extract their
|
|
33
|
-
* metadata. It is *not* meant to be used directly by a spec author, it instead
|
|
34
|
-
* gets implicitly applied when the spec author defines a model type in this form:
|
|
35
|
-
*
|
|
36
|
-
* `model Server is TrackedResource<ServerProperties>;`
|
|
37
|
-
*
|
|
38
|
-
* The `TrackedResource<T>` type (and other associated base types) use the @armResource
|
|
39
|
-
* decorator, so it also gets applied to the type which absorbs the `TrackedResource<T>`
|
|
40
|
-
* definition by using the `is` keyword.
|
|
41
|
-
*/
|
|
42
|
-
export declare function $armResourceInternal(context: DecoratorContext, resourceType: Type, propertiesType: Type): void;
|
|
43
31
|
/**
|
|
44
32
|
* This decorator is used to identify interfaces containing resource operations.
|
|
45
33
|
* When applied, it marks the interface with the `@autoRoute` decorator so that
|
|
@@ -50,14 +38,14 @@ export declare function $armResourceInternal(context: DecoratorContext, resource
|
|
|
50
38
|
* of the operations will be grouped based on the interface name in generated
|
|
51
39
|
* clients.
|
|
52
40
|
*/
|
|
53
|
-
export declare function $armResourceOperations(context: DecoratorContext, interfaceType:
|
|
41
|
+
export declare function $armResourceOperations(context: DecoratorContext, interfaceType: Interface): void;
|
|
54
42
|
/**
|
|
55
43
|
* This decorator is used to mark a resource type as a "singleton", a type with
|
|
56
44
|
* only one instance. The standard set of resource operations can be applied to
|
|
57
45
|
* such a resource type, they will generate the correct routes and parameter
|
|
58
46
|
* lists.
|
|
59
47
|
*/
|
|
60
|
-
export declare function $singleton(context: DecoratorContext, resourceType:
|
|
48
|
+
export declare function $singleton(context: DecoratorContext, resourceType: Model, keyValue?: string): void;
|
|
61
49
|
export declare function isSingletonResource(program: Program, resourceType: Model): boolean;
|
|
62
50
|
export declare function getSingletonResourceKey(program: Program, resourceType: Model): string | undefined;
|
|
63
51
|
export declare enum ResourceBaseType {
|
|
@@ -67,16 +55,12 @@ export declare enum ResourceBaseType {
|
|
|
67
55
|
ResourceGroup = "ResourceGroup",
|
|
68
56
|
Extension = "Extension"
|
|
69
57
|
}
|
|
70
|
-
export declare function $tenantResource(context: DecoratorContext, entity:
|
|
71
|
-
export declare function $subscriptionResource(context: DecoratorContext, entity:
|
|
72
|
-
export declare function $locationResource(context: DecoratorContext, entity:
|
|
73
|
-
export declare function $resourceGroupResource(context: DecoratorContext, entity:
|
|
74
|
-
export declare function $extensionResource(context: DecoratorContext, entity:
|
|
75
|
-
export declare function $armProviderNameValue(context: DecoratorContext, entity:
|
|
76
|
-
export declare function $resourceParameterBaseFor(context: DecoratorContext, entity: Type, values: Type): void;
|
|
77
|
-
export declare function $resourceBaseParametersOf(context: DecoratorContext, entity: Type, resourceType: Type): void;
|
|
78
|
-
export declare function $omitIfEmpty(context: DecoratorContext, entity: Type, propertyName: string): void;
|
|
79
|
-
export declare function isResourceParameterBaseFor(program: Program, property: ModelProperty, resourceBaseType: string): boolean;
|
|
80
|
-
export declare function getResourceParameterBases(program: Program, property: ModelProperty): string[] | undefined;
|
|
58
|
+
export declare function $tenantResource(context: DecoratorContext, entity: Model): void;
|
|
59
|
+
export declare function $subscriptionResource(context: DecoratorContext, entity: Model): void;
|
|
60
|
+
export declare function $locationResource(context: DecoratorContext, entity: Model): void;
|
|
61
|
+
export declare function $resourceGroupResource(context: DecoratorContext, entity: Model): void;
|
|
62
|
+
export declare function $extensionResource(context: DecoratorContext, entity: Model): void;
|
|
63
|
+
export declare function $armProviderNameValue(context: DecoratorContext, entity: Operation): void;
|
|
81
64
|
export declare function getResourceBaseType(program: Program, resource: Model): ResourceBaseType;
|
|
65
|
+
export declare function resolveResourceBaseType(type?: string | undefined): ResourceBaseType;
|
|
82
66
|
//# sourceMappingURL=resource.d.ts.map
|