@diagonal-hq/cli 0.42.11 → 0.42.12
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/README.md +2 -2
- package/dist/check-data.json +1 -1
- package/dist/{cli-check-data-NOJMQBO5.mjs → cli-check-data-EAKFHVPZ.mjs} +6 -6
- package/dist/{cli-chunk-L5DINKQM.mjs → cli-chunk-SD7APJJ6.mjs} +2 -0
- package/dist/{cli-chunk-6VD2BES2.mjs → cli-chunk-YSDTJ57P.mjs} +2 -2
- package/dist/{cli-sdk-files.generated-ZKHJVYQH.mjs → cli-sdk-files.generated-KZHKLP6A.mjs} +1 -1
- package/dist/{cli-workflows-EFTLEHKL.mjs → cli-workflows-DUSY244F.mjs} +1 -1
- package/dist/cli.mjs +110 -52
- package/dist/index.d.ts +19 -1
- package/dist/script-sdk.json +1 -1
- package/dist/workflow/generated/capabilities.d.ts +1 -1
- package/package.json +4 -4
|
@@ -9,7 +9,7 @@ import type { ContentDocument } from '../input';
|
|
|
9
9
|
import type { DeepReadonly, Liquid, StaticLiquid } from '../liquid';
|
|
10
10
|
import { invoke } from '../transport';
|
|
11
11
|
|
|
12
|
-
export const SDK_VERSION =
|
|
12
|
+
export const SDK_VERSION = 83;
|
|
13
13
|
|
|
14
14
|
export interface WorkspaceSystemFields {
|
|
15
15
|
"ai_custom_system_prompt": string | null;
|
package/dist/cli.mjs
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
GENERATED_PAGES_MODULE,
|
|
17
17
|
GENERATED_PERMISSIONS_MODULE,
|
|
18
18
|
GENERATED_RECORD_BINDINGS_MODULE,
|
|
19
|
+
PERMISSIONS_EXPORT,
|
|
20
|
+
SYSTEM_PERMISSIONS_EXPORT,
|
|
19
21
|
brand_kit_catalog_default,
|
|
20
22
|
buildField,
|
|
21
23
|
buildPermission,
|
|
@@ -42,7 +44,7 @@ import {
|
|
|
42
44
|
readWorkspaceSettings,
|
|
43
45
|
routeParamNames,
|
|
44
46
|
workspace_settings_catalog_default
|
|
45
|
-
} from "./cli-chunk-
|
|
47
|
+
} from "./cli-chunk-SD7APJJ6.mjs";
|
|
46
48
|
import {
|
|
47
49
|
compareVersions,
|
|
48
50
|
isVersion,
|
|
@@ -3868,6 +3870,15 @@ function branchResources(context) {
|
|
|
3868
3870
|
}
|
|
3869
3871
|
return paths.map((path) => Object.hasOwn(slugs, path) ? { path, slug: slugs[path] } : path);
|
|
3870
3872
|
}
|
|
3873
|
+
function branchPermissions(context) {
|
|
3874
|
+
const permissions = context.permissions ?? [];
|
|
3875
|
+
if (!Array.isArray(permissions) || permissions.some(
|
|
3876
|
+
(permission) => !isPlainObject(permission) || typeof permission.path !== "string" || !(typeof permission.uid === "string" || permission.uid === null)
|
|
3877
|
+
)) {
|
|
3878
|
+
throw new SourceTransformRequestError("permissions must be an array of { path, uid } objects.");
|
|
3879
|
+
}
|
|
3880
|
+
return permissions.map(({ path, uid }) => ({ path, uid }));
|
|
3881
|
+
}
|
|
3871
3882
|
|
|
3872
3883
|
// scripts/lib/runtime-build/source-adapters/asset-reference.mjs
|
|
3873
3884
|
var assetReferenceAdapter = Object.freeze({
|
|
@@ -7601,15 +7612,6 @@ ${closing}}`;
|
|
|
7601
7612
|
}
|
|
7602
7613
|
|
|
7603
7614
|
// scripts/lib/runtime-build/source-adapters/page.mjs
|
|
7604
|
-
function branchPermissions(context) {
|
|
7605
|
-
const permissions = context.permissions ?? [];
|
|
7606
|
-
if (!Array.isArray(permissions) || permissions.some(
|
|
7607
|
-
(permission) => !isPlainObject(permission) || typeof permission.path !== "string" || !(typeof permission.uid === "string" || permission.uid === null)
|
|
7608
|
-
)) {
|
|
7609
|
-
throw new SourceTransformRequestError("permissions must be an array of { path, uid } objects.");
|
|
7610
|
-
}
|
|
7611
|
-
return permissions.map(({ path, uid }) => ({ path, uid }));
|
|
7612
|
-
}
|
|
7613
7615
|
function contextOf(context) {
|
|
7614
7616
|
if (context.previous_path !== void 0 && context.previous_path !== null && typeof context.previous_path !== "string") {
|
|
7615
7617
|
throw new SourceTransformRequestError("previous_path must be a string or null.");
|
|
@@ -9459,16 +9461,30 @@ function relationsOf(value) {
|
|
|
9459
9461
|
}
|
|
9460
9462
|
return value.length === 0 ? {} : { relations: value };
|
|
9461
9463
|
}
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9464
|
+
var REFERENCE_MODULES = [
|
|
9465
|
+
["resources", RESOURCES_EXPORT, GENERATED_RESOURCES_MODULE],
|
|
9466
|
+
["workflows", WORKFLOWS_EXPORT, GENERATED_WORKFLOWS_MODULE],
|
|
9467
|
+
["domains", DOMAINS_EXPORT, GENERATED_DOMAINS_MODULE],
|
|
9468
|
+
["permissions", PERMISSIONS_EXPORT, GENERATED_PERMISSIONS_MODULE],
|
|
9469
|
+
["systemPermissions", SYSTEM_PERMISSIONS_EXPORT, AUTHORING_MODULE]
|
|
9470
|
+
];
|
|
9471
|
+
function referenceWriter(ast, resources, permissions) {
|
|
9472
|
+
const locals = Object.fromEntries(
|
|
9473
|
+
REFERENCE_MODULES.map(([key, name, module]) => [key, generatedBindingLocal(ast, module, name)])
|
|
9474
|
+
);
|
|
9475
|
+
const imports = /* @__PURE__ */ new Map();
|
|
9469
9476
|
const resourceNames = branchResourceNames(resources).namesBySlug;
|
|
9477
|
+
const permissionEntries = declaredPermissionEntries(permissions);
|
|
9478
|
+
const localOf = (key, exportName) => {
|
|
9479
|
+
if (locals[key] !== null) {
|
|
9480
|
+
return locals[key];
|
|
9481
|
+
}
|
|
9482
|
+
if (!imports.has(key)) {
|
|
9483
|
+
imports.set(key, freeName(exportName, ast));
|
|
9484
|
+
}
|
|
9485
|
+
return imports.get(key);
|
|
9486
|
+
};
|
|
9470
9487
|
return {
|
|
9471
|
-
locals,
|
|
9472
9488
|
imports,
|
|
9473
9489
|
resource(value) {
|
|
9474
9490
|
if (!isPlainObject(value) || typeof value.slug !== "string" || value.slug === "") {
|
|
@@ -9478,8 +9494,7 @@ function referenceWriter(ast, resources) {
|
|
|
9478
9494
|
if (name === null) {
|
|
9479
9495
|
return value.slug;
|
|
9480
9496
|
}
|
|
9481
|
-
|
|
9482
|
-
return new SourceExpression(`${locals.resources ?? RESOURCES_EXPORT}.${name}.slug`);
|
|
9497
|
+
return new SourceExpression(`${localOf("resources", RESOURCES_EXPORT)}.${name}.slug`);
|
|
9483
9498
|
},
|
|
9484
9499
|
workflow(value) {
|
|
9485
9500
|
if (!isPlainObject(value) || typeof value.uid !== "string" || value.uid === "" || typeof value.path !== "string" || !isWorkflowConfigPath(value.path)) {
|
|
@@ -9494,12 +9509,19 @@ function referenceWriter(ast, resources) {
|
|
|
9494
9509
|
if (name === null) {
|
|
9495
9510
|
return value.uid;
|
|
9496
9511
|
}
|
|
9497
|
-
|
|
9498
|
-
return new SourceExpression(`${locals.workflows ?? WORKFLOWS_EXPORT}.${name}.uid`);
|
|
9512
|
+
return new SourceExpression(`${localOf("workflows", WORKFLOWS_EXPORT)}.${name}.uid`);
|
|
9499
9513
|
},
|
|
9500
9514
|
domain(key) {
|
|
9501
|
-
|
|
9502
|
-
|
|
9515
|
+
return new SourceExpression(`${localOf("domains", DOMAINS_EXPORT)}.${studlyName(key)}.key`);
|
|
9516
|
+
},
|
|
9517
|
+
// A uid of no known permission stays a string, and the build reports it.
|
|
9518
|
+
permission(uid) {
|
|
9519
|
+
const reference = permissionUidReference(uid, permissionEntries);
|
|
9520
|
+
if (reference === null) {
|
|
9521
|
+
return uid;
|
|
9522
|
+
}
|
|
9523
|
+
const key = reference.exportName === PERMISSIONS_EXPORT ? "permissions" : "systemPermissions";
|
|
9524
|
+
return new SourceExpression(`${localOf(key, reference.exportName)}.${reference.name}.uid`);
|
|
9503
9525
|
}
|
|
9504
9526
|
};
|
|
9505
9527
|
}
|
|
@@ -9587,6 +9609,26 @@ function runAsOf(runAs, references2) {
|
|
|
9587
9609
|
}
|
|
9588
9610
|
return { resource: references2.resource(runAs.resource), record: runAs.record };
|
|
9589
9611
|
}
|
|
9612
|
+
function authorizerOf(authorizer, references2) {
|
|
9613
|
+
if (authorizer === null || authorizer === "authenticated") {
|
|
9614
|
+
return authorizer;
|
|
9615
|
+
}
|
|
9616
|
+
const message = `"authorizer" must be 'authenticated', { resource, permissions }, or null. "permissions" is a list of permission uids.`;
|
|
9617
|
+
if (!isPlainObject(authorizer) || Object.keys(authorizer).some((key) => key !== "resource" && key !== "permissions")) {
|
|
9618
|
+
throw new SourceError(message);
|
|
9619
|
+
}
|
|
9620
|
+
const permissions = authorizer.permissions ?? [];
|
|
9621
|
+
if (!Array.isArray(permissions) || permissions.some((uid) => typeof uid !== "string" || uid === "")) {
|
|
9622
|
+
throw new SourceError(message);
|
|
9623
|
+
}
|
|
9624
|
+
if (authorizer.resource === void 0 && permissions.length === 0) {
|
|
9625
|
+
return "authenticated";
|
|
9626
|
+
}
|
|
9627
|
+
return {
|
|
9628
|
+
...authorizer.resource === void 0 ? {} : { resource: references2.resource(authorizer.resource) },
|
|
9629
|
+
...permissions.length === 0 ? {} : { permissions: permissions.map((uid) => references2.permission(uid)) }
|
|
9630
|
+
};
|
|
9631
|
+
}
|
|
9590
9632
|
function optionsOf2(changes, properties, references2) {
|
|
9591
9633
|
const options = {};
|
|
9592
9634
|
if (changes.name !== void 0) {
|
|
@@ -9611,10 +9653,7 @@ function optionsOf2(changes, properties, references2) {
|
|
|
9611
9653
|
options.runAs = runAsOf(changes.run_as, references2);
|
|
9612
9654
|
}
|
|
9613
9655
|
if (changes.authorizer !== void 0) {
|
|
9614
|
-
|
|
9615
|
-
throw new SourceError(`"authorizer" must be 'authenticated' or null.`);
|
|
9616
|
-
}
|
|
9617
|
-
options.authorizer = changes.authorizer;
|
|
9656
|
+
options.authorizer = authorizerOf(changes.authorizer, references2);
|
|
9618
9657
|
}
|
|
9619
9658
|
if (changes.execution_mode !== void 0) {
|
|
9620
9659
|
if (changes.execution_mode !== null && !EXECUTION_MODES.includes(changes.execution_mode)) {
|
|
@@ -9658,27 +9697,34 @@ function routeEdits(source, properties, changes) {
|
|
|
9658
9697
|
0
|
|
9659
9698
|
);
|
|
9660
9699
|
}
|
|
9661
|
-
function importEdits2(ast, { imports
|
|
9662
|
-
const modules = [
|
|
9663
|
-
["resources", RESOURCES_EXPORT, GENERATED_RESOURCES_MODULE],
|
|
9664
|
-
["workflows", WORKFLOWS_EXPORT, GENERATED_WORKFLOWS_MODULE],
|
|
9665
|
-
["domains", DOMAINS_EXPORT, GENERATED_DOMAINS_MODULE]
|
|
9666
|
-
];
|
|
9667
|
-
const lines = modules.filter(([key]) => imports.has(key) && locals[key] === null).map(([, name, module]) => `import { ${name} } from '${module}';`);
|
|
9668
|
-
if (lines.length === 0) {
|
|
9669
|
-
return [];
|
|
9670
|
-
}
|
|
9700
|
+
function importEdits2(ast, { imports }) {
|
|
9671
9701
|
const declarations = ast.program.body.filter(
|
|
9672
9702
|
(statement) => statement.type === "ImportDeclaration"
|
|
9673
9703
|
);
|
|
9674
|
-
const
|
|
9675
|
-
|
|
9676
|
-
|
|
9704
|
+
const edits = [];
|
|
9705
|
+
const lines = [];
|
|
9706
|
+
for (const [key, name, module] of REFERENCE_MODULES) {
|
|
9707
|
+
if (!imports.has(key)) {
|
|
9708
|
+
continue;
|
|
9709
|
+
}
|
|
9710
|
+
const local = imports.get(key);
|
|
9711
|
+
const specifier = local === name ? name : `${name} as ${local}`;
|
|
9712
|
+
const named = declarations.filter((statement) => statement.source.value === module && statement.importKind !== "type").flatMap((statement) => statement.specifiers).findLast((specifier2) => specifier2.type === "ImportSpecifier");
|
|
9713
|
+
if (named === void 0) {
|
|
9714
|
+
lines.push(`import { ${specifier} } from '${module}';`);
|
|
9715
|
+
} else {
|
|
9716
|
+
edits.push({ start: named.end, end: named.end, text: `, ${specifier}` });
|
|
9717
|
+
}
|
|
9718
|
+
}
|
|
9719
|
+
if (lines.length > 0) {
|
|
9720
|
+
const at = declarations.at(-1)?.end ?? 0;
|
|
9721
|
+
edits.push({ start: at, end: at, text: at === 0 ? `${lines.join("\n")}
|
|
9677
9722
|
` : `
|
|
9678
|
-
${lines.join("\n")}` }
|
|
9679
|
-
|
|
9723
|
+
${lines.join("\n")}` });
|
|
9724
|
+
}
|
|
9725
|
+
return edits;
|
|
9680
9726
|
}
|
|
9681
|
-
function writeWorkflowConfigFile(path, source, changes, resources = []) {
|
|
9727
|
+
function writeWorkflowConfigFile(path, source, changes, resources = [], permissions = []) {
|
|
9682
9728
|
if (typeof source !== "string") {
|
|
9683
9729
|
throw new SourceError("A workflow config write edits an existing workflow file.");
|
|
9684
9730
|
}
|
|
@@ -9690,7 +9736,7 @@ function writeWorkflowConfigFile(path, source, changes, resources = []) {
|
|
|
9690
9736
|
const properties = new Map(
|
|
9691
9737
|
node.properties.filter((property2) => property2.type === "ObjectProperty" || property2.type === "ObjectMethod").map((property2) => [propertyKey(property2), property2])
|
|
9692
9738
|
);
|
|
9693
|
-
const references2 = referenceWriter(ast, resources);
|
|
9739
|
+
const references2 = referenceWriter(ast, resources, permissions);
|
|
9694
9740
|
const options = optionsOf2(changes, properties, references2);
|
|
9695
9741
|
const written = applySourceEdits(source, [
|
|
9696
9742
|
...objectPatchEdits(source, node, options, "config", 0),
|
|
@@ -9705,7 +9751,7 @@ function writeWorkflowConfigFile(path, source, changes, resources = []) {
|
|
|
9705
9751
|
|
|
9706
9752
|
// scripts/lib/runtime-build/source-adapters/workflow-config.mjs
|
|
9707
9753
|
var workflowConfigAdapter = Object.freeze({
|
|
9708
|
-
contextFields: ["resources", "resource_slugs"],
|
|
9754
|
+
contextFields: ["resources", "resource_slugs", "permissions"],
|
|
9709
9755
|
writeFields: ["name", "slug", "description", "trigger", "route", "run_as", "authorizer", "execution_mode", "paused"],
|
|
9710
9756
|
accepts: isWorkflowConfigPath,
|
|
9711
9757
|
identity: (data) => data.uid,
|
|
@@ -9713,7 +9759,13 @@ var workflowConfigAdapter = Object.freeze({
|
|
|
9713
9759
|
return readWorkflowConfigFile(path, source);
|
|
9714
9760
|
},
|
|
9715
9761
|
write({ path, source, data, context }) {
|
|
9716
|
-
return writeWorkflowConfigFile(
|
|
9762
|
+
return writeWorkflowConfigFile(
|
|
9763
|
+
path,
|
|
9764
|
+
source,
|
|
9765
|
+
data,
|
|
9766
|
+
branchResources(context),
|
|
9767
|
+
branchPermissions(context)
|
|
9768
|
+
);
|
|
9717
9769
|
}
|
|
9718
9770
|
});
|
|
9719
9771
|
|
|
@@ -9737,7 +9789,7 @@ var workspaceBrandAdapter = Object.freeze({
|
|
|
9737
9789
|
// scripts/lib/runtime-build/source-adapters/workspace-config.mjs
|
|
9738
9790
|
var workspaceConfigAdapter = Object.freeze({
|
|
9739
9791
|
contextFields: ["setting_key", "pages", "value_definitions"],
|
|
9740
|
-
writeFields: ["name", "settings", "brand", "domains", "primary_domain", "packages"],
|
|
9792
|
+
writeFields: ["name", "settings", "brand", "domains", "primary_domain", "default_menu", "packages"],
|
|
9741
9793
|
accepts: (path) => path === "diagonal.config.ts",
|
|
9742
9794
|
identity: null,
|
|
9743
9795
|
read({ source, context }) {
|
|
@@ -9799,7 +9851,13 @@ var workspaceConfigAdapter = Object.freeze({
|
|
|
9799
9851
|
${text}${target.properties.length ? "," : ""}
|
|
9800
9852
|
` + source.slice(target.start + 1);
|
|
9801
9853
|
}
|
|
9802
|
-
|
|
9854
|
+
if (source !== null && !Object.hasOwn(data, "default_menu")) {
|
|
9855
|
+
const defaultMenu = configProperties(configObject(source)).get("defaultMenu");
|
|
9856
|
+
if (defaultMenu) {
|
|
9857
|
+
throw new SourceError("A full config write must specify default_menu to keep or clear the existing default menu.", defaultMenu);
|
|
9858
|
+
}
|
|
9859
|
+
}
|
|
9860
|
+
const { primary_domain, default_menu, packages, ...config2 } = data;
|
|
9803
9861
|
if (Object.hasOwn(data, "primary_domain")) config2.primaryDomain = primary_domain;
|
|
9804
9862
|
let written = definitionSource("defineConfig", config2, context);
|
|
9805
9863
|
if (Object.hasOwn(data, "packages")) {
|
|
@@ -9821,7 +9879,7 @@ ${text}${target.properties.length ? "," : ""}
|
|
|
9821
9879
|
}
|
|
9822
9880
|
written = writeConfigPackages(written, packages, {}, context.value_definitions);
|
|
9823
9881
|
}
|
|
9824
|
-
return written;
|
|
9882
|
+
return Object.hasOwn(data, "default_menu") ? writeConfigSettings(written, { defaultMenu: default_menu }).content : written;
|
|
9825
9883
|
}
|
|
9826
9884
|
});
|
|
9827
9885
|
function settingKey(context) {
|
|
@@ -11149,7 +11207,7 @@ async function checkSources() {
|
|
|
11149
11207
|
if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
|
|
11150
11208
|
return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
|
|
11151
11209
|
}
|
|
11152
|
-
const { checkData, scriptSdk } = await import("./cli-check-data-
|
|
11210
|
+
const { checkData, scriptSdk } = await import("./cli-check-data-EAKFHVPZ.mjs");
|
|
11153
11211
|
return { data: checkData(), sdk: scriptSdk() };
|
|
11154
11212
|
}
|
|
11155
11213
|
function isScriptTestPath(path) {
|
|
@@ -11169,7 +11227,7 @@ function holdsSkills(root, plan) {
|
|
|
11169
11227
|
async function checkCheckout(root, options) {
|
|
11170
11228
|
const sources = await checkSources();
|
|
11171
11229
|
const plan = composePackages(root);
|
|
11172
|
-
const testRunner = async () => (await import("./cli-workflows-
|
|
11230
|
+
const testRunner = async () => (await import("./cli-workflows-DUSY244F.mjs")).runBuildTests;
|
|
11173
11231
|
const skillReader = async () => (await import("./cli-skill-file-PHFXSLAU.mjs")).skillFrontMatter;
|
|
11174
11232
|
const finish = (checkoutRoot, buildPlan, answer, runTests2) => {
|
|
11175
11233
|
const run = hasScriptTests(answer) ? runTests2(checkoutRoot, answer.tests) : null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1096,6 +1096,24 @@ type WorkflowLabel =
|
|
|
1096
1096
|
name?: never;
|
|
1097
1097
|
};
|
|
1098
1098
|
|
|
1099
|
+
/**
|
|
1100
|
+
* Who may call a request workflow, as a page authorizer names it. `'authenticated'` admits every
|
|
1101
|
+
* signed-in caller. The object form also limits the callers to the signed-in records of one
|
|
1102
|
+
* authenticatable resource, to the callers that hold any one of the permissions, or to both. A
|
|
1103
|
+
* request workflow without an authorizer is public.
|
|
1104
|
+
*/
|
|
1105
|
+
export type WorkflowAuthorizer =
|
|
1106
|
+
| 'authenticated'
|
|
1107
|
+
| {
|
|
1108
|
+
/** The authenticatable resource whose signed-in records may call the workflow, as `Resources.<Name>.slug`. */
|
|
1109
|
+
resource?: ResourceReference | null;
|
|
1110
|
+
/**
|
|
1111
|
+
* Permission uids, as `Permissions.<Name>.uid` or `SystemPermissions.<Name>.uid`.
|
|
1112
|
+
* A caller needs any one of them.
|
|
1113
|
+
*/
|
|
1114
|
+
permissions?: readonly PermissionUid[];
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1099
1117
|
/** A migration config takes this type too, but the build refuses its `slug`: a migration's file name is its identity. */
|
|
1100
1118
|
type ConfigBase = UidOption &
|
|
1101
1119
|
SlugOption &
|
|
@@ -1130,7 +1148,7 @@ export type WorkflowConfig =
|
|
|
1130
1148
|
ExecutionModeOption & {
|
|
1131
1149
|
trigger: RequestTrigger;
|
|
1132
1150
|
runAs?: WorkflowRunAs;
|
|
1133
|
-
authorizer?:
|
|
1151
|
+
authorizer?: WorkflowAuthorizer;
|
|
1134
1152
|
})
|
|
1135
1153
|
| (ConfigBase & {
|
|
1136
1154
|
trigger: RecordEventTrigger | RecordScheduleTrigger | ScheduledTrigger | WorkflowEventTrigger;
|