@classytic/arc 2.23.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/{BaseController-BQ8KNvWC.mjs → BaseController-B65zbz9m.mjs} +94 -23
- package/dist/QueryCache-DOMT_iq7.d.mts +72 -0
- package/dist/actionPermissions-CAphcmUG.mjs +24 -0
- package/dist/{applyPermissionResult-Tw4iXtlf.mjs → applyPermissionResult-BnyVE9eD.mjs} +10 -0
- package/dist/audit/index.d.mts +32 -3
- package/dist/audit/index.mjs +7 -4
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.mjs +263 -259
- package/dist/{buildHandler-D_2ULWxZ.mjs → buildHandler-Dtwd8fdz.mjs} +1 -1
- package/dist/cache/index.d.mts +41 -3
- package/dist/cache/index.mjs +33 -4
- package/dist/cleanup/index.d.mts +313 -0
- package/dist/cleanup/index.mjs +1267 -0
- package/dist/cli/commands/describe.d.mts +1 -1
- package/dist/cli/commands/docs.mjs +1 -1
- package/dist/cli/commands/generate.mjs +1 -1
- package/dist/cli/commands/init.mjs +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/context/index.mjs +2 -64
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +5 -4
- package/dist/core-BGa8TXJR.mjs +221 -0
- package/dist/{createActionRouter-BuOv-m4Y.mjs → createActionRouter-C-N7z2EL.mjs} +3 -2
- package/dist/{createAggregationRouter-CgJv_BU_.mjs → createAggregationRouter-wzwFa_dW.mjs} +3 -3
- package/dist/{createApp-CjOeWJ9_.mjs → createApp-Du5G54TM.mjs} +187 -96
- package/dist/{core-DQ6rDTyH.mjs → defineResource-2zvVVpxg.mjs} +297 -230
- package/dist/docs/index.d.mts +1 -1
- package/dist/docs/index.mjs +2 -2
- package/dist/{elevation-COpYKt2h.mjs → elevation-CIz1GjGm.mjs} +4 -3
- package/dist/{eventPlugin-A6EbthXR.d.mts → eventPlugin-Bg3cP2_u.d.mts} +38 -3
- package/dist/{eventPlugin-DJG2D7sy.mjs → eventPlugin-DrQ_FesK.mjs} +22 -4
- package/dist/events/index.d.mts +83 -314
- package/dist/events/index.mjs +183 -95
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +24 -2
- package/dist/factory/index.d.mts +5 -5
- package/dist/factory/index.mjs +30 -8
- package/dist/{fastify-augmentation-g_f9omSc.d.mts → fastify-augmentation-OzYGIiU1.d.mts} +26 -2
- package/dist/{generate-usRSdQmP.mjs → generate-D0wZupBg.mjs} +1 -1
- package/dist/headers-BvlQSDMB.mjs +45 -0
- package/dist/health-CB_m4S32.mjs +377 -0
- package/dist/hooks/index.d.mts +1 -1
- package/dist/idempotency/index.mjs +27 -3
- package/dist/{index-wMoWBLkn.d.mts → index-BMnbzvtO.d.mts} +3 -3
- package/dist/{integrations/jobs.d.mts → index-CG4yqMDB.d.mts} +82 -2
- package/dist/index-CZY4EGga.d.mts +107 -0
- package/dist/{index-CC5ruDGh.d.mts → index-CjVg-Epg.d.mts} +37 -5
- package/dist/{index-BBsvQt7U.d.mts → index-DPRH0Cme.d.mts} +36 -106
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +7 -6
- package/dist/{init-CjO4p_q1.mjs → init-tlRSt667.mjs} +206 -208
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +1 -1
- package/dist/integrations/index.d.mts +3 -3
- package/dist/integrations/jobs/index.d.mts +2 -0
- package/dist/integrations/{jobs.mjs → jobs/index.mjs} +110 -67
- package/dist/integrations/mcp/index.d.mts +4 -4
- package/dist/integrations/mcp/index.mjs +2 -2
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/integrations/webhooks.d.mts +37 -30
- package/dist/integrations/webhooks.mjs +51 -62
- package/dist/integrations/websocket-redis.d.mts +1 -1
- package/dist/integrations/websocket.d.mts +1 -1
- package/dist/integrations/websocket.mjs +41 -14
- package/dist/{interface-C1_WLTMK.d.mts → interface-BGZCzOGL.d.mts} +24 -31
- package/dist/{mcpPlugin-BtzIL_kM.mjs → mcpPlugin-Cs6nRGCt.mjs} +12 -10
- package/dist/{memory-CLXA2VeJ.mjs → memory-CmnzXE5Z.mjs} +29 -0
- package/dist/middleware/index.d.mts +17 -1
- package/dist/middleware/index.mjs +1 -1
- package/dist/migrations/index.d.mts +94 -44
- package/dist/migrations/index.mjs +196 -44
- package/dist/module-_-M7C5ES.mjs +29 -0
- package/dist/{multipartBody-CHEQSZ6G.mjs → multipartBody-D0eBvkeq.mjs} +17 -0
- package/dist/{openapi-jSDx-VDv.mjs → openapi-BLV4OMXb.mjs} +3 -3
- package/dist/permissions/index.d.mts +2 -2
- package/dist/permissions/index.mjs +3 -3
- package/dist/{permissions-tbxFHxjZ.mjs → permissions-BrtiBKGs.mjs} +229 -229
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/{actionPermissions-lszoJle1.mjs → pipeline-BGRnV-To.mjs} +4 -27
- package/dist/plugins/index.d.mts +6 -77
- package/dist/plugins/index.mjs +11 -95
- package/dist/plugins/response-cache.mjs +1 -0
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/{index-Ba10fdKp.d.mts → preloadResources-CM4uUaFv.d.mts} +51 -50
- package/dist/preloadResources-DSY5HGpS.mjs +45 -0
- package/dist/presets/filesUpload.d.mts +3 -3
- package/dist/presets/filesUpload.mjs +3 -3
- package/dist/presets/index.d.mts +2 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +1 -1
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +1 -1
- package/dist/{presets-BOe4Ugkl.mjs → presets-DwFDVKP0.mjs} +2 -2
- package/dist/{queryCachePlugin-DzqLN904.mjs → queryCachePlugin-DSGuSVLW.mjs} +39 -8
- package/dist/{queryCachePlugin-CfYWq-Ak.d.mts → queryCachePlugin-br4otiqF.d.mts} +2 -2
- package/dist/{registerRoute-CWO6mdYe.mjs → rateLimit-DrED-C4v.mjs} +2 -109
- package/dist/{realtime-I8OrfnMR.mjs → realtime-DEuDu9io.mjs} +3 -3
- package/dist/{redis-stream-iVR2l7aS.d.mts → redis-stream-uIaauNpZ.d.mts} +22 -0
- package/dist/registerRoute-DTp18Ah_.mjs +108 -0
- package/dist/registry/index.d.mts +2 -2
- package/dist/registry/index.mjs +1 -1
- package/dist/{registry-vcOCtPij.mjs → registry-9km_w1aP.mjs} +15 -0
- package/dist/renewingLease-3cuQH7h8.mjs +44 -0
- package/dist/{requestContext-BZKOr13H.mjs → requestContext-MrlJwECf.mjs} +2 -2
- package/dist/schedules-CjOd2MG9.mjs +113 -0
- package/dist/schemas/index.d.mts +67 -67
- package/dist/schemas/index.mjs +2 -3
- package/dist/scim/index.mjs +1 -2
- package/dist/scope/index.d.mts +2 -2
- package/dist/scope/index.mjs +4 -4
- package/dist/{scope-LONQ3mfZ.mjs → scope-DfaPntpo.mjs} +4 -5
- package/dist/{sse-0u4P4-OI.mjs → sse-BQ1w0dfl.mjs} +1 -1
- package/dist/testing/cleanupStoreContract.d.mts +10 -0
- package/dist/testing/cleanupStoreContract.mjs +375 -0
- package/dist/testing/index.d.mts +5 -3
- package/dist/testing/index.mjs +4 -2
- package/dist/testing/outboxStoreContract.d.mts +13 -0
- package/dist/testing/outboxStoreContract.mjs +247 -0
- package/dist/transactionContext-PNdoyLLm.mjs +64 -0
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-bHblZ9YN.mjs → types-CSyCxl2V.mjs} +38 -7
- package/dist/types-C_ZZRcD6.d.mts +450 -0
- package/dist/{module-B4u10iOJ.d.mts → types-Cu6vVJmh.d.mts} +196 -60
- package/dist/{types-DH0GupI7.d.mts → types-DjC-KUCz.d.mts} +118 -20
- package/dist/{types-Csxga7d3.d.mts → types-Dmw-6Qeo.d.mts} +96 -4
- package/dist/{types-5OuqeTDX.d.mts → types-QFGc3Cjv.d.mts} +1 -1
- package/dist/usage/index.d.mts +3 -52
- package/dist/usage/index.mjs +0 -0
- package/dist/userHelpers-Cg_y3fBz.mjs +29 -0
- package/dist/utils/index.d.mts +58 -85
- package/dist/utils/index.mjs +4 -2
- package/dist/{utils-CZyeRXTh.mjs → utils-taUVD4p3.mjs} +47 -337
- package/dist/{validate-C2mGgSXg.mjs → validate-Bk44F2yT.mjs} +1 -1
- package/dist/{versioning-D6PvCwpq.d.mts → versioning-DXgY5BUm.d.mts} +11 -29
- package/dist/{versioning-Dk-71iIz.mjs → versioning-gKWyryT3.mjs} +8 -1
- package/dist/{websocket-uuWqM6UY.d.mts → websocket-_Pd0CgR0.d.mts} +15 -1
- package/package.json +541 -513
- package/skills/arc/references/api-reference.md +3 -1
- package/skills/arc/references/integrations.md +20 -11
- package/dist/QueryCache-Z1B38koh.d.mts +0 -40
- package/dist/betterAuthOpenApi-CV1lxpRX.mjs +0 -2
- package/dist/health-ScyjIVo5.mjs +0 -202
- package/dist/requestId-5BhTVzBv.mjs +0 -113
- package/dist/types-XTApa8b6.mjs +0 -24
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as RequestContext, Et as ActionDefinition, F as FastifyWithDecorators, H as CrudController,
|
|
2
|
-
import { i as RequestScope } from "./types-
|
|
3
|
-
import { t as PermissionCheck } from "./types-
|
|
4
|
-
import "./fastify-augmentation-
|
|
1
|
+
import { C as RequestContext, Et as ActionDefinition, F as FastifyWithDecorators, H as CrudController, L as RequestWithExtras, Lt as IController, Rt as IControllerResponse, T as CrudRouterOptions, U as ResourceConfig, V as ResourceDefinition, et as RouteSchemaOptions, jt as RouteMcpConfig, tt as ArcFieldRule, ut as AggregationConfig, zt as IRequestContext } from "./index-DPRH0Cme.mjs";
|
|
2
|
+
import { i as RequestScope } from "./types-DjC-KUCz.mjs";
|
|
3
|
+
import { c as AnyRecord, t as PermissionCheck } from "./types-Dmw-6Qeo.mjs";
|
|
4
|
+
import "./fastify-augmentation-OzYGIiU1.mjs";
|
|
5
5
|
import { FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { DataAdapter } from "@classytic/repo-core/adapter";
|
|
@@ -425,4 +425,36 @@ declare function isFieldReadable(rule: ArcFieldRule | undefined): boolean;
|
|
|
425
425
|
*/
|
|
426
426
|
declare function collectReadBlockedFields(schemaOptions: RouteSchemaOptions | undefined): Set<string> | null;
|
|
427
427
|
//#endregion
|
|
428
|
-
|
|
428
|
+
//#region src/core/validateResourceConfig.d.ts
|
|
429
|
+
interface ConfigError {
|
|
430
|
+
field: string;
|
|
431
|
+
message: string;
|
|
432
|
+
suggestion?: string;
|
|
433
|
+
}
|
|
434
|
+
interface ValidationResult {
|
|
435
|
+
valid: boolean;
|
|
436
|
+
errors: ConfigError[];
|
|
437
|
+
warnings: ConfigError[];
|
|
438
|
+
}
|
|
439
|
+
interface ValidateOptions {
|
|
440
|
+
/** Skip controller method validation (for testing) */
|
|
441
|
+
skipControllerCheck?: boolean;
|
|
442
|
+
/** Allow unknown preset names */
|
|
443
|
+
allowUnknownPresets?: boolean;
|
|
444
|
+
/** Custom valid permission keys beyond CRUD */
|
|
445
|
+
additionalPermissionKeys?: string[];
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Validate a resource configuration
|
|
449
|
+
*/
|
|
450
|
+
declare function validateResourceConfig(config: ResourceConfig, options?: ValidateOptions): ValidationResult;
|
|
451
|
+
/**
|
|
452
|
+
* Format validation errors for display
|
|
453
|
+
*/
|
|
454
|
+
declare function formatValidationErrors(resourceName: string, result: ValidationResult): string;
|
|
455
|
+
/**
|
|
456
|
+
* Validate and throw if invalid
|
|
457
|
+
*/
|
|
458
|
+
declare function assertValidConfig(config: ResourceConfig, options?: ValidateOptions): void;
|
|
459
|
+
//#endregion
|
|
460
|
+
export { DEFAULT_ID_FIELD as A, MAX_FILTER_DEPTH as B, DefineActionConfig as C, defineAggregation as D, createPermissionMiddleware as E, DEFAULT_UPDATE_METHOD as F, RESERVED_QUERY_PARAMS as G, MAX_SEARCH_LENGTH as H, HOOK_OPERATIONS as I, SYSTEM_FIELDS as K, HOOK_PHASES as L, DEFAULT_MAX_LIMIT as M, DEFAULT_SORT as N, CRUD_OPERATIONS as O, DEFAULT_TENANT_FIELD as P, HookOperation as R, mergeResourceConfig as S, createCrudRouter as T, MUTATION_OPERATIONS as U, MAX_REGEX_LENGTH as V, MutationOperation as W, getEntityQuery as _, formatValidationErrors as a, ResourceSeams as b, isFieldReadable as c, createRequestContext as d, getControllerContext as f, getEntityIdField as g, getEntityId as h, assertValidConfig as i, DEFAULT_LIMIT as j, CrudOperation as k, createCrudHandlers as l, sendControllerResponse as m, ValidateOptions as n, validateResourceConfig as o, getControllerScope as p, ValidationResult as r, collectReadBlockedFields as s, ConfigError as t, createFastifyHandler as u, defineResourceVariants as v, defineAction as w, SeamedResourceConfig as x, AdapterLike as y, HookPhase as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as QueryCacheConfig } from "./QueryCache-
|
|
2
|
-
import { i as RequestScope } from "./types-
|
|
3
|
-
import { i as UserBase, t as PermissionCheck } from "./types-
|
|
1
|
+
import { a as QueryCacheConfig } from "./QueryCache-DOMT_iq7.mjs";
|
|
2
|
+
import { P as ArcHeaders, i as RequestScope } from "./types-DjC-KUCz.mjs";
|
|
3
|
+
import { c as AnyRecord, i as UserBase, t as PermissionCheck } from "./types-Dmw-6Qeo.mjs";
|
|
4
4
|
import "./elevation-C9s5hFP_.mjs";
|
|
5
5
|
import { n as FieldPermissionMap } from "./fields-D3lhgzhD.mjs";
|
|
6
6
|
import { n as EncryptionDirective } from "./types-Cc91nXuA.mjs";
|
|
@@ -620,9 +620,9 @@ declare class QueryResolver {
|
|
|
620
620
|
/** Sanitize advanced populate options against allowedPopulate */
|
|
621
621
|
private sanitizePopulateOptions;
|
|
622
622
|
/**
|
|
623
|
-
* Sanitize lookup/join options.
|
|
624
|
-
*
|
|
625
|
-
*
|
|
623
|
+
* Sanitize lookup/join options. Deny-by-default: `allowedLookups` must be
|
|
624
|
+
* configured for any client-driven lookup to pass; listed collections are
|
|
625
|
+
* then structurally validated to prevent injection.
|
|
626
626
|
*/
|
|
627
627
|
private sanitizeLookups;
|
|
628
628
|
/**
|
|
@@ -833,6 +833,26 @@ declare class BaseCrudController<TDoc = AnyRecord, TRepository extends Repositor
|
|
|
833
833
|
* create/update, the original input (`existing`) for delete.
|
|
834
834
|
*/
|
|
835
835
|
protected runAfterHook(req: IRequestContext, op: "create" | "update" | "delete", data: AnyRecord, meta?: Record<string, unknown>): Promise<void>;
|
|
836
|
+
/**
|
|
837
|
+
* Per-instance single-flight for cache fills — concurrent requests for
|
|
838
|
+
* the SAME cache key coalesce onto one repository query instead of each
|
|
839
|
+
* issuing its own (a popular entry expiring under 1,000 concurrent
|
|
840
|
+
* readers must produce 1 DB query, not 1,000). Keys already encode the
|
|
841
|
+
* resolved query + user/org scope + resource version, so coalescing can
|
|
842
|
+
* never cross tenants, scopes, or invalidation generations. Per-process
|
|
843
|
+
* by design; distributed refresh leases are a store-level concern
|
|
844
|
+
* (planned with the repo-core CacheEngine façade, which ships
|
|
845
|
+
* single-flight natively).
|
|
846
|
+
*/
|
|
847
|
+
private readonly inFlightCacheFills;
|
|
848
|
+
private cacheSingleFlight;
|
|
849
|
+
/**
|
|
850
|
+
* Register a background SWR refresh for `key` unless one is already in
|
|
851
|
+
* flight. Registration is SYNCHRONOUS (before the deferred tick) so a
|
|
852
|
+
* burst of stale readers arriving in the same tick schedules exactly one
|
|
853
|
+
* revalidation.
|
|
854
|
+
*/
|
|
855
|
+
private scheduleCacheRefresh;
|
|
836
856
|
/** Cached `list()` flow with SWR semantics. Returns null when cache is disabled. */
|
|
837
857
|
protected withListCache(req: IRequestContext, options: ParsedQuery): Promise<IControllerResponse<ListResult<TDoc>> | null>;
|
|
838
858
|
/** Cached `get()` flow with SWR semantics. Returns null when cache is disabled. */
|
|
@@ -1044,96 +1064,6 @@ declare class BaseController<TDoc extends AnyRecord = AnyRecord, _TRepository ex
|
|
|
1044
1064
|
readonly _phantom?: [TDoc, _TRepository];
|
|
1045
1065
|
}
|
|
1046
1066
|
//#endregion
|
|
1047
|
-
//#region src/types/base.d.ts
|
|
1048
|
-
declare module "fastify" {
|
|
1049
|
-
interface FastifyRequest {
|
|
1050
|
-
/** Request scope — set by auth adapter, read by permissions/presets/guards */
|
|
1051
|
-
scope: RequestScope;
|
|
1052
|
-
/**
|
|
1053
|
-
* Current user — set by auth adapter (Better Auth, JWT, custom).
|
|
1054
|
-
* `undefined` on public routes (`auth: false`) or unauthenticated requests.
|
|
1055
|
-
* Guard with `if (request.user)` on routes that allow anonymous access.
|
|
1056
|
-
*
|
|
1057
|
-
* Kept as required (not `user?`) because `@fastify/jwt` declares it
|
|
1058
|
-
* as required — declaration merges must have identical modifiers.
|
|
1059
|
-
* The `| undefined` in the type achieves the same DX.
|
|
1060
|
-
*/
|
|
1061
|
-
user: Record<string, unknown> | undefined;
|
|
1062
|
-
/** Policy-injected query filters (e.g. ownership, org-scoping) */
|
|
1063
|
-
_policyFilters?: Record<string, unknown>;
|
|
1064
|
-
/** Field mask — fields to include/exclude in responses */
|
|
1065
|
-
fieldMask?: {
|
|
1066
|
-
include?: string[];
|
|
1067
|
-
exclude?: string[];
|
|
1068
|
-
};
|
|
1069
|
-
/** Arbitrary policy metadata for downstream consumers */
|
|
1070
|
-
policyMetadata?: Record<string, unknown>;
|
|
1071
|
-
/** Document loaded by policy middleware for ownership checks */
|
|
1072
|
-
document?: unknown;
|
|
1073
|
-
/** Ownership check context (field name + user field) */
|
|
1074
|
-
_ownershipCheck?: Record<string, unknown>;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
type AnyRecord = Record<string, unknown>;
|
|
1078
|
-
/** MongoDB ObjectId — accepts string or any object with a `toString()` (e.g. mongoose ObjectId). */
|
|
1079
|
-
type ObjectId = string | {
|
|
1080
|
-
toString(): string;
|
|
1081
|
-
};
|
|
1082
|
-
/**
|
|
1083
|
-
* Flexible user type that accepts any object with id/_id properties.
|
|
1084
|
-
* The actual user structure is defined by your app's auth system.
|
|
1085
|
-
*/
|
|
1086
|
-
type UserLike = UserBase & {
|
|
1087
|
-
/** User email (optional) */
|
|
1088
|
-
email?: string;
|
|
1089
|
-
};
|
|
1090
|
-
interface UserOrganization {
|
|
1091
|
-
userId: string;
|
|
1092
|
-
organizationId: string;
|
|
1093
|
-
[key: string]: unknown;
|
|
1094
|
-
}
|
|
1095
|
-
interface JWTPayload {
|
|
1096
|
-
sub: string;
|
|
1097
|
-
[key: string]: unknown;
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* @deprecated LEGACY envelope — arc's actual wire contract has not used
|
|
1101
|
-
* `{ success, data, error, message }` for a long time. Successes return
|
|
1102
|
-
* DIRECT data (see `IControllerResponse` — `{ data, meta?, status?, headers? }`
|
|
1103
|
-
* flattened onto the wire), and errors return the canonical `ErrorContract`
|
|
1104
|
-
* (`{ code, message, status, details? }` from `@classytic/repo-core/errors`)
|
|
1105
|
-
* emitted by the global error handler. Keeping this type visible teaches new
|
|
1106
|
-
* applications and AI agents to generate an obsolete shape. Scheduled for
|
|
1107
|
-
* removal in v3. Do NOT build new response handling against it.
|
|
1108
|
-
*/
|
|
1109
|
-
interface ApiResponse<T = unknown> {
|
|
1110
|
-
success: boolean;
|
|
1111
|
-
data?: T;
|
|
1112
|
-
error?: string;
|
|
1113
|
-
message?: string;
|
|
1114
|
-
meta?: Record<string, unknown>;
|
|
1115
|
-
}
|
|
1116
|
-
/**
|
|
1117
|
-
* Typed Fastify request with Arc decorations. Use in `raw: true` handlers
|
|
1118
|
-
* instead of `(req as any).user`.
|
|
1119
|
-
*
|
|
1120
|
-
* @example
|
|
1121
|
-
* ```typescript
|
|
1122
|
-
* import type { ArcRequest } from '@classytic/arc';
|
|
1123
|
-
*
|
|
1124
|
-
* handler: async (req: ArcRequest, reply) => {
|
|
1125
|
-
* req.user?.id; // typed
|
|
1126
|
-
* req.scope.organizationId; // typed (when member)
|
|
1127
|
-
* req.signal; // AbortSignal (Fastify 5)
|
|
1128
|
-
* }
|
|
1129
|
-
* ```
|
|
1130
|
-
*/
|
|
1131
|
-
type ArcRequest = FastifyRequest & {
|
|
1132
|
-
scope: RequestScope;
|
|
1133
|
-
user: Record<string, unknown> | undefined;
|
|
1134
|
-
signal: AbortSignal;
|
|
1135
|
-
};
|
|
1136
|
-
//#endregion
|
|
1137
1067
|
//#region src/types/auth.d.ts
|
|
1138
1068
|
/**
|
|
1139
1069
|
* JWT utilities provided to authenticator. Arc provides the helpers;
|
|
@@ -1430,15 +1360,15 @@ interface IRequestContext<TBody = unknown, TParams extends Record<string, string
|
|
|
1430
1360
|
/** Authenticated user or null */
|
|
1431
1361
|
user: TUser | null;
|
|
1432
1362
|
/**
|
|
1433
|
-
* Request headers
|
|
1434
|
-
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
* access
|
|
1363
|
+
* Request headers — `ArcHeaders` (`string | string[] | undefined` per
|
|
1364
|
+
* name), the HONEST type: on the HTTP path this is Fastify's headers
|
|
1365
|
+
* object passed through, and repeated headers arrive as `string[]` at
|
|
1366
|
+
* runtime (2.24 widening — the previous `Record<string, string |
|
|
1367
|
+
* undefined>` lied about that). Read via `getHeader(ctx.headers, name)`
|
|
1368
|
+
* from `@classytic/arc/utils` for array-safe, duplicate-deterministic
|
|
1369
|
+
* access, or `requireSingleHeaderValue` for security-sensitive headers.
|
|
1440
1370
|
*/
|
|
1441
|
-
headers:
|
|
1371
|
+
headers: ArcHeaders;
|
|
1442
1372
|
/** Organization ID (for multi-tenant apps) */
|
|
1443
1373
|
organizationId?: string;
|
|
1444
1374
|
/** Team ID (for team-scoped resources) */
|
|
@@ -1666,7 +1596,7 @@ interface RouteDefinition {
|
|
|
1666
1596
|
* compiler to catch typos. `handler` stays optional when `controllerMethod`
|
|
1667
1597
|
* is set — exactly one of the two must be declared.
|
|
1668
1598
|
*/
|
|
1669
|
-
readonly handler?: string | ControllerHandler | RouteHandlerMethod | ((request:
|
|
1599
|
+
readonly handler?: string | ControllerHandler | RouteHandlerMethod | ((request: never, reply: never) => unknown);
|
|
1670
1600
|
/**
|
|
1671
1601
|
* Typed function-reference handler (2.16). Receives the live controller
|
|
1672
1602
|
* instance and returns the method to invoke — TypeScript catches typos
|
|
@@ -4259,4 +4189,4 @@ interface ValidateOptions {
|
|
|
4259
4189
|
strict?: boolean;
|
|
4260
4190
|
}
|
|
4261
4191
|
//#endregion
|
|
4262
|
-
export { OpenApiSchemas as $,
|
|
4192
|
+
export { OpenApiSchemas as $, SlugExt as $t, RequestIdOptions as A, ControllerConfigurableOptions as An, RouteDefinition as At, defineResource as B, RouteHandler as Bt, RequestContext as C, defineHook as Cn, PipelineStep as Ct, HealthCheck as D, ArcListResult as Dn, ActionEntry as Dt, GracefulShutdownOptions as E, ArcGetResult as En, ActionDefinition as Et, FastifyWithDecorators as F, ControllerLike as Ft, OnTenantDeleteConfig as G, AuthenticatorContext as Gt, CrudController as H, AuthHelpers as Ht, MiddlewareHandler as I, FastifyHandler as It, PresetHook as J, BaseController as Jt, ResolvedTenantPurge as K, JwtContext as Kt, RequestWithExtras as L, IController as Lt, EventsDecorator as M, ListResult as Mn, RouteMethod as Mt, FastifyRequestExtras as N, BodySanitizer as Nn, RateLimitConfig as Nt, HealthOptions as O, ArcUpdateResult as On, ActionHandlerFn as Ot, FastifyWithAuth as P, BodySanitizerConfig as Pn, ControllerHandler as Pt, MiddlewareConfig as Q, TreeMixin as Qt, RegisterOptions as R, IControllerResponse as Rt, QueryParserInterface as S, createHookSystem as Sn, PipelineContext as St, CrudRouterOptions as T, ArcDeleteResult as Tn, ResourceCacheConfig as Tt, ResourceConfig as U, AuthPluginOptions as Ut, ResourceDefinition as V, ServerAccessor as Vt, ResourcePermissions as W, Authenticator as Wt, CrudRouteKey as X, SoftDeleteMixin as Xt, PresetResult as Y, SoftDeleteExt as Yt, CrudSchemas as Z, TreeExt as Zt, ControllerQueryOptions as _, afterDelete as _n, Guard as _t, InferAdapterDoc as a, QueryResolverConfig as an, ResourceExtensions as at, ParsedQuery as b, beforeDelete as bn, OperationFilter as bt, TypedController as c, DefineHookOptions as cn, AggMeasureShorthand as ct, PaginationResult as d, HookOperation as dn, AggregationDateRangeRequirement as dt, SlugMixin as en, RouteSchemaOptions as et, IntrospectionData as f, HookPhase as fn, AggregationIndexHint as ft, ArcInternalMetadata as g, afterCreate as gn, AggregationsMap as gt, ResourceMetadata as h, HookSystemOptions as hn, AggregationRateLimit as ht, ValidationResult as i, QueryResolver as in, ResourceHooks as it, ArcDecorator as j, ControllerConstructionOptions as jn, RouteMcpConfig as jt, IntrospectionPluginOptions as k, BaseControllerOptions as kn, ActionsMap as kt, TypedRepository as l, HookContext as ln, AggregationCacheConfig as lt, RegistryStats as m, HookSystem as mn, AggregationMaterializedResult as mt, ConfigError as n, BulkMixin as nn, FieldRule$1 as nt, InferDocType as o, AccessControl as on, EventDefinition as ot, RegistryEntry as p, HookRegistration as pn, AggregationMaterializedContext as pt, PresetFunction as q, TokenPair as qt, ValidateOptions as r, BaseCrudController as rn, ResourceHookContext as rt, InferResourceDoc as s, AccessControlConfig as sn, AggMeasureInput as st, RouteHandlerMethod$1 as t, BulkExt as tn, ArcFieldRule as tt, TypedResourceConfig as u, HookHandler as un, AggregationConfig as ut, LookupOption as v, afterUpdate as vn, Interceptor as vt, ServiceContext as w, ArcCreateResult as wn, Transform as wt, PopulateOption as x, beforeUpdate as xn, PipelineConfig as xt, OwnershipCheck as y, beforeCreate as yn, NextFunction as yt, ResourceRegistry as z, IRequestContext as zt };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as RequestIdOptions, B as defineResource, Bt as RouteHandler, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions,
|
|
2
|
-
import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-
|
|
1
|
+
import { $t as SlugExt, A as RequestIdOptions, An as ControllerConfigurableOptions, B as defineResource, Bt as RouteHandler, C as RequestContext, D as HealthCheck, Dn as ArcListResult, E as GracefulShutdownOptions, En as ArcGetResult, F as FastifyWithDecorators, Ft as ControllerLike, H as CrudController, Jt as BaseController, L as RequestWithExtras, Lt as IController, Mn as ListResult, N as FastifyRequestExtras, Nt as RateLimitConfig, O as HealthOptions, On as ArcUpdateResult, P as FastifyWithAuth, Q as MiddlewareConfig, Qt as TreeMixin, Rt as IControllerResponse, S as QueryParserInterface, T as CrudRouterOptions, Tn as ArcDeleteResult, U as ResourceConfig, Ut as AuthPluginOptions, V as ResourceDefinition, X as CrudRouteKey, Xt as SoftDeleteMixin, Y as PresetResult, Yt as SoftDeleteExt, Z as CrudSchemas, Zt as TreeExt, a as InferAdapterDoc, c as TypedController, ct as AggMeasureShorthand, d as PaginationResult, dt as AggregationDateRangeRequirement, en as SlugMixin, et as RouteSchemaOptions, f as IntrospectionData, ft as AggregationIndexHint, g as ArcInternalMetadata, gt as AggregationsMap, h as ResourceMetadata, ht as AggregationRateLimit, i as ValidationResult, jn as ControllerConstructionOptions, k as IntrospectionPluginOptions, kn as BaseControllerOptions, l as TypedRepository, lt as AggregationCacheConfig, m as RegistryStats, mt as AggregationMaterializedResult, n as ConfigError, nn as BulkMixin, nt as FieldRule, o as InferDocType, ot as EventDefinition, p as RegistryEntry, pt as AggregationMaterializedContext, q as PresetFunction, r as ValidateOptions, rn as BaseCrudController, s as InferResourceDoc, st as AggMeasureInput, t as RouteHandlerMethod, tn as BulkExt, u as TypedResourceConfig, ut as AggregationConfig, w as ServiceContext, wn as ArcCreateResult, y as OwnershipCheck, zt as IRequestContext } from "./index-DPRH0Cme.mjs";
|
|
2
|
+
import { c as AnyRecord, i as UserBase, l as ArcRequest, n as PermissionContext, p as UserOrganization, r as PermissionResult, t as PermissionCheck, u as JWTPayload } from "./types-Dmw-6Qeo.mjs";
|
|
3
3
|
import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, t as FieldPermission } from "./fields-D3lhgzhD.mjs";
|
|
4
|
-
import "./fastify-augmentation-
|
|
5
|
-
import { A as
|
|
6
|
-
import { A as allOf, E as DynamicPermissionMatrixConfig, F as requireAuth, I as requireOwnership, L as requireRoles, M as anyOf, N as denyAll, O as createDynamicPermissionMatrix, T as DynamicPermissionMatrix, c as publicReadAdminWrite, d as requireOrgMembership, f as requireOrgRole, h as requireTeamMembership, i as ownerWithAdminBypass, j as allowPublic, k as createOrgPermissions, l as readOnly, m as requireServiceScope, n as authenticated, o as presets_d_exports, p as requireScopeContext, r as fullPublic, s as publicRead, t as adminOnly, u as requireOrgInScope, z as when } from "./index-
|
|
4
|
+
import "./fastify-augmentation-OzYGIiU1.mjs";
|
|
5
|
+
import { A as DEFAULT_ID_FIELD, B as MAX_FILTER_DEPTH, D as defineAggregation, F as DEFAULT_UPDATE_METHOD, G as RESERVED_QUERY_PARAMS, H as MAX_SEARCH_LENGTH, I as HOOK_OPERATIONS, K as SYSTEM_FIELDS, L as HOOK_PHASES, M as DEFAULT_MAX_LIMIT, N as DEFAULT_SORT, O as CRUD_OPERATIONS, P as DEFAULT_TENANT_FIELD, R as HookOperation, S as mergeResourceConfig, U as MUTATION_OPERATIONS, V as MAX_REGEX_LENGTH, W as MutationOperation, b as ResourceSeams, j as DEFAULT_LIMIT, k as CrudOperation, p as getControllerScope, v as defineResourceVariants, w as defineAction, x as SeamedResourceConfig, y as AdapterLike, z as HookPhase } from "./index-CjVg-Epg.mjs";
|
|
6
|
+
import { A as allOf, E as DynamicPermissionMatrixConfig, F as requireAuth, I as requireOwnership, L as requireRoles, M as anyOf, N as denyAll, O as createDynamicPermissionMatrix, T as DynamicPermissionMatrix, c as publicReadAdminWrite, d as requireOrgMembership, f as requireOrgRole, h as requireTeamMembership, i as ownerWithAdminBypass, j as allowPublic, k as createOrgPermissions, l as readOnly, m as requireServiceScope, n as authenticated, o as presets_d_exports, p as requireScopeContext, r as fullPublic, s as publicRead, t as adminOnly, u as requireOrgInScope, z as when } from "./index-BMnbzvtO.mjs";
|
|
7
7
|
import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-DHcHVAgk.mjs";
|
|
8
8
|
//#region src/index.d.ts
|
|
9
9
|
declare const version: string;
|
|
10
10
|
//#endregion
|
|
11
|
-
export { type AdapterLike, type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, type AnyRecord, type
|
|
11
|
+
export { type AdapterLike, type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, type AnyRecord, type ArcCreateResult, type ArcDeleteResult, ArcError, type ArcGetResult, type ArcInternalMetadata, type ArcListResult, type ArcRequest, type ArcUpdateResult, type AuthPluginOptions, BaseController, type BaseControllerOptions, BaseCrudController, type BulkExt, BulkMixin, CRUD_OPERATIONS, type ConfigError, type ControllerConfigurableOptions, type ControllerConstructionOptions, type ControllerLike, type CrudController, type CrudOperation, type CrudRouteKey, type CrudRouterOptions, type CrudSchemas, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type EventDefinition, type FastifyRequestExtras, type FastifyWithAuth, type FastifyWithDecorators, type FieldPermission, type FieldPermissionMap, type FieldRule, ForbiddenError, type GracefulShutdownOptions, HOOK_OPERATIONS, HOOK_PHASES, type HealthCheck, type HealthOptions, type HookOperation, type HookPhase, type IController, type IControllerResponse, type IRequestContext, type InferAdapterDoc, type InferDocType, type InferResourceDoc, type IntrospectionData, type IntrospectionPluginOptions, type JWTPayload, type ListResult, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, type MiddlewareConfig, type MutationOperation, NotFoundError, type OwnershipCheck, type PaginationResult, type PermissionCheck, type PermissionContext, type PermissionResult, type PresetFunction, type PresetResult, type QueryParserInterface, RESERVED_QUERY_PARAMS, type RateLimitConfig, type RegistryEntry, type RegistryStats, type RequestContext, type RequestIdOptions, type RequestWithExtras, type ResourceConfig, ResourceDefinition, type ResourceMetadata, type ResourceSeams, type RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, type SeamedResourceConfig, type ServiceContext, type SlugExt, SlugMixin, type SoftDeleteExt, SoftDeleteMixin, type TreeExt, TreeMixin, type TypedController, type TypedRepository, type TypedResourceConfig, UnauthorizedError, type UserBase, type UserOrganization, type ValidateOptions, ValidationError, type ValidationResult, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, ownerWithAdminBypass, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "./constants-DNre0wRg.mjs";
|
|
2
2
|
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-DkO8Nk6-.mjs";
|
|
3
|
-
import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-
|
|
4
|
-
import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, o as fields } from "./applyPermissionResult-
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-B65zbz9m.mjs";
|
|
4
|
+
import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, o as fields } from "./applyPermissionResult-BnyVE9eD.mjs";
|
|
5
|
+
import { a as ResourceDefinition, t as defineResource } from "./defineResource-2zvVVpxg.mjs";
|
|
6
|
+
import { c as getControllerScope } from "./pipeline-BGRnV-To.mjs";
|
|
7
|
+
import { a as mergeResourceConfig, i as defineResourceVariants, o as defineAction, s as defineAggregation } from "./core-BGa8TXJR.mjs";
|
|
8
|
+
import { A as requireAuth, D as anyOf, E as allowPublic, M as requireRoles, O as denyAll, P as when, T as allOf, _ as requireOrgMembership, b as requireServiceScope, c as publicReadAdminWrite, g as requireOrgInScope, h as createOrgPermissions, i as ownerWithAdminBypass, j as requireOwnership, l as readOnly, m as createDynamicPermissionMatrix, n as authenticated, o as presets_exports, r as fullPublic, s as publicRead, t as adminOnly, v as requireOrgRole, x as requireTeamMembership, y as requireScopeContext } from "./permissions-BrtiBKGs.mjs";
|
|
8
9
|
//#region src/index.ts
|
|
9
|
-
const version = "2.
|
|
10
|
+
const version = "2.28.0";
|
|
10
11
|
//#endregion
|
|
11
12
|
export { ArcError, BaseController, BaseCrudController, BulkMixin, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, ForbiddenError, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, NotFoundError, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createOrgPermissions, defineAction, defineAggregation, defineResource, defineResourceVariants, denyAll, fields, fullPublic, getControllerScope, mergeResourceConfig, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
|