@phis/ui 0.7.5 → 0.7.7
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/components/controls/phi-form-control.d.ts +3 -1
- package/components/controls/phi-form-control.js +4 -4
- package/components/forms/auth-admin-settings-labels.d.ts +1 -1
- package/components/forms/auth-admin-settings-labels.js +2 -2
- package/components/forms/form-descriptor-contract.d.ts +1 -1
- package/components/forms/form-descriptor-contract.js +1 -1
- package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
- package/components/forms/form-descriptor-runtime-client.js +33 -11
- package/components/forms/form-media-limits.d.ts +12 -0
- package/components/forms/form-media-limits.js +14 -0
- package/components/forms/form-provider-registry.d.ts +8 -0
- package/components/forms/form-record-title.d.ts +14 -0
- package/components/forms/form-record-title.js +38 -0
- package/components/forms/form-widget-config.d.ts +3 -0
- package/components/forms/form-widget-config.js +2 -0
- package/components/forms/phi-form-widget.d.ts +1 -1
- package/components/forms/phi-form-widget.js +4 -0
- package/components/overlays/phi-overlay-container-client.js +8 -8
- package/components/overlays/phi-overlay-title.d.ts +7 -0
- package/components/overlays/phi-overlay-title.js +21 -0
- package/components/tables/client/phi-table-binding.d.ts +3 -1
- package/components/tables/client/phi-table-binding.js +90 -49
- package/components/tables/client/phi-table-filter-options.d.ts +27 -0
- package/components/tables/client/phi-table-filter-options.js +35 -0
- package/components/widgets/accessible-areas.d.ts +1 -1
- package/components/widgets/accessible-areas.js +1 -1
- package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
- package/components/widgets/client/shared/phi-rendered-value.js +49 -1
- package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
- package/components/widgets/client/shared/phi-table-provider.js +22 -0
- package/components/widgets/label-sets/admin-users.d.ts +15 -0
- package/components/widgets/label-sets/admin-users.js +31 -0
- package/constants/core-data-provider-keys.d.ts +7 -0
- package/constants/core-data-provider-keys.js +7 -0
- package/constants/phi-base-role-metadata.d.ts +2 -2
- package/constants/phi-base-role-metadata.js +1 -1
- package/constants/runtime-module-ownership.js +3 -0
- package/forms.d.ts +1 -1
- package/forms.js +1 -1
- package/gateway/capability-media-limits.d.ts +10 -0
- package/gateway/capability-media-limits.js +40 -0
- package/gateway/server-capabilities.js +4 -0
- package/helpers/preset-tree-contract-check.d.ts +3 -2
- package/helpers/preset-tree-contract-check.js +60 -0
- package/helpers/record-title.d.ts +7 -0
- package/helpers/record-title.js +25 -0
- package/helpers/record-widget.d.ts +15 -0
- package/helpers/record-widget.js +57 -0
- package/package.json +2 -2
- package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
- package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
- package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
- package/plugins/runtime-modules/accounting/data-providers.js +127 -0
- package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
- package/plugins/runtime-modules/accounting/definition.js +5 -3
- package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
- package/plugins/runtime-modules/accounting/ids.js +27 -0
- package/plugins/runtime-modules/accounting/module.d.ts +52 -0
- package/plugins/runtime-modules/accounting/presets.js +23 -4
- package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
- package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
- package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
- package/plugins/runtime-modules/area-definitions.js +2 -2
- package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
- package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
- package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
- package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
- package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
- package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
- package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
- package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
- package/plugins/runtime-modules/core/cards.js +2 -2
- package/plugins/runtime-modules/core/client-data-providers.js +5 -0
- package/plugins/runtime-modules/core/data-providers.js +14 -0
- package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
- package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
- package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
- package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
- package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
- package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
- package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
- package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
- package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
- package/plugins/runtime-modules/groups/data-providers.js +1 -1
- package/plugins/runtime-modules/groups/definition.js +1 -1
- package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
- package/plugins/runtime-modules/groups/page-visibility.js +1 -1
- package/plugins/runtime-modules/groups/presets.js +1 -1
- package/plugins/runtime-modules/groups/services/options.js +1 -1
- package/plugins/runtime-modules/groups/services/table.js +1 -1
- package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
- package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
- package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
- package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
- package/plugins/runtime-modules/user-management/controller/client.js +1 -1
- package/plugins/runtime-modules/user-management/data-providers.js +1 -0
- package/plugins/runtime-modules/user-management/forms.js +22 -0
- package/plugins/runtime-modules/user-management/presets.js +2 -2
- package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
- package/plugins/runtime-modules/user-management/services/options.js +14 -6
- package/plugins/runtime-modules/user-management/services/table.js +12 -3
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
- package/types/access.d.ts +1 -1
- package/types/access.js +7 -7
- package/types/core-widget-placements.d.ts +7 -0
- package/types/form-descriptor.d.ts +1 -1
- package/types/record-widget.d.ts +35 -0
- package/types/server-capabilities.d.ts +1 -1
- package/types/table-widget.d.ts +20 -0
- package/types/table-widget.js +44 -0
|
@@ -1,2 +1,29 @@
|
|
|
1
1
|
import { PHI_SHARED_PACKAGE_NAME } from "../../../types/signals";
|
|
2
|
+
import { createPhiSharedRuntimeDataProviderKey } from "../../../constants/runtime-data-provider-key";
|
|
3
|
+
import { createPhiPresetCmsInstanceIdMap } from "../../../types/cms-instance-id";
|
|
2
4
|
export const PHI_ACCOUNTING_RUNTIME_MODULE_ID = `${PHI_SHARED_PACKAGE_NAME}/modules/accounting`;
|
|
5
|
+
/**
|
|
6
|
+
* The Module's identity as its Label Sets inherit it (`definePhiRuntimeModuleLabelSet`): the id and,
|
|
7
|
+
* where a Module declares one, its source locale. Stated here beside the id and spread into the
|
|
8
|
+
* definition, so a Label Set a tree reads does not import the definition that imports the tree.
|
|
9
|
+
*/
|
|
10
|
+
export const PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY = {
|
|
11
|
+
moduleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`): every product of every
|
|
15
|
+
* supplier Add-on, as the Site operator administers it. A Page of the Accounting Area itself rather than
|
|
16
|
+
* of a shop, because every supplier's products land in it and it has to work with no shop at all.
|
|
17
|
+
*/
|
|
18
|
+
export const PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY = createPhiSharedRuntimeDataProviderKey("tables", "accounting-products");
|
|
19
|
+
/** The one resource the directory's Provider answers. */
|
|
20
|
+
export const PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY = "products";
|
|
21
|
+
export const PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET_KEY = "accounting-products-page";
|
|
22
|
+
const PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET = {
|
|
23
|
+
domain: "page",
|
|
24
|
+
ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
|
|
25
|
+
presetKey: PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET_KEY,
|
|
26
|
+
};
|
|
27
|
+
export const PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS = createPhiPresetCmsInstanceIdMap(PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET, ["layoutTerms", "layoutTermsFooter"]);
|
|
28
|
+
export const PHI_ACCOUNTING_PRODUCTS_PAGE_OVERLAY_IDS = createPhiPresetCmsInstanceIdMap(PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET, ["overlayTerms"]);
|
|
29
|
+
export const PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS = createPhiPresetCmsInstanceIdMap(PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET, ["widgetTable", "widgetTerms", "widgetTermsNote", "widgetTermsCommands"]);
|
|
@@ -9,6 +9,58 @@ export declare const PHI_ACCOUNTING_RUNTIME_MODULE: {
|
|
|
9
9
|
description: string;
|
|
10
10
|
icon: string;
|
|
11
11
|
serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
|
|
12
|
+
dataProviders: {
|
|
13
|
+
key: `${string}/${string}`;
|
|
14
|
+
ownerModuleId: "@phis/ui/modules/accounting";
|
|
15
|
+
kind: "table";
|
|
16
|
+
executionMode: "live";
|
|
17
|
+
authoringMode: "none";
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
resources: {
|
|
21
|
+
resourceKey: string;
|
|
22
|
+
title: string;
|
|
23
|
+
rowIdentityPath: string;
|
|
24
|
+
fields: import("../../../types").PhiTableProviderFieldDefinition[];
|
|
25
|
+
query: {
|
|
26
|
+
search: true;
|
|
27
|
+
filterFields: string[];
|
|
28
|
+
sorting: "none";
|
|
29
|
+
pagination: "offset";
|
|
30
|
+
total: true;
|
|
31
|
+
};
|
|
32
|
+
recordRead: true;
|
|
33
|
+
actions: ({
|
|
34
|
+
key: string;
|
|
35
|
+
title: string;
|
|
36
|
+
scope: "row";
|
|
37
|
+
intent: "write";
|
|
38
|
+
confirmation: "required";
|
|
39
|
+
disabledWhen: {
|
|
40
|
+
match: "any";
|
|
41
|
+
conditions: {
|
|
42
|
+
source: "row";
|
|
43
|
+
valuePath: string;
|
|
44
|
+
operator: "falsy";
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
} | {
|
|
48
|
+
key: string;
|
|
49
|
+
title: string;
|
|
50
|
+
scope: "row";
|
|
51
|
+
intent: "destructive";
|
|
52
|
+
confirmation: "required";
|
|
53
|
+
disabledWhen: {
|
|
54
|
+
match: "any";
|
|
55
|
+
conditions: {
|
|
56
|
+
source: "row";
|
|
57
|
+
valuePath: string;
|
|
58
|
+
operator: "truthy";
|
|
59
|
+
}[];
|
|
60
|
+
};
|
|
61
|
+
})[];
|
|
62
|
+
}[];
|
|
63
|
+
}[];
|
|
12
64
|
kind: "module";
|
|
13
65
|
eligibleAreas: readonly ["public" | "app" | "admin" | "builder" | "editor" | "accounting"];
|
|
14
66
|
title: "Public Base" | "App Base" | "Accounting Base" | "Admin Base" | "Builder Base" | "Editor Base";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { buildPhiAreaRootRoutePresetDescriptor } from "../area-root-route";
|
|
2
|
+
import { buildPhiSidebarRoutePresetDescriptor } from "../sidebar-route";
|
|
2
3
|
import { PhiCmsRegionType } from "../../../constants/phi-cms";
|
|
3
4
|
import { PHI_DEFAULT_PUB_AREA_COMPOSITION_NODE_KEYS } from "../preset-contracts/pub-area";
|
|
4
|
-
import { PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "./ids";
|
|
5
|
+
import { PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET_KEY, PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "./ids";
|
|
5
6
|
/*
|
|
6
|
-
* What the Accounting base Module brings: the Site shell for its Area
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* What the Accounting base Module brings: the Site shell for its Area, the Area root, and the Site's
|
|
8
|
+
* product directory. The root lands on the first sidebar entry a viewer can see -- the Dashboard
|
|
9
|
+
* Module's where it is on, the directory where it is not.
|
|
9
10
|
*/
|
|
10
11
|
export const PHI_ACCOUNTING_RUNTIME_MODULE_AREA_SHELLS = [
|
|
11
12
|
{
|
|
@@ -44,4 +45,22 @@ export const PHI_ACCOUNTING_RUNTIME_MODULE_ROUTES = [
|
|
|
44
45
|
area: "accounting",
|
|
45
46
|
title: "Accounting",
|
|
46
47
|
}),
|
|
48
|
+
/*
|
|
49
|
+
* The product directory, the Area's own Page: every supplier Add-on's products land in it, so it
|
|
50
|
+
* belongs to none of them, and it works with no shop at all (phis-server SERVER_ADDONS.md,
|
|
51
|
+
* `products:v1`). Whoever the Area lets in holds Core's `accounting` access, which is what Core asks
|
|
52
|
+
* of every request the Page makes.
|
|
53
|
+
*/
|
|
54
|
+
buildPhiSidebarRoutePresetDescriptor({
|
|
55
|
+
area: "accounting",
|
|
56
|
+
anchor: "main",
|
|
57
|
+
ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
|
|
58
|
+
presetKey: PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET_KEY,
|
|
59
|
+
title: "Products",
|
|
60
|
+
path: "/products",
|
|
61
|
+
itemKey: "@phis/ui/modules/accounting/nav/accounting/products",
|
|
62
|
+
icon: "antd:appstore",
|
|
63
|
+
loadTree: ({ page, runtime }) => import("./trees/phi-default-accounting-products-page-tree")
|
|
64
|
+
.then((module) => module.buildPhiDefaultAccountingProductsPageTree({ page, runtime })),
|
|
65
|
+
}),
|
|
47
66
|
];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type PhiTableProviderMutationRequest, type PhiTableProviderQueryRequest, type PhiTableProviderRecordRequest } from "../../../../types/table-widget";
|
|
2
|
+
/**
|
|
3
|
+
* A directory row as the Table speaks it: Core's fields, and what the Page reads off them -- the state as
|
|
4
|
+
* a lock mark, the parts as a count, whether a release waits, and the terms in force beside the terms
|
|
5
|
+
* waiting. A publisher's product never released has nothing in force; its terms are what waits. The
|
|
6
|
+
* Site's own product (no publisher) is always released and never waits.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toPhiAccountingProductRow(product: Record<string, unknown>): {
|
|
9
|
+
parts: string[];
|
|
10
|
+
partCount: number;
|
|
11
|
+
locked: boolean;
|
|
12
|
+
awaitingRelease: boolean;
|
|
13
|
+
};
|
|
14
|
+
declare function queryProducts({ resourceKey, query, signal }: PhiTableProviderQueryRequest): Promise<{
|
|
15
|
+
rows: {
|
|
16
|
+
parts: string[];
|
|
17
|
+
partCount: number;
|
|
18
|
+
locked: boolean;
|
|
19
|
+
awaitingRelease: boolean;
|
|
20
|
+
}[];
|
|
21
|
+
total: number;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* One product, read again for the record that sets its terms side by side. Core lists, it has no read of
|
|
25
|
+
* one product here, so the id is searched for -- it is part of what the search reads -- and the one
|
|
26
|
+
* product with exactly that id is taken from the matches.
|
|
27
|
+
*/
|
|
28
|
+
declare function readProductRecord({ resourceKey, rowIdentity, signal }: PhiTableProviderRecordRequest): Promise<{
|
|
29
|
+
parts: string[];
|
|
30
|
+
partCount: number;
|
|
31
|
+
locked: boolean;
|
|
32
|
+
awaitingRelease: boolean;
|
|
33
|
+
}>;
|
|
34
|
+
/** The path of one operator command; the id is one segment, so its `@`, `/` and `:` are encoded. */
|
|
35
|
+
export declare function buildPhiAccountingProductCommandPath(productId: string, command: string): string;
|
|
36
|
+
declare function mutateProducts(request: PhiTableProviderMutationRequest): Promise<{
|
|
37
|
+
status: "accepted";
|
|
38
|
+
invalidation: "view";
|
|
39
|
+
}>;
|
|
40
|
+
/** The registration itself, apart from the component, so the requests it makes can be read in a test. */
|
|
41
|
+
export declare const PHI_ACCOUNTING_PRODUCTS_TABLE_PROVIDER_REGISTRATION: {
|
|
42
|
+
key: `${string}/${string}`;
|
|
43
|
+
resources: {
|
|
44
|
+
resourceKey: string;
|
|
45
|
+
title: string;
|
|
46
|
+
rowIdentityPath: string;
|
|
47
|
+
fields: import("../../../../types").PhiTableProviderFieldDefinition[];
|
|
48
|
+
query: {
|
|
49
|
+
search: true;
|
|
50
|
+
filterFields: string[];
|
|
51
|
+
sorting: "none";
|
|
52
|
+
pagination: "offset";
|
|
53
|
+
total: true;
|
|
54
|
+
};
|
|
55
|
+
recordRead: true;
|
|
56
|
+
actions: ({
|
|
57
|
+
key: string;
|
|
58
|
+
title: string;
|
|
59
|
+
scope: "row";
|
|
60
|
+
intent: "write";
|
|
61
|
+
confirmation: "required";
|
|
62
|
+
disabledWhen: {
|
|
63
|
+
match: "any";
|
|
64
|
+
conditions: {
|
|
65
|
+
source: "row";
|
|
66
|
+
valuePath: string;
|
|
67
|
+
operator: "falsy";
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
key: string;
|
|
72
|
+
title: string;
|
|
73
|
+
scope: "row";
|
|
74
|
+
intent: "destructive";
|
|
75
|
+
confirmation: "required";
|
|
76
|
+
disabledWhen: {
|
|
77
|
+
match: "any";
|
|
78
|
+
conditions: {
|
|
79
|
+
source: "row";
|
|
80
|
+
valuePath: string;
|
|
81
|
+
operator: "truthy";
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
})[];
|
|
85
|
+
}[];
|
|
86
|
+
query: typeof queryProducts;
|
|
87
|
+
readRecord: typeof readProductRecord;
|
|
88
|
+
mutate: typeof mutateProducts;
|
|
89
|
+
};
|
|
90
|
+
export declare const PhiAccountingProductsTableProviderClient: import("react").ComponentType<{
|
|
91
|
+
children: import("react").ReactNode;
|
|
92
|
+
}>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { isPhiRecord } from "../../../../helpers/is-record";
|
|
3
|
+
import { buildPhiTablePageParams, createPhiTableProviderRequestInit, readPhiTableRows, readPhiTableStringFilter, } from "../../../../components/widgets/client/shared/phi-table-provider-request";
|
|
4
|
+
import { readPhiTableProviderResponse, } from "../../../../components/widgets/client/shared/phi-table-provider-response";
|
|
5
|
+
import { createPhiTableProviderClient, } from "../../../../components/widgets/client/shared/phi-table-provider";
|
|
6
|
+
import { PhiTableProviderError, } from "../../../../types/table-widget";
|
|
7
|
+
import { PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "../data-providers";
|
|
8
|
+
import { PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY, PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY } from "../ids";
|
|
9
|
+
const API_PATH = "/api/site/products";
|
|
10
|
+
const RESPONSE_OPTIONS = { subject: "Products" };
|
|
11
|
+
// What a list shows before the reader picks another size; the Page names the same number.
|
|
12
|
+
const DEFAULT_PAGE_SIZE = 25;
|
|
13
|
+
// The route's largest page, which a record read asks for to find its one product among the matches.
|
|
14
|
+
const RECORD_SEARCH_PAGE_SIZE = 100;
|
|
15
|
+
const COMMANDS = new Set(["release", "lock", "unlock"]);
|
|
16
|
+
/*
|
|
17
|
+
* The version of each product as the terms dialog last read it (`readProductRecord`), which is what a
|
|
18
|
+
* release names: the operator releases the terms they compared, and Core refuses (409) a product that has
|
|
19
|
+
* moved on since -- the publisher changed its terms again while the dialog stood open. The Table's own
|
|
20
|
+
* list does not write it: the dialog's record is the one the release runs from.
|
|
21
|
+
*/
|
|
22
|
+
const versionsShown = new Map();
|
|
23
|
+
const readParts = (value) => Array.isArray(value) ? value.filter((part) => typeof part === "string") : [];
|
|
24
|
+
function termValues(prefix, terms) {
|
|
25
|
+
return {
|
|
26
|
+
[`${prefix}Sale`]: terms ? terms.sale ?? null : null,
|
|
27
|
+
[`${prefix}ReferralUrl`]: terms ? terms.referralUrl ?? null : null,
|
|
28
|
+
[`${prefix}Free`]: terms ? terms.free === true : null,
|
|
29
|
+
[`${prefix}AccountRequired`]: terms ? terms.accountRequired === true : null,
|
|
30
|
+
[`${prefix}Parts`]: terms ? readParts(terms.parts) : null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A directory row as the Table speaks it: Core's fields, and what the Page reads off them -- the state as
|
|
35
|
+
* a lock mark, the parts as a count, whether a release waits, and the terms in force beside the terms
|
|
36
|
+
* waiting. A publisher's product never released has nothing in force; its terms are what waits. The
|
|
37
|
+
* Site's own product (no publisher) is always released and never waits.
|
|
38
|
+
*/
|
|
39
|
+
export function toPhiAccountingProductRow(product) {
|
|
40
|
+
const pending = isPhiRecord(product.pendingTerms) ? product.pendingTerms : null;
|
|
41
|
+
const released = product.released === true;
|
|
42
|
+
const parts = readParts(product.parts);
|
|
43
|
+
return {
|
|
44
|
+
...product,
|
|
45
|
+
parts,
|
|
46
|
+
partCount: parts.length,
|
|
47
|
+
locked: product.state === "locked",
|
|
48
|
+
awaitingRelease: !released || pending !== null,
|
|
49
|
+
...termValues("inForce", released ? product : null),
|
|
50
|
+
...termValues("pending", released ? pending : product),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function readStateFilter(query) {
|
|
54
|
+
const value = query.filters?.state;
|
|
55
|
+
const states = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
|
|
56
|
+
return states.filter((state) => typeof state === "string" && Boolean(state.trim()));
|
|
57
|
+
}
|
|
58
|
+
function readTotal(result) {
|
|
59
|
+
if (typeof result?.total !== "number" || !Number.isFinite(result.total) || result.total < 0) {
|
|
60
|
+
throw new PhiTableProviderError("invalid-response", "Products total is invalid.");
|
|
61
|
+
}
|
|
62
|
+
return result.total;
|
|
63
|
+
}
|
|
64
|
+
async function readDirectory(params, signal) {
|
|
65
|
+
return readPhiTableProviderResponse(await fetch(`${API_PATH}?${params.toString()}`, createPhiTableProviderRequestInit(signal)), RESPONSE_OPTIONS);
|
|
66
|
+
}
|
|
67
|
+
function requireResource(resourceKey) {
|
|
68
|
+
if (resourceKey !== PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY) {
|
|
69
|
+
throw new PhiTableProviderError("resource-not-found", `Unknown Accounting resource "${resourceKey}".`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function queryProducts({ resourceKey, query, signal }) {
|
|
73
|
+
requireResource(resourceKey);
|
|
74
|
+
const params = buildPhiTablePageParams(query, DEFAULT_PAGE_SIZE);
|
|
75
|
+
const search = query.search?.trim() ?? "";
|
|
76
|
+
if (search)
|
|
77
|
+
params.set("q", search);
|
|
78
|
+
const supplier = readPhiTableStringFilter(query, "supplier");
|
|
79
|
+
if (supplier)
|
|
80
|
+
params.set("supplier", supplier);
|
|
81
|
+
const states = readStateFilter(query);
|
|
82
|
+
if (states.length > 0)
|
|
83
|
+
params.set("state", states.join(","));
|
|
84
|
+
// The switch asks for those waiting; off, it asks for nothing rather than for those not waiting.
|
|
85
|
+
if (query.filters?.pendingTerms === true)
|
|
86
|
+
params.set("pendingTerms", "true");
|
|
87
|
+
const result = await readDirectory(params, signal);
|
|
88
|
+
return { rows: readPhiTableRows(result?.rows).map(toPhiAccountingProductRow), total: readTotal(result) };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* One product, read again for the record that sets its terms side by side. Core lists, it has no read of
|
|
92
|
+
* one product here, so the id is searched for -- it is part of what the search reads -- and the one
|
|
93
|
+
* product with exactly that id is taken from the matches.
|
|
94
|
+
*/
|
|
95
|
+
async function readProductRecord({ resourceKey, rowIdentity, signal }) {
|
|
96
|
+
requireResource(resourceKey);
|
|
97
|
+
if (typeof rowIdentity !== "string" || !rowIdentity) {
|
|
98
|
+
throw new PhiTableProviderError("record-not-found", "A product id is required.");
|
|
99
|
+
}
|
|
100
|
+
const params = new URLSearchParams({ q: rowIdentity, page: "1", pageSize: String(RECORD_SEARCH_PAGE_SIZE) });
|
|
101
|
+
const result = await readDirectory(params, signal);
|
|
102
|
+
const product = readPhiTableRows(result?.rows).find((row) => row.id === rowIdentity);
|
|
103
|
+
if (!product) {
|
|
104
|
+
versionsShown.delete(rowIdentity);
|
|
105
|
+
throw new PhiTableProviderError("record-not-found", `The Site has no product ${rowIdentity}.`);
|
|
106
|
+
}
|
|
107
|
+
if (typeof product.version !== "number" || !Number.isSafeInteger(product.version) || product.version < 1) {
|
|
108
|
+
throw new PhiTableProviderError("invalid-response", `Product ${rowIdentity} has no version.`);
|
|
109
|
+
}
|
|
110
|
+
versionsShown.set(rowIdentity, product.version);
|
|
111
|
+
return toPhiAccountingProductRow(product);
|
|
112
|
+
}
|
|
113
|
+
/** The path of one operator command; the id is one segment, so its `@`, `/` and `:` are encoded. */
|
|
114
|
+
export function buildPhiAccountingProductCommandPath(productId, command) {
|
|
115
|
+
return `${API_PATH}/${encodeURIComponent(productId)}/${command}`;
|
|
116
|
+
}
|
|
117
|
+
/*
|
|
118
|
+
* The operator's three acts. Each can move the row out of what the filters show -- a lock out of the
|
|
119
|
+
* active ones, a release out of those waiting -- so the view is read again rather than patched. A release
|
|
120
|
+
* sends the version of the record the terms dialog shows (`versionsShown`); with none read there is
|
|
121
|
+
* nothing the operator compared, and it is refused here rather than sent without one.
|
|
122
|
+
*/
|
|
123
|
+
async function mutateProducts(request) {
|
|
124
|
+
requireResource(request.resourceKey);
|
|
125
|
+
if (request.kind !== "action" || !COMMANDS.has(request.actionKey)) {
|
|
126
|
+
throw new PhiTableProviderError("mutation-not-supported", "Products are released, locked or unlocked here, never edited.");
|
|
127
|
+
}
|
|
128
|
+
if (typeof request.rowIdentity !== "string" || !request.rowIdentity) {
|
|
129
|
+
throw new PhiTableProviderError("invalid-query", "A product id is required.");
|
|
130
|
+
}
|
|
131
|
+
const init = createPhiTableProviderRequestInit(request.signal);
|
|
132
|
+
let body;
|
|
133
|
+
if (request.actionKey === "release") {
|
|
134
|
+
const expectedVersion = versionsShown.get(request.rowIdentity);
|
|
135
|
+
if (expectedVersion === undefined) {
|
|
136
|
+
throw new PhiTableProviderError("invalid-query", `The terms of ${request.rowIdentity} were not read; open them before releasing.`);
|
|
137
|
+
}
|
|
138
|
+
body = JSON.stringify({ expectedVersion });
|
|
139
|
+
}
|
|
140
|
+
await readPhiTableProviderResponse(await fetch(buildPhiAccountingProductCommandPath(request.rowIdentity, request.actionKey), {
|
|
141
|
+
...init,
|
|
142
|
+
method: "POST",
|
|
143
|
+
...(body === undefined ? {} : { body, headers: { ...init.headers, "content-type": "application/json" } }),
|
|
144
|
+
}), RESPONSE_OPTIONS);
|
|
145
|
+
return { status: "accepted", invalidation: "view" };
|
|
146
|
+
}
|
|
147
|
+
// Its own descriptor by key, not by position: a Provider added to the list must not take its place.
|
|
148
|
+
const resources = PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS
|
|
149
|
+
.find((descriptor) => descriptor.key === PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY)?.resources ?? [];
|
|
150
|
+
/** The registration itself, apart from the component, so the requests it makes can be read in a test. */
|
|
151
|
+
export const PHI_ACCOUNTING_PRODUCTS_TABLE_PROVIDER_REGISTRATION = {
|
|
152
|
+
key: PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY,
|
|
153
|
+
resources,
|
|
154
|
+
query: queryProducts,
|
|
155
|
+
readRecord: readProductRecord,
|
|
156
|
+
mutate: mutateProducts,
|
|
157
|
+
};
|
|
158
|
+
export const PhiAccountingProductsTableProviderClient = createPhiTableProviderClient(PHI_ACCOUNTING_PRODUCTS_TABLE_PROVIDER_REGISTRATION);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type PhiGlobalTranslatorOptions } from "../../../../gateway/tr";
|
|
3
|
+
export declare function getPhiAccountingProductsPageLabels(options: PhiGlobalTranslatorOptions): Promise<{
|
|
4
|
+
pageTitle: string;
|
|
5
|
+
pageDescription: string;
|
|
6
|
+
widgetLabel: string;
|
|
7
|
+
columns: {
|
|
8
|
+
picture: string;
|
|
9
|
+
title: string;
|
|
10
|
+
id: string;
|
|
11
|
+
supplier: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
state: string;
|
|
14
|
+
sale: string;
|
|
15
|
+
free: string;
|
|
16
|
+
account: string;
|
|
17
|
+
parts: string;
|
|
18
|
+
waiting: string;
|
|
19
|
+
};
|
|
20
|
+
states: {
|
|
21
|
+
draft: string;
|
|
22
|
+
active: string;
|
|
23
|
+
withdrawn: string;
|
|
24
|
+
locked: string;
|
|
25
|
+
};
|
|
26
|
+
sales: {
|
|
27
|
+
own: string;
|
|
28
|
+
referral: string;
|
|
29
|
+
payout: string;
|
|
30
|
+
};
|
|
31
|
+
search: string;
|
|
32
|
+
filters: {
|
|
33
|
+
supplier: string;
|
|
34
|
+
supplierPlaceholder: string;
|
|
35
|
+
state: string;
|
|
36
|
+
waiting: string;
|
|
37
|
+
};
|
|
38
|
+
footer: string;
|
|
39
|
+
empty: {
|
|
40
|
+
title: string;
|
|
41
|
+
text: string;
|
|
42
|
+
};
|
|
43
|
+
actions: {
|
|
44
|
+
release: string;
|
|
45
|
+
lock: string;
|
|
46
|
+
unlock: string;
|
|
47
|
+
cancel: string;
|
|
48
|
+
};
|
|
49
|
+
release: {
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
lock: {
|
|
53
|
+
title: string;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
unlock: {
|
|
57
|
+
title: string;
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
terms: {
|
|
61
|
+
title: string;
|
|
62
|
+
titleOf: string;
|
|
63
|
+
release: string;
|
|
64
|
+
product: string;
|
|
65
|
+
sale: {
|
|
66
|
+
inForce: string;
|
|
67
|
+
waiting: string;
|
|
68
|
+
};
|
|
69
|
+
referral: {
|
|
70
|
+
inForce: string;
|
|
71
|
+
waiting: string;
|
|
72
|
+
};
|
|
73
|
+
free: {
|
|
74
|
+
inForce: string;
|
|
75
|
+
waiting: string;
|
|
76
|
+
};
|
|
77
|
+
account: {
|
|
78
|
+
inForce: string;
|
|
79
|
+
waiting: string;
|
|
80
|
+
};
|
|
81
|
+
parts: {
|
|
82
|
+
inForce: string;
|
|
83
|
+
waiting: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { PHI_TR_CTX_WEB_UI_LABEL } from "../../../../gateway/tr";
|
|
3
|
+
import { definePhiRuntimeModuleLabelSet, definePhiMessageLabel, getPhiLabelSet } from "../../../../gateway/label-set";
|
|
4
|
+
import { PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY } from "../ids";
|
|
5
|
+
/**
|
|
6
|
+
* What the product directory in the Accounting Area says: its frame, the Table's columns, filters and
|
|
7
|
+
* footer, the terms side by side in the dialog that releases them, and the three acts.
|
|
8
|
+
*/
|
|
9
|
+
const PHI_ACCOUNTING_PRODUCTS_PAGE_LABEL_SET = definePhiRuntimeModuleLabelSet(PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY, {
|
|
10
|
+
key: "preset:accounting-products-page",
|
|
11
|
+
ctx: PHI_TR_CTX_WEB_UI_LABEL,
|
|
12
|
+
labels: {
|
|
13
|
+
page_title: "Products",
|
|
14
|
+
page_description: definePhiMessageLabel("Every product the Site's Add-ons supply: release their terms, lock and unlock them."),
|
|
15
|
+
widget_label: "products",
|
|
16
|
+
column_picture: "Picture",
|
|
17
|
+
column_title: "Title",
|
|
18
|
+
column_id: "ID",
|
|
19
|
+
column_supplier: "Supplier",
|
|
20
|
+
column_kind: "Kind",
|
|
21
|
+
column_state: "State",
|
|
22
|
+
column_sale: "Sale",
|
|
23
|
+
column_free: "Free",
|
|
24
|
+
column_account: "Account required",
|
|
25
|
+
column_parts: "Bundle parts",
|
|
26
|
+
column_waiting: "Terms waiting",
|
|
27
|
+
state_draft: "Draft",
|
|
28
|
+
state_active: "Active",
|
|
29
|
+
state_withdrawn: "Withdrawn",
|
|
30
|
+
state_locked: "Locked",
|
|
31
|
+
sale_own: "Own",
|
|
32
|
+
sale_referral: "Referral",
|
|
33
|
+
sale_payout: "Payout",
|
|
34
|
+
search_placeholder: "Title or ID",
|
|
35
|
+
filter_supplier: "Supplier",
|
|
36
|
+
filter_supplier_placeholder: "@scope/name",
|
|
37
|
+
filter_state: "State",
|
|
38
|
+
filter_waiting: "Terms waiting",
|
|
39
|
+
footer: "%1 products",
|
|
40
|
+
empty_title: definePhiMessageLabel("No product matches."),
|
|
41
|
+
empty_text: definePhiMessageLabel("The Site's Add-ons register their products here; none does yet, or the filters leave none."),
|
|
42
|
+
action_release: "Release terms",
|
|
43
|
+
action_lock: "Lock",
|
|
44
|
+
action_unlock: "Unlock",
|
|
45
|
+
action_cancel: "Cancel",
|
|
46
|
+
release_description: definePhiMessageLabel("The terms waiting for release take effect now, and the Add-ons that sell it are told."),
|
|
47
|
+
lock_title: "Lock %1?",
|
|
48
|
+
lock_description: definePhiMessageLabel("Nobody can acquire it, and no entitlement to it counts while it is locked. Its supplier cannot undo it."),
|
|
49
|
+
unlock_title: "Unlock %1?",
|
|
50
|
+
unlock_description: definePhiMessageLabel("It becomes withdrawn: entitlements count again, nobody acquires it until its supplier makes it active."),
|
|
51
|
+
terms_title: "Terms",
|
|
52
|
+
terms_title_of: "Terms: %1",
|
|
53
|
+
terms_release: "Release",
|
|
54
|
+
terms_product: "Product",
|
|
55
|
+
terms_sale_in_force: "Sale in force",
|
|
56
|
+
terms_sale_waiting: "Sale waiting for release",
|
|
57
|
+
terms_referral_in_force: "Referral address in force",
|
|
58
|
+
terms_referral_waiting: "Referral address waiting for release",
|
|
59
|
+
terms_free_in_force: "Free in force",
|
|
60
|
+
terms_free_waiting: "Free waiting for release",
|
|
61
|
+
terms_account_in_force: "Account required in force",
|
|
62
|
+
terms_account_waiting: "Account required waiting for release",
|
|
63
|
+
terms_parts_in_force: "Bundle parts in force",
|
|
64
|
+
terms_parts_waiting: "Bundle parts waiting for release",
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export async function getPhiAccountingProductsPageLabels(options) {
|
|
68
|
+
const labels = await getPhiLabelSet(options, PHI_ACCOUNTING_PRODUCTS_PAGE_LABEL_SET);
|
|
69
|
+
return {
|
|
70
|
+
pageTitle: labels.page_title,
|
|
71
|
+
pageDescription: labels.page_description,
|
|
72
|
+
widgetLabel: labels.widget_label,
|
|
73
|
+
columns: {
|
|
74
|
+
picture: labels.column_picture,
|
|
75
|
+
title: labels.column_title,
|
|
76
|
+
id: labels.column_id,
|
|
77
|
+
supplier: labels.column_supplier,
|
|
78
|
+
kind: labels.column_kind,
|
|
79
|
+
state: labels.column_state,
|
|
80
|
+
sale: labels.column_sale,
|
|
81
|
+
free: labels.column_free,
|
|
82
|
+
account: labels.column_account,
|
|
83
|
+
parts: labels.column_parts,
|
|
84
|
+
waiting: labels.column_waiting,
|
|
85
|
+
},
|
|
86
|
+
states: {
|
|
87
|
+
draft: labels.state_draft,
|
|
88
|
+
active: labels.state_active,
|
|
89
|
+
withdrawn: labels.state_withdrawn,
|
|
90
|
+
locked: labels.state_locked,
|
|
91
|
+
},
|
|
92
|
+
sales: { own: labels.sale_own, referral: labels.sale_referral, payout: labels.sale_payout },
|
|
93
|
+
search: labels.search_placeholder,
|
|
94
|
+
filters: {
|
|
95
|
+
supplier: labels.filter_supplier,
|
|
96
|
+
supplierPlaceholder: labels.filter_supplier_placeholder,
|
|
97
|
+
state: labels.filter_state,
|
|
98
|
+
waiting: labels.filter_waiting,
|
|
99
|
+
},
|
|
100
|
+
footer: labels.footer,
|
|
101
|
+
empty: { title: labels.empty_title, text: labels.empty_text },
|
|
102
|
+
actions: {
|
|
103
|
+
release: labels.action_release,
|
|
104
|
+
lock: labels.action_lock,
|
|
105
|
+
unlock: labels.action_unlock,
|
|
106
|
+
cancel: labels.action_cancel,
|
|
107
|
+
},
|
|
108
|
+
release: { description: labels.release_description },
|
|
109
|
+
lock: { title: labels.lock_title, description: labels.lock_description },
|
|
110
|
+
unlock: { title: labels.unlock_title, description: labels.unlock_description },
|
|
111
|
+
terms: {
|
|
112
|
+
title: labels.terms_title,
|
|
113
|
+
titleOf: labels.terms_title_of,
|
|
114
|
+
release: labels.terms_release,
|
|
115
|
+
product: labels.terms_product,
|
|
116
|
+
sale: { inForce: labels.terms_sale_in_force, waiting: labels.terms_sale_waiting },
|
|
117
|
+
referral: { inForce: labels.terms_referral_in_force, waiting: labels.terms_referral_waiting },
|
|
118
|
+
free: { inForce: labels.terms_free_in_force, waiting: labels.terms_free_waiting },
|
|
119
|
+
account: { inForce: labels.terms_account_in_force, waiting: labels.terms_account_waiting },
|
|
120
|
+
parts: { inForce: labels.terms_parts_in_force, waiting: labels.terms_parts_waiting },
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PhiCmsPageNode, PhiResolvedCmsPageTree } from "../../../../types/cms";
|
|
2
|
+
import type { PhiBlockRuntime } from "../../../../types";
|
|
3
|
+
/**
|
|
4
|
+
* The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`).
|
|
5
|
+
*
|
|
6
|
+
* Every product of every supplier Add-on, in every state, for whoever the Accounting Area lets in --
|
|
7
|
+
* Admin, Maintainer and Accountant, the holders of Core's `accounting` access, which is also what Core
|
|
8
|
+
* asks of each act. The operator releases a publisher's terms and locks or unlocks; title, summary and
|
|
9
|
+
* picture stay the supplier's and are not edited here.
|
|
10
|
+
*
|
|
11
|
+
* The picture is a small column of its own and the icon stands ahead of the title, both the server's `icon`
|
|
12
|
+
* variant (`imageListPath`, `iconListPath`: 64 x 64, fitted whole, with their cache revisions).
|
|
13
|
+
* Releasing opens a dialog named after the product, whose record sets the terms in force beside the ones
|
|
14
|
+
* waiting; its Release runs the Provider's release on that record, and the dialog closes and the Table
|
|
15
|
+
* reads again. The dialog is the confirmation, so the release asks nothing more; lock and unlock stay the
|
|
16
|
+
* row's own acts with a question naming the product.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildPhiDefaultAccountingProductsPageTree({ page, runtime, }: {
|
|
19
|
+
page: PhiCmsPageNode;
|
|
20
|
+
runtime: PhiBlockRuntime;
|
|
21
|
+
}): Promise<PhiResolvedCmsPageTree>;
|