@openfn/project 0.14.2 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -3
- package/dist/index.js +31 -35
- package/package.json +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as l from '@openfn/lexicon';
|
|
2
2
|
import l__default, { SandboxMeta, WorkspaceConfig, UUID } from '@openfn/lexicon';
|
|
3
|
-
import { Logger } from '@openfn/logger';
|
|
4
3
|
import { Provisioner } from '@openfn/lexicon/lightning';
|
|
4
|
+
import { Logger } from '@openfn/logger';
|
|
5
5
|
|
|
6
6
|
type DiffType = 'added' | 'changed' | 'removed';
|
|
7
7
|
type WorkflowDiff = {
|
|
@@ -78,6 +78,7 @@ type fromAppStateConfig = Partial<l.WorkspaceConfig> & {
|
|
|
78
78
|
format?: 'yaml' | 'json';
|
|
79
79
|
alias?: string;
|
|
80
80
|
};
|
|
81
|
+
declare const mapWorkflow: (workflow: Provisioner.Workflow, credentials?: Credential[]) => l.Workflow;
|
|
81
82
|
|
|
82
83
|
type FromPathConfig = l.WorkspaceConfig & {
|
|
83
84
|
format: 'json' | 'yaml';
|
|
@@ -182,7 +183,7 @@ declare class Project {
|
|
|
182
183
|
collections: any;
|
|
183
184
|
credentials: Credential[];
|
|
184
185
|
sandbox?: SandboxMeta;
|
|
185
|
-
static from(type: 'project', data: any,
|
|
186
|
+
static from(type: 'project', data: any, config?: Partial<l__default.WorkspaceConfig>): Promise<Project>;
|
|
186
187
|
static from(type: 'state', data: Provisioner.Project, meta?: Partial<l__default.ProjectMeta>, config?: fromAppStateConfig): Promise<Project>;
|
|
187
188
|
static from(type: 'fs', options: FromFsConfig): Promise<Project>;
|
|
188
189
|
static from(type: 'path', data: string, options?: {
|
|
@@ -248,4 +249,4 @@ type GenerateProjectOptions = GenerateWorkflowOptions & {
|
|
|
248
249
|
declare function generateWorkflow(def: string, options?: Partial<GenerateWorkflowOptions>): Workflow;
|
|
249
250
|
declare function generateProject(name: string, workflowDefs: string[], options?: Partial<GenerateProjectOptions>): Project;
|
|
250
251
|
|
|
251
|
-
export { DiffType, WorkflowDiff, Workspace, Project as default, diff, generateProject, generateHash as generateVersionHash, generateWorkflow, jsonToYaml, match as versionsEqual, yamlToJson };
|
|
252
|
+
export { type DiffType, type WorkflowDiff, Workspace, Project as default, diff, generateProject, generateHash as generateVersionHash, generateWorkflow, jsonToYaml, mapWorkflow, match as versionsEqual, yamlToJson };
|
package/dist/index.js
CHANGED
|
@@ -13,12 +13,12 @@ function slugify(text) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// src/util/version.ts
|
|
16
|
-
import crypto from "
|
|
16
|
+
import crypto from "crypto";
|
|
17
17
|
import { get } from "lodash-es";
|
|
18
18
|
|
|
19
19
|
// src/serialize/to-app-state.ts
|
|
20
20
|
import { pick, omitBy, isNil, sortBy } from "lodash-es";
|
|
21
|
-
import { randomUUID } from "
|
|
21
|
+
import { randomUUID } from "crypto";
|
|
22
22
|
|
|
23
23
|
// src/util/rename-keys.ts
|
|
24
24
|
function renameKeys(props = {}, keyMap) {
|
|
@@ -55,7 +55,7 @@ var parse = (credentialName) => {
|
|
|
55
55
|
// src/serialize/to-app-state.ts
|
|
56
56
|
var defaultJobProps = {
|
|
57
57
|
// TODO why does the provisioner throw if these keys are not set?
|
|
58
|
-
// Ok, 90% of jobs will have a
|
|
58
|
+
// Ok, 90% of jobs will have a credential, but it's still optional right?
|
|
59
59
|
keychain_credential_id: null,
|
|
60
60
|
project_credential_id: null
|
|
61
61
|
};
|
|
@@ -428,10 +428,8 @@ var Workflow = class {
|
|
|
428
428
|
const step = s;
|
|
429
429
|
const next = typeof step.next === "string" ? { [step.next]: true } : step.next || {};
|
|
430
430
|
for (const toNode of Object.keys(next)) {
|
|
431
|
-
if (!Array.isArray(edges[step.id]))
|
|
432
|
-
|
|
433
|
-
else
|
|
434
|
-
edges[step.id].push(toNode);
|
|
431
|
+
if (!Array.isArray(edges[step.id])) edges[step.id] = [toNode];
|
|
432
|
+
else edges[step.id].push(toNode);
|
|
435
433
|
}
|
|
436
434
|
}
|
|
437
435
|
return edges;
|
|
@@ -448,8 +446,7 @@ var Workflow = class {
|
|
|
448
446
|
all_parents.push(parent);
|
|
449
447
|
}
|
|
450
448
|
const root = all_parents.find((parent) => !all_children.includes(parent));
|
|
451
|
-
if (!root)
|
|
452
|
-
return;
|
|
449
|
+
if (!root) return;
|
|
453
450
|
return this.index.steps[root];
|
|
454
451
|
}
|
|
455
452
|
getUUID(id) {
|
|
@@ -490,8 +487,8 @@ import nodepath from "path";
|
|
|
490
487
|
import { omit } from "lodash-es";
|
|
491
488
|
|
|
492
489
|
// src/util/config.ts
|
|
493
|
-
import { readFileSync } from "
|
|
494
|
-
import path from "
|
|
490
|
+
import { readFileSync } from "fs";
|
|
491
|
+
import path from "path";
|
|
495
492
|
import { pickBy, isNil as isNil2 } from "lodash-es";
|
|
496
493
|
var buildConfig = (config = {}) => ({
|
|
497
494
|
credentials: "credentials.yaml",
|
|
@@ -891,8 +888,8 @@ var mapWorkflow2 = (workflow, credentials = []) => {
|
|
|
891
888
|
};
|
|
892
889
|
|
|
893
890
|
// src/parse/from-path.ts
|
|
894
|
-
import { readFile } from "
|
|
895
|
-
import path2 from "
|
|
891
|
+
import { readFile } from "fs/promises";
|
|
892
|
+
import path2 from "path";
|
|
896
893
|
|
|
897
894
|
// src/parse/from-project.ts
|
|
898
895
|
var from_project_default = (data, config) => {
|
|
@@ -927,8 +924,8 @@ var from_path_default = async (filePath, config = {}) => {
|
|
|
927
924
|
};
|
|
928
925
|
|
|
929
926
|
// src/parse/from-fs.ts
|
|
930
|
-
import fs from "
|
|
931
|
-
import path3 from "
|
|
927
|
+
import fs from "fs/promises";
|
|
928
|
+
import path3 from "path";
|
|
932
929
|
import { glob } from "glob";
|
|
933
930
|
import { omit as omit2 } from "lodash-es";
|
|
934
931
|
var parseProject = async (options) => {
|
|
@@ -1164,8 +1161,7 @@ function getUnmappedCandidates(unmappedTarget, idMap) {
|
|
|
1164
1161
|
return unmappedTarget.filter((step) => !mappedIds.has(step.id));
|
|
1165
1162
|
}
|
|
1166
1163
|
function findBestMatch(sourceStep, candidates, sourceEdges, targetEdges, getMappedId, isLastIteration) {
|
|
1167
|
-
if (candidates.length === 0)
|
|
1168
|
-
return null;
|
|
1164
|
+
if (candidates.length === 0) return null;
|
|
1169
1165
|
let bestCandidates = candidates;
|
|
1170
1166
|
let topResult = null;
|
|
1171
1167
|
let didStructuralFilter = false;
|
|
@@ -1275,8 +1271,7 @@ function findByParent(parentIds, edges, steps) {
|
|
|
1275
1271
|
const matches = [];
|
|
1276
1272
|
for (const parentId of parentIds) {
|
|
1277
1273
|
const children = edges[parentId];
|
|
1278
|
-
if (!children || children.length === 0)
|
|
1279
|
-
continue;
|
|
1274
|
+
if (!children || children.length === 0) continue;
|
|
1280
1275
|
const matchingSteps = steps.filter((step) => children.includes(step.id));
|
|
1281
1276
|
matches.push(...matchingSteps);
|
|
1282
1277
|
}
|
|
@@ -1341,10 +1336,8 @@ function getDuplicates(arr) {
|
|
|
1341
1336
|
const duplicates = /* @__PURE__ */ new Set();
|
|
1342
1337
|
for (let i = 0; i < arr.length; i++) {
|
|
1343
1338
|
const item = arr[i];
|
|
1344
|
-
if (hmap[item])
|
|
1345
|
-
|
|
1346
|
-
else
|
|
1347
|
-
hmap[item] = true;
|
|
1339
|
+
if (hmap[item]) duplicates.add(item);
|
|
1340
|
+
else hmap[item] = true;
|
|
1348
1341
|
}
|
|
1349
1342
|
return Array.from(duplicates);
|
|
1350
1343
|
}
|
|
@@ -1450,7 +1443,11 @@ Pass --force to force the merge anyway`
|
|
|
1450
1443
|
}
|
|
1451
1444
|
}
|
|
1452
1445
|
const assigns = options.mode === SANDBOX_MERGE ? {
|
|
1453
|
-
workflows: finalWorkflows
|
|
1446
|
+
workflows: finalWorkflows,
|
|
1447
|
+
credentials: replaceCredentials(
|
|
1448
|
+
source.credentials,
|
|
1449
|
+
target.credentials
|
|
1450
|
+
)
|
|
1454
1451
|
} : {
|
|
1455
1452
|
workflows: finalWorkflows,
|
|
1456
1453
|
openfn: {
|
|
@@ -1699,18 +1696,16 @@ var Project_default = Project;
|
|
|
1699
1696
|
|
|
1700
1697
|
// src/Workspace.ts
|
|
1701
1698
|
import createLogger from "@openfn/logger";
|
|
1702
|
-
import path4 from "
|
|
1703
|
-
import fs3 from "
|
|
1699
|
+
import path4 from "path";
|
|
1700
|
+
import fs3 from "fs";
|
|
1704
1701
|
|
|
1705
1702
|
// src/util/path-exists.ts
|
|
1706
1703
|
import fs2 from "fs";
|
|
1707
1704
|
function pathExists(fpath, type) {
|
|
1708
1705
|
try {
|
|
1709
1706
|
const stat = fs2.statSync(fpath);
|
|
1710
|
-
if (type === "file" && stat.isFile())
|
|
1711
|
-
|
|
1712
|
-
else if (type === "directory" && stat.isDirectory())
|
|
1713
|
-
return true;
|
|
1707
|
+
if (type === "file" && stat.isFile()) return true;
|
|
1708
|
+
else if (type === "directory" && stat.isDirectory()) return true;
|
|
1714
1709
|
return false;
|
|
1715
1710
|
} catch (e) {
|
|
1716
1711
|
return false;
|
|
@@ -1850,9 +1845,9 @@ var Workspace = class {
|
|
|
1850
1845
|
};
|
|
1851
1846
|
|
|
1852
1847
|
// src/gen/generator.ts
|
|
1853
|
-
import { randomUUID as randomUUID2 } from "
|
|
1854
|
-
import path5 from "
|
|
1855
|
-
import { readFileSync as readFileSync2 } from "
|
|
1848
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1849
|
+
import path5 from "path";
|
|
1850
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
1856
1851
|
import { grammar } from "ohm-js";
|
|
1857
1852
|
import { isNil as isNil5, set } from "lodash-es";
|
|
1858
1853
|
var parser;
|
|
@@ -2061,15 +2056,16 @@ function generateProject(name, workflowDefs, options = {}) {
|
|
|
2061
2056
|
}
|
|
2062
2057
|
|
|
2063
2058
|
// src/index.ts
|
|
2064
|
-
var
|
|
2059
|
+
var index_default = Project;
|
|
2065
2060
|
export {
|
|
2066
2061
|
Workspace,
|
|
2067
|
-
|
|
2062
|
+
index_default as default,
|
|
2068
2063
|
diff,
|
|
2069
2064
|
generateProject,
|
|
2070
2065
|
generateHash as generateVersionHash,
|
|
2071
2066
|
generateWorkflow,
|
|
2072
2067
|
jsonToYaml,
|
|
2068
|
+
mapWorkflow2 as mapWorkflow,
|
|
2073
2069
|
match as versionsEqual,
|
|
2074
2070
|
yamlToJson
|
|
2075
2071
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfn/project",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"description": "Read, serialize, replicate and sync OpenFn projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,25 +17,25 @@
|
|
|
17
17
|
"author": "Open Function Group <admin@openfn.org>",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@types/lodash": "^4.17.
|
|
20
|
+
"@types/lodash": "^4.17.24",
|
|
21
21
|
"@types/mock-fs": "~4.13.4",
|
|
22
22
|
"ava": "5.3.1",
|
|
23
23
|
"mock-fs": "^5.5.0",
|
|
24
|
-
"rimraf": "^
|
|
24
|
+
"rimraf": "^6.1.3",
|
|
25
25
|
"tslib": "^2.8.1",
|
|
26
|
-
"tsup": "^
|
|
27
|
-
"typescript": "^5.9.
|
|
26
|
+
"tsup": "^8.5.1",
|
|
27
|
+
"typescript": "^5.9.3"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/lodash-es": "^4.17.12",
|
|
31
|
-
"glob": "^
|
|
32
|
-
"human-id": "^4.1.
|
|
33
|
-
"lodash": "^4.17.
|
|
34
|
-
"lodash-es": "^4.17.
|
|
35
|
-
"ohm-js": "^17.
|
|
36
|
-
"yaml": "^2.
|
|
37
|
-
"@openfn/
|
|
38
|
-
"@openfn/
|
|
31
|
+
"glob": "^13.0.6",
|
|
32
|
+
"human-id": "^4.1.3",
|
|
33
|
+
"lodash": "^4.17.23",
|
|
34
|
+
"lodash-es": "^4.17.23",
|
|
35
|
+
"ohm-js": "^17.5.0",
|
|
36
|
+
"yaml": "^2.8.2",
|
|
37
|
+
"@openfn/lexicon": "^1.4.2",
|
|
38
|
+
"@openfn/logger": "1.1.2"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"dist",
|