@classytic/arc 2.8.1 → 2.8.4
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 +22 -1
- package/dist/{ResourceRegistry-Dtcojmu8.mjs → ResourceRegistry-Dq3_zBQP.mjs} +5 -5
- package/dist/adapters/index.d.mts +2 -2
- package/dist/audit/index.d.mts +1 -1
- package/dist/audit/index.mjs +1 -1
- package/dist/audit/mongodb.d.mts +1 -1
- package/dist/audit/mongodb.mjs +1 -1
- package/dist/auth/index.d.mts +4 -4
- package/dist/auth/redis-session.d.mts +1 -1
- package/dist/cache/index.d.mts +2 -2
- package/dist/cli/commands/describe.mjs +1 -1
- package/dist/cli/commands/docs.mjs +2 -2
- package/dist/cli/commands/generate.mjs +1 -1
- package/dist/cli/commands/init.mjs +10 -10
- package/dist/cli/commands/introspect.mjs +3 -3
- package/dist/core/index.d.mts +3 -3
- package/dist/core/index.mjs +4 -4
- package/dist/{core-CrLDuqoT.mjs → core-DKSwNSXf.mjs} +1 -1
- package/dist/{createApp-p2OThysU.mjs → createApp-BOYjBgdI.mjs} +16 -7
- package/dist/{defineResource-CqeUltrW.mjs → defineResource-Bb_Bdhtw.mjs} +42 -27
- package/dist/docs/index.d.mts +2 -2
- package/dist/docs/index.mjs +1 -1
- package/dist/dynamic/index.d.mts +2 -2
- package/dist/dynamic/index.mjs +1 -1
- package/dist/{errorHandler-DJ7OAB2V.d.mts → errorHandler-CdZDavNH.d.mts} +2 -2
- package/dist/{eventPlugin-Cdjwo0Gv.d.mts → eventPlugin-CVxlE6De.d.mts} +1 -1
- package/dist/events/index.d.mts +3 -3
- package/dist/events/index.mjs +1 -1
- package/dist/events/transports/redis-stream-entry.d.mts +1 -1
- package/dist/events/transports/redis-stream-entry.mjs +3 -1
- package/dist/events/transports/redis.d.mts +1 -1
- package/dist/factory/index.d.mts +1 -1
- package/dist/factory/index.mjs +2 -152
- package/dist/hooks/index.d.mts +1 -1
- package/dist/idempotency/index.d.mts +3 -3
- package/dist/idempotency/mongodb.d.mts +1 -1
- package/dist/idempotency/mongodb.mjs +18 -6
- package/dist/idempotency/redis.d.mts +1 -1
- package/dist/idempotency/redis.mjs +10 -1
- package/dist/{index-0zj73o2U.d.mts → index-BgmMdpm8.d.mts} +1 -1
- package/dist/{index-CBru2y5Y.d.mts → index-CSkeivBx.d.mts} +3 -3
- package/dist/{index-DadoLP51.d.mts → index-CpTSDqmD.d.mts} +26 -4
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +3 -3
- package/dist/integrations/event-gateway.d.mts +1 -1
- package/dist/integrations/event-gateway.mjs +1 -1
- package/dist/integrations/index.d.mts +1 -1
- package/dist/integrations/mcp/index.d.mts +51 -3
- package/dist/integrations/mcp/index.mjs +78 -19
- package/dist/integrations/mcp/testing.d.mts +1 -1
- package/dist/integrations/mcp/testing.mjs +1 -1
- package/dist/{interface-CS6d7HiB.d.mts → interface-BVuMfeVv.d.mts} +47 -18
- package/dist/loadResources-Bksk8ydA.mjs +154 -0
- package/dist/{mongodb-B1eVtFhw.d.mts → mongodb-B8U2xaLj.d.mts} +1 -1
- package/dist/{mongodb-NShVZDMr.d.mts → mongodb-X7LbEjTN.d.mts} +10 -1
- package/dist/{openapi-q6rNKfZy.mjs → openapi-CYCuekCn.mjs} +2 -2
- package/dist/org/index.d.mts +2 -2
- package/dist/permissions/index.d.mts +3 -3
- package/dist/plugins/index.d.mts +5 -5
- package/dist/plugins/index.mjs +7 -7
- package/dist/plugins/tracing-entry.d.mts +1 -1
- package/dist/plugins/tracing-entry.mjs +1 -1
- package/dist/policies/index.d.mts +1 -1
- 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-BFrGvvjL.mjs → presets-C2xgzW6x.mjs} +10 -18
- package/dist/{queryCachePlugin-BCFVXnxK.d.mts → queryCachePlugin-CnTZZTC5.d.mts} +1 -1
- package/dist/{redis-stream-BgrYzpeq.d.mts → redis-stream-D54N5oXs.d.mts} +1 -1
- package/dist/{redis-Bunu3qWg.d.mts → redis-z3sFr1UP.d.mts} +1 -1
- package/dist/registry/index.d.mts +1 -1
- package/dist/registry/index.mjs +1 -1
- package/dist/{resourceToTools-DNNWnZtx.mjs → resourceToTools-O_HwWXFa.mjs} +1 -1
- package/dist/rpc/index.d.mts +1 -1
- package/dist/scope/index.d.mts +2 -2
- package/dist/testing/index.d.mts +2 -2
- package/dist/testing/index.mjs +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/{types-BlOuKTPw.d.mts → types-Bg2X42_m.d.mts} +30 -9
- package/dist/{types-BoaZHr-2.d.mts → types-CVC4HOKi.d.mts} +1 -1
- package/dist/{types-D3b7hA00.d.mts → types-CcG4avic.d.mts} +1 -1
- package/dist/utils/index.d.mts +43 -5
- package/dist/utils/index.mjs +3 -3
- package/dist/{utils-7sJ8X83I.mjs → utils-yYT3HDXt.mjs} +65 -1
- package/package.json +8 -8
- package/skills/arc/SKILL.md +101 -6
- package/skills/arc/references/mcp.md +37 -0
- /package/dist/{EventTransport-CLXJUzyT.d.mts → EventTransport-CinyO7zQ.d.mts} +0 -0
- /package/dist/{caching-CHH-iHs3.mjs → caching-CjybdRwx.mjs} +0 -0
- /package/dist/{circuitBreaker-BGVoB1hD.d.mts → circuitBreaker-CvXkjfrW.d.mts} +0 -0
- /package/dist/{elevation-UJO3-NvX.d.mts → elevation-s5ykdNHr.d.mts} +0 -0
- /package/dist/{errorHandler-Cw34h_om.mjs → errorHandler-mzqk4cGl.mjs} +0 -0
- /package/dist/{errors-BI8kEKsO.d.mts → errors-Bmn3eZT6.d.mts} +0 -0
- /package/dist/{eventPlugin-XijlQmlL.mjs → eventPlugin-D91S2YF4.mjs} +0 -0
- /package/dist/{externalPaths-BQ8QijNH.d.mts → externalPaths-Bapitwvd.d.mts} +0 -0
- /package/dist/{fields-DoeDgh2b.d.mts → fields-DC4So2M2.d.mts} +0 -0
- /package/dist/{interface-CkkWm5uR.d.mts → interface-B-pe8fhj.d.mts} +0 -0
- /package/dist/{interface-bpoLKKqx.d.mts → interface-DplgQO2e.d.mts} +0 -0
- /package/dist/{metrics-DuhiSEZI.mjs → metrics-TuOmguhi.mjs} +0 -0
- /package/dist/{mongodb-5Ff3w8jy.mjs → mongodb-B5O6xaW1.mjs} +0 -0
- /package/dist/{pluralize-BneOJkpi.mjs → pluralize-A0tWEl1K.mjs} +0 -0
- /package/dist/{replyHelpers-CXtJDAZ0.mjs → replyHelpers-BLojtuvR.mjs} +0 -0
- /package/dist/{sessionManager-BkzVU8h2.d.mts → sessionManager-D-oNWHz3.d.mts} +0 -0
- /package/dist/{sse-CD5Hghpu.mjs → sse-CJpt7LGI.mjs} +0 -0
- /package/dist/{tracing-xqXzWeaf.d.mts → tracing-DxjKk7eW.d.mts} +0 -0
- /package/dist/{types-CN6JvmYz.d.mts → types-C72d3NDn.d.mts} +0 -0
- /package/dist/{versioning-CPU_5Xfs.mjs → versioning-Cm8qoFDg.mjs} +0 -0
package/dist/docs/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { it as RegistryEntry } from "../interface-
|
|
2
|
-
import { t as ExternalOpenApiPaths } from "../externalPaths-
|
|
1
|
+
import { it as RegistryEntry } from "../interface-BVuMfeVv.mjs";
|
|
2
|
+
import { t as ExternalOpenApiPaths } from "../externalPaths-Bapitwvd.mjs";
|
|
3
3
|
import { FastifyPluginAsync } from "fastify";
|
|
4
4
|
|
|
5
5
|
//#region src/docs/openapi.d.ts
|
package/dist/docs/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as getUserRoles } from "../types-ZUu_h0jp.mjs";
|
|
2
|
-
import { n as openApiPlugin, r as openapi_default, t as buildOpenApiSpec } from "../openapi-
|
|
2
|
+
import { n as openApiPlugin, r as openapi_default, t as buildOpenApiSpec } from "../openapi-CYCuekCn.mjs";
|
|
3
3
|
import fp from "fastify-plugin";
|
|
4
4
|
//#region src/docs/scalar.ts
|
|
5
5
|
const scalarPlugin = async (fastify, opts = {}) => {
|
package/dist/dynamic/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { qt as ResourceDefinition, r as DataAdapter } from "../interface-
|
|
2
|
-
import { t as PermissionCheck } from "../types-
|
|
1
|
+
import { qt as ResourceDefinition, r as DataAdapter } from "../interface-BVuMfeVv.mjs";
|
|
2
|
+
import { t as PermissionCheck } from "../types-CVC4HOKi.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/dynamic/ArcDynamicLoader.d.ts
|
|
5
5
|
interface ArcArchitectureSchema {
|
package/dist/dynamic/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ArcQueryParser } from "../queryParser-CgCtsjti.mjs";
|
|
2
|
-
import { n as defineResource } from "../defineResource-
|
|
2
|
+
import { n as defineResource } from "../defineResource-Bb_Bdhtw.mjs";
|
|
3
3
|
import { C as publicRead, T as readOnly, b as fullPublic, v as adminOnly, w as publicReadAdminWrite, x as ownerWithAdminBypass, y as authenticated } from "../permissions-CH4cNwJi.mjs";
|
|
4
4
|
//#region src/dynamic/ArcDynamicLoader.ts
|
|
5
5
|
const VALID_FIELD_TYPES = new Set([
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DomainEvent } from "./EventTransport-
|
|
1
|
+
import { t as DomainEvent } from "./EventTransport-CinyO7zQ.mjs";
|
|
2
2
|
import { FastifyInstance, FastifyPluginAsync, FastifyRequest } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/caching.d.ts
|
|
@@ -180,4 +180,4 @@ interface ErrorHandlerOptions {
|
|
|
180
180
|
declare function errorHandlerPluginFn(fastify: FastifyInstance, options?: ErrorHandlerOptions): Promise<void>;
|
|
181
181
|
declare const errorHandlerPlugin: typeof errorHandlerPluginFn;
|
|
182
182
|
//#endregion
|
|
183
|
-
export {
|
|
183
|
+
export { _default$3 as _, _default as a, MetricsCollector as c, metricsPlugin as d, SSEOptions as f, CachingRule as g, CachingOptions as h, VersioningOptions as i, MetricsOptions as l, ssePlugin as m, ErrorMapper as n, versioningPlugin as o, _default$2 as p, errorHandlerPlugin as r, MetricEntry as s, ErrorHandlerOptions as t, _default$1 as u, cachingPlugin as v };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "./EventTransport-
|
|
1
|
+
import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "./EventTransport-CinyO7zQ.mjs";
|
|
2
2
|
import { FastifyPluginAsync } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region src/events/defineEvent.d.ts
|
package/dist/events/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as MemoryEventTransport, c as createEvent, i as EventTransport, n as EventHandler, o as MemoryEventTransportOptions, r as EventLogger, s as PublishManyResult, t as DomainEvent } from "../EventTransport-
|
|
2
|
-
import { a as withRetry, c as EventDefinitionOutput, d as EventSchema, f as ValidationResult, i as createDeadLetterPublisher, l as EventRegistry, m as defineEvent, n as eventPlugin, o as CustomValidator, p as createEventRegistry, r as RetryOptions, s as EventDefinitionInput, t as EventPluginOptions, u as EventRegistryOptions } from "../eventPlugin-
|
|
1
|
+
import { a as MemoryEventTransport, c as createEvent, i as EventTransport, n as EventHandler, o as MemoryEventTransportOptions, r as EventLogger, s as PublishManyResult, t as DomainEvent } from "../EventTransport-CinyO7zQ.mjs";
|
|
2
|
+
import { a as withRetry, c as EventDefinitionOutput, d as EventSchema, f as ValidationResult, i as createDeadLetterPublisher, l as EventRegistry, m as defineEvent, n as eventPlugin, o as CustomValidator, p as createEventRegistry, r as RetryOptions, s as EventDefinitionInput, t as EventPluginOptions, u as EventRegistryOptions } from "../eventPlugin-CVxlE6De.mjs";
|
|
3
3
|
import { RedisEventTransportOptions, RedisLike } from "./transports/redis.mjs";
|
|
4
|
-
import { r as RedisStreamTransportOptions, t as RedisStreamLike } from "../redis-stream-
|
|
4
|
+
import { r as RedisStreamTransportOptions, t as RedisStreamLike } from "../redis-stream-D54N5oXs.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/events/eventTypes.d.ts
|
|
7
7
|
/**
|
package/dist/events/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MemoryEventTransport, i as withRetry, o as createEvent, r as createDeadLetterPublisher, t as eventPlugin } from "../eventPlugin-
|
|
1
|
+
import { a as MemoryEventTransport, i as withRetry, o as createEvent, r as createDeadLetterPublisher, t as eventPlugin } from "../eventPlugin-D91S2YF4.mjs";
|
|
2
2
|
//#region src/events/defineEvent.ts
|
|
3
3
|
/**
|
|
4
4
|
* defineEvent — Typed Event Definitions with Optional Schema Validation
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-
|
|
1
|
+
import { n as RedisStreamTransport, r as RedisStreamTransportOptions, t as RedisStreamLike } from "../../redis-stream-D54N5oXs.mjs";
|
|
2
2
|
export { type RedisStreamLike, RedisStreamTransport, type RedisStreamTransportOptions };
|
|
@@ -118,7 +118,9 @@ var RedisStreamTransport = class {
|
|
|
118
118
|
const claimed = await this.redis.xclaim(this.stream, this.group, this.consumer, this.claimTimeoutMs, ...staleIds);
|
|
119
119
|
for (const [messageId, fields] of claimed) await this.processEntry(messageId, fields);
|
|
120
120
|
}
|
|
121
|
-
} catch {
|
|
121
|
+
} catch (err) {
|
|
122
|
+
this.logger.error("[RedisStreamTransport] claimPending error:", err);
|
|
123
|
+
}
|
|
122
124
|
}
|
|
123
125
|
async processEntry(messageId, fields) {
|
|
124
126
|
const fieldMap = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "../../EventTransport-
|
|
1
|
+
import { i as EventTransport, n as EventHandler, r as EventLogger, t as DomainEvent } from "../../EventTransport-CinyO7zQ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/events/transports/redis.d.ts
|
|
4
4
|
interface RedisLike {
|
package/dist/factory/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CustomPluginAuthOption, c as RawBodyOptions, d as ResourceLike, f as loadResources, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption, u as LoadResourcesOptions } from "../types-
|
|
1
|
+
import { a as CustomPluginAuthOption, c as RawBodyOptions, d as ResourceLike, f as loadResources, i as CustomAuthenticatorOption, l as UnderPressureOptions, n as BetterAuthOption, o as JwtAuthOption, r as CreateAppOptions, s as MultipartOptions, t as AuthOption, u as LoadResourcesOptions } from "../types-Bg2X42_m.mjs";
|
|
2
2
|
import { FastifyInstance } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region src/factory/createApp.d.ts
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { a as edgePreset, c as testingPreset, i as developmentPreset, n as createApp, o as getPreset, s as productionPreset, t as ArcFactory } from "../createApp-
|
|
2
|
-
import {
|
|
3
|
-
import { dirname, join, resolve } from "node:path";
|
|
4
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
1
|
+
import { a as edgePreset, c as testingPreset, i as developmentPreset, n as createApp, o as getPreset, s as productionPreset, t as ArcFactory } from "../createApp-BOYjBgdI.mjs";
|
|
2
|
+
import { t as loadResources } from "../loadResources-Bksk8ydA.mjs";
|
|
5
3
|
//#region src/factory/edge.ts
|
|
6
4
|
/**
|
|
7
5
|
* Convert a Fastify app into a Web Standards fetch handler.
|
|
@@ -48,152 +46,4 @@ function toFetchHandler(app, options = {}) {
|
|
|
48
46
|
};
|
|
49
47
|
}
|
|
50
48
|
//#endregion
|
|
51
|
-
//#region src/factory/loadResources.ts
|
|
52
|
-
/**
|
|
53
|
-
* loadResources — Auto-discover resource files from a directory.
|
|
54
|
-
*
|
|
55
|
-
* Scans for `*.resource.{ts,js,mts,mjs}` files, imports each,
|
|
56
|
-
* and collects their default exports. No barrel file needed.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* import { createApp, loadResources } from '@classytic/arc/factory';
|
|
61
|
-
*
|
|
62
|
-
* // Recommended: import.meta.url — works in both src/ (dev) and dist/ (prod)
|
|
63
|
-
* const app = await createApp({
|
|
64
|
-
* resources: await loadResources(import.meta.url),
|
|
65
|
-
* auth: { type: 'jwt', jwt: { secret: process.env.JWT_SECRET } },
|
|
66
|
-
* });
|
|
67
|
-
*
|
|
68
|
-
* // Or explicit path (must match runtime layout)
|
|
69
|
-
* const app2 = await createApp({
|
|
70
|
-
* resources: await loadResources('./src/resources'),
|
|
71
|
-
* });
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* File convention:
|
|
75
|
-
* ```
|
|
76
|
-
* src/resources/
|
|
77
|
-
* product/product.resource.ts → export default defineResource({ name: 'product', ... })
|
|
78
|
-
* order/order.resource.ts → export default defineResource({ name: 'order', ... })
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
/**
|
|
82
|
-
* Scan a directory for resource files and import their default exports.
|
|
83
|
-
*
|
|
84
|
-
* Accepts a directory path OR `import.meta.url` (file:// URL).
|
|
85
|
-
* When given a URL, resolves to the directory containing that file —
|
|
86
|
-
* so `loadResources(import.meta.url)` works in both dev (`src/`) and
|
|
87
|
-
* production (`dist/`) without path gymnastics.
|
|
88
|
-
*
|
|
89
|
-
* @param dir - Directory path, or `import.meta.url` (file:// URL resolved to its dirname)
|
|
90
|
-
* @param options - Pattern and recursion options
|
|
91
|
-
* @returns Array of resource definitions (anything with `.toPlugin()`)
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* // Works from both src/ and dist/ — resolves relative to the calling file
|
|
96
|
-
* await loadResources(import.meta.url);
|
|
97
|
-
*
|
|
98
|
-
* // Subdirectory relative to the calling file
|
|
99
|
-
* await loadResources(import.meta.url, { suffix: '.resource' });
|
|
100
|
-
*
|
|
101
|
-
* // Explicit path (must match runtime layout)
|
|
102
|
-
* await loadResources('./src/resources');
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
async function loadResources(dir, options = {}) {
|
|
106
|
-
const { suffix = ".resource", recursive = true, exclude, include, silent = false } = options;
|
|
107
|
-
const files = await collectFiles(resolve(dir.startsWith("file://") ? dirname(fileURLToPath(dir)) : dir), new RegExp(`${escapeRegex(suffix)}\\.(ts|js|mts|mjs)$`), recursive);
|
|
108
|
-
files.sort();
|
|
109
|
-
const includeSet = include ? new Set(include) : null;
|
|
110
|
-
const excludeSet = exclude ? new Set(exclude) : null;
|
|
111
|
-
const skipped = [];
|
|
112
|
-
const failed = [];
|
|
113
|
-
const isWindowsPath = (p) => /^[a-z]:[\\/]/i.test(p);
|
|
114
|
-
const results = await Promise.all(files.map(async (file) => {
|
|
115
|
-
let mod;
|
|
116
|
-
let primaryError;
|
|
117
|
-
try {
|
|
118
|
-
mod = await import(pathToFileURL(file).href);
|
|
119
|
-
return {
|
|
120
|
-
file,
|
|
121
|
-
mod
|
|
122
|
-
};
|
|
123
|
-
} catch (err) {
|
|
124
|
-
primaryError = err;
|
|
125
|
-
}
|
|
126
|
-
if (!isWindowsPath(file)) try {
|
|
127
|
-
mod = await import(file);
|
|
128
|
-
return {
|
|
129
|
-
file,
|
|
130
|
-
mod
|
|
131
|
-
};
|
|
132
|
-
} catch {}
|
|
133
|
-
const err = primaryError;
|
|
134
|
-
const code = err.code;
|
|
135
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
136
|
-
if (code === "ERR_MODULE_NOT_FOUND" && msg.includes(".js")) failed.push(`${file}: ${msg}\n Hint: This file uses .js extension imports (TypeScript ESM convention).
|
|
137
|
-
• Production: ensure your build compiles .ts→.js before loadResources() runs.
|
|
138
|
-
• Node.js: use tsx, ts-node/esm, or a build step.
|
|
139
|
-
• Vitest: nested .js→.ts resolution may fail through dynamic imports.
|
|
140
|
-
Workaround: use import.meta.glob to preload resources statically.
|
|
141
|
-
See: https://github.com/classytic/arc/blob/main/docs/production-ops/factory.mdx#vitest-limitation`);
|
|
142
|
-
else failed.push(`${file}: ${msg}`);
|
|
143
|
-
return null;
|
|
144
|
-
}));
|
|
145
|
-
const resources = [];
|
|
146
|
-
for (const result of results) {
|
|
147
|
-
if (!result) continue;
|
|
148
|
-
let resource = result.mod.default ?? result.mod.resource;
|
|
149
|
-
if (!resource || typeof resource.toPlugin !== "function") {
|
|
150
|
-
for (const value of Object.values(result.mod)) if (value && typeof value === "object" && typeof value.toPlugin === "function") {
|
|
151
|
-
resource = value;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (!resource || typeof resource.toPlugin !== "function") {
|
|
156
|
-
skipped.push(result.file);
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const name = resource.name;
|
|
160
|
-
if (name) {
|
|
161
|
-
if (includeSet && !includeSet.has(name)) continue;
|
|
162
|
-
if (!includeSet && excludeSet?.has(name)) continue;
|
|
163
|
-
}
|
|
164
|
-
resources.push(resource);
|
|
165
|
-
}
|
|
166
|
-
const log = silent ? void 0 : options?.logger;
|
|
167
|
-
if (log) {
|
|
168
|
-
if (failed.length) {
|
|
169
|
-
log.warn(`[arc] loadResources: ${failed.length} file(s) failed to import:`);
|
|
170
|
-
for (const f of failed) log.warn(` - ${f}`);
|
|
171
|
-
}
|
|
172
|
-
if (skipped.length) {
|
|
173
|
-
log.warn(`[arc] loadResources: ${skipped.length} file(s) skipped (no default export with toPlugin):`);
|
|
174
|
-
for (const f of skipped) log.warn(` - ${f}`);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return resources;
|
|
178
|
-
}
|
|
179
|
-
async function collectFiles(dir, pattern, recursive) {
|
|
180
|
-
const results = [];
|
|
181
|
-
let entries;
|
|
182
|
-
try {
|
|
183
|
-
entries = await readdir(dir, { withFileTypes: true });
|
|
184
|
-
} catch {
|
|
185
|
-
return results;
|
|
186
|
-
}
|
|
187
|
-
for (const entry of entries) {
|
|
188
|
-
const name = String(entry.name);
|
|
189
|
-
const fullPath = join(dir, name);
|
|
190
|
-
if (entry.isDirectory() && recursive) results.push(...await collectFiles(fullPath, pattern, recursive));
|
|
191
|
-
else if (entry.isFile() && pattern.test(name)) results.push(fullPath);
|
|
192
|
-
}
|
|
193
|
-
return results;
|
|
194
|
-
}
|
|
195
|
-
function escapeRegex(str) {
|
|
196
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
197
|
-
}
|
|
198
|
-
//#endregion
|
|
199
49
|
export { ArcFactory, createApp, developmentPreset, edgePreset, getPreset, loadResources, productionPreset, testingPreset, toFetchHandler };
|
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as beforeCreate, Cn as HookPhase, Dn as afterCreate, En as HookSystemOptions, Mn as beforeUpdate, Nn as createHookSystem, On as afterDelete, Pn as defineHook, Sn as HookOperation, Tn as HookSystem, bn as HookContext, jn as beforeDelete, kn as afterUpdate, wn as HookRegistration, xn as HookHandler, yn as DefineHookOptions } from "../interface-
|
|
1
|
+
import { An as beforeCreate, Cn as HookPhase, Dn as afterCreate, En as HookSystemOptions, Mn as beforeUpdate, Nn as createHookSystem, On as afterDelete, Pn as defineHook, Sn as HookOperation, Tn as HookSystem, bn as HookContext, jn as beforeDelete, kn as afterUpdate, wn as HookRegistration, xn as HookHandler, yn as DefineHookOptions } from "../interface-BVuMfeVv.mjs";
|
|
2
2
|
export { type DefineHookOptions, type HookContext, type HookHandler, type HookOperation, type HookPhase, type HookRegistration, HookSystem, type HookSystemOptions, afterCreate, afterDelete, afterUpdate, beforeCreate, beforeDelete, beforeUpdate, createHookSystem, defineHook };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-
|
|
2
|
-
import { n as MongoIdempotencyStoreOptions } from "../mongodb-
|
|
3
|
-
import { r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-
|
|
1
|
+
import { i as createIdempotencyResult, n as IdempotencyResult, r as IdempotencyStore, t as IdempotencyLock } from "../interface-B-pe8fhj.mjs";
|
|
2
|
+
import { n as MongoIdempotencyStoreOptions } from "../mongodb-X7LbEjTN.mjs";
|
|
3
|
+
import { r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-z3sFr1UP.mjs";
|
|
4
4
|
import { FastifyPluginAsync } from "fastify";
|
|
5
5
|
|
|
6
6
|
//#region src/idempotency/idempotencyPlugin.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-
|
|
1
|
+
import { n as MongoIdempotencyStoreOptions, t as MongoIdempotencyStore } from "../mongodb-X7LbEjTN.mjs";
|
|
2
2
|
export { MongoIdempotencyStore, type MongoIdempotencyStoreOptions };
|
|
@@ -5,11 +5,15 @@ var MongoIdempotencyStore = class {
|
|
|
5
5
|
collectionName;
|
|
6
6
|
ttlMs;
|
|
7
7
|
indexCreated = false;
|
|
8
|
+
shouldEnsureIndex;
|
|
9
|
+
logger;
|
|
8
10
|
constructor(options) {
|
|
9
11
|
this.connection = options.connection;
|
|
10
12
|
this.collectionName = options.collection ?? "arc_idempotency";
|
|
11
13
|
this.ttlMs = options.ttlMs ?? 864e5;
|
|
12
|
-
|
|
14
|
+
this.shouldEnsureIndex = options.createIndex !== false;
|
|
15
|
+
this.logger = options.logger ?? console;
|
|
16
|
+
if (this.shouldEnsureIndex) this.ensureIndex().catch(() => {});
|
|
13
17
|
}
|
|
14
18
|
get collection() {
|
|
15
19
|
return this.connection.db.collection(this.collectionName);
|
|
@@ -19,8 +23,13 @@ var MongoIdempotencyStore = class {
|
|
|
19
23
|
try {
|
|
20
24
|
await this.collection.createIndex({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
21
25
|
this.indexCreated = true;
|
|
22
|
-
} catch {
|
|
23
|
-
|
|
26
|
+
} catch (err) {
|
|
27
|
+
const code = err?.code;
|
|
28
|
+
if (code === 85 || code === 86) {
|
|
29
|
+
this.indexCreated = true;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.logger.warn(`[MongoIdempotencyStore] TTL index creation failed (will retry on next write): ${err.message ?? err}`);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
async get(key) {
|
|
@@ -37,6 +46,7 @@ var MongoIdempotencyStore = class {
|
|
|
37
46
|
};
|
|
38
47
|
}
|
|
39
48
|
async set(key, result) {
|
|
49
|
+
if (this.shouldEnsureIndex && !this.indexCreated) await this.ensureIndex().catch(() => {});
|
|
40
50
|
await this.collection.updateOne({ _id: key }, {
|
|
41
51
|
$set: {
|
|
42
52
|
result: {
|
|
@@ -51,6 +61,7 @@ var MongoIdempotencyStore = class {
|
|
|
51
61
|
}, { upsert: true });
|
|
52
62
|
}
|
|
53
63
|
async tryLock(key, requestId, ttlMs) {
|
|
64
|
+
if (this.shouldEnsureIndex && !this.indexCreated) await this.ensureIndex().catch(() => {});
|
|
54
65
|
const now = /* @__PURE__ */ new Date();
|
|
55
66
|
const expiresAt = new Date(now.getTime() + ttlMs);
|
|
56
67
|
try {
|
|
@@ -67,9 +78,10 @@ var MongoIdempotencyStore = class {
|
|
|
67
78
|
expiresAt: new Date(now.getTime() + this.ttlMs)
|
|
68
79
|
}
|
|
69
80
|
}, { upsert: true });
|
|
70
|
-
return result.matchedCount === 1 || result.
|
|
71
|
-
} catch {
|
|
72
|
-
return false;
|
|
81
|
+
return result.matchedCount === 1 || (result.upsertedCount ?? 0) === 1;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
if (err?.code === 11e3) return false;
|
|
84
|
+
throw err;
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
async unlock(key, requestId) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-
|
|
1
|
+
import { n as RedisIdempotencyStore, r as RedisIdempotencyStoreOptions, t as RedisClient } from "../redis-z3sFr1UP.mjs";
|
|
2
2
|
export { type RedisClient, RedisIdempotencyStore, type RedisIdempotencyStoreOptions };
|
|
@@ -51,7 +51,16 @@ var RedisIdempotencyStore = class {
|
|
|
51
51
|
}) === "OK";
|
|
52
52
|
}
|
|
53
53
|
async unlock(key, requestId) {
|
|
54
|
-
|
|
54
|
+
const luaScript = `
|
|
55
|
+
if redis.call("get", KEYS[1]) == ARGV[1] then
|
|
56
|
+
return redis.call("del", KEYS[1])
|
|
57
|
+
else
|
|
58
|
+
return 0
|
|
59
|
+
end
|
|
60
|
+
`;
|
|
61
|
+
const lockKey = this.lockKey(key);
|
|
62
|
+
if (typeof this.client.eval === "function") await this.client.eval(luaScript, 1, lockKey, requestId);
|
|
63
|
+
else if (await this.client.get(lockKey) === requestId) await this.client.del(lockKey);
|
|
55
64
|
}
|
|
56
65
|
async isLocked(key) {
|
|
57
66
|
return await this.client.exists(this.lockKey(key)) > 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Y as OpenApiSchemas, Z as ParsedQuery, Zt as CrudRepository, c as ValidationResult, n as AdapterSchemaContext, nt as QueryParserInterface, o as RepositoryLike, r as DataAdapter, s as SchemaMetadata, vt as RouteSchemaOptions } from "./interface-
|
|
1
|
+
import { Y as OpenApiSchemas, Z as ParsedQuery, Zt as CrudRepository, c as ValidationResult, n as AdapterSchemaContext, nt as QueryParserInterface, o as RepositoryLike, r as DataAdapter, s as SchemaMetadata, vt as RouteSchemaOptions } from "./interface-BVuMfeVv.mjs";
|
|
2
2
|
import { Model } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/mongoose.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as RequestScope } from "./types-
|
|
2
|
-
import { n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-
|
|
3
|
-
import { i as CacheStore, t as CacheLogger } from "./interface-
|
|
1
|
+
import { r as RequestScope } from "./types-C72d3NDn.mjs";
|
|
2
|
+
import { n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-CVC4HOKi.mjs";
|
|
3
|
+
import { i as CacheStore, t as CacheLogger } from "./interface-DplgQO2e.mjs";
|
|
4
4
|
import { FastifyRequest } from "fastify";
|
|
5
5
|
|
|
6
6
|
//#region src/permissions/applyPermissionResult.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as RequestScope } from "./types-
|
|
2
|
-
import { D as CrudRouterOptions, Ht as IControllerResponse, N as FastifyWithDecorators, T as CrudController, Ut as IRequestContext, Vt as IController, ct as RequestWithExtras, m as AnyRecord, ot as RequestContext, qt as ResourceDefinition, ut as ResourceConfig } from "./interface-
|
|
3
|
-
import { t as PermissionCheck } from "./types-
|
|
1
|
+
import { r as RequestScope } from "./types-C72d3NDn.mjs";
|
|
2
|
+
import { D as CrudRouterOptions, Ht as IControllerResponse, N as FastifyWithDecorators, T as CrudController, Ut as IRequestContext, Vt as IController, ct as RequestWithExtras, m as AnyRecord, ot as RequestContext, qt as ResourceDefinition, ut as ResourceConfig } from "./interface-BVuMfeVv.mjs";
|
|
3
|
+
import { t as PermissionCheck } from "./types-CVC4HOKi.mjs";
|
|
4
4
|
import { FastifyInstance, FastifyReply, FastifyRequest, RouteHandlerMethod } from "fastify";
|
|
5
5
|
|
|
6
6
|
//#region src/constants.d.ts
|
|
@@ -160,6 +160,28 @@ interface IdempotencyService {
|
|
|
160
160
|
* @param config - Action router configuration
|
|
161
161
|
*/
|
|
162
162
|
declare function createActionRouter(fastify: FastifyInstance, config: ActionRouterConfig): void;
|
|
163
|
+
/**
|
|
164
|
+
* Build a discriminated body schema for the unified action endpoint.
|
|
165
|
+
*
|
|
166
|
+
* Produces a schema of the form:
|
|
167
|
+
* ```json
|
|
168
|
+
* {
|
|
169
|
+
* "type": "object",
|
|
170
|
+
* "required": ["action"],
|
|
171
|
+
* "oneOf": [
|
|
172
|
+
* { "properties": { "action": { "const": "dispatch" }, "carrier": {...} }, "required": ["action", "carrier"] },
|
|
173
|
+
* { "properties": { "action": { "const": "approve" } }, "required": ["action"] }
|
|
174
|
+
* ]
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* AJV validates this natively, so an action call missing required fields is
|
|
179
|
+
* rejected with HTTP 400 before the handler ever runs.
|
|
180
|
+
*
|
|
181
|
+
* Exported so OpenAPI generation and MCP tool generation can reuse the same
|
|
182
|
+
* schema shape (single source of truth).
|
|
183
|
+
*/
|
|
184
|
+
declare function buildActionBodySchema(actionEnum: readonly string[], actionSchemas?: Record<string, Record<string, unknown>>): Record<string, unknown>;
|
|
163
185
|
//#endregion
|
|
164
186
|
//#region src/core/createCrudRouter.d.ts
|
|
165
187
|
/**
|
|
@@ -287,4 +309,4 @@ declare function createCrudHandlers<TDoc>(controller: IController<TDoc>): {
|
|
|
287
309
|
delete: (req: FastifyRequest, reply: FastifyReply) => Promise<void>;
|
|
288
310
|
};
|
|
289
311
|
//#endregion
|
|
290
|
-
export {
|
|
312
|
+
export { MUTATION_OPERATIONS as A, HOOK_OPERATIONS as C, MAX_FILTER_DEPTH as D, HookPhase as E, RESERVED_QUERY_PARAMS as M, SYSTEM_FIELDS as N, MAX_REGEX_LENGTH as O, DEFAULT_UPDATE_METHOD as S, HookOperation as T, DEFAULT_ID_FIELD as _, getControllerScope as a, DEFAULT_SORT as b, createCrudRouter as c, ActionRouterConfig as d, IdempotencyService as f, CrudOperation as g, CRUD_OPERATIONS as h, getControllerContext as i, MutationOperation as j, MAX_SEARCH_LENGTH as k, createPermissionMiddleware as l, createActionRouter as m, createFastifyHandler as n, sendControllerResponse as o, buildActionBodySchema as p, createRequestContext as r, defineResourceVariants as s, createCrudHandlers as t, ActionHandler as u, DEFAULT_LIMIT as v, HOOK_PHASES as w, DEFAULT_TENANT_FIELD as x, DEFAULT_MAX_LIMIT as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { $ as PresetFunction, $t as DeleteOptions, At as BaseController, B as InferResourceDoc, C as ConfigError, Ct as TypedResourceConfig, D as CrudRouterOptions, Dt as ValidationResult$1, E as CrudRouteKey, Et as ValidateOptions, F as GracefulShutdownOptions, H as IntrospectionPluginOptions, Ht as IControllerResponse, I as HealthCheck, Jt as defineResource, K as MiddlewareConfig, L as HealthOptions, M as FastifyWithAuth, N as FastifyWithDecorators, O as CrudSchemas, Ot as envelope, P as FieldRule, Qt as DeleteManyResult, R as InferAdapterDoc, St as TypedRepository, T as CrudController, Tt as UserOrganization, U as JWTPayload, Ut as IRequestContext, V as IntrospectionData, Vt as IController, Wt as RouteHandler, X as OwnershipCheck, Xt as BulkWriteResult, Yt as BulkWriteOperation, Zt as CrudRepository, _ as ArcInternalMetadata, _n as PipelineStep, a as RelationMetadata, an as PaginationParams, at as RegistryStats, b as AuthPluginOptions, c as ValidationResult, cn as RepositorySession, ct as RequestWithExtras, dn as Guard, en as DeleteResult, fn as Interceptor, gn as PipelineContext, gt as RouteHandlerMethod, h as ApiResponse, hn as PipelineConfig, i as FieldMetadata, in as PaginatedResult, it as RegistryEntry, j as FastifyRequestExtras, jt as BaseControllerOptions, k as EventDefinition, ln as UpdateManyResult, m as AnyRecord, mn as OperationFilter, nn as KeysetPaginatedResult, o as RepositoryLike, on as PaginationResult, ot as RequestContext, p as AdditionalRoute, pn as NextFunction, pt as ResourceMetadata, q as MiddlewareHandler, qt as ResourceDefinition, r as DataAdapter, rn as OffsetPaginatedResult, rt as RateLimitConfig, s as SchemaMetadata, sn as QueryOptions, st as RequestIdOptions, tt as PresetResult, un as WriteOptions, ut as ResourceConfig, v as ArcRequest, vn as Transform, vt as RouteSchemaOptions, xt as TypedController, yt as ServiceContext, z as InferDocType, zt as ControllerLike } from "./interface-
|
|
2
|
-
import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, t as FieldPermission } from "./fields-
|
|
3
|
-
import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-
|
|
4
|
-
import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-
|
|
5
|
-
import { A as
|
|
6
|
-
import { C as authenticated, D as publicRead, E as presets_d_exports, O as publicReadAdminWrite, S as adminOnly, T as ownerWithAdminBypass, _ as requireScopeContext, a as allOf, c as createDynamicPermissionMatrix, d as requireAuth, f as requireOrgInScope, g as requireRoles, h as requireOwnership, k as readOnly, l as createOrgPermissions, m as requireOrgRole, n as DynamicPermissionMatrix, o as allowPublic, p as requireOrgMembership, r as DynamicPermissionMatrixConfig, s as anyOf, u as denyAll, v as requireServiceScope, w as fullPublic, x as when, y as requireTeamMembership } from "./index-
|
|
7
|
-
import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-
|
|
1
|
+
import { $ as PresetFunction, $t as DeleteOptions, At as BaseController, B as InferResourceDoc, C as ConfigError, Ct as TypedResourceConfig, D as CrudRouterOptions, Dt as ValidationResult$1, E as CrudRouteKey, Et as ValidateOptions, F as GracefulShutdownOptions, H as IntrospectionPluginOptions, Ht as IControllerResponse, I as HealthCheck, Jt as defineResource, K as MiddlewareConfig, L as HealthOptions, M as FastifyWithAuth, N as FastifyWithDecorators, O as CrudSchemas, Ot as envelope, P as FieldRule, Qt as DeleteManyResult, R as InferAdapterDoc, St as TypedRepository, T as CrudController, Tt as UserOrganization, U as JWTPayload, Ut as IRequestContext, V as IntrospectionData, Vt as IController, Wt as RouteHandler, X as OwnershipCheck, Xt as BulkWriteResult, Yt as BulkWriteOperation, Zt as CrudRepository, _ as ArcInternalMetadata, _n as PipelineStep, a as RelationMetadata, an as PaginationParams, at as RegistryStats, b as AuthPluginOptions, c as ValidationResult, cn as RepositorySession, ct as RequestWithExtras, dn as Guard, en as DeleteResult, fn as Interceptor, gn as PipelineContext, gt as RouteHandlerMethod, h as ApiResponse, hn as PipelineConfig, i as FieldMetadata, in as PaginatedResult, it as RegistryEntry, j as FastifyRequestExtras, jt as BaseControllerOptions, k as EventDefinition, ln as UpdateManyResult, m as AnyRecord, mn as OperationFilter, nn as KeysetPaginatedResult, o as RepositoryLike, on as PaginationResult, ot as RequestContext, p as AdditionalRoute, pn as NextFunction, pt as ResourceMetadata, q as MiddlewareHandler, qt as ResourceDefinition, r as DataAdapter, rn as OffsetPaginatedResult, rt as RateLimitConfig, s as SchemaMetadata, sn as QueryOptions, st as RequestIdOptions, tt as PresetResult, un as WriteOptions, ut as ResourceConfig, v as ArcRequest, vn as Transform, vt as RouteSchemaOptions, xt as TypedController, yt as ServiceContext, z as InferDocType, zt as ControllerLike } from "./interface-BVuMfeVv.mjs";
|
|
2
|
+
import { a as applyFieldWritePermissions, i as applyFieldReadPermissions, n as FieldPermissionMap, o as fields, t as FieldPermission } from "./fields-DC4So2M2.mjs";
|
|
3
|
+
import { i as UserBase, n as PermissionContext, r as PermissionResult, t as PermissionCheck } from "./types-CVC4HOKi.mjs";
|
|
4
|
+
import { l as createMongooseAdapter, o as createPrismaAdapter, s as MongooseAdapter, t as PrismaAdapter } from "./index-BgmMdpm8.mjs";
|
|
5
|
+
import { A as MUTATION_OPERATIONS, C as HOOK_OPERATIONS, D as MAX_FILTER_DEPTH, E as HookPhase, M as RESERVED_QUERY_PARAMS, N as SYSTEM_FIELDS, O as MAX_REGEX_LENGTH, S as DEFAULT_UPDATE_METHOD, T as HookOperation, _ as DEFAULT_ID_FIELD, a as getControllerScope, b as DEFAULT_SORT, g as CrudOperation, h as CRUD_OPERATIONS, j as MutationOperation, k as MAX_SEARCH_LENGTH, s as defineResourceVariants, v as DEFAULT_LIMIT, w as HOOK_PHASES, x as DEFAULT_TENANT_FIELD, y as DEFAULT_MAX_LIMIT } from "./index-CpTSDqmD.mjs";
|
|
6
|
+
import { C as authenticated, D as publicRead, E as presets_d_exports, O as publicReadAdminWrite, S as adminOnly, T as ownerWithAdminBypass, _ as requireScopeContext, a as allOf, c as createDynamicPermissionMatrix, d as requireAuth, f as requireOrgInScope, g as requireRoles, h as requireOwnership, k as readOnly, l as createOrgPermissions, m as requireOrgRole, n as DynamicPermissionMatrix, o as allowPublic, p as requireOrgMembership, r as DynamicPermissionMatrixConfig, s as anyOf, u as denyAll, v as requireServiceScope, w as fullPublic, x as when, y as requireTeamMembership } from "./index-CSkeivBx.mjs";
|
|
7
|
+
import { a as NotFoundError, d as ValidationError, f as createDomainError, i as ForbiddenError, t as ArcError, u as UnauthorizedError } from "./errors-Bmn3eZT6.mjs";
|
|
8
8
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
import { RouteHandlerMethod as RouteHandlerMethod$1 } from "fastify";
|
|
10
10
|
|
package/dist/index.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { envelope } from "./types/index.mjs";
|
|
|
5
5
|
import { n as applyFieldWritePermissions, r as fields, t as applyFieldReadPermissions } from "./fields-ipsbIRPK.mjs";
|
|
6
6
|
import { t as requestContext } from "./requestContext-DYvHl113.mjs";
|
|
7
7
|
import { d as createDomainError, i as NotFoundError, l as UnauthorizedError, r as ForbiddenError, t as ArcError, u as ValidationError } from "./errors-BF2bIOIS.mjs";
|
|
8
|
-
import { a as validateResourceConfig, f as getControllerScope, i as formatValidationErrors, m as pipe, n as defineResource, r as assertValidConfig, t as ResourceDefinition } from "./defineResource-
|
|
8
|
+
import { a as validateResourceConfig, f as getControllerScope, i as formatValidationErrors, m as pipe, n as defineResource, r as assertValidConfig, t as ResourceDefinition } from "./defineResource-Bb_Bdhtw.mjs";
|
|
9
9
|
import { C as publicRead, S as presets_exports, T as readOnly, _ as when, a as createOrgPermissions, b as fullPublic, c as requireOrgInScope, d as requireOwnership, f as requireRoles, h as requireTeamMembership, i as createDynamicPermissionMatrix, l as requireOrgMembership, m as requireServiceScope, n as allowPublic, o as denyAll, p as requireScopeContext, r as anyOf, s as requireAuth, t as allOf, u as requireOrgRole, v as adminOnly, w as publicReadAdminWrite, x as ownerWithAdminBypass, y as authenticated } from "./permissions-CH4cNwJi.mjs";
|
|
10
|
-
import { t as defineResourceVariants } from "./core-
|
|
10
|
+
import { t as defineResourceVariants } from "./core-DKSwNSXf.mjs";
|
|
11
11
|
import { n as configureArcLogger, t as arcLog } from "./logger-CDjpjySd.mjs";
|
|
12
12
|
//#region src/middleware/middleware.ts
|
|
13
13
|
/**
|
|
@@ -128,6 +128,6 @@ function transform(name, handlerOrOptions) {
|
|
|
128
128
|
}
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/index.ts
|
|
131
|
-
const version = "2.8.
|
|
131
|
+
const version = "2.8.4";
|
|
132
132
|
//#endregion
|
|
133
133
|
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, arcLog, assertValidConfig, authenticated, configureArcLogger, createDomainError, createDynamicPermissionMatrix, createMongooseAdapter, createOrgPermissions, createPrismaAdapter, defineResource, defineResourceVariants, denyAll, envelope, fields, formatValidationErrors, fullPublic, getControllerScope, guard, intercept, middleware, ownerWithAdminBypass, presets_exports as permissions, pipe, publicRead, publicReadAdminWrite, readOnly, requestContext, requireAuth, requireOrgInScope, requireOrgMembership, requireOrgRole, requireOwnership, requireRoles, requireScopeContext, requireServiceScope, requireTeamMembership, sortMiddlewares, transform, validateResourceConfig, version, when };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as DomainEvent } from "../EventTransport-
|
|
1
|
+
import { t as DomainEvent } from "../EventTransport-CinyO7zQ.mjs";
|
|
2
2
|
import { WebSocketClient, WebSocketMessage } from "./websocket.mjs";
|
|
3
3
|
import { FastifyPluginAsync, FastifyRequest } from "fastify";
|
|
4
4
|
|
|
@@ -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-CJpt7LGI.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
1
|
import { WebSocketClient, WebSocketMessage, WebSocketPluginOptions } from "./websocket.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-CcG4avic.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,8 +1,56 @@
|
|
|
1
|
-
import { qt as ResourceDefinition } from "../../interface-
|
|
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 { qt as ResourceDefinition } from "../../interface-BVuMfeVv.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-CcG4avic.mjs";
|
|
3
3
|
import { FastifyPluginAsync } from "fastify";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
|
+
//#region src/integrations/mcp/aiSdkBridge.d.ts
|
|
7
|
+
/** Minimal AI SDK tool shape we need to invoke. */
|
|
8
|
+
interface AiSdkExecutable {
|
|
9
|
+
execute: (input: unknown, options?: unknown) => Promise<unknown>;
|
|
10
|
+
}
|
|
11
|
+
interface McpBridge {
|
|
12
|
+
/** MCP tool name. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** LLM-facing description. */
|
|
15
|
+
description: string;
|
|
16
|
+
/** Zod input schema — matches the AI SDK tool's inputSchema. */
|
|
17
|
+
inputSchema: Record<string, z.ZodType>;
|
|
18
|
+
/** MCP annotations — same shape as `defineTool`. */
|
|
19
|
+
annotations?: ToolAnnotations;
|
|
20
|
+
/**
|
|
21
|
+
* Build the AI SDK tool from MCP session context. Called per-request.
|
|
22
|
+
* The caller injects deps (companyId, projectId, etc.) from `ctx`.
|
|
23
|
+
*/
|
|
24
|
+
buildTool: (ctx: ToolContext) => AiSdkExecutable;
|
|
25
|
+
/**
|
|
26
|
+
* Optional pre-execution guard. Return an error message to reject, or
|
|
27
|
+
* `null` to proceed. Runs after `isAuthenticated`.
|
|
28
|
+
*/
|
|
29
|
+
guard?: (ctx: ToolContext) => string | null;
|
|
30
|
+
}
|
|
31
|
+
/** Convert a McpBridge into a registered MCP tool. */
|
|
32
|
+
declare function bridgeToMcp(bridge: McpBridge): ToolDefinition;
|
|
33
|
+
interface BuildMcpToolsFromBridgesOptions {
|
|
34
|
+
/** If set, only bridges whose `name` is in this array are registered. */
|
|
35
|
+
include?: string[];
|
|
36
|
+
/** If set, bridges whose `name` is in this array are skipped. */
|
|
37
|
+
exclude?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Take a list of McpBridge objects and produce a ready-to-register MCP tool
|
|
41
|
+
* array, with optional include/exclude filtering for per-environment config.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // All bridges
|
|
46
|
+
* extraTools: [...buildMcpToolsFromBridges(allBridges)]
|
|
47
|
+
*
|
|
48
|
+
* // Read-only deployment — hide destructive tools
|
|
49
|
+
* extraTools: [...buildMcpToolsFromBridges(allBridges, { exclude: ['trigger_job'] })]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare function buildMcpToolsFromBridges(bridges: readonly McpBridge[], options?: BuildMcpToolsFromBridgesOptions): ToolDefinition[];
|
|
53
|
+
//#endregion
|
|
6
54
|
//#region src/integrations/mcp/createMcpServer.d.ts
|
|
7
55
|
/**
|
|
8
56
|
* Mutable auth ref — updated per-request by mcpPlugin.
|
|
@@ -218,4 +266,4 @@ interface ResourceToToolsConfig extends McpResourceConfig {
|
|
|
218
266
|
*/
|
|
219
267
|
declare function resourceToTools(resource: ResourceDefinition, config?: ResourceToToolsConfig): ToolDefinition[];
|
|
220
268
|
//#endregion
|
|
221
|
-
export { type AuthRef, type BetterAuthHandler, type CallToolResult, type CreateMcpServerConfig, type CrudOperation, type DefinePromptConfig, type DefineToolConfig, type FieldRuleEntry, type FieldRulesToZodOptions, type McpAuthResolver, type McpAuthResult, type McpGuard, type McpPluginOptions, type McpResourceConfig, type McpServerInstance, type PromptDefinition, type PromptResult, type ResourceToToolsConfig, type ToolAnnotations, type ToolContext, type ToolDefinition, createMcpServer, customGuard, definePrompt, defineTool, denied, fieldRulesToZod, getOrgId, getUserId, guard, hasOrg, isAuthenticated, isOrg, mcpPlugin, requireAuth, requireOrg, requireOrgId, requireRole, resourceToTools };
|
|
269
|
+
export { type AuthRef, type BetterAuthHandler, type BuildMcpToolsFromBridgesOptions, type CallToolResult, type CreateMcpServerConfig, type CrudOperation, type DefinePromptConfig, type DefineToolConfig, type FieldRuleEntry, type FieldRulesToZodOptions, type McpAuthResolver, type McpAuthResult, type McpBridge, type McpGuard, type McpPluginOptions, type McpResourceConfig, type McpServerInstance, type PromptDefinition, type PromptResult, type ResourceToToolsConfig, type ToolAnnotations, type ToolContext, type ToolDefinition, bridgeToMcp, buildMcpToolsFromBridges, createMcpServer, customGuard, definePrompt, defineTool, denied, fieldRulesToZod, getOrgId, getUserId, guard, hasOrg, isAuthenticated, isOrg, mcpPlugin, requireAuth, requireOrg, requireOrgId, requireRole, resourceToTools };
|