@nuwah/vertical-sdk 0.0.0-stage → 0.2.0-rc.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/LICENSE +17 -0
- package/README.md +229 -2
- package/bin/nuwah-contract-check-rules.d.mts +41 -0
- package/bin/nuwah-contract-check-rules.mjs +333 -0
- package/bin/nuwah-contract-check.mjs +64 -0
- package/dist/accounting.d.ts +1417 -0
- package/dist/accounting.js +274 -0
- package/dist/active-org.d.ts +13 -0
- package/dist/active-org.js +59 -0
- package/dist/actors.d.ts +448 -0
- package/dist/actors.js +143 -0
- package/dist/ai.d.ts +359 -0
- package/dist/ai.js +229 -0
- package/dist/analytics.d.ts +37 -0
- package/dist/analytics.js +8 -0
- package/dist/atlas.d.ts +291 -0
- package/dist/atlas.js +78 -0
- package/dist/audit.d.ts +193 -0
- package/dist/audit.js +26 -0
- package/dist/authentication.d.ts +119 -0
- package/dist/authentication.js +83 -0
- package/dist/awards.d.ts +38 -0
- package/dist/awards.js +10 -0
- package/dist/blueprint/document.d.ts +178 -0
- package/dist/blueprint/document.js +17 -0
- package/dist/blueprint/index.d.ts +3 -0
- package/dist/blueprint/index.js +5 -0
- package/dist/blueprint/manifest.d.ts +105 -0
- package/dist/blueprint/manifest.js +11 -0
- package/dist/blueprint/validate.d.ts +14 -0
- package/dist/blueprint/validate.js +416 -0
- package/dist/bookings-directory.d.ts +118 -0
- package/dist/bookings-directory.js +289 -0
- package/dist/bookings-extra.d.ts +1448 -0
- package/dist/bookings-extra.js +582 -0
- package/dist/bookings.d.ts +1365 -0
- package/dist/bookings.js +305 -0
- package/dist/builder-code.d.ts +164 -0
- package/dist/builder-code.js +12 -0
- package/dist/builder-core-gaps.d.ts +83 -0
- package/dist/builder-core-gaps.js +8 -0
- package/dist/builder-repos.d.ts +73 -0
- package/dist/builder-repos.js +37 -0
- package/dist/builder.d.ts +730 -0
- package/dist/builder.js +105 -0
- package/dist/campaigns.d.ts +105 -0
- package/dist/campaigns.js +25 -0
- package/dist/catalogs.d.ts +188 -0
- package/dist/catalogs.js +36 -0
- package/dist/commerce-ai.d.ts +182 -0
- package/dist/commerce-ai.js +27 -0
- package/dist/connections.d.ts +278 -0
- package/dist/connections.js +96 -0
- package/dist/content-control.d.ts +121 -0
- package/dist/content-control.js +23 -0
- package/dist/contributions.d.ts +560 -0
- package/dist/contributions.js +140 -0
- package/dist/conversation-assist.d.ts +154 -0
- package/dist/conversation-assist.js +51 -0
- package/dist/conversation-info.d.ts +219 -0
- package/dist/conversation-info.js +43 -0
- package/dist/crm.d.ts +533 -0
- package/dist/crm.js +142 -0
- package/dist/dashboards.d.ts +119 -0
- package/dist/dashboards.js +22 -0
- package/dist/delegations.d.ts +161 -0
- package/dist/delegations.js +39 -0
- package/dist/docs.d.ts +289 -0
- package/dist/docs.js +49 -0
- package/dist/documents.d.ts +317 -0
- package/dist/documents.js +84 -0
- package/dist/drafts.d.ts +132 -0
- package/dist/drafts.js +56 -0
- package/dist/engagements.d.ts +133 -0
- package/dist/engagements.js +15 -0
- package/dist/event-stream.d.ts +54 -0
- package/dist/event-stream.js +228 -0
- package/dist/exchanges.d.ts +447 -0
- package/dist/exchanges.js +145 -0
- package/dist/exports.d.ts +113 -0
- package/dist/exports.js +81 -0
- package/dist/feeds.d.ts +228 -0
- package/dist/feeds.js +52 -0
- package/dist/files.d.ts +56 -0
- package/dist/files.js +55 -0
- package/dist/finance-insights.d.ts +41 -0
- package/dist/finance-insights.js +61 -0
- package/dist/fixed-assets.d.ts +155 -0
- package/dist/fixed-assets.js +28 -0
- package/dist/fulfilment-jobs.d.ts +405 -0
- package/dist/fulfilment-jobs.js +76 -0
- package/dist/fulfilment.d.ts +205 -0
- package/dist/fulfilment.js +39 -0
- package/dist/hr.d.ts +350 -0
- package/dist/hr.js +94 -0
- package/dist/http.d.ts +124 -0
- package/dist/http.js +392 -0
- package/dist/inbox.d.ts +206 -0
- package/dist/inbox.js +36 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +294 -0
- package/dist/insights.d.ts +176 -0
- package/dist/insights.js +52 -0
- package/dist/inventory.d.ts +797 -0
- package/dist/inventory.js +120 -0
- package/dist/list-query.d.ts +211 -0
- package/dist/list-query.js +158 -0
- package/dist/listings.d.ts +381 -0
- package/dist/listings.js +173 -0
- package/dist/location-sharing.d.ts +83 -0
- package/dist/location-sharing.js +20 -0
- package/dist/marketplace.d.ts +268 -0
- package/dist/marketplace.js +59 -0
- package/dist/matching.d.ts +103 -0
- package/dist/matching.js +22 -0
- package/dist/media.d.ts +221 -0
- package/dist/media.js +239 -0
- package/dist/metrics.d.ts +125 -0
- package/dist/metrics.js +45 -0
- package/dist/moderation.d.ts +240 -0
- package/dist/moderation.js +40 -0
- package/dist/money.d.ts +41 -0
- package/dist/money.js +79 -0
- package/dist/my-data.d.ts +266 -0
- package/dist/my-data.js +32 -0
- package/dist/names.d.ts +14 -0
- package/dist/names.js +17 -0
- package/dist/occasions.d.ts +256 -0
- package/dist/occasions.js +40 -0
- package/dist/onboarding.d.ts +88 -0
- package/dist/onboarding.js +38 -0
- package/dist/pagination.d.ts +204 -0
- package/dist/pagination.js +141 -0
- package/dist/party-baseline-attributes.d.ts +245 -0
- package/dist/party-baseline-attributes.js +36 -0
- package/dist/party.d.ts +401 -0
- package/dist/party.js +56 -0
- package/dist/patient.d.ts +161 -0
- package/dist/patient.js +45 -0
- package/dist/payroll.d.ts +378 -0
- package/dist/payroll.js +60 -0
- package/dist/person-addresses.d.ts +88 -0
- package/dist/person-addresses.js +18 -0
- package/dist/person-cart.d.ts +250 -0
- package/dist/person-cart.js +63 -0
- package/dist/person-chat-assist.d.ts +47 -0
- package/dist/person-chat-assist.js +13 -0
- package/dist/person-data-webhooks.d.ts +72 -0
- package/dist/person-data-webhooks.js +86 -0
- package/dist/person-data.d.ts +212 -0
- package/dist/person-data.js +162 -0
- package/dist/person-locations.d.ts +54 -0
- package/dist/person-locations.js +6 -0
- package/dist/person-messaging.d.ts +405 -0
- package/dist/person-messaging.js +112 -0
- package/dist/person-notifications.d.ts +319 -0
- package/dist/person-notifications.js +164 -0
- package/dist/personalisation.d.ts +21 -0
- package/dist/personalisation.js +8 -0
- package/dist/platform.d.ts +63 -0
- package/dist/platform.js +45 -0
- package/dist/portfolio.d.ts +163 -0
- package/dist/portfolio.js +28 -0
- package/dist/pos.d.ts +743 -0
- package/dist/pos.js +129 -0
- package/dist/procurement.d.ts +664 -0
- package/dist/procurement.js +157 -0
- package/dist/promotions.d.ts +169 -0
- package/dist/promotions.js +39 -0
- package/dist/publications.d.ts +583 -0
- package/dist/publications.js +164 -0
- package/dist/ranking.d.ts +43 -0
- package/dist/ranking.js +34 -0
- package/dist/ratings.d.ts +293 -0
- package/dist/ratings.js +109 -0
- package/dist/reactions.d.ts +123 -0
- package/dist/reactions.js +41 -0
- package/dist/recipient-orders.d.ts +294 -0
- package/dist/recipient-orders.js +73 -0
- package/dist/relationships.d.ts +18 -0
- package/dist/relationships.js +8 -0
- package/dist/reporting.d.ts +107 -0
- package/dist/reporting.js +56 -0
- package/dist/sales.d.ts +270 -0
- package/dist/sales.js +66 -0
- package/dist/shares.d.ts +105 -0
- package/dist/shares.js +27 -0
- package/dist/shop.d.ts +993 -0
- package/dist/shop.js +215 -0
- package/dist/shopping-assistant.d.ts +65 -0
- package/dist/shopping-assistant.js +14 -0
- package/dist/spaces.d.ts +422 -0
- package/dist/spaces.js +118 -0
- package/dist/stored-value.d.ts +754 -0
- package/dist/stored-value.js +177 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/vault.d.ts +290 -0
- package/dist/vault.js +55 -0
- package/dist/vertical-runtime.d.ts +17 -0
- package/dist/vertical-runtime.js +8 -0
- package/dist/vite/build-manifest-plugin.d.ts +42 -0
- package/dist/vite/build-manifest-plugin.js +42 -0
- package/dist/vite/first-paint-plugin.d.ts +26 -0
- package/dist/vite/first-paint-plugin.js +57 -0
- package/dist/wishlists.d.ts +591 -0
- package/dist/wishlists.js +188 -0
- package/dist/workbench.d.ts +114 -0
- package/dist/workbench.js +22 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +41 -0
- package/package.json +52 -4
- package/templates/extension-image.Dockerfile +38 -0
- package/templates/nuwah-vertical.yml +102 -0
- package/templates/vertical-app/.env.example +34 -0
- package/templates/vertical-app/README.md +108 -0
- package/templates/vertical-app/github/workflows/ci.yml +51 -0
- package/templates/vertical-app/gitignore +5 -0
- package/templates/vertical-app/index.html +12 -0
- package/templates/vertical-app/package.json +28 -0
- package/templates/vertical-app/src/App.tsx +64 -0
- package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
- package/templates/vertical-app/src/blueprint/screens.ts +15 -0
- package/templates/vertical-app/src/env.d.ts +18 -0
- package/templates/vertical-app/src/index.css +139 -0
- package/templates/vertical-app/src/lib/i18n.ts +5 -0
- package/templates/vertical-app/src/lib/iam.ts +19 -0
- package/templates/vertical-app/src/lib/operations.ts +93 -0
- package/templates/vertical-app/src/lib/router.ts +24 -0
- package/templates/vertical-app/src/lib/sdk.ts +21 -0
- package/templates/vertical-app/src/lib/theme.ts +18 -0
- package/templates/vertical-app/src/lib/words.ts +39 -0
- package/templates/vertical-app/src/main.tsx +25 -0
- package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
- package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
- package/templates/vertical-app/src/pages/Home.tsx +36 -0
- package/templates/vertical-app/tsconfig.json +24 -0
- package/templates/vertical-app/vite.config.ts +23 -0
- package/templates/vertical-ci.yml +192 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
import { type ListPage, type ListQueryState } from './list-query.js';
|
|
4
|
+
export interface PersonCartMoney {
|
|
5
|
+
/** The decimal, rounded to the currency's precision: for display fallbacks only. */
|
|
6
|
+
amount: string;
|
|
7
|
+
/** An integer of the currency's minor unit (fils, cents): the one to compute with. */
|
|
8
|
+
amount_minor: number;
|
|
9
|
+
currency_code: string;
|
|
10
|
+
currency_decimals: number;
|
|
11
|
+
}
|
|
12
|
+
export type PersonCartLineStatus = 'ok' | 'price_changed' | 'out_of_stock' | 'unavailable' | (string & {});
|
|
13
|
+
export type PersonCartLineState = 'active' | 'saved_for_later';
|
|
14
|
+
export type PersonCartLocalisedName = Partial<BilingualText> & Record<string, string>;
|
|
15
|
+
export interface PersonCartShopReference {
|
|
16
|
+
tenant_id: string;
|
|
17
|
+
slug: string | null;
|
|
18
|
+
name: PersonCartLocalisedName;
|
|
19
|
+
}
|
|
20
|
+
export interface PersonCartLine {
|
|
21
|
+
id: string;
|
|
22
|
+
state: PersonCartLineState;
|
|
23
|
+
status: PersonCartLineStatus;
|
|
24
|
+
shop_item_id: string;
|
|
25
|
+
/** The catalog entry that shows this item: open its preview in place with it. */
|
|
26
|
+
catalog_entry_id: string | null;
|
|
27
|
+
name: PersonCartLocalisedName;
|
|
28
|
+
image_url: string | null;
|
|
29
|
+
/** The version and add-ons chosen ("Large · Red + Engraving"); null for an item sold as one thing (MARKET-CATALOG). */
|
|
30
|
+
choice_label?: PersonCartLocalisedName | null;
|
|
31
|
+
variant_id?: string | null;
|
|
32
|
+
modifier_option_ids?: string[];
|
|
33
|
+
quantity: number;
|
|
34
|
+
/** Null when the item is not stock-tracked (always available). */
|
|
35
|
+
available_quantity: number | null;
|
|
36
|
+
/** The price the person saw when they added it. */
|
|
37
|
+
unit_price: PersonCartMoney;
|
|
38
|
+
/** What the shop asks now. */
|
|
39
|
+
live_unit_price: PersonCartMoney;
|
|
40
|
+
line_total: PersonCartMoney;
|
|
41
|
+
recipient_name: string | null;
|
|
42
|
+
recipient_message: string | null;
|
|
43
|
+
created_at: string;
|
|
44
|
+
/** Saved-for-later lines only. */
|
|
45
|
+
shop?: PersonCartShopReference;
|
|
46
|
+
}
|
|
47
|
+
export interface PersonCartPaymentOption {
|
|
48
|
+
unit_key: string;
|
|
49
|
+
unit_label: PersonCartLocalisedName;
|
|
50
|
+
balance: PersonCartMoney;
|
|
51
|
+
}
|
|
52
|
+
export interface PersonCartShop {
|
|
53
|
+
tenant_id: string;
|
|
54
|
+
slug: string | null;
|
|
55
|
+
name: PersonCartLocalisedName;
|
|
56
|
+
open: boolean;
|
|
57
|
+
currency_code: string;
|
|
58
|
+
currency_decimals: number;
|
|
59
|
+
fulfillment: {
|
|
60
|
+
options: Array<'pickup' | 'delivery'>;
|
|
61
|
+
pickup_location: unknown;
|
|
62
|
+
};
|
|
63
|
+
lines: PersonCartLine[];
|
|
64
|
+
subtotal: PersonCartMoney;
|
|
65
|
+
/** The person's balances accepted at this shop, in its currency. */
|
|
66
|
+
payment_options: PersonCartPaymentOption[];
|
|
67
|
+
}
|
|
68
|
+
export interface PersonCartChange {
|
|
69
|
+
line_id: string;
|
|
70
|
+
status: PersonCartLineStatus;
|
|
71
|
+
unit_price: string;
|
|
72
|
+
live_unit_price: string | null;
|
|
73
|
+
currency_code: string;
|
|
74
|
+
quantity: number;
|
|
75
|
+
available_quantity: number | null;
|
|
76
|
+
}
|
|
77
|
+
export interface PersonCart {
|
|
78
|
+
shops: PersonCartShop[];
|
|
79
|
+
saved_for_later: PersonCartLine[];
|
|
80
|
+
/** One per currency, never summed across currencies; [] when the policy shows none. */
|
|
81
|
+
totals: PersonCartMoney[];
|
|
82
|
+
total_display: 'per_currency' | 'none';
|
|
83
|
+
currencies: string[];
|
|
84
|
+
line_count: number;
|
|
85
|
+
changes: PersonCartChange[];
|
|
86
|
+
can_check_out: boolean;
|
|
87
|
+
}
|
|
88
|
+
/** A line as written (add, change, remove, restore). `removed` → offer "undo". */
|
|
89
|
+
export interface PersonCartLineWritten {
|
|
90
|
+
id: string;
|
|
91
|
+
state: PersonCartLineState;
|
|
92
|
+
removed: boolean;
|
|
93
|
+
shop: PersonCartShopReference;
|
|
94
|
+
shop_item_id: string;
|
|
95
|
+
catalog_entry_id: string | null;
|
|
96
|
+
name: PersonCartLocalisedName;
|
|
97
|
+
image_url: string | null;
|
|
98
|
+
quantity: number;
|
|
99
|
+
unit_price: PersonCartMoney;
|
|
100
|
+
recipient_name: string | null;
|
|
101
|
+
/** The version and add-ons chosen ("Large · Red + Engraving"); null for an item sold as one thing (MARKET-CATALOG). */
|
|
102
|
+
choice_label?: PersonCartLocalisedName | null;
|
|
103
|
+
variant_id?: string | null;
|
|
104
|
+
modifier_option_ids?: string[];
|
|
105
|
+
recipient_message: string | null;
|
|
106
|
+
created_at: string;
|
|
107
|
+
updated_at: string;
|
|
108
|
+
}
|
|
109
|
+
export type PersonCartCheckoutStatus = 'placing' | 'completed' | 'partially_completed' | 'failed' | (string & {});
|
|
110
|
+
export type PersonCartCheckoutOrderStatus = 'pending' | 'held' | 'confirmed' | 'paid' | 'released' | 'failed' | (string & {});
|
|
111
|
+
export interface PersonCartCheckoutOrder {
|
|
112
|
+
id: string;
|
|
113
|
+
/** `order` for the person; `recipient_order` for someone who claims it by link. */
|
|
114
|
+
kind: 'order' | 'recipient_order';
|
|
115
|
+
status: PersonCartCheckoutOrderStatus;
|
|
116
|
+
succeeded: boolean;
|
|
117
|
+
shop: PersonCartShopReference;
|
|
118
|
+
recipient_name: string | null;
|
|
119
|
+
order_id: string | null;
|
|
120
|
+
order_reference: string | null;
|
|
121
|
+
recipient_order_id: string | null;
|
|
122
|
+
items: Array<{
|
|
123
|
+
shop_item_id: string;
|
|
124
|
+
name: PersonCartLocalisedName;
|
|
125
|
+
quantity: number;
|
|
126
|
+
image_url: string | null;
|
|
127
|
+
}>;
|
|
128
|
+
quoted_total: PersonCartMoney;
|
|
129
|
+
amount: PersonCartMoney | null;
|
|
130
|
+
payment_unit_key: string;
|
|
131
|
+
failure_reason: string | null;
|
|
132
|
+
}
|
|
133
|
+
export interface PersonCartCheckout {
|
|
134
|
+
id: string;
|
|
135
|
+
status: PersonCartCheckoutStatus;
|
|
136
|
+
status_label: BilingualText;
|
|
137
|
+
payment_policy: 'all_or_nothing' | 'per_shop';
|
|
138
|
+
failure_reason: string | null;
|
|
139
|
+
totals: PersonCartMoney[];
|
|
140
|
+
order_count: number;
|
|
141
|
+
orders: PersonCartCheckoutOrder[];
|
|
142
|
+
completed_at: string | null;
|
|
143
|
+
created_at: string;
|
|
144
|
+
updated_at: string;
|
|
145
|
+
}
|
|
146
|
+
export interface AddToPersonCartRequest {
|
|
147
|
+
/** From the cross-catalog search; OR `shop_slug` + `shop_item_id`. */
|
|
148
|
+
catalog_entry_id?: string;
|
|
149
|
+
shop_slug?: string;
|
|
150
|
+
shop_item_id?: string;
|
|
151
|
+
/**
|
|
152
|
+
* The version chosen (MARKET-CATALOG). Needed when the item has more than one version on sale;
|
|
153
|
+
* refused 422 `shop_variant_required` / `shop_variant_unavailable` otherwise.
|
|
154
|
+
*/
|
|
155
|
+
variant_id?: string | null;
|
|
156
|
+
/** The add-ons chosen; each group's minimum and maximum apply (422 `shop_option_choices`). */
|
|
157
|
+
modifier_option_ids?: string[];
|
|
158
|
+
/** 1–99; adding the same choice again adds to its line; another version is another line. */
|
|
159
|
+
quantity?: number;
|
|
160
|
+
/** Buy it for someone who claims it by link (1–120). */
|
|
161
|
+
recipient_name?: string | null;
|
|
162
|
+
/** At most 500 characters, only with a recipient. */
|
|
163
|
+
recipient_message?: string | null;
|
|
164
|
+
}
|
|
165
|
+
export interface CheckOutPersonCartRequest {
|
|
166
|
+
buyer: {
|
|
167
|
+
name: string;
|
|
168
|
+
phone: string;
|
|
169
|
+
email?: string | null;
|
|
170
|
+
};
|
|
171
|
+
/** 1–10 balances in order of preference; each shop takes the first it accepts in its currency. */
|
|
172
|
+
unit_keys: string[];
|
|
173
|
+
/** Per shop tenant id. Pickup when absent. */
|
|
174
|
+
fulfillment?: Record<string, {
|
|
175
|
+
fulfillment: 'pickup' | 'delivery';
|
|
176
|
+
delivery_address?: string | null;
|
|
177
|
+
}>;
|
|
178
|
+
}
|
|
179
|
+
export type PersonCartCheckoutListQuery = ListQueryState;
|
|
180
|
+
/** The answer of "Buy again": each line of the order, added at today's price or not added and why. */
|
|
181
|
+
export interface PersonCartBuyAgain {
|
|
182
|
+
person_order_id: string;
|
|
183
|
+
added: Array<{
|
|
184
|
+
shop_item_id: string;
|
|
185
|
+
name: PersonCartLocalisedName;
|
|
186
|
+
quantity: number;
|
|
187
|
+
line_id: string;
|
|
188
|
+
/** Set when the shop had fewer than were ordered: what was added instead. */
|
|
189
|
+
reduced_to: number | null;
|
|
190
|
+
unit_price: PersonCartMoney;
|
|
191
|
+
/** The price on the order, when the order disclosed prices to this person. */
|
|
192
|
+
previous_unit_price: PersonCartMoney | null;
|
|
193
|
+
price_changed: boolean;
|
|
194
|
+
}>;
|
|
195
|
+
not_added: Array<{
|
|
196
|
+
shop_item_id: string;
|
|
197
|
+
name: PersonCartLocalisedName;
|
|
198
|
+
quantity: number;
|
|
199
|
+
reason: 'unavailable' | 'out_of_stock' | 'cart_full' | (string & {});
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
export declare const PERSON_CART_MAXIMUM_QUANTITY = 99;
|
|
203
|
+
export declare const PERSON_CART_MAXIMUM_LINES = 100;
|
|
204
|
+
/** Stable refusal reasons (`body.reason`) of the cart routes. */
|
|
205
|
+
export declare const PERSON_CART_REFUSAL: {
|
|
206
|
+
readonly lineNotFound: "cart_line_not_found";
|
|
207
|
+
readonly checkoutNotFound: "cart_checkout_not_found";
|
|
208
|
+
readonly itemUnavailable: "cart_item_unavailable";
|
|
209
|
+
readonly outOfStock: "cart_item_out_of_stock";
|
|
210
|
+
readonly full: "cart_full";
|
|
211
|
+
readonly empty: "cart_empty";
|
|
212
|
+
readonly changed: "cart_changed";
|
|
213
|
+
readonly paymentUnitUnusable: "payment_unit_unusable";
|
|
214
|
+
readonly insufficientBalance: "insufficient_balance";
|
|
215
|
+
readonly inProgress: "checkout_in_progress";
|
|
216
|
+
readonly idempotencyKeyReused: "idempotency_key_reused";
|
|
217
|
+
readonly idempotencyKeyInvalid: "idempotency_key_invalid";
|
|
218
|
+
readonly buyAgainNotOffered: "buy_again_not_offered";
|
|
219
|
+
};
|
|
220
|
+
/** `amount_minor` shown in its currency, in the reader's locale (never added across currencies). */
|
|
221
|
+
export declare function formatCartMoney(money: PersonCartMoney, locale?: string): string;
|
|
222
|
+
export declare function createPersonCartNamespace(http: Http): {
|
|
223
|
+
/** GET /api/person/cart — the whole cart, grouped by shop, re-quoted live. */
|
|
224
|
+
show: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCart>>;
|
|
225
|
+
/** POST /lines — add an item (by catalog entry, or by shop and item). */
|
|
226
|
+
add: (request: AddToPersonCartRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartLineWritten>>;
|
|
227
|
+
/** PATCH /lines/{id} — quantity and/or saved-for-later. */
|
|
228
|
+
update: (lineId: string, change: {
|
|
229
|
+
quantity?: number;
|
|
230
|
+
state?: PersonCartLineState;
|
|
231
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartLineWritten>>;
|
|
232
|
+
/** DELETE /lines/{id} — take it out; `restore()` undoes it. */
|
|
233
|
+
remove: (lineId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartLineWritten>>;
|
|
234
|
+
/** POST /lines/{id}/restore — undo a removal. */
|
|
235
|
+
restore: (lineId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartLineWritten>>;
|
|
236
|
+
/** POST /price-acceptances — accept every shop's current price; answers the cart. */
|
|
237
|
+
acceptPrices: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCart>>;
|
|
238
|
+
/**
|
|
239
|
+
* POST /reorders — "Buy again": a past order (offered when the order detail's `buy_again` is
|
|
240
|
+
* set) goes back into the cart at today's prices; answers what was added and what was not.
|
|
241
|
+
*/
|
|
242
|
+
buyAgain: (personOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartBuyAgain>>;
|
|
243
|
+
/** POST /checkouts — one order per shop. Mint ONE key per intent and reuse it on retry. */
|
|
244
|
+
checkOut: (request: CheckOutPersonCartRequest, idempotencyKey: string, options?: Omit<PersonDomainCallOptions, "idempotencyKey">) => Promise<PersonDomainEnvelope<PersonCartCheckout>>;
|
|
245
|
+
/** GET /checkouts — the declared list `shop.person_cart.checkouts`; one cursor page. */
|
|
246
|
+
checkouts: (query?: PersonCartCheckoutListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<PersonCartCheckout>>;
|
|
247
|
+
/** GET /checkouts/{id} — one checkout and the orders it placed. */
|
|
248
|
+
checkout: (checkoutId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonCartCheckout>>;
|
|
249
|
+
};
|
|
250
|
+
export type PersonCartNamespace = ReturnType<typeof createPersonCartNamespace>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
import { listQueryParams } from './list-query.js';
|
|
3
|
+
export const PERSON_CART_MAXIMUM_QUANTITY = 99;
|
|
4
|
+
export const PERSON_CART_MAXIMUM_LINES = 100;
|
|
5
|
+
|
|
6
|
+
export const PERSON_CART_REFUSAL = {
|
|
7
|
+
lineNotFound: 'cart_line_not_found',
|
|
8
|
+
checkoutNotFound: 'cart_checkout_not_found',
|
|
9
|
+
itemUnavailable: 'cart_item_unavailable',
|
|
10
|
+
outOfStock: 'cart_item_out_of_stock',
|
|
11
|
+
full: 'cart_full',
|
|
12
|
+
empty: 'cart_empty',
|
|
13
|
+
changed: 'cart_changed',
|
|
14
|
+
paymentUnitUnusable: 'payment_unit_unusable',
|
|
15
|
+
insufficientBalance: 'insufficient_balance',
|
|
16
|
+
inProgress: 'checkout_in_progress',
|
|
17
|
+
idempotencyKeyReused: 'idempotency_key_reused',
|
|
18
|
+
idempotencyKeyInvalid: 'idempotency_key_invalid',
|
|
19
|
+
buyAgainNotOffered: 'buy_again_not_offered',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function formatCartMoney(money, locale = 'en') {
|
|
23
|
+
const value = money.amount_minor / 10 ** money.currency_decimals;
|
|
24
|
+
try {
|
|
25
|
+
return new Intl.NumberFormat(locale, {
|
|
26
|
+
style: 'currency',
|
|
27
|
+
currency: money.currency_code,
|
|
28
|
+
minimumFractionDigits: money.currency_decimals,
|
|
29
|
+
maximumFractionDigits: money.currency_decimals,
|
|
30
|
+
}).format(value);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return `${money.currency_code} ${value.toFixed(money.currency_decimals)}`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const BASE = '/api/person/cart';
|
|
37
|
+
export function createPersonCartNamespace(http) {
|
|
38
|
+
const read = (options) => personDomainRequest(options, false);
|
|
39
|
+
const write = (options) => personDomainRequest(options, true);
|
|
40
|
+
const segment = encodeURIComponent;
|
|
41
|
+
return {
|
|
42
|
+
|
|
43
|
+
show: (options) => http.get(BASE, read(options)),
|
|
44
|
+
|
|
45
|
+
add: (request, options) => http.post(`${BASE}/lines`, request, write(options)),
|
|
46
|
+
|
|
47
|
+
update: (lineId, change, options) => http.patch(`${BASE}/lines/${segment(lineId)}`, change, write(options)),
|
|
48
|
+
|
|
49
|
+
remove: (lineId, options) => http.delete(`${BASE}/lines/${segment(lineId)}`, write(options)),
|
|
50
|
+
|
|
51
|
+
restore: (lineId, options) => http.post(`${BASE}/lines/${segment(lineId)}/restore`, {}, write(options)),
|
|
52
|
+
|
|
53
|
+
acceptPrices: (options) => http.post(`${BASE}/price-acceptances`, {}, write(options)),
|
|
54
|
+
|
|
55
|
+
buyAgain: (personOrderId, options) => http.post(`${BASE}/reorders`, { person_order_id: personOrderId }, write(options)),
|
|
56
|
+
|
|
57
|
+
checkOut: (request, idempotencyKey, options) => http.post(`${BASE}/checkouts`, request, personDomainRequest({ ...options, idempotencyKey }, true)),
|
|
58
|
+
|
|
59
|
+
checkouts: (query = {}, options) => http.get(`${BASE}/checkouts`, personDomainRequest(options, false, listQueryParams(query))),
|
|
60
|
+
|
|
61
|
+
checkout: (checkoutId, options) => http.get(`${BASE}/checkouts/${segment(checkoutId)}`, read(options)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions } from './actors.js';
|
|
3
|
+
export type PersonChatAiReason = 'opted_out' | 'not_turned_on' | 'ai_off' | 'budget' | 'too_short' | 'nothing_useful' | 'failed';
|
|
4
|
+
export interface PersonChatAiStatus {
|
|
5
|
+
conversation_id: string;
|
|
6
|
+
private_chats: boolean;
|
|
7
|
+
opted_out_by_you: boolean;
|
|
8
|
+
opted_out_by_others: boolean;
|
|
9
|
+
available: boolean;
|
|
10
|
+
reason: PersonChatAiReason | null;
|
|
11
|
+
message: BilingualText | null;
|
|
12
|
+
features: {
|
|
13
|
+
translate: boolean;
|
|
14
|
+
summary: boolean;
|
|
15
|
+
reply_draft: boolean;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface PersonChatAiUnavailable {
|
|
19
|
+
state: 'unavailable';
|
|
20
|
+
reason: PersonChatAiReason;
|
|
21
|
+
message: BilingualText;
|
|
22
|
+
}
|
|
23
|
+
export type PersonChatAiAnswer<T> = ({
|
|
24
|
+
state: 'ready';
|
|
25
|
+
run_id: string | null;
|
|
26
|
+
} & T) | PersonChatAiUnavailable;
|
|
27
|
+
export type PersonChatReplyIntent = 'reply' | 'agree' | 'decline' | 'ask' | 'thank';
|
|
28
|
+
export interface PersonChatAssistNamespace {
|
|
29
|
+
status(conversationId: string, options?: PersonDomainCallOptions): Promise<PersonChatAiStatus>;
|
|
30
|
+
optOut(conversationId: string, options?: PersonDomainCallOptions): Promise<PersonChatAiStatus>;
|
|
31
|
+
withdrawOptOut(conversationId: string, options?: PersonDomainCallOptions): Promise<PersonChatAiStatus>;
|
|
32
|
+
translate(conversationId: string, messageIds: string[], to: string, options?: PersonDomainCallOptions): Promise<PersonChatAiAnswer<{
|
|
33
|
+
to: string;
|
|
34
|
+
translations: Array<{
|
|
35
|
+
message_id: string;
|
|
36
|
+
text: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>>;
|
|
39
|
+
summary(conversationId: string, sinceMessageId?: string | null, options?: PersonDomainCallOptions): Promise<PersonChatAiAnswer<{
|
|
40
|
+
summary: string;
|
|
41
|
+
message_count: number;
|
|
42
|
+
}>>;
|
|
43
|
+
replyDraft(conversationId: string, intent?: PersonChatReplyIntent, note?: string | null, options?: PersonDomainCallOptions): Promise<PersonChatAiAnswer<{
|
|
44
|
+
draft: string;
|
|
45
|
+
}>>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createPersonChatAssistNamespace(http: Http): PersonChatAssistNamespace;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
export function createPersonChatAssistNamespace(http) {
|
|
3
|
+
const base = (conversationId) => `/api/person/conversations/${encodeURIComponent(conversationId)}/ai`;
|
|
4
|
+
const data = async (promise) => (await promise).data;
|
|
5
|
+
return {
|
|
6
|
+
status: (conversationId, options) => data(http.get(base(conversationId), personDomainRequest(options))),
|
|
7
|
+
optOut: (conversationId, options) => data(http.put(`${base(conversationId)}/opt-out`, {}, personDomainRequest(options, true))),
|
|
8
|
+
withdrawOptOut: (conversationId, options) => data(http.delete(`${base(conversationId)}/opt-out`, personDomainRequest(options, true))),
|
|
9
|
+
translate: (conversationId, messageIds, to, options) => data(http.post(`${base(conversationId)}/translate`, { message_ids: messageIds.slice(0, 50), to }, personDomainRequest(options, true))),
|
|
10
|
+
summary: (conversationId, sinceMessageId = null, options) => data(http.post(`${base(conversationId)}/summary`, sinceMessageId ? { since_message_id: sinceMessageId } : {}, personDomainRequest(options, true))),
|
|
11
|
+
replyDraft: (conversationId, intent = 'reply', note = null, options) => data(http.post(`${base(conversationId)}/reply-draft`, note ? { intent, note } : { intent }, personDomainRequest(options, true))),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export type PersonDataWebhookType = 'person_data.grant.revoked' | 'person_data.grant.changed' | 'person_data.app.frozen' | 'person_data.app.resumed' | 'person_data.app.terminated' | 'person_data.case.opened' | 'vault.proposal.decided';
|
|
2
|
+
interface PersonDataWebhookEnvelope<Type extends string, Data> {
|
|
3
|
+
/** The idempotency key: dedupe on it. */
|
|
4
|
+
id: string;
|
|
5
|
+
type: Type;
|
|
6
|
+
/** The app's registry key. */
|
|
7
|
+
app: string;
|
|
8
|
+
/** The business the event concerns, when there is one. */
|
|
9
|
+
tenant: string | null;
|
|
10
|
+
occurred_at: string | null;
|
|
11
|
+
data: Data;
|
|
12
|
+
}
|
|
13
|
+
export type PersonDataGrantRevokedEvent = PersonDataWebhookEnvelope<'person_data.grant.revoked', {
|
|
14
|
+
person_id: string;
|
|
15
|
+
category: string;
|
|
16
|
+
recipient_tenant_org_id: string | null;
|
|
17
|
+
reason: string;
|
|
18
|
+
revoked_at: string | null;
|
|
19
|
+
grant_id: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type PersonDataGrantChangedEvent = PersonDataWebhookEnvelope<'person_data.grant.changed', {
|
|
22
|
+
person_id: string;
|
|
23
|
+
category: string;
|
|
24
|
+
recipient_tenant_org_id: string | null;
|
|
25
|
+
purposes: string[];
|
|
26
|
+
expires_at: string | null;
|
|
27
|
+
grant_id: string;
|
|
28
|
+
replaced_grant_id: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** `measure`: `data_access` | `account` | `app` — what Nuwah paused. */
|
|
31
|
+
export type PersonDataAppFrozenEvent = PersonDataWebhookEnvelope<'person_data.app.frozen', {
|
|
32
|
+
measure: string;
|
|
33
|
+
case_id: string;
|
|
34
|
+
}>;
|
|
35
|
+
export type PersonDataAppResumedEvent = PersonDataWebhookEnvelope<'person_data.app.resumed', {
|
|
36
|
+
measure: string;
|
|
37
|
+
case_id: string;
|
|
38
|
+
}>;
|
|
39
|
+
export type PersonDataAppTerminatedEvent = PersonDataWebhookEnvelope<'person_data.app.terminated', {
|
|
40
|
+
case_id: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* A case about this app opened (developer organisations only; a person developer is told in-app).
|
|
44
|
+
* `category` is the ecosystem-standard category key, or the opening reason when the case has none.
|
|
45
|
+
* `response_deadline` is ISO-8601 UTC, or null when the case sets none.
|
|
46
|
+
*/
|
|
47
|
+
export type PersonDataCaseOpenedEvent = PersonDataWebhookEnvelope<'person_data.case.opened', {
|
|
48
|
+
case_id: string;
|
|
49
|
+
category: string;
|
|
50
|
+
response_deadline: string | null;
|
|
51
|
+
}>;
|
|
52
|
+
export type VaultProposalDecidedEvent = PersonDataWebhookEnvelope<'vault.proposal.decided', Record<string, unknown>>;
|
|
53
|
+
export type PersonDataWebhookEvent = PersonDataGrantRevokedEvent | PersonDataGrantChangedEvent | PersonDataAppFrozenEvent | PersonDataAppResumedEvent | PersonDataAppTerminatedEvent | PersonDataCaseOpenedEvent | VaultProposalDecidedEvent;
|
|
54
|
+
/** Whether an envelope type is a person-data event this module understands. */
|
|
55
|
+
export declare function isPersonDataWebhookType(type: string): type is PersonDataWebhookType;
|
|
56
|
+
/**
|
|
57
|
+
* Verify a webhook's `sha256=<hex>` signature over the RAW body. Fails closed: false for an empty
|
|
58
|
+
* secret, a missing or malformed header, or any mismatch. Constant-time over equal lengths.
|
|
59
|
+
*
|
|
60
|
+
* While a secret rotation overlaps, core signs with both secrets: `sha256=<new>, sha256=<previous>`.
|
|
61
|
+
* The delivery verifies when ANY listed signature matches your secret, so a receiver switches at
|
|
62
|
+
* its own pace inside the window.
|
|
63
|
+
*/
|
|
64
|
+
export declare function verifyPersonDataWebhook(rawBody: string, signatureHeader: string | null | undefined, secret: string): Promise<boolean>;
|
|
65
|
+
/** The header value core sends for a body — for tests and local relays. */
|
|
66
|
+
export declare function signPersonDataWebhook(rawBody: string, secret: string): Promise<string>;
|
|
67
|
+
/**
|
|
68
|
+
* Parse a VERIFIED body into a typed event. Null when it is not JSON, has no `id`, or is not a
|
|
69
|
+
* person-data event (other core events share the envelope and are someone else's business).
|
|
70
|
+
*/
|
|
71
|
+
export declare function parsePersonDataWebhook(rawBody: string): PersonDataWebhookEvent | null;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const KNOWN_TYPES = new Set([
|
|
4
|
+
'person_data.grant.revoked',
|
|
5
|
+
'person_data.grant.changed',
|
|
6
|
+
'person_data.app.frozen',
|
|
7
|
+
'person_data.app.resumed',
|
|
8
|
+
'person_data.app.terminated',
|
|
9
|
+
'person_data.case.opened',
|
|
10
|
+
'vault.proposal.decided',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export function isPersonDataWebhookType(type) {
|
|
14
|
+
return KNOWN_TYPES.has(type);
|
|
15
|
+
}
|
|
16
|
+
function hexToBytes(hex) {
|
|
17
|
+
if (hex.length === 0 || hex.length % 2 !== 0 || !/^[0-9a-f]+$/i.test(hex))
|
|
18
|
+
return null;
|
|
19
|
+
const bytes = new Uint8Array(hex.length / 2);
|
|
20
|
+
for (let index = 0; index < bytes.length; index++)
|
|
21
|
+
bytes[index] = parseInt(hex.slice(index * 2, index * 2 + 2), 16);
|
|
22
|
+
return bytes;
|
|
23
|
+
}
|
|
24
|
+
function subtleCrypto() {
|
|
25
|
+
const subtle = globalThis.crypto?.subtle;
|
|
26
|
+
if (!subtle)
|
|
27
|
+
throw new Error('Web Crypto (globalThis.crypto.subtle) is not available in this runtime.');
|
|
28
|
+
return subtle;
|
|
29
|
+
}
|
|
30
|
+
async function hmacSha256(secret, body) {
|
|
31
|
+
const encoder = new TextEncoder();
|
|
32
|
+
const subtle = subtleCrypto();
|
|
33
|
+
const key = await subtle.importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
|
|
34
|
+
return new Uint8Array(await subtle.sign('HMAC', key, encoder.encode(body)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function verifyPersonDataWebhook(rawBody, signatureHeader, secret) {
|
|
38
|
+
if (!secret || !signatureHeader)
|
|
39
|
+
return false;
|
|
40
|
+
const signatures = signatureHeader.split(',').map((part) => {
|
|
41
|
+
const match = part.trim().match(/^sha256=([0-9a-f]+)$/i);
|
|
42
|
+
return match ? hexToBytes(match[1]) : null;
|
|
43
|
+
});
|
|
44
|
+
if (signatures.length === 0 || signatures.some((signature) => !signature))
|
|
45
|
+
return false;
|
|
46
|
+
const expected = await hmacSha256(secret, rawBody);
|
|
47
|
+
let matched = false;
|
|
48
|
+
for (const provided of signatures) {
|
|
49
|
+
if (!provided || provided.length !== expected.length)
|
|
50
|
+
continue;
|
|
51
|
+
let difference = 0;
|
|
52
|
+
for (let index = 0; index < expected.length; index++)
|
|
53
|
+
difference |= provided[index] ^ expected[index];
|
|
54
|
+
if (difference === 0)
|
|
55
|
+
matched = true;
|
|
56
|
+
}
|
|
57
|
+
return matched;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function signPersonDataWebhook(rawBody, secret) {
|
|
61
|
+
const digest = await hmacSha256(secret, rawBody);
|
|
62
|
+
return `sha256=${Array.from(digest, (byte) => byte.toString(16).padStart(2, '0')).join('')}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function parsePersonDataWebhook(rawBody) {
|
|
66
|
+
let parsed;
|
|
67
|
+
try {
|
|
68
|
+
parsed = JSON.parse(rawBody);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
if (!parsed || typeof parsed !== 'object')
|
|
74
|
+
return null;
|
|
75
|
+
const envelope = parsed;
|
|
76
|
+
if (typeof envelope.id !== 'string' || typeof envelope.type !== 'string' || !isPersonDataWebhookType(envelope.type))
|
|
77
|
+
return null;
|
|
78
|
+
return {
|
|
79
|
+
id: envelope.id,
|
|
80
|
+
type: envelope.type,
|
|
81
|
+
app: typeof envelope.app === 'string' ? envelope.app : '',
|
|
82
|
+
tenant: typeof envelope.tenant === 'string' ? envelope.tenant : null,
|
|
83
|
+
occurred_at: typeof envelope.occurred_at === 'string' ? envelope.occurred_at : null,
|
|
84
|
+
data: envelope.data && typeof envelope.data === 'object' ? envelope.data : {},
|
|
85
|
+
};
|
|
86
|
+
}
|