@toa.io/definitions 1.0.0-alpha.288
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/digest/extensions.cadence.json +1 -0
- package/digest/extensions.configuration.json +1 -0
- package/digest/extensions.exposition.json +1 -0
- package/digest/extensions.introspection.json +1 -0
- package/digest/extensions.realtime.json +1 -0
- package/package.json +42 -0
- package/readme.md +75 -0
- package/schemas/extensions.cadence/annotation.cos.yaml +9 -0
- package/schemas/extensions.cadence/declaration.cos.yaml +20 -0
- package/schemas/extensions.configuration/annotation.cos.yaml +29 -0
- package/schemas/extensions.configuration/manifest.cos.yaml +9 -0
- package/schemas/extensions.exposition/annotation.cos.yaml +125 -0
- package/schemas/extensions.exposition/call.cos.yaml +18 -0
- package/schemas/extensions.exposition/directive.cos.yaml +7 -0
- package/schemas/extensions.exposition/method.cos.yaml +23 -0
- package/schemas/extensions.exposition/node.cos.yaml +22 -0
- package/schemas/extensions.exposition/query.cos.yaml +31 -0
- package/schemas/extensions.exposition/querystring.cos.yaml +19 -0
- package/schemas/extensions.exposition/range.cos.yaml +10 -0
- package/schemas/extensions.exposition/route.cos.yaml +6 -0
- package/schemas/extensions.introspection/annotation.cos.yaml +31 -0
- package/schemas/extensions.introspection/declaration.cos.yaml +5 -0
- package/schemas/extensions.storages/annotation.cos.yaml +11 -0
- package/schemas/extensions.storages/cloudinary.cos.yaml +38 -0
- package/schemas/extensions.storages/fs.cos.yaml +13 -0
- package/schemas/extensions.storages/s3.cos.yaml +17 -0
- package/schemas/extensions.storages/spaces.cos.yaml +16 -0
- package/schemas/extensions.storages/test.cos.yaml +10 -0
- package/schemas/extensions.storages/tmp.cos.yaml +10 -0
- package/source/bindings.amqp/annotation.ts +26 -0
- package/source/bindings.amqp/context.ts +68 -0
- package/source/bindings.amqp/deployment.ts +14 -0
- package/source/bindings.amqp/index.ts +9 -0
- package/source/bindings.amqp/instance.ts +3 -0
- package/source/bindings.amqp/sources.ts +39 -0
- package/source/bindings.loop/index.ts +3 -0
- package/source/bridges.bash/const.ts +2 -0
- package/source/bridges.bash/define.ts +38 -0
- package/source/bridges.bash/index.ts +2 -0
- package/source/bridges.node/define.ts +69 -0
- package/source/bridges.node/exports.ts +175 -0
- package/source/bridges.node/index.ts +6 -0
- package/source/bridges.node/operations.ts +127 -0
- package/source/bridges.node/sources.ts +44 -0
- package/source/definition.ts +38 -0
- package/source/digest/generate.ts +77 -0
- package/source/digest/read.ts +39 -0
- package/source/extensions.cadence/components.ts +6 -0
- package/source/extensions.cadence/const.ts +31 -0
- package/source/extensions.cadence/context.ts +10 -0
- package/source/extensions.cadence/deployment.ts +37 -0
- package/source/extensions.cadence/index.ts +8 -0
- package/source/extensions.cadence/manifest.ts +64 -0
- package/source/extensions.cadence/schemas.ts +10 -0
- package/source/extensions.cadence/types.ts +41 -0
- package/source/extensions.configuration/components.ts +6 -0
- package/source/extensions.configuration/const.ts +30 -0
- package/source/extensions.configuration/context.ts +13 -0
- package/source/extensions.configuration/deployment.ts +159 -0
- package/source/extensions.configuration/epoch.ts +22 -0
- package/source/extensions.configuration/index.ts +10 -0
- package/source/extensions.configuration/manifest.ts +12 -0
- package/source/extensions.configuration/schemas.ts +9 -0
- package/source/extensions.exposition/Annotation.ts +91 -0
- package/source/extensions.exposition/components.ts +6 -0
- package/source/extensions.exposition/const.ts +45 -0
- package/source/extensions.exposition/deployment.ts +95 -0
- package/source/extensions.exposition/index.ts +16 -0
- package/source/extensions.exposition/manifest.ts +56 -0
- package/source/extensions.exposition/schemas.ts +16 -0
- package/source/extensions.exposition/shortcuts.ts +14 -0
- package/source/extensions.exposition/syntax/index.ts +2 -0
- package/source/extensions.exposition/syntax/parse.ts +171 -0
- package/source/extensions.exposition/syntax/types.ts +69 -0
- package/source/extensions.fetch/context.ts +10 -0
- package/source/extensions.fetch/index.ts +1 -0
- package/source/extensions.introspection/annotation.ts +87 -0
- package/source/extensions.introspection/components.ts +13 -0
- package/source/extensions.introspection/const.ts +46 -0
- package/source/extensions.introspection/deployment.ts +48 -0
- package/source/extensions.introspection/index.ts +6 -0
- package/source/extensions.introspection/manifest.ts +18 -0
- package/source/extensions.introspection/schemas.ts +12 -0
- package/source/extensions.realtime/components.ts +5 -0
- package/source/extensions.realtime/deployment.ts +89 -0
- package/source/extensions.realtime/index.ts +4 -0
- package/source/extensions.stash/context.ts +10 -0
- package/source/extensions.stash/deployment.ts +22 -0
- package/source/extensions.stash/index.ts +2 -0
- package/source/extensions.state/context.ts +9 -0
- package/source/extensions.state/index.ts +1 -0
- package/source/extensions.storages/Annotation.ts +57 -0
- package/source/extensions.storages/context.ts +14 -0
- package/source/extensions.storages/deployment.ts +91 -0
- package/source/extensions.storages/index.ts +9 -0
- package/source/extensions.storages/manifest.ts +7 -0
- package/source/extensions.storages/schemas.ts +15 -0
- package/source/extensions.storages/secrets.ts +22 -0
- package/source/extensions.telemetry/const.ts +6 -0
- package/source/extensions.telemetry/context.ts +11 -0
- package/source/extensions.telemetry/deployment.ts +91 -0
- package/source/extensions.telemetry/index.ts +5 -0
- package/source/extensions.telemetry/ready.ts +33 -0
- package/source/index.ts +2 -0
- package/source/storages.mongodb/deployment.ts +22 -0
- package/source/storages.mongodb/index.ts +1 -0
- package/source/version.ts +10 -0
- package/transpiled/bindings.amqp/annotation.d.ts +10 -0
- package/transpiled/bindings.amqp/annotation.js +16 -0
- package/transpiled/bindings.amqp/annotation.js.map +1 -0
- package/transpiled/bindings.amqp/annotation.test.d.ts +1 -0
- package/transpiled/bindings.amqp/annotation.test.js +36 -0
- package/transpiled/bindings.amqp/annotation.test.js.map +1 -0
- package/transpiled/bindings.amqp/context.d.ts +7 -0
- package/transpiled/bindings.amqp/context.js +47 -0
- package/transpiled/bindings.amqp/context.js.map +1 -0
- package/transpiled/bindings.amqp/deployment.d.ts +4 -0
- package/transpiled/bindings.amqp/deployment.js +11 -0
- package/transpiled/bindings.amqp/deployment.js.map +1 -0
- package/transpiled/bindings.amqp/index.d.ts +6 -0
- package/transpiled/bindings.amqp/index.js +5 -0
- package/transpiled/bindings.amqp/index.js.map +1 -0
- package/transpiled/bindings.amqp/instance.d.ts +2 -0
- package/transpiled/bindings.amqp/instance.js +2 -0
- package/transpiled/bindings.amqp/instance.js.map +1 -0
- package/transpiled/bindings.amqp/properties.test.d.ts +1 -0
- package/transpiled/bindings.amqp/properties.test.js +7 -0
- package/transpiled/bindings.amqp/properties.test.js.map +1 -0
- package/transpiled/bindings.amqp/sources.d.ts +7 -0
- package/transpiled/bindings.amqp/sources.js +27 -0
- package/transpiled/bindings.amqp/sources.js.map +1 -0
- package/transpiled/bindings.loop/index.d.ts +2 -0
- package/transpiled/bindings.loop/index.js +2 -0
- package/transpiled/bindings.loop/index.js.map +1 -0
- package/transpiled/bindings.loop/properties.test.d.ts +1 -0
- package/transpiled/bindings.loop/properties.test.js +7 -0
- package/transpiled/bindings.loop/properties.test.js.map +1 -0
- package/transpiled/bridges.bash/const.d.ts +2 -0
- package/transpiled/bridges.bash/const.js +3 -0
- package/transpiled/bridges.bash/const.js.map +1 -0
- package/transpiled/bridges.bash/define.d.ts +3 -0
- package/transpiled/bridges.bash/define.js +25 -0
- package/transpiled/bridges.bash/define.js.map +1 -0
- package/transpiled/bridges.bash/index.d.ts +2 -0
- package/transpiled/bridges.bash/index.js +3 -0
- package/transpiled/bridges.bash/index.js.map +1 -0
- package/transpiled/bridges.node/define.d.ts +18 -0
- package/transpiled/bridges.node/define.js +46 -0
- package/transpiled/bridges.node/define.js.map +1 -0
- package/transpiled/bridges.node/exports.d.ts +16 -0
- package/transpiled/bridges.node/exports.js +134 -0
- package/transpiled/bridges.node/exports.js.map +1 -0
- package/transpiled/bridges.node/exports.test.d.ts +1 -0
- package/transpiled/bridges.node/exports.test.js +88 -0
- package/transpiled/bridges.node/exports.test.js.map +1 -0
- package/transpiled/bridges.node/index.d.ts +5 -0
- package/transpiled/bridges.node/index.js +4 -0
- package/transpiled/bridges.node/index.js.map +1 -0
- package/transpiled/bridges.node/operations.d.ts +13 -0
- package/transpiled/bridges.node/operations.js +96 -0
- package/transpiled/bridges.node/operations.js.map +1 -0
- package/transpiled/bridges.node/operations.test.d.ts +1 -0
- package/transpiled/bridges.node/operations.test.js +108 -0
- package/transpiled/bridges.node/operations.test.js.map +1 -0
- package/transpiled/bridges.node/sources.d.ts +7 -0
- package/transpiled/bridges.node/sources.js +36 -0
- package/transpiled/bridges.node/sources.js.map +1 -0
- package/transpiled/definition.d.ts +7 -0
- package/transpiled/definition.js +34 -0
- package/transpiled/definition.js.map +1 -0
- package/transpiled/digest/generate.d.ts +1 -0
- package/transpiled/digest/generate.js +60 -0
- package/transpiled/digest/generate.js.map +1 -0
- package/transpiled/digest/read.d.ts +16 -0
- package/transpiled/digest/read.js +22 -0
- package/transpiled/digest/read.js.map +1 -0
- package/transpiled/extensions.cadence/components.d.ts +3 -0
- package/transpiled/extensions.cadence/components.js +6 -0
- package/transpiled/extensions.cadence/components.js.map +1 -0
- package/transpiled/extensions.cadence/const.d.ts +21 -0
- package/transpiled/extensions.cadence/const.js +26 -0
- package/transpiled/extensions.cadence/const.js.map +1 -0
- package/transpiled/extensions.cadence/context.d.ts +3 -0
- package/transpiled/extensions.cadence/context.js +9 -0
- package/transpiled/extensions.cadence/context.js.map +1 -0
- package/transpiled/extensions.cadence/deployment.d.ts +9 -0
- package/transpiled/extensions.cadence/deployment.js +28 -0
- package/transpiled/extensions.cadence/deployment.js.map +1 -0
- package/transpiled/extensions.cadence/index.d.ts +7 -0
- package/transpiled/extensions.cadence/index.js +7 -0
- package/transpiled/extensions.cadence/index.js.map +1 -0
- package/transpiled/extensions.cadence/manifest.d.ts +11 -0
- package/transpiled/extensions.cadence/manifest.js +42 -0
- package/transpiled/extensions.cadence/manifest.js.map +1 -0
- package/transpiled/extensions.cadence/manifest.test.d.ts +1 -0
- package/transpiled/extensions.cadence/manifest.test.js +41 -0
- package/transpiled/extensions.cadence/manifest.test.js.map +1 -0
- package/transpiled/extensions.cadence/schemas.d.ts +4 -0
- package/transpiled/extensions.cadence/schemas.js +7 -0
- package/transpiled/extensions.cadence/schemas.js.map +1 -0
- package/transpiled/extensions.cadence/types.d.ts +34 -0
- package/transpiled/extensions.cadence/types.js +2 -0
- package/transpiled/extensions.cadence/types.js.map +1 -0
- package/transpiled/extensions.configuration/components.d.ts +3 -0
- package/transpiled/extensions.configuration/components.js +6 -0
- package/transpiled/extensions.configuration/components.js.map +1 -0
- package/transpiled/extensions.configuration/const.d.ts +18 -0
- package/transpiled/extensions.configuration/const.js +22 -0
- package/transpiled/extensions.configuration/const.js.map +1 -0
- package/transpiled/extensions.configuration/context.d.ts +4 -0
- package/transpiled/extensions.configuration/context.js +9 -0
- package/transpiled/extensions.configuration/context.js.map +1 -0
- package/transpiled/extensions.configuration/deployment.d.ts +17 -0
- package/transpiled/extensions.configuration/deployment.js +106 -0
- package/transpiled/extensions.configuration/deployment.js.map +1 -0
- package/transpiled/extensions.configuration/deployment.test.d.ts +1 -0
- package/transpiled/extensions.configuration/deployment.test.js +74 -0
- package/transpiled/extensions.configuration/deployment.test.js.map +1 -0
- package/transpiled/extensions.configuration/epoch.d.ts +2 -0
- package/transpiled/extensions.configuration/epoch.js +19 -0
- package/transpiled/extensions.configuration/epoch.js.map +1 -0
- package/transpiled/extensions.configuration/index.d.ts +9 -0
- package/transpiled/extensions.configuration/index.js +8 -0
- package/transpiled/extensions.configuration/index.js.map +1 -0
- package/transpiled/extensions.configuration/manifest.d.ts +5 -0
- package/transpiled/extensions.configuration/manifest.js +6 -0
- package/transpiled/extensions.configuration/manifest.js.map +1 -0
- package/transpiled/extensions.configuration/manifest.test.d.ts +1 -0
- package/transpiled/extensions.configuration/manifest.test.js +14 -0
- package/transpiled/extensions.configuration/manifest.test.js.map +1 -0
- package/transpiled/extensions.configuration/schemas.d.ts +3 -0
- package/transpiled/extensions.configuration/schemas.js +7 -0
- package/transpiled/extensions.configuration/schemas.js.map +1 -0
- package/transpiled/extensions.exposition/Annotation.d.ts +71 -0
- package/transpiled/extensions.exposition/Annotation.js +2 -0
- package/transpiled/extensions.exposition/Annotation.js.map +1 -0
- package/transpiled/extensions.exposition/components.d.ts +3 -0
- package/transpiled/extensions.exposition/components.js +6 -0
- package/transpiled/extensions.exposition/components.js.map +1 -0
- package/transpiled/extensions.exposition/const.d.ts +36 -0
- package/transpiled/extensions.exposition/const.js +37 -0
- package/transpiled/extensions.exposition/const.js.map +1 -0
- package/transpiled/extensions.exposition/deployment.d.ts +6 -0
- package/transpiled/extensions.exposition/deployment.js +75 -0
- package/transpiled/extensions.exposition/deployment.js.map +1 -0
- package/transpiled/extensions.exposition/index.d.ts +8 -0
- package/transpiled/extensions.exposition/index.js +8 -0
- package/transpiled/extensions.exposition/index.js.map +1 -0
- package/transpiled/extensions.exposition/manifest.d.ts +3 -0
- package/transpiled/extensions.exposition/manifest.js +39 -0
- package/transpiled/extensions.exposition/manifest.js.map +1 -0
- package/transpiled/extensions.exposition/manifest.test.d.ts +1 -0
- package/transpiled/extensions.exposition/manifest.test.js +38 -0
- package/transpiled/extensions.exposition/manifest.test.js.map +1 -0
- package/transpiled/extensions.exposition/schemas.d.ts +7 -0
- package/transpiled/extensions.exposition/schemas.js +10 -0
- package/transpiled/extensions.exposition/schemas.js.map +1 -0
- package/transpiled/extensions.exposition/schemas.test.d.ts +1 -0
- package/transpiled/extensions.exposition/schemas.test.js +22 -0
- package/transpiled/extensions.exposition/schemas.test.js.map +1 -0
- package/transpiled/extensions.exposition/shortcuts.d.ts +3 -0
- package/transpiled/extensions.exposition/shortcuts.js +13 -0
- package/transpiled/extensions.exposition/shortcuts.js.map +1 -0
- package/transpiled/extensions.exposition/syntax/index.d.ts +2 -0
- package/transpiled/extensions.exposition/syntax/index.js +3 -0
- package/transpiled/extensions.exposition/syntax/index.js.map +1 -0
- package/transpiled/extensions.exposition/syntax/parse.d.ts +4 -0
- package/transpiled/extensions.exposition/syntax/parse.js +112 -0
- package/transpiled/extensions.exposition/syntax/parse.js.map +1 -0
- package/transpiled/extensions.exposition/syntax/parse.test.d.ts +1 -0
- package/transpiled/extensions.exposition/syntax/parse.test.js +156 -0
- package/transpiled/extensions.exposition/syntax/parse.test.js.map +1 -0
- package/transpiled/extensions.exposition/syntax/types.d.ts +52 -0
- package/transpiled/extensions.exposition/syntax/types.js +11 -0
- package/transpiled/extensions.exposition/syntax/types.js.map +1 -0
- package/transpiled/extensions.fetch/context.d.ts +3 -0
- package/transpiled/extensions.fetch/context.js +9 -0
- package/transpiled/extensions.fetch/context.js.map +1 -0
- package/transpiled/extensions.fetch/index.d.ts +1 -0
- package/transpiled/extensions.fetch/index.js +2 -0
- package/transpiled/extensions.fetch/index.js.map +1 -0
- package/transpiled/extensions.introspection/annotation.d.ts +40 -0
- package/transpiled/extensions.introspection/annotation.js +39 -0
- package/transpiled/extensions.introspection/annotation.js.map +1 -0
- package/transpiled/extensions.introspection/components.d.ts +8 -0
- package/transpiled/extensions.introspection/components.js +12 -0
- package/transpiled/extensions.introspection/components.js.map +1 -0
- package/transpiled/extensions.introspection/const.d.ts +30 -0
- package/transpiled/extensions.introspection/const.js +35 -0
- package/transpiled/extensions.introspection/const.js.map +1 -0
- package/transpiled/extensions.introspection/deployment.d.ts +14 -0
- package/transpiled/extensions.introspection/deployment.js +41 -0
- package/transpiled/extensions.introspection/deployment.js.map +1 -0
- package/transpiled/extensions.introspection/index.d.ts +6 -0
- package/transpiled/extensions.introspection/index.js +7 -0
- package/transpiled/extensions.introspection/index.js.map +1 -0
- package/transpiled/extensions.introspection/manifest.d.ts +9 -0
- package/transpiled/extensions.introspection/manifest.js +16 -0
- package/transpiled/extensions.introspection/manifest.js.map +1 -0
- package/transpiled/extensions.introspection/schemas.d.ts +4 -0
- package/transpiled/extensions.introspection/schemas.js +7 -0
- package/transpiled/extensions.introspection/schemas.js.map +1 -0
- package/transpiled/extensions.realtime/components.d.ts +2 -0
- package/transpiled/extensions.realtime/components.js +5 -0
- package/transpiled/extensions.realtime/components.js.map +1 -0
- package/transpiled/extensions.realtime/deployment.d.ts +22 -0
- package/transpiled/extensions.realtime/deployment.js +53 -0
- package/transpiled/extensions.realtime/deployment.js.map +1 -0
- package/transpiled/extensions.realtime/index.d.ts +3 -0
- package/transpiled/extensions.realtime/index.js +3 -0
- package/transpiled/extensions.realtime/index.js.map +1 -0
- package/transpiled/extensions.stash/context.d.ts +3 -0
- package/transpiled/extensions.stash/context.js +9 -0
- package/transpiled/extensions.stash/context.js.map +1 -0
- package/transpiled/extensions.stash/deployment.d.ts +5 -0
- package/transpiled/extensions.stash/deployment.js +14 -0
- package/transpiled/extensions.stash/deployment.js.map +1 -0
- package/transpiled/extensions.stash/index.d.ts +2 -0
- package/transpiled/extensions.stash/index.js +3 -0
- package/transpiled/extensions.stash/index.js.map +1 -0
- package/transpiled/extensions.state/context.d.ts +6 -0
- package/transpiled/extensions.state/context.js +8 -0
- package/transpiled/extensions.state/context.js.map +1 -0
- package/transpiled/extensions.state/index.d.ts +1 -0
- package/transpiled/extensions.state/index.js +2 -0
- package/transpiled/extensions.state/index.js.map +1 -0
- package/transpiled/extensions.storages/Annotation.d.ts +8 -0
- package/transpiled/extensions.storages/Annotation.js +31 -0
- package/transpiled/extensions.storages/Annotation.js.map +1 -0
- package/transpiled/extensions.storages/context.d.ts +3 -0
- package/transpiled/extensions.storages/context.js +12 -0
- package/transpiled/extensions.storages/context.js.map +1 -0
- package/transpiled/extensions.storages/deployment.d.ts +5 -0
- package/transpiled/extensions.storages/deployment.js +64 -0
- package/transpiled/extensions.storages/deployment.js.map +1 -0
- package/transpiled/extensions.storages/index.d.ts +8 -0
- package/transpiled/extensions.storages/index.js +7 -0
- package/transpiled/extensions.storages/index.js.map +1 -0
- package/transpiled/extensions.storages/manifest.d.ts +1 -0
- package/transpiled/extensions.storages/manifest.js +8 -0
- package/transpiled/extensions.storages/manifest.js.map +1 -0
- package/transpiled/extensions.storages/schemas.d.ts +9 -0
- package/transpiled/extensions.storages/schemas.js +12 -0
- package/transpiled/extensions.storages/schemas.js.map +1 -0
- package/transpiled/extensions.storages/schemas.test.d.ts +1 -0
- package/transpiled/extensions.storages/schemas.test.js +59 -0
- package/transpiled/extensions.storages/schemas.test.js.map +1 -0
- package/transpiled/extensions.storages/secrets.d.ts +10 -0
- package/transpiled/extensions.storages/secrets.js +16 -0
- package/transpiled/extensions.storages/secrets.js.map +1 -0
- package/transpiled/extensions.telemetry/const.d.ts +4 -0
- package/transpiled/extensions.telemetry/const.js +6 -0
- package/transpiled/extensions.telemetry/const.js.map +1 -0
- package/transpiled/extensions.telemetry/context.d.ts +3 -0
- package/transpiled/extensions.telemetry/context.js +9 -0
- package/transpiled/extensions.telemetry/context.js.map +1 -0
- package/transpiled/extensions.telemetry/deployment.d.ts +18 -0
- package/transpiled/extensions.telemetry/deployment.js +49 -0
- package/transpiled/extensions.telemetry/deployment.js.map +1 -0
- package/transpiled/extensions.telemetry/index.d.ts +5 -0
- package/transpiled/extensions.telemetry/index.js +5 -0
- package/transpiled/extensions.telemetry/index.js.map +1 -0
- package/transpiled/extensions.telemetry/ready.d.ts +14 -0
- package/transpiled/extensions.telemetry/ready.js +16 -0
- package/transpiled/extensions.telemetry/ready.js.map +1 -0
- package/transpiled/index.d.ts +2 -0
- package/transpiled/index.js +3 -0
- package/transpiled/index.js.map +1 -0
- package/transpiled/storages.mongodb/deployment.d.ts +5 -0
- package/transpiled/storages.mongodb/deployment.js +14 -0
- package/transpiled/storages.mongodb/deployment.js.map +1 -0
- package/transpiled/storages.mongodb/index.d.ts +1 -0
- package/transpiled/storages.mongodb/index.js +2 -0
- package/transpiled/storages.mongodb/index.js.map +1 -0
- package/transpiled/version.d.ts +5 -0
- package/transpiled/version.js +8 -0
- package/transpiled/version.js.map +1 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const BRANCH_TTL = 1_800_000;
|
|
2
|
+
/** The broadcast the gateway and its tenants share. */
|
|
3
|
+
export const CHANNEL = 'exposition';
|
|
4
|
+
/** The replicas of the gateway decide together, whatever context they serve. */
|
|
5
|
+
export const ATOM_GROUP = 'exposition';
|
|
6
|
+
/**
|
|
7
|
+
* Where JSON-RPC is served, for every procedure at once. Pinned rather than configured: a
|
|
8
|
+
* path an application could choose is a path it could collide with a route of its own.
|
|
9
|
+
*/
|
|
10
|
+
export const RPC = '/.rpc';
|
|
11
|
+
/** Calls one request may carry where the annotation does not say. */
|
|
12
|
+
export const BATCH = 32;
|
|
13
|
+
/**
|
|
14
|
+
* Where the Model Context Protocol is served. Pinned for the reason `/.rpc` is: a path an
|
|
15
|
+
* application could choose is a path it could collide with a route of its own.
|
|
16
|
+
*/
|
|
17
|
+
export const MCP = '/.mcp';
|
|
18
|
+
/**
|
|
19
|
+
* Where the resource tree and the page that reads it are served. Pinned for the reason
|
|
20
|
+
* `/.rpc` is: a path an application could choose is a path it could collide with a route of
|
|
21
|
+
* its own. Unlike those two it is not annotated — every entry it carries is what `OPTIONS`
|
|
22
|
+
* on that path already answers to the same caller, and what it adds is the enumeration.
|
|
23
|
+
*/
|
|
24
|
+
export const DISCOVERY = '/.discovery';
|
|
25
|
+
/** Where the gateway serves. */
|
|
26
|
+
export const PORT = 8000;
|
|
27
|
+
/**
|
|
28
|
+
* Reserved for the readiness probe. `8001` is the Telemetry readiness probe's, and `toa export`
|
|
29
|
+
* refuses a port claimed twice — `toa mono` and a local run put every service in one process.
|
|
30
|
+
*/
|
|
31
|
+
export const PROBE = 8004;
|
|
32
|
+
/**
|
|
33
|
+
* The initial delay of the readiness probe. The server does not sleep for it: whoever
|
|
34
|
+
* probes is the one that waits, and doing it here as well only delayed the process twice.
|
|
35
|
+
*/
|
|
36
|
+
export const DELAY = 3; // seconds
|
|
37
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../source/extensions.exposition/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AAEnC,uDAAuD;AACvD,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAA;AAEnC,gFAAgF;AAChF,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAA;AAE1B,qEAAqE;AACrE,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAA;AAEvB;;;GAGG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,OAAO,CAAA;AAE1B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAA;AAEtC,gCAAgC;AAChC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAA;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAA;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAA,CAAC,UAAU"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Dependency } from '@toa.io/operations';
|
|
2
|
+
import { type Annotation } from './Annotation.js';
|
|
3
|
+
/** Where Toa's release publishes this service's image. An application takes it
|
|
4
|
+
* instead of building one when its context says `registry.services: published`. */
|
|
5
|
+
export declare const image = "ghcr.io/toa-io/extension-exposition-gateway";
|
|
6
|
+
export declare function deployment(_: unknown, annotation?: Annotation): Dependency;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import * as schemas from './schemas.js';
|
|
3
|
+
import { shortcuts } from './shortcuts.js';
|
|
4
|
+
import { components } from './components.js';
|
|
5
|
+
import { parse } from './syntax/index.js';
|
|
6
|
+
import { DELAY, PORT, PROBE } from './const.js';
|
|
7
|
+
import { version } from '../version.js';
|
|
8
|
+
/** Where Toa's release publishes this service's image. An application takes it
|
|
9
|
+
* instead of building one when its context says `registry.services: published`. */
|
|
10
|
+
export const image = 'ghcr.io/toa-io/extension-exposition-gateway';
|
|
11
|
+
export function deployment(_, annotation) {
|
|
12
|
+
assert.ok(annotation !== undefined, 'Exposition context annotation is required');
|
|
13
|
+
schemas.annotation.validate(annotation);
|
|
14
|
+
const labels = components().labels;
|
|
15
|
+
const service = {
|
|
16
|
+
group: 'exposition',
|
|
17
|
+
name: 'gateway',
|
|
18
|
+
image,
|
|
19
|
+
port: PORT,
|
|
20
|
+
version,
|
|
21
|
+
variables: [],
|
|
22
|
+
components: labels,
|
|
23
|
+
resources: annotation.resources,
|
|
24
|
+
ingress: { path: '/', hosts: [] },
|
|
25
|
+
probe: {
|
|
26
|
+
path: '/.ready',
|
|
27
|
+
port: PROBE,
|
|
28
|
+
delay: DELAY
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
if (annotation?.['/'] !== undefined) {
|
|
32
|
+
const tree = parse(annotation['/'], shortcuts);
|
|
33
|
+
service.variables.push({
|
|
34
|
+
name: 'TOA_EXPOSITION',
|
|
35
|
+
value: JSON.stringify(tree)
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const { debug, authorities } = annotation;
|
|
39
|
+
service.ingress.hosts = Object.values(authorities);
|
|
40
|
+
// leaving these undefined lets the context's own ingress section supply them
|
|
41
|
+
if (annotation.class !== undefined)
|
|
42
|
+
service.ingress.class = annotation.class;
|
|
43
|
+
if (annotation.annotations !== undefined)
|
|
44
|
+
service.ingress.annotations = annotation.annotations;
|
|
45
|
+
if (annotation.service?.annotations !== undefined)
|
|
46
|
+
service.annotations = annotation.service.annotations;
|
|
47
|
+
const properties = { authorities };
|
|
48
|
+
if (debug === true)
|
|
49
|
+
properties.debug = true;
|
|
50
|
+
if (annotation.protocol !== undefined)
|
|
51
|
+
properties.protocol = annotation.protocol;
|
|
52
|
+
if (annotation.ip !== undefined)
|
|
53
|
+
properties.ip = annotation.ip;
|
|
54
|
+
if (annotation.bouncer !== undefined)
|
|
55
|
+
properties.bouncer = annotation.bouncer;
|
|
56
|
+
if (annotation.oauth !== undefined)
|
|
57
|
+
properties.oauth = annotation.oauth;
|
|
58
|
+
if (annotation.rpc !== undefined)
|
|
59
|
+
properties.rpc = annotation.rpc;
|
|
60
|
+
if (annotation.mcp !== undefined)
|
|
61
|
+
properties.mcp = annotation.mcp;
|
|
62
|
+
service.variables.push({
|
|
63
|
+
name: 'TOA_EXPOSITION_PROPERTIES',
|
|
64
|
+
value: JSON.stringify(properties)
|
|
65
|
+
});
|
|
66
|
+
// The identity composition nested in this process connects before route discovery settles,
|
|
67
|
+
// so telemetry's probe — which tracks that composition — would report ready too early.
|
|
68
|
+
// The gateway answers for itself, on the same port telemetry would have used.
|
|
69
|
+
service.variables.push({
|
|
70
|
+
name: 'TOA_TELEMETRY_READY',
|
|
71
|
+
value: JSON.stringify(false)
|
|
72
|
+
});
|
|
73
|
+
return { services: [service] };
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=deployment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../source/extensions.exposition/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAGhC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;oFACoF;AACpF,MAAM,CAAC,MAAM,KAAK,GAAG,6CAA6C,CAAA;AAElE,MAAM,UAAU,UAAU,CAAC,CAAU,EAAE,UAAuB;IAC5D,MAAM,CAAC,EAAE,CAAC,UAAU,KAAK,SAAS,EAAE,2CAA2C,CAAC,CAAA;IAChF,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;I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ment.js';
|
|
4
|
+
export { shortcuts } from './shortcuts.js';
|
|
5
|
+
export * from './const.js';
|
|
6
|
+
export * as schemas from './schemas.js';
|
|
7
|
+
export * as syntax from './syntax/index.js';
|
|
8
|
+
export type { Annotation, Bouncer, MCP as MCPAnnotation, OAuth, Protocol, RPC as RPCAnnotation } from './Annotation.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { manifest } from './manifest.js';
|
|
2
|
+
export { components } from './components.js';
|
|
3
|
+
export { deployment, image } from './deployment.js';
|
|
4
|
+
export { shortcuts } from './shortcuts.js';
|
|
5
|
+
export * from './const.js';
|
|
6
|
+
export * as schemas from './schemas.js';
|
|
7
|
+
export * as syntax from './syntax/index.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/extensions.exposition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,cAAc,YAAY,CAAA;AAC1B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { parse } from './syntax/index.js';
|
|
3
|
+
import { shortcuts } from './shortcuts.js';
|
|
4
|
+
import * as schemas from './schemas.js';
|
|
5
|
+
export function manifest(declaration, manifest) {
|
|
6
|
+
assert.ok(typeof declaration === 'object' && declaration !== null, 'Exposition declaration must be an object');
|
|
7
|
+
declaration = wrap(declaration, manifest.namespace, manifest.name);
|
|
8
|
+
const node = parse(declaration, shortcuts);
|
|
9
|
+
specify(node, manifest);
|
|
10
|
+
schemas.node.validate(node);
|
|
11
|
+
return node;
|
|
12
|
+
}
|
|
13
|
+
function wrap(declaration, namespace, name) {
|
|
14
|
+
const path = (namespace === undefined || namespace === 'default' ? '' : '/' + namespace) +
|
|
15
|
+
'/' +
|
|
16
|
+
name;
|
|
17
|
+
return { [path]: declaration };
|
|
18
|
+
}
|
|
19
|
+
function specify(node, manifest) {
|
|
20
|
+
for (const route of node.routes) {
|
|
21
|
+
for (const method of route.node.methods)
|
|
22
|
+
specifyMethod(method, manifest);
|
|
23
|
+
specify(route.node, manifest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function specifyMethod(method, manifest) {
|
|
27
|
+
if (method.mapping?.endpoint === undefined)
|
|
28
|
+
return;
|
|
29
|
+
const operation = manifest.operations[method.mapping.endpoint];
|
|
30
|
+
assert.ok(operation !== undefined, `Operation '${method.mapping.endpoint}' not found`);
|
|
31
|
+
if (method.mapping.query === undefined)
|
|
32
|
+
method.mapping.query = operation.query === false ? null : {};
|
|
33
|
+
// a page is taken of a collection, and of nothing else: an operation that answers one object
|
|
34
|
+
// takes no `omit` and no `limit`, and refuses a request that carries them
|
|
35
|
+
method.mapping.paged = operation.type === 'observation' && operation.scope === 'objects';
|
|
36
|
+
method.mapping.namespace = manifest.namespace;
|
|
37
|
+
method.mapping.component = manifest.name;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../source/extensions.exposition/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,KAAK,EAAsC,MAAM,mBAAmB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAGvC,MAAM,UAAU,QAAQ,CAAC,WAAmB,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D,MAAM,CAAC,EAAE,CAAC,SAAS,KAAK,SAAS,EAAE,cAAc,MAAM,CAAC,OAAO,CAAC,QAAQ,aAAa,CAAC,CAAA;IAEtF,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK,SAAS;QACpC,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,EAAuB,CAAA;IAEpF,6FAA6F;IAC7F,0EAA0E;IAC1E,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,IAAI,KAAK,aAAa,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS,CAAA;IAExF,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;IAC7C,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { it, beforeEach } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { generate } from 'randomstring';
|
|
4
|
+
import { manifest } from './manifest.js';
|
|
5
|
+
const name = 'cm-' + generate();
|
|
6
|
+
const namespace = 'ns' + generate();
|
|
7
|
+
let mf;
|
|
8
|
+
const operations = { observe: {} };
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
mf = { namespace, name, operations };
|
|
11
|
+
});
|
|
12
|
+
const declaration = {
|
|
13
|
+
'/': { GET: 'observe' }
|
|
14
|
+
};
|
|
15
|
+
it('should create branch', async () => {
|
|
16
|
+
const node = manifest(declaration, mf);
|
|
17
|
+
assert.notStrictEqual(node, undefined);
|
|
18
|
+
assert.strictEqual(node.routes.length, 1);
|
|
19
|
+
assert.strictEqual(node.routes[0].path, '/' + namespace + '/' + name);
|
|
20
|
+
});
|
|
21
|
+
it('should not create node for default namespace', async () => {
|
|
22
|
+
mf.namespace = 'default';
|
|
23
|
+
const node = manifest(declaration, mf);
|
|
24
|
+
assert.strictEqual(node.routes.length, 1);
|
|
25
|
+
assert.strictEqual(node.routes[0].path, '/' + name);
|
|
26
|
+
});
|
|
27
|
+
it('should throw on invalid declaration type', async () => {
|
|
28
|
+
assert.throws(() => manifest('hello', mf), (error) => /Exposition declaration must be an object/.test(error.message));
|
|
29
|
+
});
|
|
30
|
+
it('should set namespace and component', async () => {
|
|
31
|
+
const node = manifest(declaration, mf);
|
|
32
|
+
const root = node.routes[0].node;
|
|
33
|
+
const intemediate = root.routes[0].node;
|
|
34
|
+
const GET = intemediate.methods[0];
|
|
35
|
+
assert.strictEqual(GET.mapping?.namespace, namespace);
|
|
36
|
+
assert.strictEqual(GET.mapping?.component, name);
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=manifest.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.test.js","sourceRoot":"","sources":["../../source/extensions.exposition/manifest.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAGvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,IAAI,GAAG,KAAK,GAAG,QAAQ,EAAE,CAAA;AAC/B,MAAM,SAAS,GAAG,IAAI,GAAG,QAAQ,EAAE,CAAA;AAEnC,IAAI,EAAY,CAAA;AAEhB,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAAA;AAElC,UAAU,CAAC,GAAG,EAAE;IACd,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAyB,CAAA;AAC7D,CAAC,CAAC,CAAA;AAEF,MAAM,WAAW,GAAG;IAClB,GAAG,EAAE,EAAE,G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M,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACvC,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAElC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IACrD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;AAClD,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Schema } from '@toa.io/schemas';
|
|
2
|
+
import type { Node } from './syntax/types.js';
|
|
3
|
+
import type { Annotation } from './Annotation.js';
|
|
4
|
+
export declare const querystring: Schema<Record<string, unknown>>;
|
|
5
|
+
export declare const call: Schema<Record<string, unknown>>;
|
|
6
|
+
export declare const annotation: Schema<Annotation>;
|
|
7
|
+
export declare const node: Schema<Node>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import * as schemas from '@toa.io/schemas';
|
|
3
|
+
const path = resolve(import.meta.dirname, '../../schemas/extensions.exposition');
|
|
4
|
+
const namespace = schemas.namespace(path);
|
|
5
|
+
// what the gateway validates a request by, kept beside what a manifest is validated by
|
|
6
|
+
export const querystring = namespace.schema('querystring');
|
|
7
|
+
export const call = namespace.schema('call');
|
|
8
|
+
export const annotation = namespace.schema('annotation');
|
|
9
|
+
export const node = namespace.schema('node');
|
|
10
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../source/extensions.exposition/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAK1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAA;AAChF,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAEzC,uFAAuF;AACvF,MAAM,CAAC,MAAM,WAAW,GACtB,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,IAAI,GAAoC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAE7E,MAAM,CAAC,MAAM,UAAU,GAAuB,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;AAC5E,MAAM,CAAC,MAAM,IAAI,GAAiB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import * as schemas from './schemas.js';
|
|
4
|
+
const authorities = { nex: 'nex.toa.io' };
|
|
5
|
+
it('should require ip with bouncer', () => {
|
|
6
|
+
assert.throws(() => schemas.annotation.validate({ authorities, bouncer: {} }));
|
|
7
|
+
assert.doesNotThrow(() => schemas.annotation.validate({ authorities, bouncer: {}, ip: 'x-real-ip' }));
|
|
8
|
+
assert.doesNotThrow(() => schemas.annotation.validate({ authorities, ip: 'x-real-ip' }));
|
|
9
|
+
});
|
|
10
|
+
it('should default nothing in bouncer', () => {
|
|
11
|
+
assert.doesNotThrow(() => schemas.annotation.validate({
|
|
12
|
+
authorities,
|
|
13
|
+
ip: 'x-real-ip',
|
|
14
|
+
bouncer: { attempts: 5 }
|
|
15
|
+
}));
|
|
16
|
+
assert.throws(() => schemas.annotation.validate({
|
|
17
|
+
authorities,
|
|
18
|
+
ip: 'x-real-ip',
|
|
19
|
+
bouncer: { attempts: 0 }
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=schemas.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.test.js","sourceRoot":"","sources":["../../source/extensions.exposition/schemas.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAC9B,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,CAAA;AAEzC,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAC9E,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CACvB,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAC3E,CAAA;IACD,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;AAC1F,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC3C,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,CACvB,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1B,WAAW;QACX,EAAE,EAAE,WAAW;QACf,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;KACzB,CAAC,CACH,CAAA;IACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CACjB,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC1B,WAAW;QACX,EAAE,EAAE,WAAW;QACf,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE;KACzB,CAAC,CACH,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What a directive may be written as, where the family is implied. */
|
|
2
|
+
export const shortcuts = new Map([
|
|
3
|
+
['anonymous', 'auth:anonymous'],
|
|
4
|
+
['anyone', 'auth:anyone'],
|
|
5
|
+
['id', 'auth:id'],
|
|
6
|
+
['role', 'auth:role'],
|
|
7
|
+
['rule', 'auth:rule'],
|
|
8
|
+
['incept', 'auth:incept'],
|
|
9
|
+
['input', 'io:input'],
|
|
10
|
+
['output', 'io:output'],
|
|
11
|
+
['languages', 'map:languages']
|
|
12
|
+
]);
|
|
13
|
+
//# sourceMappingURL=shortcuts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shortcuts.js","sourceRoot":"","sources":["../../source/extensions.exposition/shortcuts.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAc,IAAI,GAAG,CAAC;IAC1C,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAC/B,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,QAAQ,EAAE,aAAa,CAAC;IACzB,CAAC,OAAO,EAAE,UAAU,CAAC;IACrB,CAAC,QAAQ,EAAE,WAAW,CAAC;IACvB,CAAC,WAAW,EAAE,eAAe,CAAC;CAC/B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/extensions.exposition/syntax/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as schemas from '../schemas.js';
|
|
2
|
+
import { verbs } from './types.js';
|
|
3
|
+
export function parse(input, shortcuts) {
|
|
4
|
+
const node = parseNode(input, shortcuts);
|
|
5
|
+
schemas.node.validate(node);
|
|
6
|
+
return node;
|
|
7
|
+
}
|
|
8
|
+
function parseNode(input, shortcuts) {
|
|
9
|
+
const node = createNode();
|
|
10
|
+
if (typeof input === 'string') {
|
|
11
|
+
node.forward = input;
|
|
12
|
+
return node;
|
|
13
|
+
}
|
|
14
|
+
for (const [key, value] of Object.entries(input))
|
|
15
|
+
switch (key) {
|
|
16
|
+
case 'protected':
|
|
17
|
+
case 'isolated':
|
|
18
|
+
node[key] = value;
|
|
19
|
+
break;
|
|
20
|
+
case 'forward':
|
|
21
|
+
node[key] = value;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
// eslint-disable-next-line max-depth
|
|
25
|
+
if (key[0] === '/') {
|
|
26
|
+
const route = parseRoute(key, value, shortcuts);
|
|
27
|
+
node.routes.push(route);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line max-depth
|
|
31
|
+
if (verbs.has(key)) {
|
|
32
|
+
const method = parseMethod(key, value, shortcuts);
|
|
33
|
+
node.methods.push(method);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line no-case-declarations
|
|
37
|
+
const directive = parseDirective(key, value, shortcuts);
|
|
38
|
+
// eslint-disable-next-line max-depth
|
|
39
|
+
if (directive !== null) {
|
|
40
|
+
node.directives.push(directive);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`RTD parse error: unknown key '${key}'`);
|
|
44
|
+
}
|
|
45
|
+
return node;
|
|
46
|
+
}
|
|
47
|
+
export function createNode() {
|
|
48
|
+
return {
|
|
49
|
+
routes: [],
|
|
50
|
+
methods: [],
|
|
51
|
+
directives: []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function parseRoute(path, value, shortcuts) {
|
|
55
|
+
const node = parse(value, shortcuts);
|
|
56
|
+
return createRoute(path, node);
|
|
57
|
+
}
|
|
58
|
+
function createRoute(path, node) {
|
|
59
|
+
return { path, node };
|
|
60
|
+
}
|
|
61
|
+
function parseMethod(verb, value, shortcuts) {
|
|
62
|
+
const mapping = typeof value === 'string' ? { endpoint: value } : value;
|
|
63
|
+
parseEndpoint(mapping);
|
|
64
|
+
parseQuery(mapping);
|
|
65
|
+
const directives = parseDirectives(mapping, shortcuts);
|
|
66
|
+
return { verb, mapping, directives };
|
|
67
|
+
}
|
|
68
|
+
function parseEndpoint(mapping) {
|
|
69
|
+
if (mapping.endpoint === undefined)
|
|
70
|
+
return;
|
|
71
|
+
const [endpoiont, component, namespace] = mapping.endpoint.split('.').reverse();
|
|
72
|
+
if (component !== undefined) {
|
|
73
|
+
mapping.component = component;
|
|
74
|
+
mapping.namespace = namespace ?? mapping.namespace ?? 'default';
|
|
75
|
+
mapping.endpoint = endpoiont;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function parseQuery(mapping) {
|
|
79
|
+
const query = mapping.query;
|
|
80
|
+
if (query === undefined || query === null)
|
|
81
|
+
return;
|
|
82
|
+
if (typeof query.limit === 'number')
|
|
83
|
+
query.limit = expandRange(query.limit);
|
|
84
|
+
if (typeof query.omit === 'number')
|
|
85
|
+
query.omit = expandRange(query.omit);
|
|
86
|
+
}
|
|
87
|
+
function parseDirectives(mapping, shortcuts) {
|
|
88
|
+
const directives = [];
|
|
89
|
+
for (const [key, value] of Object.entries(mapping)) {
|
|
90
|
+
const directive = parseDirective(key, value, shortcuts);
|
|
91
|
+
if (directive === null)
|
|
92
|
+
continue;
|
|
93
|
+
directives.push(directive);
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
95
|
+
delete mapping[key];
|
|
96
|
+
}
|
|
97
|
+
return directives;
|
|
98
|
+
}
|
|
99
|
+
function parseDirective(key, value, shortcuts) {
|
|
100
|
+
if (shortcuts?.has(key) === true)
|
|
101
|
+
key = shortcuts.get(key); // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
const match = key.match(DIRECTIVE_RX);
|
|
103
|
+
if (match === null)
|
|
104
|
+
return null;
|
|
105
|
+
const { family, name } = match.groups;
|
|
106
|
+
return { family, name, value };
|
|
107
|
+
}
|
|
108
|
+
function expandRange(range) {
|
|
109
|
+
return { value: range, range: [range, range] };
|
|
110
|
+
}
|
|
111
|
+
const DIRECTIVE_RX = /^(?<family>\w{1,32}):(?<name>\w{1,32})$/;
|
|
112
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../source/extensions.exposition/syntax/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,KAAK,EAON,MAAM,YAAY,CAAA;AAEnB,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,SAAqB;IACxD,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAExC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAE3B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,SAAS,CAAC,KAAsB,EAAE,SAAqB;IAC9D,MAAM,IAAI,GAAG,UAAU,EAAE,CAAA;IAEzB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QAEpB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAiC;QAC9E,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,WAAW,CAAC;YACjB,KAAK,UAAU;gBACb,IAAI,CAAC,GAAG,CAAC,GAAG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YAAY,GAAG,yCAAyC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { parse } from './parse.js';
|
|
4
|
+
describe('routes', () => {
|
|
5
|
+
it('should parse route', async () => {
|
|
6
|
+
const declaration = {
|
|
7
|
+
'/': {},
|
|
8
|
+
'/foo': {}
|
|
9
|
+
};
|
|
10
|
+
const node = parse(declaration);
|
|
11
|
+
assert.strictEqual(node.routes.length, 2);
|
|
12
|
+
assert.strictEqual(node.routes[0].path, '/');
|
|
13
|
+
assert.strictEqual(node.routes[1].path, '/foo');
|
|
14
|
+
});
|
|
15
|
+
it('should parse nested routes', async () => {
|
|
16
|
+
const declaration = {
|
|
17
|
+
'/': {
|
|
18
|
+
'/foo': {},
|
|
19
|
+
'/bar': {}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const node = parse(declaration);
|
|
23
|
+
const root = node.routes[0].node;
|
|
24
|
+
assert.strictEqual(root.routes.length, 2);
|
|
25
|
+
assert.strictEqual(root.routes[0].path, '/foo');
|
|
26
|
+
assert.strictEqual(root.routes[1].path, '/bar');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('methods', () => {
|
|
30
|
+
it('should parse methods', () => {
|
|
31
|
+
const declaration = {
|
|
32
|
+
'/': {
|
|
33
|
+
GET: {
|
|
34
|
+
endpoint: 'observe'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const node = parse(declaration);
|
|
39
|
+
const root = node.routes[0].node;
|
|
40
|
+
assert.strictEqual(root.methods.length, 1);
|
|
41
|
+
assert.strictEqual(root.methods[0].verb, 'GET');
|
|
42
|
+
assert.partialDeepStrictEqual(root.methods[0].mapping, { endpoint: 'observe' });
|
|
43
|
+
});
|
|
44
|
+
it('should parse endpoint shortcut', async () => {
|
|
45
|
+
const declaration = {
|
|
46
|
+
'/': {
|
|
47
|
+
GET: 'observe'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const node = parse(declaration);
|
|
51
|
+
const root = node.routes[0].node;
|
|
52
|
+
assert.strictEqual(root.methods.length, 1);
|
|
53
|
+
assert.strictEqual(root.methods[0].verb, 'GET');
|
|
54
|
+
assert.partialDeepStrictEqual(root.methods[0].mapping, { endpoint: 'observe' });
|
|
55
|
+
});
|
|
56
|
+
it('should parse fq endpoint', async () => {
|
|
57
|
+
const declaration = {
|
|
58
|
+
'/': {
|
|
59
|
+
GET: 'dummies.dummy.observe'
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const node = parse(declaration);
|
|
63
|
+
const root = node.routes[0].node;
|
|
64
|
+
assert.strictEqual(root.methods.length, 1);
|
|
65
|
+
assert.strictEqual(root.methods[0].verb, 'GET');
|
|
66
|
+
assert.partialDeepStrictEqual(root.methods[0].mapping, {
|
|
67
|
+
namespace: 'dummies',
|
|
68
|
+
component: 'dummy',
|
|
69
|
+
endpoint: 'observe'
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
it('should parse fq endpoint within default namespace', async () => {
|
|
73
|
+
const declaration = {
|
|
74
|
+
'/': {
|
|
75
|
+
GET: 'dummy.observe'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const node = parse(declaration);
|
|
79
|
+
const root = node.routes[0].node;
|
|
80
|
+
assert.strictEqual(root.methods.length, 1);
|
|
81
|
+
assert.strictEqual(root.methods[0].verb, 'GET');
|
|
82
|
+
assert.partialDeepStrictEqual(root.methods[0].mapping, {
|
|
83
|
+
namespace: 'default',
|
|
84
|
+
component: 'dummy',
|
|
85
|
+
endpoint: 'observe'
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it('should parse directives', async () => {
|
|
89
|
+
const declaration = {
|
|
90
|
+
'/': {
|
|
91
|
+
GET: {
|
|
92
|
+
'auth:incept': 'id',
|
|
93
|
+
endpoint: 'observe'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const node = parse(declaration);
|
|
98
|
+
const root = node.routes[0].node;
|
|
99
|
+
assert.deepStrictEqual(root.methods[0].directives, [
|
|
100
|
+
{ family: 'auth', name: 'incept', value: 'id' }
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
describe('directives', () => {
|
|
105
|
+
it('should parse shortcuts', async () => {
|
|
106
|
+
const declaration = {
|
|
107
|
+
'/': {
|
|
108
|
+
foo: 'baz'
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const shortcuts = new Map([['foo', 'dev:foo']]);
|
|
112
|
+
const node = parse(declaration, shortcuts);
|
|
113
|
+
const root = node.routes[0].node;
|
|
114
|
+
assert.strictEqual(root.directives.length, 1);
|
|
115
|
+
assert.strictEqual(root.directives[0].family, 'dev');
|
|
116
|
+
assert.strictEqual(root.directives[0].name, 'foo');
|
|
117
|
+
assert.strictEqual(root.directives[0].value, 'baz');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
describe('validation', () => {
|
|
121
|
+
it('should throw on unknown key', async () => {
|
|
122
|
+
const declaration = { hello: 'world' };
|
|
123
|
+
assert.throws(() => parse(declaration), (error) => /RTD parse error: unknown key 'hello'/.test(error.message));
|
|
124
|
+
});
|
|
125
|
+
it('should throw on invalid mapping', async () => {
|
|
126
|
+
const declaration = {
|
|
127
|
+
'/': {
|
|
128
|
+
GET: {
|
|
129
|
+
endpoint: 'observe',
|
|
130
|
+
hello: 'world'
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
assert.throws(() => parse(declaration), (error) => /\/methods\/0\/mapping/.test(error.message));
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
it('should expand ranges', async () => {
|
|
138
|
+
const declaration = {
|
|
139
|
+
'/': {
|
|
140
|
+
GET: {
|
|
141
|
+
endpoint: 'enumerate',
|
|
142
|
+
query: {
|
|
143
|
+
omit: 3,
|
|
144
|
+
limit: 2
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const node = parse(declaration);
|
|
150
|
+
const query = node.routes[0].node.methods[0].mapping?.query;
|
|
151
|
+
assert.partialDeepStrictEqual(query, {
|
|
152
|
+
omit: { value: 3, range: [3, 3] },
|
|
153
|
+
limit: { value: 2, range: [2, 2] }
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
//# sourceMappingURL=parse.test.js.map
|