Skip to content

Commit 031d6d3

Browse files
committed
enable type checking on project tests and fix a bunch of types
1 parent 067b0dd commit 031d6d3

11 files changed

Lines changed: 93 additions & 111 deletions

File tree

packages/lexicon/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './core';
2+
export * from './portability';
23
export * as lightning from './lighting';

packages/lexicon/lightning.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ export namespace Provisioner {
285285
inserted_at?: string;
286286
updated_at?: string;
287287
deleted_at: string | null;
288+
289+
positions?: Record<string, { x: number; y: number }>;
288290
}
289291

290292
export type Collection = {

packages/lexicon/portability.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ export interface Trigger extends Step {
8484
success_code?: number;
8585
};
8686
cron_cursor_job_id?: string;
87-
88-
/** Allow arbitrary properties on trigger nodes (as configuration options) */
89-
[option: string]: any;
9087
}
9188

9289
// TODO credential should just be an id string in the near future

packages/project/test/canonical.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const project: ProjectSpec = {
2727
type: 'webhook',
2828
enabled: true,
2929
webhook_reply: 'before_start',
30-
webhook_response: {
30+
webhook_response_config: {
3131
success_code: 202,
3232
error_code: 500,
3333
},

packages/project/test/gen/generator.test.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const LOG_OUTPUTS = false;
88

99
// Generate a workflow with a fixed UUID seed
1010
// Pass test context to log the result
11-
const gen = (src: string, t?: ExecutionContext<unknown>, options = {}) => {
11+
const gen = (src: string, t?: ExecutionContext<unknown>, options = {}): any => {
1212
const result = generateWorkflow(src, {
1313
uuidSeed: 1,
1414
printErrors: false,
@@ -444,15 +444,15 @@ test('it should generate a webhook trigger', (t) => {
444444

445445
test('it should generate a node with a prop', (t) => {
446446
const result = gen('a(expression=y)-b', t);
447-
const expected = _.cloneDeep(fixtures.ab);
447+
const expected: any = _.cloneDeep(fixtures.ab);
448448
expected.steps[0].expression = 'y';
449449

450450
t.deepEqual(result, expected);
451451
});
452452

453453
test('it should generate a node with a prop with an underscore', (t) => {
454454
const result = gen('a(project_credential_id=y)-b', t);
455-
const expected = _.cloneDeep(fixtures.ab);
455+
const expected: any = _.cloneDeep(fixtures.ab);
456456
expected.steps[0].openfn = {
457457
uuid: 1,
458458
project_credential_id: 'y',
@@ -486,7 +486,7 @@ test('it should save unexpected props to .openfn', (t) => {
486486

487487
test('it should generate a node with two props', (t) => {
488488
const result = gen('a(adaptor=j,expression=k)-b', t);
489-
const expected = _.cloneDeep(fixtures.ab);
489+
const expected: any = _.cloneDeep(fixtures.ab);
490490
expected.steps[0].adaptor = 'j';
491491
expected.steps[0].expression = 'k';
492492

@@ -623,40 +623,12 @@ a-b #zz
623623
});
624624

625625
test('it should generate a project with seeded uuids', (t) => {
626-
const result = generateProject('x', ['a-b'], {
626+
const result: any = generateProject('x', ['a-b'], {
627627
openfnUuid: true,
628628
uuidSeed: 1000,
629629
uuid: 123,
630630
});
631631

632-
const expected = {
633-
id: 'workflow',
634-
name: 'Workflow',
635-
history: [],
636-
steps: [
637-
{
638-
id: 'a',
639-
name: 'a',
640-
openfn: {
641-
uuid: 'A',
642-
},
643-
next: {
644-
b: {
645-
openfn: {
646-
uuid: 'AB',
647-
},
648-
},
649-
},
650-
},
651-
{
652-
id: 'b',
653-
name: 'b',
654-
openfn: {
655-
uuid: 'B',
656-
},
657-
},
658-
],
659-
};
660632
t.deepEqual(result.openfn, {
661633
uuid: 123,
662634
});
@@ -710,6 +682,7 @@ test('it should generate a simple workflow with mapped uuids', (t) => {
710682
test('it should generate a project with mapped uuids', (t) => {
711683
const result = generateProject('x', ['a-b'], {
712684
openfnUuid: true,
685+
// @ts-ignore
713686
uuidMap: [
714687
{
715688
a: 'A',

packages/project/test/merge/map-uuids.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import * as l from '@openfn/lexicon';
2-
31
import test from 'ava';
42
import mapUUIDs from '../../src/merge/map-uuids';
53
import generateWorkflow from '../../src/gen/generator';
64
import Workflow from '../../src/Workflow';
75

8-
const gen = (src) => generateWorkflow(src, { uuidSeed: 1 });
6+
const gen = (src: string) => generateWorkflow(src, { uuidSeed: 1 });
97

108
let idgen = 0;
119

12-
const createSingleNode = (name, uuid) =>
10+
const createSingleNode = (name: string, uuid?: string | number) =>
1311
new Workflow({
1412
id: `wf-${++idgen}}`,
1513
steps: [
1614
{
1715
id: name,
1816
name,
17+
// @ts-ignore
1918
openfn: { uuid: uuid ?? crypto.randomUUID() },
2019
},
2120
],

0 commit comments

Comments
 (0)