@classytic/arc 1.1.0 → 2.1.2
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 +247 -794
- package/bin/arc.js +91 -52
- package/dist/EventTransport-BD2U0BTc.d.mts +100 -0
- package/dist/EventTransport-BD2U0BTc.d.mts.map +1 -0
- package/dist/HookSystem-BsGV-j2l.mjs +405 -0
- package/dist/HookSystem-BsGV-j2l.mjs.map +1 -0
- package/dist/ResourceRegistry-DsN4KJjV.mjs +250 -0
- package/dist/ResourceRegistry-DsN4KJjV.mjs.map +1 -0
- package/dist/adapters/index.d.mts +5 -0
- package/dist/adapters/index.mjs +3 -0
- package/dist/audit/index.d.mts +82 -0
- package/dist/audit/index.d.mts.map +1 -0
- package/dist/audit/index.mjs +276 -0
- package/dist/audit/index.mjs.map +1 -0
- package/dist/audit/mongodb.d.mts +5 -0
- package/dist/audit/mongodb.mjs +3 -0
- package/dist/audited-C3T5DTUx.mjs +141 -0
- package/dist/audited-C3T5DTUx.mjs.map +1 -0
- package/dist/auth/index.d.mts +189 -0
- package/dist/auth/index.d.mts.map +1 -0
- package/dist/auth/index.mjs +1102 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/auth/redis-session.d.mts +44 -0
- package/dist/auth/redis-session.d.mts.map +1 -0
- package/dist/auth/redis-session.mjs +76 -0
- package/dist/auth/redis-session.mjs.map +1 -0
- package/dist/betterAuthOpenApi-BrHKeSAx.mjs +250 -0
- package/dist/betterAuthOpenApi-BrHKeSAx.mjs.map +1 -0
- package/dist/cache/index.d.mts +146 -0
- package/dist/cache/index.d.mts.map +1 -0
- package/dist/cache/index.mjs +92 -0
- package/dist/cache/index.mjs.map +1 -0
- package/dist/caching-Bl28lYsR.mjs +94 -0
- package/dist/caching-Bl28lYsR.mjs.map +1 -0
- package/dist/chunk-C7Uep-_p.mjs +20 -0
- package/dist/circuitBreaker-DeY4FCjs.mjs +1097 -0
- package/dist/circuitBreaker-DeY4FCjs.mjs.map +1 -0
- package/dist/cli/commands/describe.d.mts +19 -0
- package/dist/cli/commands/describe.d.mts.map +1 -0
- package/dist/cli/commands/describe.mjs +239 -0
- package/dist/cli/commands/describe.mjs.map +1 -0
- package/dist/cli/commands/docs.d.mts +14 -0
- package/dist/cli/commands/docs.d.mts.map +1 -0
- package/dist/cli/commands/docs.mjs +53 -0
- package/dist/cli/commands/docs.mjs.map +1 -0
- package/dist/cli/commands/{generate.d.ts → generate.d.mts} +3 -1
- package/dist/cli/commands/generate.d.mts.map +1 -0
- package/dist/cli/commands/generate.mjs +358 -0
- package/dist/cli/commands/generate.mjs.map +1 -0
- package/dist/cli/commands/{init.d.ts → init.d.mts} +12 -8
- package/dist/cli/commands/init.d.mts.map +1 -0
- package/dist/cli/commands/{init.js → init.mjs} +807 -616
- package/dist/cli/commands/init.mjs.map +1 -0
- package/dist/cli/commands/introspect.d.mts +11 -0
- package/dist/cli/commands/introspect.d.mts.map +1 -0
- package/dist/cli/commands/introspect.mjs +76 -0
- package/dist/cli/commands/introspect.mjs.map +1 -0
- package/dist/cli/index.d.mts +17 -0
- package/dist/cli/index.d.mts.map +1 -0
- package/dist/cli/index.mjs +157 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/constants-DdXFXQtN.mjs +85 -0
- package/dist/constants-DdXFXQtN.mjs.map +1 -0
- package/dist/core/index.d.mts +5 -0
- package/dist/core/index.mjs +4 -0
- package/dist/createApp-CUgNqegw.mjs +560 -0
- package/dist/createApp-CUgNqegw.mjs.map +1 -0
- package/dist/defineResource-k0_BDn8v.mjs +2197 -0
- package/dist/defineResource-k0_BDn8v.mjs.map +1 -0
- package/dist/discovery/index.d.mts +47 -0
- package/dist/discovery/index.d.mts.map +1 -0
- package/dist/discovery/index.mjs +110 -0
- package/dist/discovery/index.mjs.map +1 -0
- package/dist/docs/index.d.mts +163 -0
- package/dist/docs/index.d.mts.map +1 -0
- package/dist/docs/index.mjs +73 -0
- package/dist/docs/index.mjs.map +1 -0
- package/dist/elevation-BRy3yFWT.mjs +113 -0
- package/dist/elevation-BRy3yFWT.mjs.map +1 -0
- package/dist/elevation-B_2dRLVP.d.mts +88 -0
- package/dist/elevation-B_2dRLVP.d.mts.map +1 -0
- package/dist/errorHandler-BbcgBmIH.d.mts +73 -0
- package/dist/errorHandler-BbcgBmIH.d.mts.map +1 -0
- package/dist/errorHandler-C1okiriz.mjs +109 -0
- package/dist/errorHandler-C1okiriz.mjs.map +1 -0
- package/dist/errors-B9bZok84.mjs +212 -0
- package/dist/errors-B9bZok84.mjs.map +1 -0
- package/dist/errors-ChKiFz62.d.mts +125 -0
- package/dist/errors-ChKiFz62.d.mts.map +1 -0
- package/dist/eventPlugin-CTrLH3mt.d.mts +125 -0
- package/dist/eventPlugin-CTrLH3mt.d.mts.map +1 -0
- package/dist/eventPlugin-DGR_B2on.mjs +230 -0
- package/dist/eventPlugin-DGR_B2on.mjs.map +1 -0
- package/dist/events/index.d.mts +54 -0
- package/dist/events/index.d.mts.map +1 -0
- package/dist/events/index.mjs +52 -0
- package/dist/events/index.mjs.map +1 -0
- package/dist/events/transports/redis-stream-entry.d.mts +2 -0
- package/dist/events/transports/redis-stream-entry.mjs +178 -0
- package/dist/events/transports/redis-stream-entry.mjs.map +1 -0
- package/dist/events/transports/redis.d.mts +77 -0
- package/dist/events/transports/redis.d.mts.map +1 -0
- package/dist/events/transports/redis.mjs +125 -0
- package/dist/events/transports/redis.mjs.map +1 -0
- package/dist/externalPaths-DlINfKbP.d.mts +51 -0
- package/dist/externalPaths-DlINfKbP.d.mts.map +1 -0
- package/dist/factory/index.d.mts +64 -0
- package/dist/factory/index.d.mts.map +1 -0
- package/dist/factory/index.mjs +3 -0
- package/dist/fastifyAdapter-BkrGrlFi.d.mts +217 -0
- package/dist/fastifyAdapter-BkrGrlFi.d.mts.map +1 -0
- package/dist/fields-DyaDVX4J.d.mts +110 -0
- package/dist/fields-DyaDVX4J.d.mts.map +1 -0
- package/dist/fields-iagOozy0.mjs +115 -0
- package/dist/fields-iagOozy0.mjs.map +1 -0
- package/dist/hooks/index.d.mts +4 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/idempotency/index.d.mts +97 -0
- package/dist/idempotency/index.d.mts.map +1 -0
- package/dist/idempotency/index.mjs +320 -0
- package/dist/idempotency/index.mjs.map +1 -0
- package/dist/idempotency/mongodb.d.mts +2 -0
- package/dist/idempotency/mongodb.mjs +115 -0
- package/dist/idempotency/mongodb.mjs.map +1 -0
- package/dist/idempotency/redis.d.mts +2 -0
- package/dist/idempotency/redis.mjs +104 -0
- package/dist/idempotency/redis.mjs.map +1 -0
- package/dist/index.d.mts +261 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +105 -0
- package/dist/index.mjs.map +1 -0
- package/dist/integrations/event-gateway.d.mts +47 -0
- package/dist/integrations/event-gateway.d.mts.map +1 -0
- package/dist/integrations/event-gateway.mjs +44 -0
- package/dist/integrations/event-gateway.mjs.map +1 -0
- package/dist/integrations/index.d.mts +5 -0
- package/dist/integrations/index.mjs +1 -0
- package/dist/integrations/jobs.d.mts +104 -0
- package/dist/integrations/jobs.d.mts.map +1 -0
- package/dist/integrations/jobs.mjs +124 -0
- package/dist/integrations/jobs.mjs.map +1 -0
- package/dist/integrations/streamline.d.mts +61 -0
- package/dist/integrations/streamline.d.mts.map +1 -0
- package/dist/integrations/streamline.mjs +126 -0
- package/dist/integrations/streamline.mjs.map +1 -0
- package/dist/integrations/websocket.d.mts +83 -0
- package/dist/integrations/websocket.d.mts.map +1 -0
- package/dist/integrations/websocket.mjs +289 -0
- package/dist/integrations/websocket.mjs.map +1 -0
- package/dist/interface-B01JvPVc.d.mts +78 -0
- package/dist/interface-B01JvPVc.d.mts.map +1 -0
- package/dist/interface-CZe8IkMf.d.mts +55 -0
- package/dist/interface-CZe8IkMf.d.mts.map +1 -0
- package/dist/interface-Ch8HU9uM.d.mts +1098 -0
- package/dist/interface-Ch8HU9uM.d.mts.map +1 -0
- package/dist/introspectionPlugin-rFdO8ZUa.mjs +54 -0
- package/dist/introspectionPlugin-rFdO8ZUa.mjs.map +1 -0
- package/dist/keys-BqNejWup.mjs +43 -0
- package/dist/keys-BqNejWup.mjs.map +1 -0
- package/dist/logger-Df2O2WsW.mjs +79 -0
- package/dist/logger-Df2O2WsW.mjs.map +1 -0
- package/dist/memory-cQgelFOj.mjs +144 -0
- package/dist/memory-cQgelFOj.mjs.map +1 -0
- package/dist/migrations/index.d.mts +157 -0
- package/dist/migrations/index.d.mts.map +1 -0
- package/dist/migrations/index.mjs +261 -0
- package/dist/migrations/index.mjs.map +1 -0
- package/dist/mongodb-BfJVlUJH.mjs +94 -0
- package/dist/mongodb-BfJVlUJH.mjs.map +1 -0
- package/dist/mongodb-CGzRbfAK.d.mts +119 -0
- package/dist/mongodb-CGzRbfAK.d.mts.map +1 -0
- package/dist/mongodb-JN-9JA7K.d.mts +72 -0
- package/dist/mongodb-JN-9JA7K.d.mts.map +1 -0
- package/dist/openapi-G3Cw7XuM.mjs +524 -0
- package/dist/openapi-G3Cw7XuM.mjs.map +1 -0
- package/dist/org/index.d.mts +69 -0
- package/dist/org/index.d.mts.map +1 -0
- package/dist/org/index.mjs +514 -0
- package/dist/org/index.mjs.map +1 -0
- package/dist/org/types.d.mts +83 -0
- package/dist/org/types.d.mts.map +1 -0
- package/dist/org/types.mjs +1 -0
- package/dist/permissions/index.d.mts +279 -0
- package/dist/permissions/index.d.mts.map +1 -0
- package/dist/permissions/index.mjs +579 -0
- package/dist/permissions/index.mjs.map +1 -0
- package/dist/plugins/index.d.mts +173 -0
- package/dist/plugins/index.d.mts.map +1 -0
- package/dist/plugins/index.mjs +523 -0
- package/dist/plugins/index.mjs.map +1 -0
- package/dist/plugins/response-cache.d.mts +88 -0
- package/dist/plugins/response-cache.d.mts.map +1 -0
- package/dist/plugins/response-cache.mjs +284 -0
- package/dist/plugins/response-cache.mjs.map +1 -0
- package/dist/plugins/tracing-entry.d.mts +2 -0
- package/dist/plugins/tracing-entry.mjs +186 -0
- package/dist/plugins/tracing-entry.mjs.map +1 -0
- package/dist/pluralize-CEweyOEm.mjs +87 -0
- package/dist/pluralize-CEweyOEm.mjs.map +1 -0
- package/dist/policies/{index.d.ts → index.d.mts} +204 -169
- package/dist/policies/index.d.mts.map +1 -0
- package/dist/policies/index.mjs +322 -0
- package/dist/policies/index.mjs.map +1 -0
- package/dist/presets/{index.d.ts → index.d.mts} +63 -131
- package/dist/presets/index.d.mts.map +1 -0
- package/dist/presets/index.mjs +144 -0
- package/dist/presets/index.mjs.map +1 -0
- package/dist/presets/multiTenant.d.mts +25 -0
- package/dist/presets/multiTenant.d.mts.map +1 -0
- package/dist/presets/multiTenant.mjs +114 -0
- package/dist/presets/multiTenant.mjs.map +1 -0
- package/dist/presets-BITljm96.mjs +120 -0
- package/dist/presets-BITljm96.mjs.map +1 -0
- package/dist/presets-DzSMwlKj.d.mts +58 -0
- package/dist/presets-DzSMwlKj.d.mts.map +1 -0
- package/dist/prisma-DJbMt3yf.mjs +628 -0
- package/dist/prisma-DJbMt3yf.mjs.map +1 -0
- package/dist/prisma-Dg9GoVdj.d.mts +275 -0
- package/dist/prisma-Dg9GoVdj.d.mts.map +1 -0
- package/dist/queryCachePlugin-7THaI5mt.d.mts +72 -0
- package/dist/queryCachePlugin-7THaI5mt.d.mts.map +1 -0
- package/dist/queryCachePlugin-DMBnp2Q0.mjs +139 -0
- package/dist/queryCachePlugin-DMBnp2Q0.mjs.map +1 -0
- package/dist/redis-D-JAeLtm.d.mts +50 -0
- package/dist/redis-D-JAeLtm.d.mts.map +1 -0
- package/dist/redis-stream-Bdh_vUU8.d.mts +104 -0
- package/dist/redis-stream-Bdh_vUU8.d.mts.map +1 -0
- package/dist/registry/index.d.mts +12 -0
- package/dist/registry/index.d.mts.map +1 -0
- package/dist/registry/index.mjs +4 -0
- package/dist/requestContext-QQD6ROJc.mjs +56 -0
- package/dist/requestContext-QQD6ROJc.mjs.map +1 -0
- package/dist/schemaConverter-BwrmWroW.mjs +99 -0
- package/dist/schemaConverter-BwrmWroW.mjs.map +1 -0
- package/dist/schemas/index.d.mts +64 -0
- package/dist/schemas/index.d.mts.map +1 -0
- package/dist/schemas/index.mjs +83 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/scope/index.d.mts +22 -0
- package/dist/scope/index.d.mts.map +1 -0
- package/dist/scope/index.mjs +66 -0
- package/dist/scope/index.mjs.map +1 -0
- package/dist/sessionManager-jPKLbHE0.d.mts +187 -0
- package/dist/sessionManager-jPKLbHE0.d.mts.map +1 -0
- package/dist/sse-B3c3_yZp.mjs +124 -0
- package/dist/sse-B3c3_yZp.mjs.map +1 -0
- package/dist/testing/index.d.mts +908 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +1977 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/tracing-Cc7vVQPp.d.mts +71 -0
- package/dist/tracing-Cc7vVQPp.d.mts.map +1 -0
- package/dist/typeGuards-DhMNLuvU.mjs +10 -0
- package/dist/typeGuards-DhMNLuvU.mjs.map +1 -0
- package/dist/types/index.d.mts +947 -0
- package/dist/types/index.d.mts.map +1 -0
- package/dist/types/index.mjs +15 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/types-Beqn1Un7.mjs +39 -0
- package/dist/types-Beqn1Un7.mjs.map +1 -0
- package/dist/types-CIgB7UUl.d.mts +446 -0
- package/dist/types-CIgB7UUl.d.mts.map +1 -0
- package/dist/types-aYB4V7uN.d.mts +87 -0
- package/dist/types-aYB4V7uN.d.mts.map +1 -0
- package/dist/utils/index.d.mts +748 -0
- package/dist/utils/index.d.mts.map +1 -0
- package/dist/utils/index.mjs +6 -0
- package/package.json +194 -68
- package/dist/BaseController-DVAiHxEQ.d.ts +0 -233
- package/dist/adapters/index.d.ts +0 -237
- package/dist/adapters/index.js +0 -668
- package/dist/arcCorePlugin-CsShQdyP.d.ts +0 -273
- package/dist/audit/index.d.ts +0 -195
- package/dist/audit/index.js +0 -319
- package/dist/auth/index.d.ts +0 -47
- package/dist/auth/index.js +0 -174
- package/dist/cli/commands/docs.d.ts +0 -11
- package/dist/cli/commands/docs.js +0 -474
- package/dist/cli/commands/generate.js +0 -334
- package/dist/cli/commands/introspect.d.ts +0 -8
- package/dist/cli/commands/introspect.js +0 -338
- package/dist/cli/index.d.ts +0 -4
- package/dist/cli/index.js +0 -3269
- package/dist/core/index.d.ts +0 -220
- package/dist/core/index.js +0 -2786
- package/dist/createApp-Ce9wl8W9.d.ts +0 -77
- package/dist/docs/index.d.ts +0 -166
- package/dist/docs/index.js +0 -658
- package/dist/errors-8WIxGS_6.d.ts +0 -122
- package/dist/events/index.d.ts +0 -117
- package/dist/events/index.js +0 -89
- package/dist/factory/index.d.ts +0 -38
- package/dist/factory/index.js +0 -1652
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/index.js +0 -199
- package/dist/idempotency/index.d.ts +0 -323
- package/dist/idempotency/index.js +0 -500
- package/dist/index-B4t03KQ0.d.ts +0 -1366
- package/dist/index.d.ts +0 -135
- package/dist/index.js +0 -4756
- package/dist/migrations/index.d.ts +0 -185
- package/dist/migrations/index.js +0 -274
- package/dist/org/index.d.ts +0 -129
- package/dist/org/index.js +0 -220
- package/dist/permissions/index.d.ts +0 -144
- package/dist/permissions/index.js +0 -103
- package/dist/plugins/index.d.ts +0 -46
- package/dist/plugins/index.js +0 -1069
- package/dist/policies/index.js +0 -196
- package/dist/presets/index.js +0 -384
- package/dist/presets/multiTenant.d.ts +0 -39
- package/dist/presets/multiTenant.js +0 -112
- package/dist/registry/index.d.ts +0 -16
- package/dist/registry/index.js +0 -253
- package/dist/testing/index.d.ts +0 -618
- package/dist/testing/index.js +0 -48020
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -8
- package/dist/types-B99TBmFV.d.ts +0 -76
- package/dist/types-BvckRbs2.d.ts +0 -143
- package/dist/utils/index.d.ts +0 -679
- package/dist/utils/index.js +0 -931
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { FastifyPluginAsync, FastifyInstance, FastifyRequest } from 'fastify';
|
|
2
|
-
import { H as HookSystem, j as ResourceRegistry } from './index-B4t03KQ0.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Request ID Plugin
|
|
6
|
-
*
|
|
7
|
-
* Propagates request IDs for distributed tracing.
|
|
8
|
-
* - Accepts incoming x-request-id header
|
|
9
|
-
* - Generates UUID if not provided
|
|
10
|
-
* - Attaches to request.id and response header
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* import { requestIdPlugin } from '@classytic/arc';
|
|
14
|
-
*
|
|
15
|
-
* await fastify.register(requestIdPlugin);
|
|
16
|
-
*
|
|
17
|
-
* // In handlers, access via request.id
|
|
18
|
-
* fastify.get('/', async (request) => {
|
|
19
|
-
* console.log(request.id); // UUID
|
|
20
|
-
* });
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
interface RequestIdOptions {
|
|
24
|
-
/** Header name to read/write request ID (default: 'x-request-id') */
|
|
25
|
-
header?: string;
|
|
26
|
-
/** Custom ID generator (default: crypto.randomUUID) */
|
|
27
|
-
generator?: () => string;
|
|
28
|
-
/** Whether to set response header (default: true) */
|
|
29
|
-
setResponseHeader?: boolean;
|
|
30
|
-
}
|
|
31
|
-
declare module 'fastify' {
|
|
32
|
-
interface FastifyRequest {
|
|
33
|
-
/** Unique request identifier for tracing */
|
|
34
|
-
requestId: string;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
declare const requestIdPlugin: FastifyPluginAsync<RequestIdOptions>;
|
|
38
|
-
declare const _default$4: FastifyPluginAsync<RequestIdOptions>;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Health Check Plugin
|
|
42
|
-
*
|
|
43
|
-
* Kubernetes-ready health endpoints:
|
|
44
|
-
* - /health/live - Liveness probe (is the process alive?)
|
|
45
|
-
* - /health/ready - Readiness probe (can we serve traffic?)
|
|
46
|
-
* - /health/metrics - Prometheus metrics (optional)
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* import { healthPlugin } from '@classytic/arc';
|
|
50
|
-
*
|
|
51
|
-
* await fastify.register(healthPlugin, {
|
|
52
|
-
* prefix: '/_health',
|
|
53
|
-
* checks: [
|
|
54
|
-
* { name: 'mongodb', check: async () => mongoose.connection.readyState === 1 },
|
|
55
|
-
* { name: 'redis', check: async () => redis.ping() === 'PONG' },
|
|
56
|
-
* ],
|
|
57
|
-
* });
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
interface HealthCheck {
|
|
61
|
-
/** Name of the dependency */
|
|
62
|
-
name: string;
|
|
63
|
-
/** Function that returns true if healthy, false otherwise */
|
|
64
|
-
check: () => Promise<boolean> | boolean;
|
|
65
|
-
/** Optional timeout in ms (default: 5000) */
|
|
66
|
-
timeout?: number;
|
|
67
|
-
/** Whether this check is critical for readiness (default: true) */
|
|
68
|
-
critical?: boolean;
|
|
69
|
-
}
|
|
70
|
-
interface HealthOptions {
|
|
71
|
-
/** Route prefix (default: '/_health') */
|
|
72
|
-
prefix?: string;
|
|
73
|
-
/** Health check dependencies */
|
|
74
|
-
checks?: HealthCheck[];
|
|
75
|
-
/** Enable metrics endpoint (default: false) */
|
|
76
|
-
metrics?: boolean;
|
|
77
|
-
/** Custom metrics collector function */
|
|
78
|
-
metricsCollector?: () => Promise<string> | string;
|
|
79
|
-
/** Version info to include in responses */
|
|
80
|
-
version?: string;
|
|
81
|
-
/** Collect HTTP request metrics (default: true if metrics enabled) */
|
|
82
|
-
collectHttpMetrics?: boolean;
|
|
83
|
-
}
|
|
84
|
-
declare const healthPlugin: FastifyPluginAsync<HealthOptions>;
|
|
85
|
-
declare const _default$3: FastifyPluginAsync<HealthOptions>;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* OpenTelemetry Distributed Tracing Plugin
|
|
89
|
-
*
|
|
90
|
-
* Traces HTTP requests, repository operations, and MongoDB queries
|
|
91
|
-
* across the entire application lifecycle.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* import { tracingPlugin } from '@classytic/arc/plugins';
|
|
95
|
-
*
|
|
96
|
-
* await fastify.register(tracingPlugin, {
|
|
97
|
-
* serviceName: 'my-api',
|
|
98
|
-
* exporterUrl: 'http://localhost:4318/v1/traces', // OTLP endpoint
|
|
99
|
-
* });
|
|
100
|
-
*/
|
|
101
|
-
|
|
102
|
-
interface TracingOptions {
|
|
103
|
-
/**
|
|
104
|
-
* Service name for traces
|
|
105
|
-
*/
|
|
106
|
-
serviceName?: string;
|
|
107
|
-
/**
|
|
108
|
-
* OTLP exporter endpoint URL
|
|
109
|
-
* @default 'http://localhost:4318/v1/traces'
|
|
110
|
-
*/
|
|
111
|
-
exporterUrl?: string;
|
|
112
|
-
/**
|
|
113
|
-
* Enable auto-instrumentation for HTTP, MongoDB, etc.
|
|
114
|
-
* @default true
|
|
115
|
-
*/
|
|
116
|
-
autoInstrumentation?: boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Trace all repository operations
|
|
119
|
-
* @default true
|
|
120
|
-
*/
|
|
121
|
-
traceRepository?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Trace all controller operations
|
|
124
|
-
* @default true
|
|
125
|
-
*/
|
|
126
|
-
traceController?: boolean;
|
|
127
|
-
/**
|
|
128
|
-
* Sample rate (0.0 to 1.0)
|
|
129
|
-
* @default 1.0 (trace everything)
|
|
130
|
-
*/
|
|
131
|
-
sampleRate?: number;
|
|
132
|
-
}
|
|
133
|
-
interface TracerContext {
|
|
134
|
-
tracer: any;
|
|
135
|
-
currentSpan: any;
|
|
136
|
-
}
|
|
137
|
-
declare module 'fastify' {
|
|
138
|
-
interface FastifyRequest {
|
|
139
|
-
tracer?: TracerContext;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* OpenTelemetry Distributed Tracing Plugin
|
|
144
|
-
*/
|
|
145
|
-
declare function tracingPlugin(fastify: FastifyInstance, options?: TracingOptions): Promise<void>;
|
|
146
|
-
/**
|
|
147
|
-
* Utility to create custom spans in your code
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* import { createSpan } from '@classytic/arc/plugins';
|
|
151
|
-
*
|
|
152
|
-
* async function expensiveOperation(req) {
|
|
153
|
-
* return createSpan(req, 'expensiveOperation', async (span) => {
|
|
154
|
-
* span.setAttribute('custom.attribute', 'value');
|
|
155
|
-
* return await doWork();
|
|
156
|
-
* });
|
|
157
|
-
* }
|
|
158
|
-
*/
|
|
159
|
-
declare function createSpan<T>(request: FastifyRequest, name: string, fn: (span: any) => Promise<T>, attributes?: Record<string, any>): Promise<T>;
|
|
160
|
-
/**
|
|
161
|
-
* Decorator to automatically trace repository methods
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* class ProductRepository extends Repository {
|
|
165
|
-
* @traced()
|
|
166
|
-
* async findActive() {
|
|
167
|
-
* return this.findAll({ filter: { isActive: true } });
|
|
168
|
-
* }
|
|
169
|
-
* }
|
|
170
|
-
*/
|
|
171
|
-
declare function traced(spanName?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
172
|
-
/**
|
|
173
|
-
* Check if OpenTelemetry is available
|
|
174
|
-
*/
|
|
175
|
-
declare function isTracingAvailable(): boolean;
|
|
176
|
-
declare const _default$2: typeof tracingPlugin;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Graceful Shutdown Plugin
|
|
180
|
-
*
|
|
181
|
-
* Handles SIGTERM and SIGINT signals for clean shutdown:
|
|
182
|
-
* - Stops accepting new connections
|
|
183
|
-
* - Waits for in-flight requests to complete
|
|
184
|
-
* - Closes database connections
|
|
185
|
-
* - Exits cleanly
|
|
186
|
-
*
|
|
187
|
-
* Essential for Kubernetes deployments.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* import { gracefulShutdownPlugin } from '@classytic/arc';
|
|
191
|
-
*
|
|
192
|
-
* await fastify.register(gracefulShutdownPlugin, {
|
|
193
|
-
* timeout: 30000, // 30 seconds max
|
|
194
|
-
* onShutdown: async () => {
|
|
195
|
-
* await mongoose.disconnect();
|
|
196
|
-
* await redis.quit();
|
|
197
|
-
* },
|
|
198
|
-
* });
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
interface GracefulShutdownOptions {
|
|
202
|
-
/** Maximum time to wait for graceful shutdown in ms (default: 30000) */
|
|
203
|
-
timeout?: number;
|
|
204
|
-
/** Custom cleanup function called before exit */
|
|
205
|
-
onShutdown?: () => Promise<void> | void;
|
|
206
|
-
/** Signals to handle (default: ['SIGTERM', 'SIGINT']) */
|
|
207
|
-
signals?: NodeJS.Signals[];
|
|
208
|
-
/** Whether to log shutdown events (default: true) */
|
|
209
|
-
logEvents?: boolean;
|
|
210
|
-
}
|
|
211
|
-
declare const gracefulShutdownPlugin: FastifyPluginAsync<GracefulShutdownOptions>;
|
|
212
|
-
declare module 'fastify' {
|
|
213
|
-
interface FastifyInstance {
|
|
214
|
-
/** Trigger graceful shutdown manually */
|
|
215
|
-
shutdown: () => Promise<void>;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
declare const _default$1: FastifyPluginAsync<GracefulShutdownOptions>;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Arc Core Plugin
|
|
222
|
-
*
|
|
223
|
-
* Sets up instance-scoped Arc systems:
|
|
224
|
-
* - HookSystem: Lifecycle hooks per app instance
|
|
225
|
-
* - ResourceRegistry: Resource tracking per app instance
|
|
226
|
-
* - Event integration: Wires CRUD operations to fastify.events
|
|
227
|
-
*
|
|
228
|
-
* This solves the global singleton leak problem where multiple
|
|
229
|
-
* app instances (e.g., in tests) would share state.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* import { arcCorePlugin } from '@classytic/arc';
|
|
233
|
-
*
|
|
234
|
-
* const app = Fastify();
|
|
235
|
-
* await app.register(arcCorePlugin);
|
|
236
|
-
*
|
|
237
|
-
* // Now use instance-scoped hooks
|
|
238
|
-
* app.arc.hooks.before('product', 'create', async (ctx) => {
|
|
239
|
-
* ctx.data.slug = slugify(ctx.data.name);
|
|
240
|
-
* });
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
interface ArcCorePluginOptions {
|
|
244
|
-
/** Enable event emission for CRUD operations (requires eventPlugin) */
|
|
245
|
-
emitEvents?: boolean;
|
|
246
|
-
/** Hook system instance (for testing/custom setup) */
|
|
247
|
-
hookSystem?: HookSystem;
|
|
248
|
-
/** Resource registry instance (for testing/custom setup) */
|
|
249
|
-
registry?: ResourceRegistry;
|
|
250
|
-
/**
|
|
251
|
-
* Use global singletons for backward compatibility with presets
|
|
252
|
-
* When false (default), creates new isolated instances for better test isolation
|
|
253
|
-
* When true, uses global hookSystem/registry (for preset compatibility)
|
|
254
|
-
*/
|
|
255
|
-
useGlobalSingletons?: boolean;
|
|
256
|
-
}
|
|
257
|
-
interface ArcCore {
|
|
258
|
-
/** Instance-scoped hook system */
|
|
259
|
-
hooks: HookSystem;
|
|
260
|
-
/** Instance-scoped resource registry */
|
|
261
|
-
registry: ResourceRegistry;
|
|
262
|
-
/** Whether event emission is enabled */
|
|
263
|
-
emitEvents: boolean;
|
|
264
|
-
}
|
|
265
|
-
declare module 'fastify' {
|
|
266
|
-
interface FastifyInstance {
|
|
267
|
-
arc: ArcCore;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
declare const arcCorePlugin: FastifyPluginAsync<ArcCorePluginOptions>;
|
|
271
|
-
declare const _default: FastifyPluginAsync<ArcCorePluginOptions>;
|
|
272
|
-
|
|
273
|
-
export { type ArcCorePluginOptions as A, type GracefulShutdownOptions as G, type HealthOptions as H, type RequestIdOptions as R, type TracingOptions as T, _default$4 as _, _default$3 as a, type HealthCheck as b, _default$2 as c, createSpan as d, _default$1 as e, _default as f, gracefulShutdownPlugin as g, healthPlugin as h, isTracingAvailable as i, arcCorePlugin as j, type ArcCore as k, requestIdPlugin as r, traced as t };
|
package/dist/audit/index.d.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { U as UserBase } from '../types-B99TBmFV.js';
|
|
2
|
-
import { FastifyPluginAsync } from 'fastify';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Audit Store Interface
|
|
6
|
-
*
|
|
7
|
-
* Pluggable storage backend for audit logs.
|
|
8
|
-
* Implementations: memory (dev), mongodb, event (emit only)
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
type AuditAction = 'create' | 'update' | 'delete' | 'restore' | 'custom';
|
|
12
|
-
interface AuditEntry {
|
|
13
|
-
/** Unique audit log ID */
|
|
14
|
-
id: string;
|
|
15
|
-
/** Resource name (e.g., 'product', 'user') */
|
|
16
|
-
resource: string;
|
|
17
|
-
/** Document/entity ID */
|
|
18
|
-
documentId: string;
|
|
19
|
-
/** Action performed */
|
|
20
|
-
action: AuditAction;
|
|
21
|
-
/** User who performed the action */
|
|
22
|
-
userId?: string;
|
|
23
|
-
/** Organization context */
|
|
24
|
-
organizationId?: string;
|
|
25
|
-
/** Previous state (for updates) */
|
|
26
|
-
before?: Record<string, unknown>;
|
|
27
|
-
/** New state (for creates/updates) */
|
|
28
|
-
after?: Record<string, unknown>;
|
|
29
|
-
/** Changed fields (for updates) */
|
|
30
|
-
changes?: string[];
|
|
31
|
-
/** Request ID for tracing */
|
|
32
|
-
requestId?: string;
|
|
33
|
-
/** IP address */
|
|
34
|
-
ipAddress?: string;
|
|
35
|
-
/** User agent */
|
|
36
|
-
userAgent?: string;
|
|
37
|
-
/** Custom metadata */
|
|
38
|
-
metadata?: Record<string, unknown>;
|
|
39
|
-
/** When the action occurred */
|
|
40
|
-
timestamp: Date;
|
|
41
|
-
}
|
|
42
|
-
interface AuditContext {
|
|
43
|
-
user?: UserBase;
|
|
44
|
-
organizationId?: string;
|
|
45
|
-
requestId?: string;
|
|
46
|
-
ipAddress?: string;
|
|
47
|
-
userAgent?: string;
|
|
48
|
-
}
|
|
49
|
-
interface AuditStoreOptions {
|
|
50
|
-
/** Store name for logging */
|
|
51
|
-
name: string;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Abstract audit store interface
|
|
55
|
-
*/
|
|
56
|
-
interface AuditStore {
|
|
57
|
-
/** Store name */
|
|
58
|
-
readonly name: string;
|
|
59
|
-
/** Log an audit entry */
|
|
60
|
-
log(entry: AuditEntry): Promise<void>;
|
|
61
|
-
/** Query audit logs (optional - not all stores support querying) */
|
|
62
|
-
query?(options: AuditQueryOptions): Promise<AuditEntry[]>;
|
|
63
|
-
/** Close/cleanup (optional) */
|
|
64
|
-
close?(): Promise<void>;
|
|
65
|
-
}
|
|
66
|
-
interface AuditQueryOptions {
|
|
67
|
-
resource?: string;
|
|
68
|
-
documentId?: string;
|
|
69
|
-
userId?: string;
|
|
70
|
-
organizationId?: string;
|
|
71
|
-
action?: AuditAction | AuditAction[];
|
|
72
|
-
from?: Date;
|
|
73
|
-
to?: Date;
|
|
74
|
-
limit?: number;
|
|
75
|
-
offset?: number;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Create audit entry from context
|
|
79
|
-
*/
|
|
80
|
-
declare function createAuditEntry(resource: string, documentId: string, action: AuditAction, context: AuditContext, data?: {
|
|
81
|
-
before?: Record<string, unknown>;
|
|
82
|
-
after?: Record<string, unknown>;
|
|
83
|
-
metadata?: Record<string, unknown>;
|
|
84
|
-
}): AuditEntry;
|
|
85
|
-
|
|
86
|
-
interface AuditPluginOptions {
|
|
87
|
-
/** Enable audit logging (default: false) */
|
|
88
|
-
enabled?: boolean;
|
|
89
|
-
/** Storage backends to use */
|
|
90
|
-
stores?: ('memory' | 'mongodb')[];
|
|
91
|
-
/** MongoDB connection (required if using mongodb store) */
|
|
92
|
-
mongoConnection?: {
|
|
93
|
-
collection: (name: string) => unknown;
|
|
94
|
-
};
|
|
95
|
-
/** MongoDB collection name (default: 'audit_logs') */
|
|
96
|
-
mongoCollection?: string;
|
|
97
|
-
/** TTL in days for MongoDB (default: 90) */
|
|
98
|
-
ttlDays?: number;
|
|
99
|
-
/** Custom stores (advanced) */
|
|
100
|
-
customStores?: AuditStore[];
|
|
101
|
-
}
|
|
102
|
-
declare module 'fastify' {
|
|
103
|
-
interface FastifyInstance {
|
|
104
|
-
/** Log an audit entry */
|
|
105
|
-
audit: AuditLogger;
|
|
106
|
-
}
|
|
107
|
-
interface FastifyRequest {
|
|
108
|
-
/** Audit context for current request */
|
|
109
|
-
auditContext?: AuditContext;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
interface AuditLogger {
|
|
113
|
-
/** Log a create action */
|
|
114
|
-
create: (resource: string, documentId: string, data: Record<string, unknown>, context?: AuditContext) => Promise<void>;
|
|
115
|
-
/** Log an update action */
|
|
116
|
-
update: (resource: string, documentId: string, before: Record<string, unknown>, after: Record<string, unknown>, context?: AuditContext) => Promise<void>;
|
|
117
|
-
/** Log a delete action */
|
|
118
|
-
delete: (resource: string, documentId: string, data: Record<string, unknown>, context?: AuditContext) => Promise<void>;
|
|
119
|
-
/** Log a restore action (soft delete undo) */
|
|
120
|
-
restore: (resource: string, documentId: string, data: Record<string, unknown>, context?: AuditContext) => Promise<void>;
|
|
121
|
-
/** Log a custom action */
|
|
122
|
-
custom: (resource: string, documentId: string, action: string, data?: Record<string, unknown>, context?: AuditContext) => Promise<void>;
|
|
123
|
-
/** Query audit logs (if stores support it) */
|
|
124
|
-
query: (options: AuditQueryOptions) => Promise<AuditEntry[]>;
|
|
125
|
-
}
|
|
126
|
-
declare const auditPlugin: FastifyPluginAsync<AuditPluginOptions>;
|
|
127
|
-
declare const _default: FastifyPluginAsync<AuditPluginOptions>;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* In-Memory Audit Store
|
|
131
|
-
*
|
|
132
|
-
* For development and testing. Not suitable for production.
|
|
133
|
-
* Logs are lost on restart.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
interface MemoryAuditStoreOptions {
|
|
137
|
-
/** Maximum entries to keep (default: 1000) */
|
|
138
|
-
maxEntries?: number;
|
|
139
|
-
}
|
|
140
|
-
declare class MemoryAuditStore implements AuditStore {
|
|
141
|
-
readonly name = "memory";
|
|
142
|
-
private entries;
|
|
143
|
-
private maxEntries;
|
|
144
|
-
constructor(options?: MemoryAuditStoreOptions);
|
|
145
|
-
log(entry: AuditEntry): Promise<void>;
|
|
146
|
-
query(options?: AuditQueryOptions): Promise<AuditEntry[]>;
|
|
147
|
-
close(): Promise<void>;
|
|
148
|
-
/** Get all entries (for testing) */
|
|
149
|
-
getAll(): AuditEntry[];
|
|
150
|
-
/** Clear all entries (for testing) */
|
|
151
|
-
clear(): void;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* MongoDB Audit Store
|
|
156
|
-
*
|
|
157
|
-
* Persists audit logs to MongoDB collection with TTL support.
|
|
158
|
-
* Suitable for production use.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
interface MongoAuditStoreOptions {
|
|
162
|
-
/** MongoDB connection or mongoose instance */
|
|
163
|
-
connection: MongoConnection;
|
|
164
|
-
/** Collection name (default: 'audit_logs') */
|
|
165
|
-
collection?: string;
|
|
166
|
-
/** TTL in days (default: 90, 0 = no expiry) */
|
|
167
|
-
ttlDays?: number;
|
|
168
|
-
}
|
|
169
|
-
interface MongoConnection {
|
|
170
|
-
collection: (name: string) => MongoCollection;
|
|
171
|
-
}
|
|
172
|
-
interface MongoCollection {
|
|
173
|
-
insertOne: (doc: Record<string, unknown>) => Promise<unknown>;
|
|
174
|
-
find: (query: Record<string, unknown>) => MongoCursor;
|
|
175
|
-
createIndex: (spec: Record<string, unknown>, options?: Record<string, unknown>) => Promise<unknown>;
|
|
176
|
-
}
|
|
177
|
-
interface MongoCursor {
|
|
178
|
-
sort: (spec: Record<string, unknown>) => MongoCursor;
|
|
179
|
-
skip: (n: number) => MongoCursor;
|
|
180
|
-
limit: (n: number) => MongoCursor;
|
|
181
|
-
toArray: () => Promise<Record<string, unknown>[]>;
|
|
182
|
-
}
|
|
183
|
-
declare class MongoAuditStore implements AuditStore {
|
|
184
|
-
private options;
|
|
185
|
-
readonly name = "mongodb";
|
|
186
|
-
private collection;
|
|
187
|
-
private initialized;
|
|
188
|
-
private ttlDays;
|
|
189
|
-
constructor(options: MongoAuditStoreOptions);
|
|
190
|
-
private ensureIndexes;
|
|
191
|
-
log(entry: AuditEntry): Promise<void>;
|
|
192
|
-
query(options?: AuditQueryOptions): Promise<AuditEntry[]>;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export { type AuditAction, type AuditContext, type AuditEntry, type AuditLogger, type AuditPluginOptions, type AuditQueryOptions, type AuditStore, type AuditStoreOptions, MemoryAuditStore, type MemoryAuditStoreOptions, MongoAuditStore, type MongoAuditStoreOptions, _default as auditPlugin, auditPlugin as auditPluginFn, createAuditEntry };
|