@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
package/dist/shop.d.ts
ADDED
|
@@ -0,0 +1,993 @@
|
|
|
1
|
+
import { type Http } from './http.js';
|
|
2
|
+
import { type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
import { type ListPage, type ListQueryState } from './list-query.js';
|
|
4
|
+
/** A decimal string at scale 4 (`"12.5000"`). Never a number. */
|
|
5
|
+
export type ShopAmount = string;
|
|
6
|
+
/** How a return WAS settled. */
|
|
7
|
+
export type ShopReturnSettlementMethod = 'original_tender' | 'stored_value';
|
|
8
|
+
/** Who brought the goods back. */
|
|
9
|
+
export type ShopReturningParty = 'payer' | 'beneficiary';
|
|
10
|
+
/** The shop's policy `shop.return_settlement`. */
|
|
11
|
+
export type ShopReturnSettlementPolicy = 'original_tender' | 'stored_value' | 'holder_choice';
|
|
12
|
+
/** The shop's policy `shop.return_party`. */
|
|
13
|
+
export type ShopReturningPartyPolicy = 'beneficiary_when_present' | 'payer_only' | 'payer_or_beneficiary';
|
|
14
|
+
export interface ShopOrderReturnLine {
|
|
15
|
+
id: string;
|
|
16
|
+
order_line_id: string;
|
|
17
|
+
shop_item_id: string | null;
|
|
18
|
+
quantity: number;
|
|
19
|
+
unit_price: ShopAmount;
|
|
20
|
+
line_subtotal: ShopAmount;
|
|
21
|
+
/** The tax this line REVERSES (core posts it as a debit to the tax account). */
|
|
22
|
+
line_tax: ShopAmount;
|
|
23
|
+
line_total: ShopAmount;
|
|
24
|
+
}
|
|
25
|
+
/** One return as the SHOP sees it. */
|
|
26
|
+
export interface ShopOrderReturn {
|
|
27
|
+
id: string;
|
|
28
|
+
order_id: string;
|
|
29
|
+
number: string;
|
|
30
|
+
returning_party: ShopReturningParty;
|
|
31
|
+
/** Null for a beneficiary unless the order's disclosure allows naming her. */
|
|
32
|
+
returning_person_id: string | null;
|
|
33
|
+
settlement_method: ShopReturnSettlementMethod;
|
|
34
|
+
status: 'awaiting_settlement' | 'settled' | (string & {});
|
|
35
|
+
subtotal: ShopAmount;
|
|
36
|
+
tax_total: ShopAmount;
|
|
37
|
+
total: ShopAmount;
|
|
38
|
+
currency_code: string;
|
|
39
|
+
refund_method: string | null;
|
|
40
|
+
stored_value_unit_key: string | null;
|
|
41
|
+
stored_value_entry_id: string | null;
|
|
42
|
+
reason: string | null;
|
|
43
|
+
lines: ShopOrderReturnLine[];
|
|
44
|
+
processed_at: string;
|
|
45
|
+
settled_at: string | null;
|
|
46
|
+
replayed: boolean;
|
|
47
|
+
}
|
|
48
|
+
/** `GET …/returns` answers the returns AND the order's return status. */
|
|
49
|
+
export interface ShopOrderReturnsAnswer {
|
|
50
|
+
data: ShopOrderReturn[];
|
|
51
|
+
return_status: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ReturnShopOrderLinesRequest {
|
|
54
|
+
lines: Array<{
|
|
55
|
+
order_line_id: string;
|
|
56
|
+
quantity: number;
|
|
57
|
+
}>;
|
|
58
|
+
/** Only needed when the policy lets either party return. */
|
|
59
|
+
returning_party?: ShopReturningParty | null;
|
|
60
|
+
/** Only honoured under `holder_choice`; a beneficiary may only choose `stored_value`. */
|
|
61
|
+
settlement_method?: ShopReturnSettlementMethod | null;
|
|
62
|
+
reason?: string | null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* One return as the PERSON who made it sees it (`person.returns.create`). No
|
|
66
|
+
* `returning_person_id` (it is you). A BENEFICIARY gets no line prices and no `refund_method`.
|
|
67
|
+
*/
|
|
68
|
+
export interface PersonShopOrderReturn {
|
|
69
|
+
id: string;
|
|
70
|
+
order_id: string;
|
|
71
|
+
number: string;
|
|
72
|
+
returning_party: ShopReturningParty;
|
|
73
|
+
settlement_method: ShopReturnSettlementMethod;
|
|
74
|
+
status: 'awaiting_settlement' | 'settled' | (string & {});
|
|
75
|
+
total: ShopAmount;
|
|
76
|
+
currency_code: string;
|
|
77
|
+
refund_method: string | null;
|
|
78
|
+
stored_value_unit_key: string | null;
|
|
79
|
+
reason: string | null;
|
|
80
|
+
lines: Array<{
|
|
81
|
+
order_line_id: string;
|
|
82
|
+
quantity: number;
|
|
83
|
+
unit_price?: ShopAmount;
|
|
84
|
+
line_total?: ShopAmount;
|
|
85
|
+
}>;
|
|
86
|
+
processed_at: string;
|
|
87
|
+
settled_at: string | null;
|
|
88
|
+
replayed: boolean;
|
|
89
|
+
}
|
|
90
|
+
/** One party's options: methods accepted now, and each policy-allowed method a fact removed → its refusal reason. */
|
|
91
|
+
export interface ShopReturnPartyOptions {
|
|
92
|
+
party: ShopReturningParty;
|
|
93
|
+
methods: ShopReturnSettlementMethod[];
|
|
94
|
+
unavailable: Partial<Record<ShopReturnSettlementMethod, string>>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* `GET …/orders/{id}/return-options` — resolved by the SAME object the return action decides
|
|
98
|
+
* with, so offer exactly `parties[].methods`. The counter sees every allowed party
|
|
99
|
+
* (`viewer_party: null`); a person sees only their own. `unit_price` only for the counter and
|
|
100
|
+
* the payer.
|
|
101
|
+
*/
|
|
102
|
+
export interface ShopReturnOptions {
|
|
103
|
+
order_id: string;
|
|
104
|
+
returnable: boolean;
|
|
105
|
+
/** Why nothing can be returned, in the action's own refusal vocabulary. */
|
|
106
|
+
refusal_reason: string | null;
|
|
107
|
+
return_status: 'none' | 'partially_returned' | 'returned' | (string & {});
|
|
108
|
+
settlement_policy: ShopReturnSettlementPolicy;
|
|
109
|
+
returning_party_policy: ShopReturningPartyPolicy;
|
|
110
|
+
viewer_party: ShopReturningParty | null;
|
|
111
|
+
credit_unit_key: string | null;
|
|
112
|
+
parties: ShopReturnPartyOptions[];
|
|
113
|
+
lines: Array<{
|
|
114
|
+
order_line_id: string;
|
|
115
|
+
name: Record<string, string>;
|
|
116
|
+
quantity_bought: number;
|
|
117
|
+
returned_quantity: number;
|
|
118
|
+
returnable_quantity: number;
|
|
119
|
+
unit_price?: ShopAmount;
|
|
120
|
+
}>;
|
|
121
|
+
}
|
|
122
|
+
/** `awaiting_inspection` → `accepted` | `rejected`; forward only. */
|
|
123
|
+
export type ShopReturnRequestStatus = 'awaiting_inspection' | 'accepted' | 'rejected' | (string & {});
|
|
124
|
+
/** A return a person asked for, waiting for (or decided by) the shop's inspection. */
|
|
125
|
+
export interface ShopReturnRequest {
|
|
126
|
+
id: string;
|
|
127
|
+
order_id: string;
|
|
128
|
+
returning_party: ShopReturningParty;
|
|
129
|
+
status: ShopReturnRequestStatus;
|
|
130
|
+
status_label: Record<string, string>;
|
|
131
|
+
lines: Array<{
|
|
132
|
+
order_line_id: string;
|
|
133
|
+
quantity: number;
|
|
134
|
+
}>;
|
|
135
|
+
reason: string | null;
|
|
136
|
+
/** The return the acceptance made. */
|
|
137
|
+
return_id: string | null;
|
|
138
|
+
rejection_reason: string | null;
|
|
139
|
+
requested_at: string;
|
|
140
|
+
decided_at: string | null;
|
|
141
|
+
replayed: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface ShopAcceptedReturnRequest {
|
|
144
|
+
request: ShopReturnRequest;
|
|
145
|
+
return: ShopOrderReturn;
|
|
146
|
+
}
|
|
147
|
+
/** One of the caller's balances, and whether this shop takes it now. */
|
|
148
|
+
export interface ShopStoredValueAcceptance {
|
|
149
|
+
unit_key: string;
|
|
150
|
+
unit_label: Record<string, string>;
|
|
151
|
+
currency_code: string;
|
|
152
|
+
decimals: number;
|
|
153
|
+
balance: ShopAmount;
|
|
154
|
+
held: ShopAmount;
|
|
155
|
+
accepted: boolean;
|
|
156
|
+
}
|
|
157
|
+
export type StoredValueTenderStatus = 'pending' | 'completed' | 'refused' | 'compensated' | (string & {});
|
|
158
|
+
/** One stored-value tender. The holder is deliberately absent. */
|
|
159
|
+
export interface StoredValueTender {
|
|
160
|
+
id: string;
|
|
161
|
+
order_id: string;
|
|
162
|
+
mode: 'redeem' | 'hold' | (string & {});
|
|
163
|
+
unit_key: string;
|
|
164
|
+
amount: ShopAmount;
|
|
165
|
+
currency_code: string;
|
|
166
|
+
status: StoredValueTenderStatus;
|
|
167
|
+
/** `not_accepted_here`, `insufficient_balance`, … when refused. */
|
|
168
|
+
refusal_reason: string | null;
|
|
169
|
+
receipt_id: string | null;
|
|
170
|
+
created_at: string | null;
|
|
171
|
+
replayed: boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* One hold a held contribution drive designated to THIS shop, as the counter reads it
|
|
175
|
+
* (`GET /api/shop/contribution-drives/{driveId}/holds`). The clerk captures each `hold_id` with
|
|
176
|
+
* `orders.captureStoredValueHold`; no contributor is named. Amounts are fixed-point strings.
|
|
177
|
+
*/
|
|
178
|
+
export interface ContributionDriveHold {
|
|
179
|
+
hold_id: string;
|
|
180
|
+
stored_value_unit_key: string;
|
|
181
|
+
amount: string;
|
|
182
|
+
currency_code: string;
|
|
183
|
+
/** `held` until captured; `captured` once the drive's purchase took it. */
|
|
184
|
+
status: 'held' | 'captured' | (string & {});
|
|
185
|
+
captured_amount: string | null;
|
|
186
|
+
}
|
|
187
|
+
/** Stable refusal reasons (`body.reason`) of the return and tender routes. */
|
|
188
|
+
export declare const SHOP_RETURN_REFUSAL: {
|
|
189
|
+
readonly orderNotFound: "order_not_found";
|
|
190
|
+
readonly orderNotReturnable: "order_not_returnable";
|
|
191
|
+
readonly orderAlreadyReturned: "order_already_returned";
|
|
192
|
+
readonly lineNotOnOrder: "line_not_on_order";
|
|
193
|
+
readonly quantityExceedsReturnable: "quantity_exceeds_returnable";
|
|
194
|
+
readonly partyNotAllowed: "party_not_allowed";
|
|
195
|
+
readonly methodNotAllowed: "method_not_allowed";
|
|
196
|
+
readonly noCreditUnit: "no_credit_unit";
|
|
197
|
+
readonly creditUnitUnusable: "credit_unit_unusable";
|
|
198
|
+
readonly noPersonToCredit: "no_person_to_credit";
|
|
199
|
+
readonly originalTenderUnavailable: "original_tender_unavailable";
|
|
200
|
+
readonly tenderNotPayable: "tender_not_payable";
|
|
201
|
+
readonly tenderExceedsOutstanding: "tender_exceeds_outstanding";
|
|
202
|
+
readonly tenderHoldUnusable: "tender_hold_unusable";
|
|
203
|
+
readonly tenderCurrencyMismatch: "tender_currency_mismatch";
|
|
204
|
+
/** StoredValue's: the shop does not accept that unit (pay and capture both ask first). */
|
|
205
|
+
readonly notAcceptedHere: "not_accepted_here";
|
|
206
|
+
readonly idempotencyKeyInvalid: "idempotency_key_invalid";
|
|
207
|
+
readonly idempotencyKeyReused: "idempotency_key_reused";
|
|
208
|
+
};
|
|
209
|
+
/** The regex core validates every tender amount against. */
|
|
210
|
+
export declare const SHOP_AMOUNT_PATTERN: RegExp;
|
|
211
|
+
/** The most lines one return request may carry. */
|
|
212
|
+
export declare const SHOP_RETURN_MAXIMUM_LINES = 100;
|
|
213
|
+
/** `body.reason` of a refusal, else the global middleware's `body.code`, else null. See {@link refusalReason}. */
|
|
214
|
+
export declare function shopRefusalReason(error: unknown): string | null;
|
|
215
|
+
export declare function returnedQuantityByOrderLine(returns: ShopOrderReturn[]): Record<string, number>;
|
|
216
|
+
/** Lifecycle as the person sees it. Shop has no carrier step: there is no shipped/delivered. */
|
|
217
|
+
export type PersonOrderStatus = 'placed' | 'confirmed' | 'ready' | 'completed' | 'cancelled';
|
|
218
|
+
/** `payer` — bought by me; `beneficiary` — bought for me. */
|
|
219
|
+
export type PersonOrderRole = 'payer' | 'beneficiary';
|
|
220
|
+
export type PersonOrderMilestoneKind = 'placed' | 'confirmed' | 'ready' | 'completed' | 'cancelled' | 'paid' | 'returned' | 'refunded';
|
|
221
|
+
export interface PersonOrderShop {
|
|
222
|
+
/** The public slug, or null when the shop has none (no return or reorder links then). */
|
|
223
|
+
slug: string | null;
|
|
224
|
+
name: {
|
|
225
|
+
en: string;
|
|
226
|
+
ar: string;
|
|
227
|
+
};
|
|
228
|
+
/** The brand mark (initials) and accent the shop already shows; Shop has no logo. */
|
|
229
|
+
mark: string | null;
|
|
230
|
+
accent: string | null;
|
|
231
|
+
}
|
|
232
|
+
/** One row of "my orders" (v1). `id` is YOUR view of the order; `order_id` is the shop's. */
|
|
233
|
+
export interface PersonOrderSummary {
|
|
234
|
+
id: string;
|
|
235
|
+
order_id: string;
|
|
236
|
+
/** The shop's tenant. With `order_id` it names the order elsewhere — e.g. a contribution drive's `shop.order` purchase (`outcome_tenant_id`). */
|
|
237
|
+
tenant_id: string;
|
|
238
|
+
role: PersonOrderRole;
|
|
239
|
+
shop: PersonOrderShop;
|
|
240
|
+
reference: string;
|
|
241
|
+
status: PersonOrderStatus;
|
|
242
|
+
return_state: 'none' | 'partially_returned' | 'returned' | (string & {});
|
|
243
|
+
fulfillment: string;
|
|
244
|
+
item_count: number;
|
|
245
|
+
item_names: Array<{
|
|
246
|
+
en: string;
|
|
247
|
+
ar: string;
|
|
248
|
+
}>;
|
|
249
|
+
/** False for the person an order was for, unless the shop shows them prices. */
|
|
250
|
+
prices_disclosed: boolean;
|
|
251
|
+
total: ShopAmount | null;
|
|
252
|
+
currency_code: string | null;
|
|
253
|
+
placed_at: string;
|
|
254
|
+
last_event_at: string;
|
|
255
|
+
}
|
|
256
|
+
export interface PersonOrderLine {
|
|
257
|
+
line_id: string;
|
|
258
|
+
shop_item_id: string | null;
|
|
259
|
+
name: {
|
|
260
|
+
en: string;
|
|
261
|
+
ar: string;
|
|
262
|
+
};
|
|
263
|
+
/** The version and add-ons as sold ("Large · Red + Engraving"); null for an item sold as one thing (MARKET-CATALOG). */
|
|
264
|
+
choice_label?: {
|
|
265
|
+
en: string;
|
|
266
|
+
ar: string;
|
|
267
|
+
} | null;
|
|
268
|
+
variant_id?: string | null;
|
|
269
|
+
modifier_option_ids?: string[];
|
|
270
|
+
image_url?: string | null;
|
|
271
|
+
quantity: number;
|
|
272
|
+
returned_quantity: number;
|
|
273
|
+
unit_price: ShopAmount | null;
|
|
274
|
+
line_total: ShopAmount | null;
|
|
275
|
+
}
|
|
276
|
+
export interface PersonOrderTimelineStep {
|
|
277
|
+
kind: PersonOrderMilestoneKind;
|
|
278
|
+
label: {
|
|
279
|
+
en: string;
|
|
280
|
+
ar: string;
|
|
281
|
+
};
|
|
282
|
+
from_status: string | null;
|
|
283
|
+
to_status: string | null;
|
|
284
|
+
detail: Record<string, string | number | boolean | null>;
|
|
285
|
+
occurred_at: string;
|
|
286
|
+
}
|
|
287
|
+
export interface PersonOrderDetail extends Omit<PersonOrderSummary, 'item_names'> {
|
|
288
|
+
subtotal: ShopAmount | null;
|
|
289
|
+
discount_amount: ShopAmount | null;
|
|
290
|
+
amount_paid: ShopAmount | null;
|
|
291
|
+
lines: PersonOrderLine[];
|
|
292
|
+
timeline: PersonOrderTimelineStep[];
|
|
293
|
+
/** Carried for a future carrier integration; null today. */
|
|
294
|
+
tracking: Record<string, unknown> | null;
|
|
295
|
+
/**
|
|
296
|
+
* Follow the courier live (delivery dispatch): `GET /api/person/fulfilment-tracking/{organisation_id}/{token}`
|
|
297
|
+
* (`fulfilmentJobs.track`). Only for the person the delivery is addressed to; null otherwise.
|
|
298
|
+
*/
|
|
299
|
+
delivery_tracking?: {
|
|
300
|
+
organisation_id: string;
|
|
301
|
+
token: string;
|
|
302
|
+
} | null;
|
|
303
|
+
receipt_available: boolean;
|
|
304
|
+
/** Where to ask (`options_path`) and where to return (`create_path`); null before completion. */
|
|
305
|
+
returns: {
|
|
306
|
+
options_path: string;
|
|
307
|
+
create_path: string;
|
|
308
|
+
} | null;
|
|
309
|
+
/** Put these in the shop's cart; the public checkout re-prices them. */
|
|
310
|
+
reorder: {
|
|
311
|
+
shop_slug: string;
|
|
312
|
+
items: Array<{
|
|
313
|
+
shop_item_id: string;
|
|
314
|
+
quantity: number;
|
|
315
|
+
}>;
|
|
316
|
+
} | null;
|
|
317
|
+
/** Where to ask whether the buyer may cancel (`GET`) and to cancel (`POST`); the payer, while placed or confirmed. */
|
|
318
|
+
cancellation?: {
|
|
319
|
+
path: string;
|
|
320
|
+
} | null;
|
|
321
|
+
/** The shop's business profile to message ("Contact the shop"), and the card type to attach; null when it has none. */
|
|
322
|
+
contact?: {
|
|
323
|
+
actor_id: string;
|
|
324
|
+
card_type: string;
|
|
325
|
+
} | null;
|
|
326
|
+
revealed_at: string;
|
|
327
|
+
}
|
|
328
|
+
/** Why a buyer cancels, from the shop's declared list (`reasons` of the cancellation answer). */
|
|
329
|
+
export type PersonOrderCancellationReasonKey = 'changed_my_mind' | 'ordered_by_mistake' | 'found_elsewhere' | 'takes_too_long' | 'other';
|
|
330
|
+
/** `GET …/orders/{orderId}/cancellation`: may the buyer cancel NOW (the shop's window and the order's state, live). */
|
|
331
|
+
export interface PersonOrderCancellationAnswer {
|
|
332
|
+
can_cancel: boolean;
|
|
333
|
+
cancelled: boolean;
|
|
334
|
+
/** Why not, as a stable key: `cancellation_not_allowed` · `order_in_progress` · `order_paid` · `order_awaiting_recipient`. */
|
|
335
|
+
refusal_reason: string | null;
|
|
336
|
+
/** `immediate` (cancelled and refunded at once) or `request` (a PAID order: the shop accepts or declines first). */
|
|
337
|
+
mode: 'immediate' | 'request';
|
|
338
|
+
/** What goes back to the buyer's wallet if it is cancelled; null when nothing was paid. */
|
|
339
|
+
refund: {
|
|
340
|
+
total: ShopAmount;
|
|
341
|
+
currency_code: string;
|
|
342
|
+
} | null;
|
|
343
|
+
/** The buyer's open or last request and the shop's answer, when there was one. */
|
|
344
|
+
request: {
|
|
345
|
+
status: 'requested' | 'accepted' | 'declined';
|
|
346
|
+
decision_note: string | null;
|
|
347
|
+
requested_at: string | null;
|
|
348
|
+
decided_at: string | null;
|
|
349
|
+
} | null;
|
|
350
|
+
window: {
|
|
351
|
+
key: 'never' | 'until_confirmed' | 'until_ready';
|
|
352
|
+
label: {
|
|
353
|
+
en: string;
|
|
354
|
+
ar: string;
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
paid_orders: {
|
|
358
|
+
key: 'never' | 'shop_approves' | 'allowed';
|
|
359
|
+
label: {
|
|
360
|
+
en: string;
|
|
361
|
+
ar: string;
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
reasons: Array<{
|
|
365
|
+
key: PersonOrderCancellationReasonKey;
|
|
366
|
+
label: {
|
|
367
|
+
en: string;
|
|
368
|
+
ar: string;
|
|
369
|
+
};
|
|
370
|
+
}>;
|
|
371
|
+
}
|
|
372
|
+
/** `POST …/orders/{orderId}/cancellation` answers 201 (or 200 when the buyer had already cancelled it). */
|
|
373
|
+
export interface PersonOrderCancelled {
|
|
374
|
+
order_id: string;
|
|
375
|
+
reference: string;
|
|
376
|
+
/** `cancelled`, or `requested` when the order is paid and the shop has to answer first. */
|
|
377
|
+
outcome: 'cancelled' | 'requested';
|
|
378
|
+
status: string;
|
|
379
|
+
cancelled_at: string | null;
|
|
380
|
+
/** What went back to the wallet; null when nothing was paid or the shop has not answered yet. */
|
|
381
|
+
refunded: {
|
|
382
|
+
total: ShopAmount;
|
|
383
|
+
currency_code: string;
|
|
384
|
+
} | null;
|
|
385
|
+
replayed: boolean;
|
|
386
|
+
}
|
|
387
|
+
export interface PersonOrderReceipt {
|
|
388
|
+
id: string;
|
|
389
|
+
shop: PersonOrderShop;
|
|
390
|
+
reference: string;
|
|
391
|
+
invoice_number: string;
|
|
392
|
+
issued_at: string;
|
|
393
|
+
status: string;
|
|
394
|
+
currency_code: string;
|
|
395
|
+
subtotal: ShopAmount;
|
|
396
|
+
discount_amount: ShopAmount;
|
|
397
|
+
total: ShopAmount;
|
|
398
|
+
paid_amount: ShopAmount;
|
|
399
|
+
lines: Array<{
|
|
400
|
+
name: {
|
|
401
|
+
en: string;
|
|
402
|
+
ar: string;
|
|
403
|
+
};
|
|
404
|
+
quantity: number;
|
|
405
|
+
unit_price: ShopAmount;
|
|
406
|
+
line_total: ShopAmount;
|
|
407
|
+
}>;
|
|
408
|
+
payments: Array<{
|
|
409
|
+
method: string;
|
|
410
|
+
amount: ShopAmount;
|
|
411
|
+
received_at: string;
|
|
412
|
+
}>;
|
|
413
|
+
refunds: Array<{
|
|
414
|
+
number: string;
|
|
415
|
+
settlement_method: string;
|
|
416
|
+
total: ShopAmount;
|
|
417
|
+
settled_at: string | null;
|
|
418
|
+
}>;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The declared list (`shop.person_orders`): `sort` `-placed_at` (default) · `placed_at` ·
|
|
422
|
+
* `-last_event_at` · `last_event_at`; filters `status` (one of), `role`, `shop` (a slug),
|
|
423
|
+
* `placed_at` (`{from, to, time_zone}` — whole days in the reader's zone); `search` (folded).
|
|
424
|
+
*/
|
|
425
|
+
export type PersonOrderListQuery = ListQueryState;
|
|
426
|
+
export declare const PERSON_ORDER_REFUSAL: {
|
|
427
|
+
readonly notFound: "person_order_not_found";
|
|
428
|
+
readonly receiptNotAvailable: "receipt_not_available";
|
|
429
|
+
};
|
|
430
|
+
/** One catalogue item as the editor holds it right now (what Assist reads; nothing here is saved). */
|
|
431
|
+
export interface ShopCatalogAssistDraft {
|
|
432
|
+
item_id?: string | null;
|
|
433
|
+
name?: {
|
|
434
|
+
en?: string | null;
|
|
435
|
+
ar?: string | null;
|
|
436
|
+
} | null;
|
|
437
|
+
description?: {
|
|
438
|
+
en?: string | null;
|
|
439
|
+
ar?: string | null;
|
|
440
|
+
} | null;
|
|
441
|
+
category_key?: string | null;
|
|
442
|
+
}
|
|
443
|
+
/** Either the item in the editor, or up to 10 saved items for a reviewable table of rows. */
|
|
444
|
+
export type ShopCatalogAssistInput = {
|
|
445
|
+
item: ShopCatalogAssistDraft;
|
|
446
|
+
itemIds?: undefined;
|
|
447
|
+
locale?: 'en' | 'ar';
|
|
448
|
+
} | {
|
|
449
|
+
itemIds: string[];
|
|
450
|
+
item?: undefined;
|
|
451
|
+
locale?: 'en' | 'ar';
|
|
452
|
+
};
|
|
453
|
+
/** What every catalogue Assist call answers. Suggestions only; the seller reviews each one. */
|
|
454
|
+
export interface ShopCatalogAssistAnswer<TSuggestions> {
|
|
455
|
+
state: 'ready' | 'unavailable';
|
|
456
|
+
/** One item: the suggestions. Bulk: `{ rows }`, one per item, each with `item_id`, `label` and the item's `current` text. */
|
|
457
|
+
suggestions: TSuggestions | ShopCatalogAssistRows | null;
|
|
458
|
+
reason: string | null;
|
|
459
|
+
message: {
|
|
460
|
+
en: string;
|
|
461
|
+
ar: string;
|
|
462
|
+
} | null;
|
|
463
|
+
retry_after_ms: number | null;
|
|
464
|
+
run_id: string | null;
|
|
465
|
+
ai_generated: boolean;
|
|
466
|
+
}
|
|
467
|
+
export interface ShopCatalogAssistRows {
|
|
468
|
+
rows: Array<Record<string, unknown> & {
|
|
469
|
+
item_id: string;
|
|
470
|
+
label?: string;
|
|
471
|
+
}>;
|
|
472
|
+
}
|
|
473
|
+
export interface ShopCatalogAssistAttribute {
|
|
474
|
+
name: {
|
|
475
|
+
en: string;
|
|
476
|
+
ar: string | null;
|
|
477
|
+
};
|
|
478
|
+
value: {
|
|
479
|
+
en: string;
|
|
480
|
+
ar: string | null;
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
export interface ShopCatalogDescribeSuggestions {
|
|
484
|
+
name: {
|
|
485
|
+
en: string | null;
|
|
486
|
+
ar: string | null;
|
|
487
|
+
};
|
|
488
|
+
description: {
|
|
489
|
+
en: string | null;
|
|
490
|
+
ar: string | null;
|
|
491
|
+
};
|
|
492
|
+
category_key: string | null;
|
|
493
|
+
category_label: {
|
|
494
|
+
en: string;
|
|
495
|
+
ar: string;
|
|
496
|
+
} | null;
|
|
497
|
+
attributes: ShopCatalogAssistAttribute[];
|
|
498
|
+
tags: Array<{
|
|
499
|
+
en: string;
|
|
500
|
+
ar: string | null;
|
|
501
|
+
}>;
|
|
502
|
+
confidence: number;
|
|
503
|
+
}
|
|
504
|
+
export interface ShopCatalogTranslateSuggestions {
|
|
505
|
+
name: {
|
|
506
|
+
en: string | null;
|
|
507
|
+
ar: string | null;
|
|
508
|
+
};
|
|
509
|
+
description: {
|
|
510
|
+
en: string | null;
|
|
511
|
+
ar: string | null;
|
|
512
|
+
};
|
|
513
|
+
/** The fields that were empty and now carry a proposal. */
|
|
514
|
+
filled: string[];
|
|
515
|
+
}
|
|
516
|
+
export interface ShopCatalogClassifySuggestions {
|
|
517
|
+
category_key: string | null;
|
|
518
|
+
category_label: {
|
|
519
|
+
en: string;
|
|
520
|
+
ar: string;
|
|
521
|
+
} | null;
|
|
522
|
+
attributes: ShopCatalogAssistAttribute[];
|
|
523
|
+
reason: string | null;
|
|
524
|
+
}
|
|
525
|
+
/** Words in both languages. */
|
|
526
|
+
export interface ShopBilingual {
|
|
527
|
+
en: string;
|
|
528
|
+
ar: string;
|
|
529
|
+
}
|
|
530
|
+
export type ShopOptionGroupKind = 'variant' | 'modifier';
|
|
531
|
+
export interface ShopItemOptionView {
|
|
532
|
+
id: string;
|
|
533
|
+
name: ShopBilingual;
|
|
534
|
+
position?: number;
|
|
535
|
+
extra_price: ShopAmount;
|
|
536
|
+
visible?: boolean;
|
|
537
|
+
}
|
|
538
|
+
export interface ShopItemOptionGroupView {
|
|
539
|
+
id: string;
|
|
540
|
+
kind: ShopOptionGroupKind;
|
|
541
|
+
name: ShopBilingual;
|
|
542
|
+
position?: number;
|
|
543
|
+
minimum_choices: number;
|
|
544
|
+
/** null = no upper limit. */
|
|
545
|
+
maximum_choices: number | null;
|
|
546
|
+
options: ShopItemOptionView[];
|
|
547
|
+
}
|
|
548
|
+
/** A version as the owner edits it (`GET /api/shop/items/{id}`). */
|
|
549
|
+
export interface ShopItemVariantView {
|
|
550
|
+
id: string;
|
|
551
|
+
/** One option id per version group. */
|
|
552
|
+
option_ids: string[];
|
|
553
|
+
sku: string | null;
|
|
554
|
+
/** Its own price, or null when it follows the item's price (plus `price_difference_amount`). */
|
|
555
|
+
price: ShopAmount | null;
|
|
556
|
+
price_difference_amount: ShopAmount | null;
|
|
557
|
+
/** What the shopper pays for it, add-ons aside. */
|
|
558
|
+
effective_price: ShopAmount;
|
|
559
|
+
compare_at_price: ShopAmount | null;
|
|
560
|
+
inventory_item_id: string | null;
|
|
561
|
+
deduct_stock: boolean;
|
|
562
|
+
visible: boolean;
|
|
563
|
+
image_id: string | null;
|
|
564
|
+
position: number;
|
|
565
|
+
}
|
|
566
|
+
/** A version as a shopper sees it (the storefront catalogue): on sale, priced. */
|
|
567
|
+
export interface ShopperVariantView {
|
|
568
|
+
id: string;
|
|
569
|
+
option_ids: string[];
|
|
570
|
+
sku: string | null;
|
|
571
|
+
price: ShopAmount;
|
|
572
|
+
compare_at_price: ShopAmount | null;
|
|
573
|
+
image_url: string | null;
|
|
574
|
+
}
|
|
575
|
+
/** The fields a shopper's option picker reads (the storefront product carries them). */
|
|
576
|
+
export interface ShopperProductOptions {
|
|
577
|
+
price_from: ShopAmount;
|
|
578
|
+
price_to: ShopAmount;
|
|
579
|
+
option_groups: ShopItemOptionGroupView[];
|
|
580
|
+
variants: ShopperVariantView[];
|
|
581
|
+
}
|
|
582
|
+
/** One catalogue item as the owner edits it. */
|
|
583
|
+
export interface ShopAdminItem {
|
|
584
|
+
id: string;
|
|
585
|
+
name: ShopBilingual;
|
|
586
|
+
description: ShopBilingual | null;
|
|
587
|
+
category_key: string | null;
|
|
588
|
+
/** The free text a category key was tidied from, until the owner saves the item again. */
|
|
589
|
+
category_text: string | null;
|
|
590
|
+
price: ShopAmount;
|
|
591
|
+
compare_at: ShopAmount | null;
|
|
592
|
+
currency_code: string;
|
|
593
|
+
position: number;
|
|
594
|
+
visible: boolean;
|
|
595
|
+
inventory_item_id: string | null;
|
|
596
|
+
deduct_stock: boolean;
|
|
597
|
+
vendor_id: string;
|
|
598
|
+
images: Array<{
|
|
599
|
+
id: string;
|
|
600
|
+
url: string;
|
|
601
|
+
sort: number;
|
|
602
|
+
is_primary: boolean;
|
|
603
|
+
}>;
|
|
604
|
+
/** When the owner archived it (ISO 8601); null while it is in the catalogue. */
|
|
605
|
+
archived_at: string | null;
|
|
606
|
+
price_from: ShopAmount;
|
|
607
|
+
price_to: ShopAmount;
|
|
608
|
+
option_groups: ShopItemOptionGroupView[];
|
|
609
|
+
variants: ShopItemVariantView[];
|
|
610
|
+
}
|
|
611
|
+
export interface ShopItemListQuery {
|
|
612
|
+
search?: string;
|
|
613
|
+
/** active (default) · archived · all */
|
|
614
|
+
status?: 'active' | 'archived' | 'all';
|
|
615
|
+
visible?: boolean;
|
|
616
|
+
/** A category key; matches it and everything under it. */
|
|
617
|
+
category?: string;
|
|
618
|
+
page?: number;
|
|
619
|
+
per_page?: number;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* `PUT /api/shop/items/{id}/options` — the whole option model in one write. `key`: an existing
|
|
623
|
+
* id keeps that group or option; any other text makes a new one. Omit `variants` and the versions
|
|
624
|
+
* follow the options; send them to set each version's SKU, price, stock link and picture.
|
|
625
|
+
*/
|
|
626
|
+
export interface ReplaceShopItemOptionsRequest {
|
|
627
|
+
groups: Array<{
|
|
628
|
+
key: string;
|
|
629
|
+
kind: ShopOptionGroupKind;
|
|
630
|
+
name: Partial<ShopBilingual>;
|
|
631
|
+
minimum_choices?: number;
|
|
632
|
+
maximum_choices?: number | null;
|
|
633
|
+
options: Array<{
|
|
634
|
+
key: string;
|
|
635
|
+
name: Partial<ShopBilingual>;
|
|
636
|
+
extra_price?: ShopAmount | null;
|
|
637
|
+
visible?: boolean;
|
|
638
|
+
}>;
|
|
639
|
+
}>;
|
|
640
|
+
variants?: Array<{
|
|
641
|
+
/** One option key per version group. */
|
|
642
|
+
option_keys: string[];
|
|
643
|
+
sku?: string | null;
|
|
644
|
+
price?: ShopAmount | null;
|
|
645
|
+
price_difference_amount?: ShopAmount | null;
|
|
646
|
+
compare_at_price?: ShopAmount | null;
|
|
647
|
+
inventory_item_id?: string | null;
|
|
648
|
+
deduct_stock?: boolean;
|
|
649
|
+
visible?: boolean;
|
|
650
|
+
image_id?: string | null;
|
|
651
|
+
}> | null;
|
|
652
|
+
}
|
|
653
|
+
export type ShopItemBulkAction = 'show' | 'hide' | 'archive' | 'restore' | 'set_category' | 'adjust_price' | 'set_prices';
|
|
654
|
+
export type ShopItemBulkRequest = {
|
|
655
|
+
action: 'show' | 'hide' | 'archive' | 'restore';
|
|
656
|
+
ids: string[];
|
|
657
|
+
} | {
|
|
658
|
+
action: 'set_category';
|
|
659
|
+
ids: string[];
|
|
660
|
+
category_key: string | null;
|
|
661
|
+
} | {
|
|
662
|
+
action: 'adjust_price';
|
|
663
|
+
ids: string[];
|
|
664
|
+
percent: number;
|
|
665
|
+
} | {
|
|
666
|
+
action: 'set_prices';
|
|
667
|
+
ids: string[];
|
|
668
|
+
prices: Record<string, ShopAmount>;
|
|
669
|
+
};
|
|
670
|
+
export interface ShopItemBulkResult {
|
|
671
|
+
action: ShopItemBulkAction;
|
|
672
|
+
affected: number;
|
|
673
|
+
/** Each changed item's state before — what an undo sends back. */
|
|
674
|
+
previous: Array<{
|
|
675
|
+
id: string;
|
|
676
|
+
visible?: boolean;
|
|
677
|
+
archived?: boolean;
|
|
678
|
+
category_key?: string | null;
|
|
679
|
+
price?: ShopAmount;
|
|
680
|
+
}>;
|
|
681
|
+
}
|
|
682
|
+
export interface ShopCategoryNode {
|
|
683
|
+
key: string;
|
|
684
|
+
parent_key: string | null;
|
|
685
|
+
name: ShopBilingual;
|
|
686
|
+
/** platform · vertical · shop (a key only this shop uses) */
|
|
687
|
+
source: 'platform' | 'vertical' | 'shop';
|
|
688
|
+
depth: number;
|
|
689
|
+
/** How many of the shop's live items carry it. */
|
|
690
|
+
in_use: number;
|
|
691
|
+
}
|
|
692
|
+
export interface ShopCategoryList {
|
|
693
|
+
data: ShopCategoryNode[];
|
|
694
|
+
/** `open`: any well-formed key; `listed`: only keys from the list. */
|
|
695
|
+
meta: {
|
|
696
|
+
vocabulary: 'open' | 'listed';
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
export type ShopItemImportAction = 'create' | 'update' | 'update_variant' | 'skip';
|
|
700
|
+
export interface ShopItemImportRow {
|
|
701
|
+
/** The file's line number (1 = the header row). */
|
|
702
|
+
line: number;
|
|
703
|
+
action: ShopItemImportAction;
|
|
704
|
+
item_id: string | null;
|
|
705
|
+
variant_id: string | null;
|
|
706
|
+
name: ShopBilingual;
|
|
707
|
+
price: ShopAmount | null;
|
|
708
|
+
category_key: string | null;
|
|
709
|
+
errors: Array<{
|
|
710
|
+
column: string;
|
|
711
|
+
message: string;
|
|
712
|
+
}>;
|
|
713
|
+
}
|
|
714
|
+
export interface ShopItemImportReport {
|
|
715
|
+
rows: ShopItemImportRow[];
|
|
716
|
+
summary: {
|
|
717
|
+
rows: number;
|
|
718
|
+
create: number;
|
|
719
|
+
update: number;
|
|
720
|
+
update_variant: number;
|
|
721
|
+
errors: number;
|
|
722
|
+
};
|
|
723
|
+
columns: string[];
|
|
724
|
+
unknown_columns: string[];
|
|
725
|
+
/** null on a preview; the counts written on an apply. */
|
|
726
|
+
applied: {
|
|
727
|
+
created: number;
|
|
728
|
+
updated: number;
|
|
729
|
+
updated_variants: number;
|
|
730
|
+
skipped: number;
|
|
731
|
+
} | null;
|
|
732
|
+
}
|
|
733
|
+
/** The columns a catalogue spreadsheet may carry (header row, any order). */
|
|
734
|
+
export declare const SHOP_ITEM_IMPORT_COLUMNS: readonly ["id", "sku", "name_en", "name_ar", "description_en", "description_ar", "price", "compare_at", "category_key", "visible"];
|
|
735
|
+
/** Refusal reasons of a choice (422) — from the storefront, the cart and checkout. */
|
|
736
|
+
export declare const SHOP_SELECTION_REFUSAL: {
|
|
737
|
+
readonly variantRequired: "shop_variant_required";
|
|
738
|
+
readonly variantUnavailable: "shop_variant_unavailable";
|
|
739
|
+
readonly optionUnknown: "shop_option_unknown";
|
|
740
|
+
readonly optionChoices: "shop_option_choices";
|
|
741
|
+
};
|
|
742
|
+
/** A declared policy row of the shop's returns-policy screen (`DeclaredPolicyView` in `@nuwah/ui`). */
|
|
743
|
+
export interface ShopReturnsPolicyRow {
|
|
744
|
+
/** The request field it is written under, e.g. `beneficiary_return_policy`. */
|
|
745
|
+
field: ShopReturnsPolicyField;
|
|
746
|
+
/** The declared key, e.g. `shop.beneficiary_return_to_wallet`. */
|
|
747
|
+
key: string;
|
|
748
|
+
label: {
|
|
749
|
+
en: string;
|
|
750
|
+
ar: string;
|
|
751
|
+
};
|
|
752
|
+
/** The value obeyed now. */
|
|
753
|
+
value: string;
|
|
754
|
+
/** Which level decided it: `platform`, `vertical` or `organisation`. */
|
|
755
|
+
decided_at: string;
|
|
756
|
+
/** This shop's own choice; null when it inherits. */
|
|
757
|
+
chosen: string | null;
|
|
758
|
+
default: string;
|
|
759
|
+
options: Array<{
|
|
760
|
+
value: string;
|
|
761
|
+
label: {
|
|
762
|
+
en: string;
|
|
763
|
+
ar: string;
|
|
764
|
+
};
|
|
765
|
+
}>;
|
|
766
|
+
}
|
|
767
|
+
export type ShopReturnsPolicyField = 'settlement_policy' | 'returning_party_policy' | 'return_window_policy' | 'beneficiary_return_policy' | 'failed_fulfilment_policy';
|
|
768
|
+
/**
|
|
769
|
+
* `GET /api/shop/returns-policy` — the shop's own returns and aftercare choices, the credit unit a
|
|
770
|
+
* return is credited in, and what would go wrong now:
|
|
771
|
+
* `no_credit_unit` credit is allowed (always for the person an order was for) but no unit is chosen
|
|
772
|
+
* `credit_unit_unusable` the chosen unit is not this shop's, not active, or in another currency
|
|
773
|
+
* `shop_not_set_up` the shop has no settings yet
|
|
774
|
+
*/
|
|
775
|
+
export interface ShopReturnsPolicy {
|
|
776
|
+
organisation_id: string;
|
|
777
|
+
shop_currency_code: string | null;
|
|
778
|
+
policies: ShopReturnsPolicyRow[];
|
|
779
|
+
credit_unit: {
|
|
780
|
+
key: string;
|
|
781
|
+
label: {
|
|
782
|
+
en: string;
|
|
783
|
+
ar: string;
|
|
784
|
+
} | null;
|
|
785
|
+
currency_code: string | null;
|
|
786
|
+
/** The same test a return applies: true means a return can be credited now. */
|
|
787
|
+
usable: boolean;
|
|
788
|
+
/** Other businesses that take this credit (null when unknown). */
|
|
789
|
+
accepting_organisation_count: number | null;
|
|
790
|
+
} | null;
|
|
791
|
+
warnings: Array<'no_credit_unit' | 'credit_unit_unusable' | 'shop_not_set_up' | (string & {})>;
|
|
792
|
+
}
|
|
793
|
+
/** Absent = unchanged; null = inherit (a policy) or clear (the credit unit). */
|
|
794
|
+
export type ShopReturnsPolicyChanges = Partial<Record<ShopReturnsPolicyField, string | null>> & {
|
|
795
|
+
/** A stored-value unit this shop issues, active, in the shop's currency; null clears it. */
|
|
796
|
+
return_credit_unit_key?: string | null;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* The unit a shop declares when its owner presses "Set up store credit" on the returns screen:
|
|
800
|
+
* `store_credit.<organisation id>` (unique per shop), in the shop's currency and its minor units,
|
|
801
|
+
* named "Store credit". Declare it with `storedValue.organisation.units.declare(…)` (permission
|
|
802
|
+
* `stored_value.manage`), then choose it with `shop.returnsPolicy.update({ return_credit_unit_key })`.
|
|
803
|
+
* If the key already exists for this shop, skip the declare and choose it.
|
|
804
|
+
*
|
|
805
|
+
* Returns null when the shop has no currency yet (`shop_not_set_up`): nothing can be declared.
|
|
806
|
+
*/
|
|
807
|
+
export declare function returnCreditUnitDeclaration(policy: Pick<ShopReturnsPolicy, 'organisation_id' | 'shop_currency_code'>): {
|
|
808
|
+
key: string;
|
|
809
|
+
currency_code: string;
|
|
810
|
+
decimals: number;
|
|
811
|
+
label: {
|
|
812
|
+
en: string;
|
|
813
|
+
ar: string;
|
|
814
|
+
};
|
|
815
|
+
} | null;
|
|
816
|
+
export declare function createShopNamespace(http: Http): {
|
|
817
|
+
/** GET /api/shop/categories — the managed list: platform, the vertical's, the shop's own keys (`shop.view`). */
|
|
818
|
+
categories: (options?: PersonDomainCallOptions) => Promise<ShopCategoryList>;
|
|
819
|
+
/**
|
|
820
|
+
* The shop's returns and aftercare policy, as its OWNER sees and chooses it (organisation
|
|
821
|
+
* plane, `tenant.bind`). One screen: how returns settle, who may return, the window, whether
|
|
822
|
+
* the person an order was for may return it to their wallet (and whether staff inspect it
|
|
823
|
+
* first), what a failed delivery does, and the credit unit. See {@link ShopReturnsPolicy}.
|
|
824
|
+
*/
|
|
825
|
+
returnsPolicy: {
|
|
826
|
+
/** GET /api/shop/returns-policy */
|
|
827
|
+
show: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopReturnsPolicy>>;
|
|
828
|
+
/**
|
|
829
|
+
* PUT /api/shop/returns-policy — only the fields sent change; null inherits again. Every
|
|
830
|
+
* choice and the credit unit land together or not at all, each audited. 422 for an
|
|
831
|
+
* option the policy does not declare; 422 `credit_unit_not_choosable` for a unit that is
|
|
832
|
+
* not this shop's, not active, or in another currency.
|
|
833
|
+
*/
|
|
834
|
+
update: (changes: ShopReturnsPolicyChanges, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopReturnsPolicy>>;
|
|
835
|
+
};
|
|
836
|
+
/** The organisation plane (`tenant.bind` + `iam.permission:shop.orders.*`). */
|
|
837
|
+
orders: {
|
|
838
|
+
returns: {
|
|
839
|
+
/** GET /api/shop/orders/{id}/returns — oldest first, with the order's `return_status`. */
|
|
840
|
+
list: (orderId: string, options?: PersonDomainCallOptions) => Promise<ShopOrderReturnsAnswer>;
|
|
841
|
+
/**
|
|
842
|
+
* POST /api/shop/orders/{id}/returns — take goods back. Quantities are capped by
|
|
843
|
+
* bought − already returned; the settlement follows the shop's policies.
|
|
844
|
+
*/
|
|
845
|
+
create: (orderId: string, request: ReturnShopOrderLinesRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopOrderReturn>>;
|
|
846
|
+
/** GET /api/shop/orders/{id}/return-options — every allowed party, with prices (`shop.orders.view`). */
|
|
847
|
+
options: (orderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopReturnOptions>>;
|
|
848
|
+
requests: {
|
|
849
|
+
/** GET /api/shop/orders/{id}/return-requests — newest first (`shop.orders.view`). */
|
|
850
|
+
list: (orderId: string, options?: PersonDomainCallOptions) => Promise<{
|
|
851
|
+
data: ShopReturnRequest[];
|
|
852
|
+
}>;
|
|
853
|
+
/**
|
|
854
|
+
* POST …/return-requests/{requestId}/acceptance (`shop.orders.manage`) — credits the
|
|
855
|
+
* person; accepting twice answers the same return. 409 `return_request_decided`
|
|
856
|
+
* for a rejected request.
|
|
857
|
+
*/
|
|
858
|
+
accept: (orderId: string, requestId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopAcceptedReturnRequest>>;
|
|
859
|
+
/** POST …/return-requests/{requestId}/rejection `{reason}` (2–500 characters) — moves nothing; the person is told why. */
|
|
860
|
+
reject: (orderId: string, requestId: string, reason: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopReturnRequest>>;
|
|
861
|
+
};
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* POST /api/shop/orders/{id}/payments/stored-value-hold `{hold_id}` — apply a hold
|
|
865
|
+
* that names this shop to the order (recognises a hold already captured; never twice).
|
|
866
|
+
*/
|
|
867
|
+
captureStoredValueHold: (orderId: string, holdId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<StoredValueTender>>;
|
|
868
|
+
/**
|
|
869
|
+
* GET /api/shop/contribution-drives/{driveId}/holds — the holds a held drive designated
|
|
870
|
+
* to this shop (`shop.orders.view`), at most 200; an empty list for any other drive.
|
|
871
|
+
*/
|
|
872
|
+
contributionDriveHolds: (driveId: string, options?: PersonDomainCallOptions) => Promise<{
|
|
873
|
+
data: ContributionDriveHold[];
|
|
874
|
+
}>;
|
|
875
|
+
};
|
|
876
|
+
/** The person plane: the holder paying their own order. */
|
|
877
|
+
person: {
|
|
878
|
+
/** "My orders across every shop" — reads only; a projection the shops write. */
|
|
879
|
+
orders: {
|
|
880
|
+
/**
|
|
881
|
+
* GET /api/person/orders — a declared cursor list. Pass `describe: true` on the
|
|
882
|
+
* first page for `meta.list` (sorts and filter chips); follow `next_cursor`.
|
|
883
|
+
*/
|
|
884
|
+
list: (query?: PersonOrderListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<PersonOrderSummary>>;
|
|
885
|
+
/** GET /api/person/orders/{id} — 404 `person_order_not_found` for anything not yours. */
|
|
886
|
+
show: (personOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderDetail>>;
|
|
887
|
+
/** GET /api/person/orders/{id}/receipt — the payer's, once invoiced; else 404 `receipt_not_available`. */
|
|
888
|
+
receipt: (personOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderReceipt>>;
|
|
889
|
+
};
|
|
890
|
+
cancellation: {
|
|
891
|
+
/**
|
|
892
|
+
* GET /api/person/orders/{personOrderId}/cancellation — the same answer keyed by the PERSON-ORDER id, so a shop with no
|
|
893
|
+
* public slug can offer it (the order detail's `cancellation.path` is this). 404 for anyone who is not a party to it.
|
|
894
|
+
*/
|
|
895
|
+
optionsByOrder: (personOrderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderCancellationAnswer>>;
|
|
896
|
+
/** POST /api/person/orders/{personOrderId}/cancellation `{reason, note?}` — as {@link create}, keyed by the person-order id. */
|
|
897
|
+
createByOrder: (personOrderId: string, request: {
|
|
898
|
+
reason: PersonOrderCancellationReasonKey;
|
|
899
|
+
note?: string | null;
|
|
900
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderCancelled>>;
|
|
901
|
+
/** GET /api/person/shops/{slug}/orders/{orderId}/cancellation — the slug form, kept as an alias. 404 for anyone who did not place the order. */
|
|
902
|
+
options: (shopSlug: string, orderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderCancellationAnswer>>;
|
|
903
|
+
/**
|
|
904
|
+
* POST /api/person/shops/{slug}/orders/{orderId}/cancellation `{reason, note?}` — cancel the order you
|
|
905
|
+
* placed. Refused 409 `cancellation_not_allowed` · `order_in_progress` · `order_paid` ·
|
|
906
|
+
* `order_awaiting_recipient`; `note` is required for reason `other`. Cancelling twice answers the first.
|
|
907
|
+
*/
|
|
908
|
+
create: (shopSlug: string, orderId: string, request: {
|
|
909
|
+
reason: PersonOrderCancellationReasonKey;
|
|
910
|
+
note?: string | null;
|
|
911
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonOrderCancelled>>;
|
|
912
|
+
};
|
|
913
|
+
/**
|
|
914
|
+
* POST /api/person/shops/{slug}/orders/{orderId}/stored-value-payments
|
|
915
|
+
* `{unit_key, amount}` — refused `not_accepted_here` / `insufficient_balance` (the
|
|
916
|
+
* tender answers `status: refused` with the reason), `tender_exceeds_outstanding`.
|
|
917
|
+
*/
|
|
918
|
+
payWithStoredValue: (shopSlug: string, orderId: string, request: {
|
|
919
|
+
unit_key: string;
|
|
920
|
+
amount: ShopAmount;
|
|
921
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<StoredValueTender>>;
|
|
922
|
+
/**
|
|
923
|
+
* GET /api/person/shops/{slug}/stored-value-acceptance — the caller's balances, each
|
|
924
|
+
* with whether this shop takes it now. Offer only `accepted` ones as a tender.
|
|
925
|
+
*/
|
|
926
|
+
storedValueAcceptance: (shopSlug: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopStoredValueAcceptance[]>>;
|
|
927
|
+
returns: {
|
|
928
|
+
/**
|
|
929
|
+
* GET /api/person/shops/{slug}/orders/{orderId}/return-options — for the payer or
|
|
930
|
+
* the person the order was for; 404 `order_not_found` for anyone else.
|
|
931
|
+
*/
|
|
932
|
+
options: (shopSlug: string, orderId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopReturnOptions>>;
|
|
933
|
+
/**
|
|
934
|
+
* POST /api/person/shops/{slug}/orders/{orderId}/returns — return it yourself, as
|
|
935
|
+
* the party you ARE on the order (`returning_party` is ignored). Same policies and
|
|
936
|
+
* idempotency as the counter; pass the SAME key on the retry of a press.
|
|
937
|
+
*/
|
|
938
|
+
create: (shopSlug: string, orderId: string, request: Omit<ReturnShopOrderLinesRequest, "returning_party">, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<PersonShopOrderReturn>>;
|
|
939
|
+
request: (shopSlug: string, orderId: string, request: {
|
|
940
|
+
lines?: Array<{
|
|
941
|
+
order_line_id: string;
|
|
942
|
+
quantity: number;
|
|
943
|
+
}>;
|
|
944
|
+
reason?: string | null;
|
|
945
|
+
}, idempotencyKey: string, options?: Omit<PersonDomainCallOptions, "idempotencyKey">) => Promise<PersonDomainEnvelope<ShopReturnRequest>>;
|
|
946
|
+
/** GET /api/person/shops/{slug}/orders/{orderId}/return-requests — your own requests on it. */
|
|
947
|
+
requests: (shopSlug: string, orderId: string, options?: PersonDomainCallOptions) => Promise<{
|
|
948
|
+
data: ShopReturnRequest[];
|
|
949
|
+
}>;
|
|
950
|
+
};
|
|
951
|
+
};
|
|
952
|
+
items: {
|
|
953
|
+
/** GET /api/shop/items — paged (`meta.current_page`/`last_page`); filter by status, visibility, category. */
|
|
954
|
+
list: (query?: ShopItemListQuery, options?: PersonDomainCallOptions) => Promise<{
|
|
955
|
+
data: ShopAdminItem[];
|
|
956
|
+
meta: {
|
|
957
|
+
current_page: number;
|
|
958
|
+
last_page: number;
|
|
959
|
+
total: number;
|
|
960
|
+
};
|
|
961
|
+
}>;
|
|
962
|
+
/** GET /api/shop/items/{id} — with its option groups, versions and price range. */
|
|
963
|
+
show: (itemId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopAdminItem>>;
|
|
964
|
+
/** PUT /api/shop/items/{id}/options — replace the option groups and versions in one write (`shop.manage`). */
|
|
965
|
+
replaceOptions: (itemId: string, request: ReplaceShopItemOptionsRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopAdminItem>>;
|
|
966
|
+
/** POST /api/shop/items/bulk — one action over up to 200 items, all or none; `previous` is the undo. */
|
|
967
|
+
bulk: (request: ShopItemBulkRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopItemBulkResult>>;
|
|
968
|
+
/** Spreadsheet import: preview row by row, then apply (only the valid rows are written). */
|
|
969
|
+
imports: {
|
|
970
|
+
preview: (input: {
|
|
971
|
+
file: Blob;
|
|
972
|
+
} | {
|
|
973
|
+
csv: string;
|
|
974
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopItemImportReport>>;
|
|
975
|
+
apply: (input: {
|
|
976
|
+
file: Blob;
|
|
977
|
+
} | {
|
|
978
|
+
csv: string;
|
|
979
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopItemImportReport>>;
|
|
980
|
+
};
|
|
981
|
+
assist: {
|
|
982
|
+
/** POST /describe — title and description in English and Arabic, attributes, a category and tags. */
|
|
983
|
+
describe: (input: ShopCatalogAssistInput & {
|
|
984
|
+
words?: string | null;
|
|
985
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopCatalogAssistAnswer<ShopCatalogDescribeSuggestions>>>;
|
|
986
|
+
/** POST /translate — the missing language of the title and description; only empty fields. */
|
|
987
|
+
translate: (input: ShopCatalogAssistInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopCatalogAssistAnswer<ShopCatalogTranslateSuggestions>>>;
|
|
988
|
+
/** POST /classify — a category from the declared list, and attributes. */
|
|
989
|
+
classify: (input: ShopCatalogAssistInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ShopCatalogAssistAnswer<ShopCatalogClassifySuggestions>>>;
|
|
990
|
+
};
|
|
991
|
+
};
|
|
992
|
+
};
|
|
993
|
+
export type ShopNamespace = ReturnType<typeof createShopNamespace>;
|