@loxtep/sdk 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/README.md +255 -4
- package/dist/authoring/agent.d.ts +164 -0
- package/dist/authoring/agent.d.ts.map +1 -0
- package/dist/authoring/agent.js +376 -0
- package/dist/authoring/agent.js.map +1 -0
- package/dist/authoring/compiler.d.ts +103 -0
- package/dist/authoring/compiler.d.ts.map +1 -0
- package/dist/authoring/compiler.js +305 -0
- package/dist/authoring/compiler.js.map +1 -0
- package/dist/authoring/define-data-workflow.d.ts +24 -0
- package/dist/authoring/define-data-workflow.d.ts.map +1 -0
- package/dist/authoring/define-data-workflow.js +93 -0
- package/dist/authoring/define-data-workflow.js.map +1 -0
- package/dist/authoring/index.d.ts +19 -0
- package/dist/authoring/index.d.ts.map +1 -0
- package/dist/authoring/index.js +15 -0
- package/dist/authoring/index.js.map +1 -0
- package/dist/authoring/toolbox.d.ts +133 -0
- package/dist/authoring/toolbox.d.ts.map +1 -0
- package/dist/authoring/toolbox.js +166 -0
- package/dist/authoring/toolbox.js.map +1 -0
- package/dist/authoring/triggers.d.ts +41 -0
- package/dist/authoring/triggers.d.ts.map +1 -0
- package/dist/authoring/triggers.js +60 -0
- package/dist/authoring/triggers.js.map +1 -0
- package/dist/authoring/types.d.ts +111 -0
- package/dist/authoring/types.d.ts.map +1 -0
- package/dist/authoring/types.js +9 -0
- package/dist/authoring/types.js.map +1 -0
- package/dist/cli/commands/activity-cmd.d.ts +28 -0
- package/dist/cli/commands/activity-cmd.d.ts.map +1 -0
- package/dist/cli/commands/activity-cmd.js +78 -0
- package/dist/cli/commands/activity-cmd.js.map +1 -0
- package/dist/cli/commands/attach-cmd.d.ts +38 -0
- package/dist/cli/commands/attach-cmd.d.ts.map +1 -0
- package/dist/cli/commands/attach-cmd.js +141 -0
- package/dist/cli/commands/attach-cmd.js.map +1 -0
- package/dist/cli/commands/data-contracts-cmd.d.ts +8 -0
- package/dist/cli/commands/data-contracts-cmd.d.ts.map +1 -1
- package/dist/cli/commands/data-contracts-cmd.js +11 -0
- package/dist/cli/commands/data-contracts-cmd.js.map +1 -1
- package/dist/cli/commands/data-products-cmd.d.ts +2 -0
- package/dist/cli/commands/data-products-cmd.d.ts.map +1 -1
- package/dist/cli/commands/data-products-cmd.js +35 -0
- package/dist/cli/commands/data-products-cmd.js.map +1 -1
- package/dist/cli/commands/deploy-cmd.d.ts +101 -0
- package/dist/cli/commands/deploy-cmd.d.ts.map +1 -0
- package/dist/cli/commands/deploy-cmd.js +461 -0
- package/dist/cli/commands/deploy-cmd.js.map +1 -0
- package/dist/cli/commands/generate-cmd.d.ts +35 -0
- package/dist/cli/commands/generate-cmd.d.ts.map +1 -0
- package/dist/cli/commands/generate-cmd.js +134 -0
- package/dist/cli/commands/generate-cmd.js.map +1 -0
- package/dist/cli/commands/improvements-cmd.d.ts +44 -0
- package/dist/cli/commands/improvements-cmd.d.ts.map +1 -0
- package/dist/cli/commands/improvements-cmd.js +215 -0
- package/dist/cli/commands/improvements-cmd.js.map +1 -0
- package/dist/cli/commands/init-cmd.d.ts +78 -0
- package/dist/cli/commands/init-cmd.d.ts.map +1 -0
- package/dist/cli/commands/init-cmd.js +250 -0
- package/dist/cli/commands/init-cmd.js.map +1 -0
- package/dist/cli/commands/instances-cmd.d.ts +37 -0
- package/dist/cli/commands/instances-cmd.d.ts.map +1 -0
- package/dist/cli/commands/instances-cmd.js +150 -0
- package/dist/cli/commands/instances-cmd.js.map +1 -0
- package/dist/cli/commands/test-cmd.d.ts +89 -0
- package/dist/cli/commands/test-cmd.d.ts.map +1 -0
- package/dist/cli/commands/test-cmd.js +378 -0
- package/dist/cli/commands/test-cmd.js.map +1 -0
- package/dist/cli/index.d.ts +5 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +240 -8
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/project-context.d.ts +153 -0
- package/dist/cli/project-context.d.ts.map +1 -0
- package/dist/cli/project-context.js +190 -0
- package/dist/cli/project-context.js.map +1 -0
- package/dist/client/activity-types.d.ts +66 -0
- package/dist/client/activity-types.d.ts.map +1 -0
- package/dist/client/activity-types.js +9 -0
- package/dist/client/activity-types.js.map +1 -0
- package/dist/client/activity.d.ts +22 -0
- package/dist/client/activity.d.ts.map +1 -0
- package/dist/client/activity.js +43 -0
- package/dist/client/activity.js.map +1 -0
- package/dist/client/data-products-types.d.ts +23 -0
- package/dist/client/data-products-types.d.ts.map +1 -1
- package/dist/client/data-products.d.ts +3 -1
- package/dist/client/data-products.d.ts.map +1 -1
- package/dist/client/data-products.js +20 -98
- package/dist/client/data-products.js.map +1 -1
- package/dist/client/{consumptions-types.d.ts → delivery-types.d.ts} +25 -8
- package/dist/client/delivery-types.d.ts.map +1 -0
- package/dist/client/delivery-types.js +10 -0
- package/dist/client/delivery-types.js.map +1 -0
- package/dist/client/delivery.d.ts +23 -0
- package/dist/client/delivery.d.ts.map +1 -0
- package/dist/client/delivery.js +105 -0
- package/dist/client/delivery.js.map +1 -0
- package/dist/client/flow-types.d.ts +4 -2
- package/dist/client/flow-types.d.ts.map +1 -1
- package/dist/client/flows.d.ts +1 -1
- package/dist/client/flows.d.ts.map +1 -1
- package/dist/client/flows.js +49 -124
- package/dist/client/flows.js.map +1 -1
- package/dist/client/improvements-types.d.ts +55 -0
- package/dist/client/improvements-types.d.ts.map +1 -0
- package/dist/client/improvements-types.js +9 -0
- package/dist/client/improvements-types.js.map +1 -0
- package/dist/client/improvements.d.ts +29 -0
- package/dist/client/improvements.d.ts.map +1 -0
- package/dist/client/improvements.js +50 -0
- package/dist/client/improvements.js.map +1 -0
- package/dist/client/index.d.ts +8 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/instances-types.d.ts +92 -0
- package/dist/client/instances-types.d.ts.map +1 -1
- package/dist/client/instances.d.ts +26 -4
- package/dist/client/instances.d.ts.map +1 -1
- package/dist/client/instances.js +94 -3
- package/dist/client/instances.js.map +1 -1
- package/dist/client/loxtep-client.d.ts +48 -3
- package/dist/client/loxtep-client.d.ts.map +1 -1
- package/dist/client/loxtep-client.js +73 -5
- package/dist/client/loxtep-client.js.map +1 -1
- package/dist/client/projects-types.d.ts +25 -0
- package/dist/client/projects-types.d.ts.map +1 -1
- package/dist/client/projects.d.ts +2 -1
- package/dist/client/projects.d.ts.map +1 -1
- package/dist/client/projects.js +17 -0
- package/dist/client/projects.js.map +1 -1
- package/dist/client/promises.d.ts +11 -0
- package/dist/client/promises.d.ts.map +1 -1
- package/dist/client/promises.js +11 -0
- package/dist/client/promises.js.map +1 -1
- package/dist/client/queue-types.d.ts +15 -2
- package/dist/client/queue-types.d.ts.map +1 -1
- package/dist/client/queues.d.ts.map +1 -1
- package/dist/client/queues.js +3 -14
- package/dist/client/queues.js.map +1 -1
- package/dist/client/schemas.d.ts +1 -0
- package/dist/client/schemas.d.ts.map +1 -1
- package/dist/client/schemas.js +4 -0
- package/dist/client/schemas.js.map +1 -1
- package/dist/client/thesaurus.d.ts +5 -0
- package/dist/client/thesaurus.d.ts.map +1 -1
- package/dist/client/thesaurus.js +12 -0
- package/dist/client/thesaurus.js.map +1 -1
- package/dist/codegen/emit.d.ts +25 -0
- package/dist/codegen/emit.d.ts.map +1 -0
- package/dist/codegen/emit.js +158 -0
- package/dist/codegen/emit.js.map +1 -0
- package/dist/codegen/index.d.ts +17 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +16 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/load-workspace-context.d.ts +30 -0
- package/dist/codegen/load-workspace-context.d.ts.map +1 -0
- package/dist/codegen/load-workspace-context.js +127 -0
- package/dist/codegen/load-workspace-context.js.map +1 -0
- package/dist/codegen/normalize.d.ts +35 -0
- package/dist/codegen/normalize.d.ts.map +1 -0
- package/dist/codegen/normalize.js +77 -0
- package/dist/codegen/normalize.js.map +1 -0
- package/dist/codegen/types.d.ts +89 -0
- package/dist/codegen/types.d.ts.map +1 -0
- package/dist/codegen/types.js +9 -0
- package/dist/codegen/types.js.map +1 -0
- package/dist/codegen/write-artifact.d.ts +40 -0
- package/dist/codegen/write-artifact.d.ts.map +1 -0
- package/dist/codegen/write-artifact.js +74 -0
- package/dist/codegen/write-artifact.js.map +1 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/workspace-config.d.ts +76 -0
- package/dist/config/workspace-config.d.ts.map +1 -0
- package/dist/config/workspace-config.js +129 -0
- package/dist/config/workspace-config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/rstreams/event-bridge.d.ts +16 -2
- package/dist/rstreams/event-bridge.d.ts.map +1 -1
- package/dist/rstreams/event-bridge.js +38 -5
- package/dist/rstreams/event-bridge.js.map +1 -1
- package/dist/skills/check-scope.d.ts +42 -0
- package/dist/skills/check-scope.d.ts.map +1 -0
- package/dist/skills/check-scope.js +84 -0
- package/dist/skills/check-scope.js.map +1 -0
- package/dist/skills/index.d.ts +14 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +12 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/loader.d.ts +79 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +102 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/skills/types.d.ts +55 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +9 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/skills/validate-references.d.ts +54 -0
- package/dist/skills/validate-references.d.ts.map +1 -0
- package/dist/skills/validate-references.js +80 -0
- package/dist/skills/validate-references.js.map +1 -0
- package/docs/getting-started.md +7 -0
- package/package.json +7 -5
- package/dist/cli/commands/data-assets-cmd.d.ts +0 -12
- package/dist/cli/commands/data-assets-cmd.d.ts.map +0 -1
- package/dist/cli/commands/data-assets-cmd.js +0 -75
- package/dist/cli/commands/data-assets-cmd.js.map +0 -1
- package/dist/cli/commands/pipelines-cmd.d.ts +0 -17
- package/dist/cli/commands/pipelines-cmd.d.ts.map +0 -1
- package/dist/cli/commands/pipelines-cmd.js +0 -52
- package/dist/cli/commands/pipelines-cmd.js.map +0 -1
- package/dist/cli/commands/promises-cmd.d.ts +0 -11
- package/dist/cli/commands/promises-cmd.d.ts.map +0 -1
- package/dist/cli/commands/promises-cmd.js +0 -53
- package/dist/cli/commands/promises-cmd.js.map +0 -1
- package/dist/client/consumptions-types.d.ts.map +0 -1
- package/dist/client/consumptions-types.js +0 -5
- package/dist/client/consumptions-types.js.map +0 -1
- package/dist/client/consumptions.d.ts +0 -14
- package/dist/client/consumptions.d.ts.map +0 -1
- package/dist/client/consumptions.js +0 -47
- package/dist/client/consumptions.js.map +0 -1
- package/dist/client/data-assets-types.d.ts +0 -150
- package/dist/client/data-assets-types.d.ts.map +0 -1
- package/dist/client/data-assets-types.js +0 -5
- package/dist/client/data-assets-types.js.map +0 -1
- package/dist/client/data-assets.d.ts +0 -31
- package/dist/client/data-assets.d.ts.map +0 -1
- package/dist/client/data-assets.js +0 -182
- package/dist/client/data-assets.js.map +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 3: Emit — render typed TypeScript source from NormalizedContext.
|
|
3
|
+
*
|
|
4
|
+
* This pure function transforms a `NormalizedContext` into a string of TypeScript
|
|
5
|
+
* source code containing typed `as const` constants and a `workspace` namespace
|
|
6
|
+
* that aggregates all resource collections.
|
|
7
|
+
*
|
|
8
|
+
* Requirements: R2.1, R2.2, R2.3, R2.4, R2.5
|
|
9
|
+
*
|
|
10
|
+
* @module codegen/emit
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Computes a deterministic SHA-256-like hash of the normalized context for cache
|
|
14
|
+
* invalidation (R12.4). Uses a simple djb2-based hash over the JSON-serialized
|
|
15
|
+
* context to produce a stable hex string.
|
|
16
|
+
*/
|
|
17
|
+
function computeContextHash(norm) {
|
|
18
|
+
const serialized = JSON.stringify(norm);
|
|
19
|
+
let hash = 5381;
|
|
20
|
+
for (let i = 0; i < serialized.length; i++) {
|
|
21
|
+
hash = ((hash << 5) + hash + serialized.charCodeAt(i)) | 0;
|
|
22
|
+
}
|
|
23
|
+
// Convert to unsigned 32-bit hex
|
|
24
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Serializes a JavaScript value to a TypeScript literal string.
|
|
28
|
+
* Handles strings, numbers, booleans, null, arrays, and plain objects.
|
|
29
|
+
*/
|
|
30
|
+
function toLiteral(value, indent) {
|
|
31
|
+
const pad = ' '.repeat(indent);
|
|
32
|
+
const innerPad = ' '.repeat(indent + 1);
|
|
33
|
+
if (value === null) {
|
|
34
|
+
return 'null';
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
return JSON.stringify(value);
|
|
38
|
+
}
|
|
39
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
40
|
+
return String(value);
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
if (value.length === 0) {
|
|
44
|
+
return '[]';
|
|
45
|
+
}
|
|
46
|
+
const items = value.map((item) => `${innerPad}${toLiteral(item, indent + 1)}`);
|
|
47
|
+
return `[\n${items.join(',\n')}\n${pad}]`;
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === 'object') {
|
|
50
|
+
const entries = Object.entries(value);
|
|
51
|
+
if (entries.length === 0) {
|
|
52
|
+
return '{}';
|
|
53
|
+
}
|
|
54
|
+
const props = entries.map(([key, val]) => `${innerPad}${safeKey(key)}: ${toLiteral(val, indent + 1)}`);
|
|
55
|
+
return `{\n${props.join(',\n')}\n${pad}}`;
|
|
56
|
+
}
|
|
57
|
+
return 'undefined';
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns a safe object key — quoted if not a valid identifier, bare otherwise.
|
|
61
|
+
*/
|
|
62
|
+
function safeKey(key) {
|
|
63
|
+
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)) {
|
|
64
|
+
return key;
|
|
65
|
+
}
|
|
66
|
+
return JSON.stringify(key);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Emits a single resource entry as a TypeScript object literal line.
|
|
70
|
+
*/
|
|
71
|
+
function emitResourceEntry(key, fields) {
|
|
72
|
+
const props = Object.entries(fields)
|
|
73
|
+
.map(([k, v]) => `${safeKey(k)}: ${toLiteral(v, 2)}`)
|
|
74
|
+
.join(', ');
|
|
75
|
+
return ` ${safeKey(key)}: { ${props} }`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Emits a resource collection as a typed `as const` export.
|
|
79
|
+
* Returns an empty object `{}` when the collection has no entries.
|
|
80
|
+
*/
|
|
81
|
+
function emitCollection(name, resources, fieldExtractor) {
|
|
82
|
+
if (resources.length === 0) {
|
|
83
|
+
return `export const ${name} = {} as const;`;
|
|
84
|
+
}
|
|
85
|
+
const entries = resources.map((r) => {
|
|
86
|
+
const fields = fieldExtractor(r.data);
|
|
87
|
+
return emitResourceEntry(r.key, fields);
|
|
88
|
+
});
|
|
89
|
+
return `export const ${name} = {\n${entries.join(',\n')},\n} as const;`;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Renders a `NormalizedContext` into a complete TypeScript source string.
|
|
93
|
+
*
|
|
94
|
+
* The output includes:
|
|
95
|
+
* - A header comment with an auto-generated notice and context hash (R12.4)
|
|
96
|
+
* - Per-resource-type `as const` exports with required fields (R2.1–R2.4)
|
|
97
|
+
* - A `workspace` namespace aggregating all collections (R2.5)
|
|
98
|
+
* - Empty objects for empty collections in the workspace namespace (R2.5)
|
|
99
|
+
*
|
|
100
|
+
* This is a pure function: same input always produces the same output (R2.6).
|
|
101
|
+
*/
|
|
102
|
+
export function emitArtifact(norm) {
|
|
103
|
+
const hash = computeContextHash(norm);
|
|
104
|
+
const header = [
|
|
105
|
+
`// .loxtep/generated/index.ts (AUTO-GENERATED — do not edit)`,
|
|
106
|
+
`// Context hash: ${hash}`,
|
|
107
|
+
'',
|
|
108
|
+
].join('\n');
|
|
109
|
+
const dataProductsBlock = emitCollection('dataProducts', norm.dataProducts, (dp) => ({
|
|
110
|
+
name: dp.name,
|
|
111
|
+
id: dp.id,
|
|
112
|
+
domain: dp.domain,
|
|
113
|
+
schema: dp.schema,
|
|
114
|
+
}));
|
|
115
|
+
const connectorsBlock = emitCollection('connectors', norm.connectors, (c) => ({
|
|
116
|
+
name: c.name,
|
|
117
|
+
type: c.type,
|
|
118
|
+
id: c.id,
|
|
119
|
+
connection_id: c.connection_id,
|
|
120
|
+
}));
|
|
121
|
+
const domainsBlock = emitCollection('domains', norm.domains, (d) => ({
|
|
122
|
+
name: d.name,
|
|
123
|
+
id: d.id,
|
|
124
|
+
data_product_ids: d.data_product_ids,
|
|
125
|
+
}));
|
|
126
|
+
const queuesBlock = emitCollection('queues', norm.queues, (q) => ({
|
|
127
|
+
name: q.name,
|
|
128
|
+
id: q.id,
|
|
129
|
+
}));
|
|
130
|
+
const flowsBlock = emitCollection('flows', norm.flows, (f) => ({
|
|
131
|
+
name: f.name,
|
|
132
|
+
id: f.id,
|
|
133
|
+
}));
|
|
134
|
+
const workflowsBlock = emitCollection('workflows', norm.workflows, (w) => ({
|
|
135
|
+
name: w.name,
|
|
136
|
+
id: w.id,
|
|
137
|
+
}));
|
|
138
|
+
const workspaceExport = 'export const workspace = { dataProducts, connectors, domains, queues, flows, workflows } as const;';
|
|
139
|
+
const parts = [
|
|
140
|
+
header,
|
|
141
|
+
dataProductsBlock,
|
|
142
|
+
'',
|
|
143
|
+
connectorsBlock,
|
|
144
|
+
'',
|
|
145
|
+
domainsBlock,
|
|
146
|
+
'',
|
|
147
|
+
queuesBlock,
|
|
148
|
+
'',
|
|
149
|
+
flowsBlock,
|
|
150
|
+
'',
|
|
151
|
+
workflowsBlock,
|
|
152
|
+
'',
|
|
153
|
+
workspaceExport,
|
|
154
|
+
'',
|
|
155
|
+
];
|
|
156
|
+
return parts.join('\n');
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=emit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/codegen/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAuB;IACjD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7D,CAAC;IACD,iCAAiC;IACjC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,SAAS,CAAC,KAAc,EAAE,MAAc;IAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEzC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,O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,CACnC,WAAW,EACX,IAAI,CAAC,SAAS,EACd,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACN,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,EAAE,EAAE,CAAC,CAAC,EAAE;KACT,CAAC,CACH,CAAC;IAEF,MAAM,eAAe,GACnB,oGAAoG,CAAC;IAEvG,MAAM,KAAK,GAAG;QACZ,MAAM;QACN,iBAAiB;QACjB,EAAE;QACF,eAAe;QACf,EAAE;QACF,YAAY;QACZ,EAAE;QACF,WAAW;QACX,EAAE;QACF,UAAU;QACV,EAAE;QACF,cAAc;QACd,EAAE;QACF,eAAe;QACf,EAAE;KACH,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen module — typed Workspace Context generation pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The pipeline has four stages:
|
|
5
|
+
* 1. load (I/O) — fetch resources from the control plane
|
|
6
|
+
* 2. normalize (pure) — deterministic key derivation + canonical ordering
|
|
7
|
+
* 3. emit (pure) — render typed TypeScript source
|
|
8
|
+
* 4. write (I/O) — atomic file write
|
|
9
|
+
*
|
|
10
|
+
* @module codegen
|
|
11
|
+
*/
|
|
12
|
+
export type { JsonSchema, WorkspaceContext, NormalizedContext, NormalizedResource, GenerateCounts, } from './types.js';
|
|
13
|
+
export { loadWorkspaceContext } from './load-workspace-context.js';
|
|
14
|
+
export { deriveKey, normalizeContext } from './normalize.js';
|
|
15
|
+
export { emitArtifact } from './emit.js';
|
|
16
|
+
export { writeArtifact, computeCounts } from './write-artifact.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen module — typed Workspace Context generation pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The pipeline has four stages:
|
|
5
|
+
* 1. load (I/O) — fetch resources from the control plane
|
|
6
|
+
* 2. normalize (pure) — deterministic key derivation + canonical ordering
|
|
7
|
+
* 3. emit (pure) — render typed TypeScript source
|
|
8
|
+
* 4. write (I/O) — atomic file write
|
|
9
|
+
*
|
|
10
|
+
* @module codegen
|
|
11
|
+
*/
|
|
12
|
+
export { loadWorkspaceContext } from './load-workspace-context.js';
|
|
13
|
+
export { deriveKey, normalizeContext } from './normalize.js';
|
|
14
|
+
export { emitArtifact } from './emit.js';
|
|
15
|
+
export { writeArtifact, computeCounts } from './write-artifact.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 1 (I/O): Load the raw WorkspaceContext from the control plane.
|
|
3
|
+
*
|
|
4
|
+
* Queries the Loxtep API via LoxtepClient namespaces scoped to the project_id:
|
|
5
|
+
* - data_products (org-level, all available to the project)
|
|
6
|
+
* - connectors (org-level)
|
|
7
|
+
* - domains (org-level, with associated data product ids)
|
|
8
|
+
* - queues (instance-level, from observe)
|
|
9
|
+
* - flows (project-scoped)
|
|
10
|
+
* - workflows (project-scoped)
|
|
11
|
+
*
|
|
12
|
+
* @module codegen/load-workspace-context
|
|
13
|
+
*/
|
|
14
|
+
import type { LoxtepClient } from '../client/loxtep-client.js';
|
|
15
|
+
import type { WorkspaceContext } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Fetch all workspace resources from the control plane and assemble them into
|
|
18
|
+
* a WorkspaceContext. The client must be configured with a valid project_id.
|
|
19
|
+
*
|
|
20
|
+
* All list calls use large page sizes to fetch the complete resource set.
|
|
21
|
+
* Pagination is handled by fetching the maximum page size; projects with
|
|
22
|
+
* extremely large resource counts may need future iteration.
|
|
23
|
+
*
|
|
24
|
+
* @param client - An authenticated LoxtepClient instance
|
|
25
|
+
* @param projectId - The project to scope the context to
|
|
26
|
+
* @returns The assembled WorkspaceContext with all resource collections
|
|
27
|
+
* @throws If any control-plane query fails (caller should handle R2.8)
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadWorkspaceContext(client: LoxtepClient, projectId: string): Promise<WorkspaceContext>;
|
|
30
|
+
//# sourceMappingURL=load-workspace-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-workspace-context.d.ts","sourceRoot":"","sources":["../../src/codegen/load-workspace-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,CAAC,CAmF3B"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 1 (I/O): Load the raw WorkspaceContext from the control plane.
|
|
3
|
+
*
|
|
4
|
+
* Queries the Loxtep API via LoxtepClient namespaces scoped to the project_id:
|
|
5
|
+
* - data_products (org-level, all available to the project)
|
|
6
|
+
* - connectors (org-level)
|
|
7
|
+
* - domains (org-level, with associated data product ids)
|
|
8
|
+
* - queues (instance-level, from observe)
|
|
9
|
+
* - flows (project-scoped)
|
|
10
|
+
* - workflows (project-scoped)
|
|
11
|
+
*
|
|
12
|
+
* @module codegen/load-workspace-context
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fetch all workspace resources from the control plane and assemble them into
|
|
16
|
+
* a WorkspaceContext. The client must be configured with a valid project_id.
|
|
17
|
+
*
|
|
18
|
+
* All list calls use large page sizes to fetch the complete resource set.
|
|
19
|
+
* Pagination is handled by fetching the maximum page size; projects with
|
|
20
|
+
* extremely large resource counts may need future iteration.
|
|
21
|
+
*
|
|
22
|
+
* @param client - An authenticated LoxtepClient instance
|
|
23
|
+
* @param projectId - The project to scope the context to
|
|
24
|
+
* @returns The assembled WorkspaceContext with all resource collections
|
|
25
|
+
* @throws If any control-plane query fails (caller should handle R2.8)
|
|
26
|
+
*/
|
|
27
|
+
export async function loadWorkspaceContext(client, projectId) {
|
|
28
|
+
// Fetch all resource types concurrently for performance.
|
|
29
|
+
// Project-scoped resources (flows, workflows) use projectId directly.
|
|
30
|
+
// Org-scoped resources (data products, connectors, domains) fetch all available.
|
|
31
|
+
const [dataProductsResult, connectorsResult, domainsResult, flowsResult, workflowsResult,] = await Promise.all([
|
|
32
|
+
client.data_products.list({ page: 1, page_size: 1000 }),
|
|
33
|
+
client.connectors.list({ page: 1, page_size: 1000 }),
|
|
34
|
+
client.domains.list({ page: 1, page_size: 1000 }),
|
|
35
|
+
client.flows.list({ project_id: projectId, page: 1, page_size: 1000 }),
|
|
36
|
+
client.workflows.listWorkflows({ project_id: projectId, page: 1, page_size: 1000 }),
|
|
37
|
+
]);
|
|
38
|
+
// Fetch queues from the observe endpoint (instance-level).
|
|
39
|
+
// The observe.status() returns bot/queue info for the configured instance.
|
|
40
|
+
let queuesRaw = [];
|
|
41
|
+
try {
|
|
42
|
+
const observeData = await client.observe.status();
|
|
43
|
+
queuesRaw = extractQueuesFromObserve(observeData);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// If observe is not available (e.g. no instance configured), queues will be empty.
|
|
47
|
+
// This is acceptable — queues are instance-level and may not be reachable during
|
|
48
|
+
// initial setup.
|
|
49
|
+
queuesRaw = [];
|
|
50
|
+
}
|
|
51
|
+
// Map data products to workspace context shape
|
|
52
|
+
const dataProducts = (dataProductsResult?.items ?? []).map(dp => ({
|
|
53
|
+
name: dp.name,
|
|
54
|
+
id: dp.data_product_id,
|
|
55
|
+
domain: dp.domain_id ?? null,
|
|
56
|
+
schema: dp.schema ?? null,
|
|
57
|
+
}));
|
|
58
|
+
// Map connectors to workspace context shape
|
|
59
|
+
const connectors = (connectorsResult?.items ?? []).map(c => ({
|
|
60
|
+
type: c.connector_type,
|
|
61
|
+
id: c.connector_id,
|
|
62
|
+
connection_id: null, // Connectors at org-level don't have a project connection_id
|
|
63
|
+
name: c.metadata?.name ?? c.connector_type,
|
|
64
|
+
}));
|
|
65
|
+
// Map domains to workspace context shape
|
|
66
|
+
const domainsItems = domainsResult?.items ?? [];
|
|
67
|
+
const domains = domainsItems.map(d => ({
|
|
68
|
+
name: d.name,
|
|
69
|
+
id: d.domain_id,
|
|
70
|
+
data_product_ids: dataProducts
|
|
71
|
+
.filter(dp => dp.domain === d.domain_id)
|
|
72
|
+
.map(dp => dp.id),
|
|
73
|
+
}));
|
|
74
|
+
// Map flows to workspace context shape
|
|
75
|
+
const flowItems = flowsResult?.items ?? [];
|
|
76
|
+
const flows = flowItems.map(f => ({
|
|
77
|
+
name: f.name,
|
|
78
|
+
id: f.workflow_id,
|
|
79
|
+
}));
|
|
80
|
+
// Map workflows to workspace context shape
|
|
81
|
+
const workflowItems = workflowsResult?.items ?? [];
|
|
82
|
+
const workflows = workflowItems.map(w => ({
|
|
83
|
+
name: w.name,
|
|
84
|
+
id: w.workflow_id,
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
dataProducts,
|
|
88
|
+
connectors,
|
|
89
|
+
domains,
|
|
90
|
+
queues: queuesRaw,
|
|
91
|
+
flows,
|
|
92
|
+
workflows,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Extract queue names and ids from the observe status response.
|
|
97
|
+
* The observe endpoint returns various shapes; we extract queue-like entries
|
|
98
|
+
* that have a name/queue_name and an identifier.
|
|
99
|
+
*/
|
|
100
|
+
function extractQueuesFromObserve(observeData) {
|
|
101
|
+
if (!observeData || typeof observeData !== 'object')
|
|
102
|
+
return [];
|
|
103
|
+
const data = observeData;
|
|
104
|
+
// Try to extract queues from common observe response shapes
|
|
105
|
+
const queuesArray = data.queues ??
|
|
106
|
+
data.data?.queues ??
|
|
107
|
+
[];
|
|
108
|
+
if (!Array.isArray(queuesArray))
|
|
109
|
+
return [];
|
|
110
|
+
const result = [];
|
|
111
|
+
for (const q of queuesArray) {
|
|
112
|
+
if (!q || typeof q !== 'object')
|
|
113
|
+
continue;
|
|
114
|
+
const entry = q;
|
|
115
|
+
const name = entry.queue_name ??
|
|
116
|
+
entry.name ??
|
|
117
|
+
'';
|
|
118
|
+
const id = entry.queue_id ??
|
|
119
|
+
entry.id ??
|
|
120
|
+
'';
|
|
121
|
+
if (name) {
|
|
122
|
+
result.push({ name, id: id || name });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=load-workspace-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-workspace-context.js","sourceRoot":"","sources":["../../src/codegen/load-workspace-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAoB,EACpB,SAAiB;IAEjB,yDAAyD;IACzD,sEAAsE;IACtE,iFAAiF;IACjF,MAAM,CACJ,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,eAAe,EAChB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACvD,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACpD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACjD,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACtE,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;KACpF,CAAC,CAAC;IAEH,2DAA2D;IAC3D,2EAA2E;IAC3E,IAAI,SAAS,GAAwC,EAAE,CAAC;IACxD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAClD,SAAS,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,mFAAmF;QACnF,iFAAiF;QACjF,iBAAiB;QACjB,SA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YACpB,EAAE,CAAC;QACL,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2: Normalize — deterministic key derivation + canonical ordering.
|
|
3
|
+
*
|
|
4
|
+
* This pure function transforms a raw `WorkspaceContext` into a `NormalizedContext`
|
|
5
|
+
* with stable, deterministic keys and canonical id-sorted ordering, ensuring
|
|
6
|
+
* byte-identical output for unchanged contexts (R2.6).
|
|
7
|
+
*
|
|
8
|
+
* @module codegen/normalize
|
|
9
|
+
*/
|
|
10
|
+
import type { WorkspaceContext, NormalizedContext } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Derives a deterministic, valid TypeScript identifier key from a resource name.
|
|
13
|
+
*
|
|
14
|
+
* Rules:
|
|
15
|
+
* 1. Lowercase the name
|
|
16
|
+
* 2. Replace any run of non-alphanumeric characters with a single `_`
|
|
17
|
+
* 3. Trim leading/trailing `_`
|
|
18
|
+
* 4. If result is empty or starts with a digit, prefix with `_`
|
|
19
|
+
*
|
|
20
|
+
* Collision resolution is handled separately in `normalizeCollection`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function deriveKey(name: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes the entire workspace context.
|
|
25
|
+
*
|
|
26
|
+
* Transforms raw `WorkspaceContext` into `NormalizedContext` by:
|
|
27
|
+
* - Sorting each resource collection by id (ascending) for canonical ordering
|
|
28
|
+
* - Deriving deterministic keys from resource names
|
|
29
|
+
* - Resolving key collisions with `_2`, `_3`, … suffixes in id-sorted order
|
|
30
|
+
*
|
|
31
|
+
* This is a pure function: given the same input, it always produces the same output,
|
|
32
|
+
* guaranteeing byte-identical artifacts for unchanged contexts (R2.6).
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeContext(ctx: WorkspaceContext): NormalizedContext;
|
|
35
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/codegen/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAsB,MAAM,YAAY,CAAC;AAE1F;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB9C;AAgCD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,iBAAiB,CASzE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 2: Normalize — deterministic key derivation + canonical ordering.
|
|
3
|
+
*
|
|
4
|
+
* This pure function transforms a raw `WorkspaceContext` into a `NormalizedContext`
|
|
5
|
+
* with stable, deterministic keys and canonical id-sorted ordering, ensuring
|
|
6
|
+
* byte-identical output for unchanged contexts (R2.6).
|
|
7
|
+
*
|
|
8
|
+
* @module codegen/normalize
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Derives a deterministic, valid TypeScript identifier key from a resource name.
|
|
12
|
+
*
|
|
13
|
+
* Rules:
|
|
14
|
+
* 1. Lowercase the name
|
|
15
|
+
* 2. Replace any run of non-alphanumeric characters with a single `_`
|
|
16
|
+
* 3. Trim leading/trailing `_`
|
|
17
|
+
* 4. If result is empty or starts with a digit, prefix with `_`
|
|
18
|
+
*
|
|
19
|
+
* Collision resolution is handled separately in `normalizeCollection`.
|
|
20
|
+
*/
|
|
21
|
+
export function deriveKey(name) {
|
|
22
|
+
// Step 1: lowercase
|
|
23
|
+
let key = name.toLowerCase();
|
|
24
|
+
// Step 2: replace any run of non-alphanumeric characters with a single `_`
|
|
25
|
+
key = key.replace(/[^a-z0-9]+/g, '_');
|
|
26
|
+
// Step 3: trim leading/trailing `_`
|
|
27
|
+
key = key.replace(/^_+|_+$/g, '');
|
|
28
|
+
// Step 4: if empty or starts with a digit, prefix with `_`
|
|
29
|
+
if (key === '' || /^[0-9]/.test(key)) {
|
|
30
|
+
key = '_' + key;
|
|
31
|
+
}
|
|
32
|
+
return key;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes a single resource collection:
|
|
36
|
+
* - Sorts resources by `id` in ascending lexicographic order (canonical ordering)
|
|
37
|
+
* - Derives a key from each resource's `name`
|
|
38
|
+
* - Resolves collisions by appending `_2`, `_3`, etc. in id-sorted order
|
|
39
|
+
* (the first resource in id order keeps the base key, subsequent collisions get suffixes)
|
|
40
|
+
*/
|
|
41
|
+
function normalizeCollection(resources) {
|
|
42
|
+
// Sort by id ascending for canonical ordering
|
|
43
|
+
const sorted = [...resources].sort((a, b) => a.id.localeCompare(b.id));
|
|
44
|
+
// Group by derived base key to detect collisions
|
|
45
|
+
const keyGroups = new Map();
|
|
46
|
+
return sorted.map((resource) => {
|
|
47
|
+
const baseKey = deriveKey(resource.name);
|
|
48
|
+
// Track how many times we've seen this base key
|
|
49
|
+
const count = keyGroups.get(baseKey) ?? 0;
|
|
50
|
+
keyGroups.set(baseKey, count + 1);
|
|
51
|
+
// First occurrence keeps the base key; subsequent get _2, _3, etc.
|
|
52
|
+
const key = count === 0 ? baseKey : `${baseKey}_${count + 1}`;
|
|
53
|
+
return { key, data: resource };
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Normalizes the entire workspace context.
|
|
58
|
+
*
|
|
59
|
+
* Transforms raw `WorkspaceContext` into `NormalizedContext` by:
|
|
60
|
+
* - Sorting each resource collection by id (ascending) for canonical ordering
|
|
61
|
+
* - Deriving deterministic keys from resource names
|
|
62
|
+
* - Resolving key collisions with `_2`, `_3`, … suffixes in id-sorted order
|
|
63
|
+
*
|
|
64
|
+
* This is a pure function: given the same input, it always produces the same output,
|
|
65
|
+
* guaranteeing byte-identical artifacts for unchanged contexts (R2.6).
|
|
66
|
+
*/
|
|
67
|
+
export function normalizeContext(ctx) {
|
|
68
|
+
return {
|
|
69
|
+
dataProducts: normalizeCollection(ctx.dataProducts),
|
|
70
|
+
connectors: normalizeCollection(ctx.connectors),
|
|
71
|
+
domains: normalizeCollection(ctx.domains),
|
|
72
|
+
queues: normalizeCollection(ctx.queues),
|
|
73
|
+
flows: normalizeCollection(ctx.flows),
|
|
74
|
+
workflows: normalizeCollection(ctx.workflows),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/codegen/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,oBAAoB;IACpB,IAAI,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAE7B,2EAA2E;IAC3E,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAEtC,oCAAoC;IACpC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAElC,2DAA2D;IAC3D,IAAI,GAAG,KAAK,EAAE,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,SAAS,mBAAmB,CAC1B,SAAc;IAEd,8CAA8C;IAC9C,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,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tep resources into a single
|
|
5
|
+
* typed SDK artifact at `.loxtep/generated/index.ts`. These types define the
|
|
6
|
+
* intermediate representations used across the pipeline stages.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A JSON Schema representation. Matches the standard JSON Schema shape used
|
|
10
|
+
* across the Loxtep platform for data product schemas.
|
|
11
|
+
*/
|
|
12
|
+
export interface JsonSchema {
|
|
13
|
+
type?: string;
|
|
14
|
+
properties?: Record<string, JsonSchema>;
|
|
15
|
+
items?: JsonSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Raw workspace context fetched from the control plane.
|
|
21
|
+
* Each resource collection contains the minimal fields needed for typed codegen.
|
|
22
|
+
* This is the output of Stage 1 (I/O load) and input to Stage 2 (normalize).
|
|
23
|
+
*/
|
|
24
|
+
export interface WorkspaceContext {
|
|
25
|
+
dataProducts: {
|
|
26
|
+
name: string;
|
|
27
|
+
id: string;
|
|
28
|
+
domain: string | null;
|
|
29
|
+
schema: JsonSchema | null;
|
|
30
|
+
}[];
|
|
31
|
+
connectors: {
|
|
32
|
+
type: string;
|
|
33
|
+
id: string;
|
|
34
|
+
connection_id: string | null;
|
|
35
|
+
name: string;
|
|
36
|
+
}[];
|
|
37
|
+
domains: {
|
|
38
|
+
name: string;
|
|
39
|
+
id: string;
|
|
40
|
+
data_product_ids: string[];
|
|
41
|
+
}[];
|
|
42
|
+
queues: {
|
|
43
|
+
name: string;
|
|
44
|
+
id: string;
|
|
45
|
+
}[];
|
|
46
|
+
flows: {
|
|
47
|
+
name: string;
|
|
48
|
+
id: string;
|
|
49
|
+
}[];
|
|
50
|
+
workflows: {
|
|
51
|
+
name: string;
|
|
52
|
+
id: string;
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A single normalized resource entry after deterministic key derivation.
|
|
57
|
+
* The `key` is the stable namespace accessor (e.g. `shopify_gql_customer`).
|
|
58
|
+
*/
|
|
59
|
+
export interface NormalizedResource<T> {
|
|
60
|
+
key: string;
|
|
61
|
+
data: T;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Normalized context after Stage 2 processing.
|
|
65
|
+
* Resources are sorted by id in ascending order with deterministic keys derived
|
|
66
|
+
* from resource names. This guarantees byte-identical output for unchanged contexts.
|
|
67
|
+
*/
|
|
68
|
+
export interface NormalizedContext {
|
|
69
|
+
dataProducts: NormalizedResource<WorkspaceContext['dataProducts'][number]>[];
|
|
70
|
+
connectors: NormalizedResource<WorkspaceContext['connectors'][number]>[];
|
|
71
|
+
domains: NormalizedResource<WorkspaceContext['domains'][number]>[];
|
|
72
|
+
queues: NormalizedResource<WorkspaceContext['queues'][number]>[];
|
|
73
|
+
flows: NormalizedResource<WorkspaceContext['flows'][number]>[];
|
|
74
|
+
workflows: NormalizedResource<WorkspaceContext['workflows'][number]>[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Per-resource-type counts reported after artifact generation.
|
|
78
|
+
* Each field reports the number of typed constants written for that resource type.
|
|
79
|
+
* Reports 0 for resource types with no resources (R2.7).
|
|
80
|
+
*/
|
|
81
|
+
export interface GenerateCounts {
|
|
82
|
+
dataProducts: number;
|
|
83
|
+
connectors: number;
|
|
84
|
+
domains: number;
|
|
85
|
+
queues: number;
|
|
86
|
+
flows: number;
|
|
87
|
+
workflows: number;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/codegen/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,UAAU,CAAC;IACn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EAAE,CAAC;IACzE,OAAO,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IACnE,MAAM,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IACjE,KAAK,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;IAC/D,SAAS,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;CACxE;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codegen types for the typed Workspace Context generation pipeline.
|
|
3
|
+
*
|
|
4
|
+
* The codegen pipeline compiles the connected Loxtep resources into a single
|
|
5
|
+
* typed SDK artifact at `.loxtep/generated/index.ts`. These types define the
|
|
6
|
+
* intermediate representations used across the pipeline stages.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/codegen/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stage 4: Write — atomic file overwrite returning per-type counts.
|
|
3
|
+
*
|
|
4
|
+
* This I/O stage takes the emitted TypeScript source string and writes it
|
|
5
|
+
* atomically to the target path. "Atomic" means: write to a temporary file
|
|
6
|
+
* in the same directory, then rename over the target. If the process crashes
|
|
7
|
+
* or the write fails at any point, the prior artifact remains unchanged (R2.8).
|
|
8
|
+
*
|
|
9
|
+
* The function also computes and returns per-resource-type counts from the
|
|
10
|
+
* provided NormalizedContext so the CLI can print them (R2.7).
|
|
11
|
+
*
|
|
12
|
+
* Requirements: R2.6, R2.7, R2.8
|
|
13
|
+
*
|
|
14
|
+
* @module codegen/write-artifact
|
|
15
|
+
*/
|
|
16
|
+
import type { NormalizedContext, GenerateCounts } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* Computes per-resource-type counts from a NormalizedContext.
|
|
19
|
+
* Returns 0 for each resource type that has no resources (R2.7).
|
|
20
|
+
*/
|
|
21
|
+
export declare function computeCounts(norm: NormalizedContext): GenerateCounts;
|
|
22
|
+
/**
|
|
23
|
+
* Writes the generated artifact source to disk atomically and returns per-type counts.
|
|
24
|
+
*
|
|
25
|
+
* Atomicity strategy:
|
|
26
|
+
* 1. Ensure the target directory exists.
|
|
27
|
+
* 2. Write the full source to a temporary file in the same directory (same filesystem).
|
|
28
|
+
* 3. Rename the temporary file over the target path (atomic on POSIX filesystems).
|
|
29
|
+
*
|
|
30
|
+
* If any step fails, the temporary file is cleaned up (best-effort) and the
|
|
31
|
+
* prior artifact at `targetPath` remains unchanged (R2.8). The error is re-thrown
|
|
32
|
+
* so the caller can handle it (e.g. exit non-zero, print the failure reason).
|
|
33
|
+
*
|
|
34
|
+
* @param targetPath - Absolute or relative path to the generated artifact file.
|
|
35
|
+
* @param source - The TypeScript source string produced by `emitArtifact`.
|
|
36
|
+
* @param norm - The NormalizedContext used to compute resource counts.
|
|
37
|
+
* @returns Per-resource-type counts written to the artifact (R2.7).
|
|
38
|
+
*/
|
|
39
|
+
export declare function writeArtifact(targetPath: string, source: string, norm: NormalizedContext): Promise<GenerateCounts>;
|
|
40
|
+
//# sourceMappingURL=write-artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-artifact.d.ts","sourceRoot":"","sources":["../../src/codegen/write-artifact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CASrE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,cAAc,CAAC,CAyBzB"}
|