@api-client/core 0.19.10 → 0.19.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -63
- package/bin/test.ts +1 -12
- package/build/src/browser.d.ts +0 -15
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -17
- package/build/src/browser.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -6
- package/build/src/events/EventTypes.d.ts.map +1 -1
- package/build/src/events/EventTypes.js +0 -2
- package/build/src/events/EventTypes.js.map +1 -1
- package/build/src/events/Events.d.ts +0 -2
- package/build/src/events/Events.d.ts.map +1 -1
- package/build/src/events/Events.js +0 -2
- package/build/src/events/Events.js.map +1 -1
- package/build/src/index.d.ts +0 -15
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +0 -17
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +3 -3
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +5 -5
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +2 -3
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +2 -3
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/ai/types.d.ts +2 -2
- package/build/src/modeling/ai/types.d.ts.map +1 -1
- package/build/src/modeling/ai/types.js.map +1 -1
- package/build/src/{amf → modeling/amf}/DataValueGenerator.d.ts +1 -1
- package/build/src/modeling/amf/DataValueGenerator.d.ts.map +1 -0
- package/build/src/{amf → modeling/amf}/DataValueGenerator.js +2 -3
- package/build/src/modeling/amf/DataValueGenerator.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +20 -20
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js +16 -18
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/amf/core_types.d.ts +9 -0
- package/build/src/modeling/amf/core_types.d.ts.map +1 -0
- package/build/src/modeling/amf/core_types.js +45 -0
- package/build/src/modeling/amf/core_types.js.map +1 -0
- package/build/src/models/http-flows/LegacyTranslator.js +1 -1
- package/build/src/models/http-flows/LegacyTranslator.js.map +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +0 -1
- package/package.json +11 -14
- package/src/events/EventTypes.ts +0 -2
- package/src/events/Events.ts +0 -2
- package/src/modeling/Bindings.ts +3 -3
- package/src/modeling/DomainAssociation.ts +5 -5
- package/src/modeling/DomainEntity.ts +3 -4
- package/src/modeling/DomainProperty.ts +3 -4
- package/src/modeling/ai/types.ts +2 -2
- package/src/{amf → modeling/amf}/DataValueGenerator.ts +3 -4
- package/src/modeling/amf/ShapeGenerator.ts +45 -61
- package/src/modeling/amf/core_types.ts +47 -0
- package/src/models/http-flows/LegacyTranslator.ts +1 -1
- package/src/runtime/http-runner/HttpFlows.ts +1 -1
- package/tests/unit/{amf → modeling/amf}/data_value_generator.spec.ts +2 -2
- package/tests/unit/modeling/amf/shape_generator.spec.ts +146 -167
- package/tests/unit/modeling/domain_asociation.spec.ts +13 -13
- package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/http_flow_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/project_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/request_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/serial_runner.spec.ts +1 -1
- package/build/src/amf/AmfMixin.d.ts +0 -396
- package/build/src/amf/AmfMixin.d.ts.map +0 -1
- package/build/src/amf/AmfMixin.js +0 -1138
- package/build/src/amf/AmfMixin.js.map +0 -1
- package/build/src/amf/AmfSerializer.d.ts +0 -137
- package/build/src/amf/AmfSerializer.d.ts.map +0 -1
- package/build/src/amf/AmfSerializer.js +0 -1947
- package/build/src/amf/AmfSerializer.js.map +0 -1
- package/build/src/amf/AmfTypes.d.ts +0 -25
- package/build/src/amf/AmfTypes.d.ts.map +0 -1
- package/build/src/amf/AmfTypes.js +0 -143
- package/build/src/amf/AmfTypes.js.map +0 -1
- package/build/src/amf/ApiExampleGenerator.d.ts +0 -40
- package/build/src/amf/ApiExampleGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiExampleGenerator.js +0 -112
- package/build/src/amf/ApiExampleGenerator.js.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +0 -68
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.js +0 -248
- package/build/src/amf/ApiMonacoSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.d.ts +0 -56
- package/build/src/amf/ApiSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.js +0 -94
- package/build/src/amf/ApiSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaValues.d.ts +0 -111
- package/build/src/amf/ApiSchemaValues.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaValues.js +0 -463
- package/build/src/amf/ApiSchemaValues.js.map +0 -1
- package/build/src/amf/DataValueGenerator.d.ts.map +0 -1
- package/build/src/amf/DataValueGenerator.js.map +0 -1
- package/build/src/amf/Parsing.d.ts +0 -48
- package/build/src/amf/Parsing.d.ts.map +0 -1
- package/build/src/amf/Parsing.js +0 -2
- package/build/src/amf/Parsing.js.map +0 -1
- package/build/src/amf/Utils.d.ts +0 -37
- package/build/src/amf/Utils.d.ts.map +0 -1
- package/build/src/amf/Utils.js +0 -169
- package/build/src/amf/Utils.js.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.d.ts +0 -34
- package/build/src/amf/data-node/DataNodeBase.d.ts.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.js +0 -77
- package/build/src/amf/data-node/DataNodeBase.js.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +0 -15
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.js +0 -23
- package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +0 -14
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js +0 -48
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +0 -22
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.js +0 -34
- package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +0 -1
- package/build/src/amf/definitions/Amf.d.ts +0 -363
- package/build/src/amf/definitions/Amf.d.ts.map +0 -1
- package/build/src/amf/definitions/Amf.js +0 -3
- package/build/src/amf/definitions/Amf.js.map +0 -1
- package/build/src/amf/definitions/Api.d.ts +0 -383
- package/build/src/amf/definitions/Api.d.ts.map +0 -1
- package/build/src/amf/definitions/Api.js +0 -2
- package/build/src/amf/definitions/Api.js.map +0 -1
- package/build/src/amf/definitions/Base.d.ts +0 -12
- package/build/src/amf/definitions/Base.d.ts.map +0 -1
- package/build/src/amf/definitions/Base.js +0 -2
- package/build/src/amf/definitions/Base.js.map +0 -1
- package/build/src/amf/definitions/Namespace.d.ts +0 -327
- package/build/src/amf/definitions/Namespace.d.ts.map +0 -1
- package/build/src/amf/definitions/Namespace.js +0 -346
- package/build/src/amf/definitions/Namespace.js.map +0 -1
- package/build/src/amf/definitions/Shapes.d.ts +0 -312
- package/build/src/amf/definitions/Shapes.d.ts.map +0 -1
- package/build/src/amf/definitions/Shapes.js +0 -87
- package/build/src/amf/definitions/Shapes.js.map +0 -1
- package/build/src/amf/models/AmfDataNode.d.ts +0 -67
- package/build/src/amf/models/AmfDataNode.d.ts.map +0 -1
- package/build/src/amf/models/AmfDataNode.js +0 -192
- package/build/src/amf/models/AmfDataNode.js.map +0 -1
- package/build/src/amf/shape/ShapeBase.d.ts +0 -74
- package/build/src/amf/shape/ShapeBase.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeBase.js +0 -93
- package/build/src/amf/shape/ShapeBase.js.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +0 -47
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js +0 -420
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +0 -85
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +0 -852
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +0 -1
- package/build/src/events/amf/AmfEventTypes.d.ts +0 -7
- package/build/src/events/amf/AmfEventTypes.d.ts.map +0 -1
- package/build/src/events/amf/AmfEventTypes.js +0 -7
- package/build/src/events/amf/AmfEventTypes.js.map +0 -1
- package/build/src/events/amf/AmfEvents.d.ts +0 -34
- package/build/src/events/amf/AmfEvents.d.ts.map +0 -1
- package/build/src/events/amf/AmfEvents.js +0 -63
- package/build/src/events/amf/AmfEvents.js.map +0 -1
- package/build/src/mocking/RandExp.d.ts +0 -55
- package/build/src/mocking/RandExp.d.ts.map +0 -1
- package/build/src/mocking/RandExp.js +0 -302
- package/build/src/mocking/RandExp.js.map +0 -1
- package/build/src/mocking/lib/ret.d.ts +0 -16
- package/build/src/mocking/lib/ret.d.ts.map +0 -1
- package/build/src/mocking/lib/ret.js +0 -284
- package/build/src/mocking/lib/ret.js.map +0 -1
- package/data/apis/APIC-187/APIC-187.raml +0 -21
- package/data/apis/APIC-187/dataType.raml +0 -132
- package/data/apis/APIC-187/example.raml +0 -84
- package/data/apis/APIC-188/APIC-188.raml +0 -21
- package/data/apis/APIC-188/dataType.raml +0 -132
- package/data/apis/APIC-188/example.raml +0 -84
- package/data/apis/APIC-233/APIC-233.raml +0 -15
- package/data/apis/APIC-391/APIC-391.raml +0 -44
- package/data/apis/APIC-391/examples/post-body-request-example.raml +0 -7
- package/data/apis/APIC-483/APIC-483.raml +0 -16
- package/data/apis/APIC-483/example/list-of-bank-succ.json +0 -32
- package/data/apis/APIC-483/schema/response-retrieve-list-bank.json +0 -68
- package/data/apis/APIC-487/APIC-487.raml +0 -36
- package/data/apis/APIC-655/APIC-655.raml +0 -44
- package/data/apis/APIC-655/delivery.json +0 -12
- package/data/apis/APIC-689/APIC-689.raml +0 -20
- package/data/apis/APIC-690/APIC-690.raml +0 -17
- package/data/apis/APIC-690/datatypes/Address.raml +0 -10
- package/data/apis/APIC-690/datatypes/Customer.raml +0 -17
- package/data/apis/APIC-690/examples/CustomerExample2.raml +0 -17
- package/data/apis/APIC-690/examples/CustomersExample.raml +0 -34
- package/data/apis/SE-10469/Purchase-Order-oagis-id-dd32f9c6c01048a19e15c423c9c741ae.json +0 -1383
- package/data/apis/SE-10469/SE-10469.raml +0 -11
- package/data/apis/SE-13092/Examples/PersonExample.raml +0 -7
- package/data/apis/SE-13092/SE-13092.raml +0 -37
- package/data/apis/SE-13092/datatypes/Address.raml +0 -5
- package/data/apis/SE-13092/datatypes/InlineType.raml +0 -5
- package/data/apis/SE-13092/datatypes/Person.raml +0 -15
- package/data/apis/SE-22063/SE-22063.raml +0 -14
- package/data/apis/SE-22063/stock.raml +0 -41
- package/data/apis/amf-helper-api/amf-helper-api.raml +0 -1024
- package/data/apis/amf-helper-api/examples/comment-example.json +0 -42
- package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +0 -7
- package/data/apis/amf-helper-api/examples/commentList-example.json +0 -48
- package/data/apis/amf-helper-api/examples/person.json +0 -14
- package/data/apis/amf-helper-api/examples/person.raml +0 -13
- package/data/apis/amf-helper-api/examples/person.xml +0 -14
- package/data/apis/amf-helper-api/libraries/comment-lib.raml +0 -143
- package/data/apis/amf-helper-api/library.raml +0 -7
- package/data/apis/amf-helper-api/schemas/person.json +0 -104
- package/data/apis/amf-helper-api/schemas/person.xsd +0 -26
- package/data/apis/amf-helper-api/traits/file.raml +0 -33
- package/data/apis/amf-helper-api/traits/pagination.raml +0 -80
- package/data/apis/amf-helper-api/traits/results.raml +0 -19
- package/data/apis/amf-helper-api/traits/visibility.raml +0 -14
- package/data/apis/amf-helper-api/types/app-person.raml +0 -101
- package/data/apis/amf-helper-api/types/dimensions.raml +0 -24
- package/data/apis/amf-helper-api/types/external-type.raml +0 -7
- package/data/apis/amf-helper-api/types/image.raml +0 -23
- package/data/apis/amf-helper-api/types/product.raml +0 -52
- package/data/apis/amf-helper-api/types/resource.raml +0 -11
- package/data/apis/amf-helper-api/types/standard-request.raml +0 -50
- package/data/apis/amf-helper-api/types/user.raml +0 -37
- package/data/apis/arc-demo-api/arc-demo-api.raml +0 -468
- package/data/apis/arc-demo-api/examples/e400.xml +0 -4
- package/data/apis/arc-demo-api/examples/e401.xml +0 -4
- package/data/apis/arc-demo-api/examples/e404.xml +0 -4
- package/data/apis/arc-demo-api/examples/image.xml +0 -5
- package/data/apis/arc-demo-api/examples/messages-example.json +0 -22
- package/data/apis/arc-demo-api/examples/messages-sent-example.json +0 -15
- package/data/apis/arc-demo-api/examples/person.json +0 -14
- package/data/apis/arc-demo-api/examples/person.url.encoded +0 -1
- package/data/apis/arc-demo-api/examples/person.xml +0 -14
- package/data/apis/arc-demo-api/examples/product.xml +0 -9
- package/data/apis/arc-demo-api/library.raml +0 -36
- package/data/apis/arc-demo-api/resourceTypes/app-person.raml +0 -49
- package/data/apis/arc-demo-api/resourceTypes/example-types.raml +0 -45
- package/data/apis/arc-demo-api/resourceTypes/image.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-sent-type.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-type.raml +0 -33
- package/data/apis/arc-demo-api/resourceTypes/product.raml +0 -52
- package/data/apis/arc-demo-api/resourceTypes/resource.raml +0 -11
- package/data/apis/arc-demo-api/schemas/error-response.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/image.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/person.json +0 -104
- package/data/apis/arc-demo-api/schemas/person.xsd +0 -26
- package/data/apis/arc-demo-api/schemas/product.xsd +0 -17
- package/data/apis/arc-demo-api/securitySchemes/basic.raml +0 -5
- package/data/apis/arc-demo-api/securitySchemes/oauth_2_0.raml +0 -29
- package/data/apis/arc-demo-api/securitySchemes/x-custom.raml +0 -26
- package/data/apis/arc-demo-api/traits/adminable.raml +0 -23
- package/data/apis/arc-demo-api/traits/pagination.raml +0 -83
- package/data/apis/arc-demo-api/traits/rate-limited.raml +0 -9
- package/data/apis/async-api/async-api.yaml +0 -96
- package/data/apis/example-generator-api/contact-email-example.raml +0 -6
- package/data/apis/example-generator-api/contact-example.raml +0 -5
- package/data/apis/example-generator-api/contact-fax-example.raml +0 -5
- package/data/apis/example-generator-api/contact-website-example.raml +0 -2
- package/data/apis/example-generator-api/example-1.raml +0 -6
- package/data/apis/example-generator-api/example-2.raml +0 -9
- package/data/apis/example-generator-api/example-3.raml +0 -4
- package/data/apis/example-generator-api/example-4.raml +0 -2
- package/data/apis/example-generator-api/example-5.raml +0 -4
- package/data/apis/example-generator-api/example-6.raml +0 -2
- package/data/apis/example-generator-api/example-7.raml +0 -5
- package/data/apis/example-generator-api/example-generator-api.raml +0 -423
- package/data/apis/example-generator-api/example.json +0 -14
- package/data/apis/example-generator-api/example.xml +0 -15
- package/data/apis/example-generator-api/example.xsd +0 -26
- package/data/apis/example-generator-api/examples/employee.raml +0 -7
- package/data/apis/example-generator-api/examples/employees.raml +0 -7
- package/data/apis/example-generator-api/linked-named-example.raml +0 -21
- package/data/apis/example-generator-api/named-example-with-link.raml +0 -5
- package/data/apis/example-generator-api/named-example.raml +0 -9
- package/data/apis/example-generator-api/user-json-example.raml +0 -17
- package/data/apis/example-generator-api/user-raml-example.raml +0 -37
- package/data/apis/example-generator-api/user.json +0 -8
- package/data/apis/example-generator-api/user.raml +0 -18
- package/data/apis/example-generator-api/users-json-example.raml +0 -17
- package/data/apis/example-generator-api/users-raml-example.raml +0 -32
- package/data/apis/example-generator-api/users.json +0 -8
- package/data/apis/expanded-api/expanded-api.raml +0 -8
- package/data/apis/flattened-api/flattened-api.raml +0 -8
- package/data/apis/multiple-servers/multiple-servers.yaml +0 -112
- package/data/apis/oas-3-api/oas-3-api.yaml +0 -356
- package/data/apis/oas-date/oas-date.yaml +0 -28
- package/data/apis/oas-types/oas-types.yaml +0 -159
- package/data/apis/oas-unions/oas-unions.yaml +0 -75
- package/data/apis/petstore/petstore.yaml +0 -954
- package/data/apis/raml-date/raml-date.raml +0 -28
- package/data/apis/recursive/recursive.raml +0 -14
- package/data/apis/schema-api/examples/person.json +0 -14
- package/data/apis/schema-api/examples/person.raml +0 -14
- package/data/apis/schema-api/examples/person.url.encoded +0 -1
- package/data/apis/schema-api/examples/person.xml +0 -14
- package/data/apis/schema-api/library/demo-types.raml +0 -43
- package/data/apis/schema-api/schema-api.raml +0 -656
- package/data/apis/schema-api/schemas/person.json +0 -104
- package/data/apis/schema-api/schemas/person.xsd +0 -26
- package/data/apis/schema-api/types/DemoPerson.raml +0 -67
- package/data/apis/secured-api/oauth-2-custom-settings.raml +0 -143
- package/data/apis/secured-api/oauth2-header-delivery.raml +0 -13
- package/data/apis/secured-api/oauth2-no-delivery.raml +0 -8
- package/data/apis/secured-api/oauth2-no-grants.raml +0 -12
- package/data/apis/secured-api/oauth2-pkce.raml +0 -13
- package/data/apis/secured-api/oauth2-query-delivery.raml +0 -13
- package/data/apis/secured-api/oauth_1_0.raml +0 -8
- package/data/apis/secured-api/oauth_1_0_no-settings.raml +0 -3
- package/data/apis/secured-api/oauth_1_0_no-signature.raml +0 -7
- package/data/apis/secured-api/oauth_1_0_signature.raml +0 -8
- package/data/apis/secured-api/passthrough-querystring.raml +0 -16
- package/data/apis/secured-api/passthrough.raml +0 -24
- package/data/apis/secured-api/secured-api.raml +0 -231
- package/data/apis/secured-api/x-custom.raml +0 -33
- package/data/apis/secured-api/x-other.raml +0 -29
- package/data/apis/secured-api/x-query-string.raml +0 -16
- package/data/apis/tracked-examples/datatypes/employee.raml +0 -5
- package/data/apis/tracked-examples/examples/employee.raml +0 -4
- package/data/apis/tracked-examples/examples/employees.raml +0 -8
- package/data/apis/tracked-examples/tracked-to-linked.raml +0 -28
- package/data/model.js +0 -129
- package/data/models/APIC-187.json +0 -11416
- package/data/models/APIC-188.json +0 -11416
- package/data/models/APIC-233.json +0 -539
- package/data/models/APIC-391.json +0 -1903
- package/data/models/APIC-483.json +0 -3110
- package/data/models/APIC-487.json +0 -1225
- package/data/models/APIC-655.json +0 -3145
- package/data/models/APIC-689.json +0 -797
- package/data/models/APIC-690.json +0 -5992
- package/data/models/SE-10469.json +0 -22898
- package/data/models/SE-13092.json +0 -2769
- package/data/models/SE-22063.json +0 -2314
- package/data/models/amf-helper-api.json +0 -84457
- package/data/models/arc-demo-api.json +0 -52041
- package/data/models/async-api.json +0 -3227
- package/data/models/example-generator-api.json +0 -45209
- package/data/models/expanded-api.json +0 -251
- package/data/models/flattened-api.json +0 -251
- package/data/models/multiple-servers.json +0 -2769
- package/data/models/oas-3-api.json +0 -10590
- package/data/models/oas-date.json +0 -637
- package/data/models/oas-types.json +0 -5352
- package/data/models/oas-unions.json +0 -1935
- package/data/models/petstore.json +0 -27712
- package/data/models/raml-date.json +0 -1114
- package/data/models/recursive.json +0 -610
- package/data/models/schema-api.json +0 -35527
- package/data/models/secured-api.json +0 -21071
- package/data/models/tracked-to-linked.json +0 -1914
- package/src/amf/AmfMixin.ts +0 -1726
- package/src/amf/AmfSerializer.ts +0 -2358
- package/src/amf/AmfTypes.ts +0 -147
- package/src/amf/ApiExampleGenerator.ts +0 -122
- package/src/amf/ApiMonacoSchemaGenerator.ts +0 -332
- package/src/amf/ApiSchemaGenerator.ts +0 -115
- package/src/amf/ApiSchemaValues.ts +0 -509
- package/src/amf/Parsing.ts +0 -50
- package/src/amf/Utils.ts +0 -172
- package/src/amf/data-node/DataNodeBase.ts +0 -83
- package/src/amf/data-node/JsonDataNodeGenerator.ts +0 -24
- package/src/amf/data-node/README.md +0 -3
- package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +0 -49
- package/src/amf/data-node/XmlDataNodeGenerator.ts +0 -46
- package/src/amf/definitions/Amf.ts +0 -440
- package/src/amf/definitions/Api.ts +0 -445
- package/src/amf/definitions/Base.ts +0 -13
- package/src/amf/definitions/Namespace.ts +0 -357
- package/src/amf/definitions/Shapes.ts +0 -438
- package/src/amf/models/AmfDataNode.ts +0 -210
- package/src/amf/shape/README.md +0 -4
- package/src/amf/shape/ShapeBase.ts +0 -174
- package/src/amf/shape/ShapeJsonSchemaGenerator.ts +0 -457
- package/src/amf/shape/ShapeXmlSchemaGenerator.ts +0 -933
- package/src/events/amf/AmfEventTypes.ts +0 -6
- package/src/events/amf/AmfEvents.ts +0 -78
- package/src/mocking/RandExp.ts +0 -335
- package/src/mocking/lib/ret.ts +0 -279
- package/tests/unit/amf/APIC-187.spec.ts +0 -41
- package/tests/unit/amf/APIC-188.spec.ts +0 -30
- package/tests/unit/amf/APIC-233.spec.ts +0 -32
- package/tests/unit/amf/APIC-391.spec.ts +0 -39
- package/tests/unit/amf/APIC-487.spec.ts +0 -44
- package/tests/unit/amf/APIC-655.spec.ts +0 -41
- package/tests/unit/amf/APIC-689.spec.ts +0 -28
- package/tests/unit/amf/APIC-690.spec.ts +0 -93
- package/tests/unit/amf/AmfLoader.ts +0 -538
- package/tests/unit/amf/AmfMixin.spec.ts +0 -1707
- package/tests/unit/amf/ApiExampleGenerator.spec.ts +0 -250
- package/tests/unit/amf/ApiMonacoSchemaGenerator.spec.ts +0 -183
- package/tests/unit/amf/ApiSchemaValues.spec.ts +0 -602
- package/tests/unit/amf/Namepsace.spec.ts +0 -494
- package/tests/unit/amf/SE-10469.spec.ts +0 -35
- package/tests/unit/amf/SE-13092.spec.ts +0 -64
- package/tests/unit/amf/SE-22063.spec.ts +0 -45
- package/tests/unit/amf/raml-examples.spec.ts +0 -43
- package/tests/unit/amf/schema_gen_array.spec.ts +0 -199
- package/tests/unit/amf/schema_gen_oas.spec.ts +0 -140
- package/tests/unit/amf/schema_gen_object.spec.ts +0 -279
- package/tests/unit/amf/schema_gen_scalar.spec.ts +0 -143
- package/tests/unit/amf/schema_gen_union.spec.ts +0 -401
- package/tests/unit/amf/schema_gen_unknown.spec.ts +0 -42
- package/tests/unit/amf/schema_gen_xml.spec.ts +0 -726
- package/tests/unit/amf/serializer/APIC-483.spec.ts +0 -36
- package/tests/unit/amf/serializer/Anotations.spec.ts +0 -50
- package/tests/unit/amf/serializer/Api.spec.ts +0 -210
- package/tests/unit/amf/serializer/Documentation.spec.ts +0 -52
- package/tests/unit/amf/serializer/Endpoints.spec.ts +0 -172
- package/tests/unit/amf/serializer/Operations.spec.ts +0 -330
- package/tests/unit/amf/serializer/Parameters.spec.ts +0 -149
- package/tests/unit/amf/serializer/PayloadExamples.spec.ts +0 -152
- package/tests/unit/amf/serializer/Security.spec.ts +0 -626
- package/tests/unit/amf/serializer/Server.spec.ts +0 -78
- package/tests/unit/amf/serializer/Shapes.spec.ts +0 -304
- package/tests/unit/amf/serializer/SourceMaps.spec.ts +0 -52
- package/tests/unit/amf/shapes/ShapeXmlSchemaGenerator.spec.ts +0 -28
- package/tests/unit/amf/tracked-to-linked.spec.ts +0 -90
- package/tests/unit/amf/xml-data-processing.spec.ts +0 -217
- package/tests/unit/events/amf.spec.ts +0 -151
|
@@ -1,1707 +0,0 @@
|
|
|
1
|
-
import { test } from '@japa/runner'
|
|
2
|
-
import sinon from 'sinon'
|
|
3
|
-
import { AmfMixin } from '../../../src/amf/AmfMixin.js'
|
|
4
|
-
import { AmfNamespace } from '../../../src/amf/definitions/Namespace.js'
|
|
5
|
-
import { AmfLoader } from './AmfLoader.js'
|
|
6
|
-
import {
|
|
7
|
-
IAmfDocument,
|
|
8
|
-
IAmfDomainElement,
|
|
9
|
-
IAmfEndPoint,
|
|
10
|
-
IAmfOperation,
|
|
11
|
-
IAmfServer,
|
|
12
|
-
IAmfShape,
|
|
13
|
-
IAmfWebApi,
|
|
14
|
-
} from '../../../src/amf/definitions/Amf.js'
|
|
15
|
-
import { nextFrame } from '../../../src/lib/timers/Timers.js'
|
|
16
|
-
|
|
17
|
-
class Helper extends AmfMixin(Object) {}
|
|
18
|
-
|
|
19
|
-
const loader = new AmfLoader()
|
|
20
|
-
const asyncApi = 'async-api'
|
|
21
|
-
const helperApiApi = 'amf-helper-api'
|
|
22
|
-
|
|
23
|
-
test.group('amf setter/getter', (group) => {
|
|
24
|
-
let model: IAmfDocument
|
|
25
|
-
|
|
26
|
-
group.setup(async () => {
|
|
27
|
-
model = await loader.getGraph(helperApiApi)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
let element: Helper
|
|
31
|
-
group.each.setup(async () => {
|
|
32
|
-
element = new Helper()
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('sets _amf property', ({ assert }) => {
|
|
36
|
-
element.amf = model
|
|
37
|
-
assert.isTrue(element._amf === model)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test.group('_amfChanged()', (group) => {
|
|
42
|
-
let model: IAmfDocument
|
|
43
|
-
|
|
44
|
-
group.setup(async () => {
|
|
45
|
-
model = await loader.getGraph(helperApiApi)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
let element: Helper
|
|
49
|
-
group.each.setup(async () => {
|
|
50
|
-
element = new Helper()
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('calls the function when amf property change', ({ assert }) => {
|
|
54
|
-
const spy = sinon.spy(element, '_amfChanged')
|
|
55
|
-
element.amf = model
|
|
56
|
-
assert.isTrue(spy.args[0][0] === model)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test('calls the function only once', ({ assert }) => {
|
|
60
|
-
const spy = sinon.spy(element, '_amfChanged')
|
|
61
|
-
element.amf = model
|
|
62
|
-
element.amf = model
|
|
63
|
-
assert.equal(spy.callCount, 1)
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test.group('_getAmfKey()', (group) => {
|
|
68
|
-
let model: IAmfDocument
|
|
69
|
-
|
|
70
|
-
group.setup(async () => {
|
|
71
|
-
model = await loader.getGraph(helperApiApi)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
let element: Helper
|
|
75
|
-
group.each.setup(async () => {
|
|
76
|
-
element = new Helper()
|
|
77
|
-
element.amf = model
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('returns empty string when no argument', ({ assert }) => {
|
|
81
|
-
const result = element._getAmfKey(undefined)
|
|
82
|
-
assert.equal(result, '')
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test('returns the passed property when no amf', ({ assert }) => {
|
|
86
|
-
element.amf = undefined
|
|
87
|
-
const result = element._getAmfKey(AmfNamespace.aml.vocabularies.core.description)
|
|
88
|
-
assert.equal(result, AmfNamespace.aml.vocabularies.core.description)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test('returns a value for a property', ({ assert }) => {
|
|
92
|
-
const result = element._getAmfKey(AmfNamespace.aml.vocabularies.core.description)
|
|
93
|
-
assert.equal(result.split(':')[1], 'description')
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
test.group('_getValue()', (group) => {
|
|
98
|
-
let model: IAmfDocument
|
|
99
|
-
|
|
100
|
-
group.setup(async () => {
|
|
101
|
-
model = await loader.getGraph(helperApiApi)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
let element: Helper
|
|
105
|
-
group.each.setup(() => {
|
|
106
|
-
element = new Helper()
|
|
107
|
-
element.amf = model
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
111
|
-
// @ts-expect-error Used in testing
|
|
112
|
-
assert.isUndefined(element._getValue(undefined, undefined))
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
116
|
-
// @ts-expect-error Used in testing
|
|
117
|
-
assert.isUndefined(element._getValue(undefined, 'test'))
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
test('returns undefined if no key argument', ({ assert }) => {
|
|
121
|
-
assert.isUndefined(
|
|
122
|
-
element._getValue(
|
|
123
|
-
{
|
|
124
|
-
'@id': 'amf://1',
|
|
125
|
-
'@type': ['test'],
|
|
126
|
-
},
|
|
127
|
-
// @ts-expect-error Used in testing
|
|
128
|
-
undefined
|
|
129
|
-
)
|
|
130
|
-
)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test('returns undefined if no key in object', ({ assert }) => {
|
|
134
|
-
assert.isUndefined(
|
|
135
|
-
element._getValue(
|
|
136
|
-
/** @type DomainElement */ {
|
|
137
|
-
// @ts-expect-error Used in testing
|
|
138
|
-
'a': [],
|
|
139
|
-
'b': [],
|
|
140
|
-
'@id': 'amf://1',
|
|
141
|
-
'@type': ['test'],
|
|
142
|
-
},
|
|
143
|
-
'c'
|
|
144
|
-
)
|
|
145
|
-
)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
test('returns undefined if no value in value array', ({ assert }) => {
|
|
149
|
-
assert.isUndefined(
|
|
150
|
-
element._getValue(
|
|
151
|
-
/** @type DomainElement */ {
|
|
152
|
-
'@id': '1',
|
|
153
|
-
'@type': ['test'],
|
|
154
|
-
// @ts-expect-error Used in testing
|
|
155
|
-
'a': [],
|
|
156
|
-
},
|
|
157
|
-
'a'
|
|
158
|
-
)
|
|
159
|
-
)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
test('returns the value', ({ assert }) => {
|
|
163
|
-
assert.equal(
|
|
164
|
-
element._getValue(
|
|
165
|
-
/** @type DomainElement */ {
|
|
166
|
-
'@id': 'amf://1',
|
|
167
|
-
'@type': ['test'],
|
|
168
|
-
// @ts-expect-error Used in testing
|
|
169
|
-
'a': [
|
|
170
|
-
{
|
|
171
|
-
'@value': 'test',
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
'a'
|
|
176
|
-
),
|
|
177
|
-
'test'
|
|
178
|
-
)
|
|
179
|
-
})
|
|
180
|
-
|
|
181
|
-
test('returns primitive value from compact model', ({ assert }) => {
|
|
182
|
-
assert.equal(
|
|
183
|
-
element._getValue(
|
|
184
|
-
/** @type DomainElement */ {
|
|
185
|
-
'@id': 'amf://1',
|
|
186
|
-
'@type': ['test'],
|
|
187
|
-
// @ts-expect-error Used in testing
|
|
188
|
-
'a': 'test',
|
|
189
|
-
},
|
|
190
|
-
'a'
|
|
191
|
-
),
|
|
192
|
-
'test'
|
|
193
|
-
)
|
|
194
|
-
})
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
test.group('_getValueArray()', (group) => {
|
|
198
|
-
let model: IAmfDocument
|
|
199
|
-
|
|
200
|
-
group.setup(async () => {
|
|
201
|
-
model = await loader.getGraph(helperApiApi)
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
let element: Helper
|
|
205
|
-
group.each.setup(() => {
|
|
206
|
-
element = new Helper()
|
|
207
|
-
element.amf = model
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
211
|
-
// @ts-expect-error Used in testing
|
|
212
|
-
assert.isUndefined(element._getValueArray(undefined, undefined))
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
216
|
-
// @ts-expect-error Used in testing
|
|
217
|
-
assert.isUndefined(element._getValueArray(undefined, 'test'))
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
test('returns undefined if no key argument', ({ assert }) => {
|
|
221
|
-
assert.isUndefined(
|
|
222
|
-
element._getValueArray(
|
|
223
|
-
{
|
|
224
|
-
'@id': 'amf://1',
|
|
225
|
-
'@type': ['test'],
|
|
226
|
-
},
|
|
227
|
-
// @ts-expect-error Used in testing
|
|
228
|
-
undefined
|
|
229
|
-
)
|
|
230
|
-
)
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
test('returns undefined if no key in object', ({ assert }) => {
|
|
234
|
-
assert.isUndefined(
|
|
235
|
-
element._getValueArray(
|
|
236
|
-
/** @type DomainElement */ {
|
|
237
|
-
// @ts-expect-error Used in testing
|
|
238
|
-
'a': [],
|
|
239
|
-
'b': [],
|
|
240
|
-
'@id': 'amf://1',
|
|
241
|
-
'@type': ['test'],
|
|
242
|
-
},
|
|
243
|
-
'c'
|
|
244
|
-
)
|
|
245
|
-
)
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
test('returns empty array if no value in value array', ({ assert }) => {
|
|
249
|
-
assert.deepEqual(
|
|
250
|
-
element._getValueArray(
|
|
251
|
-
/** @type DomainElement */ {
|
|
252
|
-
// @ts-expect-error Used in testing
|
|
253
|
-
'a': [],
|
|
254
|
-
'@id': 'amf://1',
|
|
255
|
-
'@type': ['test'],
|
|
256
|
-
},
|
|
257
|
-
'a'
|
|
258
|
-
),
|
|
259
|
-
[]
|
|
260
|
-
)
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
test('returns the values', ({ assert }) => {
|
|
264
|
-
assert.deepEqual(
|
|
265
|
-
element._getValueArray(
|
|
266
|
-
/** @type DomainElement */ {
|
|
267
|
-
// @ts-expect-error Used in testing
|
|
268
|
-
'a': [
|
|
269
|
-
{
|
|
270
|
-
'@value': 'test',
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
'@value': 'test2',
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
'@id': 'amf://1',
|
|
277
|
-
'@type': ['test'],
|
|
278
|
-
},
|
|
279
|
-
'a'
|
|
280
|
-
),
|
|
281
|
-
['test', 'test2']
|
|
282
|
-
)
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
test('returns values for non object values', ({ assert }) => {
|
|
286
|
-
assert.deepEqual(
|
|
287
|
-
element._getValueArray(
|
|
288
|
-
/** @type DomainElement */ {
|
|
289
|
-
// @ts-expect-error Used in testing
|
|
290
|
-
'a': ['test', 'test2'],
|
|
291
|
-
'@id': 'amf://1',
|
|
292
|
-
'@type': ['test'],
|
|
293
|
-
},
|
|
294
|
-
'a'
|
|
295
|
-
),
|
|
296
|
-
['test', 'test2']
|
|
297
|
-
)
|
|
298
|
-
})
|
|
299
|
-
})
|
|
300
|
-
|
|
301
|
-
test.group('_hasType()', (group) => {
|
|
302
|
-
let model: IAmfDocument
|
|
303
|
-
|
|
304
|
-
group.setup(async () => {
|
|
305
|
-
model = await loader.getGraph(helperApiApi)
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
let element: Helper
|
|
309
|
-
group.each.setup(() => {
|
|
310
|
-
element = new Helper()
|
|
311
|
-
element.amf = model
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
test('returns false if no arguments', ({ assert }) => {
|
|
315
|
-
assert.isFalse(element._hasType(undefined, undefined))
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
test('returns false if no model argument', ({ assert }) => {
|
|
319
|
-
assert.isFalse(element._hasType(undefined, 'test'))
|
|
320
|
-
})
|
|
321
|
-
|
|
322
|
-
test('returns false if no key argument', ({ assert }) => {
|
|
323
|
-
assert.isFalse(
|
|
324
|
-
element._hasType(
|
|
325
|
-
{
|
|
326
|
-
'@id': 'amf://1',
|
|
327
|
-
'@type': ['test'],
|
|
328
|
-
},
|
|
329
|
-
undefined
|
|
330
|
-
)
|
|
331
|
-
)
|
|
332
|
-
})
|
|
333
|
-
|
|
334
|
-
test('returns false if type does not match', ({ assert }) => {
|
|
335
|
-
assert.isFalse(
|
|
336
|
-
element._hasType(
|
|
337
|
-
{
|
|
338
|
-
'@type': ['a', 'b'],
|
|
339
|
-
'@id': 'amf://1',
|
|
340
|
-
},
|
|
341
|
-
'c'
|
|
342
|
-
)
|
|
343
|
-
)
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
test('returns true if type does match', ({ assert }) => {
|
|
347
|
-
assert.isTrue(
|
|
348
|
-
element._hasType(
|
|
349
|
-
{
|
|
350
|
-
'@type': ['a', 'b', 'c'],
|
|
351
|
-
'@id': 'amf://1',
|
|
352
|
-
},
|
|
353
|
-
'c'
|
|
354
|
-
)
|
|
355
|
-
)
|
|
356
|
-
})
|
|
357
|
-
})
|
|
358
|
-
|
|
359
|
-
test.group('_hasProperty()', (group) => {
|
|
360
|
-
let model: IAmfDocument
|
|
361
|
-
|
|
362
|
-
group.setup(async () => {
|
|
363
|
-
model = await loader.getGraph(helperApiApi)
|
|
364
|
-
})
|
|
365
|
-
|
|
366
|
-
let element: Helper
|
|
367
|
-
group.each.setup(() => {
|
|
368
|
-
element = new Helper()
|
|
369
|
-
element.amf = model
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
test('returns false if no arguments', ({ assert }) => {
|
|
373
|
-
// @ts-expect-error Used in testing
|
|
374
|
-
assert.isFalse(element._hasProperty(undefined, undefined))
|
|
375
|
-
})
|
|
376
|
-
|
|
377
|
-
test('returns false if no model argument', ({ assert }) => {
|
|
378
|
-
// @ts-expect-error Used in testing
|
|
379
|
-
assert.isFalse(element._hasProperty(undefined, 'test'))
|
|
380
|
-
})
|
|
381
|
-
|
|
382
|
-
test('returns false if no key argument', ({ assert }) => {
|
|
383
|
-
assert.isFalse(
|
|
384
|
-
element._hasProperty(
|
|
385
|
-
{
|
|
386
|
-
'@id': 'amf://1',
|
|
387
|
-
'@type': ['test'],
|
|
388
|
-
},
|
|
389
|
-
// @ts-expect-error Used in testing
|
|
390
|
-
undefined
|
|
391
|
-
)
|
|
392
|
-
)
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
test('returns false if type does not have property', ({ assert }) => {
|
|
396
|
-
assert.isFalse(
|
|
397
|
-
element._hasProperty(
|
|
398
|
-
/** @type DomainElement */ {
|
|
399
|
-
// @ts-expect-error Used in testing
|
|
400
|
-
'a': 'test',
|
|
401
|
-
'b': 'test',
|
|
402
|
-
'@id': 'amf://1',
|
|
403
|
-
'@type': ['test'],
|
|
404
|
-
},
|
|
405
|
-
'c'
|
|
406
|
-
)
|
|
407
|
-
)
|
|
408
|
-
})
|
|
409
|
-
|
|
410
|
-
test('returns true if have a property', ({ assert }) => {
|
|
411
|
-
assert.isTrue(
|
|
412
|
-
element._hasProperty(
|
|
413
|
-
/** @type DomainElement */ {
|
|
414
|
-
// @ts-expect-error Used in testing
|
|
415
|
-
'a': 'test',
|
|
416
|
-
'b': 'test',
|
|
417
|
-
'c': 'test',
|
|
418
|
-
'@id': 'amf://1',
|
|
419
|
-
'@type': ['test'],
|
|
420
|
-
},
|
|
421
|
-
'c'
|
|
422
|
-
)
|
|
423
|
-
)
|
|
424
|
-
})
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
test.group('_computePropertyArray()', (group) => {
|
|
428
|
-
let model: IAmfDocument
|
|
429
|
-
|
|
430
|
-
group.setup(async () => {
|
|
431
|
-
model = await loader.getGraph(helperApiApi)
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
let element: Helper
|
|
435
|
-
group.each.setup(() => {
|
|
436
|
-
element = new Helper()
|
|
437
|
-
element.amf = model
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
441
|
-
assert.isUndefined(element._computePropertyArray(undefined, undefined))
|
|
442
|
-
})
|
|
443
|
-
|
|
444
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
445
|
-
assert.isUndefined(element._computePropertyArray(undefined, 'test'))
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
test('returns undefined if no key argument', ({ assert }) => {
|
|
449
|
-
assert.isUndefined(
|
|
450
|
-
element._computePropertyArray(
|
|
451
|
-
{
|
|
452
|
-
'@id': 'amf://1',
|
|
453
|
-
'@type': ['test'],
|
|
454
|
-
},
|
|
455
|
-
undefined
|
|
456
|
-
)
|
|
457
|
-
)
|
|
458
|
-
})
|
|
459
|
-
|
|
460
|
-
test('returns array', ({ assert }) => {
|
|
461
|
-
assert.deepEqual(
|
|
462
|
-
element._computePropertyArray(
|
|
463
|
-
/** @type DomainElement */ {
|
|
464
|
-
// @ts-expect-error Used in testing
|
|
465
|
-
'test': ['a', 'b', 'c'],
|
|
466
|
-
'@id': 'amf://1',
|
|
467
|
-
'@type': ['test'],
|
|
468
|
-
},
|
|
469
|
-
'test'
|
|
470
|
-
),
|
|
471
|
-
['a', 'b', 'c']
|
|
472
|
-
)
|
|
473
|
-
})
|
|
474
|
-
})
|
|
475
|
-
|
|
476
|
-
test.group('_computeEncodes()', (group) => {
|
|
477
|
-
let model: IAmfDocument
|
|
478
|
-
|
|
479
|
-
group.setup(async () => {
|
|
480
|
-
model = await loader.getGraph(helperApiApi)
|
|
481
|
-
})
|
|
482
|
-
|
|
483
|
-
let element: Helper
|
|
484
|
-
group.each.setup(() => {
|
|
485
|
-
element = new Helper()
|
|
486
|
-
element.amf = model
|
|
487
|
-
})
|
|
488
|
-
|
|
489
|
-
test('returns undefined if no argument', ({ assert }) => {
|
|
490
|
-
assert.isUndefined(element._computeEncodes(undefined))
|
|
491
|
-
})
|
|
492
|
-
|
|
493
|
-
test('returns undefined if no encodes', ({ assert }) => {
|
|
494
|
-
assert.isUndefined(
|
|
495
|
-
element._computeEncodes({
|
|
496
|
-
'@id': 'amf://1',
|
|
497
|
-
'@type': ['test'],
|
|
498
|
-
})
|
|
499
|
-
)
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
test('returns an array from AMF model', ({ assert }) => {
|
|
503
|
-
const result = element._computeEncodes(model)
|
|
504
|
-
assert.typeOf(result, 'object')
|
|
505
|
-
})
|
|
506
|
-
})
|
|
507
|
-
|
|
508
|
-
test.group('_computeDeclares()', (group) => {
|
|
509
|
-
let model: IAmfDocument
|
|
510
|
-
|
|
511
|
-
group.setup(async () => {
|
|
512
|
-
model = await loader.getGraph(helperApiApi)
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
let element: Helper
|
|
516
|
-
group.each.setup(() => {
|
|
517
|
-
element = new Helper()
|
|
518
|
-
element.amf = model
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
test('returns undefined if no argument', ({ assert }) => {
|
|
522
|
-
assert.isUndefined(element._computeDeclares(undefined))
|
|
523
|
-
})
|
|
524
|
-
|
|
525
|
-
test('returns undefined if no declares', ({ assert }) => {
|
|
526
|
-
assert.isUndefined(
|
|
527
|
-
element._computeDeclares({
|
|
528
|
-
'@id': 'amf://1',
|
|
529
|
-
'@type': ['test'],
|
|
530
|
-
})
|
|
531
|
-
)
|
|
532
|
-
})
|
|
533
|
-
|
|
534
|
-
test('returns undefined argument is empty array', ({ assert }) => {
|
|
535
|
-
// @ts-expect-error Used in testing
|
|
536
|
-
assert.isUndefined(element._computeDeclares([]))
|
|
537
|
-
})
|
|
538
|
-
|
|
539
|
-
test('returns an array from AMF model', ({ assert }) => {
|
|
540
|
-
const result = element._computeDeclares(model)
|
|
541
|
-
assert.typeOf(result, 'array')
|
|
542
|
-
})
|
|
543
|
-
|
|
544
|
-
test('returns all items in the array', ({ assert }) => {
|
|
545
|
-
const result = element._computeDeclares(model) as IAmfDomainElement[]
|
|
546
|
-
assert.isAbove(result.length, 1)
|
|
547
|
-
})
|
|
548
|
-
})
|
|
549
|
-
|
|
550
|
-
test.group('_computeReferences()', (group) => {
|
|
551
|
-
let model: IAmfDocument
|
|
552
|
-
|
|
553
|
-
group.setup(async () => {
|
|
554
|
-
model = await loader.getGraph(helperApiApi)
|
|
555
|
-
})
|
|
556
|
-
|
|
557
|
-
let element: Helper
|
|
558
|
-
group.each.setup(() => {
|
|
559
|
-
element = new Helper()
|
|
560
|
-
element.amf = model
|
|
561
|
-
})
|
|
562
|
-
|
|
563
|
-
test('returns undefined if no argument', ({ assert }) => {
|
|
564
|
-
assert.isUndefined(element._computeReferences(undefined))
|
|
565
|
-
})
|
|
566
|
-
|
|
567
|
-
test('returns undefined argument is empty array', ({ assert }) => {
|
|
568
|
-
// @ts-expect-error Used in testing
|
|
569
|
-
assert.isUndefined(element._computeReferences([]))
|
|
570
|
-
})
|
|
571
|
-
|
|
572
|
-
test('returns undefined if no references', ({ assert }) => {
|
|
573
|
-
assert.isUndefined(
|
|
574
|
-
element._computeReferences({
|
|
575
|
-
'@id': 'amf://1',
|
|
576
|
-
'@type': ['test'],
|
|
577
|
-
})
|
|
578
|
-
)
|
|
579
|
-
})
|
|
580
|
-
|
|
581
|
-
test('returns an array from AMF model', ({ assert }) => {
|
|
582
|
-
const result = element._computeReferences(model)
|
|
583
|
-
assert.typeOf(result, 'array')
|
|
584
|
-
})
|
|
585
|
-
|
|
586
|
-
test('returns all items in the array', ({ assert }) => {
|
|
587
|
-
const result = element._computeReferences(model)
|
|
588
|
-
assert.isNotEmpty(result)
|
|
589
|
-
})
|
|
590
|
-
})
|
|
591
|
-
|
|
592
|
-
test.group('_computeWebApi()', (group) => {
|
|
593
|
-
let model: IAmfDocument
|
|
594
|
-
let asyncModel: IAmfDocument
|
|
595
|
-
|
|
596
|
-
group.setup(async () => {
|
|
597
|
-
model = await loader.getGraph(helperApiApi)
|
|
598
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
599
|
-
})
|
|
600
|
-
|
|
601
|
-
let element: Helper
|
|
602
|
-
group.each.setup(() => {
|
|
603
|
-
element = new Helper()
|
|
604
|
-
element.amf = model
|
|
605
|
-
})
|
|
606
|
-
|
|
607
|
-
test('returns undefined if no argument', ({ assert }) => {
|
|
608
|
-
assert.isUndefined(element._computeWebApi(undefined))
|
|
609
|
-
})
|
|
610
|
-
|
|
611
|
-
test('returns undefined if no encodes', ({ assert }) => {
|
|
612
|
-
assert.isUndefined(
|
|
613
|
-
element._computeWebApi({
|
|
614
|
-
'@id': 'amf://1',
|
|
615
|
-
'@type': ['test'],
|
|
616
|
-
})
|
|
617
|
-
)
|
|
618
|
-
})
|
|
619
|
-
|
|
620
|
-
test('returns undefined if no WebApi', ({ assert }) => {
|
|
621
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.document.encodes)
|
|
622
|
-
const amfModel = {
|
|
623
|
-
'@id': 'amf://1',
|
|
624
|
-
'@type': ['test'],
|
|
625
|
-
}
|
|
626
|
-
// @ts-expect-error Used in testing
|
|
627
|
-
amfModel[key] = {}
|
|
628
|
-
assert.isUndefined(element._computeWebApi(amfModel))
|
|
629
|
-
})
|
|
630
|
-
|
|
631
|
-
test('returns an object from AMF model', ({ assert }) => {
|
|
632
|
-
const result = element._computeWebApi(model)
|
|
633
|
-
assert.typeOf(result, 'object')
|
|
634
|
-
})
|
|
635
|
-
|
|
636
|
-
test('should return undefined for AsyncAPI model', async ({ assert }) => {
|
|
637
|
-
element.amf = asyncModel
|
|
638
|
-
assert.isUndefined(element._computeWebApi(asyncModel))
|
|
639
|
-
})
|
|
640
|
-
})
|
|
641
|
-
|
|
642
|
-
test.group('_computeApi()', (group) => {
|
|
643
|
-
let model: IAmfDocument
|
|
644
|
-
|
|
645
|
-
group.setup(async () => {
|
|
646
|
-
model = await loader.getGraph(helperApiApi)
|
|
647
|
-
})
|
|
648
|
-
|
|
649
|
-
let element: Helper
|
|
650
|
-
group.each.setup(() => {
|
|
651
|
-
element = new Helper()
|
|
652
|
-
element.amf = model
|
|
653
|
-
})
|
|
654
|
-
|
|
655
|
-
test('should return undefined if no argument', ({ assert }) => {
|
|
656
|
-
assert.isUndefined(element._computeApi(undefined))
|
|
657
|
-
})
|
|
658
|
-
|
|
659
|
-
test('should return undefined if no encodes', ({ assert }) => {
|
|
660
|
-
assert.isUndefined(
|
|
661
|
-
element._computeApi({
|
|
662
|
-
'@id': 'amf://1',
|
|
663
|
-
'@type': ['test'],
|
|
664
|
-
})
|
|
665
|
-
)
|
|
666
|
-
})
|
|
667
|
-
|
|
668
|
-
test('should return undefined if not API', ({ assert }) => {
|
|
669
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.document.encodes)
|
|
670
|
-
const amfModel = {
|
|
671
|
-
'@id': 'amf://1',
|
|
672
|
-
'@type': ['test'],
|
|
673
|
-
}
|
|
674
|
-
// @ts-expect-error Used in testing
|
|
675
|
-
amfModel[key] = {}
|
|
676
|
-
assert.isUndefined(element._computeApi(amfModel))
|
|
677
|
-
})
|
|
678
|
-
})
|
|
679
|
-
|
|
680
|
-
test.group('_computeApi() / WebAPI', (group) => {
|
|
681
|
-
let model: IAmfDocument
|
|
682
|
-
let asyncModel: IAmfDocument
|
|
683
|
-
|
|
684
|
-
group.setup(async () => {
|
|
685
|
-
model = await loader.getGraph(helperApiApi)
|
|
686
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
687
|
-
})
|
|
688
|
-
|
|
689
|
-
let element: Helper
|
|
690
|
-
group.each.setup(() => {
|
|
691
|
-
element = new Helper()
|
|
692
|
-
element.amf = model
|
|
693
|
-
})
|
|
694
|
-
|
|
695
|
-
test('should return encodes node from AMF model', ({ assert }) => {
|
|
696
|
-
const result = element._computeApi(asyncModel)
|
|
697
|
-
assert.typeOf(result, 'object')
|
|
698
|
-
})
|
|
699
|
-
|
|
700
|
-
test('should return encodes if API type is missing but WebAPI type is present', ({ assert }) => {
|
|
701
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.document.encodes)
|
|
702
|
-
const webApiKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.WebAPI)
|
|
703
|
-
const amfModel = {
|
|
704
|
-
'@id': 'amf://1',
|
|
705
|
-
'@type': ['test'],
|
|
706
|
-
}
|
|
707
|
-
// @ts-expect-error Used in testing
|
|
708
|
-
amfModel[key] = {
|
|
709
|
-
'@type': [webApiKey],
|
|
710
|
-
}
|
|
711
|
-
assert.typeOf(element._computeApi(amfModel), 'object')
|
|
712
|
-
})
|
|
713
|
-
})
|
|
714
|
-
|
|
715
|
-
test.group('_computeApi() / AsyncAPI', (group) => {
|
|
716
|
-
let asyncModel: IAmfDocument
|
|
717
|
-
|
|
718
|
-
group.setup(async () => {
|
|
719
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
720
|
-
})
|
|
721
|
-
|
|
722
|
-
let element: Helper
|
|
723
|
-
group.each.setup(() => {
|
|
724
|
-
element = new Helper()
|
|
725
|
-
element.amf = asyncModel
|
|
726
|
-
})
|
|
727
|
-
|
|
728
|
-
test('should return encodes node from AMF model', ({ assert }) => {
|
|
729
|
-
const result = element._computeApi(asyncModel)
|
|
730
|
-
assert.typeOf(result, 'object')
|
|
731
|
-
})
|
|
732
|
-
|
|
733
|
-
test('should return encodes if API type is missing but WebAPI type is present', ({ assert }) => {
|
|
734
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.document.encodes)
|
|
735
|
-
const asyncApiKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.AsyncAPI)
|
|
736
|
-
const amfModel = {
|
|
737
|
-
'@id': 'amf://1',
|
|
738
|
-
'@type': ['test'],
|
|
739
|
-
}
|
|
740
|
-
// @ts-expect-error Used in testing
|
|
741
|
-
amfModel[key] = {
|
|
742
|
-
'@type': [asyncApiKey],
|
|
743
|
-
}
|
|
744
|
-
assert.typeOf(element._computeApi(amfModel), 'object')
|
|
745
|
-
})
|
|
746
|
-
})
|
|
747
|
-
|
|
748
|
-
test.group('_isWebAPI()', (group) => {
|
|
749
|
-
let model: IAmfDocument
|
|
750
|
-
let asyncModel: IAmfDocument
|
|
751
|
-
|
|
752
|
-
group.setup(async () => {
|
|
753
|
-
model = await loader.getGraph(helperApiApi)
|
|
754
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
755
|
-
})
|
|
756
|
-
|
|
757
|
-
test('should return false if no argument', ({ assert }) => {
|
|
758
|
-
const element = new Helper()
|
|
759
|
-
assert.isFalse(element._isWebAPI(undefined))
|
|
760
|
-
})
|
|
761
|
-
|
|
762
|
-
test('should return false if no encodes', ({ assert }) => {
|
|
763
|
-
const element = new Helper()
|
|
764
|
-
assert.isFalse(
|
|
765
|
-
element._isWebAPI({
|
|
766
|
-
'@id': 'amf://1',
|
|
767
|
-
'@type': ['test'],
|
|
768
|
-
})
|
|
769
|
-
)
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
test('should return false for AsyncAPI', async ({ assert }) => {
|
|
773
|
-
const element = new Helper()
|
|
774
|
-
element.amf = asyncModel
|
|
775
|
-
assert.isFalse(element._isWebAPI(asyncModel))
|
|
776
|
-
})
|
|
777
|
-
|
|
778
|
-
test('should return true for WebAPI', async ({ assert }) => {
|
|
779
|
-
const element = new Helper()
|
|
780
|
-
element.amf = model
|
|
781
|
-
assert.isTrue(element._isWebAPI(model))
|
|
782
|
-
})
|
|
783
|
-
})
|
|
784
|
-
|
|
785
|
-
test.group('_isAsyncAPI()', (group) => {
|
|
786
|
-
let model: IAmfDocument
|
|
787
|
-
let asyncModel: IAmfDocument
|
|
788
|
-
|
|
789
|
-
group.setup(async () => {
|
|
790
|
-
model = await loader.getGraph(helperApiApi)
|
|
791
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
792
|
-
})
|
|
793
|
-
|
|
794
|
-
test('should return false if no argument', ({ assert }) => {
|
|
795
|
-
const element = new Helper()
|
|
796
|
-
assert.isFalse(element._isAsyncAPI(undefined))
|
|
797
|
-
})
|
|
798
|
-
|
|
799
|
-
test('should return false if no encodes', ({ assert }) => {
|
|
800
|
-
const element = new Helper()
|
|
801
|
-
assert.isFalse(
|
|
802
|
-
element._isAsyncAPI({
|
|
803
|
-
'@id': 'amf://1',
|
|
804
|
-
'@type': ['test'],
|
|
805
|
-
})
|
|
806
|
-
)
|
|
807
|
-
})
|
|
808
|
-
|
|
809
|
-
test('should return true for AsyncAPI', async ({ assert }) => {
|
|
810
|
-
const element = new Helper()
|
|
811
|
-
element.amf = asyncModel
|
|
812
|
-
assert.isTrue(element._isAsyncAPI(asyncModel))
|
|
813
|
-
})
|
|
814
|
-
|
|
815
|
-
test('should return false for WebAPI', async ({ assert }) => {
|
|
816
|
-
const element = new Helper()
|
|
817
|
-
element.amf = model
|
|
818
|
-
assert.isFalse(element._isAsyncAPI(model))
|
|
819
|
-
})
|
|
820
|
-
})
|
|
821
|
-
|
|
822
|
-
test.group('_isAPI()', (group) => {
|
|
823
|
-
let model: IAmfDocument
|
|
824
|
-
let asyncModel: IAmfDocument
|
|
825
|
-
|
|
826
|
-
group.setup(async () => {
|
|
827
|
-
model = await loader.getGraph(helperApiApi)
|
|
828
|
-
asyncModel = await loader.getGraph(asyncApi)
|
|
829
|
-
})
|
|
830
|
-
|
|
831
|
-
test('should return false if no argument', ({ assert }) => {
|
|
832
|
-
const element = new Helper()
|
|
833
|
-
assert.isFalse(element._isAPI(undefined))
|
|
834
|
-
})
|
|
835
|
-
|
|
836
|
-
test('should return false if no encodes', ({ assert }) => {
|
|
837
|
-
const element = new Helper()
|
|
838
|
-
assert.isFalse(
|
|
839
|
-
element._isAPI({
|
|
840
|
-
'@id': 'amf://1',
|
|
841
|
-
'@type': ['test'],
|
|
842
|
-
})
|
|
843
|
-
)
|
|
844
|
-
})
|
|
845
|
-
|
|
846
|
-
test('should return true for AsyncAPI', async ({ assert }) => {
|
|
847
|
-
const element = new Helper()
|
|
848
|
-
element.amf = asyncModel
|
|
849
|
-
assert.isTrue(element._isAPI(asyncModel))
|
|
850
|
-
})
|
|
851
|
-
|
|
852
|
-
test('should return true for WebAPI', async ({ assert }) => {
|
|
853
|
-
const element = new Helper()
|
|
854
|
-
element.amf = model
|
|
855
|
-
assert.isTrue(element._isAPI(model))
|
|
856
|
-
})
|
|
857
|
-
})
|
|
858
|
-
|
|
859
|
-
test.group('_computeEndpoints()', (group) => {
|
|
860
|
-
let model: IAmfDocument
|
|
861
|
-
let element: Helper
|
|
862
|
-
let webApi: IAmfWebApi
|
|
863
|
-
|
|
864
|
-
group.setup(async () => {
|
|
865
|
-
model = await loader.getGraph(helperApiApi)
|
|
866
|
-
element = new Helper()
|
|
867
|
-
element.amf = model
|
|
868
|
-
webApi = element._computeWebApi(model) as IAmfWebApi
|
|
869
|
-
})
|
|
870
|
-
|
|
871
|
-
test('returns a list of endpoints', ({ assert }) => {
|
|
872
|
-
const result = element._computeEndpoints(webApi) as IAmfEndPoint[]
|
|
873
|
-
assert.typeOf(result, 'array')
|
|
874
|
-
assert.isAbove(result.length, 1)
|
|
875
|
-
})
|
|
876
|
-
})
|
|
877
|
-
|
|
878
|
-
test.group('_computeExpects()', (group) => {
|
|
879
|
-
let model: IAmfDocument
|
|
880
|
-
|
|
881
|
-
group.setup(async () => {
|
|
882
|
-
model = await loader.getGraph(helperApiApi)
|
|
883
|
-
})
|
|
884
|
-
|
|
885
|
-
let element: Helper
|
|
886
|
-
let operation: IAmfOperation
|
|
887
|
-
let noExpectsOperation: IAmfOperation
|
|
888
|
-
group.each.setup(() => {
|
|
889
|
-
element = new Helper()
|
|
890
|
-
element.amf = model
|
|
891
|
-
const endpoint = loader.lookupEndpoint(model, '/changes/watch')
|
|
892
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation)
|
|
893
|
-
// @ts-expect-error Used in testing
|
|
894
|
-
operation = endpoint[key][0]
|
|
895
|
-
// @ts-expect-error Used in testing
|
|
896
|
-
noExpectsOperation = endpoint[key][1]
|
|
897
|
-
})
|
|
898
|
-
|
|
899
|
-
test('returns undefined if no argument', ({ assert }) => {
|
|
900
|
-
assert.isUndefined(element._computeExpects(undefined))
|
|
901
|
-
})
|
|
902
|
-
|
|
903
|
-
test('returns undefined if operation does not have "expects"', ({ assert }) => {
|
|
904
|
-
assert.isUndefined(element._computeExpects(noExpectsOperation))
|
|
905
|
-
})
|
|
906
|
-
|
|
907
|
-
test('returns object for an operation', ({ assert }) => {
|
|
908
|
-
const result = element._computeExpects(operation)
|
|
909
|
-
assert.typeOf(result, 'object')
|
|
910
|
-
})
|
|
911
|
-
})
|
|
912
|
-
|
|
913
|
-
test.group('_computeEndpointModel()', (group) => {
|
|
914
|
-
let model: IAmfDocument
|
|
915
|
-
|
|
916
|
-
group.setup(async () => {
|
|
917
|
-
model = await loader.getGraph(helperApiApi)
|
|
918
|
-
})
|
|
919
|
-
|
|
920
|
-
let element: Helper
|
|
921
|
-
let webApi: IAmfWebApi
|
|
922
|
-
group.each.setup(() => {
|
|
923
|
-
element = new Helper()
|
|
924
|
-
element.amf = model
|
|
925
|
-
webApi = element._computeWebApi(model) as IAmfWebApi
|
|
926
|
-
})
|
|
927
|
-
|
|
928
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
929
|
-
assert.isUndefined(element._computeEndpointModel(undefined, undefined))
|
|
930
|
-
})
|
|
931
|
-
|
|
932
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
933
|
-
assert.isUndefined(element._computeEndpointModel(undefined, 'test'))
|
|
934
|
-
})
|
|
935
|
-
|
|
936
|
-
test('returns undefined if no selected argument', ({ assert }) => {
|
|
937
|
-
assert.isUndefined(element._computeEndpointModel(webApi, undefined))
|
|
938
|
-
})
|
|
939
|
-
|
|
940
|
-
test('returns undefined if selection does not exists', ({ assert }) => {
|
|
941
|
-
assert.isUndefined(element._computeEndpointModel(webApi, 'hello'))
|
|
942
|
-
})
|
|
943
|
-
|
|
944
|
-
test('returns object for endpoint', ({ assert }) => {
|
|
945
|
-
const endpoint = loader.lookupEndpoint(model, '/changes/watch')
|
|
946
|
-
const id = endpoint['@id']
|
|
947
|
-
const result = element._computeEndpointModel(webApi, id) as IAmfEndPoint
|
|
948
|
-
assert.typeOf(result, 'object')
|
|
949
|
-
const type = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.EndPoint)
|
|
950
|
-
assert.equal(result['@type'][0], type)
|
|
951
|
-
})
|
|
952
|
-
})
|
|
953
|
-
|
|
954
|
-
test.group('_computeMethodModel()', (group) => {
|
|
955
|
-
let model: IAmfDocument
|
|
956
|
-
|
|
957
|
-
group.setup(async () => {
|
|
958
|
-
model = await loader.getGraph(helperApiApi)
|
|
959
|
-
})
|
|
960
|
-
|
|
961
|
-
let element: Helper
|
|
962
|
-
let webApi: IAmfWebApi
|
|
963
|
-
group.each.setup(() => {
|
|
964
|
-
element = new Helper()
|
|
965
|
-
element.amf = model
|
|
966
|
-
webApi = element._computeWebApi(model) as IAmfWebApi
|
|
967
|
-
})
|
|
968
|
-
|
|
969
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
970
|
-
assert.isUndefined(element._computeMethodModel(undefined, undefined))
|
|
971
|
-
})
|
|
972
|
-
|
|
973
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
974
|
-
assert.isUndefined(element._computeMethodModel(undefined, 'test'))
|
|
975
|
-
})
|
|
976
|
-
|
|
977
|
-
test('returns undefined if no selected argument', ({ assert }) => {
|
|
978
|
-
assert.isUndefined(element._computeMethodModel(webApi, undefined))
|
|
979
|
-
})
|
|
980
|
-
|
|
981
|
-
test('returns undefined if selection does not exists', ({ assert }) => {
|
|
982
|
-
assert.isUndefined(element._computeMethodModel(webApi, 'hello'))
|
|
983
|
-
})
|
|
984
|
-
|
|
985
|
-
test('returns object for an operation', ({ assert }) => {
|
|
986
|
-
const endpoint = loader.lookupEndpoint(model, '/permissionIds/{email}')
|
|
987
|
-
// @ts-expect-error Used in testing
|
|
988
|
-
const operation = endpoint[loader._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation)][0]
|
|
989
|
-
|
|
990
|
-
const result = element._computeMethodModel(webApi, operation['@id']) as IAmfOperation
|
|
991
|
-
assert.typeOf(result, 'object')
|
|
992
|
-
const type = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.Operation)
|
|
993
|
-
assert.equal(result['@type'][0], type)
|
|
994
|
-
})
|
|
995
|
-
})
|
|
996
|
-
|
|
997
|
-
test.group('_computeType()', (group) => {
|
|
998
|
-
let model: IAmfDocument
|
|
999
|
-
|
|
1000
|
-
group.setup(async () => {
|
|
1001
|
-
model = await loader.getGraph(helperApiApi)
|
|
1002
|
-
})
|
|
1003
|
-
|
|
1004
|
-
let element: Helper
|
|
1005
|
-
let references: IAmfDomainElement[]
|
|
1006
|
-
let declares: IAmfDomainElement[]
|
|
1007
|
-
group.each.setup(() => {
|
|
1008
|
-
element = new Helper()
|
|
1009
|
-
element.amf = model
|
|
1010
|
-
declares = element._computeDeclares(model) as IAmfDomainElement[]
|
|
1011
|
-
references = element._computeReferences(model) as IAmfDomainElement[]
|
|
1012
|
-
})
|
|
1013
|
-
|
|
1014
|
-
test('returns undefined if no arguments', ({ assert }) => {
|
|
1015
|
-
assert.isUndefined(element._computeType(undefined, undefined, undefined))
|
|
1016
|
-
})
|
|
1017
|
-
|
|
1018
|
-
test('returns undefined if no model argument', ({ assert }) => {
|
|
1019
|
-
assert.isUndefined(element._computeType(undefined, undefined, 'test'))
|
|
1020
|
-
})
|
|
1021
|
-
|
|
1022
|
-
test('returns undefined if no selected argument', ({ assert }) => {
|
|
1023
|
-
assert.isUndefined(element._computeType(declares, references, undefined))
|
|
1024
|
-
})
|
|
1025
|
-
|
|
1026
|
-
test('returns undefined if selection does not exists', ({ assert }) => {
|
|
1027
|
-
assert.isUndefined(element._computeType(declares, references, 'not-here'))
|
|
1028
|
-
})
|
|
1029
|
-
|
|
1030
|
-
// test('returns type in declarations', ({ assert }) => {
|
|
1031
|
-
// const id = declares[1]['@id']; // Node shape.
|
|
1032
|
-
// const result = element._computeType(declares, undefined, id);
|
|
1033
|
-
// assert.typeOf(result, 'object');
|
|
1034
|
-
// const type = element._getAmfKey(AmfNamespace.w3.shacl.NodeShape);
|
|
1035
|
-
// assert.equal(result['@type'][0], type);
|
|
1036
|
-
// });
|
|
1037
|
-
|
|
1038
|
-
// test('returns type for non-compact id', ({ assert }) => {
|
|
1039
|
-
// if (!compact) {
|
|
1040
|
-
// // This only affects compact model.
|
|
1041
|
-
// return;
|
|
1042
|
-
// }
|
|
1043
|
-
// const id = `amf://id${ declares[1]['@id']}`;
|
|
1044
|
-
// const result = element._computeType(declares, undefined, id);
|
|
1045
|
-
// assert.typeOf(result, 'object');
|
|
1046
|
-
// const type = element._getAmfKey(AmfNamespace.w3.shacl.NodeShape);
|
|
1047
|
-
// assert.equal(result['@type'][0], type);
|
|
1048
|
-
// });
|
|
1049
|
-
|
|
1050
|
-
test('returns type in references (library)', ({ assert }) => {
|
|
1051
|
-
const dKey = element._getAmfKey(AmfNamespace.aml.vocabularies.document.declares)
|
|
1052
|
-
const library = references.find((unit) =>
|
|
1053
|
-
unit['@type'].find((t) => t.indexOf('Module') !== -1)
|
|
1054
|
-
) as IAmfDomainElement
|
|
1055
|
-
// let ref = references[4][dKey][0];
|
|
1056
|
-
// @ts-expect-error Used in testing
|
|
1057
|
-
let ref = library[dKey][0]
|
|
1058
|
-
if (ref instanceof Array) {
|
|
1059
|
-
ref = ref[0]
|
|
1060
|
-
}
|
|
1061
|
-
const id = ref['@id']
|
|
1062
|
-
const result = element._computeType(declares, references, id) as IAmfShape
|
|
1063
|
-
assert.typeOf(result, 'object')
|
|
1064
|
-
const type = element._getAmfKey(AmfNamespace.w3.shacl.NodeShape)
|
|
1065
|
-
assert.equal(result['@type'][0], type)
|
|
1066
|
-
})
|
|
1067
|
-
|
|
1068
|
-
test('returns type in references (library) when no declarations', ({ assert }) => {
|
|
1069
|
-
const dKey = element._getAmfKey(AmfNamespace.aml.vocabularies.document.declares)
|
|
1070
|
-
const library = references.find((unit) =>
|
|
1071
|
-
unit['@type'].find((t) => t.indexOf('Module') !== -1)
|
|
1072
|
-
) as IAmfDomainElement
|
|
1073
|
-
// @ts-expect-error Used in testing
|
|
1074
|
-
let ref = library[dKey][0]
|
|
1075
|
-
if (ref instanceof Array) {
|
|
1076
|
-
ref = ref[0]
|
|
1077
|
-
}
|
|
1078
|
-
const id = ref['@id']
|
|
1079
|
-
const result = element._computeType(undefined, references, id) as IAmfShape
|
|
1080
|
-
assert.typeOf(result, 'object')
|
|
1081
|
-
const type = element._getAmfKey(AmfNamespace.w3.shacl.NodeShape)
|
|
1082
|
-
assert.isTrue(result['@type'].includes(type))
|
|
1083
|
-
})
|
|
1084
|
-
})
|
|
1085
|
-
|
|
1086
|
-
test.group('_getLinkTarget()', (group) => {
|
|
1087
|
-
let model: IAmfDocument
|
|
1088
|
-
|
|
1089
|
-
group.setup(async () => {
|
|
1090
|
-
model = await loader.getGraph(helperApiApi)
|
|
1091
|
-
})
|
|
1092
|
-
|
|
1093
|
-
let element: Helper
|
|
1094
|
-
let schemaId: string
|
|
1095
|
-
let resolved: IAmfDomainElement
|
|
1096
|
-
group.each.setup(() => {
|
|
1097
|
-
element = new Helper()
|
|
1098
|
-
element.amf = model
|
|
1099
|
-
const declares = element._computeDeclares(model) as IAmfDomainElement[]
|
|
1100
|
-
schemaId = declares[0]['@id']
|
|
1101
|
-
resolved = element._getLinkTarget(model, schemaId) as IAmfDomainElement
|
|
1102
|
-
})
|
|
1103
|
-
|
|
1104
|
-
test('computes a reference', ({ assert }) => {
|
|
1105
|
-
assert.typeOf(resolved, 'object')
|
|
1106
|
-
})
|
|
1107
|
-
|
|
1108
|
-
test('resolves a reference', ({ assert }) => {
|
|
1109
|
-
const itemsKey = element._getAmfKey(AmfNamespace.aml.vocabularies.shapes.items)
|
|
1110
|
-
const nameKey = element._getAmfKey(AmfNamespace.aml.vocabularies.core.name)
|
|
1111
|
-
// @ts-expect-error Used in testing
|
|
1112
|
-
const shape = resolved[itemsKey][0]
|
|
1113
|
-
assert.equal(shape[nameKey][0]['@value'], 'Pic')
|
|
1114
|
-
}).skip()
|
|
1115
|
-
|
|
1116
|
-
test('returns undefined when no amf argument', ({ assert }) => {
|
|
1117
|
-
const result = element._getLinkTarget(undefined, undefined)
|
|
1118
|
-
assert.isUndefined(result)
|
|
1119
|
-
})
|
|
1120
|
-
|
|
1121
|
-
test('returns undefined when no id argument', ({ assert }) => {
|
|
1122
|
-
const result = element._getLinkTarget(model, undefined)
|
|
1123
|
-
assert.isUndefined(result)
|
|
1124
|
-
})
|
|
1125
|
-
|
|
1126
|
-
test('returns undefined when id is not found', ({ assert }) => {
|
|
1127
|
-
const result = element._getLinkTarget(model, 'other-test')
|
|
1128
|
-
assert.isUndefined(result)
|
|
1129
|
-
})
|
|
1130
|
-
})
|
|
1131
|
-
|
|
1132
|
-
test.group('_getReferenceId()', (group) => {
|
|
1133
|
-
let model: IAmfDocument
|
|
1134
|
-
|
|
1135
|
-
group.setup(async () => {
|
|
1136
|
-
model = await loader.getGraph(helperApiApi)
|
|
1137
|
-
})
|
|
1138
|
-
|
|
1139
|
-
let element: Helper
|
|
1140
|
-
let refId: string
|
|
1141
|
-
group.each.setup(() => {
|
|
1142
|
-
element = new Helper()
|
|
1143
|
-
element.amf = model
|
|
1144
|
-
const refs = element._computeReferences(model) as IAmfDomainElement[]
|
|
1145
|
-
const ref = refs.find((unit) =>
|
|
1146
|
-
(unit['@type'] || []).find((t) => t.indexOf('ExternalFragment') !== -1)
|
|
1147
|
-
) as IAmfDomainElement
|
|
1148
|
-
const enc = element._computeEncodes(ref) as IAmfDomainElement
|
|
1149
|
-
refId = enc['@id']
|
|
1150
|
-
})
|
|
1151
|
-
|
|
1152
|
-
test('computes a reference', ({ assert }) => {
|
|
1153
|
-
const result = element._getReferenceId(model, refId) as IAmfDomainElement
|
|
1154
|
-
assert.typeOf(result, 'object')
|
|
1155
|
-
const type = element._getAmfKey(AmfNamespace.aml.vocabularies.document.ExternalDomainElement)
|
|
1156
|
-
assert.equal(result['@type'][0], type)
|
|
1157
|
-
})
|
|
1158
|
-
|
|
1159
|
-
test('returns undefined when no amf argument', ({ assert }) => {
|
|
1160
|
-
const result = element._getReferenceId(undefined, undefined)
|
|
1161
|
-
assert.isUndefined(result)
|
|
1162
|
-
})
|
|
1163
|
-
|
|
1164
|
-
test('returns undefined when no id argument', ({ assert }) => {
|
|
1165
|
-
const result = element._getReferenceId(model, undefined)
|
|
1166
|
-
assert.isUndefined(result)
|
|
1167
|
-
})
|
|
1168
|
-
|
|
1169
|
-
test('returns undefined when no references in the model', ({ assert }) => {
|
|
1170
|
-
const result = element._getReferenceId(
|
|
1171
|
-
{
|
|
1172
|
-
'@id': 'amf://1',
|
|
1173
|
-
'@type': ['test'],
|
|
1174
|
-
},
|
|
1175
|
-
undefined
|
|
1176
|
-
)
|
|
1177
|
-
assert.isUndefined(result)
|
|
1178
|
-
})
|
|
1179
|
-
})
|
|
1180
|
-
|
|
1181
|
-
test.group('_resolve()', (group) => {
|
|
1182
|
-
let model: IAmfDocument
|
|
1183
|
-
|
|
1184
|
-
group.setup(async () => {
|
|
1185
|
-
model = await loader.getGraph(helperApiApi)
|
|
1186
|
-
})
|
|
1187
|
-
|
|
1188
|
-
let element: Helper
|
|
1189
|
-
group.each.setup(() => {
|
|
1190
|
-
element = new Helper()
|
|
1191
|
-
element.amf = model
|
|
1192
|
-
})
|
|
1193
|
-
|
|
1194
|
-
test('resolves link target', ({ assert }) => {
|
|
1195
|
-
const endpoint = loader.lookupEndpoint(model, '/referenceId')
|
|
1196
|
-
const opKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation)
|
|
1197
|
-
const exKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.expects)
|
|
1198
|
-
const plKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.payload)
|
|
1199
|
-
const scKey = element._getAmfKey(AmfNamespace.aml.vocabularies.shapes.schema)
|
|
1200
|
-
const nameKey = element._getAmfKey(AmfNamespace.w3.shacl.name)
|
|
1201
|
-
// @ts-expect-error Used in testing
|
|
1202
|
-
const op = (element._ensureArray(endpoint[opKey]) as IAmfEndPoint[])[0]
|
|
1203
|
-
// @ts-expect-error Used in testing
|
|
1204
|
-
const expects = (element._ensureArray(op[exKey]) as IAmfEndPoint[])[0]
|
|
1205
|
-
// @ts-expect-error Used in testing
|
|
1206
|
-
const payload = (element._ensureArray(expects[plKey]) as IAmfEndPoint[])[0]
|
|
1207
|
-
// @ts-expect-error Used in testing
|
|
1208
|
-
const schema = (element._ensureArray(payload[scKey]) as IAmfEndPoint[])[0]
|
|
1209
|
-
const result = element._resolve(schema)
|
|
1210
|
-
assert.typeOf(result[nameKey], 'array')
|
|
1211
|
-
})
|
|
1212
|
-
|
|
1213
|
-
test('resolves link target for external fragment', ({ assert }) => {
|
|
1214
|
-
const endpoint = loader.lookupEndpoint(model, '/external-data-type')
|
|
1215
|
-
const opKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.supportedOperation)
|
|
1216
|
-
const exKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.expects)
|
|
1217
|
-
const plKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.payload)
|
|
1218
|
-
const scKey = element._getAmfKey(AmfNamespace.aml.vocabularies.shapes.schema)
|
|
1219
|
-
const nameKey = element._getAmfKey(AmfNamespace.w3.shacl.name)
|
|
1220
|
-
// @ts-expect-error Used in testing
|
|
1221
|
-
const op = (element._ensureArray(endpoint[opKey]) as IAmfEndPoint[])[0]
|
|
1222
|
-
// @ts-expect-error Used in testing
|
|
1223
|
-
const expects = (element._ensureArray(op[exKey]) as IAmfEndPoint[])[0]
|
|
1224
|
-
// @ts-expect-error Used in testing
|
|
1225
|
-
const payload = (element._ensureArray(expects[plKey]) as IAmfEndPoint[])[0]
|
|
1226
|
-
// @ts-expect-error Used in testing
|
|
1227
|
-
const schema = (element._ensureArray(payload[scKey]) as IAmfEndPoint[])[0]
|
|
1228
|
-
const result = element._resolve(schema)
|
|
1229
|
-
assert.typeOf(result[nameKey], 'array')
|
|
1230
|
-
})
|
|
1231
|
-
})
|
|
1232
|
-
|
|
1233
|
-
test.group('_computeDocument()', (group) => {
|
|
1234
|
-
let model: IAmfDocument
|
|
1235
|
-
|
|
1236
|
-
group.setup(async () => {
|
|
1237
|
-
model = await loader.getGraph(helperApiApi)
|
|
1238
|
-
})
|
|
1239
|
-
|
|
1240
|
-
let element: Helper
|
|
1241
|
-
let obj: IAmfDomainElement
|
|
1242
|
-
group.each.setup(() => {
|
|
1243
|
-
element = new Helper()
|
|
1244
|
-
element.amf = model
|
|
1245
|
-
const key = element._getAmfKey(AmfNamespace.aml.vocabularies.core.documentation)
|
|
1246
|
-
// @ts-expect-error Used in testing
|
|
1247
|
-
obj = {}
|
|
1248
|
-
// @ts-expect-error Used in testing
|
|
1249
|
-
obj[key] = [
|
|
1250
|
-
{
|
|
1251
|
-
'@id': 'a',
|
|
1252
|
-
},
|
|
1253
|
-
]
|
|
1254
|
-
})
|
|
1255
|
-
|
|
1256
|
-
test('returns undefined when no webApi', ({ assert }) => {
|
|
1257
|
-
const result = element._computeDocument(undefined, undefined)
|
|
1258
|
-
assert.isUndefined(result)
|
|
1259
|
-
})
|
|
1260
|
-
|
|
1261
|
-
test('returns undefined when no id', ({ assert }) => {
|
|
1262
|
-
const result = element._computeDocument(obj, undefined)
|
|
1263
|
-
assert.isUndefined(result)
|
|
1264
|
-
})
|
|
1265
|
-
|
|
1266
|
-
test('returns undefined when id not found', ({ assert }) => {
|
|
1267
|
-
const result = element._computeDocument(obj, 'b')
|
|
1268
|
-
assert.isUndefined(result)
|
|
1269
|
-
})
|
|
1270
|
-
|
|
1271
|
-
test('returns undefined when no documents key', ({ assert }) => {
|
|
1272
|
-
const result = element._computeDocument(
|
|
1273
|
-
{
|
|
1274
|
-
'@id': 'amf://1',
|
|
1275
|
-
'@type': ['test'],
|
|
1276
|
-
},
|
|
1277
|
-
'b'
|
|
1278
|
-
)
|
|
1279
|
-
assert.isUndefined(result)
|
|
1280
|
-
})
|
|
1281
|
-
|
|
1282
|
-
test('returns model for id', ({ assert }) => {
|
|
1283
|
-
const result = element._computeDocument(obj, 'a')
|
|
1284
|
-
assert.typeOf(result, 'object')
|
|
1285
|
-
})
|
|
1286
|
-
})
|
|
1287
|
-
|
|
1288
|
-
test.group('_computeApiVersion()', (group) => {
|
|
1289
|
-
let model: IAmfDocument
|
|
1290
|
-
|
|
1291
|
-
group.setup(async () => {
|
|
1292
|
-
model = await loader.getGraph(helperApiApi)
|
|
1293
|
-
})
|
|
1294
|
-
|
|
1295
|
-
let element: Helper
|
|
1296
|
-
group.each.setup(() => {
|
|
1297
|
-
element = new Helper()
|
|
1298
|
-
element.amf = model
|
|
1299
|
-
})
|
|
1300
|
-
|
|
1301
|
-
test('Computes version of the API', ({ assert }) => {
|
|
1302
|
-
const result = element._computeApiVersion(model)
|
|
1303
|
-
assert.equal(result, 'v2')
|
|
1304
|
-
})
|
|
1305
|
-
|
|
1306
|
-
test('returns undefined when no WebApi', ({ assert }) => {
|
|
1307
|
-
const result = element._computeApiVersion({
|
|
1308
|
-
'@id': 'amf://1',
|
|
1309
|
-
'@type': ['test'],
|
|
1310
|
-
})
|
|
1311
|
-
assert.isUndefined(result)
|
|
1312
|
-
})
|
|
1313
|
-
})
|
|
1314
|
-
|
|
1315
|
-
test.group('_ensureArray()', (group) => {
|
|
1316
|
-
let model: IAmfDocument
|
|
1317
|
-
|
|
1318
|
-
group.setup(async () => {
|
|
1319
|
-
model = await loader.getGraph(helperApiApi)
|
|
1320
|
-
})
|
|
1321
|
-
|
|
1322
|
-
let element: Helper
|
|
1323
|
-
group.each.setup(() => {
|
|
1324
|
-
element = new Helper()
|
|
1325
|
-
element.amf = model
|
|
1326
|
-
})
|
|
1327
|
-
|
|
1328
|
-
test('returns undefined when no argument', ({ assert }) => {
|
|
1329
|
-
const result = element._ensureArray(undefined)
|
|
1330
|
-
assert.isUndefined(result)
|
|
1331
|
-
})
|
|
1332
|
-
|
|
1333
|
-
test('returns the same array', ({ assert }) => {
|
|
1334
|
-
const arr = ['a']
|
|
1335
|
-
const result = element._ensureArray(arr)
|
|
1336
|
-
assert.isTrue(result === arr)
|
|
1337
|
-
})
|
|
1338
|
-
|
|
1339
|
-
test('returns array value from not array argument', ({ assert }) => {
|
|
1340
|
-
const arr = 'a'
|
|
1341
|
-
const result = element._ensureArray(arr)
|
|
1342
|
-
assert.deepEqual(result, ['a'])
|
|
1343
|
-
})
|
|
1344
|
-
})
|
|
1345
|
-
|
|
1346
|
-
test.group('_findById()', (group) => {
|
|
1347
|
-
let model: IAmfDocument
|
|
1348
|
-
|
|
1349
|
-
group.setup(async () => {
|
|
1350
|
-
model = await loader.getGraph(helperApiApi)
|
|
1351
|
-
})
|
|
1352
|
-
|
|
1353
|
-
let element: Helper
|
|
1354
|
-
group.each.setup(() => {
|
|
1355
|
-
element = new Helper()
|
|
1356
|
-
element.amf = model
|
|
1357
|
-
})
|
|
1358
|
-
|
|
1359
|
-
test('Returns undefined when no argument', ({ assert }) => {
|
|
1360
|
-
const result = element._findById(undefined, undefined)
|
|
1361
|
-
assert.isUndefined(result)
|
|
1362
|
-
})
|
|
1363
|
-
|
|
1364
|
-
test('Returns undefined when array does not contain id', ({ assert }) => {
|
|
1365
|
-
const arr = [
|
|
1366
|
-
{ '@id': '1', '@type': ['test'] },
|
|
1367
|
-
{ '@id': '2', '@type': ['test'] },
|
|
1368
|
-
{ '@id': '3', '@type': ['test'] },
|
|
1369
|
-
]
|
|
1370
|
-
const result = element._findById(arr, '0')
|
|
1371
|
-
assert.isUndefined(result)
|
|
1372
|
-
})
|
|
1373
|
-
|
|
1374
|
-
test('Returns object when array contains id', ({ assert }) => {
|
|
1375
|
-
const arr = [
|
|
1376
|
-
{ '@id': '1', '@type': ['test'] },
|
|
1377
|
-
{ '@id': '2', '@type': ['test'] },
|
|
1378
|
-
{ '@id': '3', '@type': ['test'] },
|
|
1379
|
-
]
|
|
1380
|
-
const result = element._findById(arr, '1')
|
|
1381
|
-
assert.deepEqual(result, { '@id': '1', '@type': ['test'] })
|
|
1382
|
-
})
|
|
1383
|
-
})
|
|
1384
|
-
|
|
1385
|
-
test.group('_isValidServerPartial() / with mock objects / not in arrays', (group) => {
|
|
1386
|
-
let model: IAmfDocument
|
|
1387
|
-
let element: Helper
|
|
1388
|
-
|
|
1389
|
-
group.setup(async () => {
|
|
1390
|
-
model = await loader.getGraph(helperApiApi)
|
|
1391
|
-
})
|
|
1392
|
-
|
|
1393
|
-
group.each.setup(() => {
|
|
1394
|
-
element = new Helper()
|
|
1395
|
-
element.amf = model
|
|
1396
|
-
})
|
|
1397
|
-
|
|
1398
|
-
test('should return true for endpoint type', ({ assert }) => {
|
|
1399
|
-
const endpointKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.EndPoint)
|
|
1400
|
-
const shape = { '@type': [endpointKey] } as IAmfDomainElement
|
|
1401
|
-
assert.isTrue(element._isValidServerPartial(shape))
|
|
1402
|
-
})
|
|
1403
|
-
|
|
1404
|
-
test('should return true for method type', ({ assert }) => {
|
|
1405
|
-
const methodKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.Operation)
|
|
1406
|
-
const shape = { '@type': [methodKey] } as IAmfDomainElement
|
|
1407
|
-
assert.isTrue(element._isValidServerPartial(shape))
|
|
1408
|
-
})
|
|
1409
|
-
|
|
1410
|
-
test('should return false for any other type', ({ assert }) => {
|
|
1411
|
-
const otherKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.WebAPI)
|
|
1412
|
-
const shape = { '@type': [otherKey] } as IAmfDomainElement
|
|
1413
|
-
assert.isFalse(element._isValidServerPartial(shape))
|
|
1414
|
-
})
|
|
1415
|
-
})
|
|
1416
|
-
|
|
1417
|
-
test.group('_isValidServerPartial() / with mock objects / in arrays', (group) => {
|
|
1418
|
-
let model: IAmfDocument
|
|
1419
|
-
|
|
1420
|
-
group.setup(async () => {
|
|
1421
|
-
model = await loader.getGraph(helperApiApi)
|
|
1422
|
-
})
|
|
1423
|
-
|
|
1424
|
-
let element: Helper
|
|
1425
|
-
group.each.setup(() => {
|
|
1426
|
-
element = new Helper()
|
|
1427
|
-
element.amf = model
|
|
1428
|
-
})
|
|
1429
|
-
|
|
1430
|
-
test('should return true for endpoint type', ({ assert }) => {
|
|
1431
|
-
const endpointKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.EndPoint)
|
|
1432
|
-
const shape = { '@type': [endpointKey] } as IAmfDomainElement
|
|
1433
|
-
assert.isTrue(element._isValidServerPartial([shape]))
|
|
1434
|
-
})
|
|
1435
|
-
|
|
1436
|
-
test('should return true for method type', ({ assert }) => {
|
|
1437
|
-
const methodKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.Operation)
|
|
1438
|
-
const shape = { '@type': [methodKey] } as IAmfDomainElement
|
|
1439
|
-
assert.isTrue(element._isValidServerPartial([shape]))
|
|
1440
|
-
})
|
|
1441
|
-
|
|
1442
|
-
test('should return false for any other type', ({ assert }) => {
|
|
1443
|
-
const otherKey = element._getAmfKey(AmfNamespace.aml.vocabularies.apiContract.WebAPI)
|
|
1444
|
-
const shape = { '@type': [otherKey] } as IAmfDomainElement
|
|
1445
|
-
assert.isFalse(element._isValidServerPartial([shape]))
|
|
1446
|
-
})
|
|
1447
|
-
})
|
|
1448
|
-
|
|
1449
|
-
test.group('_isValidServerPartial() with real nodes', (group) => {
|
|
1450
|
-
let model: IAmfDocument
|
|
1451
|
-
|
|
1452
|
-
group.setup(async () => {
|
|
1453
|
-
model = await loader.getGraph(helperApiApi)
|
|
1454
|
-
})
|
|
1455
|
-
|
|
1456
|
-
let element: Helper
|
|
1457
|
-
group.each.setup(() => {
|
|
1458
|
-
element = new Helper()
|
|
1459
|
-
element.amf = model
|
|
1460
|
-
})
|
|
1461
|
-
|
|
1462
|
-
test('should return true for endpoint type', ({ assert }) => {
|
|
1463
|
-
const endpoint = loader.lookupEndpoint(model, '/files')
|
|
1464
|
-
assert.isTrue(element._isValidServerPartial(endpoint))
|
|
1465
|
-
})
|
|
1466
|
-
|
|
1467
|
-
test('should return true for method type', ({ assert }) => {
|
|
1468
|
-
const method = loader.lookupOperation(model, '/files', 'get')
|
|
1469
|
-
assert.isTrue(element._isValidServerPartial(method))
|
|
1470
|
-
})
|
|
1471
|
-
|
|
1472
|
-
test('should return false for any other type', ({ assert }) => {
|
|
1473
|
-
assert.isFalse(element._isValidServerPartial(model))
|
|
1474
|
-
})
|
|
1475
|
-
})
|
|
1476
|
-
|
|
1477
|
-
test.group('_mergeShapes()', (group) => {
|
|
1478
|
-
let model: IAmfDocument
|
|
1479
|
-
let sourcesKey: string
|
|
1480
|
-
let element: Helper
|
|
1481
|
-
|
|
1482
|
-
group.setup(async () => {
|
|
1483
|
-
model = await loader.getGraph(helperApiApi)
|
|
1484
|
-
})
|
|
1485
|
-
|
|
1486
|
-
group.each.setup(() => {
|
|
1487
|
-
element = new Helper()
|
|
1488
|
-
element.amf = model
|
|
1489
|
-
sourcesKey = element._getAmfKey(AmfNamespace.aml.vocabularies.docSourceMaps.sources)
|
|
1490
|
-
})
|
|
1491
|
-
|
|
1492
|
-
test('should merge two objects together', ({ assert }) => {
|
|
1493
|
-
const a = { foo: 'foo', a: 1 }
|
|
1494
|
-
const b = { bar: 'bar', a: 2, b: 3 }
|
|
1495
|
-
const merged = element._mergeShapes(a, b)
|
|
1496
|
-
assert.deepEqual(merged, { foo: 'foo', bar: 'bar', a: 2, b: 3 })
|
|
1497
|
-
})
|
|
1498
|
-
|
|
1499
|
-
test('should merge sources from both nodes', ({ assert }) => {
|
|
1500
|
-
const a = { foo: 'foo', a: 1, [sourcesKey]: [{ s1: 1, s2: 2 }] }
|
|
1501
|
-
const b = { bar: 'bar', a: 2, b: 3, [sourcesKey]: [{ s2: 20, s3: 30 }] }
|
|
1502
|
-
const merged = element._mergeShapes(a, b)
|
|
1503
|
-
assert.deepEqual(merged, {
|
|
1504
|
-
foo: 'foo',
|
|
1505
|
-
bar: 'bar',
|
|
1506
|
-
a: 2,
|
|
1507
|
-
b: 3,
|
|
1508
|
-
[sourcesKey]: [{ s1: 1, s2: 20, s3: 30 }],
|
|
1509
|
-
})
|
|
1510
|
-
})
|
|
1511
|
-
})
|
|
1512
|
-
|
|
1513
|
-
test.group('special merges / _mergeSourceMapsSources()', (group) => {
|
|
1514
|
-
let model: IAmfDocument
|
|
1515
|
-
let element: Helper
|
|
1516
|
-
let sourcesKey: string
|
|
1517
|
-
|
|
1518
|
-
group.setup(async () => {
|
|
1519
|
-
model = await loader.getGraph(helperApiApi)
|
|
1520
|
-
})
|
|
1521
|
-
|
|
1522
|
-
group.each.setup(() => {
|
|
1523
|
-
element = new Helper()
|
|
1524
|
-
element.amf = model
|
|
1525
|
-
sourcesKey = element._getAmfKey(AmfNamespace.aml.vocabularies.docSourceMaps.sources)
|
|
1526
|
-
})
|
|
1527
|
-
|
|
1528
|
-
test('should merge sources from both nodes', ({ assert }) => {
|
|
1529
|
-
const a = { foo: 'foo', a: 1, [sourcesKey]: [{ s1: 1, s2: 2 }] }
|
|
1530
|
-
const b = { bar: 'bar', a: 2, b: 3, [sourcesKey]: [{ s2: 20, s3: 30 }] }
|
|
1531
|
-
const result = element._mergeSourceMapsSources(a, b)
|
|
1532
|
-
assert.deepEqual(result, [{ s1: 1, s2: 20, s3: 30 }])
|
|
1533
|
-
})
|
|
1534
|
-
|
|
1535
|
-
test('should merge nodes when only A has sources', ({ assert }) => {
|
|
1536
|
-
const a = { foo: 'foo', a: 1, [sourcesKey]: [{ s2: 20, s3: 30 }] }
|
|
1537
|
-
const b = { bar: 'bar', a: 2, b: 3 }
|
|
1538
|
-
const merged = element._mergeSourceMapsSources(a, b)
|
|
1539
|
-
assert.deepEqual(merged, [{ s2: 20, s3: 30 }])
|
|
1540
|
-
})
|
|
1541
|
-
|
|
1542
|
-
test('should merge nodes when only B has sources', ({ assert }) => {
|
|
1543
|
-
const a = { foo: 'foo', a: 1 }
|
|
1544
|
-
const b = { bar: 'bar', a: 2, b: 3, [sourcesKey]: [{ s2: 20, s3: 30 }] }
|
|
1545
|
-
const merged = element._mergeSourceMapsSources(a, b)
|
|
1546
|
-
assert.deepEqual(merged, [{ s2: 20, s3: 30 }])
|
|
1547
|
-
})
|
|
1548
|
-
|
|
1549
|
-
test('should return empty object when neither node has sources', ({ assert }) => {
|
|
1550
|
-
const a = { foo: 'foo', a: 1 }
|
|
1551
|
-
const b = { bar: 'bar', a: 2, b: 3 }
|
|
1552
|
-
const merged = element._mergeSourceMapsSources(a, b)
|
|
1553
|
-
assert.deepEqual(merged, [{}])
|
|
1554
|
-
})
|
|
1555
|
-
})
|
|
1556
|
-
|
|
1557
|
-
test.group('keys computation caching', (group) => {
|
|
1558
|
-
let model: IAmfDocument
|
|
1559
|
-
|
|
1560
|
-
group.setup(async () => {
|
|
1561
|
-
model = await loader.getGraph(helperApiApi)
|
|
1562
|
-
})
|
|
1563
|
-
|
|
1564
|
-
let element: Helper
|
|
1565
|
-
group.each.setup(() => {
|
|
1566
|
-
element = new Helper()
|
|
1567
|
-
element.amf = model
|
|
1568
|
-
})
|
|
1569
|
-
|
|
1570
|
-
test('caches a key value', ({ assert }) => {
|
|
1571
|
-
const prop = AmfNamespace.aml.vocabularies.document.encodes
|
|
1572
|
-
const key = element._getAmfKey(prop)
|
|
1573
|
-
// @ts-expect-error Used in testing
|
|
1574
|
-
assert.equal(element.__cachedKeys[prop], key)
|
|
1575
|
-
})
|
|
1576
|
-
|
|
1577
|
-
test('returns the same value', ({ assert }) => {
|
|
1578
|
-
const prop = AmfNamespace.aml.vocabularies.document.encodes
|
|
1579
|
-
const key1 = element._getAmfKey(prop)
|
|
1580
|
-
const key2 = element._getAmfKey(prop)
|
|
1581
|
-
assert.equal(key1, key2)
|
|
1582
|
-
})
|
|
1583
|
-
|
|
1584
|
-
test('uses cached value', ({ assert }) => {
|
|
1585
|
-
const prop = AmfNamespace.aml.vocabularies.document.encodes
|
|
1586
|
-
element._getAmfKey(prop)
|
|
1587
|
-
// @ts-expect-error Used in testing
|
|
1588
|
-
element.__cachedKeys[prop] = 'test'
|
|
1589
|
-
const key = element._getAmfKey(prop)
|
|
1590
|
-
assert.equal(key, 'test')
|
|
1591
|
-
})
|
|
1592
|
-
|
|
1593
|
-
test('resets cache when AMF changes', ({ assert }) => {
|
|
1594
|
-
const prop = AmfNamespace.aml.vocabularies.document.encodes
|
|
1595
|
-
element._getAmfKey(prop)
|
|
1596
|
-
element.amf = undefined
|
|
1597
|
-
// @ts-expect-error Used in testing
|
|
1598
|
-
assert.deepEqual(element.__cachedKeys, {})
|
|
1599
|
-
})
|
|
1600
|
-
})
|
|
1601
|
-
|
|
1602
|
-
test.group('_getServers() / RAML', (group) => {
|
|
1603
|
-
let model: IAmfDocument
|
|
1604
|
-
let element: Helper
|
|
1605
|
-
|
|
1606
|
-
group.setup(async () => {
|
|
1607
|
-
model = await loader.getGraph('amf-helper-api')
|
|
1608
|
-
})
|
|
1609
|
-
|
|
1610
|
-
group.each.setup(() => {
|
|
1611
|
-
element = new Helper()
|
|
1612
|
-
element.amf = model
|
|
1613
|
-
})
|
|
1614
|
-
|
|
1615
|
-
test('Returns all servers', ({ assert }) => {
|
|
1616
|
-
const servers = element._getServers({}) as IAmfServer[]
|
|
1617
|
-
assert.typeOf(servers, 'array')
|
|
1618
|
-
assert.lengthOf(servers, 1)
|
|
1619
|
-
})
|
|
1620
|
-
})
|
|
1621
|
-
|
|
1622
|
-
test.group('_getServers() / OAS / for operation', (group) => {
|
|
1623
|
-
let methodId: string
|
|
1624
|
-
// TODO uncomment this once AMF model has resolved servers on all levels
|
|
1625
|
-
// const endpointId = `${compact ? '' : 'amf://id'}#22`;
|
|
1626
|
-
|
|
1627
|
-
let localModel: IAmfDocument
|
|
1628
|
-
let element: Helper
|
|
1629
|
-
group.setup(async () => {
|
|
1630
|
-
localModel = await loader.getGraph('multiple-servers')
|
|
1631
|
-
methodId = loader.lookupOperation(localModel, '/pets', 'get')['@id']
|
|
1632
|
-
})
|
|
1633
|
-
|
|
1634
|
-
group.each.setup(() => {
|
|
1635
|
-
element = new Helper()
|
|
1636
|
-
element.amf = localModel
|
|
1637
|
-
})
|
|
1638
|
-
|
|
1639
|
-
test('Returns all servers for method', ({ assert }) => {
|
|
1640
|
-
const servers = element._getServers({ methodId }) as IAmfServer[]
|
|
1641
|
-
assert.typeOf(servers, 'array')
|
|
1642
|
-
assert.lengthOf(servers, 2)
|
|
1643
|
-
})
|
|
1644
|
-
|
|
1645
|
-
test('Returns all root servers if method not found and endpoint undefined', ({ assert }) => {
|
|
1646
|
-
const servers = element._getServers({ methodId: 'foo' }) as IAmfServer[]
|
|
1647
|
-
assert.typeOf(servers, 'array')
|
|
1648
|
-
assert.lengthOf(servers, 2)
|
|
1649
|
-
})
|
|
1650
|
-
|
|
1651
|
-
// TODO uncomment this once AMF model has resolved servers on all levels
|
|
1652
|
-
/* test('Returns all endpoint servers if method not found and endpoint is defined', ({ assert }) => {
|
|
1653
|
-
const servers = element._getServers({ model, methodId: 'foo', endpointId });
|
|
1654
|
-
assert.typeOf(servers, 'array');
|
|
1655
|
-
assert.lengthOf(servers, 2);
|
|
1656
|
-
}); */
|
|
1657
|
-
|
|
1658
|
-
test('Returns undefined if no model', async ({ assert }) => {
|
|
1659
|
-
const localElement = new Helper()
|
|
1660
|
-
assert.isUndefined(localElement._getServers({}))
|
|
1661
|
-
})
|
|
1662
|
-
|
|
1663
|
-
test('Returns all method servers for partial model', ({ assert }) => {
|
|
1664
|
-
const operation = { ...loader.lookupOperation(localModel, '/pets', 'get') }
|
|
1665
|
-
operation['@context'] = localModel['@context']
|
|
1666
|
-
element.amf = operation
|
|
1667
|
-
const servers = element._getServers({ methodId }) as IAmfServer[]
|
|
1668
|
-
assert.typeOf(servers, 'array')
|
|
1669
|
-
assert.lengthOf(servers, 2)
|
|
1670
|
-
})
|
|
1671
|
-
})
|
|
1672
|
-
|
|
1673
|
-
test.group('Expander', async (group) => {
|
|
1674
|
-
let localElement: Helper
|
|
1675
|
-
const flattenedApi = 'flattened-api'
|
|
1676
|
-
const expandedApi = 'expanded-api'
|
|
1677
|
-
let flattenedModel: IAmfDocument
|
|
1678
|
-
let expandedModel: IAmfDocument
|
|
1679
|
-
|
|
1680
|
-
group.setup(async () => {
|
|
1681
|
-
flattenedModel = await loader.getGraph(flattenedApi, { noExpand: true })
|
|
1682
|
-
expandedModel = await loader.getGraph(expandedApi, { noExpand: true })
|
|
1683
|
-
})
|
|
1684
|
-
|
|
1685
|
-
group.each.setup(async () => {
|
|
1686
|
-
localElement = new Helper()
|
|
1687
|
-
})
|
|
1688
|
-
|
|
1689
|
-
test('should not call __amfChanged again if same flattened model is set', async ({ assert }) => {
|
|
1690
|
-
localElement.amf = flattenedModel
|
|
1691
|
-
await nextFrame()
|
|
1692
|
-
const spy = sinon.spy(localElement, '_amfChanged')
|
|
1693
|
-
localElement.amf = flattenedModel
|
|
1694
|
-
await nextFrame()
|
|
1695
|
-
assert.isTrue(spy.notCalled)
|
|
1696
|
-
})
|
|
1697
|
-
|
|
1698
|
-
test('should create same object for flattened as original expanded', async ({ assert }) => {
|
|
1699
|
-
const expandedElement = new Helper()
|
|
1700
|
-
expandedElement.amf = expandedModel
|
|
1701
|
-
await nextFrame()
|
|
1702
|
-
localElement.amf = flattenedModel
|
|
1703
|
-
await nextFrame()
|
|
1704
|
-
// @ts-expect-error Used in testing
|
|
1705
|
-
assert.deepEqual(localElement.amf[0], expandedElement.amf[0])
|
|
1706
|
-
})
|
|
1707
|
-
})
|