@diagonal-hq/cli 0.42.7 → 0.42.9
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-assets-cli-LXLBKDDH.mjs → cli-assets-cli-B4ERYIRF.mjs} +3 -3
- package/dist/{cli-check-data-W7BPD75Y.mjs → cli-check-data-YUN3PNMM.mjs} +10 -10
- package/dist/{cli-chunk-KZOQCV4Y.mjs → cli-chunk-3LF7KYRH.mjs} +2 -2
- package/dist/{cli-chunk-YSDTJ57P.mjs → cli-chunk-6VD2BES2.mjs} +2 -2
- package/dist/{cli-chunk-3SEADNVJ.mjs → cli-chunk-IHJR3KQG.mjs} +3 -3
- package/dist/{cli-chunk-4A3XCNXP.mjs → cli-chunk-IX4ZJ6J5.mjs} +2 -2
- package/dist/{cli-chunk-NEXRHJ3X.mjs → cli-chunk-KP2RSHLJ.mjs} +2 -0
- package/dist/{cli-chunk-ES45EAOO.mjs → cli-chunk-KRD6O5UC.mjs} +1 -1
- package/dist/{cli-chunk-XO3FRXQ4.mjs → cli-chunk-L5DINKQM.mjs} +3 -3
- package/dist/{cli-chunk-XQQBHS6I.mjs → cli-chunk-LBQOYO4G.mjs} +1 -1
- package/dist/{cli-chunk-25JQRNTW.mjs → cli-chunk-SCJXN7B6.mjs} +1 -1
- package/dist/{cli-sdk-files.generated-KZHKLP6A.mjs → cli-sdk-files.generated-ZKHJVYQH.mjs} +1 -1
- package/dist/{cli-skill-file-XEFKCU5Y.mjs → cli-skill-file-PHFXSLAU.mjs} +3 -3
- package/dist/{cli-workflows-ZDUTSUQP.mjs → cli-workflows-EFTLEHKL.mjs} +6 -6
- package/dist/cli.mjs +193 -42
- package/dist/index.d.ts +11 -1
- package/dist/script-sdk.json +1 -1
- package/dist/workflow/generated/capabilities.d.ts +1 -1
- package/package.json +4 -4
|
@@ -2,15 +2,15 @@ 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-SCJXN7B6.mjs";
|
|
6
6
|
import {
|
|
7
7
|
readUid
|
|
8
|
-
} from "./cli-chunk-
|
|
8
|
+
} from "./cli-chunk-KRD6O5UC.mjs";
|
|
9
9
|
import {
|
|
10
10
|
SourceError,
|
|
11
11
|
declaredSlug,
|
|
12
12
|
propertyKey
|
|
13
|
-
} from "./cli-chunk-
|
|
13
|
+
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
14
14
|
|
|
15
15
|
// scripts/lib/runtime-build/workflow-config.mjs
|
|
16
16
|
var WORKFLOW_STAGE = "workflow";
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
assetsBinding,
|
|
8
8
|
buildAssets,
|
|
9
9
|
isAssetKey
|
|
10
|
-
} from "./cli-chunk-
|
|
10
|
+
} from "./cli-chunk-LBQOYO4G.mjs";
|
|
11
11
|
import {
|
|
12
12
|
SourceError,
|
|
13
13
|
bindsName,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
staticObject,
|
|
19
19
|
studlyName,
|
|
20
20
|
traverse
|
|
21
|
-
} from "./cli-chunk-
|
|
21
|
+
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
22
22
|
|
|
23
23
|
// scripts/lib/runtime-build/api-cli.mjs
|
|
24
24
|
var WORKFLOWS_USAGE = "Usage: diagonal workflows [--json]";
|
|
@@ -41559,6 +41559,8 @@ export {
|
|
|
41559
41559
|
diagnosticAt,
|
|
41560
41560
|
hasErrors,
|
|
41561
41561
|
sortDiagnostics,
|
|
41562
|
+
isDeclaration,
|
|
41563
|
+
getOuterBindingIdentifiers,
|
|
41562
41564
|
TraceMap,
|
|
41563
41565
|
presortedDecodedMap,
|
|
41564
41566
|
decodedMap,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
SystemPermissions,
|
|
5
5
|
isTimezone,
|
|
6
6
|
isUrl
|
|
7
|
-
} from "./cli-chunk-
|
|
7
|
+
} from "./cli-chunk-SCJXN7B6.mjs";
|
|
8
8
|
import {
|
|
9
9
|
UID_PATTERN
|
|
10
|
-
} from "./cli-chunk-
|
|
10
|
+
} from "./cli-chunk-KRD6O5UC.mjs";
|
|
11
11
|
import {
|
|
12
12
|
AUTHORING_MODULE,
|
|
13
13
|
BUILT_IN_RESOURCE_SLUGS,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
staticValue,
|
|
30
30
|
studlyName,
|
|
31
31
|
withoutDevInfix
|
|
32
|
-
} from "./cli-chunk-
|
|
32
|
+
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
33
33
|
|
|
34
34
|
// packages/cli/workspace-settings-catalog.json
|
|
35
35
|
var workspace_settings_catalog_default = {
|
|
@@ -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 = 84;
|
|
13
13
|
|
|
14
14
|
export interface WorkspaceSystemFields {
|
|
15
15
|
"ai_custom_system_prompt": string | null;
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
skillFrontMatter,
|
|
11
11
|
skillUidDefinition,
|
|
12
12
|
writeSkillFile
|
|
13
|
-
} from "./cli-chunk-
|
|
14
|
-
import "./cli-chunk-
|
|
15
|
-
import "./cli-chunk-
|
|
13
|
+
} from "./cli-chunk-3LF7KYRH.mjs";
|
|
14
|
+
import "./cli-chunk-KRD6O5UC.mjs";
|
|
15
|
+
import "./cli-chunk-KP2RSHLJ.mjs";
|
|
16
16
|
import "./cli-chunk-LRS5IEI3.mjs";
|
|
17
17
|
export {
|
|
18
18
|
SKILL_DESCRIPTION_MAX_LENGTH,
|
|
@@ -3,10 +3,10 @@ const require = __diagonalCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
WORKFLOW_STAGE,
|
|
5
5
|
stripTypes
|
|
6
|
-
} from "./cli-chunk-
|
|
6
|
+
} from "./cli-chunk-IHJR3KQG.mjs";
|
|
7
7
|
import {
|
|
8
8
|
scriptSdkRuntimeFiles
|
|
9
|
-
} from "./cli-chunk-
|
|
9
|
+
} from "./cli-chunk-6VD2BES2.mjs";
|
|
10
10
|
import {
|
|
11
11
|
AUTHORING_HELPERS_MODULE,
|
|
12
12
|
GENERATED_NOTIFICATION_TYPES_PATH,
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
appModuleClosure,
|
|
16
16
|
isAppSpecifier,
|
|
17
17
|
resolveAppSpecifier
|
|
18
|
-
} from "./cli-chunk-
|
|
19
|
-
import "./cli-chunk-
|
|
18
|
+
} from "./cli-chunk-SCJXN7B6.mjs";
|
|
19
|
+
import "./cli-chunk-KRD6O5UC.mjs";
|
|
20
20
|
import {
|
|
21
21
|
GENERATED_ASSETS_PATH
|
|
22
|
-
} from "./cli-chunk-
|
|
22
|
+
} from "./cli-chunk-LBQOYO4G.mjs";
|
|
23
23
|
import {
|
|
24
24
|
AUTHORING_MODULE,
|
|
25
25
|
SourceError,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
diagnosticAt,
|
|
29
29
|
diagnosticFromError,
|
|
30
30
|
parseSource
|
|
31
|
-
} from "./cli-chunk-
|
|
31
|
+
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
32
32
|
import "./cli-chunk-LRS5IEI3.mjs";
|
|
33
33
|
|
|
34
34
|
// scripts/lib/runtime-build/workflows.mjs
|
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
buildSkill,
|
|
6
6
|
isSkillPath,
|
|
7
7
|
writeSkillFile
|
|
8
|
-
} from "./cli-chunk-
|
|
8
|
+
} from "./cli-chunk-3LF7KYRH.mjs";
|
|
9
9
|
import {
|
|
10
10
|
DOMAINS_EXPORT,
|
|
11
11
|
DOMAIN_REFERENCE_MESSAGE,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
readWorkspaceSettings,
|
|
43
43
|
routeParamNames,
|
|
44
44
|
workspace_settings_catalog_default
|
|
45
|
-
} from "./cli-chunk-
|
|
45
|
+
} from "./cli-chunk-L5DINKQM.mjs";
|
|
46
46
|
import {
|
|
47
47
|
compareVersions,
|
|
48
48
|
isVersion,
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
workflowConfigObject,
|
|
53
53
|
workflowMetadata,
|
|
54
54
|
workspaceBuildNeeds
|
|
55
|
-
} from "./cli-chunk-
|
|
55
|
+
} from "./cli-chunk-IHJR3KQG.mjs";
|
|
56
56
|
import {
|
|
57
57
|
GENERATED_NOTIFICATION_TYPES_MODULE,
|
|
58
58
|
GENERATED_WORKFLOWS_MODULE,
|
|
@@ -71,12 +71,12 @@ import {
|
|
|
71
71
|
require_types,
|
|
72
72
|
styleModuleExpression,
|
|
73
73
|
templateSlugOf
|
|
74
|
-
} from "./cli-chunk-
|
|
74
|
+
} from "./cli-chunk-SCJXN7B6.mjs";
|
|
75
75
|
import {
|
|
76
76
|
isUid,
|
|
77
77
|
readDefinitionUid,
|
|
78
78
|
readUid
|
|
79
|
-
} from "./cli-chunk-
|
|
79
|
+
} from "./cli-chunk-KRD6O5UC.mjs";
|
|
80
80
|
import {
|
|
81
81
|
ASSETS_LIST_USAGE,
|
|
82
82
|
ASSETS_PATH,
|
|
@@ -96,14 +96,14 @@ import {
|
|
|
96
96
|
takesAssetReference,
|
|
97
97
|
writeAssetCatalog,
|
|
98
98
|
writeAssetEntry
|
|
99
|
-
} from "./cli-chunk-
|
|
99
|
+
} from "./cli-chunk-IX4ZJ6J5.mjs";
|
|
100
100
|
import {
|
|
101
101
|
ASSETS_EXPORT,
|
|
102
102
|
GENERATED_ASSETS_MODULE,
|
|
103
103
|
assetKeyMessage,
|
|
104
104
|
assetsBinding,
|
|
105
105
|
isAssetKey
|
|
106
|
-
} from "./cli-chunk-
|
|
106
|
+
} from "./cli-chunk-LBQOYO4G.mjs";
|
|
107
107
|
import {
|
|
108
108
|
APP_PREFIX,
|
|
109
109
|
AUTHORING_MODULE,
|
|
@@ -132,9 +132,11 @@ import {
|
|
|
132
132
|
expectDefineCall,
|
|
133
133
|
freeName,
|
|
134
134
|
generatedBindingLocal,
|
|
135
|
+
getOuterBindingIdentifiers,
|
|
135
136
|
hasErrors,
|
|
136
137
|
importKind,
|
|
137
138
|
isAuthoringModule,
|
|
139
|
+
isDeclaration,
|
|
138
140
|
isDevPath,
|
|
139
141
|
isFunctionNode,
|
|
140
142
|
isJson,
|
|
@@ -170,7 +172,7 @@ import {
|
|
|
170
172
|
traverse,
|
|
171
173
|
usesImplicitName,
|
|
172
174
|
withoutDevInfix
|
|
173
|
-
} from "./cli-chunk-
|
|
175
|
+
} from "./cli-chunk-KP2RSHLJ.mjs";
|
|
174
176
|
import {
|
|
175
177
|
__commonJS,
|
|
176
178
|
__toESM
|
|
@@ -9096,35 +9098,178 @@ function testSettings({ value, at, problem: problem2 }) {
|
|
|
9096
9098
|
}
|
|
9097
9099
|
|
|
9098
9100
|
// scripts/lib/runtime-build/test-suite-files.mjs
|
|
9099
|
-
var
|
|
9100
|
-
|
|
9101
|
-
export default defineTest(
|
|
9102
|
-
{},
|
|
9103
|
-
{
|
|
9104
|
-
async test({ page, expect }) {
|
|
9101
|
+
var DEFAULT_BROWSER_HANDLER = ` async test({ page, expect }) {
|
|
9105
9102
|
await page.goto('/');
|
|
9106
9103
|
await expect(page).toHaveTitle(/.+/);
|
|
9104
|
+
}`;
|
|
9105
|
+
var BROWSER_HANDLER = "async test({ page, context, request, browser, expect })";
|
|
9106
|
+
var WORKFLOW_SDKS = /* @__PURE__ */ new Set(["@diagonal/workflow", "@diagonal-hq/workflows/test"]);
|
|
9107
|
+
var traverse3 = traverse.default ?? traverse;
|
|
9108
|
+
function scriptParts(source, phase) {
|
|
9109
|
+
if (typeof source !== "string") {
|
|
9110
|
+
throw new SourceError(`"${phase}" must be a workflow module.`);
|
|
9111
|
+
}
|
|
9112
|
+
const ast = parseSource(source, { jsx: false });
|
|
9113
|
+
const { program } = ast;
|
|
9114
|
+
const entry2 = program.body.find((node) => node.type === "ExportDefaultDeclaration");
|
|
9115
|
+
const call = entry2?.declaration;
|
|
9116
|
+
const callee = calleeName(call);
|
|
9117
|
+
const handler = call?.arguments?.[0];
|
|
9118
|
+
const imports = program.body.filter((node) => node.type === "ImportDeclaration");
|
|
9119
|
+
const wrapper = imports.filter((node) => WORKFLOW_SDKS.has(node.source.value)).flatMap((node) => node.specifiers).find((specifier) => specifier.type === "ImportSpecifier" && specifier.local.name === callee && (specifier.imported.name ?? specifier.imported.value) === "defineWorkflow");
|
|
9120
|
+
if (wrapper === void 0 || call.arguments.length !== 1 || !["FunctionExpression", "ArrowFunctionExpression"].includes(handler?.type)) {
|
|
9121
|
+
throw new SourceError(`"${phase}" must default-export defineWorkflow with one inline handler.`, entry2);
|
|
9122
|
+
}
|
|
9123
|
+
let globals;
|
|
9124
|
+
let wrapperUsed;
|
|
9125
|
+
traverse3(ast, {
|
|
9126
|
+
Program(path) {
|
|
9127
|
+
globals = Object.keys(path.scope.globals);
|
|
9128
|
+
wrapperUsed = path.scope.getBinding(callee).referencePaths.some((reference) => reference.node !== call.callee);
|
|
9129
|
+
path.stop();
|
|
9107
9130
|
}
|
|
9131
|
+
});
|
|
9132
|
+
const helpers = program.body.filter((node) => node !== entry2 && node.type !== "ImportDeclaration");
|
|
9133
|
+
const localDeclarations = new Set(helpers.flatMap((node) => declarationBindings(node.type === "ExportNamedDeclaration" ? node.declaration : node)));
|
|
9134
|
+
const comments = (node) => (node.leadingComments ?? []).map((comment) => sliceOf(source, comment));
|
|
9135
|
+
return {
|
|
9136
|
+
imports,
|
|
9137
|
+
wrapper: wrapperUsed ? null : wrapper,
|
|
9138
|
+
helpers,
|
|
9139
|
+
globals: globals.filter((name) => !localDeclarations.has(name)),
|
|
9140
|
+
handler: [...comments(entry2), `${phase}: ${sliceOf(source, handler)}`].join("\n "),
|
|
9141
|
+
comments
|
|
9142
|
+
};
|
|
9143
|
+
}
|
|
9144
|
+
function declarationBindings(declaration) {
|
|
9145
|
+
if (!isDeclaration(declaration)) return [];
|
|
9146
|
+
const bindings = Object.keys(getOuterBindingIdentifiers(declaration));
|
|
9147
|
+
if (declaration.id?.type === "Identifier" && !bindings.includes(declaration.id.name)) {
|
|
9148
|
+
bindings.push(declaration.id.name);
|
|
9108
9149
|
}
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
function
|
|
9112
|
-
if (
|
|
9113
|
-
|
|
9150
|
+
return bindings;
|
|
9151
|
+
}
|
|
9152
|
+
function hasStaticInitializer({ id, init }) {
|
|
9153
|
+
if (id.type !== "Identifier" || init === null) return false;
|
|
9154
|
+
if (init.type === "FunctionExpression" || init.type === "ArrowFunctionExpression") return true;
|
|
9155
|
+
try {
|
|
9156
|
+
staticValue(init);
|
|
9157
|
+
return true;
|
|
9158
|
+
} catch (error) {
|
|
9159
|
+
if (!(error instanceof SourceError)) throw error;
|
|
9160
|
+
return false;
|
|
9114
9161
|
}
|
|
9115
|
-
|
|
9162
|
+
}
|
|
9163
|
+
function assertShareableHelper(node, declaration, bindings, phase) {
|
|
9164
|
+
if (node.type === "ExportNamedDeclaration" && node.exportKind !== "type" && (bindings.includes("validateInput") || node.specifiers.some((specifier) => (specifier.exported.name ?? specifier.exported.value) === "validateInput"))) {
|
|
9165
|
+
throw new SourceError(`The ${phase} script exports validateInput, which would also validate the other script.`, node);
|
|
9166
|
+
}
|
|
9167
|
+
if (node.exportKind === "type" || declaration?.type === "TSTypeAliasDeclaration" || declaration?.type === "TSInterfaceDeclaration" || declaration?.type === "FunctionDeclaration" || declaration?.type === "EmptyStatement" || declaration?.type === "VariableDeclaration" && declaration.kind === "const" && declaration.declarations.every(hasStaticInitializer)) {
|
|
9168
|
+
return;
|
|
9169
|
+
}
|
|
9170
|
+
throw new SourceError(`The ${phase} script has module code that would also run in the other handler. Move it inside the ${phase} handler.`, node);
|
|
9171
|
+
}
|
|
9172
|
+
function composeScripts(setup, assert) {
|
|
9173
|
+
const names = /* @__PURE__ */ new Map([["defineTest", null]]);
|
|
9174
|
+
const globals = /* @__PURE__ */ new Set();
|
|
9175
|
+
const modules = /* @__PURE__ */ new Map();
|
|
9176
|
+
const helpers = [];
|
|
9177
|
+
const handlers = {};
|
|
9178
|
+
for (const [phase, source] of [["setup", setup], ["assert", assert]]) {
|
|
9179
|
+
if (source === void 0) continue;
|
|
9180
|
+
const parts = scriptParts(source, phase);
|
|
9181
|
+
const helperNames = /* @__PURE__ */ new Set();
|
|
9182
|
+
handlers[phase] = ` ${parts.handler}`;
|
|
9183
|
+
for (const name of parts.globals) {
|
|
9184
|
+
if (names.has(name)) {
|
|
9185
|
+
throw new SourceError(`A binding would change the global "${name}" in the ${phase} script.`);
|
|
9186
|
+
}
|
|
9187
|
+
}
|
|
9188
|
+
for (const node of parts.imports) {
|
|
9189
|
+
const module = node.source.value;
|
|
9190
|
+
const group = modules.get(module) ?? { bindings: [], sideEffect: false };
|
|
9191
|
+
modules.set(module, group);
|
|
9192
|
+
group.sideEffect ||= node.specifiers.length === 0;
|
|
9193
|
+
for (const specifier of node.specifiers) {
|
|
9194
|
+
if (specifier === parts.wrapper) continue;
|
|
9195
|
+
const local = specifier.local.name;
|
|
9196
|
+
if (globals.has(local)) {
|
|
9197
|
+
throw new SourceError(`The ${phase} script would change the global "${local}" in the other script.`, specifier);
|
|
9198
|
+
}
|
|
9199
|
+
const imported = specifier.type === "ImportSpecifier" ? specifier.imported.name ?? specifier.imported.value : specifier.type === "ImportNamespaceSpecifier" ? "*" : "default";
|
|
9200
|
+
const typeOnly = node.importKind === "type" || specifier.importKind === "type";
|
|
9201
|
+
const binding = JSON.stringify([module, imported, typeOnly]);
|
|
9202
|
+
if (names.has(local)) {
|
|
9203
|
+
if (names.get(local) !== binding) {
|
|
9204
|
+
throw new SourceError(`The test scripts have conflicting bindings for "${local}".`, specifier);
|
|
9205
|
+
}
|
|
9206
|
+
continue;
|
|
9207
|
+
}
|
|
9208
|
+
names.set(local, binding);
|
|
9209
|
+
group.bindings.push({ local, imported, typeOnly });
|
|
9210
|
+
}
|
|
9211
|
+
}
|
|
9212
|
+
for (const node of parts.helpers) {
|
|
9213
|
+
const declaration = node.type === "ExportNamedDeclaration" ? node.declaration : node;
|
|
9214
|
+
const bindings = declarationBindings(declaration);
|
|
9215
|
+
for (const name of bindings) helperNames.add(name);
|
|
9216
|
+
const text = sliceOf(source, node);
|
|
9217
|
+
const boundary = text.endsWith(";") || ["FunctionDeclaration", "ClassDeclaration", "TSInterfaceDeclaration"].includes(declaration?.type) ? "" : ";";
|
|
9218
|
+
helpers.push({ node, declaration, bindings, phase, source: [...parts.comments(node), text + boundary].join("\n") });
|
|
9219
|
+
}
|
|
9220
|
+
for (const name of helperNames) {
|
|
9221
|
+
if (globals.has(name)) {
|
|
9222
|
+
throw new SourceError(`The ${phase} script would change the global "${name}" in the other script.`);
|
|
9223
|
+
}
|
|
9224
|
+
if (names.has(name)) {
|
|
9225
|
+
throw new SourceError(`The test scripts have conflicting bindings for "${name}".`);
|
|
9226
|
+
}
|
|
9227
|
+
names.set(name, null);
|
|
9228
|
+
}
|
|
9229
|
+
for (const name of parts.globals) globals.add(name);
|
|
9230
|
+
}
|
|
9231
|
+
if (setup !== void 0 && assert !== void 0) {
|
|
9232
|
+
for (const { node, declaration, bindings, phase } of helpers) {
|
|
9233
|
+
assertShareableHelper(node, declaration, bindings, phase);
|
|
9234
|
+
}
|
|
9235
|
+
}
|
|
9236
|
+
const imports = [];
|
|
9237
|
+
for (const [module, { bindings, sideEffect }] of modules) {
|
|
9238
|
+
const specifier = quotedLiteral(module);
|
|
9239
|
+
const named = bindings.filter(({ imported }) => imported !== "*");
|
|
9240
|
+
if (named.length > 0) {
|
|
9241
|
+
const allTypes = named.every(({ typeOnly }) => typeOnly);
|
|
9242
|
+
const entries = named.map(({ local, imported, typeOnly }) => {
|
|
9243
|
+
const name = imported === local ? local : `${imported} as ${local}`;
|
|
9244
|
+
return typeOnly && !allTypes ? `type ${name}` : name;
|
|
9245
|
+
});
|
|
9246
|
+
imports.push(`import ${allTypes ? "type " : ""}{ ${entries.join(", ")} } from ${specifier};`);
|
|
9247
|
+
}
|
|
9248
|
+
for (const { local, imported, typeOnly } of bindings) {
|
|
9249
|
+
if (imported === "*") {
|
|
9250
|
+
imports.push(`import ${typeOnly ? "type " : ""}* as ${local} from ${specifier};`);
|
|
9251
|
+
}
|
|
9252
|
+
}
|
|
9253
|
+
if (sideEffect && bindings.every(({ typeOnly }) => typeOnly)) imports.push(`import ${specifier};`);
|
|
9254
|
+
}
|
|
9255
|
+
return { imports, helpers: helpers.map(({ source }) => source), handlers };
|
|
9256
|
+
}
|
|
9257
|
+
function newTest(body, setup, assert) {
|
|
9258
|
+
if (body !== void 0 && typeof body !== "string") {
|
|
9116
9259
|
throw new SourceError('"test" must be the body of the test function.');
|
|
9117
9260
|
}
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9261
|
+
const { imports, helpers, handlers } = composeScripts(setup, assert);
|
|
9262
|
+
const head = ["import { defineTest } from '@diagonal-hq/cli';", ...imports].join("\n");
|
|
9263
|
+
const test = body === void 0 ? DEFAULT_BROWSER_HANDLER : ` ${BROWSER_HANDLER} {${body}
|
|
9264
|
+
}`;
|
|
9265
|
+
const phases = [handlers.setup, test, handlers.assert].filter(Boolean).join(",\n");
|
|
9266
|
+
return [head, ...helpers, `export default defineTest(
|
|
9121
9267
|
{},
|
|
9122
9268
|
{
|
|
9123
|
-
|
|
9124
|
-
}
|
|
9269
|
+
${phases}
|
|
9125
9270
|
}
|
|
9126
9271
|
);
|
|
9127
|
-
|
|
9272
|
+
`].join("\n\n");
|
|
9128
9273
|
}
|
|
9129
9274
|
function patchConfig(source, node, changes) {
|
|
9130
9275
|
if (node.type !== "ObjectExpression") {
|
|
@@ -9174,8 +9319,12 @@ function readTestFile(path, source) {
|
|
|
9174
9319
|
return { key: /^tests\/[^/]+\/([^/]+)\.ts$/.exec(path)[1], ...config2 };
|
|
9175
9320
|
}
|
|
9176
9321
|
function writeTestFile(path, source, changes) {
|
|
9177
|
-
if (source !== null
|
|
9178
|
-
|
|
9322
|
+
if (source !== null) {
|
|
9323
|
+
for (const phase of ["setup", "test", "assert"]) {
|
|
9324
|
+
if (changes[phase] !== void 0) {
|
|
9325
|
+
throw new SourceError(`A test edit cannot write its ${phase} function. Edit the file in Files.`);
|
|
9326
|
+
}
|
|
9327
|
+
}
|
|
9179
9328
|
}
|
|
9180
9329
|
const options = {};
|
|
9181
9330
|
for (const key of ["name", "description"]) {
|
|
@@ -9195,7 +9344,7 @@ function writeTestFile(path, source, changes) {
|
|
|
9195
9344
|
}
|
|
9196
9345
|
options.timeoutSeconds = changes.timeout_seconds;
|
|
9197
9346
|
}
|
|
9198
|
-
const current = source ?? newTest(changes.test);
|
|
9347
|
+
const current = source ?? newTest(changes.test, changes.setup, changes.assert);
|
|
9199
9348
|
const written = patchConfig(current, readTestConfig(path, current).node, options);
|
|
9200
9349
|
readTestConfig(path, written);
|
|
9201
9350
|
return written;
|
|
@@ -9204,7 +9353,7 @@ function writeTestFile(path, source, changes) {
|
|
|
9204
9353
|
// scripts/lib/runtime-build/source-adapters/test-case.mjs
|
|
9205
9354
|
var testCaseAdapter = Object.freeze({
|
|
9206
9355
|
contextFields: [],
|
|
9207
|
-
writeFields: ["name", "description", "enabled", "timeout_seconds", "test"],
|
|
9356
|
+
writeFields: ["name", "description", "enabled", "timeout_seconds", "test", "setup", "assert"],
|
|
9208
9357
|
accepts: isTestFile,
|
|
9209
9358
|
identity: null,
|
|
9210
9359
|
read({ path, source }) {
|
|
@@ -9292,14 +9441,14 @@ function oneOf(value, allowed, label) {
|
|
|
9292
9441
|
}
|
|
9293
9442
|
return value;
|
|
9294
9443
|
}
|
|
9295
|
-
function filtersOf(value) {
|
|
9444
|
+
function filtersOf(value, key = "filters") {
|
|
9296
9445
|
if (value === void 0 || value === null) {
|
|
9297
9446
|
return {};
|
|
9298
9447
|
}
|
|
9299
9448
|
if (!isPlainObject(value)) {
|
|
9300
|
-
throw new SourceError(
|
|
9449
|
+
throw new SourceError(`"trigger.${key}" must be a filter group or null.`);
|
|
9301
9450
|
}
|
|
9302
|
-
return {
|
|
9451
|
+
return { [key]: value };
|
|
9303
9452
|
}
|
|
9304
9453
|
function referenceWriter(ast, resources) {
|
|
9305
9454
|
const locals = {
|
|
@@ -9381,14 +9530,16 @@ function triggerOf(trigger, references2) {
|
|
|
9381
9530
|
type: "recordEvent",
|
|
9382
9531
|
resource: references2.resource(trigger.resource),
|
|
9383
9532
|
event: oneOf(trigger.event, RECORD_EVENTS, "trigger.event"),
|
|
9384
|
-
...filtersOf(trigger.filters)
|
|
9533
|
+
...filtersOf(trigger.filters),
|
|
9534
|
+
...filtersOf(trigger.previousFilters, "previousFilters")
|
|
9385
9535
|
};
|
|
9386
9536
|
case "recordLifecycle":
|
|
9387
9537
|
return {
|
|
9388
9538
|
type: "recordLifecycle",
|
|
9389
9539
|
resource: references2.resource(trigger.resource),
|
|
9390
9540
|
hook: oneOf(trigger.hook, LIFECYCLE_HOOKS, "trigger.hook"),
|
|
9391
|
-
...filtersOf(trigger.filters)
|
|
9541
|
+
...filtersOf(trigger.filters),
|
|
9542
|
+
...filtersOf(trigger.previousFilters, "previousFilters")
|
|
9392
9543
|
};
|
|
9393
9544
|
case "recordSchedule": {
|
|
9394
9545
|
const offsets = trigger.offsets;
|
|
@@ -10134,7 +10285,7 @@ function transformField(op, path, source, data) {
|
|
|
10134
10285
|
// scripts/lib/runtime-build/package-input-bindings.mjs
|
|
10135
10286
|
import { readFileSync } from "node:fs";
|
|
10136
10287
|
import { basename as basename4, join as join2 } from "node:path";
|
|
10137
|
-
var
|
|
10288
|
+
var traverse4 = traverse.default ?? traverse;
|
|
10138
10289
|
var KINDS = {
|
|
10139
10290
|
resource: { module: "resources", exportName: "Resources", argument: defineResourceArgument },
|
|
10140
10291
|
role: { module: "roles", exportName: "Roles", argument: defineRoleArgument },
|
|
@@ -10323,7 +10474,7 @@ function bindPackageSource(source, path, bindings) {
|
|
|
10323
10474
|
}
|
|
10324
10475
|
}
|
|
10325
10476
|
const edits = [];
|
|
10326
|
-
|
|
10477
|
+
traverse4(ast, {
|
|
10327
10478
|
TSQualifiedName(nodePath) {
|
|
10328
10479
|
const node = nodePath.node;
|
|
10329
10480
|
if (node.left.type !== "Identifier" || nodePath.scope.getBinding(node.left.name)?.kind !== "module" || !nodePath.findParent((parent) => parent.isTSTypeQuery())) {
|
|
@@ -10988,7 +11139,7 @@ async function checkSources() {
|
|
|
10988
11139
|
if (existsSync4(DATA_FILE) && existsSync4(SDK_FILE)) {
|
|
10989
11140
|
return { dataFile: DATA_FILE, sdkFile: SDK_FILE };
|
|
10990
11141
|
}
|
|
10991
|
-
const { checkData, scriptSdk } = await import("./cli-check-data-
|
|
11142
|
+
const { checkData, scriptSdk } = await import("./cli-check-data-YUN3PNMM.mjs");
|
|
10992
11143
|
return { data: checkData(), sdk: scriptSdk() };
|
|
10993
11144
|
}
|
|
10994
11145
|
function isScriptTestPath(path) {
|
|
@@ -11008,8 +11159,8 @@ function holdsSkills(root, plan) {
|
|
|
11008
11159
|
async function checkCheckout(root, options) {
|
|
11009
11160
|
const sources = await checkSources();
|
|
11010
11161
|
const plan = composePackages(root);
|
|
11011
|
-
const testRunner = async () => (await import("./cli-workflows-
|
|
11012
|
-
const skillReader = async () => (await import("./cli-skill-file-
|
|
11162
|
+
const testRunner = async () => (await import("./cli-workflows-EFTLEHKL.mjs")).runBuildTests;
|
|
11163
|
+
const skillReader = async () => (await import("./cli-skill-file-PHFXSLAU.mjs")).skillFrontMatter;
|
|
11013
11164
|
const finish = (checkoutRoot, buildPlan, answer, runTests2) => {
|
|
11014
11165
|
const run = hasScriptTests(answer) ? runTests2(checkoutRoot, answer.tests) : null;
|
|
11015
11166
|
const diagnostics = finishedDiagnostics(withTestDiagnostics(answer, run), buildPlan);
|
|
@@ -11094,9 +11245,9 @@ async function main(argv, io) {
|
|
|
11094
11245
|
case "assets": {
|
|
11095
11246
|
const [subcommand, ...assetArgs] = args;
|
|
11096
11247
|
if (subcommand === "upload")
|
|
11097
|
-
return (await import("./cli-assets-cli-
|
|
11248
|
+
return (await import("./cli-assets-cli-B4ERYIRF.mjs")).uploadAsset(assetArgs, io);
|
|
11098
11249
|
if (subcommand === "list")
|
|
11099
|
-
return (await import("./cli-assets-cli-
|
|
11250
|
+
return (await import("./cli-assets-cli-B4ERYIRF.mjs")).listAssets(assetArgs, io);
|
|
11100
11251
|
io.stderr.write(`${ASSETS_UPLOAD_USAGE}
|
|
11101
11252
|
${ASSETS_LIST_USAGE}
|
|
11102
11253
|
`);
|
package/dist/index.d.ts
CHANGED
|
@@ -432,7 +432,7 @@ export type FilterCondition = {
|
|
|
432
432
|
|
|
433
433
|
/**
|
|
434
434
|
* A filter tree: a policy `filter` and `authorizer`, a `recordEvent` trigger
|
|
435
|
-
* `filters`, and a notification schedule `filters`.
|
|
435
|
+
* `filters` and `previousFilters`, and a notification schedule `filters`.
|
|
436
436
|
*/
|
|
437
437
|
export type FilterGroup = {
|
|
438
438
|
operator: 'and' | 'or' | 'nor';
|
|
@@ -1024,6 +1024,11 @@ export type RecordEventTrigger = {
|
|
|
1024
1024
|
event: 'created' | 'updated' | 'deleted' | 'restored' | 'saved';
|
|
1025
1025
|
/** Runs the workflow only for the records that match. */
|
|
1026
1026
|
filters?: FilterGroup;
|
|
1027
|
+
/**
|
|
1028
|
+
* Runs the workflow only when the record before the change matches, for
|
|
1029
|
+
* example a status that was `'pending'`. Only the `'updated'` event takes it.
|
|
1030
|
+
*/
|
|
1031
|
+
previousFilters?: FilterGroup;
|
|
1027
1032
|
};
|
|
1028
1033
|
|
|
1029
1034
|
export type RecordLifecycleTrigger = {
|
|
@@ -1031,6 +1036,11 @@ export type RecordLifecycleTrigger = {
|
|
|
1031
1036
|
resource: ResourceReference;
|
|
1032
1037
|
hook: 'creating' | 'updating' | 'saving' | 'deleting' | 'restoring';
|
|
1033
1038
|
filters?: FilterGroup;
|
|
1039
|
+
/**
|
|
1040
|
+
* Runs the workflow only when the record before the write matches. Only the
|
|
1041
|
+
* `'updating'` hook takes it.
|
|
1042
|
+
*/
|
|
1043
|
+
previousFilters?: FilterGroup;
|
|
1034
1044
|
};
|
|
1035
1045
|
|
|
1036
1046
|
export type RecordScheduleTrigger = {
|