@warlock.js/core 4.5.0 → 4.6.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.
- package/CHANGELOG.md +27 -0
- package/esm/ai/src/agent/agent.mjs +126 -7
- package/esm/ai/src/agent/agent.mjs.map +1 -1
- package/esm/ai/src/agent/signature.mjs +57 -0
- package/esm/ai/src/agent/signature.mjs.map +1 -0
- package/esm/ai/src/agent/snapshot.mjs +101 -0
- package/esm/ai/src/agent/snapshot.mjs.map +1 -0
- package/esm/ai/src/ai.mjs +37 -1
- package/esm/ai/src/ai.mjs.map +1 -1
- package/esm/ai/src/errors/agent-drift-error.mjs +31 -0
- package/esm/ai/src/errors/agent-drift-error.mjs.map +1 -0
- package/esm/ai/src/errors/index.mjs +2 -0
- package/esm/ai/src/errors/planner-drift-error.mjs +33 -0
- package/esm/ai/src/errors/planner-drift-error.mjs.map +1 -0
- package/esm/ai/src/image/image-cost.mjs +55 -0
- package/esm/ai/src/image/image-cost.mjs.map +1 -0
- package/esm/ai/src/image/image.mjs +112 -0
- package/esm/ai/src/image/image.mjs.map +1 -0
- package/esm/ai/src/image/index.mjs +4 -0
- package/esm/ai/src/index.mjs +20 -0
- package/esm/ai/src/planner/planner-run.mjs +161 -6
- package/esm/ai/src/planner/planner-run.mjs.map +1 -1
- package/esm/ai/src/planner/planner.mjs +25 -1
- package/esm/ai/src/planner/planner.mjs.map +1 -1
- package/esm/ai/src/planner/snapshot.mjs +95 -0
- package/esm/ai/src/planner/snapshot.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/bm25.mjs +51 -0
- package/esm/ai/src/rag/hybrid/bm25.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +29 -0
- package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +1 -0
- package/esm/ai/src/rag/hybrid/rrf.mjs +30 -0
- package/esm/ai/src/rag/hybrid/rrf.mjs.map +1 -0
- package/esm/ai/src/rag/index.mjs +11 -0
- package/esm/ai/src/rag/loaders/errors.mjs +25 -0
- package/esm/ai/src/rag/loaders/errors.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/index.mjs +7 -0
- package/esm/ai/src/rag/loaders/load-html.mjs +138 -0
- package/esm/ai/src/rag/loaders/load-html.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-pdf.mjs +150 -0
- package/esm/ai/src/rag/loaders/load-pdf.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-text.mjs +60 -0
- package/esm/ai/src/rag/loaders/load-text.mjs.map +1 -0
- package/esm/ai/src/rag/loaders/load-web.mjs +89 -0
- package/esm/ai/src/rag/loaders/load-web.mjs.map +1 -0
- package/esm/ai/src/rag/store/pg-vector-store.mjs +328 -0
- package/esm/ai/src/rag/store/pg-vector-store.mjs.map +1 -0
- package/esm/ai/src/rag/transforms/multi-query.mjs +41 -0
- package/esm/ai/src/rag/transforms/multi-query.mjs.map +1 -0
- package/esm/ai/src/speech/index.mjs +3 -0
- package/esm/ai/src/speech/speech.mjs +122 -0
- package/esm/ai/src/speech/speech.mjs.map +1 -0
- package/esm/ai/src/supervisor/entries.mjs +2 -2
- package/esm/ai/src/supervisor/entries.mjs.map +1 -1
- package/esm/ai/src/transcribe/audio-input.mjs +84 -0
- package/esm/ai/src/transcribe/audio-input.mjs.map +1 -0
- package/esm/ai/src/transcribe/index.mjs +4 -0
- package/esm/ai/src/transcribe/transcribe.mjs +127 -0
- package/esm/ai/src/transcribe/transcribe.mjs.map +1 -0
- package/esm/ai-openai/src/image.mjs +5 -0
- package/esm/ai-openai/src/index.mjs +3 -0
- package/esm/ai-openai/src/sdk.mjs +3 -0
- package/esm/ai-openai/src/speech.mjs +5 -0
- package/esm/ai-openai/src/transcription.mjs +6 -0
- package/esm/ai-openai/src/utils/index.mjs +1 -0
- package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
- package/esm/cli/commands/doctor/checks/config.check.mjs +42 -0
- package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/connectors.check.mjs +28 -0
- package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/health.check.mjs +35 -0
- package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/index.mjs +25 -0
- package/esm/cli/commands/doctor/checks/index.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +90 -0
- package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +69 -0
- package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/checks/routes.check.mjs +30 -0
- package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -0
- package/esm/cli/commands/doctor/doctor-command.action.mjs +28 -0
- package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -0
- package/esm/cli/commands/doctor/format-report.mjs +44 -0
- package/esm/cli/commands/doctor/format-report.mjs.map +1 -0
- package/esm/cli/commands/doctor/run-checks.mjs +50 -0
- package/esm/cli/commands/doctor/run-checks.mjs.map +1 -0
- package/esm/cli/commands/doctor.command.mjs +29 -0
- package/esm/cli/commands/doctor.command.mjs.map +1 -0
- package/esm/cli/commands/generate/templates/stubs.mjs +6 -8
- package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
- package/esm/cli/commands/routes/format-routes-table.mjs +129 -0
- package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -0
- package/esm/cli/commands/routes/route-row.mjs +92 -0
- package/esm/cli/commands/routes/route-row.mjs.map +1 -0
- package/esm/cli/commands/routes/routes-command.action.mjs +43 -0
- package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -0
- package/esm/cli/commands/routes.command.mjs +51 -0
- package/esm/cli/commands/routes.command.mjs.map +1 -0
- package/esm/cli/commands/seed.command.mjs +5 -0
- package/esm/cli/commands/seed.command.mjs.map +1 -1
- package/esm/cli/framework-cli-commands.mjs +4 -0
- package/esm/cli/framework-cli-commands.mjs.map +1 -1
- package/esm/config/config-getter.mjs +5 -5
- package/esm/config/config-getter.mjs.map +1 -1
- package/esm/config/config-loader.mjs +2 -2
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/connectors/access-connector.mjs +2 -2
- package/esm/connectors/access-connector.mjs.map +1 -1
- package/esm/connectors/ai-connector.mjs +2 -2
- package/esm/connectors/ai-connector.mjs.map +1 -1
- package/esm/connectors/cache-connector.mjs +2 -2
- package/esm/connectors/cache-connector.mjs.map +1 -1
- package/esm/connectors/database-connector.mjs +2 -2
- package/esm/connectors/database-connector.mjs.map +1 -1
- package/esm/connectors/herald-connector.mjs +2 -2
- package/esm/connectors/herald-connector.mjs.map +1 -1
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +9 -7
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/logger-connector.mjs +2 -2
- package/esm/connectors/logger-connector.mjs.map +1 -1
- package/esm/connectors/mail-connector.mjs +2 -2
- package/esm/connectors/mail-connector.mjs.map +1 -1
- package/esm/connectors/notifications-connector.mjs +2 -2
- package/esm/connectors/notifications-connector.mjs.map +1 -1
- package/esm/connectors/socket-connector.mjs +3 -3
- package/esm/connectors/socket-connector.mjs.map +1 -1
- package/esm/database/index.d.mts +2 -1
- package/esm/database/index.mjs +1 -0
- package/esm/database/seed-command-action.mjs +44 -4
- package/esm/database/seed-command-action.mjs.map +1 -1
- package/esm/database/seeds/seed-records-table-migration.mjs +36 -0
- package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -0
- package/esm/database/seeds/seeder.d.mts +22 -5
- package/esm/database/seeds/seeder.d.mts.map +1 -1
- package/esm/database/seeds/seeder.errors.d.mts +22 -0
- package/esm/database/seeds/seeder.errors.d.mts.map +1 -0
- package/esm/database/seeds/seeder.errors.mjs +29 -0
- package/esm/database/seeds/seeder.errors.mjs.map +1 -0
- package/esm/database/seeds/seeder.mjs.map +1 -1
- package/esm/database/seeds/seeders.manager.mjs +90 -11
- package/esm/database/seeds/seeders.manager.mjs.map +1 -1
- package/esm/database/seeds/types.d.mts +117 -1
- package/esm/database/seeds/types.d.mts.map +1 -1
- package/esm/database/seeds/utils.mjs +6 -1
- package/esm/database/seeds/utils.mjs.map +1 -1
- package/esm/dev-server/module-loader.d.mts +12 -0
- package/esm/dev-server/module-loader.d.mts.map +1 -1
- package/esm/dev-server/module-loader.mjs +30 -2
- package/esm/dev-server/module-loader.mjs.map +1 -1
- package/esm/http/config.mjs +2 -2
- package/esm/http/config.mjs.map +1 -1
- package/esm/http/createHttpApplication.mjs +2 -2
- package/esm/http/createHttpApplication.mjs.map +1 -1
- package/esm/http/health.d.mts +14 -0
- package/esm/http/health.d.mts.map +1 -1
- package/esm/http/health.mjs +16 -0
- package/esm/http/health.mjs.map +1 -1
- package/esm/http/middleware/idempotency.middleware.mjs +5 -5
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +2 -2
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs +4 -4
- package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
- package/esm/http/plugins.mjs +9 -9
- package/esm/http/plugins.mjs.map +1 -1
- package/esm/http/response.mjs +5 -5
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server.mjs +4 -4
- package/esm/http/server.mjs.map +1 -1
- package/esm/index.d.mts +4 -3
- package/esm/index.mjs +2 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +28 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +39 -0
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
- package/esm/repositories/contracts/index.d.mts +1 -1
- package/esm/repositories/contracts/query-builder.contract.d.mts +87 -1
- package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
- package/esm/repositories/index.d.mts +1 -1
- package/esm/repositories/repository.manager.d.mts +99 -1
- package/esm/repositories/repository.manager.d.mts.map +1 -1
- package/esm/repositories/repository.manager.mjs +128 -0
- package/esm/repositories/repository.manager.mjs.map +1 -1
- package/esm/router/router.d.mts +9 -0
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +21 -1
- package/esm/router/router.mjs.map +1 -1
- package/esm/utils/paths.mjs +2 -2
- package/esm/utils/paths.mjs.map +1 -1
- package/esm/validation/validateAll.mjs +2 -2
- package/esm/validation/validateAll.mjs.map +1 -1
- package/llms-full.txt +427 -45
- package/llms.txt +4 -2
- package/package.json +9 -9
- package/skills/README.md +65 -0
- package/skills/health-checks/SKILL.md +13 -0
- package/skills/use-repository/SKILL.md +38 -1
- package/skills/warlock-doctor/SKILL.md +135 -0
- package/skills/warlock-routes/SKILL.md +91 -0
- package/skills/write-seeder/SKILL.md +143 -45
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { methodRank } from "./route-row.mjs";
|
|
2
|
+
import { colors } from "@mongez/copper";
|
|
3
|
+
|
|
4
|
+
//#region ../@warlock.js/core/src/cli/commands/routes/format-routes-table.ts
|
|
5
|
+
/** The columns rendered, in order, with their header labels. */
|
|
6
|
+
const COLUMNS = [
|
|
7
|
+
{
|
|
8
|
+
key: "method",
|
|
9
|
+
header: "METHOD"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: "path",
|
|
13
|
+
header: "PATH"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: "name",
|
|
17
|
+
header: "NAME"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "action",
|
|
21
|
+
header: "ACTION"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "middleware",
|
|
25
|
+
header: "MW"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: "source",
|
|
29
|
+
header: "SOURCE"
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
/** Two spaces between columns. */
|
|
33
|
+
const GAP = " ";
|
|
34
|
+
/** Shown for an empty string cell so the column doesn't read as a gap. */
|
|
35
|
+
const EMPTY_CELL = "—";
|
|
36
|
+
/**
|
|
37
|
+
* The plain (uncolored) text of one cell. Numbers render as-is; an empty string
|
|
38
|
+
* renders as {@link EMPTY_CELL}. This is the single source of truth for both
|
|
39
|
+
* the width math and the rendered text, so colored and uncolored output stay
|
|
40
|
+
* aligned.
|
|
41
|
+
*
|
|
42
|
+
* @param row - The row
|
|
43
|
+
* @param key - The column key
|
|
44
|
+
* @returns The cell's printable text
|
|
45
|
+
*/
|
|
46
|
+
function cellText(row, key) {
|
|
47
|
+
if (key === "middleware") return String(row.middleware);
|
|
48
|
+
const value = row[key];
|
|
49
|
+
return value.length > 0 ? value : EMPTY_CELL;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Per-column display width: the longest of the header and every cell.
|
|
53
|
+
*
|
|
54
|
+
* @param rows - The rows to measure
|
|
55
|
+
* @returns One width per column, in column order
|
|
56
|
+
*/
|
|
57
|
+
function columnWidths(rows) {
|
|
58
|
+
return COLUMNS.map((column) => Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a one-line, human-readable summary: the total plus a per-method
|
|
62
|
+
* breakdown ordered by {@link methodRank}, e.g.
|
|
63
|
+
* `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.
|
|
64
|
+
*
|
|
65
|
+
* @param rows - The rows being summarized
|
|
66
|
+
* @returns The summary line
|
|
67
|
+
*/
|
|
68
|
+
function routesSummary(rows) {
|
|
69
|
+
const noun = rows.length === 1 ? "route" : "routes";
|
|
70
|
+
if (rows.length === 0) return `0 ${noun}`;
|
|
71
|
+
const counts = /* @__PURE__ */ new Map();
|
|
72
|
+
for (const row of rows) counts.set(row.method, (counts.get(row.method) ?? 0) + 1);
|
|
73
|
+
const breakdown = [...counts.entries()].sort(([a], [b]) => methodRank(a) - methodRank(b)).map(([method, count]) => `${count} ${method}`).join(" · ");
|
|
74
|
+
return `${rows.length} ${noun} (${breakdown})`;
|
|
75
|
+
}
|
|
76
|
+
/** Per-verb color for the METHOD column. Unknown verbs fall back to white. */
|
|
77
|
+
const METHOD_COLOR = {
|
|
78
|
+
GET: colors.green,
|
|
79
|
+
POST: colors.blue,
|
|
80
|
+
PUT: colors.yellow,
|
|
81
|
+
PATCH: colors.yellow,
|
|
82
|
+
DELETE: colors.red,
|
|
83
|
+
OPTIONS: colors.gray,
|
|
84
|
+
HEAD: colors.gray,
|
|
85
|
+
ALL: colors.magenta
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Colorize the method label, then right-pad with plain spaces so column
|
|
89
|
+
* alignment is computed from the visible width, not the ANSI-coded length.
|
|
90
|
+
*
|
|
91
|
+
* @param method - The uppercased HTTP verb
|
|
92
|
+
* @param width - The METHOD column width
|
|
93
|
+
* @returns The colored, padded cell
|
|
94
|
+
*/
|
|
95
|
+
function colorizeMethodCell(method, width) {
|
|
96
|
+
return (METHOD_COLOR[method] ?? colors.white)(method) + " ".repeat(Math.max(0, width - method.length));
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Print the routes table to stdout with a bold header, verb-colored METHOD
|
|
100
|
+
* column, and a dimmed summary. The empty case prints a single yellow notice
|
|
101
|
+
* (a booted app with zero routes usually means a route module failed to load).
|
|
102
|
+
*
|
|
103
|
+
* Thin presentation wrapper over {@link formatRoutesTableLines} /
|
|
104
|
+
* {@link routesSummary} — those stay the source of truth for layout.
|
|
105
|
+
*
|
|
106
|
+
* @param rows - The rows to print (already filtered/sorted by the caller)
|
|
107
|
+
*/
|
|
108
|
+
function printRoutesTable(rows) {
|
|
109
|
+
if (rows.length === 0) {
|
|
110
|
+
console.log(colors.yellow("No routes registered — did a route module fail to load?"));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const widths = columnWidths(rows);
|
|
114
|
+
const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index])).join(GAP).trimEnd();
|
|
115
|
+
console.log(colors.bold(headerLine));
|
|
116
|
+
for (const row of rows) {
|
|
117
|
+
const cells = COLUMNS.map((column, index) => {
|
|
118
|
+
if (column.key === "method") return colorizeMethodCell(row.method, widths[index]);
|
|
119
|
+
return cellText(row, column.key).padEnd(widths[index]);
|
|
120
|
+
});
|
|
121
|
+
console.log(cells.join(GAP).trimEnd());
|
|
122
|
+
}
|
|
123
|
+
console.log("");
|
|
124
|
+
console.log(colors.gray(routesSummary(rows)));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { printRoutesTable };
|
|
129
|
+
//# sourceMappingURL=format-routes-table.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-routes-table.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/format-routes-table.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { methodRank, type RouteRow } from \"./route-row\";\n\n/** The columns rendered, in order, with their header labels. */\nconst COLUMNS = [\n { key: \"method\", header: \"METHOD\" },\n { key: \"path\", header: \"PATH\" },\n { key: \"name\", header: \"NAME\" },\n { key: \"action\", header: \"ACTION\" },\n { key: \"middleware\", header: \"MW\" },\n { key: \"source\", header: \"SOURCE\" },\n] as const;\n\ntype ColumnKey = (typeof COLUMNS)[number][\"key\"];\n\n/** Two spaces between columns. */\nconst GAP = \" \";\n\n/** Shown for an empty string cell so the column doesn't read as a gap. */\nconst EMPTY_CELL = \"—\";\n\n/**\n * The plain (uncolored) text of one cell. Numbers render as-is; an empty string\n * renders as {@link EMPTY_CELL}. This is the single source of truth for both\n * the width math and the rendered text, so colored and uncolored output stay\n * aligned.\n *\n * @param row - The row\n * @param key - The column key\n * @returns The cell's printable text\n */\nfunction cellText(row: RouteRow, key: ColumnKey): string {\n if (key === \"middleware\") return String(row.middleware);\n\n const value = row[key] as string;\n\n return value.length > 0 ? value : EMPTY_CELL;\n}\n\n/**\n * Per-column display width: the longest of the header and every cell.\n *\n * @param rows - The rows to measure\n * @returns One width per column, in column order\n */\nfunction columnWidths(rows: RouteRow[]): number[] {\n return COLUMNS.map((column) =>\n Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)),\n );\n}\n\n/**\n * Build a one-line, human-readable summary: the total plus a per-method\n * breakdown ordered by {@link methodRank}, e.g.\n * `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.\n *\n * @param rows - The rows being summarized\n * @returns The summary line\n */\nexport function routesSummary(rows: RouteRow[]): string {\n const noun = rows.length === 1 ? \"route\" : \"routes\";\n\n if (rows.length === 0) return `0 ${noun}`;\n\n const counts = new Map<string, number>();\n\n for (const row of rows) {\n counts.set(row.method, (counts.get(row.method) ?? 0) + 1);\n }\n\n const breakdown = [...counts.entries()]\n .sort(([a], [b]) => methodRank(a) - methodRank(b))\n .map(([method, count]) => `${count} ${method}`)\n .join(\" · \");\n\n return `${rows.length} ${noun} (${breakdown})`;\n}\n\n/**\n * Render the routes table as an ordered list of plain (uncolored) lines:\n * a header row, one row per route, a blank line, then the summary. Returned as\n * strings (not printed) so the layout is unit-testable without ANSI noise.\n *\n * @param rows - The rows to render (already filtered/sorted by the caller)\n * @returns The lines to print, top to bottom\n */\nexport function formatRoutesTableLines(rows: RouteRow[]): string[] {\n if (rows.length === 0) {\n return [\"No routes registered.\"];\n }\n\n const widths = columnWidths(rows);\n\n const renderRow = (cells: string[]) =>\n cells.map((text, index) => text.padEnd(widths[index])).join(GAP).trimEnd();\n\n const lines = [renderRow(COLUMNS.map((column) => column.header))];\n\n for (const row of rows) {\n lines.push(renderRow(COLUMNS.map((column) => cellText(row, column.key))));\n }\n\n lines.push(\"\");\n lines.push(routesSummary(rows));\n\n return lines;\n}\n\n/** Per-verb color for the METHOD column. Unknown verbs fall back to white. */\nconst METHOD_COLOR: Record<string, (input: string) => string> = {\n GET: colors.green,\n POST: colors.blue,\n PUT: colors.yellow,\n PATCH: colors.yellow,\n DELETE: colors.red,\n OPTIONS: colors.gray,\n HEAD: colors.gray,\n ALL: colors.magenta,\n};\n\n/**\n * Colorize the method label, then right-pad with plain spaces so column\n * alignment is computed from the visible width, not the ANSI-coded length.\n *\n * @param method - The uppercased HTTP verb\n * @param width - The METHOD column width\n * @returns The colored, padded cell\n */\nfunction colorizeMethodCell(method: string, width: number): string {\n const colorize = METHOD_COLOR[method] ?? colors.white;\n\n return colorize(method) + \" \".repeat(Math.max(0, width - method.length));\n}\n\n/**\n * Print the routes table to stdout with a bold header, verb-colored METHOD\n * column, and a dimmed summary. The empty case prints a single yellow notice\n * (a booted app with zero routes usually means a route module failed to load).\n *\n * Thin presentation wrapper over {@link formatRoutesTableLines} /\n * {@link routesSummary} — those stay the source of truth for layout.\n *\n * @param rows - The rows to print (already filtered/sorted by the caller)\n */\nexport function printRoutesTable(rows: RouteRow[]): void {\n if (rows.length === 0) {\n console.log(colors.yellow(\"No routes registered — did a route module fail to load?\"));\n return;\n }\n\n const widths = columnWidths(rows);\n\n const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index]))\n .join(GAP)\n .trimEnd();\n\n console.log(colors.bold(headerLine));\n\n for (const row of rows) {\n const cells = COLUMNS.map((column, index) => {\n if (column.key === \"method\") {\n return colorizeMethodCell(row.method, widths[index]);\n }\n\n return cellText(row, column.key).padEnd(widths[index]);\n });\n\n console.log(cells.join(GAP).trimEnd());\n }\n\n console.log(\"\");\n console.log(colors.gray(routesSummary(rows)));\n}\n"],"mappings":";;;;;AAIA,MAAM,UAAU;CACd;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAc,QAAQ;CAAK;CAClC;EAAE,KAAK;EAAU,QAAQ;CAAS;AACpC;;AAKA,MAAM,MAAM;;AAGZ,MAAM,aAAa;;;;;;;;;;;AAYnB,SAAS,SAAS,KAAe,KAAwB;CACvD,IAAI,QAAQ,cAAc,OAAO,OAAO,IAAI,UAAU;CAEtD,MAAM,QAAQ,IAAI;CAElB,OAAO,MAAM,SAAS,IAAI,QAAQ;AACpC;;;;;;;AAQA,SAAS,aAAa,MAA4B;CAChD,OAAO,QAAQ,KAAK,WAClB,KAAK,IAAI,OAAO,OAAO,QAAQ,GAAG,KAAK,KAAK,QAAQ,SAAS,KAAK,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,CACvF;AACF;;;;;;;;;AAUA,SAAgB,cAAc,MAA0B;CACtD,MAAM,OAAO,KAAK,WAAW,IAAI,UAAU;CAE3C,IAAI,KAAK,WAAW,GAAG,OAAO,KAAK;CAEnC,MAAM,yBAAS,IAAI,IAAoB;CAEvC,KAAK,MAAM,OAAO,MAChB,OAAO,IAAI,IAAI,SAAS,OAAO,IAAI,IAAI,MAAM,KAAK,KAAK,CAAC;CAG1D,MAAM,YAAY,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC,CACpC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CACjD,KAAK,CAAC,QAAQ,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC,CAC9C,KAAK,KAAK;CAEb,OAAO,GAAG,KAAK,OAAO,GAAG,KAAK,IAAI,UAAU;AAC9C;;AAiCA,MAAM,eAA0D;CAC9D,KAAK,OAAO;CACZ,MAAM,OAAO;CACb,KAAK,OAAO;CACZ,OAAO,OAAO;CACd,QAAQ,OAAO;CACf,SAAS,OAAO;CAChB,MAAM,OAAO;CACb,KAAK,OAAO;AACd;;;;;;;;;AAUA,SAAS,mBAAmB,QAAgB,OAAuB;CAGjE,QAFiB,aAAa,WAAW,OAAO,MAEjC,CAAC,MAAM,IAAI,IAAI,OAAO,KAAK,IAAI,GAAG,QAAQ,OAAO,MAAM,CAAC;AACzE;;;;;;;;;;;AAYA,SAAgB,iBAAiB,MAAwB;CACvD,IAAI,KAAK,WAAW,GAAG;EACrB,QAAQ,IAAI,OAAO,OAAO,yDAAyD,CAAC;EACpF;CACF;CAEA,MAAM,SAAS,aAAa,IAAI;CAEhC,MAAM,aAAa,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO,OAAO,OAAO,MAAM,CAAC,CAAC,CACnF,KAAK,GAAG,CAAC,CACT,QAAQ;CAEX,QAAQ,IAAI,OAAO,KAAK,UAAU,CAAC;CAEnC,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,QAAQ,KAAK,QAAQ,UAAU;GAC3C,IAAI,OAAO,QAAQ,UACjB,OAAO,mBAAmB,IAAI,QAAQ,OAAO,MAAM;GAGrD,OAAO,SAAS,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO,OAAO,MAAM;EACvD,CAAC;EAED,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC;CACvC;CAEA,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,OAAO,KAAK,cAAc,IAAI,CAAC,CAAC;AAC9C"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region ../@warlock.js/core/src/cli/commands/routes/route-row.ts
|
|
2
|
+
/**
|
|
3
|
+
* Display order of HTTP methods — used to rank rows within a path and to order
|
|
4
|
+
* the per-method breakdown in the summary line.
|
|
5
|
+
*/
|
|
6
|
+
const METHOD_ORDER = [
|
|
7
|
+
"GET",
|
|
8
|
+
"POST",
|
|
9
|
+
"PUT",
|
|
10
|
+
"PATCH",
|
|
11
|
+
"DELETE",
|
|
12
|
+
"OPTIONS",
|
|
13
|
+
"HEAD",
|
|
14
|
+
"ALL"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* Rank of a method for sorting. Unknown methods sort last (stable among
|
|
18
|
+
* themselves).
|
|
19
|
+
*
|
|
20
|
+
* @param method - Uppercased HTTP verb
|
|
21
|
+
* @returns The sort index
|
|
22
|
+
*/
|
|
23
|
+
function methodRank(method) {
|
|
24
|
+
const index = METHOD_ORDER.indexOf(method);
|
|
25
|
+
return index === -1 ? METHOD_ORDER.length : index;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derive the handler/controller-action label for a route. Uses the handler
|
|
29
|
+
* function's name, stripping the `bound ` prefix that `Function.prototype.bind`
|
|
30
|
+
* prepends, and falls back to `"anonymous"` for an unnamed handler.
|
|
31
|
+
*
|
|
32
|
+
* @param route - The route to label
|
|
33
|
+
* @returns A printable action label
|
|
34
|
+
*/
|
|
35
|
+
function routeAction(route) {
|
|
36
|
+
const handler = route.handler;
|
|
37
|
+
if (typeof handler !== "function") return "anonymous";
|
|
38
|
+
const name = handler.name?.replace(/^bound /, "").trim();
|
|
39
|
+
return name ? name : "anonymous";
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a live {@link Route} into a printable {@link RouteRow}.
|
|
43
|
+
*
|
|
44
|
+
* @param route - The registered route
|
|
45
|
+
* @returns The display-ready row
|
|
46
|
+
*/
|
|
47
|
+
function toRouteRow(route) {
|
|
48
|
+
return {
|
|
49
|
+
method: route.method.toUpperCase(),
|
|
50
|
+
path: route.path,
|
|
51
|
+
name: route.name ?? "",
|
|
52
|
+
action: routeAction(route),
|
|
53
|
+
middleware: route.middleware?.length ?? 0,
|
|
54
|
+
source: route.sourceFile ?? ""
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Apply the `--method` / `--path` / `--name` filters to a set of rows. An
|
|
59
|
+
* omitted filter matches everything; provided filters are AND-ed.
|
|
60
|
+
*
|
|
61
|
+
* @param rows - The rows to filter
|
|
62
|
+
* @param filter - The active filters
|
|
63
|
+
* @returns The matching rows (a new array)
|
|
64
|
+
*/
|
|
65
|
+
function filterRouteRows(rows, filter) {
|
|
66
|
+
const method = filter.method?.toUpperCase();
|
|
67
|
+
const path = filter.path?.toLowerCase();
|
|
68
|
+
const name = filter.name?.toLowerCase();
|
|
69
|
+
return rows.filter((row) => {
|
|
70
|
+
if (method && row.method !== method) return false;
|
|
71
|
+
if (path && !row.path.toLowerCase().includes(path)) return false;
|
|
72
|
+
if (name && !row.name.toLowerCase().includes(name)) return false;
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Sort rows by path (ascending), then by HTTP-method order within a path, so
|
|
78
|
+
* every verb of one resource lists together in a predictable sequence.
|
|
79
|
+
*
|
|
80
|
+
* @param rows - The rows to sort
|
|
81
|
+
* @returns A new, sorted array
|
|
82
|
+
*/
|
|
83
|
+
function sortRouteRows(rows) {
|
|
84
|
+
return [...rows].sort((a, b) => {
|
|
85
|
+
if (a.path !== b.path) return a.path < b.path ? -1 : 1;
|
|
86
|
+
return methodRank(a.method) - methodRank(b.method);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { filterRouteRows, methodRank, sortRouteRows, toRouteRow };
|
|
92
|
+
//# sourceMappingURL=route-row.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-row.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/route-row.ts"],"sourcesContent":["import type { Route } from \"../../../router/types\";\n\n/**\n * A single registered route, normalized to the flat, display-ready shape the\n * `warlock routes` table (and its `--json` output) render. Kept separate from\n * the live {@link Route} so the formatter and filters never touch the handler\n * function, validation object, or Fastify server options — only printable\n * scalars.\n */\nexport type RouteRow = {\n /** Uppercased HTTP verb (`\"all\"` → `\"ALL\"`). */\n method: string;\n\n /** Full request path (prefix already folded in by the router). */\n path: string;\n\n /** Route name, or `\"\"` when the route was registered without one. */\n name: string;\n\n /** Handler/controller-action label — the handler function name, or `\"anonymous\"`. */\n action: string;\n\n /** Number of middleware attached to the route. */\n middleware: number;\n\n /** Relative source file the route was registered from, or `\"\"`. */\n source: string;\n};\n\n/** Filters accepted by `warlock routes`, each optional and additive (AND-ed). */\nexport type RouteFilter = {\n /** Exact HTTP method (case-insensitive). */\n method?: string;\n\n /** Case-insensitive substring matched against the path. */\n path?: string;\n\n /** Case-insensitive substring matched against the route name. */\n name?: string;\n};\n\n/**\n * Display order of HTTP methods — used to rank rows within a path and to order\n * the per-method breakdown in the summary line.\n */\nexport const METHOD_ORDER = [\n \"GET\",\n \"POST\",\n \"PUT\",\n \"PATCH\",\n \"DELETE\",\n \"OPTIONS\",\n \"HEAD\",\n \"ALL\",\n];\n\n/**\n * Rank of a method for sorting. Unknown methods sort last (stable among\n * themselves).\n *\n * @param method - Uppercased HTTP verb\n * @returns The sort index\n */\nexport function methodRank(method: string): number {\n const index = METHOD_ORDER.indexOf(method);\n return index === -1 ? METHOD_ORDER.length : index;\n}\n\n/**\n * Derive the handler/controller-action label for a route. Uses the handler\n * function's name, stripping the `bound ` prefix that `Function.prototype.bind`\n * prepends, and falls back to `\"anonymous\"` for an unnamed handler.\n *\n * @param route - The route to label\n * @returns A printable action label\n */\nfunction routeAction(route: Route): string {\n const handler = route.handler as unknown;\n\n if (typeof handler !== \"function\") return \"anonymous\";\n\n const name = handler.name?.replace(/^bound /, \"\").trim();\n\n return name ? name : \"anonymous\";\n}\n\n/**\n * Normalize a live {@link Route} into a printable {@link RouteRow}.\n *\n * @param route - The registered route\n * @returns The display-ready row\n */\nexport function toRouteRow(route: Route): RouteRow {\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name ?? \"\",\n action: routeAction(route),\n middleware: route.middleware?.length ?? 0,\n source: route.sourceFile ?? \"\",\n };\n}\n\n/**\n * Apply the `--method` / `--path` / `--name` filters to a set of rows. An\n * omitted filter matches everything; provided filters are AND-ed.\n *\n * @param rows - The rows to filter\n * @param filter - The active filters\n * @returns The matching rows (a new array)\n */\nexport function filterRouteRows(rows: RouteRow[], filter: RouteFilter): RouteRow[] {\n const method = filter.method?.toUpperCase();\n const path = filter.path?.toLowerCase();\n const name = filter.name?.toLowerCase();\n\n return rows.filter((row) => {\n if (method && row.method !== method) return false;\n if (path && !row.path.toLowerCase().includes(path)) return false;\n if (name && !row.name.toLowerCase().includes(name)) return false;\n return true;\n });\n}\n\n/**\n * Sort rows by path (ascending), then by HTTP-method order within a path, so\n * every verb of one resource lists together in a predictable sequence.\n *\n * @param rows - The rows to sort\n * @returns A new, sorted array\n */\nexport function sortRouteRows(rows: RouteRow[]): RouteRow[] {\n return [...rows].sort((a, b) => {\n if (a.path !== b.path) return a.path < b.path ? -1 : 1;\n return methodRank(a.method) - methodRank(b.method);\n });\n}\n"],"mappings":";;;;;AA6CA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,WAAW,QAAwB;CACjD,MAAM,QAAQ,aAAa,QAAQ,MAAM;CACzC,OAAO,UAAU,KAAK,aAAa,SAAS;AAC9C;;;;;;;;;AAUA,SAAS,YAAY,OAAsB;CACzC,MAAM,UAAU,MAAM;CAEtB,IAAI,OAAO,YAAY,YAAY,OAAO;CAE1C,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,EAAE,CAAC,CAAC,KAAK;CAEvD,OAAO,OAAO,OAAO;AACvB;;;;;;;AAQA,SAAgB,WAAW,OAAwB;CACjD,OAAO;EACL,QAAQ,MAAM,OAAO,YAAY;EACjC,MAAM,MAAM;EACZ,MAAM,MAAM,QAAQ;EACpB,QAAQ,YAAY,KAAK;EACzB,YAAY,MAAM,YAAY,UAAU;EACxC,QAAQ,MAAM,cAAc;CAC9B;AACF;;;;;;;;;AAUA,SAAgB,gBAAgB,MAAkB,QAAiC;CACjF,MAAM,SAAS,OAAO,QAAQ,YAAY;CAC1C,MAAM,OAAO,OAAO,MAAM,YAAY;CACtC,MAAM,OAAO,OAAO,MAAM,YAAY;CAEtC,OAAO,KAAK,QAAQ,QAAQ;EAC1B,IAAI,UAAU,IAAI,WAAW,QAAQ,OAAO;EAC5C,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,OAAO;CACT,CAAC;AACH;;;;;;;;AASA,SAAgB,cAAc,MAA8B;CAC1D,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;EAC9B,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK;EACrD,OAAO,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM;CACnD,CAAC;AACH"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { router } from "../../../router/router.mjs";
|
|
2
|
+
import { filterRouteRows, sortRouteRows, toRouteRow } from "./route-row.mjs";
|
|
3
|
+
import { printRoutesTable } from "./format-routes-table.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../@warlock.js/core/src/cli/commands/routes/routes-command.action.ts
|
|
6
|
+
/**
|
|
7
|
+
* Read the active option as a trimmed string, or `undefined` when it is absent
|
|
8
|
+
* or not a string (a bare boolean flag).
|
|
9
|
+
*
|
|
10
|
+
* @param value - The parsed option value
|
|
11
|
+
* @returns The string value, or `undefined`
|
|
12
|
+
*/
|
|
13
|
+
function stringOption(value) {
|
|
14
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Action behind `warlock routes`. Reads the registered routes from the router
|
|
18
|
+
* singleton (populated by the `bootstrap` preload, with no connectors started),
|
|
19
|
+
* applies the `--method` / `--path` / `--name` filters, sorts them, and either
|
|
20
|
+
* prints a verb-colored table or — with `--json` — emits the normalized rows as
|
|
21
|
+
* JSON for piping into scripts/CI.
|
|
22
|
+
*
|
|
23
|
+
* Read-only: it never opens a database/cache/socket connection and never
|
|
24
|
+
* mutates the router.
|
|
25
|
+
*
|
|
26
|
+
* @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).
|
|
27
|
+
*/
|
|
28
|
+
function routesCommandAction({ options }) {
|
|
29
|
+
const rows = sortRouteRows(filterRouteRows(router.list().map(toRouteRow), {
|
|
30
|
+
method: stringOption(options.method),
|
|
31
|
+
path: stringOption(options.path),
|
|
32
|
+
name: stringOption(options.name)
|
|
33
|
+
}));
|
|
34
|
+
if (options.json) {
|
|
35
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
printRoutesTable(rows);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { routesCommandAction };
|
|
43
|
+
//# sourceMappingURL=routes-command.action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\nimport type { CommandActionData } from \"../../types\";\nimport { printRoutesTable } from \"./format-routes-table\";\nimport { filterRouteRows, sortRouteRows, toRouteRow } from \"./route-row\";\n\n/**\n * Read the active option as a trimmed string, or `undefined` when it is absent\n * or not a string (a bare boolean flag).\n *\n * @param value - The parsed option value\n * @returns The string value, or `undefined`\n */\nfunction stringOption(value: string | number | boolean | undefined): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n}\n\n/**\n * Action behind `warlock routes`. Reads the registered routes from the router\n * singleton (populated by the `bootstrap` preload, with no connectors started),\n * applies the `--method` / `--path` / `--name` filters, sorts them, and either\n * prints a verb-colored table or — with `--json` — emits the normalized rows as\n * JSON for piping into scripts/CI.\n *\n * Read-only: it never opens a database/cache/socket connection and never\n * mutates the router.\n *\n * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).\n */\nexport function routesCommandAction({ options }: CommandActionData): void {\n const rows = sortRouteRows(\n filterRouteRows(router.list().map(toRouteRow), {\n method: stringOption(options.method),\n path: stringOption(options.path),\n name: stringOption(options.name),\n }),\n );\n\n if (options.json) {\n console.log(JSON.stringify(rows, null, 2));\n return;\n }\n\n printRoutesTable(rows);\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aAAa,OAAkE;CACtF,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,EAAE,WAAoC;CACxE,MAAM,OAAO,cACX,gBAAgB,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,GAAG;EAC7C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,aAAa,QAAQ,IAAI;CACjC,CAAC,CACH;CAEA,IAAI,QAAQ,MAAM;EAChB,QAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;EACzC;CACF;CAEA,iBAAiB,IAAI;AACvB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { command } from "../cli-command.mjs";
|
|
2
|
+
import { routesCommandAction } from "./routes/routes-command.action.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../@warlock.js/core/src/cli/commands/routes.command.ts
|
|
5
|
+
/**
|
|
6
|
+
* `warlock routes` — list every registered HTTP route as a table (a read-only
|
|
7
|
+
* sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,
|
|
8
|
+
* or emit the normalized rows as JSON with `--json`.
|
|
9
|
+
*
|
|
10
|
+
* Preload plan: load config + bootstrap app code so route modules register on
|
|
11
|
+
* the router singleton, but start NO connectors — listing routes must never
|
|
12
|
+
* open a database/cache/socket connection. Because the route-module loader is
|
|
13
|
+
* fail-loud, a route file that throws on import surfaces here instead of being
|
|
14
|
+
* silently omitted from the table.
|
|
15
|
+
*/
|
|
16
|
+
const routesCommand = command({
|
|
17
|
+
name: "routes",
|
|
18
|
+
description: "List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json",
|
|
19
|
+
action: routesCommandAction,
|
|
20
|
+
preload: {
|
|
21
|
+
config: true,
|
|
22
|
+
env: true,
|
|
23
|
+
bootstrap: true
|
|
24
|
+
},
|
|
25
|
+
options: [
|
|
26
|
+
{
|
|
27
|
+
text: "--method, -m",
|
|
28
|
+
description: "Filter by HTTP method (case-insensitive, e.g. GET, POST)",
|
|
29
|
+
type: "string"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: "--path, -p",
|
|
33
|
+
description: "Filter by a case-insensitive path substring",
|
|
34
|
+
type: "string"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
text: "--name, -n",
|
|
38
|
+
description: "Filter by a case-insensitive route-name substring",
|
|
39
|
+
type: "string"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
text: "--json, -j",
|
|
43
|
+
description: "Output the routes as JSON instead of a table",
|
|
44
|
+
type: "boolean"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { routesCommand };
|
|
51
|
+
//# sourceMappingURL=routes.command.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../cli-command\";\nimport { routesCommandAction } from \"./routes/routes-command.action\";\n\n/**\n * `warlock routes` — list every registered HTTP route as a table (a read-only\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\n * or emit the normalized rows as JSON with `--json`.\n *\n * Preload plan: load config + bootstrap app code so route modules register on\n * the router singleton, but start NO connectors — listing routes must never\n * open a database/cache/socket connection. Because the route-module loader is\n * fail-loud, a route file that throws on import surfaces here instead of being\n * silently omitted from the table.\n */\nexport const routesCommand = command({\n name: \"routes\",\n description:\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\n action: routesCommandAction,\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n },\n options: [\n {\n text: \"--method, -m\",\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\n type: \"string\",\n },\n {\n text: \"--path, -p\",\n description: \"Filter by a case-insensitive path substring\",\n type: \"string\",\n },\n {\n text: \"--name, -n\",\n description: \"Filter by a case-insensitive route-name substring\",\n type: \"string\",\n },\n {\n text: \"--json, -j\",\n description: \"Output the routes as JSON instead of a table\",\n type: \"boolean\",\n },\n ],\n});\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -32,6 +32,11 @@ const seedCommand = command({
|
|
|
32
32
|
description: "Run seeds in a transaction",
|
|
33
33
|
type: "boolean",
|
|
34
34
|
defaultValue: true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
text: "--drop, -d",
|
|
38
|
+
description: "Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"",
|
|
39
|
+
type: "string"
|
|
35
40
|
}
|
|
36
41
|
]
|
|
37
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\
|
|
1
|
+
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\nimport { command } from \"../cli-command\";\n\nexport const seedCommand = command({\n action: seedCommandAction,\n name: \"seed\",\n description: \"Run database seeds\",\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n connectors: [\"database\", \"cache\", \"logger\"],\n },\n options: [\n {\n text: \"--fresh, -f\",\n description: \"Drop all tables records and run seeds\",\n type: \"boolean\",\n },\n {\n text: \"--list, -l\",\n description: \"Display the seeds list in order without execution\",\n type: \"boolean\",\n },\n {\n text: \"--transaction, -t\",\n description: \"Run seeds in a transaction\",\n type: \"boolean\",\n defaultValue: true,\n },\n {\n text: \"--drop, -d\",\n description:\n 'Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"',\n type: \"string\",\n },\n ],\n});\n"],"mappings":";;;;AAGA,MAAa,cAAc,QAAQ;CACjC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;EACX,YAAY;GAAC;GAAY;GAAS;EAAQ;CAC5C;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACN,cAAc;EAChB;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -2,9 +2,11 @@ import { addCommand } from "./commands/add.command.mjs";
|
|
|
2
2
|
import { buildCommand } from "./commands/build.command.mjs";
|
|
3
3
|
import { createDatabaseCommand } from "./commands/create-database.command.mjs";
|
|
4
4
|
import { devServerCommand } from "./commands/dev-server.command.mjs";
|
|
5
|
+
import { doctorCommand } from "./commands/doctor.command.mjs";
|
|
5
6
|
import { dropTablesCommand } from "./commands/drop-tables.command.mjs";
|
|
6
7
|
import { generateCommand, generateControllerCommand, generateMigrationCommand, generateModelCommand, generateModuleCommand, generateRepositoryCommand, generateResourceCommand, generateServiceCommand } from "./commands/generate/generate.command.mjs";
|
|
7
8
|
import { migrateCommand } from "./commands/migrate.command.mjs";
|
|
9
|
+
import { routesCommand } from "./commands/routes.command.mjs";
|
|
8
10
|
import { seedCommand } from "./commands/seed.command.mjs";
|
|
9
11
|
import { startProductionCommand } from "./commands/start-production.command.mjs";
|
|
10
12
|
import { storagePutCommand } from "./commands/storage-put.command.mjs";
|
|
@@ -15,6 +17,8 @@ import { updateCommand } from "./commands/update.command.mjs";
|
|
|
15
17
|
const frameworkCommands = [
|
|
16
18
|
devServerCommand,
|
|
17
19
|
typingsGeneratorCommand,
|
|
20
|
+
doctorCommand,
|
|
21
|
+
routesCommand,
|
|
18
22
|
buildCommand,
|
|
19
23
|
startProductionCommand,
|
|
20
24
|
migrateCommand,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-cli-commands.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/cli/framework-cli-commands.ts"],"sourcesContent":["import { addCommand } from \"./commands/add.command\";\r\nimport { buildCommand } from \"./commands/build.command\";\r\nimport { createDatabaseCommand } from \"./commands/create-database.command\";\r\nimport { devServerCommand } from \"./commands/dev-server.command\";\r\nimport { dropTablesCommand } from \"./commands/drop-tables.command\";\r\nimport {\r\n generateCommand,\r\n generateControllerCommand,\r\n generateMigrationCommand,\r\n generateModelCommand,\r\n generateModuleCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateServiceCommand,\r\n} from \"./commands/generate/generate.command\";\r\nimport { migrateCommand } from \"./commands/migrate.command\";\r\nimport { seedCommand } from \"./commands/seed.command\";\r\nimport { startProductionCommand } from \"./commands/start-production.command\";\r\nimport { storagePutCommand } from \"./commands/storage-put.command\";\r\nimport { typingsGeneratorCommand } from \"./commands/typings-generator.command\";\r\nimport { updateCommand } from \"./commands/update.command\";\r\n\r\nexport const frameworkCommands = [\r\n // development commands\r\n devServerCommand,\r\n typingsGeneratorCommand,\r\n\r\n // production commands\r\n buildCommand,\r\n startProductionCommand,\r\n\r\n // database commands\r\n migrateCommand,\r\n seedCommand,\r\n createDatabaseCommand,\r\n dropTablesCommand,\r\n\r\n // generation/installation commands\r\n addCommand,\r\n updateCommand,\r\n\r\n // scaffolding commands\r\n generateCommand,\r\n generateModuleCommand,\r\n generateControllerCommand,\r\n generateServiceCommand,\r\n generateModelCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateMigrationCommand,\r\n\r\n // storage commands\r\n storagePutCommand,\r\n];\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"framework-cli-commands.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/cli/framework-cli-commands.ts"],"sourcesContent":["import { addCommand } from \"./commands/add.command\";\r\nimport { buildCommand } from \"./commands/build.command\";\r\nimport { createDatabaseCommand } from \"./commands/create-database.command\";\r\nimport { devServerCommand } from \"./commands/dev-server.command\";\r\nimport { doctorCommand } from \"./commands/doctor.command\";\r\nimport { dropTablesCommand } from \"./commands/drop-tables.command\";\r\nimport {\r\n generateCommand,\r\n generateControllerCommand,\r\n generateMigrationCommand,\r\n generateModelCommand,\r\n generateModuleCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateServiceCommand,\r\n} from \"./commands/generate/generate.command\";\r\nimport { migrateCommand } from \"./commands/migrate.command\";\r\nimport { routesCommand } from \"./commands/routes.command\";\r\nimport { seedCommand } from \"./commands/seed.command\";\r\nimport { startProductionCommand } from \"./commands/start-production.command\";\r\nimport { storagePutCommand } from \"./commands/storage-put.command\";\r\nimport { typingsGeneratorCommand } from \"./commands/typings-generator.command\";\r\nimport { updateCommand } from \"./commands/update.command\";\r\n\r\nexport const frameworkCommands = [\r\n // development commands\r\n devServerCommand,\r\n typingsGeneratorCommand,\r\n\r\n // diagnostics commands\r\n doctorCommand,\r\n routesCommand,\r\n\r\n // production commands\r\n buildCommand,\r\n startProductionCommand,\r\n\r\n // database commands\r\n migrateCommand,\r\n seedCommand,\r\n createDatabaseCommand,\r\n dropTablesCommand,\r\n\r\n // generation/installation commands\r\n addCommand,\r\n updateCommand,\r\n\r\n // scaffolding commands\r\n generateCommand,\r\n generateModuleCommand,\r\n generateControllerCommand,\r\n generateServiceCommand,\r\n generateModelCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateMigrationCommand,\r\n\r\n // storage commands\r\n storagePutCommand,\r\n];\r\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,oBAAoB;CAE/B;CACA;CAGA;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import config from "@mongez/config";
|
|
2
2
|
|
|
3
3
|
//#region ../@warlock.js/core/src/config/config-getter.ts
|
|
4
4
|
/**
|
|
@@ -14,15 +14,15 @@ import baseConfig from "@mongez/config";
|
|
|
14
14
|
* const port = config.key<number>("database.port", 27017);
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
const config = {
|
|
17
|
+
const config$1 = {
|
|
18
18
|
key(key, defaultValue) {
|
|
19
|
-
return
|
|
19
|
+
return config.get(key, defaultValue);
|
|
20
20
|
},
|
|
21
21
|
get(name, defaultValue) {
|
|
22
|
-
return
|
|
22
|
+
return config.get(name, defaultValue);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
27
|
-
export { config };
|
|
27
|
+
export { config$1 as config };
|
|
28
28
|
//# sourceMappingURL=config-getter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-getter.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-getter.ts"],"sourcesContent":["import baseConfig from \"@mongez/config\";\nimport type { ConfigKey, ConfigRegistry } from \"./types\";\n\n/**\n * Config accessor interface with typed overloads\n */\ninterface ConfigAccessor {\n /**\n * Get a config value by dot-notation key path.\n */\n key<T = any>(key: ConfigKey | (string & {}), defaultValue?: T): T;\n\n /**\n * Get an entire config group by name with type inference.\n * Returns the typed config object for known config names.\n */\n get<K extends keyof ConfigRegistry>(name: K, defaultValue?: ConfigRegistry[K]): ConfigRegistry[K];\n\n /**\n * Get an entire config group by name (dynamic string).\n */\n get<T = any>(name: string, defaultValue?: T): T;\n}\n\n/**\n * Config accessor with typed autocomplete and return type inference.\n *\n * @example\n * ```typescript\n * // Get entire config group - returns the actual config type\n * const db = config.get(\"database\"); // → DatabaseConfigurations\n *\n * // Get specific key with dot notation\n * const host = config.key(\"database.host\");\n * const port = config.key<number>(\"database.port\", 27017);\n * ```\n */\nexport const config: ConfigAccessor = {\n key(key: ConfigKey | (string & {}), defaultValue?: any): any {\n return baseConfig.get(key, defaultValue);\n },\n\n get(name: string, defaultValue?: any): any {\n return baseConfig.get(name, defaultValue);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,
|
|
1
|
+
{"version":3,"file":"config-getter.mjs","names":["config","baseConfig"],"sources":["../../../../../../../@warlock.js/core/src/config/config-getter.ts"],"sourcesContent":["import baseConfig from \"@mongez/config\";\nimport type { ConfigKey, ConfigRegistry } from \"./types\";\n\n/**\n * Config accessor interface with typed overloads\n */\ninterface ConfigAccessor {\n /**\n * Get a config value by dot-notation key path.\n */\n key<T = any>(key: ConfigKey | (string & {}), defaultValue?: T): T;\n\n /**\n * Get an entire config group by name with type inference.\n * Returns the typed config object for known config names.\n */\n get<K extends keyof ConfigRegistry>(name: K, defaultValue?: ConfigRegistry[K]): ConfigRegistry[K];\n\n /**\n * Get an entire config group by name (dynamic string).\n */\n get<T = any>(name: string, defaultValue?: T): T;\n}\n\n/**\n * Config accessor with typed autocomplete and return type inference.\n *\n * @example\n * ```typescript\n * // Get entire config group - returns the actual config type\n * const db = config.get(\"database\"); // → DatabaseConfigurations\n *\n * // Get specific key with dot notation\n * const host = config.key(\"database.host\");\n * const port = config.key<number>(\"database.port\", 27017);\n * ```\n */\nexport const config: ConfigAccessor = {\n key(key: ConfigKey | (string & {}), defaultValue?: any): any {\n return baseConfig.get(key, defaultValue);\n },\n\n get(name: string, defaultValue?: any): any {\n return baseConfig.get(name, defaultValue);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAaA,WAAyB;CACpC,IAAI,KAAgC,cAAyB;EAC3D,OAAOC,OAAW,IAAI,KAAK,YAAY;CACzC;CAEA,IAAI,MAAc,cAAyB;EACzC,OAAOA,OAAW,IAAI,MAAM,YAAY;CAC1C;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { configSpecialHandlers } from "./config-special-handlers.mjs";
|
|
2
|
-
import
|
|
2
|
+
import config from "@mongez/config";
|
|
3
3
|
import { colors } from "@mongez/copper";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ var ConfigLoader = class {
|
|
|
27
27
|
console.log(colors.red(`config error: `), `Config file ${colors.yellow(file.relativePath)} does not have a default export`);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
config.set(configName, configValue);
|
|
31
31
|
await configSpecialHandlers.execute(configName, configValue);
|
|
32
32
|
} catch (error) {
|
|
33
33
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,CAAC,CAAC,MAEjB,CAAC;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,
|
|
1
|
+
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,CAAC,CAAC,MAEjB,CAAC;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,OAAO,IAAI,YAAY,WAAW;GAClC,MAAM,sBAAsB,QAAQ,YAAY,WAAW;EAC7D,SAAS,OAAO;GACd,MAAM;EACR;CACF;CAEA,MAAa,aAAa,MAAkC;EAC1D,MAAM,KAAK,WAAW,IAAI;CAC5B;CAEA,AAAQ,cAAc,cAA8B;EAClD,MAAM,QAAQ,aAAa,MAAM,+BAA+B;EAEhE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,6BAA6B,cAAc;EAG7D,OAAO,MAAM;CACf;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
|
-
import
|
|
3
|
+
import config from "@mongez/config";
|
|
4
4
|
import { log } from "@warlock.js/logger";
|
|
5
5
|
|
|
6
6
|
//#region ../@warlock.js/core/src/connectors/access-connector.ts
|
|
@@ -29,7 +29,7 @@ var AccessConnector = class extends BaseConnector {
|
|
|
29
29
|
* Register the access configuration with the package.
|
|
30
30
|
*/
|
|
31
31
|
async start() {
|
|
32
|
-
const accessConfiguration =
|
|
32
|
+
const accessConfiguration = config.get("access");
|
|
33
33
|
if (!accessConfiguration) return;
|
|
34
34
|
const { setAccessConfig } = await import("@warlock.js/access");
|
|
35
35
|
setAccessConfig(accessConfiguration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-connector.mjs","names":[
|
|
1
|
+
{"version":3,"file":"access-connector.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/connectors/access-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { log } from \"@warlock.js/logger\";\nimport { BaseConnector } from \"./base-connector\";\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\n\n/**\n * Access Connector\n *\n * Wires `@warlock.js/access` from `src/config/access.ts` at boot: reads the\n * exported config object and hands it to the package's `setAccessConfig`, which\n * validates that a resolver is present — so a misconfigured authorization layer\n * fails at STARTUP, not on the first protected request. Config files stay\n * declarative; the connector performs the side-effect.\n *\n * The package is lazy-imported (only when an access config is present), so core\n * carries no hard dependency on it — the same pattern as the notifications and\n * herald connectors.\n */\nexport class AccessConnector extends BaseConnector {\n public readonly name = \"access\";\n public readonly priority = ConnectorPriority.ACCESS;\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\n\n /**\n * Files that trigger an access restart\n */\n protected readonly watchedFiles = [\"src/config/access.ts\"];\n\n /**\n * Register the access configuration with the package.\n */\n public async start(): Promise<void> {\n const accessConfiguration = config.get(\"access\");\n\n if (!accessConfiguration) {\n return;\n }\n\n const { setAccessConfig } = await import(\"@warlock.js/access\");\n\n setAccessConfig(accessConfiguration);\n this.active = true;\n\n log.info(\"access\", \"configured\", \"Authorization wired from config/access.ts\");\n }\n\n /**\n * Clear the active config so a dev restart re-registers from the (possibly\n * changed, or now-removed) config file. The package holds no external\n * connection of its own.\n */\n public async shutdown(): Promise<void> {\n if (!this.active) {\n return;\n }\n\n const { resetAccessConfig } = await import(\"@warlock.js/access\");\n\n resetAccessConfig();\n this.active = false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,sBAAsB;;;;;CAKzD,MAAa,QAAuB;EAClC,MAAM,sBAAsB,OAAO,IAAI,QAAQ;EAE/C,IAAI,CAAC,qBACH;EAGF,MAAM,EAAE,oBAAoB,MAAM,OAAO;EAEzC,gBAAgB,mBAAmB;EACnC,KAAK,SAAS;EAEd,IAAI,KAAK,UAAU,cAAc,2CAA2C;CAC9E;;;;;;CAOA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,MAAM,EAAE,sBAAsB,MAAM,OAAO;EAE3C,kBAAkB;EAClB,KAAK,SAAS;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
|
-
import
|
|
3
|
+
import config from "@mongez/config";
|
|
4
4
|
import { log } from "@warlock.js/logger";
|
|
5
5
|
|
|
6
6
|
//#region ../@warlock.js/core/src/connectors/ai-connector.ts
|
|
@@ -33,7 +33,7 @@ var AiConnector = class extends BaseConnector {
|
|
|
33
33
|
* Register the ai configuration with the package.
|
|
34
34
|
*/
|
|
35
35
|
async start() {
|
|
36
|
-
const aiConfiguration =
|
|
36
|
+
const aiConfiguration = config.get("ai");
|
|
37
37
|
if (!aiConfiguration) return;
|
|
38
38
|
const { ai } = await import("../ai/src/index.mjs");
|
|
39
39
|
ai.config(aiConfiguration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-connector.mjs","names":[
|
|
1
|
+
{"version":3,"file":"ai-connector.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/connectors/ai-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { log } from \"@warlock.js/logger\";\nimport { BaseConnector } from \"./base-connector\";\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\n\n/**\n * AI Connector\n *\n * Wires `@warlock.js/ai` from `src/config/ai.ts` at boot: reads the exported\n * config object and hands it to the package's `ai.config(...)`. Config files stay\n * declarative; the connector performs the side-effect.\n *\n * The package is lazy-imported (only when an ai config is present), so core\n * carries no hard dependency on it — the same pattern as the access,\n * notifications and herald connectors.\n *\n * Because the satellite packages' side-effect imports sit at the TOP of\n * config/ai.ts, they have already registered their surface on `ai` (ai.tools /\n * ai.mcp, ai.workspace, panoptic) by the time config-loader runs the file and\n * this connector applies the config — so this single `ai.config(...)` call also\n * fires panoptic's onConfigApplied wiring.\n */\nexport class AiConnector extends BaseConnector {\n public readonly name = \"ai\";\n public readonly priority = ConnectorPriority.AI;\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\n\n /**\n * Files that trigger an ai restart\n */\n protected readonly watchedFiles = [\"src/config/ai.ts\"];\n\n /**\n * Register the ai configuration with the package.\n */\n public async start(): Promise<void> {\n const aiConfiguration = config.get(\"ai\");\n\n if (!aiConfiguration) return;\n\n const { ai } = await import(\"@warlock.js/ai\");\n\n ai.config(aiConfiguration);\n this.active = true;\n\n log.info(\"ai\", \"configured\", \"AI wired from config/ai.ts\");\n }\n\n /**\n * Clear the active flag so a dev restart re-registers from the (possibly\n * changed, or now-removed) config file. The package holds no external\n * connection of its own.\n */\n public async shutdown(): Promise<void> {\n if (!this.active) return;\n\n this.active = false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,cAAb,cAAiC,cAAc;;;cACtB;;;sBAOW,CAAC,kBAAkB;;;;;CAKrD,MAAa,QAAuB;EAClC,MAAM,kBAAkB,OAAO,IAAI,IAAI;EAEvC,IAAI,CAAC,iBAAiB;EAEtB,MAAM,EAAE,OAAO,MAAM,OAAO;EAE5B,GAAG,OAAO,eAAe;EACzB,KAAK,SAAS;EAEd,IAAI,KAAK,MAAM,cAAc,4BAA4B;CAC3D;;;;;;CAOA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QAAQ;EAElB,KAAK,SAAS;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
2
2
|
import { BaseConnector } from "./base-connector.mjs";
|
|
3
|
-
import
|
|
3
|
+
import config from "@mongez/config";
|
|
4
4
|
import { cache } from "@warlock.js/cache";
|
|
5
5
|
|
|
6
6
|
//#region ../@warlock.js/core/src/connectors/cache-connector.ts
|
|
@@ -20,7 +20,7 @@ var CacheConnector = class extends BaseConnector {
|
|
|
20
20
|
* Initialize cache connection
|
|
21
21
|
*/
|
|
22
22
|
async start() {
|
|
23
|
-
const cacheConfig =
|
|
23
|
+
const cacheConfig = config.get("cache");
|
|
24
24
|
if (!cacheConfig) return;
|
|
25
25
|
cache.setCacheConfigurations(cacheConfig);
|
|
26
26
|
await cache.init();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-connector.mjs","names":[
|
|
1
|
+
{"version":3,"file":"cache-connector.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/connectors/cache-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { cache } from \"@warlock.js/cache\";\nimport type { CacheDriver } from \"@warlock.js/cache\";\nimport { BaseConnector } from \"./base-connector\";\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\n\n/**\n * Cache Connector\n * Manages cache engine connection lifecycle\n */\nexport class CacheConnector extends BaseConnector {\n public readonly name = \"cache\";\n public readonly priority = ConnectorPriority.CACHE;\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\n\n /**\n * Files that trigger cache restart\n */\n protected readonly watchedFiles = [\"src/config/cache.ts\", \"src/config/cache.tsx\"];\n\n /**\n * Initialize cache connection\n */\n public async start(): Promise<void> {\n const cacheConfig = config.get(\"cache\");\n\n if (!cacheConfig) return;\n\n cache.setCacheConfigurations(cacheConfig);\n\n await cache.init();\n\n this.active = true;\n }\n\n /**\n * Shutdown cache connection\n *\n * Disconnects every loaded cache driver so external clients (e.g. a Redis\n * connection) are released instead of left dangling — mirroring the\n * database and herald connectors, which disconnect all registered\n * connections on shutdown.\n */\n public async shutdown(): Promise<void> {\n if (!this.active) {\n return;\n }\n\n // Disconnect every driver the manager loaded (not just the current one),\n // so secondary drivers selected via `cache.use(\"...\")` also release their\n // connections.\n const drivers: CacheDriver<unknown, unknown>[] = Object.values(cache.loadedDrivers);\n\n for (const driver of drivers) {\n await driver.disconnect();\n }\n\n this.active = false;\n }\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAa,iBAAb,cAAoC,cAAc;;;cACzB;;;sBAOW,CAAC,uBAAuB,sBAAsB;;;;;CAKhF,MAAa,QAAuB;EAClC,MAAM,cAAc,OAAO,IAAI,OAAO;EAEtC,IAAI,CAAC,aAAa;EAElB,MAAM,uBAAuB,WAAW;EAExC,MAAM,MAAM,KAAK;EAEjB,KAAK,SAAS;CAChB;;;;;;;;;CAUA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAMF,MAAM,UAA2C,OAAO,OAAO,MAAM,aAAa;EAElF,KAAK,MAAM,UAAU,SACnB,MAAM,OAAO,WAAW;EAG1B,KAAK,SAAS;CAChB;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { container } from "../container/index.mjs";
|
|
2
2
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
3
3
|
import { BaseConnector } from "./base-connector.mjs";
|
|
4
|
-
import
|
|
4
|
+
import config from "@mongez/config";
|
|
5
5
|
import { connectToDatabase, dataSourceRegistry } from "@warlock.js/cascade";
|
|
6
6
|
|
|
7
7
|
//#region ../@warlock.js/core/src/connectors/database-connector.ts
|
|
@@ -21,7 +21,7 @@ var DatabaseConnector = class extends BaseConnector {
|
|
|
21
21
|
* Initialize database connection
|
|
22
22
|
*/
|
|
23
23
|
async start() {
|
|
24
|
-
const databaseConfig =
|
|
24
|
+
const databaseConfig = config.get("database");
|
|
25
25
|
if (!databaseConfig) return;
|
|
26
26
|
try {
|
|
27
27
|
const source = await connectToDatabase(databaseConfig);
|