@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,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids import <file> [--key k] [--name n]`: create a NEW workflow (a
|
|
3
|
+
* DRAFT) from one file, the way the builder's import dialog does (spec 07 §1,
|
|
4
|
+
* §8), through `importWorkflow`:
|
|
5
|
+
*
|
|
6
|
+
* - `.json`: an export envelope or a bare definition, sent as
|
|
7
|
+
* `source: { format: JSON }` so the service reads it exactly as Git restore does;
|
|
8
|
+
* - `.ts`: a tier-1 module of a project, sent as `source: { format: TYPESCRIPT }`
|
|
9
|
+
* with the files it imports and the connection names resolved, so the service
|
|
10
|
+
* lowers it in its own isolate;
|
|
11
|
+
* - `.py`: lowered by the installed `fluidgrids-workflows` Python package and sent
|
|
12
|
+
* as `definitionJson` (the service does not run Python).
|
|
13
|
+
*
|
|
14
|
+
* The file is lowered locally first as well, and the stored version's `irHash`
|
|
15
|
+
* is compared with the local one, so a disagreement between the CLI and the
|
|
16
|
+
* service's lowering shows up immediately. An existing workflow key is refused
|
|
17
|
+
* by the service; `fluidgrids push` creates new versions of existing workflows.
|
|
18
|
+
*/
|
|
19
|
+
import { existsSync, readFileSync } from 'fs';
|
|
20
|
+
import { basename, dirname, extname, relative, resolve, sep } from 'path';
|
|
21
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
22
|
+
import { irHash, parseWorkflowDocument } from '@fluidgrids/workflows/ir';
|
|
23
|
+
import { lower } from '@fluidgrids/workflows/roundtrip';
|
|
24
|
+
import { UnresolvedConnectionsError } from '@fluidgrids/workflows';
|
|
25
|
+
import { explainUnresolved, refsForNames } from '../connections.js';
|
|
26
|
+
import { lowerFailure } from '../lowering.js';
|
|
27
|
+
import { assertProjectWorkspace, ACTIVITIES_DIR, GENERATED_DIR, findProjectRoot, isLoweringInput, listSourcePaths, loadProject, readProjectFiles, WORKFLOWS_DIR, } from '../project.js';
|
|
28
|
+
import { lowerPython, PythonUnresolvedConnectionsError, resolvePythonInterpreter, } from '../python.js';
|
|
29
|
+
import { projectConnectionIndex } from '../remote.js';
|
|
30
|
+
import { emit } from '../shared.js';
|
|
31
|
+
function nameOf(definition, fallback) {
|
|
32
|
+
const name = definition['name'];
|
|
33
|
+
return typeof name === 'string' && name.trim() !== '' ? name : fallback;
|
|
34
|
+
}
|
|
35
|
+
function common(options) {
|
|
36
|
+
return {
|
|
37
|
+
...(options.description ? { description: options.description } : {}),
|
|
38
|
+
...(options.allowMissingNodes ? { allowMissingNodes: true } : {}),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function prepareJson(path, absolute, text, options) {
|
|
42
|
+
const parsed = parseWorkflowDocument(text);
|
|
43
|
+
if (!parsed)
|
|
44
|
+
throw new CliUserError(`${path} is not a workflow export or definition.`);
|
|
45
|
+
const declared = parsed.definitionJson['key'];
|
|
46
|
+
const key = options.key ??
|
|
47
|
+
parsed.workflowKey ??
|
|
48
|
+
(typeof declared === 'string' && declared !== '' ? declared : undefined);
|
|
49
|
+
if (!key) {
|
|
50
|
+
throw new CliUserError(`${path} names no workflow key.`, { hint: 'Pass --key <key>.' });
|
|
51
|
+
}
|
|
52
|
+
const name = options.name ?? nameOf(parsed.definitionJson, key);
|
|
53
|
+
const source = {
|
|
54
|
+
format: 'JSON',
|
|
55
|
+
files: [{ path: `${WORKFLOWS_DIR}/${basename(absolute)}`, content: text }],
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
format: 'JSON',
|
|
59
|
+
key,
|
|
60
|
+
name,
|
|
61
|
+
definition: parsed.definitionJson,
|
|
62
|
+
input: { name, workflowKey: key, source, ...common(options) },
|
|
63
|
+
warnings: [],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** A resolver over the index that records every name it resolved. */
|
|
67
|
+
function recordingResolver(index) {
|
|
68
|
+
const used = new Set();
|
|
69
|
+
return {
|
|
70
|
+
used,
|
|
71
|
+
resolve: (name) => {
|
|
72
|
+
if (!Object.hasOwn(index.refs, name))
|
|
73
|
+
return undefined;
|
|
74
|
+
used.add(name);
|
|
75
|
+
return index.refs[name];
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function unresolved(names, index) {
|
|
80
|
+
return new CliUserError(`The code names connections that do not resolve in this workspace: ${[...names].sort().join(', ')}`, { hint: explainUnresolved(names, index).join('\n') });
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The workflow among `found` that the import is for, as the service chooses:
|
|
84
|
+
* the only one (which `--key` then renames), or among several the one `--key` names.
|
|
85
|
+
*/
|
|
86
|
+
function chooseWorkflow(found, file, key) {
|
|
87
|
+
const chosen = found.length === 1 ? found[0] : found.find((item) => item.key === key);
|
|
88
|
+
if (!chosen) {
|
|
89
|
+
throw new CliUserError(found.length === 0
|
|
90
|
+
? `${file} defines no workflow.`
|
|
91
|
+
: key
|
|
92
|
+
? `${file} defines no workflow "${key}" (found: ${found.map((item) => item.key).join(', ')}).`
|
|
93
|
+
: `${file} defines ${found.length} workflows (${found.map((item) => item.key).join(', ')}); pass --key to choose one.`);
|
|
94
|
+
}
|
|
95
|
+
return chosen;
|
|
96
|
+
}
|
|
97
|
+
async function prepareTypeScript(env, project, path, options) {
|
|
98
|
+
const index = await projectConnectionIndex(env.api, project, options.key ? [options.key] : []);
|
|
99
|
+
const inputs = readProjectFiles(project.root, listSourcePaths(project.root).filter((candidate) => isLoweringInput(candidate, 'ts')));
|
|
100
|
+
const resolver = recordingResolver(index);
|
|
101
|
+
let lowered;
|
|
102
|
+
try {
|
|
103
|
+
lowered = await lower(inputs, { entries: [path], connections: resolver.resolve });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof UnresolvedConnectionsError)
|
|
107
|
+
throw unresolved(error.names, index);
|
|
108
|
+
throw lowerFailure(error, path);
|
|
109
|
+
}
|
|
110
|
+
const workflow = chooseWorkflow(lowered.workflows, path, options.key);
|
|
111
|
+
// The module itself, the code it may import (activities and the generated
|
|
112
|
+
// clients) and the workflow's own sidecars; other workflow modules stay out.
|
|
113
|
+
// `lower()` has already refused sources over its limit (1 MiB, the service's too).
|
|
114
|
+
const files = inputs.filter((file) => file.path === path ||
|
|
115
|
+
file.path.startsWith(`${ACTIVITIES_DIR}/`) ||
|
|
116
|
+
file.path.startsWith(`${GENERATED_DIR}/`) ||
|
|
117
|
+
file.path === `${WORKFLOWS_DIR}/${workflow.key}.layout.json` ||
|
|
118
|
+
file.path === `${WORKFLOWS_DIR}/${workflow.key}.pinned.json`);
|
|
119
|
+
const definition = workflow.definition;
|
|
120
|
+
const key = options.key ?? workflow.key;
|
|
121
|
+
const name = options.name ?? nameOf(definition, key);
|
|
122
|
+
// Only the names the code uses: the service caps the map (500 names), and the
|
|
123
|
+
// rest of the workspace's connections are none of this import's business.
|
|
124
|
+
const source = {
|
|
125
|
+
format: 'TYPESCRIPT',
|
|
126
|
+
files,
|
|
127
|
+
connections: refsForNames(index.refs, resolver.used),
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
format: 'TYPESCRIPT',
|
|
131
|
+
key,
|
|
132
|
+
name,
|
|
133
|
+
definition: { ...definition, key },
|
|
134
|
+
input: { name, workflowKey: key, source, ...common(options) },
|
|
135
|
+
warnings: [],
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function preparePython(env, project, path, options) {
|
|
139
|
+
const index = await projectConnectionIndex(env.api, project, options.key ? [options.key] : []);
|
|
140
|
+
let lowered;
|
|
141
|
+
try {
|
|
142
|
+
lowered = await lowerPython({
|
|
143
|
+
python: resolvePythonInterpreter(project.root, project.config.python),
|
|
144
|
+
root: project.root,
|
|
145
|
+
entries: [path],
|
|
146
|
+
connections: { ...index.refs },
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
if (error instanceof PythonUnresolvedConnectionsError)
|
|
151
|
+
throw unresolved(error.names, index);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
const workflow = chooseWorkflow(lowered.workflows, path, options.key);
|
|
155
|
+
const key = options.key ?? workflow.key;
|
|
156
|
+
const name = options.name ?? nameOf(workflow.definition, key);
|
|
157
|
+
const definition = { ...workflow.definition, key };
|
|
158
|
+
return {
|
|
159
|
+
format: 'PYTHON',
|
|
160
|
+
key,
|
|
161
|
+
name,
|
|
162
|
+
definition,
|
|
163
|
+
input: { name, workflowKey: key, definitionJson: definition, ...common(options) },
|
|
164
|
+
warnings: lowered.warnings,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** The project a `.ts` / `.py` file belongs to, and the file's project path. */
|
|
168
|
+
function projectOf(absolute) {
|
|
169
|
+
const root = findProjectRoot(dirname(absolute));
|
|
170
|
+
if (!root) {
|
|
171
|
+
throw new CliUserError(`${absolute} is not inside a code-first project.`, {
|
|
172
|
+
hint: 'Run `fluidgrids init` in the project directory first.',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const project = loadProject(root, root);
|
|
176
|
+
const path = relative(root, absolute).split(sep).join('/');
|
|
177
|
+
if (!path.startsWith(`${WORKFLOWS_DIR}/`)) {
|
|
178
|
+
throw new CliUserError(`${path} is not under ${WORKFLOWS_DIR}/ of the project at ${root}.`);
|
|
179
|
+
}
|
|
180
|
+
return { project, path };
|
|
181
|
+
}
|
|
182
|
+
export async function runImport(env, file, options) {
|
|
183
|
+
const absolute = resolve(env.cwd(), file);
|
|
184
|
+
if (!existsSync(absolute))
|
|
185
|
+
throw new CliUserError(`${file} does not exist.`);
|
|
186
|
+
const extension = extname(absolute).toLowerCase();
|
|
187
|
+
let prepared;
|
|
188
|
+
if (extension === '.json') {
|
|
189
|
+
prepared = prepareJson(file, absolute, readFileSync(absolute, 'utf8'), options);
|
|
190
|
+
}
|
|
191
|
+
else if (extension === '.ts' || extension === '.py') {
|
|
192
|
+
const { project, path } = projectOf(absolute);
|
|
193
|
+
assertProjectWorkspace(env, project);
|
|
194
|
+
if ((extension === '.ts') !== (project.config.language === 'ts')) {
|
|
195
|
+
throw new CliUserError(`${path} is ${extension === '.ts' ? 'TypeScript' : 'Python'}, but the project language is ${project.config.language}.`);
|
|
196
|
+
}
|
|
197
|
+
prepared =
|
|
198
|
+
extension === '.ts'
|
|
199
|
+
? await prepareTypeScript(env, project, path, options)
|
|
200
|
+
: await preparePython(env, project, path, options);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
throw new CliUserError(`Cannot import ${file}: expected a .json, .ts or .py file.`);
|
|
204
|
+
}
|
|
205
|
+
const saved = await env.api.importWorkflow(prepared.input);
|
|
206
|
+
const stored = await env.api.exportWorkflow(saved.workflowKey, saved.version);
|
|
207
|
+
const local = irHash(prepared.definition);
|
|
208
|
+
const storedHash = irHash(stored.definitionJson);
|
|
209
|
+
const warnings = [...prepared.warnings, ...saved.validationWarnings];
|
|
210
|
+
// The service may rename the stored definition's key; compare the content with the key aligned.
|
|
211
|
+
const matches = storedHash === local ||
|
|
212
|
+
irHash({ ...stored.definitionJson, key: prepared.definition['key'] }) === local;
|
|
213
|
+
if (!matches) {
|
|
214
|
+
warnings.push(`the stored version's irHash ${storedHash} differs from the local ${local}; run \`fluidgrids diff ${saved.workflowKey}\` to see how`);
|
|
215
|
+
}
|
|
216
|
+
const result = {
|
|
217
|
+
file,
|
|
218
|
+
format: prepared.format,
|
|
219
|
+
workflowKey: saved.workflowKey,
|
|
220
|
+
version: saved.version,
|
|
221
|
+
status: saved.status,
|
|
222
|
+
irHash: local,
|
|
223
|
+
storedIrHash: storedHash,
|
|
224
|
+
matches,
|
|
225
|
+
warnings,
|
|
226
|
+
};
|
|
227
|
+
emit(env, options, result, {
|
|
228
|
+
headers: ['Workflow', 'Version', 'Status', 'From', 'Matches local'],
|
|
229
|
+
rows: [
|
|
230
|
+
[saved.workflowKey, saved.version, saved.status, prepared.format, matches ? 'yes' : 'no'],
|
|
231
|
+
],
|
|
232
|
+
}, warnings.map((warning) => `warning: ${warning}`));
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/code-first/commands/import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAsB,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAwB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,aAAa,GAEd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,gCAAgC,EAChC,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,c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QACb,YAAY,EAAE,UAAU;QACxB,OAAO;QACP,QAAQ;KACT,CAAC;IACF,IAAI,CACF,GAAG,EACH,OAAO,EACP,MAAM,EACN;QACE,OAAO,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC;QACnE,IAAI,EAAE;YACJ,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;SAC1F;KACF,EACD,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,OAAO,EAAE,CAAC,CACjD,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids init [dir] [--lang ts|py]`: scaffold a code-first project
|
|
3
|
+
* (spec 07 §7), sign in with the device-code flow when the CLI is not signed in
|
|
4
|
+
* and a person is at the terminal, and run codegen.
|
|
5
|
+
*
|
|
6
|
+
* In CI (no terminal, or `--no-login`) init never waits for a login: it
|
|
7
|
+
* scaffolds and prints the next steps. `FLUIDGRIDS_TOKEN` counts as signed in.
|
|
8
|
+
*/
|
|
9
|
+
import { type ProjectConfig, type ProjectLanguage } from '../project.js';
|
|
10
|
+
import { type CommandEnv, type OutputOptions } from '../shared.js';
|
|
11
|
+
export interface InitOptions extends OutputOptions {
|
|
12
|
+
lang?: string;
|
|
13
|
+
workspace?: string;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
codegen?: boolean;
|
|
16
|
+
login?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface InitResult {
|
|
19
|
+
root: string;
|
|
20
|
+
language: ProjectLanguage;
|
|
21
|
+
files: string[];
|
|
22
|
+
login: 'existing' | 'signed-in' | 'skipped' | 'needs-workspace';
|
|
23
|
+
codegen: 'written' | 'skipped' | 'needs-login' | 'needs-workspace' | 'failed';
|
|
24
|
+
next: string[];
|
|
25
|
+
}
|
|
26
|
+
/** An npm package name from a directory name. */
|
|
27
|
+
export declare function packageName(dir: string): string;
|
|
28
|
+
export declare function scaffoldFiles(dir: string, language: ProjectLanguage, config: ProjectConfig, productVersion: string): Array<{
|
|
29
|
+
path: string;
|
|
30
|
+
content: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function runInit(env: CommandEnv, dir: string | undefined, options: InitOptions): Promise<InitResult>;
|
|
33
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/code-first/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EAWL,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAGtB,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,UAAU,GAAG,WAAW,GAAG,SAAS,GAAG,iBAAiB,CAAC;IAChE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,iBAAiB,GAAG,QAAQ,CAAC;IAC9E,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,iDAAiD;AACjD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C;AAMD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,EACzB,MAAM,EAAE,aAAa,EACrB,cAAc,EAAE,MAAM,GACrB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAkE1C;AAED,wBAAsB,OAAO,CAC3B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAqFrB"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids init [dir] [--lang ts|py]`: scaffold a code-first project
|
|
3
|
+
* (spec 07 §7), sign in with the device-code flow when the CLI is not signed in
|
|
4
|
+
* and a person is at the terminal, and run codegen.
|
|
5
|
+
*
|
|
6
|
+
* In CI (no terminal, or `--no-login`) init never waits for a login: it
|
|
7
|
+
* scaffolds and prints the next steps. `FLUIDGRIDS_TOKEN` counts as signed in.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from 'fs';
|
|
10
|
+
import { basename, join, resolve } from 'path';
|
|
11
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
12
|
+
import { SDK_VERSION } from '@fluidgrids/workflows';
|
|
13
|
+
import { ACTIVITIES_DIR, CONFIG_FILE, CONFIG_FORMAT_VERSION, emptyLock, jsonText, LOCK_FILE, PROJECT_LANGUAGES, WORKFLOWS_DIR, writeProjectFile, } from '../project.js';
|
|
14
|
+
import { PYTHON_PACKAGE } from '../python.js';
|
|
15
|
+
import { describeError, emit, parseChoice, } from '../shared.js';
|
|
16
|
+
import { writeNodeClients } from './codegen.js';
|
|
17
|
+
/** An npm package name from a directory name. */
|
|
18
|
+
export function packageName(dir) {
|
|
19
|
+
const name = basename(dir)
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.replace(/[^a-z0-9._-]+/g, '-')
|
|
22
|
+
.replace(/^[-._]+|[-._]+$/g, '');
|
|
23
|
+
return name === '' ? 'fluidgrids-workflows-project' : name.slice(0, 214);
|
|
24
|
+
}
|
|
25
|
+
function cliRange(productVersion) {
|
|
26
|
+
return /^\d+\.\d+\.\d+$/.test(productVersion) ? `^${productVersion}` : 'latest';
|
|
27
|
+
}
|
|
28
|
+
export function scaffoldFiles(dir, language, config, productVersion) {
|
|
29
|
+
const name = packageName(dir);
|
|
30
|
+
const common = [
|
|
31
|
+
{ path: CONFIG_FILE, content: jsonText(config) },
|
|
32
|
+
{ path: LOCK_FILE, content: jsonText(emptyLock()) },
|
|
33
|
+
{ path: `${WORKFLOWS_DIR}/.gitkeep`, content: '' },
|
|
34
|
+
{ path: `${ACTIVITIES_DIR}/.gitkeep`, content: '' },
|
|
35
|
+
];
|
|
36
|
+
if (language === 'ts') {
|
|
37
|
+
return [
|
|
38
|
+
...common,
|
|
39
|
+
{
|
|
40
|
+
path: 'package.json',
|
|
41
|
+
content: jsonText({
|
|
42
|
+
name,
|
|
43
|
+
private: true,
|
|
44
|
+
type: 'module',
|
|
45
|
+
scripts: {
|
|
46
|
+
codegen: 'fluidgrids codegen',
|
|
47
|
+
pull: 'fluidgrids pull',
|
|
48
|
+
push: 'fluidgrids push',
|
|
49
|
+
typecheck: 'tsc --noEmit',
|
|
50
|
+
validate: 'fluidgrids validate --strict',
|
|
51
|
+
},
|
|
52
|
+
dependencies: { '@fluidgrids/workflows': SDK_VERSION },
|
|
53
|
+
devDependencies: {
|
|
54
|
+
'@fluidgrids/cli': cliRange(productVersion),
|
|
55
|
+
typescript: '^5.9.3',
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
path: 'tsconfig.json',
|
|
61
|
+
content: jsonText({
|
|
62
|
+
compilerOptions: {
|
|
63
|
+
target: 'ES2023',
|
|
64
|
+
module: 'ESNext',
|
|
65
|
+
moduleResolution: 'Bundler',
|
|
66
|
+
lib: ['ES2023'],
|
|
67
|
+
strict: true,
|
|
68
|
+
noEmit: true,
|
|
69
|
+
skipLibCheck: true,
|
|
70
|
+
resolveJsonModule: true,
|
|
71
|
+
isolatedModules: true,
|
|
72
|
+
},
|
|
73
|
+
include: [`${WORKFLOWS_DIR}/**/*.ts`, `${ACTIVITIES_DIR}/**/*.ts`, '.fluidgrids/**/*.ts'],
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
{ path: '.gitignore', content: 'node_modules/\ndist/\n*.log\n' },
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
return [
|
|
80
|
+
...common,
|
|
81
|
+
{
|
|
82
|
+
path: 'pyproject.toml',
|
|
83
|
+
content: [
|
|
84
|
+
'[project]',
|
|
85
|
+
`name = "${name}"`,
|
|
86
|
+
'version = "0.1.0"',
|
|
87
|
+
'requires-python = ">=3.11"',
|
|
88
|
+
`dependencies = ["${PYTHON_PACKAGE}"]`,
|
|
89
|
+
'',
|
|
90
|
+
].join('\n'),
|
|
91
|
+
},
|
|
92
|
+
{ path: '.gitignore', content: '.venv/\n__pycache__/\n*.pyc\n*.log\n' },
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
export async function runInit(env, dir, options) {
|
|
96
|
+
const root = resolve(env.cwd(), dir ?? '.');
|
|
97
|
+
const language = parseChoice(options.lang, '--lang', PROJECT_LANGUAGES) ?? 'ts';
|
|
98
|
+
const config = {
|
|
99
|
+
formatVersion: CONFIG_FORMAT_VERSION,
|
|
100
|
+
language,
|
|
101
|
+
defaultTaskQueue: 'managed',
|
|
102
|
+
...(options.workspace ? { workspaceId: options.workspace } : {}),
|
|
103
|
+
};
|
|
104
|
+
const files = scaffoldFiles(root, language, config, env.ctx.productVersion);
|
|
105
|
+
const existing = files.filter((file) => existsSync(join(root, ...file.path.split('/'))));
|
|
106
|
+
if (existing.length > 0 && !options.force) {
|
|
107
|
+
throw new CliUserError(`Refusing to overwrite: ${existing.map((file) => file.path).join(', ')}`, { hint: 'Pass --force to overwrite them, or run init in an empty directory.' });
|
|
108
|
+
}
|
|
109
|
+
for (const file of files)
|
|
110
|
+
writeProjectFile(root, file.path, file.content);
|
|
111
|
+
const project = { root, config, lock: emptyLock() };
|
|
112
|
+
const next = [];
|
|
113
|
+
let login = 'existing';
|
|
114
|
+
if (!env.ctx.auth.isAuthenticated()) {
|
|
115
|
+
if (options.login !== false && env.interactive()) {
|
|
116
|
+
const signedIn = await env.login(options.workspace);
|
|
117
|
+
login = signedIn.workspaceId ? 'signed-in' : 'needs-workspace';
|
|
118
|
+
if (!signedIn.workspaceId) {
|
|
119
|
+
for (const choice of signedIn.choices) {
|
|
120
|
+
console.log(` ${choice.name}: fluidgrids workspace set ${choice.id}`);
|
|
121
|
+
}
|
|
122
|
+
next.push('fluidgrids workspace set <id>');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
login = 'skipped';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (options.workspace) {
|
|
130
|
+
// Already signed in: the node registry is read from the current workspace,
|
|
131
|
+
// which must be the one the project records.
|
|
132
|
+
const current = env.ctx.auth.read()?.workspaceId;
|
|
133
|
+
if (current && current !== options.workspace) {
|
|
134
|
+
login = 'needs-workspace';
|
|
135
|
+
next.push(`fluidgrids workspace set ${options.workspace}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let codegen = 'skipped';
|
|
139
|
+
if (options.codegen === false) {
|
|
140
|
+
next.push('fluidgrids codegen');
|
|
141
|
+
}
|
|
142
|
+
else if (login === 'needs-workspace') {
|
|
143
|
+
codegen = 'needs-workspace';
|
|
144
|
+
next.push('fluidgrids codegen');
|
|
145
|
+
}
|
|
146
|
+
else if (!env.ctx.auth.isAuthenticated()) {
|
|
147
|
+
codegen = 'needs-login';
|
|
148
|
+
next.push('fluidgrids auth login', 'fluidgrids workspace set <id>', 'fluidgrids codegen');
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
try {
|
|
152
|
+
await writeNodeClients(project, await env.api.nodeManifests(), language);
|
|
153
|
+
codegen = 'written';
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
codegen = 'failed';
|
|
157
|
+
env.ctx.output.printWarning(`codegen did not run: ${describeError(error)}`);
|
|
158
|
+
next.push('fluidgrids codegen');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
next.push(language === 'ts' ? 'npm install' : `python -m pip install ${PYTHON_PACKAGE}`);
|
|
162
|
+
next.push('fluidgrids pull <workflow-key>');
|
|
163
|
+
const result = {
|
|
164
|
+
root,
|
|
165
|
+
language,
|
|
166
|
+
files: files.map((file) => file.path),
|
|
167
|
+
login,
|
|
168
|
+
codegen,
|
|
169
|
+
next,
|
|
170
|
+
};
|
|
171
|
+
emit(env, options, result, {
|
|
172
|
+
headers: ['Project', 'Language', 'Files', 'Login', 'Codegen'],
|
|
173
|
+
rows: [[root, language, String(result.files.length), login, codegen]],
|
|
174
|
+
}, ['Next:', ...next.map((step) => ` ${step}`)]);
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/code-first/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,cAAc,EACd,WAAW,EACX,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,gBAAgB,GAIjB,MAAM,eAAe,CAAC;AACvB,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KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;QACrC,KAAK;QACL,OAAO;QACP,IAAI;KACL,CAAC;IACF,IAAI,CACF,GAAG,EACH,OAAO,EACP,MAAM,EACN;QACE,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC;QAC7D,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KACtE,EACD,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAC9C,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids interface <key> [--wf-version v]`: the stored workflow's
|
|
3
|
+
* interface (inputs, outputs, signals, queries, updates) from
|
|
4
|
+
* `workflowInterface`, for wiring a workflow into code as a child or a
|
|
5
|
+
* code-workflow node.
|
|
6
|
+
*/
|
|
7
|
+
import { type CommandEnv, type OutputOptions } from '../shared.js';
|
|
8
|
+
export interface InterfaceOptions extends OutputOptions {
|
|
9
|
+
wfVersion?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function runInterface(env: CommandEnv, key: string, options: InterfaceOptions): Promise<unknown>;
|
|
12
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/code-first/commands/interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAEnE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,OAAO,CAAC,CAYlB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids interface <key> [--wf-version v]`: the stored workflow's
|
|
3
|
+
* interface (inputs, outputs, signals, queries, updates) from
|
|
4
|
+
* `workflowInterface`, for wiring a workflow into code as a child or a
|
|
5
|
+
* code-workflow node.
|
|
6
|
+
*/
|
|
7
|
+
import { CliUserError } from '@burdenoff/cli-sdk/core';
|
|
8
|
+
export async function runInterface(env, key, options) {
|
|
9
|
+
const value = await env.api.workflowInterface(key, options.wfVersion);
|
|
10
|
+
if (value === null || value === undefined) {
|
|
11
|
+
throw new CliUserError(`${key}${options.wfVersion ? ` ${options.wfVersion}` : ''} has no interface.`);
|
|
12
|
+
}
|
|
13
|
+
// An interface is a nested JSON document; YAML and JSON print it whole.
|
|
14
|
+
const format = env.ctx.output.getFormat(options);
|
|
15
|
+
if (format === 'yaml')
|
|
16
|
+
env.ctx.output.printYaml(value);
|
|
17
|
+
else
|
|
18
|
+
env.ctx.output.printJson(value);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/code-first/commands/interface.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAQvD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAe,EACf,GAAW,EACX,OAAyB;IAEzB,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACtE,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,YAAY,CACpB,GAAG,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAC9E,CAAC;IACJ,CAAC;IACD,wEAAwE;IACxE,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,MAAM,KAAK,MAAM;QAAE,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;;QAClD,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fluidgrids pull [key…] [--as ts|py|json] [--check]`: export workflows into
|
|
3
|
+
* the project (spec 07 §3, §7).
|
|
4
|
+
*
|
|
5
|
+
* Code is lifted locally with `@fluidgrids/workflows` (the library the service
|
|
6
|
+
* uses as well), and the fidelity report comes from lowering the lifted code
|
|
7
|
+
* and comparing `irHash`, never from heuristics. `--server` asks the service
|
|
8
|
+
* to render instead, which checks that the service and the CLI agree.
|
|
9
|
+
*
|
|
10
|
+
* The code format option is `--as`, because `-f/--format` is the CLI-wide
|
|
11
|
+
* output format (json, table, yaml). The spelling of spec 07 §7,
|
|
12
|
+
* `--format ts|py`, is accepted too: those two values cannot be output formats.
|
|
13
|
+
* `--format json` stays the output format; JSON files are pulled with `--as json`.
|
|
14
|
+
*/
|
|
15
|
+
import type { RemoteExport } from '../api.js';
|
|
16
|
+
import { type WorkflowFormat } from '../project.js';
|
|
17
|
+
import { type CommandEnv, type ProjectOptions } from '../shared.js';
|
|
18
|
+
export interface PullOptions extends ProjectOptions {
|
|
19
|
+
as?: string;
|
|
20
|
+
check?: boolean;
|
|
21
|
+
wfVersion?: string;
|
|
22
|
+
server?: boolean;
|
|
23
|
+
pinnedData?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface PulledFile {
|
|
26
|
+
path: string;
|
|
27
|
+
contentType: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
/** A fidelity report as printed: the library's report, or the service's. */
|
|
31
|
+
export interface Fidelity {
|
|
32
|
+
level: 'lossless' | 'lossy';
|
|
33
|
+
items: Array<{
|
|
34
|
+
kind: string;
|
|
35
|
+
detail: string;
|
|
36
|
+
nodeId?: string;
|
|
37
|
+
path?: string;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface PullItem {
|
|
41
|
+
key: string;
|
|
42
|
+
version: string;
|
|
43
|
+
format: WorkflowFormat;
|
|
44
|
+
irHash: string;
|
|
45
|
+
fidelity: Fidelity;
|
|
46
|
+
files: string[];
|
|
47
|
+
/** Files whose content differs from what is on disk (all of them on a first pull). */
|
|
48
|
+
changed: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface PullResult {
|
|
51
|
+
check: boolean;
|
|
52
|
+
workflows: PullItem[];
|
|
53
|
+
lossy: string[];
|
|
54
|
+
}
|
|
55
|
+
/** The export envelope as Git sync writes it: exportedAt pinned to the version's creation time. */
|
|
56
|
+
export declare function envelopeFile(exported: RemoteExport, createdAt: Date): PulledFile;
|
|
57
|
+
/** `--format ts|py` is the code format (spec 07 §7 spelling); any other value is the output format. */
|
|
58
|
+
export declare function splitFormat(options: PullOptions): {
|
|
59
|
+
options: PullOptions;
|
|
60
|
+
codeFormat: 'ts' | 'py' | undefined;
|
|
61
|
+
};
|
|
62
|
+
export declare function runPull(env: CommandEnv, keys: readonly string[], rawOptions: PullOptions): Promise<PullResult>;
|
|
63
|
+
//# sourceMappingURL=pull.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"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