@phis/ui 0.7.5 → 0.7.8

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.
Files changed (158) hide show
  1. package/components/controls/phi-form-control.d.ts +3 -1
  2. package/components/controls/phi-form-control.js +15 -4
  3. package/components/forms/auth-admin-settings-labels.d.ts +1 -1
  4. package/components/forms/auth-admin-settings-labels.js +2 -2
  5. package/components/forms/extended-form-field-controls.d.ts +1 -1
  6. package/components/forms/extended-form-field-controls.js +23 -7
  7. package/components/forms/form-descriptor-contract.d.ts +1 -1
  8. package/components/forms/form-descriptor-contract.js +1 -1
  9. package/components/forms/form-descriptor-runtime-client.d.ts +4 -1
  10. package/components/forms/form-descriptor-runtime-client.js +33 -11
  11. package/components/forms/form-media-limits.d.ts +12 -0
  12. package/components/forms/form-media-limits.js +14 -0
  13. package/components/forms/form-provider-contract.d.ts +5 -0
  14. package/components/forms/form-provider-contract.js +9 -2
  15. package/components/forms/form-provider-registry.d.ts +14 -0
  16. package/components/forms/form-record-title.d.ts +14 -0
  17. package/components/forms/form-record-title.js +38 -0
  18. package/components/forms/form-widget-config.d.ts +3 -0
  19. package/components/forms/form-widget-config.js +2 -0
  20. package/components/forms/money-field-currency-key.d.ts +6 -0
  21. package/components/forms/money-field-currency-key.js +14 -0
  22. package/components/forms/money-field.d.ts +26 -3
  23. package/components/forms/money-field.js +54 -4
  24. package/components/forms/phi-form-widget.d.ts +1 -1
  25. package/components/forms/phi-form-widget.js +4 -0
  26. package/components/overlays/phi-overlay-container-client.js +8 -8
  27. package/components/overlays/phi-overlay-title.d.ts +7 -0
  28. package/components/overlays/phi-overlay-title.js +21 -0
  29. package/components/regions/presets/navigation-redirect.d.ts +4 -1
  30. package/components/regions/presets/navigation-redirect.js +6 -3
  31. package/components/tables/client/phi-table-binding.d.ts +3 -1
  32. package/components/tables/client/phi-table-binding.js +90 -49
  33. package/components/tables/client/phi-table-filter-options.d.ts +27 -0
  34. package/components/tables/client/phi-table-filter-options.js +35 -0
  35. package/components/widgets/accessible-areas.d.ts +1 -1
  36. package/components/widgets/accessible-areas.js +1 -1
  37. package/components/widgets/client/shared/phi-rendered-value.d.ts +10 -0
  38. package/components/widgets/client/shared/phi-rendered-value.js +54 -4
  39. package/components/widgets/client/shared/phi-table-provider.d.ts +10 -1
  40. package/components/widgets/client/shared/phi-table-provider.js +22 -0
  41. package/components/widgets/label-sets/admin-users.d.ts +15 -0
  42. package/components/widgets/label-sets/admin-users.js +31 -0
  43. package/constants/core-data-provider-keys.d.ts +7 -0
  44. package/constants/core-data-provider-keys.js +7 -0
  45. package/constants/phi-base-role-metadata.d.ts +2 -2
  46. package/constants/phi-base-role-metadata.js +1 -1
  47. package/constants/runtime-module-ownership.js +3 -0
  48. package/forms.d.ts +1 -1
  49. package/forms.js +1 -1
  50. package/gateway/capability-media-limits.d.ts +10 -0
  51. package/gateway/capability-media-limits.js +40 -0
  52. package/gateway/server-capabilities.js +4 -0
  53. package/helpers/money-amount.d.ts +7 -0
  54. package/helpers/money-amount.js +15 -0
  55. package/helpers/preset-tree-contract-check.d.ts +3 -2
  56. package/helpers/preset-tree-contract-check.js +60 -0
  57. package/helpers/record-title.d.ts +7 -0
  58. package/helpers/record-title.js +25 -0
  59. package/helpers/record-widget.d.ts +15 -0
  60. package/helpers/record-widget.js +57 -0
  61. package/package.json +2 -2
  62. package/plugins/runtime-modules/accounting/client-data-providers.d.ts +7 -0
  63. package/plugins/runtime-modules/accounting/client-data-providers.js +9 -0
  64. package/plugins/runtime-modules/accounting/data-providers.d.ts +63 -0
  65. package/plugins/runtime-modules/accounting/data-providers.js +127 -0
  66. package/plugins/runtime-modules/accounting/definition.d.ts +54 -2
  67. package/plugins/runtime-modules/accounting/definition.js +5 -3
  68. package/plugins/runtime-modules/accounting/ids.d.ts +20 -0
  69. package/plugins/runtime-modules/accounting/ids.js +27 -0
  70. package/plugins/runtime-modules/accounting/module.d.ts +52 -0
  71. package/plugins/runtime-modules/accounting/presets.js +23 -4
  72. package/plugins/runtime-modules/accounting/services/products-table.d.ts +93 -0
  73. package/plugins/runtime-modules/accounting/services/products-table.js +158 -0
  74. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.d.ts +86 -0
  75. package/plugins/runtime-modules/accounting/trees/accounting-products-label-set.js +123 -0
  76. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.d.ts +21 -0
  77. package/plugins/runtime-modules/accounting/trees/phi-default-accounting-products-page-tree.js +435 -0
  78. package/plugins/runtime-modules/app/presets.js +3 -6
  79. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.d.ts +3 -6
  80. package/plugins/runtime-modules/app/trees/phi-default-app-area-preset-tree.js +4 -7
  81. package/plugins/runtime-modules/area-definitions.js +2 -2
  82. package/plugins/runtime-modules/asset/media-asset-field.d.ts +15 -0
  83. package/plugins/runtime-modules/asset/media-asset-field.js +21 -0
  84. package/plugins/runtime-modules/asset/media-asset-form-control.d.ts +4 -0
  85. package/plugins/runtime-modules/asset/media-asset-form-control.js +10 -5
  86. package/plugins/runtime-modules/asset/media-assets-field.d.ts +8 -0
  87. package/plugins/runtime-modules/asset/media-assets-field.js +10 -0
  88. package/plugins/runtime-modules/asset/media-assets-form-control.d.ts +5 -0
  89. package/plugins/runtime-modules/asset/media-assets-form-control.js +15 -6
  90. package/plugins/runtime-modules/auth/admin-settings-forms.js +1 -1
  91. package/plugins/runtime-modules/builder/controller/client.d.ts +5 -5
  92. package/plugins/runtime-modules/builder/controller/client.js +2 -1
  93. package/plugins/runtime-modules/builder/controller/definition.d.ts +4 -4
  94. package/plugins/runtime-modules/builder/controller/definition.js +7 -0
  95. package/plugins/runtime-modules/builder/controller/draft-command-controller.d.ts +3 -1
  96. package/plugins/runtime-modules/builder/controller/draft-command-controller.js +2 -1
  97. package/plugins/runtime-modules/builder/controller/draft-status-controller.js +44 -17
  98. package/plugins/runtime-modules/builder/controller/server-definition.d.ts +4 -4
  99. package/plugins/runtime-modules/builder/controller/workspace-controller.d.ts +3 -1
  100. package/plugins/runtime-modules/builder/controller/workspace-controller.js +8 -10
  101. package/plugins/runtime-modules/builder/developer-workspace-store.d.ts +10 -0
  102. package/plugins/runtime-modules/builder/developer-workspace-store.js +35 -1
  103. package/plugins/runtime-modules/builder/offered-page-catalog.d.ts +6 -0
  104. package/plugins/runtime-modules/builder/offered-page-catalog.js +35 -6
  105. package/plugins/runtime-modules/builder/persistence.d.ts +4 -1
  106. package/plugins/runtime-modules/builder/persistence.js +10 -3
  107. package/plugins/runtime-modules/client-manifests/accounting.js +5 -1
  108. package/plugins/runtime-modules/core/cards.js +2 -2
  109. package/plugins/runtime-modules/core/client-data-providers.js +5 -0
  110. package/plugins/runtime-modules/core/data-providers.js +14 -0
  111. package/plugins/runtime-modules/core/definition.d.ts +5 -0
  112. package/plugins/runtime-modules/core/form-providers.d.ts +5 -0
  113. package/plugins/runtime-modules/core/services/site-members-options.d.ts +27 -0
  114. package/plugins/runtime-modules/core/services/site-members-options.js +55 -0
  115. package/plugins/runtime-modules/core/widgets/form/config.d.ts +5 -0
  116. package/plugins/runtime-modules/core/widgets/form/config.js +3 -0
  117. package/plugins/runtime-modules/core/widgets/record/actions.d.ts +20 -0
  118. package/plugins/runtime-modules/core/widgets/record/actions.js +77 -0
  119. package/plugins/runtime-modules/core/widgets/record/client.js +71 -8
  120. package/plugins/runtime-modules/core/widgets/record/config.d.ts +66 -1
  121. package/plugins/runtime-modules/core/widgets/record/config.js +71 -2
  122. package/plugins/runtime-modules/core/widgets/spacer/client.js +3 -3
  123. package/plugins/runtime-modules/core/widgets/table/client.js +33 -29
  124. package/plugins/runtime-modules/core/widgets/table/config.js +5 -1
  125. package/plugins/runtime-modules/groups/data-providers.js +1 -1
  126. package/plugins/runtime-modules/groups/definition.js +1 -1
  127. package/plugins/runtime-modules/groups/page-visibility.d.ts +1 -1
  128. package/plugins/runtime-modules/groups/page-visibility.js +1 -1
  129. package/plugins/runtime-modules/groups/presets.js +1 -1
  130. package/plugins/runtime-modules/groups/services/options.js +1 -1
  131. package/plugins/runtime-modules/groups/services/table.js +1 -1
  132. package/plugins/runtime-modules/groups/trees/phi-default-app-groups-page-tree.js +2 -2
  133. package/plugins/runtime-modules/phi-default-site-area-preset-tree.js +46 -39
  134. package/plugins/runtime-modules/preset-contracts/pub-area.d.ts +1 -1
  135. package/plugins/runtime-modules/preset-contracts/pub-area.js +1 -0
  136. package/plugins/runtime-modules/revisions/controller/client.js +48 -46
  137. package/plugins/runtime-modules/revisions/services/table.js +3 -1
  138. package/plugins/runtime-modules/user-management/addon-roles.d.ts +60 -4
  139. package/plugins/runtime-modules/user-management/addon-roles.js +92 -8
  140. package/plugins/runtime-modules/user-management/addresses.d.ts +1 -1
  141. package/plugins/runtime-modules/user-management/controller/client.js +1 -1
  142. package/plugins/runtime-modules/user-management/data-providers.js +1 -0
  143. package/plugins/runtime-modules/user-management/forms.js +22 -0
  144. package/plugins/runtime-modules/user-management/presets.js +2 -2
  145. package/plugins/runtime-modules/user-management/services/options.d.ts +4 -0
  146. package/plugins/runtime-modules/user-management/services/options.js +14 -6
  147. package/plugins/runtime-modules/user-management/services/table.js +12 -3
  148. package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +9 -4
  149. package/styles/builder-scaffold.css +7 -1
  150. package/styles/layout-authoring-scaffold.css +27 -0
  151. package/types/access.d.ts +1 -1
  152. package/types/access.js +7 -7
  153. package/types/core-widget-placements.d.ts +7 -0
  154. package/types/form-descriptor.d.ts +1 -1
  155. package/types/record-widget.d.ts +35 -0
  156. package/types/server-capabilities.d.ts +1 -1
  157. package/types/table-widget.d.ts +20 -0
  158. package/types/table-widget.js +44 -0
@@ -0,0 +1,57 @@
1
+ import { isPhiRecord } from "./is-record";
2
+ import { checkPhiRecordTitleTemplate } from "./record-title";
3
+ /*
4
+ * The record Widget's two readers that the descriptor compiler and the Widget share: its title from the
5
+ * record and its actions against the resource (TABLES.md, "The record Widget"). Apart from
6
+ * `types/record-widget.ts`, so the type stays a type for everything that only names it.
7
+ */
8
+ /**
9
+ * The placement's `titleFromRecord`, or null where it states none. Strict, as the Form's: no field, or a
10
+ * sentence without exactly one `%1`, is refused rather than read as no title.
11
+ */
12
+ export function readPhiRecordWidgetTitleFromRecord(value) {
13
+ if (value == null)
14
+ return null;
15
+ if (!isPhiRecord(value))
16
+ throw new Error(`Record titleFromRecord ${JSON.stringify(value)} is no { template, field }.`);
17
+ const field = typeof value.field === "string" ? value.field.trim() : "";
18
+ if (!field)
19
+ throw new Error("Record titleFromRecord.field must name the record field the title takes its value from.");
20
+ const template = typeof value.template === "string" ? value.template.trim() : "";
21
+ if (!template)
22
+ throw new Error("Record titleFromRecord.template must be the sentence the title is made of.");
23
+ const templateError = checkPhiRecordTitleTemplate(template);
24
+ if (templateError)
25
+ throw new Error(`Record titleFromRecord.template ${templateError}`);
26
+ return { template, field };
27
+ }
28
+ /**
29
+ * What the record Widget's actions ask of its resource, as the errors it shows instead of the record --
30
+ * the Table's binding check (`validatePhiTableWidgetBinding`) for the one scope a record has. Each action
31
+ * is the resource's, of scope `row`, named once, and drawn as the danger a destructive one is. A
32
+ * confirmation the resource requires is not asked for here: the record on screen, named in the dialog's
33
+ * title, and the press beside it are that confirmation, and a `confirm` would ask a second time.
34
+ */
35
+ export function validatePhiRecordWidgetBinding(config, resource) {
36
+ const errors = [];
37
+ const declared = new Map(resource.actions?.map((action) => [action.key, action]) ?? []);
38
+ const seen = new Set();
39
+ for (const action of config.actions) {
40
+ if (seen.has(action.key)) {
41
+ errors.push(`Record action "${action.key}" is configured more than once.`);
42
+ continue;
43
+ }
44
+ seen.add(action.key);
45
+ const capability = declared.get(action.key);
46
+ if (!capability) {
47
+ errors.push(`Record action "${action.key}" is not declared by resource "${resource.resourceKey}".`);
48
+ }
49
+ else if (capability.scope !== "row") {
50
+ errors.push(`Record action "${action.key}" cannot run on a record: its scope is "${capability.scope}".`);
51
+ }
52
+ else if (capability.intent === "destructive" && action.mode !== "danger") {
53
+ errors.push(`Destructive Record action "${action.key}" requires danger presentation.`);
54
+ }
55
+ }
56
+ return errors;
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phis/ui",
3
- "version": "0.7.5",
3
+ "version": "0.7.8",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -521,7 +521,7 @@
521
521
  "@lexical/rich-text": "0.50.0",
522
522
  "@lexical/selection": "0.50.0",
523
523
  "@lexical/utils": "0.50.0",
524
- "@phis/contracts": "^0.8.1",
524
+ "@phis/contracts": "^0.8.9",
525
525
  "dayjs": "^1.11.23",
526
526
  "dom-serializer": "^2.0.0",
527
527
  "htmlparser2": "^10.1.0",
@@ -0,0 +1,7 @@
1
+ export declare const PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS: readonly [{
2
+ readonly key: `${string}/${string}`;
3
+ readonly ownerModuleId: "@phis/ui/modules/accounting";
4
+ readonly loadLive: () => Promise<import("react").ComponentType<{
5
+ children: import("react").ReactNode;
6
+ }>>;
7
+ }];
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY, PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "./ids";
3
+ export const PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_CLIENT_DEFINITIONS = [
4
+ {
5
+ key: PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY,
6
+ ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
7
+ loadLive: async () => (await import("./services/products-table")).PhiAccountingProductsTableProviderClient,
8
+ },
9
+ ];
@@ -0,0 +1,63 @@
1
+ import type { PhiTableProviderFieldDefinition } from "../../../types/table-widget";
2
+ /**
3
+ * The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`), as the operator
4
+ * administers it: every product of every supplier Add-on, in every state.
5
+ *
6
+ * `live` and `authoringMode: "none"`: the Builder has no business reading a Site's products while somebody
7
+ * composes a Page. The rows come from `GET /api/site/products` and the three acts go to
8
+ * `POST /api/site/products/{id}/release|lock|unlock`, behind Core's Accounting guard; Core refuses them to
9
+ * anybody else whatever a Table offers. Nothing a supplier says of its product -- title, summary, picture
10
+ * -- is edited here: that stays the supplier's.
11
+ */
12
+ export declare const PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS: {
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: 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
+ }[];
@@ -0,0 +1,127 @@
1
+ import { PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY, PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY, PHI_ACCOUNTING_RUNTIME_MODULE_ID, } from "./ids";
2
+ const SALE_OPTIONS = [
3
+ { value: "own", label: "Own" },
4
+ { value: "referral", label: "Referral" },
5
+ { value: "payout", label: "Payout" },
6
+ ];
7
+ /**
8
+ * The terms the operator releases (`PhisProductReleasedTerms`), once as they are in force and once as
9
+ * they wait for the release, so a record can set the two side by side. A publisher's product never
10
+ * released has nothing in force yet; the Site's own has nothing waiting.
11
+ */
12
+ function termFields(prefix, title) {
13
+ return [
14
+ { key: `${prefix}Sale`, title: `Sale (${title})`, type: "enum", options: SALE_OPTIONS },
15
+ { key: `${prefix}ReferralUrl`, title: `Referral address (${title})`, type: "string" },
16
+ { key: `${prefix}Free`, title: `Free (${title})`, type: "boolean" },
17
+ { key: `${prefix}AccountRequired`, title: `Account required (${title})`, type: "boolean" },
18
+ { key: `${prefix}Parts`, title: `Bundle parts (${title})`, type: "json" },
19
+ ];
20
+ }
21
+ /**
22
+ * The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`), as the operator
23
+ * administers it: every product of every supplier Add-on, in every state.
24
+ *
25
+ * `live` and `authoringMode: "none"`: the Builder has no business reading a Site's products while somebody
26
+ * composes a Page. The rows come from `GET /api/site/products` and the three acts go to
27
+ * `POST /api/site/products/{id}/release|lock|unlock`, behind Core's Accounting guard; Core refuses them to
28
+ * anybody else whatever a Table offers. Nothing a supplier says of its product -- title, summary, picture
29
+ * -- is edited here: that stays the supplier's.
30
+ */
31
+ export const PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
32
+ {
33
+ key: PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY,
34
+ ownerModuleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
35
+ kind: "table",
36
+ executionMode: "live",
37
+ authoringMode: "none",
38
+ title: "Products",
39
+ description: "The Site's product directory: every supplier's products, their terms and their state.",
40
+ resources: [
41
+ {
42
+ resourceKey: PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY,
43
+ title: "Products",
44
+ rowIdentityPath: "id",
45
+ fields: [
46
+ { key: "id", title: "ID", type: "string", required: true },
47
+ { key: "title", title: "Title", type: "string" },
48
+ { key: "summary", title: "Summary", type: "string" },
49
+ { key: "supplier", title: "Supplier", type: "string" },
50
+ { key: "publisher", title: "Publisher", type: "string" },
51
+ { key: "type", title: "Kind", type: "string" },
52
+ {
53
+ key: "state",
54
+ title: "State",
55
+ type: "enum",
56
+ options: [
57
+ { value: "draft", label: "Draft" },
58
+ { value: "active", label: "Active" },
59
+ { value: "withdrawn", label: "Withdrawn" },
60
+ { value: "locked", label: "Locked" },
61
+ ],
62
+ },
63
+ // The state as a mark, for the two acts that each apply to one side of it.
64
+ { key: "locked", title: "Locked", type: "boolean" },
65
+ { key: "sale", title: "Sale", type: "enum", options: SALE_OPTIONS },
66
+ { key: "referralUrl", title: "Referral address", type: "string" },
67
+ { key: "free", title: "Free", type: "boolean" },
68
+ { key: "accountRequired", title: "Account required", type: "boolean" },
69
+ { key: "counted", title: "Counted", type: "boolean" },
70
+ { key: "parts", title: "Bundle parts", type: "json" },
71
+ { key: "partCount", title: "Bundle parts", type: "number" },
72
+ { key: "released", title: "Released", type: "boolean" },
73
+ // Never released, or released with terms pending: what the release acts on.
74
+ { key: "awaitingRelease", title: "Terms waiting for release", type: "boolean" },
75
+ ...termFields("inForce", "in force"),
76
+ ...termFields("pending", "waiting for release"),
77
+ { key: "imagePath", title: "Picture", type: "string" },
78
+ { key: "iconPath", title: "Icon", type: "string" },
79
+ // The same two as the server's small `icon` variant, ready for a line of the list.
80
+ { key: "imageListPath", title: "Picture (list)", type: "string" },
81
+ { key: "iconListPath", title: "Icon (list)", type: "string" },
82
+ { key: "version", title: "Version", type: "number" },
83
+ ],
84
+ query: {
85
+ search: true,
86
+ filterFields: ["supplier", "state", "pendingTerms"],
87
+ sorting: "none",
88
+ pagination: "offset",
89
+ total: true,
90
+ },
91
+ recordRead: true,
92
+ actions: [
93
+ {
94
+ key: "release",
95
+ title: "Release terms",
96
+ scope: "row",
97
+ intent: "write",
98
+ confirmation: "required",
99
+ disabledWhen: { match: "any", conditions: [
100
+ { source: "row", valuePath: "awaitingRelease", operator: "falsy" },
101
+ ] },
102
+ },
103
+ {
104
+ key: "lock",
105
+ title: "Lock",
106
+ scope: "row",
107
+ intent: "destructive",
108
+ confirmation: "required",
109
+ disabledWhen: { match: "any", conditions: [
110
+ { source: "row", valuePath: "locked", operator: "truthy" },
111
+ ] },
112
+ },
113
+ {
114
+ key: "unlock",
115
+ title: "Unlock",
116
+ scope: "row",
117
+ intent: "write",
118
+ confirmation: "required",
119
+ disabledWhen: { match: "any", conditions: [
120
+ { source: "row", valuePath: "locked", operator: "falsy" },
121
+ ] },
122
+ },
123
+ ],
124
+ },
125
+ ],
126
+ },
127
+ ];
@@ -1,10 +1,62 @@
1
1
  export declare const PHI_ACCOUNTING_RUNTIME_MODULE_DEFINITION: Omit<{
2
- area: "accounting";
3
- moduleId: "@phis/ui/modules/accounting";
4
2
  serverBinding: import("../../../types").PhiRuntimeModuleServerBinding;
5
3
  description: string;
6
4
  category: "foundation";
7
5
  icon: string;
6
+ dataProviders: {
7
+ key: `${string}/${string}`;
8
+ ownerModuleId: "@phis/ui/modules/accounting";
9
+ kind: "table";
10
+ executionMode: "live";
11
+ authoringMode: "none";
12
+ title: string;
13
+ description: string;
14
+ resources: {
15
+ resourceKey: string;
16
+ title: string;
17
+ rowIdentityPath: string;
18
+ fields: import("../../../types").PhiTableProviderFieldDefinition[];
19
+ query: {
20
+ search: true;
21
+ filterFields: string[];
22
+ sorting: "none";
23
+ pagination: "offset";
24
+ total: true;
25
+ };
26
+ recordRead: true;
27
+ actions: ({
28
+ key: string;
29
+ title: string;
30
+ scope: "row";
31
+ intent: "write";
32
+ confirmation: "required";
33
+ disabledWhen: {
34
+ match: "any";
35
+ conditions: {
36
+ source: "row";
37
+ valuePath: string;
38
+ operator: "falsy";
39
+ }[];
40
+ };
41
+ } | {
42
+ key: string;
43
+ title: string;
44
+ scope: "row";
45
+ intent: "destructive";
46
+ confirmation: "required";
47
+ disabledWhen: {
48
+ match: "any";
49
+ conditions: {
50
+ source: "row";
51
+ valuePath: string;
52
+ operator: "truthy";
53
+ }[];
54
+ };
55
+ })[];
56
+ }[];
57
+ }[];
58
+ moduleId: "@phis/ui/modules/accounting";
59
+ area: "accounting";
8
60
  }, "area"> & {
9
61
  kind: "module";
10
62
  eligibleAreas: readonly ["public" | "app" | "admin" | "builder" | "editor" | "accounting"];
@@ -1,11 +1,13 @@
1
1
  import { definePhiAreaBaseRuntimeModuleDefinition } from "../area-base-definition";
2
- import { PHI_ACCOUNTING_RUNTIME_MODULE_ID } from "./ids";
2
+ import { PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY } from "./ids";
3
+ import { PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "./data-providers";
3
4
  import { PHI_CORE_SERVER_BINDING, } from "../../../types/server-capabilities";
4
5
  export const PHI_ACCOUNTING_RUNTIME_MODULE_DEFINITION = definePhiAreaBaseRuntimeModuleDefinition({
5
6
  area: "accounting",
6
- moduleId: PHI_ACCOUNTING_RUNTIME_MODULE_ID,
7
+ ...PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY,
7
8
  serverBinding: PHI_CORE_SERVER_BINDING,
8
- description: "Locked Accounting Area shell, navigation surface, and root route.",
9
+ description: "Locked Accounting Area shell, navigation surface, root route, and the Site's product directory.",
9
10
  category: "foundation",
10
11
  icon: "antd:profile",
12
+ dataProviders: PHI_ACCOUNTING_RUNTIME_DATA_PROVIDER_DESCRIPTORS,
11
13
  });
@@ -1 +1,21 @@
1
1
  export declare const PHI_ACCOUNTING_RUNTIME_MODULE_ID: "@phis/ui/modules/accounting";
2
+ /**
3
+ * The Module's identity as its Label Sets inherit it (`definePhiRuntimeModuleLabelSet`): the id and,
4
+ * where a Module declares one, its source locale. Stated here beside the id and spread into the
5
+ * definition, so a Label Set a tree reads does not import the definition that imports the tree.
6
+ */
7
+ export declare const PHI_ACCOUNTING_RUNTIME_MODULE_IDENTITY: {
8
+ readonly moduleId: "@phis/ui/modules/accounting";
9
+ };
10
+ /**
11
+ * The Site's product directory (phis-server SERVER_ADDONS.md, `products:v1`): every product of every
12
+ * supplier Add-on, as the Site operator administers it. A Page of the Accounting Area itself rather than
13
+ * of a shop, because every supplier's products land in it and it has to work with no shop at all.
14
+ */
15
+ export declare const PHI_ACCOUNTING_PRODUCTS_DATA_PROVIDER_KEY: `${string}/${string}`;
16
+ /** The one resource the directory's Provider answers. */
17
+ export declare const PHI_ACCOUNTING_PRODUCTS_RESOURCE_KEY = "products";
18
+ export declare const PHI_ACCOUNTING_PRODUCTS_PAGE_PRESET_KEY = "accounting-products-page";
19
+ export declare const PHI_ACCOUNTING_PRODUCTS_PAGE_LAYOUT_IDS: Readonly<Record<"layoutTerms" | "layoutTermsFooter", import("@phis/contracts/cms").PhiCmsInstanceId>>;
20
+ export declare const PHI_ACCOUNTING_PRODUCTS_PAGE_OVERLAY_IDS: Readonly<Record<"overlayTerms", import("@phis/contracts/cms").PhiCmsInstanceId>>;
21
+ export declare const PHI_ACCOUNTING_PRODUCTS_PAGE_WIDGET_IDS: Readonly<Record<"widgetTable" | "widgetTerms" | "widgetTermsNote" | "widgetTermsCommands", import("@phis/contracts/cms").PhiCmsInstanceId>>;
@@ -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 and the Area root. No Page of its
7
- * own -- the Dashboard Module's entry stands first in the sidebar, so the root lands there, and every other
8
- * Accounting Page is a Module's.
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 {};