@contrail/documents 1.15.0-alpha.ba306dc → 1.15.0-alpha.c7091a8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,7 +10,7 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10
10
  ### Added
11
11
 
12
12
  - `sortElementsByArrayOrder(elements, sortOrder)` and `assignSortIndexes(orderedElements)` — the two ordering transforms that convert, restore and the document read path had each grown their own copy of. `sortElementsByArrayOrder` puts elements missing from the array last, keeping their relative order.
13
- - `SORT_MODE` — the named constants for `DocumentSortMode`, alongside the existing `DOCUMENT_SORT_MODES` tuple.
13
+ - `SORT_MODE` — the named constants for `DocumentSortMode`. `DocumentSortMode` and `DOCUMENT_SORT_MODES` are now derived from it, so the mode values are declared in exactly one place. `DOCUMENT_SORT_MODES` is now `readonly DocumentSortMode[]` rather than a literal tuple; it stays exported because it is the runtime list behind the entity's `@IsIn` validation.
14
14
 
15
15
  ## [1.14.0] - 2026-07-29
16
16
 
@@ -1,3 +1,6 @@
1
- import { DocumentElement } from './types';
2
- export declare function sortElementsByArrayOrder<T extends DocumentElement>(elements: T[], sortOrder?: string[]): T[];
3
- export declare function assignSortIndexes<T extends DocumentElement>(orderedElements: T[]): T[];
1
+ export interface OrderableElement {
2
+ id?: string;
3
+ sortIndex?: string;
4
+ }
5
+ export declare function sortElementsByArrayOrder<T extends OrderableElement>(elements: T[], sortOrder?: string[]): T[];
6
+ export declare function assignSortIndexes<T extends OrderableElement>(orderedElements: T[]): T[];
@@ -5,13 +5,13 @@ export interface ImportReferenceDetail {
5
5
  importedFileReference?: string;
6
6
  }
7
7
  export type DocumentWriteMode = 'transactional' | 'legacy';
8
- export declare const DOCUMENT_SORT_MODES: readonly ["array", "elementIndexing", "migrating"];
9
- export type DocumentSortMode = (typeof DOCUMENT_SORT_MODES)[number];
10
8
  export declare const SORT_MODE: {
11
9
  readonly ARRAY: "array";
12
10
  readonly ELEMENT_INDEXING: "elementIndexing";
13
11
  readonly MIGRATING: "migrating";
14
12
  };
13
+ export type DocumentSortMode = (typeof SORT_MODE)[keyof typeof SORT_MODE];
14
+ export declare const DOCUMENT_SORT_MODES: readonly DocumentSortMode[];
15
15
  export interface Document {
16
16
  id?: string;
17
17
  name?: string;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SORT_MODE = exports.DOCUMENT_SORT_MODES = void 0;
4
- exports.DOCUMENT_SORT_MODES = ['array', 'elementIndexing', 'migrating'];
3
+ exports.DOCUMENT_SORT_MODES = exports.SORT_MODE = void 0;
5
4
  exports.SORT_MODE = {
6
5
  ARRAY: 'array',
7
6
  ELEMENT_INDEXING: 'elementIndexing',
8
7
  MIGRATING: 'migrating',
9
8
  };
9
+ exports.DOCUMENT_SORT_MODES = Object.values(exports.SORT_MODE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.15.0-alpha.ba306dc",
3
+ "version": "1.15.0-alpha.c7091a8",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",