@microsoft/typespec-msgraph 0.0.1-Preview.3 → 0.0.1-Preview.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/components/alternate-keys-annotation.js +4 -4
- package/dist/src/components/alternate-keys-annotation.js.map +1 -1
- package/dist/src/components/annotations.d.ts +9 -0
- package/dist/src/components/annotations.d.ts.map +1 -0
- package/dist/src/components/annotations.js +50 -0
- package/dist/src/components/annotations.js.map +1 -0
- package/dist/src/components/common-elements.d.ts +17 -4
- package/dist/src/components/common-elements.d.ts.map +1 -1
- package/dist/src/components/common-elements.js +2 -2
- package/dist/src/components/common-elements.js.map +1 -1
- package/dist/src/components/computed-annotation.js +1 -1
- package/dist/src/components/computed-annotation.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +3 -8
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/description-annotation.d.ts.map +1 -1
- package/dist/src/components/description-annotation.js +1 -0
- package/dist/src/components/description-annotation.js.map +1 -1
- package/dist/src/components/entity-container-element.d.ts +18 -3
- package/dist/src/components/entity-container-element.d.ts.map +1 -1
- package/dist/src/components/entity-container-element.js +6 -42
- package/dist/src/components/entity-container-element.js.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +7 -13
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/operation-element.js +3 -3
- package/dist/src/components/operation-element.js.map +1 -1
- package/dist/src/components/schema-element.d.ts.map +1 -1
- package/dist/src/components/schema-element.js +6 -3
- package/dist/src/components/schema-element.js.map +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +3 -8
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +1 -6
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +7 -13
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/structured-type-element.d.ts +4 -7
- package/dist/src/components/structured-type-element.d.ts.map +1 -1
- package/dist/src/components/structured-type-element.js +21 -23
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +1 -4
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/decorators/{handlers/custom/additional-query-parameters.d.ts → additional-query-parameters.d.ts} +4 -3
- package/dist/src/decorators/additional-query-parameters.d.ts.map +1 -0
- package/dist/src/decorators/additional-query-parameters.js +21 -0
- package/dist/src/decorators/additional-query-parameters.js.map +1 -0
- package/dist/src/decorators/ags-attribute.d.ts +13 -0
- package/dist/src/decorators/ags-attribute.d.ts.map +1 -0
- package/dist/src/decorators/ags-attribute.js +68 -0
- package/dist/src/decorators/ags-attribute.js.map +1 -0
- package/dist/src/decorators/delta-collection.d.ts +8 -0
- package/dist/src/decorators/delta-collection.d.ts.map +1 -0
- package/dist/src/decorators/delta-collection.js +12 -0
- package/dist/src/decorators/delta-collection.js.map +1 -0
- package/dist/src/decorators/deprecated-definition.d.ts +3 -4
- package/dist/src/decorators/deprecated-definition.d.ts.map +1 -1
- package/dist/src/decorators/deprecated-definition.js +1 -7
- package/dist/src/decorators/deprecated-definition.js.map +1 -1
- package/dist/src/decorators/expand.d.ts +1 -2
- package/dist/src/decorators/expand.d.ts.map +1 -1
- package/dist/src/decorators/expand.js +1 -1
- package/dist/src/decorators/expand.js.map +1 -1
- package/dist/src/decorators/function.d.ts +1 -2
- package/dist/src/decorators/function.d.ts.map +1 -1
- package/dist/src/decorators/function.js +1 -1
- package/dist/src/decorators/function.js.map +1 -1
- package/dist/src/decorators/graph-route.d.ts +9 -0
- package/dist/src/decorators/graph-route.d.ts.map +1 -0
- package/dist/src/decorators/graph-route.js +84 -0
- package/dist/src/decorators/graph-route.js.map +1 -0
- package/dist/src/decorators/has-stream.d.ts +1 -2
- package/dist/src/decorators/has-stream.d.ts.map +1 -1
- package/dist/src/decorators/has-stream.js +1 -1
- package/dist/src/decorators/has-stream.js.map +1 -1
- package/dist/src/decorators/index.d.ts +9 -2
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +9 -2
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/is-owner.d.ts +9 -0
- package/dist/src/decorators/is-owner.d.ts.map +1 -0
- package/dist/src/decorators/is-owner.js +14 -0
- package/dist/src/decorators/is-owner.js.map +1 -0
- package/dist/src/decorators/order-by.d.ts +1 -2
- package/dist/src/decorators/order-by.d.ts.map +1 -1
- package/dist/src/decorators/order-by.js +1 -1
- package/dist/src/decorators/order-by.js.map +1 -1
- package/dist/src/decorators/paged-collection.d.ts +8 -0
- package/dist/src/decorators/paged-collection.d.ts.map +1 -0
- package/dist/src/decorators/paged-collection.js +12 -0
- package/dist/src/decorators/paged-collection.js.map +1 -0
- package/dist/src/decorators/private-preview-definition.d.ts +3 -4
- package/dist/src/decorators/private-preview-definition.d.ts.map +1 -1
- package/dist/src/decorators/private-preview-definition.js +1 -6
- package/dist/src/decorators/private-preview-definition.js.map +1 -1
- package/dist/src/decorators/private-preview.d.ts +1 -2
- package/dist/src/decorators/private-preview.d.ts.map +1 -1
- package/dist/src/decorators/private-preview.js +1 -1
- package/dist/src/decorators/private-preview.js.map +1 -1
- package/dist/src/decorators/privileged.d.ts +9 -0
- package/dist/src/decorators/privileged.d.ts.map +1 -0
- package/dist/src/decorators/privileged.js +13 -0
- package/dist/src/decorators/privileged.js.map +1 -0
- package/dist/src/decorators/workload-name-msa.d.ts +9 -0
- package/dist/src/decorators/workload-name-msa.d.ts.map +1 -0
- package/dist/src/decorators/workload-name-msa.js +13 -0
- package/dist/src/decorators/workload-name-msa.js.map +1 -0
- package/dist/src/decorators/workload-name.d.ts +9 -0
- package/dist/src/decorators/workload-name.d.ts.map +1 -0
- package/dist/src/decorators/workload-name.js +13 -0
- package/dist/src/decorators/workload-name.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +30 -0
- package/dist/src/entities/annotations.d.ts.map +1 -0
- package/dist/src/entities/annotations.js +97 -0
- package/dist/src/entities/annotations.js.map +1 -0
- package/dist/src/entities/entity-container.d.ts +3 -24
- package/dist/src/entities/entity-container.d.ts.map +1 -1
- package/dist/src/entities/entity-container.js +24 -118
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/enum.d.ts.map +1 -1
- package/dist/src/entities/enum.js +3 -3
- package/dist/src/entities/enum.js.map +1 -1
- package/dist/src/entities/model.d.ts +12 -22
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +64 -101
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +7 -2
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +20 -13
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts +2 -2
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +30 -14
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +25 -25
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/count.d.ts.map +1 -1
- package/dist/src/rules/count.js +3 -1
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/entity.d.ts.map +1 -1
- package/dist/src/rules/entity.js +4 -1
- package/dist/src/rules/entity.js.map +1 -1
- package/dist/src/rules/expand.d.ts.map +1 -1
- package/dist/src/rules/expand.js +5 -7
- package/dist/src/rules/expand.js.map +1 -1
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +1 -0
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/order-by.d.ts +1 -1
- package/dist/src/rules/order-by.d.ts.map +1 -1
- package/dist/src/rules/order-by.js +11 -10
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/search.d.ts.map +1 -1
- package/dist/src/rules/search.js +3 -1
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.d.ts.map +1 -1
- package/dist/src/rules/skip.js +3 -1
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.d.ts.map +1 -1
- package/dist/src/rules/top.js +3 -1
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/utils.d.ts +16 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +89 -1
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +90 -14
- package/lib/deployment.tsp +18 -0
- package/lib/lib.tsp +9 -14
- package/lib/msgraph.tsp +4 -0
- package/lib/porcelain.tsp +135 -0
- package/lib/responses.tsp +82 -0
- package/lib/shared-models.tsp +74 -0
- package/package.json +6 -10
- package/dist/src/decorators/attribute-builder.d.ts +0 -2
- package/dist/src/decorators/attribute-builder.d.ts.map +0 -1
- package/dist/src/decorators/attribute-builder.js +0 -166
- package/dist/src/decorators/attribute-builder.js.map +0 -1
- package/dist/src/decorators/attributes.d.ts +0 -57
- package/dist/src/decorators/attributes.d.ts.map +0 -1
- package/dist/src/decorators/attributes.js +0 -50
- package/dist/src/decorators/attributes.js.map +0 -1
- package/dist/src/decorators/decorator-parameter.d.ts +0 -4
- package/dist/src/decorators/decorator-parameter.d.ts.map +0 -1
- package/dist/src/decorators/decorator-parameter.js +0 -2
- package/dist/src/decorators/decorator-parameter.js.map +0 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js +0 -38
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js.map +0 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts +0 -8
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.js +0 -36
- package/dist/src/decorators/handlers/custom/ags-attribute.js.map +0 -1
- package/dist/src/decorators/handlers/custom/index.d.ts +0 -3
- package/dist/src/decorators/handlers/custom/index.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/index.js +0 -3
- package/dist/src/decorators/handlers/custom/index.js.map +0 -1
- package/dist/src/decorators/handlers/index.d.ts +0 -31
- package/dist/src/decorators/handlers/index.d.ts.map +0 -1
- package/dist/src/decorators/handlers/index.js +0 -121
- package/dist/src/decorators/handlers/index.js.map +0 -1
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getNamespaceFullName, isArrayModelType, } from "@typespec/compiler";
|
|
2
2
|
import { getEntity, isEntity } from "./decorators/index.js";
|
|
3
|
+
import { getRoutePath } from "@typespec/http";
|
|
3
4
|
export function getNameForType(program, type) {
|
|
4
5
|
switch (type.kind) {
|
|
5
6
|
case "Union":
|
|
@@ -87,6 +88,30 @@ export function getNavigationTypeId(program, getOperation) {
|
|
|
87
88
|
}
|
|
88
89
|
return getIdForType(program, returnType.templateArguments[0]);
|
|
89
90
|
}
|
|
91
|
+
export function getInterfacesOfKinds(program, navigationSources, kinds) {
|
|
92
|
+
const map = new Map();
|
|
93
|
+
navigationSources.forEach(theInterface => {
|
|
94
|
+
var _a;
|
|
95
|
+
if (!theInterface.sourceInterfaces.some(s => kinds.includes(s.name))) {
|
|
96
|
+
// if source interfaces DO NOT have the kinds.
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const routePath = (_a = getRoutePath(program, theInterface)) === null || _a === void 0 ? void 0 : _a.path.split("/")[0];
|
|
100
|
+
if (!routePath) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
let operations = [...theInterface.operations.values()];
|
|
104
|
+
if (map.has(routePath)) {
|
|
105
|
+
const existing = map.get(routePath);
|
|
106
|
+
operations = [...operations, ...existing.operations];
|
|
107
|
+
}
|
|
108
|
+
map.set(routePath, {
|
|
109
|
+
theInterface: theInterface,
|
|
110
|
+
operations: operations,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return map;
|
|
114
|
+
}
|
|
90
115
|
export function getPropertyTypeName(program, type) {
|
|
91
116
|
var _a;
|
|
92
117
|
if (type.kind === "Union") {
|
|
@@ -130,6 +155,28 @@ export function getSingletonTypeId(program, singletonType, getOperation) {
|
|
|
130
155
|
}
|
|
131
156
|
return getOperation && getNavigationTypeId(program, getOperation);
|
|
132
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Returns whether a type used as a return type matches Graph's definition of a collection
|
|
160
|
+
* @param program
|
|
161
|
+
* @param returnType
|
|
162
|
+
*/
|
|
163
|
+
export function isReturnTypeCollection(program, returnType) {
|
|
164
|
+
let returnTypes = [];
|
|
165
|
+
if (returnType.kind === "Model") {
|
|
166
|
+
returnTypes.push(returnType);
|
|
167
|
+
}
|
|
168
|
+
else if (returnType.kind === "Union") {
|
|
169
|
+
const extracted = extractTypesFromUnion(returnType).filter(t => t.kind === "Model");
|
|
170
|
+
returnTypes = returnTypes.concat(extracted);
|
|
171
|
+
}
|
|
172
|
+
if (returnTypes.length === 0) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return returnTypes.some(t => isTypeCollection(t));
|
|
176
|
+
}
|
|
177
|
+
function isTypeCollection(type) {
|
|
178
|
+
return type.kind === "Model" && (type.name === "Array" || type.name.includes("Collection"));
|
|
179
|
+
}
|
|
133
180
|
/**
|
|
134
181
|
* Imported from typespec-azure
|
|
135
182
|
* Returns the full namespace name for the given type, if available.
|
|
@@ -167,7 +214,12 @@ export function isExcludedCoreType(program, type) {
|
|
|
167
214
|
// https://github.com/Azure/typespec-azure/issues/801#issuecomment-1194454247
|
|
168
215
|
//
|
|
169
216
|
const nsName = getNamespaceName(program, type);
|
|
170
|
-
const excludedNamespaces = ["TypeSpec"
|
|
217
|
+
const excludedNamespaces = ["TypeSpec"];
|
|
218
|
+
return excludedNamespaces.find((ns) => nsName.startsWith(ns)) !== undefined;
|
|
219
|
+
}
|
|
220
|
+
export function isExcludedLibraryType(program, type) {
|
|
221
|
+
const nsName = getNamespaceName(program, type);
|
|
222
|
+
const excludedNamespaces = ["TypeSpec", "MicrosoftGraph"];
|
|
171
223
|
return excludedNamespaces.find((ns) => nsName.startsWith(ns)) !== undefined;
|
|
172
224
|
}
|
|
173
225
|
export function isNavigationProperty(program, property) {
|
|
@@ -183,4 +235,40 @@ export function isNavigationProperty(program, property) {
|
|
|
183
235
|
}
|
|
184
236
|
return isEntity(program, propertyType);
|
|
185
237
|
}
|
|
238
|
+
export function getNavigationSources(program, namespace) {
|
|
239
|
+
return [...namespace.interfaces.values()].filter(theInterface => isNavigationSource(theInterface));
|
|
240
|
+
}
|
|
241
|
+
export function isNavigationSource(theInterface) {
|
|
242
|
+
return findNavigationSource(theInterface) !== undefined;
|
|
243
|
+
}
|
|
244
|
+
// Get the type returned by all operations in an interface representing a navigation source.
|
|
245
|
+
// This is the 'T' in EntitySet<T> and friends.
|
|
246
|
+
export function getInterfaceNavigationSourceType(program, theInterface) {
|
|
247
|
+
var _a;
|
|
248
|
+
const navSource = findNavigationSource(theInterface);
|
|
249
|
+
if (navSource === undefined) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
return (_a = navSource.templateMapper) === null || _a === void 0 ? void 0 : _a.args[0];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Get the type returned by all operations in an interface representing a navigation source.
|
|
257
|
+
export function getNavigationSourceType(program, operation) {
|
|
258
|
+
return getInterfaceNavigationSourceType(program, operation.interface);
|
|
259
|
+
}
|
|
260
|
+
function findNavigationSource(theInterface) {
|
|
261
|
+
for (const baseInterface of theInterface.sourceInterfaces) {
|
|
262
|
+
if (baseInterface.name === "SingleNavigationSource" || baseInterface.name === "CollectionNavigationSource") {
|
|
263
|
+
return baseInterface;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
const baseBase = findNavigationSource(baseInterface);
|
|
267
|
+
if (baseBase !== undefined) {
|
|
268
|
+
return baseBase;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return undefined;
|
|
273
|
+
}
|
|
186
274
|
//# sourceMappingURL=utils.js.map
|
package/dist/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EAEpB,gBAAgB,GASjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EAEpB,gBAAgB,GASjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAO9C,MAAM,UAAU,cAAc,CAAC,OAAgB,EAAE,IAAU;IACzD,QAAQ,IAAI,CAAC,IAAI,EAAE;QACjB,KAAK,OAAO;YACV,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5E,KAAK,mBAAmB;YACtB,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACzB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QACzB,KAA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,CAAC,IAAI,KAAK,wBAAwB,IAAI,aAAa,CAAC,IAAI,KAAK,4BAA4B,EAAE;YAC1G,OAAO,aAAa,CAAC;SACtB;aACI;YACH,MAAM,QAAQ,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;YACrD,IAAI,QAAQ,KAAK,SAAS,EAAG;gBAC3B,OAAO,QAAQ,CAAC;aACjB;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/lib/decorators.tsp
CHANGED
|
@@ -48,11 +48,11 @@ extern dec count(target: Operation);
|
|
|
48
48
|
*/
|
|
49
49
|
extern dec deprecatedDefinition(
|
|
50
50
|
target: Namespace,
|
|
51
|
-
name: string,
|
|
52
|
-
category: string,
|
|
53
|
-
announcementDate: string,
|
|
54
|
-
removalDate: string,
|
|
55
|
-
description: string
|
|
51
|
+
name: valueof string,
|
|
52
|
+
category: valueof string,
|
|
53
|
+
announcementDate: valueof string,
|
|
54
|
+
removalDate: valueof string,
|
|
55
|
+
description: valueof string
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -69,21 +69,21 @@ extern dec entity(target: Model);
|
|
|
69
69
|
* `properties` - Property names in the model returned from the get that can be used in a $expand query parameter.
|
|
70
70
|
* At least one property must be specified.
|
|
71
71
|
*/
|
|
72
|
-
extern dec expand(target: Operation, property: string, ...otherProperties: string[]);
|
|
72
|
+
extern dec expand(target: Operation, property: valueof string, ...otherProperties: valueof string[]);
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* `@function` - mark an operation as a function
|
|
76
76
|
*
|
|
77
77
|
* `@function` can only be applied to operations.
|
|
78
78
|
*/
|
|
79
|
-
extern dec function(target: Operation, name?: string);
|
|
79
|
+
extern dec function(target: Operation, name?: valueof string);
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* `@hasStream` - indicates that an `@entity` model has a stream.
|
|
83
83
|
*
|
|
84
84
|
* `mediaTypes` - list of media types supported by the stream. If not specified, the stream supports any media type.
|
|
85
85
|
*/
|
|
86
|
-
extern dec hasStream(target: Model, ...mediaTypes: string[]);
|
|
86
|
+
extern dec hasStream(target: Model, ...mediaTypes: valueof string[]);
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* `@open` - mark a model type as open
|
|
@@ -108,7 +108,7 @@ extern dec operationParameters(target: Model);
|
|
|
108
108
|
* `properties` - List of property names in the model returned from the get operation that can be used in a $orderBy query parameter.
|
|
109
109
|
* At least one property must be specified.
|
|
110
110
|
*/
|
|
111
|
-
extern dec orderBy(target: Operation, property: string, ...otherProperties: string[]);
|
|
111
|
+
extern dec orderBy(target: Operation, property: valueof string, ...otherProperties: valueof string[]);
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
114
|
* `@privatePreview` - Allow us define a privatePreview element.
|
|
@@ -116,7 +116,7 @@ extern dec orderBy(target: Operation, property: string, ...otherProperties: stri
|
|
|
116
116
|
*/
|
|
117
117
|
extern dec privatePreview(
|
|
118
118
|
target: Model | ModelProperty | EnumMember | Enum | Operation | Namespace,
|
|
119
|
-
name: string
|
|
119
|
+
name: valueof string
|
|
120
120
|
);
|
|
121
121
|
|
|
122
122
|
/**
|
|
@@ -125,10 +125,10 @@ extern dec privatePreview(
|
|
|
125
125
|
*/
|
|
126
126
|
extern dec privatePreviewDefinition(
|
|
127
127
|
target: Namespace,
|
|
128
|
-
name: string,
|
|
129
|
-
announcementDate: string,
|
|
130
|
-
removalDate: string,
|
|
131
|
-
owner: string
|
|
128
|
+
name: valueof string,
|
|
129
|
+
announcementDate: valueof string,
|
|
130
|
+
removalDate: valueof string,
|
|
131
|
+
owner: valueof string
|
|
132
132
|
);
|
|
133
133
|
|
|
134
134
|
/**
|
|
@@ -169,3 +169,79 @@ extern dec top(target: Operation);
|
|
|
169
169
|
* `@writeOnly` can only be applied to model properties.
|
|
170
170
|
*/
|
|
171
171
|
extern dec writeOnly(target: ModelProperty);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `@additionalQueryParameters` - Appends a key=value pair to the query string of the mapped internal URL for all models defined within the namespace.
|
|
175
|
+
*
|
|
176
|
+
* `@additionalQueryParameters` can only be applied to namespaces
|
|
177
|
+
*/
|
|
178
|
+
extern dec additionalQueryParameters(target: Namespace, name: valueof string, value: valueof string);
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* `@agsAttribute` - Allows all AGS CSDL extensions that are not yet modelled explicitly in TypeSpec to be maintained
|
|
182
|
+
*
|
|
183
|
+
* `@agsAttribute` - Applies to models.
|
|
184
|
+
*/
|
|
185
|
+
extern dec agsAttribute(
|
|
186
|
+
target: Model | ModelProperty | Enum | EnumMember | Operation | Interface,
|
|
187
|
+
name: valueof string,
|
|
188
|
+
value: valueof string
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* `@isOwner` - specify that this workload is the primary owner of this entity model
|
|
193
|
+
*
|
|
194
|
+
* `@isOwner` can be applied to Model where the model also has an @entity decorator or a ModelProperty where it has either an @contains or @references decorator.
|
|
195
|
+
*/
|
|
196
|
+
extern dec isOwner(target: Model | ModelProperty);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* `@privileged` - mark the entity as privileged
|
|
200
|
+
*
|
|
201
|
+
* `@privileged` can be applied to Model, ModelProperty, Enum, EnumMember, Operation, Namespace.
|
|
202
|
+
*/
|
|
203
|
+
extern dec privileged(target: Model | ModelProperty | Enum | EnumMember | Operation | Namespace);
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* `@workloadName` - specifies the name used by the underlying workload
|
|
207
|
+
*
|
|
208
|
+
* `@workloadName` can be applied to Model, ModelProperty, Enum, EnumMember.
|
|
209
|
+
*/
|
|
210
|
+
extern dec workloadName(
|
|
211
|
+
target: Model | ModelProperty | Enum | EnumMember,
|
|
212
|
+
workloadName: valueof string
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* `@workloadNameMsa` - specifies the name used by the underlying workload for consumer use cases
|
|
217
|
+
*
|
|
218
|
+
* `@workloadNameMsa` can be applied to Model, ModelProperty, Enum, EnumMember.
|
|
219
|
+
*/
|
|
220
|
+
extern dec workloadNameMsa(
|
|
221
|
+
target: Model | ModelProperty | Enum | EnumMember,
|
|
222
|
+
workloadNameMsa: valueof string
|
|
223
|
+
);
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* `@pagedCollection` - mark a model as representing a paged collection.
|
|
227
|
+
*
|
|
228
|
+
* `@pagedCollection` can only be applied to models.
|
|
229
|
+
*/
|
|
230
|
+
extern dec pagedCollection(target: Model);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* `@deltaCollection` - mark a model as representing a delta paged collection.
|
|
234
|
+
*
|
|
235
|
+
* `@deltaCollection` can only be applied to models.
|
|
236
|
+
*/
|
|
237
|
+
extern dec deltaCollection(target: Model);
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* `@graphRoute` - mark an interface or operation with an HTTP route.
|
|
241
|
+
*
|
|
242
|
+
* `@graphRoute` - can only be applied to interfaces or operations.
|
|
243
|
+
*/
|
|
244
|
+
// TODO: Using @graphRoute on an operation currently does not work due to the following TypeSpec core issue
|
|
245
|
+
// https://github.com/microsoft/typespec/issues/2106
|
|
246
|
+
// Disabling all related features while we await the outcome.
|
|
247
|
+
extern dec graphRoute(target: Interface /* | Operation */, path: valueof string);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
namespace TypeSpec.MsGraph.Deployment;
|
|
2
|
+
|
|
3
|
+
enum deploymentTargets {
|
|
4
|
+
prodBeta,
|
|
5
|
+
prodV1_0,
|
|
6
|
+
prodEdu,
|
|
7
|
+
ppeBeta,
|
|
8
|
+
ppeV1_0,
|
|
9
|
+
ppeEdu,
|
|
10
|
+
mooncakeBeta,
|
|
11
|
+
mooncakeV1_0,
|
|
12
|
+
fairfaxBeta,
|
|
13
|
+
fairfaxV1_0,
|
|
14
|
+
usNatBeta,
|
|
15
|
+
usNatV1_0,
|
|
16
|
+
usSecBeta,
|
|
17
|
+
usSecV1_0
|
|
18
|
+
}
|
package/lib/lib.tsp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../dist/src/index.js";
|
|
2
|
-
import "@typespec/
|
|
2
|
+
import "@typespec/http";
|
|
3
3
|
|
|
4
4
|
using TypeSpec.Http;
|
|
5
5
|
namespace TypeSpec.MsGraph;
|
|
@@ -8,28 +8,23 @@ scalar date;
|
|
|
8
8
|
|
|
9
9
|
scalar stream;
|
|
10
10
|
|
|
11
|
-
model ResourceResponse {}
|
|
12
|
-
|
|
13
11
|
model EmptyParameters {}
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
// --- Base interfaces for all interfaces that contain operations returning entities.
|
|
14
|
+
interface SingleNavigationSource<T> {}
|
|
15
|
+
interface CollectionNavigationSource<T> {}
|
|
16
16
|
|
|
17
|
-
interface
|
|
18
|
-
@head _isOperation(@path id: string): T;
|
|
17
|
+
interface Resource<T> extends SingleNavigationSource<T> {
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
interface
|
|
22
|
-
@head _isOperation(): T[];
|
|
20
|
+
interface Collection<T> extends CollectionNavigationSource<T> {
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
interface Singleton<T> {
|
|
26
|
-
@head _isNavigationSource(@path id: string): T;
|
|
23
|
+
interface Singleton<T> extends SingleNavigationSource<T> {
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
interface EntitySet<T> {
|
|
30
|
-
@head _isNavigationSource(): T[];
|
|
26
|
+
interface EntitySet<T> extends CollectionNavigationSource<T> {
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
interface EntitySetResource<T> {
|
|
34
|
-
@head _isNavigationSource(@path id: string): T[];
|
|
29
|
+
interface EntitySetResource<T> extends SingleNavigationSource<T> {
|
|
35
30
|
}
|
package/lib/msgraph.tsp
CHANGED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// -------------------------------------------------
|
|
2
|
+
// porcelain.tsp
|
|
3
|
+
// Operation templates to provide a much-simplified syntax for defining standard Graph operations.
|
|
4
|
+
// -------------------------------------------------
|
|
5
|
+
import "@typespec/http";
|
|
6
|
+
import "./lib.tsp";
|
|
7
|
+
import "./shared-models.tsp";
|
|
8
|
+
import "./responses.tsp";
|
|
9
|
+
|
|
10
|
+
using TypeSpec.Http;
|
|
11
|
+
using TypeSpec.MsGraph;
|
|
12
|
+
using TypeSpec.MsGraph.SharedModels;
|
|
13
|
+
using TypeSpec.MsGraph.Responses;
|
|
14
|
+
|
|
15
|
+
namespace TypeSpec.MsGraph;
|
|
16
|
+
|
|
17
|
+
namespace Foundations {
|
|
18
|
+
|
|
19
|
+
@doc("Foundational operations for individual resources and collections.")
|
|
20
|
+
interface GraphFoundations {
|
|
21
|
+
op Operation<TParams, TResponse, TErrorResponse>(
|
|
22
|
+
...TParams
|
|
23
|
+
): TResponse | TErrorResponse;
|
|
24
|
+
|
|
25
|
+
op ResourceOperation<
|
|
26
|
+
TResource extends {},
|
|
27
|
+
TParams,
|
|
28
|
+
TResponse,
|
|
29
|
+
TErrorResponse = ResourceErrorResponse
|
|
30
|
+
> is GraphFoundations.Operation<TParams, TResponse, TErrorResponse>;
|
|
31
|
+
|
|
32
|
+
op CollectionOperation<
|
|
33
|
+
TResource extends {},
|
|
34
|
+
TParams,
|
|
35
|
+
TResponse,
|
|
36
|
+
TErrorResponse = CollectionErrorResponse
|
|
37
|
+
> is GraphFoundations.Operation<TParams, TResponse, TErrorResponse>;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@doc("Primary operation shapes for Microsoft Graph")
|
|
42
|
+
interface GraphOps {
|
|
43
|
+
|
|
44
|
+
// TODO: This is how we should make $select standard for Graph. Define a select decorator and use it here.
|
|
45
|
+
// @select("*")
|
|
46
|
+
@get op GetCollection<
|
|
47
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
48
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
49
|
+
TResponse = CollectionResponse<TResource>,
|
|
50
|
+
TErrorResponse = CollectionErrorResponse
|
|
51
|
+
> is Foundations.GraphFoundations.CollectionOperation<
|
|
52
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
53
|
+
|
|
54
|
+
// @select("*")
|
|
55
|
+
@get op GetPagedCollection<
|
|
56
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
57
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
58
|
+
TResponse = PagedCollectionResponse<TResource>,
|
|
59
|
+
TErrorResponse = CollectionErrorResponse
|
|
60
|
+
> is Foundations.GraphFoundations.CollectionOperation<
|
|
61
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
62
|
+
|
|
63
|
+
// TODO: GetDelta? FUnction etc.?
|
|
64
|
+
|
|
65
|
+
// @select("*")
|
|
66
|
+
@post op Post<
|
|
67
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
68
|
+
TParams = { ... Automatic.GraphRouteParams, @body body: TResource },
|
|
69
|
+
TResponse = ResourceCreatedResponse<TResource>,
|
|
70
|
+
TErrorResponse = CollectionErrorResponse
|
|
71
|
+
> is Foundations.GraphFoundations.CollectionOperation<
|
|
72
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
73
|
+
|
|
74
|
+
// @select("*")
|
|
75
|
+
@get op Get<
|
|
76
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
77
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
78
|
+
TResponse = ResourceResponse<TResource>,
|
|
79
|
+
TErrorResponse = ResourceErrorResponse
|
|
80
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
81
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
82
|
+
|
|
83
|
+
@delete op Delete<
|
|
84
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
85
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
86
|
+
TResponse = EmptyResponse,
|
|
87
|
+
TErrorResponse = ResourceErrorResponse
|
|
88
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
89
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
90
|
+
|
|
91
|
+
@patch op PatchNoResponse<
|
|
92
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
93
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
94
|
+
TResponse = EmptyResponse,
|
|
95
|
+
TErrorResponse = ResourceErrorResponse
|
|
96
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
97
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
98
|
+
|
|
99
|
+
// @select("*")
|
|
100
|
+
@patch op PatchWithResponse<
|
|
101
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
102
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
103
|
+
TResponse = ResourceResponse<TResource>,
|
|
104
|
+
TErrorResponse = ResourceErrorResponse
|
|
105
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
106
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
107
|
+
|
|
108
|
+
@put op PutNoResponse<
|
|
109
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
110
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
111
|
+
TResponse = EmptyResponse,
|
|
112
|
+
TErrorResponse = ResourceErrorResponse
|
|
113
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
114
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
115
|
+
|
|
116
|
+
// @select("*")
|
|
117
|
+
@put op PutWithResponse<
|
|
118
|
+
TResource extends {} = Automatic.CalculatedResourceType,
|
|
119
|
+
TParams = {... Automatic.GraphRouteParams},
|
|
120
|
+
TResponse = ResourceResponse<TResource>,
|
|
121
|
+
TErrorResponse = ResourceErrorResponse
|
|
122
|
+
> is Foundations.GraphFoundations.ResourceOperation<
|
|
123
|
+
TResource, TParams, TResponse, TErrorResponse>;
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
namespace Automatic {
|
|
128
|
+
@doc("Marker type to allow injection of parameters from @route decorator.")
|
|
129
|
+
model GraphRouteParams { graphRouteParams: string }
|
|
130
|
+
|
|
131
|
+
// TODO: Needs direct support in the graphRoute decorator code to be able to make use of this.
|
|
132
|
+
@doc("Marker type to indicate to emitter that it should calculate resource from the Resource type of the containing interface's extended interface.")
|
|
133
|
+
model CalculatedResourceType {}
|
|
134
|
+
}
|
|
135
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// -------------------------------------------------
|
|
2
|
+
// responses.tsp
|
|
3
|
+
// Standard responses that Graph will return.
|
|
4
|
+
// -------------------------------------------------
|
|
5
|
+
import "@typespec/http";
|
|
6
|
+
import "@microsoft/typespec-msgraph";
|
|
7
|
+
import "./shared-models.tsp";
|
|
8
|
+
|
|
9
|
+
using TypeSpec.Http;
|
|
10
|
+
using TypeSpec.MsGraph;
|
|
11
|
+
using TypeSpec.MsGraph.SharedModels;
|
|
12
|
+
|
|
13
|
+
// Raw body models represent the content of the response body, without any additional metadata.
|
|
14
|
+
// Note that these are primarily marker types. CSDL has no notion of what actual body content is returned in such types,
|
|
15
|
+
// but by passing markers through, HIDI can translate to OpenAPI.
|
|
16
|
+
// The content of the types exists for other future emitters that run directly off TypeSpec.
|
|
17
|
+
namespace TypeSpec.MsGraph.Responses.Bodies {
|
|
18
|
+
|
|
19
|
+
@error
|
|
20
|
+
model ErrorBody {
|
|
21
|
+
error: publicError;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
model ResourceBody<TResource> {
|
|
25
|
+
...TResource;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
model CollectionBody<TResource> {
|
|
29
|
+
value: TResource[];
|
|
30
|
+
`@odata.count`?: int64;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@pagedCollection
|
|
34
|
+
model PagedCollectionBody<TResource> is CollectionBody<TResource> {
|
|
35
|
+
`@odata.nextLink`?: url;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@pagedCollection
|
|
39
|
+
@deltaCollection
|
|
40
|
+
model DeltaCollectionBody<TResource> is PagedCollectionBody<TResource> {
|
|
41
|
+
`@odata.deltaLink`?: url;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Response models represent the response as a whole, including the status code, headers, and body.
|
|
46
|
+
namespace TypeSpec.MsGraph.Responses {
|
|
47
|
+
@doc("Response to represent a Microsoft Graph collection response payload.")
|
|
48
|
+
model CollectionResponse<TResource, TStatus = 200, TBody = Bodies.CollectionBody<TResource>>
|
|
49
|
+
is Http.Response<TStatus> {
|
|
50
|
+
...Http.Body<TBody>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@doc("Response to represent a Microsoft Graph paged collection response payload.")
|
|
54
|
+
model PagedCollectionResponse<TResource, TStatus = 200, TBody = Bodies.PagedCollectionBody<TResource>>
|
|
55
|
+
is CollectionResponse<TResource, TStatus, TBody>;
|
|
56
|
+
|
|
57
|
+
@doc("Response to represent a Microsoft Graph individual resource response payload.")
|
|
58
|
+
model ResourceResponse<TResource, TStatus = 200, TBody = Bodies.ResourceBody<TResource>>
|
|
59
|
+
is Http.Response<TStatus> {
|
|
60
|
+
...Http.Body<TBody>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@doc("Response to represent a Microsoft Graph resource creation response payload.")
|
|
64
|
+
model ResourceCreatedResponse<TResource, TStatus = 201, TBody = Bodies.ResourceBody<TResource>>
|
|
65
|
+
is ResourceResponse<TResource, TStatus, TBody> {
|
|
66
|
+
...Http.LocationHeader
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@doc("Response to represent a Microsoft Graph empty response payload.")
|
|
70
|
+
model EmptyResponse
|
|
71
|
+
is Http.Response<204>;
|
|
72
|
+
|
|
73
|
+
@doc("Response to represent a Microsoft Graph error response payload.")
|
|
74
|
+
model ErrorResponse<TStatus>
|
|
75
|
+
is Http.Response<TStatus> {
|
|
76
|
+
...Http.Body<Bodies.ErrorBody>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
alias ResourceErrorResponse = ErrorResponse<400 | 404 | 429>;
|
|
80
|
+
alias CollectionErrorResponse = ErrorResponse<400 | 429>;
|
|
81
|
+
|
|
82
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// -------------------------------------------------
|
|
2
|
+
// shared-models.tsp
|
|
3
|
+
// Common types shared among many workloads on Microsoft Graph
|
|
4
|
+
// -------------------------------------------------
|
|
5
|
+
import "@microsoft/typespec-msgraph";
|
|
6
|
+
|
|
7
|
+
using TypeSpec.MsGraph;
|
|
8
|
+
|
|
9
|
+
namespace TypeSpec.MsGraph.SharedModels;
|
|
10
|
+
|
|
11
|
+
// TODO: Spec how to deal with specified and unspecified ultimate base entities w.r.t. AGS runtime replacement policies. See #140
|
|
12
|
+
@doc("The primary entity base model for Microsoft Graph.")
|
|
13
|
+
@entity
|
|
14
|
+
model msGraphEntity {
|
|
15
|
+
@key id: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@doc("Complex type to represent an identity principal by id, when a human-readable name is also useful.")
|
|
19
|
+
@complex
|
|
20
|
+
@open
|
|
21
|
+
model identity {
|
|
22
|
+
id: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@doc("Complex type to represent a group of identity principals used at a point in time, such as createdBy, lastModifiedBy.")
|
|
27
|
+
@complex
|
|
28
|
+
@open
|
|
29
|
+
model identitySet {
|
|
30
|
+
user: identity | null;
|
|
31
|
+
device: identity | null;
|
|
32
|
+
application: identity | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@doc("Enum for identifying the format of a text string.")
|
|
36
|
+
enum bodyType {
|
|
37
|
+
text,
|
|
38
|
+
html
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@doc("Complex type to represent a chunk of text that could be either plain text or html.")
|
|
42
|
+
@complex
|
|
43
|
+
model itemBody {
|
|
44
|
+
contentType: bodyType;
|
|
45
|
+
content: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@doc("Scalar type for URLs that would be expected to work in the browser address bar.")
|
|
49
|
+
scalar webUrl extends string;
|
|
50
|
+
|
|
51
|
+
@doc("Scalar type for URLs that represent Graph APIs.")
|
|
52
|
+
scalar url extends string;
|
|
53
|
+
|
|
54
|
+
@doc("Complex type to represent a nested error that potentially has other recursive nested errors.")
|
|
55
|
+
@complex
|
|
56
|
+
@open
|
|
57
|
+
model innerError {
|
|
58
|
+
code: string;
|
|
59
|
+
innererror: innerError | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@doc("""
|
|
63
|
+
Complex type to represent a standard Microsoft Graph error.
|
|
64
|
+
{code}: The error code.
|
|
65
|
+
""")
|
|
66
|
+
@complex
|
|
67
|
+
@error
|
|
68
|
+
model publicError {
|
|
69
|
+
code: string;
|
|
70
|
+
message: string;
|
|
71
|
+
target: string | null;
|
|
72
|
+
innererror: innerError | null;
|
|
73
|
+
details: publicError[];
|
|
74
|
+
}
|