@classytic/arc 2.10.8 → 2.11.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.
Files changed (136) hide show
  1. package/dist/{BaseController-DVNKvoX4.mjs → BaseController-JNV08qOT.mjs} +480 -442
  2. package/dist/{queryCachePlugin-Dumka73q.d.mts → QueryCache-DOBNHBE0.d.mts} +2 -32
  3. package/dist/adapters/index.d.mts +2 -2
  4. package/dist/adapters/index.mjs +1 -1
  5. package/dist/{adapters-BXY4i-hw.mjs → adapters-D0tT2Tyo.mjs} +54 -0
  6. package/dist/audit/index.d.mts +1 -1
  7. package/dist/auth/index.d.mts +1 -1
  8. package/dist/auth/index.mjs +5 -5
  9. package/dist/{betterAuthOpenApi--rdY15Ld.mjs → betterAuthOpenApi-DwxtK3uG.mjs} +1 -1
  10. package/dist/cache/index.d.mts +3 -2
  11. package/dist/cache/index.mjs +3 -3
  12. package/dist/cli/commands/docs.mjs +2 -2
  13. package/dist/cli/commands/generate.mjs +37 -27
  14. package/dist/cli/commands/init.mjs +46 -33
  15. package/dist/cli/commands/introspect.mjs +1 -1
  16. package/dist/context/index.mjs +1 -1
  17. package/dist/core/index.d.mts +3 -3
  18. package/dist/core/index.mjs +4 -3
  19. package/dist/core-DXdSSFW-.mjs +1037 -0
  20. package/dist/createActionRouter-BwaSM0No.mjs +166 -0
  21. package/dist/{createApp-BwnEAO2h.mjs → createApp-DvNYEhpb.mjs} +75 -27
  22. package/dist/docs/index.d.mts +1 -1
  23. package/dist/docs/index.mjs +2 -2
  24. package/dist/{elevation-Dci0AYLT.mjs → elevation-DOFoxoDs.mjs} +1 -1
  25. package/dist/{errorHandler-CSxe7KIM.mjs → errorHandler-BQm8ZxTK.mjs} +1 -1
  26. package/dist/{eventPlugin-ByU4Cv0e.mjs → eventPlugin--5HIkdPU.mjs} +1 -1
  27. package/dist/events/index.d.mts +3 -3
  28. package/dist/events/index.mjs +2 -2
  29. package/dist/events/transports/redis-stream-entry.d.mts +1 -1
  30. package/dist/factory/index.d.mts +1 -1
  31. package/dist/factory/index.mjs +2 -2
  32. package/dist/hooks/index.d.mts +1 -1
  33. package/dist/hooks/index.mjs +1 -1
  34. package/dist/idempotency/index.d.mts +3 -3
  35. package/dist/idempotency/index.mjs +1 -1
  36. package/dist/idempotency/redis.d.mts +1 -1
  37. package/dist/{index-C_Noptz-.d.mts → index-BYCqHCVu.d.mts} +2 -2
  38. package/dist/{index-BGbpGVyM.d.mts → index-Cm0vUrr_.d.mts} +699 -494
  39. package/dist/{index-BziRPS4H.d.mts → index-DAushRTt.d.mts} +29 -10
  40. package/dist/index-DsJ1MNfC.d.mts +1179 -0
  41. package/dist/{index-EqQN6p0W.d.mts → index-t8pLpPFW.d.mts} +11 -8
  42. package/dist/index.d.mts +6 -38
  43. package/dist/index.mjs +9 -9
  44. package/dist/integrations/event-gateway.d.mts +1 -1
  45. package/dist/integrations/event-gateway.mjs +1 -1
  46. package/dist/integrations/index.d.mts +2 -2
  47. package/dist/integrations/mcp/index.d.mts +2 -2
  48. package/dist/integrations/mcp/index.mjs +1 -1
  49. package/dist/integrations/mcp/testing.d.mts +1 -1
  50. package/dist/integrations/mcp/testing.mjs +1 -1
  51. package/dist/integrations/streamline.d.mts +46 -5
  52. package/dist/integrations/streamline.mjs +50 -21
  53. package/dist/integrations/websocket-redis.d.mts +1 -1
  54. package/dist/integrations/websocket.d.mts +2 -154
  55. package/dist/integrations/websocket.mjs +292 -224
  56. package/dist/{keys-nWQGUTu1.mjs → keys-CARyUjiR.mjs} +2 -0
  57. package/dist/{loadResources-Bksk8ydA.mjs → loadResources-YNwKHvRA.mjs} +3 -1
  58. package/dist/middleware/index.d.mts +1 -1
  59. package/dist/middleware/index.mjs +1 -1
  60. package/dist/{openapi-DpNpqBmo.mjs → openapi-C0L9ar7m.mjs} +4 -4
  61. package/dist/org/index.d.mts +1 -1
  62. package/dist/permissions/index.d.mts +1 -1
  63. package/dist/permissions/index.mjs +2 -4
  64. package/dist/{permissions-wkqRwicB.mjs → permissions-B4vU9L0Q.mjs} +221 -3
  65. package/dist/{pipe-CGJxqDGx.mjs → pipe-DVoIheVC.mjs} +1 -1
  66. package/dist/pipeline/index.d.mts +1 -1
  67. package/dist/pipeline/index.mjs +1 -1
  68. package/dist/plugins/index.d.mts +4 -4
  69. package/dist/plugins/index.mjs +10 -10
  70. package/dist/plugins/response-cache.mjs +1 -1
  71. package/dist/plugins/tracing-entry.d.mts +1 -1
  72. package/dist/plugins/tracing-entry.mjs +42 -24
  73. package/dist/presets/filesUpload.d.mts +1 -1
  74. package/dist/presets/filesUpload.mjs +3 -3
  75. package/dist/presets/index.d.mts +1 -1
  76. package/dist/presets/index.mjs +1 -1
  77. package/dist/presets/multiTenant.d.mts +1 -1
  78. package/dist/presets/multiTenant.mjs +6 -0
  79. package/dist/presets/search.d.mts +1 -1
  80. package/dist/presets/search.mjs +1 -1
  81. package/dist/{presets-CrwOvuXI.mjs → presets-k604Lj99.mjs} +1 -1
  82. package/dist/queryCachePlugin-BUXBSm4F.d.mts +34 -0
  83. package/dist/{queryCachePlugin-ChLNZvFT.mjs → queryCachePlugin-Bq6bO6vc.mjs} +3 -3
  84. package/dist/{redis-MXLp1oOf.d.mts → redis-Cm1gnRDf.d.mts} +1 -1
  85. package/dist/registry/index.d.mts +1 -1
  86. package/dist/registry/index.mjs +2 -2
  87. package/dist/{resourceToTools-BhF3JV5p.mjs → resourceToTools--okX6QBr.mjs} +534 -420
  88. package/dist/routerShared-DeESFp4a.mjs +515 -0
  89. package/dist/schemaIR-BlG9bY7v.mjs +137 -0
  90. package/dist/scope/index.mjs +2 -2
  91. package/dist/testing/index.d.mts +367 -711
  92. package/dist/testing/index.mjs +637 -1434
  93. package/dist/{tracing-xqXzWeaf.d.mts → tracing-DokiEsuz.d.mts} +9 -4
  94. package/dist/types/index.d.mts +3 -3
  95. package/dist/types/index.mjs +1 -3
  96. package/dist/{types-CVdgPXBW.d.mts → types-CgikqKAj.d.mts} +118 -19
  97. package/dist/{types-CVKBssX5.d.mts → types-D9NqiYIw.d.mts} +1 -1
  98. package/dist/utils/index.d.mts +2 -968
  99. package/dist/utils/index.mjs +5 -6
  100. package/dist/utils-D3Yxnrwr.mjs +1639 -0
  101. package/dist/websocket-CyJ1VIFI.d.mts +186 -0
  102. package/package.json +7 -5
  103. package/skills/arc/SKILL.md +123 -38
  104. package/skills/arc/references/testing.md +212 -183
  105. package/dist/applyPermissionResult-QhV1Pa-g.mjs +0 -37
  106. package/dist/core-3MWJosCH.mjs +0 -1459
  107. package/dist/createActionRouter-C8UUB3Px.mjs +0 -249
  108. package/dist/errors-BI8kEKsO.d.mts +0 -140
  109. package/dist/fields-CTMWOUDt.mjs +0 -126
  110. package/dist/queryParser-NR__Qiju.mjs +0 -419
  111. package/dist/types-CDnTEpga.mjs +0 -27
  112. package/dist/utils-LMwVidKy.mjs +0 -947
  113. /package/dist/{HookSystem-BjFu7zf1.mjs → HookSystem-CGsMd6oK.mjs} +0 -0
  114. /package/dist/{ResourceRegistry-CcN2LVrc.mjs → ResourceRegistry-DkAeAuTX.mjs} +0 -0
  115. /package/dist/{actionPermissions-TUVR3uiZ.mjs → actionPermissions-C8YYU92K.mjs} +0 -0
  116. /package/dist/{caching-3h93rkJM.mjs → caching-CheW3m-S.mjs} +0 -0
  117. /package/dist/{errorHandler-2ii4RIYr.d.mts → errorHandler-Co3lnVmJ.d.mts} +0 -0
  118. /package/dist/{errors-BqdUDja_.mjs → errors-D5c-5BJL.mjs} +0 -0
  119. /package/dist/{eventPlugin-D1ThQ1Pp.d.mts → eventPlugin-CUNjYYRY.d.mts} +0 -0
  120. /package/dist/{interface-B-pe8fhj.d.mts → interface-CkkWm5uR.d.mts} +0 -0
  121. /package/dist/{interface-yhyb_pLY.d.mts → interface-Da0r7Lna.d.mts} +0 -0
  122. /package/dist/{memory-DqI-449b.mjs → memory-DikHSvWa.mjs} +0 -0
  123. /package/dist/{metrics-TuOmguhi.mjs → metrics-Csh4nsvv.mjs} +0 -0
  124. /package/dist/{multipartBody-CUQGVlM_.mjs → multipartBody-CvTR1Un6.mjs} +0 -0
  125. /package/dist/{pluralize-CWP6MB39.mjs → pluralize-BneOJkpi.mjs} +0 -0
  126. /package/dist/{redis-stream-bkO88VHx.d.mts → redis-stream-CM8TXTix.d.mts} +0 -0
  127. /package/dist/{registry-B0Wl7uVV.mjs → registry-D63ee7fl.mjs} +0 -0
  128. /package/dist/{replyHelpers-BLojtuvR.mjs → replyHelpers-ByllIXXV.mjs} +0 -0
  129. /package/dist/{requestContext-C38GskNt.mjs → requestContext-CfRkaxwf.mjs} +0 -0
  130. /package/dist/{schemaConverter-BxFDdtXu.mjs → schemaConverter-B0oKLuqI.mjs} +0 -0
  131. /package/dist/{sse-D8UeDwis.mjs → sse-V7aXc3bW.mjs} +0 -0
  132. /package/dist/{store-helpers-DYYUQbQN.mjs → store-helpers-BhrzxvyQ.mjs} +0 -0
  133. /package/dist/{typeGuards-Cj5Rgvlg.mjs → typeGuards-CcFZXgU7.mjs} +0 -0
  134. /package/dist/{types-D57iXYb8.mjs → types-DV9WDfeg.mjs} +0 -0
  135. /package/dist/{versioning-B6mimogM.mjs → versioning-CGPjkqAg.mjs} +0 -0
  136. /package/dist/{versioning-CeUXHfjw.d.mts → versioning-M9lNLhO8.d.mts} +0 -0
@@ -1,4 +1,4 @@
1
- import { B as ResourceDefinition, C as RequestContext, F as FastifyWithDecorators, Mt as IControllerResponse, Nt as IRequestContext, T as CrudRouterOptions, Yt as AnyRecord, bt as ResourceConfig, ct as CrudController, jt as IController } from "./index-BGbpGVyM.mjs";
1
+ import { B as ResourceDefinition, C as RequestContext, F as FastifyWithDecorators, Pt as AnyRecord, T as CrudRouterOptions, _t as IControllerResponse, at as ResourceConfig, gt as IController, q as CrudController, vt as IRequestContext } from "./index-Cm0vUrr_.mjs";
2
2
  import { r as RequestScope } from "./types-tgR4Pt8F.mjs";
3
3
  import { c as PermissionCheck } from "./fields-C8Y0XLAu.mjs";
4
4
  import { FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
@@ -54,16 +54,19 @@ declare const RESERVED_QUERY_PARAMS: Readonly<Set<string>>;
54
54
  //#endregion
55
55
  //#region src/core/createCrudRouter.d.ts
56
56
  /**
57
- * Create CRUD routes for a controller
57
+ * Create CRUD routes for a controller.
58
58
  *
59
- * @param fastify - Fastify instance with Arc decorators
60
- * @param controller - CRUD controller with handler methods
61
- * @param options - Router configuration
59
+ * @param fastify - Fastify instance with Arc decorators
60
+ * @param controller - CRUD controller with handler methods (optional when
61
+ * `disableDefaultRoutes: true` and only custom `routes`
62
+ * are being registered)
63
+ * @param options - Router configuration
62
64
  */
63
65
  declare function createCrudRouter<TDoc = unknown>(fastify: FastifyWithDecorators, controller: CrudController<TDoc> | undefined, options?: CrudRouterOptions): void;
64
66
  /**
65
- * Create permission middleware from PermissionCheck
66
- * Useful for custom route registration
67
+ * Build a permission middleware from a PermissionCheck — useful when hosts
68
+ * register their own routes outside the resource system but still want to
69
+ * evaluate permissions through the shared applicator.
67
70
  */
68
71
  declare function createPermissionMiddleware(permission: PermissionCheck, resourceName: string, action: string): RouteHandlerMethod | null;
69
72
  //#endregion
@@ -108,7 +111,7 @@ type VariantsResult<TDoc, V extends VariantsMap<TDoc>> = { [K in keyof V]: Resou
108
111
  * @returns A record where each key from `variants` maps to a real
109
112
  * `ResourceDefinition` ready for `.toPlugin()` registration.
110
113
  */
111
- declare function defineResourceVariants<TDoc = AnyRecord, V extends VariantsMap<TDoc> = VariantsMap<TDoc>>(base: Omit<ResourceConfig<TDoc>, "name" | "prefix">, variants: V): VariantsResult<TDoc, V>;
114
+ declare function defineResourceVariants<TDoc extends AnyRecord = AnyRecord, V extends VariantsMap<TDoc> = VariantsMap<TDoc>>(base: Omit<ResourceConfig<TDoc>, "name" | "prefix">, variants: V): VariantsResult<TDoc, V>;
112
115
  //#endregion
113
116
  //#region src/core/fastifyAdapter.d.ts
114
117
  /**
package/dist/index.d.mts CHANGED
@@ -1,43 +1,11 @@
1
- import { A as RequestIdOptions, B as ResourceDefinition, C as RequestContext, D as HealthCheck, Dt as RouteSchemaOptions, E as GracefulShutdownOptions, F as FastifyWithDecorators, L as RequestWithExtras, Mt as IControllerResponse, N as FastifyRequestExtras, Nt as IRequestContext, O as HealthOptions, P as FastifyWithAuth, Pt as RouteHandler, Qt as JWTPayload, T as CrudRouterOptions, V as defineResource, Wt as AuthPluginOptions, Xt as ApiResponse, Yt as AnyRecord, Zt as ArcRequest, _n as RepositoryLike, _t as PresetResult, a as InferAdapterDoc, an as BaseControllerOptions, bt as ResourceConfig, c as TypedController, ct as CrudController, d as PaginationResult, dt as EventDefinition, f as IntrospectionData, ft as FieldRule, g as ArcInternalMetadata, gn as RelationMetadata, h as ResourceMetadata, hn as FieldMetadata, ht as PresetFunction, i as ValidationResult$1, in as BaseController, jt as IController, k as IntrospectionPluginOptions, kt as ControllerLike, l as TypedRepository, lt as CrudRouteKey, m as RegistryStats, mn as DataAdapter, n as ConfigError, nn as envelope, o as InferDocType, p as RegistryEntry, pt as MiddlewareConfig, r as ValidateOptions, s as InferResourceDoc, t as RouteHandlerMethod, tn as UserOrganization, u as TypedResourceConfig, ut as CrudSchemas, vn as SchemaMetadata, vt as RateLimitConfig, w as ServiceContext, y as OwnershipCheck, yn as ValidationResult } from "./index-BGbpGVyM.mjs";
1
+ import { $t as ArcListResult, A as RequestIdOptions, An as RelationMetadata, B as ResourceDefinition, Bt as UserOrganization, C as RequestContext, D as HealthCheck, E as GracefulShutdownOptions, F as FastifyWithDecorators, Ft as ApiResponse, Gt as TreeMixin, Ht as SoftDeleteExt, It as ArcRequest, J as CrudRouteKey, Jt as BulkExt, Kt as SlugExt, L as RequestWithExtras, Lt as JWTPayload, Mn as SchemaMetadata, N as FastifyRequestExtras, Nn as ValidationResult, O as HealthOptions, On as DataAdapter, P as FastifyWithAuth, Pt as AnyRecord, Q as MiddlewareConfig, Qt as ArcGetResult, S as QueryParserInterface, T as CrudRouterOptions, Ut as SoftDeleteMixin, V as defineResource, Vt as BaseController, Wt as TreeExt, X as EventDefinition, Xt as ArcCreateResult, Y as CrudSchemas, Yt as BulkMixin, Z as FieldRule, Zt as ArcDeleteResult, _t as IControllerResponse, a as InferAdapterDoc, at as ResourceConfig, c as TypedController, d as PaginationResult, en as ArcUpdateResult, et as PresetFunction, f as IntrospectionData, ft as RouteSchemaOptions, g as ArcInternalMetadata, gt as IController, h as ResourceMetadata, i as ValidationResult$1, jn as RepositoryLike, k as IntrospectionPluginOptions, kn as FieldMetadata, kt as AuthPluginOptions, l as TypedRepository, m as RegistryStats, mt as ControllerLike, n as ConfigError, nn as BaseCrudController, nt as PresetResult, o as InferDocType, p as RegistryEntry, q as CrudController, qt as SlugMixin, r as ValidateOptions, rn as ListResult, rt as RateLimitConfig, s as InferResourceDoc, t as RouteHandlerMethod, tn as BaseControllerOptions, u as TypedResourceConfig, vt as IRequestContext, w as ServiceContext, y as OwnershipCheck, yt as RouteHandler } from "./index-Cm0vUrr_.mjs";
2
2
  import { a as applyFieldWritePermissions, c as PermissionCheck, d as UserBase, i as applyFieldReadPermissions, l as PermissionContext, n as FieldPermissionMap, o as fields, t as FieldPermission, u as PermissionResult } from "./fields-C8Y0XLAu.mjs";
3
- import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-BziRPS4H.mjs";
4
- import { C as MAX_REGEX_LENGTH, D as RESERVED_QUERY_PARAMS, E as MutationOperation, O as SYSTEM_FIELDS, S as MAX_FILTER_DEPTH, T as MUTATION_OPERATIONS, _ as DEFAULT_UPDATE_METHOD, a as getControllerScope, b as HookOperation, d as CrudOperation, f as DEFAULT_ID_FIELD, g as DEFAULT_TENANT_FIELD, h as DEFAULT_SORT, m as DEFAULT_MAX_LIMIT, p as DEFAULT_LIMIT, s as defineResourceVariants, u as CRUD_OPERATIONS, v as HOOK_OPERATIONS, w as MAX_SEARCH_LENGTH, x as HookPhase, y as HOOK_PHASES } from "./index-EqQN6p0W.mjs";
5
- import { A as requireRoles, C as allOf, E as denyAll, M as when, O as requireAuth, S as createOrgPermissions, T as anyOf, a as presets_d_exports, c as readOnly, d as requireOrgRole, f as requireScopeContext, i as ownerWithAdminBypass, k as requireOwnership, l as requireOrgInScope, m as requireTeamMembership, n as authenticated, o as publicRead, p as requireServiceScope, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as requireOrgMembership, v as DynamicPermissionMatrix, w as allowPublic, x as createDynamicPermissionMatrix, y as DynamicPermissionMatrixConfig } from "./index-C_Noptz-.mjs";
6
- import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-BI8kEKsO.mjs";
3
+ import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-DAushRTt.mjs";
4
+ import { C as MAX_REGEX_LENGTH, D as RESERVED_QUERY_PARAMS, E as MutationOperation, O as SYSTEM_FIELDS, S as MAX_FILTER_DEPTH, T as MUTATION_OPERATIONS, _ as DEFAULT_UPDATE_METHOD, a as getControllerScope, b as HookOperation, d as CrudOperation, f as DEFAULT_ID_FIELD, g as DEFAULT_TENANT_FIELD, h as DEFAULT_SORT, m as DEFAULT_MAX_LIMIT, p as DEFAULT_LIMIT, s as defineResourceVariants, u as CRUD_OPERATIONS, v as HOOK_OPERATIONS, w as MAX_SEARCH_LENGTH, x as HookPhase, y as HOOK_PHASES } from "./index-t8pLpPFW.mjs";
5
+ import { A as requireRoles, C as allOf, E as denyAll, M as when, O as requireAuth, S as createOrgPermissions, T as anyOf, a as presets_d_exports, c as readOnly, d as requireOrgRole, f as requireScopeContext, i as ownerWithAdminBypass, k as requireOwnership, l as requireOrgInScope, m as requireTeamMembership, n as authenticated, o as publicRead, p as requireServiceScope, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as requireOrgMembership, v as DynamicPermissionMatrix, w as allowPublic, x as createDynamicPermissionMatrix, y as DynamicPermissionMatrixConfig } from "./index-BYCqHCVu.mjs";
6
+ import { ft as UnauthorizedError, j as envelope, mt as createDomainError, ot as ForbiddenError, pt as ValidationError, rt as ArcError, st as NotFoundError, t as getUserId } from "./index-DsJ1MNfC.mjs";
7
7
 
8
- //#region src/core/validateResourceConfig.d.ts
9
- interface ConfigError$1 {
10
- field: string;
11
- message: string;
12
- suggestion?: string;
13
- }
14
- interface ValidationResult$2 {
15
- valid: boolean;
16
- errors: ConfigError$1[];
17
- warnings: ConfigError$1[];
18
- }
19
- interface ValidateOptions$1 {
20
- /** Skip controller method validation (for testing) */
21
- skipControllerCheck?: boolean;
22
- /** Allow unknown preset names */
23
- allowUnknownPresets?: boolean;
24
- /** Custom valid permission keys beyond CRUD */
25
- additionalPermissionKeys?: string[];
26
- }
27
- /**
28
- * Validate a resource configuration
29
- */
30
- declare function validateResourceConfig(config: ResourceConfig, options?: ValidateOptions$1): ValidationResult$2;
31
- /**
32
- * Format validation errors for display
33
- */
34
- declare function formatValidationErrors(resourceName: string, result: ValidationResult$2): string;
35
- /**
36
- * Validate and throw if invalid
37
- */
38
- declare function assertValidConfig(config: ResourceConfig, options?: ValidateOptions$1): void;
39
- //#endregion
40
8
  //#region src/index.d.ts
41
9
  declare const version: string;
42
10
  //#endregion
43
- export { type ValidationResult as AdapterValidationResult, type AnyRecord, type ApiResponse, ArcError, type ArcInternalMetadata, type ArcRequest, type AuthPluginOptions, BaseController, type BaseControllerOptions, CRUD_OPERATIONS, type ConfigError, type ControllerLike, type CrudController, CrudOperation, type CrudRouteKey, type CrudRouterOptions, type CrudSchemas, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, type DataAdapter, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type EventDefinition, type FastifyRequestExtras, type FastifyWithAuth, type FastifyWithDecorators, type FieldMetadata, type FieldPermission, type FieldPermissionMap, type FieldRule, ForbiddenError, type GracefulShutdownOptions, HOOK_OPERATIONS, HOOK_PHASES, type HealthCheck, type HealthOptions, HookOperation, HookPhase, type IController, type IControllerResponse, type IRequestContext, type InferAdapterDoc, type InferDocType, type InferResourceDoc, type IntrospectionData, type IntrospectionPluginOptions, type JWTPayload, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, type MiddlewareConfig, MongooseAdapter, MutationOperation, NotFoundError, type OwnershipCheck, type PaginationResult, type PermissionCheck, type PermissionContext, type PermissionResult, type PresetFunction, type PresetResult, PrismaAdapter, RESERVED_QUERY_PARAMS, type RateLimitConfig, type RegistryEntry, type RegistryStats, type RelationMetadata, type RepositoryLike, type RequestContext, type RequestIdOptions, type RequestWithExtras, type ResourceConfig, ResourceDefinition, type ResourceMetadata, type RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, type SchemaMetadata, type ServiceContext, type TypedController, type TypedRepository, type TypedResourceConfig, UnauthorizedError, type UserBase, type UserOrganization, type ValidateOptions, ValidationError, type ValidationResult$1 as ValidationResult, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, assertValidConfig, authenticated, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, formatValidationErrors, fullPublic, getControllerScope, ownerWithAdminBypass, presets_d_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, validateResourceConfig, version, when };
11
+ export { type ValidationResult as AdapterValidationResult, type AnyRecord, type ApiResponse, 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 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 DataAdapter, type DynamicPermissionMatrix, type DynamicPermissionMatrixConfig, type EventDefinition, type FastifyRequestExtras, type FastifyWithAuth, type FastifyWithDecorators, type FieldMetadata, 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, MongooseAdapter, type MutationOperation, NotFoundError, type OwnershipCheck, type PaginationResult, type PermissionCheck, type PermissionContext, type PermissionResult, type PresetFunction, type PresetResult, PrismaAdapter, type QueryParserInterface, RESERVED_QUERY_PARAMS, type RateLimitConfig, type RegistryEntry, type RegistryStats, type RelationMetadata, type RepositoryLike, type RequestContext, type RequestIdOptions, type RequestWithExtras, type ResourceConfig, ResourceDefinition, type ResourceMetadata, type RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, type SchemaMetadata, 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$1 as ValidationResult, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, fullPublic, getControllerScope, getUserId, 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,12 +1,12 @@
1
- import { a as createMongooseAdapter, i as MongooseAdapter, r as createPrismaAdapter, t as PrismaAdapter } from "./adapters-BXY4i-hw.mjs";
1
+ import { a as createMongooseAdapter, i as MongooseAdapter, r as createPrismaAdapter, t as PrismaAdapter } from "./adapters-D0tT2Tyo.mjs";
2
2
  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-BhY1OHoH.mjs";
3
- import { t as BaseController } from "./BaseController-DVNKvoX4.mjs";
4
- import { t as envelope } from "./types-CDnTEpga.mjs";
5
- import { n as applyFieldWritePermissions, r as fields, t as applyFieldReadPermissions } from "./fields-CTMWOUDt.mjs";
6
- import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-BqdUDja_.mjs";
7
- import { a as formatValidationErrors, i as assertValidConfig, n as ResourceDefinition, o as validateResourceConfig, p as getControllerScope, r as defineResource, t as defineResourceVariants } from "./core-3MWJosCH.mjs";
8
- import { C as requireAuth, D as when, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "./permissions-wkqRwicB.mjs";
3
+ import { j as getUserId, r as envelope } from "./utils-D3Yxnrwr.mjs";
4
+ import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-JNV08qOT.mjs";
5
+ import { C as requireAuth, D as when, M as applyFieldWritePermissions, N as fields, T as requireRoles, _ as requireTeamMembership, a as presets_exports, b as anyOf, c as readOnly, d as createOrgPermissions, f as requireOrgInScope, g as requireServiceScope, h as requireScopeContext, i as ownerWithAdminBypass, j as applyFieldReadPermissions, m as requireOrgRole, n as authenticated, o as publicRead, p as requireOrgMembership, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as createDynamicPermissionMatrix, v as allOf, w as requireOwnership, x as denyAll, y as allowPublic } from "./permissions-B4vU9L0Q.mjs";
6
+ import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-D5c-5BJL.mjs";
7
+ import { _ as getControllerScope } from "./routerShared-DeESFp4a.mjs";
8
+ import { n as ResourceDefinition, r as defineResource, t as defineResourceVariants } from "./core-DXdSSFW-.mjs";
9
9
  //#region src/index.ts
10
- const version = "2.10.8";
10
+ const version = "2.11.0";
11
11
  //#endregion
12
- export { ArcError, BaseController, 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, MongooseAdapter, NotFoundError, PrismaAdapter, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, assertValidConfig, authenticated, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, formatValidationErrors, fullPublic, getControllerScope, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, validateResourceConfig, version, when };
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, MongooseAdapter, NotFoundError, PrismaAdapter, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, SlugMixin, SoftDeleteMixin, TreeMixin, UnauthorizedError, ValidationError, adminOnly, allOf, allowPublic, anyOf, applyFieldReadPermissions, applyFieldWritePermissions, authenticated, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, fullPublic, getControllerScope, getUserId, ownerWithAdminBypass, presets_exports as permissions, publicRead, publicReadAdminWrite, readOnly, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, version, when };
@@ -1,5 +1,5 @@
1
1
  import { n as DomainEvent } from "../EventTransport-CfVEGaEl.mjs";
2
- import { WebSocketClient, WebSocketMessage } from "./websocket.mjs";
2
+ import { a as WebSocketMessage, i as WebSocketClient } from "../websocket-CyJ1VIFI.mjs";
3
3
  import { FastifyPluginAsync, FastifyRequest } from "fastify";
4
4
 
5
5
  //#region src/integrations/event-gateway.d.ts
@@ -4,7 +4,7 @@ const eventGatewayPluginImpl = async (fastify, opts = {}) => {
4
4
  const { auth = true, orgScoped = false, roomPolicy, maxMessageBytes, maxSubscriptionsPerClient, authenticate } = opts;
5
5
  if (auth && !authenticate && !fastify.hasDecorator("authenticate")) throw new Error("[arc-event-gateway] auth is true but fastify.authenticate is not registered. Register an auth plugin first, provide a custom authenticate function, or set auth: false.");
6
6
  if (opts.sse !== false) {
7
- const { default: ssePlugin } = await import("../sse-D8UeDwis.mjs").then((n) => n.r);
7
+ const { default: ssePlugin } = await import("../sse-V7aXc3bW.mjs").then((n) => n.r);
8
8
  await fastify.register(ssePlugin, {
9
9
  path: opts.sse?.path ?? "/events/stream",
10
10
  requireAuth: auth,
@@ -1,7 +1,7 @@
1
- import { WebSocketClient, WebSocketMessage, WebSocketPluginOptions } from "./websocket.mjs";
1
+ import { a as WebSocketMessage, i as WebSocketClient, o as WebSocketPluginOptions } from "../websocket-CyJ1VIFI.mjs";
2
2
  import { EventGatewayOptions } from "./event-gateway.mjs";
3
3
  import { JobDefinition, JobDispatchOptions, JobDispatcher, JobMeta, JobsPluginOptions, QueueStats } from "./jobs.mjs";
4
- import { c as McpResourceConfig, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler } from "../types-CVKBssX5.mjs";
4
+ import { c as McpResourceConfig, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler } from "../types-D9NqiYIw.mjs";
5
5
  import { StreamlinePluginOptions, WorkflowLike, WorkflowRunLike } from "./streamline.mjs";
6
6
  import { WebhookDeliveryRecord, WebhookManager, WebhookPluginOptions, WebhookStore, WebhookSubscription } from "./webhooks.mjs";
7
7
  export { type BetterAuthHandler, type CallToolResult, type CreateMcpServerConfig, type CrudOperation, type EventGatewayOptions, type JobDefinition, type JobDispatchOptions, type JobDispatcher, type JobMeta, type JobsPluginOptions, type McpAuthResult, type McpPluginOptions, type McpResourceConfig, type PromptDefinition, type QueueStats, type StreamlinePluginOptions, type ToolAnnotations, type ToolContext, type ToolDefinition, type WebSocketClient, type WebSocketMessage, type WebSocketPluginOptions, type WebhookDeliveryRecord, type WebhookManager, type WebhookPluginOptions, type WebhookStore, type WebhookSubscription, type WorkflowLike, type WorkflowRunLike };
@@ -1,5 +1,5 @@
1
- import { B as ResourceDefinition } from "../../index-BGbpGVyM.mjs";
2
- import { a as McpAuthResolver, c as McpResourceConfig, d as SessionEntry, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler, u as PromptResult } from "../../types-CVKBssX5.mjs";
1
+ import { B as ResourceDefinition } from "../../index-Cm0vUrr_.mjs";
2
+ import { a as McpAuthResolver, c as McpResourceConfig, d as SessionEntry, f as ToolAnnotations, i as CrudOperation, l as PromptDefinition, m as ToolDefinition, n as CallToolResult, o as McpAuthResult, p as ToolContext, r as CreateMcpServerConfig, s as McpPluginOptions, t as BetterAuthHandler, u as PromptResult } from "../../types-D9NqiYIw.mjs";
3
3
  import { FastifyPluginAsync } from "fastify";
4
4
  import { z } from "zod";
5
5
 
@@ -1,4 +1,4 @@
1
- import { n as fieldRulesToZod, r as createMcpServer, t as resourceToTools } from "../../resourceToTools-BhF3JV5p.mjs";
1
+ import { n as fieldRulesToZod, r as createMcpServer, t as resourceToTools } from "../../resourceToTools--okX6QBr.mjs";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import fp from "fastify-plugin";
4
4
  //#region src/integrations/mcp/defineTool.ts
@@ -1,4 +1,4 @@
1
- import { o as McpAuthResult, s as McpPluginOptions } from "../../types-CVKBssX5.mjs";
1
+ import { o as McpAuthResult, s as McpPluginOptions } from "../../types-D9NqiYIw.mjs";
2
2
 
3
3
  //#region src/integrations/mcp/testing.d.ts
4
4
  interface TestMcpClientOptions {
@@ -1,4 +1,4 @@
1
- import { r as createMcpServer, t as resourceToTools } from "../../resourceToTools-BhF3JV5p.mjs";
1
+ import { r as createMcpServer, t as resourceToTools } from "../../resourceToTools--okX6QBr.mjs";
2
2
  //#region src/integrations/mcp/testing.ts
3
3
  /**
4
4
  * @classytic/arc/mcp/testing — MCP Test Utilities
@@ -1,7 +1,7 @@
1
1
  import { FastifyPluginAsync } from "fastify";
2
2
 
3
3
  //#region src/integrations/streamline.d.ts
4
- /** Start options — matches @classytic/streamline v2.1 StartOptions */
4
+ /** Start options — matches @classytic/streamline v2.1+ StartOptions */
5
5
  interface WorkflowStartOptions {
6
6
  meta?: Record<string, unknown>;
7
7
  idempotencyKey?: string;
@@ -65,15 +65,38 @@ interface StreamlinePluginOptions {
65
65
  /** Connect workflow lifecycle events to Arc's event bus (default: true) */
66
66
  bridgeEvents?: boolean;
67
67
  /**
68
- * Bridge step-level events (step:started, step:completed, step:failed) to Arc's event bus.
68
+ * Bridge the workflow's internal event bus (step + workflow lifecycle +
69
+ * engine telemetry) to Arc's event bus, topic-scoped as
70
+ * `workflow.${workflowId}.${eventName}`.
71
+ *
72
+ * Covers the full streamline 2.2 event surface:
73
+ * - Step events: started, completed, failed, waiting, skipped,
74
+ * retry-scheduled, compensated
75
+ * - Workflow lifecycle: started, completed, failed, waiting, resumed,
76
+ * cancelled, recovered, retry, compensating
77
+ * - Engine telemetry: engine:error, scheduler:error,
78
+ * scheduler:circuit-open
79
+ *
80
+ * Subscriptions use structural `container.eventBus.on(...)` — future
81
+ * streamline releases can add events without breaking arc; missing
82
+ * events are simply never handled (no crash). Requires the workflow
83
+ * to expose `container.eventBus`.
84
+ *
69
85
  * Disabled by default — enable for dashboards or monitoring.
70
- * Requires the workflow to expose `container.eventBus` (streamline >=2.1).
71
86
  * @default false
72
87
  */
88
+ bridgeBusEvents?: boolean;
89
+ /**
90
+ * @deprecated v2.11.0 — renamed to `bridgeBusEvents` which now covers
91
+ * step + workflow + engine events (not just step-level). Still accepted
92
+ * as an alias; will be removed in v3. Prefer `bridgeBusEvents`.
93
+ */
73
94
  bridgeStepEvents?: boolean;
74
95
  /**
75
96
  * Enable SSE streaming endpoint: GET /:workflowId/runs/:runId/stream
76
- * Streams step-level events as Server-Sent Events for live UI updates.
97
+ * Streams step-level + lifecycle events as Server-Sent Events for live
98
+ * UI updates. Auto-closes the stream on terminal workflow events
99
+ * (completed / failed / cancelled).
77
100
  * @default false
78
101
  */
79
102
  enableStreaming?: boolean;
@@ -86,7 +109,25 @@ interface StreamlinePluginOptions {
86
109
  get?: (request: unknown) => boolean | Promise<boolean>;
87
110
  };
88
111
  }
112
+ /**
113
+ * Full event list published on a streamline workflow's internal `eventBus`
114
+ * (tracks streamline 2.2's `EventPayloadMap` in
115
+ * `@classytic/streamline/src/core/events.ts`).
116
+ *
117
+ * Hardcoded here by design — arc subscribes via structural
118
+ * `eventBus.on(name, handler)`, which is a no-op for events the running
119
+ * streamline version doesn't emit. New events a future streamline release
120
+ * adds can be bridged by updating this list; arc never breaks just
121
+ * because streamline extended its bus.
122
+ */
123
+ declare const STREAMLINE_BUS_EVENTS: readonly ["step:started", "step:completed", "step:failed", "step:waiting", "step:skipped", "step:retry-scheduled", "step:compensated", "workflow:started", "workflow:completed", "workflow:failed", "workflow:waiting", "workflow:resumed", "workflow:cancelled", "workflow:recovered", "workflow:retry", "workflow:compensating", "engine:error", "scheduler:error", "scheduler:circuit-open"];
124
+ /**
125
+ * Workflow events that should auto-close an SSE stream when observed.
126
+ * Recovered / waiting / resumed / retry / compensating are NOT terminal —
127
+ * the run is still active after them.
128
+ */
129
+ declare const STREAMLINE_TERMINAL_EVENTS: readonly ["workflow:completed", "workflow:failed", "workflow:cancelled"];
89
130
  /** Pluggable streamline integration for Arc */
90
131
  declare const streamlinePlugin: FastifyPluginAsync<StreamlinePluginOptions>;
91
132
  //#endregion
92
- export { StreamlinePluginOptions, WorkflowLike, WorkflowRunLike, WorkflowStartOptions, streamlinePlugin };
133
+ export { STREAMLINE_BUS_EVENTS, STREAMLINE_TERMINAL_EVENTS, StreamlinePluginOptions, WorkflowLike, WorkflowRunLike, WorkflowStartOptions, streamlinePlugin };
@@ -1,6 +1,49 @@
1
1
  //#region src/integrations/streamline.ts
2
+ /**
3
+ * Full event list published on a streamline workflow's internal `eventBus`
4
+ * (tracks streamline 2.2's `EventPayloadMap` in
5
+ * `@classytic/streamline/src/core/events.ts`).
6
+ *
7
+ * Hardcoded here by design — arc subscribes via structural
8
+ * `eventBus.on(name, handler)`, which is a no-op for events the running
9
+ * streamline version doesn't emit. New events a future streamline release
10
+ * adds can be bridged by updating this list; arc never breaks just
11
+ * because streamline extended its bus.
12
+ */
13
+ const STREAMLINE_BUS_EVENTS = [
14
+ "step:started",
15
+ "step:completed",
16
+ "step:failed",
17
+ "step:waiting",
18
+ "step:skipped",
19
+ "step:retry-scheduled",
20
+ "step:compensated",
21
+ "workflow:started",
22
+ "workflow:completed",
23
+ "workflow:failed",
24
+ "workflow:waiting",
25
+ "workflow:resumed",
26
+ "workflow:cancelled",
27
+ "workflow:recovered",
28
+ "workflow:retry",
29
+ "workflow:compensating",
30
+ "engine:error",
31
+ "scheduler:error",
32
+ "scheduler:circuit-open"
33
+ ];
34
+ /**
35
+ * Workflow events that should auto-close an SSE stream when observed.
36
+ * Recovered / waiting / resumed / retry / compensating are NOT terminal —
37
+ * the run is still active after them.
38
+ */
39
+ const STREAMLINE_TERMINAL_EVENTS = [
40
+ "workflow:completed",
41
+ "workflow:failed",
42
+ "workflow:cancelled"
43
+ ];
2
44
  const streamlinePluginImpl = async (fastify, options) => {
3
- const { workflows, prefix = "/workflows", auth = true, bridgeEvents = true, bridgeStepEvents = false, enableStreaming = false, permissions: perms } = options;
45
+ const { workflows, prefix = "/workflows", auth = true, bridgeEvents = true, enableStreaming = false, permissions: perms } = options;
46
+ const bridgeBus = options.bridgeBusEvents ?? options.bridgeStepEvents ?? false;
4
47
  const registry = /* @__PURE__ */ new Map();
5
48
  for (const wf of workflows) {
6
49
  const id = wf.definition.id;
@@ -148,13 +191,7 @@ const streamlinePluginImpl = async (fastify, options) => {
148
191
  data: await wf.engine.rewindTo?.(runId, stepId)
149
192
  };
150
193
  });
151
- if (bridgeStepEvents && wf.container?.eventBus && fastify.events?.publish) for (const eventName of [
152
- "step:started",
153
- "step:completed",
154
- "step:failed",
155
- "step:skipped",
156
- "step:retry-scheduled"
157
- ]) wf.container.eventBus.on(eventName, (payload) => {
194
+ if (bridgeBus && wf.container?.eventBus && fastify.events?.publish) for (const eventName of STREAMLINE_BUS_EVENTS) wf.container.eventBus.on(eventName, (payload) => {
158
195
  const p = payload;
159
196
  fastify.events.publish(`workflow.${id}.${eventName}`, {
160
197
  runId: p?.runId,
@@ -183,15 +220,7 @@ const streamlinePluginImpl = async (fastify, options) => {
183
220
  "Cache-Control": "no-cache",
184
221
  Connection: "keep-alive"
185
222
  });
186
- const events = [
187
- "step:started",
188
- "step:completed",
189
- "step:failed",
190
- "step:skipped",
191
- "workflow:completed",
192
- "workflow:failed",
193
- "workflow:cancelled"
194
- ];
223
+ const terminalEvents = new Set(STREAMLINE_TERMINAL_EVENTS);
195
224
  const listeners = [];
196
225
  let closed = false;
197
226
  const send = (event, data) => {
@@ -211,12 +240,12 @@ const streamlinePluginImpl = async (fastify, options) => {
211
240
  reply.raw.end();
212
241
  } catch {}
213
242
  };
214
- for (const eventName of events) {
243
+ for (const eventName of STREAMLINE_BUS_EVENTS) {
215
244
  const fn = (payload) => {
216
245
  const p = payload;
217
- if (p?.runId !== runId) return;
246
+ if (typeof p?.runId === "string" && p.runId !== runId) return;
218
247
  send(eventName, p);
219
- if (eventName === "workflow:completed" || eventName === "workflow:failed" || eventName === "workflow:cancelled") cleanup();
248
+ if (terminalEvents.has(eventName) && p?.runId === runId) cleanup();
220
249
  };
221
250
  wf.container.eventBus.on(eventName, fn);
222
251
  listeners.push({
@@ -244,4 +273,4 @@ const streamlinePluginImpl = async (fastify, options) => {
244
273
  /** Pluggable streamline integration for Arc */
245
274
  const streamlinePlugin = streamlinePluginImpl;
246
275
  //#endregion
247
- export { streamlinePlugin };
276
+ export { STREAMLINE_BUS_EVENTS, STREAMLINE_TERMINAL_EVENTS, streamlinePlugin };
@@ -1,4 +1,4 @@
1
- import { WebSocketAdapter } from "./websocket.mjs";
1
+ import { c as WebSocketAdapter } from "../websocket-CyJ1VIFI.mjs";
2
2
 
3
3
  //#region src/integrations/websocket-redis.d.ts
4
4
  interface RedisLike {
@@ -1,154 +1,2 @@
1
- import { FastifyPluginAsync } from "fastify";
2
-
3
- //#region src/integrations/websocket.d.ts
4
- interface WebSocketClient {
5
- id: string;
6
- socket: {
7
- send(data: string): void;
8
- close(): void;
9
- readyState: number;
10
- };
11
- subscriptions: Set<string>;
12
- userId?: string;
13
- organizationId?: string;
14
- /** OAuth client ID — present for service/machine-to-machine connections */
15
- clientId?: string;
16
- /** OAuth scopes — present for service/machine-to-machine connections */
17
- scopes?: readonly string[];
18
- metadata?: Record<string, unknown>;
19
- }
20
- interface WebSocketMessage {
21
- type: string;
22
- resource?: string;
23
- channel?: string;
24
- data?: unknown;
25
- }
26
- interface WebSocketPluginOptions {
27
- /** WebSocket endpoint path (default: '/ws') */
28
- path?: string;
29
- /** Require authentication for WebSocket connections (default: true) */
30
- auth?: boolean;
31
- /** Resources to auto-broadcast CRUD events for */
32
- resources?: string[];
33
- /** Heartbeat interval in ms (default: 30000). Set 0 to disable. */
34
- heartbeatInterval?: number;
35
- /** Custom authentication function for WebSocket upgrade */
36
- authenticate?: (request: unknown) => Promise<{
37
- userId?: string;
38
- organizationId?: string; /** Set for machine-to-machine / service account auth */
39
- clientId?: string; /** OAuth scopes for service accounts */
40
- scopes?: readonly string[];
41
- } | null>;
42
- /** Max clients per resource subscription (default: 10000) */
43
- maxClientsPerRoom?: number;
44
- /**
45
- * Expose a stats endpoint at `{path}/stats`.
46
- * - `false` (default): stats endpoint is not registered
47
- * - `true`: registered without auth
48
- * - `'authenticated'`: guarded by `fastify.authenticate` if available
49
- */
50
- exposeStats?: boolean | "authenticated";
51
- /**
52
- * Authorize room subscriptions. Return true to allow, false to deny.
53
- * Called before every subscribe. If not provided, all rooms are allowed.
54
- */
55
- roomPolicy?: (client: WebSocketClient, room: string) => boolean | Promise<boolean>;
56
- /** Maximum message size in bytes from client (default: 16384 = 16KB). Messages exceeding this are dropped. */
57
- maxMessageBytes?: number;
58
- /** Maximum subscriptions per client (default: 100). Prevents resource exhaustion. */
59
- maxSubscriptionsPerClient?: number;
60
- /**
61
- * Periodic re-authentication interval in ms (default: 0 = disabled).
62
- * When set, the server periodically re-validates the client's auth token.
63
- * If the token is expired/revoked, the client is disconnected with code 4003.
64
- *
65
- * Recommended: 300000 (5 minutes) for production.
66
- *
67
- * @example
68
- * ```typescript
69
- * websocketPlugin({ reauthInterval: 5 * 60 * 1000 }) // re-check every 5 min
70
- * ```
71
- */
72
- reauthInterval?: number;
73
- /** Custom message handler */
74
- onMessage?: (client: WebSocketClient, message: WebSocketMessage) => void | Promise<void>;
75
- /** Called when a client connects */
76
- onConnect?: (client: WebSocketClient) => void | Promise<void>;
77
- /** Called when a client disconnects */
78
- onDisconnect?: (client: WebSocketClient) => void | Promise<void>;
79
- /**
80
- * Cross-instance broadcast adapter (default: LocalWebSocketAdapter — single-instance only).
81
- * Provide a RedisWebSocketAdapter for multi-instance deployments.
82
- *
83
- * @example
84
- * ```typescript
85
- * import { RedisWebSocketAdapter } from '@classytic/arc/integrations/websocket';
86
- * adapter: new RedisWebSocketAdapter(redis, { channel: 'arc-ws' })
87
- * ```
88
- */
89
- adapter?: WebSocketAdapter;
90
- }
91
- /**
92
- * Adapter interface for cross-instance WebSocket broadcast.
93
- *
94
- * - `publish()`: Send a message to all instances (via Redis, NATS, etc.)
95
- * - `subscribe()`: Receive messages from other instances
96
- * - `close()`: Clean up connections
97
- *
98
- * The adapter is NOT used for local broadcasts — RoomManager handles those.
99
- * The adapter only handles the cross-instance relay.
100
- */
101
- interface WebSocketAdapter {
102
- /** Adapter name for logging */
103
- readonly name: string;
104
- /** Publish a room broadcast to all other instances */
105
- publish(room: string, message: string): Promise<void>;
106
- /** Subscribe to broadcasts from other instances */
107
- subscribe(callback: (room: string, message: string) => void): Promise<void>;
108
- /** Close adapter connections */
109
- close(): Promise<void>;
110
- }
111
- /**
112
- * Default adapter — no cross-instance broadcast (single-instance only).
113
- * All methods are no-ops. Used when no adapter is configured.
114
- */
115
- declare class LocalWebSocketAdapter implements WebSocketAdapter {
116
- readonly name = "local";
117
- publish(): Promise<void>;
118
- subscribe(): Promise<void>;
119
- close(): Promise<void>;
120
- }
121
- declare class RoomManager {
122
- private rooms;
123
- private clients;
124
- private maxPerRoom;
125
- private adapter?;
126
- constructor(maxPerRoom?: number, adapter?: WebSocketAdapter);
127
- addClient(client: WebSocketClient): void;
128
- removeClient(clientId: string): void;
129
- subscribe(clientId: string, room: string): boolean;
130
- unsubscribe(clientId: string, room: string): void;
131
- broadcast(room: string, message: string, excludeClientId?: string): void;
132
- broadcastToOrg(organizationId: string, room: string, message: string): void;
133
- /**
134
- * Broadcast locally AND through adapter (for cross-instance delivery).
135
- * Use this instead of broadcast() when multi-instance is possible.
136
- */
137
- broadcastWithAdapter(room: string, message: string, excludeClientId?: string): Promise<void>;
138
- /**
139
- * Org-scoped broadcast locally AND through adapter.
140
- * Uses a namespaced room key for the adapter so other instances
141
- * can filter by org when delivering locally.
142
- */
143
- broadcastToOrgWithAdapter(organizationId: string, room: string, message: string): Promise<void>;
144
- getClient(clientId: string): WebSocketClient | undefined;
145
- getStats(): {
146
- clients: number;
147
- rooms: number;
148
- subscriptions: Record<string, number>;
149
- };
150
- }
151
- /** Pluggable WebSocket integration for Arc */
152
- declare const websocketPlugin: FastifyPluginAsync<WebSocketPluginOptions>;
153
- //#endregion
154
- export { LocalWebSocketAdapter, RoomManager, WebSocketAdapter, WebSocketClient, WebSocketMessage, WebSocketPluginOptions, websocketPlugin };
1
+ import { a as WebSocketMessage, c as WebSocketAdapter, i as WebSocketClient, n as websocketPlugin, o as WebSocketPluginOptions, r as AuthResult, s as LocalWebSocketAdapter, t as RoomManager } from "../websocket-CyJ1VIFI.mjs";
2
+ export { AuthResult, LocalWebSocketAdapter, RoomManager, WebSocketAdapter, WebSocketClient, WebSocketMessage, WebSocketPluginOptions, websocketPlugin };