@azure-tools/typespec-azure-resource-manager 0.27.0

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 (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +346 -0
  3. package/dist/src/common-types.d.ts +8 -0
  4. package/dist/src/common-types.d.ts.map +1 -0
  5. package/dist/src/common-types.js +14 -0
  6. package/dist/src/common-types.js.map +1 -0
  7. package/dist/src/index.d.ts +7 -0
  8. package/dist/src/index.d.ts.map +1 -0
  9. package/dist/src/index.js +7 -0
  10. package/dist/src/index.js.map +1 -0
  11. package/dist/src/internal.d.ts +44 -0
  12. package/dist/src/internal.d.ts.map +1 -0
  13. package/dist/src/internal.js +142 -0
  14. package/dist/src/internal.js.map +1 -0
  15. package/dist/src/lib.d.ts +615 -0
  16. package/dist/src/lib.d.ts.map +1 -0
  17. package/dist/src/lib.js +250 -0
  18. package/dist/src/lib.js.map +1 -0
  19. package/dist/src/linter.d.ts +3 -0
  20. package/dist/src/linter.d.ts.map +1 -0
  21. package/dist/src/linter.js +42 -0
  22. package/dist/src/linter.js.map +1 -0
  23. package/dist/src/namespace.d.ts +16 -0
  24. package/dist/src/namespace.d.ts.map +1 -0
  25. package/dist/src/namespace.js +106 -0
  26. package/dist/src/namespace.js.map +1 -0
  27. package/dist/src/operations.d.ts +36 -0
  28. package/dist/src/operations.d.ts.map +1 -0
  29. package/dist/src/operations.js +186 -0
  30. package/dist/src/operations.js.map +1 -0
  31. package/dist/src/resource.d.ts +81 -0
  32. package/dist/src/resource.d.ts.map +1 -0
  33. package/dist/src/resource.js +358 -0
  34. package/dist/src/resource.js.map +1 -0
  35. package/dist/src/rules/arm-resource-action-no-segment.d.ts +2 -0
  36. package/dist/src/rules/arm-resource-action-no-segment.d.ts.map +1 -0
  37. package/dist/src/rules/arm-resource-action-no-segment.js +31 -0
  38. package/dist/src/rules/arm-resource-action-no-segment.js.map +1 -0
  39. package/dist/src/rules/arm-resource-invalid-chars.d.ts +2 -0
  40. package/dist/src/rules/arm-resource-invalid-chars.d.ts.map +1 -0
  41. package/dist/src/rules/arm-resource-invalid-chars.js +61 -0
  42. package/dist/src/rules/arm-resource-invalid-chars.js.map +1 -0
  43. package/dist/src/rules/arm-resource-invalid-version-format.d.ts +2 -0
  44. package/dist/src/rules/arm-resource-invalid-version-format.d.ts.map +1 -0
  45. package/dist/src/rules/arm-resource-invalid-version-format.js +48 -0
  46. package/dist/src/rules/arm-resource-invalid-version-format.js.map +1 -0
  47. package/dist/src/rules/arm-resource-operations.d.ts +2 -0
  48. package/dist/src/rules/arm-resource-operations.d.ts.map +1 -0
  49. package/dist/src/rules/arm-resource-operations.js +70 -0
  50. package/dist/src/rules/arm-resource-operations.js.map +1 -0
  51. package/dist/src/rules/arm-resource-properties.d.ts +2 -0
  52. package/dist/src/rules/arm-resource-properties.d.ts.map +1 -0
  53. package/dist/src/rules/arm-resource-properties.js +55 -0
  54. package/dist/src/rules/arm-resource-properties.js.map +1 -0
  55. package/dist/src/rules/arm-resource-provisioning-state-rule.d.ts +2 -0
  56. package/dist/src/rules/arm-resource-provisioning-state-rule.d.ts.map +1 -0
  57. package/dist/src/rules/arm-resource-provisioning-state-rule.js +62 -0
  58. package/dist/src/rules/arm-resource-provisioning-state-rule.js.map +1 -0
  59. package/dist/src/rules/beyond-nesting-levels.d.ts +5 -0
  60. package/dist/src/rules/beyond-nesting-levels.d.ts.map +1 -0
  61. package/dist/src/rules/beyond-nesting-levels.js +37 -0
  62. package/dist/src/rules/beyond-nesting-levels.js.map +1 -0
  63. package/dist/src/rules/core-operations.d.ts +2 -0
  64. package/dist/src/rules/core-operations.d.ts.map +1 -0
  65. package/dist/src/rules/core-operations.js +181 -0
  66. package/dist/src/rules/core-operations.js.map +1 -0
  67. package/dist/src/rules/delete-operation.d.ts +5 -0
  68. package/dist/src/rules/delete-operation.d.ts.map +1 -0
  69. package/dist/src/rules/delete-operation.js +28 -0
  70. package/dist/src/rules/delete-operation.js.map +1 -0
  71. package/dist/src/rules/envelope-properties.d.ts +5 -0
  72. package/dist/src/rules/envelope-properties.d.ts.map +1 -0
  73. package/dist/src/rules/envelope-properties.js +62 -0
  74. package/dist/src/rules/envelope-properties.js.map +1 -0
  75. package/dist/src/rules/list-operation.d.ts +5 -0
  76. package/dist/src/rules/list-operation.d.ts.map +1 -0
  77. package/dist/src/rules/list-operation.js +35 -0
  78. package/dist/src/rules/list-operation.js.map +1 -0
  79. package/dist/src/rules/no-response-body.d.ts +5 -0
  80. package/dist/src/rules/no-response-body.d.ts.map +1 -0
  81. package/dist/src/rules/no-response-body.js +27 -0
  82. package/dist/src/rules/no-response-body.js.map +1 -0
  83. package/dist/src/rules/operations-interface-missing.d.ts +5 -0
  84. package/dist/src/rules/operations-interface-missing.d.ts.map +1 -0
  85. package/dist/src/rules/operations-interface-missing.js +37 -0
  86. package/dist/src/rules/operations-interface-missing.js.map +1 -0
  87. package/dist/src/rules/resource-name.d.ts +5 -0
  88. package/dist/src/rules/resource-name.d.ts.map +1 -0
  89. package/dist/src/rules/resource-name.js +47 -0
  90. package/dist/src/rules/resource-name.js.map +1 -0
  91. package/dist/src/rules/retry-after.d.ts +5 -0
  92. package/dist/src/rules/retry-after.d.ts.map +1 -0
  93. package/dist/src/rules/retry-after.js +31 -0
  94. package/dist/src/rules/retry-after.js.map +1 -0
  95. package/dist/src/rules/unsupported-types.d.ts +5 -0
  96. package/dist/src/rules/unsupported-types.d.ts.map +1 -0
  97. package/dist/src/rules/unsupported-types.js +39 -0
  98. package/dist/src/rules/unsupported-types.js.map +1 -0
  99. package/dist/src/rules/utils.d.ts +18 -0
  100. package/dist/src/rules/utils.d.ts.map +1 -0
  101. package/dist/src/rules/utils.js +77 -0
  102. package/dist/src/rules/utils.js.map +1 -0
  103. package/dist/src/testing/index.d.ts +3 -0
  104. package/dist/src/testing/index.d.ts.map +1 -0
  105. package/dist/src/testing/index.js +24 -0
  106. package/dist/src/testing/index.js.map +1 -0
  107. package/lib/arm.foundations.tsp +465 -0
  108. package/lib/arm.tsp +31 -0
  109. package/lib/decorators.tsp +87 -0
  110. package/lib/interfaces.tsp +287 -0
  111. package/lib/models.tsp +203 -0
  112. package/lib/operations.tsp +260 -0
  113. package/lib/parameters.tsp +126 -0
  114. package/lib/responses.tsp +47 -0
  115. package/package.json +85 -0
@@ -0,0 +1,186 @@
1
+ import { $doc, ignoreDiagnostics, validateDecoratorParamType, validateDecoratorTarget, } from "@typespec/compiler";
2
+ import { getAllHttpServices } from "@typespec/http";
3
+ import { $actionSegment, getActionSegment, getParentResource, getSegment } from "@typespec/rest";
4
+ import { createStateSymbol, reportDiagnostic } from "./lib.js";
5
+ import { getArmResourceInfo, getResourceBaseType, ResourceBaseType } from "./resource.js";
6
+ const armResourceOperationsKey = createStateSymbol("armResourceOperations");
7
+ const armResourceOperationsMapKey = createStateSymbol("armResourceOperationsMap");
8
+ function getArmResourceOperations(program, resourceType) {
9
+ let operations = program.stateMap(armResourceOperationsKey).get(resourceType);
10
+ if (!operations) {
11
+ operations = { lifecycle: {}, lists: {}, actions: {} };
12
+ program.stateMap(armResourceOperationsKey).set(resourceType, operations);
13
+ }
14
+ return operations;
15
+ }
16
+ export function resolveResourceOperations(program, resourceType) {
17
+ const operations = getArmResourceOperations(program, resourceType);
18
+ const operationMap = program.stateMap(armResourceOperationsMapKey);
19
+ const services = ignoreDiagnostics(getAllHttpServices(program));
20
+ // Get all resolved operations and update ARM operation details
21
+ for (const httpOperation of services[0].operations) {
22
+ const operation = operationMap.get(httpOperation.operation);
23
+ if (operation) {
24
+ // Populate the remaining details of the operation
25
+ operation.path = httpOperation.path;
26
+ operation.httpOperation = httpOperation;
27
+ }
28
+ }
29
+ // Returned the updated operations object
30
+ return operations;
31
+ }
32
+ function setResourceLifecycleOperation(context, target, resourceType, kind, decoratorName) {
33
+ // If the properties type is a template parameter, this must be a templated type
34
+ if (resourceType.kind === "TemplateParameter") {
35
+ return;
36
+ }
37
+ if (!validateDecoratorTarget(context, target, decoratorName, "Operation") ||
38
+ !validateDecoratorParamType(context.program, target, resourceType, "Model")) {
39
+ return;
40
+ }
41
+ // Only register methods from non-templated interface types
42
+ if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
43
+ return;
44
+ }
45
+ // We can't resolve the operation path yet so treat the operation as a partial
46
+ // type so that we can fill in the missing details later
47
+ const operations = getArmResourceOperations(context.program, resourceType);
48
+ const operation = {
49
+ name: target.name,
50
+ kind,
51
+ operation: target,
52
+ operationGroup: target.interface.name,
53
+ };
54
+ operations.lifecycle[kind] = operation;
55
+ // Add it to the OperationType -> ArmResourceOperation map
56
+ context.program.stateMap(armResourceOperationsMapKey).set(target, operations.lifecycle[kind]);
57
+ }
58
+ export function $armResourceRead(context, target, resourceType) {
59
+ setResourceLifecycleOperation(context, target, resourceType, "read", "@armResourceRead");
60
+ }
61
+ export function $armResourceCreateOrUpdate(context, target, resourceType) {
62
+ setResourceLifecycleOperation(context, target, resourceType, "createOrUpdate", "@armResourceCreateOrUpdate");
63
+ }
64
+ export function $armResourceUpdate(context, target, resourceType) {
65
+ setResourceLifecycleOperation(context, target, resourceType, "update", "@armResourceUpdate");
66
+ }
67
+ export function $armResourceDelete(context, target, resourceType) {
68
+ setResourceLifecycleOperation(context, target, resourceType, "delete", "@armResourceDelete");
69
+ }
70
+ export function $armResourceList(context, target, resourceType) {
71
+ // If the properties type is a template parameter, this must be a templated type
72
+ if (resourceType.kind === "TemplateParameter") {
73
+ return;
74
+ }
75
+ if (!validateDecoratorTarget(context, target, "@armResourceList", "Operation") ||
76
+ !validateDecoratorParamType(context.program, target, resourceType, "Model")) {
77
+ return;
78
+ }
79
+ // Only register methods from non-templated interface types
80
+ if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
81
+ return;
82
+ }
83
+ // We can't resolve the operation path yet so treat the operation as a partial
84
+ // type so that we can fill in the missing details later
85
+ const operations = getArmResourceOperations(context.program, resourceType);
86
+ const operation = {
87
+ name: target.name,
88
+ kind: "list",
89
+ operation: target,
90
+ operationGroup: target.interface.name,
91
+ };
92
+ operations.lists[target.name] = operation;
93
+ // Add it to the OperationType -> ArmResourceOperation map
94
+ context.program.stateMap(armResourceOperationsMapKey).set(target, operation);
95
+ }
96
+ export function $armRenameListByOperation(context, entity, resourceType, parentTypeName, parentFriendlyTypeName) {
97
+ const { program } = context;
98
+ if (resourceType.kind === "TemplateParameter") {
99
+ // Don't execute when this decorator is being applied within a templated interface
100
+ return;
101
+ }
102
+ if (!validateDecoratorTarget(context, entity, "@armRenameListByOperation", "Operation") ||
103
+ !validateDecoratorParamType(program, entity, resourceType, "Model")) {
104
+ return;
105
+ }
106
+ if (parentTypeName === undefined ||
107
+ parentTypeName === "" ||
108
+ parentFriendlyTypeName === undefined ||
109
+ parentFriendlyTypeName === "") {
110
+ [parentTypeName, parentFriendlyTypeName] = getArmParentName(context.program, resourceType);
111
+ }
112
+ const parentType = getParentResource(program, resourceType);
113
+ if (parentType) {
114
+ const parentResourceInfo = getArmResourceInfo(program, parentType);
115
+ if (!parentResourceInfo) {
116
+ reportDiagnostic(program, {
117
+ code: "parent-type",
118
+ messageId: "notResourceType",
119
+ target: resourceType,
120
+ format: { type: resourceType.name, parent: parentType.name },
121
+ });
122
+ return;
123
+ }
124
+ // Make sure the first character of the name is upper-cased
125
+ parentTypeName = parentType.name[0].toUpperCase() + parentType.name.substring(1);
126
+ }
127
+ // Add a formatted doc string too
128
+ context.call($doc, entity, `List ${resourceType.name} resources by ${parentType ? parentTypeName : parentFriendlyTypeName}`, undefined);
129
+ // Set the operation name
130
+ entity.name = parentTypeName === "Extension" ? "List" : `ListBy${parentTypeName}`;
131
+ }
132
+ function getArmParentName(program, resource) {
133
+ switch (getResourceBaseType(program, resource)) {
134
+ case ResourceBaseType.Extension:
135
+ return ["Extension", "parent"];
136
+ case ResourceBaseType.Location:
137
+ return ["Location", "location"];
138
+ case ResourceBaseType.Subscription:
139
+ return ["Subscription", "subscription"];
140
+ case ResourceBaseType.Tenant:
141
+ return ["Tenant", "tenant"];
142
+ case ResourceBaseType.ResourceGroup:
143
+ default:
144
+ return ["ResourceGroup", "resource group"];
145
+ }
146
+ }
147
+ export function $armResourceAction(context, target, resourceType) {
148
+ var _a;
149
+ const { program } = context;
150
+ // If the properties type is a template parameter, this must be a templated type
151
+ if (resourceType.kind === "TemplateParameter") {
152
+ return;
153
+ }
154
+ if (!validateDecoratorTarget(context, target, "@armResourceAction", "Operation") ||
155
+ !validateDecoratorParamType(program, target, resourceType, "Model")) {
156
+ return;
157
+ }
158
+ // Only register methods from non-templated interface types
159
+ if (target.interface === undefined || target.interface.node.templateParameters.length > 0) {
160
+ return;
161
+ }
162
+ // We can't resolve the operation path yet so treat the operation as a partial
163
+ // type so that we can fill in the missing details later
164
+ const operations = getArmResourceOperations(program, resourceType);
165
+ const operation = {
166
+ name: target.name,
167
+ kind: "action",
168
+ operation: target,
169
+ operationGroup: target.interface.name,
170
+ };
171
+ operations.actions[target.name] = operation;
172
+ // Add it to the OperationType -> ArmResourceOperation map
173
+ program.stateMap(armResourceOperationsMapKey).set(target, operation);
174
+ const segment = (_a = getSegment(program, target)) !== null && _a !== void 0 ? _a : getActionSegment(program, target);
175
+ if (!segment) {
176
+ // Also apply the @actionSegment decorator to the operation
177
+ context.call($actionSegment, target, uncapitalize(target.name));
178
+ }
179
+ }
180
+ function uncapitalize(name) {
181
+ if (name === "") {
182
+ return name;
183
+ }
184
+ return name[0].toLowerCase() + name.substring(1);
185
+ }
186
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,iBAAiB,EAKjB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAiB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MA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,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"}
@@ -0,0 +1,81 @@
1
+ import { DecoratorContext, Model, ModelProperty, Program, Type } from "@typespec/compiler";
2
+ import { ArmResourceOperations } from "./operations.js";
3
+ export type ArmResourceKind = "Tracked" | "Proxy" | "Extension";
4
+ /**
5
+ * Interface for ARM resource detail base.
6
+ *
7
+ * @interface
8
+ */
9
+ export interface ArmResourceDetailsBase {
10
+ name: string;
11
+ kind: ArmResourceKind;
12
+ armProviderNamespace: string;
13
+ keyName: string;
14
+ collectionName: string;
15
+ typespecType: Model;
16
+ }
17
+ export interface ArmResourceDetails extends ArmResourceDetailsBase {
18
+ operations: ArmResourceOperations;
19
+ }
20
+ /**
21
+ * This function returns fully-resolved details about all ARM resources
22
+ * registered in the TypeSpec document including operations and their details.
23
+ *
24
+ * It should only be called after the full TypeSpec document has been compiled
25
+ * so that operation route details are certain to be present.
26
+ */
27
+ export declare function getArmResources(program: Program): ArmResourceDetails[];
28
+ export declare function getArmResource(program: Program, resourceType: Model): ArmResourceDetails | undefined;
29
+ export declare function getArmResourceInfo(program: Program, resourceType: Model): ArmResourceDetails | undefined;
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
+ /**
44
+ * This decorator is used to identify interfaces containing resource operations.
45
+ * When applied, it marks the interface with the `@autoRoute` decorator so that
46
+ * all of its contained operations will have their routes generated
47
+ * automatically.
48
+ *
49
+ * It also adds a `@tag` decorator bearing the name of the interface so that all
50
+ * of the operations will be grouped based on the interface name in generated
51
+ * clients.
52
+ */
53
+ export declare function $armResourceOperations(context: DecoratorContext, interfaceType: Type): void;
54
+ /**
55
+ * This decorator is used to mark a resource type as a "singleton", a type with
56
+ * only one instance. The standard set of resource operations can be applied to
57
+ * such a resource type, they will generate the correct routes and parameter
58
+ * lists.
59
+ */
60
+ export declare function $singleton(context: DecoratorContext, resourceType: Type, keyValue?: string): void;
61
+ export declare function isSingletonResource(program: Program, resourceType: Model): boolean;
62
+ export declare function getSingletonResourceKey(program: Program, resourceType: Model): string | undefined;
63
+ export declare enum ResourceBaseType {
64
+ Tenant = "Tenant",
65
+ Subscription = "Subscription",
66
+ Location = "Location",
67
+ ResourceGroup = "ResourceGroup",
68
+ Extension = "Extension"
69
+ }
70
+ export declare function $tenantResource(context: DecoratorContext, entity: Type): void;
71
+ export declare function $subscriptionResource(context: DecoratorContext, entity: Type): void;
72
+ export declare function $locationResource(context: DecoratorContext, entity: Type): void;
73
+ export declare function $resourceGroupResource(context: DecoratorContext, entity: Type): void;
74
+ export declare function $extensionResource(context: DecoratorContext, entity: Type): void;
75
+ export declare function $resourceParameterBaseFor(context: DecoratorContext, entity: Type, values: Type): void;
76
+ export declare function $resourceBaseParametersOf(context: DecoratorContext, entity: Type, resourceType: Type): void;
77
+ export declare function $omitIfEmpty(context: DecoratorContext, entity: Type, propertyName: string): void;
78
+ export declare function isResourceParameterBaseFor(program: Program, property: ModelProperty, resourceBaseType: string): boolean;
79
+ export declare function getResourceParameterBases(program: Program, property: ModelProperty): string[] | undefined;
80
+ export declare function getResourceBaseType(program: Program, resource: Model): ResourceBaseType;
81
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","s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vC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,GACtB,MAAM,EAAE,GAAG,SAAS,CAEtB;AAaD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,GAAG,gBAAgB,CAYvF"}
@@ -0,0 +1,358 @@
1
+ import { $tag, $visibility, getKeyName, getTags, getTypeName, validateDecoratorParamType, validateDecoratorTarget, } from "@typespec/compiler";
2
+ import { $autoRoute, getParentResource, getSegment } from "@typespec/rest";
3
+ import { createStateSymbol, reportDiagnostic } from "./lib.js";
4
+ import { getArmProviderNamespace } from "./namespace.js";
5
+ import { resolveResourceOperations } from "./operations.js";
6
+ const armResourcesKey = createStateSymbol("armResources");
7
+ const armResourcesCachedKey = createStateSymbol("armResourcesCached");
8
+ const armSingletonResourcesKey = createStateSymbol("armSingletonResources");
9
+ function resolveArmResourceDetails(program, resource) {
10
+ // Combine fully-resolved operation details with the base details we already have
11
+ return {
12
+ ...resource,
13
+ operations: resolveResourceOperations(program, resource.typespecType),
14
+ };
15
+ }
16
+ /**
17
+ * This function returns fully-resolved details about all ARM resources
18
+ * registered in the TypeSpec document including operations and their details.
19
+ *
20
+ * It should only be called after the full TypeSpec document has been compiled
21
+ * so that operation route details are certain to be present.
22
+ */
23
+ export function getArmResources(program) {
24
+ // Have we cached the resolved resource details already?
25
+ const cachedResources = program.stateMap(armResourcesCachedKey);
26
+ if (cachedResources.size > 0) {
27
+ // Return the cached resource details
28
+ return Array.from(program.stateMap(armResourcesCachedKey).values());
29
+ }
30
+ // We haven't generated the full resource details yet
31
+ const resources = [];
32
+ for (const resource of program.stateMap(armResourcesKey).values()) {
33
+ const fullResource = resolveArmResourceDetails(program, resource);
34
+ cachedResources.set(resource.typespecType, fullResource);
35
+ resources.push(fullResource);
36
+ }
37
+ return resources;
38
+ }
39
+ export function getArmResource(program, resourceType) {
40
+ return program.stateMap(armResourcesKey).get(resourceType);
41
+ }
42
+ export function getArmResourceInfo(program, resourceType) {
43
+ const resourceInfo = program.stateMap(armResourcesKey).get(resourceType);
44
+ if (!resourceInfo) {
45
+ reportDiagnostic(program, {
46
+ code: "arm-resource-missing",
47
+ format: { type: resourceType.name },
48
+ target: resourceType,
49
+ });
50
+ }
51
+ return resourceInfo;
52
+ }
53
+ export function getArmResourceKind(resourceType) {
54
+ if (resourceType.baseModel) {
55
+ const coreType = resourceType.baseModel;
56
+ if (coreType.name.startsWith("TrackedResource")) {
57
+ return "Tracked";
58
+ }
59
+ else if (coreType.name.startsWith("ProxyResource")) {
60
+ return "Proxy";
61
+ }
62
+ else if (coreType.name.startsWith("ExtensionResource")) {
63
+ return "Extension";
64
+ }
65
+ }
66
+ return undefined;
67
+ }
68
+ /**
69
+ * This decorator is used to identify ARM resource types and extract their
70
+ * metadata. It is *not* meant to be used directly by a spec author, it instead
71
+ * gets implicitly applied when the spec author defines a model type in this form:
72
+ *
73
+ * `model Server is TrackedResource<ServerProperties>;`
74
+ *
75
+ * The `TrackedResource<T>` type (and other associated base types) use the @armResource
76
+ * decorator, so it also gets applied to the type which absorbs the `TrackedResource<T>`
77
+ * definition by using the `is` keyword.
78
+ */
79
+ export function $armResourceInternal(context, resourceType, propertiesType) {
80
+ const { program } = context;
81
+ // If the properties type is a template parameter, this must be a templated type
82
+ if (propertiesType.kind === "TemplateParameter") {
83
+ return;
84
+ }
85
+ if (!validateDecoratorTarget(context, resourceType, "@armResource", "Model") ||
86
+ !validateDecoratorParamType(program, resourceType, propertiesType, "Model")) {
87
+ return;
88
+ }
89
+ const fullyQualifiedName = getTypeName(resourceType);
90
+ if (fullyQualifiedName.startsWith("Azure.ResourceManager")) {
91
+ // The @armResource decorator will be evaluated on instantiations of
92
+ // base templated resource types like TrackedResource<SomeResource>,
93
+ // so ignore in that case.
94
+ return;
95
+ }
96
+ // The global namespace has an empty string as name
97
+ if (!resourceType.namespace || resourceType.namespace.name === "") {
98
+ reportDiagnostic(program, {
99
+ code: "decorator-in-namespace",
100
+ format: { decoratorName: "armResource" },
101
+ target: resourceType,
102
+ });
103
+ return;
104
+ }
105
+ // Locate the ARM namespace in the namespace hierarchy
106
+ const armProviderNamespace = getArmProviderNamespace(program, resourceType.namespace);
107
+ if (!armProviderNamespace) {
108
+ reportDiagnostic(program, { code: "arm-resource-missing-arm-namespace", target: resourceType });
109
+ return;
110
+ }
111
+ // Ensure the resource type has defined a name property that has a segment
112
+ const nameProperty = resourceType.properties.get("name");
113
+ if (!nameProperty) {
114
+ reportDiagnostic(program, { code: "arm-resource-missing-name-property", target: resourceType });
115
+ return;
116
+ }
117
+ // Set the name property to be read only
118
+ context.call($visibility, nameProperty, "read");
119
+ const keyName = getKeyName(program, nameProperty);
120
+ if (!keyName) {
121
+ reportDiagnostic(program, {
122
+ code: "arm-resource-missing-name-key-decorator",
123
+ target: resourceType,
124
+ });
125
+ return;
126
+ }
127
+ const collectionName = getSegment(program, nameProperty);
128
+ if (!collectionName) {
129
+ reportDiagnostic(program, {
130
+ code: "arm-resource-missing-name-segment-decorator",
131
+ target: resourceType,
132
+ });
133
+ return;
134
+ }
135
+ const kind = getArmResourceKind(resourceType);
136
+ if (!kind) {
137
+ reportDiagnostic(program, {
138
+ code: "arm-resource-invalid-base-type",
139
+ target: resourceType,
140
+ });
141
+ return;
142
+ }
143
+ const armResourceDetails = {
144
+ name: resourceType.name,
145
+ kind,
146
+ typespecType: resourceType,
147
+ collectionName,
148
+ keyName,
149
+ armProviderNamespace: armProviderNamespace !== null && armProviderNamespace !== void 0 ? armProviderNamespace : "",
150
+ operations: {
151
+ lifecycle: {},
152
+ lists: {},
153
+ actions: {},
154
+ },
155
+ };
156
+ program.stateMap(armResourcesKey).set(resourceType, armResourceDetails);
157
+ }
158
+ /**
159
+ * This decorator is used to identify interfaces containing resource operations.
160
+ * When applied, it marks the interface with the `@autoRoute` decorator so that
161
+ * all of its contained operations will have their routes generated
162
+ * automatically.
163
+ *
164
+ * It also adds a `@tag` decorator bearing the name of the interface so that all
165
+ * of the operations will be grouped based on the interface name in generated
166
+ * clients.
167
+ */
168
+ export function $armResourceOperations(context, interfaceType) {
169
+ const { program } = context;
170
+ if (!validateDecoratorTarget(context, interfaceType, "@armResourceOperations", "Interface")) {
171
+ return undefined;
172
+ }
173
+ // All resource interfaces should use @autoRoute
174
+ context.call($autoRoute, interfaceType);
175
+ // If no tag is given for the interface, tag it with the interface name
176
+ if (getTags(program, interfaceType).length === 0) {
177
+ context.call($tag, interfaceType, interfaceType.name);
178
+ }
179
+ }
180
+ /**
181
+ * This decorator is used to mark a resource type as a "singleton", a type with
182
+ * only one instance. The standard set of resource operations can be applied to
183
+ * such a resource type, they will generate the correct routes and parameter
184
+ * lists.
185
+ */
186
+ export function $singleton(context, resourceType, keyValue = "default") {
187
+ if (!validateDecoratorTarget(context, resourceType, "@singleton", "Model")) {
188
+ return undefined;
189
+ }
190
+ context.program.stateMap(armSingletonResourcesKey).set(resourceType, keyValue);
191
+ }
192
+ export function isSingletonResource(program, resourceType) {
193
+ return program.stateMap(armSingletonResourcesKey).has(resourceType);
194
+ }
195
+ export function getSingletonResourceKey(program, resourceType) {
196
+ return program.stateMap(armSingletonResourcesKey).get(resourceType);
197
+ }
198
+ export var ResourceBaseType;
199
+ (function (ResourceBaseType) {
200
+ ResourceBaseType["Tenant"] = "Tenant";
201
+ ResourceBaseType["Subscription"] = "Subscription";
202
+ ResourceBaseType["Location"] = "Location";
203
+ ResourceBaseType["ResourceGroup"] = "ResourceGroup";
204
+ ResourceBaseType["Extension"] = "Extension";
205
+ })(ResourceBaseType = ResourceBaseType || (ResourceBaseType = {}));
206
+ const resourceBaseTypeKey = createStateSymbol("resourceBaseTypeKey");
207
+ const parameterBaseTypesKey = createStateSymbol("parameterBaseTypesKey");
208
+ export function $tenantResource(context, entity) {
209
+ if (!validateDecoratorTarget(context, entity, "@tenantResource", "Model")) {
210
+ return;
211
+ }
212
+ setResourceBaseType(context.program, entity, "Tenant");
213
+ }
214
+ export function $subscriptionResource(context, entity) {
215
+ if (!validateDecoratorTarget(context, entity, "@subscriptionResource", "Model")) {
216
+ return;
217
+ }
218
+ setResourceBaseType(context.program, entity, "Subscription");
219
+ }
220
+ export function $locationResource(context, entity) {
221
+ if (!validateDecoratorTarget(context, entity, "@locationResource", "Model")) {
222
+ return;
223
+ }
224
+ setResourceBaseType(context.program, entity, "Location");
225
+ }
226
+ export function $resourceGroupResource(context, entity) {
227
+ if (!validateDecoratorTarget(context, entity, "@resourceGroupResource", "Model")) {
228
+ return;
229
+ }
230
+ setResourceBaseType(context.program, entity, "ResourceGroup");
231
+ }
232
+ export function $extensionResource(context, entity) {
233
+ if (!validateDecoratorTarget(context, entity, "@extensionResource", "Model")) {
234
+ return;
235
+ }
236
+ setResourceBaseType(context.program, entity, "Extension");
237
+ }
238
+ export function $resourceParameterBaseFor(context, entity, values) {
239
+ if (!validateDecoratorTarget(context, entity, "@resourceParameterBaseFor", "ModelProperty")) {
240
+ return;
241
+ }
242
+ if (!validateDecoratorTarget(context, values, "@resourceParameterBaseFor", "Tuple")) {
243
+ return;
244
+ }
245
+ const resolvedValues = [];
246
+ for (const value of values.values) {
247
+ if (value.kind !== "EnumMember") {
248
+ return;
249
+ }
250
+ resolvedValues.push(value.name);
251
+ }
252
+ context.program.stateMap(parameterBaseTypesKey).set(entity, resolvedValues);
253
+ }
254
+ export function $resourceBaseParametersOf(context, entity, resourceType) {
255
+ if (!validateDecoratorTarget(context, entity, "@resourceBaseParameterseOf", "Model")) {
256
+ return;
257
+ }
258
+ if (!validateDecoratorTarget(context, resourceType, "@resourceBaseParameterseOf", "Model")) {
259
+ return;
260
+ }
261
+ const targetResourceBaseType = getResourceBaseType(context.program, resourceType);
262
+ const removedProperties = [];
263
+ for (const [propertyName, property] of entity.properties) {
264
+ if (!isResourceParameterBaseForInternal(context.program, property, targetResourceBaseType))
265
+ removedProperties.push(propertyName);
266
+ }
267
+ for (const removedProperty of removedProperties) {
268
+ entity.properties.delete(removedProperty);
269
+ }
270
+ }
271
+ export function $omitIfEmpty(context, entity, propertyName) {
272
+ if (!validateDecoratorTarget(context, entity, "@omitIfEmpty", "Model")) {
273
+ return;
274
+ }
275
+ const modelProp = getProperty(entity, propertyName);
276
+ if (modelProp &&
277
+ modelProp.type.kind === "Model" &&
278
+ !hasProperty(context.program, modelProp.type)) {
279
+ entity.properties.delete(propertyName);
280
+ }
281
+ }
282
+ export function isResourceParameterBaseFor(program, property, resourceBaseType) {
283
+ return isResourceParameterBaseForInternal(program, property, resolveResourceBaseType(resourceBaseType));
284
+ }
285
+ function isResourceParameterBaseForInternal(program, property, resolvedBaseType) {
286
+ const resourceBases = getResourceParameterBases(program, property);
287
+ if (resourceBases !== undefined) {
288
+ for (const rawType of resourceBases) {
289
+ if (resolveResourceBaseType(rawType) === resolvedBaseType)
290
+ return true;
291
+ }
292
+ }
293
+ return false;
294
+ }
295
+ export function getResourceParameterBases(program, property) {
296
+ return program.stateMap(parameterBaseTypesKey).get(property);
297
+ }
298
+ function setResourceBaseType(program, resource, type) {
299
+ if (program.stateMap(resourceBaseTypeKey).has(resource)) {
300
+ reportDiagnostic(program, {
301
+ code: "arm-resource-duplicate-base-parameter",
302
+ target: resource,
303
+ });
304
+ }
305
+ program.stateMap(resourceBaseTypeKey).set(resource, type);
306
+ }
307
+ export function getResourceBaseType(program, resource) {
308
+ const parentTracker = new Set();
309
+ let parent = getParentResource(program, resource);
310
+ while (parent !== undefined) {
311
+ if (parentTracker.has(parent))
312
+ reportDiagnostic(program, { code: "arm-resource-circular-ancestry", target: resource });
313
+ parentTracker.add(parent);
314
+ resource = parent;
315
+ parent = getParentResource(program, resource);
316
+ }
317
+ const keyValue = program.stateMap(resourceBaseTypeKey).get(resource);
318
+ return resolveResourceBaseType(keyValue);
319
+ }
320
+ function resolveResourceBaseType(type) {
321
+ let resolvedType = ResourceBaseType.ResourceGroup;
322
+ if (type !== undefined) {
323
+ switch (type) {
324
+ case "Tenant":
325
+ resolvedType = ResourceBaseType.Tenant;
326
+ break;
327
+ case "Subscription":
328
+ resolvedType = ResourceBaseType.Subscription;
329
+ break;
330
+ case "Location":
331
+ resolvedType = ResourceBaseType.Location;
332
+ break;
333
+ case "ResourceGroup":
334
+ resolvedType = ResourceBaseType.ResourceGroup;
335
+ break;
336
+ case "Extension":
337
+ resolvedType = ResourceBaseType.Extension;
338
+ break;
339
+ }
340
+ }
341
+ return resolvedType;
342
+ }
343
+ function getProperty(model, propertyName) {
344
+ var _a;
345
+ let returnProperty = (_a = model.properties) === null || _a === void 0 ? void 0 : _a.get(propertyName);
346
+ if (!returnProperty && model.baseModel) {
347
+ returnProperty = getProperty(model.baseModel, propertyName);
348
+ }
349
+ return returnProperty;
350
+ }
351
+ function hasProperty(program, model) {
352
+ if (model.properties.size > 0)
353
+ return true;
354
+ if (model.baseModel)
355
+ return hasProperty(program, model.baseModel);
356
+ return false;
357
+ }
358
+ //# sourceMappingURL=resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,WAAW,EAEX,UAAU,EACV,OAAO,EACP,WAAW,EAKX,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAyB,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAsBnF,MAAM,eAAe,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;AAC1D,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AACtE,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,uBAAuB,CAAC,CAAC;AAE5E,SAAS,yBAAyB,CAChC,OAAgB,EAChB,QAAgC;IAE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