@classytic/arc 2.11.3 → 2.13.1
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 +27 -18
- package/dist/{BaseController-swXruJ2_.mjs → BaseController-DX_T-bDB.mjs} +388 -423
- package/dist/EventTransport-CT_52aWU.d.mts +34 -0
- package/dist/EventTransport-DLWoUMHy.mjs +103 -0
- package/dist/{QueryCache-DOBNHBE0.d.mts → QueryCache-D41bfdBB.d.mts} +1 -1
- package/dist/{ResourceRegistry-DkAeAuTX.mjs → ResourceRegistry-CTERg_2x.mjs} +139 -66
- package/dist/audit/index.d.mts +2 -2
- package/dist/audit/index.mjs +1 -1
- package/dist/auth/audit.d.mts +199 -0
- package/dist/auth/audit.mjs +288 -0
- package/dist/auth/index.d.mts +5 -5
- package/dist/auth/index.mjs +117 -191
- package/dist/auth/redis-session.d.mts +1 -1
- package/dist/{betterAuthOpenApi-DwxtK3uG.mjs → betterAuthOpenApi--M_i87dQ.mjs} +1 -1
- package/dist/buildHandler-olo-gt94.mjs +610 -0
- package/dist/cache/index.d.mts +3 -3
- package/dist/cache/index.mjs +3 -3
- package/dist/cli/commands/describe.d.mts +89 -13
- package/dist/cli/commands/describe.mjs +56 -2
- package/dist/cli/commands/docs.mjs +2 -2
- package/dist/cli/commands/generate.mjs +147 -48
- package/dist/cli/commands/init.d.mts +13 -0
- package/dist/cli/commands/init.mjs +237 -112
- package/dist/cli/commands/introspect.mjs +8 -1
- package/dist/context/index.mjs +1 -1
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +5 -5
- package/dist/core-D72ia0EH.mjs +1399 -0
- package/dist/{createActionRouter-u3ql2EDo.mjs → createActionRouter-CEvzKcy8.mjs} +7 -20
- package/dist/createAggregationRouter-CyecOxnO.mjs +114 -0
- package/dist/{createApp-BFxtdKy6.mjs → createApp-XX2-N0Yd.mjs} +31 -27
- package/dist/defineEvent-D5h7EvAx.mjs +188 -0
- package/dist/docs/index.d.mts +2 -2
- package/dist/docs/index.mjs +2 -2
- package/dist/{elevation-DOFoxoDs.mjs → elevation-DgoeTyfX.mjs} +1 -1
- package/dist/errorHandler-Bk-AGhkU.mjs +174 -0
- package/dist/errorHandler-DFr45ZG4.d.mts +45 -0
- package/dist/errors-j4aJm1Wg.mjs +184 -0
- package/dist/{eventPlugin-KrFIQ097.mjs → eventPlugin-CaKTYkYM.mjs} +35 -137
- package/dist/{eventPlugin-CUNjYYRY.d.mts → eventPlugin-qXpqTebY.d.mts} +57 -7
- package/dist/events/index.d.mts +164 -5
- package/dist/events/index.mjs +133 -209
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +204 -31
- package/dist/events/transports/redis.d.mts +1 -1
- package/dist/factory/index.d.mts +2 -2
- package/dist/factory/index.mjs +2 -2
- package/dist/{fields-C8Y0XLAu.d.mts → fields-COhcH3fk.d.mts} +23 -2
- package/dist/hooks/index.d.mts +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/idempotency/index.d.mts +3 -3
- package/dist/idempotency/index.mjs +1 -20
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +1 -1
- package/dist/{index-BYCqHCVu.d.mts → index-BTqLEvhu.d.mts} +164 -4
- package/dist/{index-6u4_Gg6G.d.mts → index-BtW7qYwa.d.mts} +661 -281
- package/dist/{index-BdXnTPRj.d.mts → index-Ds61mrJE.d.mts} +50 -4
- package/dist/{index-DdQ3O9Pg.d.mts → index-Dz5IKsrE.d.mts} +360 -219
- package/dist/index.d.mts +6 -7
- package/dist/index.mjs +9 -10
- package/dist/integrations/event-gateway.d.mts +2 -2
- package/dist/integrations/event-gateway.mjs +1 -1
- package/dist/integrations/index.d.mts +2 -2
- package/dist/integrations/mcp/index.d.mts +2 -2
- package/dist/integrations/mcp/index.mjs +1 -1
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/integrations/streamline.d.mts +60 -11
- package/dist/integrations/streamline.mjs +75 -85
- package/dist/integrations/websocket-redis.d.mts +1 -1
- package/dist/integrations/websocket.d.mts +1 -1
- package/dist/integrations/websocket.mjs +2 -8
- package/dist/middleware/index.d.mts +1 -1
- package/dist/middleware/index.mjs +2 -2
- package/dist/migrations/index.d.mts +23 -3
- package/dist/migrations/index.mjs +0 -7
- package/dist/{multipartBody-CvTR1Un6.mjs → multipartBody-BOvVSVCD.mjs} +11 -8
- package/dist/{openapi-BGUn7Ki1.mjs → openapi-CiOMVW1p.mjs} +143 -13
- package/dist/org/index.d.mts +2 -2
- package/dist/org/index.mjs +1 -1
- package/dist/permissions/index.d.mts +3 -3
- package/dist/permissions/index.mjs +3 -3
- package/dist/{permissions-gd_aUWrR.mjs → permissions-ohQyv50e.mjs} +404 -176
- package/dist/{pipe-DVoIheVC.mjs → pipe-Zr0KXjQe.mjs} +1 -1
- package/dist/pipeline/index.d.mts +1 -1
- package/dist/pipeline/index.mjs +1 -1
- package/dist/plugins/index.d.mts +18 -33
- package/dist/plugins/index.mjs +33 -13
- package/dist/plugins/response-cache.mjs +1 -1
- package/dist/plugins/tracing-entry.d.mts +1 -1
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/presets/filesUpload.d.mts +5 -5
- package/dist/presets/filesUpload.mjs +6 -9
- package/dist/presets/index.d.mts +1 -1
- package/dist/presets/index.mjs +1 -1
- package/dist/presets/multiTenant.d.mts +1 -1
- package/dist/presets/multiTenant.mjs +2 -2
- package/dist/presets/search.d.mts +2 -2
- package/dist/presets/search.mjs +6 -8
- package/dist/{presets-Z7P5w4gF.mjs → presets-BbkjdPeH.mjs} +6 -28
- package/dist/{queryCachePlugin-BUXBSm4F.d.mts → queryCachePlugin-CqMdLI2-.d.mts} +2 -2
- package/dist/{queryCachePlugin-Bq6bO6vc.mjs → queryCachePlugin-m1XsgAIJ.mjs} +3 -3
- package/dist/{redis-Cm1gnRDf.d.mts → redis-DiMkdHEl.d.mts} +1 -1
- package/dist/redis-stream-D6HzR1Z_.d.mts +232 -0
- package/dist/registry/index.d.mts +1 -1
- package/dist/registry/index.mjs +2 -2
- package/dist/{replyHelpers-ByllIXXV.mjs → replyHelpers-CK-FNO8E.mjs} +3 -21
- package/dist/{resourceToTools-ByZpgjeH.mjs → resourceToTools-C5coh64w.mjs} +224 -71
- package/dist/{routerShared-BqLRb5l7.mjs → routerShared-D6_fEGHh.mjs} +40 -36
- package/dist/{schemaIR-BlG9bY7v.mjs → schemaIR-7Vl611Qs.mjs} +1 -1
- package/dist/schemas/index.d.mts +100 -30
- package/dist/schemas/index.mjs +86 -29
- package/dist/scim/index.d.mts +264 -0
- package/dist/scim/index.mjs +963 -0
- package/dist/scope/index.d.mts +3 -3
- package/dist/scope/index.mjs +4 -4
- package/dist/{sse-V7aXc3bW.mjs → sse-Bz-5ZeTt.mjs} +1 -1
- package/dist/{store-helpers-BhrzxvyQ.mjs → store-helpers-BkIN9-vu.mjs} +1 -1
- package/dist/testing/index.d.mts +2 -8
- package/dist/testing/index.mjs +16 -24
- package/dist/testing/storageContract.d.mts +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/types/storage.d.mts +1 -1
- package/dist/{types-BH7dEGvU.d.mts → types-BvqwCCSx.d.mts} +77 -29
- package/dist/{types-tgR4Pt8F.d.mts → types-CTYvcwHe.d.mts} +195 -1
- package/dist/{types-AOD8fxIw.mjs → types-C_s5moIu.mjs} +117 -1
- package/dist/{types-9beEMe25.d.mts → types-DQHFc8PM.d.mts} +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +5 -5
- package/dist/{utils-CcYTj09l.mjs → utils-_h9B3c57.mjs} +1269 -1334
- package/dist/{versioning-M9lNLhO8.d.mts → versioning-DTTvc80y.d.mts} +1 -1
- package/package.json +24 -34
- package/skills/arc/SKILL.md +521 -785
- package/skills/arc/references/agent-auth.md +238 -0
- package/skills/arc/references/api-reference.md +187 -0
- package/skills/arc/references/auth.md +354 -7
- package/skills/arc/references/enterprise-auth.md +94 -0
- package/skills/arc/references/events.md +8 -6
- package/skills/arc/references/mcp.md +2 -2
- package/skills/arc/references/multi-tenancy.md +11 -2
- package/skills/arc/references/production.md +10 -9
- package/skills/arc/references/scim.md +247 -0
- package/skills/arc/references/testing.md +1 -1
- package/skills/arc-code-review/SKILL.md +141 -0
- package/skills/arc-code-review/references/anti-patterns.md +911 -0
- package/skills/arc-code-review/references/arc-cheatsheet.md +380 -0
- package/skills/arc-code-review/references/migration-recipes.md +700 -0
- package/skills/arc-code-review/references/mongokit-migration.md +386 -0
- package/skills/arc-code-review/references/scaffolding.md +230 -0
- package/skills/arc-code-review/references/severity.md +127 -0
- package/dist/EventTransport-CfVEGaEl.d.mts +0 -293
- package/dist/adapters/index.d.mts +0 -3
- package/dist/adapters/index.mjs +0 -2
- package/dist/adapters-D0tT2Tyo.mjs +0 -949
- package/dist/auth/mongoose.d.mts +0 -191
- package/dist/auth/mongoose.mjs +0 -73
- package/dist/core-DnUsRpuX.mjs +0 -1049
- package/dist/errorHandler-BQm8ZxTK.mjs +0 -173
- package/dist/errorHandler-Co3lnVmJ.d.mts +0 -114
- package/dist/errors-D5c-5BJL.mjs +0 -232
- package/dist/index-BbMrcvGp.d.mts +0 -362
- package/dist/redis-stream-CM8TXTix.d.mts +0 -110
- /package/dist/{HookSystem-CGsMd6oK.mjs → HookSystem-Iiebom92.mjs} +0 -0
- /package/dist/{actionPermissions-sUUKDhtP.mjs → actionPermissions-CyUkQu6O.mjs} +0 -0
- /package/dist/{caching-CheW3m-S.mjs → caching-SM8gghN6.mjs} +0 -0
- /package/dist/{constants-BhY1OHoH.mjs → constants-Cxde4rpC.mjs} +0 -0
- /package/dist/{elevation-s5ykdNHr.d.mts → elevation-BXOWoGCF.d.mts} +0 -0
- /package/dist/{externalPaths-Bapitwvd.d.mts → externalPaths-BD5nw6St.d.mts} +0 -0
- /package/dist/{interface-CkkWm5uR.d.mts → interface-DfLGcus7.d.mts} +0 -0
- /package/dist/{interface-Da0r7Lna.d.mts → interface-beEtJyWM.d.mts} +0 -0
- /package/dist/{keys-CARyUjiR.mjs → keys-CGcCbNyu.mjs} +0 -0
- /package/dist/{loadResources-CPpkyKfM.mjs → loadResources-DBMQg_Aj.mjs} +0 -0
- /package/dist/{memory-DikHSvWa.mjs → memory-UBydS5ku.mjs} +0 -0
- /package/dist/{metrics-Csh4nsvv.mjs → metrics-Qnvwc-LQ.mjs} +0 -0
- /package/dist/{pluralize-BneOJkpi.mjs → pluralize-DQgqgifU.mjs} +0 -0
- /package/dist/{registry-D63ee7fl.mjs → registry-I-ogLgL9.mjs} +0 -0
- /package/dist/{requestContext-C5XeK3VA.mjs → requestContext-SSaaTgW8.mjs} +0 -0
- /package/dist/{schemaConverter-B0oKLuqI.mjs → schemaConverter-De34B1ZG.mjs} +0 -0
- /package/dist/{sessionManager-D-oNWHz3.d.mts → sessionManager-C4Le_UB3.d.mts} +0 -0
- /package/dist/{storage-BwGQXUpd.d.mts → storage-Dfzt4VTl.d.mts} +0 -0
- /package/dist/{tracing-DokiEsuz.d.mts → tracing-QJVprktp.d.mts} +0 -0
- /package/dist/{typeGuards-CcFZXgU7.mjs → typeGuards-BzkXkvVv.mjs} +0 -0
- /package/dist/{types-DV9WDfeg.mjs → types-D57iXYb8.mjs} +0 -0
- /package/dist/{versioning-CGPjkqAg.mjs → versioning-BUrT5aP4.mjs} +0 -0
- /package/dist/{websocket-CyJ1VIFI.d.mts → websocket-ChC2rqe1.d.mts} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { $t as
|
|
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-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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-DdQ3O9Pg.mjs";
|
|
1
|
+
import { $t as SoftDeleteMixin, A as RequestIdOptions, B as defineResource, C as RequestContext, Ct as AggregationConfig, D as HealthCheck, Dt as AggregationMaterializedResult, E as GracefulShutdownOptions, Et as AggregationMaterializedContext, F as FastifyWithDecorators, Gt as ApiResponse, J as CrudRouteKey, Kt as ArcRequest, L as RequestWithExtras, N as FastifyRequestExtras, O as HealthOptions, Ot as AggregationRateLimit, P as FastifyWithAuth, Q as MiddlewareConfig, Qt as SoftDeleteExt, S as QueryParserInterface, St as AggregationCacheConfig, T as CrudRouterOptions, Tt as AggregationIndexHint, V as ResourceDefinition, Wt as AnyRecord, X as EventDefinition, Xt as UserOrganization, Y as CrudSchemas, Z as FieldRule, Zt as BaseController, _t as IControllerResponse, a as InferAdapterDoc, an as BulkMixin, at as ResourceConfig, bt as AggMeasureInput, c as TypedController, d as PaginationResult, dn as ArcDeleteResult, en as TreeExt, et as PresetFunction, f as IntrospectionData, fn as ArcGetResult, ft as RouteSchemaOptions, g as ArcInternalMetadata, gt as IController, h as ResourceMetadata, hn as ListResult, i as ValidationResult, in as BulkExt, k as IntrospectionPluginOptions, kt as AggregationsMap, l as TypedRepository, m as RegistryStats, mn as ArcUpdateResult, mt as ControllerLike, n as ConfigError, nn as SlugExt, nt as PresetResult, o as InferDocType, on as BaseControllerOptions, p as RegistryEntry, pn as ArcListResult, q as CrudController, qt as JWTPayload, r as ValidateOptions, rn as SlugMixin, rt as RateLimitConfig, s as InferResourceDoc, sn as BaseCrudController, t as RouteHandlerMethod, tn as TreeMixin, u as TypedResourceConfig, un as ArcCreateResult, vt as IRequestContext, w as ServiceContext, wt as AggregationDateRangeRequirement, xt as AggMeasureShorthand, y as OwnershipCheck, yt as RouteHandler, zt as AuthPluginOptions } from "./index-BtW7qYwa.mjs";
|
|
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-COhcH3fk.mjs";
|
|
3
|
+
import { C as MAX_FILTER_DEPTH, D as MutationOperation, E as MUTATION_OPERATIONS, O as RESERVED_QUERY_PARAMS, S as HookPhase, T as MAX_SEARCH_LENGTH, _ as DEFAULT_TENANT_FIELD, a as getControllerScope, b as HOOK_PHASES, d as CRUD_OPERATIONS, f as CrudOperation, g as DEFAULT_SORT, h as DEFAULT_MAX_LIMIT, k as SYSTEM_FIELDS, m as DEFAULT_LIMIT, p as DEFAULT_ID_FIELD, s as defineResourceVariants, u as defineAggregation, v as DEFAULT_UPDATE_METHOD, w as MAX_REGEX_LENGTH, x as HookOperation, y as HOOK_OPERATIONS } from "./index-Ds61mrJE.mjs";
|
|
4
|
+
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-BTqLEvhu.mjs";
|
|
5
|
+
import { ct as NotFoundError, ht as createDomainError, it as ArcError, mt as ValidationError, pt as UnauthorizedError, st as ForbiddenError, t as getUserId } from "./index-Dz5IKsrE.mjs";
|
|
7
6
|
|
|
8
7
|
//#region src/index.d.ts
|
|
9
8
|
declare const version: string;
|
|
10
9
|
//#endregion
|
|
11
|
-
export { type
|
|
10
|
+
export { type AggMeasureInput, type AggMeasureShorthand, type AggregationCacheConfig, type AggregationConfig, type AggregationDateRangeRequirement, type AggregationIndexHint, type AggregationMaterializedContext, type AggregationMaterializedResult, type AggregationRateLimit, type AggregationsMap, 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 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 RouteHandler, type RouteHandlerMethod, type RouteSchemaOptions, SYSTEM_FIELDS, 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, defineAggregation, defineResource, defineResourceVariants, denyAll, 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,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-
|
|
5
|
-
import { C as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as ResourceDefinition, r as defineResource, t as defineResourceVariants } from "./core-DnUsRpuX.mjs";
|
|
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-Cxde4rpC.mjs";
|
|
2
|
+
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-j4aJm1Wg.mjs";
|
|
3
|
+
import { t as getUserId } from "./utils-_h9B3c57.mjs";
|
|
4
|
+
import { a as BulkMixin, i as SlugMixin, n as TreeMixin, o as BaseCrudController, r as SoftDeleteMixin, t as BaseController } from "./BaseController-DX_T-bDB.mjs";
|
|
5
|
+
import { C as allowPublic, D as requireAuth, O as requireOwnership, S as allOf, T as denyAll, _ as requireOrgMembership, a as presets_exports, b as requireServiceScope, c as readOnly, d as applyFieldWritePermissions, f as fields, g as requireOrgInScope, h as createOrgPermissions, i as ownerWithAdminBypass, j as when, k as requireRoles, m as createDynamicPermissionMatrix, n as authenticated, o as publicRead, r as fullPublic, s as publicReadAdminWrite, t as adminOnly, u as applyFieldReadPermissions, v as requireOrgRole, w as anyOf, x as requireTeamMembership, y as requireScopeContext } from "./permissions-ohQyv50e.mjs";
|
|
6
|
+
import { v as getControllerScope } from "./routerShared-D6_fEGHh.mjs";
|
|
7
|
+
import { n as defineResource, o as defineAggregation, r as ResourceDefinition, t as defineResourceVariants } from "./core-D72ia0EH.mjs";
|
|
9
8
|
//#region src/index.ts
|
|
10
|
-
const version = "2.
|
|
9
|
+
const version = "2.13.1";
|
|
11
10
|
//#endregion
|
|
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,
|
|
11
|
+
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, defineAggregation, defineResource, defineResourceVariants, denyAll, 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
|
-
import { n as DomainEvent } from "../EventTransport-
|
|
2
|
-
import { a as WebSocketMessage, i as WebSocketClient } from "../websocket-
|
|
1
|
+
import { n as DomainEvent } from "../EventTransport-CT_52aWU.mjs";
|
|
2
|
+
import { a as WebSocketMessage, i as WebSocketClient } from "../websocket-ChC2rqe1.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-
|
|
7
|
+
const { default: ssePlugin } = await import("../sse-Bz-5ZeTt.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 { a as WebSocketMessage, i as WebSocketClient, o as WebSocketPluginOptions } from "../websocket-
|
|
1
|
+
import { a as WebSocketMessage, i as WebSocketClient, o as WebSocketPluginOptions } from "../websocket-ChC2rqe1.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-
|
|
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-DQHFc8PM.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 {
|
|
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-
|
|
1
|
+
import { V as ResourceDefinition } from "../../index-BtW7qYwa.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-DQHFc8PM.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-
|
|
1
|
+
import { n as fieldRulesToZod, r as createMcpServer, t as resourceToTools } from "../../resourceToTools-C5coh64w.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 { r as createMcpServer, t as resourceToTools } from "../../resourceToTools-
|
|
1
|
+
import { r as createMcpServer, t as resourceToTools } from "../../resourceToTools-C5coh64w.mjs";
|
|
2
2
|
//#region src/integrations/mcp/testing.ts
|
|
3
3
|
/**
|
|
4
4
|
* @classytic/arc/mcp/testing — MCP Test Utilities
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { FastifyPluginAsync } from "fastify";
|
|
1
|
+
import { FastifyPluginAsync, FastifyRequest } from "fastify";
|
|
2
2
|
|
|
3
3
|
//#region src/integrations/streamline.d.ts
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Start options — matches @classytic/streamline v2.3+ `StartOptions`.
|
|
6
|
+
*
|
|
7
|
+
* v2.3 additions:
|
|
8
|
+
* - `tenantId` — required when streamline's `multiTenant.strict: true`.
|
|
9
|
+
* Hosts should NOT accept this from the request body in untrusted
|
|
10
|
+
* contexts; use `tenantResolver` to extract from auth context instead.
|
|
11
|
+
* - `bypassTenant` — admin/cross-tenant operations. Same caveat.
|
|
12
|
+
*/
|
|
5
13
|
interface WorkflowStartOptions {
|
|
6
14
|
meta?: Record<string, unknown>;
|
|
7
15
|
idempotencyKey?: string;
|
|
8
16
|
priority?: number;
|
|
17
|
+
tenantId?: string;
|
|
18
|
+
bypassTenant?: boolean;
|
|
9
19
|
}
|
|
10
20
|
/** Minimal workflow interface — matches @classytic/streamline's createWorkflow() return */
|
|
11
21
|
interface WorkflowLike {
|
|
@@ -32,11 +42,14 @@ interface WorkflowLike {
|
|
|
32
42
|
cancel(runId: string): Promise<WorkflowRunLike>;
|
|
33
43
|
get(runId: string): Promise<WorkflowRunLike | null>;
|
|
34
44
|
shutdown?(): void;
|
|
35
|
-
/** Streamline container for event bridging (streamline >=2.1) */
|
|
45
|
+
/** Streamline container for event bridging + repository access (streamline >=2.1) */
|
|
36
46
|
container?: {
|
|
37
47
|
eventBus: {
|
|
38
48
|
on(event: string, listener: (...args: unknown[]) => void): void;
|
|
39
49
|
off(event: string, listener: (...args: unknown[]) => void): void;
|
|
50
|
+
}; /** Repository — used by the list-runs endpoint to query workflow_runs. */
|
|
51
|
+
repository?: {
|
|
52
|
+
getAll(params: Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown>;
|
|
40
53
|
};
|
|
41
54
|
};
|
|
42
55
|
}
|
|
@@ -69,7 +82,7 @@ interface StreamlinePluginOptions {
|
|
|
69
82
|
* engine telemetry) to Arc's event bus, topic-scoped as
|
|
70
83
|
* `workflow.${workflowId}.${eventName}`.
|
|
71
84
|
*
|
|
72
|
-
* Covers the full streamline 2.
|
|
85
|
+
* Covers the full streamline 2.3 event surface:
|
|
73
86
|
* - Step events: started, completed, failed, waiting, skipped,
|
|
74
87
|
* retry-scheduled, compensated
|
|
75
88
|
* - Workflow lifecycle: started, completed, failed, waiting, resumed,
|
|
@@ -86,12 +99,6 @@ interface StreamlinePluginOptions {
|
|
|
86
99
|
* @default false
|
|
87
100
|
*/
|
|
88
101
|
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
|
-
*/
|
|
94
|
-
bridgeStepEvents?: boolean;
|
|
95
102
|
/**
|
|
96
103
|
* Enable SSE streaming endpoint: GET /:workflowId/runs/:runId/stream
|
|
97
104
|
* Streams step-level + lifecycle events as Server-Sent Events for live
|
|
@@ -100,6 +107,48 @@ interface StreamlinePluginOptions {
|
|
|
100
107
|
* @default false
|
|
101
108
|
*/
|
|
102
109
|
enableStreaming?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Enable webhook resume endpoint: POST /hooks/:token
|
|
112
|
+
*
|
|
113
|
+
* Routes incoming webhook calls through streamline's `resumeHook(token,
|
|
114
|
+
* body)` — which validates the token against the stored `hookToken` on
|
|
115
|
+
* the waiting step (fail-closed since streamline 2.3). Hosts use this
|
|
116
|
+
* for "wait for external approval / SaaS callback" patterns.
|
|
117
|
+
*
|
|
118
|
+
* Workflows MUST pass `{ hookToken: hook.token }` to `ctx.wait(...)` —
|
|
119
|
+
* streamline 2.3 rejects resume otherwise (security). The endpoint is
|
|
120
|
+
* registered at the plugin's `prefix` root, NOT scoped per workflow,
|
|
121
|
+
* because the token encodes the runId.
|
|
122
|
+
*
|
|
123
|
+
* Auth is OPTIONAL on this route by design — the token IS the
|
|
124
|
+
* authentication. If you also want to gate by user (e.g. only the
|
|
125
|
+
* inviting user can approve), set `auth: true` and a permission check.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
enableHookEndpoint?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Resolve the tenant id for a request — extract from auth context
|
|
132
|
+
* (JWT claim, session, header), NOT from the request body. Returning
|
|
133
|
+
* `undefined` skips tenant injection (use for non-multi-tenant routes
|
|
134
|
+
* or admin paths that pass `bypassTenant` explicitly).
|
|
135
|
+
*
|
|
136
|
+
* When set, the resolved tenantId is forwarded to every streamline
|
|
137
|
+
* call (`start`, `resume`, `cancel`, `get`, `list`, etc.) so
|
|
138
|
+
* streamline's `multiTenant.strict` mode never throws "missing
|
|
139
|
+
* tenantId" inside arc's request lifecycle.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* tenantResolver: (req) => req.user?.organizationId
|
|
143
|
+
*/
|
|
144
|
+
tenantResolver?: (request: FastifyRequest) => string | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Per-call bypass-tenant resolver. Returns `true` for requests that
|
|
147
|
+
* should skip tenant scoping entirely (cross-tenant admin operations).
|
|
148
|
+
* Honored only when streamline's tenant-filter plugin allows bypass
|
|
149
|
+
* (`allowBypass: true`, the default).
|
|
150
|
+
*/
|
|
151
|
+
bypassTenantResolver?: (request: FastifyRequest) => boolean;
|
|
103
152
|
/** Custom permission check for workflow operations */
|
|
104
153
|
permissions?: {
|
|
105
154
|
start?: (request: unknown) => boolean | Promise<boolean>;
|
|
@@ -111,7 +160,7 @@ interface StreamlinePluginOptions {
|
|
|
111
160
|
}
|
|
112
161
|
/**
|
|
113
162
|
* Full event list published on a streamline workflow's internal `eventBus`
|
|
114
|
-
* (tracks streamline 2.
|
|
163
|
+
* (tracks streamline 2.3's `EventPayloadMap` in
|
|
115
164
|
* `@classytic/streamline/src/core/events.ts`).
|
|
116
165
|
*
|
|
117
166
|
* Hardcoded here by design — arc subscribes via structural
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { f as createError, i as NotFoundError, r as ForbiddenError } from "../errors-j4aJm1Wg.mjs";
|
|
1
2
|
//#region src/integrations/streamline.ts
|
|
2
3
|
/**
|
|
3
4
|
* Full event list published on a streamline workflow's internal `eventBus`
|
|
4
|
-
* (tracks streamline 2.
|
|
5
|
+
* (tracks streamline 2.3's `EventPayloadMap` in
|
|
5
6
|
* `@classytic/streamline/src/core/events.ts`).
|
|
6
7
|
*
|
|
7
8
|
* Hardcoded here by design — arc subscribes via structural
|
|
@@ -42,8 +43,8 @@ const STREAMLINE_TERMINAL_EVENTS = [
|
|
|
42
43
|
"workflow:cancelled"
|
|
43
44
|
];
|
|
44
45
|
const streamlinePluginImpl = async (fastify, options) => {
|
|
45
|
-
const { workflows, prefix = "/workflows", auth = true, bridgeEvents = true, enableStreaming = false, permissions: perms } = options;
|
|
46
|
-
const bridgeBus = options.bridgeBusEvents ??
|
|
46
|
+
const { workflows, prefix = "/workflows", auth = true, bridgeEvents = true, enableStreaming = false, enableHookEndpoint = false, tenantResolver, bypassTenantResolver, permissions: perms } = options;
|
|
47
|
+
const bridgeBus = options.bridgeBusEvents ?? false;
|
|
47
48
|
const registry = /* @__PURE__ */ new Map();
|
|
48
49
|
for (const wf of workflows) {
|
|
49
50
|
const id = wf.definition.id;
|
|
@@ -53,6 +54,16 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
53
54
|
if (!fastify.hasDecorator("workflows")) fastify.decorate("workflows", registry);
|
|
54
55
|
if (!fastify.hasDecorator("getWorkflow")) fastify.decorate("getWorkflow", (id) => registry.get(id) ?? null);
|
|
55
56
|
const authPreHandler = auth && typeof fastify.authenticate === "function" ? [fastify.authenticate] : [];
|
|
57
|
+
const resolveTenantOpts = (request) => {
|
|
58
|
+
const opts = {};
|
|
59
|
+
if (bypassTenantResolver?.(request)) {
|
|
60
|
+
opts.bypassTenant = true;
|
|
61
|
+
return opts;
|
|
62
|
+
}
|
|
63
|
+
const tenantId = tenantResolver?.(request);
|
|
64
|
+
if (tenantId !== void 0) opts.tenantId = tenantId;
|
|
65
|
+
return opts;
|
|
66
|
+
};
|
|
56
67
|
const checkPerm = async (op, request) => {
|
|
57
68
|
const check = perms?.[op];
|
|
58
69
|
if (!check) return true;
|
|
@@ -61,15 +72,14 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
61
72
|
for (const [id, wf] of registry) {
|
|
62
73
|
const routePrefix = `${prefix}/${id}`;
|
|
63
74
|
fastify.post(`${routePrefix}/start`, { preHandler: authPreHandler }, async (request, reply) => {
|
|
64
|
-
if (!await checkPerm("start", request))
|
|
65
|
-
success: false,
|
|
66
|
-
error: "Forbidden"
|
|
67
|
-
});
|
|
75
|
+
if (!await checkPerm("start", request)) throw new ForbiddenError();
|
|
68
76
|
const { input, meta, idempotencyKey, priority } = request.body ?? {};
|
|
77
|
+
const tenantOpts = resolveTenantOpts(request);
|
|
69
78
|
const run = await wf.start(input, {
|
|
70
79
|
meta,
|
|
71
80
|
idempotencyKey,
|
|
72
|
-
priority
|
|
81
|
+
priority,
|
|
82
|
+
...tenantOpts
|
|
73
83
|
});
|
|
74
84
|
if (bridgeEvents && fastify.events?.publish) try {
|
|
75
85
|
await fastify.events.publish(`workflow.${id}.started`, {
|
|
@@ -83,32 +93,36 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
83
93
|
workflowId: id
|
|
84
94
|
}, "Failed to publish workflow.started event");
|
|
85
95
|
}
|
|
86
|
-
return reply.status(201).send(
|
|
87
|
-
success: true,
|
|
88
|
-
data: run
|
|
89
|
-
});
|
|
96
|
+
return reply.status(201).send(run);
|
|
90
97
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
const listRepo = wf.container?.repository;
|
|
99
|
+
if (listRepo?.getAll) fastify.get(`${routePrefix}/runs`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
100
|
+
if (!await checkPerm("list", request)) throw new ForbiddenError();
|
|
101
|
+
const tenantOpts = resolveTenantOpts(request);
|
|
102
|
+
const { page = "1", limit = "20", cursor, status } = request.query ?? {};
|
|
103
|
+
const filters = { workflowId: id };
|
|
104
|
+
if (status) filters.status = status;
|
|
105
|
+
return await listRepo.getAll({
|
|
106
|
+
filters,
|
|
107
|
+
sort: { createdAt: -1 },
|
|
108
|
+
page: Number.parseInt(page, 10) || 1,
|
|
109
|
+
limit: Math.min(Number.parseInt(limit, 10) || 20, 100),
|
|
110
|
+
...cursor ? { cursor } : {},
|
|
111
|
+
...tenantOpts.tenantId !== void 0 ? { tenantId: tenantOpts.tenantId } : {}
|
|
112
|
+
}, {
|
|
113
|
+
lean: true,
|
|
114
|
+
...tenantOpts.bypassTenant ? { bypassTenant: true } : {}
|
|
95
115
|
});
|
|
116
|
+
});
|
|
117
|
+
fastify.get(`${routePrefix}/runs/:runId`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
118
|
+
if (!await checkPerm("get", request)) throw new ForbiddenError();
|
|
96
119
|
const { runId } = request.params;
|
|
97
120
|
const run = await wf.get(runId);
|
|
98
|
-
if (!run)
|
|
99
|
-
|
|
100
|
-
error: "Workflow run not found"
|
|
101
|
-
});
|
|
102
|
-
return {
|
|
103
|
-
success: true,
|
|
104
|
-
data: run
|
|
105
|
-
};
|
|
121
|
+
if (!run) throw new NotFoundError("Workflow run", runId);
|
|
122
|
+
return run;
|
|
106
123
|
});
|
|
107
|
-
fastify.post(`${routePrefix}/runs/:runId/resume`, { preHandler: authPreHandler }, async (request,
|
|
108
|
-
if (!await checkPerm("resume", request))
|
|
109
|
-
success: false,
|
|
110
|
-
error: "Forbidden"
|
|
111
|
-
});
|
|
124
|
+
fastify.post(`${routePrefix}/runs/:runId/resume`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
125
|
+
if (!await checkPerm("resume", request)) throw new ForbiddenError();
|
|
112
126
|
const { runId } = request.params;
|
|
113
127
|
const { payload } = request.body ?? {};
|
|
114
128
|
const run = await wf.resume(runId, payload);
|
|
@@ -124,16 +138,10 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
124
138
|
workflowId: id
|
|
125
139
|
}, "Failed to publish workflow.resumed event");
|
|
126
140
|
}
|
|
127
|
-
return
|
|
128
|
-
success: true,
|
|
129
|
-
data: run
|
|
130
|
-
};
|
|
141
|
+
return run;
|
|
131
142
|
});
|
|
132
|
-
fastify.post(`${routePrefix}/runs/:runId/cancel`, { preHandler: authPreHandler }, async (request,
|
|
133
|
-
if (!await checkPerm("cancel", request))
|
|
134
|
-
success: false,
|
|
135
|
-
error: "Forbidden"
|
|
136
|
-
});
|
|
143
|
+
fastify.post(`${routePrefix}/runs/:runId/cancel`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
144
|
+
if (!await checkPerm("cancel", request)) throw new ForbiddenError();
|
|
137
145
|
const { runId } = request.params;
|
|
138
146
|
const run = await wf.cancel(runId);
|
|
139
147
|
if (bridgeEvents && fastify.events?.publish) try {
|
|
@@ -147,49 +155,28 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
147
155
|
workflowId: id
|
|
148
156
|
}, "Failed to publish workflow.cancelled event");
|
|
149
157
|
}
|
|
150
|
-
return
|
|
151
|
-
success: true,
|
|
152
|
-
data: run
|
|
153
|
-
};
|
|
158
|
+
return run;
|
|
154
159
|
});
|
|
155
160
|
fastify.post(`${routePrefix}/runs/:runId/execute`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
156
161
|
const { runId } = request.params;
|
|
157
|
-
return
|
|
158
|
-
success: true,
|
|
159
|
-
data: await wf.engine.execute(runId)
|
|
160
|
-
};
|
|
162
|
+
return await wf.engine.execute(runId);
|
|
161
163
|
});
|
|
162
|
-
if (wf.engine.waitFor) fastify.get(`${routePrefix}/runs/:runId/wait`, { preHandler: authPreHandler }, async (request,
|
|
163
|
-
if (!await checkPerm("get", request))
|
|
164
|
-
success: false,
|
|
165
|
-
error: "Forbidden"
|
|
166
|
-
});
|
|
164
|
+
if (wf.engine.waitFor) fastify.get(`${routePrefix}/runs/:runId/wait`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
165
|
+
if (!await checkPerm("get", request)) throw new ForbiddenError();
|
|
167
166
|
const { runId } = request.params;
|
|
168
167
|
const { timeout } = request.query ?? {};
|
|
169
168
|
const timeoutMs = timeout ? Number.parseInt(timeout, 10) : 3e4;
|
|
170
|
-
return {
|
|
171
|
-
success: true,
|
|
172
|
-
data: await wf.engine.waitFor(runId, { timeout: Math.min(timeoutMs, 12e4) })
|
|
173
|
-
};
|
|
169
|
+
return await wf.engine.waitFor?.(runId, { timeout: Math.min(timeoutMs, 12e4) });
|
|
174
170
|
});
|
|
175
171
|
if (wf.engine.pause) fastify.post(`${routePrefix}/runs/:runId/pause`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
176
172
|
const { runId } = request.params;
|
|
177
|
-
return
|
|
178
|
-
success: true,
|
|
179
|
-
data: await wf.engine.pause?.(runId)
|
|
180
|
-
};
|
|
173
|
+
return await wf.engine.pause?.(runId);
|
|
181
174
|
});
|
|
182
|
-
if (wf.engine.rewindTo) fastify.post(`${routePrefix}/runs/:runId/rewind`, { preHandler: authPreHandler }, async (request,
|
|
175
|
+
if (wf.engine.rewindTo) fastify.post(`${routePrefix}/runs/:runId/rewind`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
183
176
|
const { runId } = request.params;
|
|
184
177
|
const { stepId } = request.body ?? {};
|
|
185
|
-
if (!stepId)
|
|
186
|
-
|
|
187
|
-
error: "stepId is required"
|
|
188
|
-
});
|
|
189
|
-
return {
|
|
190
|
-
success: true,
|
|
191
|
-
data: await wf.engine.rewindTo?.(runId, stepId)
|
|
192
|
-
};
|
|
178
|
+
if (!stepId) throw createError(400, "stepId is required");
|
|
179
|
+
return await wf.engine.rewindTo?.(runId, stepId);
|
|
193
180
|
});
|
|
194
181
|
if (bridgeBus && wf.container?.eventBus && fastify.events?.publish) for (const eventName of STREAMLINE_BUS_EVENTS) wf.container.eventBus.on(eventName, (payload) => {
|
|
195
182
|
const p = payload;
|
|
@@ -206,15 +193,9 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
206
193
|
});
|
|
207
194
|
});
|
|
208
195
|
if (enableStreaming && wf.container?.eventBus) fastify.get(`${routePrefix}/runs/:runId/stream`, { preHandler: authPreHandler }, async (request, reply) => {
|
|
209
|
-
if (!await checkPerm("get", request))
|
|
210
|
-
success: false,
|
|
211
|
-
error: "Forbidden"
|
|
212
|
-
});
|
|
196
|
+
if (!await checkPerm("get", request)) throw new ForbiddenError();
|
|
213
197
|
const { runId } = request.params;
|
|
214
|
-
if (!await wf.get(runId))
|
|
215
|
-
success: false,
|
|
216
|
-
error: "Workflow run not found"
|
|
217
|
-
});
|
|
198
|
+
if (!await wf.get(runId)) throw new NotFoundError("Workflow run", runId);
|
|
218
199
|
reply.raw.writeHead(200, {
|
|
219
200
|
"Content-Type": "text/event-stream",
|
|
220
201
|
"Cache-Control": "no-cache",
|
|
@@ -247,7 +228,7 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
247
228
|
send(eventName, p);
|
|
248
229
|
if (terminalEvents.has(eventName) && p?.runId === runId) cleanup();
|
|
249
230
|
};
|
|
250
|
-
wf.container
|
|
231
|
+
wf.container?.eventBus.on(eventName, fn);
|
|
251
232
|
listeners.push({
|
|
252
233
|
event: eventName,
|
|
253
234
|
fn
|
|
@@ -256,15 +237,24 @@ const streamlinePluginImpl = async (fastify, options) => {
|
|
|
256
237
|
request.raw.on("close", cleanup);
|
|
257
238
|
});
|
|
258
239
|
}
|
|
240
|
+
if (enableHookEndpoint) {
|
|
241
|
+
let resumeHookFn;
|
|
242
|
+
fastify.post(`${prefix}/hooks/:token`, { preHandler: authPreHandler }, async (request, _reply) => {
|
|
243
|
+
if (!resumeHookFn) resumeHookFn = (await import("@classytic/streamline")).resumeHook;
|
|
244
|
+
const { token } = request.params;
|
|
245
|
+
const result = await resumeHookFn(token, request.body);
|
|
246
|
+
return {
|
|
247
|
+
runId: result.runId,
|
|
248
|
+
run: result.run
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
}
|
|
259
252
|
fastify.get(prefix, { preHandler: authPreHandler }, async () => {
|
|
260
|
-
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
steps: Array.isArray(wf.definition.steps) ? wf.definition.steps.map((s) => s.id ?? String(s)) : Object.keys(wf.definition.steps)
|
|
266
|
-
}))
|
|
267
|
-
};
|
|
253
|
+
return Array.from(registry.entries()).map(([id, wf]) => ({
|
|
254
|
+
id,
|
|
255
|
+
name: wf.definition.name ?? id,
|
|
256
|
+
steps: Array.isArray(wf.definition.steps) ? wf.definition.steps.map((s) => s.id ?? String(s)) : Object.keys(wf.definition.steps)
|
|
257
|
+
}));
|
|
268
258
|
});
|
|
269
259
|
fastify.addHook("onClose", async () => {
|
|
270
260
|
for (const wf of registry.values()) wf.shutdown?.();
|
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-ChC2rqe1.mjs";
|
|
2
2
|
export { AuthResult, LocalWebSocketAdapter, RoomManager, WebSocketAdapter, WebSocketClient, WebSocketMessage, WebSocketPluginOptions, websocketPlugin };
|
|
@@ -259,18 +259,12 @@ async function wireResourceEvents(fastify, rooms, resources) {
|
|
|
259
259
|
*/
|
|
260
260
|
function registerStatsRoute(fastify, rooms, path, expose) {
|
|
261
261
|
if (expose === true) {
|
|
262
|
-
fastify.get(`${path}/stats`, async () => (
|
|
263
|
-
success: true,
|
|
264
|
-
data: rooms.getStats()
|
|
265
|
-
}));
|
|
262
|
+
fastify.get(`${path}/stats`, async () => rooms.getStats());
|
|
266
263
|
return;
|
|
267
264
|
}
|
|
268
265
|
if (expose === "authenticated") if (fastify.hasDecorator("authenticate")) {
|
|
269
266
|
const authenticate = fastify.authenticate;
|
|
270
|
-
fastify.get(`${path}/stats`, { preHandler: authenticate }, async () => (
|
|
271
|
-
success: true,
|
|
272
|
-
data: rooms.getStats()
|
|
273
|
-
}));
|
|
267
|
+
fastify.get(`${path}/stats`, { preHandler: authenticate }, async () => rooms.getStats());
|
|
274
268
|
} else fastify.log.warn("arc-websocket: exposeStats is \"authenticated\" but fastify.authenticate is not registered — stats endpoint skipped");
|
|
275
269
|
}
|
|
276
270
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-
|
|
1
|
+
import { I as MiddlewareHandler, L as RequestWithExtras, Q as MiddlewareConfig } from "../index-BtW7qYwa.mjs";
|
|
2
2
|
import { RouteHandlerMethod } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/middleware.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as CRUD_OPERATIONS } from "../constants-
|
|
2
|
-
import { t as multipartBody } from "../multipartBody-
|
|
1
|
+
import { t as CRUD_OPERATIONS } from "../constants-Cxde4rpC.mjs";
|
|
2
|
+
import { t as multipartBody } from "../multipartBody-BOvVSVCD.mjs";
|
|
3
3
|
//#region src/middleware/middleware.ts
|
|
4
4
|
/**
|
|
5
5
|
* Named Middleware — Priority-based, conditional middleware execution.
|
|
@@ -94,12 +94,32 @@ interface MigrationLogger {
|
|
|
94
94
|
* The `db` parameter accepts any object with a `.collection()` method
|
|
95
95
|
* (Mongoose db, native MongoDB Db, etc.)
|
|
96
96
|
*/
|
|
97
|
+
/**
|
|
98
|
+
* Structural subset of a Mongo collection arc consumes. Held as a
|
|
99
|
+
* driver-free interface so this file never imports `mongodb` /
|
|
100
|
+
* `mongoose` — both Mongoose's `Connection.db.collection(...)` and the
|
|
101
|
+
* native `MongoClient.db().collection(...)` satisfy this shape.
|
|
102
|
+
*
|
|
103
|
+
* The fluent `find().sort().toArray()` chain is typed loosely with
|
|
104
|
+
* `unknown[]`; we cast to `MigrationRecord[]` once at the boundary
|
|
105
|
+
* inside `getApplied()`.
|
|
106
|
+
*/
|
|
107
|
+
interface MongoCollectionLike {
|
|
108
|
+
find(query: Record<string, unknown>): {
|
|
109
|
+
sort(spec: Record<string, 1 | -1>): {
|
|
110
|
+
toArray(): Promise<unknown[]>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
insertOne(doc: Record<string, unknown>): Promise<unknown>;
|
|
114
|
+
deleteOne(filter: Record<string, unknown>): Promise<unknown>;
|
|
115
|
+
}
|
|
116
|
+
interface MongoDbLike {
|
|
117
|
+
collection(name: string): MongoCollectionLike;
|
|
118
|
+
}
|
|
97
119
|
declare class MongoMigrationStore implements MigrationStore {
|
|
98
120
|
private readonly collectionName;
|
|
99
121
|
private readonly db;
|
|
100
|
-
constructor(db: {
|
|
101
|
-
collection(name: string): any;
|
|
102
|
-
}, opts?: {
|
|
122
|
+
constructor(db: MongoDbLike, opts?: {
|
|
103
123
|
collectionName?: string;
|
|
104
124
|
});
|
|
105
125
|
getApplied(): Promise<MigrationRecord[]>;
|
|
@@ -4,13 +4,6 @@ const defaultLogger = {
|
|
|
4
4
|
info: (msg) => process.stdout.write(`${msg}\n`),
|
|
5
5
|
error: (msg) => process.stderr.write(`${msg}\n`)
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* MongoDB-backed migration store.
|
|
9
|
-
*
|
|
10
|
-
* Uses a `_migrations` collection in the same database.
|
|
11
|
-
* The `db` parameter accepts any object with a `.collection()` method
|
|
12
|
-
* (Mongoose db, native MongoDB Db, etc.)
|
|
13
|
-
*/
|
|
14
7
|
var MongoMigrationStore = class {
|
|
15
8
|
collectionName;
|
|
16
9
|
db;
|