@stndrds/schema 0.1.0-alpha.55 → 0.1.0-alpha.57

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.
@@ -709,6 +709,155 @@ declare function slugify(input: string): string;
709
709
  */
710
710
  declare function generateTemplateName(label: string): string;
711
711
 
712
+ /**
713
+ * Feature flag levels (resolution priority: user > tenant > global).
714
+ *
715
+ * - `global`: Applies to all tenants and users
716
+ * - `tenant`: Applies to a specific tenant
717
+ * - `user`: Applies to a specific user within a tenant
718
+ */
719
+ type FlagLevel = "global" | "tenant" | "user";
720
+ /**
721
+ * Flag value types supported by the system.
722
+ */
723
+ type FlagValueType = "boolean" | "string" | "number" | "json";
724
+ /**
725
+ * Definition of a feature flag.
726
+ * Created using the flag builders (booleanFlag, stringFlag, etc.)
727
+ */
728
+ interface FeatureFlagDefinition<T = unknown> {
729
+ /** Unique identifier for the flag (kebab-case) */
730
+ name: string;
731
+ /** Human-readable label */
732
+ label: string;
733
+ /** Optional description */
734
+ description?: string;
735
+ /** Type of the flag value */
736
+ valueType: FlagValueType;
737
+ /** Default value when no override exists */
738
+ defaultValue: T;
739
+ /** Levels at which this flag can be overridden */
740
+ allowedLevels: FlagLevel[];
741
+ /** Grouping category for UI */
742
+ category?: string;
743
+ /** System flag - cannot be modified via API */
744
+ system?: boolean;
745
+ }
746
+ /**
747
+ * Stored override for a feature flag.
748
+ * Represents a row in the feature_flag_overrides table.
749
+ */
750
+ interface FlagOverride<T = unknown> {
751
+ /** Name of the flag being overridden */
752
+ flagName: string;
753
+ /** Level of the override */
754
+ level: FlagLevel;
755
+ /** Target ID (tenantId for tenant-level, userId for user-level) */
756
+ targetId?: string;
757
+ /** Override value */
758
+ value: T;
759
+ /** Optional expiration date */
760
+ expiresAt?: Date;
761
+ /** Who created this override */
762
+ createdBy?: string;
763
+ /** When the override was created */
764
+ createdAt: Date;
765
+ /** When the override was last updated */
766
+ updatedAt: Date;
767
+ }
768
+ /**
769
+ * Resolved flag value with source information.
770
+ * Result of flag resolution including where the value came from.
771
+ */
772
+ interface ResolvedFlag<T = unknown> {
773
+ /** Flag name */
774
+ name: string;
775
+ /** Resolved value */
776
+ value: T;
777
+ /** Where the value came from */
778
+ source: FlagLevel | "default";
779
+ /** ID of the source (tenantId or userId) if not default */
780
+ sourceId?: string;
781
+ }
782
+ /**
783
+ * Feature gate configuration for conditional attribute visibility.
784
+ * Used with the `.featureGate()` builder method.
785
+ */
786
+ interface FeatureGate {
787
+ /** Name of the flag to check */
788
+ flag: string;
789
+ /**
790
+ * Expected value for the gate to pass.
791
+ * For boolean flags, defaults to `true`.
792
+ * For other types, compares with strict equality.
793
+ */
794
+ expectedValue?: unknown;
795
+ /**
796
+ * Behavior when the gate fails.
797
+ * - `hide`: Attribute is completely hidden (default)
798
+ * - `show`: Attribute is shown regardless (no gating)
799
+ * - `disable`: Attribute is visible but read-only
800
+ */
801
+ fallback?: "hide" | "show" | "disable";
802
+ }
803
+ /**
804
+ * Repository interface for feature flag overrides storage.
805
+ * Added to DatabaseAdapter as an optional repository.
806
+ *
807
+ * If not provided, only static defaults from module config are used.
808
+ */
809
+ interface FeatureFlagsRepository {
810
+ /**
811
+ * Get all overrides matching the criteria.
812
+ * Returns overrides from the database (global, tenant, or user level).
813
+ */
814
+ getOverrides(options: {
815
+ /** Filter by level */
816
+ level?: FlagLevel;
817
+ /** Filter by target ID (tenantId or userId) */
818
+ targetId?: string;
819
+ }): Promise<FlagOverride[]>;
820
+ /**
821
+ * Create or update an override.
822
+ * Uses upsert semantics based on (flagName, level, targetId).
823
+ */
824
+ setOverride(override: Omit<FlagOverride, "createdAt" | "updatedAt">): Promise<FlagOverride>;
825
+ /**
826
+ * Delete an override.
827
+ */
828
+ deleteOverride(flagName: string, level: FlagLevel, targetId?: string): Promise<void>;
829
+ }
830
+ /**
831
+ * Static flag default value for module configuration.
832
+ */
833
+ interface StaticFlagDefault {
834
+ /** Flag name */
835
+ name: string;
836
+ /** Default value */
837
+ value: unknown;
838
+ }
839
+ /**
840
+ * Feature flags configuration for SchemaModule.
841
+ */
842
+ interface FeatureFlagsConfig {
843
+ /**
844
+ * Static default values for flags.
845
+ * These are always applied and used when no database override exists.
846
+ *
847
+ * @example
848
+ * ```typescript
849
+ * featureFlags: {
850
+ * defaults: [
851
+ * { name: "architect-mode", value: false },
852
+ * { name: "ai-chat", value: false },
853
+ * { name: "tier", value: "free" },
854
+ * ],
855
+ * }
856
+ * ```
857
+ */
858
+ defaults?: StaticFlagDefault[];
859
+ }
860
+
712
861
  type AttributeType = "text" | "textarea" | "richtext" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "location" | "select" | "multiselect" | "file" | "user" | "relation" | "rating" | "formula" | "rollup" | "document";
713
862
  /**
714
863
  * Status group categorization
@@ -754,6 +903,14 @@ interface BaseAttribute<DefaultValueType = unknown> {
754
903
  archived?: boolean;
755
904
  deprecated?: boolean;
756
905
  system?: boolean;
906
+ /**
907
+ * Feature gate to conditionally show/hide/disable this attribute.
908
+ * When the flag condition is not met, the attribute behavior depends on `fallback`:
909
+ * - "hide" (default): Attribute is completely hidden
910
+ * - "disable": Attribute is visible but read-only
911
+ * - "show": No gating (useful for overriding parent settings)
912
+ */
913
+ featureGate?: FeatureGate;
757
914
  metadata?: Record<string, unknown>;
758
915
  }
759
916
  interface TextAttribute extends BaseAttribute<string> {
@@ -3769,6 +3926,10 @@ declare function canResumeInstance(instance: WorkflowInstance): boolean;
3769
3926
  */
3770
3927
  declare function createStartTransition(startNodeId: string, startedBy: string): WorkflowTransition;
3771
3928
 
3929
+ /**
3930
+ * Type of view - determines the config structure
3931
+ */
3932
+ type ViewType = "detail" | "list" | "calendar" | "timeline" | "gallery";
3772
3933
  /**
3773
3934
  * Inline attribute group configuration
3774
3935
  * Groups multiple attributes into a single composite field with dropdown editing
@@ -3827,8 +3988,6 @@ interface BaseTab {
3827
3988
  label: string;
3828
3989
  icon?: IconName;
3829
3990
  order?: number;
3830
- /** If true, tab is defined by developer (protected) */
3831
- system?: boolean;
3832
3991
  }
3833
3992
  /**
3834
3993
  * Form tab - displays attributes organized in groups
@@ -3859,14 +4018,6 @@ interface TableTabBase extends BaseTab {
3859
4018
  * Direct table tab - displays records from a relation attribute on the current object
3860
4019
  *
3861
4020
  * @example Project.members → shows Users linked via the "members" relation
3862
- * ```typescript
3863
- * {
3864
- * type: "table",
3865
- * relationMode: "direct",
3866
- * relationAttribute: "members",
3867
- * columns: ["name", "email"]
3868
- * }
3869
- * ```
3870
4021
  */
3871
4022
  interface DirectTableTab extends TableTabBase {
3872
4023
  relationMode: "direct";
@@ -3877,15 +4028,6 @@ interface DirectTableTab extends TableTabBase {
3877
4028
  * Inverse table tab - displays records from another object that have a relation to us
3878
4029
  *
3879
4030
  * @example Contact.company → on Company, shows Contacts that point to this Company
3880
- * ```typescript
3881
- * {
3882
- * type: "table",
3883
- * relationMode: "inverse",
3884
- * sourceObject: "contacts",
3885
- * relationAttribute: "company",
3886
- * columns: ["firstName", "lastName", "email"]
3887
- * }
3888
- * ```
3889
4031
  */
3890
4032
  interface InverseTableTab extends TableTabBase {
3891
4033
  relationMode: "inverse";
@@ -3896,7 +4038,6 @@ interface InverseTableTab extends TableTabBase {
3896
4038
  }
3897
4039
  /**
3898
4040
  * Table tab - displays related records in a table
3899
- * Discriminated union by relationMode for type-safe configuration
3900
4041
  */
3901
4042
  type TableTab = DirectTableTab | InverseTableTab;
3902
4043
  /**
@@ -3919,21 +4060,6 @@ interface ActivityTab extends BaseTab {
3919
4060
  }
3920
4061
  /**
3921
4062
  * Notes tab - displays notes linked to the current record
3922
- *
3923
- * Shows all notes where linked_object_name matches the current object
3924
- * and linked_record_id matches the current record ID.
3925
- * Respects visibility rules (private notes only visible to author).
3926
- *
3927
- * @example
3928
- * ```typescript
3929
- * {
3930
- * type: "notes",
3931
- * id: "notes",
3932
- * name: "notes",
3933
- * label: "Notes",
3934
- * allowCreate: true
3935
- * }
3936
- * ```
3937
4063
  */
3938
4064
  interface NotesTab extends BaseTab {
3939
4065
  type: "notes";
@@ -3944,22 +4070,6 @@ interface NotesTab extends BaseTab {
3944
4070
  }
3945
4071
  /**
3946
4072
  * Flows tab - displays workflow instances linked to the current record
3947
- *
3948
- * Uses record.metadata.createdByWorkflow to find linked instances.
3949
- * Allows launching new instances from published workflows that have
3950
- * a slot matching the current object.
3951
- *
3952
- * @example
3953
- * ```typescript
3954
- * {
3955
- * type: "flows",
3956
- * id: "workflows",
3957
- * name: "workflows",
3958
- * label: "Workflows",
3959
- * allowStart: true,
3960
- * allowCancel: true
3961
- * }
3962
- * ```
3963
4073
  */
3964
4074
  interface FlowsTab extends BaseTab {
3965
4075
  type: "flows";
@@ -3974,25 +4084,6 @@ interface FlowsTab extends BaseTab {
3974
4084
  }
3975
4085
  /**
3976
4086
  * Documents tab - displays all documents attached to the record
3977
- *
3978
- * Shows documents from:
3979
- * - Document attributes defined on the object
3980
- * - System `attachments` attribute (free-form documents)
3981
- *
3982
- * Allows uploading new documents either to a specific attribute or as attachments.
3983
- *
3984
- * @example
3985
- * ```typescript
3986
- * {
3987
- * type: "documents",
3988
- * id: "documents",
3989
- * name: "documents",
3990
- * label: "Documents",
3991
- * allowUpload: true,
3992
- * allowRemove: true,
3993
- * showProcessing: true
3994
- * }
3995
- * ```
3996
4087
  */
3997
4088
  interface DocumentsTab extends BaseTab {
3998
4089
  type: "documents";
@@ -4008,36 +4099,118 @@ interface DocumentsTab extends BaseTab {
4008
4099
  hideAttachments?: boolean;
4009
4100
  }
4010
4101
  /**
4011
- * Union of all tab types
4102
+ * Union of all tab types (for detail views)
4012
4103
  */
4013
4104
  type Tab = FormTab | TableTab | CustomTab | ActivityTab | NotesTab | FlowsTab | DocumentsTab;
4014
4105
  /**
4015
- * View layout mode
4016
- * - `page`: Full view with multiple tabs (form, table, activity, notes, custom)
4017
- * - `modal`: Simplified view for modals, single FormTab without tabs UI
4106
+ * Detail view layout mode
4107
+ * - `page`: Full view with multiple tabs
4108
+ * - `modal`: Simplified view for modals (single FormTab, no tabs UI)
4109
+ */
4110
+ type DetailViewLayout = "page" | "modal";
4111
+ /**
4112
+ * List view layout mode
4113
+ * - `table`: Table/grid layout
4114
+ * - `kanban`: Kanban board layout (grouped by attribute)
4018
4115
  */
4019
- type ViewLayout = "page" | "modal";
4116
+ type ListViewLayout = "table" | "kanban";
4117
+ /** @deprecated Use DetailViewLayout instead */
4118
+ type ViewLayout = DetailViewLayout;
4020
4119
  /**
4021
- * View definition - organizes object attributes into tabs/pages
4120
+ * Internal tab within a list view (filter preset)
4022
4121
  *
4023
4122
  * @example
4024
4123
  * ```typescript
4025
- * const companyView: ViewDefinition = {
4026
- * name: "detail",
4027
- * label: "Company Detail",
4028
- * object: "companies",
4029
- * layout: "page",
4030
- * tabs: [
4031
- * { type: "form", name: "general", label: "Info", groups: [...] },
4032
- * { type: "table", relationMode: "inverse", sourceObject: "contacts", relationAttribute: "company", columns: [...] }
4033
- * ],
4034
- * default: true,
4035
- * system: true
4036
- * };
4124
+ * const tabs: ViewTab[] = [
4125
+ * { id: "all", label: "All Contacts", default: true },
4126
+ * { id: "active", label: "Active", filters: { status: { eq: "active" } } },
4127
+ * { id: "mine", label: "My Contacts", filters: { assignee: { eq: "me" } } }
4128
+ * ];
4037
4129
  * ```
4038
4130
  */
4039
- interface ViewDefinition {
4040
- id?: Uuid;
4131
+ interface ViewTab {
4132
+ /** Unique identifier */
4133
+ id: string;
4134
+ /** Display label */
4135
+ label: string;
4136
+ /** Icon */
4137
+ icon?: IconName;
4138
+ /** Filter preset for this tab */
4139
+ filters?: FilterGroup;
4140
+ /** Default tab (shown on load) */
4141
+ default?: boolean;
4142
+ }
4143
+ /**
4144
+ * Configuration for detail views (RecordEditView)
4145
+ */
4146
+ interface DetailViewConfig {
4147
+ /** Layout mode */
4148
+ layout: DetailViewLayout;
4149
+ /** Tabs in this view */
4150
+ tabs: Tab[];
4151
+ }
4152
+ /**
4153
+ * Configuration for list views (RecordsView)
4154
+ */
4155
+ interface ListViewConfig {
4156
+ /** Layout mode */
4157
+ layout: ListViewLayout;
4158
+ /** Attribute names to display as columns */
4159
+ columns: string[];
4160
+ /** Column widths in pixels */
4161
+ columnSizing?: Record<string, number>;
4162
+ /** Default filters applied to the view */
4163
+ defaultFilters?: FilterGroup;
4164
+ /** Default sort rules */
4165
+ defaultSorts?: SortRule[];
4166
+ /** Attribute to group by (for kanban layout) */
4167
+ groupByAttribute?: string;
4168
+ /** Internal tabs (filter presets) */
4169
+ tabs?: ViewTab[];
4170
+ }
4171
+ /**
4172
+ * Configuration for calendar views (future)
4173
+ */
4174
+ interface CalendarViewConfig {
4175
+ /** Date attribute for positioning events */
4176
+ dateAttribute: string;
4177
+ /** End date attribute (for range events) */
4178
+ endDateAttribute?: string;
4179
+ /** Title attribute for event display */
4180
+ titleAttribute: string;
4181
+ /** Color attribute (status/select) */
4182
+ colorAttribute?: string;
4183
+ }
4184
+ /**
4185
+ * Configuration for timeline views (future)
4186
+ */
4187
+ interface TimelineViewConfig {
4188
+ /** Date attribute for timeline positioning */
4189
+ dateAttribute: string;
4190
+ /** Group by attribute */
4191
+ groupByAttribute?: string;
4192
+ }
4193
+ /**
4194
+ * Configuration for gallery views (future)
4195
+ */
4196
+ interface GalleryViewConfig {
4197
+ /** Image attribute to display */
4198
+ imageAttribute: string;
4199
+ /** Title attribute */
4200
+ titleAttribute?: string;
4201
+ /** Columns per row */
4202
+ columnsPerRow?: number;
4203
+ }
4204
+ /**
4205
+ * Union of all view configs
4206
+ */
4207
+ type ViewConfig = DetailViewConfig | ListViewConfig | CalendarViewConfig | TimelineViewConfig | GalleryViewConfig;
4208
+ /**
4209
+ * Base view properties shared by all view types
4210
+ */
4211
+ interface BaseViewDefinition {
4212
+ /** Unique identifier (UUID, assigned by database) */
4213
+ id?: string;
4041
4214
  /** Technical name (kebab-case) */
4042
4215
  name: string;
4043
4216
  /** Display label */
@@ -4048,22 +4221,100 @@ interface ViewDefinition {
4048
4221
  icon?: IconName;
4049
4222
  /** Object this view belongs to (object name) */
4050
4223
  object: string;
4051
- /**
4052
- * Layout mode for the view
4053
- * - `page`: Full view with multiple tabs
4054
- * - `modal`: Simplified view for modals (single FormTab, no tabs UI)
4055
- * @default "page"
4056
- */
4057
- layout?: ViewLayout;
4058
- /** Tabs in this view */
4059
- tabs: Tab[];
4060
- /** Default view for this object (per layout) */
4224
+ /** Default view for this object+type combination */
4061
4225
  default?: boolean;
4062
- /** System view (defined by developer, protected) */
4063
- system?: boolean;
4064
4226
  /** Extensible metadata */
4065
4227
  metadata?: Record<string, unknown>;
4066
4228
  }
4229
+ /**
4230
+ * Detail view definition
4231
+ */
4232
+ interface DetailViewDefinition extends BaseViewDefinition {
4233
+ type: "detail";
4234
+ config: DetailViewConfig;
4235
+ }
4236
+ /**
4237
+ * List view definition
4238
+ */
4239
+ interface ListViewDefinition extends BaseViewDefinition {
4240
+ type: "list";
4241
+ config: ListViewConfig;
4242
+ }
4243
+ /**
4244
+ * Calendar view definition (future)
4245
+ */
4246
+ interface CalendarViewDefinition extends BaseViewDefinition {
4247
+ type: "calendar";
4248
+ config: CalendarViewConfig;
4249
+ }
4250
+ /**
4251
+ * Timeline view definition (future)
4252
+ */
4253
+ interface TimelineViewDefinition extends BaseViewDefinition {
4254
+ type: "timeline";
4255
+ config: TimelineViewConfig;
4256
+ }
4257
+ /**
4258
+ * Gallery view definition (future)
4259
+ */
4260
+ interface GalleryViewDefinition extends BaseViewDefinition {
4261
+ type: "gallery";
4262
+ config: GalleryViewConfig;
4263
+ }
4264
+ /**
4265
+ * Unified view definition - discriminated union by type
4266
+ */
4267
+ type ViewDefinition = DetailViewDefinition | ListViewDefinition | CalendarViewDefinition | TimelineViewDefinition | GalleryViewDefinition;
4268
+ /**
4269
+ * Configuration overrides for user customizations
4270
+ * Only stores the delta from the source view
4271
+ */
4272
+ interface ConfigOverrides {
4273
+ tabs?: ViewTab[];
4274
+ hiddenTabIds?: string[];
4275
+ detailTabs?: Tab[];
4276
+ hiddenDetailTabIds?: string[];
4277
+ }
4278
+ /**
4279
+ * User customization overlay for a view
4280
+ * Stored per user, merged at runtime with the source view
4281
+ */
4282
+ interface ViewOverlay {
4283
+ /** Unique identifier */
4284
+ id: string;
4285
+ /** View ID this overlay applies to (UUID or virtual ID) */
4286
+ viewId: string;
4287
+ /** User ID who owns this overlay */
4288
+ userId: string;
4289
+ /** Configuration overrides (delta only) */
4290
+ configOverrides: ConfigOverrides;
4291
+ /** User's default view for this object (stored in overlay) */
4292
+ isUserDefault?: boolean;
4293
+ /** Created timestamp */
4294
+ createdAt: Date;
4295
+ /** Updated timestamp */
4296
+ updatedAt: Date;
4297
+ }
4298
+ /**
4299
+ * Check if a view is a detail view
4300
+ */
4301
+ declare function isDetailView(view: ViewDefinition): view is DetailViewDefinition;
4302
+ /**
4303
+ * Check if a view is a list view
4304
+ */
4305
+ declare function isListView(view: ViewDefinition): view is ListViewDefinition;
4306
+ /**
4307
+ * Check if a view is a calendar view
4308
+ */
4309
+ declare function isCalendarView(view: ViewDefinition): view is CalendarViewDefinition;
4310
+ /**
4311
+ * Check if a view is a timeline view
4312
+ */
4313
+ declare function isTimelineView(view: ViewDefinition): view is TimelineViewDefinition;
4314
+ /**
4315
+ * Check if a view is a gallery view
4316
+ */
4317
+ declare function isGalleryView(view: ViewDefinition): view is GalleryViewDefinition;
4067
4318
  /**
4068
4319
  * Check if a tab is a form tab
4069
4320
  */
@@ -4543,22 +4794,24 @@ interface FileListOptions extends ListOptions {
4543
4794
  visibility?: FileVisibility;
4544
4795
  }
4545
4796
  /**
4546
- * View as stored in database
4797
+ * Unified view as stored in database
4798
+ * Supports all view types (detail, list, calendar, etc.) via polymorphic config
4547
4799
  */
4548
4800
  interface DBView extends Timestamps {
4549
4801
  id: Uuid;
4550
4802
  tenantId: TenantId;
4551
4803
  objectId?: Uuid;
4552
4804
  objectName: string;
4805
+ /** View type discriminant */
4806
+ type: ViewType;
4553
4807
  name: string;
4554
4808
  label: string;
4555
4809
  description?: string;
4556
4810
  icon?: IconName;
4557
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
4558
- layout?: ViewLayout;
4559
- tabs: Tab[];
4811
+ /** Polymorphic configuration (DetailViewConfig, ListViewConfig, etc.) */
4812
+ config: ViewConfig;
4813
+ /** Default view for this object+type combination */
4560
4814
  default: boolean;
4561
- system: boolean;
4562
4815
  metadata?: Record<string, unknown>;
4563
4816
  }
4564
4817
  /**
@@ -4568,44 +4821,74 @@ interface DBView extends Timestamps {
4568
4821
  interface CreateDBView {
4569
4822
  objectId?: Uuid;
4570
4823
  objectName: string;
4824
+ type: ViewType;
4571
4825
  name: string;
4572
4826
  label: string;
4573
4827
  description?: string;
4574
4828
  icon?: IconName;
4575
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
4576
- layout?: ViewLayout;
4577
- tabs: Tab[];
4829
+ config: ViewConfig;
4578
4830
  default?: boolean;
4579
- system?: boolean;
4580
4831
  metadata?: Record<string, unknown>;
4581
4832
  }
4833
+ /**
4834
+ * Data for updating a view.
4835
+ */
4582
4836
  interface UpdateDBView {
4583
4837
  label?: string;
4584
4838
  description?: string;
4585
4839
  icon?: IconName;
4586
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
4587
- layout?: ViewLayout;
4588
- tabs?: Tab[];
4840
+ config?: ViewConfig;
4589
4841
  default?: boolean;
4590
4842
  metadata?: Record<string, unknown>;
4591
4843
  }
4592
4844
  /**
4593
- * Data for upserting a view.
4845
+ * Data for upserting a view (used by registry seeding).
4594
4846
  * Tenant ID is automatically set from the execution context.
4595
4847
  */
4596
4848
  interface UpsertDBView {
4597
4849
  objectName: string;
4850
+ type: ViewType;
4598
4851
  name: string;
4599
4852
  label: string;
4600
4853
  description?: string;
4601
4854
  icon?: IconName;
4602
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
4603
- layout?: ViewLayout;
4604
- tabs: Tab[];
4855
+ config: ViewConfig;
4605
4856
  default?: boolean;
4606
- system?: boolean;
4607
4857
  metadata?: Record<string, unknown>;
4608
4858
  }
4859
+ /**
4860
+ * View overlay as stored in database
4861
+ * Stores user-specific customizations (delta only)
4862
+ */
4863
+ interface DBViewOverlay extends Timestamps {
4864
+ id: Uuid;
4865
+ tenantId: TenantId;
4866
+ /** View ID this overlay applies to (UUID or virtual ID like "fallback:contacts:list") */
4867
+ viewId: string;
4868
+ /** User ID who owns this overlay */
4869
+ userId: string;
4870
+ /** Configuration overrides (delta only) */
4871
+ configOverrides: ConfigOverrides;
4872
+ /** User's default view for this object */
4873
+ isUserDefault?: boolean;
4874
+ }
4875
+ /**
4876
+ * Data for creating a view overlay.
4877
+ * Tenant ID is automatically set from the execution context.
4878
+ */
4879
+ interface CreateDBViewOverlay {
4880
+ viewId: string;
4881
+ userId: string;
4882
+ configOverrides: ConfigOverrides;
4883
+ isUserDefault?: boolean;
4884
+ }
4885
+ /**
4886
+ * Data for updating a view overlay.
4887
+ */
4888
+ interface UpdateDBViewOverlay {
4889
+ configOverrides?: ConfigOverrides;
4890
+ isUserDefault?: boolean;
4891
+ }
4609
4892
  /**
4610
4893
  * Workflow definition as stored in database.
4611
4894
  * Uses snake_case to match database column names.
@@ -5185,19 +5468,24 @@ declare class NativeObjectRegistryClass {
5185
5468
  declare const registry: NativeObjectRegistryClass;
5186
5469
 
5187
5470
  /**
5188
- * Registry for native view definitions
5471
+ * Registry for developer-defined view definitions
5472
+ *
5473
+ * Views registered here are defined by developers and synced to the database
5474
+ * at application startup. They serve as "source" views that users can customize
5475
+ * via overlays.
5189
5476
  *
5190
- * Views registered here are considered "system" views, defined by the developer.
5191
- * They are protected from modification by end-users and synced to the database
5192
- * at application startup.
5477
+ * Seeding behavior:
5478
+ * - INSERT if view doesn't exist in DB
5479
+ * - SKIP if view already exists (no overwrite)
5480
+ * - To force update: delete the view in DB, then restart app
5193
5481
  *
5194
5482
  * @example
5195
5483
  * ```typescript
5196
- * import { view, group, viewRegistry } from "@stndrds/schema";
5484
+ * import { detailView, group, viewRegistry } from "@stndrds/schema";
5197
5485
  *
5198
- * const COMPANY_DETAIL = view("detail", "Detail")
5486
+ * const COMPANY_DETAIL = detailView("detail", "Detail")
5199
5487
  * .for("companies")
5200
- * .system()
5488
+ * .default()
5201
5489
  * .tab("general", "Info")
5202
5490
  * .form(group("main", "Main").fields("name", "status"))
5203
5491
  * .build();
@@ -5208,11 +5496,11 @@ declare const registry: NativeObjectRegistryClass;
5208
5496
  declare class ViewRegistry {
5209
5497
  private views;
5210
5498
  private byObject;
5499
+ private byObjectAndType;
5211
5500
  /**
5212
- * Register a native view
5501
+ * Register a view
5213
5502
  * @param viewOrViews - Single view or array of views
5214
- * @throws Error if view is not marked as system
5215
- * @throws Error if view with same name already exists for the object
5503
+ * @throws Error if view with same name and type already exists for the object
5216
5504
  */
5217
5505
  register(viewOrViews: ViewDefinition | ViewDefinition[]): this;
5218
5506
  private registerSingle;
@@ -5221,13 +5509,17 @@ declare class ViewRegistry {
5221
5509
  */
5222
5510
  getByObjectName(objectName: string): ViewDefinition[];
5223
5511
  /**
5224
- * Get a specific view by object and view name
5512
+ * Get views for an object filtered by type
5225
5513
  */
5226
- get(objectName: string, viewName: string): ViewDefinition | undefined;
5514
+ getByObjectNameAndType(objectName: string, type: ViewType): ViewDefinition[];
5515
+ /**
5516
+ * Get a specific view by object, name, and type
5517
+ */
5518
+ get(objectName: string, viewName: string, type?: ViewType): ViewDefinition | undefined;
5227
5519
  /**
5228
5520
  * Get a view or throw if not found
5229
5521
  */
5230
- getOrThrow(objectName: string, viewName: string): ViewDefinition;
5522
+ getOrThrow(objectName: string, viewName: string, type?: ViewType): ViewDefinition;
5231
5523
  /**
5232
5524
  * Get all registered views
5233
5525
  */
@@ -5235,7 +5527,7 @@ declare class ViewRegistry {
5235
5527
  /**
5236
5528
  * Check if a view exists
5237
5529
  */
5238
- has(objectName: string, viewName: string): boolean;
5530
+ has(objectName: string, viewName: string, type?: ViewType): boolean;
5239
5531
  /**
5240
5532
  * Check if any views exist for an object
5241
5533
  */
@@ -5249,9 +5541,9 @@ declare class ViewRegistry {
5249
5541
  */
5250
5542
  listObjectNames(): string[];
5251
5543
  /**
5252
- * Get default view for an object (if any)
5544
+ * Get default view for an object and type
5253
5545
  */
5254
- getDefault(objectName: string): ViewDefinition | undefined;
5546
+ getDefault(objectName: string, type: ViewType): ViewDefinition | undefined;
5255
5547
  /**
5256
5548
  * Clear all registered views (for testing)
5257
5549
  */
@@ -5267,7 +5559,7 @@ declare class ViewRegistry {
5267
5559
  private makeKey;
5268
5560
  }
5269
5561
  /**
5270
- * Global registry for native views
5562
+ * Global registry for developer-defined views
5271
5563
  */
5272
5564
  declare const viewRegistry: ViewRegistry;
5273
5565
 
@@ -5906,7 +6198,8 @@ declare function createFormAttributeValidator(attr: Attribute, messages?: Valida
5906
6198
  /**
5907
6199
  * Create a Zod schema for an entire object
5908
6200
  *
5909
- * Uses strict mode to reject unknown keys, preventing invalid data from being stored.
6201
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
6202
+ * present in record data but are not part of the mutable schema.
5910
6203
  */
5911
6204
  declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
5912
6205
  /**
@@ -5936,7 +6229,8 @@ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record
5936
6229
  * Create a Zod schema for draft validation.
5937
6230
  * All attributes become optional, but provided values are still validated.
5938
6231
  *
5939
- * Uses strict mode to reject unknown keys, preventing invalid data from being stored.
6232
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
6233
+ * present in record data but are not part of the mutable schema.
5940
6234
  */
5941
6235
  declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
5942
6236
  /**
@@ -6026,7 +6320,7 @@ declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<s
6026
6320
  * Supported cache key types for type-safe cache operations.
6027
6321
  * Used by `cachedBy()` and `cachedList()` helpers in BaseService.
6028
6322
  */
6029
- type CacheKeyType = "record" | "objectSchema" | "objectSchemaByName" | "objectSchemaList" | "objectAttributes" | "attributeById" | "userProfileById" | "userProfileByAuthId" | "userProfileByEmail" | "viewsByObject" | "workflowByName" | "workflowById" | "workflowList" | "relationOptions" | "resolvedRelation" | "rollupValue" | "userPermissions" | "recordList" | "searchResults" | "globalSearch" | "allRecordLists" | "allSearchResults" | "allGlobalSearch" | "allSchemas" | "allAttributes" | "allPermissions" | "allRelations" | "allResolvedRelations" | "resolvedRelationsByRecord" | "resolvedRelationsByAttr" | "allRollups" | "rollupsByRecord" | "allRecords" | "allViews" | "allUserProfiles" | "allWorkflows" | "allForTenant";
6323
+ type CacheKeyType = "record" | "objectSchema" | "objectSchemaByName" | "objectSchemaList" | "objectOwnerInfo" | "objectAttributes" | "attributeById" | "userProfileById" | "userProfileByAuthId" | "userProfileByEmail" | "viewsByObject" | "workflowByName" | "workflowById" | "workflowList" | "relationOptions" | "resolvedRelation" | "rollupValue" | "userPermissions" | "recordList" | "searchResults" | "globalSearch" | "allRecordLists" | "allSearchResults" | "allGlobalSearch" | "allSchemas" | "allAttributes" | "allPermissions" | "allRelations" | "allResolvedRelations" | "resolvedRelationsByRecord" | "resolvedRelationsByAttr" | "allRollups" | "rollupsByRecord" | "allRecords" | "allViews" | "allUserProfiles" | "allWorkflows" | "allForTenant";
6030
6324
  /**
6031
6325
  * Generate a deterministic hash from query options.
6032
6326
  * Keys are sorted recursively to ensure same hash regardless of property order.
@@ -6114,6 +6408,7 @@ declare const cacheKeys: {
6114
6408
  readonly objectSchemaByName: (tenantId: string, name: string) => string;
6115
6409
  /** List of all object schemas */
6116
6410
  readonly objectSchemaList: (tenantId: string) => string;
6411
+ readonly objectOwnerInfo: (tenantId: string, objectId: string) => string;
6117
6412
  /** Attributes for an object */
6118
6413
  readonly objectAttributes: (tenantId: string, objectId: string) => string;
6119
6414
  /** Single attribute by ID (covered by allAttributes pattern) */
@@ -6128,7 +6423,15 @@ declare const cacheKeys: {
6128
6423
  * Used by cachedByMany in RelationService.resolveIds()
6129
6424
  */
6130
6425
  readonly resolvedRelation: (tenantId: string, compositeId: string) => string;
6131
- /** Computed rollup value for a record */
6426
+ /**
6427
+ * Computed rollup value for a record.
6428
+ *
6429
+ * NOTE: When used via `cachedBy("rollupValue", compositeId, ...)`, the compositeId
6430
+ * is `${recordId}:${attrName}`. Since `cachedBy` calls `keyFn(tenantId, compositeId)`,
6431
+ * the third parameter receives the composite string, producing the same key as
6432
+ * calling `rollupValue(tenantId, recordId, attrName)` directly. This works because
6433
+ * the colon separator in the composite matches the key format, but is intentional.
6434
+ */
6132
6435
  readonly rollupValue: (tenantId: string, recordId: string, attrName: string) => string;
6133
6436
  /** Individual record by ID */
6134
6437
  readonly record: (tenantId: string, recordId: string) => string;
@@ -6266,207 +6569,232 @@ declare class NoopCacheAdapter implements CacheAdapter {
6266
6569
  }
6267
6570
 
6268
6571
  /**
6269
- * Repository for objects table (metadata).
6572
+ * Repository for unified views table.
6573
+ * Supports all view types (detail, list, calendar, etc.) via polymorphic config.
6270
6574
  *
6271
6575
  * All operations are automatically scoped to the current tenant
6272
6576
  * from the execution context (via AsyncLocalStorage).
6273
6577
  */
6274
- interface ObjectsRepository {
6578
+ interface ViewsRepository {
6275
6579
  /**
6276
- * Find object by ID.
6580
+ * Find view by ID.
6277
6581
  * Automatically filtered by current tenant context.
6278
6582
  */
6279
- findById(id: Uuid): Promise<DBObject | null>;
6583
+ findById(id: Uuid): Promise<DBView | null>;
6280
6584
  /**
6281
- * Find object by name.
6585
+ * Find view by name for an object.
6282
6586
  * Automatically filtered by current tenant context.
6283
6587
  */
6284
- findByName(name: string): Promise<DBObject | null>;
6588
+ findByName(objectName: string, viewName: string): Promise<DBView | null>;
6285
6589
  /**
6286
- * Find system/native object by name (system=true, for sync).
6287
- * System objects are shared across tenants.
6590
+ * Find view by name and type for an object.
6591
+ * Automatically filtered by current tenant context.
6288
6592
  */
6289
- findSystemByName(name: string): Promise<DBObject | null>;
6593
+ findByNameAndType(objectName: string, viewName: string, type: ViewType): Promise<DBView | null>;
6290
6594
  /**
6291
- * Create object.
6595
+ * Find all views for an object.
6596
+ * Optionally filter by type.
6597
+ * Automatically filtered by current tenant context.
6598
+ */
6599
+ findByObjectName(objectName: string, type?: ViewType): Promise<DBView[]>;
6600
+ /**
6601
+ * Find all views for current tenant.
6602
+ * Optionally filter by type.
6603
+ * Automatically filtered by current tenant context.
6604
+ */
6605
+ findAllForTenant(type?: ViewType): Promise<DBView[]>;
6606
+ /**
6607
+ * Find default view for an object and type.
6608
+ * Returns the view marked as default, or null if none.
6609
+ */
6610
+ findDefault(objectName: string, type: ViewType): Promise<DBView | null>;
6611
+ /**
6612
+ * Create view.
6292
6613
  * Tenant ID is automatically set from context.
6293
6614
  */
6294
- create(data: CreateDBObject): Promise<DBObject>;
6615
+ create(data: CreateDBView): Promise<DBView>;
6295
6616
  /**
6296
- * Update object.
6617
+ * Update view.
6297
6618
  * Automatically filtered by current tenant context.
6298
6619
  */
6299
- update(id: Uuid, data: Partial<UpdateDBObject>): Promise<DBObject>;
6620
+ update(id: Uuid, data: Partial<UpdateDBView>): Promise<DBView>;
6300
6621
  /**
6301
- * Delete object.
6622
+ * Delete view.
6302
6623
  * Automatically filtered by current tenant context.
6303
6624
  */
6304
6625
  delete(id: Uuid): Promise<void>;
6305
6626
  /**
6306
- * List all objects for current tenant.
6627
+ * Delete views not in the list (for sync cleanup).
6307
6628
  * Automatically filtered by current tenant context.
6629
+ * @returns Number of deleted views
6308
6630
  */
6309
- list(): Promise<DBObject[]>;
6631
+ deleteNotIn(objectName: string, type: ViewType, keepViewNames: string[]): Promise<number>;
6310
6632
  /**
6311
- * Upsert object (create or update based on nativeObjectId).
6633
+ * Upsert view (create or update based on objectName + name + type).
6634
+ * Used by registry seeding - skips if view already exists.
6312
6635
  * Tenant ID is automatically set from context.
6313
6636
  */
6314
- upsert(data: UpsertDBObject): Promise<DBObject>;
6637
+ upsert(data: UpsertDBView): Promise<DBView>;
6638
+ /**
6639
+ * Check if a view exists by name and type.
6640
+ * Used by registry seeding to skip existing views.
6641
+ */
6642
+ exists(objectName: string, viewName: string, type: ViewType): Promise<boolean>;
6315
6643
  }
6316
6644
  /**
6317
- * Repository for attributes table (metadata)
6645
+ * Repository for view overlays (user customizations).
6646
+ * Stores delta/overrides per user, merged at runtime with source view.
6647
+ *
6648
+ * All operations are automatically scoped to the current tenant
6649
+ * from the execution context (via AsyncLocalStorage).
6318
6650
  */
6319
- interface AttributesRepository {
6651
+ interface ViewOverlaysRepository {
6320
6652
  /**
6321
- * Find attribute by ID
6653
+ * Find overlay by ID.
6654
+ * Automatically filtered by current tenant context.
6322
6655
  */
6323
- findById(id: Uuid): Promise<DBAttribute | null>;
6656
+ findById(id: Uuid): Promise<DBViewOverlay | null>;
6324
6657
  /**
6325
- * Find attributes by object ID
6658
+ * Find overlay for a view and user.
6659
+ * ViewId can be a UUID or a virtual fallback ID.
6326
6660
  */
6327
- findByObjectId(objectId: Uuid): Promise<DBAttribute[]>;
6661
+ findByViewAndUser(viewId: string, userId: string): Promise<DBViewOverlay | null>;
6328
6662
  /**
6329
- * Create attribute
6663
+ * Find all overlays for a user.
6330
6664
  */
6331
- create(data: CreateDBAttribute): Promise<DBAttribute>;
6665
+ findByUser(userId: string): Promise<DBViewOverlay[]>;
6332
6666
  /**
6333
- * Update attribute
6667
+ * Find all overlays for a view (all users).
6334
6668
  */
6335
- update(id: Uuid, data: Partial<UpdateDBAttribute>): Promise<DBAttribute>;
6669
+ findByView(viewId: string): Promise<DBViewOverlay[]>;
6336
6670
  /**
6337
- * Delete attribute
6671
+ * Find user's default view overlay for an object.
6672
+ * Returns the overlay where isUserDefault is true.
6673
+ */
6674
+ findUserDefault(userId: string, objectName: string, type: ViewType): Promise<DBViewOverlay | null>;
6675
+ /**
6676
+ * Create overlay.
6677
+ * Tenant ID is automatically set from context.
6678
+ */
6679
+ create(data: CreateDBViewOverlay): Promise<DBViewOverlay>;
6680
+ /**
6681
+ * Update overlay.
6682
+ * Automatically filtered by current tenant context.
6683
+ */
6684
+ update(id: Uuid, data: Partial<UpdateDBViewOverlay>): Promise<DBViewOverlay>;
6685
+ /**
6686
+ * Delete overlay.
6687
+ * Automatically filtered by current tenant context.
6338
6688
  */
6339
6689
  delete(id: Uuid): Promise<void>;
6340
6690
  /**
6341
- * Delete multiple attributes by names (for sync cleanup)
6691
+ * Delete overlay by view and user.
6692
+ * Used for "reset to default" functionality.
6342
6693
  */
6343
- deleteByNames(objectId: Uuid, excludeNames: string[]): Promise<number>;
6694
+ deleteByViewAndUser(viewId: string, userId: string): Promise<void>;
6344
6695
  /**
6345
- * Upsert attribute (create or update based on objectId + name)
6696
+ * Delete all overlays for a view.
6697
+ * Called when a view is deleted (cascade).
6346
6698
  */
6347
- upsert(data: UpsertDBAttribute): Promise<DBAttribute>;
6699
+ deleteByView(viewId: string): Promise<number>;
6700
+ /**
6701
+ * Migrate overlays from one viewId to another.
6702
+ * Used when a fallback view becomes a real view.
6703
+ * @returns Number of migrated overlays
6704
+ */
6705
+ migrateViewId(fromViewId: string, toViewId: string): Promise<number>;
6706
+ /**
6707
+ * Upsert overlay (create or update based on viewId + userId).
6708
+ */
6709
+ upsert(data: CreateDBViewOverlay): Promise<DBViewOverlay>;
6710
+ /**
6711
+ * Clear user default for an object (before setting a new one).
6712
+ */
6713
+ clearUserDefault(userId: string, objectName: string, type: ViewType): Promise<void>;
6348
6714
  }
6715
+
6349
6716
  /**
6350
- * Repository for user_profiles table.
6717
+ * Repository for objects table (metadata).
6351
6718
  *
6352
6719
  * All operations are automatically scoped to the current tenant
6353
6720
  * from the execution context (via AsyncLocalStorage).
6354
6721
  */
6355
- interface UserProfilesRepository {
6356
- /**
6357
- * Find user profile by ID.
6358
- * Automatically filtered by current tenant context.
6359
- */
6360
- findById(id: Uuid): Promise<UserProfile | null>;
6722
+ interface ObjectsRepository {
6361
6723
  /**
6362
- * Find multiple user profiles by IDs.
6724
+ * Find object by ID.
6363
6725
  * Automatically filtered by current tenant context.
6364
- * Returns only profiles that exist and belong to the current tenant.
6365
6726
  */
6366
- findByIds(ids: Uuid[]): Promise<UserProfile[]>;
6727
+ findById(id: Uuid): Promise<DBObject | null>;
6367
6728
  /**
6368
- * Find user profile by auth ID (external auth provider).
6729
+ * Find object by name.
6369
6730
  * Automatically filtered by current tenant context.
6370
6731
  */
6371
- findByAuthId(authId: string): Promise<UserProfile | null>;
6732
+ findByName(name: string): Promise<DBObject | null>;
6372
6733
  /**
6373
- * Find user profile by email.
6374
- * Automatically filtered by current tenant context.
6734
+ * Find system/native object by name (system=true, for sync).
6735
+ * System objects are shared across tenants.
6375
6736
  */
6376
- findByEmail(email: string): Promise<UserProfile | null>;
6737
+ findSystemByName(name: string): Promise<DBObject | null>;
6377
6738
  /**
6378
- * Create user profile.
6739
+ * Create object.
6379
6740
  * Tenant ID is automatically set from context.
6380
6741
  */
6381
- create(data: CreateUserProfile): Promise<UserProfile>;
6742
+ create(data: CreateDBObject): Promise<DBObject>;
6382
6743
  /**
6383
- * Update user profile.
6744
+ * Update object.
6384
6745
  * Automatically filtered by current tenant context.
6385
6746
  */
6386
- update(id: Uuid, data: UpdateUserProfile): Promise<UserProfile>;
6747
+ update(id: Uuid, data: Partial<UpdateDBObject>): Promise<DBObject>;
6387
6748
  /**
6388
- * Delete user profile.
6749
+ * Delete object.
6389
6750
  * Automatically filtered by current tenant context.
6390
6751
  */
6391
6752
  delete(id: Uuid): Promise<void>;
6392
6753
  /**
6393
- * List all user profiles for current tenant.
6394
- * Automatically filtered by current tenant context.
6395
- */
6396
- list(options?: ListOptions): Promise<UserProfile[]>;
6397
- /**
6398
- * Count user profiles by role within current tenant.
6399
- * Useful for checking if last admin before deletion.
6400
- */
6401
- countByRole(role: string): Promise<number>;
6402
- /**
6403
- * Update last login timestamp.
6754
+ * List all objects for current tenant.
6404
6755
  * Automatically filtered by current tenant context.
6405
6756
  */
6406
- updateLastLogin(id: Uuid): Promise<void>;
6757
+ list(): Promise<DBObject[]>;
6407
6758
  /**
6408
- * Invite a user by email.
6409
- * Creates a pending user profile with a temporary authId.
6759
+ * Upsert object (create or update based on nativeObjectId).
6410
6760
  * Tenant ID is automatically set from context.
6411
- *
6412
- * @param data - Invitation data (email, firstName, lastName, role)
6413
- * @returns Created pending user profile
6414
6761
  */
6415
- invite(data: InviteUserInput): Promise<UserProfile>;
6762
+ upsert(data: UpsertDBObject): Promise<DBObject>;
6416
6763
  }
6417
6764
  /**
6418
- * Repository for files table.
6419
- *
6420
- * All operations are automatically scoped to the current tenant
6421
- * from the execution context (via AsyncLocalStorage).
6765
+ * Repository for attributes table (metadata)
6422
6766
  */
6423
- interface FilesRepository {
6767
+ interface AttributesRepository {
6424
6768
  /**
6425
- * Find file by ID.
6426
- * Returns file with signed URL. Automatically filtered by current tenant context.
6769
+ * Find attribute by ID
6427
6770
  */
6428
- findById(id: Uuid): Promise<File | null>;
6771
+ findById(id: Uuid): Promise<DBAttribute | null>;
6429
6772
  /**
6430
- * Find multiple files by IDs.
6431
- * Returns files with signed URLs. Automatically filtered by current tenant context.
6773
+ * Find attributes by object ID
6432
6774
  */
6433
- findByIds(ids: Uuid[]): Promise<File[]>;
6775
+ findByObjectId(objectId: Uuid): Promise<DBAttribute[]>;
6434
6776
  /**
6435
- * Create file.
6436
- * Returns file with signed URL. Tenant ID is automatically set from context.
6777
+ * Create attribute
6437
6778
  */
6438
- create(data: CreateFile): Promise<File>;
6779
+ create(data: CreateDBAttribute): Promise<DBAttribute>;
6439
6780
  /**
6440
- * Update file.
6441
- * Automatically filtered by current tenant context.
6781
+ * Update attribute
6442
6782
  */
6443
- update(id: Uuid, data: UpdateFile): Promise<File>;
6783
+ update(id: Uuid, data: Partial<UpdateDBAttribute>): Promise<DBAttribute>;
6444
6784
  /**
6445
- * Delete file (soft delete).
6446
- * Automatically filtered by current tenant context.
6785
+ * Delete attribute
6447
6786
  */
6448
6787
  delete(id: Uuid): Promise<void>;
6449
6788
  /**
6450
- * Hard delete file (permanent).
6451
- * Automatically filtered by current tenant context.
6452
- */
6453
- hardDelete(id: Uuid): Promise<void>;
6454
- /**
6455
- * List files for current tenant.
6456
- * Automatically filtered by current tenant context.
6457
- */
6458
- list(options?: FileListOptions): Promise<File[]>;
6459
- /**
6460
- * Find files by folder path.
6461
- * Automatically filtered by current tenant context.
6789
+ * Delete multiple attributes by names (for sync cleanup)
6462
6790
  */
6463
- findByFolder(folderPath: string): Promise<File[]>;
6791
+ deleteByNames(objectId: Uuid, excludeNames: string[]): Promise<number>;
6464
6792
  /**
6465
- * Find files by uploader.
6466
- * Automatically filtered by current tenant context.
6793
+ * Upsert attribute (create or update based on objectId + name)
6467
6794
  */
6468
- findByUploader(uploadedBy: Uuid): Promise<File[]>;
6795
+ upsert(data: UpsertDBAttribute): Promise<DBAttribute>;
6469
6796
  }
6797
+
6470
6798
  /**
6471
6799
  * Repository for object_records table (unified JSONB).
6472
6800
  *
@@ -6542,19 +6870,10 @@ interface ObjectRecordsRepository {
6542
6870
  * Count records that reference a given record ID in any relation attribute.
6543
6871
  * Used to implement the "Restrict" delete behavior.
6544
6872
  *
6545
- * This method scans all relation attributes across all objects to find
6546
- * records that contain the target ID in their relation values.
6547
- *
6548
6873
  * **Important:** This method should exclude soft-deleted records from the count.
6549
6874
  *
6550
6875
  * @param targetId - The record ID being checked for references
6551
6876
  * @returns Array of objects with reference counts, grouped by object
6552
- *
6553
- * @example
6554
- * ```typescript
6555
- * const refs = await repo.countRecordsReferencingId("rec-123");
6556
- * // [{ objectName: "contacts", objectLabel: "Contacts", count: 3 }]
6557
- * ```
6558
6877
  */
6559
6878
  countRecordsReferencingId(targetId: Uuid): Promise<Array<{
6560
6879
  objectName: string;
@@ -6565,43 +6884,18 @@ interface ObjectRecordsRepository {
6565
6884
  * Remove an attribute's data from all records of an object.
6566
6885
  * Used after attribute deletion to clean up orphaned data.
6567
6886
  *
6568
- * This efficiently removes the key from the JSONB values column
6569
- * for all records belonging to the specified object.
6570
- *
6571
6887
  * @param objectId - Object UUID
6572
6888
  * @param attributeName - Name of the attribute to remove
6573
6889
  * @returns Number of records that were updated
6574
- *
6575
- * @example
6576
- * ```typescript
6577
- * const updated = await repo.removeAttributeData("obj-123", "oldField");
6578
- * console.log(`Cleaned up ${updated} records`);
6579
- * ```
6580
6890
  */
6581
6891
  removeAttributeData(objectId: Uuid, attributeName: string): Promise<number>;
6582
6892
  /**
6583
6893
  * Batch update labels for all records of an object.
6584
6894
  * Used after labelExpression changes to refresh all record labels.
6585
6895
  *
6586
- * Supports both sync and async compute functions to allow for
6587
- * relation resolution when the label expression references relations.
6588
- *
6589
6896
  * @param objectId - Object UUID
6590
6897
  * @param computeLabel - Function to compute label from record values (sync or async)
6591
6898
  * @returns Number of records that were updated
6592
- *
6593
- * @example
6594
- * ```typescript
6595
- * // Sync compute (simple labels)
6596
- * const updated = await repo.batchRefreshLabels("obj-123", (values) => {
6597
- * return `${values.sku} - ${values.name}`;
6598
- * });
6599
- *
6600
- * // Async compute (with relation resolution)
6601
- * const updated = await repo.batchRefreshLabels("obj-123", async (values) => {
6602
- * return await computeLabelWithRelations(template, values, attributes, resolver);
6603
- * });
6604
- * ```
6605
6899
  */
6606
6900
  batchRefreshLabels(objectId: Uuid, computeLabel: (values: Record<string, unknown>) => Promise<string> | string): Promise<number>;
6607
6901
  /**
@@ -6618,325 +6912,142 @@ interface ObjectRecordsRepository {
6618
6912
  * Used by rollup calculations to find related records.
6619
6913
  * Automatically filtered by current tenant context.
6620
6914
  *
6621
- * For example, find all orders where values->'companyId' = 'company-123'
6622
- *
6623
- * @param objectId - Object ID of the records to search (e.g., Orders object)
6624
- * @param relationAttribute - Name of the relation attribute (e.g., "companyId")
6915
+ * @param objectId - Object ID of the records to search
6916
+ * @param relationAttribute - Name of the relation attribute
6625
6917
  * @param targetId - The ID to search for in the relation attribute
6626
6918
  * @returns Records that reference the target ID
6627
- *
6628
- * @example
6629
- * ```typescript
6630
- * // Find all orders for a specific company
6631
- * const orders = await repo.findByRelation(
6632
- * "orders-object-id",
6633
- * "companyId",
6634
- * "company-123"
6635
- * );
6636
- * ```
6637
6919
  */
6638
6920
  findByRelation(objectId: Uuid, relationAttribute: string, targetId: Uuid): Promise<ObjectRecord[]>;
6639
6921
  }
6922
+
6640
6923
  /**
6641
- * Repository for views table.
6924
+ * Repository for user_profiles table.
6642
6925
  *
6643
6926
  * All operations are automatically scoped to the current tenant
6644
6927
  * from the execution context (via AsyncLocalStorage).
6645
6928
  */
6646
- interface ViewsRepository {
6929
+ interface UserProfilesRepository {
6647
6930
  /**
6648
- * Find view by ID.
6931
+ * Find user profile by ID.
6649
6932
  * Automatically filtered by current tenant context.
6650
6933
  */
6651
- findById(id: Uuid): Promise<DBView | null>;
6934
+ findById(id: Uuid): Promise<UserProfile | null>;
6652
6935
  /**
6653
- * Find view by name for an object.
6936
+ * Find multiple user profiles by IDs.
6654
6937
  * Automatically filtered by current tenant context.
6655
6938
  */
6656
- findByName(objectName: string, viewName: string): Promise<DBView | null>;
6939
+ findByIds(ids: Uuid[]): Promise<UserProfile[]>;
6657
6940
  /**
6658
- * Find all views for an object.
6941
+ * Find user profile by auth ID (external auth provider).
6659
6942
  * Automatically filtered by current tenant context.
6660
6943
  */
6661
- findByObjectName(objectName: string): Promise<DBView[]>;
6944
+ findByAuthId(authId: string): Promise<UserProfile | null>;
6662
6945
  /**
6663
- * Find all views for current tenant.
6946
+ * Find user profile by email.
6664
6947
  * Automatically filtered by current tenant context.
6665
6948
  */
6666
- findAllForTenant(): Promise<DBView[]>;
6949
+ findByEmail(email: string): Promise<UserProfile | null>;
6667
6950
  /**
6668
- * Find system view by name (for sync).
6669
- * System views are shared across tenants.
6951
+ * Create user profile.
6952
+ * Tenant ID is automatically set from context.
6670
6953
  */
6671
- findSystemByName(objectName: string, viewName: string): Promise<DBView | null>;
6954
+ create(data: CreateUserProfile): Promise<UserProfile>;
6672
6955
  /**
6673
- * Find all system views for an object.
6674
- * System views are shared across tenants.
6956
+ * Update user profile.
6957
+ * Automatically filtered by current tenant context.
6675
6958
  */
6676
- findSystemByObjectName(objectName: string): Promise<DBView[]>;
6959
+ update(id: Uuid, data: UpdateUserProfile): Promise<UserProfile>;
6677
6960
  /**
6678
- * Create view.
6679
- * Tenant ID is automatically set from context.
6961
+ * Delete user profile.
6962
+ * Automatically filtered by current tenant context.
6680
6963
  */
6681
- create(data: CreateDBView): Promise<DBView>;
6964
+ delete(id: Uuid): Promise<void>;
6682
6965
  /**
6683
- * Update view.
6966
+ * List all user profiles for current tenant.
6684
6967
  * Automatically filtered by current tenant context.
6685
6968
  */
6686
- update(id: Uuid, data: Partial<UpdateDBView>): Promise<DBView>;
6969
+ list(options?: ListOptions): Promise<UserProfile[]>;
6687
6970
  /**
6688
- * Delete view.
6689
- * Automatically filtered by current tenant context.
6971
+ * Count user profiles by role within current tenant.
6690
6972
  */
6691
- delete(id: Uuid): Promise<void>;
6973
+ countByRole(role: string): Promise<number>;
6692
6974
  /**
6693
- * Delete views not in the list (for sync cleanup).
6975
+ * Update last login timestamp.
6694
6976
  * Automatically filtered by current tenant context.
6695
- * @returns Number of deleted views
6696
6977
  */
6697
- deleteNotIn(objectName: string, keepViewNames: string[]): Promise<number>;
6978
+ updateLastLogin(id: Uuid): Promise<void>;
6698
6979
  /**
6699
- * Upsert view (create or update based on objectName + name).
6980
+ * Invite a user by email.
6981
+ * Creates a pending user profile with a temporary authId.
6700
6982
  * Tenant ID is automatically set from context.
6701
6983
  */
6702
- upsert(data: UpsertDBView): Promise<DBView>;
6984
+ invite(data: InviteUserInput): Promise<UserProfile>;
6703
6985
  }
6704
6986
  /**
6705
- * Repository for workflow definitions.
6706
- *
6707
- * This repository is optional - if not provided in the DatabaseAdapter,
6708
- * workflow features are disabled.
6987
+ * Repository for files table.
6709
6988
  *
6710
6989
  * All operations are automatically scoped to the current tenant
6711
6990
  * from the execution context (via AsyncLocalStorage).
6712
6991
  */
6713
- interface WorkflowsRepository {
6992
+ interface FilesRepository {
6714
6993
  /**
6715
- * Find workflow by ID.
6716
- * Automatically filtered by current tenant context.
6994
+ * Find file by ID.
6995
+ * Returns file with signed URL.
6717
6996
  */
6718
- findById(id: Uuid): Promise<DBWorkflow | null>;
6997
+ findById(id: Uuid): Promise<File | null>;
6719
6998
  /**
6720
- * Find workflow by name.
6721
- * Automatically filtered by current tenant context.
6999
+ * Find multiple files by IDs.
7000
+ * Returns files with signed URLs.
6722
7001
  */
6723
- findByName(name: string): Promise<DBWorkflow | null>;
7002
+ findByIds(ids: Uuid[]): Promise<File[]>;
6724
7003
  /**
6725
- * Find system workflow by name (for sync).
6726
- * System workflows are shared across tenants.
7004
+ * Create file.
7005
+ * Returns file with signed URL.
6727
7006
  */
6728
- findSystemByName(name: string): Promise<DBWorkflow | null>;
7007
+ create(data: CreateFile): Promise<File>;
6729
7008
  /**
6730
- * List all workflows for current tenant.
6731
- * Automatically filtered by current tenant context.
7009
+ * Update file.
6732
7010
  */
6733
- list(): Promise<DBWorkflow[]>;
7011
+ update(id: Uuid, data: UpdateFile): Promise<File>;
6734
7012
  /**
6735
- * List workflows by status.
6736
- * Automatically filtered by current tenant context.
7013
+ * Delete file (soft delete).
6737
7014
  */
6738
- listByStatus(status: WorkflowStatus): Promise<DBWorkflow[]>;
7015
+ delete(id: Uuid): Promise<void>;
6739
7016
  /**
6740
- * Create workflow.
6741
- * Tenant ID is automatically set from context.
7017
+ * Hard delete file (permanent).
6742
7018
  */
6743
- create(data: CreateDBWorkflow): Promise<DBWorkflow>;
7019
+ hardDelete(id: Uuid): Promise<void>;
6744
7020
  /**
6745
- * Update workflow.
6746
- * Automatically filtered by current tenant context.
7021
+ * List files for current tenant.
6747
7022
  */
6748
- update(id: Uuid, data: Partial<UpdateDBWorkflow>): Promise<DBWorkflow>;
7023
+ list(options?: FileListOptions): Promise<File[]>;
6749
7024
  /**
6750
- * Delete workflow.
6751
- * Automatically filtered by current tenant context.
7025
+ * Find files by folder path.
6752
7026
  */
6753
- delete(id: Uuid): Promise<void>;
7027
+ findByFolder(folderPath: string): Promise<File[]>;
6754
7028
  /**
6755
- * Upsert workflow (create or update based on name + system flag).
6756
- * Tenant ID is automatically set from context.
7029
+ * Find files by uploader.
6757
7030
  */
6758
- upsert(data: CreateDBWorkflow): Promise<DBWorkflow>;
7031
+ findByUploader(uploadedBy: Uuid): Promise<File[]>;
6759
7032
  }
7033
+
6760
7034
  /**
6761
- * Repository for workflow instances (running/completed workflows).
7035
+ * Repository for audit logs.
6762
7036
  *
6763
7037
  * This repository is optional - if not provided in the DatabaseAdapter,
6764
- * workflow execution features are disabled.
6765
- *
6766
- * All operations are automatically scoped to the current tenant
6767
- * from the execution context (via AsyncLocalStorage).
7038
+ * audit logging is disabled.
6768
7039
  */
6769
- interface WorkflowInstancesRepository {
7040
+ interface AuditRepository {
6770
7041
  /**
6771
- * Find instance by ID.
6772
- * Automatically filtered by current tenant context.
7042
+ * Create a new audit log entry.
6773
7043
  */
6774
- findById(id: Uuid): Promise<DBWorkflowInstance | null>;
7044
+ create(entry: CreateAuditLogInput): Promise<AuditLogEntry>;
6775
7045
  /**
6776
- * Find instances by workflow ID.
6777
- * Automatically filtered by current tenant context.
7046
+ * Create multiple audit log entries (batch insert).
6778
7047
  */
6779
- findByWorkflowId(workflowId: Uuid): Promise<DBWorkflowInstance[]>;
7048
+ createMany(entries: CreateAuditLogInput[]): Promise<void>;
6780
7049
  /**
6781
- * Find instances by workflow name.
6782
- * Automatically filtered by current tenant context.
6783
- */
6784
- findByWorkflowName(workflowName: string): Promise<DBWorkflowInstance[]>;
6785
- /**
6786
- * List all instances for current tenant.
6787
- * Automatically filtered by current tenant context.
6788
- */
6789
- list(options?: ListOptions): Promise<{
6790
- instances: DBWorkflowInstance[];
6791
- total: number;
6792
- }>;
6793
- /**
6794
- * List instances by status.
6795
- * Automatically filtered by current tenant context.
6796
- */
6797
- listByStatus(status: InstanceStatus): Promise<DBWorkflowInstance[]>;
6798
- /**
6799
- * Create instance.
6800
- * Tenant ID is automatically set from context.
6801
- */
6802
- create(data: CreateDBWorkflowInstance): Promise<DBWorkflowInstance>;
6803
- /**
6804
- * Update instance.
6805
- * Automatically filtered by current tenant context.
6806
- */
6807
- update(id: Uuid, data: Partial<UpdateDBWorkflowInstance>): Promise<DBWorkflowInstance>;
6808
- /**
6809
- * Upsert instance (create or update based on ID).
6810
- * Tenant ID is automatically set from context.
6811
- */
6812
- upsert(data: CreateDBWorkflowInstance & {
6813
- id: string;
6814
- }): Promise<DBWorkflowInstance>;
6815
- /**
6816
- * Find instances that reference a specific record in their slot context.
6817
- * Searches in context.slots for slots where objectName and id match.
6818
- * Automatically filtered by current tenant context.
6819
- *
6820
- * This method is required and must be implemented by all adapters.
6821
- * No fallback is provided for performance reasons - all implementations
6822
- * must use database-level optimizations (e.g., JSONB queries in PostgreSQL).
6823
- *
6824
- * @param objectName - Object name to match in slot data
6825
- * @param recordId - Record ID to match in slot data
6826
- * @param options - Optional filtering options
6827
- */
6828
- findByRecordInSlots(objectName: string, recordId: string, options?: {
6829
- status?: InstanceStatus;
6830
- limit?: number;
6831
- offset?: number;
6832
- }): Promise<{
6833
- instances: DBWorkflowInstance[];
6834
- total: number;
6835
- }>;
6836
- }
6837
- /**
6838
- * Repository for workflow participations (external user access to workflows).
6839
- *
6840
- * This repository is optional - if not provided in the DatabaseAdapter,
6841
- * external participation features are disabled.
6842
- *
6843
- * All operations are automatically scoped to the current tenant
6844
- * from the execution context (via AsyncLocalStorage).
6845
- */
6846
- /**
6847
- * Repository for workflow invitations.
6848
- *
6849
- * All operations are automatically scoped to the current tenant
6850
- * from the execution context (via AsyncLocalStorage).
6851
- */
6852
- interface WorkflowInvitationsRepository {
6853
- /**
6854
- * Find invitation by ID.
6855
- * Automatically filtered by current tenant context.
6856
- */
6857
- findById(id: Uuid): Promise<DBWorkflowInvitation | null>;
6858
- /**
6859
- * Find invitations by instance ID.
6860
- * Automatically filtered by current tenant context.
6861
- */
6862
- findByInstanceId(instanceId: Uuid): Promise<DBWorkflowInvitation[]>;
6863
- /**
6864
- * Find invitations by recipient email.
6865
- * Automatically filtered by current tenant context.
6866
- */
6867
- findByEmail(email: string): Promise<DBWorkflowInvitation[]>;
6868
- /**
6869
- * Create invitation.
6870
- * Tenant ID is automatically set from context.
6871
- */
6872
- create(data: CreateDBWorkflowInvitation): Promise<DBWorkflowInvitation>;
6873
- /**
6874
- * Update invitation.
6875
- * Automatically filtered by current tenant context.
6876
- */
6877
- update(id: Uuid, data: UpdateDBWorkflowInvitation): Promise<DBWorkflowInvitation>;
6878
- }
6879
- /**
6880
- * Repository for workflow access grants.
6881
- *
6882
- * All operations are automatically scoped to the current tenant
6883
- * from the execution context (via AsyncLocalStorage).
6884
- */
6885
- interface WorkflowAccessGrantsRepository {
6886
- /**
6887
- * Find grant by ID.
6888
- * Automatically filtered by current tenant context.
6889
- */
6890
- findById(id: Uuid): Promise<DBWorkflowAccessGrant | null>;
6891
- /**
6892
- * Find grants by invitation ID.
6893
- * Automatically filtered by current tenant context.
6894
- */
6895
- findByInvitationId(invitationId: Uuid): Promise<DBWorkflowAccessGrant[]>;
6896
- /**
6897
- * Find grants by instance ID.
6898
- * Automatically filtered by current tenant context.
6899
- */
6900
- findByInstanceId(instanceId: Uuid): Promise<DBWorkflowAccessGrant[]>;
6901
- /**
6902
- * Find grants by email.
6903
- * Automatically filtered by current tenant context.
6904
- */
6905
- findByEmail(email: string): Promise<DBWorkflowAccessGrant[]>;
6906
- /**
6907
- * Create grant.
6908
- * Tenant ID is automatically set from context.
6909
- */
6910
- create(data: CreateDBWorkflowAccessGrant): Promise<DBWorkflowAccessGrant>;
6911
- /**
6912
- * Update grant.
6913
- * Automatically filtered by current tenant context.
6914
- */
6915
- update(id: Uuid, data: UpdateDBWorkflowAccessGrant): Promise<DBWorkflowAccessGrant>;
6916
- }
6917
- /**
6918
- * Repository for audit logs.
6919
- *
6920
- * This repository is optional - if not provided in the DatabaseAdapter,
6921
- * audit logging is disabled (backward compatible behavior).
6922
- *
6923
- * All operations are automatically scoped to the current tenant
6924
- * from the execution context (via AsyncLocalStorage).
6925
- */
6926
- interface AuditRepository {
6927
- /**
6928
- * Create a new audit log entry.
6929
- * Tenant ID is automatically set from context.
6930
- */
6931
- create(entry: CreateAuditLogInput): Promise<AuditLogEntry>;
6932
- /**
6933
- * Create multiple audit log entries (batch insert for performance).
6934
- * Tenant ID is automatically set from context.
6935
- */
6936
- createMany(entries: CreateAuditLogInput[]): Promise<void>;
6937
- /**
6938
- * List audit logs with filtering and pagination.
6939
- * Automatically filtered by current tenant context.
7050
+ * List audit logs with filtering and pagination.
6940
7051
  */
6941
7052
  list(options?: AuditListOptions): Promise<{
6942
7053
  entries: AuditLogEntry[];
@@ -6944,17 +7055,14 @@ interface AuditRepository {
6944
7055
  }>;
6945
7056
  /**
6946
7057
  * Get audit logs for a specific resource.
6947
- * Automatically filtered by current tenant context.
6948
7058
  */
6949
7059
  getByResource(resourceType: AuditResourceType, resourceId: Uuid, options?: AuditListOptions): Promise<AuditLogEntry[]>;
6950
7060
  /**
6951
7061
  * Get audit logs by actor.
6952
- * Automatically filtered by current tenant context.
6953
7062
  */
6954
7063
  getByActor(actorId: Uuid, options?: AuditListOptions): Promise<AuditLogEntry[]>;
6955
7064
  /**
6956
7065
  * Delete old audit logs (for retention policy).
6957
- * Automatically filtered by current tenant context.
6958
7066
  * @returns Number of deleted entries
6959
7067
  */
6960
7068
  deleteOlderThan(date: Date): Promise<number>;
@@ -6963,418 +7071,168 @@ interface AuditRepository {
6963
7071
  * Repository for roles, permissions, and user role assignments.
6964
7072
  *
6965
7073
  * This repository is optional - if not provided in the DatabaseAdapter,
6966
- * permission checks are disabled (backward compatible behavior).
6967
- *
6968
- * All operations are automatically scoped to the current tenant
6969
- * from the execution context (via AsyncLocalStorage).
7074
+ * permission checks are disabled.
6970
7075
  */
6971
7076
  interface PermissionsRepository {
6972
- /**
6973
- * Get all roles for current tenant.
6974
- * Automatically filtered by current tenant context.
6975
- */
6976
7077
  getRoles(): Promise<Role[]>;
6977
- /**
6978
- * Get a role by ID.
6979
- * Automatically filtered by current tenant context.
6980
- */
6981
7078
  getRoleById(roleId: Uuid): Promise<Role | null>;
6982
- /**
6983
- * Get a role by name.
6984
- * Automatically filtered by current tenant context.
6985
- */
6986
7079
  getRoleByName(name: string): Promise<Role | null>;
6987
- /**
6988
- * Create a new role.
6989
- * Tenant ID is automatically set from context.
6990
- */
6991
7080
  createRole(input: CreateRoleInput): Promise<Role>;
6992
- /**
6993
- * Update an existing role.
6994
- * Automatically filtered by current tenant context.
6995
- */
6996
7081
  updateRole(roleId: Uuid, updates: UpdateRoleInput): Promise<Role>;
6997
- /**
6998
- * Delete a role (fails if role is system role).
6999
- * Automatically filtered by current tenant context.
7000
- */
7001
7082
  deleteRole(roleId: Uuid): Promise<void>;
7002
- /**
7003
- * Get all permissions for a role.
7004
- * Automatically filtered by current tenant context.
7005
- */
7006
7083
  getPermissionsByRole(roleId: Uuid): Promise<Permission[]>;
7007
- /**
7008
- * Set permissions for a role (replaces existing permissions).
7009
- * Automatically filtered by current tenant context.
7010
- */
7011
7084
  setPermissions(roleId: Uuid, permissions: CreatePermissionInput[]): Promise<void>;
7012
- /**
7013
- * Get all roles assigned to a user profile.
7014
- * Automatically filtered by current tenant context.
7015
- */
7016
7085
  getUserRoles(userProfileId: Uuid): Promise<Role[]>;
7017
- /**
7018
- * Assign a role to a user profile.
7019
- * Tenant ID is automatically set from context.
7020
- */
7021
7086
  assignRole(input: AssignRoleInput): Promise<UserRoleAssignment>;
7022
- /**
7023
- * Revoke a role from a user profile.
7024
- * Automatically filtered by current tenant context.
7025
- */
7026
7087
  revokeRole(userProfileId: Uuid, roleId: Uuid): Promise<void>;
7027
- /**
7028
- * Get effective permissions for a user profile (merged from all assigned roles).
7029
- * Automatically filtered by current tenant context.
7030
- *
7031
- * This method should:
7032
- * 1. Get all roles assigned to the user profile
7033
- * 2. Get all permissions for those roles
7034
- * 3. Merge permissions (union of actions per object)
7035
- * 4. Determine if user has admin privileges
7036
- */
7037
7088
  getEffectivePermissions(userProfileId: Uuid): Promise<EffectivePermissions>;
7038
7089
  }
7039
7090
 
7040
7091
  /**
7041
- * Repository for AI conversations and messages.
7092
+ * Repository for workflow definitions.
7042
7093
  *
7043
7094
  * This repository is optional - if not provided in the DatabaseAdapter,
7044
- * AI conversation history features are disabled.
7095
+ * workflow features are disabled.
7096
+ */
7097
+ interface WorkflowsRepository {
7098
+ findById(id: Uuid): Promise<DBWorkflow | null>;
7099
+ findByName(name: string): Promise<DBWorkflow | null>;
7100
+ findSystemByName(name: string): Promise<DBWorkflow | null>;
7101
+ list(): Promise<DBWorkflow[]>;
7102
+ listByStatus(status: WorkflowStatus): Promise<DBWorkflow[]>;
7103
+ create(data: CreateDBWorkflow): Promise<DBWorkflow>;
7104
+ update(id: Uuid, data: Partial<UpdateDBWorkflow>): Promise<DBWorkflow>;
7105
+ delete(id: Uuid): Promise<void>;
7106
+ upsert(data: CreateDBWorkflow): Promise<DBWorkflow>;
7107
+ }
7108
+ /**
7109
+ * Repository for workflow instances (running/completed workflows).
7045
7110
  *
7046
- * All operations are automatically scoped to the current tenant
7047
- * from the execution context (via AsyncLocalStorage).
7111
+ * This repository is optional - if not provided in the DatabaseAdapter,
7112
+ * workflow execution features are disabled.
7048
7113
  */
7049
- interface AIConversationsRepository {
7050
- /**
7051
- * Find conversation by ID.
7052
- * Automatically filtered by current tenant context.
7053
- */
7054
- findById(id: Uuid): Promise<AIConversation | null>;
7055
- /**
7056
- * List conversations for current user.
7057
- * Automatically filtered by current tenant and user context.
7058
- */
7059
- list(options?: {
7114
+ interface WorkflowInstancesRepository {
7115
+ findById(id: Uuid): Promise<DBWorkflowInstance | null>;
7116
+ findByWorkflowId(workflowId: Uuid, options?: {
7060
7117
  limit?: number;
7061
7118
  offset?: number;
7062
- includeDeleted?: boolean;
7063
- }): Promise<{
7064
- conversations: AIConversation[];
7119
+ status?: InstanceStatus;
7120
+ }): Promise<DBWorkflowInstance[]>;
7121
+ findByWorkflowName(workflowName: string, options?: {
7122
+ limit?: number;
7123
+ offset?: number;
7124
+ status?: InstanceStatus;
7125
+ }): Promise<DBWorkflowInstance[]>;
7126
+ list(options?: ListOptions): Promise<{
7127
+ instances: DBWorkflowInstance[];
7065
7128
  total: number;
7066
7129
  }>;
7130
+ listByStatus(status: InstanceStatus): Promise<DBWorkflowInstance[]>;
7131
+ create(data: CreateDBWorkflowInstance): Promise<DBWorkflowInstance>;
7132
+ update(id: Uuid, data: Partial<UpdateDBWorkflowInstance>): Promise<DBWorkflowInstance>;
7133
+ upsert(data: CreateDBWorkflowInstance & {
7134
+ id: string;
7135
+ }): Promise<DBWorkflowInstance>;
7067
7136
  /**
7068
- * Create conversation.
7069
- * Tenant ID and User ID are automatically set from context.
7070
- */
7071
- create(data: {
7072
- title?: string;
7073
- }): Promise<AIConversation>;
7074
- /**
7075
- * Update conversation title.
7076
- * Automatically filtered by current tenant context.
7077
- */
7078
- updateTitle(id: Uuid, title: string): Promise<AIConversation | null>;
7079
- /**
7080
- * Soft delete conversation.
7081
- * Automatically filtered by current tenant context.
7082
- */
7083
- delete(id: Uuid): Promise<boolean>;
7084
- /**
7085
- * Add message to conversation.
7086
- * Automatically updates conversation stats.
7087
- */
7088
- addMessage(input: CreateAIMessageInput): Promise<AIMessage>;
7089
- /**
7090
- * List messages in a conversation.
7091
- * Automatically filtered by current tenant context (via conversation ownership).
7137
+ * Find instances that reference a specific record in their slot context.
7138
+ * Searches in context.slots for slots where objectName and id match.
7139
+ *
7140
+ * @param objectName - Object name to match in slot data
7141
+ * @param recordId - Record ID to match in slot data
7142
+ * @param options - Optional filtering options
7092
7143
  */
7093
- listMessages(conversationId: Uuid, options?: {
7144
+ findByRecordInSlots(objectName: string, recordId: string, options?: {
7145
+ status?: InstanceStatus;
7094
7146
  limit?: number;
7095
7147
  offset?: number;
7096
7148
  }): Promise<{
7097
- messages: AIMessage[];
7149
+ instances: DBWorkflowInstance[];
7098
7150
  total: number;
7099
7151
  }>;
7100
- /**
7101
- * Get recent messages for context (last N messages).
7102
- * Returns messages ordered by created_at ASC.
7103
- */
7104
- getRecentMessages(conversationId: Uuid, count?: number): Promise<AIMessage[]>;
7105
7152
  }
7106
7153
  /**
7107
- * Repository for AI user memory (preferences and learned facts).
7108
- *
7109
- * This repository is optional - if not provided in the DatabaseAdapter,
7110
- * AI personalization features are disabled.
7111
- *
7112
- * All operations are automatically scoped to the current tenant and user
7113
- * from the execution context (via AsyncLocalStorage).
7154
+ * Repository for workflow invitations.
7114
7155
  */
7115
- interface AIUserMemoryRepository {
7116
- /**
7117
- * Get memory for current user.
7118
- * Automatically filtered by current tenant and user context.
7119
- * Returns null if no memory exists yet.
7120
- */
7121
- get(): Promise<AIUserMemory | null>;
7122
- /**
7123
- * Create or update memory for current user.
7124
- * Tenant ID and User ID are automatically set from context.
7125
- */
7126
- upsert(data: {
7127
- preferences?: Record<string, unknown>;
7128
- facts?: string[];
7129
- }): Promise<AIUserMemory>;
7130
- /**
7131
- * Add a fact to user memory.
7132
- * Automatically appends to existing facts.
7133
- */
7134
- addFact(fact: string): Promise<AIUserMemory>;
7135
- /**
7136
- * Remove a fact from user memory.
7137
- */
7138
- removeFact(fact: string): Promise<AIUserMemory>;
7139
- /**
7140
- * Update a specific preference.
7141
- */
7142
- setPreference(key: string, value: unknown): Promise<AIUserMemory>;
7143
- /**
7144
- * Clear all memory for current user.
7145
- */
7146
- clear(): Promise<void>;
7156
+ interface WorkflowInvitationsRepository {
7157
+ findById(id: Uuid): Promise<DBWorkflowInvitation | null>;
7158
+ findByInstanceId(instanceId: Uuid): Promise<DBWorkflowInvitation[]>;
7159
+ findByEmail(email: string): Promise<DBWorkflowInvitation[]>;
7160
+ create(data: CreateDBWorkflowInvitation): Promise<DBWorkflowInvitation>;
7161
+ update(id: Uuid, data: UpdateDBWorkflowInvitation): Promise<DBWorkflowInvitation>;
7147
7162
  }
7148
7163
  /**
7149
- * Repository for AI usage metrics.
7150
- *
7151
- * This repository is optional - if not provided in the DatabaseAdapter,
7152
- * AI usage tracking is disabled.
7153
- *
7154
- * All operations are automatically scoped to the current tenant
7155
- * from the execution context (via AsyncLocalStorage).
7164
+ * Repository for workflow access grants.
7156
7165
  */
7157
- interface AIUsageMetricsRepository {
7158
- /**
7159
- * Record a usage event (increments counters for the current date).
7160
- * Automatically handles upsert for the current date.
7161
- */
7162
- recordUsage(data: {
7163
- provider: string;
7164
- tokens: number;
7165
- cost: number;
7166
- toolName?: string;
7167
- }): Promise<void>;
7168
- /**
7169
- * Get usage metrics for a date range.
7170
- * Automatically filtered by current tenant context.
7171
- */
7172
- getByDateRange(startDate: Date, endDate: Date): Promise<AIUsageMetrics[]>;
7173
- /**
7174
- * Get aggregated usage for current month.
7175
- * Automatically filtered by current tenant context.
7176
- */
7177
- getCurrentMonthUsage(): Promise<{
7178
- requestCount: number;
7179
- totalTokens: number;
7180
- totalCost: number;
7181
- }>;
7166
+ interface WorkflowAccessGrantsRepository {
7167
+ findById(id: Uuid): Promise<DBWorkflowAccessGrant | null>;
7168
+ findByInvitationId(invitationId: Uuid): Promise<DBWorkflowAccessGrant[]>;
7169
+ findByInstanceId(instanceId: Uuid): Promise<DBWorkflowAccessGrant[]>;
7170
+ findByEmail(email: string): Promise<DBWorkflowAccessGrant[]>;
7171
+ create(data: CreateDBWorkflowAccessGrant): Promise<DBWorkflowAccessGrant>;
7172
+ update(id: Uuid, data: UpdateDBWorkflowAccessGrant): Promise<DBWorkflowAccessGrant>;
7182
7173
  }
7183
7174
 
7184
7175
  /**
7185
7176
  * Repository for document templates.
7186
7177
  *
7187
7178
  * Templates define the structure of documents (slots, processing, etc.).
7188
- * System templates are available to all tenants.
7189
- * Custom templates are tenant-specific.
7190
- *
7191
- * All operations are automatically scoped to the current tenant
7192
- * from the execution context (via AsyncLocalStorage).
7193
7179
  */
7194
7180
  interface DocumentTemplatesRepository {
7195
- /**
7196
- * Find template by ID.
7197
- * Returns system templates or tenant-specific templates.
7198
- */
7199
7181
  findById(id: Uuid): Promise<DocumentTemplate | null>;
7200
- /**
7201
- * Find template by name.
7202
- * First checks tenant-specific templates, then falls back to system templates.
7203
- */
7204
7182
  findByName(name: string): Promise<DocumentTemplate | null>;
7205
- /**
7206
- * Find multiple templates by names.
7207
- */
7208
7183
  findByNames(names: string[]): Promise<DocumentTemplate[]>;
7209
- /**
7210
- * List all available templates.
7211
- * Includes both system templates and tenant-specific templates.
7212
- */
7213
7184
  list(options?: DocumentTemplateListOptions): Promise<DocumentTemplate[]>;
7214
- /**
7215
- * Create a custom template.
7216
- * Tenant ID is automatically set from context.
7217
- */
7218
7185
  create(data: CreateDocumentTemplate): Promise<DocumentTemplate>;
7219
- /**
7220
- * Update a template.
7221
- * Only tenant-specific templates can be updated.
7222
- */
7223
7186
  update(id: Uuid, data: UpdateDocumentTemplate): Promise<DocumentTemplate>;
7224
- /**
7225
- * Delete a template.
7226
- * Only tenant-specific templates can be deleted.
7227
- */
7228
7187
  delete(id: Uuid): Promise<void>;
7229
7188
  }
7230
7189
  /**
7231
7190
  * Repository for documents.
7232
7191
  *
7233
7192
  * Documents are wrappers around files with templates, slots, and processing.
7234
- * They are linked to records via record.values (document attribute).
7235
- *
7236
- * All operations are automatically scoped to the current tenant
7237
- * from the execution context (via AsyncLocalStorage).
7238
7193
  */
7239
7194
  interface DocumentsRepository {
7240
- /**
7241
- * Create a new document.
7242
- * Tenant ID is automatically set from context.
7243
- */
7244
7195
  create(data: CreateDocument): Promise<Document>;
7245
- /**
7246
- * Find document by ID.
7247
- * Automatically filtered by current tenant context.
7248
- */
7249
7196
  findById(id: Uuid): Promise<Document | null>;
7250
- /**
7251
- * Find multiple documents by IDs.
7252
- * Automatically filtered by current tenant context.
7253
- */
7254
7197
  findByIds(ids: Uuid[]): Promise<Document[]>;
7255
- /**
7256
- * Update a document.
7257
- * Automatically filtered by current tenant context.
7258
- */
7259
7198
  update(id: Uuid, data: UpdateDocument): Promise<Document>;
7260
- /**
7261
- * Update document status.
7262
- * Convenience method for status transitions.
7263
- */
7264
7199
  updateStatus(id: Uuid, status: DocumentStatus): Promise<Document>;
7265
- /**
7266
- * Soft delete a document.
7267
- * Automatically filtered by current tenant context.
7268
- */
7269
7200
  delete(id: Uuid): Promise<void>;
7270
- /**
7271
- * Hard delete a document.
7272
- * Automatically filtered by current tenant context.
7273
- */
7274
7201
  hardDelete(id: Uuid): Promise<void>;
7275
- /**
7276
- * List documents with optional filters.
7277
- * Automatically filtered by current tenant context.
7278
- */
7279
7202
  list(options?: DocumentListOptions): Promise<Document[]>;
7280
- /**
7281
- * Search documents by text.
7282
- * Uses full-text search on title, description, and OCR content.
7283
- */
7284
7203
  search(query: string, options?: DocumentListOptions): Promise<Document[]>;
7285
7204
  }
7286
7205
  /**
7287
7206
  * Repository for document slots.
7288
7207
  *
7289
7208
  * Slots are individual file entries within a document.
7290
- * Each slot corresponds to a slot definition in the template.
7291
7209
  */
7292
7210
  interface DocumentSlotsRepository {
7293
- /**
7294
- * Create a slot (upload a file to a document).
7295
- */
7296
7211
  create(data: CreateDocumentSlot): Promise<DocumentSlot>;
7297
- /**
7298
- * Find slot by ID.
7299
- */
7300
7212
  findById(id: Uuid): Promise<DocumentSlot | null>;
7301
- /**
7302
- * Find all slots for a document.
7303
- */
7304
7213
  findByDocumentId(documentId: Uuid): Promise<DocumentSlot[]>;
7305
- /**
7306
- * Find a specific slot by document and slot name.
7307
- */
7308
7214
  findByDocumentAndSlot(documentId: Uuid, slotName: string): Promise<DocumentSlot | null>;
7309
- /**
7310
- * Update a slot (status, OCR results, etc.).
7311
- */
7312
7215
  update(id: Uuid, data: UpdateDocumentSlot): Promise<DocumentSlot>;
7313
- /**
7314
- * Update slot status.
7315
- */
7316
7216
  updateStatus(id: Uuid, status: SlotStatus): Promise<DocumentSlot>;
7317
- /**
7318
- * Delete a slot.
7319
- */
7320
7217
  delete(id: Uuid): Promise<void>;
7321
- /**
7322
- * Delete all slots for a document.
7323
- */
7324
7218
  deleteByDocumentId(documentId: Uuid): Promise<void>;
7325
7219
  }
7326
7220
  /**
7327
7221
  * Repository for document processing jobs.
7328
7222
  *
7329
7223
  * Jobs track async processing tasks (OCR, signature, verification).
7330
- * They are linked to documents and optionally to specific slots.
7331
7224
  */
7332
7225
  interface DocumentJobsRepository {
7333
- /**
7334
- * Create a processing job.
7335
- * Tenant ID is automatically set from context.
7336
- */
7337
7226
  create(data: CreateProcessingJob): Promise<ProcessingJob>;
7338
- /**
7339
- * Find job by ID.
7340
- */
7341
7227
  findById(id: Uuid): Promise<ProcessingJob | null>;
7342
- /**
7343
- * Find all jobs for a document.
7344
- */
7345
7228
  findByDocumentId(documentId: Uuid): Promise<ProcessingJob[]>;
7346
- /**
7347
- * Find jobs by status (for processing queue).
7348
- */
7349
7229
  findByStatus(status: ProcessingJobStatus, limit?: number): Promise<ProcessingJob[]>;
7350
- /**
7351
- * Find pending jobs (for processing queue).
7352
- */
7353
7230
  findPending(limit?: number): Promise<ProcessingJob[]>;
7354
- /**
7355
- * Update a job.
7356
- */
7357
7231
  update(id: Uuid, data: UpdateProcessingJob): Promise<ProcessingJob>;
7358
- /**
7359
- * Mark job as started.
7360
- */
7361
7232
  markStarted(id: Uuid): Promise<ProcessingJob>;
7362
- /**
7363
- * Mark job as completed with result.
7364
- */
7365
7233
  markCompleted(id: Uuid, result: Record<string, unknown>): Promise<ProcessingJob>;
7366
- /**
7367
- * Mark job as failed with error.
7368
- */
7369
7234
  markFailed(id: Uuid, error: string): Promise<ProcessingJob>;
7370
- /**
7371
- * Cancel a job.
7372
- */
7373
7235
  cancel(id: Uuid): Promise<ProcessingJob>;
7374
- /**
7375
- * Find job by external ID (e.g., signature provider ID).
7376
- * Used for webhook callbacks.
7377
- */
7378
7236
  findByExternalId?(externalId: string): Promise<ProcessingJob | null>;
7379
7237
  }
7380
7238
  /**
@@ -7390,46 +7248,85 @@ interface DocumentGenerationTemplateListOptions {
7390
7248
  }
7391
7249
  /**
7392
7250
  * Repository for document generation templates.
7393
- *
7394
- * Document generation templates define how to generate documents by injecting
7395
- * workflow context data into PDF or DOCX template files.
7396
- *
7397
- * All operations are automatically scoped to the current tenant
7398
- * from the execution context (via AsyncLocalStorage).
7399
7251
  */
7400
7252
  interface DocumentGenerationTemplatesRepository {
7401
- /**
7402
- * Find template by ID.
7403
- * Automatically filtered by current tenant context.
7404
- */
7405
7253
  findById(id: Uuid): Promise<DocumentGenerationTemplate | null>;
7406
- /**
7407
- * Find template by name.
7408
- * Automatically filtered by current tenant context.
7409
- */
7410
7254
  findByName(name: string): Promise<DocumentGenerationTemplate | null>;
7411
- /**
7412
- * List all templates for current tenant.
7413
- * Automatically filtered by current tenant context.
7414
- */
7415
7255
  list(options?: DocumentGenerationTemplateListOptions): Promise<DocumentGenerationTemplate[]>;
7416
- /**
7417
- * Create template.
7418
- * Tenant ID is automatically set from context.
7419
- */
7420
7256
  create(data: CreateDocumentGenerationTemplate): Promise<DocumentGenerationTemplate>;
7421
- /**
7422
- * Update template.
7423
- * Automatically filtered by current tenant context.
7424
- */
7425
7257
  update(id: Uuid, data: UpdateDocumentGenerationTemplate): Promise<DocumentGenerationTemplate>;
7426
- /**
7427
- * Delete template.
7428
- * Automatically filtered by current tenant context.
7429
- */
7430
7258
  delete(id: Uuid): Promise<void>;
7431
7259
  }
7432
7260
 
7261
+ /**
7262
+ * Repository for AI conversations and messages.
7263
+ *
7264
+ * This repository is optional - if not provided in the DatabaseAdapter,
7265
+ * AI conversation history features are disabled.
7266
+ */
7267
+ interface AIConversationsRepository {
7268
+ findById(id: Uuid): Promise<AIConversation | null>;
7269
+ list(options?: {
7270
+ limit?: number;
7271
+ offset?: number;
7272
+ includeDeleted?: boolean;
7273
+ }): Promise<{
7274
+ conversations: AIConversation[];
7275
+ total: number;
7276
+ }>;
7277
+ create(data: {
7278
+ title?: string;
7279
+ }): Promise<AIConversation>;
7280
+ updateTitle(id: Uuid, title: string): Promise<AIConversation | null>;
7281
+ delete(id: Uuid): Promise<boolean>;
7282
+ addMessage(input: CreateAIMessageInput): Promise<AIMessage>;
7283
+ listMessages(conversationId: Uuid, options?: {
7284
+ limit?: number;
7285
+ offset?: number;
7286
+ }): Promise<{
7287
+ messages: AIMessage[];
7288
+ total: number;
7289
+ }>;
7290
+ getRecentMessages(conversationId: Uuid, count?: number): Promise<AIMessage[]>;
7291
+ }
7292
+ /**
7293
+ * Repository for AI user memory (preferences and learned facts).
7294
+ *
7295
+ * This repository is optional - if not provided in the DatabaseAdapter,
7296
+ * AI personalization features are disabled.
7297
+ */
7298
+ interface AIUserMemoryRepository {
7299
+ get(): Promise<AIUserMemory | null>;
7300
+ upsert(data: {
7301
+ preferences?: Record<string, unknown>;
7302
+ facts?: string[];
7303
+ }): Promise<AIUserMemory>;
7304
+ addFact(fact: string): Promise<AIUserMemory>;
7305
+ removeFact(fact: string): Promise<AIUserMemory>;
7306
+ setPreference(key: string, value: unknown): Promise<AIUserMemory>;
7307
+ clear(): Promise<void>;
7308
+ }
7309
+ /**
7310
+ * Repository for AI usage metrics.
7311
+ *
7312
+ * This repository is optional - if not provided in the DatabaseAdapter,
7313
+ * AI usage tracking is disabled.
7314
+ */
7315
+ interface AIUsageMetricsRepository {
7316
+ recordUsage(data: {
7317
+ provider: string;
7318
+ tokens: number;
7319
+ cost: number;
7320
+ toolName?: string;
7321
+ }): Promise<void>;
7322
+ getByDateRange(startDate: Date, endDate: Date): Promise<AIUsageMetrics[]>;
7323
+ getCurrentMonthUsage(): Promise<{
7324
+ requestCount: number;
7325
+ totalTokens: number;
7326
+ totalCost: number;
7327
+ }>;
7328
+ }
7329
+
7433
7330
  /**
7434
7331
  * File content type - supports various formats
7435
7332
  * Use Uint8Array for cross-platform compatibility
@@ -7665,6 +7562,7 @@ interface DatabaseAdapter {
7665
7562
  objects: ObjectsRepository;
7666
7563
  attributes: AttributesRepository;
7667
7564
  views: ViewsRepository;
7565
+ viewOverlays: ViewOverlaysRepository;
7668
7566
  workflows?: WorkflowsRepository;
7669
7567
  workflowInstances?: WorkflowInstancesRepository;
7670
7568
  workflowInvitations?: WorkflowInvitationsRepository;
@@ -7684,6 +7582,7 @@ interface DatabaseAdapter {
7684
7582
  documentSlots?: DocumentSlotsRepository;
7685
7583
  documentJobs?: DocumentJobsRepository;
7686
7584
  documentGenerationTemplates?: DocumentGenerationTemplatesRepository;
7585
+ featureFlags?: FeatureFlagsRepository;
7687
7586
  transaction<T>(callback: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
7688
7587
  }
7689
7588
 
@@ -8415,14 +8314,6 @@ declare abstract class SchemaContextAwareRepository extends BaseRepository {
8415
8314
  */
8416
8315
  protected getSchemaByNameFromContext(objectName: string): ObjectDefinition | undefined;
8417
8316
  }
8418
- /**
8419
- * @deprecated Use `BaseRepository` instead. Will be removed in a future version.
8420
- */
8421
- declare const TenantAwareRepository: typeof BaseRepository;
8422
- /**
8423
- * @deprecated Use `BaseService` instead. Will be removed in a future version.
8424
- */
8425
- declare const TenantAwareService: typeof BaseService;
8426
8317
 
8427
8318
  /**
8428
8319
  * Service for audit logging.
@@ -8840,7 +8731,8 @@ declare class ObjectSchemaService extends BaseService {
8840
8731
  addAttributeToObject(objectId: string, attribute: AddAttributeInput): Promise<Attribute>;
8841
8732
  /**
8842
8733
  * Update an attribute.
8843
- * Can only update custom attributes (system=false).
8734
+ * Custom attributes can be fully updated.
8735
+ * System attributes can only have presentation properties modified (label, description, placeholder, icon).
8844
8736
  * Automatically uses tenant context from AsyncLocalStorage.
8845
8737
  *
8846
8738
  * @param attributeId - Attribute UUID
@@ -9256,6 +9148,11 @@ declare class RecordService extends BaseService {
9256
9148
  skipHooks?: boolean;
9257
9149
  hookMetadata?: Record<string, unknown>;
9258
9150
  }): Promise<ObjectRecord>;
9151
+ /**
9152
+ * Invalidate all caches related to a record (record cache + lists + global search)
9153
+ * @private
9154
+ */
9155
+ private invalidateRecordCaches;
9259
9156
  /**
9260
9157
  * List records for an object with pagination.
9261
9158
  * Delegates to RecordQueryService for permissions and policy handling.
@@ -10579,6 +10476,131 @@ declare class TenantContextError extends Error {
10579
10476
  constructor(message?: string);
10580
10477
  }
10581
10478
 
10479
+ /**
10480
+ * Feature Flags Context Module
10481
+ *
10482
+ * Provides synchronous access to resolved feature flags using AsyncLocalStorage.
10483
+ * Flags are resolved once at request start and cached for the entire request.
10484
+ *
10485
+ * @example
10486
+ * ```typescript
10487
+ * // In NestJS interceptor (after tenant context)
10488
+ * runWithFeatureFlags(resolvedFlags, () => {
10489
+ * // All code here has synchronous access to flags
10490
+ * if (isFeatureEnabled("ai-features")) {
10491
+ * // Feature-gated code
10492
+ * }
10493
+ * });
10494
+ *
10495
+ * // Anywhere in code (sync!)
10496
+ * const hasAI = isFeatureEnabled("ai-features");
10497
+ * const tier = getFeatureValue("tier", "free");
10498
+ * ```
10499
+ */
10500
+ /**
10501
+ * Immutable feature flags context stored in AsyncLocalStorage.
10502
+ *
10503
+ * This context contains all resolved flag values for the current request
10504
+ * and is frozen to prevent modification after creation.
10505
+ */
10506
+ interface FeatureFlagsContext {
10507
+ /** Resolved flags map (flagName → value) */
10508
+ readonly flags: ReadonlyMap<string, unknown>;
10509
+ }
10510
+ /**
10511
+ * Error thrown when code tries to access feature flags without a context.
10512
+ */
10513
+ declare class FeatureFlagsContextError extends Error {
10514
+ constructor(message?: string);
10515
+ }
10516
+ /**
10517
+ * Check if a boolean flag is enabled.
10518
+ *
10519
+ * @param flagName - The name of the flag to check
10520
+ * @returns true if the flag value is exactly `true`, false otherwise
10521
+ * @throws {FeatureFlagsContextError} If no context is set
10522
+ *
10523
+ * @example
10524
+ * ```typescript
10525
+ * if (isFeatureEnabled("architect-mode")) {
10526
+ * // Show architect mode toggle
10527
+ * }
10528
+ * ```
10529
+ */
10530
+ declare function isFeatureEnabled(flagName: string): boolean;
10531
+ /**
10532
+ * Get the value of a flag with type safety.
10533
+ *
10534
+ * @param flagName - The name of the flag
10535
+ * @param defaultValue - Value to return if flag is not set
10536
+ * @returns The flag value or the default value
10537
+ * @throws {FeatureFlagsContextError} If no context is set
10538
+ *
10539
+ * @example
10540
+ * ```typescript
10541
+ * const tier = getFeatureValue("tier", "free");
10542
+ * if (tier === "enterprise") {
10543
+ * // Show enterprise features
10544
+ * }
10545
+ * ```
10546
+ */
10547
+ declare function getFeatureValue<T>(flagName: string, defaultValue: T): T;
10548
+ /**
10549
+ * Get all resolved flags.
10550
+ *
10551
+ * @returns ReadonlyMap of all flag names to their resolved values
10552
+ * @throws {FeatureFlagsContextError} If no context is set
10553
+ */
10554
+ declare function getFeatureFlags(): ReadonlyMap<string, unknown>;
10555
+ /**
10556
+ * Try to get the value of a flag without throwing.
10557
+ *
10558
+ * Use this for optional feature flag checks where you want to
10559
+ * gracefully handle the absence of a context.
10560
+ *
10561
+ * @param flagName - The name of the flag
10562
+ * @returns The flag value or undefined if no context or flag not found
10563
+ *
10564
+ * @example
10565
+ * ```typescript
10566
+ * // Optional enhancement - doesn't fail if no context
10567
+ * const tier = tryGetFeatureValue<string>("tier");
10568
+ * if (tier === "enterprise") {
10569
+ * // Enhance with enterprise features
10570
+ * }
10571
+ * ```
10572
+ */
10573
+ declare function tryGetFeatureValue<T>(flagName: string): T | undefined;
10574
+ /**
10575
+ * Check if a feature flags context is currently set.
10576
+ *
10577
+ * @returns true if a context is set, false otherwise
10578
+ *
10579
+ * @example
10580
+ * ```typescript
10581
+ * if (hasFeatureFlagsContext()) {
10582
+ * // Safe to call isFeatureEnabled()
10583
+ * }
10584
+ * ```
10585
+ */
10586
+ declare function hasFeatureFlagsContext(): boolean;
10587
+ /**
10588
+ * Execute a synchronous function within a feature flags context.
10589
+ */
10590
+ declare function runWithFeatureFlags<T>(flags: Map<string, unknown>, fn: () => T): T;
10591
+ /**
10592
+ * Execute an async function within a feature flags context.
10593
+ */
10594
+ declare function runWithFeatureFlags<T>(flags: Map<string, unknown>, fn: () => Promise<T>): Promise<T>;
10595
+ /**
10596
+ * Convenience helper for NestJS interceptor.
10597
+ *
10598
+ * @param resolvedFlags - Map of resolved flag values
10599
+ * @param fn - The async function to execute
10600
+ * @returns A promise that resolves to the function's return value
10601
+ */
10602
+ declare function withFeatureFlags<T>(resolvedFlags: Map<string, unknown>, fn: () => Promise<T>): Promise<T>;
10603
+
10582
10604
  /**
10583
10605
  * Schema Context Module
10584
10606
  *
@@ -10908,6 +10930,12 @@ interface ExecutorContext {
10908
10930
  input?: Record<string, unknown>;
10909
10931
  /** ID of the user/participant executing */
10910
10932
  executorId?: string;
10933
+ /**
10934
+ * Object definitions for field validation (optional).
10935
+ * When provided, executors like FormExecutor can validate required fields
10936
+ * against attribute metadata.
10937
+ */
10938
+ objectDefinitions?: ObjectDefinition[];
10911
10939
  }
10912
10940
  /**
10913
10941
  * Interface for node executors.
@@ -11029,6 +11057,17 @@ declare class DocumentExecutor implements NodeExecutor<DocumentNode> {
11029
11057
  execute(node: DocumentNode, _context: ExecutorContext): ExecutorResult;
11030
11058
  canExecute(_node: DocumentNode, _context: ExecutorContext): boolean;
11031
11059
  validate(node: DocumentNode): string[];
11060
+ /**
11061
+ * Validate that targetSlotIds reference existing slots in the workflow definition.
11062
+ * This is a context-aware validation that requires the workflow's slot definitions.
11063
+ *
11064
+ * @param node - The document node to validate
11065
+ * @param workflowSlots - All slots defined in the workflow
11066
+ * @returns Array of validation error messages
11067
+ */
11068
+ validateSlotReferences(node: DocumentNode, workflowSlots: {
11069
+ id: string;
11070
+ }[]): string[];
11032
11071
  }
11033
11072
 
11034
11073
  /**
@@ -11434,6 +11473,7 @@ interface MockStores {
11434
11473
  files: Map<Uuid, File>;
11435
11474
  objectRecords: Map<Uuid, InternalObjectRecord>;
11436
11475
  views: Map<Uuid, DBView>;
11476
+ viewOverlays: Map<Uuid, DBViewOverlay>;
11437
11477
  roles: Map<Uuid, Role>;
11438
11478
  permissions: Map<Uuid, Permission>;
11439
11479
  userRoles: Map<Uuid, UserRoleAssignment>;
@@ -11446,6 +11486,7 @@ interface MockStores {
11446
11486
  aiUserMemory: Map<string, AIUserMemory>;
11447
11487
  aiUsageMetrics: Map<string, AIUsageMetrics>;
11448
11488
  }
11489
+
11449
11490
  /**
11450
11491
  * Create an in-memory mock adapter for testing and development
11451
11492
  *
@@ -11798,7 +11839,9 @@ declare class FileService extends BaseService {
11798
11839
  * @param userId - User ID to check
11799
11840
  * @returns true if user can access the file
11800
11841
  */
11801
- checkAccess(fileId: string, userId: string): Promise<boolean>;
11842
+ checkAccess(fileId: string, userId: string, options?: {
11843
+ isAdmin?: boolean;
11844
+ }): Promise<boolean>;
11802
11845
  /**
11803
11846
  * @deprecated Use checkAccess() instead
11804
11847
  */
@@ -12507,7 +12550,8 @@ declare class WorkflowInstanceService extends BaseService {
12507
12550
  */
12508
12551
  cancelWorkflow(instanceId: string, reason?: string): Promise<WorkflowInstance>;
12509
12552
  /**
12510
- * Get an instance by ID
12553
+ * Get an instance by ID.
12554
+ * Automatically marks expired instances as "failed" if their expiresAt has passed.
12511
12555
  */
12512
12556
  getInstance(id: string): Promise<WorkflowInstance | null>;
12513
12557
  /**
@@ -12555,17 +12599,41 @@ declare class WorkflowInstanceService extends BaseService {
12555
12599
  * Execute the current node and continue until wait/complete/error
12556
12600
  */
12557
12601
  private executeCurrentNode;
12602
+ /**
12603
+ * Check a list of instances for expiration and mark any expired non-terminal
12604
+ * instances as "failed". Saves updated instances to the database.
12605
+ */
12606
+ private markExpiredInstances;
12558
12607
  private mergeContext;
12559
12608
  private getNodeLabel;
12560
12609
  /**
12561
- * Persist all slots as records in the database.
12610
+ * Persist all slots as records in the database using a saga pattern.
12562
12611
  * - Slots with mode "create" create new records
12563
12612
  * - Slots with mode "select" or "optional" with existing ID update the record
12564
12613
  * - Slots with mode "optional" without ID create new records
12565
12614
  *
12615
+ * If any slot fails to persist, all previously persisted slots in this batch
12616
+ * are rolled back (best-effort): created records are deleted, updated records
12617
+ * are restored to their previous state.
12618
+ *
12566
12619
  * Returns updated context with createdRecordIds populated.
12567
12620
  */
12568
12621
  private persistSlots;
12622
+ /**
12623
+ * Snapshot a record's current data for potential rollback.
12624
+ * Returns the record data or undefined if the record cannot be read.
12625
+ */
12626
+ private snapshotRecord;
12627
+ /**
12628
+ * Rollback completed slot persistence operations in reverse order (saga compensation).
12629
+ *
12630
+ * This is BEST EFFORT: errors during rollback are logged but never re-thrown.
12631
+ * - For "create" operations: deletes the created record
12632
+ * - For "update" operations: restores the previous data snapshot
12633
+ *
12634
+ * @returns Array of slot IDs that were successfully rolled back
12635
+ */
12636
+ private rollbackSlotOperations;
12569
12637
  /**
12570
12638
  * Clean slot data by removing undefined and null values.
12571
12639
  * This prevents form submissions from overwriting existing record values
@@ -13340,7 +13408,10 @@ declare class DocumentRendererService {
13340
13408
  */
13341
13409
  declare class GeocodingService {
13342
13410
  private readonly adapter;
13343
- constructor(adapter: GeocodingAdapter);
13411
+ private readonly timeoutMs;
13412
+ constructor(adapter: GeocodingAdapter, options?: {
13413
+ timeoutMs?: number;
13414
+ });
13344
13415
  /**
13345
13416
  * Search for address suggestions as the user types
13346
13417
  */
@@ -13415,7 +13486,9 @@ declare class GlobalSearchService extends BaseService {
13415
13486
  * @param options - Search options
13416
13487
  * @returns Results grouped by object name
13417
13488
  */
13418
- searchGrouped(query: string, options?: Omit<GlobalSearchOptions, "limit" | "offset">): Promise<{
13489
+ searchGrouped(query: string, options?: Omit<GlobalSearchOptions, "limit" | "offset"> & {
13490
+ limitPerGroup?: number;
13491
+ }): Promise<{
13419
13492
  groups: Array<{
13420
13493
  objectName: string;
13421
13494
  objectLabel: string;
@@ -13427,17 +13500,16 @@ declare class GlobalSearchService extends BaseService {
13427
13500
  }
13428
13501
 
13429
13502
  /**
13430
- * Input for creating a custom view
13503
+ * Input for creating a view (Architect Mode)
13431
13504
  */
13432
13505
  interface CreateViewInput {
13506
+ objectName: string;
13507
+ type: ViewType;
13433
13508
  name: string;
13434
13509
  label: string;
13435
- objectName: string;
13436
13510
  description?: string;
13437
13511
  icon?: IconName;
13438
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
13439
- layout?: ViewLayout;
13440
- tabs?: Tab[];
13512
+ config: ViewConfig;
13441
13513
  default?: boolean;
13442
13514
  metadata?: Record<string, unknown>;
13443
13515
  }
@@ -13448,74 +13520,125 @@ interface UpdateViewInput {
13448
13520
  label?: string;
13449
13521
  description?: string;
13450
13522
  icon?: IconName;
13451
- /** Layout mode: "page" (full tabs) or "modal" (single form) */
13452
- layout?: ViewLayout;
13453
- tabs?: Tab[];
13523
+ config?: ViewConfig;
13454
13524
  default?: boolean;
13455
13525
  metadata?: Record<string, unknown>;
13456
13526
  }
13457
13527
  /**
13458
- * Service for managing views.
13459
- * Handles fusion of native views (from registry) and custom views (from database).
13460
- * Automatically uses tenant context from AsyncLocalStorage.
13528
+ * Options for getting views
13529
+ */
13530
+ interface GetViewsOptions {
13531
+ /** Filter by view type */
13532
+ type?: ViewType;
13533
+ /** User ID for overlay merging */
13534
+ userId?: string;
13535
+ }
13536
+ /**
13537
+ * Options for getting a single view
13538
+ */
13539
+ interface GetViewOptions {
13540
+ /** Filter by view type (for disambiguation) */
13541
+ type?: ViewType;
13542
+ /** User ID for overlay merging */
13543
+ userId?: string;
13544
+ /** Filter by layout (only for detail views: "page" or "modal") */
13545
+ layout?: "page" | "modal";
13546
+ }
13547
+ /**
13548
+ * Service for managing unified views with overlay customizations.
13461
13549
  *
13462
- * Supports optional caching via CacheAdapter for improved performance.
13463
- * Cache is automatically invalidated when views are modified.
13550
+ * Architecture:
13551
+ * - Views (sources) are created by architects or auto-generated on first access
13552
+ * - Overlays store user-specific customizations (delta only)
13553
+ * - Default views are lazily created and persisted on first access
13554
+ *
13555
+ * Lazy Creation Pattern:
13556
+ * - No views are created on object creation
13557
+ * - First navigation auto-creates a default view in DB
13558
+ * - Architect Mode modifies real views in DB
13559
+ * - User customizations create overlays (not views)
13464
13560
  */
13465
13561
  declare class ViewService extends BaseService {
13466
- private nativeViews;
13467
- constructor(adapter: DatabaseAdapter, nativeViews: typeof viewRegistry);
13468
- /**
13469
- * Invalidate cached views for an object.
13470
- * Called automatically after view mutations.
13471
- */
13562
+ constructor(adapter: DatabaseAdapter);
13472
13563
  private invalidateViewCache;
13473
13564
  /**
13474
- * Get all views for an object (native + custom).
13475
- * Automatically uses tenant context from AsyncLocalStorage.
13565
+ * Get all views for the current tenant.
13566
+ * Optionally filter by view type.
13476
13567
  *
13477
- * Results are cached if a CacheAdapter is configured.
13568
+ * @param type - Optional view type filter
13569
+ * @returns All views for the tenant
13570
+ */
13571
+ getAllViews(type?: ViewType): Promise<ViewDefinition[]>;
13572
+ /**
13573
+ * Get a specific view by its ID.
13574
+ * Returns null if not found.
13478
13575
  *
13479
- * @param objectName - Object name
13480
- * @returns All views for the object
13576
+ * @param viewId - View ID (UUID)
13577
+ * @returns View definition or null
13481
13578
  */
13482
- getViewsForObject(objectName: string): Promise<ViewDefinition[]>;
13579
+ getViewById(viewId: string): Promise<ViewDefinition | null>;
13483
13580
  /**
13484
- * Internal method to fetch views for an object (no caching)
13581
+ * Get all views for an object from the database.
13582
+ * Optionally filter by type and merge with user overlays.
13583
+ *
13584
+ * @param objectName - Object name
13585
+ * @param options - Filter and overlay options
13586
+ * @returns Views from database
13485
13587
  */
13486
- private fetchViewsForObject;
13588
+ getViews(objectName: string, options?: GetViewsOptions): Promise<ViewDefinition[]>;
13487
13589
  /**
13488
13590
  * Get a specific view by name.
13489
- * Automatically uses tenant context from AsyncLocalStorage.
13591
+ * Returns null if not found (use getDefaultView for fallback behavior).
13490
13592
  *
13491
13593
  * @param objectName - Object name
13492
13594
  * @param viewName - View name
13493
- * @returns View definition or null
13595
+ * @param options - Type filter and overlay options
13596
+ * @returns View or null
13494
13597
  */
13495
- getView(objectName: string, viewName: string): Promise<ViewDefinition | null>;
13598
+ getView(objectName: string, viewName: string, options?: GetViewOptions): Promise<ViewDefinition | null>;
13496
13599
  /**
13497
- * Get the default view for an object
13600
+ * Get the default view for an object and type.
13601
+ * If no view exists in DB, auto-creates and persists a default view.
13498
13602
  *
13499
13603
  * Priority:
13500
- * 1. Custom view marked as default (for the specified layout)
13501
- * 2. Native view marked as default (for the specified layout)
13502
- * 3. First available view (for the specified layout)
13604
+ * 1. User's preferred view (from overlay with isUserDefault=true)
13605
+ * 2. View marked as default in DB (with matching layout if specified)
13606
+ * 3. First available view (with matching layout if specified)
13607
+ * 4. Auto-created default view (persisted to DB)
13503
13608
  *
13504
13609
  * @param objectName - Object name
13505
- * @param layout - Optional layout filter ("page" or "modal")
13506
- * @returns Default view or null
13610
+ * @param type - View type
13611
+ * @param objectDefinition - Object definition (for default generation)
13612
+ * @param options - Optional filters (userId, layout for detail views)
13613
+ * @returns View definition (existing or auto-created)
13614
+ */
13615
+ getDefaultView(objectName: string, type: ViewType, objectDefinition: ObjectDefinition, options?: {
13616
+ userId?: string;
13617
+ layout?: "page" | "modal";
13618
+ }): Promise<ViewDefinition>;
13619
+ /**
13620
+ * Ensure a default view exists in DB for the given object and type.
13621
+ * If no view exists, generates and persists one.
13622
+ * Idempotent — safe to call concurrently (uses upsert).
13507
13623
  */
13508
- getDefaultView(objectName: string, layout?: ViewLayout): Promise<ViewDefinition | null>;
13624
+ private ensureDefaultView;
13509
13625
  /**
13510
- * Create a custom view.
13511
- * Automatically uses tenant context from AsyncLocalStorage.
13626
+ * Generate default view config for an object.
13627
+ * Used by ensureDefaultView() and resetViewToDefault().
13628
+ */
13629
+ generateDefaultViewConfig(objectName: string, type: ViewType, objectDefinition: ObjectDefinition, layout?: "page" | "modal"): ViewDefinition;
13630
+ private generateDefaultDetailConfig;
13631
+ private generateDefaultListConfig;
13632
+ private getDefaultFieldSpan;
13633
+ /**
13634
+ * Create a new view (Architect Mode).
13512
13635
  *
13513
13636
  * @param input - View definition
13514
13637
  * @returns Created view
13515
13638
  */
13516
13639
  createView(input: CreateViewInput): Promise<ViewDefinition>;
13517
13640
  /**
13518
- * Update a custom view
13641
+ * Update an existing view.
13519
13642
  *
13520
13643
  * @param viewId - View ID
13521
13644
  * @param input - Update data
@@ -13523,29 +13646,76 @@ declare class ViewService extends BaseService {
13523
13646
  */
13524
13647
  updateView(viewId: string, input: UpdateViewInput): Promise<ViewDefinition>;
13525
13648
  /**
13526
- * Delete a custom view
13649
+ * Delete a view.
13650
+ * Overlays are automatically deleted (cascade).
13527
13651
  *
13528
13652
  * @param viewId - View ID
13529
13653
  */
13530
13654
  deleteView(viewId: string): Promise<void>;
13531
13655
  /**
13532
- * Set a view as default for its object and layout.
13533
- * Only unsets other defaults for the same layout.
13534
- * Automatically uses tenant context from AsyncLocalStorage.
13656
+ * Set a view as default for its object and type.
13535
13657
  *
13536
13658
  * @param viewId - View ID
13537
13659
  * @returns Updated view
13538
13660
  */
13539
13661
  setDefaultView(viewId: string): Promise<ViewDefinition>;
13540
13662
  /**
13541
- * Validate view name format (kebab-case)
13663
+ * Reset a view to its default (auto-generated) state.
13664
+ * Regenerates the view config based on the object definition.
13665
+ *
13666
+ * @param viewId - View ID
13667
+ * @param objectDefinition - Object definition for regeneration
13668
+ * @returns Updated view
13669
+ */
13670
+ resetViewToDefault(viewId: string, objectDefinition: ObjectDefinition): Promise<ViewDefinition>;
13671
+ /**
13672
+ * Reset user customizations for a view.
13673
+ * Deletes the overlay, returning to source/fallback view.
13674
+ *
13675
+ * @param viewId - View ID (can be UUID or fallback ID)
13676
+ * @param userId - User ID
13542
13677
  */
13543
- private validateViewName;
13678
+ resetUserCustomizations(viewId: string, userId: string): Promise<void>;
13679
+ /**
13680
+ * Set a view as the user's default for an object and type.
13681
+ *
13682
+ * @param viewId - View ID (can be UUID or fallback ID)
13683
+ * @param userId - User ID
13684
+ * @param objectName - Object name
13685
+ * @param type - View type
13686
+ */
13687
+ setUserDefaultView(viewId: string, userId: string, objectName: string, type: ViewType): Promise<void>;
13688
+ /**
13689
+ * Check if a user has customized a view.
13690
+ *
13691
+ * @param viewId - View ID
13692
+ * @param userId - User ID
13693
+ * @returns True if overlay exists
13694
+ */
13695
+ hasUserCustomizations(viewId: string, userId: string): Promise<boolean>;
13696
+ /**
13697
+ * Apply an overlay to a view definition.
13698
+ * Implements merge semantics defined in the plan.
13699
+ *
13700
+ * @param view - Source view definition
13701
+ * @param overlay - User overlay
13702
+ * @returns Merged view definition
13703
+ */
13704
+ applyOverlay(view: ViewDefinition, overlay: DBViewOverlay): ViewDefinition;
13705
+ private applyListViewOverlay;
13706
+ private applyDetailViewOverlay;
13544
13707
  /**
13545
- * Validate modal layout constraints.
13546
- * Modal views must have exactly one form tab.
13708
+ * Merge source tabs with overlay tabs.
13709
+ * - Source tabs are visible to all
13710
+ * - Overlay tabs are appended (user-private)
13711
+ * - hiddenTabIds allows hiding source tabs
13547
13712
  */
13548
- private validateModalLayout;
13713
+ private mergeViewTabs;
13714
+ /**
13715
+ * Merge detail tabs (form, activity, etc.)
13716
+ */
13717
+ private mergeDetailTabs;
13718
+ private validateViewName;
13549
13719
  /**
13550
13720
  * Convert database view to ViewDefinition
13551
13721
  */
@@ -13559,7 +13729,7 @@ interface ViewSyncResult {
13559
13729
  success: boolean;
13560
13730
  viewsSynced: number;
13561
13731
  viewsCreated: number;
13562
- viewsUpdated: number;
13732
+ viewsSkipped: number;
13563
13733
  viewsDeleted: number;
13564
13734
  errors: Array<{
13565
13735
  viewName: string;
@@ -13567,68 +13737,96 @@ interface ViewSyncResult {
13567
13737
  error: string;
13568
13738
  }>;
13569
13739
  }
13740
+ /**
13741
+ * Logger interface for view sync operations
13742
+ */
13743
+ interface ViewSyncLogger {
13744
+ info(message: string): void;
13745
+ }
13570
13746
  /**
13571
13747
  * Options for view sync
13572
13748
  */
13573
13749
  interface ViewSyncOptions {
13574
13750
  dryRun?: boolean;
13575
13751
  verbose?: boolean;
13752
+ logger?: ViewSyncLogger;
13753
+ /**
13754
+ * Delete views in DB that are not in registry.
13755
+ * @default false
13756
+ */
13757
+ deleteOrphans?: boolean;
13576
13758
  }
13577
13759
  /**
13578
- * Sync native views from registry to database
13760
+ * Seed registry views to database
13579
13761
  *
13580
13762
  * This function:
13581
- * 1. Reads all registered native views from the registry
13582
- * 2. Upserts them into the database (views table)
13583
- * 3. Marks them as system=true for protection
13584
- * 4. Removes views that were deleted from code
13763
+ * 1. Reads all registered views from the registry
13764
+ * 2. Creates them in the database if they don't exist (INSERT if not exists)
13765
+ * 3. Skips views that already exist (no overwrite)
13766
+ * 4. Optionally removes orphan views (views in DB not in registry)
13767
+ *
13768
+ * Seeding behavior:
13769
+ * - INSERT if view doesn't exist in DB
13770
+ * - SKIP if view already exists (no overwrite)
13771
+ * - To force update: delete the view in DB, then restart app
13585
13772
  *
13586
13773
  * @param adapter - Database adapter implementing DatabaseAdapter interface
13587
- * @param nativeViewRegistry - Registry containing native views
13588
- * @param options - Sync options (dryRun, verbose, tenantId)
13774
+ * @param registry - Registry containing view definitions
13775
+ * @param options - Sync options (dryRun, verbose, deleteOrphans)
13589
13776
  * @returns Sync result with statistics
13590
13777
  *
13591
13778
  * @example
13592
13779
  * ```typescript
13593
- * import { syncNativeViews, viewRegistry } from "@stndrds/schema";
13780
+ * import { seedRegistryViews, viewRegistry } from "@stndrds/schema";
13594
13781
  * import { drizzleAdapter } from "./db/adapter";
13595
13782
  *
13596
- * const result = await syncNativeViews(drizzleAdapter, viewRegistry, {
13783
+ * const result = await seedRegistryViews(drizzleAdapter, viewRegistry, {
13597
13784
  * verbose: true,
13598
- * tenantId: "default"
13599
13785
  * });
13600
13786
  *
13601
13787
  * if (result.success) {
13602
- * console.log(`✓ Synced ${result.viewsSynced} views`);
13788
+ * console.log(`✓ Seeded ${result.viewsCreated} views`);
13603
13789
  * }
13604
13790
  * ```
13605
13791
  */
13606
- declare function syncNativeViews(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry, options?: ViewSyncOptions): Promise<ViewSyncResult>;
13792
+ declare function seedRegistryViews(adapter: DatabaseAdapter, registry: typeof viewRegistry, options?: ViewSyncOptions): Promise<ViewSyncResult>;
13793
+ /**
13794
+ * @deprecated Use seedRegistryViews instead
13795
+ */
13796
+ declare const syncNativeViews: typeof seedRegistryViews;
13607
13797
  /**
13608
- * Verify that all native views are synced to database
13798
+ * Verify that all registry views are seeded to database
13609
13799
  *
13610
13800
  * @param adapter - Database adapter
13611
- * @param nativeViewRegistry - Registry containing native views
13612
- * @returns true if all views are synced, false otherwise
13801
+ * @param registry - Registry containing view definitions
13802
+ * @returns true if all views are seeded, false otherwise
13613
13803
  *
13614
13804
  * @example
13615
13805
  * ```typescript
13616
- * const isSynced = await verifyNativeViewsSync(adapter, viewRegistry);
13617
- * if (!isSynced) {
13618
- * console.warn("Native views not synced, running sync...");
13619
- * await syncNativeViews(adapter, viewRegistry);
13806
+ * const isSeeded = await verifyRegistryViewsSeeded(adapter, viewRegistry);
13807
+ * if (!isSeeded) {
13808
+ * console.warn("Registry views not seeded, running seed...");
13809
+ * await seedRegistryViews(adapter, viewRegistry);
13620
13810
  * }
13621
13811
  * ```
13622
13812
  */
13623
- declare function verifyNativeViewsSync(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<boolean>;
13813
+ declare function verifyRegistryViewsSeeded(adapter: DatabaseAdapter, registry: typeof viewRegistry): Promise<boolean>;
13814
+ /**
13815
+ * @deprecated Use verifyRegistryViewsSeeded instead
13816
+ */
13817
+ declare const verifyNativeViewsSync: typeof verifyRegistryViewsSeeded;
13624
13818
  /**
13625
- * Get sync preview without modifying database
13819
+ * Get seed preview without modifying database
13626
13820
  *
13627
13821
  * @param adapter - Database adapter
13628
- * @param nativeViewRegistry - Registry containing native views
13629
- * @returns Sync result (dry run)
13822
+ * @param registry - Registry containing view definitions
13823
+ * @returns Seed result (dry run)
13824
+ */
13825
+ declare function getViewSeedPreview(adapter: DatabaseAdapter, registry: typeof viewRegistry): Promise<ViewSyncResult>;
13826
+ /**
13827
+ * @deprecated Use getViewSeedPreview instead
13630
13828
  */
13631
- declare function getViewSyncPreview(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<ViewSyncResult>;
13829
+ declare const getViewSyncPreview: typeof getViewSeedPreview;
13632
13830
 
13633
13831
  /**
13634
13832
  * Result of sync operation
@@ -13766,4 +13964,4 @@ interface FullSyncOptions extends SyncOptions, ViewSyncOptions {
13766
13964
  */
13767
13965
  declare function syncAll(adapter: DatabaseAdapter, objectRegistry: typeof registry, nativeViewRegistry: typeof viewRegistry, options?: FullSyncOptions): Promise<FullSyncResult>;
13768
13966
 
13769
- export { type OcrAdapter as $, type Attribute as A, type SortRule as B, type CheckboxAttribute as C, type DateAttribute as D, type DirectTableTab as E, type FileAttribute as F, type Group as G, type WorkflowConfig as H, type InferAttributeValue as I, type SlotMode as J, type ConditionGroup as K, type LocationAttribute as L, type MultiselectAttribute as M, type NumberAttribute as N, type ObjectAction as O, type PhoneAttribute as P, type ConditionRule as Q, type RichtextAttribute as R, type SystemResource as S, type TextAttribute as T, type UserAttribute as U, type ViewLayout as V, type WorkflowTheme as W, type WorkflowNode as X, type WorkflowDefinition as Y, type FlowRow as Z, type DocumentTemplate as _, type DocumentAttribute as a, type AuditActorType as a$, type OcrInput as a0, type OcrOptions as a1, type OcrResult as a2, type OcrPage as a3, type OcrTextBlock as a4, type BoundingBox as a5, type SignatureAdapter as a6, type CreateSignatureInput as a7, type SignerRequest as a8, type SignaturePosition as a9, type AIBatchQuestionAnswer as aA, type AITodoStatus as aB, type AITodoItem as aC, type AITodoList as aD, type AIMessageAttachment as aE, type AIConversation as aF, type AIMessage as aG, type AIToolCallRecord as aH, type AIUserMemory as aI, type AIUsageMetrics as aJ, type AIProviderMetrics as aK, type CreateAIMessageInput as aL, type StatusGroup as aM, type AttributeGroup as aN, type BaseAttribute as aO, type NumberUnit as aP, type DateFormat as aQ, type DateValue as aR, type Phone as aS, type Currency as aT, type Location as aU, type LocationGranularity as aV, RELATION_TARGET_ANY as aW, type RelationAttribute as aX, isUniversalRelation as aY, type AuditResourceType as aZ, type AuditAction as a_, type SignatureRequestResult as aa, type SignatureStatusResult as ab, type SignerStatus as ac, type SignatureStatus as ad, type IdentityVerificationAdapter as ae, type VerifyInput as af, type VerificationResult as ag, type DocumentData as ah, type VerificationCheck as ai, type AIMessageRole as aj, type AIThinkingLevel as ak, type AIToolCallStatus as al, type AIToolCall as am, type AIChatMessagePartType as an, type TextPartData as ao, type ToolPartData as ap, type ThinkingPartData as aq, type ReasoningPartData as ar, type AIChatMessagePart as as, type AIChatMessage as at, type AIQuestionType as au, type AIQuestionOption as av, type AIQuestion as aw, type AIQuestionAnswer as ax, type AIBatchQuestionOption as ay, type AIBatchQuestion as az, type SystemAction as b, type NoValueOperator as b$, type AuditChange as b0, type AuditLogEntry as b1, type CreateAuditLogInput as b2, type AuditListOptions as b3, type AuditServiceOptions as b4, type VariableMapping as b5, type PdfTemplateField as b6, type TemplateSource as b7, type DocumentGenerationTemplate as b8, type CreateDocumentGenerationTemplate as b9, type FileVisibility as bA, type File as bB, type CreateFile as bC, type UpdateFile as bD, type TextFilterOperator as bE, type NumberFilterOperator as bF, type CheckboxFilterOperator as bG, type DateFilterOperator as bH, type SelectFilterOperator as bI, type MultiselectFilterOperator as bJ, type RelationFilterOperator as bK, type FilterOperator as bL, type RelativeDateValue as bM, type CurrencyFilterValue as bN, type PhoneFilterValue as bO, type FilterValue as bP, type FilterRule as bQ, type ExtendedFilterRule as bR, type FilterCombinator as bS, type FilterGroup as bT, type AdvancedFilterState as bU, isAdvancedFilterState as bV, toAdvancedFilterState as bW, toSimpleFilterState as bX, type SortDirection as bY, type QueryState as bZ, OPERATORS_BY_TYPE as b_, type UpdateDocumentGenerationTemplate as ba, type PendingDocumentRequest as bb, isPdfTemplateSource as bc, isDocxTemplateSource as bd, type DocumentSlotDefinition as be, type DocumentAutoProcessing as bf, type ExtractionMapping as bg, type ExtractionField as bh, type Document as bi, type DocumentStatus as bj, type DocumentSlot as bk, type SlotStatus as bl, type ProcessingJob as bm, type ProcessingJobType as bn, type ProcessingJobStatus as bo, type CreateDocument as bp, type UpdateDocument as bq, type CreateDocumentTemplate as br, type UpdateDocumentTemplate as bs, type CreateDocumentSlot as bt, type UpdateDocumentSlot as bu, type CreateProcessingJob as bv, type UpdateProcessingJob as bw, type DocumentListOptions as bx, type DocumentTemplateListOptions as by, type StorageProvider as bz, type TextAreaAttribute as c, type UserRole as c$, NO_VALUE_OPERATORS as c0, isNoValueOperator as c1, type FlowSlot as c2, type FlowRowField as c3, type FlowPage as c4, type FlowRelation as c5, type FlowStatus as c6, type FlowDefinition as c7, isFlowDefinition as c8, isFlowPublished as c9, type ExtractAttributes as cA, type TypedObjectRecord as cB, type ExtractObjectRecord as cC, type ExtractObjectRecordWithCustom as cD, RESERVED_ATTRIBUTE_NAMES as cE, SYSTEM_FIELD_NAMES as cF, type ReservedAttributeName as cG, type SystemFieldName as cH, type Timestamps as cI, type SharingMode as cJ, type ObjectAttribute as cK, type CompletionStatus as cL, type ObjectRecord as cM, type PermissionScope as cN, type Role as cO, type Permission as cP, type UserRoleAssignment as cQ, type EffectivePermissions as cR, type ObjectPermissions as cS, type SystemPermissions as cT, type CreateRoleInput as cU, type UpdateRoleInput as cV, type CreatePermissionInput as cW, type AssignRoleInput as cX, type PolicyContext as cY, type RecordPolicy as cZ, PolicyViolationError as c_, isSystemFlow as ca, type GeocodingSuggestion as cb, type GeocodingAutocompleteParams as cc, type ReverseGeocodingParams as cd, type GeocodingParams as ce, type GeocodingAdapter as cf, NoopGeocodingAdapter as cg, type AttributeSchema as ch, type InferRecordFromSchema as ci, type InferRecordWithRequirements as cj, type TypedAttribute as ck, type AttributeMap as cl, type AddAttribute as cm, type InferRecord as cn, type InferRecordInput as co, type InferRecordUpdate as cp, type CustomAttributeValue as cq, type WithCustomAttributes as cr, type RecordMetadata as cs, type SystemFields as ct, type ExtractRecord as cu, type ExtractRecordStrict as cv, type ExtractRecordInput as cw, type ExtractRecordInputStrict as cx, type ExtractRecordUpdate as cy, type ExtractRecordUpdateStrict as cz, type RichtextFeature as d, type CreateInvitationInput as d$, type UserStatus as d0, type UserProfile as d1, type CreateUserProfile as d2, type UpdateUserProfile as d3, type InviteUserInput as d4, type TabType as d5, type FormTab as d6, type CustomTab as d7, type ActivityTab as d8, type NotesTab as d9, isStartNode as dA, type ConditionOperator as dB, and as dC, eq as dD, inValues as dE, isConditionGroup as dF, isConditionRule as dG, isEmpty as dH, isNotEmpty as dI, neq as dJ, or as dK, type CanvasViewport as dL, type NodePosition as dM, type WorkflowLayout as dN, type WorkflowSlot as dO, type WorkflowStatus as dP, isSystemWorkflow as dQ, isWorkflowDefinition as dR, isWorkflowPublished as dS, type PendingAction as dT, type WorkflowError as dU, type WorkflowInstance as dV, type WorkflowTransition as dW, canResumeInstance as dX, createStartTransition as dY, isInstanceTerminal as dZ, isInstanceWaiting as d_, type FlowsTab as da, type DocumentsTab as db, isFormTab as dc, isTableTab as dd, isDirectTableTab as de, isInverseTableTab as df, isCustomTab as dg, isActivityTab as dh, isNotesTab as di, isFlowsTab as dj, isDocumentsTab as dk, type ConditionNode as dl, type DocumentNode as dm, type EndNode as dn, type FormFieldRef as dp, type FormNode as dq, type StartNode as dr, type WorkflowNodeType as ds, getNodeOutputs as dt, isAdvancedFormNode as du, isConditionNode as dv, isDocumentNode as dw, isEndNode as dx, isFormNode as dy, isSimpleFormNode as dz, type CurrencyAttribute as e, attributeConfigSchemas as e$, type CreateInvitationResult as e0, type InvitationStatus as e1, type WorkflowInvitation as e2, isInvitationAccepted as e3, isInvitationExpired as e4, isInvitationValid as e5, type CreateGrantInput as e6, type WorkflowAccessGrant as e7, canAccessNode as e8, isGrantExpired as e9, generateId as eA, generatePrefixedId as eB, slugify as eC, generateTemplateName as eD, registry as eE, viewRegistry as eF, type ValidationMessages as eG, DEFAULT_VALIDATION_MESSAGES as eH, textConfigSchema as eI, textareaConfigSchema as eJ, richtextConfigSchema as eK, numberConfigSchema as eL, checkboxConfigSchema as eM, dateConfigSchema as eN, phoneConfigSchema as eO, currencyConfigSchema as eP, statusConfigSchema as eQ, locationConfigSchema as eR, selectConfigSchema as eS, multiselectConfigSchema as eT, fileConfigSchema as eU, userConfigSchema as eV, relationConfigSchema as eW, ratingConfigSchema as eX, formulaConfigSchema as eY, rollupConfigSchema as eZ, documentConfigSchema as e_, isGrantRevoked as ea, isGrantValid as eb, isTokenRevoked as ec, type GeneratedDocument as ed, type WorkflowExecutionContext as ee, createEmptyContext as ef, getContextValue as eg, mergeFormToSlot as eh, setContextValue as ei, type FormContextResponse as ej, type FormFieldContext as ek, type FormFieldRow as el, type FormNodeInfo as em, type ReadOnlyReason as en, type WorkflowAccessMode as eo, type ThemeColors as ep, type ThemeLogo as eq, type ThemeTypography as er, DEFAULT_THEME as es, generateCssVariables as et, mergeWithDefaults as eu, type Uuid as ev, type TenantId as ew, type UserId as ex, asTenantId as ey, asUserId as ez, type Option as f, QueryMultipleResultsError as f$, getAttributeConfigSchema as f0, validateAttributeConfig as f1, parseAttributeConfig as f2, safeParseAttributeConfig as f3, createTextValidator as f4, createNumberValidator as f5, createCheckboxValidator as f6, createDateValidator as f7, createPhoneValidator as f8, createCurrencyValidator as f9, computeRecordStatus as fA, type DatabaseAdapter as fB, WorkflowJwtService as fC, type JwtVerificationResult as fD, type MagicLinkPayload as fE, type WorkflowAccessPayload as fF, type WorkflowJwtConfig as fG, type WorkflowJwtPayload as fH, type CacheKeyType as fI, hashOptions as fJ, type CacheAdapter as fK, type CacheOptions as fL, cacheKeys as fM, cacheTtl as fN, defaultTtl as fO, NoopCacheAdapter as fP, type FetchResult as fQ, type FormattedRecord as fR, type GroupedFetchResult as fS, type InsertOptions as fT, type QueryBuilderState as fU, type RegistryMap as fV, type RegistryObjectNames as fW, type ShortcutOperator as fX, createDefaultState as fY, formatRecord as fZ, formatRecords as f_, createStatusValidator as fa, createSelectValidator as fb, createMultiselectValidator as fc, createLocationValidator as fd, createFileValidator as fe, createUserValidator as ff, createSingleRelationValidator as fg, createMultiRelationValidator as fh, createRelationValidator as fi, createRatingValidator as fj, createFormulaValidator as fk, createRollupValidator as fl, createTextAreaValidator as fm, createRichtextValidator as fn, createAttributeValidator as fo, createFormAttributeValidator as fp, createObjectValidator as fq, type ValidationResult as fr, validateAttribute as fs, validateObject as ft, validateObjectOrThrow as fu, createDraftValidator as fv, validateDraft as fw, validateDraftOrThrow as fx, getMissingRequiredAttributes as fy, isRecordComplete as fz, type StatusAttribute as g, parsePath as g$, QueryNoResultError as g0, SHORTCUT_TO_FILTER_OPERATOR as g1, createQueryBuilder as g2, QueryBuilder as g3, type QueryBuilderOptions as g4, type EvaluationResult as g5, type EvaluationTrace as g6, evaluateCondition as g7, evaluate as g8, evaluateWithTrace as g9, error as gA, ExecutorRegistry as gB, success as gC, wait as gD, ConditionExecutor as gE, DocumentExecutor as gF, EndExecutor as gG, FormExecutor as gH, StartExecutor as gI, evaluateFormula as gJ, evaluateFormulaAttribute as gK, evaluateFormulaAttributeWithRelations as gL, evaluateFormulaWithRelations as gM, evaluateFormulaWithResult as gN, extractFormulaVariables as gO, extractRelationNames as gP, extractRelationReferences as gQ, flattenRelationsForEval as gR, formatFormulaResult as gS, hasRelationReferences as gT, validateFormulaExpression as gU, type FormulaResult as gV, getPathDepth as gW, getRelationPath as gX, getTargetAttributeName as gY, InvalidPathError as gZ, MaxDepthExceededError as g_, TenantContextError as ga, addSchemaToContext as gb, getSchemaByNameFromContext as gc, getSchemaContext as gd, getSchemaFromContext as ge, hasSchemaContext as gf, runWithMergedSchemaContext as gg, runWithSchemaContext as gh, type SchemaContext as gi, getContext as gj, getTenantId as gk, getUserId as gl, hasContext as gm, runWithContext as gn, withTenantContext as go, type TenantContext as gp, createDefaultExecutorRegistry as gq, getDefaultExecutorRegistry as gr, type ExecutorCompleteResult as gs, type ExecutorContext as gt, type ExecutorErrorResult as gu, type ExecutorResult as gv, type ExecutorSuccessResult as gw, type ExecutorWaitResult as gx, type NodeExecutor as gy, complete as gz, type SelectAttribute as h, type RelationOption as h$, pathHasManyCardinality as h0, validatePath as h1, type PathCardinality as h2, type PathSegment as h3, type PathSegmentType as h4, type SchemaResolver as h5, resolveMultiplePaths as h6, resolveSingleValue as h7, traversePath as h8, type TraversalOptions as h9, type AIUsageMetricsRepository as hA, type DocumentTemplatesRepository as hB, type DocumentsRepository as hC, type DocumentSlotsRepository as hD, type DocumentJobsRepository as hE, type DocumentGenerationTemplateListOptions as hF, type DocumentGenerationTemplatesRepository as hG, BaseService as hH, BaseRepository as hI, type SchemaContextAware as hJ, SchemaContextAwareRepository as hK, TenantAwareRepository as hL, TenantAwareService as hM, type CreateCustomObjectInput as hN, type AddAttributeInput as hO, type UpdateObjectInput as hP, type ObjectSchemaServiceOptions as hQ, ObjectSchemaService as hR, type RecordServiceOptions as hS, RecordService as hT, type RecordQueryServiceOptions as hU, type QueryOptions as hV, type SearchQueryOptions as hW, type QueryResult as hX, RecordQueryService as hY, type RelationValidationResult as hZ, type RelationValidationError as h_, type TraversalResult as ha, type AttributeChange as hb, type HookContext as hc, type HookDefinition as hd, type HookHandler as he, type HookType as hf, NoopHookRegistry as hg, type HookRegistry as hh, createMockAdapter as hi, defaultPolicyRegistry as hj, PolicyRegistry as hk, notesPolicy as hl, type ObjectsRepository as hm, type AttributesRepository as hn, type UserProfilesRepository as ho, type FilesRepository as hp, type ObjectRecordsRepository as hq, type ViewsRepository as hr, type WorkflowsRepository as hs, type WorkflowInstancesRepository as ht, type WorkflowInvitationsRepository as hu, type WorkflowAccessGrantsRepository as hv, type AuditRepository as hw, type PermissionsRepository as hx, type AIConversationsRepository as hy, type AIUserMemoryRepository as hz, type SingleRelationAttribute as i, type UserProfileServiceOptions as i$, type RelationOptionsResponse as i0, type GetRelationOptionsParams as i1, type RelationServiceOptions as i2, type ResolveIdsBatchRequest as i3, type ResolveIdsBatchResponse as i4, RelationService as i5, RecordResolverService as i6, type ResolvedRelations as i7, type FormulaResolverServiceOptions as i8, FormulaResolverService as i9, DocumentProcessingHook as iA, GrantNotFoundError as iB, GrantExpiredError as iC, GrantRevokedError as iD, TokenRevokedError as iE, type GrantServiceConfig as iF, type CreateGrantResult as iG, WorkflowAccessGrantService as iH, type StartWorkflowInput as iI, type ResumeWorkflowInput as iJ, type WorkflowInstanceServiceOptions as iK, WorkflowInstanceService as iL, type InvitationServiceConfig as iM, InvitationNotFoundError as iN, InvitationExpiredError as iO, InvitationAlreadyAcceptedError as iP, InvitationRevokedError as iQ, WorkflowInvitationService as iR, type FieldReadOnlyResult as iS, WorkflowRelationService as iT, type CreateWorkflowInput as iU, type UpdateWorkflowInput as iV, type WorkflowServiceOptions as iW, WorkflowService as iX, type UserValidationResult as iY, type UserValidationError as iZ, UserService as i_, type RollupResult as ia, type RollupServiceOptions as ib, RollupService as ic, type RollupSchedulerOptions as id, RollupScheduler as ie, applyDefaultValues as ig, checkPermission as ih, getPolicy as ii, buildPolicyContext as ij, checkRecordAccess as ik, checkRecordModifyOrThrow as il, checkRecordDeleteOrThrow as im, checkSharedObjectWriteAccess as io, computeLabel as ip, type LabelResolver as iq, enrichWithFormulas as ir, enrichRecordsWithFormulas as is, createContextForCreate as it, createContextForUpdate as iu, createContextForDelete as iv, createContextForRestore as iw, recalculateParentRollups as ix, type RollupCascadeContext as iy, type DocumentProcessingHookOptions as iz, type MultiRelationAttribute as j, type GlobalSearchOptions as j$, UserProfileService as j0, AuditService as j1, buildAuditChanges as j2, DocumentGenerationTemplateNotFoundError as j3, DocumentGenerationNotConfiguredError as j4, DocumentGenerationService as j5, type DocumentProcessingConfig as j6, DocumentProcessingService as j7, type RenderDocumentInput as j8, type DocumentRendererOptions as j9, type SyncOptions as jA, syncNativeObjects as jB, verifyNativeObjectsSync as jC, getSyncPreview as jD, type FullSyncResult as jE, type FullSyncOptions as jF, syncAll as jG, DEFAULT_LABEL_FALLBACK as jH, renderLabelExpression as jI, isLabelExpression as jJ, extractAttributeNames as jK, enrichValuesForDisplay as jL, enrichValuesWithSelectLabels as jM, extractRelationIds as jN, type RelationLabelResolver as jO, computeLabelWithRelations as jP, type DBObject as jQ, type CreateDBObject as jR, type UpdateDBObject as jS, type UpsertDBObject as jT, type DBAttribute as jU, type CreateDBAttribute as jV, type UpdateDBAttribute as jW, type UpsertDBAttribute as jX, type CreateObjectRecord as jY, type ListOptions as jZ, type SearchOptions as j_, type RenderDocumentResult as ja, DocumentRenderError as jb, StorageDownloadNotSupportedError as jc, DocumentRendererService as jd, DocumentTemplateService as je, type RecordDocumentsResult as jf, type CreateRecordDocumentInput as jg, type CreateRecordDocumentResult as jh, type DocumentServiceOptions as ji, DocumentService as jj, type FileServiceOptions as jk, FileService as jl, GeocodingService as jm, GlobalSearchService as jn, type PermissionServiceOptions as jo, PermissionService as jp, type CreateViewInput as jq, type UpdateViewInput as jr, ViewService as js, type FileContent as jt, type StorageUploadInput as ju, type StorageUploadResult as jv, type SignedUrlOptions as jw, type StorageAdapter as jx, type UploadFileInput as jy, type SyncResult as jz, type RelationTarget as k, type GlobalSearchResultItem as k0, type FileListOptions as k1, type DBView as k2, type CreateDBView as k3, type UpdateDBView as k4, type UpsertDBView as k5, type DBWorkflow as k6, type CreateDBWorkflow as k7, type UpdateDBWorkflow as k8, type DBWorkflowInstance as k9, type CreateDBWorkflowInstance as ka, type UpdateDBWorkflowInstance as kb, type DBWorkflowInvitation as kc, type CreateDBWorkflowInvitation as kd, type UpdateDBWorkflowInvitation as ke, type DBWorkflowAccessGrant as kf, type CreateDBWorkflowAccessGrant as kg, type UpdateDBWorkflowAccessGrant as kh, type OperationResult as ki, type ViewSyncResult as kj, type ViewSyncOptions as kk, syncNativeViews as kl, verifyNativeViewsSync as km, getViewSyncPreview as kn, type RatingAttribute as l, type FormulaAttribute as m, type FormulaReturnType as n, type RollupAttribute as o, type RollupFunction as p, type AttributeType as q, type ObjectDefinition as r, type Field as s, type AttributeGroupField as t, type TableTab as u, type InverseTableTab as v, type ViewDefinition as w, type InstanceStatus as x, type Tab as y, type FilterState as z };
13967
+ export { type FlowRow as $, type Attribute as A, type Tab as B, type CheckboxAttribute as C, type DateAttribute as D, type FilterState as E, type FeatureGate as F, type Group as G, type SortRule as H, type InferAttributeValue as I, type DirectTableTab as J, type ListViewDefinition as K, type LocationAttribute as L, type MultiselectAttribute as M, type NumberAttribute as N, type ObjectAction as O, type PhoneAttribute as P, type WorkflowConfig as Q, type RichtextAttribute as R, type SystemResource as S, type TextAttribute as T, type UserAttribute as U, type SlotMode as V, type WorkflowTheme as W, type ConditionGroup as X, type ConditionRule as Y, type WorkflowNode as Z, type WorkflowDefinition as _, type DocumentAttribute as a, type DateValue as a$, type FlagValueType as a0, type FeatureFlagDefinition as a1, type FlagLevel as a2, type FeatureFlagsRepository as a3, type StaticFlagDefault as a4, type ResolvedFlag as a5, type ViewType as a6, type ViewDefinition as a7, type DocumentTemplate as a8, type OcrAdapter as a9, type ThinkingPartData as aA, type ReasoningPartData as aB, type AIChatMessagePart as aC, type AIChatMessage as aD, type AIQuestionType as aE, type AIQuestionOption as aF, type AIQuestion as aG, type AIQuestionAnswer as aH, type AIBatchQuestionOption as aI, type AIBatchQuestion as aJ, type AIBatchQuestionAnswer as aK, type AITodoStatus as aL, type AITodoItem as aM, type AITodoList as aN, type AIMessageAttachment as aO, type AIConversation as aP, type AIMessage as aQ, type AIToolCallRecord as aR, type AIUserMemory as aS, type AIUsageMetrics as aT, type AIProviderMetrics as aU, type CreateAIMessageInput as aV, type StatusGroup as aW, type AttributeGroup as aX, type BaseAttribute as aY, type NumberUnit as aZ, type DateFormat as a_, type OcrInput as aa, type OcrOptions as ab, type OcrResult as ac, type OcrPage as ad, type OcrTextBlock as ae, type BoundingBox as af, type SignatureAdapter as ag, type CreateSignatureInput as ah, type SignerRequest as ai, type SignaturePosition as aj, type SignatureRequestResult as ak, type SignatureStatusResult as al, type SignerStatus as am, type SignatureStatus as an, type IdentityVerificationAdapter as ao, type VerifyInput as ap, type VerificationResult as aq, type DocumentData as ar, type VerificationCheck as as, type AIMessageRole as at, type AIThinkingLevel as au, type AIToolCallStatus as av, type AIToolCall as aw, type AIChatMessagePartType as ax, type TextPartData as ay, type ToolPartData as az, type SystemAction as b, type FilterValue as b$, type Phone as b0, type Currency as b1, type Location as b2, type LocationGranularity as b3, RELATION_TARGET_ANY as b4, type RelationAttribute as b5, isUniversalRelation as b6, type AuditResourceType as b7, type AuditAction as b8, type AuditActorType as b9, type UpdateDocument as bA, type CreateDocumentTemplate as bB, type UpdateDocumentTemplate as bC, type CreateDocumentSlot as bD, type UpdateDocumentSlot as bE, type CreateProcessingJob as bF, type UpdateProcessingJob as bG, type DocumentListOptions as bH, type DocumentTemplateListOptions as bI, type FlagOverride as bJ, type FeatureFlagsConfig as bK, type StorageProvider as bL, type FileVisibility as bM, type File as bN, type CreateFile as bO, type UpdateFile as bP, type TextFilterOperator as bQ, type NumberFilterOperator as bR, type CheckboxFilterOperator as bS, type DateFilterOperator as bT, type SelectFilterOperator as bU, type MultiselectFilterOperator as bV, type RelationFilterOperator as bW, type FilterOperator as bX, type RelativeDateValue as bY, type CurrencyFilterValue as bZ, type PhoneFilterValue as b_, type AuditChange as ba, type AuditLogEntry as bb, type CreateAuditLogInput as bc, type AuditListOptions as bd, type AuditServiceOptions as be, type VariableMapping as bf, type PdfTemplateField as bg, type TemplateSource as bh, type DocumentGenerationTemplate as bi, type CreateDocumentGenerationTemplate as bj, type UpdateDocumentGenerationTemplate as bk, type PendingDocumentRequest as bl, isPdfTemplateSource as bm, isDocxTemplateSource as bn, type DocumentSlotDefinition as bo, type DocumentAutoProcessing as bp, type ExtractionMapping as bq, type ExtractionField as br, type Document as bs, type DocumentStatus as bt, type DocumentSlot as bu, type SlotStatus as bv, type ProcessingJob as bw, type ProcessingJobType as bx, type ProcessingJobStatus as by, type CreateDocument as bz, type TextAreaAttribute as c, type Permission as c$, type FilterRule as c0, type ExtendedFilterRule as c1, type FilterCombinator as c2, type FilterGroup as c3, type AdvancedFilterState as c4, isAdvancedFilterState as c5, toAdvancedFilterState as c6, toSimpleFilterState as c7, type SortDirection as c8, type QueryState as c9, type InferRecordInput as cA, type InferRecordUpdate as cB, type CustomAttributeValue as cC, type WithCustomAttributes as cD, type RecordMetadata as cE, type SystemFields as cF, type ExtractRecord as cG, type ExtractRecordStrict as cH, type ExtractRecordInput as cI, type ExtractRecordInputStrict as cJ, type ExtractRecordUpdate as cK, type ExtractRecordUpdateStrict as cL, type ExtractAttributes as cM, type TypedObjectRecord as cN, type ExtractObjectRecord as cO, type ExtractObjectRecordWithCustom as cP, RESERVED_ATTRIBUTE_NAMES as cQ, SYSTEM_FIELD_NAMES as cR, type ReservedAttributeName as cS, type SystemFieldName as cT, type Timestamps as cU, type SharingMode as cV, type ObjectAttribute as cW, type CompletionStatus as cX, type ObjectRecord as cY, type PermissionScope as cZ, type Role as c_, OPERATORS_BY_TYPE as ca, type NoValueOperator as cb, NO_VALUE_OPERATORS as cc, isNoValueOperator as cd, type FlowSlot as ce, type FlowRowField as cf, type FlowPage as cg, type FlowRelation as ch, type FlowStatus as ci, type FlowDefinition as cj, isFlowDefinition as ck, isFlowPublished as cl, isSystemFlow as cm, type GeocodingSuggestion as cn, type GeocodingAutocompleteParams as co, type ReverseGeocodingParams as cp, type GeocodingParams as cq, type GeocodingAdapter as cr, NoopGeocodingAdapter as cs, type AttributeSchema as ct, type InferRecordFromSchema as cu, type InferRecordWithRequirements as cv, type TypedAttribute as cw, type AttributeMap as cx, type AddAttribute as cy, type InferRecord as cz, type RichtextFeature as d, isDocumentNode as d$, type UserRoleAssignment as d0, type EffectivePermissions as d1, type ObjectPermissions as d2, type SystemPermissions as d3, type CreateRoleInput as d4, type UpdateRoleInput as d5, type CreatePermissionInput as d6, type AssignRoleInput as d7, type PolicyContext as d8, type RecordPolicy as d9, type GalleryViewDefinition as dA, type ConfigOverrides as dB, type ViewOverlay as dC, isDetailView as dD, isListView as dE, isCalendarView as dF, isTimelineView as dG, isGalleryView as dH, isFormTab as dI, isTableTab as dJ, isDirectTableTab as dK, isInverseTableTab as dL, isCustomTab as dM, isActivityTab as dN, isNotesTab as dO, isFlowsTab as dP, isDocumentsTab as dQ, type ConditionNode as dR, type DocumentNode as dS, type EndNode as dT, type FormFieldRef as dU, type FormNode as dV, type StartNode as dW, type WorkflowNodeType as dX, getNodeOutputs as dY, isAdvancedFormNode as dZ, isConditionNode as d_, PolicyViolationError as da, type UserRole as db, type UserStatus as dc, type UserProfile as dd, type CreateUserProfile as de, type UpdateUserProfile as df, type InviteUserInput as dg, type TabType as dh, type FormTab as di, type CustomTab as dj, type ActivityTab as dk, type NotesTab as dl, type FlowsTab as dm, type DocumentsTab as dn, type ListViewLayout as dp, type ViewLayout as dq, type ViewTab as dr, type DetailViewConfig as ds, type ListViewConfig as dt, type CalendarViewConfig as du, type TimelineViewConfig as dv, type GalleryViewConfig as dw, type ViewConfig as dx, type CalendarViewDefinition as dy, type TimelineViewDefinition as dz, type CurrencyAttribute as e, type TenantId as e$, isEndNode as e0, isFormNode as e1, isSimpleFormNode as e2, isStartNode as e3, type ConditionOperator as e4, and as e5, eq as e6, inValues as e7, isConditionGroup as e8, isConditionRule as e9, isInvitationValid as eA, type CreateGrantInput as eB, type WorkflowAccessGrant as eC, canAccessNode as eD, isGrantExpired as eE, isGrantRevoked as eF, isGrantValid as eG, isTokenRevoked as eH, type GeneratedDocument as eI, type WorkflowExecutionContext as eJ, createEmptyContext as eK, getContextValue as eL, mergeFormToSlot as eM, setContextValue as eN, type FormContextResponse as eO, type FormFieldContext as eP, type FormFieldRow as eQ, type FormNodeInfo as eR, type ReadOnlyReason as eS, type WorkflowAccessMode as eT, type ThemeColors as eU, type ThemeLogo as eV, type ThemeTypography as eW, DEFAULT_THEME as eX, generateCssVariables as eY, mergeWithDefaults as eZ, type Uuid as e_, isEmpty as ea, isNotEmpty as eb, neq as ec, or as ed, type CanvasViewport as ee, type NodePosition as ef, type WorkflowLayout as eg, type WorkflowSlot as eh, type WorkflowStatus as ei, isSystemWorkflow as ej, isWorkflowDefinition as ek, isWorkflowPublished as el, type PendingAction as em, type WorkflowError as en, type WorkflowInstance as eo, type WorkflowTransition as ep, canResumeInstance as eq, createStartTransition as er, isInstanceTerminal as es, isInstanceWaiting as et, type CreateInvitationInput as eu, type CreateInvitationResult as ev, type InvitationStatus as ew, type WorkflowInvitation as ex, isInvitationAccepted as ey, isInvitationExpired as ez, type Option as f, validateDraft as f$, type UserId as f0, asTenantId as f1, asUserId as f2, generateId as f3, generatePrefixedId as f4, slugify as f5, generateTemplateName as f6, registry as f7, viewRegistry as f8, type ValidationMessages as f9, createNumberValidator as fA, createCheckboxValidator as fB, createDateValidator as fC, createPhoneValidator as fD, createCurrencyValidator as fE, createStatusValidator as fF, createSelectValidator as fG, createMultiselectValidator as fH, createLocationValidator as fI, createFileValidator as fJ, createUserValidator as fK, createSingleRelationValidator as fL, createMultiRelationValidator as fM, createRelationValidator as fN, createRatingValidator as fO, createFormulaValidator as fP, createRollupValidator as fQ, createTextAreaValidator as fR, createRichtextValidator as fS, createAttributeValidator as fT, createFormAttributeValidator as fU, createObjectValidator as fV, type ValidationResult as fW, validateAttribute as fX, validateObject as fY, validateObjectOrThrow as fZ, createDraftValidator as f_, DEFAULT_VALIDATION_MESSAGES as fa, textConfigSchema as fb, textareaConfigSchema as fc, richtextConfigSchema as fd, numberConfigSchema as fe, checkboxConfigSchema as ff, dateConfigSchema as fg, phoneConfigSchema as fh, currencyConfigSchema as fi, statusConfigSchema as fj, locationConfigSchema as fk, selectConfigSchema as fl, multiselectConfigSchema as fm, fileConfigSchema as fn, userConfigSchema as fo, relationConfigSchema as fp, ratingConfigSchema as fq, formulaConfigSchema as fr, rollupConfigSchema as fs, documentConfigSchema as ft, attributeConfigSchemas as fu, getAttributeConfigSchema as fv, validateAttributeConfig as fw, parseAttributeConfig as fx, safeParseAttributeConfig as fy, createTextValidator as fz, type StatusAttribute as g, hasContext as g$, validateDraftOrThrow as g0, getMissingRequiredAttributes as g1, isRecordComplete as g2, computeRecordStatus as g3, type ViewOverlaysRepository as g4, type DatabaseAdapter as g5, WorkflowJwtService as g6, type JwtVerificationResult as g7, type MagicLinkPayload as g8, type WorkflowAccessPayload as g9, type QueryBuilderOptions as gA, type EvaluationResult as gB, type EvaluationTrace as gC, evaluateCondition as gD, evaluate as gE, evaluateWithTrace as gF, TenantContextError as gG, FeatureFlagsContextError as gH, getFeatureFlags as gI, getFeatureValue as gJ, hasFeatureFlagsContext as gK, isFeatureEnabled as gL, runWithFeatureFlags as gM, tryGetFeatureValue as gN, withFeatureFlags as gO, type FeatureFlagsContext as gP, addSchemaToContext as gQ, getSchemaByNameFromContext as gR, getSchemaContext as gS, getSchemaFromContext as gT, hasSchemaContext as gU, runWithMergedSchemaContext as gV, runWithSchemaContext as gW, type SchemaContext as gX, getContext as gY, getTenantId as gZ, getUserId as g_, type WorkflowJwtConfig as ga, type WorkflowJwtPayload as gb, type CacheKeyType as gc, hashOptions as gd, type CacheAdapter as ge, type CacheOptions as gf, cacheKeys as gg, cacheTtl as gh, defaultTtl as gi, NoopCacheAdapter as gj, type FetchResult as gk, type FormattedRecord as gl, type GroupedFetchResult as gm, type InsertOptions as gn, type QueryBuilderState as go, type RegistryMap as gp, type RegistryObjectNames as gq, type ShortcutOperator as gr, createDefaultState as gs, formatRecord as gt, formatRecords as gu, QueryMultipleResultsError as gv, QueryNoResultError as gw, SHORTCUT_TO_FILTER_OPERATOR as gx, createQueryBuilder as gy, QueryBuilder as gz, type SelectAttribute as h, notesPolicy as h$, runWithContext as h0, withTenantContext as h1, type TenantContext as h2, createDefaultExecutorRegistry as h3, getDefaultExecutorRegistry as h4, type ExecutorCompleteResult as h5, type ExecutorContext as h6, type ExecutorErrorResult as h7, type ExecutorResult as h8, type ExecutorSuccessResult as h9, getRelationPath as hA, getTargetAttributeName as hB, InvalidPathError as hC, MaxDepthExceededError as hD, parsePath as hE, pathHasManyCardinality as hF, validatePath as hG, type PathCardinality as hH, type PathSegment as hI, type PathSegmentType as hJ, type SchemaResolver as hK, resolveMultiplePaths as hL, resolveSingleValue as hM, traversePath as hN, type TraversalOptions as hO, type TraversalResult as hP, type AttributeChange as hQ, type HookContext as hR, type HookDefinition as hS, type HookHandler as hT, type HookType as hU, NoopHookRegistry as hV, type HookRegistry as hW, createMockAdapter as hX, type MockStores as hY, defaultPolicyRegistry as hZ, PolicyRegistry as h_, type ExecutorWaitResult as ha, type NodeExecutor as hb, complete as hc, error as hd, ExecutorRegistry as he, success as hf, wait as hg, ConditionExecutor as hh, DocumentExecutor as hi, EndExecutor as hj, FormExecutor as hk, StartExecutor as hl, evaluateFormula as hm, evaluateFormulaAttribute as hn, evaluateFormulaAttributeWithRelations as ho, evaluateFormulaWithRelations as hp, evaluateFormulaWithResult as hq, extractFormulaVariables as hr, extractRelationNames as hs, extractRelationReferences as ht, flattenRelationsForEval as hu, formatFormulaResult as hv, hasRelationReferences as hw, validateFormulaExpression as hx, type FormulaResult as hy, getPathDepth as hz, type FileAttribute as i, checkRecordDeleteOrThrow as i$, type AIConversationsRepository as i0, type AIUsageMetricsRepository as i1, type AIUserMemoryRepository as i2, type AttributesRepository as i3, type AuditRepository as i4, type DocumentGenerationTemplateListOptions as i5, type DocumentGenerationTemplatesRepository as i6, type DocumentJobsRepository as i7, type DocumentSlotsRepository as i8, type DocumentsRepository as i9, type SearchQueryOptions as iA, type QueryResult as iB, RecordQueryService as iC, type RelationValidationResult as iD, type RelationValidationError as iE, type RelationOption as iF, type RelationOptionsResponse as iG, type GetRelationOptionsParams as iH, type RelationServiceOptions as iI, type ResolveIdsBatchRequest as iJ, type ResolveIdsBatchResponse as iK, RelationService as iL, RecordResolverService as iM, type ResolvedRelations as iN, type FormulaResolverServiceOptions as iO, FormulaResolverService as iP, type RollupResult as iQ, type RollupServiceOptions as iR, RollupService as iS, type RollupSchedulerOptions as iT, RollupScheduler as iU, applyDefaultValues as iV, checkPermission as iW, getPolicy as iX, buildPolicyContext as iY, checkRecordAccess as iZ, checkRecordModifyOrThrow as i_, type DocumentTemplatesRepository as ia, type FilesRepository as ib, type ObjectRecordsRepository as ic, type ObjectsRepository as id, type PermissionsRepository as ie, type UserProfilesRepository as ig, type ViewsRepository as ih, type WorkflowAccessGrantsRepository as ii, type WorkflowInstancesRepository as ij, type WorkflowInvitationsRepository as ik, type WorkflowsRepository as il, BaseService as im, BaseRepository as io, type SchemaContextAware as ip, SchemaContextAwareRepository as iq, type CreateCustomObjectInput as ir, type AddAttributeInput as is, type UpdateObjectInput as it, type ObjectSchemaServiceOptions as iu, ObjectSchemaService as iv, type RecordServiceOptions as iw, RecordService as ix, type RecordQueryServiceOptions as iy, type QueryOptions as iz, type SingleRelationAttribute as j, GlobalSearchService as j$, checkSharedObjectWriteAccess as j0, computeLabel as j1, type LabelResolver as j2, enrichWithFormulas as j3, enrichRecordsWithFormulas as j4, createContextForCreate as j5, createContextForUpdate as j6, createContextForDelete as j7, createContextForRestore as j8, recalculateParentRollups as j9, type UserValidationResult as jA, type UserValidationError as jB, UserService as jC, type UserProfileServiceOptions as jD, UserProfileService as jE, AuditService as jF, buildAuditChanges as jG, DocumentGenerationTemplateNotFoundError as jH, DocumentGenerationNotConfiguredError as jI, DocumentGenerationService as jJ, type DocumentProcessingConfig as jK, DocumentProcessingService as jL, type RenderDocumentInput as jM, type DocumentRendererOptions as jN, type RenderDocumentResult as jO, DocumentRenderError as jP, StorageDownloadNotSupportedError as jQ, DocumentRendererService as jR, DocumentTemplateService as jS, type RecordDocumentsResult as jT, type CreateRecordDocumentInput as jU, type CreateRecordDocumentResult as jV, type DocumentServiceOptions as jW, DocumentService as jX, type FileServiceOptions as jY, FileService as jZ, GeocodingService as j_, type RollupCascadeContext as ja, type DocumentProcessingHookOptions as jb, DocumentProcessingHook as jc, GrantNotFoundError as jd, GrantExpiredError as je, GrantRevokedError as jf, TokenRevokedError as jg, type GrantServiceConfig as jh, type CreateGrantResult as ji, WorkflowAccessGrantService as jj, type StartWorkflowInput as jk, type ResumeWorkflowInput as jl, type WorkflowInstanceServiceOptions as jm, WorkflowInstanceService as jn, type InvitationServiceConfig as jo, InvitationNotFoundError as jp, InvitationExpiredError as jq, InvitationAlreadyAcceptedError as jr, InvitationRevokedError as js, WorkflowInvitationService as jt, type FieldReadOnlyResult as ju, WorkflowRelationService as jv, type CreateWorkflowInput as jw, type UpdateWorkflowInput as jx, type WorkflowServiceOptions as jy, WorkflowService as jz, type MultiRelationAttribute as k, type OperationResult as k$, type PermissionServiceOptions as k0, PermissionService as k1, type CreateViewInput as k2, type UpdateViewInput as k3, type GetViewsOptions as k4, type GetViewOptions as k5, ViewService as k6, type FileContent as k7, type StorageUploadInput as k8, type StorageUploadResult as k9, type UpdateDBAttribute as kA, type UpsertDBAttribute as kB, type CreateObjectRecord as kC, type ListOptions as kD, type SearchOptions as kE, type GlobalSearchOptions as kF, type GlobalSearchResultItem as kG, type FileListOptions as kH, type DBView as kI, type CreateDBView as kJ, type UpdateDBView as kK, type UpsertDBView as kL, type DBViewOverlay as kM, type CreateDBViewOverlay as kN, type UpdateDBViewOverlay as kO, type DBWorkflow as kP, type CreateDBWorkflow as kQ, type UpdateDBWorkflow as kR, type DBWorkflowInstance as kS, type CreateDBWorkflowInstance as kT, type UpdateDBWorkflowInstance as kU, type DBWorkflowInvitation as kV, type CreateDBWorkflowInvitation as kW, type UpdateDBWorkflowInvitation as kX, type DBWorkflowAccessGrant as kY, type CreateDBWorkflowAccessGrant as kZ, type UpdateDBWorkflowAccessGrant as k_, type SignedUrlOptions as ka, type StorageAdapter as kb, type UploadFileInput as kc, type SyncResult as kd, type SyncOptions as ke, syncNativeObjects as kf, verifyNativeObjectsSync as kg, getSyncPreview as kh, type FullSyncResult as ki, type FullSyncOptions as kj, syncAll as kk, DEFAULT_LABEL_FALLBACK as kl, renderLabelExpression as km, isLabelExpression as kn, extractAttributeNames as ko, enrichValuesForDisplay as kp, enrichValuesWithSelectLabels as kq, extractRelationIds as kr, type RelationLabelResolver as ks, computeLabelWithRelations as kt, type DBObject as ku, type CreateDBObject as kv, type UpdateDBObject as kw, type UpsertDBObject as kx, type DBAttribute as ky, type CreateDBAttribute as kz, type RelationTarget as l, type ViewSyncResult as l0, type ViewSyncLogger as l1, type ViewSyncOptions as l2, seedRegistryViews as l3, syncNativeViews as l4, verifyRegistryViewsSeeded as l5, verifyNativeViewsSync as l6, getViewSeedPreview as l7, getViewSyncPreview as l8, type RatingAttribute as m, type FormulaAttribute as n, type FormulaReturnType as o, type RollupAttribute as p, type RollupFunction as q, type AttributeType as r, type ObjectDefinition as s, type Field as t, type AttributeGroupField as u, type TableTab as v, type DetailViewLayout as w, type InverseTableTab as x, type DetailViewDefinition as y, type InstanceStatus as z };