@classytic/arc 2.25.0 → 2.30.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 +2 -0
- package/dist/{BaseController--M8EMzt0.mjs → BaseController-B5DwufbB.mjs} +15 -11
- package/dist/EventTransport-C6YA8xY9.mjs +103 -0
- package/dist/{HookSystem-C1vB_Gc9.mjs → HookSystem-WkIougo6.mjs} +15 -35
- package/dist/applyPermissionResult-Cf6zUCvb.mjs +257 -0
- package/dist/audit/index.d.mts +2 -2
- package/dist/audit/index.mjs +1 -1
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +1 -1
- package/dist/{buildHandler-Dtwd8fdz.mjs → buildHandler-BYS3Vkfz.mjs} +32 -6
- package/dist/cleanup/index.d.mts +313 -0
- package/dist/cleanup/index.mjs +1267 -0
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/docs.mjs +1 -1
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +5 -3
- package/dist/core-poalJLvp.mjs +175 -0
- package/dist/{createActionRouter-B6GvAuAX.mjs → createActionRouter-BxuywVRB.mjs} +2 -2
- package/dist/{createAggregationRouter-wzwFa_dW.mjs → createAggregationRouter-BiY-lGdY.mjs} +7 -20
- package/dist/{preloadResources-DfyngIN9.mjs → createApp-CXrKFciH.mjs} +25 -76
- package/dist/defineAggregation-ufWjUwml.mjs +47 -0
- package/dist/{core-EUNu0u07.mjs → defineResource-CxWqDCAy.mjs} +36 -261
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +1 -1
- package/dist/{eventPlugin-DrQ_FesK.mjs → eventPlugin-D2NNR4py.mjs} +2 -103
- package/dist/events/index.d.mts +28 -2
- package/dist/events/index.mjs +24 -343
- package/dist/factory/index.d.mts +4 -3
- package/dist/factory/index.mjs +3 -1
- package/dist/{fastify-augmentation-dPNBVeIj.d.mts → fastify-augmentation-0WhPnUH7.d.mts} +3 -2
- package/dist/{applyPermissionResult-Tw4iXtlf.mjs → fields-CQ_7KQWw.mjs} +1 -97
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/idempotency/index.mjs +1 -1
- package/dist/index-CCzVR-N3.d.mts +107 -0
- package/dist/{index-BMnbzvtO.d.mts → index-Ch16aAah.d.mts} +201 -21
- package/dist/{index-f4PTrk3B.d.mts → index-Cx7bro4R.d.mts} +4 -4
- package/dist/{index-DPRH0Cme.d.mts → index-Q5gzEIWY.d.mts} +97 -66
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +8 -6
- package/dist/integrations/index.d.mts +1 -1
- package/dist/integrations/mcp/index.d.mts +6 -6
- package/dist/integrations/mcp/index.mjs +1 -1
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/{mcpPlugin-Cb7olw0j.mjs → mcpPlugin-nRzm5g2s.mjs} +36 -43
- package/dist/middleware/index.d.mts +1 -1
- package/dist/migrations/index.d.mts +0 -3
- package/dist/migrations/index.mjs +0 -3
- package/dist/module-_-M7C5ES.mjs +29 -0
- package/dist/{openapi-DrLtog_B.mjs → openapi-B8Vkbxbn.mjs} +1 -1
- package/dist/permissions/index.d.mts +3 -3
- package/dist/permissions/index.mjs +4 -3
- package/dist/{permissions-BrtiBKGs.mjs → permissions-Bfu_8y1U.mjs} +318 -289
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/{pipeline-BN5G05rd.mjs → pipeline-BJnpkY9i.mjs} +4 -18
- package/dist/plugins/index.d.mts +4 -4
- package/dist/plugins/index.mjs +2 -2
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/{preloadResources-0oe-JSSS.d.mts → preloadResources-DCfa2egz.d.mts} +3 -2
- package/dist/preloadResources-DSY5HGpS.mjs +45 -0
- package/dist/presets/filesUpload.d.mts +2 -2
- package/dist/presets/filesUpload.mjs +1 -1
- package/dist/presets/index.d.mts +14 -2
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +1 -1
- package/dist/{presets-DwFDVKP0.mjs → presets-CJOEXLuk.mjs} +25 -9
- package/dist/projection-UBDgfMwu.mjs +17 -0
- package/dist/{realtime-Cuw_deA-.mjs → realtime-B9nmIY5V.mjs} +2 -1
- package/dist/{registerRoute-v0Wb6Plt.mjs → registerRoute-JkxIEBJq.mjs} +3 -1
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +1 -1
- package/dist/{registry-vcOCtPij.mjs → registry-BYXUUg21.mjs} +16 -1
- package/dist/repositoryFilter-Dz8k3S4P.mjs +44 -0
- package/dist/subscribe-helpers-DfzsivM6.mjs +339 -0
- package/dist/testing/cleanupStoreContract.d.mts +10 -0
- package/dist/testing/cleanupStoreContract.mjs +375 -0
- package/dist/testing/index.d.mts +34 -5
- package/dist/testing/index.mjs +316 -211
- package/dist/testing/outboxStoreContract.d.mts +13 -0
- package/dist/testing/outboxStoreContract.mjs +247 -0
- package/dist/types/index.d.mts +3 -3
- package/dist/{types-QFGc3Cjv.d.mts → types-Bmmn-fO0.d.mts} +1 -1
- package/dist/types-C_ZZRcD6.d.mts +450 -0
- package/dist/{types-Dmw-6Qeo.d.mts → types-ChvvVNP8.d.mts} +93 -88
- package/dist/{index-KUoxjIq1.d.mts → types-D_n8L6VY.d.mts} +33 -106
- package/dist/usage/index.d.mts +1 -1
- package/dist/usage/index.mjs +0 -0
- package/dist/utils/index.d.mts +2 -5
- package/package.json +539 -524
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as EventHandler } from "./EventTransport-QmY7A258.mjs";
|
|
1
|
+
import { n as DomainEvent, r as EventHandler } from "./EventTransport-QmY7A258.mjs";
|
|
2
2
|
import { n as ErrorMapper } from "./errorHandler-C6yv4ZTW.mjs";
|
|
3
3
|
import { FastifyInstance, FastifyPluginAsync } from "fastify";
|
|
4
4
|
import { LockAdapter } from "@classytic/repo-core/lock";
|
|
@@ -343,6 +343,37 @@ interface EventHandlerDefinition {
|
|
|
343
343
|
* `inventory.order-created`; Arc does not silently rewrite public names.
|
|
344
344
|
*/
|
|
345
345
|
name?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Contain handler failures inside an error boundary — arc wraps `handler`
|
|
348
|
+
* with `wrapWithBoundary`, so a throw is logged (through `fastify.log`, with
|
|
349
|
+
* `{ err, event, eventId, handler }`) and swallowed instead of reaching the
|
|
350
|
+
* transport.
|
|
351
|
+
*
|
|
352
|
+
* **Off by default, deliberately.** Reaching the transport is what makes the
|
|
353
|
+
* durable path work: `RedisStreamTransport` leaves the message unacked, so it
|
|
354
|
+
* is redelivered and eventually DLQ'd. Silently swallowing by default would
|
|
355
|
+
* turn every module handler into best-effort delivery.
|
|
356
|
+
*
|
|
357
|
+
* Turn it ON for fire-and-forget work — projections, cache invalidation,
|
|
358
|
+
* notification fan-out — where a failure must not block the ack and a retry
|
|
359
|
+
* would only delay the next event's resync. That is precisely the case where
|
|
360
|
+
* a module author would otherwise abandon this arm for an imperative
|
|
361
|
+
* `subscribeWithBoundary` call in `afterResources` and lose arc's
|
|
362
|
+
* teardown-before-`onClose` guarantee.
|
|
363
|
+
*
|
|
364
|
+
* ```ts
|
|
365
|
+
* defineModule({ name: "search", eventHandlers: [
|
|
366
|
+
* { name: "search.reindex", event: "product:*", handler: reindex, boundary: true },
|
|
367
|
+
* ] })
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* The object form adds an `onError` sink (metrics / alerting) in place of the
|
|
371
|
+
* default log; it runs INSIDE the boundary, so a throwing `onError` is itself
|
|
372
|
+
* caught and logged rather than escaping.
|
|
373
|
+
*/
|
|
374
|
+
boundary?: boolean | {
|
|
375
|
+
onError?: (error: Error, event: DomainEvent) => void | Promise<void>;
|
|
376
|
+
};
|
|
346
377
|
}
|
|
347
378
|
interface ArcModule<TExports = unknown> {
|
|
348
379
|
/** Stable identifier — appears in boot logs and duplicate-module detection. */
|
|
@@ -587,108 +618,4 @@ type ArcModuleInput<TExports = unknown> = ArcModule<TExports> | Promise<ArcModul
|
|
|
587
618
|
*/
|
|
588
619
|
interface ArcModuleRegistry {}
|
|
589
620
|
//#endregion
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Collect every module's `healthChecks` in the caller's order. Fails at boot
|
|
593
|
-
* on a duplicate check `name` across modules, naming BOTH owning modules.
|
|
594
|
-
* The host's app-level checks are appended AFTER this (modules-first,
|
|
595
|
-
* host-last) by the caller.
|
|
596
|
-
*/
|
|
597
|
-
declare function collectModuleHealthChecks(modules: readonly ArcModule[]): HealthCheck[];
|
|
598
|
-
/**
|
|
599
|
-
* Collect every module's `workflows`. Resolves factory contributions (so a
|
|
600
|
-
* factory can close over a container the caller has already decorated on
|
|
601
|
-
* `fastify`) and flattens to a single opaque array. Arc core deliberately
|
|
602
|
-
* does NOT validate or interpret the values — the streamline integration
|
|
603
|
-
* owns name/shape checks and registration. Called by the integration at init
|
|
604
|
-
* time, not by arc's boot pipeline (workflows depend on the integration's
|
|
605
|
-
* container).
|
|
606
|
-
*/
|
|
607
|
-
declare function collectModuleWorkflows(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<unknown[]>;
|
|
608
|
-
/**
|
|
609
|
-
* Collect every module's `scheduledJobs`. Resolves factory contributions
|
|
610
|
-
* (after bootstraps) and fails at boot on a duplicate job `name` across
|
|
611
|
-
* modules. The caller passes the returned definitions to the canonical
|
|
612
|
-
* schedules plugin; factories must therefore be resolved only once.
|
|
613
|
-
*/
|
|
614
|
-
declare function collectModuleScheduledJobs(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<ScheduleDefinition[]>;
|
|
615
|
-
//#endregion
|
|
616
|
-
//#region src/factory/module/lifecycle.d.ts
|
|
617
|
-
/**
|
|
618
|
-
* Subscribe every module's `eventHandlers` in dependency order (pass the
|
|
619
|
-
* `orderModules`-sorted list). Returns the ordered list of unsubscribe
|
|
620
|
-
* functions so the caller can tear them down at shutdown BEFORE module
|
|
621
|
-
* `onClose` (while module deps are still alive). Fails at boot on:
|
|
622
|
-
* - a duplicate NAMED handler across modules (attributing both owners);
|
|
623
|
-
* - a module declaring handlers while the event subsystem is unavailable.
|
|
624
|
-
* Resolves factory contributions (after bootstraps) so a handler can close over
|
|
625
|
-
* booted engines rather than a global getter.
|
|
626
|
-
*/
|
|
627
|
-
declare function subscribeModuleEventHandlers(fastify: FastifyInstance, modules: readonly ArcModule[]): Promise<Array<() => void | Promise<void>>>;
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region src/factory/module/order.d.ts
|
|
630
|
-
/**
|
|
631
|
-
* Order modules for composition by their `dependsOn` edges — a STABLE
|
|
632
|
-
* topological sort. Called once at the start of the bootstrap phase; every
|
|
633
|
-
* subsequent phase (bootstrap, resources, afterResources, and reverse-order
|
|
634
|
-
* onClose) iterates the returned list, so a module's declared dependencies are
|
|
635
|
-
* always composed before it.
|
|
636
|
-
*
|
|
637
|
-
* "Stable" = modules with no edge between them keep their original list order,
|
|
638
|
-
* so declaring `dependsOn` on one module never silently reorders an unrelated
|
|
639
|
-
* one. Backward compatible: a `modules` array with NO `dependsOn` anywhere is
|
|
640
|
-
* returned unchanged.
|
|
641
|
-
*
|
|
642
|
-
* Fail-fast — throws (never reorders past a broken contract) on:
|
|
643
|
-
* - duplicate module names (the name is the graph key)
|
|
644
|
-
* - a `dependsOn` name not present in the composed set
|
|
645
|
-
* - a self-reference (`dependsOn` includes the module's own name)
|
|
646
|
-
* - a dependency cycle (reports the concrete `a → b → … → a` path)
|
|
647
|
-
*/
|
|
648
|
-
declare function orderModules(modules: readonly ArcModule[]): ArcModule[];
|
|
649
|
-
//#endregion
|
|
650
|
-
//#region src/factory/module/resolve.d.ts
|
|
651
|
-
/**
|
|
652
|
-
* Resolve any module-input form to a concrete `ArcModule`. A thunk is invoked
|
|
653
|
-
* (this is where a dynamic `import()` fires); a promise (or plain module) is
|
|
654
|
-
* awaited. Called once per module at the start of the bootstrap phase.
|
|
655
|
-
*/
|
|
656
|
-
declare function resolveModule(input: ArcModuleInput): Promise<ArcModule>;
|
|
657
|
-
/** Resolve a `ModuleContribution` to a concrete array (array passthrough or factory call). */
|
|
658
|
-
declare function resolveContribution<T>(contribution: ModuleContribution<T> | undefined, fastify: FastifyInstance): Promise<readonly T[]>;
|
|
659
|
-
//#endregion
|
|
660
|
-
//#region src/factory/module/index.d.ts
|
|
661
|
-
/**
|
|
662
|
-
* Identity helper for authoring a typed module — mirrors `defineResource`.
|
|
663
|
-
* Gives inference + a single obvious construction site; does no work.
|
|
664
|
-
*
|
|
665
|
-
* `TExports` is inferred from the `bootstrap` return value, so a module
|
|
666
|
-
* author gets a typed public export for free:
|
|
667
|
-
*
|
|
668
|
-
* ```ts
|
|
669
|
-
* export const accountingModule = (deps: Deps) =>
|
|
670
|
-
* defineModule({
|
|
671
|
-
* name: "accounting",
|
|
672
|
-
* bootstrap: async () => createAccountingEngine(deps), // TExports inferred
|
|
673
|
-
* });
|
|
674
|
-
* ```
|
|
675
|
-
*/
|
|
676
|
-
declare function defineModule<TExports = unknown>(module: ArcModule<TExports>): ArcModule<TExports>;
|
|
677
|
-
/**
|
|
678
|
-
* Typed accessor for a module's public export (its `bootstrap` return value),
|
|
679
|
-
* recorded at `fastify.arc.modules[name]`.
|
|
680
|
-
*
|
|
681
|
-
* Throwing, in line with the fail-fast contract (and `requireOrgId`-style
|
|
682
|
-
* accessors): a missing entry means the module either isn't composed, is
|
|
683
|
-
* composed AFTER the caller (list order = init order), or returned nothing —
|
|
684
|
-
* all wiring bugs that must surface at boot, not as `undefined` downstream.
|
|
685
|
-
*
|
|
686
|
-
* The type parameter is an assertion, not a proof. Two ways to type it:
|
|
687
|
-
* - augment `ArcModuleRegistry` once — then the name alone infers the type:
|
|
688
|
-
* `getModuleExports(f, "accounting")` → `AccountingEngine`.
|
|
689
|
-
* - or pass it inline: `getModuleExports<AccountingEngine>(f, "accounting")`.
|
|
690
|
-
*/
|
|
691
|
-
declare function getModuleExports<K extends keyof ArcModuleRegistry>(fastify: FastifyInstance, name: K): ArcModuleRegistry[K];
|
|
692
|
-
declare function getModuleExports<TExports = unknown>(fastify: FastifyInstance, name: string): TExports;
|
|
693
|
-
//#endregion
|
|
694
|
-
export { schedulesPlugin as C, healthPlugin as D, _default$1 as E, _default as S, HealthOptions as T, ResourceModule as _, orderModules as a, ScheduleStats as b, collectModuleScheduledJobs as c, ArcModuleInput as d, ArcModuleRegistry as f, ResourceLike as g, LoadResourcesOptions as h, resolveModule as i, collectModuleWorkflows as l, ModuleContribution as m, getModuleExports as n, subscribeModuleEventHandlers as o, EventHandlerDefinition as p, resolveContribution as r, collectModuleHealthChecks as s, defineModule as t, ArcModule as u, loadResources as v, HealthCheck as w, SchedulesPluginOptions as x, ScheduleDefinition as y };
|
|
621
|
+
export { _default$1 as _, ModuleContribution as a, ResourceModule as c, ScheduleStats as d, SchedulesPluginOptions as f, HealthOptions as g, HealthCheck as h, EventHandlerDefinition as i, loadResources as l, schedulesPlugin as m, ArcModuleInput as n, LoadResourcesOptions as o, _default as p, ArcModuleRegistry as r, ResourceLike as s, ArcModule as t, ScheduleDefinition as u, healthPlugin as v };
|
package/dist/usage/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as RequestScope } from "../types-DjC-KUCz.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { i as PermissionContext, r as PermissionCheck } from "../types-ChvvVNP8.mjs";
|
|
3
3
|
import { UsageBucket, UsageStore, usagePeriod } from "@classytic/repo-core/usage";
|
|
4
4
|
import { FastifyPluginAsync, FastifyRequest } from "fastify";
|
|
5
5
|
//#region src/usage/requireQuota.d.ts
|
package/dist/usage/index.mjs
CHANGED
|
Binary file
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-
|
|
1
|
+
import { $ as OpenApiSchemas, S as QueryParserInterface, b as ParsedQuery } from "../index-Q5gzEIWY.mjs";
|
|
2
2
|
import { F as getHeader, I as requireSingleHeaderValue, P as ArcHeaders } from "../types-DjC-KUCz.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { c as normalizeRoles, l as AnyRecord, o as getUserId, s as getUserRoles } from "../types-ChvvVNP8.mjs";
|
|
4
4
|
import { n as ErrorMapper } from "../errorHandler-C6yv4ZTW.mjs";
|
|
5
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";
|
|
6
6
|
import { errorContractSchema, errorDetailSchema } from "@classytic/repo-core/errors";
|
|
@@ -1313,9 +1313,6 @@ interface StateMachine {
|
|
|
1313
1313
|
* Record a transition
|
|
1314
1314
|
*/
|
|
1315
1315
|
recordTransition?(from: string, to: string, action: string, metadata?: Record<string, unknown>): void;
|
|
1316
|
-
/**
|
|
1317
|
-
* Clear history
|
|
1318
|
-
*/
|
|
1319
1316
|
clearHistory?(): void;
|
|
1320
1317
|
/**
|
|
1321
1318
|
* Get available actions for current status
|