@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataValueGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/DataValueGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAGxC,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AAExC;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;;OAGG;IACO,SAAS,GAAG,CAAC,CAAA;IACvB;;;OAGG;IACH,MAAM,CAAU,OAAO,GAAG,OAAO,CAAA;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,EAAU,EAAE,IAAwB;QAC3C,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QAChC,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QAC9B,CAAC;QACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QAC9B,CAAC;QACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAA;QAClC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACO,cAAc,CAAC,EAAU;QACjC,QAAQ,EAAE,EAAE,CAAC;YACX,KAAK,QAAQ;gBACX,wEAAwE;gBACxE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;YAClB,KAAK,SAAS;gB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AM,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YACnD,OAAO,GAAG,IAAI,IAAI,MAAM,IAAI,MAAM,EAAE,CAAA;QACtC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;OAKG;IACO,gBAAgB,CAAC,EAAU;QACnC,IAAI,EAAE,KAAK,KAAK,EAAE,CAAC;YACjB,8BAA8B;YAC9B,sDAAsD;YACtD,MAAM,CAAC,GAAG,IAAI,IAAI,EAAE,CAAA;YACpB,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;YAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YACpD,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YAC7C,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YACnD,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;YACnD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,IAAI,IAAI,IAAI,MAAM,IAAI,MAAM,EAAE,CAAA;QAC9D,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { DomainPropertyType } from '../DataFormat.js'\n\nexport const noValue = Symbol('noValue')\n\n/**\n * A class to be used for generating values from pre-defined functions.\n * This is used to provide default values for data properties based on specified functions.\n */\nexport class DataValueGenerator {\n /**\n * The current value for the `number.incremental` function.\n * This counter is incremented each time an incremental number is generated.\n */\n protected increment = 0\n /**\n * A symbol representing the absence of a value.\n * Used as a return value when a function cannot generate a value of the requested type.\n */\n static readonly noValue = noValue\n\n /**\n * Generates a value based on the provided function name and data type.\n * @param fn The name of the function to use for value generation (e.g., 'random', 'uuid-v4', 'incremental').\n * @param type The data type of the value to generate (e.g., 'string', 'number', 'date', 'time', 'datetime').\n * @returns The generated value, or the `noValue` symbol if the function or type is not supported.\n */\n generate(fn: string, type: DomainPropertyType): string | typeof noValue {\n if (type === 'string') {\n return this.generateString(fn)\n }\n if (type === 'number') {\n return this.generateNumber(fn)\n }\n if (type === 'date') {\n return this.generateDate(fn)\n }\n if (type === 'time') {\n return this.generateTime(fn)\n }\n if (type === 'datetime') {\n return this.generateDateTime(fn)\n }\n return noValue\n }\n\n /**\n * Generates a string value based on the function name.\n * @param fn The name of the string generation function.\n * @returns The generated string value, or `noValue` if the function is not supported.\n */\n protected generateString(fn: string): string | typeof noValue {\n switch (fn) {\n case 'random':\n // TODO: we need more settings controlling the random string generation.\n return nanoid(8)\n case 'uuid-v4':\n return crypto.randomUUID()\n default:\n return noValue\n }\n }\n\n /**\n * Generates a number value based on the function name.\n * @param fn The name of the number generation function.\n * @returns The generated number value (as a string), or `noValue` if the function is not supported.\n */\n protected generateNumber(fn: string): string | typeof noValue {\n switch (fn) {\n case 'incremental':\n return `${this.increment++}`\n default:\n return noValue\n }\n }\n\n /**\n * Generates a date value based on the function name.\n * @param fn The name of the date generation function.\n * @returns The generated date value (as a string in YYYY-MM-DD format),\n * or `noValue` if the function is not supported.\n */\n protected generateDate(fn: string): string | typeof noValue {\n if (fn === 'now') {\n // Returns YYYY-MM-DD\n // @TODO: Replace with Temporal when widely available.\n const d = new Date()\n const year = d.getFullYear()\n const month = `${d.getMonth() + 1}`.padStart(2, '0')\n const day = `${d.getDate()}`.padStart(2, '0')\n return `${year}-${month}-${day}`\n }\n return noValue\n }\n\n /**\n * Generates a time value based on the function name.\n * @param fn The name of the time generation function.\n * @returns The generated time value (as a string in HH:mm:ss format), or `noValue` if the function is not supported.\n */\n protected generateTime(fn: string): string | typeof noValue {\n if (fn === 'now') {\n // Returns HH:mm:ss\n // @TODO: Replace with Temporal when widely available.\n const d = new Date()\n const hour = `${d.getHours()}`.padStart(2, '0')\n const minute = `${d.getMinutes()}`.padStart(2, '0')\n const second = `${d.getSeconds()}`.padStart(2, '0')\n return `${hour}:${minute}:${second}`\n }\n return noValue\n }\n\n /**\n * Generates a datetime value based on the function name.\n * @param fn The name of the datetime generation function.\n * @returns The generated datetime value (as a string in YYYY-MM-DDTHH:mm:ss format),\n * or `noValue` if the function is not supported.\n */\n protected generateDateTime(fn: string): string | typeof noValue {\n if (fn === 'now') {\n // Returns YYYY-MM-DDTHH:mm:ss\n // @TODO: Replace with Temporal when widely available.\n const d = new Date()\n const year = d.getFullYear()\n const month = `${d.getMonth() + 1}`.padStart(2, '0')\n const day = `${d.getDate()}`.padStart(2, '0')\n const hour = `${d.getHours()}`.padStart(2, '0')\n const minute = `${d.getMinutes()}`.padStart(2, '0')\n const second = `${d.getSeconds()}`.padStart(2, '0')\n return `${year}-${month}-${day}T${hour}:${minute}:${second}`\n }\n return noValue\n }\n}\n"]}
|
|
@@ -2,8 +2,8 @@ import { type PropertyWebBindings } from '../Bindings.js';
|
|
|
2
2
|
import type { DomainAssociation } from '../DomainAssociation.js';
|
|
3
3
|
import type { DomainProperty } from '../DomainProperty.js';
|
|
4
4
|
import type { DomainEntity } from '../DomainEntity.js';
|
|
5
|
-
import {
|
|
6
|
-
import { DataValueGenerator } from '
|
|
5
|
+
import { type Shapes } from '@api-client/amf-core';
|
|
6
|
+
import { DataValueGenerator } from './DataValueGenerator.js';
|
|
7
7
|
import type { PropertySchema } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)
|
|
@@ -65,7 +65,7 @@ export declare class ShapeGenerator {
|
|
|
65
65
|
* const amfShape = generator.entity(myDomainEntity);
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
entity(input: DomainEntity, visited?: Set<string>): IApiNodeShape | IApiRecursiveShape;
|
|
68
|
+
entity(input: DomainEntity, visited?: Set<string>): Shapes.IApiNodeShape | Shapes.IApiRecursiveShape;
|
|
69
69
|
/**
|
|
70
70
|
* Serializes a `DomainProperty` to an AMF property shape.
|
|
71
71
|
*
|
|
@@ -81,7 +81,7 @@ export declare class ShapeGenerator {
|
|
|
81
81
|
* const amfShape = generator.property(myDomainProperty);
|
|
82
82
|
* ```
|
|
83
83
|
*/
|
|
84
|
-
property(input: DomainProperty): IApiPropertyShape;
|
|
84
|
+
property(input: DomainProperty): Shapes.IApiPropertyShape;
|
|
85
85
|
/**
|
|
86
86
|
* Serializes a `DomainAssociation` to an AMF property shape, handling the
|
|
87
87
|
* association's target entity or entities.
|
|
@@ -102,7 +102,7 @@ export declare class ShapeGenerator {
|
|
|
102
102
|
* const amfShape = generator.associationProperty(myDomainAssociation);
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
associationProperty(input: DomainAssociation, visited?: Set<string>): IApiPropertyShape;
|
|
105
|
+
associationProperty(input: DomainAssociation, visited?: Set<string>): Shapes.IApiPropertyShape;
|
|
106
106
|
/**
|
|
107
107
|
* Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.
|
|
108
108
|
*
|
|
@@ -111,20 +111,20 @@ export declare class ShapeGenerator {
|
|
|
111
111
|
* recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.
|
|
112
112
|
* @returns The range value for the PropertyShape.
|
|
113
113
|
*/
|
|
114
|
-
associationShape(input: DomainAssociation, visited?: Set<string>): IShapeUnion | undefined;
|
|
114
|
+
associationShape(input: DomainAssociation, visited?: Set<string>): Shapes.IShapeUnion | undefined;
|
|
115
115
|
/**
|
|
116
116
|
* @param input The data association instance.
|
|
117
117
|
* @returns An AMF API scalar shape with the link to the schema.
|
|
118
118
|
*/
|
|
119
|
-
protected createLinkedShape(input: DomainAssociation): IApiScalarShape;
|
|
120
|
-
protected createUnionShape(input: DomainAssociation, items: IShapeUnion[]): IApiUnionShape | IApiArrayShape;
|
|
119
|
+
protected createLinkedShape(input: DomainAssociation): Shapes.IApiScalarShape;
|
|
120
|
+
protected createUnionShape(input: DomainAssociation, items: Shapes.IShapeUnion[]): Shapes.IApiUnionShape | Shapes.IApiArrayShape;
|
|
121
121
|
/**
|
|
122
122
|
* Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.
|
|
123
123
|
*
|
|
124
124
|
* @param input The data association instance.
|
|
125
125
|
* @returns The range value for the PropertyShape.
|
|
126
126
|
*/
|
|
127
|
-
associationUnion(input: DomainAssociation, visited?: Set<string>): IShapeUnion | IShapeUnion[] | undefined;
|
|
127
|
+
associationUnion(input: DomainAssociation, visited?: Set<string>): Shapes.IShapeUnion | Shapes.IShapeUnion[] | undefined;
|
|
128
128
|
/**
|
|
129
129
|
* The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for
|
|
130
130
|
* default value, examples, and enum values. We also look for the `web`
|
|
@@ -132,7 +132,7 @@ export declare class ShapeGenerator {
|
|
|
132
132
|
*
|
|
133
133
|
* @param input
|
|
134
134
|
*/
|
|
135
|
-
protected getRange(input: DomainProperty): IApiArrayShape | IApiFileShape | IApiScalarShape;
|
|
135
|
+
protected getRange(input: DomainProperty): Shapes.IApiArrayShape | Shapes.IApiFileShape | Shapes.IApiScalarShape;
|
|
136
136
|
/**
|
|
137
137
|
* Normally this would be part of generating a scalar schema but the the property is an array this
|
|
138
138
|
* is generated on the array and not on the range.
|
|
@@ -142,15 +142,15 @@ export declare class ShapeGenerator {
|
|
|
142
142
|
* @param type The data type of the parent property as set on the `range`
|
|
143
143
|
* @param isArray Whether the DomainProperty is multiple
|
|
144
144
|
*/
|
|
145
|
-
protected setShapeSchema(input: DomainProperty, result: IApiAnyShape, schema: PropertySchema, type: string, isArray?: boolean): void;
|
|
146
|
-
protected createArrayShape(input: DomainProperty, schema?: PropertySchema, bindings?: PropertyWebBindings): IApiArrayShape;
|
|
147
|
-
protected createScalarShape(input: DomainProperty, schema?: PropertySchema, bindings?: PropertyWebBindings): IApiScalarShape;
|
|
148
|
-
protected createExamples(examples: string[], type: string): IApiDataExample[];
|
|
149
|
-
protected createArrayExamples(examples: string[], type: string): IApiDataExample[];
|
|
150
|
-
protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): IApiFileShape;
|
|
151
|
-
protected setScalarCommonProperties(result: IApiFileShape | IApiScalarShape, input: DomainProperty, bindings?: PropertyWebBindings): void;
|
|
152
|
-
protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: IApiShape): void;
|
|
153
|
-
protected createRecursiveShape(input: DomainEntity): IApiRecursiveShape;
|
|
145
|
+
protected setShapeSchema(input: DomainProperty, result: Shapes.IApiAnyShape, schema: PropertySchema, type: string, isArray?: boolean): void;
|
|
146
|
+
protected createArrayShape(input: DomainProperty, schema?: PropertySchema, bindings?: PropertyWebBindings): Shapes.IApiArrayShape;
|
|
147
|
+
protected createScalarShape(input: DomainProperty, schema?: PropertySchema, bindings?: PropertyWebBindings): Shapes.IApiScalarShape;
|
|
148
|
+
protected createExamples(examples: string[], type: string): Shapes.IApiDataExample[];
|
|
149
|
+
protected createArrayExamples(examples: string[], type: string): Shapes.IApiDataExample[];
|
|
150
|
+
protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): Shapes.IApiFileShape;
|
|
151
|
+
protected setScalarCommonProperties(result: Shapes.IApiFileShape | Shapes.IApiScalarShape, input: DomainProperty, bindings?: PropertyWebBindings): void;
|
|
152
|
+
protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: Shapes.IApiShape): void;
|
|
153
|
+
protected createRecursiveShape(input: DomainEntity): Shapes.IApiRecursiveShape;
|
|
154
154
|
/**
|
|
155
155
|
* Translates the shape to an array shape. This happens when data model property
|
|
156
156
|
* is changed from 'multiple' to not-multiple and back.
|
|
@@ -159,6 +159,6 @@ export declare class ShapeGenerator {
|
|
|
159
159
|
* @param shape The shape to wrap as an array.
|
|
160
160
|
* @returns Array shape.
|
|
161
161
|
*/
|
|
162
|
-
protected refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape;
|
|
162
|
+
protected refactorShapeToArray(id: string, shape: Shapes.IShapeUnion): Shapes.IApiArrayShape;
|
|
163
163
|
}
|
|
164
164
|
//# sourceMappingURL=ShapeGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeGenerator.d.ts","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"ShapeGenerator.d.ts","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAgB,KAAK,MAAM,EAAuC,MAAM,sBAAsB,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aA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C,WAAW,GAAG,MAAM,CAAC,cAAc;CAK7F"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AmfNamespace } from '
|
|
3
|
-
import {
|
|
4
|
-
import { AmfDataNode } from '../../amf/models/AmfDataNode.js';
|
|
5
|
-
import { DataValueGenerator } from '../../amf/DataValueGenerator.js';
|
|
1
|
+
import { modelTypeToAmfDataType } from './core_types.js';
|
|
2
|
+
import { AmfNamespace, AmfDataNode, AmfTypes, ShapeHelpers } from '@api-client/amf-core';
|
|
3
|
+
import { DataValueGenerator } from './DataValueGenerator.js';
|
|
6
4
|
import { nanoid } from '../../nanoid.js';
|
|
7
5
|
import { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js';
|
|
8
6
|
const UNION_TYPE_ANY_OF = 'anyOf';
|
|
@@ -84,7 +82,7 @@ export class ShapeGenerator {
|
|
|
84
82
|
return this.createRecursiveShape(input);
|
|
85
83
|
}
|
|
86
84
|
visited.add(input.key);
|
|
87
|
-
const result = nodeShape(input.key);
|
|
85
|
+
const result = ShapeHelpers.nodeShape(input.key);
|
|
88
86
|
result.id = input.key;
|
|
89
87
|
this.updateBaseProperties(input, result);
|
|
90
88
|
result.properties = [];
|
|
@@ -130,7 +128,7 @@ export class ShapeGenerator {
|
|
|
130
128
|
*/
|
|
131
129
|
property(input) {
|
|
132
130
|
const { required, key } = input;
|
|
133
|
-
const result = propertyShape(key);
|
|
131
|
+
const result = ShapeHelpers.propertyShape(key);
|
|
134
132
|
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
135
133
|
if (required) {
|
|
136
134
|
result.minCount = 1;
|
|
@@ -167,7 +165,7 @@ export class ShapeGenerator {
|
|
|
167
165
|
*/
|
|
168
166
|
associationProperty(input, visited = new Set()) {
|
|
169
167
|
const { required, key } = input;
|
|
170
|
-
const result = propertyShape(key);
|
|
168
|
+
const result = ShapeHelpers.propertyShape(key);
|
|
171
169
|
result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`;
|
|
172
170
|
if (required) {
|
|
173
171
|
result.minCount = 1;
|
|
@@ -200,7 +198,7 @@ export class ShapeGenerator {
|
|
|
200
198
|
if (unionType === UNION_TYPE_NOT) {
|
|
201
199
|
// Need to investigate more about "not" union type.
|
|
202
200
|
// AMF supports it, but I am not sure how to handle it.
|
|
203
|
-
const wrapper = anyShape(input.key);
|
|
201
|
+
const wrapper = ShapeHelpers.anyShape(input.key);
|
|
204
202
|
wrapper.id = `not-shape-${input.key}`;
|
|
205
203
|
wrapper.not = items;
|
|
206
204
|
return wrapper;
|
|
@@ -217,13 +215,13 @@ export class ShapeGenerator {
|
|
|
217
215
|
createLinkedShape(input) {
|
|
218
216
|
// This is a link to the schema. In an API that would be the id
|
|
219
217
|
// of a resource to request the data from.
|
|
220
|
-
const range = scalarShape(input.key);
|
|
218
|
+
const range = ShapeHelpers.scalarShape(input.key);
|
|
221
219
|
range.id = `link-${input.key}`;
|
|
222
220
|
range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING);
|
|
223
221
|
return range;
|
|
224
222
|
}
|
|
225
223
|
createUnionShape(input, items) {
|
|
226
|
-
const range = unionShape(input.key);
|
|
224
|
+
const range = ShapeHelpers.unionShape(input.key);
|
|
227
225
|
this.updateBaseProperties(input, range);
|
|
228
226
|
range.anyOf = [];
|
|
229
227
|
const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF;
|
|
@@ -326,7 +324,7 @@ export class ShapeGenerator {
|
|
|
326
324
|
}
|
|
327
325
|
}
|
|
328
326
|
createArrayShape(input, schema, bindings) {
|
|
329
|
-
const result = arrayShape(input.key);
|
|
327
|
+
const result = ShapeHelpers.arrayShape(input.key);
|
|
330
328
|
const { type } = input;
|
|
331
329
|
if (type === DATA_TYPE_BINARY) {
|
|
332
330
|
// we do not pass schema to the range generator as we set schema's properties on the array shape.
|
|
@@ -342,7 +340,7 @@ export class ShapeGenerator {
|
|
|
342
340
|
return result;
|
|
343
341
|
}
|
|
344
342
|
createScalarShape(input, schema, bindings) {
|
|
345
|
-
const result = scalarShape(input.key);
|
|
343
|
+
const result = ShapeHelpers.scalarShape(input.key);
|
|
346
344
|
this.updateBaseProperties(input, result);
|
|
347
345
|
this.setScalarCommonProperties(result, input, bindings);
|
|
348
346
|
if (!result.dataType) {
|
|
@@ -360,7 +358,7 @@ export class ShapeGenerator {
|
|
|
360
358
|
id: nanoid(),
|
|
361
359
|
customDomainProperties: [],
|
|
362
360
|
strict: true,
|
|
363
|
-
types: IAmfExampleTypes,
|
|
361
|
+
types: [...AmfTypes.IAmfExampleTypes],
|
|
364
362
|
structuredValue: AmfDataNode.scalar(current, type).toJSON(),
|
|
365
363
|
};
|
|
366
364
|
result.push(item);
|
|
@@ -372,7 +370,7 @@ export class ShapeGenerator {
|
|
|
372
370
|
id: nanoid(),
|
|
373
371
|
customDomainProperties: [],
|
|
374
372
|
strict: true,
|
|
375
|
-
types: IAmfExampleTypes,
|
|
373
|
+
types: [...AmfTypes.IAmfExampleTypes],
|
|
376
374
|
};
|
|
377
375
|
const value = new AmfDataNode('array');
|
|
378
376
|
for (const item of examples) {
|
|
@@ -383,7 +381,7 @@ export class ShapeGenerator {
|
|
|
383
381
|
return [item];
|
|
384
382
|
}
|
|
385
383
|
createFileShape(input, bindings) {
|
|
386
|
-
const result = fileShape(input.key);
|
|
384
|
+
const result = ShapeHelpers.fileShape(input.key);
|
|
387
385
|
this.updateBaseProperties(input, result);
|
|
388
386
|
if (bindings) {
|
|
389
387
|
if (Array.isArray(bindings.fileTypes)) {
|
|
@@ -473,7 +471,7 @@ export class ShapeGenerator {
|
|
|
473
471
|
}
|
|
474
472
|
}
|
|
475
473
|
createRecursiveShape(input) {
|
|
476
|
-
return recursiveShape(input.key, input.key);
|
|
474
|
+
return ShapeHelpers.recursiveShape(input.key, input.key);
|
|
477
475
|
}
|
|
478
476
|
/**
|
|
479
477
|
* Translates the shape to an array shape. This happens when data model property
|
|
@@ -484,7 +482,7 @@ export class ShapeGenerator {
|
|
|
484
482
|
* @returns Array shape.
|
|
485
483
|
*/
|
|
486
484
|
refactorShapeToArray(id, shape) {
|
|
487
|
-
const result = arrayShape(id);
|
|
485
|
+
const result = ShapeHelpers.arrayShape(id);
|
|
488
486
|
result.items = shape;
|
|
489
487
|
return result;
|
|
490
488
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AACjE,OAAO,EACL,QAAQ,EACR,UAAU,EACV,SAAS,EAYT,SAAS,EACT,aAAa,EACb,cAAc,EACd,WAAW,EACX,UAAU,GACX,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAG5E,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AACjC,MAAM,cAAc,GAAG,KAAK,CAAA;AAC5B,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AACjC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,cAAc;IACzB,eAAe,CAAqB;IAEpC;;;;OAIG;IACH,IAAI,cAAc;QAChB,oEAAoE;QACpE,uEAAuE;QACvE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC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AAgB,EAAE,CAAC;YAC3C,MAAM,CAAC,UAAU,GAAI,KAAsB,CAAC,UAAU,CAAA;QACxD,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,KAAmB;QAChD,OAAO,cAAc,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC;IAED;;;;;;;OAOG;IACO,oBAAoB,CAAC,EAAU,EAAE,KAAkB;QAC3D,MAAM,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["import { type AssociationBindings, type PropertyWebBindings } from '../Bindings.js'\nimport type { DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { IAmfExampleTypes, modelTypeToAmfDataType } from '../../amf/AmfTypes.js'\nimport { AmfNamespace } from '../../amf/definitions/Namespace.js'\nimport {\n anyShape,\n arrayShape,\n fileShape,\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiRecursiveShape,\n IApiScalarShape,\n IApiShape,\n IApiUnionShape,\n IShapeUnion,\n nodeShape,\n propertyShape,\n recursiveShape,\n scalarShape,\n unionShape,\n} from '../../amf/definitions/Shapes.js'\nimport { AmfDataNode } from '../../amf/models/AmfDataNode.js'\nimport { DataValueGenerator } from '../../amf/DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited = new Set<string>()): IApiNodeShape | IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): IApiPropertyShape {\n const { required, key } = input\n const result = propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(input: DomainAssociation, items: IShapeUnion[]): IApiUnionShape | IApiArrayShape {\n const range = unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): IShapeUnion | IShapeUnion[] | undefined {\n const result: IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): IApiArrayShape | IApiFileShape | IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiArrayShape {\n const result = arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): IApiScalarShape {\n const result = scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): IApiDataExample[] {\n const result: IApiDataExample[] = []\n for (const current of examples) {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): IApiDataExample[] {\n const item: IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: IAmfExampleTypes,\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): IApiFileShape {\n const result = fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: IApiFileShape | IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n const { schema, type } = input\n if (schema) {\n if (schema.pattern) {\n result.pattern = schema.pattern\n }\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(input: DomainProperty | DomainAssociation | DomainEntity, target: IApiShape): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): IApiRecursiveShape {\n return recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: IShapeUnion): IApiArrayShape {\n const result = arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ShapeGenerator.js","sourceRoot":"","sources":["../../../../src/modeling/amf/ShapeGenerator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAe,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB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{ DomainAssociation } from '../DomainAssociation.js'\nimport type { DomainProperty } from '../DomainProperty.js'\nimport type { DomainEntity } from '../DomainEntity.js'\nimport { modelTypeToAmfDataType } from './core_types.js'\nimport { AmfNamespace, type Shapes, AmfDataNode, AmfTypes, ShapeHelpers } from '@api-client/amf-core'\nimport { DataValueGenerator } from './DataValueGenerator.js'\nimport { nanoid } from '../../nanoid.js'\nimport { DomainEntityKind, DomainPropertyKind } from '../../models/kinds.js'\nimport type { PropertySchema } from '../types.js'\n\nconst UNION_TYPE_ANY_OF = 'anyOf'\nconst UNION_TYPE_ALL_OF = 'allOf'\nconst UNION_TYPE_ONE_OF = 'oneOf'\nconst UNION_TYPE_NOT = 'not'\nconst DATA_TYPE_STRING = 'string'\nconst DATA_TYPE_BINARY = 'binary'\n\n/**\n * Serializes Data Domain elements (DomainEntity, DomainProperty, DomainAssociation)\n * to AMF shapes.\n *\n * This class provides a mechanism to translate a data domain model, defined using\n * custom classes like `DomainEntity`, `DomainProperty`, and `DomainAssociation`,\n * into AMF (API Modeling Framework) shapes. AMF shapes are a standardized way\n * to represent API structures and data models, enabling interoperability and tooling.\n *\n * This is particularly useful when you have a custom data model and need to\n * generate API definitions (e.g., RAML or OAS) from it.\n *\n * **Key Features:**\n *\n * - **Data Domain to AMF Translation:** Converts data domain elements into\n * their corresponding AMF shape representations.\n * - **Recursive Shape Handling:** Detects and handles recursive relationships\n * within the data model to prevent infinite loops during shape generation.\n * - **Union Type Support:** Supports the creation of union types in AMF\n * to represent associations that can point to multiple different entity types.\n * - **Binding Integration:** Leverages binding information (e.g., web bindings)\n * to customize the generated AMF shapes based on the target API format.\n * - **Example and Default Value Generation:** Integrates with a `DataValueGenerator`\n * to automatically generate example values and default values for properties\n * within the AMF shapes.\n *\n * **Usage:**\n *\n * 1. Create an instance of the `ShapeGenerator`.\n * 2. Call the appropriate method (e.g., `entity()`, `property()`, `associationShape()`)\n * to generate the AMF shape for a specific data domain element.\n * 3. The returned AMF shape can then be used with other AMF tools to generate\n * API definitions or perform other API-related tasks.\n */\nexport class ShapeGenerator {\n #valueGenerator?: DataValueGenerator\n\n /**\n * Used with data domain value generation for entity properties.\n * Lazily loaded class only when functions are used.\n * This needs to be a class instances because some functions are incremental\n */\n get valueGenerator(): DataValueGenerator {\n // we need a new instance of the generator for each shape generation\n // as the generator is stateful and we need to reset it for each shape.\n if (!this.#valueGenerator) {\n this.#valueGenerator = new DataValueGenerator()\n }\n return this.#valueGenerator\n }\n\n /**\n * Serializes a `DomainEntity` to an AMF node shape.\n *\n * This method is the entry point for converting a `DomainEntity` into its\n * AMF representation. It handles recursive relationships, property serialization,\n * and inheritance from parent entities.\n *\n * @param input The `DomainEntity` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiNodeShape` or `IApiRecursiveShape` representing the entity in AMF.\n * Returns a `IApiRecursiveShape` if a recursive loop is detected.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.entity(myDomainEntity);\n * ```\n */\n entity(input: DomainEntity, visited = new Set<string>()): Shapes.IApiNodeShape | Shapes.IApiRecursiveShape {\n if (visited.has(input.key)) {\n // create a recursive shape.\n return this.createRecursiveShape(input)\n }\n visited.add(input.key)\n const result = ShapeHelpers.nodeShape(input.key)\n result.id = input.key\n this.updateBaseProperties(input, result)\n result.properties = []\n for (const item of input.listProperties()) {\n // we check whether the property is hidden.\n // This is not happening when calling the `property()` because this method\n // always returns the AMF shape.\n const wb = item.readBinding('web') as PropertyWebBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const shape = this.property(item)\n result.properties.push(shape)\n }\n for (const assoc of input.listAssociations()) {\n const wb = assoc.readBinding('web') as AssociationBindings | undefined\n if (wb && wb.hidden) {\n continue\n }\n const prop = this.associationProperty(assoc, visited)\n result.properties.push(prop)\n }\n for (const parent of input.listParents()) {\n const shape = this.entity(parent, visited)\n result.inherits.push(shape)\n }\n return result\n }\n\n /**\n * Serializes a `DomainProperty` to an AMF property shape.\n *\n * This method converts a `DomainProperty` into an `IApiPropertyShape`,\n * defining its characteristics such as data type, required status, and\n * range (the shape of the property's value).\n *\n * @param input The `DomainProperty` to serialize.\n * @returns An `IApiPropertyShape` representing the property in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.property(myDomainProperty);\n * ```\n */\n property(input: DomainProperty): Shapes.IApiPropertyShape {\n const { required, key } = input\n const result = ShapeHelpers.propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.getRange(input)\n\n // for example, Example generator needs to know the name of the property\n // as it does not look into the \"range\" object.\n this.updateBaseProperties(input, result)\n\n // sync the name of the property shape with the range, in case it was changed by the bindings\n if (result.range.name) {\n result.name = result.range.name\n }\n return result\n }\n\n /**\n * Serializes a `DomainAssociation` to an AMF property shape, handling the\n * association's target entity or entities.\n *\n * This method is similar to `property()`, but it specifically handles\n * associations between entities. It determines the range of the property\n * based on the association's target(s) and generates the appropriate\n * AMF shape (e.g., a scalar shape for a linked schema, a union shape for\n * multiple targets).\n *\n * @param input The `DomainAssociation` to serialize.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns An `IApiPropertyShape` representing the association in AMF.\n * @example\n * ```typescript\n * const generator = new ShapeGenerator();\n * const amfShape = generator.associationProperty(myDomainAssociation);\n * ```\n */\n associationProperty(input: DomainAssociation, visited: Set<string> = new Set<string>()): Shapes.IApiPropertyShape {\n const { required, key } = input\n const result = ShapeHelpers.propertyShape(key)\n result.path = `${AmfNamespace.aml.vocabularies.data.key}${input.info.name}`\n if (required) {\n result.minCount = 1\n }\n result.range = this.associationShape(input, visited)\n\n this.updateBaseProperties(input, result)\n return result\n }\n\n /**\n * Generates a shape for an association. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @param visited A `Set` of keys of already generated entities. This prevents\n * recursive shape generation and avoids infinite loops. Defaults to a new empty `Set`.\n * @returns The range value for the PropertyShape.\n */\n associationShape(input: DomainAssociation, visited: Set<string> = new Set<string>()): Shapes.IShapeUnion | undefined {\n const schema = input.schema\n if (schema && schema.linked) {\n return this.createLinkedShape(input)\n }\n const items = this.associationUnion(input, visited)\n if (!items) {\n return\n }\n if (Array.isArray(items)) {\n return this.createUnionShape(input, items)\n }\n const unionType = (schema && schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_NOT) {\n // Need to investigate more about \"not\" union type.\n // AMF supports it, but I am not sure how to handle it.\n const wrapper = ShapeHelpers.anyShape(input.key)\n wrapper.id = `not-shape-${input.key}`\n wrapper.not = items\n return wrapper\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, items)\n }\n return items\n }\n\n /**\n * @param input The data association instance.\n * @returns An AMF API scalar shape with the link to the schema.\n */\n protected createLinkedShape(input: DomainAssociation): Shapes.IApiScalarShape {\n // This is a link to the schema. In an API that would be the id\n // of a resource to request the data from.\n const range = ShapeHelpers.scalarShape(input.key)\n range.id = `link-${input.key}`\n range.dataType = modelTypeToAmfDataType(DATA_TYPE_STRING)\n return range\n }\n\n protected createUnionShape(\n input: DomainAssociation,\n items: Shapes.IShapeUnion[]\n ): Shapes.IApiUnionShape | Shapes.IApiArrayShape {\n const range = ShapeHelpers.unionShape(input.key)\n this.updateBaseProperties(input, range)\n range.anyOf = []\n const unionType = (input.schema && input.schema.unionType) || UNION_TYPE_ANY_OF\n if (unionType === UNION_TYPE_ANY_OF) {\n range.anyOf = items\n } else if (unionType === UNION_TYPE_ALL_OF) {\n range.and = items\n } else if (unionType === UNION_TYPE_ONE_OF) {\n range.xone = items\n } else {\n // the \"not\" union type only supports a single schema.\n // I am not sure how this should be handled. Will take the first one\n // for now.\n range.not = items[0]\n }\n if (input.multiple) {\n return this.refactorShapeToArray(input.key, range)\n }\n return range\n }\n\n /**\n * Generates a shape list for an union. Most likely you want to use the `associationProperty()` method instead.\n *\n * @param input The data association instance.\n * @returns The range value for the PropertyShape.\n */\n associationUnion(\n input: DomainAssociation,\n visited: Set<string> = new Set<string>()\n ): Shapes.IShapeUnion | Shapes.IShapeUnion[] | undefined {\n const result: Shapes.IShapeUnion[] = []\n for (const item of input.listTargets()) {\n result.push(this.entity(item, visited))\n }\n if (!result.length) {\n return undefined\n }\n if (result.length > 1) {\n return result\n }\n return result[0]\n }\n\n /**\n * The DomainProperty may have both the `schema` and the `bindings`. For AMF shape we read `schema` for\n * default value, examples, and enum values. We also look for the `web`\n * bindings for more detailed definition of a shape.\n *\n * @param input\n */\n protected getRange(input: DomainProperty): Shapes.IApiArrayShape | Shapes.IApiFileShape | Shapes.IApiScalarShape {\n const bindings = input.readBinding('web') as PropertyWebBindings | undefined\n let schema: PropertySchema | undefined\n if (input.schema) {\n schema = input.schema\n }\n const { multiple, type } = input\n if (multiple) {\n return this.createArrayShape(input, schema, bindings)\n }\n if (type === DATA_TYPE_BINARY) {\n return this.createFileShape(input, bindings)\n }\n return this.createScalarShape(input, schema, bindings)\n }\n\n /**\n * Normally this would be part of generating a scalar schema but the the property is an array this\n * is generated on the array and not on the range.\n *\n * @param result The scalar or array shape.\n * @param schema The property schema\n * @param type The data type of the parent property as set on the `range`\n * @param isArray Whether the DomainProperty is multiple\n */\n protected setShapeSchema(\n input: DomainProperty,\n result: Shapes.IApiAnyShape,\n schema: PropertySchema,\n type: string,\n isArray?: boolean\n ): void {\n if (schema.defaultValue) {\n const { type: dfFormat } = schema.defaultValue\n const { value } = schema.defaultValue\n if (dfFormat === 'function') {\n const tmp = this.valueGenerator.generate(value, input.type)\n if (tmp !== DataValueGenerator.noValue) {\n const dt = AmfDataNode.scalar(tmp as string, dfFormat)\n result.defaultValue = dt.toJSON()\n }\n } else {\n const dt = AmfDataNode.scalar(value, type)\n result.defaultValue = dt.toJSON()\n }\n }\n if (Array.isArray(schema.enum)) {\n result.values = schema.enum.map((i) => AmfDataNode.scalar(i, type).toJSON())\n }\n if (Array.isArray(schema.examples)) {\n if (isArray) {\n result.examples = this.createArrayExamples(schema.examples, type)\n } else {\n result.examples = this.createExamples(schema.examples, type)\n }\n }\n }\n\n protected createArrayShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): Shapes.IApiArrayShape {\n const result = ShapeHelpers.arrayShape(input.key)\n const { type } = input\n if (type === DATA_TYPE_BINARY) {\n // we do not pass schema to the range generator as we set schema's properties on the array shape.\n result.items = this.createFileShape(input, bindings)\n } else {\n result.items = this.createScalarShape(input, undefined, bindings)\n }\n if (schema) {\n const type = (result.items as Shapes.IApiScalarShape).dataType as string\n this.setShapeSchema(input, result, schema, type, input.multiple)\n }\n return result\n }\n\n protected createScalarShape(\n input: DomainProperty,\n schema?: PropertySchema,\n bindings?: PropertyWebBindings\n ): Shapes.IApiScalarShape {\n const result = ShapeHelpers.scalarShape(input.key)\n this.updateBaseProperties(input, result)\n this.setScalarCommonProperties(result, input, bindings)\n if (!result.dataType) {\n result.dataType = modelTypeToAmfDataType(input.type, bindings)\n }\n if (schema) {\n this.setShapeSchema(input, result, schema, result.dataType as string, input.multiple)\n }\n return result\n }\n\n protected createExamples(examples: string[], type: string): Shapes.IApiDataExample[] {\n const result: Shapes.IApiDataExample[] = []\n for (const current of examples) {\n const item: Shapes.IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: [...AmfTypes.IAmfExampleTypes],\n structuredValue: AmfDataNode.scalar(current, type).toJSON(),\n }\n result.push(item)\n }\n return result\n }\n\n protected createArrayExamples(examples: string[], type: string): Shapes.IApiDataExample[] {\n const item: Shapes.IApiDataExample = {\n id: nanoid(),\n customDomainProperties: [],\n strict: true,\n types: [...AmfTypes.IAmfExampleTypes],\n }\n const value = new AmfDataNode('array')\n for (const item of examples) {\n const member = AmfDataNode.scalar(item, type)\n value.addMember(member)\n }\n item.structuredValue = value.toJSON()\n return [item]\n }\n\n protected createFileShape(input: DomainProperty, bindings?: PropertyWebBindings): Shapes.IApiFileShape {\n const result = ShapeHelpers.fileShape(input.key)\n this.updateBaseProperties(input, result)\n if (bindings) {\n if (Array.isArray(bindings.fileTypes)) {\n result.fileTypes = bindings.fileTypes\n }\n this.setScalarCommonProperties(result, input, bindings)\n if (bindings.format === 'base64') {\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n }\n }\n return result\n }\n\n protected setScalarCommonProperties(\n result: Shapes.IApiFileShape | Shapes.IApiScalarShape,\n input: DomainProperty,\n bindings?: PropertyWebBindings\n ): void {\n if (bindings?.name) {\n result.name = bindings.name\n }\n if (bindings?.xml) {\n result.xmlSerialization = bindings.xml\n }\n const { schema, type } = input\n if (schema) {\n if (schema.pattern) {\n result.pattern = schema.pattern\n }\n if (typeof schema.multipleOf === 'number') {\n result.multipleOf = schema.multipleOf\n }\n if (typeof schema.minimum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.minLength = schema.minimum\n } else {\n result.minimum = schema.minimum\n }\n }\n if (typeof schema.maximum === 'number') {\n if (type === DATA_TYPE_STRING) {\n result.maxLength = schema.maximum\n } else {\n result.maximum = schema.maximum\n }\n }\n if (typeof schema.exclusiveMinimum === 'boolean') {\n result.exclusiveMinimum = schema.exclusiveMinimum\n }\n if (typeof schema.exclusiveMaximum === 'boolean') {\n result.exclusiveMaximum = schema.exclusiveMaximum\n }\n }\n if (bindings?.format) {\n switch (bindings.format) {\n case 'base64':\n result.format = AmfNamespace.w3.xmlSchema.base64Binary\n break\n case 'double':\n result.format = AmfNamespace.w3.xmlSchema.double\n break\n case 'float':\n result.format = AmfNamespace.w3.xmlSchema.float\n break\n case 'int32':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n case 'int64':\n result.format = AmfNamespace.w3.xmlSchema.integer\n break\n }\n // result.format = bindings.format\n }\n if (typeof input.readOnly === 'boolean') {\n result.readOnly = input.readOnly\n }\n if (typeof input.writeOnly === 'boolean') {\n result.writeOnly = input.writeOnly\n }\n }\n\n protected updateBaseProperties(\n input: DomainProperty | DomainAssociation | DomainEntity,\n target: Shapes.IApiShape\n ): void {\n target.name = input.info.name\n target.displayName = input.info.displayName\n target.description = input.info.description\n if (input.kind === DomainPropertyKind) {\n target.deprecated = (input as DomainProperty).deprecated\n } else if (input.kind === DomainEntityKind) {\n target.deprecated = (input as DomainEntity).deprecated\n }\n }\n\n protected createRecursiveShape(input: DomainEntity): Shapes.IApiRecursiveShape {\n return ShapeHelpers.recursiveShape(input.key, input.key)\n }\n\n /**\n * Translates the shape to an array shape. This happens when data model property\n * is changed from 'multiple' to not-multiple and back.\n *\n * @param id The key of the parameter or an association\n * @param shape The shape to wrap as an array.\n * @returns Array shape.\n */\n protected refactorShapeToArray(id: string, shape: Shapes.IShapeUnion): Shapes.IApiArrayShape {\n const result = ShapeHelpers.arrayShape(id)\n result.items = shape\n return result\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropertyWebBindings } from '../Bindings.js';
|
|
2
|
+
import { DomainPropertyType } from '../DataFormat.js';
|
|
3
|
+
/**
|
|
4
|
+
* Translates the DomainProperty type to an AMF data type.
|
|
5
|
+
* @param type The property data type
|
|
6
|
+
* @returns AMF shape dataType
|
|
7
|
+
*/
|
|
8
|
+
export declare function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string;
|
|
9
|
+
//# sourceMappingURL=core_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core_types.d.ts","sourceRoot":"","sources":["../../../../src/modeling/amf/core_types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGrD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAqCvG"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AmfNamespace } from '@api-client/amf-core';
|
|
2
|
+
/**
|
|
3
|
+
* Translates the DomainProperty type to an AMF data type.
|
|
4
|
+
* @param type The property data type
|
|
5
|
+
* @returns AMF shape dataType
|
|
6
|
+
*/
|
|
7
|
+
export function modelTypeToAmfDataType(type, bindings) {
|
|
8
|
+
if (type === 'number') {
|
|
9
|
+
if (bindings?.format === 'int32' || bindings?.format === 'int64') {
|
|
10
|
+
return AmfNamespace.w3.xmlSchema.integer;
|
|
11
|
+
}
|
|
12
|
+
return AmfNamespace.w3.xmlSchema.number;
|
|
13
|
+
}
|
|
14
|
+
if (type === 'boolean') {
|
|
15
|
+
return AmfNamespace.aml.vocabularies.shapes.boolean;
|
|
16
|
+
}
|
|
17
|
+
if (type === 'date') {
|
|
18
|
+
return AmfNamespace.w3.xmlSchema.date;
|
|
19
|
+
}
|
|
20
|
+
if (type === 'datetime') {
|
|
21
|
+
return AmfNamespace.w3.xmlSchema.dateTime;
|
|
22
|
+
}
|
|
23
|
+
if (type === 'time') {
|
|
24
|
+
return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly;
|
|
25
|
+
}
|
|
26
|
+
if (type === 'binary' && bindings && bindings.format === 'base64') {
|
|
27
|
+
return AmfNamespace.w3.xmlSchema.base64Binary;
|
|
28
|
+
}
|
|
29
|
+
return AmfNamespace.w3.xmlSchema.string;
|
|
30
|
+
// switch (type) {
|
|
31
|
+
// // case 'nil':
|
|
32
|
+
// // return AmfNamespace.aml.vocabularies.shapes.nil
|
|
33
|
+
// // case 'any':
|
|
34
|
+
// // return AmfNamespace.aml.vocabularies.shapes.AnyShape
|
|
35
|
+
// default:
|
|
36
|
+
// if (type === 'binary' && bindings && bindings.format === 'base64') {
|
|
37
|
+
// return AmfNamespace.w3.xmlSchema.base64Binary
|
|
38
|
+
// }
|
|
39
|
+
// // if (bindings && bindings.format === 'binary') {
|
|
40
|
+
// // return AmfNamespace.w3.xmlSchema.base64Binary
|
|
41
|
+
// // }
|
|
42
|
+
// return AmfNamespace.w3.xmlSchema.string
|
|
43
|
+
// }
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=core_types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core_types.js","sourceRoot":"","sources":["../../../../src/modeling/amf/core_types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAwB,EAAE,QAA8B;IAC7F,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,IAAI,QAAQ,EAAE,MAAM,KAAK,OAAO,IAAI,QAAQ,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;YACjE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,OAAO,CAAA;QAC1C,CAAC;QACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACzC,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAA;IACrD,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAA;IACvC,CAAC;IACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;QACxB,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAA;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAA;IAC1D,CAAC;IACD,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAClE,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,YAAY,CAAA;IAC/C,CAAC;IACD,OAAO,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAA;IACvC,kBAAkB;IAClB,mBAAmB;IACnB,yDAAyD;IACzD,mBAAmB;IACnB,8DAA8D;IAC9D,aAAa;IACb,2EAA2E;IAC3E,sDAAsD;IACtD,QAAQ;IACR,yDAAyD;IACzD,yDAAyD;IACzD,WAAW;IACX,8CAA8C;IAC9C,IAAI;AACN,CAAC","sourcesContent":["import { PropertyWebBindings } from '../Bindings.js'\nimport { DomainPropertyType } from '../DataFormat.js'\nimport { AmfNamespace } from '@api-client/amf-core'\n\n/**\n * Translates the DomainProperty type to an AMF data type.\n * @param type The property data type\n * @returns AMF shape dataType\n */\nexport function modelTypeToAmfDataType(type: DomainPropertyType, bindings?: PropertyWebBindings): string {\n if (type === 'number') {\n if (bindings?.format === 'int32' || bindings?.format === 'int64') {\n return AmfNamespace.w3.xmlSchema.integer\n }\n return AmfNamespace.w3.xmlSchema.number\n }\n if (type === 'boolean') {\n return AmfNamespace.aml.vocabularies.shapes.boolean\n }\n if (type === 'date') {\n return AmfNamespace.w3.xmlSchema.date\n }\n if (type === 'datetime') {\n return AmfNamespace.w3.xmlSchema.dateTime\n }\n if (type === 'time') {\n return AmfNamespace.aml.vocabularies.shapes.dateTimeOnly\n }\n if (type === 'binary' && bindings && bindings.format === 'base64') {\n return AmfNamespace.w3.xmlSchema.base64Binary\n }\n return AmfNamespace.w3.xmlSchema.string\n // switch (type) {\n // // case 'nil':\n // // return AmfNamespace.aml.vocabularies.shapes.nil\n // // case 'any':\n // // return AmfNamespace.aml.vocabularies.shapes.AnyShape\n // default:\n // if (type === 'binary' && bindings && bindings.format === 'base64') {\n // return AmfNamespace.w3.xmlSchema.base64Binary\n // }\n // // if (bindings && bindings.format === 'binary') {\n // // return AmfNamespace.w3.xmlSchema.base64Binary\n // // }\n // return AmfNamespace.w3.xmlSchema.string\n // }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FlowSourceEnum } from './HttpFlows.js';
|
|
2
|
-
import { AmfNamespace } from '
|
|
2
|
+
import { AmfNamespace } from '@api-client/amf-core';
|
|
3
3
|
import { ReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js';
|
|
4
4
|
import { SetDataStepKind } from './steps/data/SetDataStep.js';
|
|
5
5
|
import { SetCookieStepKind } from './steps/data/SetCookieStep.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegacyTranslator.js","sourceRoot":"","sources":["../../../../src/models/http-flows/LegacyTranslator.ts"],"names":[],"mappings":"AAWA,OAAO,EAA0B,cAAc,EAA6C,MAAM,gBAAgB,CAAA;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEjE,OAAO,EAAiB,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC5F,OAAO,EAAgB,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAkB,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAqB,MAAM,kCAAkC,CAAA;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAExE;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,SAAS,CAAC,MAA4B;QAC3C,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAA;QACpC,MAAM,MAAM,GAAgB,EAAE,CAAA;QAE9B,IAAI,K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KAAK;gBACnB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM;aAC3C,CAAA;YACD,OAAO,OAAO,CAAA;QAChB,CAAC;QAED,4EAA4E;QAC5E,0CAA0C;QAE1C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;QACnD,MAAM,MAAM,GAAkB;YAC5B,IAAI,EAAE,gBAAgB;SACvB,CAAA;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;QACpB,CAAC;QACD,IAAI,IAAI,EAAE,CAAC;YACT,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,SAAS;oBACZ,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAA;oBACtC,MAAK;gBACP,KAAK,UAAU;oBACb,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAA;oBACvC,MAAK;YACT,CAAC;QACH,CAAC;QACD,IAAI,IAAI,IAAI,YAAY,EAAE,CAAC;YACzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,MAAM,CAAC,IAAI,GAAG,YAAmC,CAAA;YACnD,CAAC;YACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACxB,MAAM,CAAC,IAAI,GAAG,YAAoC,CAAA;YACpD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-extraneous-class */\nimport { RequestActions as LegacyRequestActions } from '../../models/legacy/request/ArcRequest.js'\nimport {\n RunnableAction as LegacyRunnable,\n Condition as LegacyCondition,\n Action as LegacyAction,\n SetCookieConfig,\n SetVariableConfig,\n DeleteCookieConfig,\n DataSourceConfiguration,\n} from '../../models/legacy/actions/Actions.js'\nimport { IHttpFlow, IHttpAction, FlowSourceEnum, FlowRequestDataEnum, FlowResponseDataEnum } from './HttpFlows.js'\nimport { AmfNamespace } from '../../amf/definitions/Namespace.js'\nimport { IHttpStep } from './HttpStep.js'\nimport { IReadDataStep, ReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js'\nimport { ISetDataStep, SetDataStepKind } from './steps/data/SetDataStep.js'\nimport { ISetCookieStep, SetCookieStepKind } from './steps/data/SetCookieStep.js'\nimport { DeleteCookieStepKind, IDeleteCookieStep } from './steps/data/DeleteCookieStep.js'\nimport { IncludesAssertion } from './steps/assertion/IncludesAssertion.js'\nimport { EqualAssertion } from './steps/assertion/EqualAssertion.js'\nimport { GreaterThanAssertion } from './steps/assertion/GreaterThanAssertion.js'\nimport { LessThanAssertion } from './steps/assertion/LessThanAssertion.js'\nimport { NotEqualAssertion } from './steps/assertion/NotEqualAssertion.js'\nimport { MatchesAssertion } from './steps/assertion/MatchesAssertion.js'\n\n/**\n * Allows to translate the old ARC actions into Action flows.\n */\nexport class LegacyTranslator {\n static translate(action: LegacyRequestActions): IHttpFlow[] {\n const { request, response } = action\n const result: IHttpFlow[] = []\n\n if (Array.isArray(request) && request.length) {\n request.forEach((runnable, index) => {\n const flow = this._runnableIntoFlow(runnable, 'request')\n flow.description = `Translated flow ${index + 1}`\n result.push(flow)\n })\n }\n\n if (Array.isArray(response) && response.length) {\n response.forEach((runnable, index) => {\n const flow = this._runnableIntoFlow(runnable, 'response')\n flow.description = `Translated flow ${index + 1}`\n result.push(flow)\n })\n }\n return result\n }\n\n protected static _runnableIntoFlow(runnable: LegacyRunnable, trigger: 'request' | 'response'): IHttpFlow {\n const flow: IHttpFlow = {\n trigger,\n actions: [],\n }\n const { actions, condition } = runnable\n if (condition) {\n flow.condition = this._translateCondition(condition)\n }\n actions.forEach((action, index) => {\n const current: IHttpAction = {\n steps: this._translateAction(action),\n }\n if (action.name) {\n current.description = action.name\n } else {\n current.description = `Translated action ${index + 1}`\n }\n flow.actions.push(current)\n })\n return flow\n }\n\n protected static _translateCondition(runnable: LegacyCondition): IHttpAction | undefined {\n const { source, alwaysPass, operator, path, predictedValue, type } = runnable\n if (alwaysPass) {\n // in the flow, if there's no condition the steps are always executed.\n return undefined\n }\n if (!path || !type) {\n return undefined\n }\n if (!['request', 'response'].includes(type)) {\n return\n }\n\n const result: IHttpAction = {\n steps: [],\n }\n const readData = new ReadDataStep()\n readData.source = type === 'request' ? FlowSourceEnum.request : FlowSourceEnum.response\n readData.path = path\n if (source) {\n if (type === 'request') {\n readData.data = source as FlowRequestDataEnum\n } else if (type === 'response') {\n readData.data = source as FlowResponseDataEnum\n }\n }\n result.steps.push(readData.toJSON())\n if (!operator) {\n return result\n }\n if (operator === 'contains') {\n const assertion = new IncludesAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'equal') {\n const assertion = new EqualAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'not-equal') {\n const assertion = new NotEqualAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'greater-than') {\n const assertion = new GreaterThanAssertion()\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'greater-than-equal') {\n const assertion = new GreaterThanAssertion()\n assertion.equal = true\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'less-than') {\n const assertion = new LessThanAssertion()\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'less-than-equal') {\n const assertion = new LessThanAssertion()\n assertion.equal = true\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'regex') {\n const assertion = new MatchesAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n }\n return result\n }\n\n protected static _translateAction(item: LegacyAction): IHttpStep[] {\n switch (item.name) {\n case 'set-cookie':\n return this._translateSetCookieAction(item)\n case 'set-variable':\n return this._translateSetVariableAction(item)\n case 'delete-cookie':\n return this._translateDeleteCookieAction(item)\n default:\n return []\n }\n }\n\n protected static _translateSetCookieAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as SetCookieConfig\n\n const steps: IHttpStep[] = []\n const ds = this._translateDataSource(legacy.source)\n steps.push(ds)\n\n const action: ISetCookieStep = {\n kind: SetCookieStepKind,\n name: legacy.name,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n if (legacy.url) {\n action.url = legacy.url\n }\n if (legacy.expires) {\n action.expires = legacy.expires\n }\n if (typeof legacy.hostOnly === 'boolean') {\n action.hostOnly = legacy.hostOnly\n }\n if (typeof legacy.httpOnly === 'boolean') {\n action.httpOnly = legacy.httpOnly\n }\n if (typeof legacy.secure === 'boolean') {\n action.secure = legacy.secure\n }\n if (typeof legacy.session === 'boolean') {\n action.session = legacy.session\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateSetVariableAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as SetVariableConfig\n\n const steps: IHttpStep[] = []\n const ds = this._translateDataSource(legacy.source)\n steps.push(ds)\n\n const action: ISetCookieStep = {\n kind: SetCookieStepKind,\n name: legacy.name,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateDeleteCookieAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as DeleteCookieConfig\n\n const steps: IHttpStep[] = []\n\n const action: IDeleteCookieStep = {\n kind: DeleteCookieStepKind,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n if (legacy.name && !legacy.removeAll) {\n action.name = legacy.name\n }\n if (legacy.url && !legacy.useRequestUrl) {\n action.url = legacy.url\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateDataSource(source: DataSourceConfiguration): IHttpStep {\n if (source.value) {\n const dataSet: ISetDataStep = {\n kind: SetDataStepKind,\n value: source.value,\n dataType: AmfNamespace.w3.xmlSchema.string,\n }\n return dataSet\n }\n\n // Note, there's no way for us to translate the old \"iterator\" configuration\n // to the current syntax. We just drop it.\n\n const { path, type, source: legacySource } = source\n const result: IReadDataStep = {\n kind: ReadDataStepKind,\n }\n\n if (typeof path === 'string') {\n result.path = path\n }\n if (type) {\n switch (type) {\n case 'request':\n result.source = FlowSourceEnum.request\n break\n case 'response':\n result.source = FlowSourceEnum.response\n break\n }\n }\n if (type && legacySource) {\n if (type === 'request') {\n result.data = legacySource as FlowRequestDataEnum\n }\n if (type === 'response') {\n result.data = legacySource as FlowResponseDataEnum\n }\n }\n return result\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LegacyTranslator.js","sourceRoot":"","sources":["../../../../src/models/http-flows/LegacyTranslator.ts"],"names":[],"mappings":"AAWA,OAAO,EAA0B,cAAc,EAA6C,MAAM,gBAAgB,CAAA;AAClH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,OAAO,EAAiB,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC5F,OAAO,EAAgB,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC3E,OAAO,EAAkB,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAqB,MAAM,kCAAkC,CAAA;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CA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CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/no-extraneous-class */\nimport { RequestActions as LegacyRequestActions } from '../../models/legacy/request/ArcRequest.js'\nimport {\n RunnableAction as LegacyRunnable,\n Condition as LegacyCondition,\n Action as LegacyAction,\n SetCookieConfig,\n SetVariableConfig,\n DeleteCookieConfig,\n DataSourceConfiguration,\n} from '../../models/legacy/actions/Actions.js'\nimport { IHttpFlow, IHttpAction, FlowSourceEnum, FlowRequestDataEnum, FlowResponseDataEnum } from './HttpFlows.js'\nimport { AmfNamespace } from '@api-client/amf-core'\nimport { IHttpStep } from './HttpStep.js'\nimport { IReadDataStep, ReadDataStep, ReadDataStepKind } from './steps/data/ReadDataStep.js'\nimport { ISetDataStep, SetDataStepKind } from './steps/data/SetDataStep.js'\nimport { ISetCookieStep, SetCookieStepKind } from './steps/data/SetCookieStep.js'\nimport { DeleteCookieStepKind, IDeleteCookieStep } from './steps/data/DeleteCookieStep.js'\nimport { IncludesAssertion } from './steps/assertion/IncludesAssertion.js'\nimport { EqualAssertion } from './steps/assertion/EqualAssertion.js'\nimport { GreaterThanAssertion } from './steps/assertion/GreaterThanAssertion.js'\nimport { LessThanAssertion } from './steps/assertion/LessThanAssertion.js'\nimport { NotEqualAssertion } from './steps/assertion/NotEqualAssertion.js'\nimport { MatchesAssertion } from './steps/assertion/MatchesAssertion.js'\n\n/**\n * Allows to translate the old ARC actions into Action flows.\n */\nexport class LegacyTranslator {\n static translate(action: LegacyRequestActions): IHttpFlow[] {\n const { request, response } = action\n const result: IHttpFlow[] = []\n\n if (Array.isArray(request) && request.length) {\n request.forEach((runnable, index) => {\n const flow = this._runnableIntoFlow(runnable, 'request')\n flow.description = `Translated flow ${index + 1}`\n result.push(flow)\n })\n }\n\n if (Array.isArray(response) && response.length) {\n response.forEach((runnable, index) => {\n const flow = this._runnableIntoFlow(runnable, 'response')\n flow.description = `Translated flow ${index + 1}`\n result.push(flow)\n })\n }\n return result\n }\n\n protected static _runnableIntoFlow(runnable: LegacyRunnable, trigger: 'request' | 'response'): IHttpFlow {\n const flow: IHttpFlow = {\n trigger,\n actions: [],\n }\n const { actions, condition } = runnable\n if (condition) {\n flow.condition = this._translateCondition(condition)\n }\n actions.forEach((action, index) => {\n const current: IHttpAction = {\n steps: this._translateAction(action),\n }\n if (action.name) {\n current.description = action.name\n } else {\n current.description = `Translated action ${index + 1}`\n }\n flow.actions.push(current)\n })\n return flow\n }\n\n protected static _translateCondition(runnable: LegacyCondition): IHttpAction | undefined {\n const { source, alwaysPass, operator, path, predictedValue, type } = runnable\n if (alwaysPass) {\n // in the flow, if there's no condition the steps are always executed.\n return undefined\n }\n if (!path || !type) {\n return undefined\n }\n if (!['request', 'response'].includes(type)) {\n return\n }\n\n const result: IHttpAction = {\n steps: [],\n }\n const readData = new ReadDataStep()\n readData.source = type === 'request' ? FlowSourceEnum.request : FlowSourceEnum.response\n readData.path = path\n if (source) {\n if (type === 'request') {\n readData.data = source as FlowRequestDataEnum\n } else if (type === 'response') {\n readData.data = source as FlowResponseDataEnum\n }\n }\n result.steps.push(readData.toJSON())\n if (!operator) {\n return result\n }\n if (operator === 'contains') {\n const assertion = new IncludesAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'equal') {\n const assertion = new EqualAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'not-equal') {\n const assertion = new NotEqualAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'greater-than') {\n const assertion = new GreaterThanAssertion()\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'greater-than-equal') {\n const assertion = new GreaterThanAssertion()\n assertion.equal = true\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'less-than') {\n const assertion = new LessThanAssertion()\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'less-than-equal') {\n const assertion = new LessThanAssertion()\n assertion.equal = true\n if (predictedValue) {\n const typed = Number(predictedValue)\n if (!Number.isNaN(typed)) {\n assertion.value = typed\n }\n }\n result.steps.push(assertion.toJSON())\n } else if (operator === 'regex') {\n const assertion = new MatchesAssertion()\n if (predictedValue) {\n assertion.value = String(predictedValue)\n }\n result.steps.push(assertion.toJSON())\n }\n return result\n }\n\n protected static _translateAction(item: LegacyAction): IHttpStep[] {\n switch (item.name) {\n case 'set-cookie':\n return this._translateSetCookieAction(item)\n case 'set-variable':\n return this._translateSetVariableAction(item)\n case 'delete-cookie':\n return this._translateDeleteCookieAction(item)\n default:\n return []\n }\n }\n\n protected static _translateSetCookieAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as SetCookieConfig\n\n const steps: IHttpStep[] = []\n const ds = this._translateDataSource(legacy.source)\n steps.push(ds)\n\n const action: ISetCookieStep = {\n kind: SetCookieStepKind,\n name: legacy.name,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n if (legacy.url) {\n action.url = legacy.url\n }\n if (legacy.expires) {\n action.expires = legacy.expires\n }\n if (typeof legacy.hostOnly === 'boolean') {\n action.hostOnly = legacy.hostOnly\n }\n if (typeof legacy.httpOnly === 'boolean') {\n action.httpOnly = legacy.httpOnly\n }\n if (typeof legacy.secure === 'boolean') {\n action.secure = legacy.secure\n }\n if (typeof legacy.session === 'boolean') {\n action.session = legacy.session\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateSetVariableAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as SetVariableConfig\n\n const steps: IHttpStep[] = []\n const ds = this._translateDataSource(legacy.source)\n steps.push(ds)\n\n const action: ISetCookieStep = {\n kind: SetCookieStepKind,\n name: legacy.name,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateDeleteCookieAction(item: LegacyAction): IHttpStep[] {\n const legacy = item.config as DeleteCookieConfig\n\n const steps: IHttpStep[] = []\n\n const action: IDeleteCookieStep = {\n kind: DeleteCookieStepKind,\n }\n if (item.enabled === false) {\n action.enabled = item.enabled\n }\n if (legacy.name && !legacy.removeAll) {\n action.name = legacy.name\n }\n if (legacy.url && !legacy.useRequestUrl) {\n action.url = legacy.url\n }\n steps.push(action)\n\n return steps\n }\n\n protected static _translateDataSource(source: DataSourceConfiguration): IHttpStep {\n if (source.value) {\n const dataSet: ISetDataStep = {\n kind: SetDataStepKind,\n value: source.value,\n dataType: AmfNamespace.w3.xmlSchema.string,\n }\n return dataSet\n }\n\n // Note, there's no way for us to translate the old \"iterator\" configuration\n // to the current syntax. We just drop it.\n\n const { path, type, source: legacySource } = source\n const result: IReadDataStep = {\n kind: ReadDataStepKind,\n }\n\n if (typeof path === 'string') {\n result.path = path\n }\n if (type) {\n switch (type) {\n case 'request':\n result.source = FlowSourceEnum.request\n break\n case 'response':\n result.source = FlowSourceEnum.response\n break\n }\n }\n if (type && legacySource) {\n if (type === 'request') {\n result.data = legacySource as FlowRequestDataEnum\n }\n if (type === 'response') {\n result.data = legacySource as FlowResponseDataEnum\n }\n }\n return result\n }\n}\n"]}
|
|
@@ -17,7 +17,7 @@ import { SubstringStepKind } from '../../models/http-flows/steps/transformation/
|
|
|
17
17
|
import { TrimStepKind } from '../../models/http-flows/steps/transformation/TrimStep.js';
|
|
18
18
|
import { EqualAssertionKind } from '../../models/http-flows/steps/assertion/EqualAssertion.js';
|
|
19
19
|
import { NotEqualAssertionKind } from '../../models/http-flows/steps/assertion/NotEqualAssertion.js';
|
|
20
|
-
import { ApiSchemaValues } from '
|
|
20
|
+
import { ApiSchemaValues } from '@api-client/amf-core';
|
|
21
21
|
import { GreaterThanAssertionKind, } from '../../models/http-flows/steps/assertion/GreaterThanAssertion.js';
|
|
22
22
|
import { LessThanAssertionKind } from '../../models/http-flows/steps/assertion/LessThanAssertion.js';
|
|
23
23
|
import { IncludesAssertionKind } from '../../models/http-flows/steps/assertion/IncludesAssertion.js';
|