@microsoft/typespec-msgraph 0.0.1-Preview.9 → 1.0.0-Preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/acceptable-media-types-annotation.js.map +1 -1
- package/dist/src/components/alternate-keys-annotation.js +2 -1
- package/dist/src/components/alternate-keys-annotation.js.map +1 -1
- package/dist/src/components/annotations.d.ts +3 -3
- package/dist/src/components/annotations.d.ts.map +1 -1
- package/dist/src/components/annotations.js +51 -8
- package/dist/src/components/annotations.js.map +1 -1
- package/dist/src/components/common-elements.d.ts +7 -7
- package/dist/src/components/common-elements.d.ts.map +1 -1
- package/dist/src/components/common-elements.js.map +1 -1
- package/dist/src/components/delta-annotation.d.ts +6 -0
- package/dist/src/components/delta-annotation.d.ts.map +1 -0
- package/dist/src/components/delta-annotation.js +18 -0
- package/dist/src/components/delta-annotation.js.map +1 -0
- package/dist/src/components/entity-container-element.d.ts.map +1 -1
- package/dist/src/components/entity-container-element.js +16 -6
- package/dist/src/components/entity-container-element.js.map +1 -1
- package/dist/src/components/enum-type-element.d.ts.map +1 -1
- package/dist/src/components/enum-type-element.js +6 -3
- package/dist/src/components/enum-type-element.js.map +1 -1
- package/dist/src/components/filter-restrictions-annotation.js +1 -1
- package/dist/src/components/filter-restrictions-annotation.js.map +1 -1
- package/dist/src/components/is-url-annotation.d.ts +5 -0
- package/dist/src/components/is-url-annotation.d.ts.map +1 -0
- package/dist/src/components/is-url-annotation.js +6 -0
- package/dist/src/components/is-url-annotation.js.map +1 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.d.ts +5 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.d.ts.map +1 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.js +7 -0
- package/dist/src/components/open-property-type-constraint-annotation-element.js.map +1 -0
- package/dist/src/components/operation-element.d.ts.map +1 -1
- package/dist/src/components/operation-element.js +30 -15
- package/dist/src/components/operation-element.js.map +1 -1
- package/dist/src/components/permissions-annotation.js.map +1 -1
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +8 -4
- package/dist/src/components/property-element.js.map +1 -1
- package/dist/src/components/reference-target-element.d.ts +9 -0
- package/dist/src/components/reference-target-element.d.ts.map +1 -0
- package/dist/src/components/reference-target-element.js +3 -0
- package/dist/src/components/reference-target-element.js.map +1 -0
- package/dist/src/components/revisions-annotation.d.ts.map +1 -1
- package/dist/src/components/revisions-annotation.js +2 -1
- package/dist/src/components/revisions-annotation.js.map +1 -1
- package/dist/src/components/schema-element.d.ts.map +1 -1
- package/dist/src/components/schema-element.js +8 -3
- package/dist/src/components/schema-element.js.map +1 -1
- package/dist/src/components/select-supported-annotation.d.ts +5 -0
- package/dist/src/components/select-supported-annotation.d.ts.map +1 -0
- package/dist/src/components/select-supported-annotation.js +6 -0
- package/dist/src/components/select-supported-annotation.js.map +1 -0
- package/dist/src/components/structured-type-element.d.ts.map +1 -1
- package/dist/src/components/structured-type-element.js +8 -6
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/term-element.d.ts +9 -0
- package/dist/src/components/term-element.d.ts.map +1 -0
- package/dist/src/components/term-element.js +8 -0
- package/dist/src/components/term-element.js.map +1 -0
- package/dist/src/components/top-supported-annotation.js +1 -1
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/components/update-restrictions-annotation.d.ts +2 -1
- package/dist/src/components/update-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/update-restrictions-annotation.js +4 -4
- package/dist/src/components/update-restrictions-annotation.js.map +1 -1
- package/dist/src/decorators/abstract.d.ts +2 -0
- package/dist/src/decorators/abstract.d.ts.map +1 -1
- package/dist/src/decorators/abstract.js +2 -0
- package/dist/src/decorators/abstract.js.map +1 -1
- package/dist/src/decorators/action.d.ts +2 -0
- package/dist/src/decorators/action.d.ts.map +1 -1
- package/dist/src/decorators/action.js +2 -0
- package/dist/src/decorators/action.js.map +1 -1
- package/dist/src/decorators/additional-query-parameters.d.ts +2 -0
- package/dist/src/decorators/additional-query-parameters.d.ts.map +1 -1
- package/dist/src/decorators/additional-query-parameters.js +2 -0
- package/dist/src/decorators/additional-query-parameters.js.map +1 -1
- package/dist/src/decorators/address-url-msa.d.ts +14 -0
- package/dist/src/decorators/address-url-msa.d.ts.map +1 -0
- package/dist/src/decorators/address-url-msa.js +21 -0
- package/dist/src/decorators/address-url-msa.js.map +1 -0
- package/dist/src/decorators/address-url.d.ts +18 -0
- package/dist/src/decorators/address-url.d.ts.map +1 -0
- package/dist/src/decorators/address-url.js +21 -0
- package/dist/src/decorators/address-url.js.map +1 -0
- package/dist/src/decorators/ags-attribute.d.ts +7 -3
- package/dist/src/decorators/ags-attribute.d.ts.map +1 -1
- package/dist/src/decorators/ags-attribute.js +102 -3
- package/dist/src/decorators/ags-attribute.js.map +1 -1
- package/dist/src/decorators/allowed-values.d.ts +2 -0
- package/dist/src/decorators/allowed-values.d.ts.map +1 -1
- package/dist/src/decorators/allowed-values.js +2 -0
- package/dist/src/decorators/allowed-values.js.map +1 -1
- package/dist/src/decorators/complex.d.ts +2 -0
- package/dist/src/decorators/complex.d.ts.map +1 -1
- package/dist/src/decorators/complex.js +2 -0
- package/dist/src/decorators/complex.js.map +1 -1
- package/dist/src/decorators/computed.d.ts +2 -0
- package/dist/src/decorators/computed.d.ts.map +1 -1
- package/dist/src/decorators/computed.js +2 -0
- package/dist/src/decorators/computed.js.map +1 -1
- package/dist/src/decorators/contains.d.ts +2 -0
- package/dist/src/decorators/contains.d.ts.map +1 -1
- package/dist/src/decorators/contains.js +2 -0
- package/dist/src/decorators/contains.js.map +1 -1
- package/dist/src/decorators/count.d.ts +2 -0
- package/dist/src/decorators/count.d.ts.map +1 -1
- package/dist/src/decorators/count.js +2 -0
- package/dist/src/decorators/count.js.map +1 -1
- package/dist/src/decorators/delta.d.ts +10 -0
- package/dist/src/decorators/delta.d.ts.map +1 -0
- package/dist/src/decorators/delta.js +14 -0
- package/dist/src/decorators/delta.js.map +1 -0
- package/dist/src/decorators/deprecated-definition.d.ts +2 -0
- package/dist/src/decorators/deprecated-definition.d.ts.map +1 -1
- package/dist/src/decorators/deprecated-definition.js.map +1 -1
- package/dist/src/decorators/entity.d.ts +3 -0
- package/dist/src/decorators/entity.d.ts.map +1 -1
- package/dist/src/decorators/entity.js +7 -1
- package/dist/src/decorators/entity.js.map +1 -1
- package/dist/src/decorators/expand.d.ts +3 -0
- package/dist/src/decorators/expand.d.ts.map +1 -1
- package/dist/src/decorators/expand.js +7 -1
- package/dist/src/decorators/expand.js.map +1 -1
- package/dist/src/decorators/experimental.d.ts +11 -0
- package/dist/src/decorators/experimental.d.ts.map +1 -0
- package/dist/src/decorators/experimental.js +15 -0
- package/dist/src/decorators/experimental.js.map +1 -0
- package/dist/src/decorators/filter.d.ts +2 -0
- package/dist/src/decorators/filter.d.ts.map +1 -1
- package/dist/src/decorators/filter.js +6 -4
- package/dist/src/decorators/filter.js.map +1 -1
- package/dist/src/decorators/function.d.ts +9 -2
- package/dist/src/decorators/function.d.ts.map +1 -1
- package/dist/src/decorators/function.js +7 -2
- package/dist/src/decorators/function.js.map +1 -1
- package/dist/src/decorators/global-operation.d.ts +11 -0
- package/dist/src/decorators/global-operation.d.ts.map +1 -0
- package/dist/src/decorators/global-operation.js +15 -0
- package/dist/src/decorators/global-operation.js.map +1 -0
- package/dist/src/decorators/graph-deprecated.d.ts +13 -0
- package/dist/src/decorators/graph-deprecated.d.ts.map +1 -0
- package/dist/src/decorators/graph-deprecated.js +21 -0
- package/dist/src/decorators/graph-deprecated.js.map +1 -0
- package/dist/src/decorators/graph-partial.d.ts +12 -0
- package/dist/src/decorators/graph-partial.d.ts.map +1 -0
- package/dist/src/decorators/graph-partial.js +18 -0
- package/dist/src/decorators/graph-partial.js.map +1 -0
- package/dist/src/decorators/graph-route.d.ts +5 -1
- package/dist/src/decorators/graph-route.d.ts.map +1 -1
- package/dist/src/decorators/graph-route.js +62 -19
- package/dist/src/decorators/graph-route.js.map +1 -1
- package/dist/src/decorators/graphFlags.d.ts +11 -0
- package/dist/src/decorators/graphFlags.d.ts.map +1 -0
- package/dist/src/decorators/graphFlags.js +15 -0
- package/dist/src/decorators/graphFlags.js.map +1 -0
- package/dist/src/decorators/immutable.d.ts +2 -0
- package/dist/src/decorators/immutable.d.ts.map +1 -1
- package/dist/src/decorators/immutable.js +2 -0
- package/dist/src/decorators/immutable.js.map +1 -1
- package/dist/src/decorators/index.d.ts +22 -4
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +22 -4
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/is-owner.d.ts +5 -2
- package/dist/src/decorators/is-owner.d.ts.map +1 -1
- package/dist/src/decorators/is-owner.js +9 -4
- package/dist/src/decorators/is-owner.js.map +1 -1
- package/dist/src/decorators/limited-charset.d.ts +11 -0
- package/dist/src/decorators/limited-charset.d.ts.map +1 -0
- package/dist/src/decorators/limited-charset.js +15 -0
- package/dist/src/decorators/limited-charset.js.map +1 -0
- package/dist/src/decorators/media.d.ts +12 -0
- package/dist/src/decorators/media.d.ts.map +1 -0
- package/dist/src/decorators/media.js +18 -0
- package/dist/src/decorators/media.js.map +1 -0
- package/dist/src/decorators/open.d.ts +2 -0
- package/dist/src/decorators/open.d.ts.map +1 -1
- package/dist/src/decorators/open.js +2 -0
- package/dist/src/decorators/open.js.map +1 -1
- package/dist/src/decorators/operation-parameters.d.ts +2 -0
- package/dist/src/decorators/operation-parameters.d.ts.map +1 -1
- package/dist/src/decorators/operation-parameters.js +2 -0
- package/dist/src/decorators/operation-parameters.js.map +1 -1
- package/dist/src/decorators/order-by.d.ts +2 -0
- package/dist/src/decorators/order-by.d.ts.map +1 -1
- package/dist/src/decorators/order-by.js +2 -0
- package/dist/src/decorators/order-by.js.map +1 -1
- package/dist/src/decorators/ownerless.d.ts +10 -0
- package/dist/src/decorators/ownerless.d.ts.map +1 -0
- package/dist/src/decorators/ownerless.js +14 -0
- package/dist/src/decorators/ownerless.js.map +1 -0
- package/dist/src/decorators/passthrough-address-url-msa.d.ts +14 -0
- package/dist/src/decorators/passthrough-address-url-msa.d.ts.map +1 -0
- package/dist/src/decorators/passthrough-address-url-msa.js +20 -0
- package/dist/src/decorators/passthrough-address-url-msa.js.map +1 -0
- package/dist/src/decorators/passthrough-address-url.d.ts +14 -0
- package/dist/src/decorators/passthrough-address-url.d.ts.map +1 -0
- package/dist/src/decorators/passthrough-address-url.js +20 -0
- package/dist/src/decorators/passthrough-address-url.js.map +1 -0
- package/dist/src/decorators/prefixed-graph-routes.d.ts +10 -0
- package/dist/src/decorators/prefixed-graph-routes.d.ts.map +1 -0
- package/dist/src/decorators/prefixed-graph-routes.js +27 -0
- package/dist/src/decorators/prefixed-graph-routes.js.map +1 -0
- package/dist/src/decorators/private-preview-definition.d.ts +2 -0
- package/dist/src/decorators/private-preview-definition.d.ts.map +1 -1
- package/dist/src/decorators/private-preview-definition.js +2 -0
- package/dist/src/decorators/private-preview-definition.js.map +1 -1
- package/dist/src/decorators/private-preview.d.ts +4 -2
- package/dist/src/decorators/private-preview.d.ts.map +1 -1
- package/dist/src/decorators/private-preview.js +2 -0
- package/dist/src/decorators/private-preview.js.map +1 -1
- package/dist/src/decorators/privileged.d.ts +2 -0
- package/dist/src/decorators/privileged.d.ts.map +1 -1
- package/dist/src/decorators/privileged.js +2 -0
- package/dist/src/decorators/privileged.js.map +1 -1
- package/dist/src/decorators/public-namespace.d.ts +2 -0
- package/dist/src/decorators/public-namespace.d.ts.map +1 -1
- package/dist/src/decorators/public-namespace.js +6 -1
- package/dist/src/decorators/public-namespace.js.map +1 -1
- package/dist/src/decorators/read-only.d.ts +2 -0
- package/dist/src/decorators/read-only.d.ts.map +1 -1
- package/dist/src/decorators/read-only.js +2 -0
- package/dist/src/decorators/read-only.js.map +1 -1
- package/dist/src/decorators/reference-target.d.ts +17 -0
- package/dist/src/decorators/reference-target.d.ts.map +1 -0
- package/dist/src/decorators/reference-target.js +59 -0
- package/dist/src/decorators/reference-target.js.map +1 -0
- package/dist/src/decorators/references.d.ts +2 -0
- package/dist/src/decorators/references.d.ts.map +1 -1
- package/dist/src/decorators/references.js +2 -0
- package/dist/src/decorators/references.js.map +1 -1
- package/dist/src/decorators/required-for-create.d.ts +2 -0
- package/dist/src/decorators/required-for-create.d.ts.map +1 -1
- package/dist/src/decorators/required-for-create.js +2 -0
- package/dist/src/decorators/required-for-create.js.map +1 -1
- package/dist/src/decorators/return-source.d.ts +11 -0
- package/dist/src/decorators/return-source.d.ts.map +1 -0
- package/dist/src/decorators/return-source.js +28 -0
- package/dist/src/decorators/return-source.js.map +1 -0
- package/dist/src/decorators/search.d.ts +2 -0
- package/dist/src/decorators/search.d.ts.map +1 -1
- package/dist/src/decorators/search.js +2 -0
- package/dist/src/decorators/search.js.map +1 -1
- package/dist/src/decorators/select.d.ts +11 -0
- package/dist/src/decorators/select.d.ts.map +1 -0
- package/dist/src/decorators/select.js +15 -0
- package/dist/src/decorators/select.js.map +1 -0
- package/dist/src/decorators/shared-entity.d.ts +9 -0
- package/dist/src/decorators/shared-entity.d.ts.map +1 -0
- package/dist/src/decorators/shared-entity.js +15 -0
- package/dist/src/decorators/shared-entity.js.map +1 -0
- package/dist/src/decorators/skip.d.ts +2 -0
- package/dist/src/decorators/skip.d.ts.map +1 -1
- package/dist/src/decorators/skip.js +2 -0
- package/dist/src/decorators/skip.js.map +1 -1
- package/dist/src/decorators/term.d.ts +13 -0
- package/dist/src/decorators/term.d.ts.map +1 -0
- package/dist/src/decorators/term.js +14 -0
- package/dist/src/decorators/term.js.map +1 -0
- package/dist/src/decorators/top.d.ts +2 -0
- package/dist/src/decorators/top.d.ts.map +1 -1
- package/dist/src/decorators/top.js +2 -0
- package/dist/src/decorators/top.js.map +1 -1
- package/dist/src/decorators/workload-name-msa.d.ts +2 -0
- package/dist/src/decorators/workload-name-msa.d.ts.map +1 -1
- package/dist/src/decorators/workload-name-msa.js +2 -0
- package/dist/src/decorators/workload-name-msa.js.map +1 -1
- package/dist/src/decorators/workload-name.d.ts +2 -0
- package/dist/src/decorators/workload-name.d.ts.map +1 -1
- package/dist/src/decorators/workload-name.js +2 -0
- package/dist/src/decorators/workload-name.js.map +1 -1
- package/dist/src/decorators/workload-namespace.d.ts +12 -0
- package/dist/src/decorators/workload-namespace.d.ts.map +1 -0
- package/dist/src/decorators/workload-namespace.js +21 -0
- package/dist/src/decorators/workload-namespace.js.map +1 -0
- package/dist/src/decorators/write-only.d.ts +2 -0
- package/dist/src/decorators/write-only.d.ts.map +1 -1
- package/dist/src/decorators/write-only.js +2 -0
- package/dist/src/decorators/write-only.js.map +1 -1
- package/dist/src/dom/error-interceptor.d.ts +2 -0
- package/dist/src/dom/error-interceptor.d.ts.map +1 -0
- package/dist/src/dom/error-interceptor.js +13 -0
- package/dist/src/dom/error-interceptor.js.map +1 -0
- package/dist/src/dom/reconciler.js.map +1 -1
- package/dist/src/dom/renderer.d.ts +1 -0
- package/dist/src/dom/renderer.d.ts.map +1 -1
- package/dist/src/dom/renderer.js +1 -0
- package/dist/src/dom/renderer.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +30 -3
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/entities/address-url.d.ts +8 -0
- package/dist/src/entities/address-url.d.ts.map +1 -0
- package/dist/src/entities/address-url.js +47 -0
- package/dist/src/entities/address-url.js.map +1 -0
- package/dist/src/entities/annotations.d.ts +17 -4
- package/dist/src/entities/annotations.d.ts.map +1 -1
- package/dist/src/entities/annotations.js +120 -74
- package/dist/src/entities/annotations.js.map +1 -1
- package/dist/src/entities/entity-container.d.ts +21 -0
- package/dist/src/entities/entity-container.d.ts.map +1 -1
- package/dist/src/entities/entity-container.js +33 -4
- package/dist/src/entities/entity-container.js.map +1 -1
- package/dist/src/entities/enum.d.ts +3 -1
- package/dist/src/entities/enum.d.ts.map +1 -1
- package/dist/src/entities/enum.js +10 -5
- package/dist/src/entities/enum.js.map +1 -1
- package/dist/src/entities/model.d.ts +34 -10
- package/dist/src/entities/model.d.ts.map +1 -1
- package/dist/src/entities/model.js +310 -14
- package/dist/src/entities/model.js.map +1 -1
- package/dist/src/entities/ms-graph-route.d.ts +13 -0
- package/dist/src/entities/ms-graph-route.d.ts.map +1 -0
- package/dist/src/entities/ms-graph-route.js +67 -0
- package/dist/src/entities/ms-graph-route.js.map +1 -0
- package/dist/src/entities/namespace.d.ts +25 -4
- package/dist/src/entities/namespace.d.ts.map +1 -1
- package/dist/src/entities/namespace.js +314 -18
- package/dist/src/entities/namespace.js.map +1 -1
- package/dist/src/entities/operation.d.ts +18 -0
- package/dist/src/entities/operation.d.ts.map +1 -1
- package/dist/src/entities/operation.js +142 -20
- package/dist/src/entities/operation.js.map +1 -1
- package/dist/src/entities/property.d.ts.map +1 -1
- package/dist/src/entities/property.js +7 -0
- package/dist/src/entities/property.js.map +1 -1
- package/dist/src/entities/revision-definition.d.ts +3 -2
- package/dist/src/entities/revision-definition.d.ts.map +1 -1
- package/dist/src/entities/revision-definition.js +17 -6
- package/dist/src/entities/revision-definition.js.map +1 -1
- package/dist/src/entities/term.d.ts +8 -0
- package/dist/src/entities/term.d.ts.map +1 -0
- package/dist/src/entities/term.js +14 -0
- package/dist/src/entities/term.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +123 -109
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +72 -10
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts +1 -2
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +32 -42
- package/dist/src/linter.js.map +1 -1
- package/dist/src/path-tree.d.ts +16 -0
- package/dist/src/path-tree.d.ts.map +1 -0
- package/dist/src/path-tree.js +76 -0
- package/dist/src/path-tree.js.map +1 -0
- package/dist/src/rules/abstract.d.ts +2 -1
- package/dist/src/rules/abstract.d.ts.map +1 -1
- package/dist/src/rules/abstract.js +8 -8
- package/dist/src/rules/abstract.js.map +1 -1
- package/dist/src/rules/address-url.d.ts +20 -0
- package/dist/src/rules/address-url.d.ts.map +1 -0
- package/dist/src/rules/address-url.js +248 -0
- package/dist/src/rules/address-url.js.map +1 -0
- package/dist/src/rules/allowed-values.d.ts +2 -1
- package/dist/src/rules/allowed-values.d.ts.map +1 -1
- package/dist/src/rules/allowed-values.js +7 -7
- package/dist/src/rules/allowed-values.js.map +1 -1
- package/dist/src/rules/alternate-key.d.ts +4 -3
- package/dist/src/rules/alternate-key.d.ts.map +1 -1
- package/dist/src/rules/alternate-key.js +23 -23
- package/dist/src/rules/alternate-key.js.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -1
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +9 -9
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -1
- package/dist/src/rules/complex.d.ts +3 -0
- package/dist/src/rules/complex.d.ts.map +1 -0
- package/dist/src/rules/complex.js +27 -0
- package/dist/src/rules/complex.js.map +1 -0
- package/dist/src/rules/computed.d.ts +2 -3
- package/dist/src/rules/computed.d.ts.map +1 -1
- package/dist/src/rules/computed.js +14 -16
- package/dist/src/rules/computed.js.map +1 -1
- package/dist/src/rules/contains.d.ts +2 -1
- package/dist/src/rules/contains.d.ts.map +1 -1
- package/dist/src/rules/contains.js +9 -8
- package/dist/src/rules/contains.js.map +1 -1
- package/dist/src/rules/count.d.ts +2 -1
- package/dist/src/rules/count.d.ts.map +1 -1
- package/dist/src/rules/count.js +9 -8
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/delta.d.ts +8 -0
- package/dist/src/rules/delta.d.ts.map +1 -0
- package/dist/src/rules/delta.js +208 -0
- package/dist/src/rules/delta.js.map +1 -0
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.js +29 -25
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -1
- package/dist/src/rules/documentation.d.ts +4 -0
- package/dist/src/rules/documentation.d.ts.map +1 -0
- package/dist/src/rules/documentation.js +91 -0
- package/dist/src/rules/documentation.js.map +1 -0
- package/dist/src/rules/entity.d.ts +9 -2
- package/dist/src/rules/entity.d.ts.map +1 -1
- package/dist/src/rules/entity.js +170 -17
- package/dist/src/rules/entity.js.map +1 -1
- package/dist/src/rules/enum.d.ts +5 -1
- package/dist/src/rules/enum.d.ts.map +1 -1
- package/dist/src/rules/enum.js +35 -6
- package/dist/src/rules/enum.js.map +1 -1
- package/dist/src/rules/expand.d.ts +3 -2
- package/dist/src/rules/expand.d.ts.map +1 -1
- package/dist/src/rules/expand.js +25 -20
- package/dist/src/rules/expand.js.map +1 -1
- package/dist/src/rules/extends-on-same-type.d.ts +2 -1
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -1
- package/dist/src/rules/extends-on-same-type.js +9 -8
- package/dist/src/rules/extends-on-same-type.js.map +1 -1
- package/dist/src/rules/filter.d.ts +6 -3
- package/dist/src/rules/filter.d.ts.map +1 -1
- package/dist/src/rules/filter.js +100 -32
- package/dist/src/rules/filter.js.map +1 -1
- package/dist/src/rules/function.d.ts +3 -1
- package/dist/src/rules/function.d.ts.map +1 -1
- package/dist/src/rules/function.js +48 -9
- package/dist/src/rules/function.js.map +1 -1
- package/dist/src/rules/global-operation.d.ts +4 -0
- package/dist/src/rules/global-operation.d.ts.map +1 -0
- package/dist/src/rules/global-operation.js +60 -0
- package/dist/src/rules/global-operation.js.map +1 -0
- package/dist/src/rules/graph-deprecated.d.ts +8 -0
- package/dist/src/rules/graph-deprecated.d.ts.map +1 -0
- package/dist/src/rules/graph-deprecated.js +152 -0
- package/dist/src/rules/graph-deprecated.js.map +1 -0
- package/dist/src/rules/graph-partial.d.ts +9 -0
- package/dist/src/rules/graph-partial.d.ts.map +1 -0
- package/dist/src/rules/graph-partial.js +84 -0
- package/dist/src/rules/graph-partial.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +13 -2
- package/dist/src/rules/graph-route.d.ts.map +1 -1
- package/dist/src/rules/graph-route.js +324 -17
- package/dist/src/rules/graph-route.js.map +1 -1
- package/dist/src/rules/index.d.ts +16 -3
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +16 -3
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/limited-charset.d.ts +3 -0
- package/dist/src/rules/limited-charset.d.ts.map +1 -0
- package/dist/src/rules/limited-charset.js +42 -0
- package/dist/src/rules/limited-charset.js.map +1 -0
- package/dist/src/rules/media.d.ts +10 -0
- package/dist/src/rules/media.d.ts.map +1 -0
- package/dist/src/rules/media.js +122 -0
- package/dist/src/rules/media.js.map +1 -0
- package/dist/src/rules/model.d.ts +10 -0
- package/dist/src/rules/model.d.ts.map +1 -0
- package/dist/src/rules/model.js +131 -0
- package/dist/src/rules/model.js.map +1 -0
- package/dist/src/rules/namespace.d.ts +5 -2
- package/dist/src/rules/namespace.d.ts.map +1 -1
- package/dist/src/rules/namespace.js +87 -35
- package/dist/src/rules/namespace.js.map +1 -1
- package/dist/src/rules/open.d.ts +2 -1
- package/dist/src/rules/open.d.ts.map +1 -1
- package/dist/src/rules/open.js +9 -8
- package/dist/src/rules/open.js.map +1 -1
- package/dist/src/rules/operation-inside-interface.d.ts +6 -1
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -1
- package/dist/src/rules/operation-inside-interface.js +78 -7
- package/dist/src/rules/operation-inside-interface.js.map +1 -1
- package/dist/src/rules/order-by.d.ts +3 -2
- package/dist/src/rules/order-by.d.ts.map +1 -1
- package/dist/src/rules/order-by.js +19 -19
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/ownerless.d.ts +11 -0
- package/dist/src/rules/ownerless.d.ts.map +1 -0
- package/dist/src/rules/ownerless.js +170 -0
- package/dist/src/rules/ownerless.js.map +1 -0
- package/dist/src/rules/record-t.d.ts +11 -0
- package/dist/src/rules/record-t.d.ts.map +1 -0
- package/dist/src/rules/record-t.js +129 -0
- package/dist/src/rules/record-t.js.map +1 -0
- package/dist/src/rules/reference-target.d.ts +6 -0
- package/dist/src/rules/reference-target.d.ts.map +1 -0
- package/dist/src/rules/reference-target.js +113 -0
- package/dist/src/rules/reference-target.js.map +1 -0
- package/dist/src/rules/references.d.ts +2 -1
- package/dist/src/rules/references.d.ts.map +1 -1
- package/dist/src/rules/references.js +9 -8
- package/dist/src/rules/references.js.map +1 -1
- package/dist/src/rules/required-for-create.d.ts +2 -1
- package/dist/src/rules/required-for-create.d.ts.map +1 -1
- package/dist/src/rules/required-for-create.js +11 -10
- package/dist/src/rules/required-for-create.js.map +1 -1
- package/dist/src/rules/return-source.d.ts +3 -0
- package/dist/src/rules/return-source.d.ts.map +1 -0
- package/dist/src/rules/return-source.js +27 -0
- package/dist/src/rules/return-source.js.map +1 -0
- package/dist/src/rules/search.d.ts +2 -1
- package/dist/src/rules/search.d.ts.map +1 -1
- package/dist/src/rules/search.js +9 -8
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/shared-entity.d.ts +8 -0
- package/dist/src/rules/shared-entity.d.ts.map +1 -0
- package/dist/src/rules/shared-entity.js +176 -0
- package/dist/src/rules/shared-entity.js.map +1 -0
- package/dist/src/rules/skip.d.ts +2 -1
- package/dist/src/rules/skip.d.ts.map +1 -1
- package/dist/src/rules/skip.js +9 -8
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.d.ts +2 -1
- package/dist/src/rules/top.d.ts.map +1 -1
- package/dist/src/rules/top.js +9 -8
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -0
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js +21 -0
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/utils.d.ts +70 -4
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +609 -54
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validate.d.ts +3 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +98 -0
- package/dist/src/validate.js.map +1 -0
- package/lib/bodies.tsp +71 -0
- package/lib/decorators.tsp +222 -29
- package/lib/lib.tsp +3 -1
- package/lib/msgraph.tsp +1 -0
- package/lib/porcelain.tsp +78 -23
- package/lib/responses.tsp +17 -40
- package/lib/shared-models.tsp +6 -51
- package/package.json +24 -26
- package/dist/src/decorators/flags.d.ts +0 -9
- package/dist/src/decorators/flags.d.ts.map +0 -1
- package/dist/src/decorators/flags.js +0 -13
- package/dist/src/decorators/flags.js.map +0 -1
- package/dist/src/decorators/has-stream.d.ts +0 -10
- package/dist/src/decorators/has-stream.d.ts.map +0 -1
- package/dist/src/decorators/has-stream.js +0 -17
- package/dist/src/decorators/has-stream.js.map +0 -1
- package/dist/src/rules/has-stream.d.ts +0 -2
- package/dist/src/rules/has-stream.d.ts.map +0 -1
- package/dist/src/rules/has-stream.js +0 -29
- package/dist/src/rules/has-stream.js.map +0 -1
package/dist/src/utils.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { getNamespaceFullName, isArrayModelType, } from "@typespec/compiler";
|
|
2
|
-
import { getEntity, getGraphRoutePaths, getPublicNamespaceName, hasPublicNamespace, isEntity } from "./decorators/index.js";
|
|
1
|
+
import { getLocationContext, getNamespaceFullName, isArrayModelType, navigateTypesInNamespace, walkPropertiesInherited, } from "@typespec/compiler";
|
|
2
|
+
import { getEntity, getExpand, getFilter, getGraphRoutePaths, getPublicNamespaceName, getWorkloadNamespaceName, hasGraphRoute, hasPublicNamespace, hasWorkloadNamespace, isComplex, isContains, isDelta, isEntity, isExpand, isFilter, isPartial, isReferences, isSharedEntity } from "./decorators/index.js";
|
|
3
|
+
import { getOperationVerb } from "@typespec/http";
|
|
4
|
+
import { DEFAULT_MSGRAPH_NAMESPACE, GetDeclaredNamespaces, usedLibraryTypesKey } from "./entities/namespace.js";
|
|
5
|
+
import { PathTree } from "./path-tree.js";
|
|
6
|
+
// schema namespace is workloadNamespace if its defined or publicNamespace if its defined
|
|
7
|
+
export function hasSchemaNamespace(program, namespace) {
|
|
8
|
+
return hasWorkloadNamespace(program, namespace) || hasPublicNamespace(program, namespace);
|
|
9
|
+
}
|
|
10
|
+
// schema namespace is workloadNamespace if its defined, publicNamespace if its defined or the defined namespace name
|
|
11
|
+
export function getSchemaNamespaceName(program, namespace) {
|
|
12
|
+
if (hasWorkloadNamespace(program, namespace)) {
|
|
13
|
+
return getWorkloadNamespaceName(program, namespace);
|
|
14
|
+
}
|
|
15
|
+
return getPublicNamespaceName(program, namespace);
|
|
16
|
+
}
|
|
3
17
|
export function getNameForType(program, type) {
|
|
4
18
|
switch (type.kind) {
|
|
5
19
|
case "Union":
|
|
@@ -25,6 +39,9 @@ export function getNameForType(program, type) {
|
|
|
25
39
|
export function getNameForModelType(program, type) {
|
|
26
40
|
switch (type.name) {
|
|
27
41
|
case "string":
|
|
42
|
+
case "url":
|
|
43
|
+
case "graphUrl":
|
|
44
|
+
case "webUrl":
|
|
28
45
|
return "Edm.String";
|
|
29
46
|
case "bytes":
|
|
30
47
|
return "Collection(Edm.Byte)";
|
|
@@ -46,6 +63,10 @@ export function getNameForModelType(program, type) {
|
|
|
46
63
|
return "Edm.TimeOfDay";
|
|
47
64
|
case "zonedDateTime":
|
|
48
65
|
return "Edm.DateTimeOffset";
|
|
66
|
+
case "offsetDateTime":
|
|
67
|
+
return "Edm.DateTimeOffset";
|
|
68
|
+
case "utcDateTime":
|
|
69
|
+
return "Edm.DateTimeOffset";
|
|
49
70
|
case "duration":
|
|
50
71
|
return "Edm.Duration";
|
|
51
72
|
case "boolean":
|
|
@@ -54,6 +75,10 @@ export function getNameForModelType(program, type) {
|
|
|
54
75
|
return "Edm.Stream";
|
|
55
76
|
case "guid":
|
|
56
77
|
return "Edm.Guid";
|
|
78
|
+
case "binary":
|
|
79
|
+
return "Edm.Binary";
|
|
80
|
+
case "unknown":
|
|
81
|
+
return "microsoft.graph.Json";
|
|
57
82
|
default:
|
|
58
83
|
break;
|
|
59
84
|
}
|
|
@@ -100,12 +125,40 @@ export function getCSDLPrimitiveType(typespecType) {
|
|
|
100
125
|
return typespecType;
|
|
101
126
|
}
|
|
102
127
|
}
|
|
128
|
+
export function isDictionaryType(program, type) {
|
|
129
|
+
var _a;
|
|
130
|
+
if (type.kind === "Model" && isTypeDefinedInLocalProject(program, type)) {
|
|
131
|
+
const indexer = (_a = type.indexer) === null || _a === void 0 ? void 0 : _a.value;
|
|
132
|
+
if (indexer) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
if (isComplex(program, type) && type.name === "Dictionary") {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
export function generateDictionaryBaseType(program, model) {
|
|
142
|
+
if (getLocationContext(program, model).type === "library") {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
if (isDictionaryType(program, model)) {
|
|
146
|
+
return "microsoft.graph.Dictionary";
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
103
150
|
export function getIdForType(program, type) {
|
|
104
151
|
switch (type.kind) {
|
|
105
152
|
case "Namespace":
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
153
|
+
if (hasWorkloadNamespace(program, type)) {
|
|
154
|
+
return getWorkloadNamespaceName(program, type);
|
|
155
|
+
}
|
|
156
|
+
else if (hasPublicNamespace(program, type)) {
|
|
157
|
+
return getPublicNamespaceName(program, type);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return getNamespaceFullName(type);
|
|
161
|
+
}
|
|
109
162
|
case "Model":
|
|
110
163
|
case "Enum":
|
|
111
164
|
case "Operation":
|
|
@@ -118,83 +171,131 @@ export function getIdForType(program, type) {
|
|
|
118
171
|
case "Union":
|
|
119
172
|
return getIdForUnion(program, type);
|
|
120
173
|
case "Scalar":
|
|
174
|
+
case "Intrinsic":
|
|
121
175
|
return getNameForModelType(program, type);
|
|
176
|
+
case "EnumMember":
|
|
177
|
+
return `${type.name}`;
|
|
122
178
|
default:
|
|
123
179
|
return type.kind;
|
|
124
180
|
}
|
|
125
181
|
}
|
|
126
182
|
export function getNavigationTypeId(program, getOperation) {
|
|
127
|
-
var _a;
|
|
183
|
+
var _a, _b;
|
|
128
184
|
const returnType = getOperation.returnType;
|
|
129
|
-
if (returnType.kind !== "Model" || !((_a = returnType.
|
|
185
|
+
if (returnType.kind !== "Model" || !((_a = returnType.templateMapper) === null || _a === void 0 ? void 0 : _a.args.length)) {
|
|
130
186
|
return getIdForType(program, returnType);
|
|
131
187
|
}
|
|
132
|
-
return getIdForType(program, returnType.
|
|
188
|
+
return getIdForType(program, (_b = returnType === null || returnType === void 0 ? void 0 : returnType.templateMapper) === null || _b === void 0 ? void 0 : _b.args[0]);
|
|
133
189
|
}
|
|
134
190
|
export function getInterfacesOfKinds(program, navigationSources, kinds) {
|
|
135
191
|
const interfaces = new Map();
|
|
136
192
|
navigationSources.forEach((theInterface) => {
|
|
137
|
-
if (!theInterface.
|
|
193
|
+
if (!getSourceInterfaces(theInterface).some((s) => kinds.includes(s.name))) {
|
|
138
194
|
// if source interfaces DO NOT have the kinds.
|
|
139
195
|
return;
|
|
140
196
|
}
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
|
|
197
|
+
const navigationSourceType = getInterfaceNavigationSourceType(program, theInterface);
|
|
198
|
+
if (navigationSourceType && isTypeDefinedInExternalLibrary(program, navigationSourceType)) {
|
|
199
|
+
program.stateSet(usedLibraryTypesKey).add(navigationSourceType);
|
|
144
200
|
}
|
|
145
|
-
|
|
201
|
+
const graphRoutePaths = getGraphRoutePaths(program, theInterface);
|
|
202
|
+
if (!graphRoutePaths || !graphRoutePaths.length) {
|
|
146
203
|
return;
|
|
147
204
|
}
|
|
148
205
|
graphRoutePaths.forEach((graphRoute) => {
|
|
149
|
-
|
|
150
|
-
if (
|
|
206
|
+
// skip two-segment resources as they are collections
|
|
207
|
+
if (isRouteIndexOfACollection(theInterface, graphRoute)) {
|
|
151
208
|
return;
|
|
152
209
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
210
|
+
processGraphRoute(program, graphRoute, interfaces, theInterface);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
return interfaces;
|
|
214
|
+
}
|
|
215
|
+
export function isRouteIndexOfACollection(theInterface, graphRoute) {
|
|
216
|
+
if (theInterface === undefined) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
const pathSegments = graphRoute.split("/");
|
|
220
|
+
const lastSegment = pathSegments[pathSegments.length - 1].replace(/\{[\w-]+\}/g, "");
|
|
221
|
+
if (lastSegment === "" && getSourceInterfaces(theInterface).some((s) => s.name === "Resource")) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
export function getComposableFunctionSegmentFromGraphRoute(graphRoutePath) {
|
|
227
|
+
const pattern = /\/([^\/]+\(.*\))$/;
|
|
228
|
+
const matches = graphRoutePath.match(pattern);
|
|
229
|
+
return matches != null ? matches[1] : undefined;
|
|
230
|
+
}
|
|
231
|
+
// Generate an interface for a resource that has a root path and an index like /users/{id}. Note that this is a collection.
|
|
232
|
+
// Resources with two-segment paths like /users/{id} are essentially collections
|
|
233
|
+
// This applies to deeply nested resources as well e.g. /cars/{carId}/wheels/{wheelId}
|
|
234
|
+
export function getCollectionIndexInterfaces(program, navigationSources) {
|
|
235
|
+
const interfaces = new Map();
|
|
236
|
+
navigationSources.forEach((theInterface) => {
|
|
237
|
+
const graphRoutePaths = getGraphRoutePaths(program, theInterface);
|
|
238
|
+
if (!graphRoutePaths || !graphRoutePaths.length) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
graphRoutePaths.forEach((graphRoute) => {
|
|
242
|
+
if (isRouteIndexOfACollection(theInterface, graphRoute)) {
|
|
243
|
+
processGraphRoute(program, graphRoute, interfaces, theInterface);
|
|
157
244
|
}
|
|
158
|
-
interfaces.set(path, {
|
|
159
|
-
theInterface: theInterface,
|
|
160
|
-
operations: operations,
|
|
161
|
-
path: graphRoute
|
|
162
|
-
});
|
|
163
245
|
});
|
|
164
246
|
});
|
|
165
247
|
return interfaces;
|
|
166
248
|
}
|
|
249
|
+
function processGraphRoute(program, graphRoute, interfaces, theInterface) {
|
|
250
|
+
const path = removeRoutePathParams(graphRoute);
|
|
251
|
+
if (!path) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
let operations = [...theInterface.operations.values()].map((operation) => ({ theOperation: operation, verb: getOperationVerb(program, operation), graphRoute: graphRoute }));
|
|
255
|
+
if (interfaces.has(path)) {
|
|
256
|
+
const existing = interfaces.get(path);
|
|
257
|
+
operations = [...operations, ...existing.operations];
|
|
258
|
+
}
|
|
259
|
+
interfaces.set(path, {
|
|
260
|
+
theInterface: theInterface,
|
|
261
|
+
operations: operations,
|
|
262
|
+
path: graphRoute
|
|
263
|
+
});
|
|
264
|
+
}
|
|
167
265
|
export function getPropertyTypeName(program, type) {
|
|
168
266
|
var _a;
|
|
169
267
|
if (type.kind === "Union") {
|
|
170
268
|
const unionTypes = extractTypesFromUnion(type);
|
|
171
|
-
const nonNullTypes = unionTypes.filter((t) => !isNullType(
|
|
269
|
+
const nonNullTypes = unionTypes.filter((t) => !isNullType(t));
|
|
172
270
|
if (!nonNullTypes.length) {
|
|
173
271
|
return "undefined.";
|
|
174
272
|
}
|
|
175
|
-
return getPropertyTypeName(program, nonNullTypes[0]);
|
|
273
|
+
return removeReferencePrefixFromType(getPropertyTypeName(program, nonNullTypes[0]));
|
|
176
274
|
}
|
|
177
275
|
if ((type.kind === "Model" || type.kind === "Scalar") && ((_a = type.namespace) === null || _a === void 0 ? void 0 : _a.name) === "TypeSpec") {
|
|
178
|
-
return getNameForType(program, type);
|
|
276
|
+
return removeReferencePrefixFromType(getNameForType(program, type));
|
|
179
277
|
}
|
|
180
|
-
return getIdForType(program, type);
|
|
278
|
+
return removeReferencePrefixFromType(getIdForType(program, type));
|
|
279
|
+
}
|
|
280
|
+
export function removeReferencePrefixFromType(typeName) {
|
|
281
|
+
return typeName.replace(/^reference\./, "");
|
|
181
282
|
}
|
|
182
283
|
export function isTypeNullable(program, type) {
|
|
183
284
|
if (type.kind !== "Union") {
|
|
184
285
|
return false;
|
|
185
286
|
}
|
|
186
287
|
const unionTypes = extractTypesFromUnion(type);
|
|
187
|
-
return unionTypes.some((t) => isNullType(
|
|
288
|
+
return unionTypes.some((t) => isNullType(t));
|
|
188
289
|
}
|
|
189
290
|
function getIdForUnion(program, unionType) {
|
|
190
291
|
const unionTypes = extractTypesFromUnion(unionType);
|
|
191
|
-
const nonNullTypes = unionTypes.filter((t) => !isNullType(
|
|
292
|
+
const nonNullTypes = unionTypes.filter((t) => !isNullType(t));
|
|
192
293
|
if (!nonNullTypes.length) {
|
|
193
294
|
return "undefined.";
|
|
194
295
|
}
|
|
195
296
|
return getIdForType(program, nonNullTypes[0]);
|
|
196
297
|
}
|
|
197
|
-
function isNullType(
|
|
298
|
+
export function isNullType(type) {
|
|
198
299
|
return type.kind === "Intrinsic" && type.name === "null";
|
|
199
300
|
}
|
|
200
301
|
export function extractTypesFromUnion(type) {
|
|
@@ -250,7 +351,8 @@ export function getNamespaceName(program, type) {
|
|
|
250
351
|
if (type === undefined) {
|
|
251
352
|
return "";
|
|
252
353
|
}
|
|
253
|
-
|
|
354
|
+
const fullNamespaceName = getNamespaceFullName(type);
|
|
355
|
+
return fullNamespaceName;
|
|
254
356
|
}
|
|
255
357
|
/**
|
|
256
358
|
* Imported from typespec-azure
|
|
@@ -265,7 +367,8 @@ export function isExcludedCoreType(program, type) {
|
|
|
265
367
|
//
|
|
266
368
|
const nsName = getNamespaceName(program, type);
|
|
267
369
|
const excludedNamespaces = ["TypeSpec", "MsGraph"];
|
|
268
|
-
|
|
370
|
+
const isExcluded = excludedNamespaces.find((ns) => nsName.startsWith(ns)) !== undefined;
|
|
371
|
+
return isExcluded;
|
|
269
372
|
}
|
|
270
373
|
export function isExcludedLibraryType(program, type) {
|
|
271
374
|
const nsName = getNamespaceName(program, type);
|
|
@@ -273,30 +376,16 @@ export function isExcludedLibraryType(program, type) {
|
|
|
273
376
|
return excludedNamespaces.find((ns) => nsName.startsWith(ns)) !== undefined;
|
|
274
377
|
}
|
|
275
378
|
export function isNavigationProperty(program, property) {
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
const unionTypes = extractTypesFromUnion(propertyType);
|
|
279
|
-
const nonNullTypes = unionTypes.filter((t) => !isNullType(program, t));
|
|
280
|
-
if (!nonNullTypes.length) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
propertyType = nonNullTypes[0];
|
|
284
|
-
}
|
|
285
|
-
if (propertyType.kind !== "Model") {
|
|
379
|
+
const model = getTypeModel(program, property.type);
|
|
380
|
+
if (!model) {
|
|
286
381
|
return false;
|
|
287
382
|
}
|
|
288
|
-
|
|
289
|
-
propertyType = propertyType.indexer.value;
|
|
290
|
-
if (propertyType.kind !== "Model") {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return isEntity(program, propertyType);
|
|
383
|
+
return isEntity(program, model) && (isContains(program, property) || isReferences(program, property));
|
|
295
384
|
}
|
|
296
385
|
export function isNavigationSource(theInterface) {
|
|
297
386
|
return findNavigationSource(theInterface) !== undefined;
|
|
298
387
|
}
|
|
299
|
-
export function isTopLevelNavigationSource(
|
|
388
|
+
export function isTopLevelNavigationSource(theInterface) {
|
|
300
389
|
return removeRoutePathParams(theInterface.path).split("/").length === 1;
|
|
301
390
|
}
|
|
302
391
|
// Get the type returned by all operations in an interface representing a navigation source.
|
|
@@ -316,7 +405,7 @@ export function getNavigationSourceType(program, operation) {
|
|
|
316
405
|
return getInterfaceNavigationSourceType(program, operation.interface);
|
|
317
406
|
}
|
|
318
407
|
function findNavigationSource(theInterface) {
|
|
319
|
-
for (const baseInterface of theInterface
|
|
408
|
+
for (const baseInterface of getSourceInterfaces(theInterface)) {
|
|
320
409
|
if (baseInterface.name === "Resource" || baseInterface.name === "Collection") {
|
|
321
410
|
return baseInterface;
|
|
322
411
|
}
|
|
@@ -335,8 +424,474 @@ function findNavigationSource(theInterface) {
|
|
|
335
424
|
* Examples:
|
|
336
425
|
* - user/{id}/manager -> user/manager
|
|
337
426
|
* - user/{id}/friends/{friendId}/hobbies -> user/friends/hobbies
|
|
427
|
+
* - user/{user-id}/friends/{friend-id}/hobbies -> user/friends/hobbies
|
|
428
|
+
*/
|
|
429
|
+
export function removeRoutePathParams(routePath) {
|
|
430
|
+
return routePath.replace(/\/\{[\w-]+\}/g, "");
|
|
431
|
+
}
|
|
432
|
+
export function isSameNamespace(program, model, baseModel) {
|
|
433
|
+
if (!baseModel) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
return getNamespaceName(program, model) === getNamespaceName(program, baseModel);
|
|
437
|
+
}
|
|
438
|
+
export function isTypeDefinedInExternalLibrary(program, type) {
|
|
439
|
+
const locationContext = getLocationContext(program, type);
|
|
440
|
+
return locationContext.type === "library";
|
|
441
|
+
}
|
|
442
|
+
export function isTypeDefinedInLocalProject(program, type) {
|
|
443
|
+
const locationContext = getLocationContext(program, type);
|
|
444
|
+
return locationContext.type === "project";
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Recursively get all source interfaces of an interface
|
|
448
|
+
* @param theInterface
|
|
449
|
+
* @returns an array of all source interfaces
|
|
450
|
+
*/
|
|
451
|
+
export function getSourceInterfaces(theInterface) {
|
|
452
|
+
return [...theInterface.sourceInterfaces, ...[...theInterface.sourceInterfaces.values()].flatMap(getSourceInterfaces)];
|
|
453
|
+
}
|
|
454
|
+
export function getModelStructuralPropertyNames(program, model) {
|
|
455
|
+
return getModelPropertyNames(program, model, true);
|
|
456
|
+
}
|
|
457
|
+
export function getAllModelPropertyNames(program, model) {
|
|
458
|
+
return getModelPropertyNames(program, model, false);
|
|
459
|
+
}
|
|
460
|
+
function getModelPropertyNames(program, model, structuralPropertiesOnly) {
|
|
461
|
+
const propertyNames = getModelProperties(program, model, structuralPropertiesOnly).map(p => p.name.trim());
|
|
462
|
+
const propertiesOfTypeModel = getPropertiesOfTypeModel(program, model, structuralPropertiesOnly);
|
|
463
|
+
const nestedPropertyNames = getNestedPropertyNames(program, propertiesOfTypeModel, structuralPropertiesOnly);
|
|
464
|
+
return [...new Set([...propertyNames, ...nestedPropertyNames])].filter(p => p !== model.name);
|
|
465
|
+
}
|
|
466
|
+
export function getModelProperties(program, model, structuralPropertiesOnly = false) {
|
|
467
|
+
const allProperties = walkPropertiesInherited(model);
|
|
468
|
+
// structural properties are the ones that are not navigation properties
|
|
469
|
+
if (structuralPropertiesOnly) {
|
|
470
|
+
return [...allProperties].filter(p => !isNavigationProperty(program, p));
|
|
471
|
+
}
|
|
472
|
+
return [...allProperties];
|
|
473
|
+
}
|
|
474
|
+
function getPropertiesOfTypeModel(program, model, structuralPropertiesOnly = false) {
|
|
475
|
+
const properties = getModelProperties(program, model, structuralPropertiesOnly);
|
|
476
|
+
const propertiesOfTypeModel = [];
|
|
477
|
+
for (const property of properties) {
|
|
478
|
+
const model = getTypeModel(program, property.type, structuralPropertiesOnly);
|
|
479
|
+
if (model) {
|
|
480
|
+
propertiesOfTypeModel.push({
|
|
481
|
+
name: property.name,
|
|
482
|
+
type: model
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return propertiesOfTypeModel;
|
|
487
|
+
}
|
|
488
|
+
function getNestedPropertyNames(program, propertyTypes, structuralPropertiesOnly = false, prefix = "") {
|
|
489
|
+
const names = [];
|
|
490
|
+
if (prefix && hasRepeatedItem(prefix)) {
|
|
491
|
+
return names;
|
|
492
|
+
}
|
|
493
|
+
for (const propertyType of propertyTypes) {
|
|
494
|
+
const propertyTypePrefix = prefix + propertyType.name + "/";
|
|
495
|
+
const nestedPropertyTypes = getNestedPropertyTypes(program, propertyType, structuralPropertiesOnly);
|
|
496
|
+
nestedPropertyTypes.forEach(m => {
|
|
497
|
+
const name = propertyTypePrefix + m.name;
|
|
498
|
+
if (!hasRepeatedItem(name)) {
|
|
499
|
+
names.push(name);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
names.push(...getNestedPropertyNames(program, nestedPropertyTypes, structuralPropertiesOnly, propertyTypePrefix));
|
|
503
|
+
}
|
|
504
|
+
return names;
|
|
505
|
+
}
|
|
506
|
+
function getNestedPropertyTypes(program, propertyType, structuralPropertiesOnly = false) {
|
|
507
|
+
const propertyTypes = [];
|
|
508
|
+
const theType = propertyType.type;
|
|
509
|
+
if (theType.kind === "Scalar" || theType.kind === "Enum") {
|
|
510
|
+
return propertyTypes;
|
|
511
|
+
}
|
|
512
|
+
theType.properties.forEach((property, name) => {
|
|
513
|
+
const type = getPropertyType(program, property, structuralPropertiesOnly);
|
|
514
|
+
if (type !== undefined) {
|
|
515
|
+
propertyTypes.push({ name: name, type: type });
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
return propertyTypes;
|
|
519
|
+
}
|
|
520
|
+
function getPropertyType(program, property, structuralPropertiesOnly = false) {
|
|
521
|
+
if (structuralPropertiesOnly && isNavigationProperty(program, property)) {
|
|
522
|
+
return undefined;
|
|
523
|
+
}
|
|
524
|
+
const type = getActualType(program, property.type);
|
|
525
|
+
if (!type || !(type.kind === "Model" || type.kind === "Scalar" || type.kind === "Enum")) {
|
|
526
|
+
return undefined;
|
|
527
|
+
}
|
|
528
|
+
return type;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* This function checks if a path is repeating.
|
|
532
|
+
* For example, if we have a tsp with this structure:
|
|
533
|
+
* @complex model inner {
|
|
534
|
+
innerName: string;
|
|
535
|
+
otherInnerName: string;
|
|
536
|
+
circularReferenceProp: outer;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
@complex model outer {
|
|
540
|
+
inner: inner | null;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
If our root (interface navigation type) is outer, some of the possible paths would be
|
|
544
|
+
- outer/inner/innerName
|
|
545
|
+
- outer/inner/otherInnerName
|
|
546
|
+
For circularReferenceProp property, we run the risk of having a path like the one below which would cause an infinite loop:
|
|
547
|
+
- outer/inner/circularReferenceProp/inner/circularReferenceProp
|
|
548
|
+
* @param slashSeparatedString
|
|
549
|
+
* @returns
|
|
550
|
+
*/
|
|
551
|
+
function hasRepeatedItem(slashSeparatedString) {
|
|
552
|
+
const items = slashSeparatedString.split('/');
|
|
553
|
+
const uniqueItems = new Set(items);
|
|
554
|
+
return items.length !== uniqueItems.size;
|
|
555
|
+
}
|
|
556
|
+
export function isInterfaceBindingTypeOwned(program, $interface) {
|
|
557
|
+
const interfaceBindingType = getInterfaceBindingType(program, $interface);
|
|
558
|
+
if (interfaceBindingType) {
|
|
559
|
+
if (isPartial(program, interfaceBindingType)) {
|
|
560
|
+
return false;
|
|
561
|
+
}
|
|
562
|
+
if (isTypeDefinedInExternalLibrary(program, interfaceBindingType)) {
|
|
563
|
+
return false;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
function getInterfaceBindingType(program, $interface) {
|
|
569
|
+
const navigationSourceType = getInterfaceNavigationSourceType(program, $interface);
|
|
570
|
+
if (navigationSourceType) {
|
|
571
|
+
return getModelFromTemplateMapper(program, navigationSourceType);
|
|
572
|
+
}
|
|
573
|
+
return undefined;
|
|
574
|
+
}
|
|
575
|
+
export function getNestedComplexTypes(program, model, nestedModels = new Set()) {
|
|
576
|
+
nestedModels.add(model);
|
|
577
|
+
const modelProperties = model.properties;
|
|
578
|
+
if (modelProperties.size === 0) {
|
|
579
|
+
return nestedModels;
|
|
580
|
+
}
|
|
581
|
+
for (const property of modelProperties.values()) {
|
|
582
|
+
const model = getTypeModel(program, property.type);
|
|
583
|
+
if (model && !nestedModels.has(model)) {
|
|
584
|
+
getNestedComplexTypes(program, model, nestedModels);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return nestedModels;
|
|
588
|
+
}
|
|
589
|
+
export function generateDeltaPropertiesForNavigationProperties(program, navigationProperty) {
|
|
590
|
+
const navigationPropertyModel = getTypeModel(program, navigationProperty.type);
|
|
591
|
+
if (navigationPropertyModel) {
|
|
592
|
+
const interfacesTargetingParentModel = getInterfacesTargetingModel(program, navigationPropertyModel);
|
|
593
|
+
for (const theInterface of interfacesTargetingParentModel) {
|
|
594
|
+
const graphRoutes = getGraphRoutePaths(program, theInterface);
|
|
595
|
+
if (graphRoutes) {
|
|
596
|
+
for (const graphRoute of graphRoutes) {
|
|
597
|
+
const routeParts = graphRoute.split("/");
|
|
598
|
+
const navPropAtEndOfRoute = routeParts[routeParts.length - 1];
|
|
599
|
+
if (navPropAtEndOfRoute === navigationProperty.name) {
|
|
600
|
+
return getDeltaProperties(program, theInterface);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
export function getInterfacesTargetingModel(program, type) {
|
|
609
|
+
const interfacesTargettingModel = [];
|
|
610
|
+
let model = getTypeModel(program, type);
|
|
611
|
+
if (model) {
|
|
612
|
+
const namespace = model.namespace;
|
|
613
|
+
const theInterfaces = namespace === null || namespace === void 0 ? void 0 : namespace.interfaces;
|
|
614
|
+
if (theInterfaces) {
|
|
615
|
+
for (const [_, theInterface] of theInterfaces.entries()) {
|
|
616
|
+
const navigationBindingType = getInterfaceNavigationSourceType(program, theInterface);
|
|
617
|
+
if (navigationBindingType && navigationBindingType.name === model.name) {
|
|
618
|
+
interfacesTargettingModel.push(theInterface);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
return interfacesTargettingModel;
|
|
624
|
+
}
|
|
625
|
+
// This function gets filterable and expandable properties
|
|
626
|
+
export function getDeltaProperties(program, entity) {
|
|
627
|
+
const operations = entity.operations;
|
|
628
|
+
let hasDelta = false;
|
|
629
|
+
let filterProps;
|
|
630
|
+
let expandProps;
|
|
631
|
+
for (const [_, operation] of operations) {
|
|
632
|
+
// Get filterable and expandable properties as defined by @filter and @expand on the @delta operation
|
|
633
|
+
if (isDelta(program, operation)) {
|
|
634
|
+
hasDelta = true;
|
|
635
|
+
filterProps = getFilterableProperties(program, operation);
|
|
636
|
+
expandProps = getExpandableProperties(program, operation);
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
// If the delta operation exists and the filter properties are not set, get the filter properties from the get operation
|
|
641
|
+
if (hasDelta && !filterProps) {
|
|
642
|
+
filterProps = [...getFilterablePropertiesFromGetOperation(program, operations)];
|
|
643
|
+
}
|
|
644
|
+
// If the delta operation exists and the expand properties are not set, get the expand properties from the get operation
|
|
645
|
+
if (hasDelta && !expandProps) {
|
|
646
|
+
expandProps = [...getExpandablePropertiesFromGetOperation(program, operations)];
|
|
647
|
+
}
|
|
648
|
+
if (hasDelta) {
|
|
649
|
+
return {
|
|
650
|
+
FilterProperties: filterProps,
|
|
651
|
+
ExpandProperties: expandProps,
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
return undefined;
|
|
655
|
+
}
|
|
656
|
+
function getFilterableProperties(program, operation) {
|
|
657
|
+
if (isFilter(program, operation)) {
|
|
658
|
+
const filterProps = getFilter(program, operation);
|
|
659
|
+
if (filterProps.includes("*")) {
|
|
660
|
+
// Return all structural properties (nested and inherited) as filterable
|
|
661
|
+
return getModelStructuralPropertyNamesFromOperation(program, operation);
|
|
662
|
+
}
|
|
663
|
+
return filterProps;
|
|
664
|
+
}
|
|
665
|
+
return undefined;
|
|
666
|
+
}
|
|
667
|
+
function getExpandableProperties(program, operation) {
|
|
668
|
+
if (isExpand(program, operation)) {
|
|
669
|
+
return getExpand(program, operation);
|
|
670
|
+
}
|
|
671
|
+
return undefined;
|
|
672
|
+
}
|
|
673
|
+
function getFilterablePropertiesFromGetOperation(program, operationsMap) {
|
|
674
|
+
const operations = [...operationsMap.values()];
|
|
675
|
+
if (operations.some(theOperation => isFilter(program, theOperation))) {
|
|
676
|
+
for (const operation of operations) {
|
|
677
|
+
if (operation.name === "get") {
|
|
678
|
+
if (isFilter(program, operation)) {
|
|
679
|
+
const filterProps = getFilter(program, operation);
|
|
680
|
+
if (filterProps.includes("*")) {
|
|
681
|
+
// Return all structural properties (nested and inherited) as filterable
|
|
682
|
+
return getModelStructuralPropertyNamesFromOperation(program, operation);
|
|
683
|
+
}
|
|
684
|
+
return filterProps;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return [];
|
|
690
|
+
}
|
|
691
|
+
function getModelStructuralPropertyNamesFromOperation(program, operation) {
|
|
692
|
+
const returnType = getNavigationSourceType(program, operation);
|
|
693
|
+
if (!returnType) {
|
|
694
|
+
return [];
|
|
695
|
+
}
|
|
696
|
+
const model = returnType.indexer ? returnType.indexer.value : returnType;
|
|
697
|
+
return getModelStructuralPropertyNames(program, model);
|
|
698
|
+
}
|
|
699
|
+
function getExpandablePropertiesFromGetOperation(program, operationsMap) {
|
|
700
|
+
const operations = [...operationsMap.values()];
|
|
701
|
+
if (operations.some(theOperation => isExpand(program, theOperation))) {
|
|
702
|
+
for (const operation of operations) {
|
|
703
|
+
if (operation.name === "get") {
|
|
704
|
+
if (isExpand(program, operation)) {
|
|
705
|
+
return getExpand(program, operation);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
return [];
|
|
711
|
+
}
|
|
712
|
+
export function isCollection(theInterfaces) {
|
|
713
|
+
return theInterfaces.some(theInterface => theInterface.name === "Collection");
|
|
714
|
+
}
|
|
715
|
+
export function isUnion(type) {
|
|
716
|
+
return type.kind === "Union";
|
|
717
|
+
}
|
|
718
|
+
export function filterMapByIdenticalValues(inputMap) {
|
|
719
|
+
var _a;
|
|
720
|
+
const resultMap = new Map();
|
|
721
|
+
const valueToKeys = new Map();
|
|
722
|
+
// Iterate over the input map
|
|
723
|
+
for (const [key, value] of inputMap.entries()) {
|
|
724
|
+
if (!valueToKeys.has(value)) {
|
|
725
|
+
valueToKeys.set(value, [key]);
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
(_a = valueToKeys.get(value)) === null || _a === void 0 ? void 0 : _a.push(key);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
// Add keys with identical values to the result map
|
|
732
|
+
for (const [value, keys] of valueToKeys.entries()) {
|
|
733
|
+
if (keys.length > 1) {
|
|
734
|
+
keys.forEach((key) => resultMap.set(key, value));
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return resultMap;
|
|
738
|
+
}
|
|
739
|
+
// This gets nested navigation paths for all contained and non-contained models and root paths for primitive types.
|
|
740
|
+
export function getAllNestedNavigationPaths(program, model) {
|
|
741
|
+
const structuralProperties = getModelProperties(program, model, false).map(property => property.name);
|
|
742
|
+
const rootPropertyNames = structuralProperties.map(property => model.name + "/" + property);
|
|
743
|
+
let nestedPropertyNames = getAllModelPropertyNames(program, model);
|
|
744
|
+
nestedPropertyNames = nestedPropertyNames.map(propertyName => model.name + "/" + propertyName);
|
|
745
|
+
return [...new Set([...structuralProperties, ...nestedPropertyNames, ...rootPropertyNames])].filter(path => path !== model.name);
|
|
746
|
+
}
|
|
747
|
+
export function removeTrailingSlash(path) {
|
|
748
|
+
return path.replace(/\/$/, "");
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
*
|
|
752
|
+
* @param obj1 Function that checks for equality of two objects
|
|
753
|
+
* @param obj2
|
|
754
|
+
* @returns
|
|
338
755
|
*/
|
|
339
|
-
function
|
|
340
|
-
|
|
756
|
+
export function isEqual(obj1, obj2) {
|
|
757
|
+
// Check if both are null or undefined
|
|
758
|
+
if (obj1 === obj2)
|
|
759
|
+
return true;
|
|
760
|
+
// Check if both are not objects or one is null
|
|
761
|
+
if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null) {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
// Check if they have the same number of properties
|
|
765
|
+
const keys1 = Object.keys(obj1);
|
|
766
|
+
const keys2 = Object.keys(obj2);
|
|
767
|
+
if (keys1.length !== keys2.length) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
// Check if values are the same for each property
|
|
771
|
+
for (let key of keys1) {
|
|
772
|
+
if (!keys2.includes(key) || !isEqual(obj1[key], obj2[key])) {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
export function checkFunctionOverloadsWithReturnType(operation1, operation2) {
|
|
779
|
+
return functionOperationsAreOverloads(operation1, operation2, true);
|
|
780
|
+
}
|
|
781
|
+
export function checkFunctionOverloads(operation1, operation2) {
|
|
782
|
+
return functionOperationsAreOverloads(operation1, operation2);
|
|
783
|
+
}
|
|
784
|
+
function functionOperationsAreOverloads(operation1, operation2, checkReturnType = false) {
|
|
785
|
+
if (operation1.Name === operation2.Name && operation1.BindingTypeName === operation2.BindingTypeName) {
|
|
786
|
+
if (!checkReturnType || operation1.ReturnTypeName === operation2.ReturnTypeName) {
|
|
787
|
+
const properties1 = operation1.Properties.filter((property) => property.Name !== "bindingParameter").sort((a, b) => a.Name.localeCompare(b.Name));
|
|
788
|
+
const properties2 = operation2.Properties.filter((property) => property.Name !== "bindingParameter").sort((a, b) => a.Name.localeCompare(b.Name));
|
|
789
|
+
return isEqual(properties1, properties2);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* @returns a Model type if the underlying type is a model, undefined otherwise
|
|
796
|
+
*/
|
|
797
|
+
export function getTypeModel(program, type, structuralPropertiesOnly = false) {
|
|
798
|
+
// Use getActualType to handle cases where the type is a union type or an array type
|
|
799
|
+
const actualType = getActualType(program, type, structuralPropertiesOnly);
|
|
800
|
+
// if the actual type is not a Model type, return undefined
|
|
801
|
+
if ((actualType === null || actualType === void 0 ? void 0 : actualType.kind) !== "Model") {
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
return actualType;
|
|
805
|
+
}
|
|
806
|
+
function getActualType(program, type, structuralPropertiesOnly = false) {
|
|
807
|
+
var _a;
|
|
808
|
+
if (type.kind === "Union") {
|
|
809
|
+
const nonNullTypes = extractTypesFromUnion(type).filter(t => !isNullType(t));
|
|
810
|
+
if (!nonNullTypes.length) {
|
|
811
|
+
return undefined;
|
|
812
|
+
}
|
|
813
|
+
type = nonNullTypes[0];
|
|
814
|
+
}
|
|
815
|
+
if (type.kind === "Model" && isArrayModelType(program, type)) {
|
|
816
|
+
// Skip array-typed properties when looking for structural properties
|
|
817
|
+
if (structuralPropertiesOnly) {
|
|
818
|
+
return undefined;
|
|
819
|
+
}
|
|
820
|
+
type = (_a = type.indexer) === null || _a === void 0 ? void 0 : _a.value;
|
|
821
|
+
}
|
|
822
|
+
return type;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
*
|
|
826
|
+
* @param model Handles case where model is wrapped in an EntityRef template
|
|
827
|
+
* @returns
|
|
828
|
+
*/
|
|
829
|
+
function getModelFromTemplateMapper(program, model) {
|
|
830
|
+
var _a;
|
|
831
|
+
const templateArguments = (_a = model.templateMapper) === null || _a === void 0 ? void 0 : _a.args;
|
|
832
|
+
if (templateArguments && templateArguments.length > 0) {
|
|
833
|
+
return getTypeModel(program, templateArguments[0]);
|
|
834
|
+
}
|
|
835
|
+
return getTypeModel(program, model);
|
|
836
|
+
}
|
|
837
|
+
function removeTrailingRef(path) {
|
|
838
|
+
if (path.endsWith("/$ref")) {
|
|
839
|
+
return path.slice(0, -5);
|
|
840
|
+
}
|
|
841
|
+
return path;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* This function removes the composable function pattern from the path
|
|
845
|
+
* accessReviews/{reviewId}/instances/{instanceId}/decisions/filterByCurrentUser(string) -> accessReviews/{reviewId}/instances/{instanceId}/decisions
|
|
846
|
+
* @param path
|
|
847
|
+
* @returns
|
|
848
|
+
*/
|
|
849
|
+
const removeComposableFunctionPattern = (path) => {
|
|
850
|
+
const pattern = /\/[^/]+\(.*?\)(?=\/|$)/g;
|
|
851
|
+
if (pattern.test(path)) {
|
|
852
|
+
return path.replace(pattern, '');
|
|
853
|
+
}
|
|
854
|
+
return path;
|
|
855
|
+
};
|
|
856
|
+
export function cleanGraphRoutePath(path) {
|
|
857
|
+
path = removeRoutePathParams(path);
|
|
858
|
+
path = removeTrailingRef(path);
|
|
859
|
+
path = removeComposableFunctionPattern(path);
|
|
860
|
+
return path;
|
|
861
|
+
}
|
|
862
|
+
export function buildPathTree(program) {
|
|
863
|
+
const tree = new PathTree();
|
|
864
|
+
for (const namespace of GetDeclaredNamespaces(program)) {
|
|
865
|
+
navigateTypesInNamespace(namespace, {
|
|
866
|
+
interface: ($interface) => {
|
|
867
|
+
if (!hasGraphRoute(program, $interface)) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
const entityType = getInterfaceNavigationSourceType(program, $interface);
|
|
871
|
+
getGraphRoutePaths(program, $interface).forEach(graphRoutePath => {
|
|
872
|
+
const path = removeRoutePathParams(graphRoutePath);
|
|
873
|
+
tree.addNode(path, entityType);
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
return tree;
|
|
879
|
+
}
|
|
880
|
+
export function getParentModelForPropertyFromGraphRoute(pathTree, graphRoutePath) {
|
|
881
|
+
var _a;
|
|
882
|
+
const path = cleanGraphRoutePath(graphRoutePath);
|
|
883
|
+
const pathSegments = path.split("/");
|
|
884
|
+
if (pathSegments.length < 2) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
const entityType = (_a = pathTree.getNodeByPath(pathSegments[pathSegments.length - 2])) === null || _a === void 0 ? void 0 : _a.entityType;
|
|
888
|
+
return entityType;
|
|
889
|
+
}
|
|
890
|
+
export function isParentSharedEntity(program, model) {
|
|
891
|
+
var _a;
|
|
892
|
+
if (!isSharedEntity(program, model)) {
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
return ((_a = model.namespace) === null || _a === void 0 ? void 0 : _a.name) === DEFAULT_MSGRAPH_NAMESPACE;
|
|
341
896
|
}
|
|
342
897
|
//# sourceMappingURL=utils.js.map
|