@microsoft/typespec-msgraph 0.0.1-Preview.1
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/src/components/acceptable-media-types-annotation.d.ts +6 -0
- package/dist/src/components/acceptable-media-types-annotation.d.ts.map +1 -0
- package/dist/src/components/acceptable-media-types-annotation.js +15 -0
- package/dist/src/components/acceptable-media-types-annotation.js.map +1 -0
- package/dist/src/components/alternate-keys-annotation.d.ts +6 -0
- package/dist/src/components/alternate-keys-annotation.d.ts.map +1 -0
- package/dist/src/components/alternate-keys-annotation.js +30 -0
- package/dist/src/components/alternate-keys-annotation.js.map +1 -0
- package/dist/src/components/common-elements.d.ts +128 -0
- package/dist/src/components/common-elements.d.ts.map +1 -0
- package/dist/src/components/common-elements.js +38 -0
- package/dist/src/components/common-elements.js.map +1 -0
- package/dist/src/components/computed-annotation.d.ts +6 -0
- package/dist/src/components/computed-annotation.d.ts.map +1 -0
- package/dist/src/components/computed-annotation.js +12 -0
- package/dist/src/components/computed-annotation.js.map +1 -0
- package/dist/src/components/count-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/count-restrictions-annotation.js +15 -0
- package/dist/src/components/count-restrictions-annotation.js.map +1 -0
- package/dist/src/components/description-annotation.d.ts +6 -0
- package/dist/src/components/description-annotation.d.ts.map +1 -0
- package/dist/src/components/description-annotation.js +13 -0
- package/dist/src/components/description-annotation.js.map +1 -0
- package/dist/src/components/expand-restrictions-annotation.d.ts +7 -0
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/expand-restrictions-annotation.js +31 -0
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -0
- package/dist/src/components/index.d.ts +15 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +15 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/permissions-annotation.d.ts +6 -0
- package/dist/src/components/permissions-annotation.d.ts.map +1 -0
- package/dist/src/components/permissions-annotation.js +20 -0
- package/dist/src/components/permissions-annotation.js.map +1 -0
- package/dist/src/components/program-context.d.ts +4 -0
- package/dist/src/components/program-context.d.ts.map +1 -0
- package/dist/src/components/program-context.js +3 -0
- package/dist/src/components/program-context.js.map +1 -0
- package/dist/src/components/property-element.d.ts +6 -0
- package/dist/src/components/property-element.d.ts.map +1 -0
- package/dist/src/components/property-element.js +41 -0
- package/dist/src/components/property-element.js.map +1 -0
- package/dist/src/components/revisions-annotation.d.ts +7 -0
- package/dist/src/components/revisions-annotation.d.ts.map +1 -0
- package/dist/src/components/revisions-annotation.js +60 -0
- package/dist/src/components/revisions-annotation.js.map +1 -0
- package/dist/src/components/search-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/search-restrictions-annotation.js +15 -0
- package/dist/src/components/search-restrictions-annotation.js.map +1 -0
- package/dist/src/components/skip-supported-annotation.d.ts +6 -0
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -0
- package/dist/src/components/skip-supported-annotation.js +13 -0
- package/dist/src/components/skip-supported-annotation.js.map +1 -0
- package/dist/src/components/sort-restrictions-annotation.d.ts +7 -0
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/sort-restrictions-annotation.js +31 -0
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -0
- package/dist/src/components/structured-type-element.d.ts +6 -0
- package/dist/src/components/structured-type-element.d.ts.map +1 -0
- package/dist/src/components/structured-type-element.js +77 -0
- package/dist/src/components/structured-type-element.js.map +1 -0
- package/dist/src/components/top-supported-annotation.d.ts +6 -0
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -0
- package/dist/src/components/top-supported-annotation.js +13 -0
- package/dist/src/components/top-supported-annotation.js.map +1 -0
- package/dist/src/csdl.d.ts +8 -0
- package/dist/src/csdl.d.ts.map +1 -0
- package/dist/src/csdl.js +298 -0
- package/dist/src/csdl.js.map +1 -0
- package/dist/src/decorators/abstract.d.ts +9 -0
- package/dist/src/decorators/abstract.d.ts.map +1 -0
- package/dist/src/decorators/abstract.js +19 -0
- package/dist/src/decorators/abstract.js.map +1 -0
- package/dist/src/decorators/alternate-key.d.ts +9 -0
- package/dist/src/decorators/alternate-key.d.ts.map +1 -0
- package/dist/src/decorators/alternate-key.js +13 -0
- package/dist/src/decorators/alternate-key.js.map +1 -0
- package/dist/src/decorators/attribute-builder.d.ts +2 -0
- package/dist/src/decorators/attribute-builder.d.ts.map +1 -0
- package/dist/src/decorators/attribute-builder.js +166 -0
- package/dist/src/decorators/attribute-builder.js.map +1 -0
- package/dist/src/decorators/attributes.d.ts +57 -0
- package/dist/src/decorators/attributes.d.ts.map +1 -0
- package/dist/src/decorators/attributes.js +50 -0
- package/dist/src/decorators/attributes.js.map +1 -0
- package/dist/src/decorators/complex.d.ts +9 -0
- package/dist/src/decorators/complex.d.ts.map +1 -0
- package/dist/src/decorators/complex.js +19 -0
- package/dist/src/decorators/complex.js.map +1 -0
- package/dist/src/decorators/computed.d.ts +9 -0
- package/dist/src/decorators/computed.d.ts.map +1 -0
- package/dist/src/decorators/computed.js +13 -0
- package/dist/src/decorators/computed.js.map +1 -0
- package/dist/src/decorators/contains.d.ts +9 -0
- package/dist/src/decorators/contains.d.ts.map +1 -0
- package/dist/src/decorators/contains.js +13 -0
- package/dist/src/decorators/contains.js.map +1 -0
- package/dist/src/decorators/count.d.ts +9 -0
- package/dist/src/decorators/count.d.ts.map +1 -0
- package/dist/src/decorators/count.js +13 -0
- package/dist/src/decorators/count.js.map +1 -0
- package/dist/src/decorators/deprecated-definition.d.ts +21 -0
- package/dist/src/decorators/deprecated-definition.d.ts.map +1 -0
- package/dist/src/decorators/deprecated-definition.js +18 -0
- package/dist/src/decorators/deprecated-definition.js.map +1 -0
- package/dist/src/decorators/entity.d.ts +10 -0
- package/dist/src/decorators/entity.d.ts.map +1 -0
- package/dist/src/decorators/entity.js +23 -0
- package/dist/src/decorators/entity.js.map +1 -0
- package/dist/src/decorators/expand.d.ts +11 -0
- package/dist/src/decorators/expand.d.ts.map +1 -0
- package/dist/src/decorators/expand.js +17 -0
- package/dist/src/decorators/expand.js.map +1 -0
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts +14 -0
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts.map +1 -0
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js +36 -0
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js.map +1 -0
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts +7 -0
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts.map +1 -0
- package/dist/src/decorators/handlers/custom/ags-attribute.js +36 -0
- package/dist/src/decorators/handlers/custom/ags-attribute.js.map +1 -0
- package/dist/src/decorators/handlers/custom/index.d.ts +3 -0
- package/dist/src/decorators/handlers/custom/index.d.ts.map +1 -0
- package/dist/src/decorators/handlers/custom/index.js +3 -0
- package/dist/src/decorators/handlers/custom/index.js.map +1 -0
- package/dist/src/decorators/handlers/index.d.ts +30 -0
- package/dist/src/decorators/handlers/index.d.ts.map +1 -0
- package/dist/src/decorators/handlers/index.js +121 -0
- package/dist/src/decorators/handlers/index.js.map +1 -0
- package/dist/src/decorators/has-stream.d.ts +11 -0
- package/dist/src/decorators/has-stream.d.ts.map +1 -0
- package/dist/src/decorators/has-stream.js +30 -0
- package/dist/src/decorators/has-stream.js.map +1 -0
- package/dist/src/decorators/index.d.ts +21 -0
- package/dist/src/decorators/index.d.ts.map +1 -0
- package/dist/src/decorators/index.js +21 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/decorators/open.d.ts +9 -0
- package/dist/src/decorators/open.d.ts.map +1 -0
- package/dist/src/decorators/open.js +19 -0
- package/dist/src/decorators/open.js.map +1 -0
- package/dist/src/decorators/order-by.d.ts +11 -0
- package/dist/src/decorators/order-by.d.ts.map +1 -0
- package/dist/src/decorators/order-by.js +17 -0
- package/dist/src/decorators/order-by.js.map +1 -0
- package/dist/src/decorators/private-preview-definition.d.ts +19 -0
- package/dist/src/decorators/private-preview-definition.d.ts.map +1 -0
- package/dist/src/decorators/private-preview-definition.js +15 -0
- package/dist/src/decorators/private-preview-definition.js.map +1 -0
- package/dist/src/decorators/private-preview.d.ts +9 -0
- package/dist/src/decorators/private-preview.d.ts.map +1 -0
- package/dist/src/decorators/private-preview.js +25 -0
- package/dist/src/decorators/private-preview.js.map +1 -0
- package/dist/src/decorators/read-only.d.ts +9 -0
- package/dist/src/decorators/read-only.d.ts.map +1 -0
- package/dist/src/decorators/read-only.js +13 -0
- package/dist/src/decorators/read-only.js.map +1 -0
- package/dist/src/decorators/references.d.ts +9 -0
- package/dist/src/decorators/references.d.ts.map +1 -0
- package/dist/src/decorators/references.js +13 -0
- package/dist/src/decorators/references.js.map +1 -0
- package/dist/src/decorators/routed-interfaces.d.ts +19 -0
- package/dist/src/decorators/routed-interfaces.d.ts.map +1 -0
- package/dist/src/decorators/routed-interfaces.js +43 -0
- package/dist/src/decorators/routed-interfaces.js.map +1 -0
- package/dist/src/decorators/search.d.ts +8 -0
- package/dist/src/decorators/search.d.ts.map +1 -0
- package/dist/src/decorators/search.js +12 -0
- package/dist/src/decorators/search.js.map +1 -0
- package/dist/src/decorators/skip.d.ts +8 -0
- package/dist/src/decorators/skip.d.ts.map +1 -0
- package/dist/src/decorators/skip.js +12 -0
- package/dist/src/decorators/skip.js.map +1 -0
- package/dist/src/decorators/top.d.ts +8 -0
- package/dist/src/decorators/top.d.ts.map +1 -0
- package/dist/src/decorators/top.js +12 -0
- package/dist/src/decorators/top.js.map +1 -0
- package/dist/src/decorators/write-only.d.ts +9 -0
- package/dist/src/decorators/write-only.d.ts.map +1 -0
- package/dist/src/decorators/write-only.js +13 -0
- package/dist/src/decorators/write-only.js.map +1 -0
- package/dist/src/dom/reconciler.d.ts +10 -0
- package/dist/src/dom/reconciler.d.ts.map +1 -0
- package/dist/src/dom/reconciler.js +95 -0
- package/dist/src/dom/reconciler.js.map +1 -0
- package/dist/src/dom/renderer.d.ts +6 -0
- package/dist/src/dom/renderer.d.ts.map +1 -0
- package/dist/src/dom/renderer.js +33 -0
- package/dist/src/dom/renderer.js.map +1 -0
- package/dist/src/dom/types.d.ts +33 -0
- package/dist/src/dom/types.d.ts.map +1 -0
- package/dist/src/dom/types.js +2 -0
- package/dist/src/dom/types.js.map +1 -0
- package/dist/src/emitter.d.ts +4 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +11 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +138 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +55 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/linter.d.ts +3 -0
- package/dist/src/linter.d.ts.map +1 -0
- package/dist/src/linter.js +35 -0
- package/dist/src/linter.js.map +1 -0
- package/dist/src/rules/abstract.d.ts +5 -0
- package/dist/src/rules/abstract.d.ts.map +1 -0
- package/dist/src/rules/abstract.js +31 -0
- package/dist/src/rules/abstract.js.map +1 -0
- package/dist/src/rules/alternate-key.d.ts +4 -0
- package/dist/src/rules/alternate-key.d.ts.map +1 -0
- package/dist/src/rules/alternate-key.js +81 -0
- package/dist/src/rules/alternate-key.js.map +1 -0
- package/dist/src/rules/computed.d.ts +7 -0
- package/dist/src/rules/computed.d.ts.map +1 -0
- package/dist/src/rules/computed.js +47 -0
- package/dist/src/rules/computed.js.map +1 -0
- package/dist/src/rules/contains.d.ts +5 -0
- package/dist/src/rules/contains.d.ts.map +1 -0
- package/dist/src/rules/contains.js +32 -0
- package/dist/src/rules/contains.js.map +1 -0
- package/dist/src/rules/count.d.ts +5 -0
- package/dist/src/rules/count.d.ts.map +1 -0
- package/dist/src/rules/count.js +35 -0
- package/dist/src/rules/count.js.map +1 -0
- package/dist/src/rules/entity.d.ts +2 -0
- package/dist/src/rules/entity.d.ts.map +1 -0
- package/dist/src/rules/entity.js +31 -0
- package/dist/src/rules/entity.js.map +1 -0
- package/dist/src/rules/expand.d.ts +3 -0
- package/dist/src/rules/expand.d.ts.map +1 -0
- package/dist/src/rules/expand.js +69 -0
- package/dist/src/rules/expand.js.map +1 -0
- package/dist/src/rules/has-stream.d.ts +2 -0
- package/dist/src/rules/has-stream.d.ts.map +1 -0
- package/dist/src/rules/has-stream.js +29 -0
- package/dist/src/rules/has-stream.js.map +1 -0
- package/dist/src/rules/index.d.ts +21 -0
- package/dist/src/rules/index.d.ts.map +1 -0
- package/dist/src/rules/index.js +176 -0
- package/dist/src/rules/index.js.map +1 -0
- package/dist/src/rules/open.d.ts +5 -0
- package/dist/src/rules/open.d.ts.map +1 -0
- package/dist/src/rules/open.js +31 -0
- package/dist/src/rules/open.js.map +1 -0
- package/dist/src/rules/order-by.d.ts +3 -0
- package/dist/src/rules/order-by.d.ts.map +1 -0
- package/dist/src/rules/order-by.js +69 -0
- package/dist/src/rules/order-by.js.map +1 -0
- package/dist/src/rules/references.d.ts +5 -0
- package/dist/src/rules/references.d.ts.map +1 -0
- package/dist/src/rules/references.js +32 -0
- package/dist/src/rules/references.js.map +1 -0
- package/dist/src/rules/search.d.ts +5 -0
- package/dist/src/rules/search.d.ts.map +1 -0
- package/dist/src/rules/search.js +35 -0
- package/dist/src/rules/search.js.map +1 -0
- package/dist/src/rules/skip.d.ts +5 -0
- package/dist/src/rules/skip.d.ts.map +1 -0
- package/dist/src/rules/skip.js +35 -0
- package/dist/src/rules/skip.js.map +1 -0
- package/dist/src/rules/top.d.ts +5 -0
- package/dist/src/rules/top.d.ts.map +1 -0
- package/dist/src/rules/top.js +35 -0
- package/dist/src/rules/top.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +24 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/utils.d.ts +27 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +186 -0
- package/dist/src/utils.js.map +1 -0
- package/lib/decorators.tsp +164 -0
- package/lib/lib.tsp +35 -0
- package/lib/msgraph.tsp +2 -0
- package/package.json +68 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getOperationVerb } from "@typespec/http";
|
|
3
|
+
import { isTop } from "../index.js";
|
|
4
|
+
import { reportDiagnostic } from "../lib.js";
|
|
5
|
+
/**
|
|
6
|
+
* @top applies to get operations that return collections.
|
|
7
|
+
*/
|
|
8
|
+
export const topAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
9
|
+
name: "top-applies-to-get-operations-that-return-collections",
|
|
10
|
+
create({ program }) {
|
|
11
|
+
return {
|
|
12
|
+
operation: (operation) => {
|
|
13
|
+
if (!isTop(program, operation)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (getOperationVerb(program, operation) === "get") {
|
|
17
|
+
const returnType = operation.returnType;
|
|
18
|
+
if (returnType.kind === "Model" && returnType.name === "PagedListResponse") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "decorator-invalid-use",
|
|
24
|
+
target: operation,
|
|
25
|
+
messageId: "wrongType",
|
|
26
|
+
format: {
|
|
27
|
+
decorator: "@top",
|
|
28
|
+
target: "get operation that returns a collection",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=top.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top.js","sourceRoot":"","sources":["../../../src/rules/top.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kDAAkD,GAAG,UAAU,CAAC;IAC3E,IAAI,EAAE,uDAAuD;IAC7D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAC9B,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,IAAI,KAAK,mBAAmB,EAAE;wBAC1E,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,MAAM;wBACjB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,eAAO,MAAM,kBAAkB,EAAE,mBAoBhC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolvePath } from "@typespec/compiler";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
export const MsGraphTestLibrary = {
|
|
4
|
+
name: "@microsoft/typespec-msgraph",
|
|
5
|
+
packageRoot: resolvePath(fileURLToPath(import.meta.url), "../../../../"),
|
|
6
|
+
files: [
|
|
7
|
+
{
|
|
8
|
+
realDir: "",
|
|
9
|
+
pattern: "package.json",
|
|
10
|
+
virtualPath: "./node_modules/@microsoft/typespec-msgraph",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
realDir: "dist/src",
|
|
14
|
+
pattern: "*.js",
|
|
15
|
+
virtualPath: "./node_modules/@microsoft/typespec-msgraph/dist/src",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
realDir: "lib",
|
|
19
|
+
pattern: "*.tsp",
|
|
20
|
+
virtualPath: "./node_modules/@microsoft/typespec-msgraph/lib",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB,GAAwB;IACrD,IAAI,EAAE,6BAA6B;IACnC,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC;IACxE,KAAK,EAAE;QACL;YACE,OAAO,EAAE,EAAE;YACX,OAAO,EAAE,cAAc;YACvB,WAAW,EAAE,4CAA4C;SAC1D;QACD;YACE,OAAO,EAAE,UAAU;YACnB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,qDAAqD;SACnE;QACD;YACE,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,gDAAgD;SAC9D;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Enum, Interface, Model, ModelProperty, Namespace, Operation, Program, Scalar, Type, Union } from "@typespec/compiler";
|
|
2
|
+
export declare function getNameForType(program: Program, type: Type): string;
|
|
3
|
+
export declare function getNameForModelType(program: Program, type: Model | Scalar): string;
|
|
4
|
+
export declare function getIdForType(program: Program, type: Type): string;
|
|
5
|
+
export declare function getNavigationTypeId(program: Program, getOperation: Operation): string;
|
|
6
|
+
export declare function getPropertyTypeName(program: Program, type: Type): string;
|
|
7
|
+
export declare function isTypeNullable(program: Program, type: Type): boolean;
|
|
8
|
+
export declare function extractTypesFromUnion(type: Union): Type[];
|
|
9
|
+
export declare function getSingletonTypeId(program: Program, singletonType: string | null, getOperation: Operation | undefined): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Imported from typespec-azure
|
|
12
|
+
* Returns the full namespace name for the given type, if available.
|
|
13
|
+
* @param program the TypeSpec program
|
|
14
|
+
* @param type the type to query
|
|
15
|
+
* @returns The name of the namespace the type belongs in.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getNamespaceName(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum | undefined): string;
|
|
18
|
+
/**
|
|
19
|
+
* Imported from typespec-azure
|
|
20
|
+
* Returns true if the type is defined in a namespace that is excluded from linting.
|
|
21
|
+
* @param program the TypeSpec program
|
|
22
|
+
* @param type the type to query
|
|
23
|
+
* @returns true if the type is defined in a namespace that is excluded from linting.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isExcludedCoreType(program: Program, type: Model | Scalar | Operation | ModelProperty | Interface | Namespace | Enum): boolean;
|
|
26
|
+
export declare function isNavigationProperty(program: Program, property: ModelProperty): boolean;
|
|
27
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,SAAS,EAET,KAAK,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AED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,WAc7E"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { getNamespaceFullName, isArrayModelType, } from "@typespec/compiler";
|
|
2
|
+
import { getEntity, isEntity } from "./decorators/index.js";
|
|
3
|
+
export function getNameForType(program, type) {
|
|
4
|
+
switch (type.kind) {
|
|
5
|
+
case "Union":
|
|
6
|
+
return type.options.map((x, i) => getNameForType(program, x)).join(" | ");
|
|
7
|
+
case "TemplateParameter":
|
|
8
|
+
return type.node.id.sv;
|
|
9
|
+
case "String":
|
|
10
|
+
case "Number":
|
|
11
|
+
case "Boolean":
|
|
12
|
+
return `${type.value}`;
|
|
13
|
+
case "Namespace":
|
|
14
|
+
case "Operation":
|
|
15
|
+
case "Interface":
|
|
16
|
+
case "Enum":
|
|
17
|
+
return type.name;
|
|
18
|
+
case "Model":
|
|
19
|
+
case "Scalar":
|
|
20
|
+
return getNameForModelType(program, type);
|
|
21
|
+
default:
|
|
22
|
+
return type.kind;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function getNameForModelType(program, type) {
|
|
26
|
+
switch (type.name) {
|
|
27
|
+
case "string":
|
|
28
|
+
return "Edm.String";
|
|
29
|
+
case "bytes":
|
|
30
|
+
return "Collection(Edm.Byte)";
|
|
31
|
+
case "int8":
|
|
32
|
+
return "Edm.Byte";
|
|
33
|
+
case "int16":
|
|
34
|
+
return "Edm.Int16";
|
|
35
|
+
case "int32":
|
|
36
|
+
return "Edm.Int32";
|
|
37
|
+
case "int64":
|
|
38
|
+
return "Edm.Int64";
|
|
39
|
+
case "float32":
|
|
40
|
+
return "Edm.Single";
|
|
41
|
+
case "float64":
|
|
42
|
+
return "Edm.Double";
|
|
43
|
+
case "plainDate":
|
|
44
|
+
return "Edm.Date";
|
|
45
|
+
case "plainTime":
|
|
46
|
+
return "Edm.TimeOfDay";
|
|
47
|
+
case "zonedDateTime":
|
|
48
|
+
return "Edm.DateTimeOffset";
|
|
49
|
+
case "duration":
|
|
50
|
+
return "Edm.Duration";
|
|
51
|
+
case "boolean":
|
|
52
|
+
return "Edm.Boolean";
|
|
53
|
+
case "stream":
|
|
54
|
+
return "Edm.Stream";
|
|
55
|
+
default:
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (type.name !== "Array" || type.kind !== "Model" || !type.indexer) {
|
|
59
|
+
return type.name;
|
|
60
|
+
}
|
|
61
|
+
return `Collection(${getPropertyTypeName(program, type.indexer.value)})`;
|
|
62
|
+
}
|
|
63
|
+
export function getIdForType(program, type) {
|
|
64
|
+
switch (type.kind) {
|
|
65
|
+
case "Namespace":
|
|
66
|
+
return getNamespaceFullName(type);
|
|
67
|
+
case "Model":
|
|
68
|
+
case "Enum":
|
|
69
|
+
case "Operation":
|
|
70
|
+
case "Interface":
|
|
71
|
+
return `${getNamespaceFullName(type.namespace)}.${type.name}`;
|
|
72
|
+
case "String":
|
|
73
|
+
case "Number":
|
|
74
|
+
case "Boolean":
|
|
75
|
+
return `${type.value}`;
|
|
76
|
+
case "Union":
|
|
77
|
+
return getIdForUnion(program, type);
|
|
78
|
+
default:
|
|
79
|
+
return type.kind;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export function getNavigationTypeId(program, getOperation) {
|
|
83
|
+
var _a;
|
|
84
|
+
const returnType = getOperation.returnType;
|
|
85
|
+
if (returnType.kind !== "Model" || !((_a = returnType.templateArguments) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
86
|
+
return getIdForType(program, returnType);
|
|
87
|
+
}
|
|
88
|
+
return getIdForType(program, returnType.templateArguments[0]);
|
|
89
|
+
}
|
|
90
|
+
export function getPropertyTypeName(program, type) {
|
|
91
|
+
var _a;
|
|
92
|
+
if (type.kind === "Union") {
|
|
93
|
+
const unionTypes = extractTypesFromUnion(type);
|
|
94
|
+
const nonNullTypes = unionTypes.filter((t) => !isNullType(program, t));
|
|
95
|
+
if (!nonNullTypes.length) {
|
|
96
|
+
return "undefined.";
|
|
97
|
+
}
|
|
98
|
+
return getPropertyTypeName(program, nonNullTypes[0]);
|
|
99
|
+
}
|
|
100
|
+
if ((type.kind === "Model" || type.kind === "Scalar") && ((_a = type.namespace) === null || _a === void 0 ? void 0 : _a.name) === "TypeSpec") {
|
|
101
|
+
return getNameForType(program, type);
|
|
102
|
+
}
|
|
103
|
+
return getIdForType(program, type);
|
|
104
|
+
}
|
|
105
|
+
export function isTypeNullable(program, type) {
|
|
106
|
+
if (type.kind !== "Union") {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const unionTypes = extractTypesFromUnion(type);
|
|
110
|
+
return unionTypes.some((t) => isNullType(program, t));
|
|
111
|
+
}
|
|
112
|
+
function getIdForUnion(program, unionType) {
|
|
113
|
+
const unionTypes = extractTypesFromUnion(unionType);
|
|
114
|
+
const nonNullTypes = unionTypes.filter((t) => !isNullType(program, t));
|
|
115
|
+
if (!nonNullTypes.length) {
|
|
116
|
+
return "undefined.";
|
|
117
|
+
}
|
|
118
|
+
return getIdForType(program, nonNullTypes[0]);
|
|
119
|
+
}
|
|
120
|
+
function isNullType(program, type) {
|
|
121
|
+
return type.kind === "Intrinsic" && type.name === "null";
|
|
122
|
+
}
|
|
123
|
+
export function extractTypesFromUnion(type) {
|
|
124
|
+
return [...type.variants].map(([_, variant]) => variant.type);
|
|
125
|
+
}
|
|
126
|
+
export function getSingletonTypeId(program, singletonType, getOperation) {
|
|
127
|
+
if (singletonType) {
|
|
128
|
+
const entity = getEntity(program, singletonType);
|
|
129
|
+
return entity && getIdForType(program, entity);
|
|
130
|
+
}
|
|
131
|
+
return getOperation && getNavigationTypeId(program, getOperation);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Imported from typespec-azure
|
|
135
|
+
* Returns the full namespace name for the given type, if available.
|
|
136
|
+
* @param program the TypeSpec program
|
|
137
|
+
* @param type the type to query
|
|
138
|
+
* @returns The name of the namespace the type belongs in.
|
|
139
|
+
*/
|
|
140
|
+
export function getNamespaceName(program, type) {
|
|
141
|
+
if (type === undefined) {
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
if (type.kind === "ModelProperty") {
|
|
145
|
+
if (!type.model) {
|
|
146
|
+
return "";
|
|
147
|
+
}
|
|
148
|
+
return getNamespaceName(program, type.model);
|
|
149
|
+
}
|
|
150
|
+
if (type.kind !== "Namespace") {
|
|
151
|
+
type = type.namespace;
|
|
152
|
+
}
|
|
153
|
+
if (type === undefined) {
|
|
154
|
+
return "";
|
|
155
|
+
}
|
|
156
|
+
return getNamespaceFullName(type);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Imported from typespec-azure
|
|
160
|
+
* Returns true if the type is defined in a namespace that is excluded from linting.
|
|
161
|
+
* @param program the TypeSpec program
|
|
162
|
+
* @param type the type to query
|
|
163
|
+
* @returns true if the type is defined in a namespace that is excluded from linting.
|
|
164
|
+
*/
|
|
165
|
+
export function isExcludedCoreType(program, type) {
|
|
166
|
+
//
|
|
167
|
+
// https://github.com/Azure/typespec-azure/issues/801#issuecomment-1194454247
|
|
168
|
+
//
|
|
169
|
+
const nsName = getNamespaceName(program, type);
|
|
170
|
+
const excludedNamespaces = ["TypeSpec", "TypeSpec"];
|
|
171
|
+
return excludedNamespaces.find((ns) => nsName.startsWith(ns)) !== undefined;
|
|
172
|
+
}
|
|
173
|
+
export function isNavigationProperty(program, property) {
|
|
174
|
+
let propertyType = property.type;
|
|
175
|
+
if (propertyType.kind !== "Model") {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
if (isArrayModelType(program, propertyType)) {
|
|
179
|
+
propertyType = propertyType.indexer.value;
|
|
180
|
+
if (propertyType.kind !== "Model") {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return isEntity(program, propertyType);
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|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Y,CAAC,IAAI,KAAK,OAAO,EAAE;YACjC,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
using TypeSpec.Reflection;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TODO: Enable this once Model type is supported. https://github.com/microsoft/typespec/issues/1655
|
|
5
|
+
*
|
|
6
|
+
* `@abstract` - mark a model type as abstract
|
|
7
|
+
*
|
|
8
|
+
* `@abstract` can only be applied to models.
|
|
9
|
+
|
|
10
|
+
extern dec abstract(target: Model);
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* `@alternateKey` - mark a model property as an alternateKey
|
|
15
|
+
*
|
|
16
|
+
* `@alternateKey` can only be applied to Model properties.
|
|
17
|
+
*/
|
|
18
|
+
extern dec alternateKey(target: ModelProperty);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* TODO: Enable this once Model type is supported. https://github.com/microsoft/typespec/issues/1655
|
|
22
|
+
*
|
|
23
|
+
* `@complex` - mark a model as an entity type
|
|
24
|
+
*
|
|
25
|
+
* `@complex` can only be applied to models.
|
|
26
|
+
|
|
27
|
+
extern dec complex(target: Model);
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `@computed` - mark a model property as a computed property
|
|
32
|
+
*
|
|
33
|
+
* `@computed` can only be applied to model properties.
|
|
34
|
+
*/
|
|
35
|
+
extern dec computed(target: ModelProperty);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `@contains` - mark a model property as a contained navigation property
|
|
39
|
+
*
|
|
40
|
+
* `@contains` can only be applied to navigation model properties.
|
|
41
|
+
*/
|
|
42
|
+
extern dec contains(target: ModelProperty);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `@count` - Applies to: get operations that return collections.
|
|
46
|
+
* Indicates that the get operation supports both the OData $count query parameter and the $count trailing segment added to the collection route.
|
|
47
|
+
* These are indivisible for the sake of customer simplicity.
|
|
48
|
+
*/
|
|
49
|
+
extern dec count(target: Operation);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `@deprecatedDefinition` - Allow us create a reusable deprecation definition.
|
|
53
|
+
* `@deprecatedDefinition` - Applies only to namespaces.
|
|
54
|
+
*/
|
|
55
|
+
extern dec deprecatedDefinition(
|
|
56
|
+
target: Namespace,
|
|
57
|
+
name: string,
|
|
58
|
+
category: string,
|
|
59
|
+
announcementDate: string,
|
|
60
|
+
removalDate: string,
|
|
61
|
+
description: string
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* TODO: Enable this once Model type is supported. https://github.com/microsoft/typespec/issues/1655
|
|
66
|
+
*
|
|
67
|
+
* `@entity` - mark a model as an entity type
|
|
68
|
+
*
|
|
69
|
+
* `@entity` can only be applied to models.
|
|
70
|
+
|
|
71
|
+
extern dec entity(target: Model);
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `@expand` - Applies to: get operations that return collections or individual instances of models that contain @contains or @references properties.
|
|
76
|
+
* Indicates that the get operation supports the OData $expand query parameter.
|
|
77
|
+
*
|
|
78
|
+
* `properties` - Property names in the model returned from the get that can be used in a $expand query parameter.
|
|
79
|
+
* At least one property must be specified.
|
|
80
|
+
*/
|
|
81
|
+
extern dec expand(target: Operation, property: string, ...otherProperties: string[]);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* TODO: Enable this once Model type is supported. https://github.com/microsoft/typespec/issues/1655
|
|
85
|
+
*
|
|
86
|
+
* `@hasStream` - indicates that an `@entity` model has a stream.
|
|
87
|
+
*
|
|
88
|
+
* `mediaTypes` - list of media types supported by the stream.
|
|
89
|
+
* If not specified, the stream supports any media type.
|
|
90
|
+
|
|
91
|
+
extern dec hasStream(target: Model, ...mediaTypes: string[]);
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* `@orderBy` - Applies to: get operations that return collections of @entity or @complex models.
|
|
96
|
+
* Indicates that the get operation supports the OData $orderBy query parameter.
|
|
97
|
+
*
|
|
98
|
+
* `properties` - List of property names in the model returned from the get operation that can be used in a $orderBy query parameter.
|
|
99
|
+
* At least one property must be specified.
|
|
100
|
+
*/
|
|
101
|
+
extern dec orderBy(target: Operation, property: string, ...otherProperties: string[]);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* TODO: Enable this once Model type is supported. https://github.com/microsoft/typespec/issues/1655
|
|
105
|
+
*
|
|
106
|
+
* `@privatePreview` - Allow us define a privatePreview element.
|
|
107
|
+
* `@privatePreview` - Applies to models, model properties, enums, enum members, namespaces and operations.
|
|
108
|
+
|
|
109
|
+
extern dec privatePreview(
|
|
110
|
+
target: Model | ModelProperty | EnumMember | Enum | Operation | Namespace,
|
|
111
|
+
name: string
|
|
112
|
+
)
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* `@privatePreviewDefinition` - Allow us create a reusable private preview definition.
|
|
117
|
+
* `@privatePreviewDefinition` - Applies only to namespaces.
|
|
118
|
+
*/
|
|
119
|
+
extern dec privatePreviewDefinition(
|
|
120
|
+
target: Namespace,
|
|
121
|
+
name: string,
|
|
122
|
+
announcementDate: string,
|
|
123
|
+
removalDate: string,
|
|
124
|
+
owner: string
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* `@search` - Applies to: get operations that return collections.
|
|
129
|
+
* Indicates that the get operation supports the OData $search query parameter.
|
|
130
|
+
*/
|
|
131
|
+
extern dec search(target: Operation);
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* `@skip` - Applies to: get operations that return collections.
|
|
135
|
+
* Indicates that the get operation supports the OData $skip query parameter.
|
|
136
|
+
*/
|
|
137
|
+
extern dec skip(target: Operation);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* `@readOnly` - mark a model property as readOnly property
|
|
141
|
+
*
|
|
142
|
+
* `@readOnly` can only be applied to model properties.
|
|
143
|
+
*/
|
|
144
|
+
extern dec readOnly(target: ModelProperty);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* `@references` - mark a model property as a non-contained navigation property
|
|
148
|
+
*
|
|
149
|
+
* `@references` can only be applied to navigation model properties.
|
|
150
|
+
*/
|
|
151
|
+
extern dec references(target: ModelProperty);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* `@top` - Applies to: get operations that return collections.
|
|
155
|
+
* Indicates that the get operation supports the OData $top query parameter.
|
|
156
|
+
*/
|
|
157
|
+
extern dec top(target: Operation);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* `@writeOnly` - mark a model property as writeOnly property
|
|
161
|
+
*
|
|
162
|
+
* `@writeOnly` can only be applied to model properties.
|
|
163
|
+
*/
|
|
164
|
+
extern dec writeOnly(target: ModelProperty);
|
package/lib/lib.tsp
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "../dist/src/index.js";
|
|
2
|
+
import "@typespec/rest";
|
|
3
|
+
|
|
4
|
+
using TypeSpec.Http;
|
|
5
|
+
namespace TypeSpec.MsGraph;
|
|
6
|
+
|
|
7
|
+
scalar date;
|
|
8
|
+
|
|
9
|
+
scalar stream;
|
|
10
|
+
|
|
11
|
+
model ResourceResponse {}
|
|
12
|
+
|
|
13
|
+
model EmptyParameters {}
|
|
14
|
+
|
|
15
|
+
model PagedListResponse {}
|
|
16
|
+
|
|
17
|
+
interface Item<T> {
|
|
18
|
+
@head _isOperation(@path id: string): T;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface List<T> {
|
|
22
|
+
@head _isOperation(): T[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Singleton<T> {
|
|
26
|
+
@head _isNavigationSource(@path id: string): T;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface EntitySet<T> {
|
|
30
|
+
@head _isNavigationSource(): T[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface EntitySetResource<T> {
|
|
34
|
+
@head _isNavigationSource(@path id: string): T[];
|
|
35
|
+
}
|
package/lib/msgraph.tsp
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/typespec-msgraph",
|
|
3
|
+
"version": "0.0.1-Preview.1",
|
|
4
|
+
"author": "Microsoft Corporation",
|
|
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
|
+
"homepage": "https://github.com/microsoftgraph/typespec-msgraph",
|
|
7
|
+
"readme": "https://github.com/microsoftgraph/typespec-msgraph/blob/master/README.md",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/microsoftgraph/typespec-msgraph.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": { "url": "https://github.com/microsoftgraph/typespec-msgraph/issues" },
|
|
14
|
+
"keywords": ["typespec"],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/src/index.js",
|
|
17
|
+
"tspMain": "lib/msgraph.tsp",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/src/index.js",
|
|
20
|
+
"./testing": "./dist/src/testing/index.js"
|
|
21
|
+
},
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
"*": {
|
|
24
|
+
"*": ["./dist/src/index.d.ts"],
|
|
25
|
+
"testing": ["./dist/src/testing/index.d.ts"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"engines": { "node": ">=14.0.0" },
|
|
29
|
+
"scripts": {
|
|
30
|
+
"clean": "rimraf ./dist ./temp",
|
|
31
|
+
"prebuild": "tsx src/decorators/attribute-builder.ts",
|
|
32
|
+
"build": "tsc -p .",
|
|
33
|
+
"watch": "tsc -p . --watch",
|
|
34
|
+
"test": "mocha",
|
|
35
|
+
"buildntest": "tsc -p . && mocha",
|
|
36
|
+
"test-official": "c8 mocha --forbid-only",
|
|
37
|
+
"lint": "eslint . --ext .ts,.tsx --max-warnings=0",
|
|
38
|
+
"lint:fix": "eslint . --fix --ext .ts,.tsx"
|
|
39
|
+
},
|
|
40
|
+
"files": ["lib/*.tsp", "dist/**", "!dist/test/**"],
|
|
41
|
+
"peerDependencies": { "@typespec/compiler": "~0.43.0" },
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"prettier": "~2.8.7",
|
|
44
|
+
"react-dom": "~18.2.0",
|
|
45
|
+
"react": "~18.2.0",
|
|
46
|
+
"react-reconciler": "~0.27.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/mocha": "~10.0.0",
|
|
50
|
+
"@types/node": "~18.11.9",
|
|
51
|
+
"@types/prettier": "2.6.0",
|
|
52
|
+
"@types/react": "~18.0.5",
|
|
53
|
+
"@types/react-reconciler": "~0.28.0",
|
|
54
|
+
"@typespec/compiler": "~0.43.0",
|
|
55
|
+
"@typespec/eslint-config-typespec": "~0.6.0",
|
|
56
|
+
"@typespec/http": "~0.43.1",
|
|
57
|
+
"@typespec/lint": "~0.43.0",
|
|
58
|
+
"@typespec/rest": "~0.43.0",
|
|
59
|
+
"@xmldom/xmldom": "~0.8.2",
|
|
60
|
+
"c8": "~7.13.0",
|
|
61
|
+
"eslint": "^8.36.0",
|
|
62
|
+
"mocha": "~10.2.0",
|
|
63
|
+
"rimraf": "~5.0.0",
|
|
64
|
+
"typescript": "~5.0.2",
|
|
65
|
+
"xpath": "~0.0.32",
|
|
66
|
+
"tsx": "~3.12.3"
|
|
67
|
+
}
|
|
68
|
+
}
|