@stndrds/schema 1.0.0-alpha.185 → 1.0.0-alpha.187

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 (55) hide show
  1. package/dist/{filters-qNc-JmQI.d.ts → filters-DVBn5tov.d.ts} +81 -39
  2. package/dist/{filters-DVbxM2W4.d.mts → filters-HDG4kLoo.d.mts} +81 -39
  3. package/dist/{helpers-g5uHrKfE.d.mts → helpers-BjuFhbQQ.d.mts} +2 -2
  4. package/dist/{helpers-D-_4FAcR.d.ts → helpers-CSuoa3kj.d.ts} +2 -2
  5. package/dist/index.d.mts +185 -56
  6. package/dist/index.d.ts +185 -56
  7. package/dist/index.js +229 -105
  8. package/dist/index.mjs +215 -99
  9. package/dist/{types-CQTltaH_.d.ts → types-Bdlhgrf7.d.ts} +1 -1
  10. package/dist/{types-BTrwWar6.d.mts → types-C5DittlR.d.mts} +1 -1
  11. package/dist/validation/all.d.mts +3 -3
  12. package/dist/validation/all.d.ts +3 -3
  13. package/dist/validation/all.js +8 -8
  14. package/dist/validation/all.mjs +2 -2
  15. package/dist/validation/complex/currency.d.mts +2 -2
  16. package/dist/validation/complex/currency.d.ts +2 -2
  17. package/dist/validation/complex/file.d.mts +2 -2
  18. package/dist/validation/complex/file.d.ts +2 -2
  19. package/dist/validation/complex/location.d.mts +2 -2
  20. package/dist/validation/complex/location.d.ts +2 -2
  21. package/dist/validation/complex/phone.d.mts +2 -2
  22. package/dist/validation/complex/phone.d.ts +2 -2
  23. package/dist/validation/complex/relation.d.mts +2 -2
  24. package/dist/validation/complex/relation.d.ts +2 -2
  25. package/dist/validation/complex/richtext.d.mts +2 -2
  26. package/dist/validation/complex/richtext.d.ts +2 -2
  27. package/dist/validation/complex/select.d.mts +2 -2
  28. package/dist/validation/complex/select.d.ts +2 -2
  29. package/dist/validation/complex/user.d.mts +2 -2
  30. package/dist/validation/complex/user.d.ts +2 -2
  31. package/dist/validation/computed/formula.d.mts +2 -2
  32. package/dist/validation/computed/formula.d.ts +2 -2
  33. package/dist/validation/computed/rollup.d.mts +2 -2
  34. package/dist/validation/computed/rollup.d.ts +2 -2
  35. package/dist/validation/config/index.d.mts +1 -1
  36. package/dist/validation/config/index.d.ts +1 -1
  37. package/dist/validation/core/index.d.mts +3 -3
  38. package/dist/validation/core/index.d.ts +3 -3
  39. package/dist/validation/object/index.d.mts +3 -3
  40. package/dist/validation/object/index.d.ts +3 -3
  41. package/dist/validation/object/index.js +14 -14
  42. package/dist/validation/object/index.mjs +2 -2
  43. package/dist/validation/primitives/checkbox.d.mts +2 -2
  44. package/dist/validation/primitives/checkbox.d.ts +2 -2
  45. package/dist/validation/primitives/date.d.mts +2 -2
  46. package/dist/validation/primitives/date.d.ts +2 -2
  47. package/dist/validation/primitives/number.d.mts +2 -2
  48. package/dist/validation/primitives/number.d.ts +2 -2
  49. package/dist/validation/primitives/rating.d.mts +2 -2
  50. package/dist/validation/primitives/rating.d.ts +2 -2
  51. package/dist/validation/primitives/text.d.mts +2 -2
  52. package/dist/validation/primitives/text.d.ts +2 -2
  53. package/package.json +2 -2
  54. package/dist/{chunk-HG6EF4XD.js → chunk-64R5X3DF.js} +1 -1
  55. package/dist/{chunk-M7ZNKBOE.mjs → chunk-6JEQE4IP.mjs} +1 -1
@@ -1,6 +1,32 @@
1
1
  import { IconName, CountryIso3, CurrencyCode, ColorId, MimeType } from '@stndrds/constants';
2
2
  import { Uuid } from './utils.js';
3
3
 
4
+ interface DocumentLayout {
5
+ /** Named sub-folders auto-created at the top of the record's drive when first used via attach --variant. */
6
+ variants?: Record<string, DocumentLayoutVariant>;
7
+ /** Dev-declared folder structures the user can instantiate via the UI inside a record's drive. */
8
+ presets?: FolderPreset[];
9
+ }
10
+ interface DocumentLayoutVariant {
11
+ /** Display title for the auto-created sub-folder. */
12
+ title: string;
13
+ description?: string;
14
+ }
15
+ interface FolderPreset {
16
+ id: string;
17
+ label: string;
18
+ icon?: IconName;
19
+ description?: string;
20
+ structure: PresetNode[];
21
+ }
22
+ interface PresetNode {
23
+ title: string;
24
+ description?: string;
25
+ children?: PresetNode[];
26
+ }
27
+ /** Max depth allowed for preset.structure to keep instantiation predictable. */
28
+ declare const MAX_PRESET_DEPTH = 5;
29
+
4
30
  /**
5
31
  * Type of view - determines the config structure
6
32
  */
@@ -422,7 +448,6 @@ declare function isFieldGroup(group: Group): group is FieldGroup;
422
448
  */
423
449
  declare function isRelationGroup(group: Group): group is RelationGroup;
424
450
 
425
- type TransformSource = "system" | "runtime" | "rollback" | "seed";
426
451
  type BuiltInTransform = "toString" | "toNumber" | "toDate" | "toBoolean" | "toISOString";
427
452
  type SchemaOperation = {
428
453
  type: "add_attribute";
@@ -472,19 +497,6 @@ type ViewOperation = {
472
497
  interface MigrationDefinition {
473
498
  version: number;
474
499
  operations: SchemaOperation[];
475
- reverse_operations: SchemaOperation[];
476
- }
477
- interface SchemaTransform {
478
- id: string;
479
- tenantId: string;
480
- objectId: string;
481
- fromVersion: number;
482
- toVersion: number;
483
- operations: SchemaOperation[];
484
- reverseOperations: SchemaOperation[];
485
- source: TransformSource;
486
- appliedAt: Date;
487
- fullyMigrated: boolean;
488
500
  }
489
501
  interface ViewTransform {
490
502
  id: string;
@@ -493,8 +505,6 @@ interface ViewTransform {
493
505
  fromVersion: number;
494
506
  toVersion: number;
495
507
  operations: ViewOperation[];
496
- reverseOperations: ViewOperation[];
497
- source: TransformSource;
498
508
  appliedAt: Date;
499
509
  }
500
510
  interface MigrationError {
@@ -552,6 +562,8 @@ interface ObjectDefinition {
552
562
  schema_version: number;
553
563
  /** Ordered list of migrations applied to this object's schema */
554
564
  migrations: MigrationDefinition[];
565
+ /** Smart-folder layout convention for documents attached to records of this object. */
566
+ documentLayout?: DocumentLayout;
555
567
  }
556
568
  /**
557
569
  * Links an attribute to an object
@@ -608,6 +620,11 @@ interface ObjectRecord extends Timestamps {
608
620
  * Queries exclude soft-deleted records by default.
609
621
  */
610
622
  deletedAt?: Date | null;
623
+ /**
624
+ * Actor ID who soft-deleted this record.
625
+ * Set alongside deletedAt when a record is soft-deleted.
626
+ */
627
+ deletedBy?: string | null;
611
628
  /**
612
629
  * Actor ID who created this record.
613
630
  * Automatically set by RecordService when actorId is configured.
@@ -622,11 +639,6 @@ interface ObjectRecord extends Timestamps {
622
639
  lastUpdatedBy?: string;
623
640
  /** Schema version at the time this record was last migrated */
624
641
  schemaVersion: number;
625
- /**
626
- * Values archived during attribute removal or type changes.
627
- * Retained according to the retention policy before permanent deletion.
628
- */
629
- archivedValues?: Record<string, unknown>;
630
642
  }
631
643
  /**
632
644
  * System-managed field names on ObjectRecord.
@@ -664,20 +676,34 @@ type SystemFieldName = (typeof SYSTEM_FIELD_NAMES)[number];
664
676
  * }
665
677
  * ```
666
678
  */
667
- declare const RESERVED_ATTRIBUTE_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy", "objectId", "label", "completionStatus", "values", "metadata", "deletedAt", "schemaVersion", "archivedValues"];
679
+ declare const RESERVED_ATTRIBUTE_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy", "objectId", "label", "completionStatus", "values", "metadata", "deletedAt", "deletedBy", "schemaVersion"];
668
680
  /**
669
681
  * Type for reserved attribute names
670
682
  */
671
683
  type ReservedAttributeName = (typeof RESERVED_ATTRIBUTE_NAMES)[number];
672
684
 
685
+ type DocumentKind = "file" | "folder";
673
686
  interface Document extends Timestamps {
674
687
  id: Uuid;
675
688
  tenantId: Uuid;
676
689
  title: string;
690
+ kind: DocumentKind;
691
+ parentId?: Uuid | null;
692
+ description?: string;
677
693
  contentHash?: string;
678
694
  createdBy?: Uuid;
679
695
  updatedBy?: Uuid;
680
696
  deletedAt?: Date | null;
697
+ /**
698
+ * Fractional ordering position within `(tenantId, parentId)`. Lower values
699
+ * sort first. New rows default to `max(siblings) + 1024` so reorderings can
700
+ * insert between neighbours without renumbering. The server may rebalance
701
+ * positions in the background to keep the spacing bounded.
702
+ */
703
+ position: number;
704
+ }
705
+ interface DocumentWithSubCount extends Document {
706
+ subCount: number | null;
681
707
  }
682
708
  /**
683
709
  * Configuration for a single named slot on a DocumentAttribute.
@@ -732,9 +758,34 @@ type ProcessingJobType = "ocr";
732
758
  type ProcessingJobStatus = "pending" | "processing" | "completed" | "failed" | "cancelled";
733
759
  interface CreateDocument {
734
760
  title: string;
761
+ kind?: DocumentKind;
762
+ parentId?: Uuid | null;
763
+ description?: string;
764
+ position?: number;
765
+ }
766
+ /**
767
+ * Reference to a record attribute that should atomically attach a freshly
768
+ * created Document. Passed alongside `CreateDocument` to make creation
769
+ * link-aware end-to-end (client → REST → service → repo).
770
+ *
771
+ * The server requires this — orphan Documents are not creatable through the
772
+ * REST API.
773
+ */
774
+ interface CreateDocumentLink {
775
+ objectName: string;
776
+ sourceRecordId: string;
777
+ attributeName: string;
778
+ /**
779
+ * Optional qualifyWith properties on the record→Document edge. Currently
780
+ * accepted by the controller DTO but silently ignored by the service (see
781
+ * `DocumentService.createDocument` — there's a TODO to support this).
782
+ */
783
+ properties?: Record<string, unknown>;
735
784
  }
736
785
  interface UpdateDocument {
737
786
  title?: string;
787
+ parentId?: Uuid | null;
788
+ position?: number;
738
789
  }
739
790
  interface CreateDocumentSlot {
740
791
  documentId: Uuid;
@@ -1395,30 +1446,21 @@ interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "r
1395
1446
  * provides structured document handling with multi-file support and
1396
1447
  * optional agent-compatible processing (for example OCR).
1397
1448
  *
1398
- * @example Single document
1399
- * ```typescript
1400
- * document({ name: "identityDocument", label: "Pièce d'identité" })
1401
- * .autoProcess()
1402
- * .required()
1403
- * ```
1449
+ * Every document attribute is multi by construction — the underlying
1450
+ * storage (documents + document_slots + files) supports 1 Doc → N slot
1451
+ * files uniformly. Single-value file fields use `file()` instead.
1404
1452
  *
1405
- * @example Multiple documents
1453
+ * @example
1406
1454
  * ```typescript
1407
1455
  * document({ name: "contracts", label: "Contrats" })
1408
- * .multiple()
1456
+ * .autoProcess()
1409
1457
  * .maxDocuments(10)
1410
1458
  * ```
1411
1459
  */
1412
- interface DocumentAttribute extends BaseAttribute<string | string[]> {
1460
+ interface DocumentAttribute extends BaseAttribute<string[]> {
1413
1461
  type: "document";
1414
1462
  /**
1415
- * Allow multiple documents.
1416
- * If true, value is string[] (document IDs).
1417
- * If false/undefined, value is string (single document ID).
1418
- */
1419
- multiple?: boolean;
1420
- /**
1421
- * Maximum number of documents when multiple: true.
1463
+ * Maximum number of documents.
1422
1464
  */
1423
1465
  maxDocuments?: number;
1424
1466
  /**
@@ -1585,4 +1627,4 @@ declare function isNoValueOperator(operator: FilterOperator): operator is NoValu
1585
1627
  */
1586
1628
  declare function getRollupFilterOperators(attr: RollupAttribute): readonly FilterOperator[];
1587
1629
 
1588
- export { type Group as $, type Attribute as A, type BilateralConfig as B, type CurrencyAttribute as C, type DateAttribute as D, type RelationTarget as E, type FileAttribute as F, type RichtextFeature as G, type RollupFunction as H, type MigrationDefinition as I, type DetailViewConfig as J, type DetailViewDefinition as K, type LocationAttribute as L, type MultiRelationAttribute as M, type NumberAttribute as N, type ObjectDefinition as O, type PhoneAttribute as P, type DetailViewLayout as Q, type RelationAttribute as R, type SingleRelationAttribute as S, type TextAreaAttribute as T, type UserAttribute as U, type ViewType as V, type SidePanelConfig as W, type Field as X, type AttributeGroupField as Y, type FieldGroup as Z, type RelationGroup as _, type RichtextAttribute as a, type RelativeDateValue as a$, type TableTab as a0, type CreateMode as a1, type Tab as a2, type ListViewConfig as a3, type ListViewDefinition as a4, type FlagValueType as a5, type FeatureFlagDefinition as a6, type FlagLevel as a7, type FeatureFlagsRepository as a8, type StaticFlagDefault as a9, type FilterCombinator as aA, type FilterGroup as aB, type FlagOverride as aC, type FormDensity as aD, type FormTab as aE, type FormsTab as aF, type InverseSource as aG, type ListViewLayout as aH, type MigrationError as aI, NO_VALUE_OPERATORS as aJ, type NoValueOperator as aK, type NumberUnit as aL, OPERATORS_BY_TYPE as aM, type ObjectAttribute as aN, type ObjectRecord as aO, type OptionPropertyAttribute as aP, type PhoneFilterValue as aQ, type ProcessingJob as aR, type ProcessingJobStatus as aS, type ProcessingJobType as aT, type PropertyAttribute as aU, type PropertyType as aV, type QueryState as aW, RELATION_TARGET_ANY as aX, RESERVED_ATTRIBUTE_NAMES as aY, type RecordDocuments as aZ, type RelationSource as a_, type ResolvedFlag as aa, type ViewDefinition as ab, type ListViewTab as ac, type FilterOperator as ad, type FilterValue as ae, type FilterRule as af, type ActivityTab as ag, type AdvancedFilterState as ah, type AttributeGroup as ai, type BaseAttribute as aj, type BuiltInTransform as ak, type CreateDocument as al, type CreateDocumentSlot as am, type CreateProcessingJob as an, type CurrencyFilterValue as ao, type CustomTab as ap, DEFAULT_DOCUMENT_SLOT as aq, type DateFormat as ar, type DateValue as as, type Document as at, type DocumentListOptions as au, type DocumentSlot as av, type DocumentWithSlots as aw, type DocumentsTab as ax, type ExtendedFilterRule as ay, type FeatureFlagsConfig as az, type MultiselectAttribute as b, type ReservedAttributeName as b0, type RichtextTab as b1, SYSTEM_FIELD_NAMES as b2, type SchemaOperation as b3, type SchemaTransform as b4, type SlotStatus as b5, type SortDirection as b6, type StatusGroup as b7, type SystemFieldName as b8, type TabType as b9, type TableSource as ba, type TransformSource as bb, type UpdateDocument as bc, type UpdateDocumentSlot as bd, type UpdateProcessingJob as be, type ViewOperation as bf, type ViewOverlay as bg, type ViewTransform as bh, getRollupFilterOperators as bi, hasOptions as bj, inferInverseCardinality as bk, isAttributeSortable as bl, isBilateralRelation as bm, isDetailView as bn, isFieldGroup as bo, isListView as bp, isNoValueOperator as bq, isRelationGroup as br, isUniversalRelation as bs, type SelectAttribute as c, type StatusAttribute as d, type FormulaAttribute as e, type RollupAttribute as f, type CheckboxAttribute as g, type RatingAttribute as h, type TextAttribute as i, type CompletionStatus as j, type SortRule as k, type FilterState as l, type Timestamps as m, type AttributeType as n, type ViewConfig as o, type ConfigOverrides as p, type LocationGranularity as q, type Location as r, type DocumentAttribute as s, type Phone as t, type Currency as u, type DocumentSlotConfig as v, type PropertySchema as w, type FeatureGate as x, type Option as y, type FormulaReturnType as z };
1630
+ export { type FieldGroup as $, type Attribute as A, type Option as B, type CurrencyAttribute as C, type DateAttribute as D, type FormulaReturnType as E, type FileAttribute as F, type BilateralConfig as G, type RelationTarget as H, type RichtextFeature as I, type RollupFunction as J, type MigrationDefinition as K, type LocationAttribute as L, type MultiRelationAttribute as M, type NumberAttribute as N, type ObjectDefinition as O, type PhoneAttribute as P, type DetailViewConfig as Q, type RelationAttribute as R, type SingleRelationAttribute as S, type TextAreaAttribute as T, type UserAttribute as U, type ViewType as V, type DetailViewDefinition as W, type DetailViewLayout as X, type SidePanelConfig as Y, type Field as Z, type AttributeGroupField as _, type RichtextAttribute as a, type ProcessingJobStatus as a$, type RelationGroup as a0, type Group as a1, type TableTab as a2, type CreateMode as a3, type Tab as a4, type ListViewConfig as a5, type ListViewDefinition as a6, type FlagValueType as a7, type FeatureFlagDefinition as a8, type FlagLevel as a9, type DocumentSlot as aA, type DocumentWithSlots as aB, type DocumentWithSubCount as aC, type DocumentsTab as aD, type ExtendedFilterRule as aE, type FeatureFlagsConfig as aF, type FilterCombinator as aG, type FilterGroup as aH, type FlagOverride as aI, type FolderPreset as aJ, type FormDensity as aK, type FormTab as aL, type FormsTab as aM, type InverseSource as aN, type ListViewLayout as aO, MAX_PRESET_DEPTH as aP, type MigrationError as aQ, NO_VALUE_OPERATORS as aR, type NoValueOperator as aS, type NumberUnit as aT, OPERATORS_BY_TYPE as aU, type ObjectAttribute as aV, type ObjectRecord as aW, type OptionPropertyAttribute as aX, type PhoneFilterValue as aY, type PresetNode as aZ, type ProcessingJob as a_, type FeatureFlagsRepository as aa, type StaticFlagDefault as ab, type ResolvedFlag as ac, type ViewDefinition as ad, type ListViewTab as ae, type FilterOperator as af, type FilterValue as ag, type FilterRule as ah, type ActivityTab as ai, type AdvancedFilterState as aj, type AttributeGroup as ak, type BaseAttribute as al, type BuiltInTransform as am, type CreateDocument as an, type CreateDocumentLink as ao, type CreateDocumentSlot as ap, type CreateProcessingJob as aq, type CurrencyFilterValue as ar, type CustomTab as as, DEFAULT_DOCUMENT_SLOT as at, type DateFormat as au, type DateValue as av, type Document as aw, type DocumentKind as ax, type DocumentLayoutVariant as ay, type DocumentListOptions as az, type MultiselectAttribute as b, type ProcessingJobType as b0, type PropertyAttribute as b1, type PropertyType as b2, type QueryState as b3, RELATION_TARGET_ANY as b4, RESERVED_ATTRIBUTE_NAMES as b5, type RecordDocuments as b6, type RelationSource as b7, type RelativeDateValue as b8, type ReservedAttributeName as b9, type RichtextTab as ba, SYSTEM_FIELD_NAMES as bb, type SlotStatus as bc, type SortDirection as bd, type StatusGroup as be, type SystemFieldName as bf, type TabType as bg, type TableSource as bh, type UpdateDocument as bi, type UpdateDocumentSlot as bj, type UpdateProcessingJob as bk, type ViewOperation as bl, type ViewOverlay as bm, type ViewTransform as bn, getRollupFilterOperators as bo, hasOptions as bp, inferInverseCardinality as bq, isAttributeSortable as br, isBilateralRelation as bs, isDetailView as bt, isFieldGroup as bu, isListView as bv, isNoValueOperator as bw, isRelationGroup as bx, isUniversalRelation as by, type SelectAttribute as c, type StatusAttribute as d, type FormulaAttribute as e, type RollupAttribute as f, type CheckboxAttribute as g, type RatingAttribute as h, type TextAttribute as i, type CompletionStatus as j, type SortRule as k, type FilterState as l, type Timestamps as m, type AttributeType as n, type DocumentLayout as o, type ViewConfig as p, type ConfigOverrides as q, type SchemaOperation as r, type LocationGranularity as s, type Location as t, type DocumentAttribute as u, type Phone as v, type Currency as w, type DocumentSlotConfig as x, type PropertySchema as y, type FeatureGate as z };
@@ -1,6 +1,32 @@
1
1
  import { IconName, CountryIso3, CurrencyCode, ColorId, MimeType } from '@stndrds/constants';
2
2
  import { Uuid } from './utils.mjs';
3
3
 
4
+ interface DocumentLayout {
5
+ /** Named sub-folders auto-created at the top of the record's drive when first used via attach --variant. */
6
+ variants?: Record<string, DocumentLayoutVariant>;
7
+ /** Dev-declared folder structures the user can instantiate via the UI inside a record's drive. */
8
+ presets?: FolderPreset[];
9
+ }
10
+ interface DocumentLayoutVariant {
11
+ /** Display title for the auto-created sub-folder. */
12
+ title: string;
13
+ description?: string;
14
+ }
15
+ interface FolderPreset {
16
+ id: string;
17
+ label: string;
18
+ icon?: IconName;
19
+ description?: string;
20
+ structure: PresetNode[];
21
+ }
22
+ interface PresetNode {
23
+ title: string;
24
+ description?: string;
25
+ children?: PresetNode[];
26
+ }
27
+ /** Max depth allowed for preset.structure to keep instantiation predictable. */
28
+ declare const MAX_PRESET_DEPTH = 5;
29
+
4
30
  /**
5
31
  * Type of view - determines the config structure
6
32
  */
@@ -422,7 +448,6 @@ declare function isFieldGroup(group: Group): group is FieldGroup;
422
448
  */
423
449
  declare function isRelationGroup(group: Group): group is RelationGroup;
424
450
 
425
- type TransformSource = "system" | "runtime" | "rollback" | "seed";
426
451
  type BuiltInTransform = "toString" | "toNumber" | "toDate" | "toBoolean" | "toISOString";
427
452
  type SchemaOperation = {
428
453
  type: "add_attribute";
@@ -472,19 +497,6 @@ type ViewOperation = {
472
497
  interface MigrationDefinition {
473
498
  version: number;
474
499
  operations: SchemaOperation[];
475
- reverse_operations: SchemaOperation[];
476
- }
477
- interface SchemaTransform {
478
- id: string;
479
- tenantId: string;
480
- objectId: string;
481
- fromVersion: number;
482
- toVersion: number;
483
- operations: SchemaOperation[];
484
- reverseOperations: SchemaOperation[];
485
- source: TransformSource;
486
- appliedAt: Date;
487
- fullyMigrated: boolean;
488
500
  }
489
501
  interface ViewTransform {
490
502
  id: string;
@@ -493,8 +505,6 @@ interface ViewTransform {
493
505
  fromVersion: number;
494
506
  toVersion: number;
495
507
  operations: ViewOperation[];
496
- reverseOperations: ViewOperation[];
497
- source: TransformSource;
498
508
  appliedAt: Date;
499
509
  }
500
510
  interface MigrationError {
@@ -552,6 +562,8 @@ interface ObjectDefinition {
552
562
  schema_version: number;
553
563
  /** Ordered list of migrations applied to this object's schema */
554
564
  migrations: MigrationDefinition[];
565
+ /** Smart-folder layout convention for documents attached to records of this object. */
566
+ documentLayout?: DocumentLayout;
555
567
  }
556
568
  /**
557
569
  * Links an attribute to an object
@@ -608,6 +620,11 @@ interface ObjectRecord extends Timestamps {
608
620
  * Queries exclude soft-deleted records by default.
609
621
  */
610
622
  deletedAt?: Date | null;
623
+ /**
624
+ * Actor ID who soft-deleted this record.
625
+ * Set alongside deletedAt when a record is soft-deleted.
626
+ */
627
+ deletedBy?: string | null;
611
628
  /**
612
629
  * Actor ID who created this record.
613
630
  * Automatically set by RecordService when actorId is configured.
@@ -622,11 +639,6 @@ interface ObjectRecord extends Timestamps {
622
639
  lastUpdatedBy?: string;
623
640
  /** Schema version at the time this record was last migrated */
624
641
  schemaVersion: number;
625
- /**
626
- * Values archived during attribute removal or type changes.
627
- * Retained according to the retention policy before permanent deletion.
628
- */
629
- archivedValues?: Record<string, unknown>;
630
642
  }
631
643
  /**
632
644
  * System-managed field names on ObjectRecord.
@@ -664,20 +676,34 @@ type SystemFieldName = (typeof SYSTEM_FIELD_NAMES)[number];
664
676
  * }
665
677
  * ```
666
678
  */
667
- declare const RESERVED_ATTRIBUTE_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy", "objectId", "label", "completionStatus", "values", "metadata", "deletedAt", "schemaVersion", "archivedValues"];
679
+ declare const RESERVED_ATTRIBUTE_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy", "objectId", "label", "completionStatus", "values", "metadata", "deletedAt", "deletedBy", "schemaVersion"];
668
680
  /**
669
681
  * Type for reserved attribute names
670
682
  */
671
683
  type ReservedAttributeName = (typeof RESERVED_ATTRIBUTE_NAMES)[number];
672
684
 
685
+ type DocumentKind = "file" | "folder";
673
686
  interface Document extends Timestamps {
674
687
  id: Uuid;
675
688
  tenantId: Uuid;
676
689
  title: string;
690
+ kind: DocumentKind;
691
+ parentId?: Uuid | null;
692
+ description?: string;
677
693
  contentHash?: string;
678
694
  createdBy?: Uuid;
679
695
  updatedBy?: Uuid;
680
696
  deletedAt?: Date | null;
697
+ /**
698
+ * Fractional ordering position within `(tenantId, parentId)`. Lower values
699
+ * sort first. New rows default to `max(siblings) + 1024` so reorderings can
700
+ * insert between neighbours without renumbering. The server may rebalance
701
+ * positions in the background to keep the spacing bounded.
702
+ */
703
+ position: number;
704
+ }
705
+ interface DocumentWithSubCount extends Document {
706
+ subCount: number | null;
681
707
  }
682
708
  /**
683
709
  * Configuration for a single named slot on a DocumentAttribute.
@@ -732,9 +758,34 @@ type ProcessingJobType = "ocr";
732
758
  type ProcessingJobStatus = "pending" | "processing" | "completed" | "failed" | "cancelled";
733
759
  interface CreateDocument {
734
760
  title: string;
761
+ kind?: DocumentKind;
762
+ parentId?: Uuid | null;
763
+ description?: string;
764
+ position?: number;
765
+ }
766
+ /**
767
+ * Reference to a record attribute that should atomically attach a freshly
768
+ * created Document. Passed alongside `CreateDocument` to make creation
769
+ * link-aware end-to-end (client → REST → service → repo).
770
+ *
771
+ * The server requires this — orphan Documents are not creatable through the
772
+ * REST API.
773
+ */
774
+ interface CreateDocumentLink {
775
+ objectName: string;
776
+ sourceRecordId: string;
777
+ attributeName: string;
778
+ /**
779
+ * Optional qualifyWith properties on the record→Document edge. Currently
780
+ * accepted by the controller DTO but silently ignored by the service (see
781
+ * `DocumentService.createDocument` — there's a TODO to support this).
782
+ */
783
+ properties?: Record<string, unknown>;
735
784
  }
736
785
  interface UpdateDocument {
737
786
  title?: string;
787
+ parentId?: Uuid | null;
788
+ position?: number;
738
789
  }
739
790
  interface CreateDocumentSlot {
740
791
  documentId: Uuid;
@@ -1395,30 +1446,21 @@ interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "r
1395
1446
  * provides structured document handling with multi-file support and
1396
1447
  * optional agent-compatible processing (for example OCR).
1397
1448
  *
1398
- * @example Single document
1399
- * ```typescript
1400
- * document({ name: "identityDocument", label: "Pièce d'identité" })
1401
- * .autoProcess()
1402
- * .required()
1403
- * ```
1449
+ * Every document attribute is multi by construction — the underlying
1450
+ * storage (documents + document_slots + files) supports 1 Doc → N slot
1451
+ * files uniformly. Single-value file fields use `file()` instead.
1404
1452
  *
1405
- * @example Multiple documents
1453
+ * @example
1406
1454
  * ```typescript
1407
1455
  * document({ name: "contracts", label: "Contrats" })
1408
- * .multiple()
1456
+ * .autoProcess()
1409
1457
  * .maxDocuments(10)
1410
1458
  * ```
1411
1459
  */
1412
- interface DocumentAttribute extends BaseAttribute<string | string[]> {
1460
+ interface DocumentAttribute extends BaseAttribute<string[]> {
1413
1461
  type: "document";
1414
1462
  /**
1415
- * Allow multiple documents.
1416
- * If true, value is string[] (document IDs).
1417
- * If false/undefined, value is string (single document ID).
1418
- */
1419
- multiple?: boolean;
1420
- /**
1421
- * Maximum number of documents when multiple: true.
1463
+ * Maximum number of documents.
1422
1464
  */
1423
1465
  maxDocuments?: number;
1424
1466
  /**
@@ -1585,4 +1627,4 @@ declare function isNoValueOperator(operator: FilterOperator): operator is NoValu
1585
1627
  */
1586
1628
  declare function getRollupFilterOperators(attr: RollupAttribute): readonly FilterOperator[];
1587
1629
 
1588
- export { type Group as $, type Attribute as A, type BilateralConfig as B, type CurrencyAttribute as C, type DateAttribute as D, type RelationTarget as E, type FileAttribute as F, type RichtextFeature as G, type RollupFunction as H, type MigrationDefinition as I, type DetailViewConfig as J, type DetailViewDefinition as K, type LocationAttribute as L, type MultiRelationAttribute as M, type NumberAttribute as N, type ObjectDefinition as O, type PhoneAttribute as P, type DetailViewLayout as Q, type RelationAttribute as R, type SingleRelationAttribute as S, type TextAreaAttribute as T, type UserAttribute as U, type ViewType as V, type SidePanelConfig as W, type Field as X, type AttributeGroupField as Y, type FieldGroup as Z, type RelationGroup as _, type RichtextAttribute as a, type RelativeDateValue as a$, type TableTab as a0, type CreateMode as a1, type Tab as a2, type ListViewConfig as a3, type ListViewDefinition as a4, type FlagValueType as a5, type FeatureFlagDefinition as a6, type FlagLevel as a7, type FeatureFlagsRepository as a8, type StaticFlagDefault as a9, type FilterCombinator as aA, type FilterGroup as aB, type FlagOverride as aC, type FormDensity as aD, type FormTab as aE, type FormsTab as aF, type InverseSource as aG, type ListViewLayout as aH, type MigrationError as aI, NO_VALUE_OPERATORS as aJ, type NoValueOperator as aK, type NumberUnit as aL, OPERATORS_BY_TYPE as aM, type ObjectAttribute as aN, type ObjectRecord as aO, type OptionPropertyAttribute as aP, type PhoneFilterValue as aQ, type ProcessingJob as aR, type ProcessingJobStatus as aS, type ProcessingJobType as aT, type PropertyAttribute as aU, type PropertyType as aV, type QueryState as aW, RELATION_TARGET_ANY as aX, RESERVED_ATTRIBUTE_NAMES as aY, type RecordDocuments as aZ, type RelationSource as a_, type ResolvedFlag as aa, type ViewDefinition as ab, type ListViewTab as ac, type FilterOperator as ad, type FilterValue as ae, type FilterRule as af, type ActivityTab as ag, type AdvancedFilterState as ah, type AttributeGroup as ai, type BaseAttribute as aj, type BuiltInTransform as ak, type CreateDocument as al, type CreateDocumentSlot as am, type CreateProcessingJob as an, type CurrencyFilterValue as ao, type CustomTab as ap, DEFAULT_DOCUMENT_SLOT as aq, type DateFormat as ar, type DateValue as as, type Document as at, type DocumentListOptions as au, type DocumentSlot as av, type DocumentWithSlots as aw, type DocumentsTab as ax, type ExtendedFilterRule as ay, type FeatureFlagsConfig as az, type MultiselectAttribute as b, type ReservedAttributeName as b0, type RichtextTab as b1, SYSTEM_FIELD_NAMES as b2, type SchemaOperation as b3, type SchemaTransform as b4, type SlotStatus as b5, type SortDirection as b6, type StatusGroup as b7, type SystemFieldName as b8, type TabType as b9, type TableSource as ba, type TransformSource as bb, type UpdateDocument as bc, type UpdateDocumentSlot as bd, type UpdateProcessingJob as be, type ViewOperation as bf, type ViewOverlay as bg, type ViewTransform as bh, getRollupFilterOperators as bi, hasOptions as bj, inferInverseCardinality as bk, isAttributeSortable as bl, isBilateralRelation as bm, isDetailView as bn, isFieldGroup as bo, isListView as bp, isNoValueOperator as bq, isRelationGroup as br, isUniversalRelation as bs, type SelectAttribute as c, type StatusAttribute as d, type FormulaAttribute as e, type RollupAttribute as f, type CheckboxAttribute as g, type RatingAttribute as h, type TextAttribute as i, type CompletionStatus as j, type SortRule as k, type FilterState as l, type Timestamps as m, type AttributeType as n, type ViewConfig as o, type ConfigOverrides as p, type LocationGranularity as q, type Location as r, type DocumentAttribute as s, type Phone as t, type Currency as u, type DocumentSlotConfig as v, type PropertySchema as w, type FeatureGate as x, type Option as y, type FormulaReturnType as z };
1630
+ export { type FieldGroup as $, type Attribute as A, type Option as B, type CurrencyAttribute as C, type DateAttribute as D, type FormulaReturnType as E, type FileAttribute as F, type BilateralConfig as G, type RelationTarget as H, type RichtextFeature as I, type RollupFunction as J, type MigrationDefinition as K, type LocationAttribute as L, type MultiRelationAttribute as M, type NumberAttribute as N, type ObjectDefinition as O, type PhoneAttribute as P, type DetailViewConfig as Q, type RelationAttribute as R, type SingleRelationAttribute as S, type TextAreaAttribute as T, type UserAttribute as U, type ViewType as V, type DetailViewDefinition as W, type DetailViewLayout as X, type SidePanelConfig as Y, type Field as Z, type AttributeGroupField as _, type RichtextAttribute as a, type ProcessingJobStatus as a$, type RelationGroup as a0, type Group as a1, type TableTab as a2, type CreateMode as a3, type Tab as a4, type ListViewConfig as a5, type ListViewDefinition as a6, type FlagValueType as a7, type FeatureFlagDefinition as a8, type FlagLevel as a9, type DocumentSlot as aA, type DocumentWithSlots as aB, type DocumentWithSubCount as aC, type DocumentsTab as aD, type ExtendedFilterRule as aE, type FeatureFlagsConfig as aF, type FilterCombinator as aG, type FilterGroup as aH, type FlagOverride as aI, type FolderPreset as aJ, type FormDensity as aK, type FormTab as aL, type FormsTab as aM, type InverseSource as aN, type ListViewLayout as aO, MAX_PRESET_DEPTH as aP, type MigrationError as aQ, NO_VALUE_OPERATORS as aR, type NoValueOperator as aS, type NumberUnit as aT, OPERATORS_BY_TYPE as aU, type ObjectAttribute as aV, type ObjectRecord as aW, type OptionPropertyAttribute as aX, type PhoneFilterValue as aY, type PresetNode as aZ, type ProcessingJob as a_, type FeatureFlagsRepository as aa, type StaticFlagDefault as ab, type ResolvedFlag as ac, type ViewDefinition as ad, type ListViewTab as ae, type FilterOperator as af, type FilterValue as ag, type FilterRule as ah, type ActivityTab as ai, type AdvancedFilterState as aj, type AttributeGroup as ak, type BaseAttribute as al, type BuiltInTransform as am, type CreateDocument as an, type CreateDocumentLink as ao, type CreateDocumentSlot as ap, type CreateProcessingJob as aq, type CurrencyFilterValue as ar, type CustomTab as as, DEFAULT_DOCUMENT_SLOT as at, type DateFormat as au, type DateValue as av, type Document as aw, type DocumentKind as ax, type DocumentLayoutVariant as ay, type DocumentListOptions as az, type MultiselectAttribute as b, type ProcessingJobType as b0, type PropertyAttribute as b1, type PropertyType as b2, type QueryState as b3, RELATION_TARGET_ANY as b4, RESERVED_ATTRIBUTE_NAMES as b5, type RecordDocuments as b6, type RelationSource as b7, type RelativeDateValue as b8, type ReservedAttributeName as b9, type RichtextTab as ba, SYSTEM_FIELD_NAMES as bb, type SlotStatus as bc, type SortDirection as bd, type StatusGroup as be, type SystemFieldName as bf, type TabType as bg, type TableSource as bh, type UpdateDocument as bi, type UpdateDocumentSlot as bj, type UpdateProcessingJob as bk, type ViewOperation as bl, type ViewOverlay as bm, type ViewTransform as bn, getRollupFilterOperators as bo, hasOptions as bp, inferInverseCardinality as bq, isAttributeSortable as br, isBilateralRelation as bs, isDetailView as bt, isFieldGroup as bu, isListView as bv, isNoValueOperator as bw, isRelationGroup as bx, isUniversalRelation as by, type SelectAttribute as c, type StatusAttribute as d, type FormulaAttribute as e, type RollupAttribute as f, type CheckboxAttribute as g, type RatingAttribute as h, type TextAttribute as i, type CompletionStatus as j, type SortRule as k, type FilterState as l, type Timestamps as m, type AttributeType as n, type DocumentLayout as o, type ViewConfig as p, type ConfigOverrides as q, type SchemaOperation as r, type LocationGranularity as s, type Location as t, type DocumentAttribute as u, type Phone as v, type Currency as w, type DocumentSlotConfig as x, type PropertySchema as y, type FeatureGate as z };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { A as Attribute, O as ObjectDefinition, j as CompletionStatus } from './filters-DVbxM2W4.mjs';
3
- import { V as ValidationMessages, a as ValidationResult } from './types-BTrwWar6.mjs';
2
+ import { A as Attribute, O as ObjectDefinition, j as CompletionStatus } from './filters-HDG4kLoo.mjs';
3
+ import { V as ValidationMessages, a as ValidationResult } from './types-C5DittlR.mjs';
4
4
 
5
5
  /**
6
6
  * Create a Zod schema for any attribute type.
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { A as Attribute, O as ObjectDefinition, j as CompletionStatus } from './filters-qNc-JmQI.js';
3
- import { V as ValidationMessages, a as ValidationResult } from './types-CQTltaH_.js';
2
+ import { A as Attribute, O as ObjectDefinition, j as CompletionStatus } from './filters-DVBn5tov.js';
3
+ import { V as ValidationMessages, a as ValidationResult } from './types-Bdlhgrf7.js';
4
4
 
5
5
  /**
6
6
  * Create a Zod schema for any attribute type.