@daloyjs/core 1.2.0 → 1.3.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 +3 -2
- package/dist/adapters/cloudflare.d.ts +8 -1
- package/dist/adapters/cloudflare.js +15 -1
- package/dist/adapters/lambda.js +15 -5
- package/dist/adapters/vercel.d.ts +5 -0
- package/dist/adapters/vercel.js +27 -2
- package/dist/app.d.ts +136 -10
- package/dist/app.js +382 -69
- package/dist/combine.js +14 -8
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/jobs.d.ts +665 -0
- package/dist/jobs.js +1102 -0
- package/dist/metrics.d.ts +23 -9
- package/dist/metrics.js +33 -10
- package/dist/otlp.d.ts +31 -5
- package/dist/otlp.js +99 -37
- package/dist/sbom.cdx.json +9 -9
- package/dist/sbom.spdx.json +5 -5
- package/package.json +7 -1
package/dist/combine.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @since 0.19.0
|
|
7
7
|
*/
|
|
8
|
-
import { _mergePreBodyWithEarlyRejections, EARLY_REJECTION_HOOK_MARKER } from "./middleware.js";
|
|
8
|
+
import { _mergePreBodyWithEarlyRejections, EARLY_REJECTION_HOOK_MARKER, } from "./middleware.js";
|
|
9
9
|
/**
|
|
10
10
|
* Run every supplied {@link Hooks} bundle in order, pipeline-style.
|
|
11
11
|
* Equivalent to passing the bundles to `app.use(...)` one after another,
|
|
@@ -88,7 +88,9 @@ export function some(...layers) {
|
|
|
88
88
|
return [
|
|
89
89
|
async (ctx) => {
|
|
90
90
|
const early = await hooks.preBody(ctx);
|
|
91
|
-
return early instanceof Response
|
|
91
|
+
return early instanceof Response
|
|
92
|
+
? early
|
|
93
|
+
: hooks.beforeHandle(ctx);
|
|
92
94
|
},
|
|
93
95
|
];
|
|
94
96
|
}
|
|
@@ -152,7 +154,9 @@ export function some(...layers) {
|
|
|
152
154
|
*/
|
|
153
155
|
export function except(when, hooks) {
|
|
154
156
|
const earlyRejectionHooks = hooks[EARLY_REJECTION_HOOK_MARKER];
|
|
155
|
-
if (!hooks.preBody &&
|
|
157
|
+
if (!hooks.preBody &&
|
|
158
|
+
!hooks.beforeHandle &&
|
|
159
|
+
!Array.isArray(earlyRejectionHooks))
|
|
156
160
|
return hooks;
|
|
157
161
|
const matches = compileExceptMatcher(when);
|
|
158
162
|
const wrapped = { ...hooks };
|
|
@@ -166,11 +170,11 @@ export function except(when, hooks) {
|
|
|
166
170
|
}
|
|
167
171
|
if (hooks.preBody) {
|
|
168
172
|
const original = hooks.preBody;
|
|
169
|
-
wrapped.preBody = async (ctx) => (
|
|
173
|
+
wrapped.preBody = async (ctx) => (await matches(ctx)) ? undefined : original(ctx);
|
|
170
174
|
}
|
|
171
175
|
if (hooks.beforeHandle) {
|
|
172
176
|
const original = hooks.beforeHandle;
|
|
173
|
-
wrapped.beforeHandle = async (ctx) => (
|
|
177
|
+
wrapped.beforeHandle = async (ctx) => (await matches(ctx)) ? undefined : original(ctx);
|
|
174
178
|
}
|
|
175
179
|
return wrapped;
|
|
176
180
|
}
|
|
@@ -206,7 +210,9 @@ function compilePathPattern(pattern) {
|
|
|
206
210
|
return (path) => regex.test(path);
|
|
207
211
|
}
|
|
208
212
|
function mergeCombineHooks(layers) {
|
|
209
|
-
const pick = (key) => layers
|
|
213
|
+
const pick = (key) => layers
|
|
214
|
+
.map((h) => h[key])
|
|
215
|
+
.filter((f) => typeof f === "function");
|
|
210
216
|
const merged = {};
|
|
211
217
|
const onRequest = pick("onRequest");
|
|
212
218
|
if (onRequest.length > 0) {
|
|
@@ -266,9 +272,9 @@ function mergeCombineHooks(layers) {
|
|
|
266
272
|
}
|
|
267
273
|
const onResponse = pick("onResponse");
|
|
268
274
|
if (onResponse.length > 0) {
|
|
269
|
-
merged.onResponse = async (res) => {
|
|
275
|
+
merged.onResponse = async (res, ctx) => {
|
|
270
276
|
for (const fn of onResponse)
|
|
271
|
-
await fn(res);
|
|
277
|
+
await fn(res, ctx);
|
|
272
278
|
};
|
|
273
279
|
}
|
|
274
280
|
// Forward symbol-keyed security markers (CORS / CSRF / session /
|
package/dist/index.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export { createWebhookSender, MemoryWebhookDeadLetterSink } from "./webhook-deli
|
|
|
48
48
|
export type { WebhookEvent, WebhookSenderOptions, WebhookDeliveryResult, WebhookDeadLetter, WebhookDeadLetterSink, WebhookAttempt, } from "./webhook-delivery.js";
|
|
49
49
|
export { Scheduler, CronParseError, parseCron, nextCronRun } from "./scheduler.js";
|
|
50
50
|
export type { SchedulerOptions, SchedulerLogger, TimerFns, TaskDefinition, TaskHandler, TaskRunContext, TaskErrorInfo, TaskState, CronFields, } from "./scheduler.js";
|
|
51
|
+
export { createJobQueue, createJobWorker, computeBackoffMs, jobIdempotencyKey, MemoryJobStore, JobConfigError, JobIdempotencyConflictError, JobFatalError, JobTimeoutError, } from "./jobs.js";
|
|
52
|
+
export type { Job, JobStatus, JobStore, JobQueue, JobQueueOptions, JobWorker, JobWorkerOptions, JobContext, JobHandler, JobHandlerMap, JobBackoffOptions, EnqueueOptions, EnqueueResult, MemoryJobStoreOptions, JobConfigErrorCode, } from "./jobs.js";
|
|
51
53
|
export { clientCertAuth, setClientCertificate, getClientCertificate, normalizePeerCertificate, parseForwardedClientCert, } from "./mtls.js";
|
|
52
54
|
export type { ClientCertificate, ClientCertificateSource, ClientCertAuthOptions, ClientCertHeaderConfig, PeerCertificateLike, } from "./mtls.js";
|
|
53
55
|
export { signMessage, signRequest, verifyMessage, verifyRequest, httpSignatureAuth, contentDigest, verifyContentDigest, DEFAULT_SIGNATURE_LABEL, DEFAULT_MAX_SIGNATURE_AGE_SECONDS, DEFAULT_SIGNATURE_CLOCK_SKEW_SECONDS, } from "./http-signatures.js";
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { fetchGuard, SsrfBlockedError } from "./fetch-guard.js";
|
|
|
26
26
|
export { resilientFetch, CircuitBreaker, CircuitOpenError, FetchTimeoutError, } from "./fetch-resilience.js";
|
|
27
27
|
export { createWebhookSender, MemoryWebhookDeadLetterSink } from "./webhook-delivery.js";
|
|
28
28
|
export { Scheduler, CronParseError, parseCron, nextCronRun } from "./scheduler.js";
|
|
29
|
+
export { createJobQueue, createJobWorker, computeBackoffMs, jobIdempotencyKey, MemoryJobStore, JobConfigError, JobIdempotencyConflictError, JobFatalError, JobTimeoutError, } from "./jobs.js";
|
|
29
30
|
export { clientCertAuth, setClientCertificate, getClientCertificate, normalizePeerCertificate, parseForwardedClientCert, } from "./mtls.js";
|
|
30
31
|
export { signMessage, signRequest, verifyMessage, verifyRequest, httpSignatureAuth, contentDigest, verifyContentDigest, DEFAULT_SIGNATURE_LABEL, DEFAULT_MAX_SIGNATURE_AGE_SECONDS, DEFAULT_SIGNATURE_CLOCK_SKEW_SECONDS, } from "./http-signatures.js";
|
|
31
32
|
export { autoBan, MemoryAutoBanStore, _resetAutoBanStoresForTests } from "./auto-ban.js";
|