@byline/client 4.19.0 → 5.1.0
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/dist/collection-handle.d.ts +33 -12
- package/dist/collection-handle.js +293 -25
- package/dist/index.d.ts +2 -2
- package/dist/read-internals.d.ts +2 -0
- package/dist/read-internals.js +2 -0
- package/dist/server/admin-context.d.ts +6 -38
- package/dist/server/admin-context.js +23 -110
- package/dist/server/admin-context.test.node.js +29 -134
- package/dist/server/request-context-contract.test.node.js +4 -2
- package/dist/server/request-context-factories.test.node.js +1 -1
- package/dist/singleton-handle.d.ts +18 -9
- package/dist/singleton-handle.js +32 -14
- package/dist/test-adapter.test-helper.d.ts +26 -0
- package/dist/test-adapter.test-helper.js +117 -0
- package/dist/types.d.ts +33 -6
- package/package.json +10 -10
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export function testAdapter(overrides = {}) {
|
|
2
|
+
const unused = () => {
|
|
3
|
+
throw new Error('Unexpected adapter operation in unit fixture');
|
|
4
|
+
};
|
|
5
|
+
return {
|
|
6
|
+
withTransaction: unused,
|
|
7
|
+
withReadSnapshot: unused,
|
|
8
|
+
...overrides,
|
|
9
|
+
revisions: {
|
|
10
|
+
readStructure: unused,
|
|
11
|
+
assertCompatibleSchema: unused,
|
|
12
|
+
isInTransaction: () => false,
|
|
13
|
+
lock: unused,
|
|
14
|
+
advance: unused,
|
|
15
|
+
...overrides.revisions,
|
|
16
|
+
},
|
|
17
|
+
commands: {
|
|
18
|
+
collections: {
|
|
19
|
+
lockCollectionRegistration: unused,
|
|
20
|
+
create: unused,
|
|
21
|
+
update: unused,
|
|
22
|
+
delete: unused,
|
|
23
|
+
...overrides.commands?.collections,
|
|
24
|
+
},
|
|
25
|
+
documents: {
|
|
26
|
+
createDocumentVersion: unused,
|
|
27
|
+
updateDocumentPath: unused,
|
|
28
|
+
setDocumentAvailableLocales: unused,
|
|
29
|
+
setDocumentStatus: unused,
|
|
30
|
+
archivePublishedVersions: unused,
|
|
31
|
+
softDeleteDocument: unused,
|
|
32
|
+
restoreSoftDeletedDocument: unused,
|
|
33
|
+
deleteDocumentLocale: unused,
|
|
34
|
+
setOrderKey: unused,
|
|
35
|
+
placeTreeNode: unused,
|
|
36
|
+
removeFromTree: unused,
|
|
37
|
+
promoteChildrenAndRemoveFromTree: unused,
|
|
38
|
+
...overrides.commands?.documents,
|
|
39
|
+
publishSchedules: {
|
|
40
|
+
lockDocuments: unused,
|
|
41
|
+
schedule: unused,
|
|
42
|
+
confirm: unused,
|
|
43
|
+
cancel: unused,
|
|
44
|
+
suspendForContentEdit: unused,
|
|
45
|
+
claimDue: unused,
|
|
46
|
+
lockClaim: unused,
|
|
47
|
+
deleteClaim: unused,
|
|
48
|
+
suspendClaimForContentEdit: unused,
|
|
49
|
+
releaseClaim: unused,
|
|
50
|
+
...overrides.commands?.documents?.publishSchedules,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
counters: {
|
|
54
|
+
ensureCounterGroup: unused,
|
|
55
|
+
nextCounterValue: unused,
|
|
56
|
+
nextScopedCounterValue: unused,
|
|
57
|
+
...overrides.commands?.counters,
|
|
58
|
+
},
|
|
59
|
+
audit: {
|
|
60
|
+
append: unused,
|
|
61
|
+
...overrides.commands?.audit,
|
|
62
|
+
},
|
|
63
|
+
singletons: {
|
|
64
|
+
lockSlot: unused,
|
|
65
|
+
setMapping: unused,
|
|
66
|
+
clearMapping: unused,
|
|
67
|
+
...overrides.commands?.singletons,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
queries: {
|
|
71
|
+
collections: {
|
|
72
|
+
getAllCollections: unused,
|
|
73
|
+
getCollectionByPath: unused,
|
|
74
|
+
getCollectionById: unused,
|
|
75
|
+
...overrides.queries?.collections,
|
|
76
|
+
},
|
|
77
|
+
documents: {
|
|
78
|
+
getDocumentRevision: unused,
|
|
79
|
+
getDocumentSystemFieldsForUpdate: unused,
|
|
80
|
+
getDocumentById: unused,
|
|
81
|
+
getCurrentVersionMetadata: unused,
|
|
82
|
+
getCurrentPath: unused,
|
|
83
|
+
getDocumentByPath: unused,
|
|
84
|
+
getDocumentByVersion: unused,
|
|
85
|
+
getDocumentsByVersionIds: unused,
|
|
86
|
+
getDocumentsByDocumentIds: unused,
|
|
87
|
+
getDocumentHistory: unused,
|
|
88
|
+
getPublishedVersion: unused,
|
|
89
|
+
getPublishedDocumentIds: unused,
|
|
90
|
+
getDocumentCountsByStatus: unused,
|
|
91
|
+
findDocuments: unused,
|
|
92
|
+
getLastOrderKey: unused,
|
|
93
|
+
getNeighborOrderKeys: unused,
|
|
94
|
+
getCanonicalDocumentOrder: unused,
|
|
95
|
+
getTreeAncestors: unused,
|
|
96
|
+
getTreeChildren: unused,
|
|
97
|
+
getTreeParent: unused,
|
|
98
|
+
getTreeSubtree: unused,
|
|
99
|
+
...overrides.queries?.documents,
|
|
100
|
+
publishSchedules: {
|
|
101
|
+
get: unused,
|
|
102
|
+
list: unused,
|
|
103
|
+
...overrides.queries?.documents?.publishSchedules,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
audit: {
|
|
107
|
+
getDocumentAuditLog: unused,
|
|
108
|
+
findAuditLog: unused,
|
|
109
|
+
...overrides.queries?.audit,
|
|
110
|
+
},
|
|
111
|
+
singletons: {
|
|
112
|
+
getMappedDocumentId: unused,
|
|
113
|
+
...overrides.queries?.singletons,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
8
|
import type { RequestContext } from '@byline/auth';
|
|
9
|
-
import type { BylineLogger, CollectionDefinition, DocumentPublishSchedule, IDbAdapter, IStorageProvider, MissingLocalePolicy, PopulateSpec, PredicateValue, QueryPredicate, ReadContext, ReadMode, RichTextPopulateFn, RichTextToTextFn, SearchFacetBucket, SearchHit, SearchMatching, SearchProvider, ServerConfig, SlugifierFn, SortSpec } from '@byline/core';
|
|
9
|
+
import type { BylineLogger, CollectionDefinition, DocumentPublishSchedule, IDbAdapter, IStorageProvider, MissingLocalePolicy, PopulateSpec, PredicateValue, QueryPredicate, ReadContext, ReadMode, RichTextPopulateFn, RichTextToTextFn, SearchFacetBucket, SearchHit, SearchMatching, SearchProvider, ServerConfig, SingletonSavePrecondition, SlugifierFn, SortSpec } from '@byline/core';
|
|
10
10
|
export type { FilterOperators, PredicateValue, QueryPredicate, SearchFacetBucket, SearchHit, SearchProvider, SearchResults, SortDirection, SortSpec, } from '@byline/core';
|
|
11
11
|
export interface BylineClientConfig {
|
|
12
12
|
/**
|
|
@@ -408,6 +408,8 @@ export interface CreateOptions {
|
|
|
408
408
|
availableLocales?: string[];
|
|
409
409
|
}
|
|
410
410
|
export interface UpdateOptions {
|
|
411
|
+
/** Revision from the editable document observed before preparing this update. */
|
|
412
|
+
expectedRevision: number;
|
|
411
413
|
/** Locale for field value resolution. Defaults to the client's `defaultLocale`. */
|
|
412
414
|
locale?: string;
|
|
413
415
|
/**
|
|
@@ -424,14 +426,13 @@ export interface UpdateOptions {
|
|
|
424
426
|
availableLocales?: string[];
|
|
425
427
|
}
|
|
426
428
|
/** Write controls for `SingletonHandle.update()`. */
|
|
427
|
-
export
|
|
428
|
-
/** Locale for field value resolution. Defaults to the client's
|
|
429
|
+
export type UpdateSingletonOptions = SingletonSavePrecondition & {
|
|
430
|
+
/** Locale for field value resolution. Defaults to the client's defaultLocale. */
|
|
429
431
|
locale?: string;
|
|
430
|
-
|
|
431
|
-
expectedVersionId?: string;
|
|
432
|
-
}
|
|
432
|
+
};
|
|
433
433
|
/** Optimistic, absolute-time input for `CollectionHandle.schedulePublish()`. */
|
|
434
434
|
export interface SchedulePublishOptions {
|
|
435
|
+
expectedRevision: number;
|
|
435
436
|
/** ISO instant carrying an explicit UTC offset or `Z`. */
|
|
436
437
|
publishAt: string;
|
|
437
438
|
/** The current version the editor reviewed and intends to publish. */
|
|
@@ -439,6 +440,7 @@ export interface SchedulePublishOptions {
|
|
|
439
440
|
}
|
|
440
441
|
/** Reviewed current version used to re-arm a suspended publication. */
|
|
441
442
|
export interface ConfirmScheduledPublishOptions {
|
|
443
|
+
expectedRevision: number;
|
|
442
444
|
expectedVersionId: string;
|
|
443
445
|
}
|
|
444
446
|
/**
|
|
@@ -459,6 +461,7 @@ export type DocumentPublishScheduleInfo = Omit<DocumentPublishSchedule, 'executi
|
|
|
459
461
|
* may be null/omitted (append as last child, or prepend before a given sibling).
|
|
460
462
|
*/
|
|
461
463
|
export interface PlaceTreeNodeOptions {
|
|
464
|
+
expectedRevision: number;
|
|
462
465
|
/** The new parent; `null` makes the node a root. */
|
|
463
466
|
parentDocumentId: string | null;
|
|
464
467
|
/** Left neighbour — the node lands immediately after it. */
|
|
@@ -470,6 +473,7 @@ export interface PlaceTreeNodeOptions {
|
|
|
470
473
|
}
|
|
471
474
|
/** Options for an idempotent tree removal or post-commit hook retry. */
|
|
472
475
|
export interface RemoveFromTreeOptions {
|
|
476
|
+
expectedRevision: number;
|
|
473
477
|
/** Re-run `afterTreeChange` when the document is already unplaced. */
|
|
474
478
|
reconcile?: boolean;
|
|
475
479
|
}
|
|
@@ -706,3 +710,26 @@ export type WithPopulated<F, K extends keyof F, Target> = {
|
|
|
706
710
|
export type WithPopulatedMany<F, K extends keyof F, Target> = {
|
|
707
711
|
[P in keyof F]: P extends K ? Array<PopulatedRelation<Target>> : F[P];
|
|
708
712
|
};
|
|
713
|
+
/** Only explicit current editable reads carry mutation observations. */
|
|
714
|
+
export interface EditableDocument<F = Record<string, any>> extends ClientDocument<F> {
|
|
715
|
+
revision: number;
|
|
716
|
+
scheduledPublication: DocumentPublishScheduleInfo | null;
|
|
717
|
+
}
|
|
718
|
+
export type EditableSingleton<F = Record<string, any>> = {
|
|
719
|
+
state: 'empty';
|
|
720
|
+
} | {
|
|
721
|
+
state: 'document';
|
|
722
|
+
document: Omit<EditableDocument<F>, 'path'>;
|
|
723
|
+
};
|
|
724
|
+
export interface EditableFindResult<F = Record<string, any>> {
|
|
725
|
+
docs: EditableDocument<F>[];
|
|
726
|
+
meta: FindResult<F>['meta'];
|
|
727
|
+
}
|
|
728
|
+
export interface EditableTreeNode<F = Record<string, any>> {
|
|
729
|
+
document: EditableDocument<F>;
|
|
730
|
+
depth: number;
|
|
731
|
+
children: EditableTreeNode<F>[];
|
|
732
|
+
}
|
|
733
|
+
export type FindByIdForEditOptions<F = Record<string, any>> = Omit<FindByIdOptions<F>, 'status'>;
|
|
734
|
+
export type FindForEditOptions<F = Record<string, any>> = Omit<FindOptions<F>, 'status'>;
|
|
735
|
+
export type GetSubtreeForEditOptions<F = Record<string, any>> = Omit<GetSubtreeOptions<F>, 'status'>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/client",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "5.1.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"uuid": "^14.0.2",
|
|
47
|
-
"@byline/auth": "
|
|
48
|
-
"@byline/core": "
|
|
47
|
+
"@byline/auth": "5.1.0",
|
|
48
|
+
"@byline/core": "5.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@biomejs/biome": "2.5.
|
|
52
|
-
"@types/node": "^26.
|
|
51
|
+
"@biomejs/biome": "2.5.12",
|
|
52
|
+
"@types/node": "^26.5.0",
|
|
53
53
|
"chokidar": "^5.0.0",
|
|
54
54
|
"chokidar-cli": "^3.0.0",
|
|
55
55
|
"dotenv": "^17.4.2",
|
|
56
56
|
"npm-run-all": "^4.1.5",
|
|
57
|
-
"tsc-alias": "^1.9.
|
|
57
|
+
"tsc-alias": "^1.9.4",
|
|
58
58
|
"typescript": "^7.0.2",
|
|
59
|
-
"vitest": "^
|
|
60
|
-
"@byline/db-postgres": "
|
|
61
|
-
"@byline/search-postgres": "
|
|
59
|
+
"vitest": "^5.0.0",
|
|
60
|
+
"@byline/db-postgres": "5.1.0",
|
|
61
|
+
"@byline/search-postgres": "5.1.0"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public",
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"test": "vitest run --mode=node",
|
|
74
74
|
"test:watch": "vitest --mode=node",
|
|
75
75
|
"test:integration": "vitest run --mode=integration",
|
|
76
|
-
"typecheck": "tsc --noEmit"
|
|
76
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json"
|
|
77
77
|
}
|
|
78
78
|
}
|