Skip to content

Commit 8b91362

Browse files
authored
Merge pull request #430 from ajthinking/string-list-cleanup
Deprecate createDefaultStringable
2 parents 24d764e + 8835493 commit 8b91362

File tree

12 files changed

+24
-97
lines changed

12 files changed

+24
-97
lines changed

packages/core/src/InputDevice.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Diagram } from './Diagram'
22
import { ExecutionMemory } from './ExecutionMemory'
33
import { InputDevice } from './InputDevice'
4-
import { createDefaultStringable } from './Param'
4+
import { str } from './Param'
55
import { UnfoldedDiagramFactory } from './UnfoldedDiagramFactory'
66
import { Node } from './types/Node'
77

@@ -222,7 +222,7 @@ describe('params', () => {
222222
name: 'node-type',
223223
inputs: [{ id: 'target-input-id', name: 'input', schema: {} }],
224224
outputs: [],
225-
params: [createDefaultStringable({
225+
params: [str({
226226
name: 'greeting',
227227
label: 'Greeting',
228228
help: 'The greeting to use',

packages/core/src/Param/Param.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -54,61 +54,6 @@ export type Param =
5454

5555
export type ParamValue = Param['input']
5656

57-
type StringableConfigType = Omit<StringableParam, 'input' | 'type'> & {
58-
value: StringableInputValue['rawValue']
59-
}
60-
61-
export const strList = ({
62-
name,
63-
label,
64-
help,
65-
value,
66-
}: {
67-
name: string,
68-
label?: string,
69-
help?: string,
70-
value?: unknown,
71-
}): StringListParam => {
72-
return {
73-
name,
74-
type: 'StringListParam',
75-
label: label ?? name,
76-
help: help ?? '',
77-
input: {
78-
rawValue: value ?? undefined,
79-
},
80-
}
81-
}
82-
83-
export const createDefaultStringable = ({
84-
name,
85-
label,
86-
help,
87-
multiline,
88-
canInterpolate,
89-
interpolate,
90-
evaluations,
91-
casts,
92-
interpolationsFromPort,
93-
value,
94-
}:StringableConfigType): StringableParam => {
95-
return {
96-
name,
97-
type: 'StringableParam',
98-
label,
99-
help,
100-
multiline,
101-
canInterpolate,
102-
interpolate,
103-
evaluations,
104-
casts,
105-
interpolationsFromPort,
106-
input: {
107-
rawValue: value ?? '',
108-
},
109-
}
110-
}
111-
11257
export const str = ({
11358
name,
11459
label,

packages/core/src/computers/Comment.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { multiline } from '../utils/multiline';
2-
import { createDefaultStringable } from '../Param';
2+
import { str } from '../Param';
33
import { Computer } from '../types/Computer';
44

55
export const Comment: Computer = {
@@ -8,15 +8,14 @@ export const Comment: Computer = {
88
inputs: [],
99
outputs: [],
1010
params: [
11-
createDefaultStringable( {
11+
str( {
1212
name: 'content',
1313
label: 'Content',
1414
help: 'Markdown content',
1515
multiline: true,
1616
canInterpolate: false,
1717
interpolate: false,
1818
evaluations: [],
19-
casts: [],
2019
value: multiline`
2120
### Comment
2221
paragraph

packages/core/src/computers/ConsoleLog.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { numberCast } from '../Param/casts/numberCast';
22
import { stringCast } from '../Param/casts/stringCast';
33
import { jsFunctionEvaluation } from '../Param/evaluations/jsFunctionEvaluation';
44
import { jsonEvaluation } from '../Param/evaluations/jsonEvaluation';
5-
import { createDefaultStringable } from '../Param';
5+
import { str } from '../Param';
66
import { Computer } from '../types/Computer';
77

88
export const ConsoleLog: Computer = {
@@ -16,7 +16,7 @@ export const ConsoleLog: Computer = {
1616
],
1717
outputs: [],
1818
params: [
19-
createDefaultStringable( {
19+
str( {
2020
name: 'message',
2121
label: 'message',
2222
help: 'What to log. Leave blank to log the whole item.',
@@ -27,10 +27,6 @@ export const ConsoleLog: Computer = {
2727
jsFunctionEvaluation,
2828
jsonEvaluation,
2929
],
30-
casts: [
31-
numberCast,
32-
stringCast,
33-
],
3430
value: '',
3531
}),
3632
],

packages/core/src/computers/Input.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createDefaultStringable, str } from '../Param';
1+
import { str } from '../Param';
22
import { Computer } from '../types/Computer';
33

44
export const Input: Computer = {
@@ -13,7 +13,7 @@ export const Input: Computer = {
1313
schema: {},
1414
}],
1515
params: [
16-
createDefaultStringable({
16+
str({
1717
name: 'port_name',
1818
label: 'Port Name',
1919
value: 'input',

packages/core/src/computers/Output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createDefaultStringable, str } from '../Param';
1+
import { str } from '../Param';
22
import { Computer } from '../types/Computer';
33
import { BatchLimit } from '../utils/batchLimit';
44

@@ -14,7 +14,7 @@ export const Output: Computer = {
1414
schema: {},
1515
}],
1616
params: [
17-
createDefaultStringable({
17+
str({
1818
name: 'port_name',
1919
label: 'Port Name',
2020
value: 'output',

packages/core/src/computers/Sleep.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { sleep } from '../utils/sleep';
2-
import { numberCast } from '../Param/casts/numberCast';
3-
import { createDefaultStringable } from '../Param';
2+
import { num } from '../Param';
43
import { Computer } from '../types/Computer';
54

65
export const Sleep: Computer = {
@@ -15,17 +14,14 @@ export const Sleep: Computer = {
1514
schema: {},
1615
}],
1716
params: [
18-
createDefaultStringable({
17+
num({
1918
name: 'duration',
2019
label: 'Duration',
2120
help: 'How many ms to sleep?',
2221
multiline: false,
2322
canInterpolate: true,
2423
interpolate: true,
25-
casts: [
26-
{ ...numberCast, selected: true },
27-
],
28-
value: String(100),
24+
value: 100,
2925
}),
3026
],
3127

packages/core/src/computers/Table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { num, str, strList } from '../Param';
1+
import { str } from '../Param';
22
import { Computer } from '../types/Computer';
33
import { BatchLimit } from '../utils/batchLimit';
44

packages/core/src/computers/Throw.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { numberCast } from '../Param/casts/numberCast';
33
import { stringCast } from '../Param/casts/stringCast';
44
import { jsFunctionEvaluation } from '../Param/evaluations/jsFunctionEvaluation';
55
import { jsonEvaluation } from '../Param/evaluations/jsonEvaluation';
6-
import { createDefaultStringable } from '../Param';
6+
import { str } from '../Param';
77
import { Computer } from '../types/Computer';
88

99
export const Throw: Computer = {
@@ -15,7 +15,7 @@ export const Throw: Computer = {
1515
}],
1616
outputs: [],
1717
params: [
18-
createDefaultStringable({
18+
str({
1919
name: 'message',
2020
label: 'message',
2121
help: 'What to throw',
@@ -26,10 +26,6 @@ export const Throw: Computer = {
2626
jsFunctionEvaluation,
2727
jsonEvaluation,
2828
],
29-
casts: [
30-
numberCast,
31-
stringCast,
32-
],
3329
value: 'Some error',
3430
}),
3531
],

packages/nodejs/src/computers/ListFiles/ListFiles.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Computer, createDefaultStringable } from '@data-story/core';
1+
import { Computer, str } from '@data-story/core';
22
import { promises as fs } from 'fs'
33
import * as nodePath from 'path'
44

@@ -19,15 +19,14 @@ export const ListFiles: Computer = {
1919
},
2020
}],
2121
params: [
22-
createDefaultStringable({
22+
str({
2323
name: 'path',
2424
label: 'Path',
2525
help: 'Dir to list',
2626
multiline: true,
2727
canInterpolate: false,
2828
interpolate: false,
2929
evaluations: [],
30-
casts: [],
3130
value: '/',
3231
}),
3332
],

packages/nodejs/src/computers/ReadFiles/ReadFiles.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as glob from 'glob';
22
import { promises as fs } from 'fs';
3-
import { Computer, createDefaultStringable } from '@data-story/core';
3+
import { Computer, str } from '@data-story/core';
44

55
export const ReadFiles: Computer = {
66
name: 'ReadFiles',
@@ -18,29 +18,26 @@ export const ReadFiles: Computer = {
1818
},
1919
}],
2020
params: [
21-
createDefaultStringable({
21+
str({
2222
name: 'include',
2323
label: 'Include',
2424
help: 'Glob pattern to include',
2525
multiline: true,
2626
canInterpolate: true,
2727
interpolate: true,
2828
evaluations: [],
29-
casts: [],
3029
value: '${path}/**/*.ts',
3130
}),
32-
createDefaultStringable( {
31+
str({
3332
name: 'ignore',
3433
label: 'Ignore',
3534
help: 'Glob pattern to ignore',
3635
multiline: true,
3736
canInterpolate: true,
3837
interpolate: true,
3938
evaluations: [],
40-
casts: [],
4139
value: '**/node_modules/**',
42-
},
43-
),
40+
}),
4441
],
4542

4643
async *run({ input, output }) {

packages/ui/src/components/DataStory/modals/runModal/DefineMode.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { createDefaultStringable } from '@data-story/core';
1+
import { str } from '@data-story/core';
22

33
const DefineMode = ({ params, setParams, setDefineMode }) => {
4-
const sampleParam = createDefaultStringable({
4+
const sampleParam = str({
55
name: 'sampleParam',
66
label: 'sampleParam',
77
help: '',
88
multiline: false,
99
canInterpolate: true,
1010
interpolate: true,
1111
evaluations: [],
12-
casts: [],
1312
value: 'default value',
1413
})
1514

0 commit comments

Comments
 (0)