@toa.io/extensions.exposition 1.0.0-alpha.2 → 1.0.0-alpha.4
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/identity.bans/manifest.toa.yaml +1 -0
- package/components/identity.basic/manifest.toa.yaml +1 -0
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/manifest.toa.yaml +13 -0
- package/components/identity.federation/operations/authenticate.js +4 -4
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/create.js +4 -4
- package/components/identity.federation/operations/create.js.map +1 -1
- package/components/identity.federation/operations/{assertions-as-values.cjs → lib/assertions-as-values.js} +1 -1
- package/components/identity.federation/operations/lib/assertions-as-values.js.map +1 -0
- package/components/identity.federation/operations/{jwt.d.cts → lib/jwt.d.ts} +5 -4
- package/components/identity.federation/operations/{jwt.cjs → lib/jwt.js} +35 -11
- package/components/identity.federation/operations/lib/jwt.js.map +1 -0
- package/components/identity.federation/operations/schemas.d.ts +16 -0
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types.d.ts +1 -1
- package/components/identity.federation/source/authenticate.ts +2 -2
- package/components/identity.federation/source/create.ts +2 -2
- package/components/identity.federation/source/{assertions-as-values.cts → lib/assertions-as-values.ts} +1 -2
- package/components/identity.federation/source/lib/jwt.test.ts +56 -0
- package/components/identity.federation/source/{jwt.cts → lib/jwt.ts} +57 -29
- package/components/identity.federation/source/schemas.ts +16 -0
- package/components/identity.federation/source/types.ts +1 -1
- package/components/identity.roles/manifest.toa.yaml +1 -0
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/manifest.toa.yaml +1 -0
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/components/octets.storage/manifest.toa.yaml +1 -0
- package/components/octets.storage/operations/store.js +1 -1
- package/documentation/components.md +12 -5
- package/documentation/identity.md +7 -0
- package/documentation/octets.md +12 -0
- package/documentation/query.md +45 -2
- package/features/body.feature +1 -1
- package/features/errors.feature +1 -1
- package/features/etag.feature +86 -0
- package/features/identity.federation.feature +31 -1
- package/features/octets.entries.feature +1 -1
- package/features/octets.workflows.feature +38 -0
- package/features/steps/Gateway.ts +3 -0
- package/features/steps/IdP.ts +29 -0
- package/features/steps/components/echo/manifest.toa.yaml +1 -0
- package/features/steps/components/greeter/manifest.toa.yaml +1 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +1 -0
- package/features/steps/components/pots/manifest.toa.yaml +10 -3
- package/features/steps/components/sequences/manifest.toa.yaml +1 -0
- package/features/timing.feature +43 -0
- package/package.json +7 -10
- package/readme.md +7 -6
- package/schemas/annotation.cos.yaml +1 -0
- package/schemas/octets/workflow.cos.yaml +12 -0
- package/schemas/querystring.cos.yaml +1 -0
- package/source/Annotation.ts +1 -0
- package/source/Directive.test.ts +3 -3
- package/source/Directive.ts +11 -11
- package/source/Endpoint.ts +18 -4
- package/source/Factory.ts +8 -4
- package/source/Gateway.ts +55 -42
- package/source/HTTP/Context.ts +67 -0
- package/source/HTTP/Server.test.ts +1 -1
- package/source/HTTP/Server.ts +60 -95
- package/source/HTTP/Timing.ts +40 -0
- package/source/HTTP/index.ts +1 -0
- package/source/HTTP/messages.test.ts +27 -8
- package/source/HTTP/messages.ts +32 -48
- package/source/Mapping.ts +7 -8
- package/source/deployment.ts +6 -0
- package/source/directives/auth/Anonymous.ts +3 -2
- package/source/directives/auth/Authorization.ts +5 -3
- package/source/directives/auth/Incept.ts +11 -6
- package/source/directives/auth/Role.ts +5 -3
- package/source/directives/auth/Scheme.ts +2 -2
- package/source/directives/cache/Cache.ts +2 -2
- package/source/directives/cache/Control.ts +5 -5
- package/source/directives/cache/types.ts +1 -1
- package/source/directives/cors/CORS.ts +5 -3
- package/source/directives/octets/Context.ts +1 -1
- package/source/directives/octets/Delete.ts +21 -11
- package/source/directives/octets/Fetch.ts +29 -14
- package/source/directives/octets/List.ts +14 -6
- package/source/directives/octets/Octets.ts +7 -3
- package/source/directives/octets/Permute.ts +12 -6
- package/source/directives/octets/Store.ts +32 -16
- package/source/directives/octets/Workflow.ts +41 -0
- package/source/directives/octets/schemas.test.ts +21 -0
- package/source/directives/octets/schemas.ts +2 -0
- package/source/directives/octets/{workflow → workflows}/Execution.ts +0 -2
- package/source/directives/octets/{workflow → workflows}/Workflow.ts +2 -2
- package/source/directives/vary/Vary.ts +1 -1
- package/source/directives/vary/embeddings/Header.ts +1 -1
- package/source/directives/vary/embeddings/Language.ts +1 -1
- package/source/io.ts +2 -2
- package/transpiled/Annotation.d.ts +1 -0
- package/transpiled/Directive.d.ts +6 -6
- package/transpiled/Directive.js +8 -8
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Endpoint.d.ts +3 -3
- package/transpiled/Endpoint.js +34 -1
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.js +4 -2
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +5 -6
- package/transpiled/Gateway.js +38 -32
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +24 -0
- package/transpiled/HTTP/Context.js +47 -0
- package/transpiled/HTTP/Context.js.map +1 -0
- package/transpiled/HTTP/Server.d.ts +8 -7
- package/transpiled/HTTP/Server.js +68 -76
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/Timing.d.ts +10 -0
- package/transpiled/HTTP/Timing.js +29 -0
- package/transpiled/HTTP/Timing.js.map +1 -0
- package/transpiled/HTTP/index.d.ts +1 -0
- package/transpiled/HTTP/index.js +1 -0
- package/transpiled/HTTP/index.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +7 -21
- package/transpiled/HTTP/messages.js +24 -26
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/Mapping.js +7 -7
- package/transpiled/Mapping.js.map +1 -1
- package/transpiled/deployment.js +5 -0
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Anonymous.js +3 -4
- package/transpiled/directives/auth/Anonymous.js.map +1 -1
- package/transpiled/directives/auth/Authorization.js +1 -1
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Incept.d.ts +1 -1
- package/transpiled/directives/auth/Incept.js +11 -6
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/auth/Role.js +5 -3
- package/transpiled/directives/auth/Role.js.map +1 -1
- package/transpiled/directives/auth/Scheme.js +2 -2
- package/transpiled/directives/auth/Scheme.js.map +1 -1
- package/transpiled/directives/cache/Cache.d.ts +1 -1
- package/transpiled/directives/cache/Cache.js +2 -2
- package/transpiled/directives/cache/Cache.js.map +1 -1
- package/transpiled/directives/cache/Control.d.ts +3 -3
- package/transpiled/directives/cache/Control.js +3 -3
- package/transpiled/directives/cache/Control.js.map +1 -1
- package/transpiled/directives/cache/types.d.ts +1 -1
- package/transpiled/directives/cors/CORS.js +4 -3
- package/transpiled/directives/cors/CORS.js.map +1 -1
- package/transpiled/directives/octets/Context.d.ts +1 -1
- package/transpiled/directives/octets/Context.js.map +1 -1
- package/transpiled/directives/octets/Delete.d.ts +2 -2
- package/transpiled/directives/octets/Delete.js +21 -11
- package/transpiled/directives/octets/Delete.js.map +1 -1
- package/transpiled/directives/octets/Fetch.d.ts +1 -1
- package/transpiled/directives/octets/Fetch.js +28 -14
- package/transpiled/directives/octets/Fetch.js.map +1 -1
- package/transpiled/directives/octets/List.d.ts +1 -1
- package/transpiled/directives/octets/List.js +13 -6
- package/transpiled/directives/octets/List.js.map +1 -1
- package/transpiled/directives/octets/Octets.js +7 -3
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/octets/Permute.d.ts +1 -1
- package/transpiled/directives/octets/Permute.js +11 -6
- package/transpiled/directives/octets/Permute.js.map +1 -1
- package/transpiled/directives/octets/Store.d.ts +3 -2
- package/transpiled/directives/octets/Store.js +19 -11
- package/transpiled/directives/octets/Store.js.map +1 -1
- package/transpiled/directives/octets/Workflow.d.ts +14 -0
- package/transpiled/directives/octets/Workflow.js +52 -0
- package/transpiled/directives/octets/Workflow.js.map +1 -0
- package/transpiled/directives/octets/schemas.d.ts +2 -0
- package/transpiled/directives/octets/schemas.js +2 -1
- package/transpiled/directives/octets/schemas.js.map +1 -1
- package/transpiled/directives/octets/{workflow → workflows}/Execution.js +0 -1
- package/transpiled/directives/octets/workflows/Execution.js.map +1 -0
- package/transpiled/directives/octets/{workflow → workflows}/Workflow.d.ts +1 -1
- package/transpiled/directives/octets/{workflow → workflows}/Workflow.js +2 -2
- package/transpiled/directives/octets/workflows/Workflow.js.map +1 -0
- package/transpiled/directives/octets/workflows/index.js.map +1 -0
- package/transpiled/directives/vary/Vary.js +1 -1
- package/transpiled/directives/vary/embeddings/Header.js +1 -1
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Language.js +1 -1
- package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
- package/transpiled/io.d.ts +2 -2
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/assertions-as-values.cjs.map +0 -1
- package/components/identity.federation/operations/jwt.cjs.map +0 -1
- package/source/HTTP/Server.fixtures.ts +0 -40
- package/transpiled/HTTP/Server.fixtures.d.ts +0 -10
- package/transpiled/HTTP/Server.fixtures.js +0 -31
- package/transpiled/HTTP/Server.fixtures.js.map +0 -1
- package/transpiled/directives/octets/workflow/Execution.js.map +0 -1
- package/transpiled/directives/octets/workflow/Workflow.js.map +0 -1
- package/transpiled/directives/octets/workflow/index.js.map +0 -1
- /package/components/identity.federation/operations/{assertions-as-values.d.cts → lib/assertions-as-values.d.ts} +0 -0
- /package/source/directives/octets/{workflow → workflows}/index.ts +0 -0
- /package/transpiled/directives/octets/{workflow → workflows}/Execution.d.ts +0 -0
- /package/transpiled/directives/octets/{workflow → workflows}/index.d.ts +0 -0
- /package/transpiled/directives/octets/{workflow → workflows}/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAElC,mCAA+B;AAC/B,uCAAqC;AAErC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,SAAS,CAAE,QAAyB,EAAE,KAAY;QACvD,OAAO,QAAQ,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAElC,mCAA+B;AAC/B,uCAAqC;AAErC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,SAAS,CAAE,QAAyB,EAAE,KAAY;QACvD,OAAO,QAAQ,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,KAAY,EAAE,QAA8B;QAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEzC,IAAI,EAAE,KAAK,SAAS;YAClB,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,qDAAqD;gBAC3E,0BAA0B,IAAI,CAAC,QAAQ,aAAa,CAAC,CAAA;QAEzD,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAA,aAAK,EAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,aAAc,CAAC,CAAA;QACzE,MAAM,QAAQ,GAAG,mBAAS,CAAC,MAAM,CAAC,CAAA;QAElC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAEvD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACxC,MAAM,CAAkB,QAAQ,EAAE;YACnC,KAAK,EAAE;gBACL,EAAE;gBACF,WAAW;aACZ;SACF,CAAC,CAAA;QAEF,IAAI,QAAQ,YAAY,KAAK;YAC3B,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAEnC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACzB,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAA;IAChC,CAAC;CACF;AAxCD,wBAwCC"}
|
|
@@ -11,9 +11,11 @@ class Role {
|
|
|
11
11
|
}
|
|
12
12
|
static async set(identity, discovery) {
|
|
13
13
|
this.remote ??= await discovery;
|
|
14
|
-
const query = {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const query = {
|
|
15
|
+
criteria: `identity==${identity.id}`,
|
|
16
|
+
limit: 1024
|
|
17
|
+
};
|
|
18
|
+
identity.roles = await this.remote.invoke('list', { query });
|
|
17
19
|
}
|
|
18
20
|
async authorize(identity) {
|
|
19
21
|
if (identity === null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../source/directives/auth/Role.ts"],"names":[],"mappings":";;;AAGA,MAAa,IAAI;IACR,MAAM,CAAC,MAAM,GAAqB,IAAI,CAAA;IAC5B,KAAK,C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GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAExC,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;YAC9B,OAAO,KAAK,CAAA;QAEd,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IAEO,KAAK,CAAE,KAAe;QAC5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;YAEzE,IAAI,KAAK,KAAK,CAAC,CAAC;gBACd,OAAO,IAAI,CAAA;QACf,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;;AA1CH,oBA2CC;AAED,SAAS,OAAO,CAAE,QAAgB,EAAE,MAAc;IAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE;QACjC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,KAAK,CAAA;IAEhB,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -34,9 +34,9 @@ class Scheme {
|
|
|
34
34
|
this.Scheme = scheme[0].toUpperCase() + scheme.substring(1);
|
|
35
35
|
}
|
|
36
36
|
authorize(_, input) {
|
|
37
|
-
if (input.headers.authorization === undefined)
|
|
37
|
+
if (input.request.headers.authorization === undefined)
|
|
38
38
|
return false;
|
|
39
|
-
const [scheme] = (0, split_1.split)(input.headers.authorization);
|
|
39
|
+
const [scheme] = (0, split_1.split)(input.request.headers.authorization);
|
|
40
40
|
if (scheme !== this.scheme)
|
|
41
41
|
throw new http.Forbidden(this.Scheme +
|
|
42
42
|
' authentication scheme is required to access this resource.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheme.js","sourceRoot":"","sources":["../../../source/directives/auth/Scheme.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAElC,mCAA+B;AAE/B,MAAa,MAAM;IACA,MAAM,CAAQ;IACd,MAAM,CAAQ;IAE/B,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC;IAEM,SAAS,CAAE,CAAkB,EAAE,KAAY;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS;
|
|
1
|
+
{"version":3,"file":"Scheme.js","sourceRoot":"","sources":["../../../source/directives/auth/Scheme.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAElC,mCAA+B;AAE/B,MAAa,MAAM;IACA,MAAM,CAAQ;IACd,MAAM,CAAQ;IAE/B,YAAoB,MAAc;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC;IAEM,SAAS,CAAE,CAAkB,EAAE,KAAY;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS;YACnD,OAAO,KAAK,CAAA;QAEd,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,aAAK,EAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAE3D,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM;YACxB,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM;gBAClC,6DAA6D,CAAC,CAAA;QAElE,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AArBD,wBAqBC"}
|
|
@@ -7,5 +7,5 @@ export declare class Cache implements Family<Directive> {
|
|
|
7
7
|
readonly mandatory: boolean;
|
|
8
8
|
create(name: string, value: any): Directive;
|
|
9
9
|
preflight(): Output;
|
|
10
|
-
settle(directives: Directive[],
|
|
10
|
+
settle(directives: Directive[], input: Input, response: http.OutgoingMessage): Promise<void>;
|
|
11
11
|
}
|
|
@@ -15,9 +15,9 @@ class Cache {
|
|
|
15
15
|
preflight() {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
async settle(directives,
|
|
18
|
+
async settle(directives, input, response) {
|
|
19
19
|
response.headers ??= new Headers();
|
|
20
|
-
directives[0]?.set(
|
|
20
|
+
directives[0]?.set(input, response.headers);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.Cache = Cache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../source/directives/cache/Cache.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,mCAA+B;AAM/B,MAAa,KAAK;IACA,IAAI,GAAW,OAAO,CAAA;IACtB,SAAS,GAAY,KAAK,CAAA;IAEnC,MAAM,CAAE,IAAY,EAAE,KAAU;QACrC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAEhC,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,6BAA6B,IAAI,CAAC,IAAI,WAAW,CAAC,CAAA;QAEtF,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,MAAM,CAClB,UAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../source/directives/cache/Cache.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,mCAA+B;AAM/B,MAAa,KAAK;IACA,IAAI,GAAW,OAAO,CAAA;IACtB,SAAS,GAAY,KAAK,CAAA;IAEnC,MAAM,CAAE,IAAY,EAAE,KAAU;QACrC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAEhC,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,cAAc,IAAI,6BAA6B,IAAI,CAAC,IAAI,WAAW,CAAC,CAAA;QAEtF,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,MAAM,CAClB,UAAuB,EAAE,KAAY,EAAE,QAA8B;QACpE,QAAQ,CAAC,OAAO,KAAK,IAAI,OAAO,EAAE,CAAA;QAClC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;CACF;AAtBD,sBAsBC;AAED,MAAM,YAAY,GAAkD;IAClE,OAAO,EAAE,iBAAO;IAChB,KAAK,EAAE,aAAK;CACb,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthenticatedContext, Directive } from './types';
|
|
2
2
|
export declare class Control implements Directive {
|
|
3
3
|
protected readonly value: string;
|
|
4
4
|
private cache;
|
|
5
5
|
constructor(value: string);
|
|
6
|
-
set(
|
|
7
|
-
protected resolve(request:
|
|
6
|
+
set(context: AuthenticatedContext, headers: Headers): void;
|
|
7
|
+
protected resolve(request: AuthenticatedContext): string;
|
|
8
8
|
private mask;
|
|
9
9
|
}
|
|
@@ -8,10 +8,10 @@ class Control {
|
|
|
8
8
|
constructor(value) {
|
|
9
9
|
this.value = value;
|
|
10
10
|
}
|
|
11
|
-
set(
|
|
12
|
-
if (!['GET', 'HEAD', 'OPTIONS'].includes(request.method))
|
|
11
|
+
set(context, headers) {
|
|
12
|
+
if (!['GET', 'HEAD', 'OPTIONS'].includes(context.request.method))
|
|
13
13
|
return;
|
|
14
|
-
this.cache ??= this.resolve(
|
|
14
|
+
this.cache ??= this.resolve(context);
|
|
15
15
|
headers.set('cache-control', this.cache);
|
|
16
16
|
}
|
|
17
17
|
resolve(request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../source/directives/cache/Control.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,MAAa,OAAO;IACC,KAAK,CAAQ;IACxB,KAAK,GAAkB,IAAI,CAAA;IAEnC,YAAoB,KAAa;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,CAAE,OAA6B,EAAE,OAAgB;QACzD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../source/directives/cache/Control.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,MAAa,OAAO;IACC,KAAK,CAAQ;IACxB,KAAK,GAAkB,IAAI,CAAA;IAEnC,YAAoB,KAAa;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,CAAE,OAA6B,EAAE,OAAgB;QACzD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YAC9D,OAAM;QAER,IAAI,CAAC,KAAK,KAAK,IAAI,CAA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|
intercept(input) {
|
|
17
|
-
const origin = input.headers.origin;
|
|
17
|
+
const origin = input.request.headers.origin;
|
|
18
18
|
if (origin === undefined)
|
|
19
19
|
return null;
|
|
20
|
-
if (input.method === 'OPTIONS')
|
|
20
|
+
if (input.request.method === 'OPTIONS')
|
|
21
21
|
return this.preflightResponse(origin);
|
|
22
22
|
input.pipelines.response.push((output) => {
|
|
23
23
|
output.headers ??= new Headers();
|
|
24
24
|
output.headers.set('access-control-allow-origin', origin);
|
|
25
25
|
output.headers.set('access-control-expose-headers', 'authorization, content-type, content-length, etag');
|
|
26
|
-
|
|
26
|
+
const method = input.request.method;
|
|
27
|
+
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS')
|
|
27
28
|
output.headers.append('vary', 'origin');
|
|
28
29
|
});
|
|
29
30
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CORS.js","sourceRoot":"","sources":["../../../source/directives/cors/CORS.ts"],"names":[],"mappings":";;;AAGA,MAAa,IAAI;IACC,IAAI,GAAG,MAAM,CAAA;IACb,SAAS,GAAG,IAAI,CAAA;IAEf,cAAc,GAAG,IAAI,GAAG,CAAS,CAAC,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC,CAAA;IAE7E,OAAO,GAAG,IAAI,OAAO,CAAC;QACrC,8BAA8B,EAAE,+BAA+B;QAC/D,kCAAkC,EAAE,MAAM;QAC1C,8BAA8B,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1E,wBAAwB,EAAE,MAAM;QAChC,eAAe,EAAE,sBAAsB;QACvC,IAAI,EAAE,QAAQ;KACf,CAAC,CAAA;IAEK,SAAS,CAAE,KAAY;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"CORS.js","sourceRoot":"","sources":["../../../source/directives/cors/CORS.ts"],"names":[],"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QAC3C,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,WAAW,CAAE,MAAc;QAChC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9F,CAAC;IAEO,iBAAiB,CAAE,MAAc;QACvC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAA;QAEvD,OAAO;YACL,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAA;IACH,CAAC;CACF;AApDD,oBAoDC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../source/directives/octets/Context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AAIpC,MAAa,OAAO;IACF,QAAQ,GAAG,KAAK,CAAA;IAChB,OAAO,CAAQ;IAE/B,YAAoB,
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../source/directives/octets/Context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AAIpC,MAAa,OAAO;IACF,QAAQ,GAAG,KAAK,CAAA;IAChB,OAAO,CAAQ;IAE/B,YAAoB,KAAc;QAChC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAbD,0BAaC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Parameter } from '../../RTD';
|
|
2
|
-
import type { Unit } from './
|
|
2
|
+
import type { Unit } from './workflows';
|
|
3
3
|
import type { Component } from '@toa.io/core';
|
|
4
4
|
import type { Output } from '../../io';
|
|
5
5
|
import type { Directive, Input } from './types';
|
|
@@ -10,7 +10,7 @@ export declare class Delete implements Directive {
|
|
|
10
10
|
private readonly discovery;
|
|
11
11
|
private storage;
|
|
12
12
|
constructor(options: Options | null, discovery: Promise<Component>, remotes: Remotes);
|
|
13
|
-
apply(storage: string,
|
|
13
|
+
apply(storage: string, input: Input, parameters: Parameter[]): Promise<Output>;
|
|
14
14
|
private delete;
|
|
15
15
|
private execute;
|
|
16
16
|
}
|
|
@@ -27,7 +27,7 @@ exports.Delete = void 0;
|
|
|
27
27
|
const stream_1 = require("stream");
|
|
28
28
|
const HTTP_1 = require("../../HTTP");
|
|
29
29
|
const schemas = __importStar(require("./schemas"));
|
|
30
|
-
const
|
|
30
|
+
const workflows_1 = require("./workflows");
|
|
31
31
|
class Delete {
|
|
32
32
|
targeted = true;
|
|
33
33
|
workflow;
|
|
@@ -36,36 +36,46 @@ class Delete {
|
|
|
36
36
|
constructor(options, discovery, remotes) {
|
|
37
37
|
schemas.remove.validate(options);
|
|
38
38
|
if (options?.workflow !== undefined)
|
|
39
|
-
this.workflow = new
|
|
39
|
+
this.workflow = new workflows_1.Workflow(options.workflow, remotes);
|
|
40
40
|
this.discovery = discovery;
|
|
41
41
|
}
|
|
42
|
-
async apply(storage,
|
|
42
|
+
async apply(storage, input, parameters) {
|
|
43
43
|
this.storage ??= await this.discovery;
|
|
44
|
-
const entry = await this.storage.invoke('get', {
|
|
44
|
+
const entry = await this.storage.invoke('get', {
|
|
45
|
+
input: {
|
|
46
|
+
storage,
|
|
47
|
+
path: input.request.url
|
|
48
|
+
}
|
|
49
|
+
});
|
|
45
50
|
if (entry instanceof Error)
|
|
46
51
|
throw new HTTP_1.NotFound();
|
|
47
52
|
const output = {};
|
|
48
53
|
if (this.workflow !== undefined) {
|
|
49
54
|
output.status = 202;
|
|
50
|
-
output.body = stream_1.Readable.from(this.execute(
|
|
55
|
+
output.body = stream_1.Readable.from(this.execute(input, storage, entry, parameters));
|
|
51
56
|
}
|
|
52
57
|
else
|
|
53
|
-
await this.delete(storage,
|
|
58
|
+
await this.delete(storage, input);
|
|
54
59
|
return output;
|
|
55
60
|
}
|
|
56
|
-
async delete(storage,
|
|
61
|
+
async delete(storage, input) {
|
|
57
62
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
58
|
-
await this.storage.invoke('delete', {
|
|
63
|
+
await this.storage.invoke('delete', {
|
|
64
|
+
input: {
|
|
65
|
+
storage,
|
|
66
|
+
path: input.request.url
|
|
67
|
+
}
|
|
68
|
+
});
|
|
59
69
|
}
|
|
60
70
|
// eslint-disable-next-line max-params
|
|
61
|
-
async *execute(
|
|
71
|
+
async *execute(input, storage, entry, parameters) {
|
|
62
72
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
-
for await (const chunk of this.workflow.execute(
|
|
73
|
+
for await (const chunk of this.workflow.execute(input, storage, entry, parameters)) {
|
|
64
74
|
yield chunk;
|
|
65
75
|
if (typeof chunk === 'object' && chunk !== null && 'error' in chunk)
|
|
66
76
|
return;
|
|
67
77
|
}
|
|
68
|
-
await this.delete(storage,
|
|
78
|
+
await this.delete(storage, input);
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
exports.Delete = Delete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../source/directives/octets/Delete.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,qCAAqC;AACrC,mDAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../source/directives/octets/Delete.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiC;AACjC,qCAAqC;AACrC,mDAAoC;AACpC,2CAAs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AY;QACjD,oEAAoE;QACpE,MAAM,IAAI,CAAC,OAAQ,CAAC,MAAM,CAAC,QAAQ,EACjC;YACE,KAAK,EAAE;gBACL,OAAO;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG;aACxB;SACF,CAAC,CAAA;IACN,CAAC;IAED,sCAAsC;IAC9B,KAAK,CAAC,CAAE,OAAO,CACtB,KAAY,EAAE,OAAe,EAAE,KAAY,EAAE,UAAuB;QACnE,oEAAoE;QACpE,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,CAAC,QAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;YACpF,MAAM,KAAK,CAAA;YAEX,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK;gBACjE,OAAM;QACV,CAAC;QAED,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IACnC,CAAC;CACF;AAjED,wBAiEC"}
|
|
@@ -7,7 +7,7 @@ export declare class Fetch implements Directive {
|
|
|
7
7
|
private readonly discovery;
|
|
8
8
|
private storage;
|
|
9
9
|
constructor(permissions: Permissions | null, discovery: Promise<Component>);
|
|
10
|
-
apply(storage: string,
|
|
10
|
+
apply(storage: string, input: Input): Promise<Output>;
|
|
11
11
|
private fetch;
|
|
12
12
|
private get;
|
|
13
13
|
}
|
|
@@ -29,7 +29,10 @@ const HTTP_1 = require("../../HTTP");
|
|
|
29
29
|
const schemas = __importStar(require("./schemas"));
|
|
30
30
|
class Fetch {
|
|
31
31
|
targeted = true;
|
|
32
|
-
permissions = {
|
|
32
|
+
permissions = {
|
|
33
|
+
blob: true,
|
|
34
|
+
meta: false
|
|
35
|
+
};
|
|
33
36
|
discovery;
|
|
34
37
|
storage = null;
|
|
35
38
|
constructor(permissions, discovery) {
|
|
@@ -37,24 +40,28 @@ class Fetch {
|
|
|
37
40
|
Object.assign(this.permissions, permissions);
|
|
38
41
|
this.discovery = discovery;
|
|
39
42
|
}
|
|
40
|
-
async apply(storage,
|
|
43
|
+
async apply(storage, input) {
|
|
41
44
|
this.storage ??= await this.discovery;
|
|
42
|
-
const variant = node_path_1.posix.basename(request.url).includes('.');
|
|
43
|
-
const metadata =
|
|
45
|
+
const variant = node_path_1.posix.basename(input.request.url).includes('.');
|
|
46
|
+
const metadata = input.subtype === 'octets.entry';
|
|
44
47
|
if (!variant && metadata)
|
|
45
48
|
if (this.permissions.meta)
|
|
46
|
-
return this.get(storage,
|
|
49
|
+
return this.get(storage, input);
|
|
47
50
|
else
|
|
48
51
|
throw new HTTP_1.Forbidden('Metadata is not accessible.');
|
|
49
52
|
if (!variant && !this.permissions.blob)
|
|
50
53
|
throw new HTTP_1.Forbidden('BLOB variant must be specified.');
|
|
51
|
-
return await this.fetch(storage,
|
|
54
|
+
return await this.fetch(storage, input);
|
|
52
55
|
}
|
|
53
|
-
async fetch(storage,
|
|
54
|
-
if ('if-none-match' in request.headers)
|
|
56
|
+
async fetch(storage, input) {
|
|
57
|
+
if ('if-none-match' in input.request.headers)
|
|
55
58
|
return { status: 304 };
|
|
56
|
-
const
|
|
57
|
-
|
|
59
|
+
const result = await this.storage.invoke('fetch', {
|
|
60
|
+
input: {
|
|
61
|
+
storage,
|
|
62
|
+
path: input.request.url
|
|
63
|
+
}
|
|
64
|
+
});
|
|
58
65
|
if (result instanceof Error)
|
|
59
66
|
throw new HTTP_1.NotFound();
|
|
60
67
|
const headers = new Headers({
|
|
@@ -62,11 +69,18 @@ class Fetch {
|
|
|
62
69
|
'content-length': result.size.toString(),
|
|
63
70
|
etag: result.checksum
|
|
64
71
|
});
|
|
65
|
-
return {
|
|
72
|
+
return {
|
|
73
|
+
headers,
|
|
74
|
+
body: result.stream
|
|
75
|
+
};
|
|
66
76
|
}
|
|
67
|
-
async get(storage,
|
|
68
|
-
const
|
|
69
|
-
|
|
77
|
+
async get(storage, input) {
|
|
78
|
+
const entry = await this.storage.invoke('get', {
|
|
79
|
+
input: {
|
|
80
|
+
storage,
|
|
81
|
+
path: input.request.url
|
|
82
|
+
}
|
|
83
|
+
});
|
|
70
84
|
if (entry instanceof Error)
|
|
71
85
|
throw new HTTP_1.NotFound();
|
|
72
86
|
return { body: entry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../../source/directives/octets/Fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AASpC,MAAa,KAAK;IACA,QAAQ,GAAG,IAAI,CAAA;IAEd,WAAW,GAA0B,
|
|
1
|
+
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../../../source/directives/octets/Fetch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AASpC,MAAa,KAAK;IACA,QAAQ,GAAG,IAAI,CAAA;IAEd,WAAW,GAA0B;QACpD,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,KAAK;KACZ,CAAA;IAEgB,SAAS,CAAoB;IACtC,OAAO,GAAc,IAA4B,CAAA;IAEzD,YAAoB,WAA+B,EAAE,SAA6B;QAChF,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;QAEnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,KAAY;QAC/C,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAErC,MAAM,OAAO,GAAG,iBAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,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AM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAe,KAAK,EAAE;YAC3D,KAAK,EAAE;gBACL,OAAO;gBACP,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG;aACxB;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;CACF;AA3ED,sBA2EC"}
|
|
@@ -7,7 +7,7 @@ export declare class List implements Directive {
|
|
|
7
7
|
private readonly discovery;
|
|
8
8
|
private storage;
|
|
9
9
|
constructor(permissions: Permissions | null, discovery: Promise<Component>);
|
|
10
|
-
apply(storage: string,
|
|
10
|
+
apply(storage: string, input: Input): Promise<Output>;
|
|
11
11
|
private expand;
|
|
12
12
|
}
|
|
13
13
|
export interface Permissions {
|
|
@@ -37,24 +37,31 @@ class List {
|
|
|
37
37
|
Object.assign(this.permissions, permissions);
|
|
38
38
|
this.discovery = discovery;
|
|
39
39
|
}
|
|
40
|
-
async apply(storage,
|
|
40
|
+
async apply(storage, input) {
|
|
41
41
|
this.storage ??= await this.discovery;
|
|
42
|
-
const metadata =
|
|
42
|
+
const metadata = input.subtype === 'octets.entries';
|
|
43
43
|
if (metadata && !this.permissions.meta)
|
|
44
44
|
throw new HTTP_1.Forbidden('Metadata is not accessible.');
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const list = await this.storage.invoke('list', {
|
|
46
|
+
input: {
|
|
47
|
+
storage,
|
|
48
|
+
path: input.request.url
|
|
49
|
+
}
|
|
50
|
+
});
|
|
47
51
|
if (list instanceof Error)
|
|
48
52
|
throw new HTTP_1.NotFound();
|
|
49
53
|
const body = metadata
|
|
50
|
-
? await this.expand(storage, request.url, list)
|
|
54
|
+
? await this.expand(storage, input.request.url, list)
|
|
51
55
|
: list;
|
|
52
56
|
return { body };
|
|
53
57
|
}
|
|
54
58
|
async expand(storage, prefix, list) {
|
|
55
59
|
const promises = list.map(async (id) => {
|
|
56
60
|
const path = node_path_1.posix.join(prefix, id);
|
|
57
|
-
const input = {
|
|
61
|
+
const input = {
|
|
62
|
+
storage,
|
|
63
|
+
path
|
|
64
|
+
};
|
|
58
65
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- ensured in `apply`
|
|
59
66
|
return this.storage.invoke('get', { input });
|
|
60
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../source/directives/octets/List.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AAQpC,MAAa,IAAI;IACC,QAAQ,GAAG,KAAK,CAAA;IAEf,WAAW,GAA0B,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACpD,SAAS,CAAoB;IACtC,OAAO,GAAqB,IAAI,CAAA;IAExC,YAAoB,WAA+B,EAAE,SAA6B;QAChF,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;QAElC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../source/directives/octets/List.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,qCAAgD;AAChD,mDAAoC;AAQpC,MAAa,IAAI;IACC,QAAQ,GAAG,KAAK,CAAA;IAEf,WAAW,GAA0B,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACpD,SAAS,CAAoB;IACtC,OAAO,GAAqB,IAAI,CAAA;IAExC,YAAoB,WAA+B,EAAE,SAA6B;QAChF,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC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AAC,MAAM,CAAe,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QAC7D,CAAC,CAAC,CAAA;QAEF,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACpC,CAAC;CACF;AAvDD,oBAuDC"}
|
|
@@ -8,6 +8,7 @@ const Fetch_1 = require("./Fetch");
|
|
|
8
8
|
const List_1 = require("./List");
|
|
9
9
|
const Delete_1 = require("./Delete");
|
|
10
10
|
const Permute_1 = require("./Permute");
|
|
11
|
+
const Workflow_1 = require("./Workflow");
|
|
11
12
|
class Octets {
|
|
12
13
|
name = 'octets';
|
|
13
14
|
mandatory = false;
|
|
@@ -31,12 +32,14 @@ class Octets {
|
|
|
31
32
|
throw new Error('Octets action is umbiguous.');
|
|
32
33
|
if (action === null)
|
|
33
34
|
return null;
|
|
35
|
+
// noinspection PointlessBooleanExpressionJS
|
|
34
36
|
if (context === null)
|
|
35
37
|
throw new Error('Octets context is not defined.');
|
|
36
|
-
const targeted = input.
|
|
38
|
+
const targeted = input.request.url[input.request.url.length - 1] !== '/';
|
|
37
39
|
if (targeted !== action.targeted)
|
|
38
40
|
throw new HTTP_1.NotFound(`Trailing slash is ${action.targeted ? 'redundant' : 'required'}.`);
|
|
39
|
-
|
|
41
|
+
// noinspection JSObjectNullOrUndefined
|
|
42
|
+
return action.apply(context.storage, input, parameters);
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
exports.Octets = Octets;
|
|
@@ -46,6 +49,7 @@ const DIRECTIVES = {
|
|
|
46
49
|
fetch: Fetch_1.Fetch,
|
|
47
50
|
list: List_1.List,
|
|
48
51
|
delete: Delete_1.Delete,
|
|
49
|
-
permute: Permute_1.Permute
|
|
52
|
+
permute: Permute_1.Permute,
|
|
53
|
+
workflow: Workflow_1.WorkflowDirective
|
|
50
54
|
};
|
|
51
55
|
//# sourceMappingURL=Octets.js.map
|
|
@@ -1 +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;
|
|
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;AACnC,yCAA8C;AAQ9C,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,CACrB,UAAuB,EAAE,KAAY,EAAE,UAAuB;QAC7D,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,4CAA4C;QAC5C,IAAI,OAAO,KAAK,IAAI;YAClB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QAEnD,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAA;QAExE,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,uCAAuC;QACvC,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACzD,CAAC;CACF;AA7CD,wBA6CC;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;IAChB,QAAQ,EAAE,4BAAiB;CAC5B,CAAA"}
|
|
@@ -6,5 +6,5 @@ export declare class Permute implements Directive {
|
|
|
6
6
|
private readonly discovery;
|
|
7
7
|
private storage;
|
|
8
8
|
constructor(value: null, discovery: Promise<Component>);
|
|
9
|
-
apply(storage: string,
|
|
9
|
+
apply(storage: string, input: Input): Promise<Output>;
|
|
10
10
|
}
|
|
@@ -34,14 +34,19 @@ class Permute {
|
|
|
34
34
|
schemas.permute.validate(value);
|
|
35
35
|
this.discovery = discovery;
|
|
36
36
|
}
|
|
37
|
-
async apply(storage,
|
|
37
|
+
async apply(storage, input) {
|
|
38
38
|
this.storage ??= await this.discovery;
|
|
39
|
-
if (
|
|
39
|
+
if (input.encoder === null)
|
|
40
40
|
throw new HTTP_1.NotAcceptable();
|
|
41
|
-
const path = request.url;
|
|
42
|
-
const list = await
|
|
43
|
-
const
|
|
44
|
-
|
|
41
|
+
const path = input.request.url;
|
|
42
|
+
const list = await input.body();
|
|
43
|
+
const error = await this.storage.invoke('permute', {
|
|
44
|
+
input: {
|
|
45
|
+
storage,
|
|
46
|
+
path,
|
|
47
|
+
list
|
|
48
|
+
}
|
|
49
|
+
});
|
|
45
50
|
if (error instanceof Error)
|
|
46
51
|
throw new HTTP_1.NotFound();
|
|
47
52
|
return {};
|
|
@@ -1 +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,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,
|
|
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,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,KAAK,CAAE,OAAe,EAAE,KAAY;QAC/C,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,CAAC,SAAS,CAAA;QAErC,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI;YACxB,MAAM,IAAI,oBAAa,EAAE,CAAA;QAE3B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAA;QAC9B,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAE/B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAiB,SAAS,EAAE;YACjE,KAAK,EAAE;gBACL,OAAO;gBACP,IAAI;gBACJ,IAAI;aACL;SACF,CAAC,CAAA;QAEF,IAAI,KAAK,YAAY,KAAK;YACxB,MAAM,IAAI,eAAQ,EAAE,CAAA;QAEtB,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAlCD,0BAkCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Parameter } from '../../RTD';
|
|
2
|
-
import type { Unit } from './
|
|
2
|
+
import type { Unit } from './workflows';
|
|
3
3
|
import type { Remotes } from '../../Remotes';
|
|
4
4
|
import type { Component } from '@toa.io/core';
|
|
5
5
|
import type { Output } from '../../io';
|
|
@@ -11,8 +11,9 @@ export declare class Store implements Directive {
|
|
|
11
11
|
private readonly discovery;
|
|
12
12
|
private storage;
|
|
13
13
|
constructor(options: Options | null, discovery: Promise<Component>, remotes: Remotes);
|
|
14
|
-
apply(storage: string,
|
|
14
|
+
apply(storage: string, input: Input, parameters: Parameter[]): Promise<Output>;
|
|
15
15
|
private reply;
|
|
16
|
+
private execute;
|
|
16
17
|
private throw;
|
|
17
18
|
private parseMeta;
|
|
18
19
|
}
|
|
@@ -24,11 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Store = void 0;
|
|
27
|
+
const node_stream_1 = require("node:stream");
|
|
27
28
|
const matchacho_1 = require("matchacho");
|
|
28
29
|
const HTTP_1 = require("../../HTTP");
|
|
29
30
|
const cors_1 = require("../cors");
|
|
30
31
|
const schemas = __importStar(require("./schemas"));
|
|
31
|
-
const
|
|
32
|
+
const workflows_1 = require("./workflows");
|
|
32
33
|
class Store {
|
|
33
34
|
targeted = false;
|
|
34
35
|
accept;
|
|
@@ -39,28 +40,35 @@ class Store {
|
|
|
39
40
|
schemas.store.validate(options);
|
|
40
41
|
this.accept = (0, matchacho_1.match)(options?.accept, String, (value) => value, Array, (types) => types.join(','), undefined);
|
|
41
42
|
if (options?.workflow !== undefined)
|
|
42
|
-
this.workflow = new
|
|
43
|
+
this.workflow = new workflows_1.Workflow(options.workflow, remotes);
|
|
43
44
|
this.discovery.storage = discovery;
|
|
44
45
|
cors_1.cors.allowHeader('content-meta');
|
|
45
46
|
}
|
|
46
|
-
async apply(storage,
|
|
47
|
+
async apply(storage, input, parameters) {
|
|
47
48
|
this.storage ??= await this.discovery.storage;
|
|
48
|
-
const
|
|
49
|
-
const meta = request.headers['content-meta'];
|
|
49
|
+
const request = { input: { storage, request: input.request } };
|
|
50
|
+
const meta = input.request.headers['content-meta'];
|
|
50
51
|
if (this.accept !== undefined)
|
|
51
|
-
input.accept = this.accept;
|
|
52
|
+
request.input.accept = this.accept;
|
|
52
53
|
if (meta !== undefined)
|
|
53
|
-
input.meta = this.parseMeta(meta);
|
|
54
|
-
const entry = await this.storage.invoke('store',
|
|
55
|
-
return (0, matchacho_1.match)(entry, Error, (error) => this.throw(error), () => this.reply(
|
|
54
|
+
request.input.meta = this.parseMeta(meta);
|
|
55
|
+
const entry = await this.storage.invoke('store', request);
|
|
56
|
+
return (0, matchacho_1.match)(entry, Error, (error) => this.throw(error), () => this.reply(input, storage, entry, parameters));
|
|
56
57
|
}
|
|
57
58
|
// eslint-disable-next-line max-params
|
|
58
|
-
reply(
|
|
59
|
+
reply(input, storage, entry, parameters) {
|
|
59
60
|
const body = this.workflow === undefined
|
|
60
61
|
? entry
|
|
61
|
-
: this.
|
|
62
|
+
: this.execute(input, storage, entry, parameters);
|
|
62
63
|
return { body };
|
|
63
64
|
}
|
|
65
|
+
// eslint-disable-next-line max-params
|
|
66
|
+
execute(input, storage, entry, parameters) {
|
|
67
|
+
const stream = new node_stream_1.PassThrough({ objectMode: true });
|
|
68
|
+
stream.push(entry);
|
|
69
|
+
this.workflow.execute(input, storage, entry, parameters).pipe(stream);
|
|
70
|
+
return stream;
|
|
71
|
+
}
|
|
64
72
|
throw(error) {
|
|
65
73
|
throw (0, matchacho_1.match)(error.code, 'NOT_ACCEPTABLE', () => new HTTP_1.UnsupportedMediaType(), 'TYPE_MISMATCH', () => new HTTP_1.BadRequest(), error);
|
|
66
74
|
}
|