@classytic/arc 2.22.0 → 2.25.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/dist/{BaseController-C6FlRWxF.mjs → BaseController--M8EMzt0.mjs} +92 -22
- package/dist/QueryCache-DOMT_iq7.d.mts +72 -0
- package/dist/{ResourceRegistry-7RnrEWNP.mjs → ResourceRegistry-y9Hnypus.mjs} +1 -0
- package/dist/actionPermissions-CAphcmUG.mjs +24 -0
- package/dist/applyPermissionResult-Tw4iXtlf.mjs +264 -0
- package/dist/audit/index.d.mts +32 -3
- package/dist/audit/index.mjs +7 -4
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +264 -260
- package/dist/{buildHandler-D_2ULWxZ.mjs → buildHandler-Dtwd8fdz.mjs} +1 -1
- package/dist/cache/index.d.mts +41 -3
- package/dist/cache/index.mjs +33 -4
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/describe.mjs +1 -1
- package/dist/cli/commands/docs.mjs +2 -2
- package/dist/cli/commands/generate.mjs +1 -1
- package/dist/cli/commands/init.mjs +1 -1
- package/dist/cli/commands/introspect.mjs +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/context/index.mjs +2 -64
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +4 -4
- package/dist/{core-b6fgFgnd.mjs → core-EUNu0u07.mjs} +298 -12
- package/dist/{createActionRouter-h1cEEaEX.mjs → createActionRouter-B6GvAuAX.mjs} +4 -3
- package/dist/{createAggregationRouter-B1C0kvTL.mjs → createAggregationRouter-wzwFa_dW.mjs} +3 -3
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +2 -2
- package/dist/{elevation-COpYKt2h.mjs → elevation-CIz1GjGm.mjs} +4 -3
- package/dist/{errorHandler-BTzXSwIg.mjs → errorHandler-Bq2OeEQL.mjs} +10 -7
- package/dist/{eventPlugin-A6EbthXR.d.mts → eventPlugin-Bg3cP2_u.d.mts} +38 -3
- package/dist/{eventPlugin-DJG2D7sy.mjs → eventPlugin-DrQ_FesK.mjs} +22 -4
- package/dist/events/index.d.mts +57 -314
- package/dist/events/index.mjs +168 -93
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +24 -2
- package/dist/factory/index.d.mts +21 -6
- package/dist/factory/index.mjs +58 -18
- package/dist/{fastify-augmentation-9_fuetB4.d.mts → fastify-augmentation-dPNBVeIj.d.mts} +25 -2
- package/dist/{generate-usRSdQmP.mjs → generate-D0wZupBg.mjs} +1 -1
- package/dist/headers-BvlQSDMB.mjs +45 -0
- package/dist/health-CB_m4S32.mjs +377 -0
- package/dist/hooks/index.d.mts +1 -1
- package/dist/idempotency/index.d.mts +7 -0
- package/dist/idempotency/index.mjs +32 -20
- package/dist/{index-ogIHvOjo.d.mts → index-BMnbzvtO.d.mts} +70 -4
- package/dist/{integrations/jobs.d.mts → index-CG4yqMDB.d.mts} +82 -2
- package/dist/{index-DbtgCOCj.d.mts → index-DPRH0Cme.d.mts} +46 -94
- package/dist/{module-B4u10iOJ.d.mts → index-KUoxjIq1.d.mts} +263 -23
- package/dist/{index-D8MKYGDa.d.mts → index-f4PTrk3B.d.mts} +37 -5
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +6 -5
- package/dist/{init-DleK3p9f.mjs → init-tlRSt667.mjs} +206 -205
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +1 -1
- package/dist/integrations/index.d.mts +3 -3
- package/dist/integrations/jobs/index.d.mts +2 -0
- package/dist/integrations/{jobs.mjs → jobs/index.mjs} +110 -67
- package/dist/integrations/mcp/index.d.mts +68 -5
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/integrations/webhooks.d.mts +149 -22
- package/dist/integrations/webhooks.mjs +186 -42
- package/dist/integrations/websocket-redis.d.mts +1 -1
- package/dist/integrations/websocket.d.mts +1 -1
- package/dist/integrations/websocket.mjs +41 -14
- package/dist/{interface-C1_WLTMK.d.mts → interface-BGZCzOGL.d.mts} +24 -31
- package/dist/interface-n5hpKg1d.mjs +16 -0
- package/dist/{loadResourcesFromEntry-OMCvIEE7.mjs → loadResourcesFromEntry-kvGT6EcO.mjs} +1 -1
- package/dist/{mcpPlugin-ByA2tf6D.mjs → mcpPlugin-Cb7olw0j.mjs} +316 -45
- package/dist/{memory-CLXA2VeJ.mjs → memory-CmnzXE5Z.mjs} +29 -0
- package/dist/middleware/index.d.mts +17 -1
- package/dist/middleware/index.mjs +1 -1
- package/dist/migrations/index.d.mts +94 -44
- package/dist/migrations/index.mjs +196 -44
- package/dist/{multipartBody-CHEQSZ6G.mjs → multipartBody-D0eBvkeq.mjs} +17 -0
- package/dist/{openapi-BRpMZD7C.mjs → openapi-DrLtog_B.mjs} +4 -4
- package/dist/permissions/index.d.mts +3 -3
- package/dist/permissions/index.mjs +4 -3
- package/dist/{permissions-BJMuKMl7.mjs → permissions-BrtiBKGs.mjs} +305 -492
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/{actionPermissions-ze70xXJi.mjs → pipeline-BN5G05rd.mjs} +4 -27
- package/dist/plugins/index.d.mts +7 -78
- package/dist/plugins/index.mjs +14 -97
- package/dist/plugins/response-cache.mjs +1 -0
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/{index-BEu4wjbL.d.mts → preloadResources-0oe-JSSS.d.mts} +59 -50
- package/dist/{createApp-Ci7yG5gv.mjs → preloadResources-DfyngIN9.mjs} +240 -68
- package/dist/presets/filesUpload.d.mts +3 -3
- package/dist/presets/filesUpload.mjs +3 -3
- package/dist/presets/index.d.mts +2 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +1 -1
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +1 -1
- package/dist/{presets-gw0ciIUD.mjs → presets-DwFDVKP0.mjs} +2 -2
- package/dist/{queryCachePlugin-DzqLN904.mjs → queryCachePlugin-DSGuSVLW.mjs} +39 -8
- package/dist/{queryCachePlugin-CfYWq-Ak.d.mts → queryCachePlugin-br4otiqF.d.mts} +2 -2
- package/dist/{registerRoute-xHc42fwB.mjs → rateLimit-DrED-C4v.mjs} +2 -109
- package/dist/realtime-Cuw_deA-.mjs +375 -0
- package/dist/{redis-stream-iVR2l7aS.d.mts → redis-stream-uIaauNpZ.d.mts} +22 -0
- package/dist/registerRoute-v0Wb6Plt.mjs +108 -0
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +1 -1
- package/dist/renewingLease-3cuQH7h8.mjs +44 -0
- package/dist/{requestContext-BZKOr13H.mjs → requestContext-MrlJwECf.mjs} +2 -2
- package/dist/schedules-CjOd2MG9.mjs +113 -0
- package/dist/{schemaConverter-Ds5reSGs.mjs → schemaConverter-DJvodiHj.mjs} +4 -1
- package/dist/{schemaIR-B-6SPe7g.mjs → schemaIR-Ca7ySNPx.mjs} +1 -1
- package/dist/schemas/index.d.mts +67 -67
- package/dist/schemas/index.mjs +2 -3
- package/dist/scim/index.mjs +1 -2
- package/dist/scope/index.d.mts +2 -2
- package/dist/scope/index.mjs +4 -4
- package/dist/scope-DfaPntpo.mjs +36 -0
- package/dist/simpleEqualityMatcher-Cg05HPsn.mjs +68 -0
- package/dist/{sse-CfUjwjDk.mjs → sse-BQ1w0dfl.mjs} +8 -31
- package/dist/sseStream-BQ7Qaynp.mjs +57 -0
- package/dist/testing/index.d.mts +4 -3
- package/dist/testing/index.mjs +2 -2
- package/dist/transactionContext-PNdoyLLm.mjs +64 -0
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-bHblZ9YN.mjs → types-CSyCxl2V.mjs} +38 -7
- package/dist/{types-DH0GupI7.d.mts → types-DjC-KUCz.d.mts} +118 -20
- package/dist/{types-Csxga7d3.d.mts → types-Dmw-6Qeo.d.mts} +96 -4
- package/dist/{types-Bc42CUyk.d.mts → types-QFGc3Cjv.d.mts} +37 -2
- package/dist/usage/index.d.mts +3 -52
- package/dist/usage/index.mjs +0 -0
- package/dist/userHelpers-Cg_y3fBz.mjs +29 -0
- package/dist/utils/index.d.mts +90 -57
- package/dist/utils/index.mjs +7 -3
- package/dist/{utils-FhJ88TJE.mjs → utils-taUVD4p3.mjs} +47 -385
- package/dist/{validate-C2mGgSXg.mjs → validate-Bk44F2yT.mjs} +1 -1
- package/dist/{versioning-DLwklPlG.d.mts → versioning-DXgY5BUm.d.mts} +52 -31
- package/dist/{versioning-Dk-71iIz.mjs → versioning-gKWyryT3.mjs} +8 -1
- package/dist/{websocket-uuWqM6UY.d.mts → websocket-_Pd0CgR0.d.mts} +15 -1
- package/package.json +526 -453
- package/skills/arc/references/api-reference.md +3 -1
- package/skills/arc/references/integrations.md +20 -11
- package/skills/arc/references/production.md +734 -696
- package/dist/QueryCache-Z1B38koh.d.mts +0 -40
- package/dist/betterAuthOpenApi-CV1lxpRX.mjs +0 -2
- package/dist/health-ScyjIVo5.mjs +0 -202
- package/dist/requestId-5BhTVzBv.mjs +0 -113
- package/dist/scope-k15RXfcq.mjs +0 -64
- package/dist/types-XTApa8b6.mjs +0 -24
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/utils/userHelpers.ts
|
|
2
|
+
/**
|
|
3
|
+
* Extract a user ID from a user object. Accepts `id` or `_id` — returns
|
|
4
|
+
* `undefined` when neither is present. Used by arc's controllers to
|
|
5
|
+
* populate `createdBy` / `updatedBy` fields and for cache scoping.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { getUserId } from '@classytic/arc/utils';
|
|
10
|
+
* const uid = getUserId(request.user);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
function getUserId(user) {
|
|
14
|
+
if (!user) return void 0;
|
|
15
|
+
const id = user.id ?? user._id;
|
|
16
|
+
return id ? String(id) : void 0;
|
|
17
|
+
}
|
|
18
|
+
/** Normalize a raw role value from Better Auth, JWT, or a custom identity provider. */
|
|
19
|
+
function normalizeRoles(value) {
|
|
20
|
+
if (Array.isArray(value)) return value.map((role) => String(role).trim()).filter(Boolean);
|
|
21
|
+
if (typeof value === "string" && value.length > 0) return value.split(",").map((role) => role.trim()).filter(Boolean);
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
/** Extract normalized roles from a user-like object. */
|
|
25
|
+
function getUserRoles(user) {
|
|
26
|
+
return user ? normalizeRoles(user.role ?? user.roles) : [];
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getUserRoles as n, normalizeRoles as r, getUserId as t };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import { $ as OpenApiSchemas,
|
|
1
|
+
import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-DPRH0Cme.mjs";
|
|
2
|
+
import { F as getHeader, I as requireSingleHeaderValue, P as ArcHeaders } from "../types-DjC-KUCz.mjs";
|
|
3
|
+
import { a as getUserId, c as AnyRecord, o as getUserRoles, s as normalizeRoles } from "../types-Dmw-6Qeo.mjs";
|
|
2
4
|
import { n as ErrorMapper } from "../errorHandler-C6yv4ZTW.mjs";
|
|
3
5
|
import { a as NotFoundError, c as RateLimitError, d as ValidationError, f as createDomainError, i as ForbiddenError, l as ServiceUnavailableError, m as isArcError, n as ConflictError, o as OrgAccessDeniedError, p as createError, r as ErrorOptions, s as OrgRequiredError, t as ArcError, u as UnauthorizedError } from "../errors-DHcHVAgk.mjs";
|
|
4
6
|
import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
|
|
7
|
+
import { scheduleBackground } from "@classytic/repo-core/cache";
|
|
5
8
|
import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
|
|
6
|
-
//#region src/core/validateResourceConfig.d.ts
|
|
7
|
-
interface ConfigError {
|
|
8
|
-
field: string;
|
|
9
|
-
message: string;
|
|
10
|
-
suggestion?: string;
|
|
11
|
-
}
|
|
12
|
-
interface ValidationResult {
|
|
13
|
-
valid: boolean;
|
|
14
|
-
errors: ConfigError[];
|
|
15
|
-
warnings: ConfigError[];
|
|
16
|
-
}
|
|
17
|
-
interface ValidateOptions {
|
|
18
|
-
/** Skip controller method validation (for testing) */
|
|
19
|
-
skipControllerCheck?: boolean;
|
|
20
|
-
/** Allow unknown preset names */
|
|
21
|
-
allowUnknownPresets?: boolean;
|
|
22
|
-
/** Custom valid permission keys beyond CRUD */
|
|
23
|
-
additionalPermissionKeys?: string[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Validate a resource configuration
|
|
27
|
-
*/
|
|
28
|
-
declare function validateResourceConfig(config: ResourceConfig, options?: ValidateOptions): ValidationResult;
|
|
29
|
-
/**
|
|
30
|
-
* Format validation errors for display
|
|
31
|
-
*/
|
|
32
|
-
declare function formatValidationErrors(resourceName: string, result: ValidationResult): string;
|
|
33
|
-
/**
|
|
34
|
-
* Validate and throw if invalid
|
|
35
|
-
*/
|
|
36
|
-
declare function assertValidConfig(config: ResourceConfig, options?: ValidateOptions): void;
|
|
37
|
-
//#endregion
|
|
38
9
|
//#region src/utils/circuitBreaker.d.ts
|
|
39
10
|
/**
|
|
40
11
|
* Circuit Breaker Pattern
|
|
@@ -103,6 +74,31 @@ interface CircuitBreakerOptions {
|
|
|
103
74
|
* @default 1
|
|
104
75
|
*/
|
|
105
76
|
successThreshold?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum concurrent probe calls allowed while HALF_OPEN.
|
|
79
|
+
* After `resetTimeout`, only this many callers actually test the
|
|
80
|
+
* downstream — the rest fail fast (or hit the fallback) as if the
|
|
81
|
+
* circuit were still open. Without a cap, every queued caller floods
|
|
82
|
+
* a barely-recovered dependency the instant the circuit half-opens.
|
|
83
|
+
* @default 1
|
|
84
|
+
*/
|
|
85
|
+
halfOpenMaxProbes?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Abort the underlying operation when the breaker times out.
|
|
88
|
+
* When `true`, the wrapped function receives an `AbortSignal` as an
|
|
89
|
+
* EXTRA TRAILING argument, aborted on timeout — pass it to fetch/DB
|
|
90
|
+
* calls so timed-out work stops consuming sockets and pool slots
|
|
91
|
+
* instead of running to completion behind the rejected caller.
|
|
92
|
+
* Opt-in because it changes the wrapped function's call shape.
|
|
93
|
+
* @default false
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const breaker = new CircuitBreaker(
|
|
97
|
+
* async (url: string, signal?: AbortSignal) => fetch(url, { signal }),
|
|
98
|
+
* { timeout: 5000, propagateAbort: true },
|
|
99
|
+
* );
|
|
100
|
+
*/
|
|
101
|
+
propagateAbort?: boolean;
|
|
106
102
|
/**
|
|
107
103
|
* Fallback function when circuit is open.
|
|
108
104
|
* Receives the same arguments as the wrapped function.
|
|
@@ -142,10 +138,13 @@ declare class CircuitBreaker<T extends AnyAsyncFn> {
|
|
|
142
138
|
private nextAttempt;
|
|
143
139
|
private lastCallAt;
|
|
144
140
|
private openedAt;
|
|
141
|
+
private halfOpenInFlight;
|
|
145
142
|
private readonly failureThreshold;
|
|
146
143
|
private readonly resetTimeout;
|
|
147
144
|
private readonly timeout;
|
|
148
145
|
private readonly successThreshold;
|
|
146
|
+
private readonly halfOpenMaxProbes;
|
|
147
|
+
private readonly propagateAbort;
|
|
149
148
|
private readonly fallback?;
|
|
150
149
|
private readonly onStateChange?;
|
|
151
150
|
private readonly onError?;
|
|
@@ -157,7 +156,10 @@ declare class CircuitBreaker<T extends AnyAsyncFn> {
|
|
|
157
156
|
*/
|
|
158
157
|
call(...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
159
158
|
/**
|
|
160
|
-
* Execute function with timeout
|
|
159
|
+
* Execute function with timeout. With `propagateAbort`, the wrapped fn
|
|
160
|
+
* receives a trailing AbortSignal that fires on timeout — the breaker's
|
|
161
|
+
* timeout otherwise only rejects the CALLER while the underlying work
|
|
162
|
+
* keeps consuming sockets/pool slots to completion.
|
|
161
163
|
*/
|
|
162
164
|
private executeWithTimeout;
|
|
163
165
|
/**
|
|
@@ -301,7 +303,20 @@ interface CompensationStep<TCtx = Record<string, unknown>, TResult = unknown> {
|
|
|
301
303
|
readonly execute: (ctx: TCtx) => Promise<TResult>;
|
|
302
304
|
/** Rollback on failure — receives context and this step's own result */
|
|
303
305
|
readonly compensate?: (ctx: TCtx, stepResult: TResult) => Promise<void>;
|
|
304
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Fire-and-forget — don't await, don't block, skip in rollback.
|
|
308
|
+
*
|
|
309
|
+
* OUTSIDE the transactional result by design: the step is NOT listed in
|
|
310
|
+
* `completedSteps` (it hasn't completed when the result is returned — a
|
|
311
|
+
* step that later fails must never have been reported as completed), its
|
|
312
|
+
* value never appears in `results`, and it is not compensatable. Its
|
|
313
|
+
* rejection is reported through `hooks.onStepFailed` (observability
|
|
314
|
+
* only — the transaction outcome is unaffected).
|
|
315
|
+
*
|
|
316
|
+
* This is best-effort by construction — a crash loses it. Side effects
|
|
317
|
+
* that must survive failure belong in the outbox or a job queue, not in
|
|
318
|
+
* a fire-and-forget step.
|
|
319
|
+
*/
|
|
305
320
|
readonly fireAndForget?: boolean;
|
|
306
321
|
}
|
|
307
322
|
/** Lifecycle hooks for observability — wire to Arc events, metrics, or logging */
|
|
@@ -309,6 +324,13 @@ interface CompensationHooks {
|
|
|
309
324
|
readonly onStepComplete?: (stepName: string, result: unknown) => void;
|
|
310
325
|
readonly onStepFailed?: (stepName: string, error: Error) => void;
|
|
311
326
|
readonly onCompensate?: (stepName: string) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Reports a hook that THREW. Hook failures never alter the transaction
|
|
329
|
+
* (contained by design), but silent containment makes a broken
|
|
330
|
+
* metrics/audit sink invisible — wire this to a logger. Must not throw;
|
|
331
|
+
* if it does, that too is contained.
|
|
332
|
+
*/
|
|
333
|
+
readonly onHookError?: (hookName: string, error: Error) => void;
|
|
312
334
|
}
|
|
313
335
|
/** Error from a compensation action that failed during rollback */
|
|
314
336
|
interface CompensationError {
|
|
@@ -1082,13 +1104,6 @@ declare function getListQueryParams(): AnyRecord;
|
|
|
1082
1104
|
*/
|
|
1083
1105
|
declare function getDefaultCrudSchemas(): Record<string, Record<string, unknown>>;
|
|
1084
1106
|
//#endregion
|
|
1085
|
-
//#region src/utils/runtime.d.ts
|
|
1086
|
-
/**
|
|
1087
|
-
* Portable "run on next tick" scheduler. `setImmediate` is Node-only — not
|
|
1088
|
-
* available in Bun workers, Deno, Cloudflare Workers, or edge runtimes.
|
|
1089
|
-
*/
|
|
1090
|
-
declare const scheduleBackground: (cb: () => void) => void;
|
|
1091
|
-
//#endregion
|
|
1092
1107
|
//#region src/utils/schemaConverter.d.ts
|
|
1093
1108
|
/**
|
|
1094
1109
|
* Supported JSON Schema output targets for Zod v4's `toJSONSchema()`.
|
|
@@ -1215,6 +1230,38 @@ declare function convertRouteSchema(schema: Record<string, unknown>, target?: Js
|
|
|
1215
1230
|
*/
|
|
1216
1231
|
declare function simpleEqualityMatcher(item: unknown, filters: Record<string, unknown>): boolean;
|
|
1217
1232
|
//#endregion
|
|
1233
|
+
//#region src/utils/sseStream.d.ts
|
|
1234
|
+
interface SseStreamOptions {
|
|
1235
|
+
/** Heartbeat comment interval in ms (default: 30000). */
|
|
1236
|
+
heartbeatMs?: number;
|
|
1237
|
+
/**
|
|
1238
|
+
* Reconnection-delay hint written once at connect as the standard SSE
|
|
1239
|
+
* `retry:` field (WHATWG EventSource honors it natively). Omit to send
|
|
1240
|
+
* no hint (browser default ~3s).
|
|
1241
|
+
*/
|
|
1242
|
+
retryMs?: number;
|
|
1243
|
+
}
|
|
1244
|
+
interface SseStream {
|
|
1245
|
+
/**
|
|
1246
|
+
* Write one SSE frame. `id` (optional) becomes the standard SSE `id:`
|
|
1247
|
+
* field — clients receive it as `lastEventId` (WHATWG), enabling
|
|
1248
|
+
* client-side dedup/resume bookkeeping even when the server keeps no
|
|
1249
|
+
* replay log. Returns `false` when the connection was destroyed
|
|
1250
|
+
* (backpressure) — the stream is already cleaned up; stop writing.
|
|
1251
|
+
*/
|
|
1252
|
+
write(eventName: string, data: string, id?: string): boolean;
|
|
1253
|
+
/** Idempotent teardown: heartbeat cleared, cleanups run, socket ended. */
|
|
1254
|
+
close(): void;
|
|
1255
|
+
/** Register teardown work (unsubscribes etc.) — runs exactly once. */
|
|
1256
|
+
onCleanup(fn: () => void): void;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Take over the reply socket and open an SSE stream. Call ONLY after every
|
|
1260
|
+
* gate (auth, permissions, validation) has passed — after `hijack()` no
|
|
1261
|
+
* JSON error can be sent.
|
|
1262
|
+
*/
|
|
1263
|
+
declare function openSseStream(request: FastifyRequest, reply: FastifyReply, options?: SseStreamOptions): SseStream;
|
|
1264
|
+
//#endregion
|
|
1218
1265
|
//#region src/utils/stateMachine.d.ts
|
|
1219
1266
|
/**
|
|
1220
1267
|
* State Machine Utility
|
|
@@ -1461,18 +1508,4 @@ declare function hasEvents(instance: FastifyInstance): instance is FastifyInstan
|
|
|
1461
1508
|
events: EventsDecorator;
|
|
1462
1509
|
};
|
|
1463
1510
|
//#endregion
|
|
1464
|
-
|
|
1465
|
-
/**
|
|
1466
|
-
* Extract a user ID from a user object. Accepts `id` or `_id` — returns
|
|
1467
|
-
* `undefined` when neither is present. Used by arc's controllers to
|
|
1468
|
-
* populate `createdBy` / `updatedBy` fields and for cache scoping.
|
|
1469
|
-
*
|
|
1470
|
-
* @example
|
|
1471
|
-
* ```ts
|
|
1472
|
-
* import { getUserId } from '@classytic/arc/utils';
|
|
1473
|
-
* const uid = getUserId(request.user);
|
|
1474
|
-
* ```
|
|
1475
|
-
*/
|
|
1476
|
-
declare function getUserId(user: UserLike | null | undefined): string | undefined;
|
|
1477
|
-
//#endregion
|
|
1478
|
-
export { ArcError, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, type ConfigError, ConflictError, type ErrorOptions, type EventsDecorator, type FilterDialect, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, ServiceUnavailableError, type StateMachine, type TransitionConfig, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, type ValidateOptions, ValidationError, type ValidationResult, aggregateListResponse, assertValidConfig, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, formatValidationErrors, forwardedStreamHeaders, getDefaultCrudSchemas, getListQueryParams, getUserId, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, offsetListResponse, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, validateResourceConfig, withCompensation };
|
|
1511
|
+
export { ArcError, type ArcHeaders, ArcQueryParser, type ArcQueryParserOptions, CircuitBreaker, CircuitBreakerError, type CircuitBreakerOptions, CircuitBreakerRegistry, type CircuitBreakerStats, CircuitState, type CompensationDefinition, type CompensationError, type CompensationHooks, type CompensationResult, type CompensationStep, ConflictError, type ErrorOptions, type EventsDecorator, type FilterDialect, ForbiddenError, type Guard, type GuardConfig, type JsonSchema, type JsonSchemaTarget, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, type PipeUIMessageStreamOptions, RateLimitError, ServiceUnavailableError, type SseStream, type SseStreamOptions, type StateMachine, type TransitionConfig, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, forwardedStreamHeaders, getDefaultCrudSchemas, getHeader, getListQueryParams, getUserId, getUserRoles, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, normalizeRoles, offsetListResponse, openSseStream, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, requireSingleHeaderValue, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, withCompensation };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { a as OrgAccessDeniedError, c as ServiceUnavailableError, d as createDomainError, f as createError, i as NotFoundError, l as UnauthorizedError, n as ConflictError, o as OrgRequiredError, p as isArcError, r as ForbiddenError, s as RateLimitError, t as ArcError, u as ValidationError } from "../errors-DkO8Nk6-.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { n as requireSingleHeaderValue, t as getHeader } from "../headers-BvlQSDMB.mjs";
|
|
3
|
+
import { n as getUserRoles, r as normalizeRoles, t as getUserId } from "../userHelpers-Cg_y3fBz.mjs";
|
|
4
|
+
import { t as simpleEqualityMatcher } from "../simpleEqualityMatcher-Cg05HPsn.mjs";
|
|
5
|
+
import { A as createCircuitBreakerRegistry, C as defineCompensation, D as CircuitBreakerRegistry, E as CircuitBreakerError, O as CircuitState, S as defineErrorMapper, T as CircuitBreaker, _ as createQueryParser, a as deleteResponse, b as NEUTRAL_DIALECT, c as getDefaultCrudSchemas, d as listResponse, f as offsetListResponse, g as ArcQueryParser, h as responses, i as bareListResponse, k as createCircuitBreaker, l as getListQueryParams, m as queryParams, n as scheduleBackground, o as errorContractSchema, p as paginationSchema, r as aggregateListResponse, s as errorDetailSchema, t as createStateMachine, u as keysetListResponse, v as handleRaw, w as withCompensation, x as defineGuard, y as MONGO_DIALECT } from "../utils-taUVD4p3.mjs";
|
|
6
|
+
import { a as isZodSchema, i as isJsonSchema, n as convertRouteSchema, o as toJsonSchema, t as convertOpenApiSchemas } from "../schemaConverter-DJvodiHj.mjs";
|
|
4
7
|
import { a as promoteStreamTokenToHeader, i as pipeUIMessageStreamToReply, n as forwardedStreamHeaders, r as isReadableStream, t as UI_MESSAGE_STREAM_HEADERS } from "../streaming-BQcW6_Kq.mjs";
|
|
8
|
+
import { t as openSseStream } from "../sseStream-BQ7Qaynp.mjs";
|
|
5
9
|
import { t as hasEvents } from "../typeGuards-C9KXUly6.mjs";
|
|
6
|
-
export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse,
|
|
10
|
+
export { ArcError, ArcQueryParser, CircuitBreaker, CircuitBreakerError, CircuitBreakerRegistry, CircuitState, ConflictError, ForbiddenError, MONGO_DIALECT, NEUTRAL_DIALECT, NotFoundError, OrgAccessDeniedError, OrgRequiredError, RateLimitError, ServiceUnavailableError, UI_MESSAGE_STREAM_HEADERS, UnauthorizedError, ValidationError, aggregateListResponse, bareListResponse, convertOpenApiSchemas, convertRouteSchema, createCircuitBreaker, createCircuitBreakerRegistry, createDomainError, createError, createQueryParser, createStateMachine, defineCompensation, defineErrorMapper, defineGuard, deleteResponse, errorContractSchema, errorDetailSchema, forwardedStreamHeaders, getDefaultCrudSchemas, getHeader, getListQueryParams, getUserId, getUserRoles, handleRaw, hasEvents, isArcError, isJsonSchema, isReadableStream, isZodSchema, keysetListResponse, listResponse, normalizeRoles, offsetListResponse, openSseStream, paginationSchema, pipeUIMessageStreamToReply, promoteStreamTokenToHeader, queryParams, requireSingleHeaderValue, responses, scheduleBackground, simpleEqualityMatcher, toJsonSchema, withCompensation };
|