@diagonal-hq/cli 0.42.15 → 0.42.17
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-check-data-VYRAU2E4.mjs → cli-check-data-R4UXA3WH.mjs} +2 -2
- package/dist/{cli-chunk-HMV62NPA.mjs → cli-chunk-AQ7QT67Z.mjs} +1 -1
- package/dist/{cli-chunk-KWMNEXZC.mjs → cli-chunk-MX5DAHDR.mjs} +2 -1
- package/dist/{cli-chunk-SCJXN7B6.mjs → cli-chunk-QONY26SY.mjs} +45 -0
- package/dist/{cli-workflows-XE3FFNFV.mjs → cli-workflows-6RHPPBQL.mjs} +2 -2
- package/dist/cli.mjs +300 -21
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
brand_kit_catalog_default,
|
|
12
12
|
page_meta_resolvers_default,
|
|
13
13
|
workspace_settings_catalog_default
|
|
14
|
-
} from "./cli-chunk-
|
|
14
|
+
} from "./cli-chunk-AQ7QT67Z.mjs";
|
|
15
15
|
import {
|
|
16
16
|
SCRIPT_SDK_FILES,
|
|
17
17
|
scriptSdkSurface
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
PROFILES,
|
|
25
25
|
SystemPermissions,
|
|
26
26
|
SystemRoles
|
|
27
|
-
} from "./cli-chunk-
|
|
27
|
+
} from "./cli-chunk-QONY26SY.mjs";
|
|
28
28
|
import "./cli-chunk-KRD6O5UC.mjs";
|
|
29
29
|
import {
|
|
30
30
|
GENERATED_ASSETS_PATH
|
|
@@ -2,7 +2,7 @@ import { createRequire as __diagonalCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __diagonalCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
stringFacts
|
|
5
|
-
} from "./cli-chunk-
|
|
5
|
+
} from "./cli-chunk-QONY26SY.mjs";
|
|
6
6
|
import {
|
|
7
7
|
readUid
|
|
8
8
|
} from "./cli-chunk-KRD6O5UC.mjs";
|
|
@@ -490,6 +490,7 @@ function runCompilerAsync(input, args) {
|
|
|
490
490
|
|
|
491
491
|
export {
|
|
492
492
|
WORKFLOW_STAGE,
|
|
493
|
+
TRIGGER_TYPES,
|
|
493
494
|
workflowConfigObject,
|
|
494
495
|
workflowMetadata,
|
|
495
496
|
editableInputSchema,
|
|
@@ -5,11 +5,14 @@ import {
|
|
|
5
5
|
AUTHORING_MODULE,
|
|
6
6
|
PAGES_SDK_MODULE,
|
|
7
7
|
SourceError,
|
|
8
|
+
byteOrder,
|
|
9
|
+
diagnosticAt,
|
|
8
10
|
importKind,
|
|
9
11
|
isAuthoringModule,
|
|
10
12
|
moduleSpecifiers,
|
|
11
13
|
pagesSdkObjectText,
|
|
12
14
|
parseSource,
|
|
15
|
+
pathName,
|
|
13
16
|
requestedNames,
|
|
14
17
|
resolveLocalSpecifier,
|
|
15
18
|
sliceOf,
|
|
@@ -24078,9 +24081,49 @@ var PROFILE_SPECIFIERS = new Set(
|
|
|
24078
24081
|
);
|
|
24079
24082
|
|
|
24080
24083
|
// scripts/lib/runtime-build/workflow-references.mjs
|
|
24084
|
+
import { basename } from "node:path";
|
|
24081
24085
|
var GENERATED_WORKFLOWS_PATH = "generated/workflows.ts";
|
|
24082
24086
|
var GENERATED_WORKFLOWS_MODULE = "@app/generated/workflows";
|
|
24083
24087
|
var WORKFLOWS_EXPORT = "Workflows";
|
|
24088
|
+
function workflowNames(paths, diagnostics) {
|
|
24089
|
+
const pathsByName = /* @__PURE__ */ new Map();
|
|
24090
|
+
const namesByPath = /* @__PURE__ */ new Map();
|
|
24091
|
+
for (const path of paths.toSorted(byteOrder)) {
|
|
24092
|
+
const name = pathName(
|
|
24093
|
+
path,
|
|
24094
|
+
basename(withoutDevInfix(path), ".ts"),
|
|
24095
|
+
{ exportName: WORKFLOWS_EXPORT, label: "workflow", showText: false, severity: "warning" },
|
|
24096
|
+
diagnostics
|
|
24097
|
+
);
|
|
24098
|
+
if (name === null) {
|
|
24099
|
+
continue;
|
|
24100
|
+
}
|
|
24101
|
+
const other = pathsByName.get(name);
|
|
24102
|
+
if (other !== void 0) {
|
|
24103
|
+
diagnostics.push(
|
|
24104
|
+
diagnosticAt(
|
|
24105
|
+
path,
|
|
24106
|
+
null,
|
|
24107
|
+
`The workflows ${other} and ${path} both have the name ${WORKFLOWS_EXPORT}.${name}. Rename one of the files`,
|
|
24108
|
+
{ relatedPath: other }
|
|
24109
|
+
)
|
|
24110
|
+
);
|
|
24111
|
+
continue;
|
|
24112
|
+
}
|
|
24113
|
+
pathsByName.set(name, path);
|
|
24114
|
+
namesByPath.set(path, name);
|
|
24115
|
+
}
|
|
24116
|
+
return { pathsByName, namesByPath };
|
|
24117
|
+
}
|
|
24118
|
+
function workflowEntries({ pathsByName }, metadataByPath) {
|
|
24119
|
+
const entries = /* @__PURE__ */ Object.create(null);
|
|
24120
|
+
for (const name of [...pathsByName.keys()].toSorted(byteOrder)) {
|
|
24121
|
+
const path = pathsByName.get(name);
|
|
24122
|
+
const { uid = null, slug = basename(withoutDevInfix(path), ".ts"), ...metadata } = metadataByPath.get(path) ?? {};
|
|
24123
|
+
entries[name] = { uid, slug, ...metadata };
|
|
24124
|
+
}
|
|
24125
|
+
return entries;
|
|
24126
|
+
}
|
|
24084
24127
|
|
|
24085
24128
|
// scripts/lib/runtime-build/string-facts.mjs
|
|
24086
24129
|
var URL_PATTERN = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
@@ -24134,5 +24177,7 @@ export {
|
|
|
24134
24177
|
GENERATED_WORKFLOWS_PATH,
|
|
24135
24178
|
GENERATED_WORKFLOWS_MODULE,
|
|
24136
24179
|
WORKFLOWS_EXPORT,
|
|
24180
|
+
workflowNames,
|
|
24181
|
+
workflowEntries,
|
|
24137
24182
|
PROFILES
|
|
24138
24183
|
};
|
|
@@ -3,7 +3,7 @@ const require = __diagonalCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
WORKFLOW_STAGE,
|
|
5
5
|
stripTypes
|
|
6
|
-
} from "./cli-chunk-
|
|
6
|
+
} from "./cli-chunk-MX5DAHDR.mjs";
|
|
7
7
|
import {
|
|
8
8
|
scriptSdkRuntimeFiles
|
|
9
9
|
} from "./cli-chunk-6VD2BES2.mjs";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
appModuleClosure,
|
|
16
16
|
isAppSpecifier,
|
|
17
17
|
resolveAppSpecifier
|
|
18
|
-
} from "./cli-chunk-
|
|
18
|
+
} from "./cli-chunk-QONY26SY.mjs";
|
|
19
19
|
import "./cli-chunk-KRD6O5UC.mjs";
|
|
20
20
|
import {
|
|
21
21
|
GENERATED_ASSETS_PATH
|
package/dist/cli.mjs
CHANGED
|
@@ -46,8 +46,9 @@ import {
|
|
|
46
46
|
routeBindingsSource,
|
|
47
47
|
routeParamNames,
|
|
48
48
|
workspace_settings_catalog_default
|
|
49
|
-
} from "./cli-chunk-
|
|
49
|
+
} from "./cli-chunk-AQ7QT67Z.mjs";
|
|
50
50
|
import {
|
|
51
|
+
TRIGGER_TYPES,
|
|
51
52
|
compareVersions,
|
|
52
53
|
editableInputSchema,
|
|
53
54
|
isVersion,
|
|
@@ -57,7 +58,7 @@ import {
|
|
|
57
58
|
workflowConfigObject,
|
|
58
59
|
workflowMetadata,
|
|
59
60
|
workspaceBuildNeeds
|
|
60
|
-
} from "./cli-chunk-
|
|
61
|
+
} from "./cli-chunk-MX5DAHDR.mjs";
|
|
61
62
|
import {
|
|
62
63
|
GENERATED_NOTIFICATION_TYPES_MODULE,
|
|
63
64
|
GENERATED_WORKFLOWS_MODULE,
|
|
@@ -75,8 +76,10 @@ import {
|
|
|
75
76
|
require_parser,
|
|
76
77
|
require_types,
|
|
77
78
|
styleModuleExpression,
|
|
78
|
-
templateSlugOf
|
|
79
|
-
|
|
79
|
+
templateSlugOf,
|
|
80
|
+
workflowEntries,
|
|
81
|
+
workflowNames
|
|
82
|
+
} from "./cli-chunk-QONY26SY.mjs";
|
|
80
83
|
import {
|
|
81
84
|
isUid,
|
|
82
85
|
readDefinitionUid,
|
|
@@ -7031,19 +7034,27 @@ function readLayoutOption(ast, source, path, property2, branchPaths) {
|
|
|
7031
7034
|
return null;
|
|
7032
7035
|
}
|
|
7033
7036
|
const paths = new Set(branchPaths ?? []);
|
|
7037
|
+
const statement = value.type === "Identifier" ? layoutImportOf(ast, value.name) : null;
|
|
7034
7038
|
let target = null;
|
|
7035
7039
|
if (value.type === "StringLiteral") {
|
|
7036
7040
|
const named = `layouts/${value.value}.tsx`;
|
|
7037
7041
|
target = paths.has(named) ? named : null;
|
|
7038
|
-
} else if (
|
|
7039
|
-
|
|
7040
|
-
(item) => item.type === "ImportDeclaration" && item.specifiers.some(
|
|
7041
|
-
(specifier) => specifier.type === "ImportDefaultSpecifier" && specifier.local.name === value.name
|
|
7042
|
-
)
|
|
7043
|
-
);
|
|
7044
|
-
target = statement === void 0 ? null : resolveLocalSpecifierIn(paths, path, statement.source.value);
|
|
7042
|
+
} else if (statement !== null) {
|
|
7043
|
+
target = resolveLocalSpecifierIn(paths, path, statement.source.value);
|
|
7045
7044
|
}
|
|
7046
|
-
return {
|
|
7045
|
+
return {
|
|
7046
|
+
read_only: true,
|
|
7047
|
+
display: sliceOf(source, value),
|
|
7048
|
+
path: target,
|
|
7049
|
+
writable: statement !== null
|
|
7050
|
+
};
|
|
7051
|
+
}
|
|
7052
|
+
function layoutImportOf(ast, local) {
|
|
7053
|
+
return ast.program.body.find(
|
|
7054
|
+
(statement) => statement.type === "ImportDeclaration" && statement.importKind !== "type" && importKind(statement.source.value) === "app" && statement.specifiers.some(
|
|
7055
|
+
(specifier) => specifier.type === "ImportDefaultSpecifier" && specifier.local.name === local
|
|
7056
|
+
)
|
|
7057
|
+
) ?? null;
|
|
7047
7058
|
}
|
|
7048
7059
|
function readPageFile(path, source, resources, branchPaths = null, permissions = []) {
|
|
7049
7060
|
return readPage(path, source, branchResourceNames(resources), branchPaths, declaredPermissionEntries(permissions));
|
|
@@ -7203,12 +7214,8 @@ function writePagePaused(path, source, paused, resources, { branchPaths = null,
|
|
|
7203
7214
|
}
|
|
7204
7215
|
function writeParts(path, options, parts, { previous, readPath: readPath2, names, permissionEntries, keep, branchPaths, sourceOptions, addsCodeImports }) {
|
|
7205
7216
|
options = migrateOptionValues(options);
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
"layout: The page builder cannot set a layout. Keep it from the file with keep: ['layout']",
|
|
7209
|
-
null
|
|
7210
|
-
);
|
|
7211
|
-
}
|
|
7217
|
+
const keepsLayout = keep.includes("layout") || Object.hasOwn(sourceOptions, "layout");
|
|
7218
|
+
const layout = keepsLayout ? void 0 : layoutChoice(options.layout, branchPaths);
|
|
7212
7219
|
if (keep.length > 0) {
|
|
7213
7220
|
const read = readPage(readPath2, previous, names, null, permissionEntries);
|
|
7214
7221
|
if (!read.ok) {
|
|
@@ -7230,6 +7237,11 @@ function writeParts(path, options, parts, { previous, readPath: readPath2, names
|
|
|
7230
7237
|
const written = parts();
|
|
7231
7238
|
const { helpers, component, trailing } = written;
|
|
7232
7239
|
let imports = written.imports;
|
|
7240
|
+
if (!keepsLayout) {
|
|
7241
|
+
const chosen = writtenLayout(path, imports, [helpers, `(${component});`, trailing].join("\n"), layout, previousLayoutOf(previous), branchPaths);
|
|
7242
|
+
imports = chosen.imports;
|
|
7243
|
+
options = chosen.value === null ? omit(options, "layout") : { ...options, layout: chosen.value };
|
|
7244
|
+
}
|
|
7233
7245
|
const binding = resourcesBinding(parseSource(imports, { jsx: false }), names);
|
|
7234
7246
|
const local = binding?.local ?? freeName("Resources", parseSource([imports, helpers, `(${component});`].join("\n"), { jsx: true }));
|
|
7235
7247
|
const references2 = withResourceReferences(options, names.namesBySlug, local);
|
|
@@ -7336,6 +7348,136 @@ function filePartsOf(source) {
|
|
|
7336
7348
|
trailing: source.slice(exportStatement.end).trim()
|
|
7337
7349
|
};
|
|
7338
7350
|
}
|
|
7351
|
+
var LAYOUT_CHOICE_MESSAGE = "layout: The page builder sets a layout as { path: 'layouts/<name>.tsx' }, or null for Blank";
|
|
7352
|
+
function layoutChoice(value, branchPaths) {
|
|
7353
|
+
if (value === void 0 || value === null) {
|
|
7354
|
+
return null;
|
|
7355
|
+
}
|
|
7356
|
+
if (!isPlainObject(value) || Object.keys(value).length !== 1 || typeof value.path !== "string") {
|
|
7357
|
+
throw new SourceError(LAYOUT_CHOICE_MESSAGE, null);
|
|
7358
|
+
}
|
|
7359
|
+
if (!isLayoutFile(value.path) || branchPaths !== null && !branchPaths.includes(value.path)) {
|
|
7360
|
+
throw new SourceError(`layout: ${value.path} is not a layout file of the workspace`, null);
|
|
7361
|
+
}
|
|
7362
|
+
return { path: value.path };
|
|
7363
|
+
}
|
|
7364
|
+
function isLayoutFile(path) {
|
|
7365
|
+
return path.startsWith("layouts/") && SOURCE_EXTENSIONS.some((extension) => path.endsWith(extension)) && !/\.(?:test|spec|d)\.[a-z]+$/.test(path);
|
|
7366
|
+
}
|
|
7367
|
+
function importsLayoutFile(path, statement, branchPaths) {
|
|
7368
|
+
const paths = branchPaths === null ? { has: isLayoutFile } : new Set(branchPaths);
|
|
7369
|
+
const target = resolveLocalSpecifierIn(paths, path, statement.source.value);
|
|
7370
|
+
return target !== null && isLayoutFile(target);
|
|
7371
|
+
}
|
|
7372
|
+
function previousLayoutOf(previous) {
|
|
7373
|
+
if (previous === null) {
|
|
7374
|
+
return null;
|
|
7375
|
+
}
|
|
7376
|
+
const ast = parseSource(previous, { jsx: true });
|
|
7377
|
+
const exportStatement = ast.program.body.find(
|
|
7378
|
+
(statement) => statement.type === "ExportDefaultDeclaration"
|
|
7379
|
+
);
|
|
7380
|
+
if (exportStatement === void 0) {
|
|
7381
|
+
return null;
|
|
7382
|
+
}
|
|
7383
|
+
let metaNode;
|
|
7384
|
+
try {
|
|
7385
|
+
[metaNode] = expectDefineCall(exportStatement.declaration, "definePage", 2);
|
|
7386
|
+
} catch (error) {
|
|
7387
|
+
if (error instanceof SourceError) {
|
|
7388
|
+
return null;
|
|
7389
|
+
}
|
|
7390
|
+
throw error;
|
|
7391
|
+
}
|
|
7392
|
+
const property2 = layoutProperty(metaNode);
|
|
7393
|
+
if (property2 === void 0 || property2.value.type === "NullLiteral") {
|
|
7394
|
+
return null;
|
|
7395
|
+
}
|
|
7396
|
+
const value = property2.value;
|
|
7397
|
+
const local = value.type === "Identifier" && layoutImportOf(ast, value.name) !== null ? value.name : null;
|
|
7398
|
+
return { display: sliceOf(previous, value), local };
|
|
7399
|
+
}
|
|
7400
|
+
function writtenLayout(path, imports, code, layout, previousLayout, branchPaths) {
|
|
7401
|
+
let result = imports;
|
|
7402
|
+
const importsAst = parseSource(imports, { jsx: true });
|
|
7403
|
+
const previousStatement = previousLayout === null || previousLayout.local === null ? null : layoutImportOf(importsAst, previousLayout.local);
|
|
7404
|
+
let removed = null;
|
|
7405
|
+
if (previousLayout !== null && (previousStatement === null || !importsLayoutFile(path, previousStatement, branchPaths))) {
|
|
7406
|
+
if (layout === null) {
|
|
7407
|
+
return { imports, value: null };
|
|
7408
|
+
}
|
|
7409
|
+
throw new SourceError(
|
|
7410
|
+
`layout: The page file sets its layout with ${previousLayout.display}, which the page builder cannot change. Change it in Files`,
|
|
7411
|
+
null
|
|
7412
|
+
);
|
|
7413
|
+
}
|
|
7414
|
+
if (previousStatement !== null) {
|
|
7415
|
+
if (layout !== null && namesFile(path, previousStatement, layout.path, branchPaths)) {
|
|
7416
|
+
return { imports, value: new SourceExpression2(previousLayout.local) };
|
|
7417
|
+
}
|
|
7418
|
+
const withoutImport = withoutDefaultImport(imports, previousStatement);
|
|
7419
|
+
if (!usesName(parseSource([withoutImport, code].join("\n"), { jsx: true }), previousLayout.local)) {
|
|
7420
|
+
result = withoutImport;
|
|
7421
|
+
removed = previousStatement;
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
if (layout === null) {
|
|
7425
|
+
return { imports: result, value: null };
|
|
7426
|
+
}
|
|
7427
|
+
const existing = parseSource(result, { jsx: true }).program.body.filter(
|
|
7428
|
+
(statement2) => statement2.type === "ImportDeclaration" && namesFile(path, statement2, layout.path, branchPaths)
|
|
7429
|
+
).flatMap((statement2) => statement2.specifiers).find((specifier) => specifier.type === "ImportDefaultSpecifier");
|
|
7430
|
+
if (existing !== void 0) {
|
|
7431
|
+
return { imports: result, value: new SourceExpression2(existing.local.name) };
|
|
7432
|
+
}
|
|
7433
|
+
const local = freeName(layoutLocalName(layout.path), parseSource([result, code].join("\n"), { jsx: true }));
|
|
7434
|
+
const statement = `import ${local} from ${quotedLiteral(layoutSpecifier(path, layout.path, branchPaths))};`;
|
|
7435
|
+
const value = new SourceExpression2(local);
|
|
7436
|
+
if (removed !== null && removed.specifiers.length === 1) {
|
|
7437
|
+
return { imports: `${imports.slice(0, removed.start)}${statement}${imports.slice(removed.end)}`, value };
|
|
7438
|
+
}
|
|
7439
|
+
return { imports: result === "" ? statement : `${result}
|
|
7440
|
+
${statement}`, value };
|
|
7441
|
+
}
|
|
7442
|
+
function namesFile(path, statement, target, branchPaths) {
|
|
7443
|
+
return statement.importKind !== "type" && importKind(statement.source.value) === "app" && resolveLocalSpecifierIn(new Set(branchPaths ?? [target]), path, statement.source.value) === target;
|
|
7444
|
+
}
|
|
7445
|
+
function layoutSpecifier(path, layoutPath, branchPaths) {
|
|
7446
|
+
const specifier = relativeSpecifier(path, layoutPath);
|
|
7447
|
+
if (branchPaths === null || resolveLocalSpecifierIn(new Set(branchPaths), path, specifier) === layoutPath) {
|
|
7448
|
+
return specifier;
|
|
7449
|
+
}
|
|
7450
|
+
const relativePath = posix3.relative(posix3.dirname(path), layoutPath);
|
|
7451
|
+
return relativePath.startsWith("../") ? relativePath : `./${relativePath}`;
|
|
7452
|
+
}
|
|
7453
|
+
function usesName(ast, name) {
|
|
7454
|
+
return allNodes(ast).some(
|
|
7455
|
+
(node) => (node.type === "Identifier" || node.type === "JSXIdentifier") && node.name === name
|
|
7456
|
+
);
|
|
7457
|
+
}
|
|
7458
|
+
function withoutDefaultImport(imports, statement) {
|
|
7459
|
+
const specifier = statement.specifiers.find((item) => item.type === "ImportDefaultSpecifier");
|
|
7460
|
+
if (statement.specifiers.length === 1) {
|
|
7461
|
+
const leading = /\n*$/.exec(imports.slice(0, statement.start))[0];
|
|
7462
|
+
const trailing = /^\n*/.exec(imports.slice(statement.end))[0];
|
|
7463
|
+
const before = imports.slice(0, statement.start - leading.length);
|
|
7464
|
+
const after = imports.slice(statement.end + trailing.length);
|
|
7465
|
+
const separator = before === "" || after === "" ? "" : leading.length >= trailing.length ? leading : trailing;
|
|
7466
|
+
return `${before}${separator}${after}`;
|
|
7467
|
+
}
|
|
7468
|
+
let rest = imports.indexOf(",", specifier.end) + 1;
|
|
7469
|
+
while (imports[rest] === " ") {
|
|
7470
|
+
rest += 1;
|
|
7471
|
+
}
|
|
7472
|
+
return `${imports.slice(0, specifier.start)}${imports.slice(rest)}`;
|
|
7473
|
+
}
|
|
7474
|
+
function layoutLocalName(layoutPath) {
|
|
7475
|
+
const segments = layoutPath.replace(/\.[jt]sx?$/, "").split("/");
|
|
7476
|
+
const base = segments.at(-1) === "index" && segments.length > 2 ? segments.at(-2) : segments.at(-1);
|
|
7477
|
+
const name = studlyName(base);
|
|
7478
|
+
const local = name.endsWith("Layout") ? name : `${name}Layout`;
|
|
7479
|
+
return /^[A-Za-z]/.test(local) ? local : `Layout${local}`;
|
|
7480
|
+
}
|
|
7339
7481
|
function withKeptOptions(options, previous, keep) {
|
|
7340
7482
|
const result = { ...options };
|
|
7341
7483
|
const seo = isPlainObject(result.seo) ? { ...result.seo } : {};
|
|
@@ -9434,9 +9576,14 @@ function literalString(node) {
|
|
|
9434
9576
|
}
|
|
9435
9577
|
function readWorkflowConfigFile(path, source) {
|
|
9436
9578
|
const { ast, node } = configOf(path, source);
|
|
9437
|
-
|
|
9579
|
+
return configIdentity(ast, configProperties2(node));
|
|
9580
|
+
}
|
|
9581
|
+
function configProperties2(node) {
|
|
9582
|
+
return new Map(
|
|
9438
9583
|
node.properties.filter((property2) => property2.type === "ObjectProperty").map((property2) => [propertyKey(property2), property2])
|
|
9439
9584
|
);
|
|
9585
|
+
}
|
|
9586
|
+
function configIdentity(ast, properties) {
|
|
9440
9587
|
const { uid, slug = null } = workflowMetadata(ast);
|
|
9441
9588
|
return {
|
|
9442
9589
|
uid,
|
|
@@ -9446,6 +9593,118 @@ function readWorkflowConfigFile(path, source) {
|
|
|
9446
9593
|
input_refusal: editableInputSchema(ast).refusal
|
|
9447
9594
|
};
|
|
9448
9595
|
}
|
|
9596
|
+
function readWorkflowSettingsFile(path, source, resources, workflowUids, permissions = []) {
|
|
9597
|
+
const { ast, node } = configOf(path, source);
|
|
9598
|
+
const properties = configProperties2(node);
|
|
9599
|
+
const names = workflowNames(Object.keys(workflowUids), []);
|
|
9600
|
+
const workflowsLocal = generatedBindingLocal(ast, GENERATED_WORKFLOWS_MODULE, WORKFLOWS_EXPORT);
|
|
9601
|
+
const metadataByPath = new Map(
|
|
9602
|
+
Object.entries(workflowUids).map(([file, uid]) => [file, { uid }])
|
|
9603
|
+
);
|
|
9604
|
+
const options = {
|
|
9605
|
+
resources: resourcesBinding(ast, branchResourceNames(resources)),
|
|
9606
|
+
workflows: workflowsLocal === null ? null : {
|
|
9607
|
+
local: workflowsLocal,
|
|
9608
|
+
entries: workflowEntries(names, metadataByPath),
|
|
9609
|
+
pathsByName: names.pathsByName
|
|
9610
|
+
},
|
|
9611
|
+
domains: domainsBinding(ast, null),
|
|
9612
|
+
permissions: permissionsBinding(ast, declaredPermissionEntries(permissions))
|
|
9613
|
+
};
|
|
9614
|
+
const triggerProperty = properties.get("trigger");
|
|
9615
|
+
const trigger = triggerProperty === void 0 ? null : staticValue(triggerProperty.value, options);
|
|
9616
|
+
if (!isPlainObject(trigger) || !Object.hasOwn(TRIGGER_TYPES, trigger.type)) {
|
|
9617
|
+
throw new SourceError(
|
|
9618
|
+
`"trigger" must be an object with a type: ${Object.keys(TRIGGER_TYPES).join(", ")}.`,
|
|
9619
|
+
triggerProperty?.value ?? node
|
|
9620
|
+
);
|
|
9621
|
+
}
|
|
9622
|
+
assertTriggerFields(trigger, triggerProperty.value);
|
|
9623
|
+
const authorizerProperty = properties.get("authorizer");
|
|
9624
|
+
const authorizer = authorizerProperty === void 0 ? null : staticValue(authorizerProperty.value, options);
|
|
9625
|
+
if (!isAuthorizer(authorizer)) {
|
|
9626
|
+
throw new SourceError(
|
|
9627
|
+
`"authorizer" must be 'authenticated', { resource, permissions }, or null.`,
|
|
9628
|
+
authorizerProperty.value
|
|
9629
|
+
);
|
|
9630
|
+
}
|
|
9631
|
+
const executionModeProperty = properties.get("executionMode");
|
|
9632
|
+
const executionMode = executionModeProperty === void 0 ? null : staticValue(executionModeProperty.value, options);
|
|
9633
|
+
if (executionMode !== null && executionMode !== "sync" && executionMode !== "async") {
|
|
9634
|
+
throw new SourceError(
|
|
9635
|
+
`"executionMode" must be 'sync' or 'async'.`,
|
|
9636
|
+
executionModeProperty.value
|
|
9637
|
+
);
|
|
9638
|
+
}
|
|
9639
|
+
const pausedProperty = properties.get("paused");
|
|
9640
|
+
const paused = pausedProperty === void 0 ? null : staticValue(pausedProperty.value, options);
|
|
9641
|
+
if (paused !== null && typeof paused !== "boolean") {
|
|
9642
|
+
throw new SourceError('"paused" must be true or false.', pausedProperty.value);
|
|
9643
|
+
}
|
|
9644
|
+
const inputSchema = editableInputSchema(ast);
|
|
9645
|
+
return {
|
|
9646
|
+
...configIdentity(ast, properties),
|
|
9647
|
+
has_input: inputSchema.refusal !== null || inputSchema.property !== null,
|
|
9648
|
+
trigger,
|
|
9649
|
+
run_as: runAsSetting(properties.get("runAs"), options),
|
|
9650
|
+
authorizer,
|
|
9651
|
+
execution_mode: executionMode,
|
|
9652
|
+
paused: paused === true
|
|
9653
|
+
};
|
|
9654
|
+
}
|
|
9655
|
+
function isAuthorizer(authorizer) {
|
|
9656
|
+
if (authorizer === null || authorizer === "authenticated") {
|
|
9657
|
+
return true;
|
|
9658
|
+
}
|
|
9659
|
+
return isPlainObject(authorizer) && Object.keys(authorizer).every((key) => key === "resource" || key === "permissions") && (authorizer.resource === void 0 || typeof authorizer.resource === "string") && (authorizer.permissions === void 0 || Array.isArray(authorizer.permissions) && authorizer.permissions.every((uid) => typeof uid === "string"));
|
|
9660
|
+
}
|
|
9661
|
+
var TRIGGER_TEXT_FIELDS = {
|
|
9662
|
+
manual: [],
|
|
9663
|
+
request: ["path", "method", "domain"],
|
|
9664
|
+
scheduled: ["expression"],
|
|
9665
|
+
recordEvent: ["resource", "event"],
|
|
9666
|
+
recordLifecycle: ["resource", "hook"],
|
|
9667
|
+
recordSchedule: ["resource", "dateField", "timing"],
|
|
9668
|
+
workflowEvent: ["workflow", "event"]
|
|
9669
|
+
};
|
|
9670
|
+
function assertTriggerFields(trigger, node) {
|
|
9671
|
+
if (trigger.type === "request" && trigger.apiDocs !== void 0 && typeof trigger.apiDocs !== "boolean") {
|
|
9672
|
+
throw new SourceError('"trigger.apiDocs" must be true or false.', node);
|
|
9673
|
+
}
|
|
9674
|
+
for (const field of TRIGGER_TEXT_FIELDS[trigger.type]) {
|
|
9675
|
+
const value = trigger[field];
|
|
9676
|
+
if (value !== void 0 && value !== null && typeof value !== "string") {
|
|
9677
|
+
throw new SourceError(`"trigger.${field}" must be a string.`, node);
|
|
9678
|
+
}
|
|
9679
|
+
}
|
|
9680
|
+
const offsets = trigger.offsets;
|
|
9681
|
+
if (trigger.type === "recordSchedule" && offsets !== void 0 && offsets !== null && (!Array.isArray(offsets) || offsets.some((offset) => typeof offset !== "string"))) {
|
|
9682
|
+
throw new SourceError('"trigger.offsets" must be a list of ISO 8601 durations.', node);
|
|
9683
|
+
}
|
|
9684
|
+
}
|
|
9685
|
+
function runAsSetting(property2, options) {
|
|
9686
|
+
if (property2 === void 0) {
|
|
9687
|
+
return null;
|
|
9688
|
+
}
|
|
9689
|
+
let value = property2.value;
|
|
9690
|
+
while (value.type === "TSAsExpression" || value.type === "TSSatisfiesExpression") {
|
|
9691
|
+
value = value.expression;
|
|
9692
|
+
}
|
|
9693
|
+
if (value.type === "ObjectExpression" && [...configProperties2(value).keys()].join() === "binding") {
|
|
9694
|
+
return { binding: true };
|
|
9695
|
+
}
|
|
9696
|
+
const runAs = staticValue(value, options);
|
|
9697
|
+
if (runAs === null || runAs === "system" || runAs === "session") {
|
|
9698
|
+
return runAs;
|
|
9699
|
+
}
|
|
9700
|
+
if (isPlainObject(runAs) && typeof runAs.resource === "string" && typeof runAs.record === "string") {
|
|
9701
|
+
return { resource: runAs.resource, record: runAs.record };
|
|
9702
|
+
}
|
|
9703
|
+
throw new SourceError(
|
|
9704
|
+
`"runAs" must be 'system', 'session', { resource, record }, or { binding }.`,
|
|
9705
|
+
property2.value
|
|
9706
|
+
);
|
|
9707
|
+
}
|
|
9449
9708
|
function nonEmptyString(value, label) {
|
|
9450
9709
|
if (typeof value !== "string" || value.trim() === "") {
|
|
9451
9710
|
throw new SourceError(`"${label}" must be a non-empty string.`);
|
|
@@ -10052,6 +10311,25 @@ var workflowConfigAdapter = Object.freeze({
|
|
|
10052
10311
|
}
|
|
10053
10312
|
});
|
|
10054
10313
|
|
|
10314
|
+
// scripts/lib/runtime-build/source-adapters/workflow-settings.mjs
|
|
10315
|
+
var workflowSettingsAdapter = Object.freeze({
|
|
10316
|
+
contextFields: ["resources", "resource_slugs", "workflow_uids", "permissions"],
|
|
10317
|
+
accepts: isWorkflowConfigPath,
|
|
10318
|
+
read({ path, source, context }) {
|
|
10319
|
+
const workflowUids = object(context.workflow_uids ?? {}, "workflow_uids");
|
|
10320
|
+
if (Object.values(workflowUids).some((uid) => typeof uid !== "string")) {
|
|
10321
|
+
throw new SourceTransformRequestError("workflow_uids must map paths to strings.");
|
|
10322
|
+
}
|
|
10323
|
+
return readWorkflowSettingsFile(
|
|
10324
|
+
path,
|
|
10325
|
+
source,
|
|
10326
|
+
branchResources(context),
|
|
10327
|
+
workflowUids,
|
|
10328
|
+
branchPermissions(context)
|
|
10329
|
+
);
|
|
10330
|
+
}
|
|
10331
|
+
});
|
|
10332
|
+
|
|
10055
10333
|
// scripts/lib/runtime-build/source-adapters/workspace-brand.mjs
|
|
10056
10334
|
var workspaceBrandAdapter = Object.freeze({
|
|
10057
10335
|
identity: null,
|
|
@@ -10426,6 +10704,7 @@ var SOURCE_ADAPTERS = Object.freeze({
|
|
|
10426
10704
|
"test-case": testCaseAdapter,
|
|
10427
10705
|
"navigation-menu": navigationMenuAdapter,
|
|
10428
10706
|
"workflow-config": workflowConfigAdapter,
|
|
10707
|
+
"workflow-settings": workflowSettingsAdapter,
|
|
10429
10708
|
"module-references": moduleReferencesAdapter
|
|
10430
10709
|
});
|
|
10431
10710
|
var fieldList = (value) => Array.isArray(value) && value.every((field) => typeof field === "string") && new Set(value).size === value.length;
|
|
@@ -11490,7 +11769,7 @@ async function checkSources() {
|
|
|
11490
11769
|
if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
|
|
11491
11770
|
return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
|
|
11492
11771
|
}
|
|
11493
|
-
const { checkData, scriptSdk } = await import("./cli-check-data-
|
|
11772
|
+
const { checkData, scriptSdk } = await import("./cli-check-data-R4UXA3WH.mjs");
|
|
11494
11773
|
return { data: checkData(), sdk: scriptSdk() };
|
|
11495
11774
|
}
|
|
11496
11775
|
function isScriptTestPath(path) {
|
|
@@ -11510,7 +11789,7 @@ function holdsSkills(root, plan) {
|
|
|
11510
11789
|
async function checkCheckout(root, options) {
|
|
11511
11790
|
const sources = await checkSources();
|
|
11512
11791
|
const plan = composePackages(root);
|
|
11513
|
-
const testRunner = async () => (await import("./cli-workflows-
|
|
11792
|
+
const testRunner = async () => (await import("./cli-workflows-6RHPPBQL.mjs")).runBuildTests;
|
|
11514
11793
|
const skillReader = async () => (await import("./cli-skill-file-PHFXSLAU.mjs")).skillFrontMatter;
|
|
11515
11794
|
const finish = (checkoutRoot, buildPlan, answer, runTests2) => {
|
|
11516
11795
|
const run = hasScriptTests(answer) ? runTests2(checkoutRoot, answer.tests) : null;
|
package/package.json
CHANGED