@classytic/arc 1.1.0 → 2.1.3
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-BkUDYZEb.d.mts +99 -0
- package/dist/HookSystem-BsGV-j2l.mjs +404 -0
- package/dist/ResourceRegistry-7Ic20ZMw.mjs +249 -0
- package/dist/adapters/index.d.mts +5 -0
- package/dist/adapters/index.mjs +3 -0
- package/dist/audit/index.d.mts +81 -0
- package/dist/audit/index.mjs +275 -0
- package/dist/audit/mongodb.d.mts +5 -0
- package/dist/audit/mongodb.mjs +3 -0
- package/dist/audited-CGdLiSlE.mjs +140 -0
- package/dist/auth/index.d.mts +188 -0
- package/dist/auth/index.mjs +1096 -0
- package/dist/auth/redis-session.d.mts +43 -0
- package/dist/auth/redis-session.mjs +75 -0
- package/dist/betterAuthOpenApi-DjWDddNc.mjs +249 -0
- package/dist/cache/index.d.mts +145 -0
- package/dist/cache/index.mjs +91 -0
- package/dist/caching-GSDJcA6-.mjs +93 -0
- package/dist/chunk-C7Uep-_p.mjs +20 -0
- package/dist/circuitBreaker-DYhWBW_D.mjs +1096 -0
- package/dist/cli/commands/describe.d.mts +18 -0
- package/dist/cli/commands/describe.mjs +238 -0
- package/dist/cli/commands/docs.d.mts +13 -0
- package/dist/cli/commands/docs.mjs +52 -0
- package/dist/cli/commands/{generate.d.ts → generate.d.mts} +3 -2
- package/dist/cli/commands/generate.mjs +357 -0
- package/dist/cli/commands/{init.d.ts → init.d.mts} +11 -8
- package/dist/cli/commands/{init.js → init.mjs} +807 -617
- package/dist/cli/commands/introspect.d.mts +10 -0
- package/dist/cli/commands/introspect.mjs +75 -0
- package/dist/cli/index.d.mts +16 -0
- package/dist/cli/index.mjs +156 -0
- package/dist/constants-DdXFXQtN.mjs +84 -0
- package/dist/core/index.d.mts +5 -0
- package/dist/core/index.mjs +4 -0
- package/dist/createApp-D2D5XXaV.mjs +559 -0
- package/dist/defineResource-PXzSJ15_.mjs +2197 -0
- package/dist/discovery/index.d.mts +46 -0
- package/dist/discovery/index.mjs +109 -0
- package/dist/docs/index.d.mts +162 -0
- package/dist/docs/index.mjs +74 -0
- package/dist/elevation-DGo5shaX.d.mts +87 -0
- package/dist/elevation-DSTbVvYj.mjs +113 -0
- package/dist/errorHandler-C3GY3_ow.mjs +108 -0
- package/dist/errorHandler-CW3OOeYq.d.mts +72 -0
- package/dist/errors-DAWRdiYP.d.mts +124 -0
- package/dist/errors-DBANPbGr.mjs +211 -0
- package/dist/eventPlugin-BEOvaDqo.mjs +229 -0
- package/dist/eventPlugin-H6wDDjGO.d.mts +124 -0
- package/dist/events/index.d.mts +53 -0
- package/dist/events/index.mjs +51 -0
- package/dist/events/transports/redis-stream-entry.d.mts +2 -0
- package/dist/events/transports/redis-stream-entry.mjs +177 -0
- package/dist/events/transports/redis.d.mts +76 -0
- package/dist/events/transports/redis.mjs +124 -0
- package/dist/externalPaths-SyPF2tgK.d.mts +50 -0
- package/dist/factory/index.d.mts +63 -0
- package/dist/factory/index.mjs +3 -0
- package/dist/fastifyAdapter-C8DlE0YH.d.mts +216 -0
- package/dist/fields-Bi_AVKSo.d.mts +109 -0
- package/dist/fields-CTd_CrKr.mjs +114 -0
- package/dist/hooks/index.d.mts +4 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/idempotency/index.d.mts +96 -0
- package/dist/idempotency/index.mjs +319 -0
- package/dist/idempotency/mongodb.d.mts +2 -0
- package/dist/idempotency/mongodb.mjs +114 -0
- package/dist/idempotency/redis.d.mts +2 -0
- package/dist/idempotency/redis.mjs +103 -0
- package/dist/index.d.mts +260 -0
- package/dist/index.mjs +104 -0
- package/dist/integrations/event-gateway.d.mts +46 -0
- package/dist/integrations/event-gateway.mjs +43 -0
- package/dist/integrations/index.d.mts +5 -0
- package/dist/integrations/index.mjs +1 -0
- package/dist/integrations/jobs.d.mts +103 -0
- package/dist/integrations/jobs.mjs +123 -0
- package/dist/integrations/streamline.d.mts +60 -0
- package/dist/integrations/streamline.mjs +125 -0
- package/dist/integrations/websocket.d.mts +82 -0
- package/dist/integrations/websocket.mjs +288 -0
- package/dist/interface-CSNjltAc.d.mts +77 -0
- package/dist/interface-DTbsvIWe.d.mts +54 -0
- package/dist/interface-e9XfSsUV.d.mts +1097 -0
- package/dist/introspectionPlugin-B3JkrjwU.mjs +53 -0
- package/dist/keys-DhqDRxv3.mjs +42 -0
- package/dist/logger-ByrvQWZO.mjs +78 -0
- package/dist/memory-B2v7KrCB.mjs +143 -0
- package/dist/migrations/index.d.mts +156 -0
- package/dist/migrations/index.mjs +260 -0
- package/dist/mongodb-ClykrfGo.d.mts +118 -0
- package/dist/mongodb-DNKEExbf.mjs +93 -0
- package/dist/mongodb-Dg8O_gvd.d.mts +71 -0
- package/dist/openapi-9nB_kiuR.mjs +525 -0
- package/dist/org/index.d.mts +68 -0
- package/dist/org/index.mjs +513 -0
- package/dist/org/types.d.mts +82 -0
- package/dist/org/types.mjs +1 -0
- package/dist/permissions/index.d.mts +278 -0
- package/dist/permissions/index.mjs +579 -0
- package/dist/plugins/index.d.mts +172 -0
- package/dist/plugins/index.mjs +522 -0
- package/dist/plugins/response-cache.d.mts +87 -0
- package/dist/plugins/response-cache.mjs +283 -0
- package/dist/plugins/tracing-entry.d.mts +2 -0
- package/dist/plugins/tracing-entry.mjs +185 -0
- package/dist/pluralize-CM-jZg7p.mjs +86 -0
- package/dist/policies/{index.d.ts → index.d.mts} +204 -170
- package/dist/policies/index.mjs +321 -0
- package/dist/presets/{index.d.ts → index.d.mts} +62 -131
- package/dist/presets/index.mjs +143 -0
- package/dist/presets/multiTenant.d.mts +24 -0
- package/dist/presets/multiTenant.mjs +113 -0
- package/dist/presets-BTeYbw7h.d.mts +57 -0
- package/dist/presets-CeFtfDR8.mjs +119 -0
- package/dist/prisma-C3iornoK.d.mts +274 -0
- package/dist/prisma-DJbMt3yf.mjs +627 -0
- package/dist/queryCachePlugin-B6R0d4av.mjs +138 -0
- package/dist/queryCachePlugin-Q6SYuHZ6.d.mts +71 -0
- package/dist/redis-UwjEp8Ea.d.mts +49 -0
- package/dist/redis-stream-CBg0upHI.d.mts +103 -0
- package/dist/registry/index.d.mts +11 -0
- package/dist/registry/index.mjs +4 -0
- package/dist/requestContext-xi6OKBL-.mjs +55 -0
- package/dist/schemaConverter-Dtg0Kt9T.mjs +98 -0
- package/dist/schemas/index.d.mts +63 -0
- package/dist/schemas/index.mjs +82 -0
- package/dist/scope/index.d.mts +21 -0
- package/dist/scope/index.mjs +65 -0
- package/dist/sessionManager-D_iEHjQl.d.mts +186 -0
- package/dist/sse-DkqQ1uxb.mjs +123 -0
- package/dist/testing/index.d.mts +907 -0
- package/dist/testing/index.mjs +1976 -0
- package/dist/tracing-8CEbhF0w.d.mts +70 -0
- package/dist/typeGuards-DwxA1t_L.mjs +9 -0
- package/dist/types/index.d.mts +946 -0
- package/dist/types/index.mjs +14 -0
- package/dist/types-B0dhNrnd.d.mts +445 -0
- package/dist/types-Beqn1Un7.mjs +38 -0
- package/dist/types-DelU6kln.mjs +25 -0
- package/dist/types-RLkFVgaw.d.mts +101 -0
- package/dist/utils/index.d.mts +747 -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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/cli/commands/introspect.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Arc CLI - Introspect Command
|
|
4
|
+
*
|
|
5
|
+
* Shows all registered resources and their configuration.
|
|
6
|
+
* Requires an entry file that exports defineResource() results.
|
|
7
|
+
*/
|
|
8
|
+
declare function introspect(args: string[]): Promise<void>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { introspect as default, introspect };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { t as ResourceRegistry } from "../../ResourceRegistry-7Ic20ZMw.mjs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/commands/introspect.ts
|
|
6
|
+
/**
|
|
7
|
+
* Arc CLI - Introspect Command
|
|
8
|
+
*
|
|
9
|
+
* Shows all registered resources and their configuration.
|
|
10
|
+
* Requires an entry file that exports defineResource() results.
|
|
11
|
+
*/
|
|
12
|
+
function describePermission(value) {
|
|
13
|
+
if (!value) return "none";
|
|
14
|
+
if (typeof value === "function") return value.name ? `${value.name}()` : "[anonymous permission function]";
|
|
15
|
+
if (Array.isArray(value)) return `[${value.join(", ")}]`;
|
|
16
|
+
if (typeof value === "object") return "[permission object]";
|
|
17
|
+
return String(value);
|
|
18
|
+
}
|
|
19
|
+
async function introspect(args) {
|
|
20
|
+
console.log("Introspecting Arc resources...\n");
|
|
21
|
+
try {
|
|
22
|
+
const entryPath = args[0];
|
|
23
|
+
if (!entryPath) {
|
|
24
|
+
console.log("Usage: arc introspect <entry-file>\n");
|
|
25
|
+
console.log("Where entry-file exports your defineResource() results.");
|
|
26
|
+
console.log("Example: arc introspect ./src/resources.js");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const entryModule = await import(pathToFileURL(resolve(process.cwd(), entryPath)).href);
|
|
30
|
+
const registry = new ResourceRegistry();
|
|
31
|
+
let registered = 0;
|
|
32
|
+
function tryRegister(value) {
|
|
33
|
+
if (value && typeof value === "object" && "name" in value && "_registryMeta" in value && "toPlugin" in value) {
|
|
34
|
+
registry.register(value, value._registryMeta ?? {});
|
|
35
|
+
registered++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
for (const exported of Object.values(entryModule)) if (Array.isArray(exported)) exported.forEach(tryRegister);
|
|
39
|
+
else tryRegister(exported);
|
|
40
|
+
if (registered === 0) {
|
|
41
|
+
console.log("No resource definitions found in entry file.");
|
|
42
|
+
console.log("\nMake sure your file exports defineResource() results:");
|
|
43
|
+
console.log(" export const productResource = defineResource({ ... });");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const resources = registry.getAll();
|
|
47
|
+
console.log(`Found ${resources.length} resource(s):\n`);
|
|
48
|
+
resources.forEach((resource, index) => {
|
|
49
|
+
console.log(`${index + 1}. ${resource.name}`);
|
|
50
|
+
console.log(` Display Name: ${resource.displayName}`);
|
|
51
|
+
console.log(` Prefix: ${resource.prefix}`);
|
|
52
|
+
console.log(` Module: ${resource.module || "none"}`);
|
|
53
|
+
if (resource.permissions) {
|
|
54
|
+
console.log(` Permissions:`);
|
|
55
|
+
Object.entries(resource.permissions).forEach(([op, permission]) => {
|
|
56
|
+
console.log(` ${op}: ${describePermission(permission)}`);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (resource.presets && resource.presets.length > 0) console.log(` Presets: ${resource.presets.join(", ")}`);
|
|
60
|
+
if (resource.additionalRoutes && resource.additionalRoutes.length > 0) console.log(` Additional Routes: ${resource.additionalRoutes.length}`);
|
|
61
|
+
console.log("");
|
|
62
|
+
});
|
|
63
|
+
const stats = registry.getStats();
|
|
64
|
+
console.log("Summary:");
|
|
65
|
+
console.log(` Total Resources: ${stats.totalResources}`);
|
|
66
|
+
console.log(` With Presets: ${resources.filter((r) => r.presets?.length > 0).length}`);
|
|
67
|
+
console.log(` With Custom Routes: ${resources.filter((r) => r.additionalRoutes && r.additionalRoutes.length > 0).length}`);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof Error) throw error;
|
|
70
|
+
throw new Error(String(error));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
export { introspect as default, introspect };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import describe from "./commands/describe.mjs";
|
|
2
|
+
import { exportDocs } from "./commands/docs.mjs";
|
|
3
|
+
import generate from "./commands/generate.mjs";
|
|
4
|
+
import init from "./commands/init.mjs";
|
|
5
|
+
import introspect from "./commands/introspect.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/commands/doctor.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Arc CLI - Doctor Command
|
|
10
|
+
*
|
|
11
|
+
* Health check utility that validates the development environment.
|
|
12
|
+
* Checks Node.js version, dependencies, configuration, and env variables.
|
|
13
|
+
*/
|
|
14
|
+
declare function doctor(_args?: string[]): Promise<void>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { describe, doctor, exportDocs, generate, init, introspect };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import generate from "./commands/generate.mjs";
|
|
2
|
+
import init from "./commands/init.mjs";
|
|
3
|
+
import introspect from "./commands/introspect.mjs";
|
|
4
|
+
import describe from "./commands/describe.mjs";
|
|
5
|
+
import { exportDocs } from "./commands/docs.mjs";
|
|
6
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
+
import { join, resolve } from "node:path";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/commands/doctor.ts
|
|
10
|
+
/**
|
|
11
|
+
* Arc CLI - Doctor Command
|
|
12
|
+
*
|
|
13
|
+
* Health check utility that validates the development environment.
|
|
14
|
+
* Checks Node.js version, dependencies, configuration, and env variables.
|
|
15
|
+
*/
|
|
16
|
+
async function doctor(_args = []) {
|
|
17
|
+
console.log("\nArc Doctor\n");
|
|
18
|
+
const results = [];
|
|
19
|
+
const cwd = process.cwd();
|
|
20
|
+
const nodeVersion = process.versions.node;
|
|
21
|
+
if (parseInt(nodeVersion.split(".")[0] ?? "0", 10) >= 22) results.push({
|
|
22
|
+
status: "pass",
|
|
23
|
+
label: `Node.js ${nodeVersion}`,
|
|
24
|
+
detail: "required: >=22"
|
|
25
|
+
});
|
|
26
|
+
else results.push({
|
|
27
|
+
status: "fail",
|
|
28
|
+
label: `Node.js ${nodeVersion}`,
|
|
29
|
+
detail: "required: >=22"
|
|
30
|
+
});
|
|
31
|
+
const pkg = findPackageJson(cwd);
|
|
32
|
+
const allDeps = {
|
|
33
|
+
...pkg?.dependencies ?? {},
|
|
34
|
+
...pkg?.devDependencies ?? {}
|
|
35
|
+
};
|
|
36
|
+
const arcVersion = allDeps["@classytic/arc"];
|
|
37
|
+
if (arcVersion) results.push({
|
|
38
|
+
status: "pass",
|
|
39
|
+
label: `@classytic/arc ${arcVersion}`
|
|
40
|
+
});
|
|
41
|
+
else results.push({
|
|
42
|
+
status: "warn",
|
|
43
|
+
label: "@classytic/arc not found in dependencies"
|
|
44
|
+
});
|
|
45
|
+
const fastifyVersion = allDeps["fastify"];
|
|
46
|
+
if (fastifyVersion) {
|
|
47
|
+
const clean = fastifyVersion.replace(/^[\^~>=<]+/, "");
|
|
48
|
+
if (parseInt(clean.split(".")[0] ?? "0", 10) >= 5) results.push({
|
|
49
|
+
status: "pass",
|
|
50
|
+
label: `fastify ${fastifyVersion}`,
|
|
51
|
+
detail: "required: ^5.0.0"
|
|
52
|
+
});
|
|
53
|
+
else results.push({
|
|
54
|
+
status: "fail",
|
|
55
|
+
label: `fastify ${fastifyVersion}`,
|
|
56
|
+
detail: "required: ^5.0.0 — Arc requires Fastify 5"
|
|
57
|
+
});
|
|
58
|
+
} else results.push({
|
|
59
|
+
status: "fail",
|
|
60
|
+
label: "fastify not found in dependencies",
|
|
61
|
+
detail: "required: ^5.0.0"
|
|
62
|
+
});
|
|
63
|
+
const tsconfigPath = resolve(cwd, "tsconfig.json");
|
|
64
|
+
if (existsSync(tsconfigPath)) try {
|
|
65
|
+
const stripped = readFileSync(tsconfigPath, "utf-8").replace(/\/\/.*$/gm, "");
|
|
66
|
+
const moduleRes = JSON.parse(stripped)?.compilerOptions?.moduleResolution;
|
|
67
|
+
if (moduleRes && ![
|
|
68
|
+
"nodenext",
|
|
69
|
+
"node16",
|
|
70
|
+
"bundler"
|
|
71
|
+
].includes(moduleRes.toLowerCase())) results.push({
|
|
72
|
+
status: "warn",
|
|
73
|
+
label: "tsconfig.json found",
|
|
74
|
+
detail: `moduleResolution "${moduleRes}" — recommend "NodeNext" or "Bundler"`
|
|
75
|
+
});
|
|
76
|
+
else results.push({
|
|
77
|
+
status: "pass",
|
|
78
|
+
label: "tsconfig.json found"
|
|
79
|
+
});
|
|
80
|
+
} catch {
|
|
81
|
+
results.push({
|
|
82
|
+
status: "pass",
|
|
83
|
+
label: "tsconfig.json found"
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else results.push({
|
|
87
|
+
status: "warn",
|
|
88
|
+
label: "tsconfig.json not found"
|
|
89
|
+
});
|
|
90
|
+
for (const dep of [
|
|
91
|
+
{
|
|
92
|
+
name: "@fastify/rate-limit",
|
|
93
|
+
purpose: "rate limiting"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "@fastify/helmet",
|
|
97
|
+
purpose: "security headers"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "@fastify/cors",
|
|
101
|
+
purpose: "CORS support"
|
|
102
|
+
}
|
|
103
|
+
]) if (allDeps[dep.name]) results.push({
|
|
104
|
+
status: "pass",
|
|
105
|
+
label: `${dep.name} installed`
|
|
106
|
+
});
|
|
107
|
+
else results.push({
|
|
108
|
+
status: "warn",
|
|
109
|
+
label: `${dep.name} not installed`,
|
|
110
|
+
detail: `${dep.purpose} disabled`
|
|
111
|
+
});
|
|
112
|
+
if (allDeps["better-auth"]) results.push({
|
|
113
|
+
status: "pass",
|
|
114
|
+
label: `better-auth ${allDeps["better-auth"]}`
|
|
115
|
+
});
|
|
116
|
+
for (const env of [{
|
|
117
|
+
name: "MONGO_URI",
|
|
118
|
+
severity: "warn",
|
|
119
|
+
detail: "required at runtime for MongoDB"
|
|
120
|
+
}, {
|
|
121
|
+
name: "BETTER_AUTH_SECRET",
|
|
122
|
+
severity: "warn",
|
|
123
|
+
detail: "required for Better Auth session encryption"
|
|
124
|
+
}]) if (process.env[env.name]) results.push({
|
|
125
|
+
status: "pass",
|
|
126
|
+
label: `${env.name} set`
|
|
127
|
+
});
|
|
128
|
+
else results.push({
|
|
129
|
+
status: env.severity,
|
|
130
|
+
label: `${env.name} not set`,
|
|
131
|
+
detail: env.detail
|
|
132
|
+
});
|
|
133
|
+
let passCount = 0;
|
|
134
|
+
let warnCount = 0;
|
|
135
|
+
let failCount = 0;
|
|
136
|
+
for (const r of results) {
|
|
137
|
+
const icon = r.status === "pass" ? "[pass]" : r.status === "warn" ? "[warn]" : "[FAIL]";
|
|
138
|
+
const detail = r.detail ? ` (${r.detail})` : "";
|
|
139
|
+
console.log(` ${icon} ${r.label}${detail}`);
|
|
140
|
+
if (r.status === "pass") passCount++;
|
|
141
|
+
else if (r.status === "warn") warnCount++;
|
|
142
|
+
else failCount++;
|
|
143
|
+
}
|
|
144
|
+
console.log(`\n${passCount} passed, ${warnCount} warnings, ${failCount} failures\n`);
|
|
145
|
+
if (failCount > 0) process.exitCode = 1;
|
|
146
|
+
}
|
|
147
|
+
function findPackageJson(dir) {
|
|
148
|
+
const paths = [join(dir, "package.json"), join(dir, "..", "package.json")];
|
|
149
|
+
for (const p of paths) try {
|
|
150
|
+
if (existsSync(p)) return JSON.parse(readFileSync(p, "utf-8"));
|
|
151
|
+
} catch {}
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
export { describe, doctor, exportDocs, generate, init, introspect };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
/**
|
|
3
|
+
* Arc Framework Constants — Single Source of Truth
|
|
4
|
+
*
|
|
5
|
+
* Every default value, magic string, and framework constant lives here.
|
|
6
|
+
* Import from this module instead of hard-coding values inline.
|
|
7
|
+
*
|
|
8
|
+
* All exported values are deeply frozen (Object.freeze) to prevent
|
|
9
|
+
* accidental mutation at runtime — inspired by Go's const blocks
|
|
10
|
+
* and Rust's immutable-by-default philosophy.
|
|
11
|
+
*/
|
|
12
|
+
/** Standard CRUD operation names */
|
|
13
|
+
const CRUD_OPERATIONS = Object.freeze([
|
|
14
|
+
"list",
|
|
15
|
+
"get",
|
|
16
|
+
"create",
|
|
17
|
+
"update",
|
|
18
|
+
"delete"
|
|
19
|
+
]);
|
|
20
|
+
/** Mutation operations that emit events */
|
|
21
|
+
const MUTATION_OPERATIONS = Object.freeze([
|
|
22
|
+
"create",
|
|
23
|
+
"update",
|
|
24
|
+
"delete"
|
|
25
|
+
]);
|
|
26
|
+
/** Lifecycle hook phases */
|
|
27
|
+
const HOOK_PHASES = Object.freeze([
|
|
28
|
+
"before",
|
|
29
|
+
"around",
|
|
30
|
+
"after"
|
|
31
|
+
]);
|
|
32
|
+
/** Hook operations (superset of CRUD — includes 'read' alias for 'get') */
|
|
33
|
+
const HOOK_OPERATIONS = Object.freeze([
|
|
34
|
+
"create",
|
|
35
|
+
"update",
|
|
36
|
+
"delete",
|
|
37
|
+
"read",
|
|
38
|
+
"list"
|
|
39
|
+
]);
|
|
40
|
+
/** Default items per page */
|
|
41
|
+
const DEFAULT_LIMIT = 20;
|
|
42
|
+
/** Maximum items per page (framework-wide ceiling) */
|
|
43
|
+
const DEFAULT_MAX_LIMIT = 1e3;
|
|
44
|
+
/** Default sort field (descending creation date) */
|
|
45
|
+
const DEFAULT_SORT = "-createdAt";
|
|
46
|
+
/** Default primary key field name */
|
|
47
|
+
const DEFAULT_ID_FIELD = "_id";
|
|
48
|
+
/** Default multi-tenant scoping field */
|
|
49
|
+
const DEFAULT_TENANT_FIELD = "organizationId";
|
|
50
|
+
/** Default HTTP method for update routes */
|
|
51
|
+
const DEFAULT_UPDATE_METHOD = "PATCH";
|
|
52
|
+
/** System-managed fields that cannot be set via request body */
|
|
53
|
+
const SYSTEM_FIELDS = Object.freeze([
|
|
54
|
+
"_id",
|
|
55
|
+
"__v",
|
|
56
|
+
"createdAt",
|
|
57
|
+
"updatedAt",
|
|
58
|
+
"deletedAt"
|
|
59
|
+
]);
|
|
60
|
+
/** Maximum regex pattern length (ReDoS mitigation) */
|
|
61
|
+
const MAX_REGEX_LENGTH = 200;
|
|
62
|
+
/** Maximum search query length */
|
|
63
|
+
const MAX_SEARCH_LENGTH = 200;
|
|
64
|
+
/** Maximum filter nesting depth (prevents filter bombs) */
|
|
65
|
+
const MAX_FILTER_DEPTH = 10;
|
|
66
|
+
/**
|
|
67
|
+
* Query parameters consumed by the framework — never treated as filters.
|
|
68
|
+
* Shared by all query parsers (Arc built-in, Prisma, custom).
|
|
69
|
+
*/
|
|
70
|
+
const RESERVED_QUERY_PARAMS = Object.freeze(new Set([
|
|
71
|
+
"page",
|
|
72
|
+
"limit",
|
|
73
|
+
"sort",
|
|
74
|
+
"populate",
|
|
75
|
+
"search",
|
|
76
|
+
"select",
|
|
77
|
+
"after",
|
|
78
|
+
"cursor",
|
|
79
|
+
"lean",
|
|
80
|
+
"_policyFilters"
|
|
81
|
+
]));
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { DEFAULT_SORT as a, HOOK_OPERATIONS as c, MAX_REGEX_LENGTH as d, MAX_SEARCH_LENGTH as f, SYSTEM_FIELDS as h, DEFAULT_MAX_LIMIT as i, HOOK_PHASES as l, RESERVED_QUERY_PARAMS as m, DEFAULT_ID_FIELD as n, DEFAULT_TENANT_FIELD as o, MUTATION_OPERATIONS as p, DEFAULT_LIMIT as r, DEFAULT_UPDATE_METHOD as s, CRUD_OPERATIONS as t, MAX_FILTER_DEPTH as u };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "../elevation-DGo5shaX.mjs";
|
|
2
|
+
import { E as defineResource, T as ResourceDefinition, c as BaseController, d as QueryResolverConfig, f as BodySanitizer, h as AccessControlConfig, l as BaseControllerOptions, m as AccessControl, p as BodySanitizerConfig, u as QueryResolver } from "../interface-e9XfSsUV.mjs";
|
|
3
|
+
import "../types-RLkFVgaw.mjs";
|
|
4
|
+
import { A as createCrudRouter, C as MutationOperation, D as ActionRouterConfig, E as ActionHandler, O as IdempotencyService, S as MUTATION_OPERATIONS, T as SYSTEM_FIELDS, _ as HookOperation, a as getControllerScope, b as MAX_REGEX_LENGTH, c as CrudOperation, d as DEFAULT_MAX_LIMIT, f as DEFAULT_SORT, g as HOOK_PHASES, h as HOOK_OPERATIONS, i as getControllerContext, j as createPermissionMiddleware, k as createActionRouter, l as DEFAULT_ID_FIELD, m as DEFAULT_UPDATE_METHOD, n as createFastifyHandler, o as sendControllerResponse, p as DEFAULT_TENANT_FIELD, r as createRequestContext, s as CRUD_OPERATIONS, t as createCrudHandlers, u as DEFAULT_LIMIT, v as HookPhase, w as RESERVED_QUERY_PARAMS, x as MAX_SEARCH_LENGTH, y as MAX_FILTER_DEPTH } from "../fastifyAdapter-C8DlE0YH.mjs";
|
|
5
|
+
export { AccessControl, type AccessControlConfig, type ActionHandler, type ActionRouterConfig, BaseController, type BaseControllerOptions, BodySanitizer, type BodySanitizerConfig, CRUD_OPERATIONS, CrudOperation, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, HookOperation, HookPhase, type IdempotencyService, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, MutationOperation, QueryResolver, type QueryResolverConfig, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, getControllerContext, getControllerScope, sendControllerResponse };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as DEFAULT_SORT, c as HOOK_OPERATIONS, d as MAX_REGEX_LENGTH, f as MAX_SEARCH_LENGTH, h as SYSTEM_FIELDS, i as DEFAULT_MAX_LIMIT, l as HOOK_PHASES, m as RESERVED_QUERY_PARAMS, n as DEFAULT_ID_FIELD, o as DEFAULT_TENANT_FIELD, p as MUTATION_OPERATIONS, r as DEFAULT_LIMIT, s as DEFAULT_UPDATE_METHOD, t as CRUD_OPERATIONS, u as MAX_FILTER_DEPTH } from "../constants-DdXFXQtN.mjs";
|
|
2
|
+
import { _ as QueryResolver, c as createPermissionMiddleware, d as createFastifyHandler, f as createRequestContext, g as BaseController, h as sendControllerResponse, m as getControllerScope, n as defineResource, o as createActionRouter, p as getControllerContext, s as createCrudRouter, t as ResourceDefinition, u as createCrudHandlers, v as BodySanitizer, y as AccessControl } from "../defineResource-PXzSJ15_.mjs";
|
|
3
|
+
|
|
4
|
+
export { AccessControl, BaseController, BodySanitizer, CRUD_OPERATIONS, DEFAULT_ID_FIELD, DEFAULT_LIMIT, DEFAULT_MAX_LIMIT, DEFAULT_SORT, DEFAULT_TENANT_FIELD, DEFAULT_UPDATE_METHOD, HOOK_OPERATIONS, HOOK_PHASES, MAX_FILTER_DEPTH, MAX_REGEX_LENGTH, MAX_SEARCH_LENGTH, MUTATION_OPERATIONS, QueryResolver, RESERVED_QUERY_PARAMS, ResourceDefinition, SYSTEM_FIELDS, createActionRouter, createCrudHandlers, createCrudRouter, createFastifyHandler, createPermissionMiddleware, createRequestContext, defineResource, getControllerContext, getControllerScope, sendControllerResponse };
|