@diagonal-hq/cli 0.34.0 → 0.35.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/dist/cli.mjs +74 -6
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -302380,7 +302380,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302380
302380
|
);
|
|
302381
302381
|
const locals = new Set([...valuesBySpecifier.keys()].map((specifier) => specifier.local.name));
|
|
302382
302382
|
if (locals.size === 0) {
|
|
302383
|
-
return { source, edits: [], problems: [], otherUses: [] };
|
|
302383
|
+
return { source, edits: [], problems: [], otherUses: [], reads: [] };
|
|
302384
302384
|
}
|
|
302385
302385
|
const parents = /* @__PURE__ */ new Map();
|
|
302386
302386
|
const pending = [ast.program];
|
|
@@ -302407,6 +302407,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302407
302407
|
const replacements = [];
|
|
302408
302408
|
const problems = [];
|
|
302409
302409
|
const otherUses = [];
|
|
302410
|
+
const reads = [];
|
|
302410
302411
|
const usedImports = /* @__PURE__ */ new Set();
|
|
302411
302412
|
const widenedBindings = /* @__PURE__ */ new Map();
|
|
302412
302413
|
const widenedDeclarations = [];
|
|
@@ -302419,6 +302420,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302419
302420
|
let node = identifier4;
|
|
302420
302421
|
let value = values.entries;
|
|
302421
302422
|
let path = identifier4.name;
|
|
302423
|
+
const names2 = [];
|
|
302422
302424
|
let problem2 = null;
|
|
302423
302425
|
let depth = 0;
|
|
302424
302426
|
for (let next = parents.get(node); memberName(next, node) !== null; next = parents.get(node)) {
|
|
@@ -302432,6 +302434,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302432
302434
|
}
|
|
302433
302435
|
value = value[key];
|
|
302434
302436
|
path = `${path}.${key}`;
|
|
302437
|
+
names2.push(key);
|
|
302435
302438
|
node = next;
|
|
302436
302439
|
depth += 1;
|
|
302437
302440
|
}
|
|
@@ -302455,6 +302458,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302455
302458
|
});
|
|
302456
302459
|
usedImports.add(values);
|
|
302457
302460
|
} else if (mode === "call" && value instanceof TypedValue) {
|
|
302461
|
+
reads.push({ values, names: names2 });
|
|
302458
302462
|
let binding = widenedBindings.get(path);
|
|
302459
302463
|
if (binding === void 0) {
|
|
302460
302464
|
binding = programScope.generateUid(path);
|
|
@@ -302467,6 +302471,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302467
302471
|
text: keepingLayout(source.slice(node.start, node.end), binding)
|
|
302468
302472
|
});
|
|
302469
302473
|
} else {
|
|
302474
|
+
reads.push({ values, names: names2 });
|
|
302470
302475
|
replacements.push({
|
|
302471
302476
|
start: node.start,
|
|
302472
302477
|
end: node.end,
|
|
@@ -302497,7 +302502,7 @@ function inlineGeneratedValues(source, ast, generatedModuleOf, { typescript: typ
|
|
|
302497
302502
|
for (const { start, end, text: text2 } of edits.toReversed()) {
|
|
302498
302503
|
result = `${result.slice(0, start)}${text2}${result.slice(end)}`;
|
|
302499
302504
|
}
|
|
302500
|
-
return { source: result, edits, problems, otherUses };
|
|
302505
|
+
return { source: result, edits, problems, otherUses, reads };
|
|
302501
302506
|
}
|
|
302502
302507
|
function unknownNameMessage(values, path, key, depth) {
|
|
302503
302508
|
return values.unknownName?.(path, key, depth) ?? (depth === 0 ? `Unknown ${values.noun} "${path}.${key}". Each name in ${path} is a file in ${values.directory}` : `${path} has no "${key}"`);
|
|
@@ -314698,6 +314703,61 @@ function runCompiler(input, args = [], { timeout } = {}) {
|
|
|
314698
314703
|
return JSON.parse(run.stdout);
|
|
314699
314704
|
}
|
|
314700
314705
|
|
|
314706
|
+
// scripts/lib/runtime-build/workflow-entity-references.mjs
|
|
314707
|
+
init_define_globalThis_DIAGONAL_SDK_RUNTIME();
|
|
314708
|
+
var ENTITIES = {
|
|
314709
|
+
[RESOURCES_EXPORT]: (exportName, [name, part, key], entry) => {
|
|
314710
|
+
const resource = { type: "resource", path: `${exportName}.${name}`, key: entry.slug };
|
|
314711
|
+
if (key === void 0) {
|
|
314712
|
+
return [resource];
|
|
314713
|
+
}
|
|
314714
|
+
const path = `${resource.path}.${part}.${key}`;
|
|
314715
|
+
if (part === "fields") {
|
|
314716
|
+
return [resource, { type: "field", path, key, resource: entry.slug }];
|
|
314717
|
+
}
|
|
314718
|
+
const record = part === "records" ? entry.records?.[key] : void 0;
|
|
314719
|
+
return typeof record?.uid === "string" ? [resource, { type: "record", path, key: record.uid, resource: entry.slug }] : [resource];
|
|
314720
|
+
},
|
|
314721
|
+
[WORKFLOWS_EXPORT]: uidEntity("workflow"),
|
|
314722
|
+
[NOTIFICATION_TYPES_EXPORT]: (exportName, [name, part, template], entry) => {
|
|
314723
|
+
const type = uidEntity("notification_type")(exportName, [name], entry);
|
|
314724
|
+
const uid2 = part === "templates" && template !== void 0 ? entry.templates?.[template]?.uid : void 0;
|
|
314725
|
+
return typeof uid2 === "string" ? [...type, { type: "notification_template", path: `${exportName}.${name}.${part}.${template}`, key: uid2 }] : type;
|
|
314726
|
+
},
|
|
314727
|
+
[EMAIL_LAYOUTS_EXPORT]: uidEntity("email_layout"),
|
|
314728
|
+
[WORKSPACE_FIELDS_EXPORT]: keyEntity("workspace_field"),
|
|
314729
|
+
[ROLES_EXPORT]: uidEntity("role"),
|
|
314730
|
+
[PERMISSIONS_EXPORT]: uidEntity("permission"),
|
|
314731
|
+
[DOMAINS_EXPORT]: keyEntity("domain"),
|
|
314732
|
+
[SKILLS_EXPORT]: uidEntity("skill")
|
|
314733
|
+
};
|
|
314734
|
+
function uidEntity(type) {
|
|
314735
|
+
return (exportName, [name], entry) => typeof entry.uid === "string" ? [{ type, path: `${exportName}.${name}`, key: entry.uid }] : [];
|
|
314736
|
+
}
|
|
314737
|
+
function keyEntity(type) {
|
|
314738
|
+
return (exportName, [name], entry) => typeof entry.key === "string" ? [{ type, path: `${exportName}.${name}`, key: entry.key }] : [];
|
|
314739
|
+
}
|
|
314740
|
+
function workflowEntityReferences(reads) {
|
|
314741
|
+
const references = /* @__PURE__ */ new Map();
|
|
314742
|
+
for (const { values, names: names2 } of reads) {
|
|
314743
|
+
const entities2 = ENTITIES[values.exportName];
|
|
314744
|
+
const entry = names2.length === 0 ? void 0 : values.entries[names2[0]];
|
|
314745
|
+
if (entities2 === void 0 || entry === null || typeof entry !== "object") {
|
|
314746
|
+
continue;
|
|
314747
|
+
}
|
|
314748
|
+
for (const reference of entities2(values.exportName, names2, entry)) {
|
|
314749
|
+
const identity = `${reference.type}\0${reference.resource ?? ""}\0${reference.key}`;
|
|
314750
|
+
const known = references.get(identity);
|
|
314751
|
+
if (known === void 0 || reference.path < known.path) {
|
|
314752
|
+
references.set(identity, reference);
|
|
314753
|
+
}
|
|
314754
|
+
}
|
|
314755
|
+
}
|
|
314756
|
+
return [...references.values()].toSorted(
|
|
314757
|
+
(left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : left.type < right.type ? -1 : 1
|
|
314758
|
+
);
|
|
314759
|
+
}
|
|
314760
|
+
|
|
314701
314761
|
// scripts/lib/runtime-build/workflows.mjs
|
|
314702
314762
|
function compileScripts(entries) {
|
|
314703
314763
|
const requests = entries.map(({ script, workspaceDeclarations, app, options = {} }) => ({
|
|
@@ -314766,7 +314826,7 @@ function generatedInliner(root, generated) {
|
|
|
314766
314826
|
ast = parseSource(source, { jsx: false });
|
|
314767
314827
|
} catch (error) {
|
|
314768
314828
|
if (error instanceof SyntaxError) {
|
|
314769
|
-
return { source, edits: [], problems: [], otherUses: [] };
|
|
314829
|
+
return { source, edits: [], problems: [], otherUses: [], reads: [] };
|
|
314770
314830
|
}
|
|
314771
314831
|
throw error;
|
|
314772
314832
|
}
|
|
@@ -314870,7 +314930,7 @@ function buildWorkflows({
|
|
|
314870
314930
|
recordBindingEntries,
|
|
314871
314931
|
reportUnknownResources: resourcesComplete
|
|
314872
314932
|
};
|
|
314873
|
-
const
|
|
314933
|
+
const inlineGenerated = generatedInliner(
|
|
314874
314934
|
root,
|
|
314875
314935
|
new Map([
|
|
314876
314936
|
[GENERATED_RECORD_BINDINGS_PATH, recordBindingValues(recordBindingEntries)],
|
|
@@ -314886,6 +314946,12 @@ function buildWorkflows({
|
|
|
314886
314946
|
...domainEntries2 === null ? [] : [[GENERATED_DOMAINS_PATH, domainValues(domainEntries2)]]
|
|
314887
314947
|
])
|
|
314888
314948
|
);
|
|
314949
|
+
const readsByPath = /* @__PURE__ */ new Map();
|
|
314950
|
+
const inline = (path, source) => {
|
|
314951
|
+
const inlined = inlineGenerated(path, source);
|
|
314952
|
+
readsByPath.set(path, inlined.reads);
|
|
314953
|
+
return inlined;
|
|
314954
|
+
};
|
|
314889
314955
|
const testModules = /* @__PURE__ */ new Map();
|
|
314890
314956
|
const assetReaders = /* @__PURE__ */ new Set();
|
|
314891
314957
|
const notificationReaders = /* @__PURE__ */ new Set();
|
|
@@ -314945,6 +315011,7 @@ function buildWorkflows({
|
|
|
314945
315011
|
return {
|
|
314946
315012
|
own,
|
|
314947
315013
|
compile: compiles ? { path, writtenSource: split.scriptSource, script, workspaceDeclarations, app } : null,
|
|
315014
|
+
references: workflowEntityReferences([path, ...app.modules.keys()].flatMap((modulePath) => readsByPath.get(modulePath) ?? [])),
|
|
314948
315015
|
entry: {
|
|
314949
315016
|
path,
|
|
314950
315017
|
uid: uidsByPath.get(path) ?? null,
|
|
@@ -314965,7 +315032,7 @@ function buildWorkflows({
|
|
|
314965
315032
|
const compiledByIndex = new Map(
|
|
314966
315033
|
compileScripts(toCompile.map((index3) => prepared[index3].compile)).map((compiled, position) => [toCompile[position], compiled])
|
|
314967
315034
|
);
|
|
314968
|
-
const built = prepared.map(({ own, entry }, index3) => {
|
|
315035
|
+
const built = prepared.map(({ own, references, entry }, index3) => {
|
|
314969
315036
|
const compiled = compiledByIndex.get(index3) ?? { compiled: null, diagnostics: [] };
|
|
314970
315037
|
diagnostics.push(...own, ...compiled.diagnostics);
|
|
314971
315038
|
return {
|
|
@@ -314973,7 +315040,8 @@ function buildWorkflows({
|
|
|
314973
315040
|
compiled: compiled.compiled?.code ?? null,
|
|
314974
315041
|
input: compiled.compiled?.input ?? null,
|
|
314975
315042
|
output: compiled.compiled?.output ?? null,
|
|
314976
|
-
script_workspace: compiled.compiled === null ? null : { resources: {} }
|
|
315043
|
+
script_workspace: compiled.compiled === null ? null : { resources: {} },
|
|
315044
|
+
references: compiled.compiled === null ? null : references
|
|
314977
315045
|
};
|
|
314978
315046
|
});
|
|
314979
315047
|
reportDuplicateLifecycleHooks(built, diagnostics);
|