@azure-tools/typespec-azure-resource-manager 0.31.0-dev.4 → 0.31.0-dev.6
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/{internal.d.ts → private.decorators.d.ts} +29 -9
- 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 +3 -19
- package/dist/src/resource.d.ts.map +1 -1
- package/dist/src/resource.js +6 -150
- 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 +17 -9
- package/lib/arm.tsp +1 -2
- package/lib/decorators.tsp +7 -38
- package/lib/interfaces.tsp +19 -12
- package/lib/models.tsp +1 -0
- package/lib/operations.tsp +16 -16
- 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.map +0 -1
- package/dist/src/internal.js +0 -123
- package/dist/src/internal.js.map +0 -1
- package/lib/arm.foundations.decorators.tsp +0 -37
package/dist/src/internal.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
export const namespace = "Azure.ResourceManager.Foundations";
|
|
2
|
-
import { $useRef } from "@azure-tools/typespec-autorest";
|
|
3
|
-
import { getSegment } from "@typespec/rest";
|
|
4
|
-
import { reportDiagnostic } from "./lib.js";
|
|
5
|
-
import { getArmProviderNamespace } from "./namespace.js";
|
|
6
|
-
function getArmTypesPath(program) {
|
|
7
|
-
return program.getOption("arm-types-path") || "{arm-types-dir}";
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Using ARM common definition for a Model
|
|
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 function $armCommonDefinition(context, entity, definitionName, version, referenceFile) {
|
|
19
|
-
// Use the name of the model type if not specified
|
|
20
|
-
if (!definitionName) {
|
|
21
|
-
definitionName = entity.name;
|
|
22
|
-
}
|
|
23
|
-
const basePath = getArmTypesPath(context.program).trim();
|
|
24
|
-
// for backward compatibility, skip if we are trying to access a non-default file and emit the type
|
|
25
|
-
if ((version || referenceFile) && basePath.endsWith(".json"))
|
|
26
|
-
return;
|
|
27
|
-
if (!version)
|
|
28
|
-
version = "v3";
|
|
29
|
-
if (!referenceFile)
|
|
30
|
-
referenceFile = "types.json";
|
|
31
|
-
const path = basePath.endsWith(".json")
|
|
32
|
-
? `${basePath}#/definitions/${definitionName}`
|
|
33
|
-
: `${basePath}/${version}/${referenceFile}#/definitions/${definitionName}`;
|
|
34
|
-
context.call($useRef, entity, path);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Refer an model property to be a common ARM parameter
|
|
38
|
-
* @param {DecoratorContext} context DecoratorContext object
|
|
39
|
-
* @param {Type} entity Decorator target type. Must be `Model`
|
|
40
|
-
* @param {string?} definitionName Optional definition name
|
|
41
|
-
* @param {string?} version Optional version
|
|
42
|
-
* @param {string?} referenceFile Optional common file path
|
|
43
|
-
* @returns void
|
|
44
|
-
*/
|
|
45
|
-
export function $armCommonParameter(context, entity, parameterName, version, referenceFile) {
|
|
46
|
-
// Use the name of the model type if not specified
|
|
47
|
-
if (!parameterName) {
|
|
48
|
-
parameterName = entity.name;
|
|
49
|
-
}
|
|
50
|
-
const basePath = getArmTypesPath(context.program).trim();
|
|
51
|
-
// for backward compatibility, skip if we are trying to access a non-default file and emit the type
|
|
52
|
-
if ((version || referenceFile) && basePath.endsWith(".json"))
|
|
53
|
-
return;
|
|
54
|
-
if (!version)
|
|
55
|
-
version = "v3";
|
|
56
|
-
if (!referenceFile)
|
|
57
|
-
referenceFile = "types.json";
|
|
58
|
-
const path = basePath.endsWith(".json")
|
|
59
|
-
? `${basePath}#/parameters/${parameterName}`
|
|
60
|
-
: `${basePath}/${version}/${referenceFile}#/parameters/${parameterName}`;
|
|
61
|
-
context.call($useRef, entity, path);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* This decorator dynamically assigns the serviceNamespace from the containing
|
|
65
|
-
* namespace to the string literal value of the path parameter to which this
|
|
66
|
-
* decorator is applied. Its purpose is to dynamically insert the provider
|
|
67
|
-
* namespace (e.g. 'Microsoft.CodeSigning') into the path parameter list.
|
|
68
|
-
* @param {DecoratorContext} context DecoratorContext
|
|
69
|
-
* @param {Type} target Target of this decorator. Must be a string `ModelProperty`.
|
|
70
|
-
* @param {Type} resourceType Must be a `Model`.
|
|
71
|
-
*/
|
|
72
|
-
export function $assignProviderNameValue(context, target, resourceType) {
|
|
73
|
-
const { program } = context;
|
|
74
|
-
const armProviderNamespace = getArmProviderNamespace(program, resourceType);
|
|
75
|
-
if (armProviderNamespace) {
|
|
76
|
-
target.type.value = armProviderNamespace;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Update the ARM provider namespace for a given entity.
|
|
81
|
-
* @param {DecoratorContext} context DecoratorContext
|
|
82
|
-
* @param {Type} entity Entity to set namespace. Must be a `Operation`.
|
|
83
|
-
* @returns
|
|
84
|
-
*/
|
|
85
|
-
export function $armUpdateProviderNamespace(context, entity) {
|
|
86
|
-
const { program } = context;
|
|
87
|
-
const operation = entity;
|
|
88
|
-
const opInterface = operation.interface;
|
|
89
|
-
if (opInterface && opInterface.namespace) {
|
|
90
|
-
const armProviderNamespace = getArmProviderNamespace(program, opInterface.namespace);
|
|
91
|
-
if (armProviderNamespace) {
|
|
92
|
-
// Set the namespace constant on the 'provider' parameter
|
|
93
|
-
const providerParam = operation.parameters.properties.get("provider");
|
|
94
|
-
if (providerParam) {
|
|
95
|
-
if (providerParam.type.kind !== "String") {
|
|
96
|
-
reportDiagnostic(program, {
|
|
97
|
-
code: "decorator-param-wrong-type",
|
|
98
|
-
messageId: "armUpdateProviderNamespace",
|
|
99
|
-
target: providerParam,
|
|
100
|
-
});
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
providerParam.type.value = armProviderNamespace;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check if an interface is extending the Azure.ResourceManager.Operations interface.
|
|
110
|
-
*/
|
|
111
|
-
export function isArmOperationsListInterface(program, type) {
|
|
112
|
-
if (type.name !== "Operations") {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
const listOperation = type.operations.get("list");
|
|
116
|
-
if (listOperation) {
|
|
117
|
-
if (getSegment(program, listOperation) === "operations") {
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=internal.js.map
|
package/dist/src/internal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,mCAAmC,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAUzD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,SAAS,eAAe,CAAC,OAAgB;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,iBAAiB,CAAC;AAClE,CAAC;AAED;;;;;;;;GAQG;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AAE;wBACxB,IAAI,EAAE,4BAA4B;wBAClC,SAAS,EAAE,4BAA4B;wBACvC,MAAM,EAAE,aAAa;qBACtB,CAAC,CAAC;oBACH,OAAO;iBACR;gBAED,aAAa,CAAC,IAAI,CAAC,KAAK,GAAG,oBAAoB,CAAC;aACjD;SACF;KACF;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAAgB,EAAE,IAAe;IAC5E,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;QAC9B,OAAO,KAAK,CAAC;KACd;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,IAAI,aAAa,EAAE;QACjB,IAAI,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,KAAK,YAAY,EAAE;YACvD,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
namespace Azure.ResourceManager.Foundations;
|
|
2
|
-
|
|
3
|
-
using TypeSpec.Reflection;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Update the ARM provider namespace for a given entity.
|
|
7
|
-
*/
|
|
8
|
-
extern dec armUpdateProviderNamespace(target: Reflection.Operation);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param resource Resource model
|
|
12
|
-
*/
|
|
13
|
-
extern dec assignProviderNameValue(target: ModelProperty, resource: Model);
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @param definitionName Definition name
|
|
17
|
-
* @param version Arm Version
|
|
18
|
-
* @param referenceFile Reference file
|
|
19
|
-
*/
|
|
20
|
-
extern dec armCommonDefinition(
|
|
21
|
-
target: Model,
|
|
22
|
-
definitionName?: string,
|
|
23
|
-
version?: string,
|
|
24
|
-
referenceFile?: string
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @param definitionName Definition name
|
|
29
|
-
* @param version Arm Version
|
|
30
|
-
* @param referenceFile Reference file
|
|
31
|
-
*/
|
|
32
|
-
extern dec armCommonParameter(
|
|
33
|
-
target: ModelProperty,
|
|
34
|
-
definitionName?: string,
|
|
35
|
-
version?: string,
|
|
36
|
-
referenceFile?: string
|
|
37
|
-
);
|