@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 @@
|
|
|
1
|
+
{"version":3,"file":"revisions-annotation.d.ts","sourceRoot":"","sources":["../../../src/components/revisions-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EACV,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAc7D,eAAO,MAAM,mBAAmB,EAAE,iBAAiB,CAAC;IAClD,IAAI,EAAE,KAAK,GAAG,aAAa,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,CAAC;IACxE,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC,CA+BA,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getDeprecated, } from "@typespec/compiler";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { getDeprecatedDefinitions, getPrivatePreview, getPrivatePreviewDefinitions, } from "../index.js";
|
|
4
|
+
import { AnnotationElement, CollectionElement, PropertyValueElement, RecordElement, } from "./common-elements.js";
|
|
5
|
+
import { ProgramContext } from "./program-context.js";
|
|
6
|
+
export const RevisionsAnnotation = ({ item, namespace }) => {
|
|
7
|
+
if (!namespace) {
|
|
8
|
+
return React.createElement(React.Fragment, null);
|
|
9
|
+
}
|
|
10
|
+
const program = useContext(ProgramContext);
|
|
11
|
+
const definition = getRevisionDefinition(program, item, namespace);
|
|
12
|
+
if (!definition) {
|
|
13
|
+
return React.createElement(React.Fragment, null);
|
|
14
|
+
}
|
|
15
|
+
return (React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.Revisions" },
|
|
16
|
+
React.createElement(CollectionElement, null,
|
|
17
|
+
React.createElement(RecordElement, null,
|
|
18
|
+
React.createElement(PropertyValueElement, { Property: "Date", Date: definition.date }),
|
|
19
|
+
React.createElement(PropertyValueElement, { Property: "Version", String: definition.version }),
|
|
20
|
+
React.createElement(PropertyValueElement, { Property: "Kind", EnumMember: "Org.OData.Core.V1.RevisionKind/Deprecated" }),
|
|
21
|
+
React.createElement(PropertyValueElement, { Property: "RemovalDate", Date: definition.removalDate }),
|
|
22
|
+
definition.description ? (React.createElement(PropertyValueElement, { Property: "Description", String: definition.description })) : (React.createElement(React.Fragment, null))))));
|
|
23
|
+
};
|
|
24
|
+
function getRevisionDefinition(program, item, namespace) {
|
|
25
|
+
const deprecated = getDeprecated(program, item);
|
|
26
|
+
if (deprecated) {
|
|
27
|
+
return getRevisionDefinitionFromDeprecation(program, namespace, deprecated);
|
|
28
|
+
}
|
|
29
|
+
const privatePreview = getPrivatePreview(program, item);
|
|
30
|
+
if (privatePreview) {
|
|
31
|
+
return getRevisionDefinitionFromPrivatePreview(program, namespace, privatePreview);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
function getRevisionDefinitionFromDeprecation(program, namespace, deprecated) {
|
|
36
|
+
const deprecatedDefinitions = getDeprecatedDefinitions(program, namespace);
|
|
37
|
+
const definition = deprecatedDefinitions.get(deprecated);
|
|
38
|
+
if (!definition) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
date: definition.announcementDate,
|
|
43
|
+
removalDate: definition.removalDate,
|
|
44
|
+
version: `${definition.announcementDate.substring(0, 7)}/${definition.category}`,
|
|
45
|
+
description: definition.description,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function getRevisionDefinitionFromPrivatePreview(program, namespace, deprecated) {
|
|
49
|
+
const privatePreviewDefinitions = getPrivatePreviewDefinitions(program, namespace);
|
|
50
|
+
const definition = privatePreviewDefinitions.get(deprecated);
|
|
51
|
+
if (!definition) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
date: definition.announcementDate,
|
|
56
|
+
removalDate: definition.removalDate,
|
|
57
|
+
version: `${definition.announcementDate.substring(0, 7)}/PrivatePreview:${definition.name}`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=revisions-annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revisions-annotation.js","sourceRoot":"","sources":["../../../src/components/revisions-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,mBAAmB,GAG3B,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;IAC3B,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,yCAAK,CAAC;KACd;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACnE,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,yCAAK,CAAC;KACd;IAED,OAAO,CACL,oBAAC,iBAAiB,IAAC,IAAI,EAAC,6BAA6B;QACnD,oBAAC,iBAAiB;YAChB,oBAAC,aAAa;gBACZ,oBAAC,oBAAoB,IAAC,QAAQ,EAAC,MAAM,EAAC,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AU,CAAC,gBAAgB;QACjC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,GAAG,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC,QAAQ,EAAE;QAChF,WAAW,EAAE,UAAU,CAAC,WAAW;KACpC,CAAC;AACJ,CAAC;AAED,SAAS,uCAAuC,CAC9C,OAAgB,EAChB,SAAoB,EACpB,UAAkB;IAElB,MAAM,yBAAyB,GAAG,4BAA4B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACnF,MAAM,UAAU,GAAG,yBAAyB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IAED,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB;QACjC,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,OAAO,EAAE,GAAG,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,mBAAmB,UAAU,CAAC,IAAI,EAAE;KAC5F,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-restrictions-annotation.d.ts","sourceRoot":"","sources":["../../../src/components/search-restrictions-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAK7D,eAAO,MAAM,4BAA4B,EAAE,iBAAiB,CAAC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAiBpF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { isSearch } from "../index.js";
|
|
3
|
+
import { AnnotationElement, PropertyValueElement, RecordElement } from "./common-elements.js";
|
|
4
|
+
import { ProgramContext } from "./program-context.js";
|
|
5
|
+
export const SearchRestrictionsAnnotation = (props) => {
|
|
6
|
+
const program = useContext(ProgramContext);
|
|
7
|
+
const hasSearchOperation = [...props.interface.operations].some(([_, operation]) => isSearch(program, operation));
|
|
8
|
+
if (hasSearchOperation) {
|
|
9
|
+
return React.createElement(React.Fragment, null);
|
|
10
|
+
}
|
|
11
|
+
return (React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.SearchRestrictions" },
|
|
12
|
+
React.createElement(RecordElement, null,
|
|
13
|
+
React.createElement(PropertyValueElement, { Property: "Searchable", Bool: "false" }))));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=search-restrictions-annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-restrictions-annotation.js","sourceRoot":"","sources":["../../../src/components/search-restrictions-annotation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,4BAA4B,GAAgD,CAAC,KAAK,EAAE,EAAE;IACjG,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,kBAAkB,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CACjF,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAC7B,CAAC;IAEF,IAAI,kBAAkB,EAAE;QACtB,OAAO,yCAAK,CAAC;KACd;IAED,OAAO,CACL,oBAAC,iBAAiB,IAAC,IAAI,EAAC,sCAAsC;QAC5D,oBAAC,aAAa;YACZ,oBAAC,oBAAoB,IAAC,QAAQ,EAAC,YAAY,EAAC,IAAI,EAAC,OAAO,GAAG,CAC7C,CACE,CACrB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-supported-annotation.d.ts","sourceRoot":"","sources":["../../../src/components/skip-supported-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAK7D,eAAO,MAAM,uBAAuB,EAAE,iBAAiB,CAAC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAW/E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { isSkip } from "../index.js";
|
|
3
|
+
import { AnnotationElement } from "./common-elements.js";
|
|
4
|
+
import { ProgramContext } from "./program-context.js";
|
|
5
|
+
export const SkipSupportedAnnotation = (props) => {
|
|
6
|
+
const program = useContext(ProgramContext);
|
|
7
|
+
const hasSkipOperation = [...props.interface.operations].some(([_, operation]) => isSkip(program, operation));
|
|
8
|
+
if (hasSkipOperation) {
|
|
9
|
+
return React.createElement(React.Fragment, null);
|
|
10
|
+
}
|
|
11
|
+
return React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.SkipSupported", Bool: "false" });
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=skip-supported-annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skip-supported-annotation.js","sourceRoot":"","sources":["../../../src/components/skip-supported-annotation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,uBAAuB,GAAgD,CAAC,KAAK,EAAE,EAAE;IAC5F,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAC/E,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAC3B,CAAC;IAEF,IAAI,gBAAgB,EAAE;QACpB,OAAO,yCAAK,CAAC;KACd;IAED,OAAO,oBAAC,iBAAiB,IAAC,IAAI,EAAC,iCAAiC,EAAC,IAAI,EAAC,OAAO,GAAG,CAAC;AACnF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Interface, Model } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export declare const SortRestrictionsAnnotation: FunctionComponent<{
|
|
4
|
+
interface: Interface;
|
|
5
|
+
model: Model;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=sort-restrictions-annotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-restrictions-annotation.d.ts","sourceRoot":"","sources":["../../../src/components/sort-restrictions-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAA2B,MAAM,oBAAoB,CAAC;AAE/E,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAa7D,eAAO,MAAM,0BAA0B,EAAE,iBAAiB,CAAC;IACzD,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;CACd,CAgDA,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { walkPropertiesInherited } from "@typespec/compiler";
|
|
2
|
+
import { getOperationVerb } from "@typespec/http";
|
|
3
|
+
import React, { useContext } from "react";
|
|
4
|
+
import { ProgramContext } from "./program-context.js";
|
|
5
|
+
import { getOrderBy, isContains, isOrderBy, isReferences } from "../index.js";
|
|
6
|
+
import { AnnotationElement, CollectionElement, PropertyPathElement, PropertyValueElement, RecordElement, } from "./common-elements.js";
|
|
7
|
+
export const SortRestrictionsAnnotation = (props) => {
|
|
8
|
+
const program = useContext(ProgramContext);
|
|
9
|
+
const orderedOperation = [...props.interface.operations].find(([_, operation]) => getOperationVerb(program, operation) === "get" &&
|
|
10
|
+
operation.parameters.properties.size === 0 &&
|
|
11
|
+
isOrderBy(program, operation));
|
|
12
|
+
if (!orderedOperation) {
|
|
13
|
+
return (React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.SortRestrictions" },
|
|
14
|
+
React.createElement(RecordElement, null,
|
|
15
|
+
React.createElement(PropertyValueElement, { Property: "Sortable", Bool: "false" }))));
|
|
16
|
+
}
|
|
17
|
+
// Destructuring to get the operation from the [string, Operation] orderedOperation tuple
|
|
18
|
+
const [_, operation] = orderedOperation;
|
|
19
|
+
const sortableProperties = getOrderBy(program, operation);
|
|
20
|
+
const nonNavigationProperties = [...walkPropertiesInherited(props.model)]
|
|
21
|
+
.filter((property) => !isContains(program, property) && !isReferences(program, property))
|
|
22
|
+
.map((property) => property.name);
|
|
23
|
+
const nonSortableProperties = nonNavigationProperties.filter((property) => !sortableProperties.includes(property));
|
|
24
|
+
return (React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.SortRestrictions" },
|
|
25
|
+
React.createElement(RecordElement, null,
|
|
26
|
+
React.createElement(PropertyValueElement, { Property: "Sortable", Bool: "true" }),
|
|
27
|
+
React.createElement(PropertyValueElement, { Property: "NonSortableProperties" },
|
|
28
|
+
React.createElement(CollectionElement, null, nonSortableProperties.map((property) => (React.createElement(PropertyPathElement, { key: property },
|
|
29
|
+
React.createElement(React.Fragment, null, property)))))))));
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=sort-restrictions-annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-restrictions-annotation.js","sourceRoot":"","sources":["../../../src/components/sort-restrictions-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,0BAA0B,GAGlC,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAE3C,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAC3D,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CACjB,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK;QAC9C,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;QAC1C,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAChC,CAAC;IAEF,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,CACL,oBAAC,iBAAiB,IAAC,IAAI,EAAC,4CAA4C;YAClE,oBAAC,aAAa;gBACZ,oBAAC,oBAAoB,IAAC,QAAQ,EAAC,UAAU,EAAC,IAAI,EAAC,OAAO,GAAG,CAC3C,CACE,CACrB,CAAC;KACH;IAED,yFAAyF;IACzF,MAAM,CAAC,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eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAcrE,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isKey } from "@typespec/compiler";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { buildAttributes, hasStream, isAbstract, isComplex, isEntity, isOpen } from "../index.js";
|
|
4
|
+
import { getIdForType } from "../utils.js";
|
|
5
|
+
import { AcceptableMediaTypesAnnotation } from "./acceptable-media-types-annotation.js";
|
|
6
|
+
import { AlternateKeysAnnotation } from "./alternate-keys-annotation.js";
|
|
7
|
+
import { ItemList, PropertyRefElement } from "./common-elements.js";
|
|
8
|
+
import { DescriptionAnnotation } from "./description-annotation.js";
|
|
9
|
+
import { ProgramContext } from "./program-context.js";
|
|
10
|
+
import { PropertyElement } from "./property-element.js";
|
|
11
|
+
import { RevisionsAnnotation } from "./revisions-annotation.js";
|
|
12
|
+
const EntityType = (props) => React.createElement("EntityType", props);
|
|
13
|
+
const ComplexType = (props) => React.createElement("ComplexType", props);
|
|
14
|
+
const Key = (props) => React.createElement("Key", props);
|
|
15
|
+
export const StructuredTypeElement = ({ model }) => {
|
|
16
|
+
const program = useContext(ProgramContext);
|
|
17
|
+
const isEntityType = isEntity(program, model);
|
|
18
|
+
const isComplexType = isComplex(program, model);
|
|
19
|
+
if (isEntityType) {
|
|
20
|
+
return React.createElement(EntityTypeElement, { model: model });
|
|
21
|
+
}
|
|
22
|
+
if (isComplexType) {
|
|
23
|
+
return React.createElement(ComplexTypeElement, { model: model });
|
|
24
|
+
}
|
|
25
|
+
return React.createElement(React.Fragment, null);
|
|
26
|
+
};
|
|
27
|
+
const EntityTypeElement = ({ model }) => {
|
|
28
|
+
const program = useContext(ProgramContext);
|
|
29
|
+
const props = getStructuredTypeProps(program, model);
|
|
30
|
+
return (React.createElement(EntityType, { ...props },
|
|
31
|
+
React.createElement(KeyPropertyElement, { model: model }),
|
|
32
|
+
React.createElement(PropertyList, { properties: model.properties }),
|
|
33
|
+
React.createElement(AlternateKeysAnnotation, { model: model }),
|
|
34
|
+
React.createElement(AcceptableMediaTypesAnnotation, { item: model }),
|
|
35
|
+
React.createElement(RevisionsAnnotation, { item: model, namespace: model.namespace }),
|
|
36
|
+
React.createElement(DescriptionAnnotation, { type: model })));
|
|
37
|
+
};
|
|
38
|
+
const ComplexTypeElement = ({ model }) => {
|
|
39
|
+
const program = useContext(ProgramContext);
|
|
40
|
+
const props = getStructuredTypeProps(program, model);
|
|
41
|
+
return (React.createElement(ComplexType, { ...props },
|
|
42
|
+
React.createElement(PropertyList, { properties: model.properties }),
|
|
43
|
+
React.createElement(RevisionsAnnotation, { item: model, namespace: model.namespace }),
|
|
44
|
+
React.createElement(DescriptionAnnotation, { type: model })));
|
|
45
|
+
};
|
|
46
|
+
const KeyPropertyElement = ({ model }) => {
|
|
47
|
+
const program = useContext(ProgramContext);
|
|
48
|
+
const keyProperty = [...model.properties.entries()].find(([k, property]) => isKey(program, property));
|
|
49
|
+
if (!keyProperty) {
|
|
50
|
+
return React.createElement(React.Fragment, null);
|
|
51
|
+
}
|
|
52
|
+
return (React.createElement(Key, null,
|
|
53
|
+
React.createElement(PropertyRefElement, { Name: keyProperty[0] })));
|
|
54
|
+
};
|
|
55
|
+
const PropertyList = (props) => {
|
|
56
|
+
return (React.createElement(ItemList, { items: props.properties, render: (property) => React.createElement(PropertyElement, { property: property }) }));
|
|
57
|
+
};
|
|
58
|
+
function getStructuredTypeProps(program, model) {
|
|
59
|
+
const props = {
|
|
60
|
+
Name: model.name,
|
|
61
|
+
};
|
|
62
|
+
if (isOpen(program, model)) {
|
|
63
|
+
props.OpenType = "true";
|
|
64
|
+
}
|
|
65
|
+
if (hasStream(program, model)) {
|
|
66
|
+
props.HasStream = "true";
|
|
67
|
+
}
|
|
68
|
+
if (model.baseModel) {
|
|
69
|
+
props.BaseType = getIdForType(program, model.baseModel);
|
|
70
|
+
}
|
|
71
|
+
if (isAbstract(program, model)) {
|
|
72
|
+
props.Abstract = "true";
|
|
73
|
+
}
|
|
74
|
+
const agsAttributes = buildAttributes(program, model);
|
|
75
|
+
return Object.assign(props, agsAttributes);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=structured-type-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured-type-element.js","sourceRoot":"","sources":["../../../src/components/structured-type-element.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAUhE,MAAM,UAAU,GAAG,CAAC,KAA0B,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;AAC5F,MAAM,WAAW,GAAG,CAAC,KAA0B,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAE9F,MAAM,GAAG,GAAG,CAAC,KAAwB,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CA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C,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;IAEF,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QAC1B,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;KACzB;IAED,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QAC7B,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;KAC1B;IAED,IAAI,KAAK,CAAC,SAAS,EAAE;QACnB,KAAK,CAAC,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;KACzD;IAED,IAAI,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;QAC9B,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;KACzB;IAED,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAEtD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-supported-annotation.d.ts","sourceRoot":"","sources":["../../../src/components/top-supported-annotation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAK7D,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAW9E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { isTop } from "../index.js";
|
|
3
|
+
import { AnnotationElement } from "./common-elements.js";
|
|
4
|
+
import { ProgramContext } from "./program-context.js";
|
|
5
|
+
export const TopSupportedAnnotation = (props) => {
|
|
6
|
+
const program = useContext(ProgramContext);
|
|
7
|
+
const hasTopOperation = [...props.interface.operations].some(([_, operation]) => isTop(program, operation));
|
|
8
|
+
if (hasTopOperation) {
|
|
9
|
+
return React.createElement(React.Fragment, null);
|
|
10
|
+
}
|
|
11
|
+
return React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.TopSupported", Bool: "false" });
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=top-supported-annotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"top-supported-annotation.js","sourceRoot":"","sources":["../../../src/components/top-supported-annotation.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAqB,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAgD,CAAC,KAAK,EAAE,EAAE;IAC3F,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAC9E,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAC1B,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,OAAO,yCAAK,CAAC;KACd;IAED,OAAO,oBAAC,iBAAiB,IAAC,IAAI,EAAC,gCAAgC,EAAC,IAAI,EAAC,OAAO,GAAG,CAAC;AAClF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Program } from "@typespec/compiler";
|
|
2
|
+
import { FunctionComponent } from "react";
|
|
3
|
+
export declare function renderCsdl(program: Program): string;
|
|
4
|
+
export interface TypeSpecProgramViewerProps {
|
|
5
|
+
program: Program;
|
|
6
|
+
}
|
|
7
|
+
export declare const TypeSpecProgramViewer: FunctionComponent<TypeSpecProgramViewerProps>;
|
|
8
|
+
//# sourceMappingURL=csdl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csdl.d.ts","sourceRoot":"","sources":["../../src/csdl.tsx"],"names":[],"mappings":"AAAA,OAAO,EASL,OAAO,EAER,MAAM,oBAAoB,CAAC;AAK5B,OAAc,EAAE,iBAAiB,EAAc,MAAM,OAAO,CAAC;AA6C7D,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,UAK1C;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,OAAO,CAAC;CAClB;AAWD,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,0BAA0B,CAkB/E,CAAC"}
|
package/dist/src/csdl.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { isVoidType, } from "@typespec/compiler";
|
|
2
|
+
import { getOperationVerb, getRoutePath, isPathParam } from "@typespec/http";
|
|
3
|
+
import { getAction } from "@typespec/rest";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
|
+
import { ProgramContext } from "./components/program-context.js";
|
|
6
|
+
import { buildAttributes } from "./decorators/handlers/index.js";
|
|
7
|
+
import { getFunction, isOperationParameters } from "./decorators/index.js";
|
|
8
|
+
import { ActionElement, AnnotationElement, CountRestrictionsAnnotation, DescriptionAnnotation, EntityContainerElement, EntitySetElement, EnumMemberElement, EnumTypeElement, ExpandRestrictionsAnnotation, FunctionElement, ItemList, ParameterElement, PropertyValueElement, RecordElement, ReturnTypeElement, RevisionsAnnotation, SchemaElement, SearchRestrictionsAnnotation, SingletonElement, SkipSupportedAnnotation, SortRestrictionsAnnotation, StructuredTypeElement, TopSupportedAnnotation, } from "./components/index.js";
|
|
9
|
+
import CsdlRenderer from "./dom/renderer.js";
|
|
10
|
+
import { extractTypesFromUnion, getNamespaceName, getPropertyTypeName, isExcludedCoreType, isTypeNullable, } from "./utils.js";
|
|
11
|
+
function expandNamespaces(namespace) {
|
|
12
|
+
return [namespace, ...[...namespace.namespaces.values()].flatMap(expandNamespaces)];
|
|
13
|
+
}
|
|
14
|
+
export function renderCsdl(program) {
|
|
15
|
+
const schemas = React.createElement(TypeSpecProgramViewer, { program: program });
|
|
16
|
+
const csdl = CsdlRenderer.getXmlText(schemas);
|
|
17
|
+
return csdl;
|
|
18
|
+
}
|
|
19
|
+
function hasChildren(type) {
|
|
20
|
+
switch (type.kind) {
|
|
21
|
+
case "Namespace":
|
|
22
|
+
return type.enums.size || type.models.size || type.interfaces.size || type.operations.size;
|
|
23
|
+
default:
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export const TypeSpecProgramViewer = ({ program, }) => {
|
|
28
|
+
const root = program.checker.getGlobalNamespaceType();
|
|
29
|
+
const namespaces = expandNamespaces(root)
|
|
30
|
+
.filter((namespace) => !isExcludedCoreType(program, namespace) && hasChildren(namespace))
|
|
31
|
+
.map((namespace) => ({ namespace, name: getNamespaceName(program, namespace) }));
|
|
32
|
+
return (React.createElement(ProgramContext.Provider, { value: program }, namespaces.map((ns) => {
|
|
33
|
+
return (React.createElement(SchemaElement, { Namespace: ns.name, key: ns.name },
|
|
34
|
+
React.createElement(Elements, { namespace: ns.namespace })));
|
|
35
|
+
})));
|
|
36
|
+
};
|
|
37
|
+
const Elements = ({ namespace }) => {
|
|
38
|
+
return (React.createElement(React.Fragment, null,
|
|
39
|
+
React.createElement(EnumTypeList, { enums: namespace.enums }),
|
|
40
|
+
React.createElement(ModelList, { models: namespace.models }),
|
|
41
|
+
React.createElement(OperationList, { namespace: namespace }),
|
|
42
|
+
React.createElement(EntityContainerItem, { namespace: namespace })));
|
|
43
|
+
};
|
|
44
|
+
const EnumTypeList = (props) => (React.createElement(ItemList, { items: props.enums, render: (type) => {
|
|
45
|
+
const program = useContext(ProgramContext);
|
|
46
|
+
const agsAttributes = buildAttributes(program, type);
|
|
47
|
+
return (React.createElement(EnumTypeElement, { Name: type.name, ...agsAttributes },
|
|
48
|
+
React.createElement(EnumMemberList, { members: type.members }),
|
|
49
|
+
React.createElement(RevisionsAnnotation, { item: type, namespace: type === null || type === void 0 ? void 0 : type.namespace })));
|
|
50
|
+
} }));
|
|
51
|
+
const EnumMemberList = (props) => (React.createElement(ItemList, { items: props.members, render: (member) => {
|
|
52
|
+
var _a;
|
|
53
|
+
const program = useContext(ProgramContext);
|
|
54
|
+
const agsAttributes = buildAttributes(program, member);
|
|
55
|
+
return (React.createElement(EnumMemberElement, { Name: member.name, Value: member.value, ...agsAttributes },
|
|
56
|
+
React.createElement(RevisionsAnnotation, { item: member, namespace: (_a = member.enum) === null || _a === void 0 ? void 0 : _a.namespace })));
|
|
57
|
+
} }));
|
|
58
|
+
const ModelList = ({ models }) => {
|
|
59
|
+
return React.createElement(ItemList, { items: models, render: (model) => React.createElement(StructuredTypeElement, { model: model }) });
|
|
60
|
+
};
|
|
61
|
+
const OperationList = (props) => {
|
|
62
|
+
const operations = [...props.namespace.interfaces]
|
|
63
|
+
.filter(([_, $interface]) => $interface.operations.has("_isOperation"))
|
|
64
|
+
.flatMap(([_, $interface]) => [...$interface.operations])
|
|
65
|
+
.map(([_, operation]) => operation);
|
|
66
|
+
return (React.createElement(ItemList, { items: operations, render: (operation) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
const program = useContext(ProgramContext);
|
|
69
|
+
const actionName = getAction(program, operation);
|
|
70
|
+
const functionName = getFunction(program, operation);
|
|
71
|
+
const agsAttributes = buildAttributes(program, operation);
|
|
72
|
+
const bindingType = (_b = (_a = operation.interface) === null || _a === void 0 ? void 0 : _a.operations.get("_isOperation")) === null || _b === void 0 ? void 0 : _b.returnType;
|
|
73
|
+
if (!bindingType) {
|
|
74
|
+
return React.createElement(React.Fragment, null);
|
|
75
|
+
}
|
|
76
|
+
const bindingTypeName = getPropertyTypeName(program, bindingType);
|
|
77
|
+
if (!bindingTypeName) {
|
|
78
|
+
return React.createElement(React.Fragment, null);
|
|
79
|
+
}
|
|
80
|
+
if (actionName) {
|
|
81
|
+
return (React.createElement(ActionElement, { Name: actionName, IsBound: "true", ...agsAttributes },
|
|
82
|
+
React.createElement(ParameterElement, { Name: "binding", Type: bindingTypeName }),
|
|
83
|
+
React.createElement(ParameterList, { parameters: operation.parameters.properties }),
|
|
84
|
+
React.createElement(ReturnTypeItem, { type: operation.returnType }),
|
|
85
|
+
React.createElement(DescriptionAnnotation, { type: operation })));
|
|
86
|
+
}
|
|
87
|
+
if (functionName) {
|
|
88
|
+
let parameterProperties = [];
|
|
89
|
+
const parameterProperty = operation.parameters.properties.get("parameters");
|
|
90
|
+
if (parameterProperty && parameterProperty.type.kind === "Union") {
|
|
91
|
+
parameterProperties = extractTypesFromUnion(parameterProperty.type).filter((type) => type.kind === "Model");
|
|
92
|
+
}
|
|
93
|
+
if (!parameterProperties.length) {
|
|
94
|
+
return (React.createElement(FunctionElement, { Name: functionName, IsBound: "true", ...agsAttributes },
|
|
95
|
+
React.createElement(ParameterElement, { Name: "binding", Type: bindingTypeName }),
|
|
96
|
+
React.createElement(ParameterList, { parameters: operation.parameters.properties }),
|
|
97
|
+
React.createElement(ReturnTypeItem, { type: operation.returnType }),
|
|
98
|
+
React.createElement(DescriptionAnnotation, { type: operation })));
|
|
99
|
+
}
|
|
100
|
+
return (React.createElement(React.Fragment, null, parameterProperties.map((property, key) => (React.createElement(FunctionElement, { Name: functionName, IsBound: "true", ...agsAttributes, key: key },
|
|
101
|
+
React.createElement(ParameterElement, { Name: "binding", Type: bindingTypeName }),
|
|
102
|
+
React.createElement(ParameterList, { parameters: property.properties }),
|
|
103
|
+
React.createElement(ReturnTypeItem, { type: operation.returnType }),
|
|
104
|
+
React.createElement(DescriptionAnnotation, { type: operation }))))));
|
|
105
|
+
}
|
|
106
|
+
return React.createElement(React.Fragment, null);
|
|
107
|
+
} }));
|
|
108
|
+
};
|
|
109
|
+
const ParameterList = (props) => {
|
|
110
|
+
return (React.createElement(ItemList, { items: props.parameters, render: (property) => {
|
|
111
|
+
const program = useContext(ProgramContext);
|
|
112
|
+
if (isPathParam(program, property)) {
|
|
113
|
+
return React.createElement(React.Fragment, null);
|
|
114
|
+
}
|
|
115
|
+
if (property.type.kind === "Model" && isOperationParameters(program, property.type)) {
|
|
116
|
+
return React.createElement(ParameterList, { parameters: property.type.properties });
|
|
117
|
+
}
|
|
118
|
+
const isNullable = isTypeNullable(program, property.type);
|
|
119
|
+
const propType = getPropertyTypeName(program, property.type);
|
|
120
|
+
return (React.createElement(ParameterElement, { Name: property.name, Type: propType, ...(isNullable ? {} : { Nullable: "false" }) },
|
|
121
|
+
React.createElement(OptionalParameterAnnotation, { property: property }),
|
|
122
|
+
React.createElement(DescriptionAnnotation, { type: property })));
|
|
123
|
+
} }));
|
|
124
|
+
};
|
|
125
|
+
const OptionalParameterAnnotation = ({ property, }) => {
|
|
126
|
+
var _a;
|
|
127
|
+
if (!property.optional) {
|
|
128
|
+
return React.createElement(React.Fragment, null);
|
|
129
|
+
}
|
|
130
|
+
let defaultValueValue = undefined;
|
|
131
|
+
switch ((_a = property.default) === null || _a === void 0 ? void 0 : _a.kind) {
|
|
132
|
+
case "String":
|
|
133
|
+
case "Boolean":
|
|
134
|
+
case "Number":
|
|
135
|
+
defaultValueValue = property.default.value;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
return React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.OptionalParameter" });
|
|
139
|
+
}
|
|
140
|
+
const program = useContext(ProgramContext);
|
|
141
|
+
const propType = getPropertyTypeName(program, property.type);
|
|
142
|
+
let defaultValueKey = "String";
|
|
143
|
+
switch (propType) {
|
|
144
|
+
case "Edm.String":
|
|
145
|
+
defaultValueKey = "String";
|
|
146
|
+
break;
|
|
147
|
+
case "Collection(Edm.Byte)":
|
|
148
|
+
defaultValueKey = "Binary";
|
|
149
|
+
break;
|
|
150
|
+
case "Edm.Byte":
|
|
151
|
+
case "Edm.Int16":
|
|
152
|
+
case "Edm.Int32":
|
|
153
|
+
case "Edm.Int64":
|
|
154
|
+
defaultValueKey = "Int";
|
|
155
|
+
break;
|
|
156
|
+
case "Edm.Single":
|
|
157
|
+
case "Edm.Double":
|
|
158
|
+
defaultValueKey = "Single";
|
|
159
|
+
break;
|
|
160
|
+
case "Edm.Date":
|
|
161
|
+
defaultValueKey = "Date";
|
|
162
|
+
break;
|
|
163
|
+
case "Edm.DateTimeOffset":
|
|
164
|
+
defaultValueKey = "DateTimeOffset";
|
|
165
|
+
break;
|
|
166
|
+
case "Edm.Boolean":
|
|
167
|
+
defaultValueKey = "Boolean";
|
|
168
|
+
break;
|
|
169
|
+
case "Edm.Stream":
|
|
170
|
+
defaultValueKey = "Binary";
|
|
171
|
+
break;
|
|
172
|
+
case "Edm.Duration":
|
|
173
|
+
case "Edm.TimeOfDay":
|
|
174
|
+
default:
|
|
175
|
+
return React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.OptionalParameter" });
|
|
176
|
+
}
|
|
177
|
+
return (React.createElement(AnnotationElement, { Term: "Org.OData.Core.V1.OptionalParameter" },
|
|
178
|
+
React.createElement(RecordElement, null,
|
|
179
|
+
React.createElement(PropertyValueElement, { Property: "DefaultValue", ...{ [defaultValueKey]: defaultValueValue } }))));
|
|
180
|
+
};
|
|
181
|
+
const ReturnTypeItem = ({ type }) => {
|
|
182
|
+
if (isVoidType(type)) {
|
|
183
|
+
return React.createElement(React.Fragment, null);
|
|
184
|
+
}
|
|
185
|
+
const program = useContext(ProgramContext);
|
|
186
|
+
const returnType = type.kind === "Model" && !!type.templateMapper && !!type.templateMapper.args.length
|
|
187
|
+
? type.templateMapper.args[0]
|
|
188
|
+
: type;
|
|
189
|
+
if (!returnType || isVoidType(returnType)) {
|
|
190
|
+
return React.createElement(React.Fragment, null);
|
|
191
|
+
}
|
|
192
|
+
const isNullable = isTypeNullable(program, returnType);
|
|
193
|
+
return (React.createElement(ReturnTypeElement, { Type: getPropertyTypeName(program, returnType), ...(isNullable ? {} : { Nullable: "false" }) }));
|
|
194
|
+
};
|
|
195
|
+
const EntityContainerItem = ({ namespace }) => {
|
|
196
|
+
const program = useContext(ProgramContext);
|
|
197
|
+
const navigationSources = [...namespace.interfaces]
|
|
198
|
+
.filter(([_, $interface]) => $interface.operations.has("_isNavigationSource"))
|
|
199
|
+
.map(([_, $interface]) => [
|
|
200
|
+
$interface.operations.get("_isNavigationSource").returnType,
|
|
201
|
+
$interface,
|
|
202
|
+
]);
|
|
203
|
+
const singletons = navigationSources
|
|
204
|
+
.filter(([returnType, _]) => returnType.kind === "Model" && returnType.name !== "Array")
|
|
205
|
+
.map(([_, $interface]) => $interface);
|
|
206
|
+
const entitySets = navigationSources
|
|
207
|
+
.filter(([returnType, _]) => returnType.kind === "Model" && returnType.name === "Array")
|
|
208
|
+
.reduce((map, [_, item]) => {
|
|
209
|
+
var _a;
|
|
210
|
+
const key = (_a = getRoutePath(program, item)) === null || _a === void 0 ? void 0 : _a.path.split("/")[0];
|
|
211
|
+
if (!key) {
|
|
212
|
+
return map;
|
|
213
|
+
}
|
|
214
|
+
const items = [...(map.get(key) || []), ...item.operations.values()];
|
|
215
|
+
map.set(key, items);
|
|
216
|
+
return map;
|
|
217
|
+
}, new Map());
|
|
218
|
+
if (!singletons.length && !entitySets.size) {
|
|
219
|
+
return React.createElement(React.Fragment, null);
|
|
220
|
+
}
|
|
221
|
+
const agsAttributes = buildAttributes(program, namespace);
|
|
222
|
+
return (React.createElement(EntityContainerElement, { Name: "container", ...agsAttributes },
|
|
223
|
+
React.createElement(SingletonList, { sources: singletons }),
|
|
224
|
+
React.createElement(EntitySetList, { sources: entitySets })));
|
|
225
|
+
};
|
|
226
|
+
const SingletonList = (props) => {
|
|
227
|
+
return (React.createElement(ItemList, { items: props.sources, render: (source) => {
|
|
228
|
+
const program = useContext(ProgramContext);
|
|
229
|
+
const routePath = getRoutePath(program, source);
|
|
230
|
+
if (!routePath) {
|
|
231
|
+
return React.createElement(React.Fragment, null);
|
|
232
|
+
}
|
|
233
|
+
const type = source.operations.get("_isNavigationSource").returnType;
|
|
234
|
+
const singletonTypeName = getPropertyTypeName(program, type);
|
|
235
|
+
if (!singletonTypeName) {
|
|
236
|
+
return React.createElement(React.Fragment, null);
|
|
237
|
+
}
|
|
238
|
+
const singletonName = routePath.path.split("/")[0];
|
|
239
|
+
const agsAttributes = buildAttributes(program, source);
|
|
240
|
+
return (React.createElement(SingletonElement, { Name: singletonName, Type: singletonTypeName, ...agsAttributes },
|
|
241
|
+
React.createElement(ExpandRestrictionsAnnotation, { interface: source, model: type }),
|
|
242
|
+
React.createElement(DescriptionAnnotation, { type: source })));
|
|
243
|
+
} }));
|
|
244
|
+
};
|
|
245
|
+
const EntitySetList = (props) => {
|
|
246
|
+
return (React.createElement(ItemList, { items: props.sources, render: (operations) => {
|
|
247
|
+
const program = useContext(ProgramContext);
|
|
248
|
+
const entitySet = operations[0].interface;
|
|
249
|
+
const routePath = getRoutePath(program, entitySet);
|
|
250
|
+
if (!routePath) {
|
|
251
|
+
return React.createElement(React.Fragment, null);
|
|
252
|
+
}
|
|
253
|
+
let agsAttributes = operations.reduce((attr, item) => ({ ...attr, ...buildAttributes(program, item) }), {});
|
|
254
|
+
agsAttributes = { ...agsAttributes, ...buildAttributes(program, entitySet) };
|
|
255
|
+
const returnType = entitySet.operations.get("_isNavigationSource").returnType;
|
|
256
|
+
const type = returnType.indexer.value;
|
|
257
|
+
const entitySetTypeName = getPropertyTypeName(program, type);
|
|
258
|
+
if (!entitySetTypeName) {
|
|
259
|
+
return React.createElement(React.Fragment, null);
|
|
260
|
+
}
|
|
261
|
+
const entitySetName = routePath.path.split("/")[0];
|
|
262
|
+
const operationMethods = operations.map((operation) => ({
|
|
263
|
+
operation,
|
|
264
|
+
verb: getOperationVerb(program, operation),
|
|
265
|
+
hasEmptyParameters: operation.parameters.properties.size === 0,
|
|
266
|
+
}));
|
|
267
|
+
const hasGetOnCollection = operationMethods.some(({ verb, hasEmptyParameters }) => hasEmptyParameters && verb === "get");
|
|
268
|
+
const hasGetOnItem = operationMethods.some(({ verb, hasEmptyParameters }) => !hasEmptyParameters && verb === "get");
|
|
269
|
+
const hasPostOnCollection = operationMethods.some(({ verb }) => verb === "post");
|
|
270
|
+
const hasPatchOnItem = operationMethods.some(({ verb }) => verb === "patch");
|
|
271
|
+
const hasDeleteOnItem = operationMethods.some(({ verb }) => verb === "delete");
|
|
272
|
+
return (React.createElement(EntitySetElement, { Name: entitySetName, EntityType: entitySetTypeName, ...agsAttributes },
|
|
273
|
+
React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.ReadRestrictions" },
|
|
274
|
+
React.createElement(RecordElement, null,
|
|
275
|
+
React.createElement(PropertyValueElement, { Property: "Readable", Bool: hasGetOnCollection.toString() }),
|
|
276
|
+
React.createElement(PropertyValueElement, { Property: "ReadByKeyRestrictions" },
|
|
277
|
+
React.createElement(RecordElement, null,
|
|
278
|
+
React.createElement(PropertyValueElement, { Property: "Readable", Bool: hasGetOnItem.toString() }))))),
|
|
279
|
+
React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.InsertRestrictions" },
|
|
280
|
+
React.createElement(RecordElement, null,
|
|
281
|
+
React.createElement(PropertyValueElement, { Property: "Insertable", Bool: hasPostOnCollection.toString() }))),
|
|
282
|
+
React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.UpdateRestrictions" },
|
|
283
|
+
React.createElement(RecordElement, null,
|
|
284
|
+
React.createElement(PropertyValueElement, { Property: "Updatable", Bool: hasPatchOnItem.toString() }),
|
|
285
|
+
React.createElement(PropertyValueElement, { Property: "UpdateMethod", EnumMember: "Org.OData.Capabilities.V1.HttpMethod/PATCH" }))),
|
|
286
|
+
React.createElement(AnnotationElement, { Term: "Org.OData.Capabilities.V1.DeleteRestrictions" },
|
|
287
|
+
React.createElement(RecordElement, null,
|
|
288
|
+
React.createElement(PropertyValueElement, { Property: "Deletable", Bool: hasDeleteOnItem.toString() }))),
|
|
289
|
+
React.createElement(CountRestrictionsAnnotation, { interface: entitySet }),
|
|
290
|
+
React.createElement(ExpandRestrictionsAnnotation, { interface: entitySet, model: type }),
|
|
291
|
+
React.createElement(SearchRestrictionsAnnotation, { interface: entitySet }),
|
|
292
|
+
React.createElement(SkipSupportedAnnotation, { interface: entitySet }),
|
|
293
|
+
React.createElement(SortRestrictionsAnnotation, { interface: entitySet, model: type }),
|
|
294
|
+
React.createElement(TopSupportedAnnotation, { interface: entitySet }),
|
|
295
|
+
React.createElement(DescriptionAnnotation, { type: entitySet })));
|
|
296
|
+
} }));
|
|
297
|
+
};
|
|
298
|
+
//# sourceMappingURL=csdl.js.map
|