@microsoft/typespec-msgraph 0.0.1-Preview.6 → 0.0.1-Preview.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/annotations.d.ts +5 -5
- package/dist/src/components/annotations.d.ts.map +1 -1
- package/dist/src/components/annotations.js +21 -20
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +2 -2
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +3 -3
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/filter-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/filter-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/filter-restrictions-annotation.js +10 -0
- package/dist/src/components/filter-restrictions-annotation.js.map +1 -0
- package/dist/src/components/immutable-annotation.d.ts +5 -0
- package/dist/src/components/immutable-annotation.d.ts.map +1 -0
- package/dist/src/components/immutable-annotation.js +6 -0
- package/dist/src/components/immutable-annotation.js.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.js +10 -0
- package/dist/src/components/insert-restrictions-annotation.js.map +1 -0
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +4 -2
- package/dist/src/components/property-element.js.map +1 -1
- package/dist/src/components/schema-element.d.ts.map +1 -1
- package/dist/src/components/schema-element.js +6 -6
- package/dist/src/components/schema-element.js.map +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +2 -2
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +1 -1
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +3 -3
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts +1 -1
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +2 -2
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/decorators/action.d.ts +10 -0
- package/dist/src/decorators/action.d.ts.map +1 -0
- package/dist/src/decorators/action.js +16 -0
- package/dist/src/decorators/action.js.map +1 -0
- package/dist/src/decorators/filter.d.ts +11 -0
- package/dist/src/decorators/filter.d.ts.map +1 -0
- package/dist/src/decorators/filter.js +27 -0
- package/dist/src/decorators/filter.js.map +1 -0
- package/dist/src/decorators/graph-route.d.ts +1 -1
- package/dist/src/decorators/graph-route.d.ts.map +1 -1
- package/dist/src/decorators/graph-route.js +12 -7
- package/dist/src/decorators/graph-route.js.map +1 -1
- package/dist/src/decorators/immutable.d.ts +8 -0
- package/dist/src/decorators/immutable.d.ts.map +1 -0
- package/dist/src/decorators/immutable.js +12 -0
- package/dist/src/decorators/immutable.js.map +1 -0
- package/dist/src/decorators/index.d.ts +4 -0
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +4 -0
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/required-for-create.d.ts +10 -0
- package/dist/src/decorators/required-for-create.d.ts.map +1 -0
- package/dist/src/decorators/required-for-create.js +14 -0
- package/dist/src/decorators/required-for-create.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +20 -17
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +69 -48
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.js +1 -1
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/model.d.ts +1 -0
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +2 -1
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/namespace.d.ts +3 -3
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +34 -8
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +1 -2
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/entities/property.d.ts.map +1 -1
- package/dist/src/entities/property.js +3 -0
- package/dist/src/entities/property.js.map +1 -1
- package/dist/src/entities/revision-definition.d.ts +1 -1
- package/dist/src/entities/revision-definition.js +3 -3
- package/dist/src/lib.d.ts +16 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +4 -0
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +4 -0
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +28 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -0
- package/dist/src/rules/count.js +2 -2
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -0
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -0
- package/dist/src/rules/disallowed-typespec-decorators.js +33 -0
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -0
- package/dist/src/rules/extends-on-same-type.d.ts +2 -0
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -0
- package/dist/src/rules/extends-on-same-type.js +38 -0
- package/dist/src/rules/extends-on-same-type.js.map +1 -0
- package/dist/src/rules/filter.d.ts +4 -0
- package/dist/src/rules/filter.d.ts.map +1 -0
- package/dist/src/rules/filter.js +92 -0
- package/dist/src/rules/filter.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +5 -0
- package/dist/src/rules/graph-route.d.ts.map +1 -0
- package/dist/src/rules/graph-route.js +39 -0
- package/dist/src/rules/graph-route.js.map +1 -0
- package/dist/src/rules/index.d.ts +7 -3
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +7 -89
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/operation-inside-interface.d.ts +2 -0
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -0
- package/dist/src/rules/operation-inside-interface.js +25 -0
- package/dist/src/rules/operation-inside-interface.js.map +1 -0
- package/dist/src/rules/order-by.js +2 -2
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/required-for-create.d.ts +2 -0
- package/dist/src/rules/required-for-create.d.ts.map +1 -0
- package/dist/src/rules/required-for-create.js +40 -0
- package/dist/src/rules/required-for-create.js.map +1 -0
- package/dist/src/rules/search.js +2 -2
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.js +2 -2
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.js +2 -2
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/utils.d.ts +16 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +81 -31
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +32 -0
- package/lib/lib.tsp +4 -15
- package/package.json +1 -2
package/dist/src/utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getNamespaceFullName, isArrayModelType, } from "@typespec/compiler";
|
|
2
|
-
import { getEntity, isEntity } from "./decorators/index.js";
|
|
3
|
-
import { getRoutePath } from "@typespec/http";
|
|
2
|
+
import { getEntity, getGraphRoutePath, isEntity } from "./decorators/index.js";
|
|
4
3
|
export function getNameForType(program, type) {
|
|
5
4
|
switch (type.kind) {
|
|
6
5
|
case "Union":
|
|
@@ -53,6 +52,8 @@ export function getNameForModelType(program, type) {
|
|
|
53
52
|
return "Edm.Boolean";
|
|
54
53
|
case "stream":
|
|
55
54
|
return "Edm.Stream";
|
|
55
|
+
case "guid":
|
|
56
|
+
return "Edm.Guid";
|
|
56
57
|
default:
|
|
57
58
|
break;
|
|
58
59
|
}
|
|
@@ -76,6 +77,8 @@ export function getIdForType(program, type) {
|
|
|
76
77
|
return `${type.value}`;
|
|
77
78
|
case "Union":
|
|
78
79
|
return getIdForUnion(program, type);
|
|
80
|
+
case "Scalar":
|
|
81
|
+
return getNameForModelType(program, type);
|
|
79
82
|
default:
|
|
80
83
|
return type.kind;
|
|
81
84
|
}
|
|
@@ -90,25 +93,40 @@ export function getNavigationTypeId(program, getOperation) {
|
|
|
90
93
|
}
|
|
91
94
|
export function getInterfacesOfKinds(program, navigationSources, kinds) {
|
|
92
95
|
const interfaces = new Map();
|
|
93
|
-
navigationSources.forEach((theInterface
|
|
94
|
-
|
|
95
|
-
if (!theInterface.sourceInterfaces.some(s => kinds.includes(s.name))) {
|
|
96
|
+
navigationSources.forEach((theInterface) => {
|
|
97
|
+
if (!theInterface.sourceInterfaces.some((s) => kinds.includes(s.name))) {
|
|
96
98
|
// if source interfaces DO NOT have the kinds.
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
+
const graphRoutePath = getGraphRoutePath(program, theInterface);
|
|
102
|
+
let graphRoutes = [];
|
|
103
|
+
if (!graphRoutePath) {
|
|
101
104
|
return;
|
|
102
105
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
else if (Array.isArray(graphRoutePath)) {
|
|
107
|
+
graphRoutes = graphRoutePath;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
graphRoutes = [graphRoutePath];
|
|
111
|
+
}
|
|
112
|
+
if (!graphRoutes.length) {
|
|
113
|
+
return;
|
|
107
114
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
graphRoutes.forEach((graphRoute) => {
|
|
116
|
+
const path = removeRoutePathParams(graphRoute);
|
|
117
|
+
if (!path) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let operations = [...theInterface.operations.values()];
|
|
121
|
+
if (interfaces.has(path)) {
|
|
122
|
+
const existing = interfaces.get(path);
|
|
123
|
+
operations = [...operations, ...existing.operations];
|
|
124
|
+
}
|
|
125
|
+
interfaces.set(path, {
|
|
126
|
+
theInterface: theInterface,
|
|
127
|
+
operations: operations,
|
|
128
|
+
path: graphRoute
|
|
129
|
+
});
|
|
112
130
|
});
|
|
113
131
|
});
|
|
114
132
|
return interfaces;
|
|
@@ -157,26 +175,24 @@ export function getSingletonTypeId(program, singletonType, getOperation) {
|
|
|
157
175
|
return getOperation && getNavigationTypeId(program, getOperation);
|
|
158
176
|
}
|
|
159
177
|
/**
|
|
160
|
-
* Returns whether a type
|
|
178
|
+
* Returns whether a type matches Graph's definition of a collection
|
|
161
179
|
* @param program
|
|
162
|
-
* @param
|
|
180
|
+
* @param type
|
|
163
181
|
*/
|
|
164
|
-
export function
|
|
165
|
-
let
|
|
166
|
-
if (
|
|
167
|
-
|
|
182
|
+
export function isTypeCollection(Program, type) {
|
|
183
|
+
let modelTypes = [];
|
|
184
|
+
if (type.kind === "Union") {
|
|
185
|
+
const extracted = (extractTypesFromUnion(type).filter((t) => t.kind === "Model"));
|
|
186
|
+
modelTypes = modelTypes.concat(extracted);
|
|
168
187
|
}
|
|
169
|
-
else if (
|
|
170
|
-
|
|
171
|
-
returnTypes = returnTypes.concat(extracted);
|
|
188
|
+
else if (type.kind === "Model") {
|
|
189
|
+
modelTypes.push(type);
|
|
172
190
|
}
|
|
173
|
-
if (
|
|
191
|
+
if (modelTypes.length === 0) {
|
|
174
192
|
return false;
|
|
175
193
|
}
|
|
176
|
-
return
|
|
177
|
-
|
|
178
|
-
function isTypeCollection(type) {
|
|
179
|
-
return type.kind === "Model" && (type.name === "Array" || type.name.includes("Collection"));
|
|
194
|
+
return modelTypes.some((t) => t.kind === "Model" &&
|
|
195
|
+
(t.name === "Array" || t.name.includes("Collection")));
|
|
180
196
|
}
|
|
181
197
|
/**
|
|
182
198
|
* Imported from typespec-azure
|
|
@@ -225,6 +241,14 @@ export function isExcludedLibraryType(program, type) {
|
|
|
225
241
|
}
|
|
226
242
|
export function isNavigationProperty(program, property) {
|
|
227
243
|
let propertyType = property.type;
|
|
244
|
+
if (propertyType.kind === "Union") {
|
|
245
|
+
const unionTypes = extractTypesFromUnion(propertyType);
|
|
246
|
+
const nonNullTypes = unionTypes.filter((t) => !isNullType(program, t));
|
|
247
|
+
if (!nonNullTypes.length) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
propertyType = nonNullTypes[0];
|
|
251
|
+
}
|
|
228
252
|
if (propertyType.kind !== "Model") {
|
|
229
253
|
return false;
|
|
230
254
|
}
|
|
@@ -239,8 +263,24 @@ export function isNavigationProperty(program, property) {
|
|
|
239
263
|
export function isNavigationSource(theInterface) {
|
|
240
264
|
return findNavigationSource(theInterface) !== undefined;
|
|
241
265
|
}
|
|
266
|
+
export function isTopLevelNavigationSource(program, theInterface) {
|
|
267
|
+
return removeRoutePathParams(theInterface.path).split("/").length === 1;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Check if a @graphRoute returns a single resource of a collection.
|
|
271
|
+
*
|
|
272
|
+
* `Example`
|
|
273
|
+
*
|
|
274
|
+
* @graphRoute("users/{id}")
|
|
275
|
+
* interface UsersById extends Resource<user> {
|
|
276
|
+
* get is GraphOps.GetResource;
|
|
277
|
+
* }
|
|
278
|
+
*/
|
|
279
|
+
export function isCollectionResource(program, theInterface) {
|
|
280
|
+
return (isTopLevelNavigationSource(program, theInterface) && theInterface.path.split("/").length === 2);
|
|
281
|
+
}
|
|
242
282
|
// Get the type returned by all operations in an interface representing a navigation source.
|
|
243
|
-
// This is the 'T' in
|
|
283
|
+
// This is the 'T' in Collection<T> and friends.
|
|
244
284
|
export function getInterfaceNavigationSourceType(program, theInterface) {
|
|
245
285
|
var _a;
|
|
246
286
|
const navSource = findNavigationSource(theInterface);
|
|
@@ -257,7 +297,7 @@ export function getNavigationSourceType(program, operation) {
|
|
|
257
297
|
}
|
|
258
298
|
function findNavigationSource(theInterface) {
|
|
259
299
|
for (const baseInterface of theInterface.sourceInterfaces) {
|
|
260
|
-
if (baseInterface.name === "
|
|
300
|
+
if (baseInterface.name === "Resource" || baseInterface.name === "Collection") {
|
|
261
301
|
return baseInterface;
|
|
262
302
|
}
|
|
263
303
|
else {
|
|
@@ -269,4 +309,14 @@ function findNavigationSource(theInterface) {
|
|
|
269
309
|
}
|
|
270
310
|
return undefined;
|
|
271
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Removes route path params from a route path
|
|
314
|
+
*
|
|
315
|
+
* Examples:
|
|
316
|
+
* - user/{id}/manager -> user/manager
|
|
317
|
+
* - user/{id}/friends/{friendId}/hobbies -> user/friends/hobbies
|
|
318
|
+
*/
|
|
319
|
+
function removeRoutePathParams(routePath) {
|
|
320
|
+
return routePath.replace(/\/\{\w+\}/g, "");
|
|
321
|
+
}
|
|
272
322
|
//# 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,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oB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QAC1B,OAAO,SAAS,CAAC;KAClB;SACI;QACH,OAAc,MAAA,SAAS,CAAC,cAAc,0CAAE,IAAI,CAAC,CAAC,CAAC,CAAC;KACjD;AACH,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,uBAAuB,CAAC,OAAgB,EAAE,SAAoB;IAC5E,OAAO,gCAAgC,CAAC,OAAO,EAAE,SAAS,CAAC,SAAU,CAAC,CAAC;AACxE,CAAC;AAEF,SAAS,oBAAoB,CAAC,YAAuB;IACnD,KAAK,MAAM,aAAa,IAAI,YAAY,CAAC,gBAAgB,EAAE;QACzD,IAAI,aAAa,CAAC,IAAI,KAAK,UAAU,IAAI,aAAa,CAAC,IAAI,KAAK,YAAY,EAAE;YAC5E,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;AAED;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;AAC7C,CAAC"}
|
package/lib/decorators.tsp
CHANGED
|
@@ -7,6 +7,13 @@ using TypeSpec.Reflection;
|
|
|
7
7
|
*/
|
|
8
8
|
extern dec abstract(target: Model);
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* `@action` - mark an operation as an action
|
|
12
|
+
*
|
|
13
|
+
* `@action` can only be applied to operations.
|
|
14
|
+
*/
|
|
15
|
+
extern dec action(target: Operation, name?: valueof string);
|
|
16
|
+
|
|
10
17
|
/**
|
|
11
18
|
* `@alternateKey` - mark a model property as an alternateKey
|
|
12
19
|
*
|
|
@@ -71,6 +78,16 @@ extern dec entity(target: Model);
|
|
|
71
78
|
*/
|
|
72
79
|
extern dec expand(target: Operation, property: valueof string, ...otherProperties: valueof string[]);
|
|
73
80
|
|
|
81
|
+
/**
|
|
82
|
+
* `@filter` - Applies to: get operations that return collections of @entity or @complex models.
|
|
83
|
+
* Indicates that the get operation supports OData $filter query parameter.
|
|
84
|
+
*
|
|
85
|
+
* `properties` - string containing comma separated list of property names in the model returned
|
|
86
|
+
* from the get operation that can be used in $filter query parameter.
|
|
87
|
+
*/
|
|
88
|
+
extern dec filter(target: Operation, properties: valueof string);
|
|
89
|
+
|
|
90
|
+
|
|
74
91
|
/**
|
|
75
92
|
* `@flags` - mark an enumeration type as a flag.
|
|
76
93
|
*
|
|
@@ -164,6 +181,14 @@ extern dec readOnly(target: ModelProperty);
|
|
|
164
181
|
*/
|
|
165
182
|
extern dec references(target: ModelProperty);
|
|
166
183
|
|
|
184
|
+
/**
|
|
185
|
+
* `@requiredForCreate` - mark a model property as required when a request is made to
|
|
186
|
+
* Graph to create or update a resource.
|
|
187
|
+
*
|
|
188
|
+
* `@requiredForCreate` can only be applied to model properties.
|
|
189
|
+
*/
|
|
190
|
+
extern dec requiredForCreate(target: ModelProperty);
|
|
191
|
+
|
|
167
192
|
/**
|
|
168
193
|
* `@top` - Applies to: get operations that return collections.
|
|
169
194
|
* Indicates that the get operation supports the OData $top query parameter.
|
|
@@ -252,3 +277,10 @@ extern dec deltaCollection(target: Model);
|
|
|
252
277
|
// https://github.com/microsoft/typespec/issues/2106
|
|
253
278
|
// Disabling all related features while we await the outcome.
|
|
254
279
|
extern dec graphRoute(target: Interface /* | Operation */, path: valueof string);
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* `@immutable` - mark a model property as immutable.
|
|
283
|
+
*
|
|
284
|
+
* `@immutable` can only be applied to model properties.
|
|
285
|
+
*/
|
|
286
|
+
extern dec immutable(target: ModelProperty);
|
package/lib/lib.tsp
CHANGED
|
@@ -8,23 +8,12 @@ scalar date;
|
|
|
8
8
|
|
|
9
9
|
scalar stream;
|
|
10
10
|
|
|
11
|
+
scalar guid extends string;
|
|
12
|
+
|
|
11
13
|
model EmptyParameters {}
|
|
12
14
|
|
|
13
15
|
// --- Base interfaces for all interfaces that contain operations returning entities.
|
|
14
|
-
interface SingleNavigationSource<T> {}
|
|
15
|
-
interface CollectionNavigationSource<T> {}
|
|
16
|
-
|
|
17
|
-
interface Resource<T> extends SingleNavigationSource<T> {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Collection<T> extends CollectionNavigationSource<T> {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface Singleton<T> extends SingleNavigationSource<T> {
|
|
24
|
-
}
|
|
25
16
|
|
|
26
|
-
interface
|
|
27
|
-
}
|
|
17
|
+
interface Resource<T> {}
|
|
28
18
|
|
|
29
|
-
interface
|
|
30
|
-
}
|
|
19
|
+
interface Collection<T> {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/typespec-msgraph",
|
|
3
|
-
"version": "0.0.1-Preview.
|
|
3
|
+
"version": "0.0.1-Preview.8",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec for Microsoft Graph provides a description of the Microsoft Graph APIs. It is used for generating API description languages, client and service code, documentation, and other assets.",
|
|
6
6
|
"homepage": "https://github.com/microsoftgraph/typespec-msgraph",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"@typespec/compiler": "~0.45.0",
|
|
57
57
|
"@typespec/http": "~0.45.0",
|
|
58
58
|
"@typespec/lint": "~0.45.0",
|
|
59
|
-
"@typespec/rest": "~0.45.0",
|
|
60
59
|
"prettier": "~2.8.7",
|
|
61
60
|
"react-dom": "~18.2.0",
|
|
62
61
|
"react": "~18.2.0",
|