@byline/host-tanstack-start 4.19.0 → 5.0.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/admin-shell/collections/edit.d.ts +1 -1
- package/dist/admin-shell/collections/edit.js +151 -31
- package/dist/admin-shell/collections/history.js +4 -2
- package/dist/admin-shell/collections/list.js +30 -6
- package/dist/admin-shell/collections/restore-version-modal.d.ts +3 -1
- package/dist/admin-shell/collections/restore-version-modal.js +9 -4
- package/dist/admin-shell/collections/tree-list.js +16 -6
- package/dist/admin-shell/collections/version-history.d.ts +2 -1
- package/dist/admin-shell/collections/version-history.js +11 -2
- package/dist/admin-shell/document-mutation-notice.d.ts +6 -0
- package/dist/admin-shell/document-mutation-notice.js +53 -0
- package/dist/admin-shell/document-mutation-state.d.ts +22 -0
- package/dist/admin-shell/document-mutation-state.js +71 -0
- package/dist/admin-shell/document-mutation-state.test.d.ts +1 -0
- package/dist/admin-shell/scheduled-publications/list.js +15 -5
- package/dist/admin-shell/singletons/history.js +4 -2
- package/dist/admin-shell/singletons/view.d.ts +1 -1
- package/dist/admin-shell/singletons/view.js +98 -19
- package/dist/integrations/byline-field-services.js +2 -9
- package/dist/routes/create-collection-edit-route.js +1 -1
- package/dist/routes/create-collection-list-route.d.ts +0 -7
- package/dist/routes/create-collection-list-route.js +7 -9
- package/dist/routes/create-singleton-route.d.ts +2 -0
- package/dist/routes/create-singleton-route.js +4 -3
- package/dist/server-fns/collections/copy-to-locale.d.ts +2 -7
- package/dist/server-fns/collections/copy-to-locale.js +4 -2
- package/dist/server-fns/collections/create.d.ts +1 -7
- package/dist/server-fns/collections/create.js +5 -3
- package/dist/server-fns/collections/delete-locale.d.ts +2 -7
- package/dist/server-fns/collections/delete-locale.js +4 -2
- package/dist/server-fns/collections/delete-outcome.d.ts +7 -3
- package/dist/server-fns/collections/delete-outcome.js +4 -0
- package/dist/server-fns/collections/delete.d.ts +2 -7
- package/dist/server-fns/collections/delete.js +5 -3
- package/dist/server-fns/collections/duplicate.d.ts +2 -7
- package/dist/server-fns/collections/duplicate.js +5 -3
- package/dist/server-fns/collections/get.d.ts +1 -7
- package/dist/server-fns/collections/get.js +5 -4
- package/dist/server-fns/collections/list.d.ts +0 -7
- package/dist/server-fns/collections/list.js +11 -3
- package/dist/server-fns/collections/reorder.d.ts +7 -8
- package/dist/server-fns/collections/reorder.js +20 -76
- package/dist/server-fns/collections/restore-version.d.ts +3 -7
- package/dist/server-fns/collections/restore-version.js +5 -2
- package/dist/server-fns/collections/save-outcome.d.ts +1 -0
- package/dist/server-fns/collections/save-outcome.js +1 -0
- package/dist/server-fns/collections/scheduled-publication.d.ts +49 -9
- package/dist/server-fns/collections/scheduled-publication.js +31 -21
- package/dist/server-fns/collections/status.d.ts +8 -7
- package/dist/server-fns/collections/status.js +13 -5
- package/dist/server-fns/collections/tree-mutation.d.ts +7 -6
- package/dist/server-fns/collections/tree-mutation.js +17 -5
- package/dist/server-fns/collections/tree.d.ts +14 -8
- package/dist/server-fns/collections/tree.js +21 -17
- package/dist/server-fns/collections/update.d.ts +12 -11
- package/dist/server-fns/collections/update.js +34 -20
- package/dist/server-fns/collections/upload.d.ts +1 -0
- package/dist/server-fns/collections/upload.js +3 -2
- package/dist/server-fns/document-mutation-errors.d.ts +5 -0
- package/dist/server-fns/document-mutation-errors.js +50 -0
- package/dist/server-fns/editable-revision.d.ts +9 -0
- package/dist/server-fns/editable-revision.js +11 -0
- package/dist/server-fns/singleton-document-read.d.ts +1 -1
- package/dist/server-fns/singleton-document-read.js +7 -3
- package/dist/server-fns/singletons/cancel-scheduled-publish.d.ts +6 -8
- package/dist/server-fns/singletons/cancel-scheduled-publish.js +4 -1
- package/dist/server-fns/singletons/change-status.d.ts +2 -7
- package/dist/server-fns/singletons/change-status.js +4 -1
- package/dist/server-fns/singletons/confirm-scheduled-publish.d.ts +5 -8
- package/dist/server-fns/singletons/confirm-scheduled-publish.js +4 -2
- package/dist/server-fns/singletons/copy-to-locale.d.ts +2 -7
- package/dist/server-fns/singletons/copy-to-locale.js +4 -2
- package/dist/server-fns/singletons/get.d.ts +4 -4
- package/dist/server-fns/singletons/restore-version.d.ts +2 -7
- package/dist/server-fns/singletons/restore-version.js +6 -3
- package/dist/server-fns/singletons/schedule-publish.d.ts +5 -8
- package/dist/server-fns/singletons/schedule-publish.js +4 -2
- package/dist/server-fns/singletons/unpublish.d.ts +2 -7
- package/dist/server-fns/singletons/unpublish.js +4 -1
- package/dist/server-fns/singletons/update.d.ts +4 -11
- package/dist/server-fns/singletons/update.js +5 -4
- package/dist/server-fns/structural-receipt.d.ts +4 -0
- package/dist/server-fns/structural-receipt.js +31 -0
- package/package.json +11 -11
- package/src/admin-shell/collections/edit.tsx +173 -54
- package/src/admin-shell/collections/history.tsx +11 -2
- package/src/admin-shell/collections/list.tsx +22 -6
- package/src/admin-shell/collections/restore-version-modal.tsx +12 -3
- package/src/admin-shell/collections/save-navigation.test.tsx +156 -8
- package/src/admin-shell/collections/tree-list.tsx +16 -6
- package/src/admin-shell/collections/version-history.tsx +13 -3
- package/src/admin-shell/document-mutation-notice.tsx +45 -0
- package/src/admin-shell/document-mutation-state.test.tsx +146 -0
- package/src/admin-shell/document-mutation-state.ts +95 -0
- package/src/admin-shell/scheduled-publications/list.tsx +16 -6
- package/src/admin-shell/singletons/history.test.tsx +3 -1
- package/src/admin-shell/singletons/history.tsx +10 -2
- package/src/admin-shell/singletons/view.test.tsx +59 -18
- package/src/admin-shell/singletons/view.tsx +110 -29
- package/src/integrations/byline-field-services.ts +2 -3
- package/src/routes/create-collection-edit-route.tsx +1 -0
- package/src/routes/create-collection-list-route.tsx +13 -2
- package/src/routes/create-singleton-route.test.node.ts +10 -2
- package/src/routes/create-singleton-route.tsx +6 -4
- package/src/server-fns/collections/copy-to-locale.ts +41 -36
- package/src/server-fns/collections/create.ts +54 -50
- package/src/server-fns/collections/delete-locale.ts +41 -32
- package/src/server-fns/collections/delete-outcome.test.node.ts +16 -0
- package/src/server-fns/collections/delete-outcome.ts +27 -16
- package/src/server-fns/collections/delete.ts +44 -38
- package/src/server-fns/collections/duplicate.ts +38 -32
- package/src/server-fns/collections/get.ts +8 -4
- package/src/server-fns/collections/list.ts +8 -3
- package/src/server-fns/collections/reorder.ts +32 -124
- package/src/server-fns/collections/restore-version.ts +47 -39
- package/src/server-fns/collections/revision-input.test.node.ts +108 -0
- package/src/server-fns/collections/save-outcome.test.node.ts +3 -0
- package/src/server-fns/collections/save-outcome.ts +2 -0
- package/src/server-fns/collections/scheduled-publication.ts +138 -111
- package/src/server-fns/collections/status.ts +86 -64
- package/src/server-fns/collections/tree-mutation.test.node.ts +87 -29
- package/src/server-fns/collections/tree-mutation.ts +28 -11
- package/src/server-fns/collections/tree.ts +150 -122
- package/src/server-fns/collections/update.ts +110 -86
- package/src/server-fns/collections/upload-singleton.test.node.ts +3 -7
- package/src/server-fns/collections/upload.ts +81 -77
- package/src/server-fns/document-mutation-errors.ts +67 -0
- package/src/server-fns/document-mutation-transport.test.node.ts +211 -0
- package/src/server-fns/editable-revision.test.node.ts +23 -0
- package/src/server-fns/editable-revision.ts +18 -0
- package/src/server-fns/singleton-document-read.ts +7 -3
- package/src/server-fns/singletons/cancel-scheduled-publish.ts +10 -3
- package/src/server-fns/singletons/change-status.ts +10 -3
- package/src/server-fns/singletons/confirm-scheduled-publish.ts +12 -6
- package/src/server-fns/singletons/copy-to-locale.ts +20 -15
- package/src/server-fns/singletons/get.ts +3 -3
- package/src/server-fns/singletons/restore-version.ts +17 -12
- package/src/server-fns/singletons/schedule-publish.ts +18 -7
- package/src/server-fns/singletons/singletons.test.node.ts +63 -25
- package/src/server-fns/singletons/unpublish.ts +10 -3
- package/src/server-fns/singletons/update.ts +21 -16
- package/src/server-fns/structural-receipt.ts +41 -0
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const changeSingletonStatus: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
status: string;
|
|
11
5
|
}) => {
|
|
6
|
+
expectedRevision: number;
|
|
12
7
|
singleton: string;
|
|
13
8
|
status: string;
|
|
14
9
|
}, Promise<import("@byline/core").ChangeStatusResult>>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { serialise } from "../serialise.js";
|
|
4
5
|
const changeSingletonStatus = createServerFn({
|
|
5
6
|
method: 'POST'
|
|
6
|
-
}).validator((input)=>input).handler(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).changeStatus(data.status
|
|
7
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).changeStatus(data.status, {
|
|
8
|
+
expectedRevision: data.expectedRevision
|
|
9
|
+
}))));
|
|
7
10
|
export { changeSingletonStatus };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const confirmSingletonScheduledPublish: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
expectedVersionId: string;
|
|
11
5
|
}) => {
|
|
6
|
+
expectedRevision: number;
|
|
12
7
|
singleton: string;
|
|
13
8
|
expectedVersionId: string;
|
|
14
|
-
}, Promise<import("@byline/client").DocumentPublishScheduleInfo
|
|
9
|
+
}, Promise<import("@byline/client").DocumentPublishScheduleInfo & {
|
|
10
|
+
revision: number;
|
|
11
|
+
}>>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { serialise } from "../serialise.js";
|
|
4
5
|
const confirmSingletonScheduledPublish = createServerFn({
|
|
5
6
|
method: 'POST'
|
|
6
|
-
}).validator((input)=>input).handler(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).confirmScheduledPublish({
|
|
7
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).confirmScheduledPublish({
|
|
8
|
+
expectedRevision: data.expectedRevision,
|
|
7
9
|
expectedVersionId: data.expectedVersionId
|
|
8
|
-
})));
|
|
10
|
+
}))));
|
|
9
11
|
export { confirmSingletonScheduledPublish };
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const copySingletonToLocale: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
sourceLocale: string;
|
|
11
5
|
targetLocale: string;
|
|
12
6
|
overwrite?: boolean;
|
|
13
7
|
}) => {
|
|
8
|
+
expectedRevision: number;
|
|
14
9
|
singleton: string;
|
|
15
10
|
sourceLocale: string;
|
|
16
11
|
targetLocale: string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { toCommittedDocumentHookFailureResponse } from "../collections/save-outcome.js";
|
|
4
5
|
import { serialise } from "../serialise.js";
|
|
5
6
|
const copySingletonToLocale = createServerFn({
|
|
6
7
|
method: 'POST'
|
|
7
|
-
}).validator((input)=>input).handler(async ({ data })=>{
|
|
8
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>{
|
|
8
9
|
try {
|
|
9
10
|
return serialise(await getAdminBylineClient().singleton(data.singleton).copyToLocale({
|
|
11
|
+
expectedRevision: data.expectedRevision,
|
|
10
12
|
sourceLocale: data.sourceLocale,
|
|
11
13
|
targetLocale: data.targetLocale,
|
|
12
14
|
overwrite: data.overwrite
|
|
@@ -16,5 +18,5 @@ const copySingletonToLocale = createServerFn({
|
|
|
16
18
|
if (null != committedFailure) return committedFailure;
|
|
17
19
|
throw error;
|
|
18
20
|
}
|
|
19
|
-
});
|
|
21
|
+
}));
|
|
20
22
|
export { copySingletonToLocale };
|
|
@@ -17,8 +17,8 @@ export interface GetSingletonInput {
|
|
|
17
17
|
* - this shared host layer owns lenient reads, raw missing-locale values,
|
|
18
18
|
* relation-summary population, transport serialization, and preservation of
|
|
19
19
|
* restore warnings and locale metadata;
|
|
20
|
-
* - the route loader composes published-version
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* - the route loader composes the informational published-version badge, feature
|
|
21
|
+
* enablement, capability, and schedule aliases. Schedule state itself comes
|
|
22
|
+
* from the same editable snapshot as the source document.
|
|
23
23
|
*/
|
|
24
|
-
export declare const getSingleton: import("@tanstack/react-start").RequiredFetcher<undefined, (input: GetSingletonInput) => GetSingletonInput, Promise<import("@byline/client").
|
|
24
|
+
export declare const getSingleton: import("@tanstack/react-start").RequiredFetcher<undefined, (input: GetSingletonInput) => GetSingletonInput, Promise<Omit<import("@byline/client").EditableDocument<Record<string, any>>, "path"> | null>>;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const restoreSingletonVersion: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
versionId: string;
|
|
11
5
|
}) => {
|
|
6
|
+
expectedRevision: number;
|
|
12
7
|
singleton: string;
|
|
13
8
|
versionId: string;
|
|
14
9
|
}, Promise<import("@byline/core").SingletonSaveResult>>;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { toCommittedDocumentHookFailureResponse } from "../collections/save-outcome.js";
|
|
4
5
|
import { serialise } from "../serialise.js";
|
|
5
6
|
const restoreSingletonVersion = createServerFn({
|
|
6
7
|
method: 'POST'
|
|
7
|
-
}).validator((input)=>input).handler(async ({ data })=>{
|
|
8
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>{
|
|
8
9
|
try {
|
|
9
|
-
return serialise(await getAdminBylineClient().singleton(data.singleton).restoreVersion(data.versionId
|
|
10
|
+
return serialise(await getAdminBylineClient().singleton(data.singleton).restoreVersion(data.versionId, {
|
|
11
|
+
expectedRevision: data.expectedRevision
|
|
12
|
+
}));
|
|
10
13
|
} catch (error) {
|
|
11
14
|
const committedFailure = toCommittedDocumentHookFailureResponse(error);
|
|
12
15
|
if (null != committedFailure) return committedFailure;
|
|
13
16
|
throw error;
|
|
14
17
|
}
|
|
15
|
-
});
|
|
18
|
+
}));
|
|
16
19
|
export { restoreSingletonVersion };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const scheduleSingletonPublish: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
publishAt: string;
|
|
11
5
|
expectedVersionId: string;
|
|
12
6
|
}) => {
|
|
7
|
+
expectedRevision: number;
|
|
13
8
|
singleton: string;
|
|
14
9
|
publishAt: string;
|
|
15
10
|
expectedVersionId: string;
|
|
16
|
-
}, Promise<import("@byline/client").DocumentPublishScheduleInfo
|
|
11
|
+
}, Promise<import("@byline/client").DocumentPublishScheduleInfo & {
|
|
12
|
+
revision: number;
|
|
13
|
+
}>>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { serialise } from "../serialise.js";
|
|
4
5
|
const scheduleSingletonPublish = createServerFn({
|
|
5
6
|
method: 'POST'
|
|
6
|
-
}).validator((input)=>input).handler(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).schedulePublish({
|
|
7
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).schedulePublish({
|
|
7
8
|
publishAt: data.publishAt,
|
|
9
|
+
expectedRevision: data.expectedRevision,
|
|
8
10
|
expectedVersionId: data.expectedVersionId
|
|
9
|
-
})));
|
|
11
|
+
}))));
|
|
10
12
|
export { scheduleSingletonPublish };
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
1
|
export declare const unpublishSingleton: import("@tanstack/react-start").RequiredFetcher<undefined, (input: {
|
|
2
|
+
expectedRevision: number;
|
|
9
3
|
singleton: string;
|
|
10
4
|
}) => {
|
|
5
|
+
expectedRevision: number;
|
|
11
6
|
singleton: string;
|
|
12
7
|
}, Promise<import("@byline/core").UnpublishResult>>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { serialise } from "../serialise.js";
|
|
4
5
|
const unpublishSingleton = createServerFn({
|
|
5
6
|
method: 'POST'
|
|
6
|
-
}).validator((input)=>input).handler(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).unpublish(
|
|
7
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>serialise(await getAdminBylineClient().singleton(data.singleton).unpublish({
|
|
8
|
+
expectedRevision: data.expectedRevision
|
|
9
|
+
}))));
|
|
7
10
|
export { unpublishSingleton };
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
export interface UpdateSingletonInput {
|
|
1
|
+
import type { SingletonSavePrecondition } from '@byline/core';
|
|
2
|
+
export type UpdateSingletonInput = SingletonSavePrecondition & {
|
|
9
3
|
singleton: string;
|
|
10
4
|
data: Record<string, any>;
|
|
11
5
|
locale?: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const updateSingleton: import("@tanstack/react-start").RequiredFetcher<undefined, (input: UpdateSingletonInput) => UpdateSingletonInput, Promise<import("@byline/core").SingletonSaveResult>>;
|
|
6
|
+
};
|
|
7
|
+
export declare const updateSingleton: import("@tanstack/react-start").RequiredFetcher<undefined, (input: UpdateSingletonInput) => UpdateSingletonInput, Promise<import("@byline/core").UpdateSingletonResult>>;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { withDocumentMutationErrors } from "../document-mutation-errors.js";
|
|
1
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
2
3
|
import { getAdminBylineClient } from "@byline/client/server";
|
|
3
4
|
import { toCommittedDocumentHookFailureResponse } from "../collections/save-outcome.js";
|
|
4
5
|
import { serialise } from "../serialise.js";
|
|
5
6
|
const updateSingleton = createServerFn({
|
|
6
7
|
method: 'POST'
|
|
7
|
-
}).validator((input)=>input).handler(async ({ data })=>{
|
|
8
|
-
const { singleton, data: fields, locale,
|
|
8
|
+
}).validator((input)=>input).handler(withDocumentMutationErrors(async ({ data })=>{
|
|
9
|
+
const { singleton, data: fields, locale, ...precondition } = data;
|
|
9
10
|
try {
|
|
10
11
|
const result = await getAdminBylineClient().singleton(singleton).update(fields, {
|
|
11
12
|
locale,
|
|
12
|
-
|
|
13
|
+
...precondition
|
|
13
14
|
});
|
|
14
15
|
return serialise(result);
|
|
15
16
|
} catch (error) {
|
|
@@ -17,5 +18,5 @@ const updateSingleton = createServerFn({
|
|
|
17
18
|
if (null != committedFailure) return committedFailure;
|
|
18
19
|
throw error;
|
|
19
20
|
}
|
|
20
|
-
});
|
|
21
|
+
}));
|
|
21
22
|
export { updateSingleton };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type StructuralMutationReceipt } from '@byline/core';
|
|
2
|
+
/** Copy only the authorized receipt fields emitted by the lifecycle service. */
|
|
3
|
+
export declare function structuralReceipt(value: unknown): StructuralMutationReceipt | null;
|
|
4
|
+
export declare function committedTreeReceipt(error: unknown): StructuralMutationReceipt | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ErrorCodes, isDocumentRevision } from "@byline/core";
|
|
2
|
+
function structuralReceipt(value) {
|
|
3
|
+
if ('object' != typeof value || null === value) return null;
|
|
4
|
+
const documentId = Reflect.get(value, 'documentId');
|
|
5
|
+
const revision = Reflect.get(value, 'revision');
|
|
6
|
+
const suspended = Reflect.get(value, 'scheduledPublicationsNeedReconfirmation');
|
|
7
|
+
const affected = Reflect.get(value, 'affectedDocuments');
|
|
8
|
+
if ('string' != typeof documentId || !isDocumentRevision(revision) || 'boolean' != typeof suspended || !Array.isArray(affected)) return null;
|
|
9
|
+
const affectedDocuments = [];
|
|
10
|
+
for (const row of affected){
|
|
11
|
+
if ('object' != typeof row || null === row) return null;
|
|
12
|
+
const id = Reflect.get(row, 'documentId');
|
|
13
|
+
const token = Reflect.get(row, 'revision');
|
|
14
|
+
if ('string' != typeof id || !isDocumentRevision(token)) return null;
|
|
15
|
+
affectedDocuments.push({
|
|
16
|
+
documentId: id,
|
|
17
|
+
revision: token
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
documentId,
|
|
22
|
+
revision,
|
|
23
|
+
affectedDocuments,
|
|
24
|
+
scheduledPublicationsNeedReconfirmation: suspended
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function committedTreeReceipt(error) {
|
|
28
|
+
if ('object' != typeof error || null === error || Reflect.get(error, 'code') !== ErrorCodes.TREE_HOOK_COMMITTED) return null;
|
|
29
|
+
return structuralReceipt(Reflect.get(error, 'details'));
|
|
30
|
+
}
|
|
31
|
+
export { committedTreeReceipt, structuralReceipt };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "5.0.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=20.9.0"
|
|
9
9
|
},
|
|
@@ -125,15 +125,15 @@
|
|
|
125
125
|
"react-json-view-lite": "^2.5.0",
|
|
126
126
|
"react-swipeable": "^7.0.2",
|
|
127
127
|
"zod": "^4.4.3",
|
|
128
|
-
"@byline/admin": "
|
|
129
|
-
"@byline/analytics": "
|
|
130
|
-
"@byline/
|
|
131
|
-
"@byline/
|
|
132
|
-
"@byline/core": "
|
|
133
|
-
"@byline/
|
|
134
|
-
"@byline/
|
|
135
|
-
"@byline/
|
|
136
|
-
"@byline/
|
|
128
|
+
"@byline/admin": "5.0.0",
|
|
129
|
+
"@byline/analytics": "5.0.0",
|
|
130
|
+
"@byline/ai": "5.0.0",
|
|
131
|
+
"@byline/analytics-agent": "5.0.0",
|
|
132
|
+
"@byline/core": "5.0.0",
|
|
133
|
+
"@byline/i18n": "5.0.0",
|
|
134
|
+
"@byline/ui": "5.0.0",
|
|
135
|
+
"@byline/client": "5.0.0",
|
|
136
|
+
"@byline/auth": "5.0.0"
|
|
137
137
|
},
|
|
138
138
|
"peerDependencies": {
|
|
139
139
|
"@tanstack/react-router": "^1.167.0",
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"build": "run-s build:*",
|
|
175
175
|
"build:clean": "node scripts/clean.js dist build",
|
|
176
176
|
"build:code": "rslib build",
|
|
177
|
-
"typecheck": "tsc --noEmit",
|
|
177
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.revision-tests.json",
|
|
178
178
|
"clean": "node scripts/clean.js node_modules dist build types .turbo",
|
|
179
179
|
"lint": "biome check --write --unsafe --diagnostic-level=error",
|
|
180
180
|
"test": "vitest run --mode=jsdom && vitest run --mode=node",
|