@donotdev/cli 0.3.7 → 0.3.9
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/dependencies-matrix.json +41 -21
- package/dist/bin/commands/build.js +9 -1
- package/dist/bin/commands/db-check.js +135 -29
- package/dist/bin/commands/db.js +135 -29
- package/dist/bin/commands/deploy.js +83 -42
- package/dist/bin/commands/make-admin.js +9 -1
- package/dist/bin/commands/seed.js +146 -36
- package/dist/bin/commands/setup-cicd.js +9 -1
- package/dist/bin/commands/setup.js +748 -70
- package/dist/bin/commands/type-check.js +9 -1
- package/dist/bin/commands/uat.js +90 -49
- package/dist/bin/dndev.js +10 -2
- package/dist/index.js +90 -49
- package/package.json +1 -1
- package/templates/app-next/src/app/ClientLayout.tsx.example +24 -8
- package/templates/root-consumer/AGENTS.md.example +0 -1
- package/templates/root-consumer/turbo.json.example +3 -0
package/dependencies-matrix.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "./dependencies-matrix.schema.json",
|
|
3
3
|
"version": "0.0.8",
|
|
4
4
|
"description": "Centralized dependency versions for DoNotDev framework. Single source of truth for all external dependencies. Third-party optional deps are auto-detected from peerDependenciesMeta via scanInstalledPackageOptionals() — no manual constants update needed.",
|
|
5
|
-
"lastUpdated": "2026-
|
|
5
|
+
"lastUpdated": "2026-12-03",
|
|
6
6
|
"migrationGuides": {
|
|
7
7
|
"0.0→0.1": {
|
|
8
8
|
"path": "docs/migration/v0.0-to-v0.1.md",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@donotdev/ai": {
|
|
23
23
|
"description": "AI package - provider-agnostic LLM plumbing",
|
|
24
24
|
"packages": {
|
|
25
|
-
"@donotdev/ai": "^0.3.
|
|
25
|
+
"@donotdev/ai": "^0.3.4"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"@donotdev/graphql": {
|
|
@@ -40,55 +40,55 @@
|
|
|
40
40
|
"@donotdev/testing": {
|
|
41
41
|
"description": "Testing utilities - opt-in, not scaffolded by default",
|
|
42
42
|
"packages": {
|
|
43
|
-
"@donotdev/testing": "^0.3.
|
|
43
|
+
"@donotdev/testing": "^0.3.3"
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"@donotdev/auth": {
|
|
47
47
|
"description": "Authentication package",
|
|
48
48
|
"packages": {
|
|
49
|
-
"@donotdev/auth": "^0.3.
|
|
49
|
+
"@donotdev/auth": "^0.3.9"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"@donotdev/billing": {
|
|
53
53
|
"description": "Billing package",
|
|
54
54
|
"packages": {
|
|
55
|
-
"@donotdev/billing": "^0.3.
|
|
55
|
+
"@donotdev/billing": "^0.3.6"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"@donotdev/components": {
|
|
59
59
|
"description": "UI components package",
|
|
60
60
|
"packages": {
|
|
61
|
-
"@donotdev/components": "^0.3.
|
|
61
|
+
"@donotdev/components": "^0.3.13"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"@donotdev/core": {
|
|
65
65
|
"description": "Core framework package",
|
|
66
66
|
"packages": {
|
|
67
|
-
"@donotdev/core": "^0.3.
|
|
67
|
+
"@donotdev/core": "^0.3.14"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"@donotdev/crud": {
|
|
71
71
|
"description": "CRUD operations package",
|
|
72
72
|
"packages": {
|
|
73
|
-
"@donotdev/crud": "^0.3.
|
|
73
|
+
"@donotdev/crud": "^0.3.11"
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
"@donotdev/demo": {
|
|
77
77
|
"description": "Zero-backend demo provider package",
|
|
78
78
|
"packages": {
|
|
79
|
-
"@donotdev/demo": "^0.3.
|
|
79
|
+
"@donotdev/demo": "^0.3.3"
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"@donotdev/firebase": {
|
|
83
83
|
"description": "Firebase provider package",
|
|
84
84
|
"packages": {
|
|
85
|
-
"@donotdev/firebase": "^0.3.
|
|
85
|
+
"@donotdev/firebase": "^0.3.7"
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
88
|
"@donotdev/functions": {
|
|
89
89
|
"description": "Firebase Functions package",
|
|
90
90
|
"packages": {
|
|
91
|
-
"@donotdev/functions": "^0.3.
|
|
91
|
+
"@donotdev/functions": "^0.3.7"
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"@donotdev/oauth": {
|
|
@@ -100,25 +100,25 @@
|
|
|
100
100
|
"@donotdev/templates": {
|
|
101
101
|
"description": "Page templates package",
|
|
102
102
|
"packages": {
|
|
103
|
-
"@donotdev/templates": "^0.3.
|
|
103
|
+
"@donotdev/templates": "^0.3.6"
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"@donotdev/ui": {
|
|
107
107
|
"description": "UI and routing package",
|
|
108
108
|
"packages": {
|
|
109
|
-
"@donotdev/ui": "^0.3.
|
|
109
|
+
"@donotdev/ui": "^0.3.13"
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"@donotdev/expo": {
|
|
113
113
|
"description": "Expo/React Native components package",
|
|
114
114
|
"packages": {
|
|
115
|
-
"@donotdev/expo": "^0.3.
|
|
115
|
+
"@donotdev/expo": "^0.3.7"
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
"@donotdev/supabase": {
|
|
119
119
|
"description": "Supabase provider package",
|
|
120
120
|
"packages": {
|
|
121
|
-
"@donotdev/supabase": "^0.3.
|
|
121
|
+
"@donotdev/supabase": "^0.3.7"
|
|
122
122
|
}
|
|
123
123
|
},
|
|
124
124
|
"supabase-js": {
|
|
@@ -309,6 +309,12 @@
|
|
|
309
309
|
"@ai-sdk/react": "^4.0.174"
|
|
310
310
|
}
|
|
311
311
|
},
|
|
312
|
+
"xyflow": {
|
|
313
|
+
"description": "React Flow (node-based editor canvas, MIT, xyflow / webkid GmbH). Optional peer of @donotdev/ai: only the chatbot tree editor imports it.",
|
|
314
|
+
"packages": {
|
|
315
|
+
"@xyflow/react": "^13.0.3"
|
|
316
|
+
}
|
|
317
|
+
},
|
|
312
318
|
"ai-sdk-providers": {
|
|
313
319
|
"description": "Vercel AI SDK model providers, loaded lazily by the @donotdev/functions AI route.",
|
|
314
320
|
"packages": {
|
|
@@ -494,13 +500,13 @@
|
|
|
494
500
|
"@donotdev/cli": {
|
|
495
501
|
"description": "Cli package",
|
|
496
502
|
"packages": {
|
|
497
|
-
"@donotdev/cli": "^0.3.
|
|
503
|
+
"@donotdev/cli": "^0.3.9"
|
|
498
504
|
}
|
|
499
505
|
},
|
|
500
506
|
"@donotdev/mcp-server": {
|
|
501
507
|
"description": "MCP server for component type lookups",
|
|
502
508
|
"packages": {
|
|
503
|
-
"@donotdev/mcp-server": "^0.3.
|
|
509
|
+
"@donotdev/mcp-server": "^0.3.4"
|
|
504
510
|
}
|
|
505
511
|
},
|
|
506
512
|
"mcp-sdk": {
|
|
@@ -572,7 +578,7 @@
|
|
|
572
578
|
"@donotdev/canvas": {
|
|
573
579
|
"description": "Canvas package",
|
|
574
580
|
"packages": {
|
|
575
|
-
"@donotdev/canvas": "^0.3.
|
|
581
|
+
"@donotdev/canvas": "^0.3.3"
|
|
576
582
|
}
|
|
577
583
|
}
|
|
578
584
|
},
|
|
@@ -590,14 +596,28 @@
|
|
|
590
596
|
"@donotdev/auth",
|
|
591
597
|
"@donotdev/components",
|
|
592
598
|
"@donotdev/core",
|
|
599
|
+
"@donotdev/crud",
|
|
593
600
|
"lucide-react",
|
|
594
601
|
"ai-sdk",
|
|
595
|
-
"ai-sdk-react"
|
|
602
|
+
"ai-sdk-react",
|
|
603
|
+
"xyflow"
|
|
596
604
|
],
|
|
597
605
|
"devDependencies": [
|
|
598
606
|
"ai-sdk",
|
|
599
|
-
"ai-sdk-react"
|
|
600
|
-
|
|
607
|
+
"ai-sdk-react",
|
|
608
|
+
"xyflow"
|
|
609
|
+
],
|
|
610
|
+
"peerDependenciesMeta": {
|
|
611
|
+
"ai-sdk": {
|
|
612
|
+
"optional": true
|
|
613
|
+
},
|
|
614
|
+
"ai-sdk-react": {
|
|
615
|
+
"optional": true
|
|
616
|
+
},
|
|
617
|
+
"xyflow": {
|
|
618
|
+
"optional": true
|
|
619
|
+
}
|
|
620
|
+
}
|
|
601
621
|
},
|
|
602
622
|
"@donotdev/graphql": {
|
|
603
623
|
"devDependencies": [
|
|
@@ -9692,11 +9692,19 @@ var init_command_registry = __esm({
|
|
|
9692
9692
|
},
|
|
9693
9693
|
{
|
|
9694
9694
|
flags: "--output-dir <dir>",
|
|
9695
|
-
description: "output directory for migrations (default: supabase/migrations)"
|
|
9695
|
+
description: "output directory for migrations (default: supabase/migrations of the app the command runs for: the nearest folder up with supabase/config.toml, or the only app with one under apps/; fails when none)"
|
|
9696
9696
|
},
|
|
9697
9697
|
{
|
|
9698
9698
|
flags: "--no-single-file",
|
|
9699
9699
|
description: "emit one migration file per entity"
|
|
9700
|
+
},
|
|
9701
|
+
{
|
|
9702
|
+
flags: "--only <collections...>",
|
|
9703
|
+
description: "emit only these collections into ONE new migration <version>_<first>[_and_more].sql (version: now, or the latest existing + 1 so it sorts last); never touches *_entity_tables.sql (for a live app adding a feature's entities; feature-owned collections accepted)"
|
|
9704
|
+
},
|
|
9705
|
+
{
|
|
9706
|
+
flags: "--app-dir <dir>",
|
|
9707
|
+
description: "app folder whose src/config/app.ts turns framework features on (their entities are included when installed; default: the app of the output dir)"
|
|
9700
9708
|
}
|
|
9701
9709
|
],
|
|
9702
9710
|
loader: "../generators/sql-generator.ts"
|
|
@@ -9078,6 +9078,9 @@ var init_typed_file_operations = __esm({
|
|
|
9078
9078
|
});
|
|
9079
9079
|
|
|
9080
9080
|
// packages/tooling/src/utils/type-guards.ts
|
|
9081
|
+
function isRecord(value) {
|
|
9082
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9083
|
+
}
|
|
9081
9084
|
function isObjectLike(value) {
|
|
9082
9085
|
return typeof value === "object" && value !== null;
|
|
9083
9086
|
}
|
|
@@ -51531,6 +51534,100 @@ var init_supabase = __esm({
|
|
|
51531
51534
|
}
|
|
51532
51535
|
});
|
|
51533
51536
|
|
|
51537
|
+
// packages/tooling/src/generators/frameworkEntities.ts
|
|
51538
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
51539
|
+
import { pathToFileURL } from "node:url";
|
|
51540
|
+
function valueAt(config, path) {
|
|
51541
|
+
let value = config;
|
|
51542
|
+
for (const key of path) {
|
|
51543
|
+
if (!isRecord(value)) return void 0;
|
|
51544
|
+
value = value[key];
|
|
51545
|
+
}
|
|
51546
|
+
return value;
|
|
51547
|
+
}
|
|
51548
|
+
function isEntityExport(value) {
|
|
51549
|
+
return isObjectLike(value) && typeof value.name === "string" && value.name !== "" && typeof value.collection === "string" && value.collection !== "" && isRecord(value.fields);
|
|
51550
|
+
}
|
|
51551
|
+
async function readAppConfig(appDir) {
|
|
51552
|
+
const file = joinPath(appDir, ...APP_CONFIG_FILE);
|
|
51553
|
+
if (!pathExists(file, true)) return null;
|
|
51554
|
+
const mod3 = await import(pathToFileURL(file).href);
|
|
51555
|
+
const appConfig = isRecord(mod3) ? mod3.appConfig : void 0;
|
|
51556
|
+
if (!isRecord(appConfig)) {
|
|
51557
|
+
throw new DoNotDevError(
|
|
51558
|
+
`${file} does not export an appConfig object (export const appConfig: AppConfig = { \u2026 }).`,
|
|
51559
|
+
DO_NOT_DEV_ERROR_CODES.CONFIGURATION_ERROR
|
|
51560
|
+
);
|
|
51561
|
+
}
|
|
51562
|
+
return appConfig;
|
|
51563
|
+
}
|
|
51564
|
+
function isEnabled(appConfig, feature) {
|
|
51565
|
+
const setting = valueAt(appConfig, feature.configPath);
|
|
51566
|
+
return setting !== void 0 && setting !== null && setting !== false;
|
|
51567
|
+
}
|
|
51568
|
+
async function loadFeatureEntities(appDir, exclude = /* @__PURE__ */ new Set(), features = FRAMEWORK_ENTITY_FEATURES) {
|
|
51569
|
+
if (!appDir) {
|
|
51570
|
+
log2.info("App folder unknown: framework feature entities skipped (pass --app-dir).");
|
|
51571
|
+
return [];
|
|
51572
|
+
}
|
|
51573
|
+
const appConfig = await readAppConfig(appDir);
|
|
51574
|
+
if (!appConfig) {
|
|
51575
|
+
log2.info(
|
|
51576
|
+
`No ${APP_CONFIG_FILE.join("/")} in ${appDir}: framework feature entities skipped.`
|
|
51577
|
+
);
|
|
51578
|
+
return [];
|
|
51579
|
+
}
|
|
51580
|
+
const configFile = joinPath(appDir, ...APP_CONFIG_FILE);
|
|
51581
|
+
const found = [];
|
|
51582
|
+
for (const feature of features) {
|
|
51583
|
+
if (!isEnabled(appConfig, feature)) continue;
|
|
51584
|
+
let resolved;
|
|
51585
|
+
try {
|
|
51586
|
+
resolved = createRequire4(configFile).resolve(feature.module);
|
|
51587
|
+
} catch {
|
|
51588
|
+
log2.warn(
|
|
51589
|
+
`Feature ${feature.name} is on (appConfig.${feature.configPath.join(".")}) but ${feature.packageName} is not installed in ${appDir}: its tables are skipped. Install ${feature.packageName}.`
|
|
51590
|
+
);
|
|
51591
|
+
continue;
|
|
51592
|
+
}
|
|
51593
|
+
const mod3 = await import(pathToFileURL(resolved).href);
|
|
51594
|
+
if (!isRecord(mod3)) continue;
|
|
51595
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51596
|
+
for (const value of Object.values(mod3)) {
|
|
51597
|
+
if (!isEntityExport(value) || seen.has(value.collection)) continue;
|
|
51598
|
+
seen.add(value.collection);
|
|
51599
|
+
if (exclude.has(value.collection)) {
|
|
51600
|
+
log2.info(
|
|
51601
|
+
`${value.collection}: defined by the app's entity files and by feature ${feature.name}; one table.`
|
|
51602
|
+
);
|
|
51603
|
+
continue;
|
|
51604
|
+
}
|
|
51605
|
+
found.push({ entity: value, feature: feature.name, path: resolved });
|
|
51606
|
+
}
|
|
51607
|
+
}
|
|
51608
|
+
return found;
|
|
51609
|
+
}
|
|
51610
|
+
var FRAMEWORK_ENTITY_FEATURES, APP_CONFIG_FILE;
|
|
51611
|
+
var init_frameworkEntities = __esm({
|
|
51612
|
+
"packages/tooling/src/generators/frameworkEntities.ts"() {
|
|
51613
|
+
"use strict";
|
|
51614
|
+
init_utils2();
|
|
51615
|
+
init_cli_output();
|
|
51616
|
+
init_errors();
|
|
51617
|
+
init_pathResolver();
|
|
51618
|
+
init_type_guards();
|
|
51619
|
+
FRAMEWORK_ENTITY_FEATURES = [
|
|
51620
|
+
{
|
|
51621
|
+
name: "chatbot",
|
|
51622
|
+
configPath: ["ai", "chatbot"],
|
|
51623
|
+
module: "@donotdev/ai/entities",
|
|
51624
|
+
packageName: "@donotdev/ai"
|
|
51625
|
+
}
|
|
51626
|
+
];
|
|
51627
|
+
APP_CONFIG_FILE = ["src", "config", "app.ts"];
|
|
51628
|
+
}
|
|
51629
|
+
});
|
|
51630
|
+
|
|
51534
51631
|
// node_modules/.bun/firebase-admin@14.5.1+c188cf0323c41673/node_modules/firebase-admin/lib/firestore/error.js
|
|
51535
51632
|
var require_error4 = __commonJS({
|
|
51536
51633
|
"node_modules/.bun/firebase-admin@14.5.1+c188cf0323c41673/node_modules/firebase-admin/lib/firestore/error.js"(exports) {
|
|
@@ -191832,44 +191929,53 @@ init_create_utils();
|
|
|
191832
191929
|
// packages/tooling/src/db/context.ts
|
|
191833
191930
|
init_utils2();
|
|
191834
191931
|
init_supabase();
|
|
191932
|
+
init_frameworkEntities();
|
|
191835
191933
|
init_app_selector();
|
|
191836
191934
|
init_cli_output();
|
|
191837
191935
|
init_pathResolver();
|
|
191838
191936
|
init_secrets_resolver();
|
|
191839
191937
|
init_type_guards();
|
|
191840
|
-
|
|
191938
|
+
function toLoadedEntity(value) {
|
|
191939
|
+
if (!isObjectLike(value)) return null;
|
|
191940
|
+
if (typeof value.name === "string" && value.name && typeof value.collection === "string" && value.collection && value.fields) {
|
|
191941
|
+
return {
|
|
191942
|
+
name: value.name,
|
|
191943
|
+
collection: value.collection,
|
|
191944
|
+
// why: shape produced by defineEntity() (the app's entities barrel or a framework
|
|
191945
|
+
// feature's entities module); fields/access are validated there, not re-validated here.
|
|
191946
|
+
fields: value.fields,
|
|
191947
|
+
access: value.access
|
|
191948
|
+
};
|
|
191949
|
+
}
|
|
191950
|
+
return null;
|
|
191951
|
+
}
|
|
191952
|
+
async function loadEntities(projectRoot, appDir) {
|
|
191953
|
+
const entities = [];
|
|
191841
191954
|
const entitiesDir = joinPath(projectRoot, "entities");
|
|
191955
|
+
const indexPath = joinPath(entitiesDir, "index.ts");
|
|
191842
191956
|
if (!pathExists(entitiesDir)) {
|
|
191843
191957
|
log2.warn("No entities/ directory found");
|
|
191844
|
-
|
|
191845
|
-
}
|
|
191846
|
-
const indexPath = joinPath(entitiesDir, "index.ts");
|
|
191847
|
-
if (!pathExists(indexPath)) {
|
|
191958
|
+
} else if (!pathExists(indexPath)) {
|
|
191848
191959
|
log2.warn("No entities/index.ts found");
|
|
191849
|
-
|
|
191850
|
-
|
|
191851
|
-
|
|
191852
|
-
|
|
191853
|
-
|
|
191854
|
-
|
|
191855
|
-
|
|
191856
|
-
|
|
191857
|
-
|
|
191858
|
-
const entities = [];
|
|
191859
|
-
for (const [key, value] of Object.entries(entityModule)) {
|
|
191860
|
-
if (!isObjectLike(value)) continue;
|
|
191861
|
-
const candidate = value;
|
|
191862
|
-
if (typeof candidate.name === "string" && candidate.name && typeof candidate.collection === "string" && candidate.collection && candidate.fields) {
|
|
191863
|
-
entities.push({
|
|
191864
|
-
name: candidate.name,
|
|
191865
|
-
collection: candidate.collection,
|
|
191866
|
-
// why: shape produced by defineEntity() in the app's entities barrel;
|
|
191867
|
-
// fields/access are validated there, not re-validated here.
|
|
191868
|
-
fields: candidate.fields,
|
|
191869
|
-
access: candidate.access
|
|
191870
|
-
});
|
|
191960
|
+
} else {
|
|
191961
|
+
try {
|
|
191962
|
+
const entityModule = await import(`file://${indexPath}`);
|
|
191963
|
+
for (const value of Object.values(entityModule)) {
|
|
191964
|
+
const entity = toLoadedEntity(value);
|
|
191965
|
+
if (entity) entities.push(entity);
|
|
191966
|
+
}
|
|
191967
|
+
} catch (err) {
|
|
191968
|
+
log2.error(`Failed to import entities:`, err);
|
|
191871
191969
|
}
|
|
191872
191970
|
}
|
|
191971
|
+
const features = await loadFeatureEntities(
|
|
191972
|
+
appDir,
|
|
191973
|
+
new Set(entities.map((entity) => entity.collection))
|
|
191974
|
+
);
|
|
191975
|
+
for (const { entity } of features) {
|
|
191976
|
+
const loaded = toLoadedEntity(entity);
|
|
191977
|
+
if (loaded) entities.push(loaded);
|
|
191978
|
+
}
|
|
191873
191979
|
return entities;
|
|
191874
191980
|
}
|
|
191875
191981
|
function detectProvider(appDir) {
|
|
@@ -192066,7 +192172,7 @@ async function createDbContext(options = {}) {
|
|
|
192066
192172
|
"Cannot detect database provider. Expected supabase/ or firebase.json in your app directory."
|
|
192067
192173
|
);
|
|
192068
192174
|
}
|
|
192069
|
-
const entities2 = await loadEntities(projectRoot);
|
|
192175
|
+
const entities2 = await loadEntities(projectRoot, projectRoot);
|
|
192070
192176
|
if (rootProvider === "firebase") {
|
|
192071
192177
|
return createFirebaseContext(
|
|
192072
192178
|
projectRoot,
|
|
@@ -192077,7 +192183,7 @@ async function createDbContext(options = {}) {
|
|
|
192077
192183
|
}
|
|
192078
192184
|
return createSupabaseContext(projectRoot, projectRoot, framework, entities2);
|
|
192079
192185
|
}
|
|
192080
|
-
const entities = await loadEntities(projectRoot);
|
|
192186
|
+
const entities = await loadEntities(projectRoot, appDir);
|
|
192081
192187
|
if (provider === "firebase") {
|
|
192082
192188
|
return createFirebaseContext(projectRoot, appDir, framework, entities);
|
|
192083
192189
|
}
|
package/dist/bin/commands/db.js
CHANGED
|
@@ -9078,6 +9078,9 @@ var init_typed_file_operations = __esm({
|
|
|
9078
9078
|
});
|
|
9079
9079
|
|
|
9080
9080
|
// packages/tooling/src/utils/type-guards.ts
|
|
9081
|
+
function isRecord(value) {
|
|
9082
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9083
|
+
}
|
|
9081
9084
|
function isObjectLike(value) {
|
|
9082
9085
|
return typeof value === "object" && value !== null;
|
|
9083
9086
|
}
|
|
@@ -51531,6 +51534,100 @@ var init_supabase = __esm({
|
|
|
51531
51534
|
}
|
|
51532
51535
|
});
|
|
51533
51536
|
|
|
51537
|
+
// packages/tooling/src/generators/frameworkEntities.ts
|
|
51538
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
51539
|
+
import { pathToFileURL } from "node:url";
|
|
51540
|
+
function valueAt(config, path) {
|
|
51541
|
+
let value = config;
|
|
51542
|
+
for (const key of path) {
|
|
51543
|
+
if (!isRecord(value)) return void 0;
|
|
51544
|
+
value = value[key];
|
|
51545
|
+
}
|
|
51546
|
+
return value;
|
|
51547
|
+
}
|
|
51548
|
+
function isEntityExport(value) {
|
|
51549
|
+
return isObjectLike(value) && typeof value.name === "string" && value.name !== "" && typeof value.collection === "string" && value.collection !== "" && isRecord(value.fields);
|
|
51550
|
+
}
|
|
51551
|
+
async function readAppConfig(appDir) {
|
|
51552
|
+
const file = joinPath(appDir, ...APP_CONFIG_FILE);
|
|
51553
|
+
if (!pathExists(file, true)) return null;
|
|
51554
|
+
const mod3 = await import(pathToFileURL(file).href);
|
|
51555
|
+
const appConfig = isRecord(mod3) ? mod3.appConfig : void 0;
|
|
51556
|
+
if (!isRecord(appConfig)) {
|
|
51557
|
+
throw new DoNotDevError(
|
|
51558
|
+
`${file} does not export an appConfig object (export const appConfig: AppConfig = { \u2026 }).`,
|
|
51559
|
+
DO_NOT_DEV_ERROR_CODES.CONFIGURATION_ERROR
|
|
51560
|
+
);
|
|
51561
|
+
}
|
|
51562
|
+
return appConfig;
|
|
51563
|
+
}
|
|
51564
|
+
function isEnabled(appConfig, feature) {
|
|
51565
|
+
const setting = valueAt(appConfig, feature.configPath);
|
|
51566
|
+
return setting !== void 0 && setting !== null && setting !== false;
|
|
51567
|
+
}
|
|
51568
|
+
async function loadFeatureEntities(appDir, exclude = /* @__PURE__ */ new Set(), features = FRAMEWORK_ENTITY_FEATURES) {
|
|
51569
|
+
if (!appDir) {
|
|
51570
|
+
log2.info("App folder unknown: framework feature entities skipped (pass --app-dir).");
|
|
51571
|
+
return [];
|
|
51572
|
+
}
|
|
51573
|
+
const appConfig = await readAppConfig(appDir);
|
|
51574
|
+
if (!appConfig) {
|
|
51575
|
+
log2.info(
|
|
51576
|
+
`No ${APP_CONFIG_FILE.join("/")} in ${appDir}: framework feature entities skipped.`
|
|
51577
|
+
);
|
|
51578
|
+
return [];
|
|
51579
|
+
}
|
|
51580
|
+
const configFile = joinPath(appDir, ...APP_CONFIG_FILE);
|
|
51581
|
+
const found = [];
|
|
51582
|
+
for (const feature of features) {
|
|
51583
|
+
if (!isEnabled(appConfig, feature)) continue;
|
|
51584
|
+
let resolved;
|
|
51585
|
+
try {
|
|
51586
|
+
resolved = createRequire4(configFile).resolve(feature.module);
|
|
51587
|
+
} catch {
|
|
51588
|
+
log2.warn(
|
|
51589
|
+
`Feature ${feature.name} is on (appConfig.${feature.configPath.join(".")}) but ${feature.packageName} is not installed in ${appDir}: its tables are skipped. Install ${feature.packageName}.`
|
|
51590
|
+
);
|
|
51591
|
+
continue;
|
|
51592
|
+
}
|
|
51593
|
+
const mod3 = await import(pathToFileURL(resolved).href);
|
|
51594
|
+
if (!isRecord(mod3)) continue;
|
|
51595
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51596
|
+
for (const value of Object.values(mod3)) {
|
|
51597
|
+
if (!isEntityExport(value) || seen.has(value.collection)) continue;
|
|
51598
|
+
seen.add(value.collection);
|
|
51599
|
+
if (exclude.has(value.collection)) {
|
|
51600
|
+
log2.info(
|
|
51601
|
+
`${value.collection}: defined by the app's entity files and by feature ${feature.name}; one table.`
|
|
51602
|
+
);
|
|
51603
|
+
continue;
|
|
51604
|
+
}
|
|
51605
|
+
found.push({ entity: value, feature: feature.name, path: resolved });
|
|
51606
|
+
}
|
|
51607
|
+
}
|
|
51608
|
+
return found;
|
|
51609
|
+
}
|
|
51610
|
+
var FRAMEWORK_ENTITY_FEATURES, APP_CONFIG_FILE;
|
|
51611
|
+
var init_frameworkEntities = __esm({
|
|
51612
|
+
"packages/tooling/src/generators/frameworkEntities.ts"() {
|
|
51613
|
+
"use strict";
|
|
51614
|
+
init_utils2();
|
|
51615
|
+
init_cli_output();
|
|
51616
|
+
init_errors();
|
|
51617
|
+
init_pathResolver();
|
|
51618
|
+
init_type_guards();
|
|
51619
|
+
FRAMEWORK_ENTITY_FEATURES = [
|
|
51620
|
+
{
|
|
51621
|
+
name: "chatbot",
|
|
51622
|
+
configPath: ["ai", "chatbot"],
|
|
51623
|
+
module: "@donotdev/ai/entities",
|
|
51624
|
+
packageName: "@donotdev/ai"
|
|
51625
|
+
}
|
|
51626
|
+
];
|
|
51627
|
+
APP_CONFIG_FILE = ["src", "config", "app.ts"];
|
|
51628
|
+
}
|
|
51629
|
+
});
|
|
51630
|
+
|
|
51534
51631
|
// node_modules/.bun/firebase-admin@14.5.1+c188cf0323c41673/node_modules/firebase-admin/lib/firestore/error.js
|
|
51535
51632
|
var require_error4 = __commonJS({
|
|
51536
51633
|
"node_modules/.bun/firebase-admin@14.5.1+c188cf0323c41673/node_modules/firebase-admin/lib/firestore/error.js"(exports) {
|
|
@@ -191802,44 +191899,53 @@ init_create_utils();
|
|
|
191802
191899
|
// packages/tooling/src/db/context.ts
|
|
191803
191900
|
init_utils2();
|
|
191804
191901
|
init_supabase();
|
|
191902
|
+
init_frameworkEntities();
|
|
191805
191903
|
init_app_selector();
|
|
191806
191904
|
init_cli_output();
|
|
191807
191905
|
init_pathResolver();
|
|
191808
191906
|
init_secrets_resolver();
|
|
191809
191907
|
init_type_guards();
|
|
191810
|
-
|
|
191908
|
+
function toLoadedEntity(value) {
|
|
191909
|
+
if (!isObjectLike(value)) return null;
|
|
191910
|
+
if (typeof value.name === "string" && value.name && typeof value.collection === "string" && value.collection && value.fields) {
|
|
191911
|
+
return {
|
|
191912
|
+
name: value.name,
|
|
191913
|
+
collection: value.collection,
|
|
191914
|
+
// why: shape produced by defineEntity() (the app's entities barrel or a framework
|
|
191915
|
+
// feature's entities module); fields/access are validated there, not re-validated here.
|
|
191916
|
+
fields: value.fields,
|
|
191917
|
+
access: value.access
|
|
191918
|
+
};
|
|
191919
|
+
}
|
|
191920
|
+
return null;
|
|
191921
|
+
}
|
|
191922
|
+
async function loadEntities(projectRoot, appDir) {
|
|
191923
|
+
const entities = [];
|
|
191811
191924
|
const entitiesDir = joinPath(projectRoot, "entities");
|
|
191925
|
+
const indexPath = joinPath(entitiesDir, "index.ts");
|
|
191812
191926
|
if (!pathExists(entitiesDir)) {
|
|
191813
191927
|
log2.warn("No entities/ directory found");
|
|
191814
|
-
|
|
191815
|
-
}
|
|
191816
|
-
const indexPath = joinPath(entitiesDir, "index.ts");
|
|
191817
|
-
if (!pathExists(indexPath)) {
|
|
191928
|
+
} else if (!pathExists(indexPath)) {
|
|
191818
191929
|
log2.warn("No entities/index.ts found");
|
|
191819
|
-
|
|
191820
|
-
|
|
191821
|
-
|
|
191822
|
-
|
|
191823
|
-
|
|
191824
|
-
|
|
191825
|
-
|
|
191826
|
-
|
|
191827
|
-
|
|
191828
|
-
const entities = [];
|
|
191829
|
-
for (const [key, value] of Object.entries(entityModule)) {
|
|
191830
|
-
if (!isObjectLike(value)) continue;
|
|
191831
|
-
const candidate = value;
|
|
191832
|
-
if (typeof candidate.name === "string" && candidate.name && typeof candidate.collection === "string" && candidate.collection && candidate.fields) {
|
|
191833
|
-
entities.push({
|
|
191834
|
-
name: candidate.name,
|
|
191835
|
-
collection: candidate.collection,
|
|
191836
|
-
// why: shape produced by defineEntity() in the app's entities barrel;
|
|
191837
|
-
// fields/access are validated there, not re-validated here.
|
|
191838
|
-
fields: candidate.fields,
|
|
191839
|
-
access: candidate.access
|
|
191840
|
-
});
|
|
191930
|
+
} else {
|
|
191931
|
+
try {
|
|
191932
|
+
const entityModule = await import(`file://${indexPath}`);
|
|
191933
|
+
for (const value of Object.values(entityModule)) {
|
|
191934
|
+
const entity = toLoadedEntity(value);
|
|
191935
|
+
if (entity) entities.push(entity);
|
|
191936
|
+
}
|
|
191937
|
+
} catch (err) {
|
|
191938
|
+
log2.error(`Failed to import entities:`, err);
|
|
191841
191939
|
}
|
|
191842
191940
|
}
|
|
191941
|
+
const features = await loadFeatureEntities(
|
|
191942
|
+
appDir,
|
|
191943
|
+
new Set(entities.map((entity) => entity.collection))
|
|
191944
|
+
);
|
|
191945
|
+
for (const { entity } of features) {
|
|
191946
|
+
const loaded = toLoadedEntity(entity);
|
|
191947
|
+
if (loaded) entities.push(loaded);
|
|
191948
|
+
}
|
|
191843
191949
|
return entities;
|
|
191844
191950
|
}
|
|
191845
191951
|
function detectProvider(appDir) {
|
|
@@ -192036,7 +192142,7 @@ async function createDbContext(options = {}) {
|
|
|
192036
192142
|
"Cannot detect database provider. Expected supabase/ or firebase.json in your app directory."
|
|
192037
192143
|
);
|
|
192038
192144
|
}
|
|
192039
|
-
const entities2 = await loadEntities(projectRoot);
|
|
192145
|
+
const entities2 = await loadEntities(projectRoot, projectRoot);
|
|
192040
192146
|
if (rootProvider === "firebase") {
|
|
192041
192147
|
return createFirebaseContext(
|
|
192042
192148
|
projectRoot,
|
|
@@ -192047,7 +192153,7 @@ async function createDbContext(options = {}) {
|
|
|
192047
192153
|
}
|
|
192048
192154
|
return createSupabaseContext(projectRoot, projectRoot, framework, entities2);
|
|
192049
192155
|
}
|
|
192050
|
-
const entities = await loadEntities(projectRoot);
|
|
192156
|
+
const entities = await loadEntities(projectRoot, appDir);
|
|
192051
192157
|
if (provider === "firebase") {
|
|
192052
192158
|
return createFirebaseContext(projectRoot, appDir, framework, entities);
|
|
192053
192159
|
}
|