@classytic/arc 2.41.1 → 2.43.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/{EventTransport-CbUKDzZZ.d.mts → EventTransport-CiicKz2Z.d.mts} +1 -1
- package/dist/{EventTransport-DSqD_Xsg.mjs → EventTransport-tzA7CAB4.mjs} +22 -17
- package/dist/{HookSystem-CMF94SEA.mjs → HookSystem-B6UaKRbF.mjs} +2 -2
- package/dist/{QueryCache-DFA-QrU9.d.mts → QueryCache--5uAuYPW.d.mts} +7 -3
- package/dist/{ResourceRegistry-MGpXoxHZ.mjs → ResourceRegistry-CuCARu2B.mjs} +44 -13
- package/dist/actionPermissions-BotX1YOa.mjs +776 -0
- package/dist/audit/index.d.mts +43 -5
- package/dist/audit/index.mjs +48 -26
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +43 -13
- package/dist/auth/index.mjs +130 -155
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-DawKGoXb.mjs → authorizationDecision-DQYrkl5f.mjs} +7 -102
- package/dist/{base-CxrV1LmG.d.mts → base-CZyixEQR.d.mts} +27 -5
- package/dist/boundedMap-BULzfXYU.mjs +57 -0
- package/dist/{buildHandler-CvxKOc0m.mjs → buildHandler-CRQ8EcX5.mjs} +4 -4
- package/dist/cache/index.d.mts +22 -34
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-DbCBxlgw.mjs → caching-Cc2M1DwO.mjs} +3 -3
- package/dist/claimed-B10RTfkM.mjs +8 -0
- package/dist/cleanup/index.d.mts +6 -10
- package/dist/cleanup/index.mjs +27 -73
- package/dist/cli/commands/describe.d.mts +4 -2
- package/dist/cli/commands/describe.mjs +7 -4
- package/dist/cli/commands/docs.mjs +3 -3
- package/dist/cli/commands/doctor.mjs +1 -1
- package/dist/cli/commands/generate.mjs +2 -2
- package/dist/cli/commands/init.mjs +2 -2
- package/dist/cli/commands/introspect.mjs +2 -2
- package/dist/cli/index.mjs +3 -3
- package/dist/{constants-D5Ubn1fe.mjs → constants-Cu7Mx7_U.mjs} +4 -2
- package/dist/context/index.d.mts +2 -5
- package/dist/context/index.mjs +18 -38
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +8 -8
- package/dist/{core-5lazhva9.mjs → core-Cb0LjccA.mjs} +5 -4
- package/dist/{createActionRouter-DNqoaK81.mjs → createActionRouter-xjqonMRO.mjs} +87 -39
- package/dist/{createAggregationRouter-BcbQJf10.mjs → createAggregationRouter-zRYWw_5D.mjs} +11 -8
- package/dist/{preloadResources-f3boenVZ.mjs → createApp-D-953ZAq.mjs} +299 -390
- package/dist/{createMcpServer-CbDWkZ1T.d.mts → createMcpServer-C9cxS8zt.d.mts} +1 -1
- package/dist/{defineAggregation-D_eJjm5A.mjs → defineAggregation-Bm8RjMbq.mjs} +1 -1
- package/dist/{defineResource-DxkMTjRn.mjs → defineResource-DIC7JZGU.mjs} +118 -1024
- package/dist/discovery/index.mjs +1 -1
- package/dist/docs/index.d.mts +10 -4
- package/dist/docs/index.mjs +4 -4
- package/dist/{elevation-BXCfVcNG.d.mts → elevation-BW2J3tNj.d.mts} +1 -2
- package/dist/{elevation-CkvG0LG2.mjs → elevation-DG8SrLN-.mjs} +41 -12
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-D1GHKGlV.mjs → errorHandler-BnfDviL1.mjs} +26 -5
- package/dist/{errors-BH7YU_9O.mjs → errors-CtrywMHP.mjs} +58 -23
- package/dist/{errors-BGdVwP25.d.mts → errors-JYc9vwqE.d.mts} +9 -0
- package/dist/{eventPlugin-B52abJ8W.d.mts → eventPlugin-BtmA4-3P.d.mts} +65 -9
- package/dist/{eventPlugin-zZY-unhr.mjs → eventPlugin-Q6BhzHzs.mjs} +82 -21
- package/dist/{subscribe-helpers-DatDkcuG.mjs → eventTypes-Cdhm6ZlV.mjs} +151 -17
- package/dist/events/index.d.mts +33 -8
- package/dist/events/index.mjs +49 -53
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +139 -157
- package/dist/events/transports/redis.d.mts +1 -1
- package/dist/events/transports/redis.mjs +2 -2
- package/dist/factory/index.d.mts +32 -17
- package/dist/factory/index.mjs +213 -32
- package/dist/{fastify-augmentation-Cq2nHVaW.d.mts → fastify-augmentation-DhUJ-mvo.d.mts} +11 -25
- package/dist/{fields-I_EeRWND.d.mts → fields-BBSpf8pS.d.mts} +1 -1
- package/dist/{fields-BHrkoF5y.mjs → fields-ToPYpMqS.mjs} +1 -1
- package/dist/filter-merge-IpGywvym.mjs +99 -0
- package/dist/{generate-BLRf2m3y.mjs → generate-DRTkLlIl.mjs} +2 -2
- package/dist/{headers-BIXWKrzQ.mjs → headers-BbkIF6vA.mjs} +2 -2
- package/dist/health-D-Ft6JM6.mjs +22 -0
- package/dist/{health-ZRHeDHXH.mjs → health-DqbsG-_w.mjs} +115 -55
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.mjs +2 -2
- package/dist/idempotency/index.d.mts +31 -7
- package/dist/idempotency/index.mjs +155 -98
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +48 -11
- package/dist/{index-BHdZD8zK.d.mts → index-Bxriq3so.d.mts} +84 -21
- package/dist/{preloadResources-CjS2OfpU.d.mts → index-C8zVGYsk.d.mts} +37 -38
- package/dist/{index-D4u76eQW.d.mts → index-CRoPtISf.d.mts} +23 -73
- package/dist/{index-CbJiYrfv.d.mts → index-Chgz3d0i.d.mts} +1 -1
- package/dist/index-JdbZAIsm.d.mts +510 -0
- package/dist/{index-DHbyPo5j.d.mts → index-mqaqZNpe.d.mts} +253 -254
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +11 -11
- package/dist/{init-CpLkjU18.mjs → init-B_oUYDXI.mjs} +1 -1
- package/dist/integrations/event-gateway.d.mts +8 -3
- package/dist/integrations/event-gateway.mjs +4 -4
- package/dist/integrations/index.d.mts +3 -3
- package/dist/integrations/index.mjs +1 -1
- package/dist/integrations/jobs/index.d.mts +1 -1
- package/dist/integrations/jobs/index.mjs +18 -5
- package/dist/integrations/mcp/index.d.mts +72 -59
- package/dist/integrations/mcp/index.mjs +19 -4
- package/dist/integrations/mcp/testing.d.mts +2 -2
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.d.mts +78 -136
- package/dist/integrations/streamline.mjs +116 -54
- package/dist/integrations/webhooks.d.mts +60 -120
- package/dist/integrations/webhooks.mjs +36 -80
- package/dist/integrations/websocket-pushref-redis.d.mts +1 -1
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.d.mts +1 -1
- package/dist/integrations/websocket-redis.mjs +1 -1
- package/dist/integrations/websocket.d.mts +3 -3
- package/dist/integrations/websocket.mjs +2 -2
- package/dist/{interface-DEWNOMza.d.mts → interface-C0395yUN.d.mts} +13 -1
- package/dist/{jsonBody-ELR9lfeU.mjs → jsonBody-B4YVGcql.mjs} +2 -2
- package/dist/{keys-cpZCtcIE.mjs → keys-B2KtgMLJ.mjs} +7 -18
- package/dist/{loadResources-BPfWiI5s.mjs → loadResources-Dn4lalw2.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-ixtfL3J2.mjs → loadResourcesFromEntry-3sLYbuse.mjs} +2 -2
- package/dist/logger/index.d.mts +1 -8
- package/dist/logger/index.mjs +3 -153
- package/dist/logger-DXjfIqjV.mjs +160 -0
- package/dist/{mcpPlugin-BX5PujI0.mjs → mcpPlugin-C08HalN5.mjs} +433 -170
- package/dist/{memory-Iotz0cCx.mjs → memory-9Cp7611C.mjs} +36 -34
- package/dist/{metrics-NMsmpRmY.mjs → metrics-CWI11eRu.mjs} +39 -72
- package/dist/middleware/index.d.mts +2 -2
- package/dist/middleware/index.mjs +3 -3
- package/dist/migrations/index.mjs +2 -2
- package/dist/{module-DpLJG2_N.mjs → module-BSvOQC7E.mjs} +8 -8
- package/dist/multiTenant-cY0FkDiA.d.mts +104 -0
- package/dist/{multipartBody-DtRWM6_U.mjs → multipartBody-CXM2a-Dy.mjs} +46 -7
- package/dist/{openapi-CmFf3yq_.mjs → openapi-DT_G4VhY.mjs} +48 -10
- package/dist/outbox-admin/index.d.mts +3 -3
- package/dist/outbox-admin/index.mjs +6 -18
- package/dist/{outbox-module-D2z5WkDY.mjs → outbox-module-Bjgzl6tg.mjs} +203 -33
- package/dist/{outbox-module-BHdUnuuK.d.mts → outbox-module-gZCHoE4H.d.mts} +79 -6
- package/dist/permissions/index.d.mts +5 -4
- package/dist/permissions/index.mjs +8 -6
- package/dist/{permissions-D8TBH44E.mjs → permissions-Cm0uYHvd.mjs} +149 -33
- package/dist/{pipe-FMWNheSO.mjs → pipe-BqeGT6UO.mjs} +2 -2
- package/dist/pipeline/index.d.mts +2 -2
- package/dist/pipeline/index.mjs +2 -2
- package/dist/plan-FVR6LP59.mjs +565 -0
- package/dist/{BaseController-CYEwjyjN.mjs → plugin-BccET1tL.mjs} +1256 -345
- package/dist/plugins/index.d.mts +14 -11
- package/dist/plugins/index.mjs +44 -22
- package/dist/plugins/response-cache.mjs +8 -14
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-CXWZIzTv.mjs → pluralize-CVIOcgMF.mjs} +1 -1
- package/dist/presets/filesUpload.d.mts +2 -2
- package/dist/presets/filesUpload.mjs +5 -5
- package/dist/presets/index.d.mts +26 -31
- package/dist/presets/index.mjs +4 -4
- package/dist/presets/multiTenant.d.mts +2 -107
- package/dist/presets/multiTenant.mjs +22 -162
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +2 -2
- package/dist/{presets-ZJSPgmT2.mjs → presets-Cpvj6fGO.mjs} +99 -107
- package/dist/{projection-BzIgzoKZ.mjs → projection-Ce4aQhQk.mjs} +2 -2
- package/dist/{pushref-registry-Dov9l4qE.d.mts → pushref-registry-UxCkoA4C.d.mts} +1 -1
- package/dist/{queryCachePlugin-BzqxconG.d.mts → queryCachePlugin-C2lZjTxk.d.mts} +1 -1
- package/dist/{queryCachePlugin-DZHPOm9p.mjs → queryCachePlugin-CFWNH8aT.mjs} +12 -14
- package/dist/{rateLimitKey-BvOvcBDi.mjs → rateLimitKey-C4O-kPm0.mjs} +1 -1
- package/dist/{realtime-8tIQWZz4.mjs → realtime-DmPE9S54.mjs} +25 -21
- package/dist/redis-stream-BMk-bpQS.d.mts +219 -0
- package/dist/{redis-Bzi1y3F9.d.mts → redis-vLvtcGy_.d.mts} +13 -24
- package/dist/redisShapes-CQksY67q.d.mts +55 -0
- package/dist/registry/index.d.mts +9 -4
- package/dist/registry/index.mjs +4 -4
- package/dist/{registry-DNkgGQcK.mjs → registry-Bcz9G1bh.mjs} +10 -8
- package/dist/{renewingLease-yF8BdW4b.mjs → renewingLease-qODa7KJQ.mjs} +1 -1
- package/dist/{replyHelpers-CNdvMfM4.mjs → replyHelpers-CG_VtVgS.mjs} +2 -2
- package/dist/{requestContext-cDkAUr-P.mjs → requestContext-Dsu9P1bV.mjs} +1 -1
- package/dist/requirement-CbiLdQ1n.d.mts +22 -0
- package/dist/requirement-KDdoRcOP.mjs +35 -0
- package/dist/resourceRateLimit-Wf6d6FL9.d.mts +30 -0
- package/dist/resourceRateLimit-dSjVr1pk.mjs +180 -0
- package/dist/{rolldown-runtime-eysyzFAF.mjs → rolldown-runtime-D1w9Y1VJ.mjs} +1 -1
- package/dist/routeValidator-D36SW8qt.mjs +70 -0
- package/dist/{runtimeCapabilities-CkhS6jn6.mjs → runtimeCapabilities-0tccjRlj.mjs} +1 -1
- package/dist/{schedules-j6uXXAeJ.mjs → schedules-C-OpmHBq.mjs} +46 -37
- package/dist/{schemaConverter-BVA7cFRG.mjs → schemaConverter-BORek3O-.mjs} +2 -2
- package/dist/{schemaIR-CTvPDoPB.mjs → schemaIR-C7Vbp71I.mjs} +2 -2
- package/dist/schemas/index.d.mts +10 -0
- package/dist/schemas/index.mjs +8 -3
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.d.mts +2 -2
- package/dist/scope/index.mjs +6 -6
- package/dist/{scope-BUi1xV1I.mjs → scope-DQthe88b.mjs} +4 -4
- package/dist/shutdown-MqA81z_P.mjs +59 -0
- package/dist/{simpleEqualityMatcher-C9bzq2gO.mjs → simpleEqualityMatcher-auW8QjXN.mjs} +1 -1
- package/dist/{sse-BeqVKQKu.mjs → sse-CYzQBVFe.mjs} +11 -15
- package/dist/{sseStream-Ppzo-WUH.mjs → sseStream-B5_Afiqn.mjs} +2 -2
- package/dist/{store-helpers-dW71XVWL.mjs → store-helpers-BOzk-CuX.mjs} +1 -1
- package/dist/{streaming-IcRFjWQU.mjs → streaming-DjTQhZrN.mjs} +1 -1
- package/dist/subscriberIdentity-CW39uA8G.mjs +28 -0
- package/dist/tenancy--ed9eH_z.mjs +43 -0
- package/dist/tenantPreparation-BKon6Yox.mjs +67 -0
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +193 -175
- package/dist/testing/index.mjs +286 -212
- package/dist/testing/outboxStoreContract.mjs +137 -2
- package/dist/testing/requiredPorts.d.mts +17 -0
- package/dist/testing/requiredPorts.mjs +65 -0
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/timing-qczZ0YC-.mjs +46 -0
- package/dist/{transactionContext-CPbdlnVw.mjs → transactionContext-DjFkrNG6.mjs} +1 -1
- package/dist/{typeGuards-BLjPgVBm.mjs → typeGuards-CySF12G-.mjs} +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +1 -1
- package/dist/types/storage.mjs +1 -1
- package/dist/{types-CWQn9-IC.d.mts → types-B4Aq4Sdj.d.mts} +22 -9
- package/dist/{types-DfVDvkdP.d.mts → types-BJ-2XqVF.d.mts} +189 -204
- package/dist/{types-CgenB1gv.mjs → types-Bk9NOgOC.mjs} +4 -4
- package/dist/usage/index.d.mts +2 -3
- package/dist/usage/index.mjs +5 -5
- package/dist/{userHelpers-ChRvkuSZ.mjs → userHelpers-aklawRaK.mjs} +1 -1
- package/dist/utils/index.d.mts +84 -223
- package/dist/utils/index.mjs +13 -12
- package/dist/{utils-CxcctrAh.mjs → utils-ec1oTo1n.mjs} +315 -404
- package/dist/{validate-DrYWnOzI.mjs → validate-9yzHC1e2.mjs} +6 -14
- package/dist/{versioning-D6JIK8Tk.d.mts → versioning-Bsb51gGT.d.mts} +28 -13
- package/dist/{versioning-DKkT4hNJ.mjs → versioning-fhhWHV74.mjs} +4 -4
- package/dist/{websocket-BOXVggMf.d.mts → websocket-Cs4awVyD.d.mts} +1 -1
- package/dist/{workScope-CxKqoIFn.mjs → workScope-zpPyge4t.mjs} +2 -2
- package/package.json +16 -12
- package/skills/arc/SKILL.md +13 -4
- package/skills/arc/references/auth.md +8 -5
- package/skills/arc/references/integrations.md +1 -1
- package/skills/arc/references/mcp.md +8 -6
- package/skills/arc/references/multi-tenancy.md +19 -14
- package/skills/arc/references/production.md +27 -10
- package/dist/actionPermissions-BoPGQ5-4.mjs +0 -350
- package/dist/index-CFfLKMH4.d.mts +0 -290
- package/dist/interface-YzIbF7Ii.mjs +0 -17
- package/dist/redis-stream-BPKscsTB.d.mts +0 -260
- package/dist/registerRoute-Bsnk6NiZ.mjs +0 -364
- package/dist/sync/changelog.d.mts +0 -3
- package/dist/sync/changelog.mjs +0 -3
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as AnyRecord } from "../base-
|
|
3
|
-
import {
|
|
2
|
+
import { t as AnyRecord } from "../base-CZyixEQR.mjs";
|
|
3
|
+
import { Et as RouteDefinition, J as MiddlewareConfig, U as PresetHook, X as RouteSchemaOptions } from "../index-mqaqZNpe.mjs";
|
|
4
4
|
import { i as errorHandlerPlugin, n as ErrorMapper, r as defaultIsDuplicateKeyError, t as ErrorHandlerOptions } from "../errorHandler--4rSMMvq.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { C as _default$8, E as _default$3, S as SchedulesPluginOptions, T as HealthOptions, b as ScheduleDefinition, w as HealthCheck, x as ScheduleStats } from "../types-BJ-2XqVF.mjs";
|
|
6
|
+
import { i as _default, n as ArcCorePluginOptions, r as PluginMeta, t as ArcCore } from "../fastify-augmentation-DhUJ-mvo.mjs";
|
|
7
|
+
import { _ as _default$2, a as MetricsOptions, c as RealtimeOptions, d as _default$9, f as CachingOptions, g as ShutdownState, h as GracefulShutdownOptions, i as MetricsCollector, l as _default$6, m as _default$1, n as _default$10, o as _default$4, p as CachingRule, r as MetricEntry, s as ChangeOperation, t as VersioningOptions, u as SSEOptions } from "../versioning-Bsb51gGT.mjs";
|
|
8
8
|
import { t as TracingOptions } from "../tracing-Dro5eH6j.mjs";
|
|
9
9
|
import { PaginatedResult } from "@classytic/repo-core/pagination";
|
|
10
10
|
import { FastifyInstance, FastifyPluginAsync } from "fastify";
|
|
@@ -19,7 +19,7 @@ interface PluginResourceResult {
|
|
|
19
19
|
/** Schema options to merge */
|
|
20
20
|
schemaOptions?: RouteSchemaOptions;
|
|
21
21
|
}
|
|
22
|
-
interface CreatePluginDefinition<TRootOpts extends
|
|
22
|
+
interface CreatePluginDefinition<TRootOpts extends object = AnyRecord, TResourceOpts extends object = AnyRecord> {
|
|
23
23
|
/**
|
|
24
24
|
* Global setup function. Called once when the plugin is registered on the Fastify instance.
|
|
25
25
|
* Use this for database connections, decorators, shared state, etc.
|
|
@@ -36,7 +36,7 @@ interface CreatePluginDefinition<TRootOpts extends AnyRecord = AnyRecord, TResou
|
|
|
36
36
|
*/
|
|
37
37
|
forResource?: (opts: TResourceOpts) => PluginResourceResult;
|
|
38
38
|
}
|
|
39
|
-
interface ArcPlugin<TRootOpts extends
|
|
39
|
+
interface ArcPlugin<TRootOpts extends object = AnyRecord, TResourceOpts extends object = AnyRecord> {
|
|
40
40
|
/** Plugin name */
|
|
41
41
|
readonly name: string;
|
|
42
42
|
/**
|
|
@@ -57,7 +57,7 @@ interface ArcPlugin<TRootOpts extends AnyRecord = AnyRecord, TResourceOpts exten
|
|
|
57
57
|
* @param definition - Plugin setup functions
|
|
58
58
|
* @returns ArcPlugin with forRoot() and forResource() methods
|
|
59
59
|
*/
|
|
60
|
-
declare function createPlugin<TRootOpts extends
|
|
60
|
+
declare function createPlugin<TRootOpts extends object = AnyRecord, TResourceOpts extends object = AnyRecord>(name: string, definition: CreatePluginDefinition<TRootOpts, TResourceOpts>): ArcPlugin<TRootOpts, TResourceOpts>;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/plugins/pressure.d.ts
|
|
63
63
|
/**
|
|
@@ -95,6 +95,11 @@ interface PressureOptions {
|
|
|
95
95
|
thresholds?: PressureThresholds;
|
|
96
96
|
/** Sampling cadence in ms. Default 1000. */
|
|
97
97
|
intervalMs?: number;
|
|
98
|
+
/**
|
|
99
|
+
* How long one signal read may take before it counts as "cannot measure" (reported as 0, like a
|
|
100
|
+
* throwing reader). A stuck read is never restarted while pending. Default: `intervalMs`.
|
|
101
|
+
*/
|
|
102
|
+
readTimeoutMs?: number;
|
|
98
103
|
/** Include the built-in event-loop-utilisation signal. Default true. */
|
|
99
104
|
eventLoopUtilization?: boolean;
|
|
100
105
|
/** Fired when the state CHANGES — not on every sample. */
|
|
@@ -136,7 +141,6 @@ declare module "fastify" {
|
|
|
136
141
|
pressure: PressureApi;
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
|
-
declare const pressurePlugin: FastifyPluginAsync<PressureOptions>;
|
|
140
144
|
/**
|
|
141
145
|
* `fp()`-wrapped so `fastify.pressure` is visible to the whole app rather than
|
|
142
146
|
* trapped in this plugin's encapsulation context — the named export above is
|
|
@@ -220,7 +224,6 @@ declare function sanitizeRequestId(value: unknown): string | undefined;
|
|
|
220
224
|
declare function createRequestIdGenerator(opts?: Pick<RequestIdOptions, "header" | "generator">): (req: {
|
|
221
225
|
headers: Record<string, string | string[] | undefined>;
|
|
222
226
|
}) => string;
|
|
223
|
-
declare const requestIdPlugin: FastifyPluginAsync<RequestIdOptions>;
|
|
224
227
|
declare const _default$7: FastifyPluginAsync<RequestIdOptions>;
|
|
225
228
|
//#endregion
|
|
226
|
-
export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type ChangeOperation, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type PressureApi, type PressureOptions, type PressureSignal, type PressureSnapshot, type PressureState, type PressureThresholds, type RealtimeOptions, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleStats, type SchedulesPluginOptions, type ShutdownState, type TracingOptions, type VersioningOptions, _default as arcCorePlugin,
|
|
229
|
+
export { type ArcCore, type ArcCorePluginOptions, type ArcPlugin, type CachingOptions, type CachingRule, type ChangeOperation, type CreatePluginDefinition, type ErrorHandlerOptions, type ErrorMapper, type GracefulShutdownOptions, type HealthCheck, type HealthOptions, type MetricEntry, type MetricsCollector, type MetricsOptions, type PluginMeta, type PluginResourceResult, type PressureApi, type PressureOptions, type PressureSignal, type PressureSnapshot, type PressureState, type PressureThresholds, type RealtimeOptions, type RequestIdOptions, type SSEOptions, type ScheduleDefinition, type ScheduleStats, type SchedulesPluginOptions, type ShutdownState, type TracingOptions, type VersioningOptions, _default as arcCorePlugin, _default$1 as cachingPlugin, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, _default$2 as gracefulShutdownPlugin, _default$3 as healthPlugin, _default$4 as metricsPlugin, _default$5 as pressurePlugin, _default$6 as realtimePlugin, replyHelpersPlugin, _default$7 as requestIdPlugin, sanitizeRequestId, _default$8 as schedulesPlugin, _default$9 as ssePlugin, _default$10 as versioningPlugin };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import {
|
|
3
|
-
import { arcLog } from "../logger
|
|
4
|
-
import { c as getOrgId } from "../types-
|
|
5
|
-
import { n as requestContext } from "../requestContext-
|
|
6
|
-
import { t as hasEvents } from "../typeGuards-
|
|
7
|
-
import { t as HookSystem } from "../HookSystem-
|
|
8
|
-
import { t as ResourceRegistry } from "../ResourceRegistry-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { t as replyHelpersPlugin } from "../replyHelpers-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
1
|
+
/*! @classytic/arc v2.43.0 | MIT | https://classytic.com */
|
|
2
|
+
import { m as MUTATION_OPERATIONS } from "../constants-Cu7Mx7_U.mjs";
|
|
3
|
+
import { t as arcLog } from "../logger-DXjfIqjV.mjs";
|
|
4
|
+
import { c as getOrgId } from "../types-Bk9NOgOC.mjs";
|
|
5
|
+
import { n as requestContext } from "../requestContext-Dsu9P1bV.mjs";
|
|
6
|
+
import { t as hasEvents } from "../typeGuards-CySF12G-.mjs";
|
|
7
|
+
import { t as HookSystem } from "../HookSystem-B6UaKRbF.mjs";
|
|
8
|
+
import { t as ResourceRegistry } from "../ResourceRegistry-CuCARu2B.mjs";
|
|
9
|
+
import { c as createRequestIdGenerator, l as requestId_default, n as health_default, u as sanitizeRequestId } from "../health-DqbsG-_w.mjs";
|
|
10
|
+
import { t as caching_default } from "../caching-Cc2M1DwO.mjs";
|
|
11
|
+
import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-BnfDviL1.mjs";
|
|
12
|
+
import { t as metrics_default } from "../metrics-CWI11eRu.mjs";
|
|
13
|
+
import { t as realtime_default } from "../realtime-DmPE9S54.mjs";
|
|
14
|
+
import { t as replyHelpersPlugin } from "../replyHelpers-CG_VtVgS.mjs";
|
|
15
|
+
import { t as schedules_default } from "../schedules-C-OpmHBq.mjs";
|
|
16
|
+
import { t as sse_default } from "../sse-CYzQBVFe.mjs";
|
|
17
|
+
import { t as versioning_default } from "../versioning-fhhWHV74.mjs";
|
|
18
18
|
import fp from "fastify-plugin";
|
|
19
19
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
20
20
|
//#region src/core/arcCorePlugin.ts
|
|
@@ -106,7 +106,7 @@ const arcCorePlugin = async (fastify, opts = {}) => {
|
|
|
106
106
|
});
|
|
107
107
|
fastify.addHook("onClose", async () => {
|
|
108
108
|
actualHookSystem.clear();
|
|
109
|
-
actualRegistry.
|
|
109
|
+
actualRegistry.reset();
|
|
110
110
|
});
|
|
111
111
|
fastify.log?.debug?.("Arc core plugin enabled (instance-scoped hooks & registry)");
|
|
112
112
|
};
|
|
@@ -277,13 +277,30 @@ const pressurePlugin = async (fastify, options) => {
|
|
|
277
277
|
worst: void 0,
|
|
278
278
|
signals: {}
|
|
279
279
|
};
|
|
280
|
+
const intervalMs = options.intervalMs ?? 1e3;
|
|
281
|
+
const readTimeoutMs = options.readTimeoutMs ?? intervalMs;
|
|
282
|
+
/** A signal whose read has not settled is not read again — the next sample waits on the same read. */
|
|
283
|
+
const pendingReads = /* @__PURE__ */ new Map();
|
|
284
|
+
const readSignal = (signal) => {
|
|
285
|
+
let read = pendingReads.get(signal.name);
|
|
286
|
+
if (!read) {
|
|
287
|
+
read = Promise.resolve().then(() => signal.read()).finally(() => pendingReads.delete(signal.name));
|
|
288
|
+
pendingReads.set(signal.name, read);
|
|
289
|
+
}
|
|
290
|
+
let timer;
|
|
291
|
+
const timeout = new Promise((_, reject) => {
|
|
292
|
+
timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`read exceeded ${readTimeoutMs}ms`)), readTimeoutMs);
|
|
293
|
+
timer.unref?.();
|
|
294
|
+
});
|
|
295
|
+
return Promise.race([read, timeout]).finally(() => clearTimeout(timer));
|
|
296
|
+
};
|
|
280
297
|
async function sample() {
|
|
281
298
|
const values = {};
|
|
282
299
|
let worst;
|
|
283
300
|
for (const signal of signals) {
|
|
284
301
|
let value = 0;
|
|
285
302
|
try {
|
|
286
|
-
value = clamp(await signal
|
|
303
|
+
value = clamp(await readSignal(signal));
|
|
287
304
|
broken.delete(signal.name);
|
|
288
305
|
} catch (error) {
|
|
289
306
|
if (!broken.has(signal.name)) {
|
|
@@ -317,9 +334,14 @@ const pressurePlugin = async (fastify, options) => {
|
|
|
317
334
|
options.onStateChange?.(next, snapshot);
|
|
318
335
|
}
|
|
319
336
|
}
|
|
337
|
+
let sampling = false;
|
|
320
338
|
const timer = setInterval(() => {
|
|
321
|
-
|
|
322
|
-
|
|
339
|
+
if (sampling) return;
|
|
340
|
+
sampling = true;
|
|
341
|
+
sample().finally(() => {
|
|
342
|
+
sampling = false;
|
|
343
|
+
});
|
|
344
|
+
}, intervalMs);
|
|
323
345
|
timer.unref?.();
|
|
324
346
|
fastify.addHook("onClose", async () => clearInterval(timer));
|
|
325
347
|
fastify.decorate("pressure", {
|
|
@@ -368,4 +390,4 @@ var pressure_default = fp(pressurePlugin, {
|
|
|
368
390
|
fastify: "5.x"
|
|
369
391
|
});
|
|
370
392
|
//#endregion
|
|
371
|
-
export { arcCorePlugin_default as arcCorePlugin,
|
|
393
|
+
export { arcCorePlugin_default as arcCorePlugin, caching_default as cachingPlugin, createPlugin, createRequestIdGenerator, defaultIsDuplicateKeyError, errorHandlerPlugin, gracefulShutdown_default as gracefulShutdownPlugin, health_default as healthPlugin, metrics_default as metricsPlugin, pressure_default as pressurePlugin, realtime_default as realtimePlugin, replyHelpersPlugin, requestId_default as requestIdPlugin, sanitizeRequestId, schedules_default as schedulesPlugin, sse_default as ssePlugin, versioning_default as versioningPlugin };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { n as declareRuntimeCapability } from "../runtimeCapabilities-
|
|
3
|
-
import { t as hasEvents } from "../typeGuards-
|
|
1
|
+
/*! @classytic/arc v2.43.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as declareRuntimeCapability } from "../runtimeCapabilities-0tccjRlj.mjs";
|
|
3
|
+
import { t as hasEvents } from "../typeGuards-CySF12G-.mjs";
|
|
4
|
+
import { n as evictToSize, r as touch, t as assertCapacity } from "../boundedMap-BULzfXYU.mjs";
|
|
4
5
|
import fp from "fastify-plugin";
|
|
5
6
|
//#region src/plugins/response-cache.ts
|
|
6
7
|
/**
|
|
@@ -28,22 +29,14 @@ var LRUCache = class {
|
|
|
28
29
|
this.misses++;
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
this.cache
|
|
32
|
-
this.cache.set(key, entry);
|
|
32
|
+
touch(this.cache, key, entry);
|
|
33
33
|
this.hits++;
|
|
34
34
|
return entry;
|
|
35
35
|
}
|
|
36
36
|
set(key, entry) {
|
|
37
37
|
if (this.isPrefixLocked(key)) return;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const firstKey = this.cache.keys().next().value;
|
|
41
|
-
if (firstKey !== void 0) {
|
|
42
|
-
this.cache.delete(firstKey);
|
|
43
|
-
this.evictions++;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
this.cache.set(key, entry);
|
|
38
|
+
touch(this.cache, key, entry);
|
|
39
|
+
this.evictions += evictToSize(this.cache, this.maxEntries);
|
|
47
40
|
}
|
|
48
41
|
/** Invalidate entries matching a path prefix and lock it from caching to allow DB replicas to catch up */
|
|
49
42
|
invalidatePrefix(prefix, jitterMs = 1500) {
|
|
@@ -95,6 +88,7 @@ const responseCachePluginImpl = async (fastify, opts = {}) => {
|
|
|
95
88
|
"DELETE"
|
|
96
89
|
], xCacheHeader = true, statsPath = null, keyFn } = opts;
|
|
97
90
|
if (maxEntries > 5e3) fastify.log.warn(`[arc] responseCache maxEntries=${maxEntries}: prefix invalidation scans all entries synchronously on every mutating request — expect event-loop pauses at this size. This cache is an instance-local micro-cache; for large shared caching use the queryCache with a Redis store instead.`);
|
|
91
|
+
assertCapacity("responseCache maxEntries", maxEntries);
|
|
98
92
|
const cache = new LRUCache(maxEntries);
|
|
99
93
|
const invalidateMethods = new Set(invalidateOn.map((m) => m.toUpperCase()));
|
|
100
94
|
declareRuntimeCapability(fastify, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
1
|
+
/*! @classytic/arc v2.43.0 | MIT | https://classytic.com */
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fp from "fastify-plugin";
|
|
4
4
|
//#region src/plugins/tracing.ts
|
|
@@ -59,7 +59,7 @@ try {
|
|
|
59
59
|
function createTracerProvider(options) {
|
|
60
60
|
if (!isAvailable || !NodeTracerProvider || !BatchSpanProcessor || !OTLPTraceExporter) return null;
|
|
61
61
|
const { serviceName = "@classytic/arc", serviceVersion, exporterUrl = "http://localhost:4318/v1/traces" } = options;
|
|
62
|
-
const resolvedVersion = serviceVersion ?? "2.
|
|
62
|
+
const resolvedVersion = serviceVersion ?? "2.43.0";
|
|
63
63
|
const exporter = new OTLPTraceExporter({ url: exporterUrl });
|
|
64
64
|
const provider = new NodeTracerProvider({ resource: { attributes: {
|
|
65
65
|
"service.name": serviceName,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { i as RequestScope } from "../types-Ddl9OjmE.mjs";
|
|
3
|
-
import { l as PermissionCheck } from "../base-
|
|
4
|
-
import {
|
|
3
|
+
import { l as PermissionCheck } from "../base-CZyixEQR.mjs";
|
|
4
|
+
import { W as PresetResult } from "../index-mqaqZNpe.mjs";
|
|
5
5
|
import { a as StorageReadResult, i as StorageReadRange, n as StorageContext, o as StorageUploadInput, r as StorageFile, t as Storage } from "../storage-Cx9Sz3Ou.mjs";
|
|
6
6
|
//#region src/presets/filesUpload.d.ts
|
|
7
7
|
interface FilesUploadPresetRoutes {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import { i as NotFoundError, u as ValidationError } from "../errors-
|
|
3
|
-
import { c as getOrgId, g as getUserId } from "../types-
|
|
4
|
-
import { B as requireAuth, F as allowPublic } from "../permissions-
|
|
5
|
-
import { t as multipartBody } from "../multipartBody-
|
|
1
|
+
/*! @classytic/arc v2.43.0 | MIT | https://classytic.com */
|
|
2
|
+
import { i as NotFoundError, u as ValidationError } from "../errors-CtrywMHP.mjs";
|
|
3
|
+
import { c as getOrgId, g as getUserId } from "../types-Bk9NOgOC.mjs";
|
|
4
|
+
import { B as requireAuth, F as allowPublic } from "../permissions-Cm0uYHvd.mjs";
|
|
5
|
+
import { t as multipartBody } from "../multipartBody-CXM2a-Dy.mjs";
|
|
6
6
|
//#region src/presets/filesUpload.ts
|
|
7
7
|
const DEFAULT_FIELD_NAME = "file";
|
|
8
8
|
const DEFAULT_MAX_FILE_SIZE = 10485760;
|
package/dist/presets/index.d.mts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as AnyRecord } from "../base-
|
|
3
|
-
import {
|
|
2
|
+
import { t as AnyRecord } from "../base-CZyixEQR.mjs";
|
|
3
|
+
import { In as IControllerResponse, L as ResourceConfig, Ln as IRequestContext, W as PresetResult, i as PaginationResult } from "../index-mqaqZNpe.mjs";
|
|
4
4
|
import { FilesUploadPresetOptions, FilesUploadPresetPermissions, FilesUploadPresetRoutes, filesUploadPreset } from "./filesUpload.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { n as multiTenantPreset, r as TenantFieldSpec, t as MultiTenantOptions } from "../multiTenant-cY0FkDiA.mjs";
|
|
6
6
|
import { SearchHandler, SearchPresetOptions, SearchRouteConfig, searchPreset } from "./search.mjs";
|
|
7
|
+
//#region src/presets/audited.d.ts
|
|
8
|
+
interface AuditedPresetOptions {
|
|
9
|
+
/** Field name for creator (default: 'createdBy') */
|
|
10
|
+
createdByField?: string;
|
|
11
|
+
/** Field name for updater (default: 'updatedBy') */
|
|
12
|
+
updatedByField?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Audited preset - adds createdBy/updatedBy tracking
|
|
16
|
+
*/
|
|
17
|
+
declare function auditedPreset(options?: AuditedPresetOptions): PresetResult;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/presets/bulk.d.ts
|
|
20
|
+
type BulkOperation = "createMany" | "updateMany" | "deleteMany";
|
|
21
|
+
interface BulkPresetOptions {
|
|
22
|
+
/** Which bulk operations to enable (default: all three) */
|
|
23
|
+
operations?: BulkOperation[];
|
|
24
|
+
/** Max items per bulk create (default: 1000) */
|
|
25
|
+
maxCreateItems?: number;
|
|
26
|
+
}
|
|
27
|
+
declare function bulkPreset(opts?: BulkPresetOptions): PresetResult;
|
|
28
|
+
//#endregion
|
|
7
29
|
//#region src/presets/ownedByUser.d.ts
|
|
8
30
|
interface OwnedByUserOptions {
|
|
9
31
|
ownerField?: string;
|
|
@@ -31,28 +53,6 @@ declare function slugLookupPreset(options?: SlugLookupOptions): PresetResult;
|
|
|
31
53
|
//#region src/presets/softDelete.d.ts
|
|
32
54
|
declare function softDeletePreset(): PresetResult;
|
|
33
55
|
//#endregion
|
|
34
|
-
//#region src/presets/audited.d.ts
|
|
35
|
-
interface AuditedPresetOptions {
|
|
36
|
-
/** Field name for creator (default: 'createdBy') */
|
|
37
|
-
createdByField?: string;
|
|
38
|
-
/** Field name for updater (default: 'updatedBy') */
|
|
39
|
-
updatedByField?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Audited preset - adds createdBy/updatedBy tracking
|
|
43
|
-
*/
|
|
44
|
-
declare function auditedPreset(options?: AuditedPresetOptions): PresetResult;
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/presets/bulk.d.ts
|
|
47
|
-
type BulkOperation = "createMany" | "updateMany" | "deleteMany";
|
|
48
|
-
interface BulkPresetOptions {
|
|
49
|
-
/** Which bulk operations to enable (default: all three) */
|
|
50
|
-
operations?: BulkOperation[];
|
|
51
|
-
/** Max items per bulk create (default: 1000) */
|
|
52
|
-
maxCreateItems?: number;
|
|
53
|
-
}
|
|
54
|
-
declare function bulkPreset(opts?: BulkPresetOptions): PresetResult;
|
|
55
|
-
//#endregion
|
|
56
56
|
//#region src/presets/tree.d.ts
|
|
57
57
|
interface TreeOptions {
|
|
58
58
|
parentField?: string;
|
|
@@ -267,11 +267,6 @@ type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) exten
|
|
|
267
267
|
type IPresetController<TDoc = unknown, TPresets extends keyof PresetControllerContracts<TDoc> = never> = UnionToIntersection<PresetControllerContracts<TDoc>[TPresets]>;
|
|
268
268
|
//#endregion
|
|
269
269
|
//#region src/presets/index.d.ts
|
|
270
|
-
/**
|
|
271
|
-
* Convenience alias for multiTenantPreset with public list/get routes
|
|
272
|
-
* Equivalent to: multiTenantPreset({ allowPublic: ['list', 'get'] })
|
|
273
|
-
*/
|
|
274
|
-
declare const flexibleMultiTenantPreset: (options?: Omit<MultiTenantOptions, "allowPublic">) => PresetResult;
|
|
275
270
|
type PresetFactory = (options?: AnyRecord) => PresetResult;
|
|
276
271
|
/**
|
|
277
272
|
* Get preset by name with options
|
|
@@ -300,4 +295,4 @@ type PresetInput = string | PresetResult | {
|
|
|
300
295
|
*/
|
|
301
296
|
declare function applyPresets<TDoc = AnyRecord>(config: ResourceConfig<TDoc>, presets?: PresetInput[]): ResourceConfig<TDoc>;
|
|
302
297
|
//#endregion
|
|
303
|
-
export { type AuditedPresetOptions, type BulkOperation, type BulkPresetOptions, type FilesUploadPresetOptions, type FilesUploadPresetPermissions, type FilesUploadPresetRoutes, type IAuditedPreset, type IMultiTenantPreset, type IOwnedByUserPreset, type IPresetController, type ISlugLookupController, type ISoftDeleteController, type ITreeController, type MultiTenantOptions, type OwnedByUserOptions, type SearchHandler, type SearchPresetOptions, type SearchRouteConfig, type SlugLookupOptions, type TenantFieldSpec, type TreeOptions, applyPresets, auditedPreset, bulkPreset, filesUploadPreset,
|
|
298
|
+
export { type AuditedPresetOptions, type BulkOperation, type BulkPresetOptions, type FilesUploadPresetOptions, type FilesUploadPresetPermissions, type FilesUploadPresetRoutes, type IAuditedPreset, type IMultiTenantPreset, type IOwnedByUserPreset, type IPresetController, type ISlugLookupController, type ISoftDeleteController, type ITreeController, type MultiTenantOptions, type OwnedByUserOptions, PresetInput, type SearchHandler, type SearchPresetOptions, type SearchRouteConfig, type SlugLookupOptions, type TenantFieldSpec, type TreeOptions, applyPresets, auditedPreset, bulkPreset, filesUploadPreset, getAvailablePresets, getPreset, multiTenantPreset, ownedByUserPreset, registerPreset, searchPreset, slugLookupPreset, softDeletePreset, treePreset };
|
package/dist/presets/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/*! @classytic/arc v2.
|
|
2
|
-
import {
|
|
3
|
-
import { a as registerPreset, c as auditedPreset, d as ownedByUserPreset, i as getPreset, l as softDeletePreset, n as flexibleMultiTenantPreset, o as treePreset, r as getAvailablePresets, s as bulkPreset, t as applyPresets, u as slugLookupPreset } from "../presets-ZJSPgmT2.mjs";
|
|
1
|
+
/*! @classytic/arc v2.43.0 | MIT | https://classytic.com */
|
|
2
|
+
import { a as treePreset, c as ownedByUserPreset, i as registerPreset, l as bulkPreset, n as getAvailablePresets, o as softDeletePreset, r as getPreset, s as slugLookupPreset, t as applyPresets, u as auditedPreset } from "../presets-Cpvj6fGO.mjs";
|
|
4
3
|
import { filesUploadPreset } from "./filesUpload.mjs";
|
|
4
|
+
import { multiTenantPreset } from "./multiTenant.mjs";
|
|
5
5
|
import { searchPreset } from "./search.mjs";
|
|
6
|
-
export { applyPresets, auditedPreset, bulkPreset, filesUploadPreset,
|
|
6
|
+
export { applyPresets, auditedPreset, bulkPreset, filesUploadPreset, getAvailablePresets, getPreset, multiTenantPreset, ownedByUserPreset, registerPreset, searchPreset, slugLookupPreset, softDeletePreset, treePreset };
|
|
@@ -1,108 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* One tenant dimension for multi-field filtering. Discriminated by source:
|
|
6
|
-
* - `type: 'org'` → reads `getOrgId(scope)`
|
|
7
|
-
* - `type: 'team'` → reads `getTeamId(scope)`
|
|
8
|
-
* - `contextKey` → reads `getScopeContext(scope, contextKey)` (any custom dimension)
|
|
9
|
-
*/
|
|
10
|
-
type TenantFieldSpec = {
|
|
11
|
-
field: string;
|
|
12
|
-
type: "org";
|
|
13
|
-
} | {
|
|
14
|
-
field: string;
|
|
15
|
-
type: "team";
|
|
16
|
-
} | {
|
|
17
|
-
field: string;
|
|
18
|
-
contextKey: string;
|
|
19
|
-
};
|
|
20
|
-
interface MultiTenantOptions {
|
|
21
|
-
/**
|
|
22
|
-
* Single-field form: name of the database field to filter by.
|
|
23
|
-
* Reads `getOrgId(scope)` as the value source.
|
|
24
|
-
*
|
|
25
|
-
* Mutually exclusive with `tenantFields` — pass one or the other, not both.
|
|
26
|
-
*
|
|
27
|
-
* @default 'organizationId'
|
|
28
|
-
*/
|
|
29
|
-
tenantField?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Multi-field form (2.7.1+): list of tenant dimensions to filter by in
|
|
32
|
-
* lockstep. Use this when a resource is scoped by more than just
|
|
33
|
-
* organization — e.g. organization + branch, organization + project,
|
|
34
|
-
* or organization + team + workspace.
|
|
35
|
-
*
|
|
36
|
-
* Each entry is a discriminated `TenantFieldSpec` declaring where the
|
|
37
|
-
* value comes from. Use `type: 'org'` / `type: 'team'` for built-in scope
|
|
38
|
-
* fields, or `contextKey: '...'` to read from `scope.context` (set by
|
|
39
|
-
* your auth function).
|
|
40
|
-
*
|
|
41
|
-
* Fail-closed: if any required dimension is missing, the request is
|
|
42
|
-
* rejected. Elevated scopes apply whatever resolves and skip the rest.
|
|
43
|
-
*
|
|
44
|
-
* Mutually exclusive with `tenantField`.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* multiTenantPreset({
|
|
49
|
-
* tenantFields: [
|
|
50
|
-
* { field: 'organizationId', type: 'org' },
|
|
51
|
-
* { field: 'branchId', contextKey: 'branchId' },
|
|
52
|
-
* ],
|
|
53
|
-
* })
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
tenantFields?: readonly TenantFieldSpec[];
|
|
57
|
-
/**
|
|
58
|
-
* Routes that allow public access (no auth required)
|
|
59
|
-
* When a route is in this array:
|
|
60
|
-
* - If no org context: allow through without filtering (public data)
|
|
61
|
-
* - If org context present: require auth and apply filter
|
|
62
|
-
*
|
|
63
|
-
* @default [] (strict mode - all routes require auth)
|
|
64
|
-
* @example
|
|
65
|
-
* multiTenantPreset({ allowPublic: ['list', 'get'] })
|
|
66
|
-
*/
|
|
67
|
-
allowPublic?: CrudRouteKey[];
|
|
68
|
-
/**
|
|
69
|
-
* Reads that are NOT scoped to a tenant at all — a marketplace listing.
|
|
70
|
-
*
|
|
71
|
-
* `allowPublic` answers "may an anonymous caller reach this route?". That is a different
|
|
72
|
-
* question from "is this listing scoped to a tenant?", and until this option there was no way
|
|
73
|
-
* to answer the second one with "no". An `allowPublic` route still filters by the caller's
|
|
74
|
-
* organization whenever they have one, and a signed-in user of a multi-org product ALWAYS has
|
|
75
|
-
* one, because choosing an organization writes it onto the session. So a cross-tenant catalog
|
|
76
|
-
* silently became single-tenant the moment one of its own sellers browsed it: the same URL,
|
|
77
|
-
* with no header and no query parameter to explain the difference, returned a different world
|
|
78
|
-
* depending on who was asking.
|
|
79
|
-
*
|
|
80
|
-
* The only escape was to drop this preset from the resource entirely, which also drops tenant
|
|
81
|
-
* INJECTION on create/update — the thing that stops a member moving a document into another
|
|
82
|
-
* organization. Trading a write guarantee for a read behaviour is not a real choice.
|
|
83
|
-
*
|
|
84
|
-
* Listed routes get no tenant middleware: no filter, and nothing stashed for the repo layer.
|
|
85
|
-
* Everything else keeps its filter, so writes are unaffected.
|
|
86
|
-
*
|
|
87
|
-
* READS ONLY, by type. A cross-tenant `create` or `update` is not a listing, it is an escape
|
|
88
|
-
* from tenancy, and it should never be one option away by accident.
|
|
89
|
-
*
|
|
90
|
-
* THIS DOES NOT AUTHORIZE ANYTHING. Removing the tenant filter widens what the query can
|
|
91
|
-
* return, so the resource owes a row-level `policy` from its permission check saying what a
|
|
92
|
-
* stranger may see (`{ status: 'active' }`, `{ visibility: 'public' }`). Declaring this without
|
|
93
|
-
* one publishes every row in every tenant.
|
|
94
|
-
*
|
|
95
|
-
* @default []
|
|
96
|
-
* @example
|
|
97
|
-
* // A public catalog: anyone may browse every seller's LIVE products,
|
|
98
|
-
* // while create/update/delete stay pinned to the caller's own shop.
|
|
99
|
-
* multiTenantPreset({
|
|
100
|
-
* allowPublic: ['list', 'get'],
|
|
101
|
-
* crossTenant: ['list', 'get'],
|
|
102
|
-
* })
|
|
103
|
-
*/
|
|
104
|
-
crossTenant?: readonly Extract<CrudRouteKey, "list" | "get">[];
|
|
105
|
-
}
|
|
106
|
-
declare function multiTenantPreset(options?: MultiTenantOptions): PresetResult;
|
|
107
|
-
//#endregion
|
|
108
|
-
export { MultiTenantOptions, TenantFieldSpec, multiTenantPreset };
|
|
2
|
+
import { n as multiTenantPreset, r as TenantFieldSpec, t as MultiTenantOptions } from "../multiTenant-cY0FkDiA.mjs";
|
|
3
|
+
export { MultiTenantOptions, type TenantFieldSpec, multiTenantPreset };
|