@fluidgrids/cli 0.0.0-stage → 2026.1028.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/LICENSE +9 -0
- package/README.md +219 -2
- package/dist/auth/device-login.d.ts +31 -0
- package/dist/auth/device-login.d.ts.map +1 -0
- package/dist/auth/device-login.js +75 -0
- package/dist/auth/device-login.js.map +1 -0
- package/dist/auth/token-auth.d.ts +49 -0
- package/dist/auth/token-auth.d.ts.map +1 -0
- package/dist/auth/token-auth.js +279 -0
- package/dist/auth/token-auth.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +37 -0
- package/dist/cli.js.map +1 -0
- package/dist/code-first/api.d.ts +170 -0
- package/dist/code-first/api.d.ts.map +1 -0
- package/dist/code-first/api.js +166 -0
- package/dist/code-first/api.js.map +1 -0
- package/dist/code-first/commands/codegen.d.ts +20 -0
- package/dist/code-first/commands/codegen.d.ts.map +1 -0
- package/dist/code-first/commands/codegen.js +50 -0
- package/dist/code-first/commands/codegen.js.map +1 -0
- package/dist/code-first/commands/diff.d.ts +28 -0
- package/dist/code-first/commands/diff.d.ts.map +1 -0
- package/dist/code-first/commands/diff.js +73 -0
- package/dist/code-first/commands/diff.js.map +1 -0
- package/dist/code-first/commands/import.d.ts +40 -0
- package/dist/code-first/commands/import.d.ts.map +1 -0
- package/dist/code-first/commands/import.js +235 -0
- package/dist/code-first/commands/import.js.map +1 -0
- package/dist/code-first/commands/init.d.ts +33 -0
- package/dist/code-first/commands/init.d.ts.map +1 -0
- package/dist/code-first/commands/init.js +177 -0
- package/dist/code-first/commands/init.js.map +1 -0
- package/dist/code-first/commands/interface.d.ts +12 -0
- package/dist/code-first/commands/interface.d.ts.map +1 -0
- package/dist/code-first/commands/interface.js +21 -0
- package/dist/code-first/commands/interface.js.map +1 -0
- package/dist/code-first/commands/pull.d.ts +63 -0
- package/dist/code-first/commands/pull.d.ts.map +1 -0
- package/dist/code-first/commands/pull.js +266 -0
- package/dist/code-first/commands/pull.js.map +1 -0
- package/dist/code-first/commands/push.d.ts +51 -0
- package/dist/code-first/commands/push.d.ts.map +1 -0
- package/dist/code-first/commands/push.js +217 -0
- package/dist/code-first/commands/push.js.map +1 -0
- package/dist/code-first/commands/validate.d.ts +34 -0
- package/dist/code-first/commands/validate.d.ts.map +1 -0
- package/dist/code-first/commands/validate.js +115 -0
- package/dist/code-first/commands/validate.js.map +1 -0
- package/dist/code-first/connections.d.ts +55 -0
- package/dist/code-first/connections.d.ts.map +1 -0
- package/dist/code-first/connections.js +180 -0
- package/dist/code-first/connections.js.map +1 -0
- package/dist/code-first/index.d.ts +14 -0
- package/dist/code-first/index.d.ts.map +1 -0
- package/dist/code-first/index.js +31 -0
- package/dist/code-first/index.js.map +1 -0
- package/dist/code-first/lowering.d.ts +42 -0
- package/dist/code-first/lowering.d.ts.map +1 -0
- package/dist/code-first/lowering.js +128 -0
- package/dist/code-first/lowering.js.map +1 -0
- package/dist/code-first/operations.d.ts +57 -0
- package/dist/code-first/operations.d.ts.map +1 -0
- package/dist/code-first/operations.js +167 -0
- package/dist/code-first/operations.js.map +1 -0
- package/dist/code-first/project.d.ts +114 -0
- package/dist/code-first/project.d.ts.map +1 -0
- package/dist/code-first/project.js +279 -0
- package/dist/code-first/project.js.map +1 -0
- package/dist/code-first/python.d.ts +70 -0
- package/dist/code-first/python.d.ts.map +1 -0
- package/dist/code-first/python.js +219 -0
- package/dist/code-first/python.js.map +1 -0
- package/dist/code-first/register.d.ts +21 -0
- package/dist/code-first/register.d.ts.map +1 -0
- package/dist/code-first/register.js +126 -0
- package/dist/code-first/register.js.map +1 -0
- package/dist/code-first/remote.d.ts +58 -0
- package/dist/code-first/remote.d.ts.map +1 -0
- package/dist/code-first/remote.js +120 -0
- package/dist/code-first/remote.js.map +1 -0
- package/dist/code-first/shared.d.ts +39 -0
- package/dist/code-first/shared.d.ts.map +1 -0
- package/dist/code-first/shared.js +57 -0
- package/dist/code-first/shared.js.map +1 -0
- package/dist/modules.d.ts +15 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +61 -0
- package/dist/modules.js.map +1 -0
- package/dist/product-defaults.d.ts +11 -0
- package/dist/product-defaults.d.ts.map +1 -0
- package/dist/product-defaults.js +25 -0
- package/dist/product-defaults.js.map +1 -0
- package/dist/program.d.ts +20 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +43 -0
- package/dist/program.js.map +1 -0
- package/package.json +100 -4
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids validate [key…] [--strict] [--remote] [--offline]`: IR v2
|
|
3
|
+
* validation of the local workflows (spec 01 §9), with the strict rules on
|
|
4
|
+
* request. `--remote` also asks the service (`validateWorkflowDefinition`),
|
|
5
|
+
* which knows the workspace's task queues and installed nodes. `--offline`
|
|
6
|
+
* skips the workspace: connection names are not resolved.
|
|
7
|
+
*/
|
|
8
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
9
|
+
import { validate } from '@fluidgrids/workflows/ir';
|
|
10
|
+
import { explainUnresolved, placeholderRef } from '../connections.js';
|
|
11
|
+
import { lowerProject } from '../lowering.js';
|
|
12
|
+
import { assertProjectWorkspace, loadProject } from '../project.js';
|
|
13
|
+
import { projectConnectionIndex } from '../remote.js';
|
|
14
|
+
import { emit, requireKnownKeys } from '../shared.js';
|
|
15
|
+
export async function runValidate(env, keys, options) {
|
|
16
|
+
if (options.offline && options.remote) {
|
|
17
|
+
throw new CliUserError('--offline and --remote cannot be combined.');
|
|
18
|
+
}
|
|
19
|
+
const project = loadProject(options.project, env.cwd());
|
|
20
|
+
let index;
|
|
21
|
+
if (!options.offline) {
|
|
22
|
+
if (!env.ctx.auth.isAuthenticated()) {
|
|
23
|
+
throw new CliUserError('Validating against the workspace needs a login.', {
|
|
24
|
+
hint: 'Run `fluidgrids auth login`, set FLUIDGRIDS_TOKEN, or pass --offline.',
|
|
25
|
+
exitCode: 2,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
assertProjectWorkspace(env, project);
|
|
29
|
+
index = await projectConnectionIndex(env.api, project, keys);
|
|
30
|
+
}
|
|
31
|
+
const connectionIndex = index;
|
|
32
|
+
const lowered = await lowerProject(project, {
|
|
33
|
+
connections: (name) => connectionIndex
|
|
34
|
+
? Object.hasOwn(connectionIndex.refs, name)
|
|
35
|
+
? connectionIndex.refs[name]
|
|
36
|
+
: undefined
|
|
37
|
+
: placeholderRef(name),
|
|
38
|
+
connectionNames: connectionIndex ? Object.keys(connectionIndex.refs) : [],
|
|
39
|
+
explainUnresolved: (names) => connectionIndex ? explainUnresolved(names, connectionIndex) : [...names],
|
|
40
|
+
});
|
|
41
|
+
requireKnownKeys(keys, lowered.workflows.map((workflow) => workflow.key));
|
|
42
|
+
const selected = keys.length > 0
|
|
43
|
+
? lowered.workflows.filter((workflow) => keys.includes(workflow.key))
|
|
44
|
+
: lowered.workflows;
|
|
45
|
+
if (selected.length === 0)
|
|
46
|
+
throw new CliUserError('The project defines no workflows.');
|
|
47
|
+
const items = [];
|
|
48
|
+
for (const workflow of selected) {
|
|
49
|
+
const local = validate(workflow.definition, { strict: options.strict === true });
|
|
50
|
+
const toIssue = (issue) => ({
|
|
51
|
+
source: 'local',
|
|
52
|
+
code: issue.code,
|
|
53
|
+
message: issue.message,
|
|
54
|
+
...(issue.nodeId ? { nodeId: issue.nodeId } : {}),
|
|
55
|
+
...(issue.path ? { path: issue.path } : {}),
|
|
56
|
+
});
|
|
57
|
+
const errors = local.errors.map(toIssue);
|
|
58
|
+
const warnings = local.warnings.map(toIssue);
|
|
59
|
+
if (options.remote) {
|
|
60
|
+
const remote = await env.api.validateDefinition(workflow.definition, options.strict === true);
|
|
61
|
+
const fromService = (issue) => ({
|
|
62
|
+
source: 'service',
|
|
63
|
+
code: issue.code,
|
|
64
|
+
message: issue.message,
|
|
65
|
+
...(issue.nodeId ? { nodeId: issue.nodeId } : {}),
|
|
66
|
+
...(issue.path ? { path: issue.path } : {}),
|
|
67
|
+
});
|
|
68
|
+
errors.push(...remote.errors.map(fromService));
|
|
69
|
+
warnings.push(...remote.warnings.map(fromService));
|
|
70
|
+
if (!remote.valid && remote.errors.length === 0) {
|
|
71
|
+
errors.push({ source: 'service', message: 'The service rejected the definition.' });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
items.push({
|
|
75
|
+
key: workflow.key,
|
|
76
|
+
path: workflow.path,
|
|
77
|
+
valid: errors.length === 0,
|
|
78
|
+
errors,
|
|
79
|
+
warnings,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const result = {
|
|
83
|
+
strict: options.strict === true,
|
|
84
|
+
connectionsChecked: connectionIndex !== undefined,
|
|
85
|
+
workflows: items,
|
|
86
|
+
};
|
|
87
|
+
const line = (key, level, issue) => {
|
|
88
|
+
const where = [issue.nodeId, issue.path].filter(Boolean).join(' ');
|
|
89
|
+
const code = issue.code ? `${issue.code} ` : '';
|
|
90
|
+
return `${key}: ${level} ${code}${where ? `(${where}) ` : ''}${issue.message}${issue.source === 'service' ? ' [service]' : ''}`;
|
|
91
|
+
};
|
|
92
|
+
const details = items.flatMap((item) => [
|
|
93
|
+
...item.errors.map((issue) => line(item.key, 'error', issue)),
|
|
94
|
+
...item.warnings.map((issue) => line(item.key, 'warning', issue)),
|
|
95
|
+
]);
|
|
96
|
+
if (!result.connectionsChecked)
|
|
97
|
+
details.push('Connection names were not resolved (--offline).');
|
|
98
|
+
details.push(...lowered.warnings);
|
|
99
|
+
emit(env, options, result, {
|
|
100
|
+
headers: ['Workflow', 'File', 'Valid', 'Errors', 'Warnings'],
|
|
101
|
+
rows: items.map((item) => [
|
|
102
|
+
item.key,
|
|
103
|
+
item.path,
|
|
104
|
+
item.valid ? 'yes' : 'no',
|
|
105
|
+
String(item.errors.length),
|
|
106
|
+
String(item.warnings.length),
|
|
107
|
+
]),
|
|
108
|
+
}, details);
|
|
109
|
+
const invalid = items.filter((item) => !item.valid).map((item) => item.key);
|
|
110
|
+
if (invalid.length > 0) {
|
|
111
|
+
throw new CliUserError(`Invalid: ${invalid.join(', ')}`);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/code-first/commands/validate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAwC,MAAM,cAAc,CAAC;AA8B5F,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,GAAe,EACf,IAAuB,EACvB,OAAwB;IAExB,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,IAAI,YAAY,CAAC,4CAA4C,CAAC,CAAC;IACvE,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,IAAI,KAAkC,CAAC;IACvC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,YAAY,CAAC,iDAAiD,EAAE;gBACxE,IAAI,EAAE,uEAAuE;gBAC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,KAAK,CAAC,CAAC,CAAC,IAAI;YACzB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAC1B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;SAC7B,CAAC;KACH,EACD,OAAO,CACR,CAAC;IACF,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,YAAY,CAAC,YAAY,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection names in code (`connection: 'slack-ops'`) resolve to the
|
|
3
|
+
* `{ connectionId, adapter }` references a node stores (spec 07 §3 rule 7, §6).
|
|
4
|
+
*
|
|
5
|
+
* The id comes from the workspace's connections, matched by name. The adapter
|
|
6
|
+
* is the name of the node's connection slot, which a connection name alone does
|
|
7
|
+
* not tell, so it is taken, in order, from:
|
|
8
|
+
* 1. the adapter the remote versions of the pushed workflows already bind that
|
|
9
|
+
* connection to (exact for every workflow that was pulled), then
|
|
10
|
+
* 2. the one adapter in the node registry whose provider is the connection's
|
|
11
|
+
* provider.
|
|
12
|
+
* When neither gives exactly one answer the name is left unresolved and the CLI
|
|
13
|
+
* says why; the code can then bind the connection by id with
|
|
14
|
+
* `connections: [{ connectionId, adapter }]`.
|
|
15
|
+
*/
|
|
16
|
+
import type { ConnectionRef, NodeManifest } from '@fluidgrids/workflows/ir';
|
|
17
|
+
import type { WorkspaceConnection } from './api.js';
|
|
18
|
+
export interface ConnectionIndex {
|
|
19
|
+
/** Name → reference, for every name that resolves to exactly one reference. */
|
|
20
|
+
refs: Record<string, ConnectionRef>;
|
|
21
|
+
/** Name → why it does not resolve. */
|
|
22
|
+
problems: Record<string, string>;
|
|
23
|
+
/** connectionId → name, for lifting. */
|
|
24
|
+
namesById: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
/** connectionId → every adapter a definition binds it to. */
|
|
27
|
+
export declare function adaptersInDefinitions(definitions: readonly unknown[]): Map<string, Set<string>>;
|
|
28
|
+
/**
|
|
29
|
+
* Provider key (lower case) → the adapter names the registry declares for it,
|
|
30
|
+
* from `connectionAdapters` / `credentialAdapters` on manifests and operations,
|
|
31
|
+
* the shapes the builder reads. The wildcard provider `*` is not indexed: it
|
|
32
|
+
* accepts any connection, so it never identifies one adapter.
|
|
33
|
+
*/
|
|
34
|
+
export declare function registryAdaptersByProvider(manifests: readonly NodeManifest[]): Map<string, Set<string>>;
|
|
35
|
+
export declare function buildConnectionIndex(connections: readonly WorkspaceConnection[], options?: {
|
|
36
|
+
remoteDefinitions?: readonly unknown[];
|
|
37
|
+
registry?: readonly NodeManifest[];
|
|
38
|
+
}): ConnectionIndex;
|
|
39
|
+
/** One line per unresolved name, saying what to do. */
|
|
40
|
+
export declare function explainUnresolved(names: readonly string[], index: ConnectionIndex): string[];
|
|
41
|
+
/**
|
|
42
|
+
* A resolver that accepts every name, for `validate --offline`: the reference
|
|
43
|
+
* marks the name instead of pointing at a real connection.
|
|
44
|
+
*/
|
|
45
|
+
export declare function placeholderRef(name: string): ConnectionRef;
|
|
46
|
+
/**
|
|
47
|
+
* The part of a connectionId → name map that lifting `definitions` needs: the
|
|
48
|
+
* ids the definitions bind, plus every other id that shares one of their names,
|
|
49
|
+
* so a name two connections have is still recognised as ambiguous. The service
|
|
50
|
+
* caps the map it accepts (500 entries), and a workspace may hold more.
|
|
51
|
+
*/
|
|
52
|
+
export declare function namesForDefinitions(namesById: Readonly<Record<string, string>>, definitions: readonly unknown[]): Record<string, string>;
|
|
53
|
+
/** The subset of `refs` that `names` asks for: what a lowering actually resolved. */
|
|
54
|
+
export declare function refsForNames(refs: Readonly<Record<string, ConnectionRef>>, names: Iterable<string>): Record<string, ConnectionRef>;
|
|
55
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../src/code-first/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IACpC,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAmBD,6DAA6D;AAC7D,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,SAAS,OAAO,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAsB/F;AAaD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,SAAS,YAAY,EAAE,GACjC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAoB1B;AAMD,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,SAAS,mBAAmB,EAAE,EAC3C,OAAO,GAAE;IACP,iBAAiB,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACvC,QAAQ,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CAC/B,GACL,eAAe,CAmDjB;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,EAAE,CAO5F;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC3C,WAAW,EAAE,SAAS,OAAO,EAAE,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWxB;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,EAC7C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GACtB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAO/B"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connection names in code (`connection: 'slack-ops'`) resolve to the
|
|
3
|
+
* `{ connectionId, adapter }` references a node stores (spec 07 §3 rule 7, §6).
|
|
4
|
+
*
|
|
5
|
+
* The id comes from the workspace's connections, matched by name. The adapter
|
|
6
|
+
* is the name of the node's connection slot, which a connection name alone does
|
|
7
|
+
* not tell, so it is taken, in order, from:
|
|
8
|
+
* 1. the adapter the remote versions of the pushed workflows already bind that
|
|
9
|
+
* connection to (exact for every workflow that was pulled), then
|
|
10
|
+
* 2. the one adapter in the node registry whose provider is the connection's
|
|
11
|
+
* provider.
|
|
12
|
+
* When neither gives exactly one answer the name is left unresolved and the CLI
|
|
13
|
+
* says why; the code can then bind the connection by id with
|
|
14
|
+
* `connections: [{ connectionId, adapter }]`.
|
|
15
|
+
*/
|
|
16
|
+
import { operationsOf } from '@fluidgrids/workflows/ir';
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function setOwn(target, key, value) {
|
|
21
|
+
Object.defineProperty(target, key, {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function getOwn(record, key) {
|
|
29
|
+
return Object.hasOwn(record, key) ? record[key] : undefined;
|
|
30
|
+
}
|
|
31
|
+
/** connectionId → every adapter a definition binds it to. */
|
|
32
|
+
export function adaptersInDefinitions(definitions) {
|
|
33
|
+
const out = new Map();
|
|
34
|
+
for (const definition of definitions) {
|
|
35
|
+
const data = isRecord(definition) && isRecord(definition['data']) ? definition['data'] : {};
|
|
36
|
+
const nodes = Array.isArray(data['nodes']) ? data['nodes'] : [];
|
|
37
|
+
for (const node of nodes) {
|
|
38
|
+
const args = isRecord(node) && isRecord(node['args']) ? node['args'] : undefined;
|
|
39
|
+
const refs = Array.isArray(args?.['connections']) ? args['connections'] : [];
|
|
40
|
+
for (const ref of refs) {
|
|
41
|
+
if (isRecord(ref) &&
|
|
42
|
+
typeof ref['connectionId'] === 'string' &&
|
|
43
|
+
typeof ref['adapter'] === 'string') {
|
|
44
|
+
const set = out.get(ref['connectionId']) ?? new Set();
|
|
45
|
+
set.add(ref['adapter']);
|
|
46
|
+
out.set(ref['connectionId'], set);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function adapterDeclarations(value) {
|
|
54
|
+
if (!Array.isArray(value))
|
|
55
|
+
return [];
|
|
56
|
+
return value
|
|
57
|
+
.filter(isRecord)
|
|
58
|
+
.map((entry) => ({
|
|
59
|
+
name: typeof entry['name'] === 'string' ? entry['name'].trim() : '',
|
|
60
|
+
provider: typeof entry['provider'] === 'string' ? entry['provider'].trim() : '',
|
|
61
|
+
}))
|
|
62
|
+
.filter((entry) => entry.name !== '' && entry.provider !== '');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Provider key (lower case) → the adapter names the registry declares for it,
|
|
66
|
+
* from `connectionAdapters` / `credentialAdapters` on manifests and operations,
|
|
67
|
+
* the shapes the builder reads. The wildcard provider `*` is not indexed: it
|
|
68
|
+
* accepts any connection, so it never identifies one adapter.
|
|
69
|
+
*/
|
|
70
|
+
export function registryAdaptersByProvider(manifests) {
|
|
71
|
+
const out = new Map();
|
|
72
|
+
const add = (declarations) => {
|
|
73
|
+
for (const { name, provider } of declarations) {
|
|
74
|
+
if (provider === '*')
|
|
75
|
+
continue;
|
|
76
|
+
const key = provider.toLowerCase();
|
|
77
|
+
const set = out.get(key) ?? new Set();
|
|
78
|
+
set.add(name);
|
|
79
|
+
out.set(key, set);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
for (const manifest of manifests) {
|
|
83
|
+
add(adapterDeclarations(manifest['connectionAdapters']));
|
|
84
|
+
add(adapterDeclarations(manifest['credentialAdapters']));
|
|
85
|
+
for (const operation of operationsOf(manifest)) {
|
|
86
|
+
add(adapterDeclarations(operation['connectionAdapters']));
|
|
87
|
+
add(adapterDeclarations(operation['credentialAdapters']));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function only(set) {
|
|
93
|
+
return set && set.size === 1 ? [...set][0] : undefined;
|
|
94
|
+
}
|
|
95
|
+
export function buildConnectionIndex(connections, options = {}) {
|
|
96
|
+
const bound = adaptersInDefinitions(options.remoteDefinitions ?? []);
|
|
97
|
+
const byProvider = registryAdaptersByProvider(options.registry ?? []);
|
|
98
|
+
const byName = new Map();
|
|
99
|
+
const namesById = {};
|
|
100
|
+
for (const connection of connections) {
|
|
101
|
+
byName.set(connection.name, [...(byName.get(connection.name) ?? []), connection]);
|
|
102
|
+
setOwn(namesById, connection.id, connection.name);
|
|
103
|
+
}
|
|
104
|
+
const refs = {};
|
|
105
|
+
const problems = {};
|
|
106
|
+
for (const [name, matches] of [...byName].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
107
|
+
const [connection] = matches;
|
|
108
|
+
if (matches.length > 1 || !connection) {
|
|
109
|
+
setOwn(problems, name, `${matches.length} connections are named "${name}"; rename one, or bind by id with connections: [{ connectionId, adapter }]`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const used = bound.get(connection.id);
|
|
113
|
+
if (used && used.size > 1) {
|
|
114
|
+
setOwn(problems, name, `"${name}" is bound to several adapters (${[...used].sort().join(', ')}); bind it by id with connections: [{ connectionId, adapter }]`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const adapter = only(used) ??
|
|
118
|
+
(connection.providerKey
|
|
119
|
+
? only(byProvider.get(connection.providerKey.toLowerCase()))
|
|
120
|
+
: undefined);
|
|
121
|
+
if (adapter === undefined) {
|
|
122
|
+
const candidates = connection.providerKey
|
|
123
|
+
? [...(byProvider.get(connection.providerKey.toLowerCase()) ?? [])].sort()
|
|
124
|
+
: [];
|
|
125
|
+
setOwn(problems, name, candidates.length > 1
|
|
126
|
+
? `"${name}" (provider ${connection.providerKey}) fits several adapters (${candidates.join(', ')}); bind it by id with connections: [{ connectionId: '${connection.id}', adapter }]`
|
|
127
|
+
: `no node declares an adapter for "${name}" (provider ${connection.providerKey ?? 'unknown'}); bind it by id with connections: [{ connectionId: '${connection.id}', adapter }]`);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
setOwn(refs, name, { connectionId: connection.id, adapter });
|
|
131
|
+
}
|
|
132
|
+
return { refs, problems, namesById };
|
|
133
|
+
}
|
|
134
|
+
/** One line per unresolved name, saying what to do. */
|
|
135
|
+
export function explainUnresolved(names, index) {
|
|
136
|
+
return [...names].sort().map((name) => {
|
|
137
|
+
const problem = getOwn(index.problems, name);
|
|
138
|
+
return problem
|
|
139
|
+
? `${name}: ${problem}`
|
|
140
|
+
: `${name}: no connection with this name exists in the workspace; create it first`;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A resolver that accepts every name, for `validate --offline`: the reference
|
|
145
|
+
* marks the name instead of pointing at a real connection.
|
|
146
|
+
*/
|
|
147
|
+
export function placeholderRef(name) {
|
|
148
|
+
return { connectionId: `unresolved:${name}`, adapter: 'unresolved' };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The part of a connectionId → name map that lifting `definitions` needs: the
|
|
152
|
+
* ids the definitions bind, plus every other id that shares one of their names,
|
|
153
|
+
* so a name two connections have is still recognised as ambiguous. The service
|
|
154
|
+
* caps the map it accepts (500 entries), and a workspace may hold more.
|
|
155
|
+
*/
|
|
156
|
+
export function namesForDefinitions(namesById, definitions) {
|
|
157
|
+
const used = new Set();
|
|
158
|
+
for (const id of adaptersInDefinitions(definitions).keys()) {
|
|
159
|
+
const name = getOwn(namesById, id);
|
|
160
|
+
if (name !== undefined)
|
|
161
|
+
used.add(name);
|
|
162
|
+
}
|
|
163
|
+
const out = {};
|
|
164
|
+
for (const [id, name] of Object.entries(namesById)) {
|
|
165
|
+
if (used.has(name))
|
|
166
|
+
setOwn(out, id, name);
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
/** The subset of `refs` that `names` asks for: what a lowering actually resolved. */
|
|
171
|
+
export function refsForNames(refs, names) {
|
|
172
|
+
const out = {};
|
|
173
|
+
for (const name of names) {
|
|
174
|
+
const ref = getOwn(refs, name);
|
|
175
|
+
if (ref !== undefined)
|
|
176
|
+
setOwn(out, name, ref);
|
|
177
|
+
}
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../src/code-first/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAaxD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAA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AC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACnD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,YAAY,CAC1B,IAA6C,EAC7C,KAAuB;IAEvB,MAAM,GAAG,GAAkC,EAAE,CAAC;IAC9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The code-first commands (spec 07 §7, Phase A): `init`, `codegen`, `pull`,
|
|
3
|
+
* `push`, `diff`, `validate`, plus `import` (a new workflow from one file,
|
|
4
|
+
* through the service's import path) and `interface`.
|
|
5
|
+
*
|
|
6
|
+
* Product-local rather than in `@burdenoff/cli-sdk`: they depend on
|
|
7
|
+
* `@fluidgrids/workflows` (esbuild, Prettier, QuickJS), which the other product
|
|
8
|
+
* CLIs built on cli-sdk must not pull in. The implementations load on first
|
|
9
|
+
* use (see `register.ts`), so the other commands do not pay for them.
|
|
10
|
+
*/
|
|
11
|
+
import type { CliModule } from '@burdenoff/cli-sdk/core';
|
|
12
|
+
declare const codeFirstModule: CliModule;
|
|
13
|
+
export default codeFirstModule;
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/code-first/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAczD,QAAA,MAAM,eAAe,EAAE,SAgBtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The code-first commands (spec 07 §7, Phase A): `init`, `codegen`, `pull`,
|
|
3
|
+
* `push`, `diff`, `validate`, plus `import` (a new workflow from one file,
|
|
4
|
+
* through the service's import path) and `interface`.
|
|
5
|
+
*
|
|
6
|
+
* Product-local rather than in `@burdenoff/cli-sdk`: they depend on
|
|
7
|
+
* `@fluidgrids/workflows` (esbuild, Prettier, QuickJS), which the other product
|
|
8
|
+
* CLIs built on cli-sdk must not pull in. The implementations load on first
|
|
9
|
+
* use (see `register.ts`), so the other commands do not pay for them.
|
|
10
|
+
*/
|
|
11
|
+
import { registerCodegen, registerDiff, registerImport, registerInit, registerInterface, registerPull, registerPush, registerValidate, } from './register.js';
|
|
12
|
+
import { createCommandEnv } from './shared.js';
|
|
13
|
+
const codeFirstModule = {
|
|
14
|
+
id: 'fluidgrids-code-first',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
displayName: 'FluidGrids code-first workflows',
|
|
17
|
+
dependsOn: ['auth', 'fluidgrids'],
|
|
18
|
+
register(program, ctx) {
|
|
19
|
+
const env = createCommandEnv(ctx);
|
|
20
|
+
registerInit(program, env);
|
|
21
|
+
registerCodegen(program, env);
|
|
22
|
+
registerPull(program, env);
|
|
23
|
+
registerPush(program, env);
|
|
24
|
+
registerDiff(program, env);
|
|
25
|
+
registerValidate(program, env);
|
|
26
|
+
registerImport(program, env);
|
|
27
|
+
registerInterface(program, env);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export default codeFirstModule;
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/code-first/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,eAAe,GAAc;IACjC,EAAE,EAAE,uBAAuB;IAC3B,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,iCAAiC;IAC9C,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,GAAG;QACnB,MAAM,GAAG,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAClC,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC9B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC3B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC/B,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,iBAAiB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;CACF,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower the project's workflows to IR v2 (spec 07 §4, tier 1):
|
|
3
|
+
* - TypeScript: `lower()` from `@fluidgrids/workflows/roundtrip`, with the
|
|
4
|
+
* pinned esbuild and the Node `vm` evaluator (the developer's own code);
|
|
5
|
+
* - Python: `python -m fluidgrids_workflows lower` from the installed
|
|
6
|
+
* `fluidgrids-workflows` package (see `python.ts`);
|
|
7
|
+
* - JSON: canvas workflows kept as the export envelope are read as they are.
|
|
8
|
+
*/
|
|
9
|
+
import type { ConnectionRef } from '@fluidgrids/workflows/ir';
|
|
10
|
+
import { type Project, type WorkflowFormat } from './project.js';
|
|
11
|
+
export interface LocalWorkflow {
|
|
12
|
+
key: string;
|
|
13
|
+
format: WorkflowFormat;
|
|
14
|
+
/** Project-relative file the workflow is defined in. */
|
|
15
|
+
path: string;
|
|
16
|
+
definition: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
export interface LoweredProject {
|
|
19
|
+
/** `buildId` of the TypeScript bundle, when the project has TypeScript workflows. */
|
|
20
|
+
buildId?: string;
|
|
21
|
+
/** `sourceHash` of the lowered sources, when the project has code workflows. */
|
|
22
|
+
sourceHash?: string;
|
|
23
|
+
workflows: LocalWorkflow[];
|
|
24
|
+
/** Notes about the lowering (for example SDK disagreements), one line each. */
|
|
25
|
+
warnings: string[];
|
|
26
|
+
}
|
|
27
|
+
export interface LowerProjectOptions {
|
|
28
|
+
/** How connection names resolve. A function is called once per name. */
|
|
29
|
+
connections: (name: string) => ConnectionRef | undefined;
|
|
30
|
+
/** Explains unresolved names; one line each. */
|
|
31
|
+
explainUnresolved: (names: readonly string[]) => string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A failure of `lower()` as the CLI reports it: builder mistakes, determinism
|
|
35
|
+
* violations, size limits and esbuild compile errors are the user's to fix;
|
|
36
|
+
* anything else is rethrown as it is.
|
|
37
|
+
*/
|
|
38
|
+
export declare function lowerFailure(error: unknown, what: string): unknown;
|
|
39
|
+
export declare function lowerProject(project: Project, options: LowerProjectOptions & {
|
|
40
|
+
connectionNames: readonly string[];
|
|
41
|
+
}): Promise<LoweredProject>;
|
|
42
|
+
//# sourceMappingURL=lowering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lowering.d.ts","sourceRoot":"","sources":["../../src/code-first/lowering.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAK9D,OAAO,EAML,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAOtB,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,cAAc,CAAC;IACvB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,cAAc;IAC7B,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,wEAAwE;IACxE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;IACzD,gDAAgD;IAChD,iBAAiB,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;CAC3D;AAMD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKlE;AA8CD,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,mBAAmB,GAAG;IAAE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACpE,OAAO,CAAC,cAAc,CAAC,CAuEzB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lower the project's workflows to IR v2 (spec 07 §4, tier 1):
|
|
3
|
+
* - TypeScript: `lower()` from `@fluidgrids/workflows/roundtrip`, with the
|
|
4
|
+
* pinned esbuild and the Node `vm` evaluator (the developer's own code);
|
|
5
|
+
* - Python: `python -m fluidgrids_workflows lower` from the installed
|
|
6
|
+
* `fluidgrids-workflows` package (see `python.ts`);
|
|
7
|
+
* - JSON: canvas workflows kept as the export envelope are read as they are.
|
|
8
|
+
*/
|
|
9
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
10
|
+
import { BuilderError, UnresolvedConnectionsError } from '@fluidgrids/workflows';
|
|
11
|
+
import { parseWorkflowDocument } from '@fluidgrids/workflows/ir';
|
|
12
|
+
import { lower, LowerError } from '@fluidgrids/workflows/roundtrip';
|
|
13
|
+
import { posix } from 'path';
|
|
14
|
+
import { isJsonWorkflow, isLoweringInput, isWorkflowModule, listSourcePaths, readProjectFiles, } from './project.js';
|
|
15
|
+
import { lowerPython, PythonUnresolvedConnectionsError, resolvePythonInterpreter, } from './python.js';
|
|
16
|
+
function isBuildFailure(error) {
|
|
17
|
+
return error instanceof Error && 'errors' in error && Array.isArray(error.errors);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A failure of `lower()` as the CLI reports it: builder mistakes, determinism
|
|
21
|
+
* violations, size limits and esbuild compile errors are the user's to fix;
|
|
22
|
+
* anything else is rethrown as it is.
|
|
23
|
+
*/
|
|
24
|
+
export function lowerFailure(error, what) {
|
|
25
|
+
if (error instanceof LowerError || error instanceof BuilderError || isBuildFailure(error)) {
|
|
26
|
+
return new CliUserError(`Lowering ${what} failed: ${error.message}`);
|
|
27
|
+
}
|
|
28
|
+
return error;
|
|
29
|
+
}
|
|
30
|
+
function unresolvedError(names, explain) {
|
|
31
|
+
return new CliUserError(`The code names connections that do not resolve in this workspace: ${[...names].sort().join(', ')}`, { hint: explain(names).join('\n') });
|
|
32
|
+
}
|
|
33
|
+
function jsonWorkflows(project, paths) {
|
|
34
|
+
return readProjectFiles(project.root, paths).map((file) => {
|
|
35
|
+
const parsed = parseWorkflowDocument(file.content);
|
|
36
|
+
if (!parsed) {
|
|
37
|
+
throw new CliUserError(`${file.path} is not a workflow export or definition.`);
|
|
38
|
+
}
|
|
39
|
+
const stem = posix.basename(file.path, '.json');
|
|
40
|
+
const declared = typeof parsed.definitionJson['key'] === 'string' ? parsed.definitionJson['key'] : null;
|
|
41
|
+
const key = parsed.workflowKey ?? declared ?? stem;
|
|
42
|
+
return { key, format: 'json', path: file.path, definition: parsed.definitionJson };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** The full name → reference map a Python lowering receives. */
|
|
46
|
+
function connectionMap(names, resolve) {
|
|
47
|
+
const out = {};
|
|
48
|
+
for (const name of names) {
|
|
49
|
+
const ref = resolve(name);
|
|
50
|
+
if (ref) {
|
|
51
|
+
Object.defineProperty(out, name, {
|
|
52
|
+
value: ref,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export async function lowerProject(project, options) {
|
|
62
|
+
const paths = listSourcePaths(project.root);
|
|
63
|
+
const language = project.config.language;
|
|
64
|
+
const entries = paths.filter((path) => isWorkflowModule(path, language));
|
|
65
|
+
const workflows = jsonWorkflows(project, paths.filter(isJsonWorkflow));
|
|
66
|
+
const result = { workflows, warnings: [] };
|
|
67
|
+
if (entries.length > 0) {
|
|
68
|
+
if (language === 'ts') {
|
|
69
|
+
const files = readProjectFiles(project.root, paths.filter((path) => isLoweringInput(path, language)));
|
|
70
|
+
try {
|
|
71
|
+
const lowered = await lower(files, { entries, connections: options.connections });
|
|
72
|
+
result.buildId = lowered.buildId;
|
|
73
|
+
result.sourceHash = lowered.sourceHash;
|
|
74
|
+
for (const workflow of lowered.workflows) {
|
|
75
|
+
workflows.push({
|
|
76
|
+
key: workflow.key,
|
|
77
|
+
format: 'ts',
|
|
78
|
+
path: workflow.module,
|
|
79
|
+
definition: workflow.definition,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof UnresolvedConnectionsError) {
|
|
85
|
+
throw unresolvedError(error.names, options.explainUnresolved);
|
|
86
|
+
}
|
|
87
|
+
throw lowerFailure(error, 'the TypeScript workflows');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
try {
|
|
92
|
+
const lowered = await lowerPython({
|
|
93
|
+
python: resolvePythonInterpreter(project.root, project.config.python),
|
|
94
|
+
root: project.root,
|
|
95
|
+
entries,
|
|
96
|
+
connections: connectionMap(options.connectionNames, options.connections),
|
|
97
|
+
});
|
|
98
|
+
result.sourceHash = lowered.sourceHash;
|
|
99
|
+
result.warnings.push(...lowered.warnings);
|
|
100
|
+
for (const workflow of lowered.workflows) {
|
|
101
|
+
workflows.push({
|
|
102
|
+
key: workflow.key,
|
|
103
|
+
format: 'py',
|
|
104
|
+
path: workflow.module,
|
|
105
|
+
definition: workflow.definition,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error instanceof PythonUnresolvedConnectionsError) {
|
|
111
|
+
throw unresolvedError(error.names, options.explainUnresolved);
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const seen = new Map();
|
|
118
|
+
for (const workflow of workflows) {
|
|
119
|
+
const previous = seen.get(workflow.key);
|
|
120
|
+
if (previous) {
|
|
121
|
+
throw new CliUserError(`Workflow key "${workflow.key}" is defined twice (${previous} and ${workflow.path}).`, { hint: 'Delete one of the files; `fluidgrids pull --as` replaces the other format.' });
|
|
122
|
+
}
|
|
123
|
+
seen.set(workflow.key, workflow.path);
|
|
124
|
+
}
|
|
125
|
+
workflows.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=lowering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lowering.js","sourceRoot":"","sources":["../../src/code-first/lowering.ts"],"names":[],"mappings":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