@start9labs/start-sdk 0.4.0-beta.50 → 0.4.0-beta.52

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.
Files changed (165) hide show
  1. package/base/lib/Effects.d.ts +4 -0
  2. package/base/lib/actions/input/builder/inputSpec.d.ts +129 -8
  3. package/base/lib/actions/input/builder/inputSpec.js +223 -13
  4. package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
  5. package/base/lib/actions/input/builder/inputSpecTools.d.ts +3 -3
  6. package/base/lib/actions/input/builder/list.d.ts +24 -3
  7. package/base/lib/actions/input/builder/list.js +26 -5
  8. package/base/lib/actions/input/builder/list.js.map +1 -1
  9. package/base/lib/actions/input/builder/value.d.ts +70 -16
  10. package/base/lib/actions/input/builder/value.js +89 -34
  11. package/base/lib/actions/input/builder/value.js.map +1 -1
  12. package/base/lib/actions/input/builder/variants.d.ts +14 -3
  13. package/base/lib/actions/input/builder/variants.js +22 -7
  14. package/base/lib/actions/input/builder/variants.js.map +1 -1
  15. package/base/lib/actions/input/inputSpecConstants.d.ts +203 -5
  16. package/base/lib/actions/input/inputSpecConstants.js +118 -38
  17. package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
  18. package/base/lib/actions/input/inputSpecTypes.d.ts +99 -0
  19. package/base/lib/actions/input/inputSpecTypes.js +6 -1
  20. package/base/lib/actions/input/inputSpecTypes.js.map +1 -1
  21. package/base/lib/actions/setupActions.d.ts +6 -3
  22. package/base/lib/actions/setupActions.js +7 -4
  23. package/base/lib/actions/setupActions.js.map +1 -1
  24. package/base/lib/exver/index.d.ts +233 -2
  25. package/base/lib/exver/index.js +197 -3
  26. package/base/lib/exver/index.js.map +1 -1
  27. package/base/lib/index.d.ts +23 -1
  28. package/base/lib/index.js +4 -2
  29. package/base/lib/index.js.map +1 -1
  30. package/base/lib/inits/setupInit.d.ts +17 -0
  31. package/base/lib/inits/setupInit.js +7 -0
  32. package/base/lib/inits/setupInit.js.map +1 -1
  33. package/base/lib/inits/setupUninit.d.ts +12 -0
  34. package/base/lib/inits/setupUninit.js +7 -0
  35. package/base/lib/inits/setupUninit.js.map +1 -1
  36. package/base/lib/interfaces/Host.js +2 -4
  37. package/base/lib/interfaces/Host.js.map +1 -1
  38. package/base/lib/osBindings/GetOutboundGatewayParams.d.ts +4 -0
  39. package/base/lib/osBindings/GetOutboundGatewayParams.js +3 -0
  40. package/base/lib/osBindings/GetOutboundGatewayParams.js.map +1 -0
  41. package/base/lib/osBindings/ServerHostname.d.ts +1 -0
  42. package/base/lib/osBindings/ServerHostname.js +4 -0
  43. package/base/lib/osBindings/ServerHostname.js.map +1 -0
  44. package/base/lib/osBindings/ServerInfo.d.ts +1 -0
  45. package/base/lib/osBindings/SetServerHostnameParams.d.ts +4 -0
  46. package/base/lib/osBindings/SetServerHostnameParams.js +4 -0
  47. package/base/lib/osBindings/SetServerHostnameParams.js.map +1 -0
  48. package/base/lib/osBindings/SetupExecuteParams.d.ts +3 -1
  49. package/base/lib/osBindings/SmtpSecurity.d.ts +1 -0
  50. package/base/lib/osBindings/SmtpSecurity.js +4 -0
  51. package/base/lib/osBindings/SmtpSecurity.js.map +1 -0
  52. package/base/lib/osBindings/SmtpValue.d.ts +4 -2
  53. package/base/lib/osBindings/SmtpValue.js +0 -1
  54. package/base/lib/osBindings/SmtpValue.js.map +1 -1
  55. package/base/lib/osBindings/StartOsRecoveryInfo.d.ts +2 -2
  56. package/base/lib/osBindings/TestSmtpParams.d.ts +4 -2
  57. package/base/lib/osBindings/TestSmtpParams.js +0 -1
  58. package/base/lib/osBindings/TestSmtpParams.js.map +1 -1
  59. package/base/lib/osBindings/index.d.ts +4 -1
  60. package/base/lib/s9pk/index.d.ts +66 -0
  61. package/base/lib/s9pk/index.js +70 -1
  62. package/base/lib/s9pk/index.js.map +1 -1
  63. package/base/lib/types.d.ts +68 -2
  64. package/base/lib/types.js +14 -0
  65. package/base/lib/types.js.map +1 -1
  66. package/base/lib/util/GetOutboundGateway.d.ts +30 -0
  67. package/base/lib/util/GetOutboundGateway.js +90 -0
  68. package/base/lib/util/GetOutboundGateway.js.map +1 -0
  69. package/base/lib/util/asError.d.ts +8 -0
  70. package/base/lib/util/asError.js +8 -0
  71. package/base/lib/util/asError.js.map +1 -1
  72. package/base/lib/util/deepEqual.d.ts +15 -0
  73. package/base/lib/util/deepEqual.js +16 -2
  74. package/base/lib/util/deepEqual.js.map +1 -1
  75. package/base/lib/util/deepMerge.d.ts +18 -0
  76. package/base/lib/util/deepMerge.js +18 -0
  77. package/base/lib/util/deepMerge.js.map +1 -1
  78. package/base/lib/util/getDefaultString.d.ts +8 -0
  79. package/base/lib/util/getDefaultString.js +8 -0
  80. package/base/lib/util/getDefaultString.js.map +1 -1
  81. package/base/lib/util/graph.d.ts +57 -0
  82. package/base/lib/util/graph.js +47 -0
  83. package/base/lib/util/graph.js.map +1 -1
  84. package/base/lib/util/inMs.d.ts +15 -0
  85. package/base/lib/util/inMs.js +15 -0
  86. package/base/lib/util/inMs.js.map +1 -1
  87. package/base/lib/util/index.d.ts +1 -0
  88. package/base/lib/util/index.js +3 -1
  89. package/base/lib/util/index.js.map +1 -1
  90. package/base/lib/util/ip.d.ts +81 -0
  91. package/base/lib/util/ip.js +81 -0
  92. package/base/lib/util/ip.js.map +1 -1
  93. package/base/lib/util/once.d.ts +13 -0
  94. package/base/lib/util/once.js +13 -0
  95. package/base/lib/util/once.js.map +1 -1
  96. package/base/lib/util/patterns.d.ts +11 -0
  97. package/base/lib/util/patterns.js +11 -0
  98. package/base/lib/util/patterns.js.map +1 -1
  99. package/base/lib/util/regexes.d.ts +38 -0
  100. package/base/lib/util/regexes.js +38 -0
  101. package/base/lib/util/regexes.js.map +1 -1
  102. package/base/lib/util/splitCommand.d.ts +14 -0
  103. package/base/lib/util/splitCommand.js +15 -2
  104. package/base/lib/util/splitCommand.js.map +1 -1
  105. package/base/lib/util/stringFromStdErrOut.d.ts +7 -0
  106. package/base/lib/util/stringFromStdErrOut.js +7 -0
  107. package/base/lib/util/stringFromStdErrOut.js.map +1 -1
  108. package/base/lib/util/typeHelpers.d.ts +35 -0
  109. package/base/lib/util/typeHelpers.js +7 -0
  110. package/base/lib/util/typeHelpers.js.map +1 -1
  111. package/package/lib/StartSdk.d.ts +330 -3
  112. package/package/lib/StartSdk.js +143 -1
  113. package/package/lib/StartSdk.js.map +1 -1
  114. package/package/lib/backup/Backups.d.ts +71 -0
  115. package/package/lib/backup/Backups.js +69 -0
  116. package/package/lib/backup/Backups.js.map +1 -1
  117. package/package/lib/backup/setupBackups.d.ts +14 -0
  118. package/package/lib/backup/setupBackups.js +9 -0
  119. package/package/lib/backup/setupBackups.js.map +1 -1
  120. package/package/lib/health/HealthCheck.d.ts +16 -0
  121. package/package/lib/health/HealthCheck.js +16 -2
  122. package/package/lib/health/HealthCheck.js.map +1 -1
  123. package/package/lib/health/checkFns/HealthCheckResult.d.ts +6 -0
  124. package/package/lib/health/checkFns/index.d.ts +8 -0
  125. package/package/lib/health/checkFns/index.js +8 -0
  126. package/package/lib/health/checkFns/index.js.map +1 -1
  127. package/package/lib/index.d.ts +2 -2
  128. package/package/lib/index.js +2 -2
  129. package/package/lib/index.js.map +1 -1
  130. package/package/lib/mainFn/CommandController.d.ts +29 -0
  131. package/package/lib/mainFn/CommandController.js +29 -0
  132. package/package/lib/mainFn/CommandController.js.map +1 -1
  133. package/package/lib/mainFn/Daemon.d.ts +38 -2
  134. package/package/lib/mainFn/Daemon.js +38 -2
  135. package/package/lib/mainFn/Daemon.js.map +1 -1
  136. package/package/lib/mainFn/Daemons.d.ts +31 -0
  137. package/package/lib/mainFn/Daemons.js +13 -0
  138. package/package/lib/mainFn/Daemons.js.map +1 -1
  139. package/package/lib/mainFn/Mounts.d.ts +38 -0
  140. package/package/lib/mainFn/Mounts.js +38 -0
  141. package/package/lib/mainFn/Mounts.js.map +1 -1
  142. package/package/lib/mainFn/index.d.ts +1 -0
  143. package/package/lib/mainFn/index.js +1 -0
  144. package/package/lib/mainFn/index.js.map +1 -1
  145. package/package/lib/manifest/setupManifest.d.ts +9 -0
  146. package/package/lib/manifest/setupManifest.js +9 -0
  147. package/package/lib/manifest/setupManifest.js.map +1 -1
  148. package/package/lib/test/output.d.ts +2 -2
  149. package/package/lib/test/output.js +418 -329
  150. package/package/lib/test/output.js.map +1 -1
  151. package/package/lib/test/output.sdk.d.ts +193 -2
  152. package/package/lib/util/SubContainer.d.ts +46 -0
  153. package/package/lib/util/SubContainer.js +10 -0
  154. package/package/lib/util/SubContainer.js.map +1 -1
  155. package/package/lib/util/fileHelper.d.ts +43 -10
  156. package/package/lib/util/fileHelper.js +13 -11
  157. package/package/lib/util/fileHelper.js.map +1 -1
  158. package/package/lib/version/VersionGraph.d.ts +64 -13
  159. package/package/lib/version/VersionGraph.js +64 -18
  160. package/package/lib/version/VersionGraph.js.map +1 -1
  161. package/package/lib/version/VersionInfo.d.ts +17 -0
  162. package/package/lib/version/VersionInfo.js +12 -0
  163. package/package/lib/version/VersionInfo.js.map +1 -1
  164. package/package/package.json +9 -8
  165. package/package.json +9 -8
@@ -1,47 +1,81 @@
1
+ /**
2
+ * A record mapping field keys to their {@link ValueSpec} definitions.
3
+ * This is the root shape of a dynamic form specification — it defines the complete set
4
+ * of configurable fields for a service or action.
5
+ */
1
6
  export type InputSpec = Record<string, ValueSpec>;
7
+ /**
8
+ * The discriminator for all supported form field types.
9
+ */
2
10
  export type ValueType = 'text' | 'textarea' | 'number' | 'color' | 'datetime' | 'toggle' | 'select' | 'multiselect' | 'list' | 'object' | 'file' | 'union' | 'hidden';
11
+ /** Union of all concrete form field spec types. Discriminate on the `type` field. */
3
12
  export type ValueSpec = ValueSpecOf<ValueType>;
4
13
  /** core spec types. These types provide the metadata for performing validations */
5
14
  export type ValueSpecOf<T extends ValueType> = T extends "text" ? ValueSpecText : T extends "textarea" ? ValueSpecTextarea : T extends "number" ? ValueSpecNumber : T extends "color" ? ValueSpecColor : T extends "datetime" ? ValueSpecDatetime : T extends "toggle" ? ValueSpecToggle : T extends "select" ? ValueSpecSelect : T extends "multiselect" ? ValueSpecMultiselect : T extends "list" ? ValueSpecList : T extends "object" ? ValueSpecObject : T extends "file" ? ValueSpecFile : T extends "union" ? ValueSpecUnion : T extends "hidden" ? ValueSpecHidden : never;
15
+ /** Spec for a single-line text input field. */
6
16
  export type ValueSpecText = {
17
+ /** Display label for the field. */
7
18
  name: string;
19
+ /** Optional help text displayed below the field. */
8
20
  description: string | null;
21
+ /** Optional warning message displayed to the user. */
9
22
  warning: string | null;
10
23
  type: 'text';
24
+ /** Regex patterns used to validate the input value. */
11
25
  patterns: Pattern[];
26
+ /** Minimum character length, or `null` for no minimum. */
12
27
  minLength: number | null;
28
+ /** Maximum character length, or `null` for no maximum. */
13
29
  maxLength: number | null;
30
+ /** Whether the field should obscure input (e.g. for passwords). */
14
31
  masked: boolean;
32
+ /** HTML input mode hint for mobile keyboards. */
15
33
  inputmode: 'text' | 'email' | 'tel' | 'url';
34
+ /** Placeholder text shown when the field is empty. */
16
35
  placeholder: string | null;
36
+ /** Whether the field must have a value. */
17
37
  required: boolean;
38
+ /** Default value, which may be a literal string or a {@link RandomString} generation spec. */
18
39
  default: DefaultString | null;
40
+ /** `false` if editable, or a string message explaining why the field is disabled. */
19
41
  disabled: false | string;
42
+ /** If set, provides a "generate" button that fills the field with a random string matching this spec. */
20
43
  generate: null | RandomString;
44
+ /** Whether the field value cannot be changed after initial configuration. */
21
45
  immutable: boolean;
22
46
  };
47
+ /** Spec for a multi-line textarea input field. */
23
48
  export type ValueSpecTextarea = {
24
49
  name: string;
25
50
  description: string | null;
26
51
  warning: string | null;
27
52
  type: 'textarea';
53
+ /** Regex patterns used to validate the input value. */
28
54
  patterns: Pattern[];
29
55
  placeholder: string | null;
30
56
  minLength: number | null;
31
57
  maxLength: number | null;
58
+ /** Minimum number of visible rows. */
32
59
  minRows: number;
60
+ /** Maximum number of visible rows before scrolling. */
33
61
  maxRows: number;
34
62
  required: boolean;
35
63
  default: string | null;
36
64
  disabled: false | string;
37
65
  immutable: boolean;
38
66
  };
67
+ /** Spec for a numeric input field. */
39
68
  export type ValueSpecNumber = {
40
69
  type: 'number';
70
+ /** Minimum allowed value, or `null` for unbounded. */
41
71
  min: number | null;
72
+ /** Maximum allowed value, or `null` for unbounded. */
42
73
  max: number | null;
74
+ /** Whether only whole numbers are accepted. */
43
75
  integer: boolean;
76
+ /** Step increment for the input spinner, or `null` for any precision. */
44
77
  step: number | null;
78
+ /** Display label for the unit (e.g. `"MB"`, `"seconds"`), shown next to the field. */
45
79
  units: string | null;
46
80
  placeholder: string | null;
47
81
  name: string;
@@ -52,51 +86,67 @@ export type ValueSpecNumber = {
52
86
  disabled: false | string;
53
87
  immutable: boolean;
54
88
  };
89
+ /** Spec for a browser-native color picker field. */
55
90
  export type ValueSpecColor = {
56
91
  name: string;
57
92
  description: string | null;
58
93
  warning: string | null;
59
94
  type: 'color';
60
95
  required: boolean;
96
+ /** Default hex color string (e.g. `"#ff0000"`), or `null`. */
61
97
  default: string | null;
62
98
  disabled: false | string;
63
99
  immutable: boolean;
64
100
  };
101
+ /** Spec for a date, time, or datetime input field. */
65
102
  export type ValueSpecDatetime = {
66
103
  name: string;
67
104
  description: string | null;
68
105
  warning: string | null;
69
106
  type: 'datetime';
70
107
  required: boolean;
108
+ /** Controls which kind of picker is displayed. */
71
109
  inputmode: 'date' | 'time' | 'datetime-local';
110
+ /** Minimum selectable date/time as an ISO string, or `null`. */
72
111
  min: string | null;
112
+ /** Maximum selectable date/time as an ISO string, or `null`. */
73
113
  max: string | null;
74
114
  default: string | null;
75
115
  disabled: false | string;
76
116
  immutable: boolean;
77
117
  };
118
+ /** Spec for a single-select field displayed as radio buttons in a modal. */
78
119
  export type ValueSpecSelect = {
120
+ /** Map of option keys to display labels. */
79
121
  values: Record<string, string>;
80
122
  name: string;
81
123
  description: string | null;
82
124
  warning: string | null;
83
125
  type: 'select';
84
126
  default: string | null;
127
+ /** `false` if all enabled, a string disabling the whole field, or an array of disabled option keys. */
85
128
  disabled: false | string | string[];
86
129
  immutable: boolean;
87
130
  };
131
+ /** Spec for a multi-select field displayed as checkboxes in a modal. */
88
132
  export type ValueSpecMultiselect = {
133
+ /** Map of option keys to display labels. */
89
134
  values: Record<string, string>;
90
135
  name: string;
91
136
  description: string | null;
92
137
  warning: string | null;
93
138
  type: 'multiselect';
139
+ /** Minimum number of selections required, or `null`. */
94
140
  minLength: number | null;
141
+ /** Maximum number of selections allowed, or `null`. */
95
142
  maxLength: number | null;
143
+ /** `false` if all enabled, a string disabling the whole field, or an array of disabled option keys. */
96
144
  disabled: false | string | string[];
145
+ /** Array of option keys selected by default. */
97
146
  default: string[];
98
147
  immutable: boolean;
99
148
  };
149
+ /** Spec for a boolean toggle (on/off switch). */
100
150
  export type ValueSpecToggle = {
101
151
  name: string;
102
152
  description: string | null;
@@ -106,55 +156,83 @@ export type ValueSpecToggle = {
106
156
  disabled: false | string;
107
157
  immutable: boolean;
108
158
  };
159
+ /**
160
+ * Spec for a discriminated union field — displays a dropdown for variant selection,
161
+ * and each variant can have its own nested sub-form.
162
+ */
109
163
  export type ValueSpecUnion = {
110
164
  name: string;
111
165
  description: string | null;
112
166
  warning: string | null;
113
167
  type: 'union';
168
+ /** Map of variant keys to their display name and nested form spec. */
114
169
  variants: Record<string, {
170
+ /** Display name for this variant in the dropdown. */
115
171
  name: string;
172
+ /** Nested form spec shown when this variant is selected. */
116
173
  spec: InputSpec;
117
174
  }>;
175
+ /** `false` if all enabled, a string disabling the whole field, or an array of disabled variant keys. */
118
176
  disabled: false | string | string[];
119
177
  default: string | null;
120
178
  immutable: boolean;
121
179
  };
180
+ /** Spec for a file upload input field. */
122
181
  export type ValueSpecFile = {
123
182
  name: string;
124
183
  description: string | null;
125
184
  warning: string | null;
126
185
  type: 'file';
186
+ /** Allowed file extensions (e.g. `[".pem", ".crt"]`). */
127
187
  extensions: string[];
128
188
  required: boolean;
129
189
  };
190
+ /** Spec for a collapsible grouping of nested fields (a "sub-form"). */
130
191
  export type ValueSpecObject = {
131
192
  name: string;
132
193
  description: string | null;
133
194
  warning: string | null;
134
195
  type: 'object';
196
+ /** The nested form spec containing this object's fields. */
135
197
  spec: InputSpec;
136
198
  };
199
+ /** Spec for a hidden field — not displayed to the user but included in the form data. */
137
200
  export type ValueSpecHidden = {
138
201
  type: 'hidden';
139
202
  };
203
+ /** The two supported list item types. */
140
204
  export type ListValueSpecType = 'text' | 'object';
205
+ /** Maps a {@link ListValueSpecType} to its concrete list item spec. */
141
206
  export type ListValueSpecOf<T extends ListValueSpecType> = T extends "text" ? ListValueSpecText : T extends "object" ? ListValueSpecObject : never;
207
+ /** A list field spec — union of text-list and object-list variants. */
142
208
  export type ValueSpecList = ValueSpecListOf<ListValueSpecType>;
209
+ /**
210
+ * Spec for a list field — an interface to add, remove, and edit items in an ordered collection.
211
+ * The `spec` field determines whether list items are text strings or structured objects.
212
+ */
143
213
  export type ValueSpecListOf<T extends ListValueSpecType> = {
144
214
  name: string;
145
215
  description: string | null;
146
216
  warning: string | null;
147
217
  type: 'list';
218
+ /** The item spec — determines whether this is a list of text values or objects. */
148
219
  spec: ListValueSpecOf<T>;
220
+ /** Minimum number of items, or `null` for no minimum. */
149
221
  minLength: number | null;
222
+ /** Maximum number of items, or `null` for no maximum. */
150
223
  maxLength: number | null;
151
224
  disabled: false | string;
225
+ /** Default list items to populate on creation. */
152
226
  default: string[] | DefaultString[] | Record<string, unknown>[] | readonly string[] | readonly DefaultString[] | readonly Record<string, unknown>[];
153
227
  };
228
+ /** A regex validation pattern with a human-readable description of what it enforces. */
154
229
  export type Pattern = {
230
+ /** The regex pattern string (without delimiters). */
155
231
  regex: string;
232
+ /** A user-facing explanation shown when validation fails (e.g. `"Must be a valid email"`). */
156
233
  description: string;
157
234
  };
235
+ /** Spec for text items within a list field. */
158
236
  export type ListValueSpecText = {
159
237
  type: 'text';
160
238
  patterns: Pattern[];
@@ -165,22 +243,43 @@ export type ListValueSpecText = {
165
243
  inputmode: 'text' | 'email' | 'tel' | 'url';
166
244
  placeholder: string | null;
167
245
  };
246
+ /** Spec for object items within a list field. */
168
247
  export type ListValueSpecObject = {
169
248
  type: 'object';
249
+ /** The form spec for each object item. */
170
250
  spec: InputSpec;
251
+ /** Defines how uniqueness is determined among list items. */
171
252
  uniqueBy: UniqueBy;
253
+ /** An expression used to generate the display string for each item in the list summary (e.g. a key path). */
172
254
  displayAs: string | null;
173
255
  };
256
+ /**
257
+ * Describes how list items determine uniqueness.
258
+ * - `null`: no uniqueness constraint
259
+ * - `string`: unique by a specific field key
260
+ * - `{ any: UniqueBy[] }`: unique if any of the sub-constraints match
261
+ * - `{ all: UniqueBy[] }`: unique if all sub-constraints match together
262
+ */
174
263
  export type UniqueBy = null | string | {
175
264
  any: readonly UniqueBy[] | UniqueBy[];
176
265
  } | {
177
266
  all: readonly UniqueBy[] | UniqueBy[];
178
267
  };
268
+ /** A default value that is either a literal string or a {@link RandomString} generation spec. */
179
269
  export type DefaultString = string | RandomString;
270
+ /** Spec for generating a random string — used for default passwords, API keys, etc. */
180
271
  export type RandomString = {
272
+ /** The character set to draw from (e.g. `"a-zA-Z0-9"`). */
181
273
  charset: string;
274
+ /** The length of the generated string. */
182
275
  len: number;
183
276
  };
277
+ /**
278
+ * Type guard that narrows a {@link ValueSpec} to a {@link ValueSpecListOf} of a specific item type.
279
+ *
280
+ * @param t - The value spec to check
281
+ * @param s - The list item type to narrow to (`"text"` or `"object"`)
282
+ */
184
283
  export declare function isValueSpecListOf<S extends ListValueSpecType>(t: ValueSpec, s: S): t is ValueSpecListOf<S> & {
185
284
  spec: ListValueSpecOf<S>;
186
285
  };
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isValueSpecListOf = isValueSpecListOf;
4
- // sometimes the type checker needs just a little bit of help
4
+ /**
5
+ * Type guard that narrows a {@link ValueSpec} to a {@link ValueSpecListOf} of a specific item type.
6
+ *
7
+ * @param t - The value spec to check
8
+ * @param s - The list item type to narrow to (`"text"` or `"object"`)
9
+ */
5
10
  function isValueSpecListOf(t, s) {
6
11
  return 'spec' in t && t.spec.type === s;
7
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inputSpecTypes.js","sourceRoot":"","sources":["../../../../../base/lib/actions/input/inputSpecTypes.ts"],"names":[],"mappings":";;AAkPA,8CAKC;AAND,6DAA6D;AAC7D,SAAgB,iBAAiB,CAC/B,CAAY,EACZ,CAAI;IAEJ,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAA;AACzC,CAAC"}
1
+ {"version":3,"file":"inputSpecTypes.js","sourceRoot":"","sources":["../../../../../base/lib/actions/input/inputSpecTypes.ts"],"names":[],"mappings":";;AAoVA,8CAKC;AAXD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,CAAY,EACZ,CAAI;IAEJ,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAA;AACzC,CAAC"}
@@ -13,9 +13,9 @@ export type GetInput<A extends Record<string, any>> = (options: {
13
13
  effects: T.Effects;
14
14
  prefill: T.DeepPartial<A> | null;
15
15
  }) => Promise<null | void | undefined | T.DeepPartial<A>>;
16
- export type MaybeFn<T> = T | ((options: {
16
+ export type MaybeFn<T, Opts = {
17
17
  effects: T.Effects;
18
- }) => Promise<T>);
18
+ }> = T | ((options: Opts) => Promise<T>);
19
19
  export interface ActionInfo<Id extends T.ActionId, Type extends Record<string, any>> {
20
20
  readonly id: Id;
21
21
  readonly _INPUT: Type;
@@ -29,7 +29,10 @@ export declare class Action<Id extends T.ActionId, Type extends Record<string, a
29
29
  readonly _INPUT: Type;
30
30
  private prevInputSpec;
31
31
  private constructor();
32
- static withInput<Id extends T.ActionId, InputSpecType extends InputSpec<Record<string, any>>>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, 'hasInput'>>, inputSpec: InputSpecType, getInput: GetInput<ExtractInputSpecType<InputSpecType>>, run: Run<ExtractInputSpecType<InputSpecType>>): Action<Id, ExtractInputSpecType<InputSpecType>>;
32
+ static withInput<Id extends T.ActionId, InputSpecType extends InputSpec<Record<string, any>>>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, 'hasInput'>>, inputSpec: MaybeFn<InputSpecType, {
33
+ effects: T.Effects;
34
+ prefill: unknown | null;
35
+ }>, getInput: GetInput<ExtractInputSpecType<InputSpecType>>, run: Run<ExtractInputSpecType<InputSpecType>>): Action<Id, ExtractInputSpecType<InputSpecType>>;
33
36
  static withoutInput<Id extends T.ActionId>(id: Id, metadata: MaybeFn<Omit<T.ActionMetadata, 'hasInput'>>, run: Run<{}>): Action<Id, {}>;
34
37
  exportMetadata(options: {
35
38
  effects: T.Effects;
@@ -48,9 +48,12 @@ class Action {
48
48
  async getInput(options) {
49
49
  let spec = {};
50
50
  if (this.inputSpec) {
51
- const built = await this.inputSpec.build(options);
52
- this.prevInputSpec[options.effects.eventId] = built;
53
- spec = built.spec;
51
+ const inputSpec = await callMaybeFn(this.inputSpec, options);
52
+ const built = await inputSpec?.build(options);
53
+ if (built) {
54
+ this.prevInputSpec[options.effects.eventId] = built;
55
+ spec = built.spec;
56
+ }
54
57
  }
55
58
  return {
56
59
  eventId: options.effects.eventId,
@@ -65,7 +68,7 @@ class Action {
65
68
  if (!prevInputSpec) {
66
69
  throw new Error(`getActionInput has not been called for EventID ${options.effects.eventId}`);
67
70
  }
68
- options.input = prevInputSpec.validator.unsafeCast(options.input);
71
+ options.input = prevInputSpec.validator.parse(options.input);
69
72
  spec = prevInputSpec.spec;
70
73
  }
71
74
  return ((await this.runFn({
@@ -1 +1 @@
1
- {"version":3,"file":"setupActions.js","sourceRoot":"","sources":["../../../../base/lib/actions/setupActions.ts"],"names":[],"mappings":";;;AAGA,kCAA8B;AAgB9B,SAAS,WAAW,CAClB,OAAmB,EACnB,OAA+B;IAE/B,IAAI,OAAO,YAAY,QAAQ,EAAE,CAAC;QAChC,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