@toa.io/extensions.exposition 0.24.0-alpha.2 → 0.24.0-alpha.21
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/components/context.toa.yaml +12 -0
- package/components/identity.bans/manifest.toa.yaml +1 -1
- package/components/identity.basic/manifest.toa.yaml +2 -2
- package/components/identity.basic/operations/authenticate.d.ts +9 -0
- package/components/identity.basic/operations/authenticate.js +24 -0
- package/components/identity.basic/operations/authenticate.js.map +1 -0
- package/components/identity.basic/operations/create.d.ts +10 -0
- package/components/identity.basic/operations/create.js +10 -0
- package/components/identity.basic/operations/create.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +12 -0
- package/components/identity.basic/operations/transit.js +53 -0
- package/components/identity.basic/operations/transit.js.map +1 -0
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.basic/operations/types.d.ts +38 -0
- package/components/identity.basic/operations/types.js +3 -0
- package/components/identity.basic/operations/types.js.map +1 -0
- package/components/identity.basic/source/authenticate.ts +0 -1
- package/components/identity.federation/events/principal.js +22 -0
- package/components/identity.federation/manifest.toa.yaml +88 -0
- package/components/identity.federation/operations/assertions-as-values.cjs +45 -0
- package/components/identity.federation/operations/assertions-as-values.cjs.map +1 -0
- package/components/identity.federation/operations/assertions-as-values.d.cts +4 -0
- package/components/identity.federation/operations/authenticate.d.ts +3 -0
- package/components/identity.federation/operations/authenticate.js +20 -0
- package/components/identity.federation/operations/authenticate.js.map +1 -0
- package/components/identity.federation/operations/create.d.ts +10 -0
- package/components/identity.federation/operations/create.js +15 -0
- package/components/identity.federation/operations/create.js.map +1 -0
- package/components/identity.federation/operations/jwt.cjs +112 -0
- package/components/identity.federation/operations/jwt.cjs.map +1 -0
- package/components/identity.federation/operations/jwt.d.cts +19 -0
- package/components/identity.federation/operations/schemas.d.ts +43 -0
- package/components/identity.federation/operations/schemas.js +9 -0
- package/components/identity.federation/operations/schemas.js.map +1 -0
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.federation/operations/types.d.ts +51 -0
- package/components/identity.federation/operations/types.js +3 -0
- package/components/identity.federation/operations/types.js.map +1 -0
- package/components/identity.federation/source/assertions-as-values.cts +20 -0
- package/components/identity.federation/source/authenticate.ts +28 -0
- package/components/identity.federation/source/create.ts +26 -0
- package/components/identity.federation/source/jwt.cts +143 -0
- package/components/identity.federation/source/schemas.ts +45 -0
- package/components/identity.federation/source/types.ts +56 -0
- package/components/identity.federation/tsconfig.json +9 -0
- package/components/identity.roles/operations/list.d.ts +5 -0
- package/components/identity.roles/operations/list.js +8 -0
- package/components/identity.roles/operations/list.js.map +1 -0
- package/components/identity.roles/operations/principal.d.ts +15 -0
- package/components/identity.roles/operations/principal.js +8 -0
- package/components/identity.roles/operations/principal.js.map +1 -0
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.tokens/manifest.toa.yaml +1 -1
- package/components/identity.tokens/operations/authenticate.d.ts +9 -0
- package/components/identity.tokens/operations/authenticate.js +32 -0
- package/components/identity.tokens/operations/authenticate.js.map +1 -0
- package/components/identity.tokens/operations/decrypt.d.ts +3 -0
- package/components/identity.tokens/operations/decrypt.js +32 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -0
- package/components/identity.tokens/operations/encrypt.d.ts +8 -0
- package/components/identity.tokens/operations/encrypt.js +22 -0
- package/components/identity.tokens/operations/encrypt.js.map +1 -0
- package/components/identity.tokens/operations/revoke.d.ts +2 -0
- package/components/identity.tokens/operations/revoke.js +8 -0
- package/components/identity.tokens/operations/revoke.js.map +1 -0
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.tokens/operations/types.d.ts +40 -0
- package/components/identity.tokens/operations/types.js +3 -0
- package/components/identity.tokens/operations/types.js.map +1 -0
- package/cucumber.js +0 -1
- package/documentation/components.md +25 -2
- package/documentation/identity.md +7 -7
- package/documentation/protocol.md +21 -1
- package/documentation/query.md +1 -1
- package/documentation/vary.md +69 -0
- package/features/cors.feature +39 -0
- package/features/identity.feature +19 -3
- package/features/identity.federation.feature +125 -0
- package/features/octets.feature +1 -1
- package/features/response.feature +65 -0
- package/features/steps/Captures.ts +5 -0
- package/features/steps/Components.ts +5 -0
- package/features/steps/Gateway.ts +1 -2
- package/features/steps/HTTP.ts +39 -84
- package/features/steps/IdP.ts +120 -0
- package/features/steps/Parameters.ts +8 -2
- package/features/steps/Workspace.ts +5 -7
- package/features/steps/components/echo/operations/error.js +11 -0
- package/features/vary.feature +150 -0
- package/package.json +17 -18
- package/source/Directive.test.ts +8 -2
- package/source/Directive.ts +19 -16
- package/source/Factory.ts +8 -7
- package/source/Gateway.ts +22 -8
- package/source/HTTP/Server.fixtures.ts +0 -1
- package/source/HTTP/Server.test.ts +61 -134
- package/source/HTTP/Server.ts +45 -23
- package/source/HTTP/formats/msgpack.ts +9 -6
- package/source/HTTP/formats/text.ts +1 -1
- package/source/HTTP/formats/yaml.ts +1 -1
- package/source/HTTP/messages.ts +8 -2
- package/source/Interception.ts +24 -0
- package/source/RTD/Directives.ts +2 -2
- package/source/RTD/Tree.ts +3 -0
- package/source/RTD/syntax/parse.ts +6 -6
- package/source/RTD/syntax/types.ts +1 -1
- package/source/deployment.ts +1 -2
- package/source/directives/auth/{Family.ts → Authorization.ts} +29 -33
- package/source/directives/auth/Incept.ts +1 -1
- package/source/directives/auth/Rule.ts +2 -2
- package/source/directives/auth/index.ts +2 -2
- package/source/directives/auth/schemes.ts +2 -1
- package/source/directives/auth/types.ts +9 -6
- package/source/directives/cache/{Family.ts → Cache.ts} +4 -5
- package/source/directives/cache/index.ts +2 -2
- package/source/directives/cache/types.ts +1 -1
- package/source/directives/cors/CORS.ts +52 -0
- package/source/directives/cors/index.ts +3 -0
- package/source/directives/dev/{Family.ts → Development.ts} +3 -4
- package/source/directives/dev/Stub.ts +4 -4
- package/source/directives/dev/Throw.ts +4 -4
- package/source/directives/dev/index.ts +2 -2
- package/source/directives/dev/types.ts +1 -1
- package/source/directives/index.ts +10 -6
- package/source/directives/octets/Context.ts +1 -1
- package/source/directives/octets/Delete.ts +1 -2
- package/source/directives/octets/Fetch.ts +1 -1
- package/source/directives/octets/List.ts +1 -1
- package/source/directives/octets/{Family.ts → Octets.ts} +3 -4
- package/source/directives/octets/Permute.ts +1 -1
- package/source/directives/octets/Store.ts +3 -3
- package/source/directives/octets/index.ts +2 -2
- package/source/directives/octets/types.ts +3 -3
- package/source/directives/vary/Directive.ts +6 -0
- package/source/directives/vary/Embed.ts +62 -0
- package/source/directives/vary/Properties.ts +17 -0
- package/source/directives/vary/Vary.ts +48 -0
- package/source/directives/vary/embeddings/Embedding.ts +6 -0
- package/source/directives/vary/embeddings/Header.ts +30 -0
- package/source/directives/vary/embeddings/Language.ts +31 -0
- package/source/directives/vary/embeddings/index.ts +11 -0
- package/source/directives/vary/index.ts +3 -0
- package/source/io.ts +4 -0
- package/transpiled/Annotation.d.ts +7 -0
- package/transpiled/Annotation.js +3 -0
- package/transpiled/Annotation.js.map +1 -0
- package/transpiled/Branch.d.ts +7 -0
- package/transpiled/Branch.js +3 -0
- package/transpiled/Branch.js.map +1 -0
- package/transpiled/Composition.d.ts +14 -0
- package/transpiled/Composition.js +43 -0
- package/transpiled/Composition.js.map +1 -0
- package/transpiled/Context.d.ts +5 -0
- package/transpiled/Context.js +3 -0
- package/transpiled/Context.js.map +1 -0
- package/transpiled/Directive.d.ts +31 -0
- package/transpiled/Directive.js +78 -0
- package/transpiled/Directive.js.map +1 -0
- package/transpiled/Endpoint.d.ts +20 -0
- package/transpiled/Endpoint.js +45 -0
- package/transpiled/Endpoint.js.map +1 -0
- package/transpiled/Factory.d.ts +9 -0
- package/transpiled/Factory.js +67 -0
- package/transpiled/Factory.js.map +1 -0
- package/transpiled/Gateway.d.ts +22 -0
- package/transpiled/Gateway.js +102 -0
- package/transpiled/Gateway.js.map +1 -0
- package/transpiled/HTTP/Server.d.ts +24 -0
- package/transpiled/HTTP/Server.fixtures.d.ts +10 -0
- package/transpiled/HTTP/Server.fixtures.js +31 -0
- package/transpiled/HTTP/Server.fixtures.js.map +1 -0
- package/transpiled/HTTP/Server.js +148 -0
- package/transpiled/HTTP/Server.js.map +1 -0
- package/transpiled/HTTP/exceptions.d.ts +34 -0
- package/transpiled/HTTP/exceptions.js +71 -0
- package/transpiled/HTTP/exceptions.js.map +1 -0
- package/transpiled/HTTP/formats/index.d.ts +10 -0
- package/transpiled/HTTP/formats/index.js +38 -0
- package/transpiled/HTTP/formats/index.js.map +1 -0
- package/transpiled/HTTP/formats/json.d.ts +6 -0
- package/transpiled/HTTP/formats/json.js +17 -0
- package/transpiled/HTTP/formats/json.js.map +1 -0
- package/transpiled/HTTP/formats/msgpack.d.ts +6 -0
- package/transpiled/HTTP/formats/msgpack.js +17 -0
- package/transpiled/HTTP/formats/msgpack.js.map +1 -0
- package/transpiled/HTTP/formats/text.d.ts +8 -0
- package/transpiled/HTTP/formats/text.js +15 -0
- package/transpiled/HTTP/formats/text.js.map +1 -0
- package/transpiled/HTTP/formats/yaml.d.ts +6 -0
- package/transpiled/HTTP/formats/yaml.js +41 -0
- package/transpiled/HTTP/formats/yaml.js.map +1 -0
- package/transpiled/HTTP/index.d.ts +3 -0
- package/transpiled/HTTP/index.js +20 -0
- package/transpiled/HTTP/index.js.map +1 -0
- package/transpiled/HTTP/messages.d.ts +32 -0
- package/transpiled/HTTP/messages.js +72 -0
- package/transpiled/HTTP/messages.js.map +1 -0
- package/transpiled/Interception.d.ts +9 -0
- package/transpiled/Interception.js +19 -0
- package/transpiled/Interception.js.map +1 -0
- package/transpiled/Mapping.d.ts +8 -0
- package/transpiled/Mapping.js +38 -0
- package/transpiled/Mapping.js.map +1 -0
- package/transpiled/Query.d.ts +13 -0
- package/transpiled/Query.js +107 -0
- package/transpiled/Query.js.map +1 -0
- package/transpiled/RTD/Context.d.ts +11 -0
- package/transpiled/RTD/Context.js +3 -0
- package/transpiled/RTD/Context.js.map +1 -0
- package/transpiled/RTD/Directives.d.ts +7 -0
- package/transpiled/RTD/Directives.js +3 -0
- package/transpiled/RTD/Directives.js.map +1 -0
- package/transpiled/RTD/Endpoint.d.ts +9 -0
- package/transpiled/RTD/Endpoint.js +3 -0
- package/transpiled/RTD/Endpoint.js.map +1 -0
- package/transpiled/RTD/Match.d.ts +11 -0
- package/transpiled/RTD/Match.js +3 -0
- package/transpiled/RTD/Match.js.map +1 -0
- package/transpiled/RTD/Method.d.ts +9 -0
- package/transpiled/RTD/Method.js +16 -0
- package/transpiled/RTD/Method.js.map +1 -0
- package/transpiled/RTD/Node.d.ts +21 -0
- package/transpiled/RTD/Node.js +61 -0
- package/transpiled/RTD/Node.js.map +1 -0
- package/transpiled/RTD/Route.d.ts +14 -0
- package/transpiled/RTD/Route.js +49 -0
- package/transpiled/RTD/Route.js.map +1 -0
- package/transpiled/RTD/Tree.d.ts +14 -0
- package/transpiled/RTD/Tree.js +42 -0
- package/transpiled/RTD/Tree.js.map +1 -0
- package/transpiled/RTD/factory.d.ts +6 -0
- package/transpiled/RTD/factory.js +36 -0
- package/transpiled/RTD/factory.js.map +1 -0
- package/transpiled/RTD/index.d.ts +8 -0
- package/transpiled/RTD/index.js +38 -0
- package/transpiled/RTD/index.js.map +1 -0
- package/transpiled/RTD/segment.d.ts +8 -0
- package/transpiled/RTD/segment.js +25 -0
- package/transpiled/RTD/segment.js.map +1 -0
- package/transpiled/RTD/syntax/index.d.ts +2 -0
- package/transpiled/RTD/syntax/index.js +19 -0
- package/transpiled/RTD/syntax/index.js.map +1 -0
- package/transpiled/RTD/syntax/parse.d.ts +4 -0
- package/transpiled/RTD/syntax/parse.js +128 -0
- package/transpiled/RTD/syntax/parse.js.map +1 -0
- package/transpiled/RTD/syntax/types.d.ts +41 -0
- package/transpiled/RTD/syntax/types.js +5 -0
- package/transpiled/RTD/syntax/types.js.map +1 -0
- package/transpiled/Remotes.d.ts +9 -0
- package/transpiled/Remotes.js +25 -0
- package/transpiled/Remotes.js.map +1 -0
- package/transpiled/Tenant.d.ts +13 -0
- package/transpiled/Tenant.js +34 -0
- package/transpiled/Tenant.js.map +1 -0
- package/transpiled/deployment.d.ts +3 -0
- package/transpiled/deployment.js +66 -0
- package/transpiled/deployment.js.map +1 -0
- package/transpiled/directives/auth/Anonymous.d.ts +6 -0
- package/transpiled/directives/auth/Anonymous.js +17 -0
- package/transpiled/directives/auth/Anonymous.js.map +1 -0
- package/transpiled/directives/auth/Authorization.d.ts +20 -0
- package/transpiled/directives/auth/Authorization.js +125 -0
- package/transpiled/directives/auth/Authorization.js.map +1 -0
- package/transpiled/directives/auth/Echo.d.ts +6 -0
- package/transpiled/directives/auth/Echo.js +13 -0
- package/transpiled/directives/auth/Echo.js.map +1 -0
- package/transpiled/directives/auth/Id.d.ts +7 -0
- package/transpiled/directives/auth/Id.js +17 -0
- package/transpiled/directives/auth/Id.js.map +1 -0
- package/transpiled/directives/auth/Incept.d.ts +10 -0
- package/transpiled/directives/auth/Incept.js +58 -0
- package/transpiled/directives/auth/Incept.js.map +1 -0
- package/transpiled/directives/auth/Role.d.ts +11 -0
- package/transpiled/directives/auth/Role.js +44 -0
- package/transpiled/directives/auth/Role.js.map +1 -0
- package/transpiled/directives/auth/Rule.d.ts +9 -0
- package/transpiled/directives/auth/Rule.js +22 -0
- package/transpiled/directives/auth/Rule.js.map +1 -0
- package/transpiled/directives/auth/Scheme.d.ts +7 -0
- package/transpiled/directives/auth/Scheme.js +47 -0
- package/transpiled/directives/auth/Scheme.js.map +1 -0
- package/transpiled/directives/auth/index.d.ts +2 -0
- package/transpiled/directives/auth/index.js +6 -0
- package/transpiled/directives/auth/index.js.map +1 -0
- package/transpiled/directives/auth/schemes.d.ts +3 -0
- package/transpiled/directives/auth/schemes.js +10 -0
- package/transpiled/directives/auth/schemes.js.map +1 -0
- package/transpiled/directives/auth/split.d.ts +2 -0
- package/transpiled/directives/auth/split.js +38 -0
- package/transpiled/directives/auth/split.js.map +1 -0
- package/transpiled/directives/auth/types.d.ts +31 -0
- package/transpiled/directives/auth/types.js +3 -0
- package/transpiled/directives/auth/types.js.map +1 -0
- package/transpiled/directives/cache/Cache.d.ts +11 -0
- package/transpiled/directives/cache/Cache.js +28 -0
- package/transpiled/directives/cache/Cache.js.map +1 -0
- package/transpiled/directives/cache/Control.d.ts +9 -0
- package/transpiled/directives/cache/Control.js +42 -0
- package/transpiled/directives/cache/Control.js.map +1 -0
- package/transpiled/directives/cache/Exact.d.ts +4 -0
- package/transpiled/directives/cache/Exact.js +11 -0
- package/transpiled/directives/cache/Exact.js.map +1 -0
- package/transpiled/directives/cache/index.d.ts +2 -0
- package/transpiled/directives/cache/index.js +6 -0
- package/transpiled/directives/cache/index.js.map +1 -0
- package/transpiled/directives/cache/types.d.ts +7 -0
- package/transpiled/directives/cache/types.js +3 -0
- package/transpiled/directives/cache/types.js.map +1 -0
- package/transpiled/directives/cors/CORS.d.ts +14 -0
- package/transpiled/directives/cors/CORS.js +42 -0
- package/transpiled/directives/cors/CORS.js.map +1 -0
- package/transpiled/directives/cors/index.d.ts +2 -0
- package/transpiled/directives/cors/index.js +6 -0
- package/transpiled/directives/cors/index.js.map +1 -0
- package/transpiled/directives/dev/Development.d.ts +9 -0
- package/transpiled/directives/dev/Development.js +29 -0
- package/transpiled/directives/dev/Development.js.map +1 -0
- package/transpiled/directives/dev/Stub.d.ts +7 -0
- package/transpiled/directives/dev/Stub.js +14 -0
- package/transpiled/directives/dev/Stub.js.map +1 -0
- package/transpiled/directives/dev/Throw.d.ts +7 -0
- package/transpiled/directives/dev/Throw.js +14 -0
- package/transpiled/directives/dev/Throw.js.map +1 -0
- package/transpiled/directives/dev/index.d.ts +2 -0
- package/transpiled/directives/dev/index.js +6 -0
- package/transpiled/directives/dev/index.js.map +1 -0
- package/transpiled/directives/dev/types.d.ts +4 -0
- package/transpiled/directives/dev/types.js +3 -0
- package/transpiled/directives/dev/types.js.map +1 -0
- package/transpiled/directives/index.d.ts +4 -0
- package/transpiled/directives/index.js +12 -0
- package/transpiled/directives/index.js.map +1 -0
- package/transpiled/directives/octets/Context.d.ts +8 -0
- package/transpiled/directives/octets/Context.js +40 -0
- package/transpiled/directives/octets/Context.js.map +1 -0
- package/transpiled/directives/octets/Delete.d.ts +10 -0
- package/transpiled/directives/octets/Delete.js +47 -0
- package/transpiled/directives/octets/Delete.js.map +1 -0
- package/transpiled/directives/octets/Fetch.d.ts +18 -0
- package/transpiled/directives/octets/Fetch.js +77 -0
- package/transpiled/directives/octets/Fetch.js.map +1 -0
- package/transpiled/directives/octets/List.d.ts +10 -0
- package/transpiled/directives/octets/List.js +47 -0
- package/transpiled/directives/octets/List.js.map +1 -0
- package/transpiled/directives/octets/Octets.d.ts +11 -0
- package/transpiled/directives/octets/Octets.js +51 -0
- package/transpiled/directives/octets/Octets.js.map +1 -0
- package/transpiled/directives/octets/Permute.d.ts +10 -0
- package/transpiled/directives/octets/Permute.js +51 -0
- package/transpiled/directives/octets/Permute.js.map +1 -0
- package/transpiled/directives/octets/Store.d.ts +33 -0
- package/transpiled/directives/octets/Store.js +124 -0
- package/transpiled/directives/octets/Store.js.map +1 -0
- package/transpiled/directives/octets/index.d.ts +2 -0
- package/transpiled/directives/octets/index.js +6 -0
- package/transpiled/directives/octets/index.js.map +1 -0
- package/transpiled/directives/octets/schemas.d.ts +6 -0
- package/transpiled/directives/octets/schemas.js +17 -0
- package/transpiled/directives/octets/schemas.js.map +1 -0
- package/transpiled/directives/octets/types.d.ts +9 -0
- package/transpiled/directives/octets/types.js +3 -0
- package/transpiled/directives/octets/types.js.map +1 -0
- package/transpiled/directives/vary/Directive.d.ts +5 -0
- package/transpiled/directives/vary/Directive.js +3 -0
- package/transpiled/directives/vary/Directive.js.map +1 -0
- package/transpiled/directives/vary/Embed.d.ts +10 -0
- package/transpiled/directives/vary/Embed.js +49 -0
- package/transpiled/directives/vary/Embed.js.map +1 -0
- package/transpiled/directives/vary/Properties.d.ts +9 -0
- package/transpiled/directives/vary/Properties.js +16 -0
- package/transpiled/directives/vary/Properties.js.map +1 -0
- package/transpiled/directives/vary/Vary.d.ts +10 -0
- package/transpiled/directives/vary/Vary.js +36 -0
- package/transpiled/directives/vary/Vary.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Embedding.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Embedding.js +3 -0
- package/transpiled/directives/vary/embeddings/Embedding.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Header.d.ts +7 -0
- package/transpiled/directives/vary/embeddings/Header.js +26 -0
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Language.d.ts +7 -0
- package/transpiled/directives/vary/embeddings/Language.js +28 -0
- package/transpiled/directives/vary/embeddings/Language.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/index.js +10 -0
- package/transpiled/directives/vary/embeddings/index.js.map +1 -0
- package/transpiled/directives/vary/index.d.ts +2 -0
- package/transpiled/directives/vary/index.js +6 -0
- package/transpiled/directives/vary/index.js.map +1 -0
- package/transpiled/discovery.d.ts +1 -0
- package/transpiled/discovery.js +3 -0
- package/transpiled/discovery.js.map +1 -0
- package/transpiled/exceptions.d.ts +2 -0
- package/transpiled/exceptions.js +39 -0
- package/transpiled/exceptions.js.map +1 -0
- package/transpiled/index.d.ts +5 -0
- package/transpiled/index.js +12 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/io.d.ts +3 -0
- package/transpiled/io.js +3 -0
- package/transpiled/io.js.map +1 -0
- package/transpiled/manifest.d.ts +3 -0
- package/transpiled/manifest.js +61 -0
- package/transpiled/manifest.js.map +1 -0
- package/transpiled/root.d.ts +2 -0
- package/transpiled/root.js +39 -0
- package/transpiled/root.js.map +1 -0
- package/transpiled/schemas.d.ts +3 -0
- package/transpiled/schemas.js +14 -0
- package/transpiled/schemas.js.map +1 -0
- package/transpiled/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Octets = void 0;
|
|
4
|
+
const HTTP_1 = require("../../HTTP");
|
|
5
|
+
const Context_1 = require("./Context");
|
|
6
|
+
const Store_1 = require("./Store");
|
|
7
|
+
const Fetch_1 = require("./Fetch");
|
|
8
|
+
const List_1 = require("./List");
|
|
9
|
+
const Delete_1 = require("./Delete");
|
|
10
|
+
const Permute_1 = require("./Permute");
|
|
11
|
+
class Octets {
|
|
12
|
+
name = 'octets';
|
|
13
|
+
mandatory = false;
|
|
14
|
+
discovery = null;
|
|
15
|
+
create(name, value, remotes) {
|
|
16
|
+
const Class = DIRECTIVES[name];
|
|
17
|
+
if (Class === undefined)
|
|
18
|
+
throw new Error(`Directive '${name}' is not provided by the '${this.name}' family.`);
|
|
19
|
+
this.discovery ??= remotes.discover('octets', 'storage');
|
|
20
|
+
return new Class(value, this.discovery, remotes);
|
|
21
|
+
}
|
|
22
|
+
async preflight(directives, input) {
|
|
23
|
+
let context = null;
|
|
24
|
+
let action = null;
|
|
25
|
+
for (const directive of directives)
|
|
26
|
+
if (directive instanceof Context_1.Context)
|
|
27
|
+
context ??= directive;
|
|
28
|
+
else if (action === null)
|
|
29
|
+
action = directive;
|
|
30
|
+
else
|
|
31
|
+
throw new Error('Octets action is umbiguous.');
|
|
32
|
+
if (action === null)
|
|
33
|
+
return null;
|
|
34
|
+
if (context === null)
|
|
35
|
+
throw new Error('Octets context is not defined.');
|
|
36
|
+
const targeted = input.path[input.path.length - 1] !== '/';
|
|
37
|
+
if (targeted !== action.targeted)
|
|
38
|
+
throw new HTTP_1.NotFound(`Trailing slash is ${action.targeted ? 'redundant' : 'required'}.`);
|
|
39
|
+
return await action.apply(context.storage, input);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Octets = Octets;
|
|
43
|
+
const DIRECTIVES = {
|
|
44
|
+
context: Context_1.Context,
|
|
45
|
+
store: Store_1.Store,
|
|
46
|
+
fetch: Fetch_1.Fetch,
|
|
47
|
+
list: List_1.List,
|
|
48
|
+
delete: Delete_1.Delete,
|
|
49
|
+
permute: Permute_1.Permute
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=Octets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Octets.js","sourceRoot":"","sources":["../../../source/directives/octets/Octets.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,uCAAmC;AACnC,mCAA+B;AAC/B,mCAA+B;AAC/B,iCAA6B;AAC7B,qCAAiC;AACjC,uCAAmC;AAOnC,MAAa,MAAM;IACD,IAAI,GAAW,QAAQ,CAAA;IACvB,SAAS,GAAY,KAAK,CAAA;IAElC,SAAS,GAAG,IAAqC,CAAA;IAElD,MAAM,CAAE,IAAY,EAAE,KAAU,EAAE,OAAgB;QACvD,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;QAE9B,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,6BAA6B,IAAI,CAAC,IAAI,WAAW,CAAC,CAAA;QAEtF,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;QAExD,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAClD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,UAAuB,EAAE,KAAY;QAC3D,IAAI,OAAO,GAAmB,IAAI,CAAA;QAClC,IAAI,MAAM,GAAqB,IAAI,CAAA;QAEnC,KAAK,MAAM,SAAS,IAAI,UAAU;YAChC,IAAI,SAAS,YAAY,iBAAO;gBAC9B,OAAO,KAAK,SAAS,CAAA;iBAClB,IAAI,MAAM,KAAK,IAAI;gBACtB,MAAM,GAAG,SAAS,CAAA;;gBAElB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAElD,IAAI,MAAM,KAAK,IAAI;YACjB,OAAO,IAAI,CAAA;QAEb,IAAI,OAAO,KAAK,IAAI;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAEnD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAA;QAE1D,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ;YAC9B,MAAM,IAAI,eAAQ,CAAC,qBAAqB,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAA;QAExF,OAAO,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnD,CAAC;CACF;AA1CD,wBA0CC;AAED,MAAM,UAAU,GAAgC;IAC9C,OAAO,EAAE,iBAAO;IAChB,KAAK,EAAE,aAAK;IACZ,KAAK,EAAE,aAAK;IACZ,IAAI,EAAE,WAAI;IACV,MAAM,EAAE,eAAM;IACd,OAAO,EAAE,iBAAO;CACjB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component } from '@toa.io/core';
|
|
2
|
+
import type { Output } from '../../io';
|
|
3
|
+
import type { Directive, Input } from './types';
|
|
4
|
+
export declare class Permute implements Directive {
|
|
5
|
+
readonly targeted = false;
|
|
6
|
+
private readonly discovery;
|
|
7
|
+
private storage;
|
|
8
|
+
constructor(value: null, discovery: Promise<Component>);
|
|
9
|
+
apply(storage: string, request: Input): Promise<Output>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Permute = void 0;
|
|
27
|
+
const HTTP_1 = require("../../HTTP");
|
|
28
|
+
const schemas = __importStar(require("./schemas"));
|
|
29
|
+
class Permute {
|
|
30
|
+
targeted = false;
|
|
31
|
+
discovery;
|
|
32
|
+
storage = null;
|
|
33
|
+
constructor(value, discovery) {
|
|
34
|
+
schemas.remove.validate(value);
|
|
35
|
+
this.discovery = discovery;
|
|
36
|
+
}
|
|
37
|
+
async apply(storage, request) {
|
|
38
|
+
this.storage ??= await this.discovery;
|
|
39
|
+
if (request.encoder === null)
|
|
40
|
+
throw new HTTP_1.NotAcceptable();
|
|
41
|
+
const path = request.path;
|
|
42
|
+
const list = await request.parse();
|
|
43
|
+
const input = { storage, path, list };
|
|
44
|
+
const error = await this.storage.invoke('permute', { input });
|
|
45
|
+
if (error instanceof Error)
|
|
46
|
+
throw new HTTP_1.NotFound();
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.Permute = Permute;
|
|
51
|
+
//# sourceMappingURL=Permute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Permute.js","sourceRoot":"","sources":["../../../source/directives/octets/Permute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoD;AACpD,mDAAoC;AAOpC,MAAa,OAAO;IACF,QAAQ,GAAG,KAAK,CAAA;IAEf,SAAS,CAAoB;IACtC,OAAO,GAAqB,IAAI,CAAA;IAExC,YAAoB,KAAW,EAAE,SAA6B;QAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,OAAc;QACjD,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAErC,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI;YAC1B,MAAM,IAAI,oBAAa,EAAE,CAAA;QAE3B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACzB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;QAClC,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QACrC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAiB,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAE7E,IAAI,KAAK,YAAY,KAAK;YACxB,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AA5BD,0BA4BC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Remotes } from '../../Remotes';
|
|
2
|
+
import type { Component } from '@toa.io/core';
|
|
3
|
+
import type { Output } from '../../io';
|
|
4
|
+
import type { Directive, Input } from './types';
|
|
5
|
+
export declare class Store implements Directive {
|
|
6
|
+
readonly targeted = false;
|
|
7
|
+
private readonly accept;
|
|
8
|
+
private readonly workflow;
|
|
9
|
+
private readonly discovery;
|
|
10
|
+
private readonly remotes;
|
|
11
|
+
private readonly components;
|
|
12
|
+
private storage;
|
|
13
|
+
constructor(options: Options | null, discovery: Promise<Component>, remotes: Remotes);
|
|
14
|
+
apply(storage: string, request: Input): Promise<Output>;
|
|
15
|
+
private reply;
|
|
16
|
+
private throw;
|
|
17
|
+
/**
|
|
18
|
+
* Execute workflow units sequentially, steps within a unit in parallel.
|
|
19
|
+
* Yield results as soon as they come.
|
|
20
|
+
*
|
|
21
|
+
* If you need to change this, it may take a while.
|
|
22
|
+
*/
|
|
23
|
+
private execute;
|
|
24
|
+
private call;
|
|
25
|
+
private discover;
|
|
26
|
+
}
|
|
27
|
+
type Unit = Record<string, string>;
|
|
28
|
+
type Workflow = Unit[];
|
|
29
|
+
interface Options {
|
|
30
|
+
accept: string | string[];
|
|
31
|
+
workflow: Workflow | Unit;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Store = void 0;
|
|
27
|
+
const node_stream_1 = require("node:stream");
|
|
28
|
+
const node_path_1 = require("node:path");
|
|
29
|
+
const matchacho_1 = require("matchacho");
|
|
30
|
+
const generic_1 = require("@toa.io/generic");
|
|
31
|
+
const HTTP_1 = require("../../HTTP");
|
|
32
|
+
const schemas = __importStar(require("./schemas"));
|
|
33
|
+
class Store {
|
|
34
|
+
targeted = false;
|
|
35
|
+
accept;
|
|
36
|
+
workflow;
|
|
37
|
+
discovery = {};
|
|
38
|
+
remotes;
|
|
39
|
+
components = {};
|
|
40
|
+
storage = null;
|
|
41
|
+
constructor(options, discovery, remotes) {
|
|
42
|
+
schemas.store.validate(options);
|
|
43
|
+
this.accept = (0, matchacho_1.match)(options?.accept, String, (value) => value, Array, (types) => types.join(','), undefined);
|
|
44
|
+
this.workflow = (0, matchacho_1.match)(options?.workflow, Array, (units) => units, Object, (unit) => [unit], undefined);
|
|
45
|
+
this.discovery.storage = discovery;
|
|
46
|
+
this.remotes = remotes;
|
|
47
|
+
}
|
|
48
|
+
async apply(storage, request) {
|
|
49
|
+
this.storage ??= await this.discovery.storage;
|
|
50
|
+
const input = { storage, request, accept: this.accept };
|
|
51
|
+
const entry = await this.storage.invoke('store', { input });
|
|
52
|
+
return (0, matchacho_1.match)(entry, Error, (error) => this.throw(error), () => this.reply(request, storage, entry));
|
|
53
|
+
}
|
|
54
|
+
reply(request, storage, entry) {
|
|
55
|
+
const body = this.workflow === undefined
|
|
56
|
+
? entry
|
|
57
|
+
: node_stream_1.Readable.from(this.execute(request, storage, entry));
|
|
58
|
+
return { body };
|
|
59
|
+
}
|
|
60
|
+
throw(error) {
|
|
61
|
+
throw (0, matchacho_1.match)(error.code, 'NOT_ACCEPTABLE', () => new HTTP_1.UnsupportedMediaType(), 'TYPE_MISMATCH', () => new HTTP_1.BadRequest(), error);
|
|
62
|
+
}
|
|
63
|
+
/* eslint-disable no-useless-return, max-depth */
|
|
64
|
+
/**
|
|
65
|
+
* Execute workflow units sequentially, steps within a unit in parallel.
|
|
66
|
+
* Yield results as soon as they come.
|
|
67
|
+
*
|
|
68
|
+
* If you need to change this, it may take a while.
|
|
69
|
+
*/
|
|
70
|
+
async *execute(request, storage, entry) {
|
|
71
|
+
yield entry;
|
|
72
|
+
const path = node_path_1.posix.join(request.path, entry.id);
|
|
73
|
+
let interrupted = false;
|
|
74
|
+
for (const unit of this.workflow) {
|
|
75
|
+
if (interrupted)
|
|
76
|
+
break;
|
|
77
|
+
const steps = Object.keys(unit);
|
|
78
|
+
// unit result promises queue
|
|
79
|
+
const results = Array.from(steps, (generic_1.promex));
|
|
80
|
+
let next = 0;
|
|
81
|
+
// execute steps in parallel
|
|
82
|
+
for (const step of steps)
|
|
83
|
+
// these promises are indirectly awaited in the yield loop
|
|
84
|
+
void (async () => {
|
|
85
|
+
const endpoint = unit[step];
|
|
86
|
+
const context = { storage, path, entry };
|
|
87
|
+
const result = await this.call(endpoint, context);
|
|
88
|
+
if (interrupted)
|
|
89
|
+
return;
|
|
90
|
+
// as a result is received, resolve the next promise from the queue
|
|
91
|
+
const promise = results[next++];
|
|
92
|
+
if (result instanceof Error) {
|
|
93
|
+
interrupted = true;
|
|
94
|
+
promise.resolve({ error: { step, ...result } });
|
|
95
|
+
// cancel pending promises
|
|
96
|
+
results[next].resolve(null);
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
promise.resolve({ [step]: result ?? null });
|
|
100
|
+
})().catch((e) => results[next].reject(e));
|
|
101
|
+
// yield results from the queue as they come
|
|
102
|
+
for (const promise of results) {
|
|
103
|
+
const result = await promise;
|
|
104
|
+
if (result === null) // canceled promise
|
|
105
|
+
break;
|
|
106
|
+
else
|
|
107
|
+
yield result;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async call(endpoint, context) {
|
|
112
|
+
const [operation, component, namespace = 'default'] = endpoint.split('.').reverse();
|
|
113
|
+
const key = `${namespace}.${component}`;
|
|
114
|
+
this.components[key] ??= await this.discover(key, namespace, component);
|
|
115
|
+
return await this.components[key].invoke(operation, { input: context });
|
|
116
|
+
}
|
|
117
|
+
async discover(key, namespace, component) {
|
|
118
|
+
if (this.discovery[key] === undefined)
|
|
119
|
+
this.discovery[key] = this.remotes.discover(namespace, component);
|
|
120
|
+
return await this.discovery[key];
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.Store = Store;
|
|
124
|
+
//# sourceMappingURL=Store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../../source/directives/octets/Store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAsC;AACtC,yCAAiC;AACjC,yCAAiC;AACjC,6CAAwC;AACxC,qCAA6D;AAC7D,mDAAoC;AASpC,MAAa,KAAK;IACA,QAAQ,GAAG,KAAK,CAAA;IAEf,MAAM,CAAoB;IAC1B,QAAQ,CAAsB;IAC9B,SAAS,GAAuC,EAAE,CAAA;IAClD,OAAO,CAAS;IAChB,UAAU,GAA8B,EAAE,CAAA;IACnD,OAAO,GAAqB,IAAI,CAAA;IAExC,YACC,OAAuB,EAAE,SAA6B,EAAE,OAAgB;QACvE,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE/B,IAAI,CAAC,MAAM,GAAG,IAAA,iBAAK,EAAC,OAAO,EAA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AAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;IACzE,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAE,GAAW,EAAE,SAAiB,EAAE,SAAiB;QACvE,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS;YACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAEnE,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;IAClC,CAAC;CACF;AAjID,sBAiIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/directives/octets/index.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEpB,QAAA,MAAM,GAAG,IAAI,eAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const context: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
2
|
+
export declare const store: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
3
|
+
export declare const fetch: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
4
|
+
export declare const remove: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
5
|
+
export declare const list: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
6
|
+
export declare const permute: import("@toa.io/schemas/types/schema").toa.schemas.Schema;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.permute = exports.list = exports.remove = exports.fetch = exports.store = exports.context = void 0;
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const schemas_1 = __importDefault(require("@toa.io/schemas"));
|
|
9
|
+
const path = (0, node_path_1.resolve)(__dirname, '../../../schemas/octets');
|
|
10
|
+
const namespace = schemas_1.default.namespace(path);
|
|
11
|
+
exports.context = namespace.schema('context');
|
|
12
|
+
exports.store = namespace.schema('store');
|
|
13
|
+
exports.fetch = namespace.schema('fetch');
|
|
14
|
+
exports.remove = namespace.schema('delete');
|
|
15
|
+
exports.list = namespace.schema('list');
|
|
16
|
+
exports.permute = namespace.schema('permute');
|
|
17
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../source/directives/octets/schemas.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmC;AACnC,8DAAqC;AAErC,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;AAC1D,MAAM,SAAS,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAE5B,QAAA,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AACrC,QAAA,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AACjC,QAAA,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AACjC,QAAA,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACnC,QAAA,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC/B,QAAA,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as io from '../../io';
|
|
2
|
+
export interface Directive {
|
|
3
|
+
readonly targeted: boolean;
|
|
4
|
+
apply: (storage: string, input: Input) => io.Output | Promise<io.Output>;
|
|
5
|
+
}
|
|
6
|
+
export interface Extension {
|
|
7
|
+
octets?: string;
|
|
8
|
+
}
|
|
9
|
+
export type Input = io.Input & Extension;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../source/directives/octets/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../../../source/directives/vary/Directive.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Input } from '../../io';
|
|
2
|
+
import type { Directive } from './Directive';
|
|
3
|
+
import type { Properties } from './Properties';
|
|
4
|
+
export declare class Embed implements Directive {
|
|
5
|
+
private readonly embeddings;
|
|
6
|
+
constructor(map: Record<string, string | string[]>);
|
|
7
|
+
preflight(input: Input, properties: Properties): void;
|
|
8
|
+
private resolve;
|
|
9
|
+
private embedding;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Embed = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const embeddings_1 = require("./embeddings");
|
|
9
|
+
class Embed {
|
|
10
|
+
embeddings = [];
|
|
11
|
+
constructor(map) {
|
|
12
|
+
for (const [key, values] of Object.entries(map)) {
|
|
13
|
+
const names = Array.isArray(values) ? values : [values];
|
|
14
|
+
const instances = names.map((name) => {
|
|
15
|
+
if (name[0] === ':')
|
|
16
|
+
return new embeddings_1.Header(name.slice(1));
|
|
17
|
+
node_assert_1.default.ok(name in embeddings_1.embeddings, `Unknown embedding: ${name}`);
|
|
18
|
+
return new embeddings_1.embeddings[name]();
|
|
19
|
+
});
|
|
20
|
+
this.embeddings.push([key, instances]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
preflight(input, properties) {
|
|
24
|
+
const values = {};
|
|
25
|
+
for (const [key, instances] of this.embeddings)
|
|
26
|
+
values[key] = this.resolve(instances, input, properties);
|
|
27
|
+
input.pipelines.body.push(this.embedding(values));
|
|
28
|
+
}
|
|
29
|
+
resolve(instances, input, properties) {
|
|
30
|
+
let value;
|
|
31
|
+
for (const instance of instances) {
|
|
32
|
+
value = instance.resolve(input, properties);
|
|
33
|
+
if (value !== undefined)
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
node_assert_1.default.ok(value !== undefined, 'Neither embedding resolved a value.');
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
embedding(values) {
|
|
40
|
+
return (body) => {
|
|
41
|
+
if (body === undefined || body === null || typeof body !== 'object')
|
|
42
|
+
return values;
|
|
43
|
+
Object.assign(body, values);
|
|
44
|
+
return body;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Embed = Embed;
|
|
49
|
+
//# sourceMappingURL=Embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embed.js","sourceRoot":"","sources":["../../../source/directives/vary/Embed.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,6CAAiD;AAMjD,MAAa,KAAK;IACC,UAAU,GAAiC,EAAE,CAAA;IAE9D,YAAoB,GAAsC;QACxD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAChD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;YAEvD,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACnC,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AAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;gBACjE,OAAO,MAAM,CAAA;YAEf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAE3B,OAAO,IAAI,CAAA;QACb,CAAC,CAAA;IACH,CAAC;CACF;AAtDD,sBAsDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface Properties {
|
|
2
|
+
languages?: string[];
|
|
3
|
+
}
|
|
4
|
+
export declare class Property<K extends keyof Properties = keyof Properties> {
|
|
5
|
+
readonly name: K;
|
|
6
|
+
readonly value: Properties[K];
|
|
7
|
+
constructor(name: K, value: Properties[K]);
|
|
8
|
+
}
|
|
9
|
+
export declare const properties: Properties;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.properties = exports.Property = void 0;
|
|
4
|
+
class Property {
|
|
5
|
+
name;
|
|
6
|
+
value;
|
|
7
|
+
constructor(name, value) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.value = value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Property = Property;
|
|
13
|
+
exports.properties = {
|
|
14
|
+
languages: []
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=Properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Properties.js","sourceRoot":"","sources":["../../../source/directives/vary/Properties.ts"],"names":[],"mappings":";;;AAIA,MAAa,QAAQ;IACH,IAAI,CAAG;IACP,KAAK,CAAe;IAEpC,YAAoB,IAAO,EAAE,KAAoB;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AARD,4BAQC;AAEY,QAAA,UAAU,GAAe;IACpC,SAAS,EAAE,EAAE;CACd,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Property } from './Properties';
|
|
2
|
+
import type { Directive } from './Directive';
|
|
3
|
+
import type { Family } from '../../Directive';
|
|
4
|
+
import type { Input, Output } from '../../io';
|
|
5
|
+
export declare class Vary implements Family {
|
|
6
|
+
readonly name = "vary";
|
|
7
|
+
readonly mandatory = false;
|
|
8
|
+
create(name: string, value: unknown): Property | Directive;
|
|
9
|
+
preflight(instances: Array<Directive | Property>, request: Input): Output;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vary = void 0;
|
|
4
|
+
const matchacho_1 = require("matchacho");
|
|
5
|
+
const Properties_1 = require("./Properties");
|
|
6
|
+
const Embed_1 = require("./Embed");
|
|
7
|
+
class Vary {
|
|
8
|
+
name = 'vary';
|
|
9
|
+
mandatory = false;
|
|
10
|
+
create(name, value) {
|
|
11
|
+
return (0, matchacho_1.match)(name, () => name in Properties_1.properties, (name) => new Properties_1.Property(name, value), () => name in directives, (name) => new directives[name](value), () => {
|
|
12
|
+
throw new Error(`Unknown directive 'vary:${name}'`);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
preflight(instances, request) {
|
|
16
|
+
/*
|
|
17
|
+
To stop consructing `properties` object on each request, Directive Families must be refactored
|
|
18
|
+
from singleton factories to per-Node instances on the Tree.
|
|
19
|
+
*/
|
|
20
|
+
const properties = {};
|
|
21
|
+
const directives = [];
|
|
22
|
+
for (const instance of instances)
|
|
23
|
+
if (instance instanceof Properties_1.Property)
|
|
24
|
+
properties[instance.name] = instance.value;
|
|
25
|
+
else
|
|
26
|
+
directives.push(instance);
|
|
27
|
+
for (const directive of directives)
|
|
28
|
+
directive.preflight(request, properties);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.Vary = Vary;
|
|
33
|
+
const directives = {
|
|
34
|
+
embed: Embed_1.Embed
|
|
35
|
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,aAAK;CACb,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embedding.js","sourceRoot":"","sources":["../../../../source/directives/vary/embeddings/Embedding.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Header = void 0;
|
|
4
|
+
const cors_1 = require("../../cors");
|
|
5
|
+
class Header {
|
|
6
|
+
name;
|
|
7
|
+
constructor(name) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
cors_1.cors.allowHeader(this.name);
|
|
10
|
+
}
|
|
11
|
+
resolve(input) {
|
|
12
|
+
const value = input.headers[this.name];
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return value;
|
|
15
|
+
input.pipelines.response.push((response) => {
|
|
16
|
+
response.headers ??= new Headers();
|
|
17
|
+
response.headers.append('vary', this.name);
|
|
18
|
+
});
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return value.join(', ');
|
|
21
|
+
else
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Header = Header;
|
|
26
|
+
//# sourceMappingURL=Header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../source/directives/vary/embeddings/Header.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAIjC,MAAa,MAAM;IACA,IAAI,CAAQ;IAE7B,YAAoB,IAAY;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,WAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAEM,OAAO,CAAE,KAAY;QAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEtC,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,KAAK,CAAA;QAEd,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACzC,QAAQ,CAAC,OAAO,KAAK,IAAI,OAAO,EAAE,CAAA;YAClC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;QAEF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACtB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;YAEvB,OAAO,KAAK,CAAA;IAChB,CAAC;CACF;AAzBD,wBAyBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Properties } from '../Properties';
|
|
2
|
+
import type { Embedding } from './Embedding';
|
|
3
|
+
import type { Input } from '../../../io';
|
|
4
|
+
export declare class Language implements Embedding {
|
|
5
|
+
constructor();
|
|
6
|
+
resolve(input: Input, properties: Properties): string | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Language = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
const negotiator_1 = __importDefault(require("negotiator"));
|
|
9
|
+
const cors_1 = require("../../cors");
|
|
10
|
+
class Language {
|
|
11
|
+
constructor() {
|
|
12
|
+
cors_1.cors.allowHeader('accept-language');
|
|
13
|
+
}
|
|
14
|
+
resolve(input, properties) {
|
|
15
|
+
node_assert_1.default.ok(properties.languages !== undefined, 'Supported languages are not defined. Use `vary:languages` directive.');
|
|
16
|
+
node_assert_1.default.ok(properties.languages.length > 0, 'List of supported languages is empty.');
|
|
17
|
+
const negotiator = new negotiator_1.default(input);
|
|
18
|
+
const language = negotiator.language(properties.languages) ?? properties.languages[0];
|
|
19
|
+
input.pipelines.response.push((response) => {
|
|
20
|
+
response.headers ??= new Headers();
|
|
21
|
+
response.headers.set('content-language', language);
|
|
22
|
+
response.headers.append('vary', 'accept-language');
|
|
23
|
+
});
|
|
24
|
+
return language;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Language = Language;
|
|
28
|
+
//# sourceMappingURL=Language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Language.js","sourceRoot":"","sources":["../../../../source/directives/vary/embeddings/Language.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAChC,4DAAmC;AACnC,qCAAiC;AAKjC,MAAa,QAAQ;IACnB;QACE,WAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAA;IACrC,CAAC;IAEM,OAAO,CAAE,KAAY,EAAE,UAAsB;QAClD,qBAAM,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAC1C,sEAAsE,CAAC,CAAA;QAEzE,qBAAM,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EACvC,uCAAuC,CAAC,CAAA;QAE1C,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC,KAAK,CAAC,CAAA;QACxC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAErF,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YACzC,QAAQ,CAAC,OAAO,KAAK,IAAI,OAAO,EAAE,CAAA;YAClC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAA;YAClD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QAEF,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AAvBD,4BAuBC"}
|