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