@api-client/core 0.19.10 → 0.19.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -63
- package/bin/test.ts +1 -12
- package/build/src/browser.d.ts +0 -15
- package/build/src/browser.d.ts.map +1 -1
- package/build/src/browser.js +0 -17
- package/build/src/browser.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -6
- package/build/src/events/EventTypes.d.ts.map +1 -1
- package/build/src/events/EventTypes.js +0 -2
- package/build/src/events/EventTypes.js.map +1 -1
- package/build/src/events/Events.d.ts +0 -2
- package/build/src/events/Events.d.ts.map +1 -1
- package/build/src/events/Events.js +0 -2
- package/build/src/events/Events.js.map +1 -1
- package/build/src/index.d.ts +0 -15
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +0 -17
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/Bindings.d.ts +3 -3
- package/build/src/modeling/Bindings.d.ts.map +1 -1
- package/build/src/modeling/Bindings.js.map +1 -1
- package/build/src/modeling/DomainAssociation.d.ts +5 -5
- package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
- package/build/src/modeling/DomainAssociation.js.map +1 -1
- package/build/src/modeling/DomainEntity.d.ts +2 -3
- package/build/src/modeling/DomainEntity.d.ts.map +1 -1
- package/build/src/modeling/DomainEntity.js +1 -1
- package/build/src/modeling/DomainEntity.js.map +1 -1
- package/build/src/modeling/DomainProperty.d.ts +2 -3
- package/build/src/modeling/DomainProperty.d.ts.map +1 -1
- package/build/src/modeling/DomainProperty.js +1 -1
- package/build/src/modeling/DomainProperty.js.map +1 -1
- package/build/src/modeling/ai/types.d.ts +2 -2
- package/build/src/modeling/ai/types.d.ts.map +1 -1
- package/build/src/modeling/ai/types.js.map +1 -1
- package/build/src/{amf → modeling/amf}/DataValueGenerator.d.ts +1 -1
- package/build/src/modeling/amf/DataValueGenerator.d.ts.map +1 -0
- package/build/src/{amf → modeling/amf}/DataValueGenerator.js +2 -3
- package/build/src/modeling/amf/DataValueGenerator.js.map +1 -0
- package/build/src/modeling/amf/ShapeGenerator.d.ts +20 -20
- package/build/src/modeling/amf/ShapeGenerator.d.ts.map +1 -1
- package/build/src/modeling/amf/ShapeGenerator.js +16 -18
- package/build/src/modeling/amf/ShapeGenerator.js.map +1 -1
- package/build/src/modeling/amf/core_types.d.ts +9 -0
- package/build/src/modeling/amf/core_types.d.ts.map +1 -0
- package/build/src/modeling/amf/core_types.js +45 -0
- package/build/src/modeling/amf/core_types.js.map +1 -0
- package/build/src/models/http-flows/LegacyTranslator.js +1 -1
- package/build/src/models/http-flows/LegacyTranslator.js.map +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js +1 -1
- package/build/src/runtime/http-runner/HttpFlows.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +0 -1
- package/package.json +11 -14
- package/src/events/EventTypes.ts +0 -2
- package/src/events/Events.ts +0 -2
- package/src/modeling/Bindings.ts +3 -3
- package/src/modeling/DomainAssociation.ts +5 -5
- package/src/modeling/DomainEntity.ts +3 -4
- package/src/modeling/DomainProperty.ts +3 -4
- package/src/modeling/ai/types.ts +2 -2
- package/src/{amf → modeling/amf}/DataValueGenerator.ts +3 -4
- package/src/modeling/amf/ShapeGenerator.ts +45 -61
- package/src/modeling/amf/core_types.ts +47 -0
- package/src/models/http-flows/LegacyTranslator.ts +1 -1
- package/src/runtime/http-runner/HttpFlows.ts +1 -1
- package/tests/unit/{amf → modeling/amf}/data_value_generator.spec.ts +2 -2
- package/tests/unit/modeling/amf/shape_generator.spec.ts +146 -167
- package/tests/unit/modeling/domain_asociation.spec.ts +13 -13
- package/tests/unit/runtime/runners/http_assertion_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/http_flow_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/project_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/request_runner.spec.ts +1 -1
- package/tests/unit/runtime/runners/serial_runner.spec.ts +1 -1
- package/build/src/amf/AmfMixin.d.ts +0 -396
- package/build/src/amf/AmfMixin.d.ts.map +0 -1
- package/build/src/amf/AmfMixin.js +0 -1138
- package/build/src/amf/AmfMixin.js.map +0 -1
- package/build/src/amf/AmfSerializer.d.ts +0 -137
- package/build/src/amf/AmfSerializer.d.ts.map +0 -1
- package/build/src/amf/AmfSerializer.js +0 -1947
- package/build/src/amf/AmfSerializer.js.map +0 -1
- package/build/src/amf/AmfTypes.d.ts +0 -25
- package/build/src/amf/AmfTypes.d.ts.map +0 -1
- package/build/src/amf/AmfTypes.js +0 -143
- package/build/src/amf/AmfTypes.js.map +0 -1
- package/build/src/amf/ApiExampleGenerator.d.ts +0 -40
- package/build/src/amf/ApiExampleGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiExampleGenerator.js +0 -112
- package/build/src/amf/ApiExampleGenerator.js.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts +0 -68
- package/build/src/amf/ApiMonacoSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiMonacoSchemaGenerator.js +0 -248
- package/build/src/amf/ApiMonacoSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.d.ts +0 -56
- package/build/src/amf/ApiSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaGenerator.js +0 -94
- package/build/src/amf/ApiSchemaGenerator.js.map +0 -1
- package/build/src/amf/ApiSchemaValues.d.ts +0 -111
- package/build/src/amf/ApiSchemaValues.d.ts.map +0 -1
- package/build/src/amf/ApiSchemaValues.js +0 -463
- package/build/src/amf/ApiSchemaValues.js.map +0 -1
- package/build/src/amf/DataValueGenerator.d.ts.map +0 -1
- package/build/src/amf/DataValueGenerator.js.map +0 -1
- package/build/src/amf/Parsing.d.ts +0 -48
- package/build/src/amf/Parsing.d.ts.map +0 -1
- package/build/src/amf/Parsing.js +0 -2
- package/build/src/amf/Parsing.js.map +0 -1
- package/build/src/amf/Utils.d.ts +0 -37
- package/build/src/amf/Utils.d.ts.map +0 -1
- package/build/src/amf/Utils.js +0 -169
- package/build/src/amf/Utils.js.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.d.ts +0 -34
- package/build/src/amf/data-node/DataNodeBase.d.ts.map +0 -1
- package/build/src/amf/data-node/DataNodeBase.js +0 -77
- package/build/src/amf/data-node/DataNodeBase.js.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts +0 -15
- package/build/src/amf/data-node/JsonDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/JsonDataNodeGenerator.js +0 -23
- package/build/src/amf/data-node/JsonDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts +0 -14
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js +0 -48
- package/build/src/amf/data-node/UrlEncodedDataNodeGenerator.js.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts +0 -22
- package/build/src/amf/data-node/XmlDataNodeGenerator.d.ts.map +0 -1
- package/build/src/amf/data-node/XmlDataNodeGenerator.js +0 -34
- package/build/src/amf/data-node/XmlDataNodeGenerator.js.map +0 -1
- package/build/src/amf/definitions/Amf.d.ts +0 -363
- package/build/src/amf/definitions/Amf.d.ts.map +0 -1
- package/build/src/amf/definitions/Amf.js +0 -3
- package/build/src/amf/definitions/Amf.js.map +0 -1
- package/build/src/amf/definitions/Api.d.ts +0 -383
- package/build/src/amf/definitions/Api.d.ts.map +0 -1
- package/build/src/amf/definitions/Api.js +0 -2
- package/build/src/amf/definitions/Api.js.map +0 -1
- package/build/src/amf/definitions/Base.d.ts +0 -12
- package/build/src/amf/definitions/Base.d.ts.map +0 -1
- package/build/src/amf/definitions/Base.js +0 -2
- package/build/src/amf/definitions/Base.js.map +0 -1
- package/build/src/amf/definitions/Namespace.d.ts +0 -327
- package/build/src/amf/definitions/Namespace.d.ts.map +0 -1
- package/build/src/amf/definitions/Namespace.js +0 -346
- package/build/src/amf/definitions/Namespace.js.map +0 -1
- package/build/src/amf/definitions/Shapes.d.ts +0 -312
- package/build/src/amf/definitions/Shapes.d.ts.map +0 -1
- package/build/src/amf/definitions/Shapes.js +0 -87
- package/build/src/amf/definitions/Shapes.js.map +0 -1
- package/build/src/amf/models/AmfDataNode.d.ts +0 -67
- package/build/src/amf/models/AmfDataNode.d.ts.map +0 -1
- package/build/src/amf/models/AmfDataNode.js +0 -192
- package/build/src/amf/models/AmfDataNode.js.map +0 -1
- package/build/src/amf/shape/ShapeBase.d.ts +0 -74
- package/build/src/amf/shape/ShapeBase.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeBase.js +0 -93
- package/build/src/amf/shape/ShapeBase.js.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts +0 -47
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js +0 -420
- package/build/src/amf/shape/ShapeJsonSchemaGenerator.js.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts +0 -85
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.d.ts.map +0 -1
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js +0 -852
- package/build/src/amf/shape/ShapeXmlSchemaGenerator.js.map +0 -1
- package/build/src/events/amf/AmfEventTypes.d.ts +0 -7
- package/build/src/events/amf/AmfEventTypes.d.ts.map +0 -1
- package/build/src/events/amf/AmfEventTypes.js +0 -7
- package/build/src/events/amf/AmfEventTypes.js.map +0 -1
- package/build/src/events/amf/AmfEvents.d.ts +0 -34
- package/build/src/events/amf/AmfEvents.d.ts.map +0 -1
- package/build/src/events/amf/AmfEvents.js +0 -63
- package/build/src/events/amf/AmfEvents.js.map +0 -1
- package/build/src/mocking/RandExp.d.ts +0 -55
- package/build/src/mocking/RandExp.d.ts.map +0 -1
- package/build/src/mocking/RandExp.js +0 -302
- package/build/src/mocking/RandExp.js.map +0 -1
- package/build/src/mocking/lib/ret.d.ts +0 -16
- package/build/src/mocking/lib/ret.d.ts.map +0 -1
- package/build/src/mocking/lib/ret.js +0 -284
- package/build/src/mocking/lib/ret.js.map +0 -1
- package/data/apis/APIC-187/APIC-187.raml +0 -21
- package/data/apis/APIC-187/dataType.raml +0 -132
- package/data/apis/APIC-187/example.raml +0 -84
- package/data/apis/APIC-188/APIC-188.raml +0 -21
- package/data/apis/APIC-188/dataType.raml +0 -132
- package/data/apis/APIC-188/example.raml +0 -84
- package/data/apis/APIC-233/APIC-233.raml +0 -15
- package/data/apis/APIC-391/APIC-391.raml +0 -44
- package/data/apis/APIC-391/examples/post-body-request-example.raml +0 -7
- package/data/apis/APIC-483/APIC-483.raml +0 -16
- package/data/apis/APIC-483/example/list-of-bank-succ.json +0 -32
- package/data/apis/APIC-483/schema/response-retrieve-list-bank.json +0 -68
- package/data/apis/APIC-487/APIC-487.raml +0 -36
- package/data/apis/APIC-655/APIC-655.raml +0 -44
- package/data/apis/APIC-655/delivery.json +0 -12
- package/data/apis/APIC-689/APIC-689.raml +0 -20
- package/data/apis/APIC-690/APIC-690.raml +0 -17
- package/data/apis/APIC-690/datatypes/Address.raml +0 -10
- package/data/apis/APIC-690/datatypes/Customer.raml +0 -17
- package/data/apis/APIC-690/examples/CustomerExample2.raml +0 -17
- package/data/apis/APIC-690/examples/CustomersExample.raml +0 -34
- package/data/apis/SE-10469/Purchase-Order-oagis-id-dd32f9c6c01048a19e15c423c9c741ae.json +0 -1383
- package/data/apis/SE-10469/SE-10469.raml +0 -11
- package/data/apis/SE-13092/Examples/PersonExample.raml +0 -7
- package/data/apis/SE-13092/SE-13092.raml +0 -37
- package/data/apis/SE-13092/datatypes/Address.raml +0 -5
- package/data/apis/SE-13092/datatypes/InlineType.raml +0 -5
- package/data/apis/SE-13092/datatypes/Person.raml +0 -15
- package/data/apis/SE-22063/SE-22063.raml +0 -14
- package/data/apis/SE-22063/stock.raml +0 -41
- package/data/apis/amf-helper-api/amf-helper-api.raml +0 -1024
- package/data/apis/amf-helper-api/examples/comment-example.json +0 -42
- package/data/apis/amf-helper-api/examples/commentCreateRequest-example.json +0 -7
- package/data/apis/amf-helper-api/examples/commentList-example.json +0 -48
- package/data/apis/amf-helper-api/examples/person.json +0 -14
- package/data/apis/amf-helper-api/examples/person.raml +0 -13
- package/data/apis/amf-helper-api/examples/person.xml +0 -14
- package/data/apis/amf-helper-api/libraries/comment-lib.raml +0 -143
- package/data/apis/amf-helper-api/library.raml +0 -7
- package/data/apis/amf-helper-api/schemas/person.json +0 -104
- package/data/apis/amf-helper-api/schemas/person.xsd +0 -26
- package/data/apis/amf-helper-api/traits/file.raml +0 -33
- package/data/apis/amf-helper-api/traits/pagination.raml +0 -80
- package/data/apis/amf-helper-api/traits/results.raml +0 -19
- package/data/apis/amf-helper-api/traits/visibility.raml +0 -14
- package/data/apis/amf-helper-api/types/app-person.raml +0 -101
- package/data/apis/amf-helper-api/types/dimensions.raml +0 -24
- package/data/apis/amf-helper-api/types/external-type.raml +0 -7
- package/data/apis/amf-helper-api/types/image.raml +0 -23
- package/data/apis/amf-helper-api/types/product.raml +0 -52
- package/data/apis/amf-helper-api/types/resource.raml +0 -11
- package/data/apis/amf-helper-api/types/standard-request.raml +0 -50
- package/data/apis/amf-helper-api/types/user.raml +0 -37
- package/data/apis/arc-demo-api/arc-demo-api.raml +0 -468
- package/data/apis/arc-demo-api/examples/e400.xml +0 -4
- package/data/apis/arc-demo-api/examples/e401.xml +0 -4
- package/data/apis/arc-demo-api/examples/e404.xml +0 -4
- package/data/apis/arc-demo-api/examples/image.xml +0 -5
- package/data/apis/arc-demo-api/examples/messages-example.json +0 -22
- package/data/apis/arc-demo-api/examples/messages-sent-example.json +0 -15
- package/data/apis/arc-demo-api/examples/person.json +0 -14
- package/data/apis/arc-demo-api/examples/person.url.encoded +0 -1
- package/data/apis/arc-demo-api/examples/person.xml +0 -14
- package/data/apis/arc-demo-api/examples/product.xml +0 -9
- package/data/apis/arc-demo-api/library.raml +0 -36
- package/data/apis/arc-demo-api/resourceTypes/app-person.raml +0 -49
- package/data/apis/arc-demo-api/resourceTypes/example-types.raml +0 -45
- package/data/apis/arc-demo-api/resourceTypes/image.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-sent-type.raml +0 -23
- package/data/apis/arc-demo-api/resourceTypes/message-type.raml +0 -33
- package/data/apis/arc-demo-api/resourceTypes/product.raml +0 -52
- package/data/apis/arc-demo-api/resourceTypes/resource.raml +0 -11
- package/data/apis/arc-demo-api/schemas/error-response.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/image.xsd +0 -11
- package/data/apis/arc-demo-api/schemas/person.json +0 -104
- package/data/apis/arc-demo-api/schemas/person.xsd +0 -26
- package/data/apis/arc-demo-api/schemas/product.xsd +0 -17
- package/data/apis/arc-demo-api/securitySchemes/basic.raml +0 -5
- package/data/apis/arc-demo-api/securitySchemes/oauth_2_0.raml +0 -29
- package/data/apis/arc-demo-api/securitySchemes/x-custom.raml +0 -26
- package/data/apis/arc-demo-api/traits/adminable.raml +0 -23
- package/data/apis/arc-demo-api/traits/pagination.raml +0 -83
- package/data/apis/arc-demo-api/traits/rate-limited.raml +0 -9
- package/data/apis/async-api/async-api.yaml +0 -96
- package/data/apis/example-generator-api/contact-email-example.raml +0 -6
- package/data/apis/example-generator-api/contact-example.raml +0 -5
- package/data/apis/example-generator-api/contact-fax-example.raml +0 -5
- package/data/apis/example-generator-api/contact-website-example.raml +0 -2
- package/data/apis/example-generator-api/example-1.raml +0 -6
- package/data/apis/example-generator-api/example-2.raml +0 -9
- package/data/apis/example-generator-api/example-3.raml +0 -4
- package/data/apis/example-generator-api/example-4.raml +0 -2
- package/data/apis/example-generator-api/example-5.raml +0 -4
- package/data/apis/example-generator-api/example-6.raml +0 -2
- package/data/apis/example-generator-api/example-7.raml +0 -5
- package/data/apis/example-generator-api/example-generator-api.raml +0 -423
- package/data/apis/example-generator-api/example.json +0 -14
- package/data/apis/example-generator-api/example.xml +0 -15
- package/data/apis/example-generator-api/example.xsd +0 -26
- package/data/apis/example-generator-api/examples/employee.raml +0 -7
- package/data/apis/example-generator-api/examples/employees.raml +0 -7
- package/data/apis/example-generator-api/linked-named-example.raml +0 -21
- package/data/apis/example-generator-api/named-example-with-link.raml +0 -5
- package/data/apis/example-generator-api/named-example.raml +0 -9
- package/data/apis/example-generator-api/user-json-example.raml +0 -17
- package/data/apis/example-generator-api/user-raml-example.raml +0 -37
- package/data/apis/example-generator-api/user.json +0 -8
- package/data/apis/example-generator-api/user.raml +0 -18
- package/data/apis/example-generator-api/users-json-example.raml +0 -17
- package/data/apis/example-generator-api/users-raml-example.raml +0 -32
- package/data/apis/example-generator-api/users.json +0 -8
- package/data/apis/expanded-api/expanded-api.raml +0 -8
- package/data/apis/flattened-api/flattened-api.raml +0 -8
- package/data/apis/multiple-servers/multiple-servers.yaml +0 -112
- package/data/apis/oas-3-api/oas-3-api.yaml +0 -356
- package/data/apis/oas-date/oas-date.yaml +0 -28
- package/data/apis/oas-types/oas-types.yaml +0 -159
- package/data/apis/oas-unions/oas-unions.yaml +0 -75
- package/data/apis/petstore/petstore.yaml +0 -954
- package/data/apis/raml-date/raml-date.raml +0 -28
- package/data/apis/recursive/recursive.raml +0 -14
- package/data/apis/schema-api/examples/person.json +0 -14
- package/data/apis/schema-api/examples/person.raml +0 -14
- package/data/apis/schema-api/examples/person.url.encoded +0 -1
- package/data/apis/schema-api/examples/person.xml +0 -14
- package/data/apis/schema-api/library/demo-types.raml +0 -43
- package/data/apis/schema-api/schema-api.raml +0 -656
- package/data/apis/schema-api/schemas/person.json +0 -104
- package/data/apis/schema-api/schemas/person.xsd +0 -26
- package/data/apis/schema-api/types/DemoPerson.raml +0 -67
- package/data/apis/secured-api/oauth-2-custom-settings.raml +0 -143
- package/data/apis/secured-api/oauth2-header-delivery.raml +0 -13
- package/data/apis/secured-api/oauth2-no-delivery.raml +0 -8
- package/data/apis/secured-api/oauth2-no-grants.raml +0 -12
- package/data/apis/secured-api/oauth2-pkce.raml +0 -13
- package/data/apis/secured-api/oauth2-query-delivery.raml +0 -13
- package/data/apis/secured-api/oauth_1_0.raml +0 -8
- package/data/apis/secured-api/oauth_1_0_no-settings.raml +0 -3
- package/data/apis/secured-api/oauth_1_0_no-signature.raml +0 -7
- package/data/apis/secured-api/oauth_1_0_signature.raml +0 -8
- package/data/apis/secured-api/passthrough-querystring.raml +0 -16
- package/data/apis/secured-api/passthrough.raml +0 -24
- package/data/apis/secured-api/secured-api.raml +0 -231
- package/data/apis/secured-api/x-custom.raml +0 -33
- package/data/apis/secured-api/x-other.raml +0 -29
- package/data/apis/secured-api/x-query-string.raml +0 -16
- package/data/apis/tracked-examples/datatypes/employee.raml +0 -5
- package/data/apis/tracked-examples/examples/employee.raml +0 -4
- package/data/apis/tracked-examples/examples/employees.raml +0 -8
- package/data/apis/tracked-examples/tracked-to-linked.raml +0 -28
- package/data/model.js +0 -129
- package/data/models/APIC-187.json +0 -11416
- package/data/models/APIC-188.json +0 -11416
- package/data/models/APIC-233.json +0 -539
- package/data/models/APIC-391.json +0 -1903
- package/data/models/APIC-483.json +0 -3110
- package/data/models/APIC-487.json +0 -1225
- package/data/models/APIC-655.json +0 -3145
- package/data/models/APIC-689.json +0 -797
- package/data/models/APIC-690.json +0 -5992
- package/data/models/SE-10469.json +0 -22898
- package/data/models/SE-13092.json +0 -2769
- package/data/models/SE-22063.json +0 -2314
- package/data/models/amf-helper-api.json +0 -84457
- package/data/models/arc-demo-api.json +0 -52041
- package/data/models/async-api.json +0 -3227
- package/data/models/example-generator-api.json +0 -45209
- package/data/models/expanded-api.json +0 -251
- package/data/models/flattened-api.json +0 -251
- package/data/models/multiple-servers.json +0 -2769
- package/data/models/oas-3-api.json +0 -10590
- package/data/models/oas-date.json +0 -637
- package/data/models/oas-types.json +0 -5352
- package/data/models/oas-unions.json +0 -1935
- package/data/models/petstore.json +0 -27712
- package/data/models/raml-date.json +0 -1114
- package/data/models/recursive.json +0 -610
- package/data/models/schema-api.json +0 -35527
- package/data/models/secured-api.json +0 -21071
- package/data/models/tracked-to-linked.json +0 -1914
- package/src/amf/AmfMixin.ts +0 -1726
- package/src/amf/AmfSerializer.ts +0 -2358
- package/src/amf/AmfTypes.ts +0 -147
- package/src/amf/ApiExampleGenerator.ts +0 -122
- package/src/amf/ApiMonacoSchemaGenerator.ts +0 -332
- package/src/amf/ApiSchemaGenerator.ts +0 -115
- package/src/amf/ApiSchemaValues.ts +0 -509
- package/src/amf/Parsing.ts +0 -50
- package/src/amf/Utils.ts +0 -172
- package/src/amf/data-node/DataNodeBase.ts +0 -83
- package/src/amf/data-node/JsonDataNodeGenerator.ts +0 -24
- package/src/amf/data-node/README.md +0 -3
- package/src/amf/data-node/UrlEncodedDataNodeGenerator.ts +0 -49
- package/src/amf/data-node/XmlDataNodeGenerator.ts +0 -46
- package/src/amf/definitions/Amf.ts +0 -440
- package/src/amf/definitions/Api.ts +0 -445
- package/src/amf/definitions/Base.ts +0 -13
- package/src/amf/definitions/Namespace.ts +0 -357
- package/src/amf/definitions/Shapes.ts +0 -438
- package/src/amf/models/AmfDataNode.ts +0 -210
- package/src/amf/shape/README.md +0 -4
- package/src/amf/shape/ShapeBase.ts +0 -174
- package/src/amf/shape/ShapeJsonSchemaGenerator.ts +0 -457
- package/src/amf/shape/ShapeXmlSchemaGenerator.ts +0 -933
- package/src/events/amf/AmfEventTypes.ts +0 -6
- package/src/events/amf/AmfEvents.ts +0 -78
- package/src/mocking/RandExp.ts +0 -335
- package/src/mocking/lib/ret.ts +0 -279
- package/tests/unit/amf/APIC-187.spec.ts +0 -41
- package/tests/unit/amf/APIC-188.spec.ts +0 -30
- package/tests/unit/amf/APIC-233.spec.ts +0 -32
- package/tests/unit/amf/APIC-391.spec.ts +0 -39
- package/tests/unit/amf/APIC-487.spec.ts +0 -44
- package/tests/unit/amf/APIC-655.spec.ts +0 -41
- package/tests/unit/amf/APIC-689.spec.ts +0 -28
- package/tests/unit/amf/APIC-690.spec.ts +0 -93
- package/tests/unit/amf/AmfLoader.ts +0 -538
- package/tests/unit/amf/AmfMixin.spec.ts +0 -1707
- package/tests/unit/amf/ApiExampleGenerator.spec.ts +0 -250
- package/tests/unit/amf/ApiMonacoSchemaGenerator.spec.ts +0 -183
- package/tests/unit/amf/ApiSchemaValues.spec.ts +0 -602
- package/tests/unit/amf/Namepsace.spec.ts +0 -494
- package/tests/unit/amf/SE-10469.spec.ts +0 -35
- package/tests/unit/amf/SE-13092.spec.ts +0 -64
- package/tests/unit/amf/SE-22063.spec.ts +0 -45
- package/tests/unit/amf/raml-examples.spec.ts +0 -43
- package/tests/unit/amf/schema_gen_array.spec.ts +0 -199
- package/tests/unit/amf/schema_gen_oas.spec.ts +0 -140
- package/tests/unit/amf/schema_gen_object.spec.ts +0 -279
- package/tests/unit/amf/schema_gen_scalar.spec.ts +0 -143
- package/tests/unit/amf/schema_gen_union.spec.ts +0 -401
- package/tests/unit/amf/schema_gen_unknown.spec.ts +0 -42
- package/tests/unit/amf/schema_gen_xml.spec.ts +0 -726
- package/tests/unit/amf/serializer/APIC-483.spec.ts +0 -36
- package/tests/unit/amf/serializer/Anotations.spec.ts +0 -50
- package/tests/unit/amf/serializer/Api.spec.ts +0 -210
- package/tests/unit/amf/serializer/Documentation.spec.ts +0 -52
- package/tests/unit/amf/serializer/Endpoints.spec.ts +0 -172
- package/tests/unit/amf/serializer/Operations.spec.ts +0 -330
- package/tests/unit/amf/serializer/Parameters.spec.ts +0 -149
- package/tests/unit/amf/serializer/PayloadExamples.spec.ts +0 -152
- package/tests/unit/amf/serializer/Security.spec.ts +0 -626
- package/tests/unit/amf/serializer/Server.spec.ts +0 -78
- package/tests/unit/amf/serializer/Shapes.spec.ts +0 -304
- package/tests/unit/amf/serializer/SourceMaps.spec.ts +0 -52
- package/tests/unit/amf/shapes/ShapeXmlSchemaGenerator.spec.ts +0 -28
- package/tests/unit/amf/tracked-to-linked.spec.ts +0 -90
- package/tests/unit/amf/xml-data-processing.spec.ts +0 -217
- package/tests/unit/events/amf.spec.ts +0 -151
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { nanoid } from '../../nanoid.js';
|
|
2
|
-
import { IAmfArrayNodeTypes, IAmfObjectNodeTypes, IAmfScalarNodeTypes } from '../AmfTypes.js';
|
|
3
|
-
import { AmfNamespace } from '../definitions/Namespace.js';
|
|
4
|
-
/**
|
|
5
|
-
* A class that manipulates the AMF's DataNode node.
|
|
6
|
-
*/
|
|
7
|
-
export class AmfDataNode {
|
|
8
|
-
id = nanoid();
|
|
9
|
-
/**
|
|
10
|
-
* AMF domain types.
|
|
11
|
-
* This is set in the constructor
|
|
12
|
-
*/
|
|
13
|
-
types;
|
|
14
|
-
/**
|
|
15
|
-
* The name of this data node.
|
|
16
|
-
*/
|
|
17
|
-
name;
|
|
18
|
-
/**
|
|
19
|
-
* Set when the object node type
|
|
20
|
-
*/
|
|
21
|
-
properties;
|
|
22
|
-
/**
|
|
23
|
-
* Scalar type value. Always a string.
|
|
24
|
-
*/
|
|
25
|
-
value;
|
|
26
|
-
/**
|
|
27
|
-
* Scalar type value data type.
|
|
28
|
-
*/
|
|
29
|
-
dataType;
|
|
30
|
-
/**
|
|
31
|
-
* Set when the type is array.
|
|
32
|
-
*/
|
|
33
|
-
members;
|
|
34
|
-
customDomainProperties = [];
|
|
35
|
-
static scalar(value, type) {
|
|
36
|
-
const result = new AmfDataNode('scalar');
|
|
37
|
-
result.value = value;
|
|
38
|
-
result.dataType = type;
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
constructor(init) {
|
|
42
|
-
if (typeof init === 'string') {
|
|
43
|
-
if (init === 'scalar') {
|
|
44
|
-
this.types = IAmfScalarNodeTypes;
|
|
45
|
-
}
|
|
46
|
-
else if (init === 'array') {
|
|
47
|
-
this.types = IAmfArrayNodeTypes;
|
|
48
|
-
}
|
|
49
|
-
else if (init === 'object') {
|
|
50
|
-
this.types = IAmfObjectNodeTypes;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
throw new Error(`Invalid data node init option: ${init}`);
|
|
54
|
-
}
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!init) {
|
|
58
|
-
throw new Error(`Expected an initialization option.`);
|
|
59
|
-
}
|
|
60
|
-
const union = init;
|
|
61
|
-
const { id, types, customDomainProperties } = union;
|
|
62
|
-
this.id = id;
|
|
63
|
-
this.types = types;
|
|
64
|
-
this.customDomainProperties = customDomainProperties;
|
|
65
|
-
if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {
|
|
66
|
-
const typed = union;
|
|
67
|
-
this.value = typed.value;
|
|
68
|
-
this.dataType = typed.dataType;
|
|
69
|
-
}
|
|
70
|
-
else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
71
|
-
const typed = union;
|
|
72
|
-
const props = {};
|
|
73
|
-
this.properties = props;
|
|
74
|
-
Object.keys(typed.properties).forEach((key) => {
|
|
75
|
-
const instance = new AmfDataNode(typed.properties[key]);
|
|
76
|
-
props[key] = instance;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
80
|
-
const typed = union;
|
|
81
|
-
const members = [];
|
|
82
|
-
this.members = members;
|
|
83
|
-
if (Array.isArray(typed.members)) {
|
|
84
|
-
typed.members.forEach((member) => {
|
|
85
|
-
const instance = new AmfDataNode(member);
|
|
86
|
-
members.push(instance);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
toJSON() {
|
|
92
|
-
const { id, customDomainProperties, types, name } = this;
|
|
93
|
-
const result = {
|
|
94
|
-
id,
|
|
95
|
-
types,
|
|
96
|
-
customDomainProperties,
|
|
97
|
-
};
|
|
98
|
-
if (name) {
|
|
99
|
-
result.name = name;
|
|
100
|
-
}
|
|
101
|
-
if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {
|
|
102
|
-
const typed = result;
|
|
103
|
-
typed.dataType = this.dataType;
|
|
104
|
-
typed.value = this.value;
|
|
105
|
-
}
|
|
106
|
-
else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
107
|
-
const typed = result;
|
|
108
|
-
typed.properties = {};
|
|
109
|
-
const props = this.properties;
|
|
110
|
-
if (props) {
|
|
111
|
-
Object.keys(props).forEach((key) => {
|
|
112
|
-
typed.properties[key] = props[key].toJSON();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
117
|
-
const typed = result;
|
|
118
|
-
typed.members = [];
|
|
119
|
-
if (this.members) {
|
|
120
|
-
this.members.forEach((member) => {
|
|
121
|
-
typed.members.push(member.toJSON());
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Adds a member to the list of members.
|
|
129
|
-
* It throws when this is not an array node.
|
|
130
|
-
*
|
|
131
|
-
* @param init The member to add.
|
|
132
|
-
*/
|
|
133
|
-
addMember(init) {
|
|
134
|
-
if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
135
|
-
throw new Error(`Not an ArrayNode.`);
|
|
136
|
-
}
|
|
137
|
-
if (!this.members) {
|
|
138
|
-
this.members = [];
|
|
139
|
-
}
|
|
140
|
-
this.members.push(init);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Removes a member from the list of members.
|
|
144
|
-
* It throws when this is not an array node.
|
|
145
|
-
*
|
|
146
|
-
* @param id The domain id of the member to remove.
|
|
147
|
-
*/
|
|
148
|
-
removeMember(id) {
|
|
149
|
-
if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Array)) {
|
|
150
|
-
throw new Error(`Not an ArrayNode.`);
|
|
151
|
-
}
|
|
152
|
-
if (!this.members) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const index = this.members.findIndex((i) => i.id === id);
|
|
156
|
-
if (index >= 0) {
|
|
157
|
-
this.members.splice(index, 1);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Adds a property to the ObjectNode.
|
|
162
|
-
* It throws when this is not an object node.
|
|
163
|
-
*
|
|
164
|
-
* @param name The name of the property.
|
|
165
|
-
* @param value The instance of the DataNode to set.
|
|
166
|
-
*/
|
|
167
|
-
addProperty(name, value) {
|
|
168
|
-
if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
169
|
-
throw new Error(`Not an ObjectNode.`);
|
|
170
|
-
}
|
|
171
|
-
if (!this.properties) {
|
|
172
|
-
this.properties = {};
|
|
173
|
-
}
|
|
174
|
-
this.properties[name] = value;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Deletes a property by name.
|
|
178
|
-
*
|
|
179
|
-
* @param name The name of the property to delete.
|
|
180
|
-
*/
|
|
181
|
-
removeProperty(name) {
|
|
182
|
-
if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Object)) {
|
|
183
|
-
throw new Error(`Not an ObjectNode.`);
|
|
184
|
-
}
|
|
185
|
-
if (!this.properties) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
189
|
-
delete this.properties[name];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
//# sourceMappingURL=AmfDataNode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AmfDataNode.js","sourceRoot":"","sources":["../../../../src/amf/models/AmfDataNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAE7F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,C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AE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QACxD,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,IAAY,EAAE,KAAkB;QAC1C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QACvC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACtB,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAAY;QACzB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QACvC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAM;QACR,CAAC;QACD,gEAAgE;QAChE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;CACF","sourcesContent":["import { nanoid } from '../../nanoid.js'\nimport { IAmfArrayNodeTypes, IAmfObjectNodeTypes, IAmfScalarNodeTypes } from '../AmfTypes.js'\nimport { IApiCustomDomainProperty } from '../definitions/Base.js'\nimport { AmfNamespace } from '../definitions/Namespace.js'\nimport {\n IApiArrayNode,\n IApiDataNode,\n IApiDataNodeUnion,\n IApiObjectNode,\n IApiScalarNode,\n} from '../definitions/Shapes.js'\n\nexport type IDataNodeInit = 'scalar' | 'object' | 'array'\n\n/**\n * A class that manipulates the AMF's DataNode node.\n */\nexport class AmfDataNode {\n id = nanoid()\n\n /**\n * AMF domain types.\n * This is set in the constructor\n */\n types: string[]\n\n /**\n * The name of this data node.\n */\n name?: string\n\n /**\n * Set when the object node type\n */\n properties?: Record<string, AmfDataNode>\n\n /**\n * Scalar type value. Always a string.\n */\n value?: string\n\n /**\n * Scalar type value data type.\n */\n dataType?: string\n\n /**\n * Set when the type is array.\n */\n members?: AmfDataNode[]\n\n customDomainProperties: IApiCustomDomainProperty[] = []\n\n static scalar(value: string, type: string): AmfDataNode {\n const result = new AmfDataNode('scalar')\n result.value = value\n result.dataType = type\n return result\n }\n\n constructor(init: IApiDataNodeUnion | IDataNodeInit) {\n if (typeof init === 'string') {\n if (init === 'scalar') {\n this.types = IAmfScalarNodeTypes\n } else if (init === 'array') {\n this.types = IAmfArrayNodeTypes\n } else if (init === 'object') {\n this.types = IAmfObjectNodeTypes\n } else {\n throw new Error(`Invalid data node init option: ${init}`)\n }\n return\n }\n if (!init) {\n throw new Error(`Expected an initialization option.`)\n }\n const union = init as IApiDataNodeUnion\n const { id, types, customDomainProperties } = union\n this.id = id\n this.types = types\n this.customDomainProperties = customDomainProperties\n if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {\n const typed = union as IApiScalarNode\n this.value = typed.value\n this.dataType = typed.dataType\n } else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {\n const typed = union as IApiObjectNode\n const props: Record<string, AmfDataNode> = {}\n this.properties = props\n Object.keys(typed.properties).forEach((key) => {\n const instance = new AmfDataNode(typed.properties[key])\n props[key] = instance\n })\n } else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {\n const typed = union as IApiArrayNode\n const members: AmfDataNode[] = []\n this.members = members\n if (Array.isArray(typed.members)) {\n typed.members.forEach((member) => {\n const instance = new AmfDataNode(member)\n members.push(instance)\n })\n }\n }\n }\n\n toJSON(): IApiDataNodeUnion {\n const { id, customDomainProperties, types, name } = this\n const result: IApiDataNode = {\n id,\n types,\n customDomainProperties,\n }\n if (name) {\n result.name = name\n }\n\n if (types.includes(AmfNamespace.aml.vocabularies.data.Scalar)) {\n const typed = result as IApiScalarNode\n typed.dataType = this.dataType\n typed.value = this.value\n } else if (types.includes(AmfNamespace.aml.vocabularies.data.Object)) {\n const typed = result as IApiObjectNode\n typed.properties = {}\n const props = this.properties\n if (props) {\n Object.keys(props).forEach((key) => {\n typed.properties[key] = props[key].toJSON()\n })\n }\n } else if (types.includes(AmfNamespace.aml.vocabularies.data.Array)) {\n const typed = result as IApiArrayNode\n typed.members = []\n if (this.members) {\n this.members.forEach((member) => {\n typed.members.push(member.toJSON())\n })\n }\n }\n return result\n }\n\n /**\n * Adds a member to the list of members.\n * It throws when this is not an array node.\n *\n * @param init The member to add.\n */\n addMember(init: AmfDataNode): void {\n if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Array)) {\n throw new Error(`Not an ArrayNode.`)\n }\n if (!this.members) {\n this.members = []\n }\n this.members.push(init)\n }\n\n /**\n * Removes a member from the list of members.\n * It throws when this is not an array node.\n *\n * @param id The domain id of the member to remove.\n */\n removeMember(id: string): void {\n if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Array)) {\n throw new Error(`Not an ArrayNode.`)\n }\n if (!this.members) {\n return\n }\n const index = this.members.findIndex((i) => i.id === id)\n if (index >= 0) {\n this.members.splice(index, 1)\n }\n }\n\n /**\n * Adds a property to the ObjectNode.\n * It throws when this is not an object node.\n *\n * @param name The name of the property.\n * @param value The instance of the DataNode to set.\n */\n addProperty(name: string, value: AmfDataNode): void {\n if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Object)) {\n throw new Error(`Not an ObjectNode.`)\n }\n if (!this.properties) {\n this.properties = {}\n }\n this.properties[name] = value\n }\n\n /**\n * Deletes a property by name.\n *\n * @param name The name of the property to delete.\n */\n removeProperty(name: string): void {\n if (!this.types.includes(AmfNamespace.aml.vocabularies.data.Object)) {\n throw new Error(`Not an ObjectNode.`)\n }\n if (!this.properties) {\n return\n }\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.properties[name]\n }\n}\n"]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Time } from '@pawel-up/data-mock/Time.js';
|
|
2
|
-
import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiFileShape, IApiNodeShape, IApiPropertyShape, IApiScalarShape, IApiSchemaShape, IShapeUnion, IApiTupleShape, IApiUnionShape } from '../definitions/Shapes.js';
|
|
3
|
-
export interface IShapeRenderOptions {
|
|
4
|
-
/**
|
|
5
|
-
* All selected unions in the current view.
|
|
6
|
-
* When the processor encounter an union it checks this array
|
|
7
|
-
* to pick the selected union.
|
|
8
|
-
* When the selected union cannot be determined it picks the first union.
|
|
9
|
-
*/
|
|
10
|
-
selectedUnions?: string[];
|
|
11
|
-
/**
|
|
12
|
-
* Whether to include optional fields into the schema.
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
renderOptional?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* When set it uses the data mocking library to generate the values
|
|
18
|
-
* when examples and default are not set.
|
|
19
|
-
*/
|
|
20
|
-
renderMocked?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* The library **always** uses default values in the schema.
|
|
23
|
-
* When a default value is not set by default it inserts an empty value for
|
|
24
|
-
* the given data type ('', false, null, random date). When this is set
|
|
25
|
-
* it includes examples in the generated value.
|
|
26
|
-
*/
|
|
27
|
-
renderExamples?: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* A base class for generators that generates a schema from AMF's shape definition.
|
|
31
|
-
*/
|
|
32
|
-
export declare abstract class ShapeBase {
|
|
33
|
-
opts: Readonly<IShapeRenderOptions>;
|
|
34
|
-
time: Time;
|
|
35
|
-
constructor(opts?: IShapeRenderOptions);
|
|
36
|
-
protected _scalarValue(schema: IApiScalarShape): string | number | boolean | null | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Checks whether the union represents a scalar + nil which is equivalent
|
|
39
|
-
* to having scalar that is not required.
|
|
40
|
-
*
|
|
41
|
-
* See more about nil values in RAML:
|
|
42
|
-
* https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#nil-type
|
|
43
|
-
*
|
|
44
|
-
* @param union The list of unions in the shape
|
|
45
|
-
*/
|
|
46
|
-
protected _isNotRequiredUnion(union: IShapeUnion[]): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Generates a schema from AMF's shape.
|
|
49
|
-
* @param schema The Shape definition
|
|
50
|
-
* @returns The generated example
|
|
51
|
-
*/
|
|
52
|
-
abstract generate(schema: IShapeUnion | IApiPropertyShape<IShapeUnion>): string | number | boolean | null | undefined;
|
|
53
|
-
/**
|
|
54
|
-
* Serializes generated values into the final mime type related form.
|
|
55
|
-
*
|
|
56
|
-
* @returns The generated example
|
|
57
|
-
*/
|
|
58
|
-
abstract serialize(value: unknown): string | undefined;
|
|
59
|
-
/**
|
|
60
|
-
* @param example The example to turn into a JS object
|
|
61
|
-
*/
|
|
62
|
-
protected abstract _exampleToObject(example?: IApiDataExample): unknown;
|
|
63
|
-
protected abstract _scalarShapeObject(schema: IApiScalarShape): unknown;
|
|
64
|
-
protected abstract _nilShapeObject(schema: IApiScalarShape): unknown;
|
|
65
|
-
protected abstract _nodeShapeObject(schema: IApiNodeShape): unknown;
|
|
66
|
-
protected abstract _unionShapeObject(schema: IApiUnionShape): unknown;
|
|
67
|
-
protected abstract _fileShapeObject(schema?: IApiFileShape): unknown;
|
|
68
|
-
protected abstract _schemaShapeObject(schema?: IApiSchemaShape): unknown;
|
|
69
|
-
protected abstract _arrayShapeObject(schema: IApiArrayShape): unknown;
|
|
70
|
-
protected abstract _tupleShapeObject(schema?: IApiTupleShape): unknown;
|
|
71
|
-
protected abstract _anyShapeObject(schema: IApiAnyShape): unknown;
|
|
72
|
-
protected abstract _propertyShapeObject(schema: IApiPropertyShape): unknown;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=ShapeBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeBase.d.ts","sourceRoot":"","sources":["../../../../src/amf/shape/ShapeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAIlD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EAEjB,eAAe,EACf,eAAe,EACf,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,0BAA0B,CAAA;AAEjC,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IACzB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED;;GAEG;AACH,8BAAsB,SAAS;IAC7B,IAAI,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAA;IACnC,IAAI,OAAa;gBAEL,IAAI,GAAE,mBAAwB;IAI1C,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IA0C7F;;;;;;;;OAQG;IACH,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO;IA2B5D;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAErH;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAEtD;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO;IAEvE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO;IAEvE,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO;IAEpE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO;IAEnE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO;IAErE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO;IAEpE,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO;IAExE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO;IAErE,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO;IAEtE,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;IAEjE,SAAS,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;CAC5E"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Time } from '@pawel-up/data-mock/Time.js';
|
|
2
|
-
import { AmfNamespace as ns } from '../definitions/Namespace.js';
|
|
3
|
-
import { ApiSchemaValues } from '../ApiSchemaValues.js';
|
|
4
|
-
import { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js';
|
|
5
|
-
/**
|
|
6
|
-
* A base class for generators that generates a schema from AMF's shape definition.
|
|
7
|
-
*/
|
|
8
|
-
export class ShapeBase {
|
|
9
|
-
opts;
|
|
10
|
-
time = new Time();
|
|
11
|
-
constructor(opts = {}) {
|
|
12
|
-
this.opts = Object.freeze({ ...opts });
|
|
13
|
-
}
|
|
14
|
-
_scalarValue(schema) {
|
|
15
|
-
const { defaultValue, examples, values, inherits, dataType } = schema;
|
|
16
|
-
// check examples
|
|
17
|
-
if (this.opts.renderExamples && examples && examples.length) {
|
|
18
|
-
const example = examples.find((item) => !!item.structuredValue);
|
|
19
|
-
const value = this._exampleToObject(example);
|
|
20
|
-
if (typeof value !== 'undefined') {
|
|
21
|
-
return ApiSchemaValues.readTypedValue(value, dataType);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// check the default value
|
|
25
|
-
if (defaultValue) {
|
|
26
|
-
const gen = new JsonDataNodeGenerator();
|
|
27
|
-
const processed = gen.processNode(defaultValue);
|
|
28
|
-
// return ApiSchemaValues.readTypedValue(processed, dataType);
|
|
29
|
-
return processed;
|
|
30
|
-
}
|
|
31
|
-
// check enum values
|
|
32
|
-
if (values && values.length) {
|
|
33
|
-
const typed = values[0];
|
|
34
|
-
if (typed.value !== undefined) {
|
|
35
|
-
return ApiSchemaValues.readTypedValue(typed.value, dataType);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
// check parents
|
|
39
|
-
if (Array.isArray(inherits) && inherits.length) {
|
|
40
|
-
for (let i = 0, len = inherits.length; i < len; i += 1) {
|
|
41
|
-
const result = this._scalarValue(inherits[i]);
|
|
42
|
-
if (result !== undefined) {
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (this.opts.renderMocked) {
|
|
48
|
-
return ApiSchemaValues.generateMockedValue(schema);
|
|
49
|
-
}
|
|
50
|
-
// return this[dataTypeToExample](dataType, format);
|
|
51
|
-
// create a default value.
|
|
52
|
-
return ApiSchemaValues.generateDefaultValue(schema);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks whether the union represents a scalar + nil which is equivalent
|
|
56
|
-
* to having scalar that is not required.
|
|
57
|
-
*
|
|
58
|
-
* See more about nil values in RAML:
|
|
59
|
-
* https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#nil-type
|
|
60
|
-
*
|
|
61
|
-
* @param union The list of unions in the shape
|
|
62
|
-
*/
|
|
63
|
-
_isNotRequiredUnion(union) {
|
|
64
|
-
let scalars = 0;
|
|
65
|
-
let hasNil = false;
|
|
66
|
-
union.forEach((i) => {
|
|
67
|
-
if (i.types.includes(ns.aml.vocabularies.shapes.NilShape)) {
|
|
68
|
-
hasNil = true;
|
|
69
|
-
}
|
|
70
|
-
else if (i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {
|
|
71
|
-
const scalar = i;
|
|
72
|
-
if (scalar.dataType === ns.w3.xmlSchema.nil) {
|
|
73
|
-
hasNil = true;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
scalars += 1;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else if (i.types.includes(ns.aml.vocabularies.shapes.FileShape)) {
|
|
80
|
-
scalars += 1;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
if (!hasNil) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
// size of union minus the nil union
|
|
87
|
-
if (scalars === union.length - 1) {
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=ShapeBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeBase.js","sourceRoot":"","sources":["../../../../src/amf/shape/ShapeBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAA;AAClD,OAAO,EAAE,YAAY,IAAI,EAAE,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,qBAAqB,EAAE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nC,IAAI,MAAM,CAAC,QAAQ,KAAK,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;oBAC5C,MAAM,GAAG,IAAI,CAAA;gBACf,CAAC;qBAAM,CAAC;oBACN,OAAO,IAAI,CAAC,CAAA;gBACd,CAAC;YACH,CAAC;iBAAM,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;gBAClE,OAAO,IAAI,CAAC,CAAA;YACd,CAAC;QACH,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAA;QACd,CAAC;QACD,oCAAoC;QACpC,IAAI,OAAO,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CAwCF","sourcesContent":["import { Time } from '@pawel-up/data-mock/Time.js'\nimport { AmfNamespace as ns } from '../definitions/Namespace.js'\nimport { ApiSchemaValues } from '../ApiSchemaValues.js'\nimport { JsonDataNodeGenerator } from '../data-node/JsonDataNodeGenerator.js'\nimport {\n IApiAnyShape,\n IApiArrayShape,\n IApiDataExample,\n IApiFileShape,\n IApiNodeShape,\n IApiPropertyShape,\n IApiScalarNode,\n IApiScalarShape,\n IApiSchemaShape,\n IShapeUnion,\n IApiTupleShape,\n IApiUnionShape,\n} from '../definitions/Shapes.js'\n\nexport interface IShapeRenderOptions {\n /**\n * All selected unions in the current view.\n * When the processor encounter an union it checks this array\n * to pick the selected union.\n * When the selected union cannot be determined it picks the first union.\n */\n selectedUnions?: string[]\n /**\n * Whether to include optional fields into the schema.\n * @default false\n */\n renderOptional?: boolean\n /**\n * When set it uses the data mocking library to generate the values\n * when examples and default are not set.\n */\n renderMocked?: boolean\n /**\n * The library **always** uses default values in the schema.\n * When a default value is not set by default it inserts an empty value for\n * the given data type ('', false, null, random date). When this is set\n * it includes examples in the generated value.\n */\n renderExamples?: boolean\n}\n\n/**\n * A base class for generators that generates a schema from AMF's shape definition.\n */\nexport abstract class ShapeBase {\n opts: Readonly<IShapeRenderOptions>\n time = new Time()\n\n constructor(opts: IShapeRenderOptions = {}) {\n this.opts = Object.freeze({ ...opts })\n }\n\n protected _scalarValue(schema: IApiScalarShape): string | number | boolean | null | undefined {\n const { defaultValue, examples, values, inherits, dataType } = schema\n // check examples\n if (this.opts.renderExamples && examples && examples.length) {\n const example = examples.find((item) => !!item.structuredValue)\n const value = this._exampleToObject(example)\n if (typeof value !== 'undefined') {\n return ApiSchemaValues.readTypedValue(value, dataType)\n }\n }\n\n // check the default value\n if (defaultValue) {\n const gen = new JsonDataNodeGenerator()\n const processed = gen.processNode(defaultValue)\n // return ApiSchemaValues.readTypedValue(processed, dataType);\n return processed as string | number | boolean | null | undefined\n }\n // check enum values\n if (values && values.length) {\n const typed = values[0] as IApiScalarNode\n if (typed.value !== undefined) {\n return ApiSchemaValues.readTypedValue(typed.value, dataType)\n }\n }\n // check parents\n if (Array.isArray(inherits) && inherits.length) {\n for (let i = 0, len = inherits.length; i < len; i += 1) {\n const result = this._scalarValue(inherits[i] as IApiScalarShape)\n if (result !== undefined) {\n return result\n }\n }\n }\n if (this.opts.renderMocked) {\n return ApiSchemaValues.generateMockedValue(schema)\n }\n // return this[dataTypeToExample](dataType, format);\n // create a default value.\n return ApiSchemaValues.generateDefaultValue(schema)\n }\n\n /**\n * Checks whether the union represents a scalar + nil which is equivalent\n * to having scalar that is not required.\n *\n * See more about nil values in RAML:\n * https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md#nil-type\n *\n * @param union The list of unions in the shape\n */\n protected _isNotRequiredUnion(union: IShapeUnion[]): boolean {\n let scalars = 0\n let hasNil = false\n union.forEach((i) => {\n if (i.types.includes(ns.aml.vocabularies.shapes.NilShape)) {\n hasNil = true\n } else if (i.types.includes(ns.aml.vocabularies.shapes.ScalarShape)) {\n const scalar = i as IApiScalarShape\n if (scalar.dataType === ns.w3.xmlSchema.nil) {\n hasNil = true\n } else {\n scalars += 1\n }\n } else if (i.types.includes(ns.aml.vocabularies.shapes.FileShape)) {\n scalars += 1\n }\n })\n if (!hasNil) {\n return false\n }\n // size of union minus the nil union\n if (scalars === union.length - 1) {\n return true\n }\n return false\n }\n\n /**\n * Generates a schema from AMF's shape.\n * @param schema The Shape definition\n * @returns The generated example\n */\n abstract generate(schema: IShapeUnion | IApiPropertyShape<IShapeUnion>): string | number | boolean | null | undefined\n\n /**\n * Serializes generated values into the final mime type related form.\n *\n * @returns The generated example\n */\n abstract serialize(value: unknown): string | undefined\n\n /**\n * @param example The example to turn into a JS object\n */\n protected abstract _exampleToObject(example?: IApiDataExample): unknown\n\n protected abstract _scalarShapeObject(schema: IApiScalarShape): unknown\n\n protected abstract _nilShapeObject(schema: IApiScalarShape): unknown\n\n protected abstract _nodeShapeObject(schema: IApiNodeShape): unknown\n\n protected abstract _unionShapeObject(schema: IApiUnionShape): unknown\n\n protected abstract _fileShapeObject(schema?: IApiFileShape): unknown\n\n protected abstract _schemaShapeObject(schema?: IApiSchemaShape): unknown\n\n protected abstract _arrayShapeObject(schema: IApiArrayShape): unknown\n\n protected abstract _tupleShapeObject(schema?: IApiTupleShape): unknown\n\n protected abstract _anyShapeObject(schema: IApiAnyShape): unknown\n\n protected abstract _propertyShapeObject(schema: IApiPropertyShape): unknown\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { ShapeBase } from './ShapeBase.js';
|
|
2
|
-
import { IApiAnyShape, IApiArrayShape, IApiDataExample, IApiDataNodeUnion, IApiNodeShape, IApiPropertyShape, IApiScalarShape, IShapeUnion, IApiTupleShape, IApiUnionShape } from '../definitions/Shapes.js';
|
|
3
|
-
export declare class ShapeJsonSchemaGenerator extends ShapeBase {
|
|
4
|
-
/**
|
|
5
|
-
* Generates a schema from AMF's shape.
|
|
6
|
-
*
|
|
7
|
-
* @param schema The Shape definition
|
|
8
|
-
*/
|
|
9
|
-
generate(schema: IShapeUnion | IApiPropertyShape<IShapeUnion>): string | number | boolean | null | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Processes the Shape definition and returns a JavaScript object or array.
|
|
12
|
-
*/
|
|
13
|
-
toObject(schema: IShapeUnion): object | object[] | string | number | boolean | null | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Serializes generated JS value according to the mime type.
|
|
16
|
-
*/
|
|
17
|
-
serialize(value: object | object[]): string;
|
|
18
|
-
protected _scalarShapeObject(schema: IApiScalarShape): string | number | boolean | null | undefined;
|
|
19
|
-
protected _nilShapeObject(): undefined;
|
|
20
|
-
protected _nodeShapeObject(schema: IApiNodeShape): object;
|
|
21
|
-
protected _unionShapeObject(schema: IApiUnionShape): object | object[] | string | number | boolean | null | undefined;
|
|
22
|
-
protected _anyOfUnion(schema: IApiUnionShape): object | object[] | string | number | boolean | null | undefined;
|
|
23
|
-
protected _oneOfUnion(schema: IApiUnionShape): object | object[] | string | number | boolean | null | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Combines all properties from both all shapes in the union
|
|
26
|
-
*/
|
|
27
|
-
protected _allOfUnion(schema: IApiUnionShape): object | object[] | string | number | boolean | null | undefined;
|
|
28
|
-
/**
|
|
29
|
-
* @param union The list of unions in the shape
|
|
30
|
-
* @param defaultValue The definition of a default value.
|
|
31
|
-
*/
|
|
32
|
-
protected _unionDefaultValue(union: IShapeUnion[], defaultValue: IApiDataNodeUnion): string | number | boolean | null | undefined;
|
|
33
|
-
protected _arrayShapeObject(schema: IApiArrayShape): unknown[];
|
|
34
|
-
protected _tupleShapeObject(schema: IApiTupleShape): object | object[] | string | number | boolean | null | undefined;
|
|
35
|
-
protected _anyShapeObject(schema: IApiAnyShape): object | object[] | string | number | boolean | null | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* @returns The value for the property or undefined when cannot generate the value.
|
|
38
|
-
*/
|
|
39
|
-
protected _propertyShapeObject(schema: IApiPropertyShape): object | object[] | string | number | boolean | null | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* @param example The example to turn into a JS object
|
|
42
|
-
*/
|
|
43
|
-
protected _exampleToObject(example?: IApiDataExample): object | object[] | string | number | boolean | null | undefined;
|
|
44
|
-
protected _fileShapeObject(): undefined;
|
|
45
|
-
protected _schemaShapeObject(): undefined;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=ShapeJsonSchemaGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeJsonSchemaGenerator.d.ts","sourceRoot":"","sources":["../../../../src/amf/shape/ShapeJsonSchemaGenerator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,cAAc,EACd,cAAc,EACf,MAAM,0BAA0B,CAAA;AAEjC,qBAAa,wBAAyB,SAAQ,SAAS;IACrD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAa5G;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IA6B/F;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAI3C,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;IAInG,SAAS,CAAC,eAAe,IAAI,SAAS;IAItC,SAAS,CAAC,gBAAgB,C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