@mmapp/react-compiler 0.1.0-alpha.19 → 0.1.0-alpha.21
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/dist/babel/index.js +29 -5
- package/dist/babel/index.mjs +1 -1
- package/dist/chunk-4FP5DXY4.mjs +3456 -0
- package/dist/chunk-5PM7CGFQ.mjs +550 -0
- package/dist/chunk-AIM5FKMV.mjs +186 -0
- package/dist/chunk-EYLOSECJ.mjs +544 -0
- package/dist/chunk-I6SSPILI.mjs +550 -0
- package/dist/chunk-MRCNUYFA.mjs +2921 -0
- package/dist/chunk-NJNAQF5I.mjs +7533 -0
- package/dist/chunk-RTAUTGHB.mjs +248 -0
- package/dist/chunk-U6F7CTHK.mjs +550 -0
- package/dist/chunk-XUQ5R6F3.mjs +213 -0
- package/dist/chunk-YOVAADAD.mjs +175 -0
- package/dist/cli/index.js +42 -14
- package/dist/cli/index.mjs +9 -9
- package/dist/deploy-VAHWALWB.mjs +9 -0
- package/dist/dev-server.js +40 -12
- package/dist/dev-server.mjs +4 -4
- package/dist/envelope.js +29 -5
- package/dist/envelope.mjs +2 -2
- package/dist/index.js +41 -13
- package/dist/index.mjs +8 -8
- package/dist/init-AVZJHZYY.mjs +538 -0
- package/dist/project-compiler-HNDWIX4J.mjs +10 -0
- package/dist/project-decompiler-QCZYY4TW.mjs +7 -0
- package/dist/pull-5WJ4LW4U.mjs +109 -0
- package/dist/testing/index.js +29 -5
- package/dist/testing/index.mjs +1 -1
- package/dist/verify-LZXUHOX6.mjs +1833 -0
- package/dist/vite/index.js +29 -5
- package/dist/vite/index.mjs +2 -2
- package/mm-dev.db +0 -0
- package/package.json +15 -5
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// src/cli/deploy.ts
|
|
2
|
+
import { glob } from "glob";
|
|
3
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
4
|
+
import { basename } from "path";
|
|
5
|
+
async function deploy(options) {
|
|
6
|
+
const dir = options.dir ?? "dist/workflows";
|
|
7
|
+
const targetLabel = options.targetName ? ` (target: ${options.targetName})` : "";
|
|
8
|
+
console.log(`[mindmatrix-react] Deploying workflows from ${dir} to ${options.apiUrl}${targetLabel}...`);
|
|
9
|
+
const files = await glob(`${dir}/**/*.workflow.json`);
|
|
10
|
+
if (files.length === 0) {
|
|
11
|
+
console.log(`[mindmatrix-react] No workflow files found in ${dir}`);
|
|
12
|
+
return { created: [], updated: [], versioned: [], skipped: [], failed: [] };
|
|
13
|
+
}
|
|
14
|
+
const result = {
|
|
15
|
+
created: [],
|
|
16
|
+
updated: [],
|
|
17
|
+
versioned: [],
|
|
18
|
+
skipped: [],
|
|
19
|
+
failed: []
|
|
20
|
+
};
|
|
21
|
+
const deployedIRs = [];
|
|
22
|
+
for (const file of files) {
|
|
23
|
+
try {
|
|
24
|
+
const ir = JSON.parse(readFileSync(file, "utf-8"));
|
|
25
|
+
const slug = ir.slug;
|
|
26
|
+
if (options.dryRun) {
|
|
27
|
+
console.log(` [dry-run] Would deploy ${slug} (${basename(file)})`);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const existing = await fetchExistingDefinition(options.apiUrl, options.token, slug);
|
|
31
|
+
if (!existing) {
|
|
32
|
+
await createDefinition(options.apiUrl, options.token, ir);
|
|
33
|
+
console.log(` \u2713 ${slug} (created)`);
|
|
34
|
+
result.created.push(slug);
|
|
35
|
+
} else if (existing.instanceCount === 0 || options.force) {
|
|
36
|
+
await updateDefinition(options.apiUrl, options.token, existing.id, ir);
|
|
37
|
+
console.log(` \u2713 ${slug} (updated)`);
|
|
38
|
+
result.updated.push(slug);
|
|
39
|
+
} else {
|
|
40
|
+
const newVersion = bumpVersion(existing.version);
|
|
41
|
+
ir.version = newVersion;
|
|
42
|
+
await createDefinition(options.apiUrl, options.token, ir);
|
|
43
|
+
console.log(` \u2713 ${slug} v${newVersion} (new version, ${existing.instanceCount} instances on v${existing.version})`);
|
|
44
|
+
result.versioned.push(slug);
|
|
45
|
+
}
|
|
46
|
+
deployedIRs.push(ir);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const slug = basename(file).replace(".workflow.json", "");
|
|
49
|
+
const msg = error.message;
|
|
50
|
+
console.error(` \u2717 ${slug}: ${msg}`);
|
|
51
|
+
result.failed.push({ slug, error: msg });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!options.dryRun) {
|
|
55
|
+
for (const ir of deployedIRs) {
|
|
56
|
+
const serviceResult = await syncServices(options.apiUrl, options.token, ir);
|
|
57
|
+
if (serviceResult) {
|
|
58
|
+
if (!result.services) {
|
|
59
|
+
result.services = { registered: [], updated: [], failed: [] };
|
|
60
|
+
}
|
|
61
|
+
result.services.registered.push(...serviceResult.registered);
|
|
62
|
+
result.services.updated.push(...serviceResult.updated);
|
|
63
|
+
result.services.failed.push(...serviceResult.failed);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (options.reportFile) {
|
|
68
|
+
writeFileSync(options.reportFile, JSON.stringify(result, null, 2), "utf-8");
|
|
69
|
+
console.log(`
|
|
70
|
+
Report written to ${options.reportFile}`);
|
|
71
|
+
}
|
|
72
|
+
const total = result.created.length + result.updated.length + result.versioned.length;
|
|
73
|
+
console.log(
|
|
74
|
+
`
|
|
75
|
+
[mindmatrix-react] Deployed ${total} workflows (${result.created.length} created, ${result.updated.length} updated, ${result.versioned.length} versioned, ${result.failed.length} failed)`
|
|
76
|
+
);
|
|
77
|
+
if (result.services) {
|
|
78
|
+
const svcTotal = result.services.registered.length + result.services.updated.length;
|
|
79
|
+
if (svcTotal > 0 || result.services.failed.length > 0) {
|
|
80
|
+
console.log(
|
|
81
|
+
`[mindmatrix-react] Synced ${svcTotal} services (${result.services.registered.length} registered, ${result.services.updated.length} updated, ${result.services.failed.length} failed)`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
async function fetchExistingDefinition(apiUrl, token, slug) {
|
|
88
|
+
try {
|
|
89
|
+
const res = await fetch(`${apiUrl}/workflow/definitions/${encodeURIComponent(slug)}`, {
|
|
90
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
91
|
+
});
|
|
92
|
+
if (!res.ok) return null;
|
|
93
|
+
const def = await res.json();
|
|
94
|
+
if (!def || !def.id) return null;
|
|
95
|
+
return {
|
|
96
|
+
id: def.id,
|
|
97
|
+
slug: def.slug,
|
|
98
|
+
version: def.version || "0.1.0",
|
|
99
|
+
instanceCount: def.instanceCount ?? def.instance_count ?? 0
|
|
100
|
+
};
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async function createDefinition(apiUrl, token, ir) {
|
|
106
|
+
const res = await fetch(`${apiUrl}/workflow/definitions`, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: {
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Authorization: `Bearer ${token}`
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify({ ...ir, visibility: "PUBLIC" })
|
|
113
|
+
});
|
|
114
|
+
if (!res.ok) {
|
|
115
|
+
const errorText = await res.text();
|
|
116
|
+
throw new Error(`Create failed: ${res.status} ${errorText}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function updateDefinition(apiUrl, token, id, ir) {
|
|
120
|
+
const { slug: _slug, ...updatePayload } = ir;
|
|
121
|
+
const res = await fetch(`${apiUrl}/workflow/definitions/${id}`, {
|
|
122
|
+
method: "PATCH",
|
|
123
|
+
headers: {
|
|
124
|
+
"Content-Type": "application/json",
|
|
125
|
+
Authorization: `Bearer ${token}`
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify(updatePayload)
|
|
128
|
+
});
|
|
129
|
+
if (!res.ok) {
|
|
130
|
+
const errorText = await res.text();
|
|
131
|
+
throw new Error(`Update failed: ${res.status} ${errorText}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function bumpVersion(version) {
|
|
135
|
+
const parts = version.split(".");
|
|
136
|
+
if (parts.length !== 3) return `${version}.1`;
|
|
137
|
+
const patch = parseInt(parts[2], 10) || 0;
|
|
138
|
+
return `${parts[0]}.${parts[1]}.${patch + 1}`;
|
|
139
|
+
}
|
|
140
|
+
async function syncServices(apiUrl, token, ir) {
|
|
141
|
+
const metadata = ir.metadata;
|
|
142
|
+
const orchestration = metadata?.orchestration;
|
|
143
|
+
const services = orchestration?.services;
|
|
144
|
+
if (!services || Object.keys(services).length === 0) return null;
|
|
145
|
+
const result = { registered: [], updated: [], failed: [] };
|
|
146
|
+
for (const [name, config] of Object.entries(services)) {
|
|
147
|
+
try {
|
|
148
|
+
const registration = {
|
|
149
|
+
name,
|
|
150
|
+
connection: {
|
|
151
|
+
type: config.type || "webhook",
|
|
152
|
+
url: config.url,
|
|
153
|
+
queue: config.queue
|
|
154
|
+
},
|
|
155
|
+
actions: config.actions || [],
|
|
156
|
+
labels: config.labels || {}
|
|
157
|
+
};
|
|
158
|
+
const existing = await fetchExistingService(apiUrl, token, name);
|
|
159
|
+
if (existing) {
|
|
160
|
+
await fetch(`${apiUrl}/services/${existing.id}`, {
|
|
161
|
+
method: "PATCH",
|
|
162
|
+
headers: {
|
|
163
|
+
"Content-Type": "application/json",
|
|
164
|
+
Authorization: `Bearer ${token}`
|
|
165
|
+
},
|
|
166
|
+
body: JSON.stringify(registration)
|
|
167
|
+
});
|
|
168
|
+
console.log(` \u2713 service: ${name} (updated)`);
|
|
169
|
+
result.updated.push(name);
|
|
170
|
+
} else {
|
|
171
|
+
const res = await fetch(`${apiUrl}/services`, {
|
|
172
|
+
method: "POST",
|
|
173
|
+
headers: {
|
|
174
|
+
"Content-Type": "application/json",
|
|
175
|
+
Authorization: `Bearer ${token}`
|
|
176
|
+
},
|
|
177
|
+
body: JSON.stringify(registration)
|
|
178
|
+
});
|
|
179
|
+
if (!res.ok) {
|
|
180
|
+
const errorText = await res.text();
|
|
181
|
+
throw new Error(`Register failed: ${res.status} ${errorText}`);
|
|
182
|
+
}
|
|
183
|
+
console.log(` \u2713 service: ${name} (registered)`);
|
|
184
|
+
result.registered.push(name);
|
|
185
|
+
}
|
|
186
|
+
} catch (error) {
|
|
187
|
+
const msg = error.message;
|
|
188
|
+
console.error(` \u2717 service: ${name}: ${msg}`);
|
|
189
|
+
result.failed.push(name);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
async function fetchExistingService(apiUrl, token, name) {
|
|
195
|
+
try {
|
|
196
|
+
const res = await fetch(`${apiUrl}/services?name=${encodeURIComponent(name)}`, {
|
|
197
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
198
|
+
});
|
|
199
|
+
if (!res.ok) return null;
|
|
200
|
+
const data = await res.json();
|
|
201
|
+
const servicesList = Array.isArray(data) ? data : data.services ?? data.items ?? data.data;
|
|
202
|
+
if (!servicesList || servicesList.length === 0) return null;
|
|
203
|
+
const found = servicesList.find((s) => s.name === name);
|
|
204
|
+
return found ? { id: found.id, name: found.name } : null;
|
|
205
|
+
} catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export {
|
|
211
|
+
deploy,
|
|
212
|
+
syncServices
|
|
213
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
babelPlugin
|
|
3
|
+
} from "./chunk-NJNAQF5I.mjs";
|
|
4
|
+
|
|
5
|
+
// src/vite/index.ts
|
|
6
|
+
import { transformSync } from "@babel/core";
|
|
7
|
+
import { writeFileSync, mkdirSync } from "fs";
|
|
8
|
+
import { dirname, join, relative, basename } from "path";
|
|
9
|
+
function mindmatrixReact(options) {
|
|
10
|
+
const include = options?.include ?? ["**/*.workflow.tsx"];
|
|
11
|
+
const mode = options?.mode ?? "infer";
|
|
12
|
+
const outDir = options?.outDir ?? "dist/workflows";
|
|
13
|
+
const seedOnCompile = options?.seedOnCompile ?? false;
|
|
14
|
+
const apiUrl = options?.apiUrl ?? "http://localhost:4200/api/v1";
|
|
15
|
+
const authToken = options?.authToken ?? process.env.MINDMATRIX_TOKEN;
|
|
16
|
+
let enableSourceMaps = options?.sourceMaps;
|
|
17
|
+
let enableSourceAnnotations = options?.sourceAnnotations;
|
|
18
|
+
let isDev = true;
|
|
19
|
+
const compiledFiles = /* @__PURE__ */ new Map();
|
|
20
|
+
function shouldTransform(id) {
|
|
21
|
+
return include.some((pattern) => {
|
|
22
|
+
const regex = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "<<GLOBSTAR>>").replace(/\*/g, "[^/]*").replace(/<<GLOBSTAR>>/g, ".*").replace(/\?/g, ".");
|
|
23
|
+
return new RegExp(regex).test(id);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function seedToApi(ir, filePath) {
|
|
27
|
+
if (!seedOnCompile || !authToken) return;
|
|
28
|
+
try {
|
|
29
|
+
const body = {
|
|
30
|
+
slug: ir.slug,
|
|
31
|
+
name: ir.name,
|
|
32
|
+
version: ir.version,
|
|
33
|
+
category: ir.category || ["workflow"],
|
|
34
|
+
fields: ir.fields || [],
|
|
35
|
+
states: ir.states || [],
|
|
36
|
+
transitions: ir.transitions || [],
|
|
37
|
+
experience: ir.experience || {},
|
|
38
|
+
metadata: {
|
|
39
|
+
...ir.metadata || {},
|
|
40
|
+
source_file: relative(process.cwd(), filePath),
|
|
41
|
+
compiled_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const resp = await fetch(`${apiUrl}/workflow/definitions`, {
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
"Authorization": `Bearer ${authToken}`
|
|
49
|
+
},
|
|
50
|
+
body: JSON.stringify(body)
|
|
51
|
+
});
|
|
52
|
+
if (resp.ok) {
|
|
53
|
+
console.log(`[mindmatrix-react] Seeded ${ir.slug} to ${apiUrl}`);
|
|
54
|
+
} else if (resp.status === 409) {
|
|
55
|
+
const existing = await fetch(
|
|
56
|
+
`${apiUrl}/workflow/definitions?slug=${encodeURIComponent(ir.slug)}&version=${encodeURIComponent(ir.version)}`,
|
|
57
|
+
{ headers: { "Authorization": `Bearer ${authToken}` } }
|
|
58
|
+
);
|
|
59
|
+
if (existing.ok) {
|
|
60
|
+
const data = await existing.json();
|
|
61
|
+
const defId = Array.isArray(data) ? data[0]?.id : data?.id;
|
|
62
|
+
if (defId) {
|
|
63
|
+
await fetch(`${apiUrl}/workflow/definitions/${defId}`, {
|
|
64
|
+
method: "PATCH",
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "application/json",
|
|
67
|
+
"Authorization": `Bearer ${authToken}`
|
|
68
|
+
},
|
|
69
|
+
body: JSON.stringify(body)
|
|
70
|
+
});
|
|
71
|
+
console.log(`[mindmatrix-react] Updated ${ir.slug} (PATCH)`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
const text = await resp.text().catch(() => "");
|
|
76
|
+
console.warn(`[mindmatrix-react] Seed failed (${resp.status}): ${text.slice(0, 200)}`);
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.warn(`[mindmatrix-react] Seed failed:`, e instanceof Error ? e.message : e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
name: "mindmatrix-react",
|
|
84
|
+
enforce: "pre",
|
|
85
|
+
configResolved(config) {
|
|
86
|
+
isDev = config.command === "serve";
|
|
87
|
+
if (enableSourceMaps === void 0) enableSourceMaps = isDev;
|
|
88
|
+
if (enableSourceAnnotations === void 0) enableSourceAnnotations = isDev;
|
|
89
|
+
},
|
|
90
|
+
transform(code, id) {
|
|
91
|
+
if (!shouldTransform(id)) return null;
|
|
92
|
+
try {
|
|
93
|
+
const wantMaps = enableSourceMaps !== false;
|
|
94
|
+
const result = transformSync(code, {
|
|
95
|
+
filename: id,
|
|
96
|
+
plugins: [[babelPlugin, { mode, filename: id, sourceAnnotations: enableSourceAnnotations }]],
|
|
97
|
+
parserOpts: { plugins: ["jsx", "typescript"] },
|
|
98
|
+
sourceMaps: wantMaps,
|
|
99
|
+
// Embed original source in the source map so debuggers can show .workflow.tsx
|
|
100
|
+
...wantMaps ? { sourceFileName: basename(id) } : {}
|
|
101
|
+
});
|
|
102
|
+
if (!result?.code) return null;
|
|
103
|
+
const metadata = result.metadata || {};
|
|
104
|
+
const ir = metadata.mindmatrixIR;
|
|
105
|
+
const warnings = metadata.mindmatrixWarnings;
|
|
106
|
+
const errors = metadata.mindmatrixErrors;
|
|
107
|
+
if (warnings?.length) {
|
|
108
|
+
for (const w of warnings) {
|
|
109
|
+
console.warn(`[mindmatrix-react] ${basename(id)}: ${w.message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (errors?.length) {
|
|
113
|
+
for (const e of errors) {
|
|
114
|
+
if (mode === "strict") {
|
|
115
|
+
this.error(`${basename(id)}: ${e.message}`);
|
|
116
|
+
} else {
|
|
117
|
+
this.warn(`${basename(id)}: ${e.message}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (ir) {
|
|
122
|
+
compiledFiles.set(id, ir);
|
|
123
|
+
const outputFileName = basename(id).replace(/\.tsx?$/, ".workflow.json");
|
|
124
|
+
const outputPath = join(process.cwd(), outDir, outputFileName);
|
|
125
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
126
|
+
writeFileSync(outputPath, JSON.stringify(ir, null, 2), "utf-8");
|
|
127
|
+
console.log(`[mindmatrix-react] Compiled ${basename(id)} \u2192 ${outputFileName}`);
|
|
128
|
+
seedToApi(ir, id);
|
|
129
|
+
}
|
|
130
|
+
if (!enableSourceAnnotations && ir) {
|
|
131
|
+
stripSourceAnnotations(ir);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
code: result.code,
|
|
135
|
+
map: wantMaps ? result.map : void 0
|
|
136
|
+
};
|
|
137
|
+
} catch (error) {
|
|
138
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
139
|
+
if (mode === "strict") {
|
|
140
|
+
this.error(`Failed to compile ${basename(id)}: ${msg}`);
|
|
141
|
+
} else {
|
|
142
|
+
console.error(`[mindmatrix-react] Error compiling ${basename(id)}:`, msg);
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
handleHotUpdate(ctx) {
|
|
148
|
+
if (!shouldTransform(ctx.file)) return;
|
|
149
|
+
console.log(`[mindmatrix-react] HMR: ${basename(ctx.file)} changed`);
|
|
150
|
+
return void 0;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function stripSourceAnnotations(ir) {
|
|
155
|
+
const strip = (obj) => {
|
|
156
|
+
if (!obj || typeof obj !== "object") return;
|
|
157
|
+
if (Array.isArray(obj)) {
|
|
158
|
+
for (const item of obj) strip(item);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const rec = obj;
|
|
162
|
+
delete rec.__source;
|
|
163
|
+
for (const val of Object.values(rec)) {
|
|
164
|
+
if (val && typeof val === "object") strip(val);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
strip(ir.fields);
|
|
168
|
+
strip(ir.states);
|
|
169
|
+
strip(ir.transitions);
|
|
170
|
+
strip(ir.experience);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
mindmatrixReact
|
|
175
|
+
};
|
package/dist/cli/index.js
CHANGED
|
@@ -1387,7 +1387,14 @@ function jsxToExperienceNode(node) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
} else if (t6.isIdentifier(expr)) {
|
|
1389
1389
|
const snakeName = localFieldMap.get(expr.name);
|
|
1390
|
-
|
|
1390
|
+
const setterField = setterToFieldMap.get(expr.name);
|
|
1391
|
+
if (snakeName) {
|
|
1392
|
+
bindings[attrName] = `$local.${snakeName}`;
|
|
1393
|
+
} else if (setterField) {
|
|
1394
|
+
bindings[attrName] = `$action.setLocal("${setterField}")`;
|
|
1395
|
+
} else {
|
|
1396
|
+
bindings[attrName] = `$instance.${expr.name}`;
|
|
1397
|
+
}
|
|
1391
1398
|
} else if (isEventHandlerProp(attrName) && (t6.isArrowFunctionExpression(expr) || t6.isFunctionExpression(expr))) {
|
|
1392
1399
|
const decomposed = decomposeHandlerToSeq(expr);
|
|
1393
1400
|
if (decomposed) {
|
|
@@ -7530,6 +7537,26 @@ function createVisitor(options = {}) {
|
|
|
7530
7537
|
const id = path.node.id;
|
|
7531
7538
|
const init2 = path.node.init;
|
|
7532
7539
|
if (t21.isArrayPattern(id)) return;
|
|
7540
|
+
if (t21.isObjectPattern(id) && init2 && t21.isCallExpression(init2) && t21.isIdentifier(init2.callee) && init2.callee.name === "useQuery") {
|
|
7541
|
+
const slug = resolveSlugArg(init2.arguments, state);
|
|
7542
|
+
if (slug) {
|
|
7543
|
+
for (const prop2 of id.properties) {
|
|
7544
|
+
if (t21.isObjectProperty(prop2) && t21.isIdentifier(prop2.key) && prop2.key.name === "data") {
|
|
7545
|
+
const alias = t21.isIdentifier(prop2.value) ? prop2.value.name : null;
|
|
7546
|
+
if (alias) {
|
|
7547
|
+
const meta = compilerState.metadata;
|
|
7548
|
+
const dataSources = meta.dataSources;
|
|
7549
|
+
if (dataSources) {
|
|
7550
|
+
const ds = dataSources.find((d) => d.name === slug);
|
|
7551
|
+
if (ds) ds.name = alias;
|
|
7552
|
+
}
|
|
7553
|
+
}
|
|
7554
|
+
break;
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
}
|
|
7558
|
+
return;
|
|
7559
|
+
}
|
|
7533
7560
|
if (!t21.isIdentifier(id) || !init2 || !t21.isExpression(init2)) return;
|
|
7534
7561
|
const parentFn = path.getFunctionParent();
|
|
7535
7562
|
if (!parentFn) return;
|
|
@@ -7557,10 +7584,7 @@ function createVisitor(options = {}) {
|
|
|
7557
7584
|
return;
|
|
7558
7585
|
}
|
|
7559
7586
|
if (callee === "useMutation") {
|
|
7560
|
-
registerDerivedVar(id.name, t21.
|
|
7561
|
-
t21.identifier("$action"),
|
|
7562
|
-
t21.identifier("transition")
|
|
7563
|
-
));
|
|
7587
|
+
registerDerivedVar(id.name, t21.identifier("$action"));
|
|
7564
7588
|
return;
|
|
7565
7589
|
}
|
|
7566
7590
|
if (callee === "useServerAction") {
|
|
@@ -13253,7 +13277,7 @@ function generatePageFileFromSection(page, modelSlugToPath) {
|
|
|
13253
13277
|
slug: page.slug,
|
|
13254
13278
|
name: page.componentName,
|
|
13255
13279
|
version: "1.0.0",
|
|
13256
|
-
category: ["
|
|
13280
|
+
category: ["view"],
|
|
13257
13281
|
states: [],
|
|
13258
13282
|
transitions: [],
|
|
13259
13283
|
fields,
|
|
@@ -14089,14 +14113,12 @@ async function deploy(options) {
|
|
|
14089
14113
|
}
|
|
14090
14114
|
async function fetchExistingDefinition(apiUrl, token, slug) {
|
|
14091
14115
|
try {
|
|
14092
|
-
const res = await fetch(`${apiUrl}/workflow/definitions
|
|
14116
|
+
const res = await fetch(`${apiUrl}/workflow/definitions/${encodeURIComponent(slug)}`, {
|
|
14093
14117
|
headers: { Authorization: `Bearer ${token}` }
|
|
14094
14118
|
});
|
|
14095
14119
|
if (!res.ok) return null;
|
|
14096
|
-
const
|
|
14097
|
-
|
|
14098
|
-
if (!definitions || definitions.length === 0) return null;
|
|
14099
|
-
const def = definitions[0];
|
|
14120
|
+
const def = await res.json();
|
|
14121
|
+
if (!def || !def.id) return null;
|
|
14100
14122
|
return {
|
|
14101
14123
|
id: def.id,
|
|
14102
14124
|
slug: def.slug,
|
|
@@ -14114,7 +14136,7 @@ async function createDefinition(apiUrl, token, ir) {
|
|
|
14114
14136
|
"Content-Type": "application/json",
|
|
14115
14137
|
Authorization: `Bearer ${token}`
|
|
14116
14138
|
},
|
|
14117
|
-
body: JSON.stringify(ir)
|
|
14139
|
+
body: JSON.stringify({ ...ir, visibility: "PUBLIC" })
|
|
14118
14140
|
});
|
|
14119
14141
|
if (!res.ok) {
|
|
14120
14142
|
const errorText = await res.text();
|
|
@@ -15567,7 +15589,13 @@ function App() {
|
|
|
15567
15589
|
try {
|
|
15568
15590
|
const res = await fetch(API_BASE + '/workflow/definitions');
|
|
15569
15591
|
const json = await res.json();
|
|
15570
|
-
const
|
|
15592
|
+
const rawItems = json.items || json.data || [];
|
|
15593
|
+
// Flatten: API returns { id, slug, definition: { experience, ... } }
|
|
15594
|
+
// Merge definition fields up to the top level for easier access
|
|
15595
|
+
const items = rawItems.map(d => {
|
|
15596
|
+
const def = d.definition || {};
|
|
15597
|
+
return { ...d, ...def, definition: undefined };
|
|
15598
|
+
});
|
|
15571
15599
|
// Find the main blueprint definition (has experience tree)
|
|
15572
15600
|
const main = items.find(d => d.experience && !(Array.isArray(d.category) ? d.category.includes('data') : d.category === 'data')) || items.find(d => d.experience) || items[0];
|
|
15573
15601
|
if (main?.experience) {
|
|
@@ -16213,7 +16241,7 @@ function generatePage(name) {
|
|
|
16213
16241
|
const title = toTitleCase(name);
|
|
16214
16242
|
const pascal = toPascalCase2(name);
|
|
16215
16243
|
return `/**
|
|
16216
|
-
* @workflow slug="${name}-home" version="1.0.0" category="
|
|
16244
|
+
* @workflow slug="${name}-home" version="1.0.0" category="view"
|
|
16217
16245
|
*
|
|
16218
16246
|
* Index page \u2014 full CRUD with create form, search, transitions, and delete.
|
|
16219
16247
|
*/
|
package/dist/cli/index.mjs
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
} from "../chunk-J3M4GUS7.mjs";
|
|
8
8
|
import {
|
|
9
9
|
deploy
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-XUQ5R6F3.mjs";
|
|
11
11
|
import {
|
|
12
12
|
build
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-RTAUTGHB.mjs";
|
|
14
14
|
import "../chunk-5M7DKKBC.mjs";
|
|
15
|
-
import "../chunk-
|
|
15
|
+
import "../chunk-NJNAQF5I.mjs";
|
|
16
16
|
import {
|
|
17
17
|
__require
|
|
18
18
|
} from "../chunk-CIESM3BP.mjs";
|
|
@@ -45,8 +45,8 @@ async function test(options = {}) {
|
|
|
45
45
|
const rel = f.startsWith(srcDir + "/") ? f.slice(srcDir.length + 1) : f;
|
|
46
46
|
fileMap[rel] = readFileSync(f, "utf-8");
|
|
47
47
|
}
|
|
48
|
-
const { compileProject } = await import("../project-compiler-
|
|
49
|
-
const { decompileProjectEnhanced } = await import("../project-decompiler-
|
|
48
|
+
const { compileProject } = await import("../project-compiler-HNDWIX4J.mjs");
|
|
49
|
+
const { decompileProjectEnhanced } = await import("../project-decompiler-QCZYY4TW.mjs");
|
|
50
50
|
process.stdout.write(` Compiling project...`);
|
|
51
51
|
const t0 = performance.now();
|
|
52
52
|
let ir1;
|
|
@@ -548,7 +548,7 @@ async function main() {
|
|
|
548
548
|
const { glob: glob2 } = await import("glob");
|
|
549
549
|
const configPath = resolve2(srcDir, "mm.config.ts");
|
|
550
550
|
if (existsSync2(configPath)) {
|
|
551
|
-
const { compileProject } = await import("../project-compiler-
|
|
551
|
+
const { compileProject } = await import("../project-compiler-HNDWIX4J.mjs");
|
|
552
552
|
const allFiles = await glob2(`${srcDir}/**/*.{ts,tsx}`, {
|
|
553
553
|
ignore: ["**/node_modules/**", "**/dist/**", "**/__tests__/**", "**/*.test.*"]
|
|
554
554
|
});
|
|
@@ -611,7 +611,7 @@ async function main() {
|
|
|
611
611
|
console.error('[mmrc] Error: name is required\n Usage: mmrc init <name> [--description "..."] [--icon "..."] [--author "..."]');
|
|
612
612
|
process.exit(1);
|
|
613
613
|
}
|
|
614
|
-
const { init } = await import("../init-
|
|
614
|
+
const { init } = await import("../init-AVZJHZYY.mjs");
|
|
615
615
|
await init({
|
|
616
616
|
name,
|
|
617
617
|
description: getFlag("--description"),
|
|
@@ -624,7 +624,7 @@ async function main() {
|
|
|
624
624
|
console.error("[mmrc] Error: target path is required\n Usage: mmrc verify <file-or-dir> [options]");
|
|
625
625
|
process.exit(1);
|
|
626
626
|
}
|
|
627
|
-
const { verifyCommand } = await import("../verify-
|
|
627
|
+
const { verifyCommand } = await import("../verify-LZXUHOX6.mjs");
|
|
628
628
|
const result = await verifyCommand({
|
|
629
629
|
target,
|
|
630
630
|
static: hasFlag("--static"),
|
|
@@ -651,7 +651,7 @@ async function main() {
|
|
|
651
651
|
console.error(" 3. Set MMRC_TOKEN environment variable");
|
|
652
652
|
process.exit(1);
|
|
653
653
|
}
|
|
654
|
-
const { pull } = await import("../pull-
|
|
654
|
+
const { pull } = await import("../pull-5WJ4LW4U.mjs");
|
|
655
655
|
await pull({ slug, apiUrl, token, outDir });
|
|
656
656
|
} else if (command === "seed") {
|
|
657
657
|
const apiUrl = getFlag("--api-url") ?? "http://localhost:4200/api/v1";
|
package/dist/dev-server.js
CHANGED
|
@@ -1386,7 +1386,14 @@ function jsxToExperienceNode(node) {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
} else if (t6.isIdentifier(expr)) {
|
|
1388
1388
|
const snakeName = localFieldMap.get(expr.name);
|
|
1389
|
-
|
|
1389
|
+
const setterField = setterToFieldMap.get(expr.name);
|
|
1390
|
+
if (snakeName) {
|
|
1391
|
+
bindings[attrName] = `$local.${snakeName}`;
|
|
1392
|
+
} else if (setterField) {
|
|
1393
|
+
bindings[attrName] = `$action.setLocal("${setterField}")`;
|
|
1394
|
+
} else {
|
|
1395
|
+
bindings[attrName] = `$instance.${expr.name}`;
|
|
1396
|
+
}
|
|
1390
1397
|
} else if (isEventHandlerProp(attrName) && (t6.isArrowFunctionExpression(expr) || t6.isFunctionExpression(expr))) {
|
|
1391
1398
|
const decomposed = decomposeHandlerToSeq(expr);
|
|
1392
1399
|
if (decomposed) {
|
|
@@ -7529,6 +7536,26 @@ function createVisitor(options = {}) {
|
|
|
7529
7536
|
const id = path.node.id;
|
|
7530
7537
|
const init = path.node.init;
|
|
7531
7538
|
if (t21.isArrayPattern(id)) return;
|
|
7539
|
+
if (t21.isObjectPattern(id) && init && t21.isCallExpression(init) && t21.isIdentifier(init.callee) && init.callee.name === "useQuery") {
|
|
7540
|
+
const slug = resolveSlugArg(init.arguments, state);
|
|
7541
|
+
if (slug) {
|
|
7542
|
+
for (const prop of id.properties) {
|
|
7543
|
+
if (t21.isObjectProperty(prop) && t21.isIdentifier(prop.key) && prop.key.name === "data") {
|
|
7544
|
+
const alias = t21.isIdentifier(prop.value) ? prop.value.name : null;
|
|
7545
|
+
if (alias) {
|
|
7546
|
+
const meta = compilerState.metadata;
|
|
7547
|
+
const dataSources = meta.dataSources;
|
|
7548
|
+
if (dataSources) {
|
|
7549
|
+
const ds = dataSources.find((d) => d.name === slug);
|
|
7550
|
+
if (ds) ds.name = alias;
|
|
7551
|
+
}
|
|
7552
|
+
}
|
|
7553
|
+
break;
|
|
7554
|
+
}
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
return;
|
|
7558
|
+
}
|
|
7532
7559
|
if (!t21.isIdentifier(id) || !init || !t21.isExpression(init)) return;
|
|
7533
7560
|
const parentFn = path.getFunctionParent();
|
|
7534
7561
|
if (!parentFn) return;
|
|
@@ -7556,10 +7583,7 @@ function createVisitor(options = {}) {
|
|
|
7556
7583
|
return;
|
|
7557
7584
|
}
|
|
7558
7585
|
if (callee === "useMutation") {
|
|
7559
|
-
registerDerivedVar(id.name, t21.
|
|
7560
|
-
t21.identifier("$action"),
|
|
7561
|
-
t21.identifier("transition")
|
|
7562
|
-
));
|
|
7586
|
+
registerDerivedVar(id.name, t21.identifier("$action"));
|
|
7563
7587
|
return;
|
|
7564
7588
|
}
|
|
7565
7589
|
if (callee === "useServerAction") {
|
|
@@ -10849,14 +10873,12 @@ async function deploy(options) {
|
|
|
10849
10873
|
}
|
|
10850
10874
|
async function fetchExistingDefinition(apiUrl, token, slug) {
|
|
10851
10875
|
try {
|
|
10852
|
-
const res = await fetch(`${apiUrl}/workflow/definitions
|
|
10876
|
+
const res = await fetch(`${apiUrl}/workflow/definitions/${encodeURIComponent(slug)}`, {
|
|
10853
10877
|
headers: { Authorization: `Bearer ${token}` }
|
|
10854
10878
|
});
|
|
10855
10879
|
if (!res.ok) return null;
|
|
10856
|
-
const
|
|
10857
|
-
|
|
10858
|
-
if (!definitions || definitions.length === 0) return null;
|
|
10859
|
-
const def = definitions[0];
|
|
10880
|
+
const def = await res.json();
|
|
10881
|
+
if (!def || !def.id) return null;
|
|
10860
10882
|
return {
|
|
10861
10883
|
id: def.id,
|
|
10862
10884
|
slug: def.slug,
|
|
@@ -10874,7 +10896,7 @@ async function createDefinition(apiUrl, token, ir) {
|
|
|
10874
10896
|
"Content-Type": "application/json",
|
|
10875
10897
|
Authorization: `Bearer ${token}`
|
|
10876
10898
|
},
|
|
10877
|
-
body: JSON.stringify(ir)
|
|
10899
|
+
body: JSON.stringify({ ...ir, visibility: "PUBLIC" })
|
|
10878
10900
|
});
|
|
10879
10901
|
if (!res.ok) {
|
|
10880
10902
|
const errorText = await res.text();
|
|
@@ -12071,7 +12093,13 @@ function App() {
|
|
|
12071
12093
|
try {
|
|
12072
12094
|
const res = await fetch(API_BASE + '/workflow/definitions');
|
|
12073
12095
|
const json = await res.json();
|
|
12074
|
-
const
|
|
12096
|
+
const rawItems = json.items || json.data || [];
|
|
12097
|
+
// Flatten: API returns { id, slug, definition: { experience, ... } }
|
|
12098
|
+
// Merge definition fields up to the top level for easier access
|
|
12099
|
+
const items = rawItems.map(d => {
|
|
12100
|
+
const def = d.definition || {};
|
|
12101
|
+
return { ...d, ...def, definition: undefined };
|
|
12102
|
+
});
|
|
12075
12103
|
// Find the main blueprint definition (has experience tree)
|
|
12076
12104
|
const main = items.find(d => d.experience && !(Array.isArray(d.category) ? d.category.includes('data') : d.category === 'data')) || items.find(d => d.experience) || items[0];
|
|
12077
12105
|
if (main?.experience) {
|
package/dist/dev-server.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDevServer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-TRR2NPAV.mjs";
|
|
3
|
+
} from "./chunk-5PM7CGFQ.mjs";
|
|
4
|
+
import "./chunk-RTAUTGHB.mjs";
|
|
6
5
|
import "./chunk-5M7DKKBC.mjs";
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-YOVAADAD.mjs";
|
|
7
|
+
import "./chunk-NJNAQF5I.mjs";
|
|
8
8
|
import "./chunk-CIESM3BP.mjs";
|
|
9
9
|
export {
|
|
10
10
|
createDevServer
|