@phis/ui 0.8.0 → 0.8.1
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/cms/phi-cms-layout-renderer.js +15 -7
- package/components/cms/phi-cms-render-diagnostic-client.d.ts +3 -1
- package/components/cms/phi-cms-render-diagnostic-client.js +4 -3
- package/components/cms/phi-cms-render-diagnostic.d.ts +8 -2
- package/components/cms/phi-cms-render-diagnostic.js +12 -2
- package/components/cms/phi-cms-render-error-boundary.d.ts +2 -0
- package/components/cms/phi-cms-render-error-boundary.js +1 -1
- package/components/cms/phi-cms-root-layout.js +3 -1
- package/components/controls/phi-media-picker-control.d.ts +9 -0
- package/components/controls/phi-media-picker-control.js +1 -1
- package/components/controls/phi-popover-control.js +4 -1
- package/components/controls/phi-table-control.d.ts +7 -1
- package/components/controls/phi-table-control.js +23 -8
- package/components/forms/form-descriptor-field-check.d.ts +18 -0
- package/components/forms/form-descriptor-field-check.js +41 -0
- package/components/forms/form-descriptor-runtime-client.js +11 -10
- package/components/forms/form-record-source.d.ts +38 -0
- package/components/forms/form-record-source.js +48 -0
- package/components/forms/shared-form-descriptors.d.ts +0 -34
- package/components/forms/shared-form-descriptors.js +0 -6
- package/components/forms/shared-form-ids.d.ts +1 -1
- package/components/forms/shared-form-ids.js +1 -1
- package/components/media/media-settings-labels.d.ts +1 -0
- package/components/media/media-settings-labels.js +2 -0
- package/components/media/phi-media-picker-binding.d.ts +41 -33
- package/components/media/phi-media-picker-binding.js +2 -1
- package/components/media/use-media-library-add-picker.d.ts +33 -32
- package/components/overlays/phi-overlay-container-client.js +11 -9
- package/components/regions/presets/phi-settings-page-shell-tree.d.ts +7 -0
- package/components/regions/presets/phi-settings-page-shell-tree.js +3 -3
- package/components/shell/phi-icon-names.d.ts +3 -0
- package/components/shell/phi-icon-names.js +3 -0
- package/components/shell/phi-icon.d.ts +5 -7
- package/components/shell/phi-icon.js +8 -21
- package/components/tables/client/phi-table-binding-params.d.ts +24 -0
- package/components/tables/client/phi-table-binding-params.js +39 -0
- package/components/tables/client/phi-table-binding.d.ts +1 -3
- package/components/tables/client/phi-table-binding.js +5 -9
- package/components/widgets/client/shared/phi-button-icons.d.ts +6 -4
- package/components/widgets/client/shared/phi-button-icons.js +8 -12
- package/components/widgets/client/shared/phi-collection-binding-params.d.ts +8 -0
- package/components/widgets/client/shared/phi-collection-binding-params.js +13 -0
- package/components/widgets/client/shared/phi-collection-provider.d.ts +11 -1
- package/components/widgets/client/shared/phi-collection-provider.js +5 -0
- package/components/widgets/client/shared/phi-collection-view-binding.d.ts +1 -0
- package/components/widgets/client/shared/phi-command-buttons.d.ts +16 -0
- package/components/widgets/client/shared/phi-command-buttons.js +9 -1
- package/components/widgets/label-sets/admin-users.d.ts +1 -0
- package/components/widgets/label-sets/admin-users.js +2 -0
- package/components/widgets/label-sets/builder-modules.js +4 -0
- package/components/widgets/label-sets/profile.d.ts +0 -16
- package/components/widgets/label-sets/profile.js +0 -37
- package/components/widgets/label-sets/registration.d.ts +0 -1
- package/components/widgets/label-sets/registration.js +0 -2
- package/components/widgets/label-sets/revisions.js +2 -0
- package/components/widgets/label-sets/signals.js +2 -0
- package/components/widgets/label-types/builder-modules.d.ts +4 -0
- package/components/widgets/label-types/builder-modules.js +2 -0
- package/components/widgets/label-types/revisions.d.ts +2 -0
- package/components/widgets/label-types/revisions.js +2 -1
- package/components/widgets/label-types/signals.d.ts +2 -0
- package/components/widgets/label-types/signals.js +1 -0
- package/components/widgets/shared/widget-failure-audience.d.ts +7 -0
- package/components/widgets/shared/widget-failure-audience.js +21 -0
- package/components/widgets/shared/widget-failure-client.js +5 -2
- package/components/widgets/shared/widget-failure-notice-client.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice-client.js +10 -0
- package/components/widgets/shared/widget-failure-notice.d.ts +6 -0
- package/components/widgets/shared/widget-failure-notice.js +17 -0
- package/components/widgets/shared/widget-failure-staff.d.ts +3 -0
- package/components/widgets/shared/widget-failure-staff.js +18 -0
- package/components/widgets/shared/widget-failure.d.ts +9 -6
- package/components/widgets/shared/widget-failure.js +0 -9
- package/components/widgets/shared/widget-failure.server.d.ts +4 -2
- package/components/widgets/shared/widget-failure.server.js +8 -3
- package/constants/customer-file.d.ts +12 -3
- package/constants/customer-file.js +12 -3
- package/constants/runtime-module-ownership.js +4 -3
- package/constants/site-address.d.ts +9 -0
- package/constants/site-address.js +10 -0
- package/constants/table-loading.d.ts +14 -0
- package/constants/table-loading.js +14 -0
- package/constants.d.ts +2 -1
- package/constants.js +3 -1
- package/gateway/site-cms-write-validation.js +19 -3
- package/helpers/announced-action.d.ts +17 -0
- package/helpers/announced-action.js +29 -0
- package/helpers/phi-metadata.d.ts +0 -8
- package/helpers/phi-metadata.js +1 -10
- package/helpers/phi-site-description.d.ts +11 -0
- package/helpers/phi-site-description.js +13 -0
- package/helpers/preset-form-check.d.ts +14 -0
- package/helpers/preset-form-check.js +12 -0
- package/helpers/preset-table-check.d.ts +19 -15
- package/helpers/preset-table-check.js +33 -39
- package/helpers/record-widget-binding.d.ts +10 -0
- package/helpers/record-widget-binding.js +35 -0
- package/helpers/record-widget.d.ts +1 -10
- package/helpers/record-widget.js +4 -33
- package/helpers/table-widget-binding.d.ts +12 -0
- package/helpers/table-widget-binding.js +296 -0
- package/helpers/tree-widget-binding.d.ts +19 -0
- package/helpers/tree-widget-binding.js +72 -0
- package/helpers/typed-confirmation.d.ts +9 -0
- package/helpers/typed-confirmation.js +13 -0
- package/helpers/widget-binding-check.d.ts +22 -0
- package/helpers/widget-binding-check.js +91 -0
- package/module-page-check.d.ts +2 -0
- package/module-page-check.js +2 -0
- package/next/root-route.js +2 -1
- package/package.json +1 -1
- package/plugins/runtime-modules/accounting/ids.d.ts +7 -4
- package/plugins/runtime-modules/accounting/ids.js +14 -3
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.d.ts +21 -9
- package/plugins/runtime-modules/accounting/trees/accounting-customer-file-label-set.js +29 -15
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.d.ts +11 -8
- package/plugins/runtime-modules/accounting/trees/phi-default-accounting-customer-file-page-tree.js +206 -137
- package/plugins/runtime-modules/app/client-data-providers.js +1 -1
- package/plugins/runtime-modules/app/data-providers.d.ts +14 -69
- package/plugins/runtime-modules/app/data-providers.js +19 -54
- package/plugins/runtime-modules/app/definition.d.ts +8 -80
- package/plugins/runtime-modules/app/forms.d.ts +1 -16
- package/plugins/runtime-modules/app/forms.js +0 -59
- package/plugins/runtime-modules/app/ids.d.ts +2 -1
- package/plugins/runtime-modules/app/ids.js +3 -2
- package/plugins/runtime-modules/app/module.d.ts +8 -80
- package/plugins/runtime-modules/app/services/addresses-collection.d.ts +59 -0
- package/plugins/runtime-modules/app/services/{addresses-table.js → addresses-collection.js} +23 -19
- package/plugins/runtime-modules/app/trees/account-addresses-panel.d.ts +10 -6
- package/plugins/runtime-modules/app/trees/account-addresses-panel.js +37 -73
- package/plugins/runtime-modules/app/trees/addresses-label-set.d.ts +0 -5
- package/plugins/runtime-modules/app/trees/addresses-label-set.js +2 -6
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.d.ts +1 -2
- package/plugins/runtime-modules/app/trees/phi-default-app-profile-page-tree.js +1 -17
- package/plugins/runtime-modules/app/trees/profile-label-set.d.ts +0 -2
- package/plugins/runtime-modules/app/trees/profile-label-set.js +2 -14
- package/plugins/runtime-modules/asset/trees/phi-default-admin-media-settings-page-tree.js +5 -0
- package/plugins/runtime-modules/builder/clients/inspector-config-field.js +16 -6
- package/plugins/runtime-modules/builder/clients/inspector-image-field.js +3 -1
- package/plugins/runtime-modules/builder/clients/inspector-section-widget.js +3 -1
- package/plugins/runtime-modules/builder/controller/signal-wiring-controller.js +5 -1
- package/plugins/runtime-modules/builder/signal-wiring-options.js +9 -2
- package/plugins/runtime-modules/builder/trees/phi-builder-inspector-area-overlay-tree.server.js +5 -0
- package/plugins/runtime-modules/builder/trees/phi-default-builder-area-preset-tree.js +14 -1
- package/plugins/runtime-modules/client-manifests/common.js +6 -0
- package/plugins/runtime-modules/core/widgets/card/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/collection-view/client.js +5 -2
- package/plugins/runtime-modules/core/widgets/collection-view/config.js +8 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.d.ts +55 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-binding.js +173 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.d.ts +48 -0
- package/plugins/runtime-modules/core/widgets/collection-view/site-address-tiles.js +67 -0
- package/plugins/runtime-modules/core/widgets/command-toolbar/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/description/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/entry-list/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/float-button/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/form/config.js +14 -1
- package/plugins/runtime-modules/core/widgets/gallery/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/markdown/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/record/client.js +2 -6
- package/plugins/runtime-modules/core/widgets/result/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/simple-text/config.d.ts +1 -1
- package/plugins/runtime-modules/core/widgets/table/client.js +30 -48
- package/plugins/runtime-modules/core/widgets/table/config.d.ts +3 -3
- package/plugins/runtime-modules/core/widgets/table/config.js +3 -0
- package/plugins/runtime-modules/core/widgets/thread-conversation/client.js +2 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.d.ts +6 -2
- package/plugins/runtime-modules/core/widgets/thread-conversation/config.js +6 -1
- package/plugins/runtime-modules/core/widgets/thread-widget-config.d.ts +10 -0
- package/plugins/runtime-modules/core/widgets/thread-widget-config.js +6 -0
- package/plugins/runtime-modules/core/widgets/tree/client.js +6 -6
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.d.ts +2 -0
- package/plugins/runtime-modules/localization/trees/editor-translations-widget-label-set.js +2 -0
- package/plugins/runtime-modules/localization/trees/phi-default-editor-translations-page-tree.js +5 -0
- package/plugins/runtime-modules/revisions/controller/binding.d.ts +37 -0
- package/plugins/runtime-modules/revisions/controller/binding.js +75 -0
- package/plugins/runtime-modules/revisions/controller/client.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/client.js +74 -50
- package/plugins/runtime-modules/revisions/controller/definition.d.ts +5 -0
- package/plugins/runtime-modules/revisions/controller/definition.js +10 -0
- package/plugins/runtime-modules/revisions/forms.js +1 -1
- package/plugins/runtime-modules/revisions/page-ids.d.ts +1 -1
- package/plugins/runtime-modules/revisions/page-ids.js +4 -1
- package/plugins/runtime-modules/revisions/services/options.js +14 -4
- package/plugins/runtime-modules/revisions/services/table.js +41 -21
- package/plugins/runtime-modules/revisions/trees/phi-default-builder-revisions-page-tree.js +76 -3
- package/plugins/runtime-modules/theme/controller/runtime.js +14 -2
- package/plugins/runtime-modules/theme/widgets/brand-controls/client.js +39 -13
- package/plugins/runtime-modules/threads/client-data-providers.js +5 -0
- package/plugins/runtime-modules/threads/controller/client.js +62 -2
- package/plugins/runtime-modules/threads/controller/definition.js +48 -0
- package/plugins/runtime-modules/threads/data-providers.d.ts +22 -37
- package/plugins/runtime-modules/threads/data-providers.js +35 -24
- package/plugins/runtime-modules/threads/definition.d.ts +22 -37
- package/plugins/runtime-modules/threads/ids.d.ts +2 -0
- package/plugins/runtime-modules/threads/ids.js +2 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.d.ts +30 -0
- package/plugins/runtime-modules/threads/services/customer-file-addresses.js +59 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.d.ts +22 -0
- package/plugins/runtime-modules/threads/services/customer-file-read.js +101 -0
- package/plugins/runtime-modules/threads/services/customer-file-table.d.ts +14 -80
- package/plugins/runtime-modules/threads/services/customer-file-table.js +27 -112
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.d.ts +4 -0
- package/plugins/runtime-modules/user-management/trees/admin-users-access-label-set.js +4 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-access-page-tree.js +15 -0
- package/plugins/runtime-modules/user-management/trees/phi-default-admin-users-page-tree.js +5 -0
- package/server-helpers/runtime.js +0 -1
- package/styles/controls.css +4 -2
- package/styles/layout.css +7 -0
- package/theme/phi-antd-token-resolver.d.ts +8 -0
- package/theme/phi-antd-token-resolver.js +10 -0
- package/theme/phi-theme-color.d.ts +19 -0
- package/theme/phi-theme-color.js +42 -0
- package/theme/phi-theme-gradients.js +4 -22
- package/theme/phi-theme-palette-defaults.d.ts +16 -0
- package/theme/phi-theme-palette-defaults.js +103 -0
- package/types/cms-plugins.d.ts +6 -1
- package/types/collection-provider.d.ts +27 -0
- package/types/collection-signal-values.d.ts +2 -0
- package/types/collection-signal-values.js +23 -0
- package/types/collection-view-widget.d.ts +9 -0
- package/types/core-widget-placements.d.ts +6 -0
- package/types/signals.d.ts +2 -0
- package/types/signals.js +2 -0
- package/types/table-widget.d.ts +15 -1
- package/types/table-widget.js +0 -282
- package/types/tree-widget.d.ts +0 -1
- package/types/tree-widget.js +0 -60
- package/types/widget-runtime.d.ts +0 -1
- package/types.d.ts +1 -1
- package/types.js +1 -1
- package/plugins/runtime-modules/app/services/addresses-table.d.ts +0 -135
|
@@ -1,20 +1,23 @@
|
|
|
1
|
+
import { PHI_SITE_ADDRESS_ITEM_RENDERER_KEY } from "../../../constants/site-address";
|
|
2
|
+
import { PHI_SIGNAL_VALUE_SCHEMAS } from "../../../types/signals";
|
|
1
3
|
import { PHI_APP_ADDRESSES_DATA_PROVIDER_KEY, PHI_APP_ADDRESSES_RESOURCE_KEY, PHI_APP_RUNTIME_MODULE_ID, } from "./ids";
|
|
2
|
-
/** What an address is for, as the Table's tags name it; the bits are `PhisSiteAddressFlags`. */
|
|
3
|
-
const PHI_APP_ADDRESS_PURPOSES = ["billing", "shipping", "defaultBilling", "defaultShipping"];
|
|
4
4
|
/**
|
|
5
5
|
* The account's own address book on this Site (`users:v1`, phis-server SERVER_ADDONS.md): the current
|
|
6
|
-
* addresses only, never a `Superseded` or `Removed` one
|
|
6
|
+
* addresses only, never a `Superseded` or `Removed` one, as Core's address tiles draw them
|
|
7
|
+
* (`PHI_SITE_ADDRESS_ITEM_RENDERER_KEY`, COLLECTIONS.md "The address renderer").
|
|
7
8
|
*
|
|
8
9
|
* `live` and `authoringMode: "none"`: they are the signed-in person's, and nobody composing a Page has any
|
|
9
10
|
* business reading them. An address never changes in Core -- a change is a new version that replaces it --
|
|
10
|
-
* so the
|
|
11
|
-
* are the Module's two Forms
|
|
11
|
+
* so the item's id moves with every edit, which is why every write answers the list read again. Adding and
|
|
12
|
+
* changing are the Module's two Forms, opened by the toolbar's `create` and a tile's `edit` (the change
|
|
13
|
+
* Form reads the address through `readRecord`); removing and the two defaults are the Provider's actions.
|
|
14
|
+
* A chosen address is `{ addressId }` (`selectionValueSchema`), prepared for the Shop's checkout.
|
|
12
15
|
*/
|
|
13
16
|
export const PHI_APP_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
14
17
|
{
|
|
15
18
|
key: PHI_APP_ADDRESSES_DATA_PROVIDER_KEY,
|
|
16
19
|
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
17
|
-
kind: "
|
|
20
|
+
kind: "collection",
|
|
18
21
|
executionMode: "live",
|
|
19
22
|
authoringMode: "none",
|
|
20
23
|
title: "My addresses",
|
|
@@ -23,56 +26,18 @@ export const PHI_APP_RUNTIME_DATA_PROVIDER_DESCRIPTORS = [
|
|
|
23
26
|
{
|
|
24
27
|
resourceKey: PHI_APP_ADDRESSES_RESOURCE_KEY,
|
|
25
28
|
title: "Addresses",
|
|
26
|
-
|
|
29
|
+
itemIdentityPath: "id",
|
|
30
|
+
itemRendererKey: PHI_SITE_ADDRESS_ITEM_RENDERER_KEY,
|
|
31
|
+
selectionValueSchema: PHI_SIGNAL_VALUE_SCHEMAS.siteAddressSelection,
|
|
27
32
|
recordRead: true,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{ key: "name", title: "Name", type: "string" },
|
|
31
|
-
{ key: "companyName", title: "Company", type: "string" },
|
|
32
|
-
{ key: "line1", title: "Address line 1", type: "string" },
|
|
33
|
-
{ key: "line2", title: "Address line 2", type: "string" },
|
|
34
|
-
{ key: "postalCode", title: "Postal code", type: "string" },
|
|
35
|
-
{ key: "city", title: "City", type: "string" },
|
|
36
|
-
{ key: "region", title: "Region", type: "string" },
|
|
37
|
-
{ key: "country", title: "Country", type: "string" },
|
|
38
|
-
// The parts after the name on one line, for a list that is read rather than edited.
|
|
39
|
-
{ key: "lines", title: "Address", type: "string" },
|
|
40
|
-
{
|
|
41
|
-
key: "purposes",
|
|
42
|
-
title: "Purposes",
|
|
43
|
-
type: "enum[]",
|
|
44
|
-
options: PHI_APP_ADDRESS_PURPOSES.map((value) => ({ value, label: value })),
|
|
45
|
-
},
|
|
46
|
-
{ key: "billing", title: "Billing", type: "boolean" },
|
|
47
|
-
{ key: "shipping", title: "Shipping", type: "boolean" },
|
|
48
|
-
{ key: "defaultBilling", title: "Default billing", type: "boolean" },
|
|
49
|
-
{ key: "defaultShipping", title: "Default shipping", type: "boolean" },
|
|
50
|
-
{ key: "createdAt", title: "Added", type: "datetime" },
|
|
51
|
-
// What the edit Form opens on: the parts as the `address` field holds them, the purposes as `flags`.
|
|
52
|
-
{ key: "address", title: "Address parts", type: "json" },
|
|
53
|
-
{ key: "flags", title: "Flags", type: "number" },
|
|
54
|
-
],
|
|
55
|
-
query: { search: false, filterFields: [], sorting: "none", pagination: "none" },
|
|
33
|
+
defaultForWidget: true,
|
|
34
|
+
query: { search: false, pagination: false },
|
|
56
35
|
actions: [
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
disabledWhen: { match: "any", conditions: [
|
|
63
|
-
{ source: "row", valuePath: "defaultBilling", operator: "truthy" },
|
|
64
|
-
] },
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: "makeDefaultShipping",
|
|
68
|
-
title: "Use for shipping by default",
|
|
69
|
-
scope: "row",
|
|
70
|
-
intent: "write",
|
|
71
|
-
disabledWhen: { match: "any", conditions: [
|
|
72
|
-
{ source: "row", valuePath: "defaultShipping", operator: "truthy" },
|
|
73
|
-
] },
|
|
74
|
-
},
|
|
75
|
-
{ key: "delete", title: "Remove", scope: "row", intent: "destructive", confirmation: "required" },
|
|
36
|
+
{ key: "create", title: "Add address", scope: "resource" },
|
|
37
|
+
{ key: "edit", title: "Change", scope: "item" },
|
|
38
|
+
{ key: "makeDefaultBilling", title: "Use for billing by default", scope: "item" },
|
|
39
|
+
{ key: "makeDefaultShipping", title: "Use for shipping by default", scope: "item" },
|
|
40
|
+
{ key: "delete", title: "Remove", scope: "item" },
|
|
76
41
|
],
|
|
77
42
|
},
|
|
78
43
|
],
|
|
@@ -60,20 +60,6 @@ export declare const PHI_APP_RUNTIME_MODULE_DEFINITION: Omit<{
|
|
|
60
60
|
csrfPath: null;
|
|
61
61
|
requiresCsrf: false;
|
|
62
62
|
credentialPolicy: "site-session";
|
|
63
|
-
} | {
|
|
64
|
-
key: `${string}/${string}`;
|
|
65
|
-
ownerModuleId: "@phis/ui/modules/app";
|
|
66
|
-
title: string;
|
|
67
|
-
phase: "submit";
|
|
68
|
-
handlerKey: "site.app.profile-newsletter";
|
|
69
|
-
category: "site";
|
|
70
|
-
transport: "relay";
|
|
71
|
-
method: "PATCH";
|
|
72
|
-
endpointKey: null;
|
|
73
|
-
upstreamPath: string;
|
|
74
|
-
csrfPath: string;
|
|
75
|
-
requiresCsrf: true;
|
|
76
|
-
credentialPolicy: "site-session";
|
|
77
63
|
} | {
|
|
78
64
|
key: `${string}/${string}`;
|
|
79
65
|
ownerModuleId: "@phis/ui/modules/app";
|
|
@@ -107,7 +93,7 @@ export declare const PHI_APP_RUNTIME_MODULE_DEFINITION: Omit<{
|
|
|
107
93
|
dataProviders: {
|
|
108
94
|
key: `${string}/${string}`;
|
|
109
95
|
ownerModuleId: "@phis/ui/modules/app";
|
|
110
|
-
kind: "
|
|
96
|
+
kind: "collection";
|
|
111
97
|
executionMode: "live";
|
|
112
98
|
authoringMode: "none";
|
|
113
99
|
title: string;
|
|
@@ -115,81 +101,23 @@ export declare const PHI_APP_RUNTIME_MODULE_DEFINITION: Omit<{
|
|
|
115
101
|
resources: {
|
|
116
102
|
resourceKey: string;
|
|
117
103
|
title: string;
|
|
118
|
-
|
|
104
|
+
itemIdentityPath: string;
|
|
105
|
+
itemRendererKey: `${string}/${string}`;
|
|
106
|
+
selectionValueSchema: `${string}/signals/${string}`;
|
|
119
107
|
recordRead: true;
|
|
120
|
-
|
|
121
|
-
key: string;
|
|
122
|
-
title: string;
|
|
123
|
-
type: "number";
|
|
124
|
-
required: true;
|
|
125
|
-
options?: undefined;
|
|
126
|
-
} | {
|
|
127
|
-
key: string;
|
|
128
|
-
title: string;
|
|
129
|
-
type: "string";
|
|
130
|
-
required?: undefined;
|
|
131
|
-
options?: undefined;
|
|
132
|
-
} | {
|
|
133
|
-
key: string;
|
|
134
|
-
title: string;
|
|
135
|
-
type: "enum[]";
|
|
136
|
-
options: {
|
|
137
|
-
value: "billing" | "shipping" | "defaultBilling" | "defaultShipping";
|
|
138
|
-
label: "billing" | "shipping" | "defaultBilling" | "defaultShipping";
|
|
139
|
-
}[];
|
|
140
|
-
required?: undefined;
|
|
141
|
-
} | {
|
|
142
|
-
key: string;
|
|
143
|
-
title: string;
|
|
144
|
-
type: "boolean";
|
|
145
|
-
required?: undefined;
|
|
146
|
-
options?: undefined;
|
|
147
|
-
} | {
|
|
148
|
-
key: string;
|
|
149
|
-
title: string;
|
|
150
|
-
type: "datetime";
|
|
151
|
-
required?: undefined;
|
|
152
|
-
options?: undefined;
|
|
153
|
-
} | {
|
|
154
|
-
key: string;
|
|
155
|
-
title: string;
|
|
156
|
-
type: "json";
|
|
157
|
-
required?: undefined;
|
|
158
|
-
options?: undefined;
|
|
159
|
-
} | {
|
|
160
|
-
key: string;
|
|
161
|
-
title: string;
|
|
162
|
-
type: "number";
|
|
163
|
-
required?: undefined;
|
|
164
|
-
options?: undefined;
|
|
165
|
-
})[];
|
|
108
|
+
defaultForWidget: true;
|
|
166
109
|
query: {
|
|
167
110
|
search: false;
|
|
168
|
-
|
|
169
|
-
sorting: "none";
|
|
170
|
-
pagination: "none";
|
|
111
|
+
pagination: false;
|
|
171
112
|
};
|
|
172
113
|
actions: ({
|
|
173
114
|
key: string;
|
|
174
115
|
title: string;
|
|
175
|
-
scope: "
|
|
176
|
-
intent: "write";
|
|
177
|
-
disabledWhen: {
|
|
178
|
-
match: "any";
|
|
179
|
-
conditions: {
|
|
180
|
-
source: "row";
|
|
181
|
-
valuePath: string;
|
|
182
|
-
operator: "truthy";
|
|
183
|
-
}[];
|
|
184
|
-
};
|
|
185
|
-
confirmation?: undefined;
|
|
116
|
+
scope: "resource";
|
|
186
117
|
} | {
|
|
187
118
|
key: string;
|
|
188
119
|
title: string;
|
|
189
|
-
scope: "
|
|
190
|
-
intent: "destructive";
|
|
191
|
-
confirmation: "required";
|
|
192
|
-
disabledWhen?: undefined;
|
|
120
|
+
scope: "item";
|
|
193
121
|
})[];
|
|
194
122
|
}[];
|
|
195
123
|
}[];
|
|
@@ -15,11 +15,10 @@ export declare const PHI_APP_FORM_IDS: {
|
|
|
15
15
|
readonly profilePhone: `${string}/forms/${string}`;
|
|
16
16
|
readonly addressCreate: `${string}/forms/${string}`;
|
|
17
17
|
readonly addressEdit: `${string}/forms/${string}`;
|
|
18
|
-
readonly profileNewsletter: `${string}/forms/${string}`;
|
|
19
18
|
readonly profileLocale: `${string}/forms/${string}`;
|
|
20
19
|
readonly profileTheme: `${string}/forms/${string}`;
|
|
21
20
|
};
|
|
22
|
-
export declare const PHI_APP_RUNTIME_MODULE_FORMS: readonly [import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition
|
|
21
|
+
export declare const PHI_APP_RUNTIME_MODULE_FORMS: readonly [import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition, import("../contracts").PhiRuntimeModuleFormDefinition];
|
|
23
22
|
export declare const PHI_APP_FORM_HANDLER_PROVIDER_DESCRIPTORS: ({
|
|
24
23
|
key: `${string}/${string}`;
|
|
25
24
|
ownerModuleId: "@phis/ui/modules/app";
|
|
@@ -76,20 +75,6 @@ export declare const PHI_APP_FORM_HANDLER_PROVIDER_DESCRIPTORS: ({
|
|
|
76
75
|
csrfPath: null;
|
|
77
76
|
requiresCsrf: false;
|
|
78
77
|
credentialPolicy: "site-session";
|
|
79
|
-
} | {
|
|
80
|
-
key: `${string}/${string}`;
|
|
81
|
-
ownerModuleId: "@phis/ui/modules/app";
|
|
82
|
-
title: string;
|
|
83
|
-
phase: "submit";
|
|
84
|
-
handlerKey: "site.app.profile-newsletter";
|
|
85
|
-
category: "site";
|
|
86
|
-
transport: "relay";
|
|
87
|
-
method: "PATCH";
|
|
88
|
-
endpointKey: null;
|
|
89
|
-
upstreamPath: string;
|
|
90
|
-
csrfPath: string;
|
|
91
|
-
requiresCsrf: true;
|
|
92
|
-
credentialPolicy: "site-session";
|
|
93
78
|
} | {
|
|
94
79
|
key: `${string}/${string}`;
|
|
95
80
|
ownerModuleId: "@phis/ui/modules/app";
|
|
@@ -24,7 +24,6 @@ export const PHI_APP_FORM_IDS = {
|
|
|
24
24
|
profilePhone: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/profile-phone"),
|
|
25
25
|
addressCreate: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/address-create"),
|
|
26
26
|
addressEdit: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/address-edit"),
|
|
27
|
-
profileNewsletter: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/profile-newsletter"),
|
|
28
27
|
profileLocale: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/profile-locale"),
|
|
29
28
|
profileTheme: createPhiFormId(PHI_SHARED_PACKAGE_NAME, "app/profile-theme"),
|
|
30
29
|
};
|
|
@@ -33,14 +32,12 @@ const PHI_APP_FORM_HANDLER_KEYS = {
|
|
|
33
32
|
profilePhone: "site.app.profile-phone",
|
|
34
33
|
addressCreate: "site.app.address-create",
|
|
35
34
|
addressEdit: "site.app.address-edit",
|
|
36
|
-
profileNewsletter: "site.app.profile-newsletter",
|
|
37
35
|
profileLocale: "site.app.profile-locale",
|
|
38
36
|
profileTheme: "site.app.profile-theme",
|
|
39
37
|
};
|
|
40
38
|
const NAME_LABEL_SET_KEY = "@phis/ui/modules/app/labels/profile-name";
|
|
41
39
|
const PHONE_LABEL_SET_KEY = "@phis/ui/modules/app/labels/profile-phone";
|
|
42
40
|
const ADDRESS_LABEL_SET_KEY = "@phis/ui/modules/app/labels/address";
|
|
43
|
-
const NEWSLETTER_LABEL_SET_KEY = "@phis/ui/modules/app/labels/profile-newsletter";
|
|
44
41
|
const LOCALE_LABEL_SET_KEY = "@phis/ui/modules/app/labels/profile-locale";
|
|
45
42
|
const THEME_LABEL_SET_KEY = "@phis/ui/modules/app/labels/profile-theme";
|
|
46
43
|
const nameDescriptor = {
|
|
@@ -173,29 +170,6 @@ function addressDescriptor(formId, mode) {
|
|
|
173
170
|
layout: { gap: { compact: "sm", medium: "base" } },
|
|
174
171
|
};
|
|
175
172
|
}
|
|
176
|
-
/**
|
|
177
|
-
* One switch, and therefore no Save button: the Preset routes the Form's own `stateChange` back to
|
|
178
|
-
* its `submit` channel, so flipping it is the submit. A panel holding more than one field states a
|
|
179
|
-
* Save instead -- two fields changed one at a time would otherwise be two writes and one of them a
|
|
180
|
-
* half-finished thought.
|
|
181
|
-
*
|
|
182
|
-
* It says nothing on success for the same reason. A switch that stays where it was put has already
|
|
183
|
-
* told the person it worked; an alert under it would be a second answer to a question nobody asked.
|
|
184
|
-
*/
|
|
185
|
-
const newsletterDescriptor = {
|
|
186
|
-
schemaVersion: 1,
|
|
187
|
-
key: PHI_APP_FORM_IDS.profileNewsletter,
|
|
188
|
-
labelSetKey: NEWSLETTER_LABEL_SET_KEY,
|
|
189
|
-
fields: [
|
|
190
|
-
{
|
|
191
|
-
key: "newsletterOptIn",
|
|
192
|
-
fieldProviderKey: PHI_FORM_FIELD_PROVIDER_KEYS.switch,
|
|
193
|
-
controlLabel: label("newsletter", "Newsletter"),
|
|
194
|
-
description: label("newsletterDescription", "Receive product and platform updates for this site."),
|
|
195
|
-
},
|
|
196
|
-
],
|
|
197
|
-
layout: { gap: { compact: "sm", medium: "base" } },
|
|
198
|
-
};
|
|
199
173
|
/**
|
|
200
174
|
* The one language question, whose answers only the Site knows.
|
|
201
175
|
*
|
|
@@ -280,10 +254,6 @@ const loadPhoneLabels = createPhiFormLabelSetLoader(() => import("../../../compo
|
|
|
280
254
|
actions: { submitLabel: labels.submitLabel },
|
|
281
255
|
}));
|
|
282
256
|
const loadAddressLabels = createPhiFormLabelSetLoader(() => import("./trees/addresses-label-set").then((module) => module.getPhiAppAddressesLabels), (labels) => ({ ...labels.form, actions: { submitLabel: labels.save } }));
|
|
283
|
-
const loadNewsletterLabels = createPhiFormLabelSetLoader(() => import("../../../components/widgets/label-sets/profile").then((module) => module.getPhiProfileOverviewWidgetLabels), (labels) => ({
|
|
284
|
-
newsletter: labels.newsletterLabel,
|
|
285
|
-
newsletterDescription: labels.newsletterDescription,
|
|
286
|
-
}));
|
|
287
257
|
const loadLocaleLabels = createPhiFormLabelSetLoader(() => import("../../../components/widgets/label-sets/profile").then((module) => module.getPhiProfileLocaleWidgetLabels), (labels) => ({
|
|
288
258
|
fieldLabel: labels.fieldLabel,
|
|
289
259
|
}));
|
|
@@ -350,20 +320,6 @@ export const PHI_APP_RUNTIME_MODULE_FORMS = [
|
|
|
350
320
|
submitHandlerKey: PHI_APP_FORM_HANDLER_KEYS.addressEdit,
|
|
351
321
|
loadLabels: loadAddressLabels,
|
|
352
322
|
}),
|
|
353
|
-
definePhiRuntimeModuleForm({
|
|
354
|
-
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
355
|
-
areas: ["app"],
|
|
356
|
-
formId: PHI_APP_FORM_IDS.profileNewsletter,
|
|
357
|
-
version: 1,
|
|
358
|
-
flags: 0,
|
|
359
|
-
title: "Newsletter",
|
|
360
|
-
description: "Whether this account receives product and platform updates.",
|
|
361
|
-
category: "forms",
|
|
362
|
-
tags: ["profile", "account"],
|
|
363
|
-
descriptor: newsletterDescriptor,
|
|
364
|
-
submitHandlerKey: PHI_APP_FORM_HANDLER_KEYS.profileNewsletter,
|
|
365
|
-
loadLabels: loadNewsletterLabels,
|
|
366
|
-
}),
|
|
367
323
|
definePhiRuntimeModuleForm({
|
|
368
324
|
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
369
325
|
areas: ["app"],
|
|
@@ -465,21 +421,6 @@ export const PHI_APP_FORM_HANDLER_PROVIDER_DESCRIPTORS = [
|
|
|
465
421
|
requiresCsrf: false,
|
|
466
422
|
credentialPolicy: "site-session",
|
|
467
423
|
},
|
|
468
|
-
{
|
|
469
|
-
key: createPhiSharedFormProviderKey("handler", "app-profile-newsletter"),
|
|
470
|
-
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
471
|
-
title: "Profile newsletter",
|
|
472
|
-
phase: "submit",
|
|
473
|
-
handlerKey: PHI_APP_FORM_HANDLER_KEYS.profileNewsletter,
|
|
474
|
-
category: "site",
|
|
475
|
-
transport: "relay",
|
|
476
|
-
method: "PATCH",
|
|
477
|
-
endpointKey: null,
|
|
478
|
-
upstreamPath: "/api/v1/auth/profile/newsletter",
|
|
479
|
-
csrfPath: "/api/v1/auth/csrf",
|
|
480
|
-
requiresCsrf: true,
|
|
481
|
-
credentialPolicy: "site-session",
|
|
482
|
-
},
|
|
483
424
|
{
|
|
484
425
|
key: createPhiSharedFormProviderKey("handler", "app-profile-theme"),
|
|
485
426
|
ownerModuleId: PHI_APP_RUNTIME_MODULE_ID,
|
|
@@ -10,7 +10,8 @@ export declare const PHI_APP_RUNTIME_MODULE_IDENTITY: {
|
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
12
|
* The signed-in person's own addresses on this Site (phis-server `GET /api/site/account/addresses`,
|
|
13
|
-
* `users:v1`), as the account lists, adds, changes and removes them
|
|
13
|
+
* `users:v1`), as the account lists, adds, changes and removes them: a Collection drawn as address tiles
|
|
14
|
+
* (`PHI_SITE_ADDRESS_ITEM_RENDERER_KEY`).
|
|
14
15
|
*/
|
|
15
16
|
export declare const PHI_APP_ADDRESSES_DATA_PROVIDER_KEY: `${string}/${string}`;
|
|
16
17
|
/** The one resource the addresses Provider answers. */
|
|
@@ -12,8 +12,9 @@ export const PHI_APP_RUNTIME_MODULE_IDENTITY = {
|
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* The signed-in person's own addresses on this Site (phis-server `GET /api/site/account/addresses`,
|
|
15
|
-
* `users:v1`), as the account lists, adds, changes and removes them
|
|
15
|
+
* `users:v1`), as the account lists, adds, changes and removes them: a Collection drawn as address tiles
|
|
16
|
+
* (`PHI_SITE_ADDRESS_ITEM_RENDERER_KEY`).
|
|
16
17
|
*/
|
|
17
|
-
export const PHI_APP_ADDRESSES_DATA_PROVIDER_KEY = createPhiSharedRuntimeDataProviderKey("
|
|
18
|
+
export const PHI_APP_ADDRESSES_DATA_PROVIDER_KEY = createPhiSharedRuntimeDataProviderKey("collections", "app-addresses");
|
|
18
19
|
/** The one resource the addresses Provider answers. */
|
|
19
20
|
export const PHI_APP_ADDRESSES_RESOURCE_KEY = "addresses";
|
|
@@ -12,7 +12,7 @@ export declare const PHI_APP_RUNTIME_MODULE: {
|
|
|
12
12
|
dataProviders: {
|
|
13
13
|
key: `${string}/${string}`;
|
|
14
14
|
ownerModuleId: "@phis/ui/modules/app";
|
|
15
|
-
kind: "
|
|
15
|
+
kind: "collection";
|
|
16
16
|
executionMode: "live";
|
|
17
17
|
authoringMode: "none";
|
|
18
18
|
title: string;
|
|
@@ -20,81 +20,23 @@ export declare const PHI_APP_RUNTIME_MODULE: {
|
|
|
20
20
|
resources: {
|
|
21
21
|
resourceKey: string;
|
|
22
22
|
title: string;
|
|
23
|
-
|
|
23
|
+
itemIdentityPath: string;
|
|
24
|
+
itemRendererKey: `${string}/${string}`;
|
|
25
|
+
selectionValueSchema: `${string}/signals/${string}`;
|
|
24
26
|
recordRead: true;
|
|
25
|
-
|
|
26
|
-
key: string;
|
|
27
|
-
title: string;
|
|
28
|
-
type: "number";
|
|
29
|
-
required: true;
|
|
30
|
-
options?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
key: string;
|
|
33
|
-
title: string;
|
|
34
|
-
type: "string";
|
|
35
|
-
required?: undefined;
|
|
36
|
-
options?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
key: string;
|
|
39
|
-
title: string;
|
|
40
|
-
type: "enum[]";
|
|
41
|
-
options: {
|
|
42
|
-
value: "billing" | "shipping" | "defaultBilling" | "defaultShipping";
|
|
43
|
-
label: "billing" | "shipping" | "defaultBilling" | "defaultShipping";
|
|
44
|
-
}[];
|
|
45
|
-
required?: undefined;
|
|
46
|
-
} | {
|
|
47
|
-
key: string;
|
|
48
|
-
title: string;
|
|
49
|
-
type: "boolean";
|
|
50
|
-
required?: undefined;
|
|
51
|
-
options?: undefined;
|
|
52
|
-
} | {
|
|
53
|
-
key: string;
|
|
54
|
-
title: string;
|
|
55
|
-
type: "datetime";
|
|
56
|
-
required?: undefined;
|
|
57
|
-
options?: undefined;
|
|
58
|
-
} | {
|
|
59
|
-
key: string;
|
|
60
|
-
title: string;
|
|
61
|
-
type: "json";
|
|
62
|
-
required?: undefined;
|
|
63
|
-
options?: undefined;
|
|
64
|
-
} | {
|
|
65
|
-
key: string;
|
|
66
|
-
title: string;
|
|
67
|
-
type: "number";
|
|
68
|
-
required?: undefined;
|
|
69
|
-
options?: undefined;
|
|
70
|
-
})[];
|
|
27
|
+
defaultForWidget: true;
|
|
71
28
|
query: {
|
|
72
29
|
search: false;
|
|
73
|
-
|
|
74
|
-
sorting: "none";
|
|
75
|
-
pagination: "none";
|
|
30
|
+
pagination: false;
|
|
76
31
|
};
|
|
77
32
|
actions: ({
|
|
78
33
|
key: string;
|
|
79
34
|
title: string;
|
|
80
|
-
scope: "
|
|
81
|
-
intent: "write";
|
|
82
|
-
disabledWhen: {
|
|
83
|
-
match: "any";
|
|
84
|
-
conditions: {
|
|
85
|
-
source: "row";
|
|
86
|
-
valuePath: string;
|
|
87
|
-
operator: "truthy";
|
|
88
|
-
}[];
|
|
89
|
-
};
|
|
90
|
-
confirmation?: undefined;
|
|
35
|
+
scope: "resource";
|
|
91
36
|
} | {
|
|
92
37
|
key: string;
|
|
93
38
|
title: string;
|
|
94
|
-
scope: "
|
|
95
|
-
intent: "destructive";
|
|
96
|
-
confirmation: "required";
|
|
97
|
-
disabledWhen?: undefined;
|
|
39
|
+
scope: "item";
|
|
98
40
|
})[];
|
|
99
41
|
}[];
|
|
100
42
|
}[];
|
|
@@ -155,20 +97,6 @@ export declare const PHI_APP_RUNTIME_MODULE: {
|
|
|
155
97
|
csrfPath: null;
|
|
156
98
|
requiresCsrf: false;
|
|
157
99
|
credentialPolicy: "site-session";
|
|
158
|
-
} | {
|
|
159
|
-
key: `${string}/${string}`;
|
|
160
|
-
ownerModuleId: "@phis/ui/modules/app";
|
|
161
|
-
title: string;
|
|
162
|
-
phase: "submit";
|
|
163
|
-
handlerKey: "site.app.profile-newsletter";
|
|
164
|
-
category: "site";
|
|
165
|
-
transport: "relay";
|
|
166
|
-
method: "PATCH";
|
|
167
|
-
endpointKey: null;
|
|
168
|
-
upstreamPath: string;
|
|
169
|
-
csrfPath: string;
|
|
170
|
-
requiresCsrf: true;
|
|
171
|
-
credentialPolicy: "site-session";
|
|
172
100
|
} | {
|
|
173
101
|
key: `${string}/${string}`;
|
|
174
102
|
ownerModuleId: "@phis/ui/modules/app";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PhiCollectionProviderActionRequest, PhiCollectionProviderData, PhiCollectionProviderQueryRequest, PhiCollectionProviderRecordRequest } from "../../../../types/collection-provider";
|
|
2
|
+
/** The account's own address book (phis-server `/api/site/account/addresses`). */
|
|
3
|
+
export declare const PHI_APP_ADDRESSES_PATH = "/api/site/account/addresses";
|
|
4
|
+
declare function queryAddresses({ resourceKey, signal }: PhiCollectionProviderQueryRequest): Promise<PhiCollectionProviderData>;
|
|
5
|
+
/** One address for the change Form, opened from its tile: read from the list, as Core has no single read. */
|
|
6
|
+
declare function readAddressRecord({ resourceKey, rowIdentity, signal }: PhiCollectionProviderRecordRequest): Promise<{
|
|
7
|
+
createdAt: {} | null;
|
|
8
|
+
flags: number;
|
|
9
|
+
billing: boolean;
|
|
10
|
+
shipping: boolean;
|
|
11
|
+
defaultBilling: boolean;
|
|
12
|
+
defaultShipping: boolean;
|
|
13
|
+
address: {
|
|
14
|
+
[k: string]: string | null;
|
|
15
|
+
};
|
|
16
|
+
lines: string;
|
|
17
|
+
purposes: ("billing" | "shipping" | "defaultBilling" | "defaultShipping")[];
|
|
18
|
+
id: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
/** The request that gives a listed address the default it asks for, or throws where it has none listed. */
|
|
21
|
+
export declare function buildPhiAppAddressDefaultRequest(address: Record<string, unknown>, actionKey: "makeDefaultBilling" | "makeDefaultShipping"): {
|
|
22
|
+
address: {
|
|
23
|
+
[k: string]: {} | null;
|
|
24
|
+
};
|
|
25
|
+
flags: number;
|
|
26
|
+
};
|
|
27
|
+
declare function actOnAddress(request: PhiCollectionProviderActionRequest): Promise<PhiCollectionProviderData>;
|
|
28
|
+
export declare const PHI_APP_ADDRESSES_COLLECTION_PROVIDER_REGISTRATION: {
|
|
29
|
+
key: `${string}/${string}`;
|
|
30
|
+
resources: {
|
|
31
|
+
resourceKey: string;
|
|
32
|
+
title: string;
|
|
33
|
+
itemIdentityPath: string;
|
|
34
|
+
itemRendererKey: `${string}/${string}`;
|
|
35
|
+
selectionValueSchema: `${string}/signals/${string}`;
|
|
36
|
+
recordRead: true;
|
|
37
|
+
defaultForWidget: true;
|
|
38
|
+
query: {
|
|
39
|
+
search: false;
|
|
40
|
+
pagination: false;
|
|
41
|
+
};
|
|
42
|
+
actions: ({
|
|
43
|
+
key: string;
|
|
44
|
+
title: string;
|
|
45
|
+
scope: "resource";
|
|
46
|
+
} | {
|
|
47
|
+
key: string;
|
|
48
|
+
title: string;
|
|
49
|
+
scope: "item";
|
|
50
|
+
})[];
|
|
51
|
+
}[];
|
|
52
|
+
query: typeof queryAddresses;
|
|
53
|
+
readRecord: typeof readAddressRecord;
|
|
54
|
+
action: typeof actOnAddress;
|
|
55
|
+
};
|
|
56
|
+
export declare const PhiAppAddressesCollectionProviderClient: import("react").ComponentType<{
|
|
57
|
+
children: import("react").ReactNode;
|
|
58
|
+
}>;
|
|
59
|
+
export {};
|
|
@@ -3,8 +3,7 @@ import { PhisSiteAddressFlags } from "@phis/contracts/users";
|
|
|
3
3
|
import { isPhiRecord } from "../../../../helpers/is-record";
|
|
4
4
|
import { createPhiTableProviderRequestInit, readPhiPositiveInteger, readPhiTableRows, } from "../../../../components/widgets/client/shared/phi-table-provider-request";
|
|
5
5
|
import { readPhiTableProviderResponse, } from "../../../../components/widgets/client/shared/phi-table-provider-response";
|
|
6
|
-
import {
|
|
7
|
-
import { PhiTableProviderError, } from "../../../../types/table-widget";
|
|
6
|
+
import { createPhiCollectionProviderClient, } from "../../../../components/widgets/client/shared/phi-collection-provider";
|
|
8
7
|
import { PHI_APP_RUNTIME_DATA_PROVIDER_DESCRIPTORS } from "../data-providers";
|
|
9
8
|
import { PHI_APP_ADDRESSES_DATA_PROVIDER_KEY, PHI_APP_ADDRESSES_RESOURCE_KEY } from "../ids";
|
|
10
9
|
import { PHI_SITE_ADDRESS_TEXT_KEYS, toPhiSiteAddressRow } from "../../../../helpers/site-address-row";
|
|
@@ -19,7 +18,7 @@ const RESPONSE_OPTIONS = { subject: "Addresses" };
|
|
|
19
18
|
const listed = new Map();
|
|
20
19
|
function requireResource(resourceKey) {
|
|
21
20
|
if (resourceKey !== PHI_APP_ADDRESSES_RESOURCE_KEY) {
|
|
22
|
-
throw new
|
|
21
|
+
throw new Error(`Unknown addresses resource "${resourceKey}".`);
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
async function readAddresses(signal) {
|
|
@@ -33,17 +32,21 @@ async function readAddresses(signal) {
|
|
|
33
32
|
}
|
|
34
33
|
return items;
|
|
35
34
|
}
|
|
35
|
+
async function listAddresses(signal) {
|
|
36
|
+
const items = (await readAddresses(signal)).map(toPhiSiteAddressRow);
|
|
37
|
+
return { resourceKey: PHI_APP_ADDRESSES_RESOURCE_KEY, items, total: items.length, loading: false, error: null };
|
|
38
|
+
}
|
|
36
39
|
async function queryAddresses({ resourceKey, signal }) {
|
|
37
40
|
requireResource(resourceKey);
|
|
38
|
-
|
|
39
|
-
return { rows, total: rows.length };
|
|
41
|
+
return listAddresses(signal);
|
|
40
42
|
}
|
|
43
|
+
/** One address for the change Form, opened from its tile: read from the list, as Core has no single read. */
|
|
41
44
|
async function readAddressRecord({ resourceKey, rowIdentity, signal }) {
|
|
42
45
|
requireResource(resourceKey);
|
|
43
46
|
const id = readPhiPositiveInteger(rowIdentity);
|
|
44
47
|
const address = (await readAddresses(signal)).find((item) => item.id === id);
|
|
45
48
|
if (!id || !address) {
|
|
46
|
-
throw new
|
|
49
|
+
throw new Error("This address is no longer one of yours.");
|
|
47
50
|
}
|
|
48
51
|
return toPhiSiteAddressRow(address);
|
|
49
52
|
}
|
|
@@ -60,14 +63,16 @@ export function buildPhiAppAddressDefaultRequest(address, actionKey) {
|
|
|
60
63
|
flags: (flags & writable) | added,
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
|
-
|
|
66
|
+
/*
|
|
67
|
+
* A removal and the two defaults, each answered by the list as it now stands: a default moves from the
|
|
68
|
+
* address that held it, and a removal takes a tile. `create` and `edit` are announced by the tiles and
|
|
69
|
+
* open the Module's two Forms; they never reach here.
|
|
70
|
+
*/
|
|
71
|
+
async function actOnAddress(request) {
|
|
64
72
|
requireResource(request.resourceKey);
|
|
65
|
-
|
|
66
|
-
throw new PhiTableProviderError("mutation-not-supported", "Addresses are changed through their dialog, never in a cell.");
|
|
67
|
-
}
|
|
68
|
-
const id = readPhiPositiveInteger(request.rowIdentity);
|
|
73
|
+
const id = readPhiPositiveInteger(request.itemKey);
|
|
69
74
|
if (!id)
|
|
70
|
-
throw new
|
|
75
|
+
throw new Error("An address id is required.");
|
|
71
76
|
const init = createPhiTableProviderRequestInit(request.signal);
|
|
72
77
|
if (request.actionKey === "delete") {
|
|
73
78
|
await readPhiTableProviderResponse(await fetch(`${PHI_APP_ADDRESSES_PATH}/${id}`, { ...init, method: "DELETE" }), RESPONSE_OPTIONS);
|
|
@@ -75,7 +80,7 @@ async function mutateAddresses(request) {
|
|
|
75
80
|
else if (request.actionKey === "makeDefaultBilling" || request.actionKey === "makeDefaultShipping") {
|
|
76
81
|
const address = listed.get(id);
|
|
77
82
|
if (!isPhiRecord(address))
|
|
78
|
-
throw new
|
|
83
|
+
throw new Error("This address is no longer listed.");
|
|
79
84
|
await readPhiTableProviderResponse(await fetch(PHI_APP_ADDRESSES_PATH, {
|
|
80
85
|
...init,
|
|
81
86
|
method: "POST",
|
|
@@ -84,18 +89,17 @@ async function mutateAddresses(request) {
|
|
|
84
89
|
}), RESPONSE_OPTIONS);
|
|
85
90
|
}
|
|
86
91
|
else {
|
|
87
|
-
throw new
|
|
92
|
+
throw new Error(`Unsupported addresses action "${request.actionKey}".`);
|
|
88
93
|
}
|
|
89
|
-
|
|
90
|
-
return { status: "accepted", invalidation: "view" };
|
|
94
|
+
return listAddresses(request.signal);
|
|
91
95
|
}
|
|
92
96
|
const resources = PHI_APP_RUNTIME_DATA_PROVIDER_DESCRIPTORS
|
|
93
97
|
.find((descriptor) => descriptor.key === PHI_APP_ADDRESSES_DATA_PROVIDER_KEY)?.resources ?? [];
|
|
94
|
-
export const
|
|
98
|
+
export const PHI_APP_ADDRESSES_COLLECTION_PROVIDER_REGISTRATION = {
|
|
95
99
|
key: PHI_APP_ADDRESSES_DATA_PROVIDER_KEY,
|
|
96
100
|
resources,
|
|
97
101
|
query: queryAddresses,
|
|
98
102
|
readRecord: readAddressRecord,
|
|
99
|
-
|
|
103
|
+
action: actOnAddress,
|
|
100
104
|
};
|
|
101
|
-
export const
|
|
105
|
+
export const PhiAppAddressesCollectionProviderClient = createPhiCollectionProviderClient(PHI_APP_ADDRESSES_COLLECTION_PROVIDER_REGISTRATION);
|