@toa.io/extensions.exposition 0.20.0-alpha.0 → 0.20.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/context.toa.yaml +2 -2
- package/documentation/notes/sse.md +71 -0
- package/documentation/protocol.md +4 -1
- package/features/access.feature +48 -42
- package/features/annotation.feature +6 -4
- package/features/body.feature +24 -0
- package/features/directives.feature +2 -2
- package/features/dynamic.feature +11 -1
- package/features/errors.feature +14 -29
- package/features/identity.basic.feature +47 -6
- package/features/identity.tokens.feature +19 -16
- package/features/steps/Gateway.ts +26 -18
- package/features/steps/components/echo/manifest.toa.yaml +9 -0
- package/features/steps/components/echo/operations/affect.js +7 -0
- package/features/steps/components/echo/operations/compute.js +7 -0
- package/features/steps/components/greeter/manifest.toa.yaml +0 -4
- package/features/steps/components/greeter/operations/greet.js +1 -1
- package/features/steps/components/sequences/manifest.toa.yaml +10 -0
- package/features/steps/components/sequences/operations/numbers.js +7 -0
- package/features/steps/components/sequences/operations/tokens.js +16 -0
- package/features/streams.feature +26 -0
- package/package.json +7 -6
- package/readme.md +2 -0
- package/schemas/annotation.cos.yaml +5 -4
- package/schemas/method.cos.yaml +0 -1
- package/schemas/query.cos.yaml +1 -0
- package/source/Annotation.ts +1 -0
- package/source/Composition.ts +1 -2
- package/source/Endpoint.ts +5 -3
- package/source/Factory.ts +8 -10
- package/source/HTTP/Server.ts +1 -1
- package/source/HTTP/messages.ts +18 -6
- package/source/Mapping.ts +12 -9
- package/source/RTD/Node.ts +5 -5
- package/source/RTD/Route.ts +5 -4
- package/source/RTD/Tree.ts +2 -5
- package/source/RTD/syntax/parse.ts +1 -1
- package/source/Remotes.test.ts +2 -1
- package/source/Remotes.ts +2 -0
- package/source/deployment.ts +9 -2
- package/source/directives/dev/Family.ts +3 -1
- package/source/directives/dev/Throw.ts +14 -0
- package/source/manifest.test.ts +3 -1
- package/source/manifest.ts +22 -9
- package/transpiled/Annotation.d.ts +0 -6
- package/transpiled/Annotation.js +0 -3
- package/transpiled/Annotation.js.map +0 -1
- package/transpiled/Branch.d.ts +0 -7
- package/transpiled/Branch.js +0 -3
- package/transpiled/Branch.js.map +0 -1
- package/transpiled/Composition.d.ts +0 -14
- package/transpiled/Composition.js +0 -43
- package/transpiled/Composition.js.map +0 -1
- package/transpiled/Context.d.ts +0 -5
- package/transpiled/Context.js +0 -3
- package/transpiled/Context.js.map +0 -1
- package/transpiled/Directive.d.ts +0 -32
- package/transpiled/Directive.js +0 -76
- package/transpiled/Directive.js.map +0 -1
- package/transpiled/Endpoint.d.ts +0 -20
- package/transpiled/Endpoint.js +0 -44
- package/transpiled/Endpoint.js.map +0 -1
- package/transpiled/Factory.d.ts +0 -11
- package/transpiled/Factory.js +0 -67
- package/transpiled/Factory.js.map +0 -1
- package/transpiled/Gateway.d.ts +0 -19
- package/transpiled/Gateway.js +0 -90
- package/transpiled/Gateway.js.map +0 -1
- package/transpiled/HTTP/Server.d.ts +0 -22
- package/transpiled/HTTP/Server.fixtures.d.ts +0 -12
- package/transpiled/HTTP/Server.fixtures.js +0 -36
- package/transpiled/HTTP/Server.fixtures.js.map +0 -1
- package/transpiled/HTTP/Server.js +0 -111
- package/transpiled/HTTP/Server.js.map +0 -1
- package/transpiled/HTTP/exceptions.d.ts +0 -39
- package/transpiled/HTTP/exceptions.js +0 -78
- package/transpiled/HTTP/exceptions.js.map +0 -1
- package/transpiled/HTTP/formats/index.d.ts +0 -8
- package/transpiled/HTTP/formats/index.js +0 -38
- package/transpiled/HTTP/formats/index.js.map +0 -1
- package/transpiled/HTTP/formats/json.d.ts +0 -4
- package/transpiled/HTTP/formats/json.js +0 -15
- package/transpiled/HTTP/formats/json.js.map +0 -1
- package/transpiled/HTTP/formats/msgpack.d.ts +0 -4
- package/transpiled/HTTP/formats/msgpack.js +0 -36
- package/transpiled/HTTP/formats/msgpack.js.map +0 -1
- package/transpiled/HTTP/formats/text.d.ts +0 -4
- package/transpiled/HTTP/formats/text.js +0 -13
- package/transpiled/HTTP/formats/text.js.map +0 -1
- package/transpiled/HTTP/formats/yaml.d.ts +0 -4
- package/transpiled/HTTP/formats/yaml.js +0 -39
- package/transpiled/HTTP/formats/yaml.js.map +0 -1
- package/transpiled/HTTP/index.d.ts +0 -3
- package/transpiled/HTTP/index.js +0 -20
- package/transpiled/HTTP/index.js.map +0 -1
- package/transpiled/HTTP/messages.d.ts +0 -27
- package/transpiled/HTTP/messages.js +0 -49
- package/transpiled/HTTP/messages.js.map +0 -1
- package/transpiled/Mapping.d.ts +0 -8
- package/transpiled/Mapping.js +0 -35
- package/transpiled/Mapping.js.map +0 -1
- package/transpiled/Query.d.ts +0 -13
- package/transpiled/Query.js +0 -107
- package/transpiled/Query.js.map +0 -1
- package/transpiled/RTD/Context.d.ts +0 -11
- package/transpiled/RTD/Context.js +0 -3
- package/transpiled/RTD/Context.js.map +0 -1
- package/transpiled/RTD/Directives.d.ts +0 -7
- package/transpiled/RTD/Directives.js +0 -3
- package/transpiled/RTD/Directives.js.map +0 -1
- package/transpiled/RTD/Endpoint.d.ts +0 -9
- package/transpiled/RTD/Endpoint.js +0 -3
- package/transpiled/RTD/Endpoint.js.map +0 -1
- package/transpiled/RTD/Match.d.ts +0 -11
- package/transpiled/RTD/Match.js +0 -3
- package/transpiled/RTD/Match.js.map +0 -1
- package/transpiled/RTD/Method.d.ts +0 -9
- package/transpiled/RTD/Method.js +0 -16
- package/transpiled/RTD/Method.js.map +0 -1
- package/transpiled/RTD/Node.d.ts +0 -21
- package/transpiled/RTD/Node.js +0 -61
- package/transpiled/RTD/Node.js.map +0 -1
- package/transpiled/RTD/Route.d.ts +0 -14
- package/transpiled/RTD/Route.js +0 -48
- package/transpiled/RTD/Route.js.map +0 -1
- package/transpiled/RTD/Tree.d.ts +0 -14
- package/transpiled/RTD/Tree.js +0 -45
- package/transpiled/RTD/Tree.js.map +0 -1
- package/transpiled/RTD/factory.d.ts +0 -6
- package/transpiled/RTD/factory.js +0 -36
- package/transpiled/RTD/factory.js.map +0 -1
- package/transpiled/RTD/index.d.ts +0 -8
- package/transpiled/RTD/index.js +0 -38
- package/transpiled/RTD/index.js.map +0 -1
- package/transpiled/RTD/segment.d.ts +0 -8
- package/transpiled/RTD/segment.js +0 -23
- package/transpiled/RTD/segment.js.map +0 -1
- package/transpiled/RTD/syntax/index.d.ts +0 -2
- package/transpiled/RTD/syntax/index.js +0 -19
- package/transpiled/RTD/syntax/index.js.map +0 -1
- package/transpiled/RTD/syntax/parse.d.ts +0 -4
- package/transpiled/RTD/syntax/parse.js +0 -128
- package/transpiled/RTD/syntax/parse.js.map +0 -1
- package/transpiled/RTD/syntax/types.d.ts +0 -41
- package/transpiled/RTD/syntax/types.js +0 -5
- package/transpiled/RTD/syntax/types.js.map +0 -1
- package/transpiled/Remotes.d.ts +0 -7
- package/transpiled/Remotes.js +0 -19
- package/transpiled/Remotes.js.map +0 -1
- package/transpiled/Tenant.d.ts +0 -12
- package/transpiled/Tenant.js +0 -30
- package/transpiled/Tenant.js.map +0 -1
- package/transpiled/deployment.d.ts +0 -3
- package/transpiled/deployment.js +0 -61
- package/transpiled/deployment.js.map +0 -1
- package/transpiled/directives/auth/Anonymous.d.ts +0 -6
- package/transpiled/directives/auth/Anonymous.js +0 -17
- package/transpiled/directives/auth/Anonymous.js.map +0 -1
- package/transpiled/directives/auth/Echo.d.ts +0 -6
- package/transpiled/directives/auth/Echo.js +0 -13
- package/transpiled/directives/auth/Echo.js.map +0 -1
- package/transpiled/directives/auth/Family.d.ts +0 -20
- package/transpiled/directives/auth/Family.js +0 -125
- package/transpiled/directives/auth/Family.js.map +0 -1
- package/transpiled/directives/auth/Id.d.ts +0 -7
- package/transpiled/directives/auth/Id.js +0 -17
- package/transpiled/directives/auth/Id.js.map +0 -1
- package/transpiled/directives/auth/Incept.d.ts +0 -10
- package/transpiled/directives/auth/Incept.js +0 -59
- package/transpiled/directives/auth/Incept.js.map +0 -1
- package/transpiled/directives/auth/Role.d.ts +0 -11
- package/transpiled/directives/auth/Role.js +0 -44
- package/transpiled/directives/auth/Role.js.map +0 -1
- package/transpiled/directives/auth/Rule.d.ts +0 -9
- package/transpiled/directives/auth/Rule.js +0 -22
- package/transpiled/directives/auth/Rule.js.map +0 -1
- package/transpiled/directives/auth/Scheme.d.ts +0 -7
- package/transpiled/directives/auth/Scheme.js +0 -47
- package/transpiled/directives/auth/Scheme.js.map +0 -1
- package/transpiled/directives/auth/index.d.ts +0 -2
- package/transpiled/directives/auth/index.js +0 -7
- package/transpiled/directives/auth/index.js.map +0 -1
- package/transpiled/directives/auth/schemes.d.ts +0 -3
- package/transpiled/directives/auth/schemes.js +0 -9
- package/transpiled/directives/auth/schemes.js.map +0 -1
- package/transpiled/directives/auth/split.d.ts +0 -2
- package/transpiled/directives/auth/split.js +0 -38
- package/transpiled/directives/auth/split.js.map +0 -1
- package/transpiled/directives/auth/types.d.ts +0 -31
- package/transpiled/directives/auth/types.js +0 -3
- package/transpiled/directives/auth/types.js.map +0 -1
- package/transpiled/directives/dev/Family.d.ts +0 -10
- package/transpiled/directives/dev/Family.js +0 -25
- package/transpiled/directives/dev/Family.js.map +0 -1
- package/transpiled/directives/dev/Stub.d.ts +0 -7
- package/transpiled/directives/dev/Stub.js +0 -14
- package/transpiled/directives/dev/Stub.js.map +0 -1
- package/transpiled/directives/dev/index.d.ts +0 -2
- package/transpiled/directives/dev/index.js +0 -7
- package/transpiled/directives/dev/index.js.map +0 -1
- package/transpiled/directives/dev/types.d.ts +0 -4
- package/transpiled/directives/dev/types.js +0 -3
- package/transpiled/directives/dev/types.js.map +0 -1
- package/transpiled/directives/index.d.ts +0 -2
- package/transpiled/directives/index.js +0 -10
- package/transpiled/directives/index.js.map +0 -1
- package/transpiled/discovery.d.ts +0 -1
- package/transpiled/discovery.js +0 -3
- package/transpiled/discovery.js.map +0 -1
- package/transpiled/exceptions.d.ts +0 -2
- package/transpiled/exceptions.js +0 -39
- package/transpiled/exceptions.js.map +0 -1
- package/transpiled/index.d.ts +0 -5
- package/transpiled/index.js +0 -12
- package/transpiled/index.js.map +0 -1
- package/transpiled/manifest.d.ts +0 -3
- package/transpiled/manifest.js +0 -30
- package/transpiled/manifest.js.map +0 -1
- package/transpiled/root.d.ts +0 -2
- package/transpiled/root.js +0 -39
- package/transpiled/root.js.map +0 -1
- package/transpiled/schemas.d.ts +0 -3
- package/transpiled/schemas.js +0 -14
- package/transpiled/schemas.js.map +0 -1
- package/transpiled/tsconfig.tsbuildinfo +0 -1
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PreconditionFailed = exports.UnsupportedMediaType = exports.NotAcceptable = exports.MethodNotAllowed = exports.Conflict = exports.NotFound = exports.Forbidden = exports.Unauthorized = exports.BadRequest = exports.ClientError = exports.Exception = void 0;
|
|
4
|
-
const formats_1 = require("./formats");
|
|
5
|
-
class Exception extends Error {
|
|
6
|
-
status;
|
|
7
|
-
body;
|
|
8
|
-
constructor(status, body) {
|
|
9
|
-
super();
|
|
10
|
-
this.status = status;
|
|
11
|
-
this.body = body;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.Exception = Exception;
|
|
15
|
-
class ClientError extends Exception {
|
|
16
|
-
}
|
|
17
|
-
exports.ClientError = ClientError;
|
|
18
|
-
class BadRequest extends ClientError {
|
|
19
|
-
constructor(body) {
|
|
20
|
-
super(400, body);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.BadRequest = BadRequest;
|
|
24
|
-
class Unauthorized extends ClientError {
|
|
25
|
-
constructor(body) {
|
|
26
|
-
super(401, body);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.Unauthorized = Unauthorized;
|
|
30
|
-
class Forbidden extends ClientError {
|
|
31
|
-
constructor(body) {
|
|
32
|
-
super(403, body);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Forbidden = Forbidden;
|
|
36
|
-
class NotFound extends ClientError {
|
|
37
|
-
constructor(body) {
|
|
38
|
-
super(404, body);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.NotFound = NotFound;
|
|
42
|
-
class Conflict extends ClientError {
|
|
43
|
-
constructor(body) {
|
|
44
|
-
super(409, body);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.Conflict = Conflict;
|
|
48
|
-
class MethodNotAllowed extends ClientError {
|
|
49
|
-
constructor() {
|
|
50
|
-
super(405);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.MethodNotAllowed = MethodNotAllowed;
|
|
54
|
-
class MediaTypeException extends ClientError {
|
|
55
|
-
static message = 'Supported media types:\n- ' + formats_1.types.join('\n- ');
|
|
56
|
-
constructor(status) {
|
|
57
|
-
super(status, MediaTypeException.message);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class NotAcceptable extends MediaTypeException {
|
|
61
|
-
constructor() {
|
|
62
|
-
super(406);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.NotAcceptable = NotAcceptable;
|
|
66
|
-
class UnsupportedMediaType extends MediaTypeException {
|
|
67
|
-
constructor() {
|
|
68
|
-
super(415);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.UnsupportedMediaType = UnsupportedMediaType;
|
|
72
|
-
class PreconditionFailed extends ClientError {
|
|
73
|
-
constructor() {
|
|
74
|
-
super(412);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.PreconditionFailed = PreconditionFailed;
|
|
78
|
-
//# sourceMappingURL=exceptions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../source/HTTP/exceptions.ts"],"names":[],"mappings":";;;AAAA,uCAAiC;AAEjC,MAAa,SAAU,SAAQ,KAAK;IAClB,MAAM,CAAQ;IACd,IAAI,CAAM;IAE1B,YAAuB,MAAc,EAAE,IAAU;QAC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CACF;AAJD,sCAIC;AAED,MAAa,oBAAqB,SAAQ,kBAAkB;IAC1D;QACE,KAAK,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,kBAAmB,SAAQ,WAAW;IACjD;QACE,KAAK,CAAC,GAAG,CAAC,CAAA;IACZ,CAAC;CACF;AAJD,gDAIC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { type Buffer } from 'node:buffer';
|
|
3
|
-
export declare const formats: Record<string, Format>;
|
|
4
|
-
export declare const types: string[];
|
|
5
|
-
export interface Format {
|
|
6
|
-
encode: (value: any) => Buffer;
|
|
7
|
-
decode: (buffer: Buffer) => any;
|
|
8
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.types = exports.formats = void 0;
|
|
27
|
-
const json = __importStar(require("./json"));
|
|
28
|
-
const yaml = __importStar(require("./yaml"));
|
|
29
|
-
const msgpack = __importStar(require("./msgpack"));
|
|
30
|
-
const text = __importStar(require("./text"));
|
|
31
|
-
exports.formats = {
|
|
32
|
-
'application/yaml': yaml,
|
|
33
|
-
'application/msgpack': msgpack,
|
|
34
|
-
'application/json': json,
|
|
35
|
-
'text/plain': text
|
|
36
|
-
};
|
|
37
|
-
exports.types = Object.keys(exports.formats);
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/HTTP/formats/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA8B;AAC9B,6CAA8B;AAC9B,mDAAoC;AACpC,6CAA8B;AAEjB,QAAA,OAAO,GAA2B;IAC7C,kBAAkB,EAAE,IAAI;IACxB,qBAAqB,EAAE,OAAO;IAC9B,kBAAkB,EAAE,IAAI;IACxB,YAAY,EAAE,IAAI;CACnB,CAAA;AAEY,QAAA,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,eAAO,CAAC,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode = exports.decode = void 0;
|
|
4
|
-
const node_buffer_1 = require("node:buffer");
|
|
5
|
-
function decode(buffer) {
|
|
6
|
-
const text = buffer.toString();
|
|
7
|
-
return JSON.parse(text);
|
|
8
|
-
}
|
|
9
|
-
exports.decode = decode;
|
|
10
|
-
function encode(value) {
|
|
11
|
-
const text = JSON.stringify(value);
|
|
12
|
-
return node_buffer_1.Buffer.from(text);
|
|
13
|
-
}
|
|
14
|
-
exports.encode = encode;
|
|
15
|
-
//# sourceMappingURL=json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../source/HTTP/formats/json.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEpC,SAAgB,MAAM,CAAE,MAAc;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAE9B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAElC,OAAO,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,wBAIC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.encode = exports.decode = void 0;
|
|
27
|
-
const msgpack = __importStar(require("msgpackr"));
|
|
28
|
-
function decode(buffer) {
|
|
29
|
-
return msgpack.decode(buffer);
|
|
30
|
-
}
|
|
31
|
-
exports.decode = decode;
|
|
32
|
-
function encode(value) {
|
|
33
|
-
return msgpack.encode(value);
|
|
34
|
-
}
|
|
35
|
-
exports.encode = encode;
|
|
36
|
-
//# sourceMappingURL=msgpack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"msgpack.js","sourceRoot":"","sources":["../../../source/HTTP/formats/msgpack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAAmC;AAEnC,SAAgB,MAAM,CAAE,MAAc;IACpC,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAFD,wBAEC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode = exports.decode = void 0;
|
|
4
|
-
const node_buffer_1 = require("node:buffer");
|
|
5
|
-
function decode(buffer) {
|
|
6
|
-
return buffer.toString();
|
|
7
|
-
}
|
|
8
|
-
exports.decode = decode;
|
|
9
|
-
function encode(value) {
|
|
10
|
-
return node_buffer_1.Buffer.from(value.toString());
|
|
11
|
-
}
|
|
12
|
-
exports.encode = encode;
|
|
13
|
-
//# sourceMappingURL=text.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../source/HTTP/formats/text.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEpC,SAAgB,MAAM,CAAE,MAAc;IACpC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC1B,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,OAAO,oBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,wBAEC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.encode = exports.decode = void 0;
|
|
27
|
-
const node_buffer_1 = require("node:buffer");
|
|
28
|
-
const yaml = __importStar(require("js-yaml"));
|
|
29
|
-
function decode(buffer) {
|
|
30
|
-
const text = buffer.toString();
|
|
31
|
-
return yaml.load(text);
|
|
32
|
-
}
|
|
33
|
-
exports.decode = decode;
|
|
34
|
-
function encode(value) {
|
|
35
|
-
const text = yaml.dump(value);
|
|
36
|
-
return node_buffer_1.Buffer.from(text);
|
|
37
|
-
}
|
|
38
|
-
exports.encode = encode;
|
|
39
|
-
//# sourceMappingURL=yaml.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../source/HTTP/formats/yaml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoC;AACpC,8CAA+B;AAE/B,SAAgB,MAAM,CAAE,MAAc;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAE7B,OAAO,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,wBAIC"}
|
package/transpiled/HTTP/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Server"), exports);
|
|
18
|
-
__exportStar(require("./messages"), exports);
|
|
19
|
-
__exportStar(require("./exceptions"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/HTTP/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,6CAA0B;AAC1B,+CAA4B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { type IncomingHttpHeaders, type OutgoingHttpHeaders } from 'node:http';
|
|
3
|
-
import { type Request, type Response } from 'express';
|
|
4
|
-
export declare function write(request: Request, response: Response, body: any): void;
|
|
5
|
-
export declare function read(request: Request): Promise<any>;
|
|
6
|
-
interface Message {
|
|
7
|
-
body: any;
|
|
8
|
-
}
|
|
9
|
-
export interface IncomingMessage extends Message {
|
|
10
|
-
method: string;
|
|
11
|
-
path: string;
|
|
12
|
-
headers: IncomingHttpHeaders;
|
|
13
|
-
query: Query;
|
|
14
|
-
}
|
|
15
|
-
export interface OutgoingMessage {
|
|
16
|
-
status?: number;
|
|
17
|
-
headers?: OutgoingHttpHeaders;
|
|
18
|
-
body?: any;
|
|
19
|
-
}
|
|
20
|
-
export interface Query {
|
|
21
|
-
id?: string;
|
|
22
|
-
criteria?: string;
|
|
23
|
-
sort?: string;
|
|
24
|
-
omit?: string;
|
|
25
|
-
limit?: string;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.read = exports.write = void 0;
|
|
7
|
-
const negotiator_1 = __importDefault(require("negotiator"));
|
|
8
|
-
const generic_1 = require("@toa.io/generic");
|
|
9
|
-
const formats_1 = require("./formats");
|
|
10
|
-
const exceptions_1 = require("./exceptions");
|
|
11
|
-
function write(request, response, body) {
|
|
12
|
-
const buf = format(body, request, response);
|
|
13
|
-
response.send(buf);
|
|
14
|
-
}
|
|
15
|
-
exports.write = write;
|
|
16
|
-
async function read(request) {
|
|
17
|
-
const type = request.headers['content-type'];
|
|
18
|
-
if (type === undefined)
|
|
19
|
-
return undefined;
|
|
20
|
-
if (!(type in formats_1.formats))
|
|
21
|
-
throw new exceptions_1.UnsupportedMediaType();
|
|
22
|
-
const format = formats_1.formats[type];
|
|
23
|
-
const buf = await (0, generic_1.buffer)(request);
|
|
24
|
-
try {
|
|
25
|
-
return format.decode(buf);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
throw new exceptions_1.BadRequest();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.read = read;
|
|
32
|
-
function format(body, request, response) {
|
|
33
|
-
if (body === undefined || body?.length === 0)
|
|
34
|
-
return;
|
|
35
|
-
const type = negotiate(request);
|
|
36
|
-
const format = formats_1.formats[type];
|
|
37
|
-
const buf = format.encode(body);
|
|
38
|
-
// content-length and etag are set by Express
|
|
39
|
-
response.set('content-type', type);
|
|
40
|
-
return buf;
|
|
41
|
-
}
|
|
42
|
-
function negotiate(request) {
|
|
43
|
-
const negotiator = new negotiator_1.default(request);
|
|
44
|
-
const mediaType = negotiator.mediaType(formats_1.types);
|
|
45
|
-
if (mediaType === undefined)
|
|
46
|
-
throw new exceptions_1.NotAcceptable();
|
|
47
|
-
return mediaType;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=messages.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../source/HTTP/messages.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAmC;AACnC,6CAAwC;AACxC,uCAA0C;AAC1C,6CAA8E;AAE9E,SAAgB,KAAK,CAAE,OAAgB,EAAE,QAAkB,EAAE,IAAS;IACpE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAE3C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACpB,CAAC;AAJD,sBAIC;AAEM,KAAK,UAAU,IAAI,CAAE,OAAgB;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAE5C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAExC,IAAI,CAAC,CAAC,IAAI,IAAI,iBAAO,CAAC;QAAE,MAAM,IAAI,iCAAoB,EAAE,CAAA;IAExD,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAA;IAE5B,MAAM,GAAG,GAAG,MAAM,IAAA,gBAAM,EAAC,OAAO,CAAC,CAAA;IAEjC,IAAI;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;KAC1B;IAAC,MAAM;QACN,MAAM,IAAI,uBAAU,EAAE,CAAA;KACvB;AACH,CAAC;AAhBD,oBAgBC;AAED,SAAS,MAAM,CAAE,IAAS,EAAE,OAAgB,EAAE,QAAkB;IAC9D,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,EAAE,MAAM,KAAK,CAAC;QAAE,OAAM;IAEpD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAC/B,MAAM,MAAM,GAAG,iBAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE/B,6CAA6C;IAC7C,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IAElC,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,SAAS,CAAE,OAAgB;IAClC,MAAM,UAAU,GAAG,IAAI,oBAAU,CAAC,OAAO,CAAC,CAAA;IAC1C,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,eAAK,CAAC,CAAA;IAE7C,IAAI,SAAS,KAAK,SAAS;QAAE,MAAM,IAAI,0BAAa,EAAE,CAAA;IAEtD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/transpiled/Mapping.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type Parameter } from './RTD';
|
|
2
|
-
import type * as http from './HTTP';
|
|
3
|
-
import type * as syntax from './RTD/syntax';
|
|
4
|
-
import type * as core from '@toa.io/core';
|
|
5
|
-
export declare abstract class Mapping {
|
|
6
|
-
static create(verb: string, query?: syntax.Query): Mapping;
|
|
7
|
-
abstract fit(input: any, qs: http.Query, parameters: Parameter[]): core.Request;
|
|
8
|
-
}
|
package/transpiled/Mapping.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Mapping = void 0;
|
|
4
|
-
const Query_1 = require("./Query");
|
|
5
|
-
class Mapping {
|
|
6
|
-
static create(verb, query) {
|
|
7
|
-
if (verb === 'POST')
|
|
8
|
-
return new InputMapping();
|
|
9
|
-
if (query === undefined)
|
|
10
|
-
throw new Error(`Query constraints must be defined for ${verb}`);
|
|
11
|
-
const q = new Query_1.Query(query);
|
|
12
|
-
return new QueryableMapping(q);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.Mapping = Mapping;
|
|
16
|
-
class QueryableMapping extends Mapping {
|
|
17
|
-
query;
|
|
18
|
-
constructor(query) {
|
|
19
|
-
super();
|
|
20
|
-
this.query = query;
|
|
21
|
-
}
|
|
22
|
-
fit(input, qs, parameters) {
|
|
23
|
-
const query = this.query.fit(qs, parameters);
|
|
24
|
-
return { input, query };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
class InputMapping extends Mapping {
|
|
28
|
-
fit(body, _, parameters) {
|
|
29
|
-
const input = { ...body };
|
|
30
|
-
for (const parameter of parameters)
|
|
31
|
-
input[parameter.name] = parameter.value;
|
|
32
|
-
return { input };
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=Mapping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Mapping.js","sourceRoot":"","sources":["../source/Mapping.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAK/B,MAAsB,OAAO;IACpB,MAAM,CAAC,MAAM,CAAE,IAAY,EAAE,KAAoB;QACtD,IAAI,IAAI,KAAK,MAAM;YACjB,OAAO,IAAI,YAAY,EAAE,CAAA;QAE3B,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,EAAE,CAAC,CAAA;QAElE,MAAM,CAAC,GAAG,IAAI,aAAK,CAAC,KAAK,CAAC,CAAA;QAE1B,OAAO,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAAA;IAChC,CAAC;CAGF;AAdD,0BAcC;AAED,MAAM,gBAAiB,SAAQ,OAAO;IACnB,KAAK,CAAO;IAE7B,YAAoB,KAAY;QAC9B,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,CAAE,KAAU,EAAE,EAAc,EAAE,UAAuB;QAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;QAE5C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;CACF;AAED,MAAM,YAAa,SAAQ,OAAO;IACzB,GAAG,CAAE,IAAS,EAAE,CAAU,EAAE,UAAuB;QACxD,MAAM,KAAK,GAAG,EAAE,GAAG,IAAI,EAAE,CAAA;QAEzB,KAAK,MAAM,SAAS,IAAI,UAAU;YAChC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,KAAK,CAAA;QAEzC,OAAO,EAAE,KAAK,EAAE,CAAA;IAClB,CAAC;CACF"}
|
package/transpiled/Query.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as http from './HTTP';
|
|
2
|
-
import { type Parameter } from './RTD';
|
|
3
|
-
import type * as syntax from './RTD/syntax';
|
|
4
|
-
import type * as core from '@toa.io/core';
|
|
5
|
-
export declare class Query {
|
|
6
|
-
private readonly query;
|
|
7
|
-
private readonly closed;
|
|
8
|
-
constructor(query: syntax.Query);
|
|
9
|
-
fit(query: http.Query, parameters: Parameter[]): core.Query;
|
|
10
|
-
private fitCriteria;
|
|
11
|
-
private fitRanges;
|
|
12
|
-
private fitSort;
|
|
13
|
-
}
|
package/transpiled/Query.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Query = void 0;
|
|
27
|
-
const http = __importStar(require("./HTTP"));
|
|
28
|
-
const schemas = __importStar(require("./schemas"));
|
|
29
|
-
class Query {
|
|
30
|
-
query;
|
|
31
|
-
closed = false;
|
|
32
|
-
constructor(query) {
|
|
33
|
-
if (query.criteria !== undefined) {
|
|
34
|
-
const open = query.criteria[query.criteria.length - 1] === ';';
|
|
35
|
-
if (open)
|
|
36
|
-
query.criteria = query.criteria.slice(0, -1);
|
|
37
|
-
else
|
|
38
|
-
this.closed = true;
|
|
39
|
-
}
|
|
40
|
-
this.query = query;
|
|
41
|
-
}
|
|
42
|
-
fit(query, parameters) {
|
|
43
|
-
const error = schemas.querystring.fit(query);
|
|
44
|
-
if (error !== null)
|
|
45
|
-
throw new http.BadRequest('Query ' + error.message);
|
|
46
|
-
this.fitCriteria(query, parameters);
|
|
47
|
-
this.fitRanges(query);
|
|
48
|
-
this.fitSort(query);
|
|
49
|
-
return query;
|
|
50
|
-
}
|
|
51
|
-
fitCriteria(query, parameters) {
|
|
52
|
-
const criteria = [];
|
|
53
|
-
if (this.query.criteria !== undefined)
|
|
54
|
-
criteria.push(this.query.criteria);
|
|
55
|
-
const idx = parameters.findIndex((parameter) => parameter.name === 'id');
|
|
56
|
-
if (idx !== -1) {
|
|
57
|
-
query.id = parameters[idx].value;
|
|
58
|
-
parameters.splice(idx, 1);
|
|
59
|
-
}
|
|
60
|
-
if (parameters.length > 0) {
|
|
61
|
-
const chunks = parameters
|
|
62
|
-
.map(({ name, value }) => `${name}==${value}`)
|
|
63
|
-
.join(';');
|
|
64
|
-
criteria.push(chunks);
|
|
65
|
-
}
|
|
66
|
-
if (query.criteria !== undefined)
|
|
67
|
-
if (this.closed)
|
|
68
|
-
throw new http.BadRequest('Query criteria is closed.');
|
|
69
|
-
else
|
|
70
|
-
criteria.push(query.criteria);
|
|
71
|
-
switch (criteria.length) {
|
|
72
|
-
case 0:
|
|
73
|
-
break;
|
|
74
|
-
case 1:
|
|
75
|
-
query.criteria = criteria[0];
|
|
76
|
-
break;
|
|
77
|
-
default:
|
|
78
|
-
query.criteria = '(' + criteria.join(');(') + ')';
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
fitRanges(qs) {
|
|
83
|
-
const query = qs;
|
|
84
|
-
if (qs.limit !== undefined)
|
|
85
|
-
query.limit = fit(qs.limit, this.query.limit.range, 'limit');
|
|
86
|
-
else
|
|
87
|
-
query.limit = this.query.limit.value;
|
|
88
|
-
if (qs.omit !== undefined)
|
|
89
|
-
query.omit = fit(qs.omit, this.query.omit.range, 'omit');
|
|
90
|
-
}
|
|
91
|
-
fitSort(qs) {
|
|
92
|
-
const query = qs;
|
|
93
|
-
if (qs.sort === undefined && this.query.sort === undefined)
|
|
94
|
-
return;
|
|
95
|
-
const sort = (this.query.sort ?? '') + (qs.sort ?? '');
|
|
96
|
-
query.sort = sort.split(';');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.Query = Query;
|
|
100
|
-
function fit(string, range, name) {
|
|
101
|
-
const number = parseInt(string);
|
|
102
|
-
if (number < range[0] || number > range[1])
|
|
103
|
-
throw new http.BadRequest(`Query ${name} must be between ` +
|
|
104
|
-
`${range[0]} and ${range[1]} inclusive.`);
|
|
105
|
-
return number;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=Query.js.map
|
package/transpiled/Query.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Query.js","sourceRoot":"","sources":["../source/Query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAE9B,mDAAoC;AAIpC,MAAa,KAAK;IACC,KAAK,CAAc;IACnB,MAAM,GAAY,KAAK,CAAA;IAExC,YAAoB,KAAmB;QACrC,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,EAAE;YAChC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,CAAA;YAE9D,IAAI,IAAI;gBAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;;gBACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;SACxB;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,GAAG,CAAE,KAAiB,EAAE,UAAuB;QACpD,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAE5C,IAAI,KAAK,KAAK,IAAI;YAChB,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,CAAA;QAErD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;QACnC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAEnB,OAAO,KAAmB,CAAA;IAC5B,CAAC;IAEO,WAAW,CAAE,KAAiB,EAAE,UAAuB;QAC7D,MAAM,QAA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AAC,CAAC,CAAC,aAAa,CAAC,CAAA;IAE7C,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Directives, type DirectivesFactory } from './Directives';
|
|
2
|
-
import { type Endpoint, type EndpointsFactory } from './Endpoint';
|
|
3
|
-
export interface Context<TEndpoint extends Endpoint = any, TDirectives extends Directives<TDirectives> = any, TExtension = any> {
|
|
4
|
-
readonly protected: boolean;
|
|
5
|
-
readonly endpoints: EndpointsFactory<TEndpoint>;
|
|
6
|
-
readonly directives: {
|
|
7
|
-
readonly factory: DirectivesFactory;
|
|
8
|
-
stack: TDirectives[];
|
|
9
|
-
};
|
|
10
|
-
readonly extension?: TExtension;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../source/RTD/Context.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Directives.js","sourceRoot":"","sources":["../../source/RTD/Directives.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Context } from './Context';
|
|
2
|
-
import type * as syntax from './syntax';
|
|
3
|
-
export interface Endpoint<T extends Endpoint = any> {
|
|
4
|
-
call: T['call'];
|
|
5
|
-
close: () => Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export interface EndpointsFactory<T extends Endpoint<T> = any> {
|
|
8
|
-
create: (method: syntax.Method, context: Context) => T;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Endpoint.js","sourceRoot":"","sources":["../../source/RTD/Endpoint.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Node } from './Node';
|
|
2
|
-
import { type Directives } from './Directives';
|
|
3
|
-
import { type Endpoint } from './Endpoint';
|
|
4
|
-
export interface Match<TEndpoint extends Endpoint<TEndpoint> = any, TDirectives extends Directives<TDirectives> = any> {
|
|
5
|
-
node: Node<TEndpoint, TDirectives>;
|
|
6
|
-
parameters: Parameter[];
|
|
7
|
-
}
|
|
8
|
-
export interface Parameter {
|
|
9
|
-
name: string;
|
|
10
|
-
value: string;
|
|
11
|
-
}
|