@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,220 @@
|
|
|
1
|
+
import { stableStringify } from "../format.js";
|
|
2
|
+
|
|
3
|
+
function normalizeVisibility(visibility = []) {
|
|
4
|
+
return [...visibility]
|
|
5
|
+
.map((entry) => ({
|
|
6
|
+
capabilityId: entry.capabilityId ?? null,
|
|
7
|
+
predicate: entry.predicate ?? null,
|
|
8
|
+
value: entry.value ?? null,
|
|
9
|
+
ownershipField: entry.ownershipField ?? null,
|
|
10
|
+
claimValue: entry.claimValue ?? null
|
|
11
|
+
}))
|
|
12
|
+
.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function normalizeScreen(screen) {
|
|
16
|
+
return {
|
|
17
|
+
id: screen.id ?? null,
|
|
18
|
+
route: screen.route ?? null,
|
|
19
|
+
kind: screen.kind ?? null,
|
|
20
|
+
title: screen.title ?? null,
|
|
21
|
+
loadCapabilityId: screen.loadCapability?.id ?? screen.loadCapabilityId ?? null,
|
|
22
|
+
viewShapeId: screen.viewShape?.id ?? screen.viewShapeId ?? null,
|
|
23
|
+
primaryActionId: screen.actions?.primary?.id ?? null,
|
|
24
|
+
secondaryActionId: screen.actions?.secondary?.id ?? null,
|
|
25
|
+
destructiveActionId: screen.actions?.destructive?.id ?? null,
|
|
26
|
+
screenActionIds: (screen.actions?.screen ?? []).map((action) => action.id ?? null).filter(Boolean).sort(),
|
|
27
|
+
visibility: normalizeVisibility(screen.visibility)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function normalizeNavigationItem(item) {
|
|
32
|
+
return {
|
|
33
|
+
screenId: item.screenId ?? null,
|
|
34
|
+
route: item.route ?? null,
|
|
35
|
+
label: item.label ?? null,
|
|
36
|
+
placement: item.placement ?? null,
|
|
37
|
+
visible: item.visible ?? null,
|
|
38
|
+
breadcrumb: item.breadcrumb ?? null,
|
|
39
|
+
pattern: item.pattern ?? null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function normalizeUiContract(contract) {
|
|
44
|
+
return {
|
|
45
|
+
appShell: contract.appShell ?? {},
|
|
46
|
+
navigation: {
|
|
47
|
+
defaultScreenId: contract.navigation?.defaultScreenId ?? null,
|
|
48
|
+
items: (contract.navigation?.items ?? []).map(normalizeNavigationItem).sort((a, b) => stableStringify(a).localeCompare(stableStringify(b))),
|
|
49
|
+
patterns: [...(contract.navigation?.patterns ?? [])].sort()
|
|
50
|
+
},
|
|
51
|
+
screens: (contract.screens ?? []).map(normalizeScreen).sort((a, b) => a.id.localeCompare(b.id))
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function extractServerContractObject(moduleSource) {
|
|
56
|
+
const match = moduleSource.match(/export const serverContract = (\{[\s\S]*\}) as const;\s*$/);
|
|
57
|
+
if (!match) {
|
|
58
|
+
throw new Error("Could not parse emitted server-contract module");
|
|
59
|
+
}
|
|
60
|
+
return JSON.parse(match[1]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function normalizeServerAuthz(authz = []) {
|
|
64
|
+
return [...authz]
|
|
65
|
+
.map((entry) => ({
|
|
66
|
+
role: entry.role ?? null,
|
|
67
|
+
permission: entry.permission ?? null,
|
|
68
|
+
claim: entry.claim ?? null,
|
|
69
|
+
claimValue: entry.claimValue ?? null,
|
|
70
|
+
ownership: entry.ownership ?? null,
|
|
71
|
+
ownershipField: entry.ownershipField ?? null
|
|
72
|
+
}))
|
|
73
|
+
.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function normalizeRoute(route) {
|
|
77
|
+
return {
|
|
78
|
+
capabilityId: route.capabilityId ?? null,
|
|
79
|
+
method: route.method ?? null,
|
|
80
|
+
path: route.path ?? null,
|
|
81
|
+
successStatus: route.successStatus ?? null,
|
|
82
|
+
requestFields: (route.requestContract?.fields ?? [])
|
|
83
|
+
.map((field) => ({
|
|
84
|
+
name: field.name ?? null,
|
|
85
|
+
required: field.required ?? null,
|
|
86
|
+
location: field.transport?.location ?? null,
|
|
87
|
+
wireName: field.transport?.wireName ?? null
|
|
88
|
+
}))
|
|
89
|
+
.sort((a, b) => stableStringify(a).localeCompare(stableStringify(b))),
|
|
90
|
+
errorCases: (route.errorCases ?? [])
|
|
91
|
+
.map((entry) => ({
|
|
92
|
+
code: entry.code ?? null,
|
|
93
|
+
status: entry.status ?? null,
|
|
94
|
+
source: entry.source ?? null
|
|
95
|
+
}))
|
|
96
|
+
.sort((a, b) => stableStringify(a).localeCompare(stableStringify(b))),
|
|
97
|
+
endpoint: {
|
|
98
|
+
auth: route.endpoint?.auth ?? null,
|
|
99
|
+
authz: normalizeServerAuthz(route.endpoint?.authz),
|
|
100
|
+
preconditions: (route.endpoint?.preconditions ?? []).map((entry) => ({
|
|
101
|
+
header: entry.header ?? null,
|
|
102
|
+
required: entry.required ?? null,
|
|
103
|
+
error: entry.error ?? null,
|
|
104
|
+
code: entry.code ?? null
|
|
105
|
+
})),
|
|
106
|
+
idempotency: (route.endpoint?.idempotency ?? []).map((entry) => ({
|
|
107
|
+
header: entry.header ?? null,
|
|
108
|
+
required: entry.required ?? null,
|
|
109
|
+
error: entry.error ?? null,
|
|
110
|
+
code: entry.code ?? null
|
|
111
|
+
}))
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function normalizeServerContract(contract) {
|
|
117
|
+
return {
|
|
118
|
+
projection: {
|
|
119
|
+
id: contract.projection?.id ?? null,
|
|
120
|
+
platform: contract.projection?.platform ?? null
|
|
121
|
+
},
|
|
122
|
+
routes: (contract.routes ?? []).map(normalizeRoute).sort((a, b) => {
|
|
123
|
+
const leftKey = `${a.method}:${a.path}:${a.capabilityId}`;
|
|
124
|
+
const rightKey = `${b.method}:${b.path}:${b.capabilityId}`;
|
|
125
|
+
return leftKey.localeCompare(rightKey);
|
|
126
|
+
})
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function buildScreenDiffs(leftScreens, rightScreens) {
|
|
131
|
+
const rightById = new Map(rightScreens.map((screen) => [screen.id, screen]));
|
|
132
|
+
const leftById = new Map(leftScreens.map((screen) => [screen.id, screen]));
|
|
133
|
+
const diffs = [];
|
|
134
|
+
|
|
135
|
+
for (const screen of leftScreens) {
|
|
136
|
+
const other = rightById.get(screen.id);
|
|
137
|
+
if (!other) {
|
|
138
|
+
diffs.push({ type: "missing_on_right", screenId: screen.id });
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (stableStringify(screen) !== stableStringify(other)) {
|
|
142
|
+
diffs.push({ type: "screen_mismatch", screenId: screen.id });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
for (const screen of rightScreens) {
|
|
147
|
+
if (!leftById.has(screen.id)) {
|
|
148
|
+
diffs.push({ type: "missing_on_left", screenId: screen.id });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return diffs;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function buildRouteDiffs(leftRoutes, rightRoutes) {
|
|
156
|
+
const rightByKey = new Map(rightRoutes.map((route) => [`${route.method}:${route.path}:${route.capabilityId}`, route]));
|
|
157
|
+
const leftByKey = new Map(leftRoutes.map((route) => [`${route.method}:${route.path}:${route.capabilityId}`, route]));
|
|
158
|
+
const diffs = [];
|
|
159
|
+
|
|
160
|
+
for (const route of leftRoutes) {
|
|
161
|
+
const key = `${route.method}:${route.path}:${route.capabilityId}`;
|
|
162
|
+
const other = rightByKey.get(key);
|
|
163
|
+
if (!other) {
|
|
164
|
+
diffs.push({ type: "missing_on_right", route: key });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (stableStringify(route) !== stableStringify(other)) {
|
|
168
|
+
diffs.push({ type: "route_mismatch", route: key });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
for (const route of rightRoutes) {
|
|
173
|
+
const key = `${route.method}:${route.path}:${route.capabilityId}`;
|
|
174
|
+
if (!leftByKey.has(key)) {
|
|
175
|
+
diffs.push({ type: "missing_on_left", route: key });
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return diffs;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function auditUiContractPair(leftContract, rightContract) {
|
|
183
|
+
const left = normalizeUiContract(leftContract);
|
|
184
|
+
const right = normalizeUiContract(rightContract);
|
|
185
|
+
const screenDiffs = buildScreenDiffs(left.screens, right.screens);
|
|
186
|
+
const navigationParity = stableStringify(left.navigation) === stableStringify(right.navigation);
|
|
187
|
+
const appShellParity = stableStringify(left.appShell) === stableStringify(right.appShell);
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
seam: "ui_web_contract",
|
|
191
|
+
semanticParity: screenDiffs.length === 0 && navigationParity && appShellParity,
|
|
192
|
+
summary: {
|
|
193
|
+
screenCount: left.screens.length,
|
|
194
|
+
navigationItemCount: left.navigation.items.length
|
|
195
|
+
},
|
|
196
|
+
differences: {
|
|
197
|
+
appShell: appShellParity ? [] : ["app_shell_mismatch"],
|
|
198
|
+
navigation: navigationParity ? [] : ["navigation_mismatch"],
|
|
199
|
+
screens: screenDiffs
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function auditServerContractModules(leftModuleSource, rightModuleSource) {
|
|
205
|
+
const left = normalizeServerContract(extractServerContractObject(leftModuleSource));
|
|
206
|
+
const right = normalizeServerContract(extractServerContractObject(rightModuleSource));
|
|
207
|
+
const routeDiffs = buildRouteDiffs(left.routes, right.routes);
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
seam: "server_contract",
|
|
211
|
+
semanticParity: routeDiffs.length === 0,
|
|
212
|
+
summary: {
|
|
213
|
+
routeCount: left.routes.length,
|
|
214
|
+
capabilityIds: left.routes.map((route) => route.capabilityId)
|
|
215
|
+
},
|
|
216
|
+
differences: {
|
|
217
|
+
routes: routeDiffs
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { stableStringify } from "../format.js";
|
|
2
|
+
import { normalizeScreens } from "./web-parity.js";
|
|
3
|
+
|
|
4
|
+
/** Semantic fingerprint of screens slice embedded in Swift ui-web-contract JSON (matches web normalization). */
|
|
5
|
+
export function fingerprintIosEmbeddedUiContract(contract) {
|
|
6
|
+
return stableStringify(normalizeScreens(contract));
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { buildBackendParityEvidence } from "./backend-parity.js";
|
|
2
|
+
import { buildWebParityEvidence } from "./web-parity.js";
|
|
3
|
+
|
|
4
|
+
export function buildIssuesParityEvidence(graph) {
|
|
5
|
+
const web = buildWebParityEvidence(graph, "proj_ui_web__react", "proj_ui_web__sveltekit");
|
|
6
|
+
return {
|
|
7
|
+
web,
|
|
8
|
+
runtime: buildBackendParityEvidence(graph, "proj_api")
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { stableStringify } from "../format.js";
|
|
2
|
+
import { buildWebRealization } from "../realization/ui/index.js";
|
|
3
|
+
|
|
4
|
+
function normalizeVisibility(visibility = []) {
|
|
5
|
+
return visibility
|
|
6
|
+
.map((entry) => ({
|
|
7
|
+
capabilityId: entry.capabilityId ?? entry.capability?.id ?? null,
|
|
8
|
+
predicate: entry.predicate ?? null,
|
|
9
|
+
value: entry.value ?? null,
|
|
10
|
+
ownershipField: entry.ownershipField ?? null,
|
|
11
|
+
claimValue: entry.claimValue ?? null
|
|
12
|
+
}))
|
|
13
|
+
.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizeScreen(screen) {
|
|
17
|
+
return {
|
|
18
|
+
id: screen.id,
|
|
19
|
+
route: screen.route ?? null,
|
|
20
|
+
kind: screen.kind ?? null,
|
|
21
|
+
title: screen.title ?? null,
|
|
22
|
+
loadCapabilityId: screen.loadCapability?.id ?? null,
|
|
23
|
+
viewShapeId: screen.viewShape?.id ?? null,
|
|
24
|
+
primaryActionId: screen.actions?.primary?.id ?? null,
|
|
25
|
+
secondaryActionId: screen.actions?.secondary?.id ?? null,
|
|
26
|
+
screenActionIds: (screen.actions?.screen ?? []).map((action) => action.id ?? action.capability?.id).sort(),
|
|
27
|
+
visibility: normalizeVisibility(screen.visibility)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function normalizeScreens(contract) {
|
|
32
|
+
return contract.screens.map(normalizeScreen).sort((left, right) => left.id.localeCompare(right.id));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function buildWebParityEvidence(graph, leftProjectionId, rightProjectionId) {
|
|
36
|
+
const left = buildWebRealization(graph, { projectionId: leftProjectionId });
|
|
37
|
+
const right = buildWebRealization(graph, { projectionId: rightProjectionId });
|
|
38
|
+
const leftScreens = normalizeScreens(left.contract);
|
|
39
|
+
const rightScreens = normalizeScreens(right.contract);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
leftProjectionId,
|
|
43
|
+
rightProjectionId,
|
|
44
|
+
leftProfile: left.contract.generatorDefaults.profile,
|
|
45
|
+
rightProfile: right.contract.generatorDefaults.profile,
|
|
46
|
+
leftScreens,
|
|
47
|
+
rightScreens,
|
|
48
|
+
semanticParity: stableStringify(leftScreens) === stableStringify(rightScreens)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { buildApiRealization } from "./build-api-realization.js";
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { buildDbRealization } from "../db/index.js";
|
|
2
|
+
import { generateServerContract } from "../../generator/surfaces/services/server-contract.js";
|
|
3
|
+
import { dbProjectionCandidates } from "../../generator/surfaces/databases/shared.js";
|
|
4
|
+
import { getExampleImplementation } from "../../example-implementation.js";
|
|
5
|
+
|
|
6
|
+
function uiLookupBindings(graph) {
|
|
7
|
+
const bindings = [];
|
|
8
|
+
for (const projection of graph.byKind.projection || []) {
|
|
9
|
+
for (const entry of projection.uiLookups || []) {
|
|
10
|
+
if (entry.entity?.id) {
|
|
11
|
+
bindings.push(entry);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return bindings;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getDefaultBackendDbProjection(graph, options = {}) {
|
|
19
|
+
const candidates = dbProjectionCandidates(graph);
|
|
20
|
+
const implementation = getExampleImplementation(graph, options);
|
|
21
|
+
const preferredProjectionId = implementation.runtime?.reference?.localDbProjectionId || null;
|
|
22
|
+
const explicit = options.dbProjectionId
|
|
23
|
+
? candidates.find((projection) => projection.id === options.dbProjectionId)
|
|
24
|
+
: null;
|
|
25
|
+
const preferred = preferredProjectionId
|
|
26
|
+
? candidates.find((projection) => projection.id === preferredProjectionId)
|
|
27
|
+
: null;
|
|
28
|
+
return (
|
|
29
|
+
explicit ||
|
|
30
|
+
preferred ||
|
|
31
|
+
candidates.find((projection) => projection.platform === "db_postgres") ||
|
|
32
|
+
candidates.find((projection) => projection.platform === "db_sqlite") ||
|
|
33
|
+
candidates[0] ||
|
|
34
|
+
null
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function buildBackendRuntimeRealization(graph, options = {}) {
|
|
39
|
+
if (!options.projectionId) {
|
|
40
|
+
throw new Error("Backend runtime realization requires --projection <id>");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dbProjection = getDefaultBackendDbProjection(graph, options);
|
|
44
|
+
if (!dbProjection) {
|
|
45
|
+
throw new Error("Backend runtime realization requires at least one DB projection");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const implementation = getExampleImplementation(graph, options);
|
|
49
|
+
const repositoryReference = implementation.backend.repositoryReference;
|
|
50
|
+
const backendReference = implementation.backend.reference;
|
|
51
|
+
const runtimeReference = implementation.runtime?.reference || null;
|
|
52
|
+
const contract = generateServerContract(graph, { projectionId: options.projectionId });
|
|
53
|
+
const db = buildDbRealization(graph, { projectionId: dbProjection.id });
|
|
54
|
+
const lookupRoutes = Array.from(
|
|
55
|
+
new Map(
|
|
56
|
+
uiLookupBindings(graph).map((entry) => [
|
|
57
|
+
entry.entity.id,
|
|
58
|
+
repositoryReference.lookupBindings.find((binding) => binding.entityId === entry.entity.id)
|
|
59
|
+
])
|
|
60
|
+
).values()
|
|
61
|
+
).filter((entry) => entry.repositoryMethod);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
type: "backend_runtime_realization",
|
|
65
|
+
app: {
|
|
66
|
+
id: options.projectionId,
|
|
67
|
+
family: "backend",
|
|
68
|
+
target: "hono",
|
|
69
|
+
name: contract.projection.name
|
|
70
|
+
},
|
|
71
|
+
contract,
|
|
72
|
+
db,
|
|
73
|
+
lookupRoutes,
|
|
74
|
+
backendReference,
|
|
75
|
+
runtimeReference,
|
|
76
|
+
repositoryReference,
|
|
77
|
+
dbProjection: {
|
|
78
|
+
id: dbProjection.id,
|
|
79
|
+
platform: dbProjection.platform
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getDefaultBackendDbProjection(graph: any, options?: any): any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildDbProjectionContract,
|
|
3
|
+
dbProjectionCandidates,
|
|
4
|
+
getProjection
|
|
5
|
+
} from "../../generator/surfaces/databases/shared.js";
|
|
6
|
+
|
|
7
|
+
export function buildDbRealization(graph, options = {}) {
|
|
8
|
+
if (options.projectionId) {
|
|
9
|
+
return buildDbProjectionContract(graph, getProjection(graph, options.projectionId));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const output = {};
|
|
13
|
+
for (const projection of dbProjectionCandidates(graph)) {
|
|
14
|
+
output[projection.id] = buildDbProjectionContract(graph, projection);
|
|
15
|
+
}
|
|
16
|
+
return output;
|
|
17
|
+
}
|