@contrail/documents 1.11.0-alpha.0 → 1.12.0-alpha.1e36a0e
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 +9 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/sort-index.d.ts +5 -0
- package/lib/sort-index.js +27 -0
- package/lib/sort-order-errors.d.ts +6 -0
- package/lib/sort-order-errors.js +11 -0
- package/lib/types/document-element.d.ts +1 -0
- package/lib/types/document.d.ts +3 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,15 @@ All notable changes to `@contrail/documents` are documented here.
|
|
|
5
5
|
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
6
|
Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [1.12.0] - 2026-07-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Reliable sort-order surface (PLAT-1270): `Document.sortMode` (`'array' | 'elementIndexing'`, `undefined` = `array`) and transient `Document.isSortMigrating` freeze flag; `DocumentElement.sortIndex` (fractional-indexing key).
|
|
13
|
+
- Sort utilities: `buildKeyBetween` / `buildNKeysBetween` (generate index key(s) between two neighbours), `compareSortIndex` (`(sortIndex, id)` comparator), and `allElementsHaveSortIndex`.
|
|
14
|
+
- `SortOrderErrorCode` / `SortOrderErrorMessage` — structured code for the mid-convert freeze (`SORT_MIGRATION_IN_PROGRESS`).
|
|
15
|
+
|
|
16
|
+
## [1.11.0] - 2026-06-29
|
|
9
17
|
|
|
10
18
|
### Added
|
|
11
19
|
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./sort-index"), exports);
|
|
19
|
+
__exportStar(require("./sort-order-errors"), exports);
|
|
18
20
|
__exportStar(require("./components"), exports);
|
|
19
21
|
__exportStar(require("./document-element-factory"), exports);
|
|
20
22
|
__exportStar(require("./document-element-property-binding-handler"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DocumentElement } from './types';
|
|
2
|
+
export declare function allElementsHaveSortIndex(elements: unknown[]): boolean;
|
|
3
|
+
export declare function buildKeyBetween(a: string | null, b: string | null): string;
|
|
4
|
+
export declare function buildNKeysBetween(a: string | null, b: string | null, n: number): string[];
|
|
5
|
+
export declare function compareSortIndex(a: DocumentElement, b: DocumentElement): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allElementsHaveSortIndex = allElementsHaveSortIndex;
|
|
4
|
+
exports.buildKeyBetween = buildKeyBetween;
|
|
5
|
+
exports.buildNKeysBetween = buildNKeysBetween;
|
|
6
|
+
exports.compareSortIndex = compareSortIndex;
|
|
7
|
+
const fractional_indexing_1 = require("fractional-indexing");
|
|
8
|
+
function allElementsHaveSortIndex(elements) {
|
|
9
|
+
return elements.every(element => typeof element.sortIndex === 'string' &&
|
|
10
|
+
element.sortIndex.length > 0);
|
|
11
|
+
}
|
|
12
|
+
function buildKeyBetween(a, b) {
|
|
13
|
+
return (0, fractional_indexing_1.generateKeyBetween)(a, b);
|
|
14
|
+
}
|
|
15
|
+
function buildNKeysBetween(a, b, n) {
|
|
16
|
+
return (0, fractional_indexing_1.generateNKeysBetween)(a, b, n);
|
|
17
|
+
}
|
|
18
|
+
function compareSortIndex(a, b) {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
const ai = (_a = a.sortIndex) !== null && _a !== void 0 ? _a : '';
|
|
21
|
+
const bi = (_b = b.sortIndex) !== null && _b !== void 0 ? _b : '';
|
|
22
|
+
if (ai !== bi)
|
|
23
|
+
return ai < bi ? -1 : 1;
|
|
24
|
+
const aid = (_c = a.id) !== null && _c !== void 0 ? _c : '';
|
|
25
|
+
const bid = (_d = b.id) !== null && _d !== void 0 ? _d : '';
|
|
26
|
+
return aid === bid ? 0 : aid < bid ? -1 : 1;
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SortOrderErrorMessage = exports.SortOrderErrorCode = void 0;
|
|
4
|
+
var SortOrderErrorCode;
|
|
5
|
+
(function (SortOrderErrorCode) {
|
|
6
|
+
SortOrderErrorCode["SORT_MIGRATION_IN_PROGRESS"] = "SORT_MIGRATION_IN_PROGRESS";
|
|
7
|
+
})(SortOrderErrorCode || (exports.SortOrderErrorCode = SortOrderErrorCode = {}));
|
|
8
|
+
var SortOrderErrorMessage;
|
|
9
|
+
(function (SortOrderErrorMessage) {
|
|
10
|
+
SortOrderErrorMessage["SORT_MIGRATION_IN_PROGRESS"] = "Sort order is being migrated for this document; editing is briefly locked";
|
|
11
|
+
})(SortOrderErrorMessage || (exports.SortOrderErrorMessage = SortOrderErrorMessage = {}));
|
package/lib/types/document.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export interface ImportReferenceDetail {
|
|
|
5
5
|
importedFileReference?: string;
|
|
6
6
|
}
|
|
7
7
|
export type DocumentWriteMode = 'transactional' | 'legacy';
|
|
8
|
+
export type DocumentSortMode = 'array' | 'elementIndexing';
|
|
8
9
|
export interface Document {
|
|
9
10
|
id?: string;
|
|
10
11
|
name?: string;
|
|
@@ -25,4 +26,6 @@ export interface Document {
|
|
|
25
26
|
ownedByReference?: string;
|
|
26
27
|
writeMode?: DocumentWriteMode;
|
|
27
28
|
lastSequenceNumber?: number;
|
|
29
|
+
sortMode?: DocumentSortMode;
|
|
30
|
+
isSortMigrating?: boolean;
|
|
28
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/documents",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0-alpha.1e36a0e",
|
|
4
4
|
"description": "Documents library for contrail platform",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@contrail/document-table": "^1.1.0",
|
|
44
44
|
"@contrail/document-util": "^1.2.0",
|
|
45
45
|
"@contrail/types": "^3.4.0",
|
|
46
|
+
"fractional-indexing": "^2.1.0",
|
|
46
47
|
"reflect-metadata": "^0.1.13"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|