@topogram/cli 0.3.34
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/ARCHITECTURE.md +67 -0
- package/CHANGELOG.md +240 -0
- package/README.md +223 -0
- package/package.json +51 -0
- package/src/adoption/index.js +3 -0
- package/src/adoption/plan.js +702 -0
- package/src/adoption/reporting.js +464 -0
- package/src/adoption/review-groups.js +313 -0
- package/src/agent-ops/query-builders.js +5012 -0
- package/src/archive/archive.js +141 -0
- package/src/archive/compact.js +26 -0
- package/src/archive/jsonl.js +70 -0
- package/src/archive/resolver-bridge.js +82 -0
- package/src/archive/schema.js +87 -0
- package/src/archive/unarchive.js +108 -0
- package/src/catalog.js +752 -0
- package/src/cli/catalog-alias.js +166 -0
- package/src/cli.js +9738 -0
- package/src/component-behavior.js +173 -0
- package/src/example-implementation.js +91 -0
- package/src/format.js +19 -0
- package/src/generator/adapters.d.ts +4 -0
- package/src/generator/adapters.js +325 -0
- package/src/generator/api.d.ts +1 -0
- package/src/generator/api.js +1196 -0
- package/src/generator/check.js +355 -0
- package/src/generator/component-conformance.js +767 -0
- package/src/generator/components.js +39 -0
- package/src/generator/context/bundle.js +291 -0
- package/src/generator/context/diff.js +256 -0
- package/src/generator/context/digest.js +182 -0
- package/src/generator/context/domain-coverage.js +94 -0
- package/src/generator/context/domain-page.js +137 -0
- package/src/generator/context/index.js +42 -0
- package/src/generator/context/report.js +121 -0
- package/src/generator/context/shared.js +1397 -0
- package/src/generator/context/slice.js +703 -0
- package/src/generator/context/task-mode.js +466 -0
- package/src/generator/docs.js +327 -0
- package/src/generator/index.js +161 -0
- package/src/generator/native/parity-bundle.js +311 -0
- package/src/generator/output.js +300 -0
- package/src/generator/registry.js +482 -0
- package/src/generator/runtime/app-bundle.js +456 -0
- package/src/generator/runtime/bundle-shared.js +166 -0
- package/src/generator/runtime/compile-check.js +163 -0
- package/src/generator/runtime/deployment.js +287 -0
- package/src/generator/runtime/environment.js +635 -0
- package/src/generator/runtime/index.js +32 -0
- package/src/generator/runtime/runtime-check.js +554 -0
- package/src/generator/runtime/shared.js +515 -0
- package/src/generator/runtime/smoke.js +219 -0
- package/src/generator/schema.js +204 -0
- package/src/generator/sdlc/board.js +66 -0
- package/src/generator/sdlc/doc-page.js +53 -0
- package/src/generator/sdlc/index.js +23 -0
- package/src/generator/sdlc/release-notes.js +62 -0
- package/src/generator/sdlc/traceability-matrix.js +65 -0
- package/src/generator/shared.js +29 -0
- package/src/generator/surfaces/contracts.js +146 -0
- package/src/generator/surfaces/databases/contract.js +40 -0
- package/src/generator/surfaces/databases/index.js +84 -0
- package/src/generator/surfaces/databases/lifecycle-shared.d.ts +1 -0
- package/src/generator/surfaces/databases/lifecycle-shared.js +612 -0
- package/src/generator/surfaces/databases/migration-plan.js +281 -0
- package/src/generator/surfaces/databases/postgres/capabilities.js +14 -0
- package/src/generator/surfaces/databases/postgres/drizzle.js +99 -0
- package/src/generator/surfaces/databases/postgres/index.js +9 -0
- package/src/generator/surfaces/databases/postgres/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/postgres/prisma.js +159 -0
- package/src/generator/surfaces/databases/postgres/sql-migration.js +102 -0
- package/src/generator/surfaces/databases/postgres/sql-schema.js +34 -0
- package/src/generator/surfaces/databases/shared.d.ts +1 -0
- package/src/generator/surfaces/databases/shared.js +350 -0
- package/src/generator/surfaces/databases/snapshot.js +96 -0
- package/src/generator/surfaces/databases/sqlite/capabilities.js +14 -0
- package/src/generator/surfaces/databases/sqlite/index.js +8 -0
- package/src/generator/surfaces/databases/sqlite/lifecycle.js +16 -0
- package/src/generator/surfaces/databases/sqlite/prisma.js +143 -0
- package/src/generator/surfaces/databases/sqlite/sql-migration.js +65 -0
- package/src/generator/surfaces/databases/sqlite/sql-schema.js +27 -0
- package/src/generator/surfaces/index.js +25 -0
- package/src/generator/surfaces/native/swiftui-app.js +38 -0
- package/src/generator/surfaces/native/swiftui-templates/Package.swift.txt +20 -0
- package/src/generator/surfaces/native/swiftui-templates/README.generated.md +26 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/DynamicScreens.swift +682 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoAPIClient.swift +156 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/TodoSwiftUIApp.swift +44 -0
- package/src/generator/surfaces/native/swiftui-templates/runtime/Visibility.swift +183 -0
- package/src/generator/surfaces/services/express.d.ts +1 -0
- package/src/generator/surfaces/services/express.js +766 -0
- package/src/generator/surfaces/services/hono.d.ts +1 -0
- package/src/generator/surfaces/services/hono.js +204 -0
- package/src/generator/surfaces/services/index.js +42 -0
- package/src/generator/surfaces/services/persistence-wiring.js +240 -0
- package/src/generator/surfaces/services/runtime-helpers.js +631 -0
- package/src/generator/surfaces/services/server-contract.js +80 -0
- package/src/generator/surfaces/services/stateless.d.ts +1 -0
- package/src/generator/surfaces/services/stateless.js +97 -0
- package/src/generator/surfaces/shared.js +64 -0
- package/src/generator/surfaces/web/api-client.js +1 -0
- package/src/generator/surfaces/web/forms.js +1 -0
- package/src/generator/surfaces/web/index.d.ts +2 -0
- package/src/generator/surfaces/web/index.js +53 -0
- package/src/generator/surfaces/web/react-components.js +248 -0
- package/src/generator/surfaces/web/react.js +538 -0
- package/src/generator/surfaces/web/routes.js +1 -0
- package/src/generator/surfaces/web/screens.js +1 -0
- package/src/generator/surfaces/web/shared.js +369 -0
- package/src/generator/surfaces/web/sveltekit-actions.js +28 -0
- package/src/generator/surfaces/web/sveltekit-components.js +234 -0
- package/src/generator/surfaces/web/sveltekit.js +426 -0
- package/src/generator/surfaces/web/ui-web-contract.js +65 -0
- package/src/generator/surfaces/web/vanilla.js +239 -0
- package/src/generator/verification.js +84 -0
- package/src/generator.js +1 -0
- package/src/import/core/context.js +52 -0
- package/src/import/core/contracts.js +23 -0
- package/src/import/core/registry.js +81 -0
- package/src/import/core/runner.js +646 -0
- package/src/import/core/shared.js +910 -0
- package/src/import/enrichers/auth-session.js +18 -0
- package/src/import/enrichers/django-rest.js +226 -0
- package/src/import/enrichers/doc-linking.js +20 -0
- package/src/import/enrichers/rails-controllers.js +246 -0
- package/src/import/enrichers/rails-models.js +130 -0
- package/src/import/enrichers/workflow-target-state.js +10 -0
- package/src/import/extractors/api/aspnet-core.js +304 -0
- package/src/import/extractors/api/django-routes.js +318 -0
- package/src/import/extractors/api/express.js +154 -0
- package/src/import/extractors/api/fastify.js +371 -0
- package/src/import/extractors/api/flutter-dio.js +135 -0
- package/src/import/extractors/api/generic-route-fallback.js +90 -0
- package/src/import/extractors/api/graphql-code-first.js +565 -0
- package/src/import/extractors/api/graphql-sdl.js +309 -0
- package/src/import/extractors/api/jaxrs.js +303 -0
- package/src/import/extractors/api/micronaut.js +213 -0
- package/src/import/extractors/api/next-route.js +50 -0
- package/src/import/extractors/api/next-server-action.js +51 -0
- package/src/import/extractors/api/nextauth.js +52 -0
- package/src/import/extractors/api/openapi-code.js +242 -0
- package/src/import/extractors/api/openapi.js +232 -0
- package/src/import/extractors/api/rails-routes.js +230 -0
- package/src/import/extractors/api/react-native-repository.js +128 -0
- package/src/import/extractors/api/retrofit.js +103 -0
- package/src/import/extractors/api/spring-web.js +372 -0
- package/src/import/extractors/api/swift-webapi.js +116 -0
- package/src/import/extractors/api/trpc.js +212 -0
- package/src/import/extractors/db/django-models.js +232 -0
- package/src/import/extractors/db/dotnet-models.js +93 -0
- package/src/import/extractors/db/drizzle.js +242 -0
- package/src/import/extractors/db/ef-core.js +221 -0
- package/src/import/extractors/db/flutter-entities.js +120 -0
- package/src/import/extractors/db/jpa.js +120 -0
- package/src/import/extractors/db/liquibase.js +180 -0
- package/src/import/extractors/db/mybatis-xml.js +145 -0
- package/src/import/extractors/db/prisma.js +185 -0
- package/src/import/extractors/db/rails-schema.js +175 -0
- package/src/import/extractors/db/react-native-entities.js +95 -0
- package/src/import/extractors/db/room.js +193 -0
- package/src/import/extractors/db/snapshot.js +112 -0
- package/src/import/extractors/db/sql.js +180 -0
- package/src/import/extractors/db/swiftdata.js +137 -0
- package/src/import/extractors/ui/android-compose.js +230 -0
- package/src/import/extractors/ui/backend-only.js +70 -0
- package/src/import/extractors/ui/blazor.js +227 -0
- package/src/import/extractors/ui/flutter-screens.js +152 -0
- package/src/import/extractors/ui/maui-xaml.js +135 -0
- package/src/import/extractors/ui/next-app-router.js +83 -0
- package/src/import/extractors/ui/next-pages-router.js +141 -0
- package/src/import/extractors/ui/razor-pages.js +181 -0
- package/src/import/extractors/ui/react-native-screens.js +166 -0
- package/src/import/extractors/ui/react-router.js +139 -0
- package/src/import/extractors/ui/sveltekit.js +123 -0
- package/src/import/extractors/ui/swiftui.js +193 -0
- package/src/import/extractors/ui/uikit.js +175 -0
- package/src/import/extractors/verification/generic.js +290 -0
- package/src/import/extractors/workflows/generic.js +137 -0
- package/src/import/index.js +7 -0
- package/src/import/provenance.js +158 -0
- package/src/new-project.js +2107 -0
- package/src/parser.js +439 -0
- package/src/policy/review-boundaries.js +165 -0
- package/src/project-config.js +535 -0
- package/src/proofs/backend-parity.js +19 -0
- package/src/proofs/contract-audit.js +220 -0
- package/src/proofs/ios-parity.js +7 -0
- package/src/proofs/issues-parity.js +10 -0
- package/src/proofs/web-parity.js +50 -0
- package/src/realization/api/build-api-realization.js +5 -0
- package/src/realization/api/index.js +1 -0
- package/src/realization/backend/build-backend-runtime-realization.js +82 -0
- package/src/realization/backend/index.d.ts +1 -0
- package/src/realization/backend/index.js +4 -0
- package/src/realization/db/build-db-realization.js +17 -0
- package/src/realization/db/index.js +3 -0
- package/src/realization/db/migration-plan.js +5 -0
- package/src/realization/db/snapshot.js +5 -0
- package/src/realization/ui/build-ui-shared-realization.js +305 -0
- package/src/realization/ui/build-web-realization.js +189 -0
- package/src/realization/ui/index.js +2 -0
- package/src/reconcile/docs.js +280 -0
- package/src/reconcile/index.js +3 -0
- package/src/reconcile/journeys.js +441 -0
- package/src/resolver/docs.js +1 -0
- package/src/resolver/enrich/acceptance-criterion.js +14 -0
- package/src/resolver/enrich/bug.js +12 -0
- package/src/resolver/enrich/component.js +2 -0
- package/src/resolver/enrich/index.js +1 -0
- package/src/resolver/enrich/pitch.js +18 -0
- package/src/resolver/enrich/requirement.js +20 -0
- package/src/resolver/enrich/task.js +16 -0
- package/src/resolver/expressions.js +1 -0
- package/src/resolver/index.js +2422 -0
- package/src/resolver/normalize.js +1 -0
- package/src/resolver.js +1 -0
- package/src/sdlc/adopt.js +65 -0
- package/src/sdlc/check.js +86 -0
- package/src/sdlc/dod/acceptance-criterion.js +22 -0
- package/src/sdlc/dod/bug.js +26 -0
- package/src/sdlc/dod/document.js +23 -0
- package/src/sdlc/dod/index.js +25 -0
- package/src/sdlc/dod/pitch.js +23 -0
- package/src/sdlc/dod/requirement.js +34 -0
- package/src/sdlc/dod/task.js +39 -0
- package/src/sdlc/explain.js +116 -0
- package/src/sdlc/history.js +80 -0
- package/src/sdlc/paths.js +11 -0
- package/src/sdlc/release.js +106 -0
- package/src/sdlc/scaffold.js +89 -0
- package/src/sdlc/status-filter.js +54 -0
- package/src/sdlc/transition.js +112 -0
- package/src/sdlc/transitions/acceptance-criterion.js +28 -0
- package/src/sdlc/transitions/bug.js +31 -0
- package/src/sdlc/transitions/document.js +29 -0
- package/src/sdlc/transitions/index.js +56 -0
- package/src/sdlc/transitions/pitch.js +34 -0
- package/src/sdlc/transitions/requirement.js +31 -0
- package/src/sdlc/transitions/task.js +34 -0
- package/src/template-trust.js +597 -0
- package/src/validator/expressions.js +1 -0
- package/src/validator/index.js +3424 -0
- package/src/validator/kinds.js +346 -0
- package/src/validator/per-kind/acceptance-criterion.js +91 -0
- package/src/validator/per-kind/bug.js +77 -0
- package/src/validator/per-kind/component.js +274 -0
- package/src/validator/per-kind/domain.js +205 -0
- package/src/validator/per-kind/pitch.js +101 -0
- package/src/validator/per-kind/requirement.js +75 -0
- package/src/validator/per-kind/task.js +96 -0
- package/src/validator/registry.js +1 -0
- package/src/validator/utils.js +12 -0
- package/src/validator.js +1 -0
- package/src/workflows.js +7597 -0
- package/src/workspace-docs.js +265 -0
- package/template-helpers/react.js +5 -0
- package/template-helpers/sveltekit.js +5 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function refList(items) {
|
|
2
|
+
if (!items || items.length === 0) {
|
|
3
|
+
return "_none_";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return items.map((item) => `\`${item.id}\``).join(", ");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function symbolList(items) {
|
|
10
|
+
if (!items || items.length === 0) {
|
|
11
|
+
return "_none_";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return items.map((item) => `\`${item}\``).join(", ");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function fieldSignature(field) {
|
|
18
|
+
const parts = [`\`${field.name}\``, `\`${field.fieldType}\``];
|
|
19
|
+
if (field.requiredness) {
|
|
20
|
+
parts.push(field.requiredness);
|
|
21
|
+
}
|
|
22
|
+
if (field.defaultValue != null) {
|
|
23
|
+
parts.push(`default \`${field.defaultValue}\``);
|
|
24
|
+
}
|
|
25
|
+
if (field.sourceName && field.sourceName !== field.name) {
|
|
26
|
+
parts.push(`from \`${field.sourceName}\``);
|
|
27
|
+
}
|
|
28
|
+
return parts.join(" - ");
|
|
29
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { refList, symbolList } from "../shared.js";
|
|
2
|
+
import { buildUiSharedRealization } from "../../realization/ui/index.js";
|
|
3
|
+
|
|
4
|
+
export function generateUiContractGraph(graph, options = {}) {
|
|
5
|
+
return buildUiSharedRealization(graph, options);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function generateUiContractDebug(graph, options = {}) {
|
|
9
|
+
const contracts = options.projectionId ? [generateUiContractGraph(graph, options)] : Object.values(generateUiContractGraph(graph, options));
|
|
10
|
+
const lines = [];
|
|
11
|
+
|
|
12
|
+
lines.push("# UI Contract Debug");
|
|
13
|
+
lines.push("");
|
|
14
|
+
lines.push(`Generated from \`${graph.root}\``);
|
|
15
|
+
lines.push("");
|
|
16
|
+
|
|
17
|
+
for (const contract of contracts) {
|
|
18
|
+
lines.push(`## \`${contract.projection.id}\` - ${contract.projection.name}`);
|
|
19
|
+
lines.push("");
|
|
20
|
+
lines.push(`Platform: \`${contract.projection.platform}\``);
|
|
21
|
+
lines.push(`Realizes: ${refList(contract.realizes)}`);
|
|
22
|
+
lines.push(`Outputs: ${symbolList(contract.outputs)}`);
|
|
23
|
+
if (contract.appShell) {
|
|
24
|
+
lines.push(`App shell: brand \`${contract.appShell.brand}\`, shell \`${contract.appShell.shell}\``);
|
|
25
|
+
}
|
|
26
|
+
if (contract.navigation) {
|
|
27
|
+
const visibleItems = (contract.navigation.items || []).filter((item) => item.visible);
|
|
28
|
+
lines.push(`Navigation: ${visibleItems.length > 0 ? visibleItems.map((item) => `\`${item.label}\``).join(", ") : "_none_"}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push("");
|
|
31
|
+
|
|
32
|
+
for (const screen of contract.screens) {
|
|
33
|
+
lines.push(`### \`${screen.id}\` - ${screen.title || screen.id}`);
|
|
34
|
+
lines.push("");
|
|
35
|
+
lines.push(`Kind: \`${screen.kind}\``);
|
|
36
|
+
if (screen.loadCapability?.id) {
|
|
37
|
+
lines.push(`Load: \`${screen.loadCapability.id}\``);
|
|
38
|
+
}
|
|
39
|
+
if (screen.submitCapability?.id) {
|
|
40
|
+
lines.push(`Submit: \`${screen.submitCapability.id}\``);
|
|
41
|
+
}
|
|
42
|
+
if (screen.viewShape?.id) {
|
|
43
|
+
lines.push(`View shape: \`${screen.viewShape.id}\``);
|
|
44
|
+
}
|
|
45
|
+
if (screen.itemShape?.id) {
|
|
46
|
+
lines.push(`Item shape: \`${screen.itemShape.id}\``);
|
|
47
|
+
}
|
|
48
|
+
if (screen.inputShape?.id) {
|
|
49
|
+
lines.push(`Input shape: \`${screen.inputShape.id}\``);
|
|
50
|
+
}
|
|
51
|
+
if (screen.navigation.successNavigate) {
|
|
52
|
+
lines.push(`Success navigate: \`${screen.navigation.successNavigate}\``);
|
|
53
|
+
}
|
|
54
|
+
if (screen.navigation.successRefresh) {
|
|
55
|
+
lines.push(`Success refresh: \`${screen.navigation.successRefresh}\``);
|
|
56
|
+
}
|
|
57
|
+
if (screen.emptyState) {
|
|
58
|
+
lines.push(`Empty state: \`${screen.emptyState.title || ""}\` ${screen.emptyState.body ? `- ${screen.emptyState.body}` : ""}`.trim());
|
|
59
|
+
}
|
|
60
|
+
lines.push(
|
|
61
|
+
`States: ${Object.entries(screen.states || {})
|
|
62
|
+
.map(([key, value]) => `\`${key}=${value}\``)
|
|
63
|
+
.join(", ")}`
|
|
64
|
+
);
|
|
65
|
+
if ((screen.patterns || []).length > 0) {
|
|
66
|
+
lines.push(`Patterns: ${(screen.patterns || []).map((pattern) => `\`${pattern}\``).join(", ")}`);
|
|
67
|
+
}
|
|
68
|
+
lines.push("");
|
|
69
|
+
|
|
70
|
+
lines.push("Actions:");
|
|
71
|
+
if (
|
|
72
|
+
!screen.actions.primary?.id &&
|
|
73
|
+
!screen.actions.secondary?.id &&
|
|
74
|
+
!screen.actions.destructive?.id &&
|
|
75
|
+
!screen.actions.terminal?.id &&
|
|
76
|
+
screen.actions.screen.length === 0
|
|
77
|
+
) {
|
|
78
|
+
lines.push("- _none_");
|
|
79
|
+
} else {
|
|
80
|
+
for (const [label, action] of [
|
|
81
|
+
["primary", screen.actions.primary],
|
|
82
|
+
["secondary", screen.actions.secondary],
|
|
83
|
+
["destructive", screen.actions.destructive],
|
|
84
|
+
["terminal", screen.actions.terminal]
|
|
85
|
+
]) {
|
|
86
|
+
if (action?.id) {
|
|
87
|
+
lines.push(`- ${label}: \`${action.id}\``);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const action of screen.actions.screen) {
|
|
91
|
+
lines.push(`- screen action: \`${action.capability?.id}\` (${action.prominence})`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
lines.push("");
|
|
95
|
+
|
|
96
|
+
lines.push("Collection:");
|
|
97
|
+
lines.push(`- filters: ${screen.collection.filters.length > 0 ? screen.collection.filters.map((field) => `\`${field}\``).join(", ") : "_none_"}`);
|
|
98
|
+
lines.push(`- search: ${screen.collection.search.length > 0 ? screen.collection.search.map((field) => `\`${field}\``).join(", ") : "_none_"}`);
|
|
99
|
+
lines.push(`- pagination: ${screen.collection.pagination ? `\`${screen.collection.pagination}\`` : "_none_"}`);
|
|
100
|
+
lines.push(`- views: ${screen.collection.views.length > 0 ? screen.collection.views.map((view) => `\`${view}\``).join(", ") : "_none_"}`);
|
|
101
|
+
lines.push(`- groupBy: ${screen.collection.groupBy.length > 0 ? screen.collection.groupBy.map((field) => `\`${field}\``).join(", ") : "_none_"}`);
|
|
102
|
+
lines.push(
|
|
103
|
+
`- sort: ${
|
|
104
|
+
screen.collection.sort.length > 0
|
|
105
|
+
? screen.collection.sort.map((entry) => `\`${entry.field}\` ${entry.direction}`).join(", ")
|
|
106
|
+
: "_none_"
|
|
107
|
+
}`
|
|
108
|
+
);
|
|
109
|
+
lines.push("");
|
|
110
|
+
|
|
111
|
+
lines.push("Visibility:");
|
|
112
|
+
if (screen.visibility.length === 0) {
|
|
113
|
+
lines.push("- _none_");
|
|
114
|
+
} else {
|
|
115
|
+
for (const rule of screen.visibility) {
|
|
116
|
+
lines.push(`- \`${rule.capability?.id}\` visible_if ${rule.predicate} \`${rule.value}\`${rule.claimValue ? ` claim_value \`${rule.claimValue}\`` : ""}${rule.ownershipField ? ` ownership_field \`${rule.ownershipField}\`` : ""}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
lines.push("");
|
|
120
|
+
|
|
121
|
+
lines.push("Lookups:");
|
|
122
|
+
if (screen.lookups.length === 0) {
|
|
123
|
+
lines.push("- _none_");
|
|
124
|
+
} else {
|
|
125
|
+
for (const lookup of screen.lookups) {
|
|
126
|
+
lines.push(
|
|
127
|
+
`- field \`${lookup.field}\` -> entity \`${lookup.entity?.id}\` label_field \`${lookup.labelField}\`${lookup.emptyLabel ? ` empty_label "${lookup.emptyLabel}"` : ""}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
lines.push("");
|
|
132
|
+
|
|
133
|
+
lines.push("Regions:");
|
|
134
|
+
if (screen.regions.length === 0) {
|
|
135
|
+
lines.push("- _none_");
|
|
136
|
+
} else {
|
|
137
|
+
for (const region of screen.regions) {
|
|
138
|
+
lines.push(`- \`${region.region}\`${region.pattern ? ` pattern \`${region.pattern}\`` : ""}${region.placement ? ` placement \`${region.placement}\`` : ""}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
lines.push("");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
146
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { buildDbRealization } from "../../../realization/db/index.js";
|
|
2
|
+
|
|
3
|
+
export function generateDbContractGraph(graph, options = {}) {
|
|
4
|
+
return buildDbRealization(graph, options);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function generateDbContractDebug(graph, options = {}) {
|
|
8
|
+
const contracts = options.projectionId ? [generateDbContractGraph(graph, options)] : Object.values(generateDbContractGraph(graph, options));
|
|
9
|
+
const lines = [];
|
|
10
|
+
|
|
11
|
+
lines.push("# DB Contract Debug");
|
|
12
|
+
lines.push("");
|
|
13
|
+
lines.push(`Generated from \`${graph.root}\``);
|
|
14
|
+
lines.push("");
|
|
15
|
+
|
|
16
|
+
for (const contract of contracts) {
|
|
17
|
+
lines.push(`## \`${contract.projection.id}\` - ${contract.projection.name}`);
|
|
18
|
+
lines.push("");
|
|
19
|
+
lines.push(`Platform: \`${contract.projection.platform}\``);
|
|
20
|
+
lines.push(`Profile: \`${contract.profile}\``);
|
|
21
|
+
lines.push("");
|
|
22
|
+
|
|
23
|
+
for (const table of contract.tables) {
|
|
24
|
+
lines.push(`### \`${table.table}\` <- \`${table.entity.id}\``);
|
|
25
|
+
lines.push("");
|
|
26
|
+
lines.push("Columns:");
|
|
27
|
+
for (const column of table.columns) {
|
|
28
|
+
lines.push(`- \`${column.name}\` <- \`${column.sourceField}\` : \`${column.fieldType}\` ${column.requiredness}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push(`Primary key: ${table.primaryKey.length > 0 ? table.primaryKey.map((field) => `\`${field}\``).join(", ") : "_none_"}`);
|
|
31
|
+
lines.push(`Unique: ${table.uniques.length > 0 ? table.uniques.map((fields) => `[${fields.join(", ")}]`).join(", ") : "_none_"}`);
|
|
32
|
+
lines.push(`Indexes: ${table.indexes.length > 0 ? table.indexes.map((entry) => `${entry.type}[${entry.fields.join(", ")}]`).join(", ") : "_none_"}`);
|
|
33
|
+
lines.push(`Relations: ${table.relations.length > 0 ? table.relations.map((entry) => `\`${entry.field}\` -> \`${entry.target?.id}.${entry.target?.field}\`${entry.onDelete ? ` on_delete ${entry.onDelete}` : ""}`).join(", ") : "_none_"}`);
|
|
34
|
+
lines.push(`Lifecycle: ${table.lifecycle.softDelete ? `soft_delete(${table.lifecycle.softDelete.field}=${table.lifecycle.softDelete.value})` : "_none_"}${table.lifecycle.timestamps ? `, timestamps(${table.lifecycle.timestamps.createdAt}, ${table.lifecycle.timestamps.updatedAt})` : ""}`);
|
|
35
|
+
lines.push("");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${lines.join("\n").trimEnd()}\n`;
|
|
40
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateDbContractDebug,
|
|
3
|
+
generateDbContractGraph
|
|
4
|
+
} from "./contract.js";
|
|
5
|
+
import { generateWithComponentGenerator } from "../../adapters.js";
|
|
6
|
+
import { generateDbLifecyclePlan } from "./lifecycle-shared.js";
|
|
7
|
+
import { generateDbSchemaSnapshot } from "./snapshot.js";
|
|
8
|
+
import { generateDbMigrationPlan } from "./migration-plan.js";
|
|
9
|
+
import { getDbFamily } from "./shared.js";
|
|
10
|
+
import {
|
|
11
|
+
generatePostgresDbLifecycleBundle,
|
|
12
|
+
generatePostgresDbLifecyclePlan,
|
|
13
|
+
generatePostgresDrizzleSchema,
|
|
14
|
+
generatePostgresPrismaSchema,
|
|
15
|
+
generatePostgresSqlMigration,
|
|
16
|
+
generatePostgresSqlSchema
|
|
17
|
+
} from "./postgres/index.js";
|
|
18
|
+
import {
|
|
19
|
+
generateSqliteDbLifecycleBundle,
|
|
20
|
+
generateSqliteDbLifecyclePlan,
|
|
21
|
+
generateSqlitePrismaSchema,
|
|
22
|
+
generateSqliteSqlMigration,
|
|
23
|
+
generateSqliteSqlSchema
|
|
24
|
+
} from "./sqlite/index.js";
|
|
25
|
+
|
|
26
|
+
export function generateDbTarget(target, graph, options = {}) {
|
|
27
|
+
const family = getDbFamily(options);
|
|
28
|
+
|
|
29
|
+
if (target === "db-contract-graph") {
|
|
30
|
+
return generateDbContractGraph(graph, options);
|
|
31
|
+
}
|
|
32
|
+
if (target === "db-contract-debug") {
|
|
33
|
+
return generateDbContractDebug(graph, options);
|
|
34
|
+
}
|
|
35
|
+
if (target === "db-schema-snapshot") {
|
|
36
|
+
return generateDbSchemaSnapshot(graph, options);
|
|
37
|
+
}
|
|
38
|
+
if (target === "db-migration-plan") {
|
|
39
|
+
return generateDbMigrationPlan(graph, options);
|
|
40
|
+
}
|
|
41
|
+
if (target === "sql-schema") {
|
|
42
|
+
return family === "sqlite"
|
|
43
|
+
? generateSqliteSqlSchema(graph, options)
|
|
44
|
+
: generatePostgresSqlSchema(graph, options);
|
|
45
|
+
}
|
|
46
|
+
if (target === "sql-migration") {
|
|
47
|
+
return family === "sqlite"
|
|
48
|
+
? generateSqliteSqlMigration(graph, options)
|
|
49
|
+
: generatePostgresSqlMigration(graph, options);
|
|
50
|
+
}
|
|
51
|
+
if (target === "db-lifecycle-plan") {
|
|
52
|
+
if (!options.projectionId) {
|
|
53
|
+
return generateDbLifecyclePlan(graph, options);
|
|
54
|
+
}
|
|
55
|
+
return family === "sqlite"
|
|
56
|
+
? generateSqliteDbLifecyclePlan(graph, options)
|
|
57
|
+
: generatePostgresDbLifecyclePlan(graph, options);
|
|
58
|
+
}
|
|
59
|
+
if (target === "db-lifecycle-bundle") {
|
|
60
|
+
if (options.component?.generator?.id) {
|
|
61
|
+
return generateWithComponentGenerator({
|
|
62
|
+
graph,
|
|
63
|
+
projection: options.component.projection,
|
|
64
|
+
component: options.component,
|
|
65
|
+
topology: options.topology || null,
|
|
66
|
+
implementation: options.implementation || null,
|
|
67
|
+
options
|
|
68
|
+
}).files;
|
|
69
|
+
}
|
|
70
|
+
return family === "sqlite"
|
|
71
|
+
? generateSqliteDbLifecycleBundle(graph, options)
|
|
72
|
+
: generatePostgresDbLifecycleBundle(graph, options);
|
|
73
|
+
}
|
|
74
|
+
if (target === "prisma-schema") {
|
|
75
|
+
return family === "sqlite"
|
|
76
|
+
? generateSqlitePrismaSchema(graph, options)
|
|
77
|
+
: generatePostgresPrismaSchema(graph, options);
|
|
78
|
+
}
|
|
79
|
+
if (target === "drizzle-schema") {
|
|
80
|
+
return generatePostgresDrizzleSchema(graph, options);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
throw new Error(`Unsupported DB generator target '${target}'`);
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function generateDbLifecycleBundleForProjection(graph: any, projection: any, options?: any): any;
|