@classytic/arc 2.2.5 → 2.4.1
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 +187 -18
- package/bin/arc.js +11 -3
- package/dist/BaseController-CkM5dUh_.mjs +1031 -0
- package/dist/{EventTransport-BkUDYZEb.d.mts → EventTransport-wc5hSLik.d.mts} +1 -1
- package/dist/{HookSystem-BsGV-j2l.mjs → HookSystem-COkyWztM.mjs} +2 -3
- package/dist/{ResourceRegistry-7Ic20ZMw.mjs → ResourceRegistry-DeCIFlix.mjs} +8 -5
- package/dist/adapters/index.d.mts +3 -5
- package/dist/adapters/index.mjs +2 -3
- package/dist/{prisma-DJbMt3yf.mjs → adapters-DTC4Ug66.mjs} +45 -12
- package/dist/audit/index.d.mts +4 -7
- package/dist/audit/index.mjs +2 -29
- package/dist/audit/mongodb.d.mts +1 -4
- package/dist/audit/mongodb.mjs +2 -3
- package/dist/auth/index.d.mts +7 -9
- package/dist/auth/index.mjs +65 -63
- package/dist/auth/redis-session.d.mts +1 -1
- package/dist/auth/redis-session.mjs +1 -2
- package/dist/{betterAuthOpenApi-DjWDddNc.mjs → betterAuthOpenApi-lz0IRbXJ.mjs} +4 -6
- package/dist/cache/index.d.mts +23 -23
- package/dist/cache/index.mjs +4 -6
- package/dist/{caching-GSDJcA6-.mjs → caching-BSXB-Xr7.mjs} +2 -24
- package/dist/chunk-BpYLSNr0.mjs +14 -0
- package/dist/circuitBreaker-BOBOpN2w.mjs +284 -0
- package/dist/circuitBreaker-JP2GdJ4b.d.mts +206 -0
- package/dist/cli/commands/describe.mjs +24 -7
- package/dist/cli/commands/docs.mjs +6 -7
- package/dist/cli/commands/doctor.d.mts +10 -0
- package/dist/cli/commands/doctor.mjs +156 -0
- package/dist/cli/commands/generate.mjs +66 -17
- package/dist/cli/commands/init.mjs +315 -45
- package/dist/cli/commands/introspect.mjs +2 -4
- package/dist/cli/index.d.mts +1 -10
- package/dist/cli/index.mjs +4 -153
- package/dist/{constants-DdXFXQtN.mjs → constants-Cxde4rpC.mjs} +1 -2
- package/dist/core/index.d.mts +3 -5
- package/dist/core/index.mjs +5 -4
- package/dist/core-C1XCMtqM.mjs +185 -0
- package/dist/{createApp-BKHSl2nT.mjs → createApp-ByWNRsZj.mjs} +65 -36
- package/dist/{defineResource-DO9ONe_D.mjs → defineResource-D9aY5Cy6.mjs} +154 -1165
- package/dist/discovery/index.mjs +37 -5
- package/dist/docs/index.d.mts +6 -9
- package/dist/docs/index.mjs +3 -21
- package/dist/dynamic/index.d.mts +93 -0
- package/dist/dynamic/index.mjs +122 -0
- package/dist/{elevation-DSTbVvYj.mjs → elevation-BEdACOLB.mjs} +5 -36
- package/dist/{elevation-DGo5shaX.d.mts → elevation-Ca_yveIO.d.mts} +41 -7
- package/dist/{errorHandler-C3GY3_ow.mjs → errorHandler--zp54tGc.mjs} +3 -5
- package/dist/errorHandler-Do4vVQ1f.d.mts +139 -0
- package/dist/{errors-DBANPbGr.mjs → errors-rxhfP7Hf.mjs} +1 -2
- package/dist/{eventPlugin-BEOvaDqo.mjs → eventPlugin-Ba00swHF.mjs} +25 -27
- package/dist/{eventPlugin-H6wDDjGO.d.mts → eventPlugin-iGrSEmwJ.d.mts} +105 -5
- package/dist/events/index.d.mts +72 -7
- package/dist/events/index.mjs +216 -4
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +19 -7
- package/dist/events/transports/redis.d.mts +1 -1
- package/dist/events/transports/redis.mjs +3 -4
- package/dist/factory/index.d.mts +23 -9
- package/dist/factory/index.mjs +48 -3
- package/dist/{fields-Bi_AVKSo.d.mts → fields-DFwdaWCq.d.mts} +1 -1
- package/dist/{fields-CTd_CrKr.mjs → fields-ipsbIRPK.mjs} +1 -2
- package/dist/hooks/index.d.mts +1 -3
- package/dist/hooks/index.mjs +2 -3
- package/dist/idempotency/index.d.mts +5 -5
- package/dist/idempotency/index.mjs +3 -7
- package/dist/idempotency/mongodb.d.mts +1 -1
- package/dist/idempotency/mongodb.mjs +4 -5
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +2 -5
- package/dist/{fastifyAdapter-CyAA2zlB.d.mts → index-BL8CaQih.d.mts} +56 -57
- package/dist/index-Diqcm14c.d.mts +369 -0
- package/dist/{prisma-xjhMEq_S.d.mts → index-yhxyjqNb.d.mts} +4 -5
- package/dist/index.d.mts +100 -105
- package/dist/index.mjs +85 -58
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +8 -4
- package/dist/integrations/index.d.mts +4 -2
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs.d.mts +2 -2
- package/dist/integrations/jobs.mjs +63 -14
- package/dist/integrations/mcp/index.d.mts +219 -0
- package/dist/integrations/mcp/index.mjs +572 -0
- package/dist/integrations/mcp/testing.d.mts +53 -0
- package/dist/integrations/mcp/testing.mjs +104 -0
- package/dist/integrations/streamline.mjs +39 -19
- package/dist/integrations/webhooks.d.mts +56 -0
- package/dist/integrations/webhooks.mjs +139 -0
- package/dist/integrations/websocket-redis.d.mts +46 -0
- package/dist/integrations/websocket-redis.mjs +50 -0
- package/dist/integrations/websocket.d.mts +68 -2
- package/dist/integrations/websocket.mjs +96 -13
- package/dist/{interface-CSNjltAc.d.mts → interface-B4awm1RJ.d.mts} +2 -2
- package/dist/interface-DGmPxakH.d.mts +2213 -0
- package/dist/{keys-DhqDRxv3.mjs → keys-qcD-TVJl.mjs} +3 -4
- package/dist/{logger-ByrvQWZO.mjs → logger-Dz3j1ItV.mjs} +2 -4
- package/dist/{memory-B2v7KrCB.mjs → memory-Cb_7iy9e.mjs} +2 -4
- package/dist/metrics-Csh4nsvv.mjs +224 -0
- package/dist/migrations/index.mjs +3 -7
- package/dist/{mongodb-DNKEExbf.mjs → mongodb-BuQ7fNTg.mjs} +1 -4
- package/dist/{mongodb-ClykrfGo.d.mts → mongodb-CUpYfxfD.d.mts} +2 -3
- package/dist/{mongodb-Dg8O_gvd.d.mts → mongodb-bga9AbkD.d.mts} +2 -2
- package/dist/{openapi-9nB_kiuR.mjs → openapi-CBmZ6EQN.mjs} +4 -21
- package/dist/org/index.d.mts +12 -14
- package/dist/org/index.mjs +92 -119
- package/dist/org/types.d.mts +2 -2
- package/dist/org/types.mjs +1 -1
- package/dist/permissions/index.d.mts +4 -278
- package/dist/permissions/index.mjs +4 -579
- package/dist/permissions-CA5zg0yK.mjs +751 -0
- package/dist/plugins/index.d.mts +104 -107
- package/dist/plugins/index.mjs +203 -313
- package/dist/plugins/response-cache.mjs +4 -69
- package/dist/plugins/tracing-entry.d.mts +1 -1
- package/dist/plugins/tracing-entry.mjs +24 -11
- package/dist/{pluralize-CM-jZg7p.mjs → pluralize-CcT6qF0a.mjs} +12 -13
- package/dist/policies/index.d.mts +2 -2
- package/dist/policies/index.mjs +80 -83
- package/dist/presets/index.d.mts +26 -19
- package/dist/presets/index.mjs +2 -142
- package/dist/presets/multiTenant.d.mts +1 -4
- package/dist/presets/multiTenant.mjs +4 -6
- package/dist/presets-C9QXJV1u.mjs +422 -0
- package/dist/{queryCachePlugin-B6R0d4av.mjs → queryCachePlugin-ClosZdNS.mjs} +6 -27
- package/dist/{queryCachePlugin-Q6SYuHZ6.d.mts → queryCachePlugin-DcmETvcB.d.mts} +3 -3
- package/dist/queryParser-CgCtsjti.mjs +352 -0
- package/dist/{redis-UwjEp8Ea.d.mts → redis-CQ5YxMC5.d.mts} +2 -2
- package/dist/{redis-stream-CBg0upHI.d.mts → redis-stream-BW9UKLZM.d.mts} +9 -2
- package/dist/registry/index.d.mts +1 -4
- package/dist/registry/index.mjs +3 -4
- package/dist/{introspectionPlugin-B3JkrjwU.mjs → registry-I-ogLgL9.mjs} +1 -8
- package/dist/{requestContext-xi6OKBL-.mjs → requestContext-DYtmNpm5.mjs} +1 -3
- package/dist/resourceToTools-B6ZN9Ing.mjs +489 -0
- package/dist/rpc/index.d.mts +90 -0
- package/dist/rpc/index.mjs +248 -0
- package/dist/{schemaConverter-Dtg0Kt9T.mjs → schemaConverter-DjzHpFam.mjs} +1 -2
- package/dist/schemas/index.d.mts +30 -30
- package/dist/schemas/index.mjs +4 -6
- package/dist/scope/index.d.mts +13 -2
- package/dist/scope/index.mjs +18 -5
- package/dist/{sessionManager-D_iEHjQl.d.mts → sessionManager-wbkYj2HL.d.mts} +2 -2
- package/dist/{sse-DkqQ1uxb.mjs → sse-BkViJPlT.mjs} +4 -25
- package/dist/testing/index.d.mts +551 -567
- package/dist/testing/index.mjs +1744 -1799
- package/dist/{tracing-8CEbhF0w.d.mts → tracing-bz_U4EM1.d.mts} +6 -1
- package/dist/{typeGuards-DwxA1t_L.mjs → typeGuards-Cj5Rgvlg.mjs} +1 -2
- package/dist/types/index.d.mts +4 -946
- package/dist/types/index.mjs +2 -4
- package/dist/types-BJmgxNbF.d.mts +275 -0
- package/dist/{types-RLkFVgaw.d.mts → types-BNUccdcf.d.mts} +2 -2
- package/dist/{types-Beqn1Un7.mjs → types-C6TQjtdi.mjs} +30 -2
- package/dist/{types-DMSBMkaZ.d.mts → types-Dt0-AI6E.d.mts} +85 -27
- package/dist/{types-DelU6kln.mjs → types-ZUu_h0jp.mjs} +1 -2
- package/dist/utils/index.d.mts +255 -352
- package/dist/utils/index.mjs +7 -6
- package/dist/utils-Dc0WhlIl.mjs +594 -0
- package/dist/versioning-BzfeHmhj.mjs +37 -0
- package/package.json +46 -12
- package/skills/arc/SKILL.md +506 -0
- package/skills/arc/references/auth.md +250 -0
- package/skills/arc/references/events.md +272 -0
- package/skills/arc/references/integrations.md +385 -0
- package/skills/arc/references/mcp.md +386 -0
- package/skills/arc/references/production.md +610 -0
- package/skills/arc/references/testing.md +183 -0
- package/dist/audited-CGdLiSlE.mjs +0 -140
- package/dist/chunk-C7Uep-_p.mjs +0 -20
- package/dist/circuitBreaker-DYhWBW_D.mjs +0 -1096
- package/dist/errorHandler-CW3OOeYq.d.mts +0 -72
- package/dist/interface-DZYNK9bb.d.mts +0 -1112
- package/dist/presets-BTeYbw7h.d.mts +0 -57
- package/dist/presets-CeFtfDR8.mjs +0 -119
- /package/dist/{errors-DAWRdiYP.d.mts → errors-CPpvPHT0.d.mts} +0 -0
- /package/dist/{externalPaths-SyPF2tgK.d.mts → externalPaths-DpO-s7r8.d.mts} +0 -0
- /package/dist/{interface-DTbsvIWe.d.mts → interface-D_BWALyZ.d.mts} +0 -0
|
@@ -52,7 +52,7 @@ var RedisEventTransport = class {
|
|
|
52
52
|
if (this.isGlob(redisPattern)) await this.sub.psubscribe(redisPattern);
|
|
53
53
|
else await this.sub.subscribe(redisPattern);
|
|
54
54
|
}
|
|
55
|
-
this.handlers.get(redisPattern)
|
|
55
|
+
this.handlers.get(redisPattern)?.add(handler);
|
|
56
56
|
return () => {
|
|
57
57
|
const set = this.handlers.get(redisPattern);
|
|
58
58
|
if (set) set.delete(handler);
|
|
@@ -92,7 +92,7 @@ var RedisEventTransport = class {
|
|
|
92
92
|
}
|
|
93
93
|
for (const handler of handlers) try {
|
|
94
94
|
const result = handler(event);
|
|
95
|
-
if (result && typeof result
|
|
95
|
+
if (result && typeof result === "object" && "catch" in result) result.catch((err) => {
|
|
96
96
|
this.logger.error(`[RedisEventTransport] Handler error for ${event.type}:`, err);
|
|
97
97
|
});
|
|
98
98
|
} catch (err) {
|
|
@@ -119,6 +119,5 @@ var RedisEventTransport = class {
|
|
|
119
119
|
return pattern.includes("*") || pattern.includes("?") || pattern.includes("[");
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
-
|
|
123
122
|
//#endregion
|
|
124
|
-
export { RedisEventTransport, RedisEventTransport as default };
|
|
123
|
+
export { RedisEventTransport, RedisEventTransport as default };
|
package/dist/factory/index.d.mts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import "../interface-DZYNK9bb.mjs";
|
|
3
|
-
import "../types-RLkFVgaw.mjs";
|
|
4
|
-
import "../queryCachePlugin-Q6SYuHZ6.mjs";
|
|
5
|
-
import "../eventPlugin-H6wDDjGO.mjs";
|
|
6
|
-
import "../errorHandler-CW3OOeYq.mjs";
|
|
7
|
-
import { a as CustomPluginAuthOption, c as RawBodyOptions, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption } from "../types-DMSBMkaZ.mjs";
|
|
1
|
+
import { a as CustomPluginAuthOption, c as RawBodyOptions, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption } from "../types-Dt0-AI6E.mjs";
|
|
8
2
|
import { FastifyInstance } from "fastify";
|
|
9
3
|
|
|
10
4
|
//#region src/factory/createApp.d.ts
|
|
@@ -42,6 +36,26 @@ declare const ArcFactory: {
|
|
|
42
36
|
testing(options: Omit<CreateAppOptions, "preset">): Promise<FastifyInstance>;
|
|
43
37
|
};
|
|
44
38
|
//#endregion
|
|
39
|
+
//#region src/factory/edge.d.ts
|
|
40
|
+
interface FetchHandlerOptions {
|
|
41
|
+
/**
|
|
42
|
+
* Whether to call `app.ready()` on the first request.
|
|
43
|
+
* Set to `false` if you've already called it during module init.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoReady?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert a Fastify app into a Web Standards fetch handler.
|
|
50
|
+
*
|
|
51
|
+
* The returned function accepts a Web Standard `Request` and returns
|
|
52
|
+
* a Web Standard `Response` — the universal serverless/edge contract.
|
|
53
|
+
*
|
|
54
|
+
* Internally uses `app.inject()` which processes the request through
|
|
55
|
+
* the full Fastify pipeline (hooks, plugins, routes) without TCP.
|
|
56
|
+
*/
|
|
57
|
+
declare function toFetchHandler(app: FastifyInstance, options?: FetchHandlerOptions): (request: Request) => Promise<Response>;
|
|
58
|
+
//#endregion
|
|
45
59
|
//#region src/factory/presets.d.ts
|
|
46
60
|
/**
|
|
47
61
|
* Production preset - strict security, performance optimized
|
|
@@ -58,6 +72,6 @@ declare const testingPreset: Partial<CreateAppOptions>;
|
|
|
58
72
|
/**
|
|
59
73
|
* Get preset by name
|
|
60
74
|
*/
|
|
61
|
-
declare function getPreset(name:
|
|
75
|
+
declare function getPreset(name: "production" | "development" | "testing" | "edge"): Partial<CreateAppOptions>;
|
|
62
76
|
//#endregion
|
|
63
|
-
export { ArcFactory, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, type JwtAuthOption, type MultipartOptions, type RawBodyOptions, type UnderPressureOptions, createApp, developmentPreset, getPreset, productionPreset, testingPreset };
|
|
77
|
+
export { ArcFactory, type AuthOption, type BetterAuthOption, type CreateAppOptions, type CustomAuthenticatorOption, type CustomPluginAuthOption, type FetchHandlerOptions, type JwtAuthOption, type MultipartOptions, type RawBodyOptions, type UnderPressureOptions, createApp, developmentPreset, getPreset, productionPreset, testingPreset, toFetchHandler };
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
import { a as getPreset, i as developmentPreset, n as createApp, o as productionPreset, s as testingPreset, t as ArcFactory } from "../createApp-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { a as getPreset, i as developmentPreset, n as createApp, o as productionPreset, s as testingPreset, t as ArcFactory } from "../createApp-ByWNRsZj.mjs";
|
|
2
|
+
//#region src/factory/edge.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert a Fastify app into a Web Standards fetch handler.
|
|
5
|
+
*
|
|
6
|
+
* The returned function accepts a Web Standard `Request` and returns
|
|
7
|
+
* a Web Standard `Response` — the universal serverless/edge contract.
|
|
8
|
+
*
|
|
9
|
+
* Internally uses `app.inject()` which processes the request through
|
|
10
|
+
* the full Fastify pipeline (hooks, plugins, routes) without TCP.
|
|
11
|
+
*/
|
|
12
|
+
function toFetchHandler(app, options = {}) {
|
|
13
|
+
const { autoReady = true } = options;
|
|
14
|
+
let ready = false;
|
|
15
|
+
return async (request) => {
|
|
16
|
+
if (autoReady && !ready) {
|
|
17
|
+
await app.ready();
|
|
18
|
+
ready = true;
|
|
19
|
+
}
|
|
20
|
+
const url = new URL(request.url);
|
|
21
|
+
const headers = {};
|
|
22
|
+
request.headers.forEach((value, key) => {
|
|
23
|
+
headers[key] = value;
|
|
24
|
+
});
|
|
25
|
+
let payload;
|
|
26
|
+
if (request.method !== "GET" && request.method !== "HEAD") try {
|
|
27
|
+
payload = await request.text();
|
|
28
|
+
} catch {}
|
|
29
|
+
const response = await app.inject({
|
|
30
|
+
method: request.method,
|
|
31
|
+
url: url.pathname + url.search,
|
|
32
|
+
headers,
|
|
33
|
+
...payload ? { payload } : {}
|
|
34
|
+
});
|
|
35
|
+
const responseHeaders = new Headers();
|
|
36
|
+
for (const [key, value] of Object.entries(response.headers)) {
|
|
37
|
+
if (value === void 0) continue;
|
|
38
|
+
if (Array.isArray(value)) for (const v of value) responseHeaders.append(key, v);
|
|
39
|
+
else responseHeaders.set(key, String(value));
|
|
40
|
+
}
|
|
41
|
+
return new Response(response.payload, {
|
|
42
|
+
status: response.statusCode,
|
|
43
|
+
headers: responseHeaders
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { ArcFactory, createApp, developmentPreset, getPreset, productionPreset, testingPreset, toFetchHandler };
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
type FieldPermissionType =
|
|
24
|
+
type FieldPermissionType = "hidden" | "visibleTo" | "writableBy" | "redactFor";
|
|
25
25
|
interface FieldPermission {
|
|
26
26
|
readonly _type: FieldPermissionType;
|
|
27
27
|
readonly roles?: readonly string[];
|
|
@@ -109,6 +109,5 @@ function resolveEffectiveRoles(userRoles, orgRoles) {
|
|
|
109
109
|
if (userRoles.length === 0) return [...orgRoles];
|
|
110
110
|
return [...new Set([...userRoles, ...orgRoles])];
|
|
111
111
|
}
|
|
112
|
-
|
|
113
112
|
//#endregion
|
|
114
|
-
export { resolveEffectiveRoles as i, applyFieldWritePermissions as n, fields as r, applyFieldReadPermissions as t };
|
|
113
|
+
export { resolveEffectiveRoles as i, applyFieldWritePermissions as n, fields as r, applyFieldReadPermissions as t };
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { $ as beforeUpdate, B as DefineHookOptions, G as HookRegistration, H as HookHandler, J as afterCreate, K as HookSystem, Q as beforeDelete, U as HookOperation, V as HookContext, W as HookPhase, X as afterUpdate, Y as afterDelete, Z as beforeCreate, et as createHookSystem, q as HookSystemOptions, tt as defineHook } from "../interface-DZYNK9bb.mjs";
|
|
3
|
-
import "../types-RLkFVgaw.mjs";
|
|
1
|
+
import { $t as HookContext, Qt as DefineHookOptions, an as HookSystemOptions, cn as afterUpdate, dn as beforeUpdate, en as HookHandler, fn as createHookSystem, in as HookSystem, ln as beforeCreate, nn as HookPhase, on as afterCreate, pn as defineHook, rn as HookRegistration, sn as afterDelete, tn as HookOperation, un as beforeDelete } from "../interface-DGmPxakH.mjs";
|
|
4
2
|
export { type DefineHookOptions, type HookContext, type HookHandler, type HookOperation, type HookPhase, type HookRegistration, HookSystem, type HookSystemOptions, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-
|
|
2
|
-
|
|
3
|
-
export { HookSystem, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
|
1
|
+
import { a as beforeCreate, c as createHookSystem, i as afterUpdate, l as defineHook, n as afterCreate, o as beforeDelete, r as afterDelete, s as beforeUpdate, t as HookSystem } from "../HookSystem-COkyWztM.mjs";
|
|
2
|
+
export { HookSystem, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-B4awm1RJ.mjs";
|
|
2
|
+
import { n as MongoIdempotencyStoreOptions } from "../mongodb-bga9AbkD.mjs";
|
|
3
|
+
import { r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-CQ5YxMC5.mjs";
|
|
4
4
|
import { FastifyPluginAsync } from "fastify";
|
|
5
5
|
|
|
6
6
|
//#region src/idempotency/idempotencyPlugin.d.ts
|
|
@@ -24,7 +24,7 @@ interface IdempotencyPluginOptions {
|
|
|
24
24
|
/** Retry-After header value in seconds when request is in-flight (default: 1) */
|
|
25
25
|
retryAfterSeconds?: number;
|
|
26
26
|
}
|
|
27
|
-
declare module
|
|
27
|
+
declare module "fastify" {
|
|
28
28
|
interface FastifyRequest {
|
|
29
29
|
/** The idempotency key for this request (if present) */
|
|
30
30
|
idempotencyKey?: string;
|
|
@@ -76,7 +76,7 @@ declare class MemoryIdempotencyStore implements IdempotencyStore {
|
|
|
76
76
|
private cleanupInterval;
|
|
77
77
|
constructor(options?: MemoryIdempotencyStoreOptions);
|
|
78
78
|
get(key: string): Promise<IdempotencyResult | undefined>;
|
|
79
|
-
set(key: string, result: Omit<IdempotencyResult,
|
|
79
|
+
set(key: string, result: Omit<IdempotencyResult, "key">): Promise<void>;
|
|
80
80
|
tryLock(key: string, requestId: string, ttlMs: number): Promise<boolean>;
|
|
81
81
|
unlock(key: string, requestId: string): Promise<void>;
|
|
82
82
|
isLocked(key: string): Promise<boolean>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import fp from "fastify-plugin";
|
|
2
|
-
import { createHash } from "crypto";
|
|
3
|
-
|
|
4
3
|
//#region src/idempotency/stores/interface.ts
|
|
5
4
|
/**
|
|
6
5
|
* Helper to create a result object
|
|
@@ -15,7 +14,6 @@ function createIdempotencyResult(statusCode, body, headers, ttlMs) {
|
|
|
15
14
|
expiresAt: new Date(now.getTime() + ttlMs)
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
//#endregion
|
|
20
18
|
//#region src/idempotency/stores/memory.ts
|
|
21
19
|
var MemoryIdempotencyStore = class {
|
|
@@ -127,7 +125,6 @@ var MemoryIdempotencyStore = class {
|
|
|
127
125
|
}
|
|
128
126
|
}
|
|
129
127
|
};
|
|
130
|
-
|
|
131
128
|
//#endregion
|
|
132
129
|
//#region src/idempotency/idempotencyPlugin.ts
|
|
133
130
|
/**
|
|
@@ -224,7 +221,7 @@ const idempotencyPlugin = async (fastify, opts = {}) => {
|
|
|
224
221
|
const normalized = normalizeBody(request.body);
|
|
225
222
|
const bodyString = JSON.stringify(normalized);
|
|
226
223
|
bodyHash = createHash("sha256").update(bodyString).digest("hex").substring(0, 16);
|
|
227
|
-
if (request.log
|
|
224
|
+
if (request.log?.debug) request.log.debug({ bodyHash }, "Generated body hash");
|
|
228
225
|
}
|
|
229
226
|
const user = request.user;
|
|
230
227
|
const userId = user?.id ?? user?._id ?? "anon";
|
|
@@ -314,6 +311,5 @@ var idempotencyPlugin_default = fp(idempotencyPlugin, {
|
|
|
314
311
|
name: "arc-idempotency",
|
|
315
312
|
fastify: "5.x"
|
|
316
313
|
});
|
|
317
|
-
|
|
318
314
|
//#endregion
|
|
319
|
-
export { MemoryIdempotencyStore, createIdempotencyResult, idempotencyPlugin_default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn };
|
|
315
|
+
export { MemoryIdempotencyStore, createIdempotencyResult, idempotencyPlugin_default as idempotencyPlugin, idempotencyPlugin as idempotencyPluginFn };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-
|
|
1
|
+
import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-bga9AbkD.mjs";
|
|
2
2
|
export { MongoIdempotencyStore, type MongoIdempotencyStoreOptions };
|
|
@@ -27,7 +27,7 @@ var MongoIdempotencyStore = class {
|
|
|
27
27
|
}
|
|
28
28
|
async get(key) {
|
|
29
29
|
const doc = await this.collection.findOne({ _id: key });
|
|
30
|
-
if (!doc
|
|
30
|
+
if (!doc?.result) return void 0;
|
|
31
31
|
if (new Date(doc.expiresAt) < /* @__PURE__ */ new Date()) return;
|
|
32
32
|
return {
|
|
33
33
|
key,
|
|
@@ -82,7 +82,7 @@ var MongoIdempotencyStore = class {
|
|
|
82
82
|
}
|
|
83
83
|
async isLocked(key) {
|
|
84
84
|
const doc = await this.collection.findOne({ _id: key });
|
|
85
|
-
if (!doc
|
|
85
|
+
if (!doc?.lock) return false;
|
|
86
86
|
return new Date(doc.lock.expiresAt) > /* @__PURE__ */ new Date();
|
|
87
87
|
}
|
|
88
88
|
async delete(key) {
|
|
@@ -97,7 +97,7 @@ var MongoIdempotencyStore = class {
|
|
|
97
97
|
result: { $exists: true },
|
|
98
98
|
expiresAt: { $gt: /* @__PURE__ */ new Date() }
|
|
99
99
|
});
|
|
100
|
-
if (!doc
|
|
100
|
+
if (!doc?.result) return void 0;
|
|
101
101
|
return {
|
|
102
102
|
key: doc._id,
|
|
103
103
|
statusCode: doc.result.statusCode,
|
|
@@ -109,6 +109,5 @@ var MongoIdempotencyStore = class {
|
|
|
109
109
|
}
|
|
110
110
|
async close() {}
|
|
111
111
|
};
|
|
112
|
-
|
|
113
112
|
//#endregion
|
|
114
|
-
export { MongoIdempotencyStore };
|
|
113
|
+
export { MongoIdempotencyStore };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-
|
|
1
|
+
import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-CQ5YxMC5.mjs";
|
|
2
2
|
export { type RedisClient, RedisIdempotencyStore, type RedisIdempotencyStoreOptions };
|
|
@@ -79,9 +79,7 @@ var RedisIdempotencyStore = class {
|
|
|
79
79
|
createdAt: new Date(result.createdAt),
|
|
80
80
|
expiresAt: new Date(result.expiresAt)
|
|
81
81
|
};
|
|
82
|
-
} catch {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
82
|
+
} catch {}
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
/** Scan Redis keys matching a prefix pattern. Falls back to empty if SCAN unavailable. */
|
|
@@ -98,6 +96,5 @@ var RedisIdempotencyStore = class {
|
|
|
98
96
|
}
|
|
99
97
|
async close() {}
|
|
100
98
|
};
|
|
101
|
-
|
|
102
99
|
//#endregion
|
|
103
|
-
export { RedisIdempotencyStore };
|
|
100
|
+
export { RedisIdempotencyStore };
|
|
@@ -1,23 +1,56 @@
|
|
|
1
|
-
import { s as RequestScope } from "./elevation-
|
|
2
|
-
import {
|
|
3
|
-
import { t as PermissionCheck } from "./types-
|
|
4
|
-
import { CrudController, CrudRouterOptions, FastifyWithDecorators, RequestContext, RequestWithExtras } from "./types/index.mjs";
|
|
1
|
+
import { s as RequestScope } from "./elevation-Ca_yveIO.mjs";
|
|
2
|
+
import { D as FastifyWithDecorators, Mt as IControllerResponse, Nt as IRequestContext, et as RequestContext, jt as IController, nt as RequestWithExtras, x as CrudRouterOptions, y as CrudController } from "./interface-DGmPxakH.mjs";
|
|
3
|
+
import { t as PermissionCheck } from "./types-BNUccdcf.mjs";
|
|
5
4
|
import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
|
|
6
5
|
|
|
7
|
-
//#region src/
|
|
6
|
+
//#region src/constants.d.ts
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* Arc Framework Constants — Single Source of Truth
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Every default value, magic string, and framework constant lives here.
|
|
11
|
+
* Import from this module instead of hard-coding values inline.
|
|
12
|
+
*
|
|
13
|
+
* All exported values are deeply frozen (Object.freeze) to prevent
|
|
14
|
+
* accidental mutation at runtime — inspired by Go's const blocks
|
|
15
|
+
* and Rust's immutable-by-default philosophy.
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
/** Standard CRUD operation names */
|
|
18
|
+
declare const CRUD_OPERATIONS: readonly ["list", "get", "create", "update", "delete"];
|
|
19
|
+
type CrudOperation = (typeof CRUD_OPERATIONS)[number];
|
|
20
|
+
/** Mutation operations that emit events */
|
|
21
|
+
declare const MUTATION_OPERATIONS: readonly ["create", "update", "delete"];
|
|
22
|
+
type MutationOperation = (typeof MUTATION_OPERATIONS)[number];
|
|
23
|
+
/** Lifecycle hook phases */
|
|
24
|
+
declare const HOOK_PHASES: readonly ["before", "around", "after"];
|
|
25
|
+
type HookPhase = (typeof HOOK_PHASES)[number];
|
|
26
|
+
/** Hook operations (superset of CRUD — includes 'read' alias for 'get') */
|
|
27
|
+
declare const HOOK_OPERATIONS: readonly ["create", "update", "delete", "read", "list"];
|
|
28
|
+
type HookOperation = (typeof HOOK_OPERATIONS)[number];
|
|
29
|
+
/** Default items per page */
|
|
30
|
+
declare const DEFAULT_LIMIT: 20;
|
|
31
|
+
/** Maximum items per page (framework-wide ceiling) */
|
|
32
|
+
declare const DEFAULT_MAX_LIMIT: 1000;
|
|
33
|
+
/** Default sort field (descending creation date) */
|
|
34
|
+
declare const DEFAULT_SORT: "-createdAt";
|
|
35
|
+
/** Default primary key field name */
|
|
36
|
+
declare const DEFAULT_ID_FIELD: "_id";
|
|
37
|
+
/** Default multi-tenant scoping field */
|
|
38
|
+
declare const DEFAULT_TENANT_FIELD: "organizationId";
|
|
39
|
+
/** Default HTTP method for update routes */
|
|
40
|
+
declare const DEFAULT_UPDATE_METHOD: "PATCH";
|
|
41
|
+
/** System-managed fields that cannot be set via request body */
|
|
42
|
+
declare const SYSTEM_FIELDS: readonly ["_id", "__v", "createdAt", "updatedAt", "deletedAt"];
|
|
43
|
+
/** Maximum regex pattern length (ReDoS mitigation) */
|
|
44
|
+
declare const MAX_REGEX_LENGTH: 200;
|
|
45
|
+
/** Maximum search query length */
|
|
46
|
+
declare const MAX_SEARCH_LENGTH: 200;
|
|
47
|
+
/** Maximum filter nesting depth (prevents filter bombs) */
|
|
48
|
+
declare const MAX_FILTER_DEPTH: 10;
|
|
16
49
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
50
|
+
* Query parameters consumed by the framework — never treated as filters.
|
|
51
|
+
* Shared by all query parsers (Arc built-in, Prisma, custom).
|
|
19
52
|
*/
|
|
20
|
-
declare
|
|
53
|
+
declare const RESERVED_QUERY_PARAMS: Readonly<Set<string>>;
|
|
21
54
|
//#endregion
|
|
22
55
|
//#region src/core/createActionRouter.d.ts
|
|
23
56
|
/**
|
|
@@ -96,54 +129,20 @@ interface IdempotencyService {
|
|
|
96
129
|
*/
|
|
97
130
|
declare function createActionRouter(fastify: FastifyInstance, config: ActionRouterConfig): void;
|
|
98
131
|
//#endregion
|
|
99
|
-
//#region src/
|
|
132
|
+
//#region src/core/createCrudRouter.d.ts
|
|
100
133
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Every default value, magic string, and framework constant lives here.
|
|
104
|
-
* Import from this module instead of hard-coding values inline.
|
|
134
|
+
* Create CRUD routes for a controller
|
|
105
135
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
136
|
+
* @param fastify - Fastify instance with Arc decorators
|
|
137
|
+
* @param controller - CRUD controller with handler methods
|
|
138
|
+
* @param options - Router configuration
|
|
109
139
|
*/
|
|
110
|
-
|
|
111
|
-
declare const CRUD_OPERATIONS: readonly ["list", "get", "create", "update", "delete"];
|
|
112
|
-
type CrudOperation = (typeof CRUD_OPERATIONS)[number];
|
|
113
|
-
/** Mutation operations that emit events */
|
|
114
|
-
declare const MUTATION_OPERATIONS: readonly ["create", "update", "delete"];
|
|
115
|
-
type MutationOperation = (typeof MUTATION_OPERATIONS)[number];
|
|
116
|
-
/** Lifecycle hook phases */
|
|
117
|
-
declare const HOOK_PHASES: readonly ["before", "around", "after"];
|
|
118
|
-
type HookPhase = (typeof HOOK_PHASES)[number];
|
|
119
|
-
/** Hook operations (superset of CRUD — includes 'read' alias for 'get') */
|
|
120
|
-
declare const HOOK_OPERATIONS: readonly ["create", "update", "delete", "read", "list"];
|
|
121
|
-
type HookOperation = (typeof HOOK_OPERATIONS)[number];
|
|
122
|
-
/** Default items per page */
|
|
123
|
-
declare const DEFAULT_LIMIT: 20;
|
|
124
|
-
/** Maximum items per page (framework-wide ceiling) */
|
|
125
|
-
declare const DEFAULT_MAX_LIMIT: 1000;
|
|
126
|
-
/** Default sort field (descending creation date) */
|
|
127
|
-
declare const DEFAULT_SORT: "-createdAt";
|
|
128
|
-
/** Default primary key field name */
|
|
129
|
-
declare const DEFAULT_ID_FIELD: "_id";
|
|
130
|
-
/** Default multi-tenant scoping field */
|
|
131
|
-
declare const DEFAULT_TENANT_FIELD: "organizationId";
|
|
132
|
-
/** Default HTTP method for update routes */
|
|
133
|
-
declare const DEFAULT_UPDATE_METHOD: "PATCH";
|
|
134
|
-
/** System-managed fields that cannot be set via request body */
|
|
135
|
-
declare const SYSTEM_FIELDS: readonly ["_id", "__v", "createdAt", "updatedAt", "deletedAt"];
|
|
136
|
-
/** Maximum regex pattern length (ReDoS mitigation) */
|
|
137
|
-
declare const MAX_REGEX_LENGTH: 200;
|
|
138
|
-
/** Maximum search query length */
|
|
139
|
-
declare const MAX_SEARCH_LENGTH: 200;
|
|
140
|
-
/** Maximum filter nesting depth (prevents filter bombs) */
|
|
141
|
-
declare const MAX_FILTER_DEPTH: 10;
|
|
140
|
+
declare function createCrudRouter<TDoc = unknown>(fastify: FastifyWithDecorators, controller: CrudController<TDoc> | undefined, options?: CrudRouterOptions): void;
|
|
142
141
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
142
|
+
* Create permission middleware from PermissionCheck
|
|
143
|
+
* Useful for custom route registration
|
|
145
144
|
*/
|
|
146
|
-
declare
|
|
145
|
+
declare function createPermissionMiddleware(permission: PermissionCheck, resourceName: string, action: string): RouteHandlerMethod | null;
|
|
147
146
|
//#endregion
|
|
148
147
|
//#region src/core/fastifyAdapter.d.ts
|
|
149
148
|
/**
|
|
@@ -213,4 +212,4 @@ declare function createCrudHandlers<TDoc>(controller: IController<TDoc>): {
|
|
|
213
212
|
delete: (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
214
213
|
};
|
|
215
214
|
//#endregion
|
|
216
|
-
export {
|
|
215
|
+
export { RESERVED_QUERY_PARAMS as A, HookOperation as C, MAX_SEARCH_LENGTH as D, MAX_REGEX_LENGTH as E, MUTATION_OPERATIONS as O, HOOK_PHASES as S, MAX_FILTER_DEPTH as T, DEFAULT_MAX_LIMIT as _, getControllerScope as a, DEFAULT_UPDATE_METHOD as b, createPermissionMiddleware as c, IdempotencyService as d, createActionRouter as f, DEFAULT_LIMIT as g, DEFAULT_ID_FIELD as h, getControllerContext as i, SYSTEM_FIELDS as j, MutationOperation as k, ActionHandler as l, CrudOperation as m, createFastifyHandler as n, sendControllerResponse as o, CRUD_OPERATIONS as p, createRequestContext as r, createCrudRouter as s, createCrudHandlers as t, ActionRouterConfig as u, DEFAULT_SORT as v, HookPhase as w, HOOK_OPERATIONS as x, DEFAULT_TENANT_FIELD as y };
|