@loutrejs/loutre 0.5.0 → 0.6.0
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/README.md +63 -32
- package/dist/adapters/aws-lambda.d.ts +5 -3
- package/dist/adapters/aws-lambda.js +53 -23
- package/dist/adapters/bun.d.ts +7 -4
- package/dist/adapters/bun.js +52 -42
- package/dist/adapters/cloudflare-workers.d.ts +5 -3
- package/dist/adapters/cloudflare-workers.js +23 -28
- package/dist/adapters/deno.d.ts +7 -4
- package/dist/adapters/deno.js +94 -57
- package/dist/adapters/electron.d.ts +13 -5
- package/dist/adapters/electron.js +76 -28
- package/dist/application/definition.d.ts +31 -0
- package/dist/application/definition.js +16 -0
- package/dist/application/index.d.ts +4 -63
- package/dist/application/index.js +2 -11
- package/dist/application/kernel-internal.d.ts +2 -0
- package/dist/application/kernel-internal.js +10 -0
- package/dist/application/kernel.d.ts +21 -0
- package/dist/application/kernel.js +65 -0
- package/dist/core/diagnostic.d.ts +9 -0
- package/dist/core/diagnostic.js +9 -0
- package/dist/core/extension.d.ts +107 -0
- package/dist/core/extension.js +73 -0
- package/dist/core/generic-layer.d.ts +26 -0
- package/dist/core/generic-layer.js +116 -0
- package/dist/core/index.d.ts +31 -15
- package/dist/core/index.js +15 -15
- package/dist/core/injection.d.ts +4 -13
- package/dist/core/injection.js +63 -0
- package/dist/core/model/context.d.ts +18 -0
- package/dist/core/model/context.js +34 -0
- package/dist/core/model/lifecycle.d.ts +5 -0
- package/dist/core/model/lifecycle.js +44 -0
- package/dist/core/model/modules.d.ts +2 -0
- package/dist/core/model/modules.js +101 -0
- package/dist/core/model/providers.d.ts +4 -0
- package/dist/core/model/providers.js +74 -0
- package/dist/core/model/snapshot.d.ts +6 -0
- package/dist/core/model/snapshot.js +31 -0
- package/dist/core/model/types.d.ts +78 -0
- package/dist/core/model/validation.d.ts +4 -0
- package/dist/core/model/validation.js +40 -0
- package/dist/core/model/visibility.d.ts +4 -0
- package/dist/core/model/visibility.js +20 -0
- package/dist/core/model.d.ts +10 -0
- package/dist/core/model.js +346 -0
- package/dist/core/module.d.ts +8 -13
- package/dist/core/source-location.d.ts +8 -0
- package/dist/core/source-location.js +31 -0
- package/dist/core/token-internal.d.ts +3 -0
- package/dist/core/token-internal.js +4 -0
- package/dist/core/type.d.ts +7 -0
- package/dist/core/type.js +4 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/graph/index.d.ts +2 -3
- package/dist/graph/index.js +1 -3
- package/dist/graph/model.d.ts +34 -0
- package/dist/graph/model.js +127 -0
- package/dist/http/auth.d.ts +46 -0
- package/dist/http/auth.js +96 -0
- package/dist/http/client.d.ts +28 -31
- package/dist/http/client.js +58 -44
- package/dist/http/cors-internal.d.ts +29 -0
- package/dist/http/cors-internal.js +160 -0
- package/dist/http/cors.d.ts +5 -8
- package/dist/http/cors.js +7 -165
- package/dist/http/extension.d.ts +348 -0
- package/dist/http/extension.js +947 -0
- package/dist/http/index.d.ts +9 -7
- package/dist/http/index.js +5 -7
- package/dist/{application → http}/openapi.d.ts +12 -3
- package/dist/{application → http}/openapi.js +164 -102
- package/dist/http/path.d.ts +1 -42
- package/dist/http/path.js +1 -2
- package/dist/http/runtime/request.d.ts +17 -0
- package/dist/http/runtime/request.js +109 -0
- package/dist/http/runtime/response.d.ts +18 -0
- package/dist/http/runtime/response.js +108 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/message-port/extension.d.ts +66 -0
- package/dist/message-port/extension.js +395 -0
- package/dist/message-port/index.d.ts +4 -73
- package/dist/message-port/index.js +2 -189
- package/dist/message-port/transport.d.ts +11 -0
- package/dist/message-port/transport.js +45 -0
- package/dist/runtime/async-iterator-lifecycle.d.ts +12 -0
- package/dist/runtime/async-iterator-lifecycle.js +95 -0
- package/dist/runtime/capability.d.ts +11 -11
- package/dist/runtime/capability.js +3 -3
- package/dist/runtime/di.d.ts +2 -22
- package/dist/runtime/di.js +8 -285
- package/dist/runtime/execution-tracker.d.ts +8 -0
- package/dist/runtime/execution-tracker.js +54 -0
- package/dist/runtime/index.d.ts +15 -9
- package/dist/runtime/index.js +9 -9
- package/dist/runtime/ingress-gate.d.ts +7 -0
- package/dist/runtime/ingress-gate.js +33 -0
- package/dist/runtime/kernel.d.ts +23 -0
- package/dist/runtime/kernel.js +354 -0
- package/dist/runtime/logger.d.ts +2 -0
- package/dist/runtime/logger.js +2 -0
- package/dist/runtime/node-capabilities.d.ts +1 -1
- package/dist/runtime/node-capabilities.js +1 -1
- package/dist/runtime/server-port.d.ts +2 -0
- package/dist/runtime/server-port.js +11 -0
- package/dist/tasks/extension.d.ts +144 -0
- package/dist/tasks/extension.js +499 -0
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.js +1 -0
- package/dist/tasks/runtime/cron.d.ts +6 -0
- package/dist/tasks/runtime/cron.js +89 -0
- package/dist/websocket/errors.d.ts +9 -0
- package/dist/websocket/errors.js +18 -0
- package/dist/websocket/extension.d.ts +154 -0
- package/dist/websocket/extension.js +524 -0
- package/dist/websocket/index.d.ts +3 -0
- package/dist/websocket/index.js +2 -0
- package/package.json +12 -16
- package/dist/application/binding.d.ts +0 -33
- package/dist/application/binding.js +0 -295
- package/dist/application/host.d.ts +0 -8
- package/dist/application/host.js +0 -14
- package/dist/application/queue.d.ts +0 -3
- package/dist/application/queue.js +0 -4
- package/dist/application/scheduler.d.ts +0 -2
- package/dist/application/scheduler.js +0 -45
- package/dist/core/context-key.d.ts +0 -16
- package/dist/core/context-key.js +0 -17
- package/dist/core/contract-internal.d.ts +0 -22
- package/dist/core/contract-internal.js +0 -61
- package/dist/core/contract.d.ts +0 -96
- package/dist/core/contract.js +0 -88
- package/dist/core/execution.d.ts +0 -78
- package/dist/core/execution.js +0 -61
- package/dist/core/implementation.d.ts +0 -44
- package/dist/core/implementation.js +0 -35
- package/dist/core/layer.d.ts +0 -137
- package/dist/core/layer.js +0 -81
- package/dist/graph/compiler.d.ts +0 -4
- package/dist/graph/compiler.js +0 -228
- package/dist/graph/graph.d.ts +0 -18
- package/dist/graph/graph.js +0 -1118
- package/dist/graph/ir.d.ts +0 -175
- package/dist/http/application.d.ts +0 -18
- package/dist/http/application.js +0 -515
- package/dist/http/basic-auth.d.ts +0 -37
- package/dist/http/basic-auth.js +0 -67
- package/dist/http/definitions.d.ts +0 -363
- package/dist/http/definitions.js +0 -310
- package/dist/http/hosted-protocol.d.ts +0 -4
- package/dist/http/hosted-protocol.js +0 -4
- package/dist/http/internal.d.ts +0 -8
- package/dist/http/internal.js +0 -1
- package/dist/http/params.d.ts +0 -2
- package/dist/http/params.js +0 -19
- package/dist/http/request-body.d.ts +0 -4
- package/dist/http/request-body.js +0 -6
- package/dist/http/validate.d.ts +0 -20
- package/dist/http/validate.js +0 -6
- package/dist/message-port/environment.d.ts +0 -2
- package/dist/message-port/environment.js +0 -4
- package/dist/runtime/application.d.ts +0 -38
- package/dist/runtime/application.js +0 -339
- package/dist/runtime/pipeline.d.ts +0 -11
- package/dist/runtime/pipeline.js +0 -161
- /package/dist/{graph/ir.js → core/model/types.js} +0 -0
package/dist/http/definitions.js
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
import { childPipelineOf } from '../core/index.js';
|
|
2
|
-
import { contractNodeBinding, contractNodeMetadata, protocolNamespaceBuilder, protocolNamespaceType, } from '../core/contract-internal.js';
|
|
3
|
-
import { httpNodeMetadata } from './internal.js';
|
|
4
|
-
import { assertValidHttpMethod, createHttpDispatchKey, parseHttpPath, } from './path.js';
|
|
5
|
-
const controller = Object.freeze({
|
|
6
|
-
kind: 'terminal',
|
|
7
|
-
name: 'http.controller',
|
|
8
|
-
role: 'terminal',
|
|
9
|
-
protocol: 'http',
|
|
10
|
-
});
|
|
11
|
-
function defineHttp(definition) {
|
|
12
|
-
assertValidHttpMethod(definition.method);
|
|
13
|
-
for (const response of Object.values(definition.responses)) {
|
|
14
|
-
if (!Number.isInteger(response.status) ||
|
|
15
|
-
response.status < 200 ||
|
|
16
|
-
response.status > 599) {
|
|
17
|
-
throw new Error(`Invalid HTTP response status: ${response.status}`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const segments = parseHttpPath(definition.path);
|
|
21
|
-
const paramsSchemas = definition.request?.params;
|
|
22
|
-
if (paramsSchemas) {
|
|
23
|
-
const pathNames = segments.flatMap((segment) => segment.kind === 'param' ? [segment.name] : []);
|
|
24
|
-
const schemaNames = Object.keys(paramsSchemas);
|
|
25
|
-
if (pathNames.length !== schemaNames.length ||
|
|
26
|
-
pathNames.some((name) => !Object.hasOwn(paramsSchemas, name))) {
|
|
27
|
-
throw new Error('HTTP path parameter names and request.params keys must match');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else if (hasParamsValidation(definition.pipeline)) {
|
|
31
|
-
throw new Error('validate.params requires request.params');
|
|
32
|
-
}
|
|
33
|
-
const body = definition.request?.body;
|
|
34
|
-
if (body && body.contentType.trim().length === 0) {
|
|
35
|
-
throw new Error('HTTP request body contentType must not be empty');
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
kind: 'protocol',
|
|
39
|
-
protocol: 'http',
|
|
40
|
-
interaction: definition.interaction ?? 'unary',
|
|
41
|
-
dispatchKey: createHttpDispatchKey(definition.method, segments),
|
|
42
|
-
definition,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function hasParamsValidation(pipeline) {
|
|
46
|
-
return pipeline.some((item) => (item.kind === 'validation' && item.part === 'params') ||
|
|
47
|
-
(item.kind === 'layer' &&
|
|
48
|
-
hasParamsValidation(childPipelineOf(item) ?? [])));
|
|
49
|
-
}
|
|
50
|
-
function defineHttpGroup(definitions) {
|
|
51
|
-
const resolution = resolveHttpTree(definitions, {
|
|
52
|
-
path: '',
|
|
53
|
-
pipeline: [],
|
|
54
|
-
responses: {},
|
|
55
|
-
procedurePrefix: '',
|
|
56
|
-
});
|
|
57
|
-
const group = {
|
|
58
|
-
kind: 'protocol-group',
|
|
59
|
-
protocol: 'http',
|
|
60
|
-
procedures: Object.freeze({ ...resolution.procedures }),
|
|
61
|
-
};
|
|
62
|
-
Object.defineProperty(group, protocolNamespaceBuilder, {
|
|
63
|
-
enumerable: false,
|
|
64
|
-
value: (root) => buildHttpNamespace(resolution.tree, root, []),
|
|
65
|
-
});
|
|
66
|
-
return Object.freeze(group);
|
|
67
|
-
}
|
|
68
|
-
const HTTP_LEAF_PROPERTIES = new Set([
|
|
69
|
-
'method',
|
|
70
|
-
'path',
|
|
71
|
-
'summary',
|
|
72
|
-
'description',
|
|
73
|
-
'tags',
|
|
74
|
-
'deprecated',
|
|
75
|
-
'request',
|
|
76
|
-
'responses',
|
|
77
|
-
'pipeline',
|
|
78
|
-
'interaction',
|
|
79
|
-
]);
|
|
80
|
-
const HTTP_BRANCH_PROPERTIES = new Set([
|
|
81
|
-
'path',
|
|
82
|
-
'pipeline',
|
|
83
|
-
'responses',
|
|
84
|
-
'routes',
|
|
85
|
-
]);
|
|
86
|
-
function assertHttpRouteTreeObject(definitions) {
|
|
87
|
-
const prototype = Object.getPrototypeOf(definitions);
|
|
88
|
-
if (prototype !== Object.prototype && prototype !== null) {
|
|
89
|
-
throw new Error('HTTP route tree must be a plain object');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function assertHttpRouteName(name) {
|
|
93
|
-
if (name.length === 0 ||
|
|
94
|
-
name === '__proto__' ||
|
|
95
|
-
name.includes('.') ||
|
|
96
|
-
Number.isFinite(Number(name))) {
|
|
97
|
-
throw new Error(`Invalid HTTP Contract node name: ${JSON.stringify(name)}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function assertHttpNodeProperties(source) {
|
|
101
|
-
const allowed = 'method' in source ? HTTP_LEAF_PROPERTIES : HTTP_BRANCH_PROPERTIES;
|
|
102
|
-
for (const property of Object.keys(source)) {
|
|
103
|
-
if (!allowed.has(property)) {
|
|
104
|
-
throw new Error(`Unknown HTTP Contract node property: ${property}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function resolveHttpTree(definitions, context) {
|
|
109
|
-
assertHttpRouteTreeObject(definitions);
|
|
110
|
-
const procedures = {};
|
|
111
|
-
const tree = {};
|
|
112
|
-
for (const [name, candidate] of Object.entries(definitions)) {
|
|
113
|
-
assertHttpRouteName(name);
|
|
114
|
-
const metadata = typeof candidate === 'object' &&
|
|
115
|
-
candidate !== null &&
|
|
116
|
-
httpNodeMetadata in candidate
|
|
117
|
-
? candidate[httpNodeMetadata]
|
|
118
|
-
: undefined;
|
|
119
|
-
const source = (metadata?.source ?? candidate);
|
|
120
|
-
assertHttpNodeProperties(source);
|
|
121
|
-
const procedureName = context.procedurePrefix === ''
|
|
122
|
-
? name
|
|
123
|
-
: `${context.procedurePrefix}.${name}`;
|
|
124
|
-
if ('method' in source) {
|
|
125
|
-
const responses = mergeHttpResponses(context.responses, source.responses);
|
|
126
|
-
const definition = {
|
|
127
|
-
...source,
|
|
128
|
-
path: joinHttpPath(context.path, source.path),
|
|
129
|
-
responses,
|
|
130
|
-
pipeline: [...context.pipeline, ...source.pipeline],
|
|
131
|
-
};
|
|
132
|
-
const protocol = defineHttp(definition);
|
|
133
|
-
procedures[procedureName] = protocol;
|
|
134
|
-
tree[name] = {
|
|
135
|
-
kind: 'leaf',
|
|
136
|
-
source,
|
|
137
|
-
handlerName: metadata?.kind === 'leaf' && metadata.handlerName
|
|
138
|
-
? metadata.handlerName
|
|
139
|
-
: name,
|
|
140
|
-
protocol,
|
|
141
|
-
};
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
assertBranchPipeline(source.pipeline ?? []);
|
|
145
|
-
const branchResponses = mergeHttpResponses(context.responses, source.responses ?? {});
|
|
146
|
-
const branch = resolveHttpTree(source.routes, {
|
|
147
|
-
path: joinHttpPath(context.path, source.path ?? ''),
|
|
148
|
-
pipeline: [...context.pipeline, ...(source.pipeline ?? [])],
|
|
149
|
-
responses: branchResponses,
|
|
150
|
-
procedurePrefix: procedureName,
|
|
151
|
-
});
|
|
152
|
-
Object.assign(procedures, branch.procedures);
|
|
153
|
-
tree[name] = {
|
|
154
|
-
kind: 'branch',
|
|
155
|
-
source,
|
|
156
|
-
children: branch.tree,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return { procedures, tree: Object.freeze(tree) };
|
|
160
|
-
}
|
|
161
|
-
function joinHttpPath(parent, child) {
|
|
162
|
-
if (parent === '')
|
|
163
|
-
return child;
|
|
164
|
-
if (child === '' || child === '/')
|
|
165
|
-
return parent;
|
|
166
|
-
return `${parent}${child}`;
|
|
167
|
-
}
|
|
168
|
-
function mergeHttpResponses(parent, local) {
|
|
169
|
-
for (const name of Object.keys(local)) {
|
|
170
|
-
if (Object.hasOwn(parent, name)) {
|
|
171
|
-
throw new Error(`Duplicate inherited HTTP response variant: ${name}`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return Object.freeze({ ...parent, ...local });
|
|
175
|
-
}
|
|
176
|
-
function assertBranchPipeline(pipeline) {
|
|
177
|
-
for (const item of pipeline) {
|
|
178
|
-
if (item.kind === 'terminal') {
|
|
179
|
-
throw new Error('HTTP branch pipeline must not contain a terminal layer');
|
|
180
|
-
}
|
|
181
|
-
if (item.kind === 'layer') {
|
|
182
|
-
const child = childPipelineOf(item);
|
|
183
|
-
if (child)
|
|
184
|
-
assertBranchPipeline(child);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function buildHttpNamespace(tree, root, parentPath) {
|
|
189
|
-
const namespace = {};
|
|
190
|
-
for (const [name, template] of Object.entries(tree)) {
|
|
191
|
-
namespace[name] = buildHttpNode(template, root, [...parentPath, name]);
|
|
192
|
-
}
|
|
193
|
-
return Object.freeze(namespace);
|
|
194
|
-
}
|
|
195
|
-
function buildHttpNode(template, root, path) {
|
|
196
|
-
if (template.kind === 'leaf') {
|
|
197
|
-
const binding = {
|
|
198
|
-
kind: 'contract',
|
|
199
|
-
procedures: Object.freeze({
|
|
200
|
-
[template.handlerName]: Object.freeze({
|
|
201
|
-
kind: 'procedure',
|
|
202
|
-
protocols: Object.freeze({ http: template.protocol }),
|
|
203
|
-
}),
|
|
204
|
-
}),
|
|
205
|
-
};
|
|
206
|
-
Object.defineProperty(binding, contractNodeMetadata, {
|
|
207
|
-
enumerable: false,
|
|
208
|
-
value: Object.freeze({
|
|
209
|
-
kind: 'leaf',
|
|
210
|
-
root,
|
|
211
|
-
path: Object.freeze(['http', ...path]),
|
|
212
|
-
procedures: Object.freeze({
|
|
213
|
-
[template.handlerName]: path.join('.'),
|
|
214
|
-
}),
|
|
215
|
-
}),
|
|
216
|
-
});
|
|
217
|
-
Object.freeze(binding);
|
|
218
|
-
const node = {};
|
|
219
|
-
Object.defineProperty(node, contractNodeBinding, {
|
|
220
|
-
enumerable: false,
|
|
221
|
-
value: binding,
|
|
222
|
-
});
|
|
223
|
-
Object.defineProperty(node, httpNodeMetadata, {
|
|
224
|
-
enumerable: false,
|
|
225
|
-
value: Object.freeze({
|
|
226
|
-
kind: 'leaf',
|
|
227
|
-
root,
|
|
228
|
-
path: Object.freeze([...path]),
|
|
229
|
-
source: template.source,
|
|
230
|
-
handlerName: template.handlerName,
|
|
231
|
-
}),
|
|
232
|
-
});
|
|
233
|
-
return Object.freeze(node);
|
|
234
|
-
}
|
|
235
|
-
const children = buildHttpNamespace(template.children, root, path);
|
|
236
|
-
const procedures = {};
|
|
237
|
-
collectHttpNodeProcedures(template.children, '', procedures);
|
|
238
|
-
const binding = {
|
|
239
|
-
kind: 'contract',
|
|
240
|
-
procedures: Object.freeze(procedures),
|
|
241
|
-
};
|
|
242
|
-
Object.defineProperty(binding, contractNodeMetadata, {
|
|
243
|
-
enumerable: false,
|
|
244
|
-
value: Object.freeze({
|
|
245
|
-
kind: 'branch',
|
|
246
|
-
root,
|
|
247
|
-
path: Object.freeze(['http', ...path]),
|
|
248
|
-
procedures: Object.freeze(Object.fromEntries(Object.keys(procedures).map((procedure) => [
|
|
249
|
-
procedure,
|
|
250
|
-
[...path, procedure].join('.'),
|
|
251
|
-
]))),
|
|
252
|
-
}),
|
|
253
|
-
});
|
|
254
|
-
Object.freeze(binding);
|
|
255
|
-
const node = { ...children };
|
|
256
|
-
Object.defineProperty(node, contractNodeBinding, {
|
|
257
|
-
enumerable: false,
|
|
258
|
-
value: binding,
|
|
259
|
-
});
|
|
260
|
-
Object.defineProperty(node, httpNodeMetadata, {
|
|
261
|
-
enumerable: false,
|
|
262
|
-
value: Object.freeze({
|
|
263
|
-
kind: 'branch',
|
|
264
|
-
root,
|
|
265
|
-
path: Object.freeze([...path]),
|
|
266
|
-
source: template.source,
|
|
267
|
-
}),
|
|
268
|
-
});
|
|
269
|
-
return Object.freeze(node);
|
|
270
|
-
}
|
|
271
|
-
function collectHttpNodeProcedures(tree, prefix, procedures) {
|
|
272
|
-
for (const [name, template] of Object.entries(tree)) {
|
|
273
|
-
const path = prefix === '' ? name : `${prefix}.${name}`;
|
|
274
|
-
if (template.kind === 'leaf') {
|
|
275
|
-
procedures[path] = Object.freeze({
|
|
276
|
-
kind: 'procedure',
|
|
277
|
-
protocols: Object.freeze({ http: template.protocol }),
|
|
278
|
-
});
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
collectHttpNodeProcedures(template.children, path, procedures);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
export const http = Object.assign(defineHttpGroup, {
|
|
285
|
-
protocol: 'http',
|
|
286
|
-
route: defineHttp,
|
|
287
|
-
controller,
|
|
288
|
-
error: httpError,
|
|
289
|
-
});
|
|
290
|
-
function validationLayer(part) {
|
|
291
|
-
return Object.freeze({
|
|
292
|
-
kind: 'validation',
|
|
293
|
-
name: `validate.${part}`,
|
|
294
|
-
role: 'validation',
|
|
295
|
-
part,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
export const validate = Object.freeze({
|
|
299
|
-
params: validationLayer('params'),
|
|
300
|
-
query: validationLayer('query'),
|
|
301
|
-
headers: validationLayer('headers'),
|
|
302
|
-
body: validationLayer('body'),
|
|
303
|
-
});
|
|
304
|
-
export function httpError(definition, map) {
|
|
305
|
-
return Object.freeze({
|
|
306
|
-
kind: 'http-error-mapping',
|
|
307
|
-
definition,
|
|
308
|
-
map: map ?? ((error) => ({ body: error.data })),
|
|
309
|
-
});
|
|
310
|
-
}
|
package/dist/http/internal.d.ts
DELETED
package/dist/http/internal.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const httpNodeMetadata = Symbol('loutre.http-node-metadata');
|
package/dist/http/params.d.ts
DELETED
package/dist/http/params.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SchemaValidationError, validateSchema } from '../core/index.js';
|
|
2
|
-
export async function validateHttpParamsSchemas(schemas, value) {
|
|
3
|
-
const output = {};
|
|
4
|
-
for (const [name, schema] of Object.entries(schemas)) {
|
|
5
|
-
try {
|
|
6
|
-
output[name] = await validateSchema(schema, value[name]);
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
if (error instanceof SchemaValidationError) {
|
|
10
|
-
throw new SchemaValidationError(error.issues.map((issue) => ({
|
|
11
|
-
...issue,
|
|
12
|
-
path: [name, ...(issue.path ?? [])],
|
|
13
|
-
})));
|
|
14
|
-
}
|
|
15
|
-
throw error;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return output;
|
|
19
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from '../core/index.js';
|
|
2
|
-
import type { HttpRequestBodyDefinition } from './definitions.js';
|
|
3
|
-
export declare function httpRequestBodySchema(body: HttpRequestBodyDefinition): StandardSchemaV1;
|
|
4
|
-
export declare function httpRequestBodyContentType(body: HttpRequestBodyDefinition): string;
|
package/dist/http/validate.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { cors } from './cors.js';
|
|
2
|
-
export declare const validate: Readonly<{
|
|
3
|
-
params: import("../index.js").ValidationLayerDescriptor & {
|
|
4
|
-
readonly part: "params";
|
|
5
|
-
readonly name: "validate.params";
|
|
6
|
-
};
|
|
7
|
-
query: import("../index.js").ValidationLayerDescriptor & {
|
|
8
|
-
readonly part: "query";
|
|
9
|
-
readonly name: "validate.query";
|
|
10
|
-
};
|
|
11
|
-
headers: import("../index.js").ValidationLayerDescriptor & {
|
|
12
|
-
readonly part: "headers";
|
|
13
|
-
readonly name: "validate.headers";
|
|
14
|
-
};
|
|
15
|
-
body: import("../index.js").ValidationLayerDescriptor & {
|
|
16
|
-
readonly part: "body";
|
|
17
|
-
readonly name: "validate.body";
|
|
18
|
-
};
|
|
19
|
-
cors: typeof cors;
|
|
20
|
-
}>;
|
package/dist/http/validate.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type ArgsClass, type EnvClass, type ModuleInstance, type ModuleTemplate, type TaskArguments, type TaskDescriptor, type TaskOutput, type TokenLike } from '../core/index.js';
|
|
2
|
-
import { Container, type RuntimeModuleGraph } from './di.js';
|
|
3
|
-
import { Logger } from './logger.js';
|
|
4
|
-
export interface ApplicationRuntimeOptions {
|
|
5
|
-
readonly logger?: Logger;
|
|
6
|
-
readonly environmentSource?: unknown;
|
|
7
|
-
readonly arguments?: ArgsClass;
|
|
8
|
-
readonly argumentsSource?: unknown;
|
|
9
|
-
readonly tasks?: readonly TaskDescriptor<any, any>[];
|
|
10
|
-
readonly publicTasks?: readonly TaskDescriptor<any, any>[];
|
|
11
|
-
}
|
|
12
|
-
export interface InitializableApplication {
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare function initializeWithEnvironment(application: InitializableApplication, environmentSource: unknown): Promise<void>;
|
|
16
|
-
export declare class EnvironmentBindingError extends Error {
|
|
17
|
-
readonly code = "LUTRE_ENV_003";
|
|
18
|
-
constructor(environment: EnvClass, cause: unknown);
|
|
19
|
-
}
|
|
20
|
-
export declare class ArgumentsBindingError extends Error {
|
|
21
|
-
readonly code = "LUTRE_ARGS_003";
|
|
22
|
-
constructor(argumentsContract: ArgsClass, cause: unknown);
|
|
23
|
-
}
|
|
24
|
-
export declare class ApplicationRuntime {
|
|
25
|
-
#private;
|
|
26
|
-
readonly graph: RuntimeModuleGraph;
|
|
27
|
-
readonly container: Container;
|
|
28
|
-
constructor(roots: readonly (ModuleInstance | ModuleTemplate<void>)[], options?: ApplicationRuntimeOptions);
|
|
29
|
-
initialize(): Promise<void>;
|
|
30
|
-
get<T>(token: TokenLike<T>): T;
|
|
31
|
-
run<TTask extends TaskDescriptor<any, any>>(task: TTask, ...args: TaskArguments<TTask>): Promise<TaskOutput<TTask>>;
|
|
32
|
-
/** public run()ではTrigger専用Taskを拒否するため、Trigger Host専用経路を分ける。 */
|
|
33
|
-
runTask<TTask extends TaskDescriptor<any, any>>(task: TTask, ...args: TaskArguments<TTask>): Promise<TaskOutput<TTask>>;
|
|
34
|
-
execute<T>(execution: () => T | Promise<T>): Promise<T>;
|
|
35
|
-
stopAcceptingExecutions(): void;
|
|
36
|
-
shutdown(signal?: string): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
export declare function createApplicationRuntime(roots: readonly (ModuleInstance | ModuleTemplate<void>)[], options?: ApplicationRuntimeOptions): ApplicationRuntime;
|