@highstate/contract 0.27.0 → 0.28.0
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.js +6 -4
- package/package.json +2 -2
- package/src/component.ts +30 -25
- package/src/entity.ts +53 -51
- package/src/instance.ts +76 -74
- package/src/utils.ts +22 -23
package/dist/index.js
CHANGED
|
@@ -599,7 +599,7 @@ var instanceModelPatchSchema = z4.object({
|
|
|
599
599
|
inputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
|
|
600
600
|
hubInputs: z4.record(z4.string(), z4.array(hubInputSchema)).optional(),
|
|
601
601
|
injectionInputs: z4.array(hubInputSchema).optional(),
|
|
602
|
-
position: positionSchema.optional()
|
|
602
|
+
position: positionSchema.partial().nullable().optional()
|
|
603
603
|
});
|
|
604
604
|
var instanceModelSchema = z4.object({
|
|
605
605
|
id: instanceIdSchema,
|
|
@@ -607,19 +607,21 @@ var instanceModelSchema = z4.object({
|
|
|
607
607
|
type: versionedNameSchema,
|
|
608
608
|
name: genericNameSchema,
|
|
609
609
|
...instanceModelPatchSchema.shape,
|
|
610
|
+
position: positionSchema.optional(),
|
|
610
611
|
resolvedInputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
|
|
611
612
|
parentId: instanceIdSchema.optional(),
|
|
612
613
|
outputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional(),
|
|
613
614
|
resolvedOutputs: z4.record(z4.string(), z4.array(instanceInputSchema)).optional()
|
|
614
615
|
});
|
|
615
616
|
var hubModelPatchSchema = z4.object({
|
|
616
|
-
position: positionSchema.optional(),
|
|
617
|
+
position: positionSchema.partial().nullable().optional(),
|
|
617
618
|
inputs: z4.array(instanceInputSchema).optional(),
|
|
618
619
|
injectionInputs: z4.array(hubInputSchema).optional()
|
|
619
620
|
});
|
|
620
621
|
var hubModelSchema = z4.object({
|
|
621
622
|
id: z4.cuid2(),
|
|
622
|
-
...hubModelPatchSchema.shape
|
|
623
|
+
...hubModelPatchSchema.shape,
|
|
624
|
+
position: positionSchema.optional()
|
|
623
625
|
});
|
|
624
626
|
function parseInstanceId(instanceId) {
|
|
625
627
|
const parts = instanceId.split(":");
|
|
@@ -634,7 +636,7 @@ function selectInput(inputs, name) {
|
|
|
634
636
|
throw new Error(`Cannot select input "${name}": empty input group has no boundary metadata to build a missing input reference.`);
|
|
635
637
|
}
|
|
636
638
|
const input = inputs.find((input2) => input2.provided && (input2.instanceId === name || parseInstanceId(input2.instanceId)[1] === name));
|
|
637
|
-
if (!input
|
|
639
|
+
if (!input?.provided) {
|
|
638
640
|
const fallbackBoundary = groupBoundary ?? inputs.find((input2) => Boolean(input2[boundaryInput]))?.[boundaryInput] ?? inputs[0]?.[boundaryInput];
|
|
639
641
|
if (!fallbackBoundary) {
|
|
640
642
|
throw new Error(`Cannot select input "${name}": input group has no boundary metadata to build a missing input reference.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@highstate/contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"zod": "^4.3.6"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@biomejs/biome": "2.
|
|
47
|
+
"@biomejs/biome": "2.5.0",
|
|
48
48
|
"@typescript/native-preview": "^7.0.0-dev.20250920.1",
|
|
49
49
|
"@vitest/coverage-v8": "2.1.8",
|
|
50
50
|
"vitest": "^3.2.4"
|
package/src/component.ts
CHANGED
|
@@ -194,13 +194,14 @@ export type ComponentInputOptionsToSpec<T extends ComponentInputOptions> = T ext
|
|
|
194
194
|
export type ComponentOutputOptionsToSpec<
|
|
195
195
|
TOutput extends ComponentOutputOptions<TInputs>,
|
|
196
196
|
TInputs extends Record<string, ComponentInputOptions>,
|
|
197
|
-
> =
|
|
198
|
-
|
|
199
|
-
?
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
> =
|
|
198
|
+
TOutput extends FromInputComponentOutputOptions<infer TInputName>
|
|
199
|
+
? TInputName extends keyof TInputs
|
|
200
|
+
? ComponentInputOptionsToSpec<TInputs[TInputName]>
|
|
201
|
+
: never
|
|
202
|
+
: TOutput extends ComponentInputOptions
|
|
203
|
+
? ComponentInputOptionsToSpec<TOutput>
|
|
204
|
+
: never
|
|
204
205
|
|
|
205
206
|
export type ComponentInputOptionsMapToSpecMap<T extends Record<string, ComponentInputOptions>> =
|
|
206
207
|
T extends Record<string, never>
|
|
@@ -221,9 +222,10 @@ type ComponentOutputMapToCreateOutputValue<
|
|
|
221
222
|
type ComponentOutputMapToReturnType<
|
|
222
223
|
TOutputs extends Record<string, ComponentOutputOptions<TInputs>>,
|
|
223
224
|
TInputs extends Record<string, ComponentInputOptions>,
|
|
224
|
-
> =
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
> =
|
|
226
|
+
TOutputs extends Record<string, never> // biome-ignore lint/suspicious/noConfusingVoidType: this is return type
|
|
227
|
+
? void
|
|
228
|
+
: Partial<ComponentOutputMapToCreateOutputValue<TOutputs, TInputs>>
|
|
227
229
|
|
|
228
230
|
export type ComponentParams<
|
|
229
231
|
TArgs extends Record<string, ComponentArgumentOptions>,
|
|
@@ -397,13 +399,14 @@ export type InputSpecMapToInputRefMap<TInputs extends Record<string, ComponentIn
|
|
|
397
399
|
export type OutputRefMap<
|
|
398
400
|
TInputs extends Record<string, ComponentInputSpec>,
|
|
399
401
|
TKind extends ComponentKind = "composite",
|
|
400
|
-
> =
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
402
|
+
> =
|
|
403
|
+
TInputs extends Record<string, [string, never, never]>
|
|
404
|
+
? Record<string, never>
|
|
405
|
+
: {
|
|
406
|
+
[K in keyof TInputs]: TKind extends "unit"
|
|
407
|
+
? InputSpecToUnitOutputRef<TInputs[K]>
|
|
408
|
+
: InputSpecToCompositeOutputRef<TInputs[K]>
|
|
409
|
+
}
|
|
407
410
|
|
|
408
411
|
type StaticOutputRefByKind<
|
|
409
412
|
TOutputSpec extends ComponentInputSpec,
|
|
@@ -426,9 +429,10 @@ type ResolveOutputRefForCall<
|
|
|
426
429
|
TCallInputs extends Record<string, unknown>,
|
|
427
430
|
TFallbackSpec extends ComponentInputSpec,
|
|
428
431
|
TKind extends ComponentKind,
|
|
429
|
-
> =
|
|
430
|
-
|
|
431
|
-
|
|
432
|
+
> =
|
|
433
|
+
TOutputOption extends FromInputComponentOutputOptions<infer TInputName>
|
|
434
|
+
? ResolveForwardedOutputRef<TInputName, TCallInputs, TFallbackSpec, TKind>
|
|
435
|
+
: StaticOutputRefByKind<TFallbackSpec, TKind>
|
|
432
436
|
|
|
433
437
|
type ResolveOutputRefMapForCall<
|
|
434
438
|
TOutputSpecs extends Record<string, ComponentInputSpec>,
|
|
@@ -449,11 +453,12 @@ type IncludesAllExpectedTypes<
|
|
|
449
453
|
TExpected extends Record<string, unknown>,
|
|
450
454
|
> = Exclude<keyof TExpected, keyof TProvided> extends never ? true : false
|
|
451
455
|
|
|
452
|
-
type ExtractProvidedInputTypes<TValue> =
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
type ExtractProvidedInputTypes<TValue> =
|
|
457
|
+
TValue extends RuntimeInput<infer TTypes, any>
|
|
458
|
+
? TTypes
|
|
459
|
+
: TValue extends Array<infer TItem>
|
|
460
|
+
? ExtractProvidedInputTypes<TItem>
|
|
461
|
+
: never
|
|
457
462
|
|
|
458
463
|
type ValidateProvidedInputValue<TValue, TExpectedSpec extends ComponentInputSpec> = [
|
|
459
464
|
ExtractProvidedInputTypes<TValue>,
|
package/src/entity.ts
CHANGED
|
@@ -177,23 +177,25 @@ type IsIncludeRequired<TIncludeRef> = TIncludeRef extends { required?: infer R }
|
|
|
177
177
|
: true
|
|
178
178
|
: true
|
|
179
179
|
|
|
180
|
-
type IsOptionalOutputInclude<TIncludeRef> =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
type IsOptionalOutputInclude<TIncludeRef> =
|
|
181
|
+
IsIncludeMultiple<TIncludeRef> extends true
|
|
182
|
+
? false
|
|
183
|
+
: IsIncludeRequired<TIncludeRef> extends false
|
|
184
|
+
? true
|
|
185
|
+
: false
|
|
185
186
|
|
|
186
|
-
type IsOptionalInputInclude<TIncludeRef> =
|
|
187
|
-
? true
|
|
188
|
-
: false
|
|
187
|
+
type IsOptionalInputInclude<TIncludeRef> =
|
|
188
|
+
IsIncludeRequired<TIncludeRef> extends false ? true : false
|
|
189
189
|
|
|
190
|
-
type IncludeOutputValue<TIncludeRef> =
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
type IncludeOutputValue<TIncludeRef> =
|
|
191
|
+
IsIncludeMultiple<TIncludeRef> extends true
|
|
192
|
+
? EntityValue<ResolveIncludeEntity<TIncludeRef>>[]
|
|
193
|
+
: EntityValue<ResolveIncludeEntity<TIncludeRef>>
|
|
193
194
|
|
|
194
|
-
type IncludeInputValue<TIncludeRef> =
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
type IncludeInputValue<TIncludeRef> =
|
|
196
|
+
IsIncludeMultiple<TIncludeRef> extends true
|
|
197
|
+
? EntityValueInput<ResolveIncludeEntity<TIncludeRef>>[]
|
|
198
|
+
: EntityValueInput<ResolveIncludeEntity<TIncludeRef>>
|
|
197
199
|
|
|
198
200
|
type InclusionValueShape<TIncludes extends Record<string, EntityIncludeRef>> =
|
|
199
201
|
TIncludes extends Record<string, never>
|
|
@@ -330,58 +332,58 @@ type InclusionShape<TImplements extends Record<string, EntityIncludeRef>> = {
|
|
|
330
332
|
: never
|
|
331
333
|
}
|
|
332
334
|
|
|
333
|
-
type AddSchemaExtensions<
|
|
334
|
-
|
|
335
|
-
TExtends extends Record<string, Entity>,
|
|
336
|
-
> = TExtends extends Record<string, never>
|
|
337
|
-
? TSchema
|
|
338
|
-
: IsEmptyObject<TExtends> extends true
|
|
335
|
+
type AddSchemaExtensions<TSchema extends z.ZodTypeAny, TExtends extends Record<string, Entity>> =
|
|
336
|
+
TExtends extends Record<string, never>
|
|
339
337
|
? TSchema
|
|
340
|
-
:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
338
|
+
: IsEmptyObject<TExtends> extends true
|
|
339
|
+
? TSchema
|
|
340
|
+
: {
|
|
341
|
+
[K in keyof TExtends]: AddSchemaExtensions<
|
|
342
|
+
z.ZodIntersection<TSchema, TExtends[K]["schema"]>,
|
|
343
|
+
Omit<TExtends, K>
|
|
344
|
+
>
|
|
345
|
+
}[keyof TExtends]
|
|
346
346
|
|
|
347
347
|
type AddTypeExtensions<
|
|
348
348
|
TImplementedTypes extends EntityTypes,
|
|
349
349
|
TExtends extends Record<string, Entity>,
|
|
350
|
-
> =
|
|
351
|
-
|
|
352
|
-
: IsEmptyObject<TExtends> extends true
|
|
350
|
+
> =
|
|
351
|
+
TExtends extends Record<string, never>
|
|
353
352
|
? TImplementedTypes
|
|
354
|
-
:
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
353
|
+
: IsEmptyObject<TExtends> extends true
|
|
354
|
+
? TImplementedTypes
|
|
355
|
+
: {
|
|
356
|
+
[K in keyof TExtends]: AddTypeExtensions<
|
|
357
|
+
TImplementedTypes & TExtends[K][typeof implementedTypes],
|
|
358
|
+
Omit<TExtends, K>
|
|
359
|
+
>
|
|
360
|
+
}[keyof TExtends]
|
|
360
361
|
|
|
361
362
|
type AddIncludeExtensions<
|
|
362
363
|
TIncludes extends Record<string, EntityIncludeRef>,
|
|
363
364
|
TExtends extends Record<string, Entity>,
|
|
364
|
-
> =
|
|
365
|
-
|
|
366
|
-
: IsEmptyObject<TExtends> extends true
|
|
365
|
+
> =
|
|
366
|
+
TExtends extends Record<string, never>
|
|
367
367
|
? TIncludes
|
|
368
|
-
:
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
368
|
+
: IsEmptyObject<TExtends> extends true
|
|
369
|
+
? TIncludes
|
|
370
|
+
: {
|
|
371
|
+
[K in keyof TExtends]: AddIncludeExtensions<
|
|
372
|
+
TIncludes & ExtractEntityIncludes<TExtends[K][typeof entityIncludes]>,
|
|
373
|
+
Omit<TExtends, K>
|
|
374
|
+
>
|
|
375
|
+
}[keyof TExtends]
|
|
376
|
+
|
|
377
|
+
type ExtractEntityIncludes<T> =
|
|
378
|
+
T extends Record<string, EntityIncludeRef> ? T : Record<string, never>
|
|
378
379
|
|
|
379
380
|
type AddSchemaInclusions<
|
|
380
381
|
TSchema extends z.ZodTypeAny,
|
|
381
382
|
TImplements extends Record<string, EntityIncludeRef>,
|
|
382
|
-
> =
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
> =
|
|
384
|
+
TImplements extends Record<string, never>
|
|
385
|
+
? TSchema
|
|
386
|
+
: z.ZodIntersection<TSchema, z.ZodObject<InclusionShape<TImplements>>>
|
|
385
387
|
|
|
386
388
|
/**
|
|
387
389
|
* The common ancestor of all entities. Any entity can be assigned to this entity.
|
package/src/instance.ts
CHANGED
|
@@ -86,19 +86,20 @@ export type RequiredMultipleInput<TInput extends RuntimeInput = RuntimeInput> =
|
|
|
86
86
|
export type RequiredMultipleInputs<TInput extends RuntimeInput = RuntimeInput> =
|
|
87
87
|
RequiredMultipleInput<TInput>
|
|
88
88
|
|
|
89
|
-
export type EntityInput<TEntity extends Entity> =
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
export type EntityInput<TEntity extends Entity> =
|
|
90
|
+
TEntity extends Entity<
|
|
91
|
+
VersionedName,
|
|
92
|
+
infer TImplementedTypes,
|
|
93
|
+
z.ZodTypeAny,
|
|
94
|
+
unknown,
|
|
95
|
+
unknown,
|
|
96
|
+
infer TIncludes
|
|
97
|
+
>
|
|
98
|
+
? RuntimeInput<TImplementedTypes, undefined> &
|
|
99
|
+
(TIncludes extends Record<string, EntityIncludeRef>
|
|
100
|
+
? EntityInputIncludes<TIncludes>
|
|
101
|
+
: Record<never, never>)
|
|
102
|
+
: never
|
|
102
103
|
|
|
103
104
|
export type RequiredEntityInput<TEntity extends Entity> = RequiredInput<EntityInput<TEntity>>
|
|
104
105
|
|
|
@@ -126,34 +127,32 @@ type IncludeRequired<TIncludeRef> = TIncludeRef extends { required?: infer R }
|
|
|
126
127
|
: true
|
|
127
128
|
: true
|
|
128
129
|
|
|
129
|
-
type IncludeRefValue<
|
|
130
|
-
TIncludeRef
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
? LiftMultipleSelectorFields<EntityInputIncludes<TIncludes, DecDepth<TDepth>>>
|
|
130
|
+
type IncludeRefValue<TIncludeRef, TDepth extends readonly unknown[]> =
|
|
131
|
+
ResolveIncludeEntity<TIncludeRef> extends infer TEntity
|
|
132
|
+
? TEntity extends Entity
|
|
133
|
+
? IncludeMultiple<TIncludeRef> extends true
|
|
134
|
+
? MultipleInput<
|
|
135
|
+
EntityInputWithDepth<TEntity, TDepth>,
|
|
136
|
+
TDepth extends readonly []
|
|
137
|
+
? Record<never, never>
|
|
138
|
+
: TEntity extends Entity<
|
|
139
|
+
VersionedName,
|
|
140
|
+
EntityTypes,
|
|
141
|
+
z.ZodTypeAny,
|
|
142
|
+
unknown,
|
|
143
|
+
unknown,
|
|
144
|
+
infer TIncludes
|
|
145
|
+
>
|
|
146
|
+
? TIncludes extends Record<string, EntityIncludeRef>
|
|
147
|
+
? LiftMultipleSelectorFields<EntityInputIncludes<TIncludes, DecDepth<TDepth>>>
|
|
148
|
+
: Record<never, never>
|
|
149
149
|
: Record<never, never>
|
|
150
|
-
|
|
151
|
-
>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
>
|
|
151
|
+
: IncludeRequired<TIncludeRef> extends false
|
|
152
|
+
? OptionalEntityInput<TEntity, TDepth>
|
|
153
|
+
: EntityInputWithDepth<TEntity, TDepth>
|
|
154
|
+
: never
|
|
155
155
|
: never
|
|
156
|
-
: never
|
|
157
156
|
|
|
158
157
|
type OptionalEntityInput<TEntity extends Entity, TDepth extends readonly unknown[]> =
|
|
159
158
|
| ({ provided: true } & EntityInputWithDepth<TEntity, TDepth>)
|
|
@@ -185,11 +184,12 @@ type RuntimeInputSelectorFields<TInput extends RuntimeInput> = {
|
|
|
185
184
|
: K]: LiftMultipleSelectorValue<TInput[K]>
|
|
186
185
|
}
|
|
187
186
|
|
|
188
|
-
type LiftMultipleSelectorValue<T> =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
187
|
+
type LiftMultipleSelectorValue<T> =
|
|
188
|
+
T extends MultipleInput<infer TItem, infer TSelectors>
|
|
189
|
+
? MultipleInput<TItem, LiftMultipleSelectorFields<TSelectors>>
|
|
190
|
+
: T extends RuntimeInput
|
|
191
|
+
? MultipleInput<T, RuntimeInputSelectorFields<T>>
|
|
192
|
+
: T
|
|
193
193
|
|
|
194
194
|
type LiftMultipleSelectorFields<TSelectors extends Record<string, unknown>> = {
|
|
195
195
|
[K in keyof TSelectors]: LiftMultipleSelectorValue<TSelectors[K]>
|
|
@@ -201,43 +201,41 @@ type OptionalizedInputFields<TInput extends RuntimeInput> = {
|
|
|
201
201
|
: K]: OptionalizeInputValue<TInput[K]>
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
type EntityInputWithDepth<
|
|
205
|
-
TEntity extends Entity
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
: Record<never, never>)
|
|
221
|
-
: never
|
|
204
|
+
type EntityInputWithDepth<TEntity extends Entity, TDepth extends readonly unknown[]> =
|
|
205
|
+
TEntity extends Entity<
|
|
206
|
+
VersionedName,
|
|
207
|
+
infer TImplementedTypes,
|
|
208
|
+
z.ZodTypeAny,
|
|
209
|
+
unknown,
|
|
210
|
+
unknown,
|
|
211
|
+
infer TIncludes
|
|
212
|
+
>
|
|
213
|
+
? RuntimeInput<TImplementedTypes, undefined> &
|
|
214
|
+
(TDepth extends readonly []
|
|
215
|
+
? Record<never, never>
|
|
216
|
+
: TIncludes extends Record<string, EntityIncludeRef>
|
|
217
|
+
? EntityInputIncludes<TIncludes, DecDepth<TDepth>>
|
|
218
|
+
: Record<never, never>)
|
|
219
|
+
: never
|
|
222
220
|
|
|
223
221
|
type EntityInputIncludes<
|
|
224
222
|
TIncludes extends Record<string, EntityIncludeRef>,
|
|
225
223
|
TDepth extends readonly unknown[] = EntityInputDepth,
|
|
226
|
-
> =
|
|
227
|
-
|
|
228
|
-
: string extends keyof TIncludes
|
|
224
|
+
> =
|
|
225
|
+
TIncludes extends Record<string, never>
|
|
229
226
|
? Record<never, never>
|
|
230
|
-
:
|
|
231
|
-
|
|
232
|
-
|
|
227
|
+
: string extends keyof TIncludes
|
|
228
|
+
? Record<never, never>
|
|
229
|
+
: {
|
|
230
|
+
[K in keyof TIncludes]: IncludeRefValue<TIncludes[K], TDepth>
|
|
231
|
+
}
|
|
233
232
|
|
|
234
233
|
export type InstanceInputGroup<TTypes extends EntityTypes = EntityTypes> = MultipleInput<
|
|
235
234
|
RuntimeInput<TTypes>
|
|
236
235
|
>
|
|
237
236
|
|
|
238
|
-
type SelectInputResult<TInput extends RuntimeInput> =
|
|
239
|
-
? TRuntime
|
|
240
|
-
: TInput
|
|
237
|
+
type SelectInputResult<TInput extends RuntimeInput> =
|
|
238
|
+
TInput extends RequiredInput<infer TRuntime> ? TRuntime : TInput
|
|
241
239
|
|
|
242
240
|
export const positionSchema = z.object({
|
|
243
241
|
x: z.number(),
|
|
@@ -295,7 +293,7 @@ export const instanceModelPatchSchema = z.object({
|
|
|
295
293
|
*
|
|
296
294
|
* Only for designer-first instances.
|
|
297
295
|
*/
|
|
298
|
-
position: positionSchema.optional(),
|
|
296
|
+
position: positionSchema.partial().nullable().optional(),
|
|
299
297
|
})
|
|
300
298
|
|
|
301
299
|
export const instanceModelSchema = z.object({
|
|
@@ -327,6 +325,8 @@ export const instanceModelSchema = z.object({
|
|
|
327
325
|
|
|
328
326
|
...instanceModelPatchSchema.shape,
|
|
329
327
|
|
|
328
|
+
position: positionSchema.optional(),
|
|
329
|
+
|
|
330
330
|
/**
|
|
331
331
|
* The id of the top level parent instance.
|
|
332
332
|
*
|
|
@@ -362,7 +362,7 @@ export const hubModelPatchSchema = z.object({
|
|
|
362
362
|
/**
|
|
363
363
|
* The position of the hub on the canvas.
|
|
364
364
|
*/
|
|
365
|
-
position: positionSchema.optional(),
|
|
365
|
+
position: positionSchema.partial().nullable().optional(),
|
|
366
366
|
|
|
367
367
|
/**
|
|
368
368
|
* The inputs of the hub.
|
|
@@ -385,6 +385,8 @@ export const hubModelSchema = z.object({
|
|
|
385
385
|
id: z.cuid2(),
|
|
386
386
|
|
|
387
387
|
...hubModelPatchSchema.shape,
|
|
388
|
+
|
|
389
|
+
position: positionSchema.optional(),
|
|
388
390
|
})
|
|
389
391
|
|
|
390
392
|
export type InstanceModelPatch = z.infer<typeof instanceModelPatchSchema>
|
|
@@ -439,7 +441,7 @@ export function selectInput<TInput extends RuntimeInput>(
|
|
|
439
441
|
(input.instanceId === name || parseInstanceId(input.instanceId)[1] === name),
|
|
440
442
|
)
|
|
441
443
|
|
|
442
|
-
if (!input
|
|
444
|
+
if (!input?.provided) {
|
|
443
445
|
const fallbackBoundary =
|
|
444
446
|
groupBoundary ??
|
|
445
447
|
inputs.find(input => Boolean(input[boundaryInput]))?.[boundaryInput] ??
|
package/src/utils.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import type { z } from "zod"
|
|
2
2
|
import { isNonNullish, pickBy } from "remeda"
|
|
3
3
|
|
|
4
|
-
type PickUndefinedKeys<T extends Record<string, unknown>> =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: true
|
|
4
|
+
type PickUndefinedKeys<T extends Record<string, unknown>> =
|
|
5
|
+
T extends Record<string, never>
|
|
6
|
+
? never
|
|
7
|
+
: Exclude<
|
|
8
|
+
{
|
|
9
|
+
[K in keyof T]: undefined extends T[K] ? K : never
|
|
10
|
+
}[keyof T],
|
|
11
|
+
undefined
|
|
12
|
+
>
|
|
13
|
+
|
|
14
|
+
type AllOptionalKeys<T extends Record<string, unknown>> =
|
|
15
|
+
T extends Record<string, never>
|
|
16
|
+
? never
|
|
17
|
+
: Exclude<
|
|
18
|
+
{
|
|
19
|
+
[K in keyof T]: undefined extends T[K] ? K : never
|
|
20
|
+
}[keyof T],
|
|
21
|
+
undefined
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
type HasRequired<T extends Record<string, unknown>> =
|
|
25
|
+
T extends Record<string, never> ? false : [keyof T] extends [AllOptionalKeys<T>] ? false : true
|
|
27
26
|
|
|
28
27
|
type PickRecordsWithAnyRequired<T extends Record<string, Record<string, unknown>>> =
|
|
29
28
|
T extends Record<string, never>
|