@classytic/arc 2.21.0 → 2.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/{BaseController-BnLYgE9A.mjs → BaseController-C6FlRWxF.mjs} +1 -1
  2. package/dist/audit/index.d.mts +2 -2
  3. package/dist/auth/index.d.mts +30 -2
  4. package/dist/auth/index.mjs +5 -2
  5. package/dist/cli/commands/describe.d.mts +1 -1
  6. package/dist/cli/commands/docs.mjs +1 -1
  7. package/dist/cli/commands/init.mjs +1 -1
  8. package/dist/cli/index.mjs +1 -1
  9. package/dist/core/index.d.mts +2 -2
  10. package/dist/core/index.mjs +2 -2
  11. package/dist/{core-DZ6Xe1jR.mjs → core-b6fgFgnd.mjs} +123 -66
  12. package/dist/{createActionRouter-BWMDW-dL.mjs → createActionRouter-h1cEEaEX.mjs} +9 -5
  13. package/dist/{createAggregationRouter-l5mNdYrZ.mjs → createAggregationRouter-B1C0kvTL.mjs} +3 -3
  14. package/dist/{createApp-Bi61XxqU.mjs → createApp-Ci7yG5gv.mjs} +242 -56
  15. package/dist/docs/index.d.mts +1 -1
  16. package/dist/docs/index.mjs +1 -1
  17. package/dist/encryption/index.mjs +9 -5
  18. package/dist/{errorHandler-Dxf6P_kV.mjs → errorHandler-BTzXSwIg.mjs} +24 -3
  19. package/dist/{errorHandler-B0e-bq-O.d.mts → errorHandler-C6yv4ZTW.d.mts} +13 -0
  20. package/dist/factory/index.d.mts +29 -8
  21. package/dist/factory/index.mjs +34 -3
  22. package/dist/{fastify-augmentation-DafigGQp.d.mts → fastify-augmentation-9_fuetB4.d.mts} +2 -2
  23. package/dist/fields-D3lhgzhD.d.mts +121 -0
  24. package/dist/health-ScyjIVo5.mjs +202 -0
  25. package/dist/hooks/index.d.mts +1 -1
  26. package/dist/idempotency/index.mjs +2 -0
  27. package/dist/{types-DpxoNX5v.d.mts → index-BEu4wjbL.d.mts} +187 -66
  28. package/dist/{index-B5N-NaHs.d.mts → index-D8MKYGDa.d.mts} +3 -3
  29. package/dist/{index-Dtrj6XZk.d.mts → index-DbtgCOCj.d.mts} +1287 -1225
  30. package/dist/{index-B5PoNbfu.d.mts → index-ogIHvOjo.d.mts} +1 -1
  31. package/dist/index.d.mts +6 -5
  32. package/dist/index.mjs +3 -3
  33. package/dist/{init-0YhHkXGk.mjs → init-DleK3p9f.mjs} +118 -2
  34. package/dist/integrations/index.d.mts +1 -1
  35. package/dist/integrations/mcp/index.d.mts +3 -3
  36. package/dist/integrations/mcp/index.mjs +1 -1
  37. package/dist/integrations/mcp/testing.d.mts +1 -1
  38. package/dist/integrations/mcp/testing.mjs +1 -1
  39. package/dist/integrations/webhooks.d.mts +8 -4
  40. package/dist/integrations/webhooks.mjs +9 -5
  41. package/dist/jsonBody-BlzAoGCe.mjs +43 -0
  42. package/dist/logger/index.d.mts +26 -1
  43. package/dist/logger/index.mjs +39 -1
  44. package/dist/{mcpPlugin-B9XjjNVG.mjs → mcpPlugin-ByA2tf6D.mjs} +6 -2
  45. package/dist/middleware/index.d.mts +1 -1
  46. package/dist/{module-WeuU5jfd.d.mts → module-B4u10iOJ.d.mts} +26 -1
  47. package/dist/{openapi-Kyod_di6.mjs → openapi-BRpMZD7C.mjs} +2 -2
  48. package/dist/permissions/index.d.mts +3 -2
  49. package/dist/pipeline/index.d.mts +1 -1
  50. package/dist/plugins/index.d.mts +22 -5
  51. package/dist/plugins/index.mjs +11 -280
  52. package/dist/plugins/response-cache.mjs +1 -0
  53. package/dist/plugins/tracing-entry.mjs +7 -4
  54. package/dist/presets/filesUpload.d.mts +2 -2
  55. package/dist/presets/index.d.mts +1 -1
  56. package/dist/presets/multiTenant.d.mts +1 -1
  57. package/dist/presets/search.d.mts +2 -2
  58. package/dist/rateLimitKey-BoWRH3e7.mjs +14 -0
  59. package/dist/{registerRoute-oGAl0oA8.mjs → registerRoute-xHc42fwB.mjs} +37 -17
  60. package/dist/registry/index.d.mts +2 -2
  61. package/dist/requestId-5BhTVzBv.mjs +113 -0
  62. package/dist/schemaConverter-Ds5reSGs.mjs +168 -0
  63. package/dist/{schemaIR-ajetw3Fv.mjs → schemaIR-B-6SPe7g.mjs} +2 -2
  64. package/dist/scim/index.mjs +6 -7
  65. package/dist/scope/index.mjs +2 -76
  66. package/dist/scope-k15RXfcq.mjs +64 -0
  67. package/dist/testing/index.d.mts +83 -3
  68. package/dist/testing/index.mjs +70 -3
  69. package/dist/types/index.d.mts +2 -2
  70. package/dist/{types-DRj-Ut4n.d.mts → types-Bc42CUyk.d.mts} +1 -1
  71. package/dist/{fields-BGqrAa_u.d.mts → types-Csxga7d3.d.mts} +1 -121
  72. package/dist/usage/index.d.mts +142 -0
  73. package/dist/usage/index.mjs +0 -0
  74. package/dist/utils/index.d.mts +40 -18
  75. package/dist/utils/index.mjs +2 -2
  76. package/dist/{utils-CO8a3B_1.mjs → utils-FhJ88TJE.mjs} +59 -13
  77. package/dist/{versioning-DQ4mCvg0.d.mts → versioning-DLwklPlG.d.mts} +0 -5
  78. package/llms.txt +39 -0
  79. package/package.json +453 -447
  80. package/skills/arc/SKILL.md +14 -8
  81. package/skills/arc/references/api-reference.md +34 -0
  82. package/skills/arc/references/auth.md +21 -4
  83. package/skills/arc/references/mcp.md +1 -1
  84. package/skills/arc/references/production.md +44 -2
  85. package/skills/arc-code-review/SKILL.md +1 -1
  86. package/skills/arc-code-review/references/anti-patterns.md +71 -18
  87. package/skills/arc-code-review/references/arc-cheatsheet.md +15 -2
  88. package/skills/arc-code-review/references/migration-recipes.md +7 -7
  89. package/skills/arc-code-review/references/mongokit-migration.md +4 -3
  90. package/skills/arc-module-publishing/SKILL.md +2 -1
  91. package/skills/arc-module-publishing/references/authoring-modules.md +55 -0
  92. package/skills/arc-module-publishing/references/package-manifest.md +4 -2
  93. package/dist/preloadResources-CHw3_oA_.mjs +0 -45
  94. package/dist/schemaConverter-U0MnO9vd.mjs +0 -110
@@ -1,45 +0,0 @@
1
- //#region src/testing/preloadResources.ts
2
- /**
3
- * Normalize an eager `import.meta.glob` result into a `ResourceLike[]`.
4
- *
5
- * Accepts either:
6
- * - `{ import: 'default' }` form: values are the resource directly
7
- * - default form: values are the full module — picks first export with `toPlugin()`
8
- *
9
- * Throws if any module doesn't yield a valid `ResourceLike`.
10
- */
11
- function preloadResources(globResult) {
12
- const resources = [];
13
- for (const [path, value] of Object.entries(globResult)) {
14
- const resource = pickResource(value);
15
- if (!resource) throw new Error(`preloadResources: ${path} does not export a valid resource.\n Expected: a default export OR a named export with toPlugin().`);
16
- resources.push(resource);
17
- }
18
- return resources.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
19
- }
20
- /**
21
- * Normalize a lazy `import.meta.glob` result into a `Promise<ResourceLike[]>`.
22
- *
23
- * Use this when resources depend on prior bootstrap (e.g., engine init) and
24
- * cannot be evaluated at import time of the preload file.
25
- */
26
- async function preloadResourcesAsync(globResult) {
27
- return (await Promise.all(Object.entries(globResult).map(async ([path, loader]) => {
28
- const resource = pickResource(await loader());
29
- if (!resource) throw new Error(`preloadResourcesAsync: ${path} does not export a valid resource.\n Expected: a default export OR a named export with toPlugin().`);
30
- return resource;
31
- }))).sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
32
- }
33
- function pickResource(value) {
34
- if (!value || typeof value !== "object") return void 0;
35
- if (typeof value.toPlugin === "function") return value;
36
- const mod = value;
37
- const candidates = [
38
- mod.default,
39
- mod.resource,
40
- ...Object.values(mod)
41
- ];
42
- for (const c of candidates) if (c && typeof c === "object" && typeof c.toPlugin === "function") return c;
43
- }
44
- //#endregion
45
- export { preloadResourcesAsync as n, preloadResources as t };
@@ -1,110 +0,0 @@
1
- //#region src/utils/schemaConverter.ts
2
- /** Default target for Fastify-consumed schemas (matches Fastify v5's default AJV draft). */
3
- const DEFAULT_FASTIFY_TARGET = "draft-7";
4
- /** Default target for OpenAPI document generation (matches arc's emitted OpenAPI version). */
5
- const DEFAULT_OPENAPI_TARGET = "openapi-3.0";
6
- let _toJSONSchema = null;
7
- import("zod").then(({ z }) => {
8
- if (typeof z?.toJSONSchema === "function") _toJSONSchema = (schema, opts) => z.toJSONSchema(schema, opts);
9
- }).catch(() => {});
10
- /**
11
- * Check if an object is already a plain JSON Schema.
12
- * Returns true if it has JSON Schema markers (`type`, `properties`, `$ref`,
13
- * `allOf`, `anyOf`, `oneOf`, `items`, `enum`) and does NOT have Zod markers.
14
- */
15
- function isJsonSchema(input) {
16
- if (input === null || typeof input !== "object") return false;
17
- const obj = input;
18
- if ("_def" in obj || "_zod" in obj) return false;
19
- return "type" in obj || "properties" in obj || "$ref" in obj || "allOf" in obj || "anyOf" in obj || "oneOf" in obj || "items" in obj || "enum" in obj;
20
- }
21
- /**
22
- * Check if an object is a Zod schema (has `_zod` marker from Zod v4).
23
- */
24
- function isZodSchema(input) {
25
- return input !== null && typeof input === "object" && "_zod" in input;
26
- }
27
- /**
28
- * Convert any schema input to JSON Schema.
29
- *
30
- * Detection order:
31
- * 1. `null`/`undefined` → `undefined`
32
- * 2. Already JSON Schema → pass through as-is (zero overhead)
33
- * 3. Zod v4 schema → `z.toJSONSchema(schema, { target })`
34
- * 4. Unrecognized object → return as-is (treat as opaque schema)
35
- *
36
- * @param input Schema (Zod, plain JSON Schema, or opaque object)
37
- * @param target Output target — defaults to `draft-7` for Fastify compatibility.
38
- * Pass `openapi-3.0`/`openapi-3.1` for OpenAPI document generation.
39
- */
40
- function toJsonSchema(input, target = DEFAULT_FASTIFY_TARGET) {
41
- if (input == null) return void 0;
42
- if (typeof input !== "object") return void 0;
43
- if (isJsonSchema(input)) return input;
44
- if (isZodSchema(input)) {
45
- if (!_toJSONSchema) return input;
46
- try {
47
- const converted = _toJSONSchema(input, { target });
48
- if ("$schema" in converted) delete converted.$schema;
49
- return converted;
50
- } catch {
51
- return { type: "object" };
52
- }
53
- }
54
- return input;
55
- }
56
- /**
57
- * Convert all schema fields in an OpenApiSchemas object.
58
- * JSON Schema values pass through unchanged. Only Zod schemas are converted.
59
- *
60
- * Defaults to the `openapi-3.0` target since this function feeds OpenAPI doc
61
- * generation, not Fastify route validation.
62
- */
63
- function convertOpenApiSchemas(schemas, target = DEFAULT_OPENAPI_TARGET) {
64
- const result = {};
65
- const schemaFields = [
66
- "entity",
67
- "createBody",
68
- "updateBody",
69
- "params",
70
- "listQuery",
71
- "response"
72
- ];
73
- for (const field of schemaFields) {
74
- const value = schemas[field];
75
- if (value !== void 0) result[field] = toJsonSchema(value, target) ?? value;
76
- }
77
- for (const [key, value] of Object.entries(schemas)) if (!schemaFields.includes(key)) result[key] = value;
78
- return result;
79
- }
80
- /**
81
- * Convert schema values in a Fastify route schema record.
82
- *
83
- * Handles `body`, `querystring`, `params`, `headers` (top-level conversion)
84
- * and `response` (iterates by status code — each value converted individually).
85
- *
86
- * JSON Schema values pass through unchanged. Only Zod schemas are converted.
87
- *
88
- * Used for both custom routes and customSchemas (CRUD overrides).
89
- *
90
- * Defaults to `draft-7` so Fastify v5's bundled AJV 8 accepts the output.
91
- * Pass `openapi-3.0` (or `openapi-3.1`) when generating OpenAPI documents.
92
- */
93
- function convertRouteSchema(schema, target = DEFAULT_FASTIFY_TARGET) {
94
- const result = { ...schema };
95
- for (const field of [
96
- "body",
97
- "querystring",
98
- "params",
99
- "headers"
100
- ]) if (result[field] !== void 0) result[field] = toJsonSchema(result[field], target) ?? result[field];
101
- if (result.response !== void 0 && typeof result.response === "object" && result.response !== null) {
102
- const responseObj = result.response;
103
- const convertedResponse = {};
104
- for (const [statusCode, responseSchema] of Object.entries(responseObj)) convertedResponse[statusCode] = toJsonSchema(responseSchema, target) ?? responseSchema;
105
- result.response = convertedResponse;
106
- }
107
- return result;
108
- }
109
- //#endregion
110
- export { toJsonSchema as a, isZodSchema as i, convertRouteSchema as n, isJsonSchema as r, convertOpenApiSchemas as t };