@microsoft/typespec-msgraph 0.0.1-Preview.1 → 0.0.1-Preview.10
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.d.ts +3 -4
- package/dist/src/components/acceptable-media-types-annotation.d.ts.map +1 -1
- package/dist/src/components/acceptable-media-types-annotation.js +2 -6
- package/dist/src/components/acceptable-media-types-annotation.js.map +1 -1
- package/dist/src/components/alternate-keys-annotation.d.ts +4 -4
- package/dist/src/components/alternate-keys-annotation.d.ts.map +1 -1
- package/dist/src/components/alternate-keys-annotation.js +8 -16
- package/dist/src/components/alternate-keys-annotation.js.map +1 -1
- package/dist/src/components/annotations.d.ts +12 -0
- package/dist/src/components/annotations.d.ts.map +1 -0
- package/dist/src/components/annotations.js +63 -0
- package/dist/src/components/annotations.js.map +1 -0
- package/dist/src/components/common-elements.d.ts +15 -73
- package/dist/src/components/common-elements.d.ts.map +1 -1
- package/dist/src/components/common-elements.js +12 -26
- package/dist/src/components/common-elements.js.map +1 -1
- package/dist/src/components/computed-annotation.d.ts +3 -4
- package/dist/src/components/computed-annotation.d.ts.map +1 -1
- package/dist/src/components/computed-annotation.js +4 -10
- package/dist/src/components/computed-annotation.js.map +1 -1
- package/dist/src/components/count-restrictions-annotation.d.ts +3 -4
- package/dist/src/components/count-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/count-restrictions-annotation.js +4 -13
- package/dist/src/components/count-restrictions-annotation.js.map +1 -1
- package/dist/src/components/description-annotation.d.ts +3 -4
- package/dist/src/components/description-annotation.d.ts.map +1 -1
- package/dist/src/components/description-annotation.js +5 -11
- package/dist/src/components/description-annotation.js.map +1 -1
- package/dist/src/components/entity-container-element.d.ts +21 -0
- package/dist/src/components/entity-container-element.d.ts.map +1 -0
- package/dist/src/components/entity-container-element.js +22 -0
- package/dist/src/components/entity-container-element.js.map +1 -0
- package/dist/src/components/enum-type-element.d.ts +6 -0
- package/dist/src/components/enum-type-element.d.ts.map +1 -0
- package/dist/src/components/enum-type-element.js +17 -0
- package/dist/src/components/enum-type-element.js.map +1 -0
- package/dist/src/components/expand-restrictions-annotation.d.ts +4 -5
- package/dist/src/components/expand-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/expand-restrictions-annotation.js +9 -30
- package/dist/src/components/expand-restrictions-annotation.js.map +1 -1
- package/dist/src/components/filter-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/filter-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/filter-restrictions-annotation.js +10 -0
- package/dist/src/components/filter-restrictions-annotation.js.map +1 -0
- package/dist/src/components/immutable-annotation.d.ts +5 -0
- package/dist/src/components/immutable-annotation.d.ts.map +1 -0
- package/dist/src/components/immutable-annotation.js +6 -0
- package/dist/src/components/immutable-annotation.js.map +1 -0
- package/dist/src/components/index.d.ts +2 -14
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +9 -14
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/insert-restrictions-annotation.d.ts +6 -0
- package/dist/src/components/insert-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/insert-restrictions-annotation.js +10 -0
- package/dist/src/components/insert-restrictions-annotation.js.map +1 -0
- package/dist/src/components/operation-element.d.ts +6 -0
- package/dist/src/components/operation-element.d.ts.map +1 -0
- package/dist/src/components/operation-element.js +70 -0
- package/dist/src/components/operation-element.js.map +1 -0
- package/dist/src/components/permissions-annotation.d.ts +3 -4
- package/dist/src/components/permissions-annotation.d.ts.map +1 -1
- package/dist/src/components/permissions-annotation.js +2 -10
- package/dist/src/components/permissions-annotation.js.map +1 -1
- package/dist/src/components/property-element.d.ts +4 -4
- package/dist/src/components/property-element.d.ts.map +1 -1
- package/dist/src/components/property-element.js +16 -32
- package/dist/src/components/property-element.js.map +1 -1
- package/dist/src/components/revisions-annotation.d.ts +4 -5
- package/dist/src/components/revisions-annotation.d.ts.map +1 -1
- package/dist/src/components/revisions-annotation.js +7 -51
- package/dist/src/components/revisions-annotation.js.map +1 -1
- package/dist/src/components/schema-element.d.ts +6 -0
- package/dist/src/components/schema-element.d.ts.map +1 -0
- package/dist/src/components/schema-element.js +42 -0
- package/dist/src/components/schema-element.js.map +1 -0
- package/dist/src/components/search-restrictions-annotation.d.ts +3 -4
- package/dist/src/components/search-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/search-restrictions-annotation.js +4 -13
- package/dist/src/components/search-restrictions-annotation.js.map +1 -1
- package/dist/src/components/skip-supported-annotation.d.ts +3 -4
- package/dist/src/components/skip-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/skip-supported-annotation.js +2 -11
- package/dist/src/components/skip-supported-annotation.js.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.d.ts +4 -5
- package/dist/src/components/sort-restrictions-annotation.d.ts.map +1 -1
- package/dist/src/components/sort-restrictions-annotation.js +9 -30
- package/dist/src/components/sort-restrictions-annotation.js.map +1 -1
- package/dist/src/components/structured-type-element.d.ts +7 -4
- package/dist/src/components/structured-type-element.d.ts.map +1 -1
- package/dist/src/components/structured-type-element.js +24 -66
- package/dist/src/components/structured-type-element.js.map +1 -1
- package/dist/src/components/top-supported-annotation.d.ts +3 -4
- package/dist/src/components/top-supported-annotation.d.ts.map +1 -1
- package/dist/src/components/top-supported-annotation.js +3 -10
- package/dist/src/components/top-supported-annotation.js.map +1 -1
- package/dist/src/components/update-restrictions-annotation.d.ts +5 -0
- package/dist/src/components/update-restrictions-annotation.d.ts.map +1 -0
- package/dist/src/components/update-restrictions-annotation.js +8 -0
- package/dist/src/components/update-restrictions-annotation.js.map +1 -0
- package/dist/src/decorators/abstract.d.ts.map +1 -1
- package/dist/src/decorators/abstract.js +0 -6
- package/dist/src/decorators/abstract.js.map +1 -1
- package/dist/src/decorators/action.d.ts +10 -0
- package/dist/src/decorators/action.d.ts.map +1 -0
- package/dist/src/decorators/action.js +16 -0
- package/dist/src/decorators/action.js.map +1 -0
- package/dist/src/decorators/{handlers/custom/additional-query-parameters.d.ts → additional-query-parameters.d.ts} +3 -1
- package/dist/src/decorators/additional-query-parameters.d.ts.map +1 -0
- package/dist/src/decorators/additional-query-parameters.js +21 -0
- package/dist/src/decorators/additional-query-parameters.js.map +1 -0
- package/dist/src/decorators/ags-attribute.d.ts +14 -0
- package/dist/src/decorators/ags-attribute.d.ts.map +1 -0
- package/dist/src/decorators/ags-attribute.js +115 -0
- package/dist/src/decorators/ags-attribute.js.map +1 -0
- package/dist/src/decorators/allowed-values.d.ts +13 -0
- package/dist/src/decorators/allowed-values.d.ts.map +1 -0
- package/dist/src/decorators/allowed-values.js +35 -0
- package/dist/src/decorators/allowed-values.js.map +1 -0
- package/dist/src/decorators/complex.d.ts.map +1 -1
- package/dist/src/decorators/complex.js +0 -6
- package/dist/src/decorators/complex.js.map +1 -1
- package/dist/src/decorators/delta-collection.d.ts +8 -0
- package/dist/src/decorators/delta-collection.d.ts.map +1 -0
- package/dist/src/decorators/delta-collection.js +12 -0
- package/dist/src/decorators/delta-collection.js.map +1 -0
- package/dist/src/decorators/entity.d.ts.map +1 -1
- package/dist/src/decorators/entity.js +0 -6
- package/dist/src/decorators/entity.js.map +1 -1
- package/dist/src/decorators/filter.d.ts +11 -0
- package/dist/src/decorators/filter.d.ts.map +1 -0
- package/dist/src/decorators/filter.js +27 -0
- package/dist/src/decorators/filter.js.map +1 -0
- package/dist/src/decorators/flags.d.ts +9 -0
- package/dist/src/decorators/flags.d.ts.map +1 -0
- package/dist/src/decorators/flags.js +13 -0
- package/dist/src/decorators/flags.js.map +1 -0
- package/dist/src/decorators/function.d.ts +10 -0
- package/dist/src/decorators/function.d.ts.map +1 -0
- package/dist/src/decorators/function.js +16 -0
- package/dist/src/decorators/function.js.map +1 -0
- package/dist/src/decorators/graph-route.d.ts +16 -0
- package/dist/src/decorators/graph-route.d.ts.map +1 -0
- package/dist/src/decorators/graph-route.js +98 -0
- package/dist/src/decorators/graph-route.js.map +1 -0
- package/dist/src/decorators/has-stream.d.ts +1 -2
- package/dist/src/decorators/has-stream.d.ts.map +1 -1
- package/dist/src/decorators/has-stream.js +1 -14
- package/dist/src/decorators/has-stream.js.map +1 -1
- package/dist/src/decorators/immutable.d.ts +8 -0
- package/dist/src/decorators/immutable.d.ts.map +1 -0
- package/dist/src/decorators/immutable.js +12 -0
- package/dist/src/decorators/immutable.js.map +1 -0
- package/dist/src/decorators/index.d.ts +20 -1
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +20 -1
- package/dist/src/decorators/index.js.map +1 -1
- package/dist/src/decorators/is-owner.d.ts +10 -0
- package/dist/src/decorators/is-owner.d.ts.map +1 -0
- package/dist/src/decorators/is-owner.js +17 -0
- package/dist/src/decorators/is-owner.js.map +1 -0
- package/dist/src/decorators/open.d.ts.map +1 -1
- package/dist/src/decorators/open.js +0 -6
- package/dist/src/decorators/open.js.map +1 -1
- package/dist/src/decorators/{routed-interfaces.d.ts → operation-parameters.d.ts} +3 -11
- package/dist/src/decorators/operation-parameters.d.ts.map +1 -0
- package/dist/src/decorators/operation-parameters.js +15 -0
- package/dist/src/decorators/operation-parameters.js.map +1 -0
- package/dist/src/decorators/paged-collection.d.ts +8 -0
- package/dist/src/decorators/paged-collection.d.ts.map +1 -0
- package/dist/src/decorators/paged-collection.js +12 -0
- package/dist/src/decorators/paged-collection.js.map +1 -0
- package/dist/src/decorators/partial.d.ts +10 -0
- package/dist/src/decorators/partial.d.ts.map +1 -0
- package/dist/src/decorators/partial.js +16 -0
- package/dist/src/decorators/partial.js.map +1 -0
- package/dist/src/decorators/private-preview.d.ts.map +1 -1
- package/dist/src/decorators/private-preview.js +0 -10
- package/dist/src/decorators/private-preview.js.map +1 -1
- package/dist/src/decorators/privileged.d.ts +9 -0
- package/dist/src/decorators/privileged.d.ts.map +1 -0
- package/dist/src/decorators/privileged.js +13 -0
- package/dist/src/decorators/privileged.js.map +1 -0
- package/dist/src/decorators/public-namespace.d.ts +10 -0
- package/dist/src/decorators/public-namespace.d.ts.map +1 -0
- package/dist/src/decorators/public-namespace.js +16 -0
- package/dist/src/decorators/public-namespace.js.map +1 -0
- package/dist/src/decorators/required-for-create.d.ts +10 -0
- package/dist/src/decorators/required-for-create.d.ts.map +1 -0
- package/dist/src/decorators/required-for-create.js +14 -0
- package/dist/src/decorators/required-for-create.js.map +1 -0
- package/dist/src/decorators/workload-name-msa.d.ts +9 -0
- package/dist/src/decorators/workload-name-msa.d.ts.map +1 -0
- package/dist/src/decorators/workload-name-msa.js +13 -0
- package/dist/src/decorators/workload-name-msa.js.map +1 -0
- package/dist/src/decorators/workload-name.d.ts +9 -0
- package/dist/src/decorators/workload-name.d.ts.map +1 -0
- package/dist/src/decorators/workload-name.js +13 -0
- package/dist/src/decorators/workload-name.js.map +1 -0
- package/dist/src/emitter.d.ts +2 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +7 -3
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/entities/annotations.d.ts +40 -0
- package/dist/src/entities/annotations.d.ts.map +1 -0
- package/dist/src/entities/annotations.js +139 -0
- package/dist/src/entities/annotations.js.map +1 -0
- package/dist/src/entities/entity-container.d.ts +15 -0
- package/dist/src/entities/entity-container.d.ts.map +1 -0
- package/dist/src/entities/entity-container.js +42 -0
- package/dist/src/entities/entity-container.js.map +1 -0
- package/dist/src/entities/enum.d.ts +17 -0
- package/dist/src/entities/enum.d.ts.map +1 -0
- package/dist/src/entities/enum.js +24 -0
- package/dist/src/entities/enum.js.map +1 -0
- package/dist/src/entities/model.d.ts +47 -0
- package/dist/src/entities/model.d.ts.map +1 -0
- package/dist/src/entities/model.js +104 -0
- package/dist/src/entities/model.js.map +1 -0
- package/dist/src/entities/namespace.d.ts +21 -0
- package/dist/src/entities/namespace.d.ts.map +1 -0
- package/dist/src/entities/namespace.js +81 -0
- package/dist/src/entities/namespace.js.map +1 -0
- package/dist/src/entities/operation.d.ts +28 -0
- package/dist/src/entities/operation.d.ts.map +1 -0
- package/dist/src/entities/operation.js +103 -0
- package/dist/src/entities/operation.js.map +1 -0
- package/dist/src/entities/property.d.ts +3 -0
- package/dist/src/entities/property.d.ts.map +1 -0
- package/dist/src/entities/property.js +57 -0
- package/dist/src/entities/property.js.map +1 -0
- package/dist/src/entities/revision-definition.d.ts +9 -0
- package/dist/src/entities/revision-definition.d.ts.map +1 -0
- package/dist/src/entities/revision-definition.js +42 -0
- package/dist/src/entities/revision-definition.js.map +1 -0
- package/dist/src/index.d.ts +0 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +53 -2
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +25 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/src/linter.d.ts.map +1 -1
- package/dist/src/linter.js +34 -25
- package/dist/src/linter.js.map +1 -1
- package/dist/src/rules/allowed-values.d.ts +6 -0
- package/dist/src/rules/allowed-values.d.ts.map +1 -0
- package/dist/src/rules/allowed-values.js +59 -0
- package/dist/src/rules/allowed-values.js.map +1 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts +2 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.d.ts.map +1 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js +28 -0
- package/dist/src/rules/collection-navigation-properties-not-nullable.js.map +1 -0
- package/dist/src/rules/count.d.ts.map +1 -1
- package/dist/src/rules/count.js +3 -1
- package/dist/src/rules/count.js.map +1 -1
- package/dist/src/rules/disallowed-typespec-decorators.d.ts +2 -0
- package/dist/src/rules/disallowed-typespec-decorators.d.ts.map +1 -0
- package/dist/src/rules/disallowed-typespec-decorators.js +33 -0
- package/dist/src/rules/disallowed-typespec-decorators.js.map +1 -0
- package/dist/src/rules/entity.d.ts +1 -0
- package/dist/src/rules/entity.d.ts.map +1 -1
- package/dist/src/rules/entity.js +43 -1
- package/dist/src/rules/entity.js.map +1 -1
- package/dist/src/rules/enum.d.ts +2 -0
- package/dist/src/rules/enum.d.ts.map +1 -0
- package/dist/src/rules/enum.js +26 -0
- package/dist/src/rules/enum.js.map +1 -0
- package/dist/src/rules/expand.d.ts.map +1 -1
- package/dist/src/rules/expand.js +5 -7
- package/dist/src/rules/expand.js.map +1 -1
- package/dist/src/rules/extends-on-same-type.d.ts +2 -0
- package/dist/src/rules/extends-on-same-type.d.ts.map +1 -0
- package/dist/src/rules/extends-on-same-type.js +38 -0
- package/dist/src/rules/extends-on-same-type.js.map +1 -0
- package/dist/src/rules/filter.d.ts +4 -0
- package/dist/src/rules/filter.d.ts.map +1 -0
- package/dist/src/rules/filter.js +92 -0
- package/dist/src/rules/filter.js.map +1 -0
- package/dist/src/rules/function.d.ts +2 -0
- package/dist/src/rules/function.d.ts.map +1 -0
- package/dist/src/rules/function.js +26 -0
- package/dist/src/rules/function.js.map +1 -0
- package/dist/src/rules/graph-route.d.ts +6 -0
- package/dist/src/rules/graph-route.d.ts.map +1 -0
- package/dist/src/rules/graph-route.js +88 -0
- package/dist/src/rules/graph-route.js.map +1 -0
- package/dist/src/rules/index.d.ts +13 -6
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +13 -161
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/namespace.d.ts +3 -0
- package/dist/src/rules/namespace.d.ts.map +1 -0
- package/dist/src/rules/namespace.js +58 -0
- package/dist/src/rules/namespace.js.map +1 -0
- package/dist/src/rules/operation-inside-interface.d.ts +2 -0
- package/dist/src/rules/operation-inside-interface.d.ts.map +1 -0
- package/dist/src/rules/operation-inside-interface.js +25 -0
- package/dist/src/rules/operation-inside-interface.js.map +1 -0
- package/dist/src/rules/order-by.d.ts +1 -1
- package/dist/src/rules/order-by.d.ts.map +1 -1
- package/dist/src/rules/order-by.js +11 -10
- package/dist/src/rules/order-by.js.map +1 -1
- package/dist/src/rules/partial.d.ts +5 -0
- package/dist/src/rules/partial.d.ts.map +1 -0
- package/dist/src/rules/partial.js +35 -0
- package/dist/src/rules/partial.js.map +1 -0
- package/dist/src/rules/required-for-create.d.ts +2 -0
- package/dist/src/rules/required-for-create.d.ts.map +1 -0
- package/dist/src/rules/required-for-create.js +40 -0
- package/dist/src/rules/required-for-create.js.map +1 -0
- package/dist/src/rules/search.d.ts.map +1 -1
- package/dist/src/rules/search.js +3 -1
- package/dist/src/rules/search.js.map +1 -1
- package/dist/src/rules/skip.d.ts.map +1 -1
- package/dist/src/rules/skip.js +3 -1
- package/dist/src/rules/skip.js.map +1 -1
- package/dist/src/rules/top.d.ts.map +1 -1
- package/dist/src/rules/top.js +3 -1
- package/dist/src/rules/top.js.map +1 -1
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +160 -4
- package/dist/src/utils.js.map +1 -1
- package/lib/decorators.tsp +182 -39
- package/lib/deployment.tsp +18 -0
- package/lib/lib.tsp +6 -22
- package/lib/msgraph.tsp +4 -0
- package/lib/porcelain.tsp +135 -0
- package/lib/responses.tsp +82 -0
- package/lib/shared-models.tsp +75 -0
- package/package.json +31 -20
- package/dist/src/components/program-context.d.ts +0 -4
- package/dist/src/components/program-context.d.ts.map +0 -1
- package/dist/src/components/program-context.js +0 -3
- package/dist/src/components/program-context.js.map +0 -1
- package/dist/src/csdl.d.ts +0 -8
- package/dist/src/csdl.d.ts.map +0 -1
- package/dist/src/csdl.js +0 -298
- package/dist/src/csdl.js.map +0 -1
- package/dist/src/decorators/attribute-builder.d.ts +0 -2
- package/dist/src/decorators/attribute-builder.d.ts.map +0 -1
- package/dist/src/decorators/attribute-builder.js +0 -166
- package/dist/src/decorators/attribute-builder.js.map +0 -1
- package/dist/src/decorators/attributes.d.ts +0 -57
- package/dist/src/decorators/attributes.d.ts.map +0 -1
- package/dist/src/decorators/attributes.js +0 -50
- package/dist/src/decorators/attributes.js.map +0 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js +0 -36
- package/dist/src/decorators/handlers/custom/additional-query-parameters.js.map +0 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts +0 -7
- package/dist/src/decorators/handlers/custom/ags-attribute.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/ags-attribute.js +0 -36
- package/dist/src/decorators/handlers/custom/ags-attribute.js.map +0 -1
- package/dist/src/decorators/handlers/custom/index.d.ts +0 -3
- package/dist/src/decorators/handlers/custom/index.d.ts.map +0 -1
- package/dist/src/decorators/handlers/custom/index.js +0 -3
- package/dist/src/decorators/handlers/custom/index.js.map +0 -1
- package/dist/src/decorators/handlers/index.d.ts +0 -30
- package/dist/src/decorators/handlers/index.d.ts.map +0 -1
- package/dist/src/decorators/handlers/index.js +0 -121
- package/dist/src/decorators/handlers/index.js.map +0 -1
- package/dist/src/decorators/routed-interfaces.d.ts.map +0 -1
- package/dist/src/decorators/routed-interfaces.js +0 -43
- package/dist/src/decorators/routed-interfaces.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getAllowedValues, hasAllowedValues, isAllowedValuesArgumentsEmpty, isAllowedValuesPrimitive } from "../index.js";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
/***
|
|
5
|
+
* @allowedValues can only be applied to string model properties
|
|
6
|
+
* @allowedValues cannot have empty values
|
|
7
|
+
*/
|
|
8
|
+
export const allowedValuesCannotBeEmptyRule = createRule({
|
|
9
|
+
name: "allowed-values-cannot-be-empty-rule",
|
|
10
|
+
create({ program }) {
|
|
11
|
+
return {
|
|
12
|
+
modelProperty: (property) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!hasAllowedValues(program, property)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (isAllowedValuesArgumentsEmpty(program, property)) {
|
|
18
|
+
reportDiagnostic(program, {
|
|
19
|
+
code: "decorator-invalid-use",
|
|
20
|
+
target: property,
|
|
21
|
+
messageId: "allowedValues",
|
|
22
|
+
format: {
|
|
23
|
+
decorator: "@allowedValues"
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const allowedValues = getAllowedValues(program, property);
|
|
28
|
+
if (((_a = allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.values) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
29
|
+
const values = allowedValues.values;
|
|
30
|
+
const expectedType = typeof values[0];
|
|
31
|
+
for (let i = 1; i < values.length; i++) {
|
|
32
|
+
if (typeof values[i] !== expectedType) {
|
|
33
|
+
reportDiagnostic(program, {
|
|
34
|
+
code: 'decorator-invalid-use',
|
|
35
|
+
target: property,
|
|
36
|
+
messageId: 'allowedValuesTypeHomogeinity',
|
|
37
|
+
format: {
|
|
38
|
+
decorator: '@allowedValues'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!isAllowedValuesPrimitive(program, property)) {
|
|
46
|
+
reportDiagnostic(program, {
|
|
47
|
+
code: "decorator-invalid-use",
|
|
48
|
+
target: property,
|
|
49
|
+
messageId: "allowedValuesInvalidType",
|
|
50
|
+
format: {
|
|
51
|
+
decorator: "@allowedValues"
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=allowed-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowed-values.js","sourceRoot":"","sources":["../../../src/rules/allowed-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC1H,OAAO,EAAE,gBAAgB,EAAE,MAAM,W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EAAE,QAAQ,CAAC,EAAE;oBAChD,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,uBAAuB;wBAC7B,MAAM,EAAE,QAAQ;wBAChB,SAAS,EAAE,0BAA0B;wBACrC,MAAM,EAAE;4BACN,SAAS,EAAE,gBAAgB;yBAC5B;qBACF,CAAC,CAAC;iBACJ;YAEH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-navigation-properties-not-nullable.d.ts","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,wDAAwD,mCA2BjE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { isTypeCollection, isNavigationProperty, isTypeNullable, } from "../utils.js";
|
|
3
|
+
import { reportDiagnostic } from "../lib.js";
|
|
4
|
+
export const collectionValuedNavigationPropertiesCannotBeNullableRule = createRule({
|
|
5
|
+
name: "collection-valued-navigation-properties-cannot-be-nullable",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
modelProperty: (property) => {
|
|
9
|
+
if (!isNavigationProperty(program, property)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!isTypeCollection(program, property.type)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!isTypeNullable(program, property.type)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
reportDiagnostic(program, {
|
|
19
|
+
code: "element-missing-dependencies",
|
|
20
|
+
target: property,
|
|
21
|
+
messageId: "collectionNavigationPropertiesNotNullable",
|
|
22
|
+
format: {},
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=collection-navigation-properties-not-nullable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-navigation-properties-not-nullable.js","sourceRoot":"","sources":["../../../src/rules/collection-navigation-properties-not-nullable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,wDAAwD,GACnE,UAAU,CAAC;IACT,IAAI,EAAE,4DAA4D;IAClE,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC1B,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBAC5C,OAAO;iBACR;gBAED,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC7C,OAAO;iBACR;gBAED,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;oBAC3C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,8BAA8B;oBACpC,MAAM,EAAE,QAAQ;oBAChB,SAAS,EAAE,2CAA2C;oBACtD,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,eAAO,MAAM,oDAAoD,mCA6B/D,CAAC"}
|
package/dist/src/rules/count.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createRule } from "@typespec/lint";
|
|
2
2
|
import { getOperationVerb } from "@typespec/http";
|
|
3
3
|
import { isCount } from "../index.js";
|
|
4
|
+
import { isTypeCollection } from "../utils.js";
|
|
4
5
|
import { reportDiagnostic } from "../lib.js";
|
|
5
6
|
/**
|
|
6
7
|
* @count applies to get operations that return collections.
|
|
@@ -15,7 +16,8 @@ export const countAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
|
15
16
|
}
|
|
16
17
|
if (getOperationVerb(program, operation) === "get") {
|
|
17
18
|
const returnType = operation.returnType;
|
|
18
|
-
|
|
19
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
20
|
+
if (isCollection) {
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,oDAAoD,GAAG,UAAU,CAAC;IAC7E,IAAI,EAAE,yDAAyD;IAC/D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAChC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,
|
|
1
|
+
{"version":3,"file":"count.js","sourceRoot":"","sources":["../../../src/rules/count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,oDAAoD,GAAG,UAAU,CAAC;IAC7E,IAAI,EAAE,yDAAyD;IAC/D,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBAChC,OAAO;iBACR;gBAED,IAAI,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,KAAK,EAAE;oBAClD,MAAM,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC;oBACxC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;oBAC3D,IAAI,YAAY,EAAE;wBAChB,OAAO;qBACR;iBACF;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,WAAW;oBACtB,MAAM,EAAE;wBACN,SAAS,EAAE,QAAQ;wBACnB,MAAM,EAAE,yCAAyC;qBAClD;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disallowed-typespec-decorators.d.ts","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gCAAgC,mCA+B3C,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
export const disallowedTypeSpecDecoratorsRule = createRule({
|
|
4
|
+
name: "disallowed-typespec-decorators",
|
|
5
|
+
create({ program }) {
|
|
6
|
+
return {
|
|
7
|
+
decorator: (decorator) => {
|
|
8
|
+
const denyList = [
|
|
9
|
+
"@friendlyName",
|
|
10
|
+
"@secret",
|
|
11
|
+
"@summary",
|
|
12
|
+
"@tag",
|
|
13
|
+
"@visibility",
|
|
14
|
+
"@withVisibility",
|
|
15
|
+
"@withUpdateableProperties",
|
|
16
|
+
"@withDefaultKeyVisibility",
|
|
17
|
+
];
|
|
18
|
+
if (denyList.indexOf(decorator.name) < 0) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
reportDiagnostic(program, {
|
|
22
|
+
code: "decorator-invalid-use",
|
|
23
|
+
target: decorator.target,
|
|
24
|
+
messageId: "disallowedTypeSpecDecorators",
|
|
25
|
+
format: {
|
|
26
|
+
decorator: decorator.name,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=disallowed-typespec-decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disallowed-typespec-decorators.js","sourceRoot":"","sources":["../../../src/rules/disallowed-typespec-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAAC;IACzD,IAAI,EAAE,gCAAgC;IACtC,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,MAAM,QAAQ,GAAG;oBACf,eAAe;oBACf,SAAS;oBACT,UAAU;oBACV,MAAM;oBACN,aAAa;oBACb,iBAAiB;oBACjB,2BAA2B;oBAC3B,2BAA2B;iBAC5B,CAAC;gBAEF,IAAI,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;oBACxC,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,SAAS,EAAE,8BAA8B;oBACzC,MAAM,EAAE;wBACN,SAAS,EAAE,SAAS,CAAC,IAAI;qBAC1B;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,mCA+BhC,CAAC;AAEH,eAAO,MAAM,+CAA+C,mCA4C1D,CAAC"}
|
package/dist/src/rules/entity.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isKey, walkPropertiesInherited } from "@typespec/compiler";
|
|
2
2
|
import { createRule } from "@typespec/lint";
|
|
3
|
-
import { isEntity } from "../index.js";
|
|
3
|
+
import { isEntity, isPartial } from "../index.js";
|
|
4
4
|
import { reportDiagnostic } from "../lib.js";
|
|
5
|
+
import { isTypeNullable, isExcludedLibraryType } from "../utils.js";
|
|
5
6
|
export const entityMustHaveKeyRule = createRule({
|
|
6
7
|
name: "entity-must-have-key",
|
|
7
8
|
create({ program }) {
|
|
@@ -15,6 +16,9 @@ export const entityMustHaveKeyRule = createRule({
|
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
19
|
+
if (isPartial(program, model)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
reportDiagnostic(program, {
|
|
19
23
|
code: "decorator-missing-dependencies",
|
|
20
24
|
target: model,
|
|
@@ -28,4 +32,42 @@ export const entityMustHaveKeyRule = createRule({
|
|
|
28
32
|
};
|
|
29
33
|
},
|
|
30
34
|
});
|
|
35
|
+
export const keyOnlyOnEntityNonNullablePrimitivePropertyRule = createRule({
|
|
36
|
+
name: "key-only-on-entity-non-nullable-primitive-property",
|
|
37
|
+
create({ program }) {
|
|
38
|
+
return {
|
|
39
|
+
modelProperty: (property) => {
|
|
40
|
+
if (!property.model || !isKey(program, property)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (isExcludedLibraryType(program, property.model)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!isEntity(program, property.model)) {
|
|
47
|
+
reportDiagnostic(program, {
|
|
48
|
+
code: "decorator-missing-dependencies",
|
|
49
|
+
target: property,
|
|
50
|
+
format: {
|
|
51
|
+
decorator: "@key",
|
|
52
|
+
required: "@entity",
|
|
53
|
+
location: "entity model",
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (isTypeNullable(program, property.type) ||
|
|
59
|
+
property.type.kind !== "Scalar" ||
|
|
60
|
+
property.name === "Array") {
|
|
61
|
+
reportDiagnostic(program, {
|
|
62
|
+
code: "decorator-invalid-use",
|
|
63
|
+
target: property,
|
|
64
|
+
messageId: "key",
|
|
65
|
+
format: {},
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
31
73
|
//# sourceMappingURL=entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/rules/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,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} from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
4
|
+
export const useEvolvableEnumRule = createRule({
|
|
5
|
+
name: "use-evolvable-enum",
|
|
6
|
+
create({ program }) {
|
|
7
|
+
return {
|
|
8
|
+
enum: (enumType) => {
|
|
9
|
+
if (isExcludedCoreType(program, enumType)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (enumType.members.has("unknownFutureValue")) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
reportDiagnostic(program, {
|
|
16
|
+
code: "use-evolvable-enum",
|
|
17
|
+
target: enumType,
|
|
18
|
+
format: {
|
|
19
|
+
enum: enumType.name,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enum.js","sourceRoot":"","sources":["../../../src/rules/enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC;IAC7C,IAAI,EAAE,oBAAoB;IAC1B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACjB,IAAI,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;oBACzC,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE;oBAC9C,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,oBAAoB;oBAC1B,MAAM,EAAE,QAAQ;oBAChB,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ,CAAC,IAAI;qBACpB;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,mCAAmC,mCA2B9C,CAAC;AAEH,eAAO,MAAM,kCAAkC,mCAwC7C,CAAC"}
|
package/dist/src/rules/expand.js
CHANGED
|
@@ -3,20 +3,19 @@ import { createRule } from "@typespec/lint";
|
|
|
3
3
|
import { getOperationVerb } from "@typespec/http";
|
|
4
4
|
import { getExpand, isContains, isExpand, isReferences } from "../index.js";
|
|
5
5
|
import { reportDiagnostic } from "../lib.js";
|
|
6
|
+
import { getNavigationSourceType } from "../utils.js";
|
|
6
7
|
export const expandOnlyOnGetNavigationSourceRule = createRule({
|
|
7
8
|
name: "expand-only-on-get-navigation-source",
|
|
8
9
|
create({ program }) {
|
|
9
10
|
return {
|
|
10
11
|
operation: (operation) => {
|
|
11
|
-
var _a;
|
|
12
12
|
if (!isExpand(program, operation)) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
if (getOperationVerb(program, operation) === "get") {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
16
|
+
if (getNavigationSourceType(program, operation) !== undefined) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
20
19
|
}
|
|
21
20
|
reportDiagnostic(program, {
|
|
22
21
|
code: "decorator-invalid-use",
|
|
@@ -36,12 +35,11 @@ export const expandOnlyNavigationPropertiesRule = createRule({
|
|
|
36
35
|
create({ program }) {
|
|
37
36
|
return {
|
|
38
37
|
operation: (operation) => {
|
|
39
|
-
var _a, _b;
|
|
40
38
|
const expanded = getExpand(program, operation);
|
|
41
39
|
if (!expanded.length) {
|
|
42
40
|
return;
|
|
43
41
|
}
|
|
44
|
-
const returnType = (
|
|
42
|
+
const returnType = getNavigationSourceType(program, operation);
|
|
45
43
|
if (!returnType) {
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expand.js","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"expand.js","sourceRoot":"","sources":["../../../src/rules/expand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,mCAAmC,GAAG,UAAU,CAAC;IAC5D,IAAI,EAAE,sCAAsC;IAC5C,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,C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CAAC;qBACtF,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAEpC,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CACvC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACvD,CAAC;gBAEF,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;oBAC7B,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,uBAAuB;oBAC7B,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,kBAAkB;oBAC7B,MAAM,EAAE;wBACN,KAAK,EAAE,SAAS,CAAC,IAAI;wBACrB,UAAU,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;qBACzC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-on-same-type.d.ts","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,mCAmChC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { reportDiagnostic } from "../lib.js";
|
|
3
|
+
import { isComplex, isEntity } from "../index.js";
|
|
4
|
+
import { isExcludedCoreType } from "../utils.js";
|
|
5
|
+
export const extendsOnSameTypeRule = createRule({
|
|
6
|
+
name: "extends-on-same-type",
|
|
7
|
+
create({ program }) {
|
|
8
|
+
return {
|
|
9
|
+
model: (model) => {
|
|
10
|
+
if (!model.baseModel) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (isExcludedCoreType(program, model)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (isEntity(program, model) && !isEntity(program, model.baseModel)) {
|
|
17
|
+
reportDiagnostic(program, {
|
|
18
|
+
code: "extends-invalid-use",
|
|
19
|
+
target: model,
|
|
20
|
+
format: {
|
|
21
|
+
type: "@entity",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (isComplex(program, model) && !isComplex(program, model.baseModel)) {
|
|
26
|
+
reportDiagnostic(program, {
|
|
27
|
+
code: "extends-invalid-use",
|
|
28
|
+
target: model,
|
|
29
|
+
format: {
|
|
30
|
+
type: "@complex",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=extends-on-same-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extends-on-same-type.js","sourceRoot":"","sources":["../../../src/rules/extends-on-same-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAC;IAC9C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;oBACpB,OAAO;iBACR;gBAED,IAAI,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACtC,OAAO;iBACR;gBAED,IAAI,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE;oBACnE,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,qBAAqB;wBAC3B,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE;4BACN,IAAI,EAAE,SAAS;yBAChB;qBACF,CAAC,CAAC;iBACJ;gBAED,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE;oBACrE,gBAAgB,CAAC,OAAO,EAAE;wBACxB,IAAI,EAAE,qBAAqB;wBAC3B,MAAM,EAAE,KAAK;wBACb,MAAM,EAAE;4BACN,IAAI,EAAE,UAAU;yBACjB;qBACF,CAAC,CAAC;iBACJ;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const filterAppliesToGetOperationsThatReturnCollectionsRule: import("@typespec/lint").LintRule;
|
|
2
|
+
export declare const filterOnlyAppliesToModelPropertiesRule: import("@typespec/lint").LintRule;
|
|
3
|
+
export declare const filterPropertiesMustNotBeEmptyRule: import("@typespec/lint").LintRule;
|
|
4
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/rules/filter.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,qDAAqD,mCA6BhE,CAAC;AAEH,eAAO,MAAM,sCAAsC,mCAuCjD,CAAC;AAEH,eAAO,MAAM,kCAAkC,mCA0B7C,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createRule } from "@typespec/lint";
|
|
2
|
+
import { getFilter, isFilter } from "../index.js";
|
|
3
|
+
import { getOperationVerb } from "@typespec/http";
|
|
4
|
+
import { getNavigationSourceType, isTypeCollection } from "../utils.js";
|
|
5
|
+
import { reportDiagnostic } from "../lib.js";
|
|
6
|
+
import { walkPropertiesInherited } from "@typespec/compiler";
|
|
7
|
+
export const filterAppliesToGetOperationsThatReturnCollectionsRule = createRule({
|
|
8
|
+
name: "filter-applies-to-get-operations-that-return-collections",
|
|
9
|
+
create({ program }) {
|
|
10
|
+
return {
|
|
11
|
+
operation: (operation) => {
|
|
12
|
+
if (!isFilter(program, operation)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (getOperationVerb(program, operation) === "get") {
|
|
16
|
+
const returnType = operation.returnType;
|
|
17
|
+
const isCollection = isTypeCollection(program, returnType);
|
|
18
|
+
if (isCollection) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
reportDiagnostic(program, {
|
|
23
|
+
code: "decorator-invalid-use",
|
|
24
|
+
target: operation,
|
|
25
|
+
messageId: "wrongType",
|
|
26
|
+
format: {
|
|
27
|
+
decorator: "@filter",
|
|
28
|
+
target: "get operation that returns a collection",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const filterOnlyAppliesToModelPropertiesRule = createRule({
|
|
36
|
+
name: "filter-only-on-model-properties",
|
|
37
|
+
create({ program }) {
|
|
38
|
+
return {
|
|
39
|
+
operation: (operation) => {
|
|
40
|
+
if (!isFilter(program, operation)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const returnType = getNavigationSourceType(program, operation);
|
|
44
|
+
if (!returnType) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const modelType = returnType.indexer ? returnType.indexer.value : returnType;
|
|
48
|
+
const filterProperties = getFilter(program, operation);
|
|
49
|
+
const modelProperties = [...walkPropertiesInherited(modelType)].map((property) => property.name);
|
|
50
|
+
const invalidFilterProperties = filterProperties.filter((property) => !modelProperties.includes(property));
|
|
51
|
+
if (!invalidFilterProperties.length) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
reportDiagnostic(program, {
|
|
55
|
+
code: "decorator-invalid-use",
|
|
56
|
+
target: operation,
|
|
57
|
+
messageId: "filterProperties",
|
|
58
|
+
format: {
|
|
59
|
+
model: modelType.name,
|
|
60
|
+
properties: invalidFilterProperties.join(", "),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export const filterPropertiesMustNotBeEmptyRule = createRule({
|
|
68
|
+
name: "filter-properties-must-not-be-empty",
|
|
69
|
+
create({ program }) {
|
|
70
|
+
return {
|
|
71
|
+
operation: (operation) => {
|
|
72
|
+
if (!isFilter(program, operation)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const filterProperties = getFilter(program, operation);
|
|
76
|
+
if (filterProperties.length) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
reportDiagnostic(program, {
|
|
80
|
+
code: "decorator-invalid-use",
|
|
81
|
+
target: operation,
|
|
82
|
+
messageId: "required",
|
|
83
|
+
format: {
|
|
84
|
+
decorator: "@filter",
|
|
85
|
+
parameters: "filter properties",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/rules/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAS,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,CAAC,MAAM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AS,EAAE,SAAS;wBACpB,UAAU,EAAE,mBAAmB;qBAChC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/rules/function.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,mCAsB3B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { isVoidType } from "@typespec/compiler";
|
|
2
|
+
import { createRule } from "@typespec/lint";
|
|
3
|
+
import { isFunction } from "../index.js";
|
|
4
|
+
import { reportDiagnostic } from "../lib.js";
|
|
5
|
+
export const voidFunctionRule = createRule({
|
|
6
|
+
name: "void-function",
|
|
7
|
+
create({ program }) {
|
|
8
|
+
return {
|
|
9
|
+
operation: (operation) => {
|
|
10
|
+
if (!isFunction(program, operation)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (!isVoidType(operation.returnType)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
reportDiagnostic(program, {
|
|
17
|
+
code: "decorator-missing-dependencies",
|
|
18
|
+
target: operation,
|
|
19
|
+
messageId: "function",
|
|
20
|
+
format: {},
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/rules/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;IACzC,IAAI,EAAE,eAAe;IACrB,MAAM,CAAC,EAAE,OAAO,EAAE;QAChB,OAAO;YACL,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE;gBACvB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;oBACnC,OAAO;iBACR;gBAED,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE;oBACrC,OAAO;iBACR;gBAED,gBAAgB,CAAC,OAAO,EAAE;oBACxB,IAAI,EAAE,gCAAgC;oBACtC,MAAM,EAAE,SAAS;oBACjB,SAAS,EAAE,UAAU;oBACrB,MAAM,EAAE,EAAE;iBACX,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @graphRoute should not have a leading forward slash
|
|
3
|
+
*/
|
|
4
|
+
export declare const graphRouteLeadingSlashRule: import("@typespec/lint").LintRule;
|
|
5
|
+
export declare const operationParametersMatchGraphRouteParametersRule: import("@typespec/lint").LintRule;
|
|
6
|
+
//# sourceMappingURL=graph-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-route.d.ts","sourceRoot":"","sources":["../../../src/rules/graph-route.ts"],"names":[],"mappings":"AAMA;;GAEG;AAEH,eAAO,MAAM,0BAA0B,mCAYrC,CAAC;AAyBH,eAAO,MAAM,gDAAgD,mCAY3D,CAAC"}
|