@classytic/arc 2.41.1 → 2.44.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-DZWDsaPa.mjs} +22 -17
- package/dist/{HookSystem-CMF94SEA.mjs → HookSystem-yjEgn7Cm.mjs} +2 -2
- package/dist/{QueryCache-DFA-QrU9.d.mts → QueryCache--5uAuYPW.d.mts} +7 -3
- package/dist/{ResourceRegistry-MGpXoxHZ.mjs → ResourceRegistry-DJxHUpE4.mjs} +44 -13
- package/dist/acquire-BozJ-9yt.mjs +35 -0
- package/dist/actionPermissions-5N04zBL4.mjs +772 -0
- package/dist/audit/index.d.mts +46 -8
- package/dist/audit/index.mjs +48 -26
- package/dist/auth/audit.d.mts +8 -8
- package/dist/auth/audit.mjs +1 -1
- package/dist/auth/index.d.mts +46 -16
- package/dist/auth/index.mjs +134 -156
- package/dist/auth/redis-session.d.mts +4 -5
- package/dist/auth/redis-session.mjs +1 -1
- package/dist/{authorizationDecision-DawKGoXb.mjs → authorizationDecision-wX3SA9w_.mjs} +7 -102
- package/dist/{base-CxrV1LmG.d.mts → base-CZyixEQR.d.mts} +27 -5
- package/dist/boundedMap-DWiKW7lP.mjs +57 -0
- package/dist/{buildHandler-CvxKOc0m.mjs → buildHandler-Bswu_vNb.mjs} +4 -4
- package/dist/cache/index.d.mts +31 -43
- package/dist/cache/index.mjs +4 -4
- package/dist/{caching-DbCBxlgw.mjs → caching-Drp68DIS.mjs} +3 -3
- package/dist/claimed-DYvQoZLv.mjs +8 -0
- package/dist/cleanup/index.d.mts +18 -22
- package/dist/cleanup/index.mjs +27 -73
- package/dist/cli/commands/describe.d.mts +7 -5
- package/dist/cli/commands/describe.mjs +7 -4
- package/dist/cli/commands/docs.d.mts +2 -3
- package/dist/cli/commands/docs.mjs +3 -3
- package/dist/cli/commands/doctor.d.mts +2 -3
- package/dist/cli/commands/doctor.mjs +1 -1
- package/dist/cli/commands/generate.mjs +2 -3
- package/dist/cli/commands/init.mjs +2 -3
- package/dist/cli/commands/introspect.d.mts +2 -3
- package/dist/cli/commands/introspect.mjs +2 -2
- package/dist/cli/index.mjs +3 -3
- package/dist/{constants-D5Ubn1fe.mjs → constants-B2QHb6u6.mjs} +4 -2
- package/dist/context/index.d.mts +11 -14
- 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-COcqo0Cp.mjs} +15 -5
- package/dist/{createActionRouter-DNqoaK81.mjs → createActionRouter-zG13rpPJ.mjs} +97 -39
- package/dist/{createAggregationRouter-BcbQJf10.mjs → createAggregationRouter-CWRz96Vr.mjs} +11 -8
- package/dist/{preloadResources-f3boenVZ.mjs → createApp-BGLYtErt.mjs} +305 -394
- package/dist/{createMcpServer-CbDWkZ1T.d.mts → createMcpServer-DSztofa9.d.mts} +1 -1
- package/dist/{defineAggregation-D_eJjm5A.mjs → defineAggregation--3xguLkk.mjs} +1 -1
- package/dist/{defineResource-DxkMTjRn.mjs → defineResource-gUp9ug66.mjs} +118 -1024
- package/dist/discovery/index.d.mts +6 -7
- package/dist/discovery/index.mjs +1 -1
- package/dist/docs/index.d.mts +11 -5
- package/dist/docs/index.mjs +4 -4
- package/dist/{elevation-CkvG0LG2.mjs → elevation-BG4gnMsJ.mjs} +41 -12
- package/dist/{elevation-BXCfVcNG.d.mts → elevation-BW2J3tNj.d.mts} +1 -2
- package/dist/encryption/index.d.mts +5 -5
- package/dist/encryption/index.mjs +3 -3
- package/dist/{errorHandler-D1GHKGlV.mjs → errorHandler-COHw3N1b.mjs} +26 -5
- package/dist/{errors-BH7YU_9O.mjs → errors-CW4anJBy.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-BweHAVws.mjs} +82 -21
- package/dist/{subscribe-helpers-DatDkcuG.mjs → eventTypes-N4-omQFR.mjs} +151 -17
- package/dist/events/index.d.mts +43 -18
- 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 +5 -6
- package/dist/events/transports/redis.mjs +2 -2
- package/dist/factory/index.d.mts +42 -27
- package/dist/factory/index.mjs +213 -32
- package/dist/{fastify-augmentation-Cq2nHVaW.d.mts → fastify-augmentation-DRlCIWE9.d.mts} +11 -25
- package/dist/{fields-BHrkoF5y.mjs → fields-A5crhsJb.mjs} +1 -1
- package/dist/{fields-I_EeRWND.d.mts → fields-BBSpf8pS.d.mts} +1 -1
- package/dist/filter-merge-DGM-GQ1J.mjs +99 -0
- package/dist/{generate-BLRf2m3y.mjs → generate-BXKo2Gc8.mjs} +2 -2
- package/dist/{headers-BIXWKrzQ.mjs → headers-DKZQKL-Z.mjs} +2 -2
- package/dist/health-BYAwA6YS.mjs +22 -0
- package/dist/{health-ZRHeDHXH.mjs → health-CrqUp3sz.mjs} +115 -55
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.mjs +2 -3
- package/dist/idempotency/index.d.mts +36 -10
- package/dist/idempotency/index.mjs +230 -111
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +77 -12
- package/dist/{index-D4u76eQW.d.mts → index-Beg3aNnK.d.mts} +23 -101
- package/dist/{preloadResources-CjS2OfpU.d.mts → index-BkV55WlV.d.mts} +37 -38
- package/dist/{index-BHdZD8zK.d.mts → index-Bxriq3so.d.mts} +84 -21
- package/dist/index-CUJvoyw3.d.mts +510 -0
- package/dist/{index-CbJiYrfv.d.mts → index-Chgz3d0i.d.mts} +1 -1
- package/dist/{index-DHbyPo5j.d.mts → index-WH7xgvxS.d.mts} +304 -254
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +11 -11
- package/dist/{init-CpLkjU18.mjs → init-BPzK5Lnr.mjs} +1 -1
- package/dist/integrations/event-gateway.d.mts +11 -7
- 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 +102 -89
- package/dist/integrations/mcp/index.mjs +19 -4
- package/dist/integrations/mcp/testing.d.mts +8 -9
- package/dist/integrations/mcp/testing.mjs +2 -2
- package/dist/integrations/streamline.d.mts +85 -144
- package/dist/integrations/streamline.mjs +131 -55
- package/dist/integrations/webhooks.d.mts +83 -143
- package/dist/integrations/webhooks.mjs +36 -80
- package/dist/integrations/websocket-pushref-redis.d.mts +5 -6
- package/dist/integrations/websocket-pushref-redis.mjs +1 -1
- package/dist/integrations/websocket-redis.d.mts +5 -6
- 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-JJzwH4Ro.d.mts} +34 -2
- package/dist/{jsonBody-ELR9lfeU.mjs → jsonBody-YIq-vGLv.mjs} +2 -2
- package/dist/{keys-cpZCtcIE.mjs → keys-CpoiZ8hU.mjs} +7 -18
- package/dist/{loadResources-BPfWiI5s.mjs → loadResources-6jO52-RR.mjs} +3 -3
- package/dist/{loadResourcesFromEntry-ixtfL3J2.mjs → loadResourcesFromEntry-MP8xEppu.mjs} +2 -2
- package/dist/logger/index.d.mts +9 -17
- package/dist/logger/index.mjs +2 -153
- package/dist/logger-D4V1zGLI.mjs +160 -0
- package/dist/{mcpPlugin-BX5PujI0.mjs → mcpPlugin-srPc7ItN.mjs} +446 -170
- package/dist/{memory-Iotz0cCx.mjs → memory-CTa5pOCW.mjs} +36 -34
- package/dist/{metrics-NMsmpRmY.mjs → metrics-DsZrvnpB.mjs} +39 -72
- package/dist/middleware/index.d.mts +5 -5
- package/dist/middleware/index.mjs +3 -3
- package/dist/migrations/index.d.mts +13 -13
- package/dist/migrations/index.mjs +2 -2
- package/dist/{module-DpLJG2_N.mjs → module--L0iBIZz.mjs} +8 -8
- package/dist/mongodb-memory-server-CHhYSq5y.mjs +35539 -0
- package/dist/mongoose-CYJCLyi-.mjs +67451 -0
- package/dist/multiTenant-CAtYlW6H.d.mts +104 -0
- package/dist/{multipartBody-DtRWM6_U.mjs → multipartBody-Cc7eZ9cq.mjs} +46 -7
- package/dist/node-D8UZv_8c.mjs +41236 -0
- package/dist/{openapi-CmFf3yq_.mjs → openapi-CMegfsm8.mjs} +48 -10
- package/dist/outbox-admin/index.d.mts +5 -5
- package/dist/outbox-admin/index.mjs +6 -18
- package/dist/{outbox-module-D2z5WkDY.mjs → outbox-module-Ryk270jd.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-C5ijIz5Q.mjs} +149 -33
- package/dist/{pipe-FMWNheSO.mjs → pipe-D81zMtWs.mjs} +2 -2
- package/dist/pipeline/index.d.mts +7 -7
- package/dist/pipeline/index.mjs +2 -2
- package/dist/plan-CJGMKoui.mjs +565 -0
- package/dist/{BaseController-CYEwjyjN.mjs → plugin-DALd9dcF.mjs} +1269 -346
- package/dist/plugins/index.d.mts +17 -14
- package/dist/plugins/index.mjs +44 -22
- package/dist/plugins/response-cache.d.mts +5 -6
- package/dist/plugins/response-cache.mjs +8 -14
- package/dist/plugins/tracing-entry.mjs +2 -2
- package/dist/{pluralize-CXWZIzTv.mjs → pluralize-COUNYo3d.mjs} +1 -1
- package/dist/presets/filesUpload.d.mts +8 -8
- package/dist/presets/filesUpload.mjs +5 -5
- package/dist/presets/index.d.mts +35 -40
- 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 +9 -10
- package/dist/presets/search.mjs +2 -2
- package/dist/{presets-ZJSPgmT2.mjs → presets-CONf2Qem.mjs} +99 -107
- package/dist/{projection-BzIgzoKZ.mjs → projection-wFoLqdss.mjs} +2 -2
- package/dist/{pushref-registry-Dov9l4qE.d.mts → pushref-registry-UxCkoA4C.d.mts} +1 -1
- package/dist/{queryCachePlugin-DZHPOm9p.mjs → queryCachePlugin-BATECpyh.mjs} +12 -14
- package/dist/{queryCachePlugin-BzqxconG.d.mts → queryCachePlugin-C2lZjTxk.d.mts} +1 -1
- package/dist/{rateLimitKey-BvOvcBDi.mjs → rateLimitKey-DVEZ_UpV.mjs} +1 -1
- package/dist/{realtime-8tIQWZz4.mjs → realtime-xyubMKSB.mjs} +25 -21
- package/dist/{redis-Bzi1y3F9.d.mts → redis-BDgv9Glw.d.mts} +17 -24
- package/dist/redis-stream-BMk-bpQS.d.mts +219 -0
- package/dist/redisShapes-CQksY67q.d.mts +55 -0
- package/dist/registry/index.d.mts +15 -10
- package/dist/registry/index.mjs +4 -4
- package/dist/{registry-DNkgGQcK.mjs → registry-Bdzg-hdm.mjs} +13 -10
- package/dist/{renewingLease-yF8BdW4b.mjs → renewingLease-BFJxGPuh.mjs} +1 -1
- package/dist/{replyHelpers-CNdvMfM4.mjs → replyHelpers-Bnc6lJyy.mjs} +2 -2
- package/dist/{requestContext-cDkAUr-P.mjs → requestContext-C10UeFe5.mjs} +1 -1
- package/dist/requirement-Bu50QALH.mjs +35 -0
- package/dist/requirement-CbiLdQ1n.d.mts +22 -0
- package/dist/resourceRateLimit-Wf6d6FL9.d.mts +30 -0
- package/dist/resourceRateLimit-urWPJxrt.mjs +180 -0
- package/dist/rolldown-runtime-MYrLNGnq.mjs +45 -0
- package/dist/routeValidator-DHtpzrzk.mjs +70 -0
- package/dist/{runtimeCapabilities-CkhS6jn6.mjs → runtimeCapabilities-DIMKMV2G.mjs} +1 -1
- package/dist/{schedules-j6uXXAeJ.mjs → schedules-CKTs5ys8.mjs} +46 -37
- package/dist/{schemaConverter-BVA7cFRG.mjs → schemaConverter-BVjkQ5DD.mjs} +2 -2
- package/dist/{schemaIR-CTvPDoPB.mjs → schemaIR-BA0Hb21Y.mjs} +2 -2
- package/dist/schemas/index.d.mts +20 -10
- package/dist/schemas/index.mjs +8 -3
- package/dist/scim/index.d.mts +13 -13
- package/dist/scim/index.mjs +2 -2
- package/dist/scope/index.d.mts +4 -4
- package/dist/scope/index.mjs +6 -6
- package/dist/{scope-BUi1xV1I.mjs → scope-DINaj7Ax.mjs} +4 -4
- package/dist/shutdown-LpLMH8T1.mjs +59 -0
- package/dist/{simpleEqualityMatcher-C9bzq2gO.mjs → simpleEqualityMatcher-DbwIM1f1.mjs} +1 -1
- package/dist/{sse-BeqVKQKu.mjs → sse-BzJFPX_1.mjs} +11 -15
- package/dist/{sseStream-Ppzo-WUH.mjs → sseStream-DQChzGTs.mjs} +2 -2
- package/dist/{store-helpers-dW71XVWL.mjs → store-helpers-Coj9RhOZ.mjs} +1 -1
- package/dist/{streaming-IcRFjWQU.mjs → streaming-JzB5CAga.mjs} +1 -1
- package/dist/subscriberIdentity-DeyppIif.mjs +28 -0
- package/dist/tenancy-DxV8OuX2.mjs +43 -0
- package/dist/tenantPreparation-CBvvAcAj.mjs +67 -0
- package/dist/testing/cleanupStoreContract.d.mts +4 -5
- package/dist/testing/cleanupStoreContract.mjs +1 -1
- package/dist/testing/index.d.mts +215 -197
- package/dist/testing/index.mjs +289 -214
- package/dist/testing/outboxStoreContract.d.mts +4 -5
- package/dist/testing/outboxStoreContract.mjs +137 -2
- package/dist/testing/requiredPorts.d.mts +16 -0
- package/dist/testing/requiredPorts.mjs +65 -0
- package/dist/testing/storageContract.d.mts +4 -5
- package/dist/testing/storageContract.mjs +1 -1
- package/dist/timing-CntavTlR.mjs +46 -0
- package/dist/{transactionContext-CPbdlnVw.mjs → transactionContext-orvnGu4F.mjs} +1 -1
- package/dist/{typeGuards-BLjPgVBm.mjs → typeGuards-kEaP_WmO.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-DfVDvkdP.d.mts → types-BJ-2XqVF.d.mts} +189 -204
- package/dist/{types-CWQn9-IC.d.mts → types-D3Ixsh00.d.mts} +22 -9
- package/dist/{types-CgenB1gv.mjs → types-fvO6Ovzx.mjs} +4 -4
- package/dist/usage/index.d.mts +5 -6
- package/dist/usage/index.mjs +5 -5
- package/dist/{userHelpers-ChRvkuSZ.mjs → userHelpers-C76zD5pa.mjs} +1 -1
- package/dist/utils/index.d.mts +125 -264
- package/dist/utils/index.mjs +13 -12
- package/dist/{utils-CxcctrAh.mjs → utils-BpkVZ8rB.mjs} +315 -404
- package/dist/{validate-DrYWnOzI.mjs → validate-CWp-lsrm.mjs} +6 -14
- package/dist/{versioning-D6JIK8Tk.d.mts → versioning-Bsb51gGT.d.mts} +28 -13
- package/dist/{versioning-DKkT4hNJ.mjs → versioning-CHhL9P3o.mjs} +4 -4
- package/dist/{websocket-BOXVggMf.d.mts → websocket-Cs4awVyD.d.mts} +1 -1
- package/dist/{workScope-CxKqoIFn.mjs → workScope-n9a7d_lZ.mjs} +2 -2
- package/package.json +57 -59
- 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/rolldown-runtime-eysyzFAF.mjs +0 -15
- 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-WH7xgvxS.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-DRlCIWE9.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
|
+
export 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
|
|
@@ -172,7 +176,7 @@ declare module "fastify" {
|
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
declare function replyHelpersPluginFn(fastify: FastifyInstance): Promise<void>;
|
|
175
|
-
declare const replyHelpersPlugin: typeof replyHelpersPluginFn;
|
|
179
|
+
export declare const replyHelpersPlugin: typeof replyHelpersPluginFn;
|
|
176
180
|
//#endregion
|
|
177
181
|
//#region src/plugins/requestId.d.ts
|
|
178
182
|
interface RequestIdOptions {
|
|
@@ -210,17 +214,16 @@ declare module "fastify" {
|
|
|
210
214
|
* (repeated headers) are rejected outright — a client sending multiple
|
|
211
215
|
* request-id headers is not tracing in good faith.
|
|
212
216
|
*/
|
|
213
|
-
declare function sanitizeRequestId(value: unknown): string | undefined;
|
|
217
|
+
export declare function sanitizeRequestId(value: unknown): string | undefined;
|
|
214
218
|
/**
|
|
215
219
|
* Build a Fastify `genReqId` function: adopt a sanitized incoming request-id
|
|
216
220
|
* header, or generate one. Wire this into the `Fastify()` constructor so
|
|
217
221
|
* `request.id`, `request.log`'s `reqId` binding, and the echoed response
|
|
218
222
|
* header all agree — `createApp` does this automatically.
|
|
219
223
|
*/
|
|
220
|
-
declare function createRequestIdGenerator(opts?: Pick<RequestIdOptions, "header" | "generator">): (req: {
|
|
224
|
+
export 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, defaultIsDuplicateKeyError, errorHandlerPlugin, _default$2 as gracefulShutdownPlugin, _default$3 as healthPlugin, _default$4 as metricsPlugin, _default$5 as pressurePlugin, _default$6 as realtimePlugin, _default$7 as requestIdPlugin, _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.44.0 | MIT | https://classytic.com */
|
|
2
|
+
import { m as MUTATION_OPERATIONS } from "../constants-B2QHb6u6.mjs";
|
|
3
|
+
import { t as arcLog } from "../logger-D4V1zGLI.mjs";
|
|
4
|
+
import { c as getOrgId } from "../types-fvO6Ovzx.mjs";
|
|
5
|
+
import { n as requestContext } from "../requestContext-C10UeFe5.mjs";
|
|
6
|
+
import { t as hasEvents } from "../typeGuards-kEaP_WmO.mjs";
|
|
7
|
+
import { t as HookSystem } from "../HookSystem-yjEgn7Cm.mjs";
|
|
8
|
+
import { t as ResourceRegistry } from "../ResourceRegistry-DJxHUpE4.mjs";
|
|
9
|
+
import { c as createRequestIdGenerator, l as requestId_default, n as health_default, u as sanitizeRequestId } from "../health-CrqUp3sz.mjs";
|
|
10
|
+
import { t as caching_default } from "../caching-Drp68DIS.mjs";
|
|
11
|
+
import { n as errorHandlerPlugin, t as defaultIsDuplicateKeyError } from "../errorHandler-COHw3N1b.mjs";
|
|
12
|
+
import { t as metrics_default } from "../metrics-DsZrvnpB.mjs";
|
|
13
|
+
import { t as realtime_default } from "../realtime-xyubMKSB.mjs";
|
|
14
|
+
import { t as replyHelpersPlugin } from "../replyHelpers-Bnc6lJyy.mjs";
|
|
15
|
+
import { t as schedules_default } from "../schedules-CKTs5ys8.mjs";
|
|
16
|
+
import { t as sse_default } from "../sse-BzJFPX_1.mjs";
|
|
17
|
+
import { t as versioning_default } from "../versioning-CHhL9P3o.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,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import { FastifyPluginAsync, FastifyRequest } from "fastify";
|
|
3
3
|
//#region src/plugins/response-cache.d.ts
|
|
4
|
-
interface ResponseCacheRule {
|
|
4
|
+
export interface ResponseCacheRule {
|
|
5
5
|
/** Path prefix to match (e.g., '/api/products') */
|
|
6
6
|
match: string;
|
|
7
7
|
/** TTL in seconds for this path (0 = don't cache) */
|
|
8
8
|
ttl: number;
|
|
9
9
|
}
|
|
10
|
-
interface ResponseCacheOptions {
|
|
10
|
+
export interface ResponseCacheOptions {
|
|
11
11
|
/** Maximum number of cached entries (default: 500). LRU eviction when exceeded. */
|
|
12
12
|
maxEntries?: number;
|
|
13
13
|
/** Default TTL in seconds (default: 30). Set to 0 to require explicit rules. */
|
|
@@ -46,7 +46,7 @@ interface ResponseCacheOptions {
|
|
|
46
46
|
patterns?: Record<string, string[]>;
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
interface ResponseCacheStats {
|
|
49
|
+
export interface ResponseCacheStats {
|
|
50
50
|
entries: number;
|
|
51
51
|
maxEntries: number;
|
|
52
52
|
hits: number;
|
|
@@ -85,6 +85,5 @@ declare module "fastify" {
|
|
|
85
85
|
__arcCacheTTL?: number;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
declare const responseCachePlugin: FastifyPluginAsync<ResponseCacheOptions>;
|
|
89
|
-
//#endregion
|
|
90
|
-
export { ResponseCacheOptions, ResponseCacheRule, ResponseCacheStats, responseCachePlugin };
|
|
88
|
+
export declare const responseCachePlugin: FastifyPluginAsync<ResponseCacheOptions>;
|
|
89
|
+
//#endregion
|
|
@@ -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.44.0 | MIT | https://classytic.com */
|
|
2
|
+
import { n as declareRuntimeCapability } from "../runtimeCapabilities-DIMKMV2G.mjs";
|
|
3
|
+
import { t as hasEvents } from "../typeGuards-kEaP_WmO.mjs";
|
|
4
|
+
import { n as evictToSize, r as touch, t as assertCapacity } from "../boundedMap-DWiKW7lP.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.44.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.44.0";
|
|
63
63
|
const exporter = new OTLPTraceExporter({ url: exporterUrl });
|
|
64
64
|
const provider = new NodeTracerProvider({ resource: { attributes: {
|
|
65
65
|
"service.name": serviceName,
|
|
@@ -1,15 +1,15 @@
|
|
|
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-WH7xgvxS.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
|
-
interface FilesUploadPresetRoutes {
|
|
7
|
+
export interface FilesUploadPresetRoutes {
|
|
8
8
|
upload?: boolean;
|
|
9
9
|
read?: boolean;
|
|
10
10
|
delete?: boolean;
|
|
11
11
|
}
|
|
12
|
-
interface FilesUploadPresetPermissions {
|
|
12
|
+
export interface FilesUploadPresetPermissions {
|
|
13
13
|
upload?: PermissionCheck;
|
|
14
14
|
read?: PermissionCheck;
|
|
15
15
|
delete?: PermissionCheck;
|
|
@@ -27,8 +27,8 @@ interface FilesUploadPresetPermissions {
|
|
|
27
27
|
* - function: custom policy. Return a string to *transform* the filename,
|
|
28
28
|
* `false` to reject (triggers `ValidationError`), or `true`/`void` to accept.
|
|
29
29
|
*/
|
|
30
|
-
type FilenamePolicy = boolean | "*" | ((filename: string) => string | boolean | undefined);
|
|
31
|
-
interface FilesUploadPresetOptions {
|
|
30
|
+
export type FilenamePolicy = boolean | "*" | ((filename: string) => string | boolean | undefined);
|
|
31
|
+
export interface FilesUploadPresetOptions {
|
|
32
32
|
/** Any implementation of the `Storage` interface. App owns it. */
|
|
33
33
|
storage: Storage;
|
|
34
34
|
/** Multipart form field name. Default: `'file'`. */
|
|
@@ -66,6 +66,6 @@ interface FilesUploadPresetOptions {
|
|
|
66
66
|
* envelope. Upload still returns the standard `{ success: true, data }`
|
|
67
67
|
* envelope manually because the response is structured metadata, not bytes.
|
|
68
68
|
*/
|
|
69
|
-
declare function filesUploadPreset(options: FilesUploadPresetOptions): PresetResult;
|
|
69
|
+
export declare function filesUploadPreset(options: FilesUploadPresetOptions): PresetResult;
|
|
70
70
|
//#endregion
|
|
71
|
-
export {
|
|
71
|
+
export type { Storage, StorageContext, StorageFile, StorageReadRange, StorageReadResult, StorageUploadInput };
|
|
@@ -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.44.0 | MIT | https://classytic.com */
|
|
2
|
+
import { i as NotFoundError, u as ValidationError } from "../errors-CW4anJBy.mjs";
|
|
3
|
+
import { c as getOrgId, g as getUserId } from "../types-fvO6Ovzx.mjs";
|
|
4
|
+
import { B as requireAuth, F as allowPublic } from "../permissions-C5ijIz5Q.mjs";
|
|
5
|
+
import { t as multipartBody } from "../multipartBody-Cc7eZ9cq.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 { Hn as IRequestContext, L as ResourceConfig, Vn as IControllerResponse, W as PresetResult, i as PaginationResult } from "../index-WH7xgvxS.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-CAtYlW6H.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
|
+
export 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
|
+
export declare function bulkPreset(opts?: BulkPresetOptions): PresetResult;
|
|
28
|
+
//#endregion
|
|
7
29
|
//#region src/presets/ownedByUser.d.ts
|
|
8
30
|
interface OwnedByUserOptions {
|
|
9
31
|
ownerField?: string;
|
|
@@ -20,44 +42,22 @@ interface OwnedByUserOptions {
|
|
|
20
42
|
*/
|
|
21
43
|
missingOwner?: "deny" | "allow";
|
|
22
44
|
}
|
|
23
|
-
declare function ownedByUserPreset(options?: OwnedByUserOptions): PresetResult;
|
|
45
|
+
export declare function ownedByUserPreset(options?: OwnedByUserOptions): PresetResult;
|
|
24
46
|
//#endregion
|
|
25
47
|
//#region src/presets/slugLookup.d.ts
|
|
26
48
|
interface SlugLookupOptions {
|
|
27
49
|
slugField?: string;
|
|
28
50
|
}
|
|
29
|
-
declare function slugLookupPreset(options?: SlugLookupOptions): PresetResult;
|
|
51
|
+
export declare function slugLookupPreset(options?: SlugLookupOptions): PresetResult;
|
|
30
52
|
//#endregion
|
|
31
53
|
//#region src/presets/softDelete.d.ts
|
|
32
|
-
declare function softDeletePreset(): PresetResult;
|
|
33
|
-
//#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;
|
|
54
|
+
export declare function softDeletePreset(): PresetResult;
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/presets/tree.d.ts
|
|
57
57
|
interface TreeOptions {
|
|
58
58
|
parentField?: string;
|
|
59
59
|
}
|
|
60
|
-
declare function treePreset(options?: TreeOptions): PresetResult;
|
|
60
|
+
export declare function treePreset(options?: TreeOptions): PresetResult;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/presets/types.d.ts
|
|
63
63
|
/**
|
|
@@ -267,30 +267,25 @@ 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
|
|
278
273
|
*/
|
|
279
|
-
declare function getPreset(nameOrConfig: string | {
|
|
274
|
+
export declare function getPreset(nameOrConfig: string | {
|
|
280
275
|
name: string;
|
|
281
276
|
[key: string]: unknown;
|
|
282
277
|
}): PresetResult;
|
|
283
278
|
/**
|
|
284
279
|
* Register a custom preset
|
|
285
280
|
*/
|
|
286
|
-
declare function registerPreset(name: string, factory: PresetFactory, options?: {
|
|
281
|
+
export declare function registerPreset(name: string, factory: PresetFactory, options?: {
|
|
287
282
|
override?: boolean;
|
|
288
283
|
}): void;
|
|
289
284
|
/**
|
|
290
285
|
* Get all available preset names
|
|
291
286
|
*/
|
|
292
|
-
declare function getAvailablePresets(): string[];
|
|
293
|
-
type PresetInput = string | PresetResult | {
|
|
287
|
+
export declare function getAvailablePresets(): string[];
|
|
288
|
+
export type PresetInput = string | PresetResult | {
|
|
294
289
|
name: string;
|
|
295
290
|
[key: string]: unknown;
|
|
296
291
|
};
|
|
@@ -298,6 +293,6 @@ type PresetInput = string | PresetResult | {
|
|
|
298
293
|
* Apply presets to resource config.
|
|
299
294
|
* Validates preset combinations for conflicts before merging.
|
|
300
295
|
*/
|
|
301
|
-
declare function applyPresets<TDoc = AnyRecord>(config: ResourceConfig<TDoc>, presets?: PresetInput[]): ResourceConfig<TDoc>;
|
|
296
|
+
export 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,
|
|
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, type SearchHandler, type SearchPresetOptions, type SearchRouteConfig, type SlugLookupOptions, type TenantFieldSpec, type TreeOptions, filesUploadPreset, multiTenantPreset, searchPreset };
|
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.44.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-CONf2Qem.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-CAtYlW6H.mjs";
|
|
3
|
+
export { MultiTenantOptions, type TenantFieldSpec, multiTenantPreset };
|