@microsoft/typespec-msgraph 0.0.1-Preview.7 → 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.map +1 -1
- package/dist/src/components/annotations.js +4 -3
- package/dist/src/components/annotations.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 +3 -1
- 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 +3 -5
- package/dist/src/components/schema-element.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 +3 -0
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +23 -1
- package/dist/src/entities/annotations.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 +0 -2
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +27 -7
- 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/lib.d.ts +12 -0
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +3 -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/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 +3 -0
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +3 -0
- package/dist/src/rules/index.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/utils.d.ts +13 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +49 -17
- 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/rules/index.js
CHANGED
|
@@ -9,13 +9,16 @@ export * from "./entity.js";
|
|
|
9
9
|
export * from "./enum.js";
|
|
10
10
|
export * from "./expand.js";
|
|
11
11
|
export * from "./extends-on-same-type.js";
|
|
12
|
+
export * from "./filter.js";
|
|
12
13
|
export * from "./function.js";
|
|
13
14
|
export * from "./has-stream.js";
|
|
14
15
|
export * from "./open.js";
|
|
15
16
|
export * from "./operation-inside-interface.js";
|
|
16
17
|
export * from "./order-by.js";
|
|
17
18
|
export * from "./references.js";
|
|
19
|
+
export * from "./required-for-create.js";
|
|
18
20
|
export * from "./search.js";
|
|
19
21
|
export * from "./skip.js";
|
|
20
22
|
export * from "./top.js";
|
|
23
|
+
export * from "./graph-route.js";
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oDAAoD,CAAC;AACnE,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,qCAAqC,CAAC;AACpD,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-for-create.d.ts","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,6BAA6B,mCAsCxC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { isComputed, isRequiredForCreate } from "../index.js";
|
|
3
|
+
import { getIdForType, isTypeNullable } from "../utils.js";
|
|
4
|
+
import { getOperationVerb } from "@typespec/http";
|
|
5
|
+
import { reportDiagnostic } from "../lib.js";
|
|
6
|
+
export const requiredRequestParametersRule = createRule({
|
|
7
|
+
name: "required-request-parameters",
|
|
8
|
+
create({ program }) {
|
|
9
|
+
return {
|
|
10
|
+
interface: (theInterface) => {
|
|
11
|
+
const postOperations = [...theInterface.operations]
|
|
12
|
+
.map(([_, operation]) => operation)
|
|
13
|
+
.filter((operation) => getOperationVerb(program, operation) === "post");
|
|
14
|
+
postOperations.forEach((operation) => {
|
|
15
|
+
if (operation.parameters.properties.has("body")) {
|
|
16
|
+
const body = operation.parameters.properties.get("body");
|
|
17
|
+
const model = body.type;
|
|
18
|
+
[...model.properties].forEach(([_, property]) => {
|
|
19
|
+
if (!(isRequiredForCreate(program, property) ||
|
|
20
|
+
isTypeNullable(program, property.type) ||
|
|
21
|
+
isComputed(program, property) ||
|
|
22
|
+
property.default)) {
|
|
23
|
+
reportDiagnostic(program, {
|
|
24
|
+
code: "element-missing-dependencies",
|
|
25
|
+
target: property,
|
|
26
|
+
messageId: "propertyRequiredForCreate",
|
|
27
|
+
format: {
|
|
28
|
+
property: property.name,
|
|
29
|
+
model: getIdForType(program, property.model),
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=required-for-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-for-create.js","sourceRoot":"","sources":["../../../src/rules/required-for-create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OA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tC,MAAM,EAAE;wCACN,QAAQ,EAAE,QAAQ,CAAC,IAAI;wCACvB,KAAK,EAAE,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAM,CAAC;qCAC9C;iCACF,CAAC,CAAC;6BACJ;wBACH,CAAC,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Enum, Interface, Model, ModelProperty, Namespace, Operation, Program, S
|
|
|
2
2
|
export interface MsGraphInterface {
|
|
3
3
|
theInterface: Interface;
|
|
4
4
|
operations: Operation[];
|
|
5
|
+
path: string;
|
|
5
6
|
}
|
|
6
7
|
export declare function getNameForType(program: Program, type: Type): string;
|
|
7
8
|
export declare function getNameForModelType(program: Program, type: Model | Scalar): string;
|
|
@@ -37,6 +38,18 @@ export declare function isExcludedCoreType(program: Program, type: Model | Scala
|
|
|
37
38
|
export declare function isExcludedLibraryType(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum): boolean;
|
|
38
39
|
export declare function isNavigationProperty(program: Program, property: ModelProperty): boolean;
|
|
39
40
|
export declare function isNavigationSource(theInterface: Interface): boolean;
|
|
41
|
+
export declare function isTopLevelNavigationSource(program: Program, theInterface: MsGraphInterface): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a @graphRoute returns a single resource of a collection.
|
|
44
|
+
*
|
|
45
|
+
* `Example`
|
|
46
|
+
*
|
|
47
|
+
* @graphRoute("users/{id}")
|
|
48
|
+
* interface UsersById extends Resource<user> {
|
|
49
|
+
* get is GraphOps.GetResource;
|
|
50
|
+
* }
|
|
51
|
+
*/
|
|
52
|
+
export declare function isCollectionResource(program: Program, theInterface: MsGraphInterface): boolean;
|
|
40
53
|
export declare function getInterfaceNavigationSourceType(program: Program, theInterface: Interface): Model | undefined;
|
|
41
54
|
export declare function getNavigationSourceType(program: Program, operation: Operation): Model | undefined;
|
|
42
55
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACN,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EACN,IAAI,EACJ,KAAK,EACN,MAAM,oBAAoB,CAAC;AAG5B,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,SAAS,CAAC;IACxB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAqBnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,GAAG,MAAM,UAyCzE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,CAoBjE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,GAAG,MAAM,CAOrF;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EACzC,KAAK,EAAE,MAAM,EAAE,GACd,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CA6C/B;AAED,wBAA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AE,gBAAgB,GAC7B,OAAO,CAET;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,gBAAgB,GAAG,OAAO,CAI9F;AAID,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,GAAG,KAAK,GAAE,SAAS,CAQ5G;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,KAAK,GAAE,SAAS,CAE/F"}
|
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
|
}
|
|
@@ -91,26 +94,39 @@ export function getNavigationTypeId(program, getOperation) {
|
|
|
91
94
|
export function getInterfacesOfKinds(program, navigationSources, kinds) {
|
|
92
95
|
const interfaces = new Map();
|
|
93
96
|
navigationSources.forEach((theInterface) => {
|
|
94
|
-
if (!theInterface.sourceInterfaces.some(s => kinds.includes(s.name))) {
|
|
97
|
+
if (!theInterface.sourceInterfaces.some((s) => kinds.includes(s.name))) {
|
|
95
98
|
// if source interfaces DO NOT have the kinds.
|
|
96
99
|
return;
|
|
97
100
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
101
|
+
const graphRoutePath = getGraphRoutePath(program, theInterface);
|
|
102
|
+
let graphRoutes = [];
|
|
103
|
+
if (!graphRoutePath) {
|
|
100
104
|
return;
|
|
101
105
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return;
|
|
106
|
+
else if (Array.isArray(graphRoutePath)) {
|
|
107
|
+
graphRoutes = graphRoutePath;
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const existing = interfaces.get(path);
|
|
109
|
-
operations = [...operations, ...existing.operations];
|
|
109
|
+
else {
|
|
110
|
+
graphRoutes = [graphRoutePath];
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
if (!graphRoutes.length) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
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
|
+
});
|
|
114
130
|
});
|
|
115
131
|
});
|
|
116
132
|
return interfaces;
|
|
@@ -247,8 +263,24 @@ export function isNavigationProperty(program, property) {
|
|
|
247
263
|
export function isNavigationSource(theInterface) {
|
|
248
264
|
return findNavigationSource(theInterface) !== undefined;
|
|
249
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
|
+
}
|
|
250
282
|
// Get the type returned by all operations in an interface representing a navigation source.
|
|
251
|
-
// This is the 'T' in
|
|
283
|
+
// This is the 'T' in Collection<T> and friends.
|
|
252
284
|
export function getInterfaceNavigationSourceType(program, theInterface) {
|
|
253
285
|
var _a;
|
|
254
286
|
const navSource = findNavigationSource(theInterface);
|
|
@@ -265,7 +297,7 @@ export function getNavigationSourceType(program, operation) {
|
|
|
265
297
|
}
|
|
266
298
|
function findNavigationSource(theInterface) {
|
|
267
299
|
for (const baseInterface of theInterface.sourceInterfaces) {
|
|
268
|
-
if (baseInterface.name === "
|
|
300
|
+
if (baseInterface.name === "Resource" || baseInterface.name === "Collection") {
|
|
269
301
|
return baseInterface;
|
|
270
302
|
}
|
|
271
303
|
else {
|
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,oBAAoB,EAEpB,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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",
|