skedyul 0.1.38 → 0.1.40

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/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1768437850820
1
+ 1768537680901
package/dist/config.d.ts CHANGED
@@ -127,12 +127,27 @@ export interface ChannelToolBindings {
127
127
  }
128
128
  /** Scope of a model: INTERNAL (app-owned) or SHARED (user-mapped) */
129
129
  export type ResourceScope = 'INTERNAL' | 'SHARED';
130
+ /**
131
+ * Field-level data ownership.
132
+ * APP: App exclusively controls this data (e.g., status field set by webhook)
133
+ * WORKPLACE: User/organization provides this data (e.g., file upload)
134
+ * BOTH: Collaborative - either can update
135
+ */
136
+ export type FieldOwner = 'APP' | 'WORKPLACE' | 'BOTH';
137
+ /**
138
+ * StructuredFilter for conditional dependencies.
139
+ * Format: { fieldHandle: { operator: value | value[] } }
140
+ * Operators: eq, neq, gt, gte, lt, lte, contains, etc.
141
+ */
142
+ export type StructuredFilter = Record<string, Record<string, string | number | boolean | (string | number | boolean)[]>>;
130
143
  /** Model dependency reference */
131
144
  export interface ModelDependency {
132
145
  /** Handle of the model being depended upon */
133
146
  model: string;
134
147
  /** Specific fields required (undefined = all fields) */
135
148
  fields?: string[];
149
+ /** Conditions the dependency instance must satisfy (StructuredFilter format) */
150
+ where?: StructuredFilter;
136
151
  }
137
152
  /** Channel dependency reference */
138
153
  export interface ChannelDependency {
@@ -146,6 +161,37 @@ export interface WorkflowDependency {
146
161
  }
147
162
  /** Union of all resource dependency types */
148
163
  export type ResourceDependency = ModelDependency | ChannelDependency | WorkflowDependency;
164
+ /** Option for choice/enum fields */
165
+ export interface FieldOption {
166
+ /** Display label */
167
+ label: string;
168
+ /** Value stored in database */
169
+ value: string;
170
+ /** Optional color for UI display */
171
+ color?: string;
172
+ }
173
+ /**
174
+ * Inline field definition (constraints, options, etc.)
175
+ * Allows defining field behavior without referencing a metafield definition.
176
+ */
177
+ export interface InlineFieldDefinition {
178
+ /** For choice fields: number of selections allowed (1 = single select, >1 = multi) */
179
+ limitChoices?: number;
180
+ /** For choice fields: available options */
181
+ options?: FieldOption[];
182
+ /** For string fields: min length */
183
+ minLength?: number;
184
+ /** For string fields: max length */
185
+ maxLength?: number;
186
+ /** For number fields: min value */
187
+ min?: number;
188
+ /** For number fields: max value */
189
+ max?: number;
190
+ /** For relation fields: target model handle */
191
+ relatedModel?: string;
192
+ /** Validation regex pattern */
193
+ pattern?: string;
194
+ }
149
195
  /** Field definition for unified models (works for INTERNAL and SHARED) */
150
196
  export interface ModelFieldDefinition {
151
197
  /** Field handle (unique within model) */
@@ -154,8 +200,10 @@ export interface ModelFieldDefinition {
154
200
  label: string;
155
201
  /** Data type (required for INTERNAL, optional for SHARED) */
156
202
  type?: InternalFieldDataType;
157
- /** Field definition handle for SHARED fields */
203
+ /** Field definition handle for SHARED fields (references a metafield definition) */
158
204
  definitionHandle?: string;
205
+ /** Inline field definition (alternative to definitionHandle for INTERNAL fields) */
206
+ definition?: InlineFieldDefinition;
159
207
  /** Whether field is required */
160
208
  required?: boolean;
161
209
  /** Whether field must be unique */
@@ -172,6 +220,8 @@ export interface ModelFieldDefinition {
172
220
  description?: string;
173
221
  /** Visibility settings (for SHARED fields) */
174
222
  visibility?: AppFieldVisibility;
223
+ /** Data ownership: APP (app controls), WORKPLACE (user provides), BOTH (collaborative) */
224
+ owner?: FieldOwner;
175
225
  }
176
226
  /** Unified model definition (supports both INTERNAL and SHARED) */
177
227
  export interface ModelDefinition {
@@ -189,6 +239,32 @@ export interface ModelDefinition {
189
239
  description?: string;
190
240
  /** Field definitions */
191
241
  fields: ModelFieldDefinition[];
242
+ /** Model-level dependencies - other models this model requires to be provisioned */
243
+ requires?: ResourceDependency[];
244
+ }
245
+ /** Relationship cardinality */
246
+ export type RelationshipCardinality = 'ONE_TO_ONE' | 'ONE_TO_MANY' | 'MANY_TO_ONE' | 'MANY_TO_MANY';
247
+ /** On-delete behavior for relationships */
248
+ export type OnDeleteBehavior = 'NONE' | 'CASCADE' | 'RESTRICT';
249
+ /** One side of a relationship */
250
+ export interface RelationshipLink {
251
+ /** Model handle for this side */
252
+ model: string;
253
+ /** Field handle on this model */
254
+ field: string;
255
+ /** Field label for display */
256
+ label: string;
257
+ /** Cardinality from this side */
258
+ cardinality: RelationshipCardinality;
259
+ /** On-delete behavior */
260
+ onDelete?: OnDeleteBehavior;
261
+ }
262
+ /** Bidirectional relationship definition between two models */
263
+ export interface RelationshipDefinition {
264
+ /** Source side of the relationship */
265
+ source: RelationshipLink;
266
+ /** Target side of the relationship */
267
+ target: RelationshipLink;
192
268
  }
193
269
  export type ChannelIdentifierType = 'DEDICATED_PHONE' | 'TEXT' | 'EMAIL';
194
270
  export interface ChannelIdentifierValue {
@@ -398,6 +474,34 @@ export interface SkedyulConfig {
398
474
  * ```
399
475
  */
400
476
  models?: ModelDefinition[];
477
+ /**
478
+ * Relationships between models.
479
+ * Defines bidirectional links between INTERNAL models.
480
+ * Creates relationship fields on both sides automatically.
481
+ *
482
+ * @example
483
+ * ```typescript
484
+ * relationships: [
485
+ * {
486
+ * source: {
487
+ * model: 'phone_number',
488
+ * field: 'compliance_record',
489
+ * label: 'Compliance Record',
490
+ * cardinality: 'MANY_TO_ONE',
491
+ * onDelete: 'RESTRICT',
492
+ * },
493
+ * target: {
494
+ * model: 'compliance_record',
495
+ * field: 'phone_numbers',
496
+ * label: 'Phone Numbers',
497
+ * cardinality: 'ONE_TO_MANY',
498
+ * onDelete: 'NONE',
499
+ * },
500
+ * },
501
+ * ]
502
+ * ```
503
+ */
504
+ relationships?: RelationshipDefinition[];
401
505
  /**
402
506
  * Communication channels this app provides (new syntax).
403
507
  * Uses typed `requires` for dependencies.
package/dist/schemas.d.ts CHANGED
@@ -125,6 +125,19 @@ export declare const ResourceScopeSchema: z.ZodEnum<{
125
125
  INTERNAL: "INTERNAL";
126
126
  SHARED: "SHARED";
127
127
  }>;
128
+ /**
129
+ * Schema for field-level data ownership.
130
+ * Describes who owns/controls the data in a field.
131
+ * APP: App exclusively controls this data (e.g., status field set by webhook)
132
+ * WORKPLACE: User/organization provides this data (e.g., file upload)
133
+ * BOTH: Collaborative - either can update
134
+ */
135
+ export declare const FieldOwnerSchema: z.ZodEnum<{
136
+ APP: "APP";
137
+ WORKPLACE: "WORKPLACE";
138
+ BOTH: "BOTH";
139
+ }>;
140
+ export declare const StructuredFilterSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>;
128
141
  /**
129
142
  * Schema for a model dependency reference.
130
143
  * Used in `requires` arrays to specify model dependencies.
@@ -132,6 +145,7 @@ export declare const ResourceScopeSchema: z.ZodEnum<{
132
145
  export declare const ModelDependencySchema: z.ZodObject<{
133
146
  model: z.ZodString;
134
147
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
148
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
135
149
  }, z.core.$strip>;
136
150
  /**
137
151
  * Schema for a channel dependency reference.
@@ -154,6 +168,7 @@ export declare const WorkflowDependencySchema: z.ZodObject<{
154
168
  export declare const ResourceDependencySchema: z.ZodUnion<readonly [z.ZodObject<{
155
169
  model: z.ZodString;
156
170
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
171
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
157
172
  }, z.core.$strip>, z.ZodObject<{
158
173
  channel: z.ZodString;
159
174
  }, z.core.$strip>, z.ZodObject<{
@@ -198,6 +213,7 @@ export declare const CommunicationChannelDefinitionSchema: z.ZodObject<{
198
213
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
199
214
  model: z.ZodString;
200
215
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
216
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
201
217
  }, z.core.$strip>, z.ZodObject<{
202
218
  channel: z.ZodString;
203
219
  }, z.core.$strip>, z.ZodObject<{
@@ -243,6 +259,7 @@ export declare const ChannelDefinitionSchema: z.ZodObject<{
243
259
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
244
260
  model: z.ZodString;
245
261
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
262
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
246
263
  }, z.core.$strip>, z.ZodObject<{
247
264
  channel: z.ZodString;
248
265
  }, z.core.$strip>, z.ZodObject<{
@@ -290,6 +307,7 @@ export declare const WorkflowDefinitionSchema: z.ZodObject<{
290
307
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
291
308
  model: z.ZodString;
292
309
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
310
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
293
311
  }, z.core.$strip>, z.ZodObject<{
294
312
  channel: z.ZodString;
295
313
  }, z.core.$strip>, z.ZodObject<{
@@ -335,6 +353,106 @@ export declare const FieldDataTypeSchema: z.ZodEnum<{
335
353
  RELATION: "RELATION";
336
354
  OBJECT: "OBJECT";
337
355
  }>;
356
+ /**
357
+ * Schema for an option in a choice/enum field.
358
+ */
359
+ export declare const FieldOptionSchema: z.ZodObject<{
360
+ label: z.ZodString;
361
+ value: z.ZodString;
362
+ color: z.ZodOptional<z.ZodString>;
363
+ }, z.core.$strip>;
364
+ /**
365
+ * Schema for relationship cardinality.
366
+ * Defines how many records can be linked on each side.
367
+ */
368
+ export declare const RelationshipCardinalitySchema: z.ZodEnum<{
369
+ ONE_TO_ONE: "ONE_TO_ONE";
370
+ ONE_TO_MANY: "ONE_TO_MANY";
371
+ MANY_TO_ONE: "MANY_TO_ONE";
372
+ MANY_TO_MANY: "MANY_TO_MANY";
373
+ }>;
374
+ /**
375
+ * Schema for on-delete behavior in relationships.
376
+ */
377
+ export declare const OnDeleteBehaviorSchema: z.ZodEnum<{
378
+ NONE: "NONE";
379
+ CASCADE: "CASCADE";
380
+ RESTRICT: "RESTRICT";
381
+ }>;
382
+ /**
383
+ * Schema for a relationship link (one side of a relationship).
384
+ */
385
+ export declare const RelationshipLinkSchema: z.ZodObject<{
386
+ model: z.ZodString;
387
+ field: z.ZodString;
388
+ label: z.ZodString;
389
+ cardinality: z.ZodEnum<{
390
+ ONE_TO_ONE: "ONE_TO_ONE";
391
+ ONE_TO_MANY: "ONE_TO_MANY";
392
+ MANY_TO_ONE: "MANY_TO_ONE";
393
+ MANY_TO_MANY: "MANY_TO_MANY";
394
+ }>;
395
+ onDelete: z.ZodDefault<z.ZodEnum<{
396
+ NONE: "NONE";
397
+ CASCADE: "CASCADE";
398
+ RESTRICT: "RESTRICT";
399
+ }>>;
400
+ }, z.core.$strip>;
401
+ /**
402
+ * Schema for a relationship definition.
403
+ * Relationships are bidirectional - they define links from both sides.
404
+ */
405
+ export declare const RelationshipDefinitionSchema: z.ZodObject<{
406
+ source: z.ZodObject<{
407
+ model: z.ZodString;
408
+ field: z.ZodString;
409
+ label: z.ZodString;
410
+ cardinality: z.ZodEnum<{
411
+ ONE_TO_ONE: "ONE_TO_ONE";
412
+ ONE_TO_MANY: "ONE_TO_MANY";
413
+ MANY_TO_ONE: "MANY_TO_ONE";
414
+ MANY_TO_MANY: "MANY_TO_MANY";
415
+ }>;
416
+ onDelete: z.ZodDefault<z.ZodEnum<{
417
+ NONE: "NONE";
418
+ CASCADE: "CASCADE";
419
+ RESTRICT: "RESTRICT";
420
+ }>>;
421
+ }, z.core.$strip>;
422
+ target: z.ZodObject<{
423
+ model: z.ZodString;
424
+ field: z.ZodString;
425
+ label: z.ZodString;
426
+ cardinality: z.ZodEnum<{
427
+ ONE_TO_ONE: "ONE_TO_ONE";
428
+ ONE_TO_MANY: "ONE_TO_MANY";
429
+ MANY_TO_ONE: "MANY_TO_ONE";
430
+ MANY_TO_MANY: "MANY_TO_MANY";
431
+ }>;
432
+ onDelete: z.ZodDefault<z.ZodEnum<{
433
+ NONE: "NONE";
434
+ CASCADE: "CASCADE";
435
+ RESTRICT: "RESTRICT";
436
+ }>>;
437
+ }, z.core.$strip>;
438
+ }, z.core.$strip>;
439
+ /**
440
+ * Schema for inline field definition (constraints, options, etc.)
441
+ * This allows defining field behavior without referencing a metafield definition.
442
+ */
443
+ export declare const InlineFieldDefinitionSchema: z.ZodObject<{
444
+ limitChoices: z.ZodOptional<z.ZodNumber>;
445
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
446
+ label: z.ZodString;
447
+ value: z.ZodString;
448
+ color: z.ZodOptional<z.ZodString>;
449
+ }, z.core.$strip>>>;
450
+ minLength: z.ZodOptional<z.ZodNumber>;
451
+ maxLength: z.ZodOptional<z.ZodNumber>;
452
+ min: z.ZodOptional<z.ZodNumber>;
453
+ max: z.ZodOptional<z.ZodNumber>;
454
+ pattern: z.ZodOptional<z.ZodString>;
455
+ }, z.core.$strip>;
338
456
  /**
339
457
  * Schema for a field within a model.
340
458
  * Works for both INTERNAL and SHARED models.
@@ -356,6 +474,19 @@ export declare const ModelFieldDefinitionSchema: z.ZodObject<{
356
474
  OBJECT: "OBJECT";
357
475
  }>>;
358
476
  definitionHandle: z.ZodOptional<z.ZodString>;
477
+ definition: z.ZodOptional<z.ZodObject<{
478
+ limitChoices: z.ZodOptional<z.ZodNumber>;
479
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
480
+ label: z.ZodString;
481
+ value: z.ZodString;
482
+ color: z.ZodOptional<z.ZodString>;
483
+ }, z.core.$strip>>>;
484
+ minLength: z.ZodOptional<z.ZodNumber>;
485
+ maxLength: z.ZodOptional<z.ZodNumber>;
486
+ min: z.ZodOptional<z.ZodNumber>;
487
+ max: z.ZodOptional<z.ZodNumber>;
488
+ pattern: z.ZodOptional<z.ZodString>;
489
+ }, z.core.$strip>>;
359
490
  required: z.ZodOptional<z.ZodBoolean>;
360
491
  unique: z.ZodOptional<z.ZodBoolean>;
361
492
  system: z.ZodOptional<z.ZodBoolean>;
@@ -369,6 +500,11 @@ export declare const ModelFieldDefinitionSchema: z.ZodObject<{
369
500
  list: z.ZodOptional<z.ZodBoolean>;
370
501
  filters: z.ZodOptional<z.ZodBoolean>;
371
502
  }, z.core.$strip>>;
503
+ owner: z.ZodOptional<z.ZodEnum<{
504
+ APP: "APP";
505
+ WORKPLACE: "WORKPLACE";
506
+ BOTH: "BOTH";
507
+ }>>;
372
508
  }, z.core.$strip>;
373
509
  /**
374
510
  * Schema for a unified model definition.
@@ -401,6 +537,19 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
401
537
  OBJECT: "OBJECT";
402
538
  }>>;
403
539
  definitionHandle: z.ZodOptional<z.ZodString>;
540
+ definition: z.ZodOptional<z.ZodObject<{
541
+ limitChoices: z.ZodOptional<z.ZodNumber>;
542
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
543
+ label: z.ZodString;
544
+ value: z.ZodString;
545
+ color: z.ZodOptional<z.ZodString>;
546
+ }, z.core.$strip>>>;
547
+ minLength: z.ZodOptional<z.ZodNumber>;
548
+ maxLength: z.ZodOptional<z.ZodNumber>;
549
+ min: z.ZodOptional<z.ZodNumber>;
550
+ max: z.ZodOptional<z.ZodNumber>;
551
+ pattern: z.ZodOptional<z.ZodString>;
552
+ }, z.core.$strip>>;
404
553
  required: z.ZodOptional<z.ZodBoolean>;
405
554
  unique: z.ZodOptional<z.ZodBoolean>;
406
555
  system: z.ZodOptional<z.ZodBoolean>;
@@ -414,7 +563,21 @@ export declare const ModelDefinitionSchema: z.ZodObject<{
414
563
  list: z.ZodOptional<z.ZodBoolean>;
415
564
  filters: z.ZodOptional<z.ZodBoolean>;
416
565
  }, z.core.$strip>>;
566
+ owner: z.ZodOptional<z.ZodEnum<{
567
+ APP: "APP";
568
+ WORKPLACE: "WORKPLACE";
569
+ BOTH: "BOTH";
570
+ }>>;
417
571
  }, z.core.$strip>>;
572
+ requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
573
+ model: z.ZodString;
574
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
575
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
576
+ }, z.core.$strip>, z.ZodObject<{
577
+ channel: z.ZodString;
578
+ }, z.core.$strip>, z.ZodObject<{
579
+ workflow: z.ZodString;
580
+ }, z.core.$strip>]>>>;
418
581
  }, z.core.$strip>;
419
582
  /**
420
583
  * @deprecated Use FieldDataTypeSchema instead
@@ -598,6 +761,19 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
598
761
  OBJECT: "OBJECT";
599
762
  }>>;
600
763
  definitionHandle: z.ZodOptional<z.ZodString>;
764
+ definition: z.ZodOptional<z.ZodObject<{
765
+ limitChoices: z.ZodOptional<z.ZodNumber>;
766
+ options: z.ZodOptional<z.ZodArray<z.ZodObject<{
767
+ label: z.ZodString;
768
+ value: z.ZodString;
769
+ color: z.ZodOptional<z.ZodString>;
770
+ }, z.core.$strip>>>;
771
+ minLength: z.ZodOptional<z.ZodNumber>;
772
+ maxLength: z.ZodOptional<z.ZodNumber>;
773
+ min: z.ZodOptional<z.ZodNumber>;
774
+ max: z.ZodOptional<z.ZodNumber>;
775
+ pattern: z.ZodOptional<z.ZodString>;
776
+ }, z.core.$strip>>;
601
777
  required: z.ZodOptional<z.ZodBoolean>;
602
778
  unique: z.ZodOptional<z.ZodBoolean>;
603
779
  system: z.ZodOptional<z.ZodBoolean>;
@@ -611,7 +787,55 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
611
787
  list: z.ZodOptional<z.ZodBoolean>;
612
788
  filters: z.ZodOptional<z.ZodBoolean>;
613
789
  }, z.core.$strip>>;
790
+ owner: z.ZodOptional<z.ZodEnum<{
791
+ APP: "APP";
792
+ WORKPLACE: "WORKPLACE";
793
+ BOTH: "BOTH";
794
+ }>>;
614
795
  }, z.core.$strip>>;
796
+ requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
797
+ model: z.ZodString;
798
+ fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
799
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
800
+ }, z.core.$strip>, z.ZodObject<{
801
+ channel: z.ZodString;
802
+ }, z.core.$strip>, z.ZodObject<{
803
+ workflow: z.ZodString;
804
+ }, z.core.$strip>]>>>;
805
+ }, z.core.$strip>>>;
806
+ relationships: z.ZodOptional<z.ZodArray<z.ZodObject<{
807
+ source: z.ZodObject<{
808
+ model: z.ZodString;
809
+ field: z.ZodString;
810
+ label: z.ZodString;
811
+ cardinality: z.ZodEnum<{
812
+ ONE_TO_ONE: "ONE_TO_ONE";
813
+ ONE_TO_MANY: "ONE_TO_MANY";
814
+ MANY_TO_ONE: "MANY_TO_ONE";
815
+ MANY_TO_MANY: "MANY_TO_MANY";
816
+ }>;
817
+ onDelete: z.ZodDefault<z.ZodEnum<{
818
+ NONE: "NONE";
819
+ CASCADE: "CASCADE";
820
+ RESTRICT: "RESTRICT";
821
+ }>>;
822
+ }, z.core.$strip>;
823
+ target: z.ZodObject<{
824
+ model: z.ZodString;
825
+ field: z.ZodString;
826
+ label: z.ZodString;
827
+ cardinality: z.ZodEnum<{
828
+ ONE_TO_ONE: "ONE_TO_ONE";
829
+ ONE_TO_MANY: "ONE_TO_MANY";
830
+ MANY_TO_ONE: "MANY_TO_ONE";
831
+ MANY_TO_MANY: "MANY_TO_MANY";
832
+ }>;
833
+ onDelete: z.ZodDefault<z.ZodEnum<{
834
+ NONE: "NONE";
835
+ CASCADE: "CASCADE";
836
+ RESTRICT: "RESTRICT";
837
+ }>>;
838
+ }, z.core.$strip>;
615
839
  }, z.core.$strip>>>;
616
840
  channels: z.ZodOptional<z.ZodArray<z.ZodObject<{
617
841
  handle: z.ZodString;
@@ -649,6 +873,7 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
649
873
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
650
874
  model: z.ZodString;
651
875
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
876
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
652
877
  }, z.core.$strip>, z.ZodObject<{
653
878
  channel: z.ZodString;
654
879
  }, z.core.$strip>, z.ZodObject<{
@@ -691,6 +916,7 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
691
916
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
692
917
  model: z.ZodString;
693
918
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
919
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
694
920
  }, z.core.$strip>, z.ZodObject<{
695
921
  channel: z.ZodString;
696
922
  }, z.core.$strip>, z.ZodObject<{
@@ -705,6 +931,7 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
705
931
  requires: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
706
932
  model: z.ZodString;
707
933
  fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
934
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>>>;
708
935
  }, z.core.$strip>, z.ZodObject<{
709
936
  channel: z.ZodString;
710
937
  }, z.core.$strip>, z.ZodObject<{
@@ -770,6 +997,22 @@ export type ParsedSkedyulConfig = z.infer<typeof SkedyulConfigSchema>;
770
997
  export declare function safeParseConfig(data: unknown): ParsedSkedyulConfig | null;
771
998
  /** Resource scope type */
772
999
  export type ResourceScope = z.infer<typeof ResourceScopeSchema>;
1000
+ /** Field owner type (data ownership) */
1001
+ export type FieldOwner = z.infer<typeof FieldOwnerSchema>;
1002
+ /** StructuredFilter type for conditional dependencies */
1003
+ export type StructuredFilter = z.infer<typeof StructuredFilterSchema>;
1004
+ /** Field option for choice/enum fields */
1005
+ export type FieldOption = z.infer<typeof FieldOptionSchema>;
1006
+ /** Inline field definition (constraints, options, etc.) */
1007
+ export type InlineFieldDefinition = z.infer<typeof InlineFieldDefinitionSchema>;
1008
+ /** Relationship cardinality type */
1009
+ export type RelationshipCardinality = z.infer<typeof RelationshipCardinalitySchema>;
1010
+ /** On-delete behavior type */
1011
+ export type OnDeleteBehavior = z.infer<typeof OnDeleteBehaviorSchema>;
1012
+ /** Relationship link (one side of a relationship) */
1013
+ export type RelationshipLink = z.infer<typeof RelationshipLinkSchema>;
1014
+ /** Relationship definition */
1015
+ export type RelationshipDefinition = z.infer<typeof RelationshipDefinitionSchema>;
773
1016
  /** Model dependency reference */
774
1017
  export type ModelDependency = z.infer<typeof ModelDependencySchema>;
775
1018
  /** Channel dependency reference */
package/dist/schemas.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SkedyulConfigSchema = exports.InternalModelDefinitionSchema = exports.InternalFieldDefinitionSchema = exports.InternalFieldDataTypeSchema = exports.ModelDefinitionSchema = exports.ModelFieldDefinitionSchema = exports.FieldDataTypeSchema = exports.ComputeLayerTypeSchema = exports.WorkflowDefinitionSchema = exports.WorkflowActionSchema = exports.WorkflowActionInputSchema = exports.ChannelDefinitionSchema = exports.CommunicationChannelDefinitionSchema = exports.ResourceDependencySchema = exports.WorkflowDependencySchema = exports.ChannelDependencySchema = exports.ModelDependencySchema = exports.ResourceScopeSchema = exports.ChannelIdentifierValueSchema = exports.ChannelIdentifierTypeSchema = exports.ChannelToolBindingsSchema = exports.AppFieldDefinitionSchema = exports.AppFieldVisibilitySchema = exports.InstallConfigSchema = exports.AppModelDefinitionSchema = exports.EnvSchemaSchema = exports.EnvVariableDefinitionSchema = exports.EnvVisibilitySchema = void 0;
3
+ exports.SkedyulConfigSchema = exports.InternalModelDefinitionSchema = exports.InternalFieldDefinitionSchema = exports.InternalFieldDataTypeSchema = exports.ModelDefinitionSchema = exports.ModelFieldDefinitionSchema = exports.InlineFieldDefinitionSchema = exports.RelationshipDefinitionSchema = exports.RelationshipLinkSchema = exports.OnDeleteBehaviorSchema = exports.RelationshipCardinalitySchema = exports.FieldOptionSchema = exports.FieldDataTypeSchema = exports.ComputeLayerTypeSchema = exports.WorkflowDefinitionSchema = exports.WorkflowActionSchema = exports.WorkflowActionInputSchema = exports.ChannelDefinitionSchema = exports.CommunicationChannelDefinitionSchema = exports.ResourceDependencySchema = exports.WorkflowDependencySchema = exports.ChannelDependencySchema = exports.ModelDependencySchema = exports.StructuredFilterSchema = exports.FieldOwnerSchema = exports.ResourceScopeSchema = exports.ChannelIdentifierValueSchema = exports.ChannelIdentifierTypeSchema = exports.ChannelToolBindingsSchema = exports.AppFieldDefinitionSchema = exports.AppFieldVisibilitySchema = exports.InstallConfigSchema = exports.AppModelDefinitionSchema = exports.EnvSchemaSchema = exports.EnvVariableDefinitionSchema = exports.EnvVisibilitySchema = void 0;
4
4
  exports.safeParseConfig = safeParseConfig;
5
5
  exports.isModelDependency = isModelDependency;
6
6
  exports.isChannelDependency = isChannelDependency;
@@ -99,6 +99,21 @@ exports.ChannelIdentifierValueSchema = zod_1.z.object({
99
99
  * SHARED: Maps to user's existing resource, requires user selection
100
100
  */
101
101
  exports.ResourceScopeSchema = zod_1.z.enum(['INTERNAL', 'SHARED']);
102
+ /**
103
+ * Schema for field-level data ownership.
104
+ * Describes who owns/controls the data in a field.
105
+ * APP: App exclusively controls this data (e.g., status field set by webhook)
106
+ * WORKPLACE: User/organization provides this data (e.g., file upload)
107
+ * BOTH: Collaborative - either can update
108
+ */
109
+ exports.FieldOwnerSchema = zod_1.z.enum(['APP', 'WORKPLACE', 'BOTH']);
110
+ /**
111
+ * Schema for StructuredFilter conditions.
112
+ * Used for conditional dependencies (e.g., require model where status = APPROVED)
113
+ * Format: { fieldHandle: { operator: value } }
114
+ */
115
+ const PrimitiveSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean()]);
116
+ exports.StructuredFilterSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.record(zod_1.z.string(), zod_1.z.union([PrimitiveSchema, zod_1.z.array(PrimitiveSchema)])));
102
117
  /**
103
118
  * Schema for a model dependency reference.
104
119
  * Used in `requires` arrays to specify model dependencies.
@@ -108,6 +123,8 @@ exports.ModelDependencySchema = zod_1.z.object({
108
123
  model: zod_1.z.string(),
109
124
  /** Specific fields required (undefined = all fields) */
110
125
  fields: zod_1.z.array(zod_1.z.string()).optional(),
126
+ /** Conditions the dependency instance must satisfy (StructuredFilter format) */
127
+ where: exports.StructuredFilterSchema.optional(),
111
128
  });
112
129
  /**
113
130
  * Schema for a channel dependency reference.
@@ -217,6 +234,80 @@ exports.FieldDataTypeSchema = zod_1.z.enum([
217
234
  'RELATION',
218
235
  'OBJECT',
219
236
  ]);
237
+ /**
238
+ * Schema for an option in a choice/enum field.
239
+ */
240
+ exports.FieldOptionSchema = zod_1.z.object({
241
+ /** Display label */
242
+ label: zod_1.z.string(),
243
+ /** Value stored in database */
244
+ value: zod_1.z.string(),
245
+ /** Optional color for UI display */
246
+ color: zod_1.z.string().optional(),
247
+ });
248
+ /**
249
+ * Schema for relationship cardinality.
250
+ * Defines how many records can be linked on each side.
251
+ */
252
+ exports.RelationshipCardinalitySchema = zod_1.z.enum([
253
+ 'ONE_TO_ONE',
254
+ 'ONE_TO_MANY',
255
+ 'MANY_TO_ONE',
256
+ 'MANY_TO_MANY',
257
+ ]);
258
+ /**
259
+ * Schema for on-delete behavior in relationships.
260
+ */
261
+ exports.OnDeleteBehaviorSchema = zod_1.z.enum([
262
+ 'NONE', // No action
263
+ 'CASCADE', // Delete related records
264
+ 'RESTRICT', // Prevent deletion
265
+ ]);
266
+ /**
267
+ * Schema for a relationship link (one side of a relationship).
268
+ */
269
+ exports.RelationshipLinkSchema = zod_1.z.object({
270
+ /** Model handle for this side of the relationship */
271
+ model: zod_1.z.string(),
272
+ /** Field handle on this model */
273
+ field: zod_1.z.string(),
274
+ /** Field label for display */
275
+ label: zod_1.z.string(),
276
+ /** Cardinality from this side */
277
+ cardinality: exports.RelationshipCardinalitySchema,
278
+ /** On-delete behavior */
279
+ onDelete: exports.OnDeleteBehaviorSchema.default('NONE'),
280
+ });
281
+ /**
282
+ * Schema for a relationship definition.
283
+ * Relationships are bidirectional - they define links from both sides.
284
+ */
285
+ exports.RelationshipDefinitionSchema = zod_1.z.object({
286
+ /** Source side of the relationship */
287
+ source: exports.RelationshipLinkSchema,
288
+ /** Target side of the relationship */
289
+ target: exports.RelationshipLinkSchema,
290
+ });
291
+ /**
292
+ * Schema for inline field definition (constraints, options, etc.)
293
+ * This allows defining field behavior without referencing a metafield definition.
294
+ */
295
+ exports.InlineFieldDefinitionSchema = zod_1.z.object({
296
+ /** For choice fields: number of selections allowed (1 = single select, >1 = multi) */
297
+ limitChoices: zod_1.z.number().optional(),
298
+ /** For choice fields: available options */
299
+ options: zod_1.z.array(exports.FieldOptionSchema).optional(),
300
+ /** For string fields: min length */
301
+ minLength: zod_1.z.number().optional(),
302
+ /** For string fields: max length */
303
+ maxLength: zod_1.z.number().optional(),
304
+ /** For number fields: min value */
305
+ min: zod_1.z.number().optional(),
306
+ /** For number fields: max value */
307
+ max: zod_1.z.number().optional(),
308
+ /** Validation regex pattern */
309
+ pattern: zod_1.z.string().optional(),
310
+ });
220
311
  /**
221
312
  * Schema for a field within a model.
222
313
  * Works for both INTERNAL and SHARED models.
@@ -228,8 +319,10 @@ exports.ModelFieldDefinitionSchema = zod_1.z.object({
228
319
  label: zod_1.z.string(),
229
320
  /** Data type (required for INTERNAL, optional for SHARED) */
230
321
  type: exports.FieldDataTypeSchema.optional(),
231
- /** Field definition handle for SHARED fields */
322
+ /** Field definition handle for SHARED fields (references a metafield definition) */
232
323
  definitionHandle: zod_1.z.string().optional(),
324
+ /** Inline field definition (alternative to definitionHandle for INTERNAL fields) */
325
+ definition: exports.InlineFieldDefinitionSchema.optional(),
233
326
  /** Whether field is required */
234
327
  required: zod_1.z.boolean().optional(),
235
328
  /** Whether field must be unique */
@@ -244,6 +337,8 @@ exports.ModelFieldDefinitionSchema = zod_1.z.object({
244
337
  description: zod_1.z.string().optional(),
245
338
  /** Visibility settings for SHARED fields */
246
339
  visibility: exports.AppFieldVisibilitySchema.optional(),
340
+ /** Data ownership: APP (app controls), WORKPLACE (user provides), BOTH (collaborative) */
341
+ owner: exports.FieldOwnerSchema.optional(),
247
342
  });
248
343
  /**
249
344
  * Schema for a unified model definition.
@@ -264,6 +359,8 @@ exports.ModelDefinitionSchema = zod_1.z.object({
264
359
  description: zod_1.z.string().optional(),
265
360
  /** Field definitions */
266
361
  fields: zod_1.z.array(exports.ModelFieldDefinitionSchema),
362
+ /** Model-level dependencies - other models this model requires to be provisioned */
363
+ requires: zod_1.z.array(exports.ResourceDependencySchema).optional(),
267
364
  });
268
365
  // ─────────────────────────────────────────────────────────────────────────────
269
366
  // Legacy Internal Model Schemas (deprecated - use ModelDefinitionSchema)
@@ -329,6 +426,8 @@ exports.SkedyulConfigSchema = zod_1.z.object({
329
426
  .optional(),
330
427
  // New unified model definitions (INTERNAL + SHARED)
331
428
  models: zod_1.z.array(exports.ModelDefinitionSchema).optional(),
429
+ // Relationships between models
430
+ relationships: zod_1.z.array(exports.RelationshipDefinitionSchema).optional(),
332
431
  // New channel syntax (alias for communicationChannels)
333
432
  channels: zod_1.z.array(exports.ChannelDefinitionSchema).optional(),
334
433
  // Legacy: communication channels (deprecated - use channels)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",