@stndrds/schema 0.1.0-alpha.14 → 0.1.0-alpha.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/chunk-2ASXJITY.mjs +5360 -0
  2. package/dist/chunk-5AWYVQKR.mjs +5310 -0
  3. package/dist/chunk-65HUQZHK.mjs +5374 -0
  4. package/dist/chunk-73P4F2OU.mjs +5809 -0
  5. package/dist/chunk-BHKKVBPP.mjs +5527 -0
  6. package/dist/chunk-BTVPMGYW.mjs +6327 -0
  7. package/dist/chunk-BUWVNOSK.mjs +5457 -0
  8. package/dist/chunk-C7HZ55GJ.mjs +6882 -0
  9. package/dist/chunk-CCEHW4E7.mjs +6071 -0
  10. package/dist/chunk-CNR3BZLU.mjs +5163 -0
  11. package/dist/chunk-DLMVX6DN.mjs +6074 -0
  12. package/dist/chunk-DUUORFHI.mjs +5379 -0
  13. package/dist/chunk-DWTD7YPJ.mjs +74 -0
  14. package/dist/chunk-FAR5ENGR.mjs +78 -0
  15. package/dist/chunk-ITWOVZOW.mjs +5809 -0
  16. package/dist/chunk-JDUTFH3J.mjs +6940 -0
  17. package/dist/chunk-KJLKY5X7.mjs +6314 -0
  18. package/dist/chunk-KTJXMGBR.mjs +5397 -0
  19. package/dist/chunk-NOVHQ7B2.mjs +6327 -0
  20. package/dist/chunk-PMFQ4ZL4.mjs +6230 -0
  21. package/dist/chunk-QAGN53HE.mjs +6327 -0
  22. package/dist/chunk-QC47SMCZ.mjs +5467 -0
  23. package/dist/chunk-UUOAVXAI.mjs +6327 -0
  24. package/dist/chunk-VYZ3BOSB.mjs +6946 -0
  25. package/dist/chunk-XAX75NSP.mjs +6321 -0
  26. package/dist/chunk-Z6LIJ5PO.mjs +5362 -0
  27. package/dist/chunk-ZG3PT3RL.mjs +6944 -0
  28. package/dist/default-roles-G4TOWUVM.mjs +20 -0
  29. package/dist/default-roles-QEZPRSUL.mjs +20 -0
  30. package/dist/index.d.mts +419 -16
  31. package/dist/index.d.ts +419 -16
  32. package/dist/index.js +2580 -406
  33. package/dist/index.mjs +80 -163
  34. package/dist/runtime-B1_syHVj.d.mts +4787 -0
  35. package/dist/runtime-B1_syHVj.d.ts +4787 -0
  36. package/dist/runtime-B7N-oycb.d.mts +4854 -0
  37. package/dist/runtime-B7N-oycb.d.ts +4854 -0
  38. package/dist/runtime-BDoAIuTe.d.mts +4872 -0
  39. package/dist/runtime-BDoAIuTe.d.ts +4872 -0
  40. package/dist/runtime-BPYJWZfC.d.mts +5130 -0
  41. package/dist/runtime-BPYJWZfC.d.ts +5130 -0
  42. package/dist/runtime-BVRmzg3d.d.mts +4718 -0
  43. package/dist/runtime-BVRmzg3d.d.ts +4718 -0
  44. package/dist/runtime-BrXwIidf.d.mts +4794 -0
  45. package/dist/runtime-BrXwIidf.d.ts +4794 -0
  46. package/dist/runtime-CC_HZhVN.d.mts +5224 -0
  47. package/dist/runtime-CC_HZhVN.d.ts +5224 -0
  48. package/dist/runtime-CEx57sBZ.d.mts +4791 -0
  49. package/dist/runtime-CEx57sBZ.d.ts +4791 -0
  50. package/dist/runtime-COGvuXIq.d.mts +4790 -0
  51. package/dist/runtime-COGvuXIq.d.ts +4790 -0
  52. package/dist/runtime-CSGWjztI.d.mts +5166 -0
  53. package/dist/runtime-CSGWjztI.d.ts +5166 -0
  54. package/dist/runtime-DRc_OhnM.d.mts +5142 -0
  55. package/dist/runtime-DRc_OhnM.d.ts +5142 -0
  56. package/dist/runtime-DUxWyRcq.d.mts +5399 -0
  57. package/dist/runtime-DUxWyRcq.d.ts +5399 -0
  58. package/dist/runtime-D_S3m9jf.d.mts +5142 -0
  59. package/dist/runtime-D_S3m9jf.d.ts +5142 -0
  60. package/dist/runtime-Db3rRxbJ.d.mts +4821 -0
  61. package/dist/runtime-Db3rRxbJ.d.ts +4821 -0
  62. package/dist/runtime-DlCiIIfr.d.mts +5130 -0
  63. package/dist/runtime-DlCiIIfr.d.ts +5130 -0
  64. package/dist/runtime-LO17NDk1.d.mts +5292 -0
  65. package/dist/runtime-LO17NDk1.d.ts +5292 -0
  66. package/dist/runtime-WqYxjhjJ.d.mts +5125 -0
  67. package/dist/runtime-WqYxjhjJ.d.ts +5125 -0
  68. package/dist/runtime.d.mts +1 -1
  69. package/dist/runtime.d.ts +1 -1
  70. package/dist/runtime.js +2178 -370
  71. package/dist/runtime.mjs +9 -1
  72. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { A as Attribute, S as StatusAttribute, a as SelectAttribute, M as MultiselectAttribute, P as Phone, C as Currency, L as Location, T as TextAttribute, b as TextAreaAttribute, N as NumberAttribute, c as CheckboxAttribute, D as DateAttribute, d as PhoneAttribute, e as CurrencyAttribute, O as Option, f as LocationAttribute, g as TimestampAttribute, F as FileAttribute, U as UserAttribute, h as SingleRelationAttribute, R as RelationOnDelete, i as MultiRelationAttribute, j as RelationTarget, k as RatingAttribute, l as ObjectDefinition, m as Field, n as AttributeGroupField, G as Group, V as ViewDefinition, o as Tab } from './runtime-yMql0npY.js';
2
- export { bS as AddAttributeInput, aa as AdvancedFilterState, bA as AttributeChange, r as AttributeGroup, p as AttributeType, bJ as AttributesRepository, B as BaseAttribute, Y as CheckboxFilterOperator, at as CompletionStatus, bR as CreateCustomObjectInput, cm as CreateDBAttribute, ci as CreateDBObject, cw as CreateDBView, K as CreateFile, cp as CreateObjectRecord, ay as CreateUserProfile, c2 as CreateViewInput, a3 as CurrencyFilterValue, aD as CustomTab, cl as DBAttribute, ch as DBObject, cv as DBView, cd as DEFAULT_LABEL_FALLBACK, bz as DatabaseAdapter, Z as DateFilterOperator, t as DateFormat, u as DateValue, x as DocumentFace, w as DocumentType, y as DocumentTypeConfig, J as File, cu as FileListOptions, bO as FileService, z as FileVerificationConfig, I as FileVisibility, bL as FilesRepository, a7 as FilterCombinator, a9 as FilterGroup, a1 as FilterOperator, a6 as FilterRule, a8 as FilterState, a5 as FilterValue, aB as FormTab, cb as FullSyncOptions, ca as FullSyncResult, ap as GeocodingAdapter, am as GeocodingAutocompleteParams, ao as GeocodingParams, bP as GeocodingService, al as GeocodingSuggestion, b$ as GetRelationOptionsParams, cs as GlobalSearchOptions, ct as GlobalSearchResultItem, bQ as GlobalSearchService, bB as HookContext, bC as HookDefinition, bD as HookHandler, bG as HookRegistry, bE as HookType, cq as ListOptions, v as LocationGranularity, $ as MultiselectFilterOperator, aj as NO_VALUE_OPERATORS, ai as NoValueOperator, aq as NoopGeocodingAdapter, bF as NoopHookRegistry, X as NumberFilterOperator, s as NumberUnit, ah as OPERATORS_BY_TYPE, as as ObjectAttribute, au as ObjectRecord, bM as ObjectRecordsRepository, bU as ObjectSchemaService, bI as ObjectsRepository, cz as OperationResult, a4 as PhoneFilterValue, ag as QueryState, bW as RecordService, bV as RecordServiceOptions, E as RelationAttribute, a0 as RelationFilterOperator, bZ as RelationOption, b_ as RelationOptionsResponse, c0 as RelationService, bY as RelationValidationError, bX as RelationValidationResult, a2 as RelativeDateValue, an as ReverseGeocodingParams, cr as SearchOptions, _ as SelectFilterOperator, ae as SortDirection, af as SortRule, q as StatusGroup, H as StorageProvider, c6 as SyncOptions, c5 as SyncResult, aA as TabType, aC as TableTab, aI as TenantId, W as TextFilterOperator, ar as Timestamps, cn as UpdateDBAttribute, cj as UpdateDBObject, cx as UpdateDBView, Q as UpdateFile, bT as UpdateObjectInput, az as UpdateUserProfile, c3 as UpdateViewInput, co as UpsertDBAttribute, ck as UpsertDBObject, cy as UpsertDBView, ax as UserProfile, c1 as UserProfileService, bK as UserProfilesRepository, av as UserRole, aw as UserStatus, aH as Uuid, bp as ValidationResult, c4 as ViewService, cB as ViewSyncOptions, cA as ViewSyncResult, bN as ViewsRepository, b1 as attributeConfigSchemas, aQ as checkboxConfigSchema, by as computeRecordStatus, bn as createAttributeValidator, b8 as createCheckboxValidator, bb as createCurrencyValidator, b9 as createDateValidator, bt as createDraftValidator, bh as createFileValidator, bf as createLocationValidator, bH as createMockAdapter, bk as createMultiRelationValidator, be as createMultiselectValidator, b7 as createNumberValidator, bo as createObjectValidator, ba as createPhoneValidator, bm as createRatingValidator, bl as createRelationValidator, bd as createSelectValidator, bj as createSingleRelationValidator, bc as createStatusValidator, b6 as createTextValidator, bg as createTimestampValidator, bi as createUserValidator, aT as currencyConfigSchema, aR as dateConfigSchema, cg as extractAttributeNames, aZ as fileConfigSchema, aJ as generateId, aK as generatePrefixedId, b2 as getAttributeConfigSchema, bw as getMissingRequiredAttributes, c9 as getSyncPreview, cE as getViewSyncPreview, ab as isAdvancedFilterState, aG as isCustomTab, aE as isFormTab, cf as isLabelExpression, ak as isNoValueOperator, bx as isRecordComplete, aF as isTableTab, aV as locationConfigSchema, aY as multiselectConfigSchema, aP as numberConfigSchema, b4 as parseAttributeConfig, aS as phoneConfigSchema, b0 as ratingConfigSchema, aL as registry, a$ as relationConfigSchema, ce as renderLabelExpression, b5 as safeParseAttributeConfig, aX as selectConfigSchema, aU as statusConfigSchema, cc as syncAll, c7 as syncNativeObjects, cC as syncNativeViews, aN as textConfigSchema, aO as textareaConfigSchema, aW as timestampConfigSchema, ac as toAdvancedFilterState, ad as toSimpleFilterState, a_ as userConfigSchema, bq as validateAttribute, b3 as validateAttributeConfig, bu as validateDraft, bv as validateDraftOrThrow, br as validateObject, bs as validateObjectOrThrow, c8 as verifyNativeObjectsSync, cD as verifyNativeViewsSync, aM as viewRegistry } from './runtime-yMql0npY.js';
3
- import { IconName, CountryIso3, CurrencyCode, MimeType } from '@stndrds/constants';
1
+ import { A as Attribute, S as StatusAttribute, a as SelectAttribute, M as MultiselectAttribute, P as Phone, C as Currency, L as Location, b as SystemResource, c as SystemAction, O as ObjectAction, T as TextAttribute, d as TextAreaAttribute, N as NumberAttribute, e as CheckboxAttribute, D as DateAttribute, f as PhoneAttribute, g as CurrencyAttribute, h as Option, i as LocationAttribute, j as TimestampAttribute, F as FileAttribute, U as UserAttribute, k as SingleRelationAttribute, l as MultiRelationAttribute, R as RelationTarget, m as RatingAttribute, n as FlowDefinition, o as FlowPage, p as FlowRow, q as ObjectDefinition, r as Field, s as AttributeGroupField, G as Group, V as ViewDefinition, t as Tab } from './runtime-DlCiIIfr.js';
2
+ export { ct as AddAttributeInput, an as AdvancedFilterState, aZ as AssignRoleInput, c3 as AttributeChange, w as AttributeGroup, u as AttributeType, cc as AttributesRepository, X as AuditAction, Y as AuditActorType, Z as AuditChange, a0 as AuditListOptions, _ as AuditLogEntry, ci as AuditRepository, W as AuditResourceType, cl as AuditService, a1 as AuditServiceOptions, B as BaseAttribute, a9 as CheckboxFilterOperator, aN as CompletionStatus, $ as CreateAuditLogInput, cs as CreateCustomObjectInput, d1 as CreateDBAttribute, df as CreateDBFlow, cZ as CreateDBObject, db as CreateDBView, a5 as CreateFile, cn as CreateFlowInput, d4 as CreateObjectRecord, aY as CreatePermissionInput, aW as CreateRoleInput, b1 as CreateUserProfile, cJ as CreateViewInput, ag as CurrencyFilterValue, b6 as CustomTab, d0 as DBAttribute, de as DBFlow, cY as DBObject, da as DBView, cU as DEFAULT_LABEL_FALLBACK, c2 as DatabaseAdapter, aa as DateFilterOperator, y as DateFormat, z as DateValue, I as DocumentFace, H as DocumentType, J as DocumentTypeConfig, aT as EffectivePermissions, a4 as File, d9 as FileListOptions, cm as FileService, K as FileVerificationConfig, a3 as FileVisibility, ce as FilesRepository, ak as FilterCombinator, am as FilterGroup, ae as FilterOperator, aj as FilterRule, al as FilterState, ai as FilterValue, aA as FlowRelation, az as FlowRowField, cp as FlowService, ay as FlowSlot, aB as FlowStatus, ch as FlowsRepository, b4 as FormTab, cS as FullSyncOptions, cR as FullSyncResult, aJ as GeocodingAdapter, aG as GeocodingAutocompleteParams, aI as GeocodingParams, cq as GeocodingService, aF as GeocodingSuggestion, cF as GetRelationOptionsParams, d7 as GlobalSearchOptions, d8 as GlobalSearchResultItem, cr as GlobalSearchService, c4 as HookContext, c5 as HookDefinition, c6 as HookHandler, c9 as HookRegistry, c7 as HookType, d5 as ListOptions, E as LocationGranularity, ac as MultiselectFilterOperator, aw as NO_VALUE_OPERATORS, av as NoValueOperator, aK as NoopGeocodingAdapter, c8 as NoopHookRegistry, a8 as NumberFilterOperator, x as NumberUnit, au as OPERATORS_BY_TYPE, aM as ObjectAttribute, aU as ObjectPermissions, aO as ObjectRecord, cf as ObjectRecordsRepository, cw as ObjectSchemaService, cv as ObjectSchemaServiceOptions, cb as ObjectsRepository, dh as OperationResult, aR as Permission, aP as PermissionScope, cy as PermissionService, cx as PermissionServiceOptions, cj as PermissionsRepository, ah as PhoneFilterValue, at as QueryState, cA as RecordService, cz as RecordServiceOptions, Q as RelationAttribute, ad as RelationFilterOperator, cD as RelationOption, cE as RelationOptionsResponse, cG as RelationService, cC as RelationValidationError, cB as RelationValidationResult, af as RelativeDateValue, aH as ReverseGeocodingParams, aQ as Role, d6 as SearchOptions, ab as SelectFilterOperator, ar as SortDirection, as as SortRule, v as StatusGroup, a2 as StorageProvider, cN as SyncOptions, cM as SyncResult, aV as SystemPermissions, b3 as TabType, b5 as TableTab, bb as TenantId, a7 as TextFilterOperator, aL as Timestamps, d2 as UpdateDBAttribute, dg as UpdateDBFlow, c_ as UpdateDBObject, dc as UpdateDBView, a6 as UpdateFile, co as UpdateFlowInput, cu as UpdateObjectInput, aX as UpdateRoleInput, b2 as UpdateUserProfile, cK as UpdateViewInput, d3 as UpsertDBAttribute, c$ as UpsertDBObject, dd as UpsertDBView, b0 as UserProfile, cI as UserProfileService, cH as UserProfileServiceOptions, cd as UserProfilesRepository, a_ as UserRole, aS as UserRoleAssignment, a$ as UserStatus, ba as Uuid, bU as ValidationResult, cL as ViewService, dj as ViewSyncOptions, di as ViewSyncResult, cg as ViewsRepository, bw as attributeConfigSchemas, ck as buildAuditChanges, bj as checkboxConfigSchema, c1 as computeRecordStatus, bS as createAttributeValidator, bD as createCheckboxValidator, bG as createCurrencyValidator, bE as createDateValidator, bY as createDraftValidator, bM as createFileValidator, bK as createLocationValidator, ca as createMockAdapter, bP as createMultiRelationValidator, bJ as createMultiselectValidator, bC as createNumberValidator, bT as createObjectValidator, bF as createPhoneValidator, bR as createRatingValidator, bQ as createRelationValidator, bI as createSelectValidator, bO as createSingleRelationValidator, bH as createStatusValidator, bB as createTextValidator, bL as createTimestampValidator, bN as createUserValidator, bm as currencyConfigSchema, bk as dateConfigSchema, cX as extractAttributeNames, bs as fileConfigSchema, bc as generateId, bd as generatePrefixedId, bx as getAttributeConfigSchema, b$ as getMissingRequiredAttributes, cQ as getSyncPreview, dm as getViewSyncPreview, ao as isAdvancedFilterState, b9 as isCustomTab, aC as isFlowDefinition, aD as isFlowPublished, b7 as isFormTab, cW as isLabelExpression, ax as isNoValueOperator, c0 as isRecordComplete, aE as isSystemFlow, b8 as isTableTab, bo as locationConfigSchema, br as multiselectConfigSchema, bi as numberConfigSchema, bz as parseAttributeConfig, bl as phoneConfigSchema, bv as ratingConfigSchema, be as registry, bu as relationConfigSchema, cV as renderLabelExpression, bA as safeParseAttributeConfig, bq as selectConfigSchema, bn as statusConfigSchema, cT as syncAll, cO as syncNativeObjects, dk as syncNativeViews, bg as textConfigSchema, bh as textareaConfigSchema, bp as timestampConfigSchema, ap as toAdvancedFilterState, aq as toSimpleFilterState, bt as userConfigSchema, bV as validateAttribute, by as validateAttributeConfig, bZ as validateDraft, b_ as validateDraftOrThrow, bW as validateObject, bX as validateObjectOrThrow, cP as verifyNativeObjectsSync, dl as verifyNativeViewsSync, bf as viewRegistry } from './runtime-DlCiIIfr.js';
3
+ import { IconName, CountryIso3, CurrencyCode, MimeType, ColorId } from '@stndrds/constants';
4
4
  import 'zod';
5
5
 
6
6
  /**
@@ -19,6 +19,94 @@ interface BuilderConfig {
19
19
  label: string;
20
20
  }
21
21
 
22
+ /**
23
+ * Reference information for a record that is blocking deletion.
24
+ */
25
+ interface RecordReference {
26
+ /** Technical name of the object (e.g., "contacts") */
27
+ objectName: string;
28
+ /** Display label of the object (e.g., "Contacts") */
29
+ objectLabel: string;
30
+ /** Number of records referencing the target */
31
+ count: number;
32
+ }
33
+ /**
34
+ * Thrown when attempting to delete a record that is referenced by other records.
35
+ *
36
+ * This implements the "Restrict" behavior: deletion is blocked and the user
37
+ * must first remove or update the referencing records.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * try {
42
+ * await recordService.deleteRecord(companyId);
43
+ * } catch (error) {
44
+ * if (error instanceof RecordReferencedError) {
45
+ * console.log(`Cannot delete: referenced by ${error.references.length} objects`);
46
+ * // Show UI with details: error.references
47
+ * }
48
+ * }
49
+ * ```
50
+ */
51
+ declare class RecordReferencedError extends Error {
52
+ readonly recordId: string;
53
+ readonly references: RecordReference[];
54
+ readonly code: "RECORD_REFERENCED";
55
+ constructor(recordId: string, references: RecordReference[]);
56
+ }
57
+ /**
58
+ * Usage context where an attribute is being used.
59
+ */
60
+ type AttributeUsage = "labelExpression" | "view" | "filter";
61
+ /**
62
+ * Thrown when attempting to delete an attribute that is in use.
63
+ *
64
+ * Attributes cannot be deleted if they are referenced in:
65
+ * - The object's labelExpression template
66
+ * - A saved view's column configuration
67
+ * - A saved filter condition
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * try {
72
+ * await schemaService.deleteAttribute(attributeId);
73
+ * } catch (error) {
74
+ * if (error instanceof AttributeInUseError) {
75
+ * console.log(`Cannot delete "${error.attributeName}": used in ${error.usage}`);
76
+ * }
77
+ * }
78
+ * ```
79
+ */
80
+ declare class AttributeInUseError extends Error {
81
+ readonly attributeName: string;
82
+ readonly usage: AttributeUsage;
83
+ readonly code: "ATTRIBUTE_IN_USE";
84
+ constructor(attributeName: string, usage: AttributeUsage);
85
+ }
86
+ /**
87
+ * Thrown when attempting to delete an object that is a relation target.
88
+ *
89
+ * Objects cannot be deleted if other objects have relation attributes
90
+ * pointing to them as a target.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * try {
95
+ * await schemaService.deleteObject(objectId);
96
+ * } catch (error) {
97
+ * if (error instanceof ObjectReferencedError) {
98
+ * console.log(`Cannot delete "${error.objectName}": target of ${error.referencingObjects.join(", ")}`);
99
+ * }
100
+ * }
101
+ * ```
102
+ */
103
+ declare class ObjectReferencedError extends Error {
104
+ readonly objectName: string;
105
+ readonly referencingObjects: string[];
106
+ readonly code: "OBJECT_REFERENCED";
107
+ constructor(objectName: string, referencingObjects: string[]);
108
+ }
109
+
22
110
  /**
23
111
  * Lookup table for primitive attribute types
24
112
  * Maps attribute type name to its runtime value type
@@ -212,6 +300,78 @@ type ExtractAttributes<TBuilder> = TBuilder extends {
212
300
  };
213
301
  } ? A : never;
214
302
 
303
+ /**
304
+ * System resources that can be managed through permissions.
305
+ */
306
+ declare const SYSTEM_RESOURCES: {
307
+ /** User profiles and invitations management */
308
+ readonly USERS: "users";
309
+ /** Object definitions and attributes management */
310
+ readonly SCHEMA: "schema";
311
+ /** Roles and permissions management */
312
+ readonly ROLES: "roles";
313
+ /** Tenant settings and configuration */
314
+ readonly SETTINGS: "settings";
315
+ /** Audit logs and activity trail */
316
+ readonly AUDIT: "audit";
317
+ };
318
+ /**
319
+ * All system resources as an array (for iteration)
320
+ */
321
+ declare const ALL_SYSTEM_RESOURCES: SystemResource[];
322
+ /**
323
+ * Human-readable labels for system resources
324
+ */
325
+ declare const SYSTEM_RESOURCE_LABELS: Record<SystemResource, string>;
326
+ /**
327
+ * Default role names that are created for every tenant.
328
+ */
329
+ declare const DEFAULT_ROLES: {
330
+ /** Full platform access - can manage everything */
331
+ readonly ADMIN: "admin";
332
+ /** Standard user - can work with business data but not platform settings */
333
+ readonly MEMBER: "member";
334
+ /** Read-only access - can view but not modify */
335
+ readonly GUEST: "guest";
336
+ };
337
+ type DefaultRoleName = (typeof DEFAULT_ROLES)[keyof typeof DEFAULT_ROLES];
338
+ /**
339
+ * Human-readable labels for default roles
340
+ */
341
+ declare const DEFAULT_ROLE_LABELS: Record<DefaultRoleName, string>;
342
+ /**
343
+ * Descriptions for default roles
344
+ */
345
+ declare const DEFAULT_ROLE_DESCRIPTIONS: Record<DefaultRoleName, string>;
346
+ /**
347
+ * Default permission configuration for each role.
348
+ * Used when initializing a new tenant.
349
+ */
350
+ interface DefaultRolePermissionConfig {
351
+ /** System resource permissions (users, schema, roles, settings) */
352
+ system: Array<{
353
+ target: SystemResource | "*";
354
+ actions: SystemAction[];
355
+ }>;
356
+ /** Object permissions (business data) */
357
+ object: Array<{
358
+ target: string;
359
+ actions: ObjectAction[];
360
+ }>;
361
+ }
362
+ /**
363
+ * Default permissions for each built-in role.
364
+ *
365
+ * - **admin**: Full access to everything (system + objects)
366
+ * - **member**: No system access, full CRUD on objects (except delete)
367
+ * - **guest**: No system access, read-only on objects
368
+ */
369
+ declare const DEFAULT_ROLE_PERMISSIONS: Record<DefaultRoleName, DefaultRolePermissionConfig>;
370
+ /**
371
+ * Check if a role name is a default/built-in role
372
+ */
373
+ declare function isDefaultRole(roleName: string): roleName is DefaultRoleName;
374
+
215
375
  /**
216
376
  * Error codes for schema exceptions
217
377
  */
@@ -222,11 +382,14 @@ declare const SchemaErrorCode: {
222
382
  readonly RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND";
223
383
  readonly USER_PROFILE_NOT_FOUND: "SCHEMA_USER_PROFILE_NOT_FOUND";
224
384
  readonly FILE_NOT_FOUND: "SCHEMA_FILE_NOT_FOUND";
385
+ readonly ROLE_NOT_FOUND: "SCHEMA_ROLE_NOT_FOUND";
225
386
  readonly VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
226
387
  readonly INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME";
227
388
  readonly INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME";
228
389
  readonly PROTECTED_OBJECT: "SCHEMA_PROTECTED_OBJECT";
229
390
  readonly PROTECTED_ATTRIBUTE: "SCHEMA_PROTECTED_ATTRIBUTE";
391
+ readonly PROTECTED_ROLE: "SCHEMA_PROTECTED_ROLE";
392
+ readonly FORBIDDEN: "SCHEMA_FORBIDDEN";
230
393
  readonly SYNC_FAILED: "SCHEMA_SYNC_FAILED";
231
394
  readonly NOT_SYSTEM_OBJECT: "SCHEMA_NOT_SYSTEM_OBJECT";
232
395
  readonly DUPLICATE_OBJECT: "SCHEMA_DUPLICATE_OBJECT";
@@ -355,6 +518,33 @@ declare function isValidationError(error: unknown): error is ValidationError;
355
518
  * Check if an error is a ProtectedResourceError
356
519
  */
357
520
  declare function isProtectedResourceError(error: unknown): error is ProtectedResourceError;
521
+ /**
522
+ * Error thrown when a user lacks permission to perform an action
523
+ */
524
+ declare class ForbiddenError extends SchemaError {
525
+ readonly objectName: string;
526
+ readonly action: string;
527
+ readonly userId?: string;
528
+ constructor(objectName: string, action: string, userId?: string);
529
+ }
530
+ /**
531
+ * Error thrown when trying to modify a protected role
532
+ */
533
+ declare class ProtectedRoleError extends SchemaError {
534
+ readonly roleName: string;
535
+ readonly operation: "delete" | "modify";
536
+ constructor(roleName: string, operation: "delete" | "modify");
537
+ }
538
+ /**
539
+ * Role not found error
540
+ */
541
+ declare class RoleNotFoundError extends NotFoundError {
542
+ constructor(roleId: string);
543
+ }
544
+ /**
545
+ * Check if an error is a ForbiddenError
546
+ */
547
+ declare function isForbiddenError(error: unknown): error is ForbiddenError;
358
548
 
359
549
  /**
360
550
  * Builder config with literal name type preservation
@@ -614,7 +804,6 @@ interface RelationTargetOptions {
614
804
  */
615
805
  interface RelationBuilderInitOptions {
616
806
  targets?: RelationTarget[];
617
- onDelete?: RelationOnDelete;
618
807
  isRequired?: boolean;
619
808
  }
620
809
  /**
@@ -633,11 +822,6 @@ declare class SingleRelationAttributeBuilder<TName extends string, TRequired ext
633
822
  * @param options - Display template and filter options
634
823
  */
635
824
  to(objectName: string, options?: RelationTargetOptions): this;
636
- /**
637
- * Set the deletion strategy when target record is deleted
638
- * @param strategy - "restrict" (default), "cascade", or "set_null"
639
- */
640
- onDelete(strategy: RelationOnDelete): this;
641
825
  /**
642
826
  * Convert to a multi-relation (cardinality: "many")
643
827
  */
@@ -661,11 +845,6 @@ declare class MultiRelationAttributeBuilder<TName extends string, TRequired exte
661
845
  * @param options - Display template and filter options
662
846
  */
663
847
  to(objectName: string, options?: RelationTargetOptions): this;
664
- /**
665
- * Set the deletion strategy when target record is deleted
666
- * @param strategy - "restrict" (default), "cascade", or "set_null"
667
- */
668
- onDelete(strategy: RelationOnDelete): this;
669
848
  /**
670
849
  * Set minimum number of relations required
671
850
  */
@@ -701,7 +880,6 @@ declare class MultiRelationAttributeBuilder<TName extends string, TRequired exte
701
880
  * .to("companies")
702
881
  * .to("contacts")
703
882
  * .many()
704
- * .onDelete("cascade")
705
883
  * ```
706
884
  */
707
885
  declare function relation<TName extends string>(config: TypedBuilderConfig<TName>): SingleRelationAttributeBuilder<TName, false>;
@@ -739,6 +917,231 @@ type ExtractAttributeRequired<T> = T extends {
739
917
  };
740
918
  } ? R : false;
741
919
 
920
+ /**
921
+ * Builder for creating flow rows with fields
922
+ */
923
+ declare class FlowRowBuilder {
924
+ private pageBuilder;
925
+ private rowData;
926
+ /** @internal */
927
+ constructor(pageBuilder: FlowPageBuilder, id: string, order: number);
928
+ /**
929
+ * Add a field to the current row
930
+ *
931
+ * @param slotId - Reference to a slot defined with .slot()
932
+ * @param attribute - Attribute name on the object
933
+ * @param options - Optional field configuration
934
+ *
935
+ * @example
936
+ * ```typescript
937
+ * .row("row-1")
938
+ * .field("mr", "firstName")
939
+ * .field("mr", "lastName")
940
+ * ```
941
+ */
942
+ field(slotId: string, attribute: string, options?: {
943
+ label?: string;
944
+ required?: boolean;
945
+ }): this;
946
+ /**
947
+ * Start a new row on the same page
948
+ */
949
+ row(id: string): FlowRowBuilder;
950
+ /**
951
+ * Start a new page
952
+ */
953
+ page(id: string, label: string, description?: string): FlowPageBuilder;
954
+ /**
955
+ * Build the final flow definition
956
+ */
957
+ build(): FlowDefinition;
958
+ }
959
+ /**
960
+ * Builder for creating flow pages with rows
961
+ */
962
+ declare class FlowPageBuilder {
963
+ private flow;
964
+ private pageData;
965
+ private rowOrder;
966
+ /** @internal */
967
+ constructor(flow: FlowBuilder, id: string, label: string, description?: string);
968
+ /**
969
+ * Add a row to the current page
970
+ *
971
+ * @param id - Unique row identifier
972
+ *
973
+ * @example
974
+ * ```typescript
975
+ * .page("identity", "Identité")
976
+ * .row("name-row")
977
+ * .field("mr", "firstName")
978
+ * .field("mr", "lastName")
979
+ * .row("email-row")
980
+ * .field("mr", "email")
981
+ * ```
982
+ */
983
+ row(id: string): FlowRowBuilder;
984
+ /**
985
+ * Start a new page
986
+ */
987
+ page(id: string, label: string, description?: string): FlowPageBuilder;
988
+ /**
989
+ * Build the final flow definition
990
+ */
991
+ build(): FlowDefinition;
992
+ /** @internal */
993
+ _finalizeRow(row: FlowRow): this;
994
+ /** @internal */
995
+ _getFlow(): FlowBuilder;
996
+ /** @internal */
997
+ _getPageData(): FlowPage;
998
+ }
999
+ /**
1000
+ * Fluent builder for creating FlowDefinition with validation
1001
+ *
1002
+ * @example
1003
+ * ```typescript
1004
+ * const COUPLE_FLOW = flow("couple-creation", "Création Couple")
1005
+ * .description("Create a couple with company")
1006
+ * .slot("mr", "contacts", "Monsieur", { color: "blue" })
1007
+ * .slot("mme", "contacts", "Madame", { color: "pink" })
1008
+ * .slot("company", "companies", "Entreprise", { color: "green" })
1009
+ * .relation("mr", "company", "company")
1010
+ * .relation("mme", "company", "company")
1011
+ * .page("identity", "Identité")
1012
+ * .row("mr-name")
1013
+ * .field("mr", "firstName")
1014
+ * .field("mr", "lastName")
1015
+ * .row("mme-name")
1016
+ * .field("mme", "firstName")
1017
+ * .field("mme", "lastName")
1018
+ * .page("company", "Entreprise")
1019
+ * .row("company-name")
1020
+ * .field("company", "name")
1021
+ * .row("company-siret")
1022
+ * .field("company", "siret")
1023
+ * .build();
1024
+ * ```
1025
+ */
1026
+ declare class FlowBuilder {
1027
+ private data;
1028
+ constructor(name: string, label: string);
1029
+ /**
1030
+ * Set flow description
1031
+ */
1032
+ description(value: string): this;
1033
+ /**
1034
+ * Set flow icon
1035
+ */
1036
+ icon(value: IconName): this;
1037
+ /**
1038
+ * Set extensible metadata
1039
+ */
1040
+ metadata(value: Record<string, unknown>): this;
1041
+ /**
1042
+ * Add a slot (object to create in the flow)
1043
+ *
1044
+ * @param id - Unique slot identifier (used to reference in fields and relations)
1045
+ * @param objectName - Name of the object to create
1046
+ * @param label - Display label for the slot
1047
+ * @param options - Optional slot configuration
1048
+ *
1049
+ * @example
1050
+ * ```typescript
1051
+ * .slot("mr", "contacts", "Monsieur", { color: "blue", icon: "user" })
1052
+ * .slot("company", "companies", "Entreprise", { color: "green" })
1053
+ * ```
1054
+ */
1055
+ slot(id: string, objectName: string, label: string, options?: {
1056
+ color?: ColorId;
1057
+ icon?: IconName;
1058
+ }): this;
1059
+ /**
1060
+ * Define a relation between two slots
1061
+ * The source slot will be linked to the target slot via the specified attribute
1062
+ *
1063
+ * @param sourceSlotId - Slot that has the relation attribute
1064
+ * @param sourceAttribute - Relation attribute name on the source
1065
+ * @param targetSlotId - Target slot to link to
1066
+ *
1067
+ * @example
1068
+ * ```typescript
1069
+ * // mr.company → company (the contact's company field will be set to the created company)
1070
+ * .relation("mr", "company", "company")
1071
+ * ```
1072
+ */
1073
+ relation(sourceSlotId: string, sourceAttribute: string, targetSlotId: string): this;
1074
+ /**
1075
+ * Start a new page/step in the flow
1076
+ *
1077
+ * @param id - Unique page identifier
1078
+ * @param label - Display label
1079
+ * @param description - Optional description
1080
+ *
1081
+ * @example
1082
+ * ```typescript
1083
+ * .page("identity", "Identité", "Informations personnelles")
1084
+ * .row("name")
1085
+ * .field("mr", "firstName")
1086
+ * .field("mr", "lastName")
1087
+ * ```
1088
+ */
1089
+ page(id: string, label: string, description?: string): FlowPageBuilder;
1090
+ /**
1091
+ * Build and validate the flow definition
1092
+ *
1093
+ * @throws Error if validation fails
1094
+ */
1095
+ build(): FlowDefinition;
1096
+ /**
1097
+ * Validate that required data is present
1098
+ */
1099
+ private validateRequiredData;
1100
+ /**
1101
+ * Validate that all field slotId references exist
1102
+ */
1103
+ private validateFieldReferences;
1104
+ /**
1105
+ * Validate that all relation references exist and are valid
1106
+ */
1107
+ private validateRelationReferences;
1108
+ /**
1109
+ * @internal Used by FlowPageBuilder to finalize a page
1110
+ */
1111
+ _finalizePage(page: FlowPage): this;
1112
+ /**
1113
+ * Validate flow name format (kebab-case)
1114
+ */
1115
+ private validateName;
1116
+ /**
1117
+ * Validate that there are no circular dependencies in relations
1118
+ * Uses DFS to detect cycles in the dependency graph
1119
+ */
1120
+ private validateNoCircularDependencies;
1121
+ }
1122
+ /**
1123
+ * Create a new flow builder
1124
+ *
1125
+ * @param name - Flow name (kebab-case)
1126
+ * @param label - Display label
1127
+ *
1128
+ * @example
1129
+ * ```typescript
1130
+ * const COUPLE_FLOW = flow("couple-creation", "Création Couple")
1131
+ * .slot("mr", "contacts", "Monsieur")
1132
+ * .slot("mme", "contacts", "Madame")
1133
+ * .page("identity", "Identité")
1134
+ * .row("mr-name")
1135
+ * .field("mr", "firstName")
1136
+ * .field("mr", "lastName")
1137
+ * .row("mme-name")
1138
+ * .field("mme", "firstName")
1139
+ * .field("mme", "lastName")
1140
+ * .build();
1141
+ * ```
1142
+ */
1143
+ declare function flow(name: string, label: string): FlowBuilder;
1144
+
742
1145
  /**
743
1146
  * Extract attribute info from a builder instance
744
1147
  */
@@ -1219,4 +1622,4 @@ declare function view(name: string, label: string): ViewBuilder;
1219
1622
  */
1220
1623
  declare function group(id: string, label: string): GroupBuilder;
1221
1624
 
1222
- export { type AddAttribute$1 as AddAttribute, type AnyAttributeBuilder, Attribute, AttributeGroupField, type AttributeMap, AttributeNotFoundError, type AttributeSchema, type BuilderConfig, CheckboxAttribute, Currency, CurrencyAttribute, type CustomAttributeValue, CustomTabConfig, DateAttribute, DuplicateError, type ExtractAttributeName, type ExtractAttributeRequired, type ExtractAttributes, type ExtractRecord, type ExtractRecordInput, type ExtractRecordInputStrict, type ExtractRecordStrict, type ExtractRecordUpdate, type ExtractRecordUpdateStrict, Field, FileAttribute, FileNotFoundError, Group, GroupBuilder, type InferAttributeValue, type InferRecord, type InferRecordFromSchema, type InferRecordInput, type InferRecordUpdate, type InferRecordWithRequirements, Location, LocationAttribute, MultiRelationAttribute, MultiselectAttribute, NotFoundError, NotSystemObjectError, NumberAttribute, ObjectBuilder, ObjectDefinition, ObjectNotFoundError, Option, Phone, PhoneAttribute, ProtectedResourceError, RatingAttribute, RecordNotFoundError, RelationOnDelete, RelationTarget, SchemaError, SchemaErrorCode, SelectAttribute, SingleRelationAttribute, StatusAttribute, SyncError, Tab, TabBuilder, TableTabConfig, TextAreaAttribute, TextAttribute, TimestampAttribute, type TypedAttribute, type TypedBuilderConfig, UserAttribute, UserProfileNotFoundError, ValidationError, type ValidationErrorDetail, ViewBuilder, ViewDefinition, type WithCustomAttributes, checkbox, currency, date, file, group, isNotFoundError, isProtectedResourceError, isSchemaError, isValidationError, location, multiselect, number, object, phone, rating, relation, select, status, text, textarea, timestamp, user, view };
1625
+ export { ALL_SYSTEM_RESOURCES, type AddAttribute$1 as AddAttribute, type AnyAttributeBuilder, Attribute, AttributeGroupField, AttributeInUseError, type AttributeMap, AttributeNotFoundError, type AttributeSchema, type AttributeUsage, type BuilderConfig, CheckboxAttribute, Currency, CurrencyAttribute, type CustomAttributeValue, CustomTabConfig, DEFAULT_ROLES, DEFAULT_ROLE_DESCRIPTIONS, DEFAULT_ROLE_LABELS, DEFAULT_ROLE_PERMISSIONS, DateAttribute, type DefaultRoleName, type DefaultRolePermissionConfig, DuplicateError, type ExtractAttributeName, type ExtractAttributeRequired, type ExtractAttributes, type ExtractRecord, type ExtractRecordInput, type ExtractRecordInputStrict, type ExtractRecordStrict, type ExtractRecordUpdate, type ExtractRecordUpdateStrict, Field, FileAttribute, FileNotFoundError, FlowBuilder, FlowDefinition, FlowPage, FlowPageBuilder, FlowRow, FlowRowBuilder, ForbiddenError, Group, GroupBuilder, type InferAttributeValue, type InferRecord, type InferRecordFromSchema, type InferRecordInput, type InferRecordUpdate, type InferRecordWithRequirements, Location, LocationAttribute, MultiRelationAttribute, MultiselectAttribute, NotFoundError, NotSystemObjectError, NumberAttribute, ObjectAction, ObjectBuilder, ObjectDefinition, ObjectNotFoundError, ObjectReferencedError, Option, Phone, PhoneAttribute, ProtectedResourceError, ProtectedRoleError, RatingAttribute, RecordNotFoundError, type RecordReference, RecordReferencedError, RelationTarget, RoleNotFoundError, SYSTEM_RESOURCES, SYSTEM_RESOURCE_LABELS, SchemaError, SchemaErrorCode, SelectAttribute, SingleRelationAttribute, StatusAttribute, SyncError, SystemAction, SystemResource, Tab, TabBuilder, TableTabConfig, TextAreaAttribute, TextAttribute, TimestampAttribute, type TypedAttribute, type TypedBuilderConfig, UserAttribute, UserProfileNotFoundError, ValidationError, type ValidationErrorDetail, ViewBuilder, ViewDefinition, type WithCustomAttributes, checkbox, currency, date, file, flow, group, isDefaultRole, isForbiddenError, isNotFoundError, isProtectedResourceError, isSchemaError, isValidationError, location, multiselect, number, object, phone, rating, relation, select, status, text, textarea, timestamp, user, view };