@contractspec/lib.contracts-transformers 0.0.0-canary-20260113162409

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.
Files changed (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/dist/common/index.d.ts +3 -0
  4. package/dist/common/index.js +3 -0
  5. package/dist/common/types.d.ts +159 -0
  6. package/dist/common/types.d.ts.map +1 -0
  7. package/dist/common/utils.d.ts +52 -0
  8. package/dist/common/utils.d.ts.map +1 -0
  9. package/dist/common/utils.js +103 -0
  10. package/dist/common/utils.js.map +1 -0
  11. package/dist/index.d.ts +18 -0
  12. package/dist/index.js +18 -0
  13. package/dist/openapi/differ.d.ts +42 -0
  14. package/dist/openapi/differ.d.ts.map +1 -0
  15. package/dist/openapi/differ.js +222 -0
  16. package/dist/openapi/differ.js.map +1 -0
  17. package/dist/openapi/exporter/data-views.d.ts +38 -0
  18. package/dist/openapi/exporter/data-views.d.ts.map +1 -0
  19. package/dist/openapi/exporter/data-views.js +47 -0
  20. package/dist/openapi/exporter/data-views.js.map +1 -0
  21. package/dist/openapi/exporter/events.d.ts +28 -0
  22. package/dist/openapi/exporter/events.d.ts.map +1 -0
  23. package/dist/openapi/exporter/events.js +39 -0
  24. package/dist/openapi/exporter/events.js.map +1 -0
  25. package/dist/openapi/exporter/features.d.ts +37 -0
  26. package/dist/openapi/exporter/features.d.ts.map +1 -0
  27. package/dist/openapi/exporter/features.js +46 -0
  28. package/dist/openapi/exporter/features.js.map +1 -0
  29. package/dist/openapi/exporter/forms.d.ts +30 -0
  30. package/dist/openapi/exporter/forms.d.ts.map +1 -0
  31. package/dist/openapi/exporter/forms.js +49 -0
  32. package/dist/openapi/exporter/forms.js.map +1 -0
  33. package/dist/openapi/exporter/index.js +8 -0
  34. package/dist/openapi/exporter/operations.d.ts +65 -0
  35. package/dist/openapi/exporter/operations.d.ts.map +1 -0
  36. package/dist/openapi/exporter/operations.js +143 -0
  37. package/dist/openapi/exporter/operations.js.map +1 -0
  38. package/dist/openapi/exporter/presentations.d.ts +32 -0
  39. package/dist/openapi/exporter/presentations.d.ts.map +1 -0
  40. package/dist/openapi/exporter/presentations.js +60 -0
  41. package/dist/openapi/exporter/presentations.js.map +1 -0
  42. package/dist/openapi/exporter/registries.d.ts +23 -0
  43. package/dist/openapi/exporter/registries.d.ts.map +1 -0
  44. package/dist/openapi/exporter/registries.js +29 -0
  45. package/dist/openapi/exporter/registries.js.map +1 -0
  46. package/dist/openapi/exporter/workflows.d.ts +36 -0
  47. package/dist/openapi/exporter/workflows.d.ts.map +1 -0
  48. package/dist/openapi/exporter/workflows.js +54 -0
  49. package/dist/openapi/exporter/workflows.js.map +1 -0
  50. package/dist/openapi/exporter.d.ts +48 -0
  51. package/dist/openapi/exporter.d.ts.map +1 -0
  52. package/dist/openapi/exporter.js +122 -0
  53. package/dist/openapi/exporter.js.map +1 -0
  54. package/dist/openapi/importer/analyzer.js +28 -0
  55. package/dist/openapi/importer/analyzer.js.map +1 -0
  56. package/dist/openapi/importer/events.js +40 -0
  57. package/dist/openapi/importer/events.js.map +1 -0
  58. package/dist/openapi/importer/generator.js +105 -0
  59. package/dist/openapi/importer/generator.js.map +1 -0
  60. package/dist/openapi/importer/grouping.js +73 -0
  61. package/dist/openapi/importer/grouping.js.map +1 -0
  62. package/dist/openapi/importer/index.d.ts +17 -0
  63. package/dist/openapi/importer/index.d.ts.map +1 -0
  64. package/dist/openapi/importer/index.js +175 -0
  65. package/dist/openapi/importer/index.js.map +1 -0
  66. package/dist/openapi/importer/models.js +22 -0
  67. package/dist/openapi/importer/models.js.map +1 -0
  68. package/dist/openapi/importer/schemas.js +60 -0
  69. package/dist/openapi/importer/schemas.js.map +1 -0
  70. package/dist/openapi/index.d.ts +16 -0
  71. package/dist/openapi/index.js +18 -0
  72. package/dist/openapi/parser/document.d.ts +20 -0
  73. package/dist/openapi/parser/document.d.ts.map +1 -0
  74. package/dist/openapi/parser/document.js +95 -0
  75. package/dist/openapi/parser/document.js.map +1 -0
  76. package/dist/openapi/parser/index.js +5 -0
  77. package/dist/openapi/parser/operation.js +59 -0
  78. package/dist/openapi/parser/operation.js.map +1 -0
  79. package/dist/openapi/parser/parameters.js +37 -0
  80. package/dist/openapi/parser/parameters.js.map +1 -0
  81. package/dist/openapi/parser/resolvers.js +63 -0
  82. package/dist/openapi/parser/resolvers.js.map +1 -0
  83. package/dist/openapi/parser/utils.d.ts +19 -0
  84. package/dist/openapi/parser/utils.d.ts.map +1 -0
  85. package/dist/openapi/parser/utils.js +48 -0
  86. package/dist/openapi/parser/utils.js.map +1 -0
  87. package/dist/openapi/parser.js +6 -0
  88. package/dist/openapi/schema-converter.d.ts +71 -0
  89. package/dist/openapi/schema-converter.d.ts.map +1 -0
  90. package/dist/openapi/schema-converter.js +161 -0
  91. package/dist/openapi/schema-converter.js.map +1 -0
  92. package/dist/openapi/schema-generators/index.js +462 -0
  93. package/dist/openapi/schema-generators/index.js.map +1 -0
  94. package/dist/openapi/types.d.ts +277 -0
  95. package/dist/openapi/types.d.ts.map +1 -0
  96. package/package.json +69 -0
@@ -0,0 +1,222 @@
1
+ import { deepEqual } from "../common/utils.js";
2
+
3
+ //#region src/openapi/differ.ts
4
+ /**
5
+ * Compare two values and generate a diff change if different.
6
+ */
7
+ function compareValues(path, oldValue, newValue, description) {
8
+ if (deepEqual(oldValue, newValue)) return null;
9
+ let changeType = "modified";
10
+ if (oldValue === void 0 || oldValue === null) changeType = "added";
11
+ else if (newValue === void 0 || newValue === null) changeType = "removed";
12
+ else if (typeof oldValue !== typeof newValue) changeType = "type_changed";
13
+ return {
14
+ path,
15
+ type: changeType,
16
+ oldValue,
17
+ newValue,
18
+ description
19
+ };
20
+ }
21
+ /**
22
+ * Diff two objects recursively.
23
+ */
24
+ function diffObjects(path, oldObj, newObj, options) {
25
+ const changes = [];
26
+ if (!oldObj && !newObj) return changes;
27
+ if (!oldObj) {
28
+ changes.push({
29
+ path,
30
+ type: "added",
31
+ newValue: newObj,
32
+ description: `Added ${path}`
33
+ });
34
+ return changes;
35
+ }
36
+ if (!newObj) {
37
+ changes.push({
38
+ path,
39
+ type: "removed",
40
+ oldValue: oldObj,
41
+ description: `Removed ${path}`
42
+ });
43
+ return changes;
44
+ }
45
+ const allKeys = new Set([...Object.keys(oldObj), ...Object.keys(newObj)]);
46
+ for (const key of allKeys) {
47
+ const keyPath = path ? `${path}.${key}` : key;
48
+ if (options.ignorePaths?.some((p) => keyPath.startsWith(p))) continue;
49
+ const oldVal = oldObj[key];
50
+ const newVal = newObj[key];
51
+ if (typeof oldVal === "object" && typeof newVal === "object") changes.push(...diffObjects(keyPath, oldVal, newVal, options));
52
+ else {
53
+ const change = compareValues(keyPath, oldVal, newVal, `Changed ${keyPath}`);
54
+ if (change) changes.push(change);
55
+ }
56
+ }
57
+ return changes;
58
+ }
59
+ /**
60
+ * Diff a ContractSpec against an OpenAPI operation.
61
+ */
62
+ function diffSpecVsOperation(spec, operation, options = {}) {
63
+ const changes = [];
64
+ if (!options.ignoreDescriptions) {
65
+ const descChange = compareValues("meta.description", spec.meta.description, operation.summary ?? operation.description, "Description changed");
66
+ if (descChange) changes.push(descChange);
67
+ }
68
+ if (!options.ignoreTags) {
69
+ const oldTags = [...spec.meta.tags ?? []].sort();
70
+ const newTags = [...operation.tags].sort();
71
+ if (!deepEqual(oldTags, newTags)) changes.push({
72
+ path: "meta.tags",
73
+ type: "modified",
74
+ oldValue: oldTags,
75
+ newValue: newTags,
76
+ description: "Tags changed"
77
+ });
78
+ }
79
+ if (!options.ignoreTransport) {
80
+ const specMethod = spec.transport?.rest?.method ?? (spec.meta.kind === "query" ? "GET" : "POST");
81
+ const opMethod = operation.method.toUpperCase();
82
+ if (specMethod !== opMethod) changes.push({
83
+ path: "transport.rest.method",
84
+ type: "modified",
85
+ oldValue: specMethod,
86
+ newValue: opMethod,
87
+ description: "HTTP method changed"
88
+ });
89
+ const specPath = spec.transport?.rest?.path;
90
+ if (specPath && specPath !== operation.path) changes.push({
91
+ path: "transport.rest.path",
92
+ type: "modified",
93
+ oldValue: specPath,
94
+ newValue: operation.path,
95
+ description: "Path changed"
96
+ });
97
+ }
98
+ if (spec.meta.stability === "deprecated" !== operation.deprecated) changes.push({
99
+ path: "meta.stability",
100
+ type: "modified",
101
+ oldValue: spec.meta.stability,
102
+ newValue: operation.deprecated ? "deprecated" : "stable",
103
+ description: "Deprecation status changed"
104
+ });
105
+ return changes;
106
+ }
107
+ /**
108
+ * Diff two ContractSpecs.
109
+ */
110
+ function diffSpecs(oldSpec, newSpec, options = {}) {
111
+ const changes = [];
112
+ const metaChanges = diffObjects("meta", oldSpec.meta, newSpec.meta, {
113
+ ...options,
114
+ ignorePaths: [
115
+ ...options.ignorePaths ?? [],
116
+ ...options.ignoreDescriptions ? [
117
+ "meta.description",
118
+ "meta.goal",
119
+ "meta.context"
120
+ ] : [],
121
+ ...options.ignoreTags ? ["meta.tags"] : []
122
+ ]
123
+ });
124
+ changes.push(...metaChanges);
125
+ if (!options.ignoreTransport) {
126
+ const transportChanges = diffObjects("transport", oldSpec.transport, newSpec.transport, options);
127
+ changes.push(...transportChanges);
128
+ }
129
+ const policyChanges = diffObjects("policy", oldSpec.policy, newSpec.policy, options);
130
+ changes.push(...policyChanges);
131
+ return changes;
132
+ }
133
+ /**
134
+ * Create a SpecDiff from an existing spec and an imported spec.
135
+ */
136
+ function createSpecDiff(operationId, existing, incoming, options = {}) {
137
+ let changes = [];
138
+ let isEquivalent = false;
139
+ if (existing && incoming.operationSpec) {
140
+ changes = diffSpecs(existing, incoming.operationSpec, options);
141
+ isEquivalent = changes.length === 0;
142
+ } else if (existing && !incoming.operationSpec) changes = [{
143
+ path: "",
144
+ type: "modified",
145
+ oldValue: existing,
146
+ newValue: incoming.code,
147
+ description: "Spec code imported from OpenAPI (runtime comparison not available)"
148
+ }];
149
+ else changes = [{
150
+ path: "",
151
+ type: "added",
152
+ newValue: incoming.operationSpec ?? incoming.code,
153
+ description: "New spec imported from OpenAPI"
154
+ }];
155
+ return {
156
+ operationId,
157
+ existing,
158
+ incoming,
159
+ changes,
160
+ isEquivalent
161
+ };
162
+ }
163
+ /**
164
+ * Batch diff multiple specs against OpenAPI operations.
165
+ */
166
+ function diffAll(existingSpecs, importedSpecs, options = {}) {
167
+ const diffs = [];
168
+ const matchedExisting = /* @__PURE__ */ new Set();
169
+ for (const imported of importedSpecs) {
170
+ const operationId = imported.source.sourceId;
171
+ let existing;
172
+ for (const [key, spec] of existingSpecs) {
173
+ const specName = spec.meta.key;
174
+ if (key === operationId || specName.includes(operationId)) {
175
+ existing = spec;
176
+ matchedExisting.add(key);
177
+ break;
178
+ }
179
+ }
180
+ diffs.push(createSpecDiff(operationId, existing, imported, options));
181
+ }
182
+ for (const [key, spec] of existingSpecs) if (!matchedExisting.has(key)) diffs.push({
183
+ operationId: key,
184
+ existing: spec,
185
+ incoming: void 0,
186
+ changes: [{
187
+ path: "",
188
+ type: "removed",
189
+ oldValue: spec,
190
+ description: "Spec no longer exists in OpenAPI source"
191
+ }],
192
+ isEquivalent: false
193
+ });
194
+ return diffs;
195
+ }
196
+ /**
197
+ * Format diff changes for display.
198
+ */
199
+ function formatDiffChanges(changes) {
200
+ if (changes.length === 0) return "No changes detected";
201
+ const lines = [];
202
+ for (const change of changes) {
203
+ const prefix = {
204
+ added: "+",
205
+ removed: "-",
206
+ modified: "~",
207
+ type_changed: "!",
208
+ required_changed: "?"
209
+ }[change.type];
210
+ lines.push(`${prefix} ${change.path}: ${change.description}`);
211
+ if (change.type === "modified" || change.type === "type_changed") {
212
+ lines.push(` old: ${JSON.stringify(change.oldValue)}`);
213
+ lines.push(` new: ${JSON.stringify(change.newValue)}`);
214
+ } else if (change.type === "added") lines.push(` value: ${JSON.stringify(change.newValue)}`);
215
+ else if (change.type === "removed") lines.push(` was: ${JSON.stringify(change.oldValue)}`);
216
+ }
217
+ return lines.join("\n");
218
+ }
219
+
220
+ //#endregion
221
+ export { createSpecDiff, diffAll, diffSpecVsOperation, diffSpecs, formatDiffChanges };
222
+ //# sourceMappingURL=differ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"differ.js","names":[],"sources":["../../src/openapi/differ.ts"],"sourcesContent":["/**\n * Diff ContractSpec specs against OpenAPI operations.\n * Used for sync operations to detect changes.\n */\n\nimport type { AnyOperationSpec } from '@contractspec/lib.contracts';\nimport type { ParsedOperation } from './types';\nimport type {\n DiffChange,\n DiffChangeType,\n ImportedOperationSpec,\n SpecDiff,\n} from '../common/types';\nimport { deepEqual } from '../common/utils';\n\n/**\n * Options for diffing specs.\n */\nexport interface DiffOptions {\n /** Ignore description changes */\n ignoreDescriptions?: boolean;\n /** Ignore tag changes */\n ignoreTags?: boolean;\n /** Ignore transport changes (path, method) */\n ignoreTransport?: boolean;\n /** Custom paths to ignore */\n ignorePaths?: string[];\n}\n\n/**\n * Compare two values and generate a diff change if different.\n */\nfunction compareValues(\n path: string,\n oldValue: unknown,\n newValue: unknown,\n description: string\n): DiffChange | null {\n if (deepEqual(oldValue, newValue)) {\n return null;\n }\n\n let changeType: DiffChangeType = 'modified';\n if (oldValue === undefined || oldValue === null) {\n changeType = 'added';\n } else if (newValue === undefined || newValue === null) {\n changeType = 'removed';\n } else if (typeof oldValue !== typeof newValue) {\n changeType = 'type_changed';\n }\n\n return {\n path,\n type: changeType,\n oldValue,\n newValue,\n description,\n };\n}\n\n/**\n * Diff two objects recursively.\n */\nfunction diffObjects(\n path: string,\n oldObj: Record<string, unknown> | undefined,\n newObj: Record<string, unknown> | undefined,\n options: DiffOptions\n): DiffChange[] {\n const changes: DiffChange[] = [];\n\n if (!oldObj && !newObj) return changes;\n if (!oldObj) {\n changes.push({\n path,\n type: 'added',\n newValue: newObj,\n description: `Added ${path}`,\n });\n return changes;\n }\n if (!newObj) {\n changes.push({\n path,\n type: 'removed',\n oldValue: oldObj,\n description: `Removed ${path}`,\n });\n return changes;\n }\n\n const allKeys = new Set([...Object.keys(oldObj), ...Object.keys(newObj)]);\n\n for (const key of allKeys) {\n const keyPath = path ? `${path}.${key}` : key;\n\n // Skip ignored paths\n if (options.ignorePaths?.some((p) => keyPath.startsWith(p))) {\n continue;\n }\n\n const oldVal = oldObj[key];\n const newVal = newObj[key];\n\n if (typeof oldVal === 'object' && typeof newVal === 'object') {\n changes.push(\n ...diffObjects(\n keyPath,\n oldVal as Record<string, unknown>,\n newVal as Record<string, unknown>,\n options\n )\n );\n } else {\n const change = compareValues(\n keyPath,\n oldVal,\n newVal,\n `Changed ${keyPath}`\n );\n if (change) {\n changes.push(change);\n }\n }\n }\n\n return changes;\n}\n\n/**\n * Diff a ContractSpec against an OpenAPI operation.\n */\nexport function diffSpecVsOperation(\n spec: AnyOperationSpec,\n operation: ParsedOperation,\n options: DiffOptions = {}\n): DiffChange[] {\n const changes: DiffChange[] = [];\n\n // Compare basic metadata\n if (!options.ignoreDescriptions) {\n const descChange = compareValues(\n 'meta.description',\n spec.meta.description,\n operation.summary ?? operation.description,\n 'Description changed'\n );\n if (descChange) changes.push(descChange);\n }\n\n if (!options.ignoreTags) {\n const oldTags = [...(spec.meta.tags ?? [])].sort();\n const newTags = [...operation.tags].sort();\n if (!deepEqual(oldTags, newTags)) {\n changes.push({\n path: 'meta.tags',\n type: 'modified',\n oldValue: oldTags,\n newValue: newTags,\n description: 'Tags changed',\n });\n }\n }\n\n // Compare transport\n if (!options.ignoreTransport) {\n const specMethod =\n spec.transport?.rest?.method ??\n (spec.meta.kind === 'query' ? 'GET' : 'POST');\n const opMethod = operation.method.toUpperCase();\n\n if (specMethod !== opMethod) {\n changes.push({\n path: 'transport.rest.method',\n type: 'modified',\n oldValue: specMethod,\n newValue: opMethod,\n description: 'HTTP method changed',\n });\n }\n\n const specPath = spec.transport?.rest?.path;\n if (specPath && specPath !== operation.path) {\n changes.push({\n path: 'transport.rest.path',\n type: 'modified',\n oldValue: specPath,\n newValue: operation.path,\n description: 'Path changed',\n });\n }\n }\n\n // Compare deprecation status\n const specDeprecated = spec.meta.stability === 'deprecated';\n if (specDeprecated !== operation.deprecated) {\n changes.push({\n path: 'meta.stability',\n type: 'modified',\n oldValue: spec.meta.stability,\n newValue: operation.deprecated ? 'deprecated' : 'stable',\n description: 'Deprecation status changed',\n });\n }\n\n return changes;\n}\n\n/**\n * Diff two ContractSpecs.\n */\nexport function diffSpecs(\n oldSpec: AnyOperationSpec,\n newSpec: AnyOperationSpec,\n options: DiffOptions = {}\n): DiffChange[] {\n const changes: DiffChange[] = [];\n\n // Compare meta\n const metaChanges = diffObjects(\n 'meta',\n oldSpec.meta as unknown as Record<string, unknown>,\n newSpec.meta as unknown as Record<string, unknown>,\n {\n ...options,\n ignorePaths: [\n ...(options.ignorePaths ?? []),\n ...(options.ignoreDescriptions\n ? ['meta.description', 'meta.goal', 'meta.context']\n : []),\n ...(options.ignoreTags ? ['meta.tags'] : []),\n ],\n }\n );\n changes.push(...metaChanges);\n\n // Compare transport\n if (!options.ignoreTransport) {\n const transportChanges = diffObjects(\n 'transport',\n oldSpec.transport as unknown as Record<string, unknown>,\n newSpec.transport as unknown as Record<string, unknown>,\n options\n );\n changes.push(...transportChanges);\n }\n\n // Compare policy\n const policyChanges = diffObjects(\n 'policy',\n oldSpec.policy as unknown as Record<string, unknown>,\n newSpec.policy as unknown as Record<string, unknown>,\n options\n );\n changes.push(...policyChanges);\n\n return changes;\n}\n\n/**\n * Create a SpecDiff from an existing spec and an imported spec.\n */\nexport function createSpecDiff(\n operationId: string,\n existing: AnyOperationSpec | undefined,\n incoming: ImportedOperationSpec,\n options: DiffOptions = {}\n): SpecDiff {\n let changes: DiffChange[] = [];\n let isEquivalent = false;\n\n if (existing && incoming.operationSpec) {\n // Compare existing vs incoming\n changes = diffSpecs(existing, incoming.operationSpec, options);\n isEquivalent = changes.length === 0;\n } else if (existing && !incoming.operationSpec) {\n // Incoming has code but no runtime spec - can't compare directly\n changes = [\n {\n path: '',\n type: 'modified',\n oldValue: existing,\n newValue: incoming.code,\n description:\n 'Spec code imported from OpenAPI (runtime comparison not available)',\n },\n ];\n } else {\n // New spec - mark as added\n changes = [\n {\n path: '',\n type: 'added',\n newValue: incoming.operationSpec ?? incoming.code,\n description: 'New spec imported from OpenAPI',\n },\n ];\n }\n\n return {\n operationId,\n existing,\n incoming,\n changes,\n isEquivalent,\n };\n}\n\n/**\n * Batch diff multiple specs against OpenAPI operations.\n */\nexport function diffAll(\n existingSpecs: Map<string, AnyOperationSpec>,\n importedSpecs: ImportedOperationSpec[],\n options: DiffOptions = {}\n): SpecDiff[] {\n const diffs: SpecDiff[] = [];\n\n // Track which existing specs have been matched\n const matchedExisting = new Set<string>();\n\n for (const imported of importedSpecs) {\n const operationId = imported.source.sourceId;\n\n // Try to find matching existing spec\n // Match by operationId in x-contractspec extension or by name\n let existing: AnyOperationSpec | undefined;\n\n for (const [key, spec] of existingSpecs) {\n // Check x-contractspec match or name match\n const specName = spec.meta.key;\n if (key === operationId || specName.includes(operationId)) {\n existing = spec;\n matchedExisting.add(key);\n break;\n }\n }\n\n diffs.push(createSpecDiff(operationId, existing, imported, options));\n }\n\n // Add diffs for existing specs that weren't matched (removed from OpenAPI)\n for (const [key, spec] of existingSpecs) {\n if (!matchedExisting.has(key)) {\n diffs.push({\n operationId: key,\n existing: spec,\n incoming: undefined as unknown as ImportedOperationSpec,\n changes: [\n {\n path: '',\n type: 'removed',\n oldValue: spec,\n description: 'Spec no longer exists in OpenAPI source',\n },\n ],\n isEquivalent: false,\n });\n }\n }\n\n return diffs;\n}\n\n/**\n * Format diff changes for display.\n */\nexport function formatDiffChanges(changes: DiffChange[]): string {\n if (changes.length === 0) {\n return 'No changes detected';\n }\n\n const lines: string[] = [];\n\n for (const change of changes) {\n const prefix = {\n added: '+',\n removed: '-',\n modified: '~',\n type_changed: '!',\n required_changed: '?',\n }[change.type];\n\n lines.push(`${prefix} ${change.path}: ${change.description}`);\n\n if (change.type === 'modified' || change.type === 'type_changed') {\n lines.push(` old: ${JSON.stringify(change.oldValue)}`);\n lines.push(` new: ${JSON.stringify(change.newValue)}`);\n } else if (change.type === 'added') {\n lines.push(` value: ${JSON.stringify(change.newValue)}`);\n } else if (change.type === 'removed') {\n lines.push(` was: ${JSON.stringify(change.oldValue)}`);\n }\n }\n\n return lines.join('\\n');\n}\n"],"mappings":"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"}
@@ -0,0 +1,38 @@
1
+ import { GeneratedRegistryCode } from "../types.js";
2
+ import { DataViewRegistry } from "@contractspec/lib.contracts";
3
+
4
+ //#region src/openapi/exporter/data-views.d.ts
5
+
6
+ /**
7
+ * Exported data view structure for OpenAPI extensions.
8
+ */
9
+ interface ExportedDataView {
10
+ name: string;
11
+ version: string;
12
+ description?: string;
13
+ stability?: string;
14
+ entity: string;
15
+ kind: 'list' | 'detail' | 'table' | 'grid';
16
+ source: {
17
+ primary: {
18
+ key: string;
19
+ version: string;
20
+ };
21
+ item?: {
22
+ key: string;
23
+ version: string;
24
+ };
25
+ };
26
+ fields: unknown[];
27
+ }
28
+ /**
29
+ * Export data views to OpenAPI extension format.
30
+ */
31
+ declare function exportDataViews(registry: DataViewRegistry): ExportedDataView[];
32
+ /**
33
+ * Generate TypeScript code for data views registry.
34
+ */
35
+ declare function generateDataViewsRegistry(registry: DataViewRegistry): GeneratedRegistryCode;
36
+ //#endregion
37
+ export { ExportedDataView, exportDataViews, generateDataViewsRegistry };
38
+ //# sourceMappingURL=data-views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-views.d.ts","names":[],"sources":["../../../src/openapi/exporter/data-views.ts"],"sourcesContent":[],"mappings":";;;;;AA0BA;AAkBA;;UAnCiB,gBAAA;;;;;;;;;;;;;;;;;;;;;;iBAiBD,eAAA,WACJ,mBACT;;;;iBAgBa,yBAAA,WACJ,mBACT"}
@@ -0,0 +1,47 @@
1
+ //#region src/openapi/exporter/data-views.ts
2
+ /**
3
+ * Export data views to OpenAPI extension format.
4
+ */
5
+ function exportDataViews(registry) {
6
+ return registry.list().map((dv) => ({
7
+ name: dv.meta.key,
8
+ version: dv.meta.version,
9
+ description: dv.meta.description,
10
+ stability: dv.meta.stability,
11
+ entity: dv.meta.entity,
12
+ kind: dv.view.kind,
13
+ source: dv.source,
14
+ fields: dv.view.fields
15
+ }));
16
+ }
17
+ /**
18
+ * Generate TypeScript code for data views registry.
19
+ */
20
+ function generateDataViewsRegistry(registry) {
21
+ const dataViews = registry.list();
22
+ const imports = /* @__PURE__ */ new Set();
23
+ const registrations = [];
24
+ for (const dv of dataViews) {
25
+ const dvVarName = dv.meta.key.replace(/\./g, "_") + `_v${dv.meta.version}`;
26
+ imports.add(`import { ${dvVarName} } from './${dv.meta.key.split(".")[0]}';`);
27
+ registrations.push(` .register(${dvVarName})`);
28
+ }
29
+ return {
30
+ code: `/**
31
+ * Auto-generated data views registry.
32
+ * DO NOT EDIT - This file is generated by ContractSpec exporter.
33
+ */
34
+ import { DataViewRegistry } from '@contractspec/lib.contracts';
35
+
36
+ ${Array.from(imports).join("\n")}
37
+
38
+ export const dataViewsRegistry = new DataViewRegistry()
39
+ ${registrations.join("\n")};
40
+ `,
41
+ fileName: "dataviews-registry.ts"
42
+ };
43
+ }
44
+
45
+ //#endregion
46
+ export { exportDataViews, generateDataViewsRegistry };
47
+ //# sourceMappingURL=data-views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-views.js","names":[],"sources":["../../../src/openapi/exporter/data-views.ts"],"sourcesContent":["/**\n * Data views exporter - exports DataViewSpec to OpenAPI extensions.\n */\nimport type { DataViewRegistry } from '@contractspec/lib.contracts';\nimport type { GeneratedRegistryCode } from '../types';\n\n/**\n * Exported data view structure for OpenAPI extensions.\n */\nexport interface ExportedDataView {\n name: string;\n version: string;\n description?: string;\n stability?: string;\n entity: string;\n kind: 'list' | 'detail' | 'table' | 'grid';\n source: {\n primary: { key: string; version: string };\n item?: { key: string; version: string };\n };\n fields: unknown[];\n}\n\n/**\n * Export data views to OpenAPI extension format.\n */\nexport function exportDataViews(\n registry: DataViewRegistry\n): ExportedDataView[] {\n return registry.list().map((dv) => ({\n name: dv.meta.key,\n version: dv.meta.version,\n description: dv.meta.description,\n stability: dv.meta.stability,\n entity: dv.meta.entity,\n kind: dv.view.kind,\n source: dv.source,\n fields: dv.view.fields,\n }));\n}\n\n/**\n * Generate TypeScript code for data views registry.\n */\nexport function generateDataViewsRegistry(\n registry: DataViewRegistry\n): GeneratedRegistryCode {\n const dataViews = registry.list();\n const imports = new Set<string>();\n const registrations: string[] = [];\n\n for (const dv of dataViews) {\n const dvVarName = dv.meta.key.replace(/\\./g, '_') + `_v${dv.meta.version}`;\n imports.add(\n `import { ${dvVarName} } from './${dv.meta.key.split('.')[0]}';`\n );\n registrations.push(` .register(${dvVarName})`);\n }\n\n const code = `/**\n * Auto-generated data views registry.\n * DO NOT EDIT - This file is generated by ContractSpec exporter.\n */\nimport { DataViewRegistry } from '@contractspec/lib.contracts';\n\n${Array.from(imports).join('\\n')}\n\nexport const dataViewsRegistry = new DataViewRegistry()\n${registrations.join('\\n')};\n`;\n\n return {\n code,\n fileName: 'dataviews-registry.ts',\n };\n}\n"],"mappings":";;;;AA0BA,SAAgB,gBACd,UACoB;AACpB,QAAO,SAAS,MAAM,CAAC,KAAK,QAAQ;EAClC,MAAM,GAAG,KAAK;EACd,SAAS,GAAG,KAAK;EACjB,aAAa,GAAG,KAAK;EACrB,WAAW,GAAG,KAAK;EACnB,QAAQ,GAAG,KAAK;EAChB,MAAM,GAAG,KAAK;EACd,QAAQ,GAAG;EACX,QAAQ,GAAG,KAAK;EACjB,EAAE;;;;;AAML,SAAgB,0BACd,UACuB;CACvB,MAAM,YAAY,SAAS,MAAM;CACjC,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,gBAA0B,EAAE;AAElC,MAAK,MAAM,MAAM,WAAW;EAC1B,MAAM,YAAY,GAAG,KAAK,IAAI,QAAQ,OAAO,IAAI,GAAG,KAAK,GAAG,KAAK;AACjE,UAAQ,IACN,YAAY,UAAU,aAAa,GAAG,KAAK,IAAI,MAAM,IAAI,CAAC,GAAG,IAC9D;AACD,gBAAc,KAAK,eAAe,UAAU,GAAG;;AAejD,QAAO;EACL,MAbW;;;;;;EAMb,MAAM,KAAK,QAAQ,CAAC,KAAK,KAAK,CAAC;;;EAG/B,cAAc,KAAK,KAAK,CAAC;;EAKvB,UAAU;EACX"}
@@ -0,0 +1,28 @@
1
+ import { GeneratedRegistryCode } from "../types.js";
2
+ import { EventSpec } from "@contractspec/lib.contracts";
3
+ import { AnySchemaModel } from "@contractspec/lib.schema";
4
+
5
+ //#region src/openapi/exporter/events.d.ts
6
+
7
+ type OpenApiSchemaObject = Record<string, unknown>;
8
+ /**
9
+ * Exported event structure for OpenAPI extensions.
10
+ */
11
+ interface ExportedEvent {
12
+ name: string;
13
+ version: string;
14
+ description: string;
15
+ payload: OpenApiSchemaObject | null;
16
+ pii?: string[];
17
+ }
18
+ /**
19
+ * Export events to OpenAPI extension format.
20
+ */
21
+ declare function exportEvents(events: EventSpec<AnySchemaModel>[]): ExportedEvent[];
22
+ /**
23
+ * Generate TypeScript code for events exports.
24
+ */
25
+ declare function generateEventsExports(events: EventSpec<AnySchemaModel>[]): GeneratedRegistryCode;
26
+ //#endregion
27
+ export { ExportedEvent, exportEvents, generateEventsExports };
28
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","names":[],"sources":["../../../src/openapi/exporter/events.ts"],"sourcesContent":[],"mappings":";;;;;;AAaA,KALK,mBAAA,GAAsB,MAShB,CAAA,MAAA,EAAA,OAAA,CAAA;AAOX;;;AAEG,UAbc,aAAA,CAad;EAAa,IAAA,EAAA,MAAA;EAeA,OAAA,EAAA,MAAA;EACI,WAAA,EAAA,MAAA;EAAV,OAAA,EAzBC,mBAyBD,GAAA,IAAA;EACP,GAAA,CAAA,EAAA,MAAA,EAAA;;;;;iBAnBa,YAAA,SACN,UAAU,oBACjB;;;;iBAea,qBAAA,SACN,UAAU,oBACjB"}
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/openapi/exporter/events.ts
4
+ /**
5
+ * Export events to OpenAPI extension format.
6
+ */
7
+ function exportEvents(events) {
8
+ return events.map((event) => ({
9
+ name: event.meta.key,
10
+ version: event.meta.version,
11
+ description: event.meta.description,
12
+ payload: event.payload ? z.toJSONSchema(event.payload.getZod()) : null,
13
+ pii: event.pii
14
+ }));
15
+ }
16
+ /**
17
+ * Generate TypeScript code for events exports.
18
+ */
19
+ function generateEventsExports(events) {
20
+ const eventExports = [];
21
+ for (const event of events) {
22
+ const eventVarName = event.meta.key.replace(/\./g, "_") + `_v${event.meta.version}`;
23
+ eventExports.push(`export { ${eventVarName} } from './${event.meta.key.split(".")[0]}';`);
24
+ }
25
+ return {
26
+ code: `/**
27
+ * Auto-generated events exports.
28
+ * DO NOT EDIT - This file is generated by ContractSpec exporter.
29
+ */
30
+
31
+ ${eventExports.join("\n")}
32
+ `,
33
+ fileName: "events-exports.ts"
34
+ };
35
+ }
36
+
37
+ //#endregion
38
+ export { exportEvents, generateEventsExports };
39
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","names":[],"sources":["../../../src/openapi/exporter/events.ts"],"sourcesContent":["/**\n * Events exporter - exports EventSpec to OpenAPI extensions.\n */\nimport type { EventSpec } from '@contractspec/lib.contracts';\nimport type { AnySchemaModel } from '@contractspec/lib.schema';\nimport { z } from 'zod';\nimport type { GeneratedRegistryCode } from '../types';\n\ntype OpenApiSchemaObject = Record<string, unknown>;\n\n/**\n * Exported event structure for OpenAPI extensions.\n */\nexport interface ExportedEvent {\n name: string;\n version: string;\n description: string;\n payload: OpenApiSchemaObject | null;\n pii?: string[];\n}\n\n/**\n * Export events to OpenAPI extension format.\n */\nexport function exportEvents(\n events: EventSpec<AnySchemaModel>[]\n): ExportedEvent[] {\n return events.map((event) => ({\n name: event.meta.key,\n version: event.meta.version,\n description: event.meta.description,\n payload: event.payload\n ? (z.toJSONSchema(event.payload.getZod()) as OpenApiSchemaObject)\n : null,\n pii: event.pii,\n }));\n}\n\n/**\n * Generate TypeScript code for events exports.\n */\nexport function generateEventsExports(\n events: EventSpec<AnySchemaModel>[]\n): GeneratedRegistryCode {\n const eventExports: string[] = [];\n\n for (const event of events) {\n const eventVarName =\n event.meta.key.replace(/\\./g, '_') + `_v${event.meta.version}`;\n eventExports.push(\n `export { ${eventVarName} } from './${event.meta.key.split('.')[0]}';`\n );\n }\n\n const code = `/**\n * Auto-generated events exports.\n * DO NOT EDIT - This file is generated by ContractSpec exporter.\n */\n\n${eventExports.join('\\n')}\n`;\n\n return {\n code,\n fileName: 'events-exports.ts',\n };\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,aACd,QACiB;AACjB,QAAO,OAAO,KAAK,WAAW;EAC5B,MAAM,MAAM,KAAK;EACjB,SAAS,MAAM,KAAK;EACpB,aAAa,MAAM,KAAK;EACxB,SAAS,MAAM,UACV,EAAE,aAAa,MAAM,QAAQ,QAAQ,CAAC,GACvC;EACJ,KAAK,MAAM;EACZ,EAAE;;;;;AAML,SAAgB,sBACd,QACuB;CACvB,MAAM,eAAyB,EAAE;AAEjC,MAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,eACJ,MAAM,KAAK,IAAI,QAAQ,OAAO,IAAI,GAAG,KAAK,MAAM,KAAK;AACvD,eAAa,KACX,YAAY,aAAa,aAAa,MAAM,KAAK,IAAI,MAAM,IAAI,CAAC,GAAG,IACpE;;AAWH,QAAO;EACL,MATW;;;;;EAKb,aAAa,KAAK,KAAK,CAAC;;EAKtB,UAAU;EACX"}
@@ -0,0 +1,37 @@
1
+ import { GeneratedRegistryCode } from "../types.js";
2
+ import { FeatureRegistry } from "@contractspec/lib.contracts";
3
+
4
+ //#region src/openapi/exporter/features.d.ts
5
+
6
+ /**
7
+ * Exported feature structure for OpenAPI extensions.
8
+ */
9
+ interface ExportedFeature {
10
+ key: string;
11
+ description?: string;
12
+ owners?: string[];
13
+ stability?: string;
14
+ operations?: {
15
+ key: string;
16
+ version: string;
17
+ }[];
18
+ events?: {
19
+ key: string;
20
+ version: string;
21
+ }[];
22
+ presentations?: {
23
+ key: string;
24
+ version: string;
25
+ }[];
26
+ }
27
+ /**
28
+ * Export features to OpenAPI extension format.
29
+ */
30
+ declare function exportFeatures(registry: FeatureRegistry): ExportedFeature[];
31
+ /**
32
+ * Generate TypeScript code for features registry.
33
+ */
34
+ declare function generateFeaturesRegistry(registry: FeatureRegistry): GeneratedRegistryCode;
35
+ //#endregion
36
+ export { ExportedFeature, exportFeatures, generateFeaturesRegistry };
37
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.d.ts","names":[],"sources":["../../../src/openapi/exporter/features.ts"],"sourcesContent":[],"mappings":";;;;;AAsBA;AAeA;;UA5BiB,eAAA;;;;;;;;;;;;;;;;;;;;;iBAaD,cAAA,WAAyB,kBAAkB;;;;iBAe3C,wBAAA,WACJ,kBACT"}
@@ -0,0 +1,46 @@
1
+ //#region src/openapi/exporter/features.ts
2
+ /**
3
+ * Export features to OpenAPI extension format.
4
+ */
5
+ function exportFeatures(registry) {
6
+ return registry.list().map((feature) => ({
7
+ key: feature.meta.key,
8
+ description: feature.meta.description,
9
+ owners: feature.meta.owners,
10
+ stability: feature.meta.stability,
11
+ operations: feature.operations,
12
+ events: feature.events,
13
+ presentations: feature.presentations
14
+ }));
15
+ }
16
+ /**
17
+ * Generate TypeScript code for features registry.
18
+ */
19
+ function generateFeaturesRegistry(registry) {
20
+ const features = registry.list();
21
+ const imports = /* @__PURE__ */ new Set();
22
+ const registrations = [];
23
+ for (const feature of features) {
24
+ const featureVarName = feature.meta.key.replace(/-/g, "_");
25
+ imports.add(`import { ${featureVarName} } from './${feature.meta.key}';`);
26
+ registrations.push(` .register(${featureVarName})`);
27
+ }
28
+ return {
29
+ code: `/**
30
+ * Auto-generated features registry.
31
+ * DO NOT EDIT - This file is generated by ContractSpec exporter.
32
+ */
33
+ import { FeatureRegistry } from '@contractspec/lib.contracts';
34
+
35
+ ${Array.from(imports).join("\n")}
36
+
37
+ export const featuresRegistry = new FeatureRegistry()
38
+ ${registrations.join("\n")};
39
+ `,
40
+ fileName: "features-registry.ts"
41
+ };
42
+ }
43
+
44
+ //#endregion
45
+ export { exportFeatures, generateFeaturesRegistry };
46
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","names":[],"sources":["../../../src/openapi/exporter/features.ts"],"sourcesContent":["/**\n * Features exporter - exports FeatureModuleSpec to OpenAPI extensions.\n */\nimport type { FeatureRegistry } from '@contractspec/lib.contracts';\nimport type { GeneratedRegistryCode } from '../types';\n\n/**\n * Exported feature structure for OpenAPI extensions.\n */\nexport interface ExportedFeature {\n key: string;\n description?: string;\n owners?: string[];\n stability?: string;\n operations?: { key: string; version: string }[];\n events?: { key: string; version: string }[];\n presentations?: { key: string; version: string }[];\n}\n\n/**\n * Export features to OpenAPI extension format.\n */\nexport function exportFeatures(registry: FeatureRegistry): ExportedFeature[] {\n return registry.list().map((feature) => ({\n key: feature.meta.key,\n description: feature.meta.description,\n owners: feature.meta.owners,\n stability: feature.meta.stability,\n operations: feature.operations,\n events: feature.events,\n presentations: feature.presentations,\n }));\n}\n\n/**\n * Generate TypeScript code for features registry.\n */\nexport function generateFeaturesRegistry(\n registry: FeatureRegistry\n): GeneratedRegistryCode {\n const features = registry.list();\n const imports = new Set<string>();\n const registrations: string[] = [];\n\n for (const feature of features) {\n const featureVarName = feature.meta.key.replace(/-/g, '_');\n imports.add(`import { ${featureVarName} } from './${feature.meta.key}';`);\n registrations.push(` .register(${featureVarName})`);\n }\n\n const code = `/**\n * Auto-generated features registry.\n * DO NOT EDIT - This file is generated by ContractSpec exporter.\n */\nimport { FeatureRegistry } from '@contractspec/lib.contracts';\n\n${Array.from(imports).join('\\n')}\n\nexport const featuresRegistry = new FeatureRegistry()\n${registrations.join('\\n')};\n`;\n\n return {\n code,\n fileName: 'features-registry.ts',\n };\n}\n"],"mappings":";;;;AAsBA,SAAgB,eAAe,UAA8C;AAC3E,QAAO,SAAS,MAAM,CAAC,KAAK,aAAa;EACvC,KAAK,QAAQ,KAAK;EAClB,aAAa,QAAQ,KAAK;EAC1B,QAAQ,QAAQ,KAAK;EACrB,WAAW,QAAQ,KAAK;EACxB,YAAY,QAAQ;EACpB,QAAQ,QAAQ;EAChB,eAAe,QAAQ;EACxB,EAAE;;;;;AAML,SAAgB,yBACd,UACuB;CACvB,MAAM,WAAW,SAAS,MAAM;CAChC,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,gBAA0B,EAAE;AAElC,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,iBAAiB,QAAQ,KAAK,IAAI,QAAQ,MAAM,IAAI;AAC1D,UAAQ,IAAI,YAAY,eAAe,aAAa,QAAQ,KAAK,IAAI,IAAI;AACzE,gBAAc,KAAK,eAAe,eAAe,GAAG;;AAetD,QAAO;EACL,MAbW;;;;;;EAMb,MAAM,KAAK,QAAQ,CAAC,KAAK,KAAK,CAAC;;;EAG/B,cAAc,KAAK,KAAK,CAAC;;EAKvB,UAAU;EACX"}
@@ -0,0 +1,30 @@
1
+ import { GeneratedRegistryCode } from "../types.js";
2
+ import { FormRegistry, Stability } from "@contractspec/lib.contracts";
3
+
4
+ //#region src/openapi/exporter/forms.d.ts
5
+
6
+ type OpenApiSchemaObject = Record<string, unknown>;
7
+ /**
8
+ * Exported form structure for OpenAPI extensions.
9
+ */
10
+ interface ExportedForm {
11
+ key: string;
12
+ version: string;
13
+ description: string;
14
+ stability: Stability;
15
+ owners?: string[];
16
+ fields: unknown[];
17
+ model: OpenApiSchemaObject | null;
18
+ actions?: unknown[];
19
+ }
20
+ /**
21
+ * Export forms to OpenAPI extension format.
22
+ */
23
+ declare function exportForms(registry: FormRegistry): ExportedForm[];
24
+ /**
25
+ * Generate TypeScript code for forms registry.
26
+ */
27
+ declare function generateFormsRegistry(registry: FormRegistry): GeneratedRegistryCode;
28
+ //#endregion
29
+ export { ExportedForm, exportForms, generateFormsRegistry };
30
+ //# sourceMappingURL=forms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.d.ts","names":[],"sources":["../../../src/openapi/exporter/forms.ts"],"sourcesContent":[],"mappings":";;;;;AAaA,KALK,mBAAA,GAAsB,MASd,CAAA,MAAA,EAGJ,OAAA,CAAA;AAOT;AAoBA;;UAlCiB,YAAA;;;;aAIJ;;;SAGJ;;;;;;iBAOO,WAAA,WAAsB,eAAe;;;;iBAoBrC,qBAAA,WACJ,eACT"}
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/openapi/exporter/forms.ts
4
+ /**
5
+ * Export forms to OpenAPI extension format.
6
+ */
7
+ function exportForms(registry) {
8
+ return registry.list().map((form) => ({
9
+ key: form.meta.key,
10
+ version: form.meta.version,
11
+ description: form.meta.description,
12
+ stability: form.meta.stability,
13
+ owners: form.meta.owners,
14
+ fields: form.fields,
15
+ model: form.model ? z.toJSONSchema(form.model.getZod()) : null,
16
+ actions: form.actions
17
+ }));
18
+ }
19
+ /**
20
+ * Generate TypeScript code for forms registry.
21
+ */
22
+ function generateFormsRegistry(registry) {
23
+ const forms = registry.list();
24
+ const imports = /* @__PURE__ */ new Set();
25
+ const registrations = [];
26
+ for (const form of forms) {
27
+ const formVarName = form.meta.key.replace(/-/g, "_") + `_v${form.meta.version}`;
28
+ imports.add(`import { ${formVarName} } from './${form.meta.key}';`);
29
+ registrations.push(` .register(${formVarName})`);
30
+ }
31
+ return {
32
+ code: `/**
33
+ * Auto-generated forms registry.
34
+ * DO NOT EDIT - This file is generated by ContractSpec exporter.
35
+ */
36
+ import { FormRegistry } from '@contractspec/lib.contracts';
37
+
38
+ ${Array.from(imports).join("\n")}
39
+
40
+ export const formsRegistry = new FormRegistry()
41
+ ${registrations.join("\n")};
42
+ `,
43
+ fileName: "forms-registry.ts"
44
+ };
45
+ }
46
+
47
+ //#endregion
48
+ export { exportForms, generateFormsRegistry };
49
+ //# sourceMappingURL=forms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms.js","names":[],"sources":["../../../src/openapi/exporter/forms.ts"],"sourcesContent":["/**\n * Forms exporter - exports FormSpec to OpenAPI extensions.\n */\nimport type { FormRegistry, Stability } from '@contractspec/lib.contracts';\nimport type { AnySchemaModel } from '@contractspec/lib.schema';\nimport { z } from 'zod';\nimport type { GeneratedRegistryCode } from '../types';\n\ntype OpenApiSchemaObject = Record<string, unknown>;\n\n/**\n * Exported form structure for OpenAPI extensions.\n */\nexport interface ExportedForm {\n key: string;\n version: string;\n description: string;\n stability: Stability;\n owners?: string[];\n fields: unknown[];\n model: OpenApiSchemaObject | null;\n actions?: unknown[];\n}\n\n/**\n * Export forms to OpenAPI extension format.\n */\nexport function exportForms(registry: FormRegistry): ExportedForm[] {\n return registry.list().map((form) => ({\n key: form.meta.key,\n version: form.meta.version,\n description: form.meta.description,\n stability: form.meta.stability,\n owners: form.meta.owners,\n fields: form.fields,\n model: form.model\n ? (z.toJSONSchema(\n (form.model as AnySchemaModel).getZod()\n ) as OpenApiSchemaObject)\n : null,\n actions: form.actions,\n }));\n}\n\n/**\n * Generate TypeScript code for forms registry.\n */\nexport function generateFormsRegistry(\n registry: FormRegistry\n): GeneratedRegistryCode {\n const forms = registry.list();\n const imports = new Set<string>();\n const registrations: string[] = [];\n\n for (const form of forms) {\n const formVarName =\n form.meta.key.replace(/-/g, '_') + `_v${form.meta.version}`;\n imports.add(`import { ${formVarName} } from './${form.meta.key}';`);\n registrations.push(` .register(${formVarName})`);\n }\n\n const code = `/**\n * Auto-generated forms registry.\n * DO NOT EDIT - This file is generated by ContractSpec exporter.\n */\nimport { FormRegistry } from '@contractspec/lib.contracts';\n\n${Array.from(imports).join('\\n')}\n\nexport const formsRegistry = new FormRegistry()\n${registrations.join('\\n')};\n`;\n\n return {\n code,\n fileName: 'forms-registry.ts',\n };\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,YAAY,UAAwC;AAClE,QAAO,SAAS,MAAM,CAAC,KAAK,UAAU;EACpC,KAAK,KAAK,KAAK;EACf,SAAS,KAAK,KAAK;EACnB,aAAa,KAAK,KAAK;EACvB,WAAW,KAAK,KAAK;EACrB,QAAQ,KAAK,KAAK;EAClB,QAAQ,KAAK;EACb,OAAO,KAAK,QACP,EAAE,aACA,KAAK,MAAyB,QAAQ,CACxC,GACD;EACJ,SAAS,KAAK;EACf,EAAE;;;;;AAML,SAAgB,sBACd,UACuB;CACvB,MAAM,QAAQ,SAAS,MAAM;CAC7B,MAAM,0BAAU,IAAI,KAAa;CACjC,MAAM,gBAA0B,EAAE;AAElC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,cACJ,KAAK,KAAK,IAAI,QAAQ,MAAM,IAAI,GAAG,KAAK,KAAK,KAAK;AACpD,UAAQ,IAAI,YAAY,YAAY,aAAa,KAAK,KAAK,IAAI,IAAI;AACnE,gBAAc,KAAK,eAAe,YAAY,GAAG;;AAenD,QAAO;EACL,MAbW;;;;;;EAMb,MAAM,KAAK,QAAQ,CAAC,KAAK,KAAK,CAAC;;;EAG/B,cAAc,KAAK,KAAK,CAAC;;EAKvB,UAAU;EACX"}
@@ -0,0 +1,8 @@
1
+ import { defaultRestPath, exportOperations, generateOperationsRegistry, jsonSchemaForSpec, schemaModelToJsonSchema, toHttpMethod, toOperationId, toRestPath, toSchemaName } from "./operations.js";
2
+ import { exportEvents, generateEventsExports } from "./events.js";
3
+ import { exportFeatures, generateFeaturesRegistry } from "./features.js";
4
+ import { exportPresentations, exportPresentationsFromArray, generatePresentationsRegistry } from "./presentations.js";
5
+ import { exportForms, generateFormsRegistry } from "./forms.js";
6
+ import { exportDataViews, generateDataViewsRegistry } from "./data-views.js";
7
+ import { exportWorkflows, generateWorkflowsRegistry } from "./workflows.js";
8
+ import { generateRegistryIndex } from "./registries.js";