@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.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { refusalReason } from './http.js';
|
|
4
|
+
import { personDomainRequest } from './actors.js';
|
|
5
|
+
import { listQueryParams } from './list-query.js';
|
|
6
|
+
|
|
7
|
+
export const SHOP_RETURN_REFUSAL = {
|
|
8
|
+
orderNotFound: 'order_not_found',
|
|
9
|
+
orderNotReturnable: 'order_not_returnable',
|
|
10
|
+
orderAlreadyReturned: 'order_already_returned',
|
|
11
|
+
lineNotOnOrder: 'line_not_on_order',
|
|
12
|
+
quantityExceedsReturnable: 'quantity_exceeds_returnable',
|
|
13
|
+
partyNotAllowed: 'party_not_allowed',
|
|
14
|
+
methodNotAllowed: 'method_not_allowed',
|
|
15
|
+
noCreditUnit: 'no_credit_unit',
|
|
16
|
+
creditUnitUnusable: 'credit_unit_unusable',
|
|
17
|
+
noPersonToCredit: 'no_person_to_credit',
|
|
18
|
+
originalTenderUnavailable: 'original_tender_unavailable',
|
|
19
|
+
tenderNotPayable: 'tender_not_payable',
|
|
20
|
+
tenderExceedsOutstanding: 'tender_exceeds_outstanding',
|
|
21
|
+
tenderHoldUnusable: 'tender_hold_unusable',
|
|
22
|
+
tenderCurrencyMismatch: 'tender_currency_mismatch',
|
|
23
|
+
|
|
24
|
+
notAcceptedHere: 'not_accepted_here',
|
|
25
|
+
idempotencyKeyInvalid: 'idempotency_key_invalid',
|
|
26
|
+
idempotencyKeyReused: 'idempotency_key_reused',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const SHOP_AMOUNT_PATTERN = /^\d{1,15}(\.\d{1,4})?$/;
|
|
30
|
+
|
|
31
|
+
export const SHOP_RETURN_MAXIMUM_LINES = 100;
|
|
32
|
+
|
|
33
|
+
export function shopRefusalReason(error) {
|
|
34
|
+
return refusalReason(error);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function returnedQuantityByOrderLine(returns) {
|
|
38
|
+
const returned = {};
|
|
39
|
+
for (const orderReturn of returns) {
|
|
40
|
+
for (const line of orderReturn.lines)
|
|
41
|
+
returned[line.order_line_id] = (returned[line.order_line_id] ?? 0) + line.quantity;
|
|
42
|
+
}
|
|
43
|
+
return returned;
|
|
44
|
+
}
|
|
45
|
+
function assertReturnLines(request) {
|
|
46
|
+
if (request.lines.length === 0 || request.lines.length > SHOP_RETURN_MAXIMUM_LINES) {
|
|
47
|
+
throw new TypeError(`shop: a return carries 1 to ${SHOP_RETURN_MAXIMUM_LINES} lines, got ${request.lines.length}.`);
|
|
48
|
+
}
|
|
49
|
+
for (const line of request.lines) {
|
|
50
|
+
if (!Number.isInteger(line.quantity) || line.quantity < 1) {
|
|
51
|
+
throw new TypeError(`shop: a returned quantity must be a whole number above zero, got ${JSON.stringify(line.quantity)}.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return request;
|
|
55
|
+
}
|
|
56
|
+
function assertAmount(amount) {
|
|
57
|
+
if (typeof amount !== 'string' || !SHOP_AMOUNT_PATTERN.test(amount)) {
|
|
58
|
+
throw new TypeError(`shop: an amount must be a decimal string, got ${JSON.stringify(amount)}.`);
|
|
59
|
+
}
|
|
60
|
+
return amount;
|
|
61
|
+
}
|
|
62
|
+
export const PERSON_ORDER_REFUSAL = {
|
|
63
|
+
notFound: 'person_order_not_found',
|
|
64
|
+
receiptNotAvailable: 'receipt_not_available',
|
|
65
|
+
};
|
|
66
|
+
function shopAssistBody(input) {
|
|
67
|
+
const { itemIds, item, locale, words } = input;
|
|
68
|
+
return {
|
|
69
|
+
opt_in: true,
|
|
70
|
+
...(itemIds ? { item_ids: itemIds } : { item }),
|
|
71
|
+
...(locale ? { locale } : {}),
|
|
72
|
+
...(words ? { words } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const SHOP_ITEM_IMPORT_COLUMNS = ['id', 'sku', 'name_en', 'name_ar', 'description_en', 'description_ar', 'price', 'compare_at', 'category_key', 'visible'];
|
|
77
|
+
|
|
78
|
+
export const SHOP_SELECTION_REFUSAL = {
|
|
79
|
+
variantRequired: 'shop_variant_required',
|
|
80
|
+
variantUnavailable: 'shop_variant_unavailable',
|
|
81
|
+
optionUnknown: 'shop_option_unknown',
|
|
82
|
+
optionChoices: 'shop_option_choices',
|
|
83
|
+
};
|
|
84
|
+
function importBody(input) {
|
|
85
|
+
if ('file' in input) {
|
|
86
|
+
const form = new FormData();
|
|
87
|
+
form.append('file', input.file);
|
|
88
|
+
return form;
|
|
89
|
+
}
|
|
90
|
+
return { csv: input.csv };
|
|
91
|
+
}
|
|
92
|
+
function itemListParams(query) {
|
|
93
|
+
const params = new URLSearchParams();
|
|
94
|
+
for (const [key, value] of Object.entries(query)) {
|
|
95
|
+
if (value === undefined || value === null || value === '')
|
|
96
|
+
continue;
|
|
97
|
+
params.set(key, typeof value === 'boolean' ? (value ? '1' : '0') : String(value));
|
|
98
|
+
}
|
|
99
|
+
const text = params.toString();
|
|
100
|
+
return text === '' ? '' : `?${text}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const CURRENCY_DECIMALS = { JOD: 3, KWD: 3, BHD: 3, OMR: 3, TND: 3, LYD: 3, IQD: 3, JPY: 0, KRW: 0 };
|
|
104
|
+
|
|
105
|
+
export function returnCreditUnitDeclaration(policy) {
|
|
106
|
+
const currency = policy.shop_currency_code;
|
|
107
|
+
if (currency === null || currency === '')
|
|
108
|
+
return null;
|
|
109
|
+
return {
|
|
110
|
+
key: `store_credit.${policy.organisation_id.toLowerCase()}`,
|
|
111
|
+
currency_code: currency,
|
|
112
|
+
decimals: CURRENCY_DECIMALS[currency] ?? 2,
|
|
113
|
+
label: { en: 'Store credit', ar: 'رصيد المتجر' },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export function createShopNamespace(http) {
|
|
117
|
+
const read = (options) => personDomainRequest(options, false);
|
|
118
|
+
const write = (options) => personDomainRequest(options, true);
|
|
119
|
+
const segment = encodeURIComponent;
|
|
120
|
+
return {
|
|
121
|
+
|
|
122
|
+
categories: (options) => http.get('/api/shop/categories', read(options)),
|
|
123
|
+
|
|
124
|
+
returnsPolicy: {
|
|
125
|
+
|
|
126
|
+
show: (options) => http.get('/api/shop/returns-policy', read(options)),
|
|
127
|
+
|
|
128
|
+
update: (changes, options) => http.put('/api/shop/returns-policy', changes, write(options)),
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
orders: {
|
|
132
|
+
returns: {
|
|
133
|
+
|
|
134
|
+
list: (orderId, options) => http.get(`/api/shop/orders/${segment(orderId)}/returns`, read(options)),
|
|
135
|
+
|
|
136
|
+
create: (orderId, request, options) => http.post(`/api/shop/orders/${segment(orderId)}/returns`, assertReturnLines(request), write(options)),
|
|
137
|
+
|
|
138
|
+
options: (orderId, options) => http.get(`/api/shop/orders/${segment(orderId)}/return-options`, read(options)),
|
|
139
|
+
|
|
140
|
+
requests: {
|
|
141
|
+
|
|
142
|
+
list: (orderId, options) => http.get(`/api/shop/orders/${segment(orderId)}/return-requests`, read(options)),
|
|
143
|
+
|
|
144
|
+
accept: (orderId, requestId, options) => http.post(`/api/shop/orders/${segment(orderId)}/return-requests/${segment(requestId)}/acceptance`, undefined, write(options)),
|
|
145
|
+
|
|
146
|
+
reject: (orderId, requestId, reason, options) => http.post(`/api/shop/orders/${segment(orderId)}/return-requests/${segment(requestId)}/rejection`, { reason }, write(options)),
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
captureStoredValueHold: (orderId, holdId, options) => http.post(`/api/shop/orders/${segment(orderId)}/payments/stored-value-hold`, { hold_id: holdId }, write(options)),
|
|
151
|
+
|
|
152
|
+
contributionDriveHolds: (driveId, options) => http.get(`/api/shop/contribution-drives/${segment(driveId)}/holds`, read(options)),
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
person: {
|
|
156
|
+
|
|
157
|
+
orders: {
|
|
158
|
+
|
|
159
|
+
list: (query = {}, options) => http.get('/api/person/orders', personDomainRequest(options, false, listQueryParams(query))),
|
|
160
|
+
|
|
161
|
+
show: (personOrderId, options) => http.get(`/api/person/orders/${segment(personOrderId)}`, read(options)),
|
|
162
|
+
|
|
163
|
+
receipt: (personOrderId, options) => http.get(`/api/person/orders/${segment(personOrderId)}/receipt`, read(options)),
|
|
164
|
+
},
|
|
165
|
+
cancellation: {
|
|
166
|
+
|
|
167
|
+
optionsByOrder: (personOrderId, options) => http.get(`/api/person/orders/${segment(personOrderId)}/cancellation`, read(options)),
|
|
168
|
+
|
|
169
|
+
createByOrder: (personOrderId, request, options) => http.post(`/api/person/orders/${segment(personOrderId)}/cancellation`, { reason: request.reason, ...(request.note ? { note: request.note } : {}) }, write(options)),
|
|
170
|
+
|
|
171
|
+
options: (shopSlug, orderId, options) => http.get(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/cancellation`, read(options)),
|
|
172
|
+
|
|
173
|
+
create: (shopSlug, orderId, request, options) => http.post(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/cancellation`, { reason: request.reason, ...(request.note ? { note: request.note } : {}) }, write(options)),
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
payWithStoredValue: (shopSlug, orderId, request, options) => http.post(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/stored-value-payments`, { unit_key: request.unit_key, amount: assertAmount(request.amount) }, write(options)),
|
|
177
|
+
|
|
178
|
+
storedValueAcceptance: (shopSlug, options) => http.get(`/api/person/shops/${segment(shopSlug)}/stored-value-acceptance`, read(options)),
|
|
179
|
+
returns: {
|
|
180
|
+
|
|
181
|
+
options: (shopSlug, orderId, options) => http.get(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/return-options`, read(options)),
|
|
182
|
+
|
|
183
|
+
create: (shopSlug, orderId, request, options) => http.post(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/returns`, assertReturnLines(request), write(options)),
|
|
184
|
+
|
|
185
|
+
request: (shopSlug, orderId, request, idempotencyKey, options) => http.post(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/return-requests`, { ...(request.lines ? { lines: request.lines } : {}), ...(request.reason ? { reason: request.reason } : {}) }, personDomainRequest({ ...options, idempotencyKey }, true)),
|
|
186
|
+
|
|
187
|
+
requests: (shopSlug, orderId, options) => http.get(`/api/person/shops/${segment(shopSlug)}/orders/${segment(orderId)}/return-requests`, read(options)),
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
items: {
|
|
192
|
+
|
|
193
|
+
list: (query = {}, options) => http.get(`/api/shop/items${itemListParams(query)}`, read(options)),
|
|
194
|
+
|
|
195
|
+
show: (itemId, options) => http.get(`/api/shop/items/${segment(itemId)}`, read(options)),
|
|
196
|
+
|
|
197
|
+
replaceOptions: (itemId, request, options) => http.put(`/api/shop/items/${segment(itemId)}/options`, request, write(options)),
|
|
198
|
+
|
|
199
|
+
bulk: (request, options) => http.post('/api/shop/items/bulk', request, write(options)),
|
|
200
|
+
|
|
201
|
+
imports: {
|
|
202
|
+
preview: (input, options) => http.post('/api/shop/items/imports/preview', importBody(input), write(options)),
|
|
203
|
+
apply: (input, options) => http.post('/api/shop/items/imports', importBody(input), write(options)),
|
|
204
|
+
},
|
|
205
|
+
assist: {
|
|
206
|
+
|
|
207
|
+
describe: (input, options) => http.post('/api/shop/items/assist/describe', shopAssistBody(input), write(options)),
|
|
208
|
+
|
|
209
|
+
translate: (input, options) => http.post('/api/shop/items/assist/translate', shopAssistBody(input), write(options)),
|
|
210
|
+
|
|
211
|
+
classify: (input, options) => http.post('/api/shop/items/assist/classify', shopAssistBody(input), write(options)),
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions } from './actors.js';
|
|
3
|
+
export type ShoppingAssistantReason = 'ai_off' | 'budget' | 'failed' | 'not_found';
|
|
4
|
+
/** One cited catalogue item, re-read for this answer. Prices are scale-4 decimal strings. */
|
|
5
|
+
export interface ShoppingAssistantItem {
|
|
6
|
+
id: string;
|
|
7
|
+
actor_id: string;
|
|
8
|
+
profile_name: BilingualText | null;
|
|
9
|
+
profile_handle: string | null;
|
|
10
|
+
title: BilingualText;
|
|
11
|
+
description: BilingualText | null;
|
|
12
|
+
category_key: string | null;
|
|
13
|
+
price: string | null;
|
|
14
|
+
compare_at_price: string | null;
|
|
15
|
+
currency_code: string | null;
|
|
16
|
+
availability: 'available' | 'limited' | 'unavailable' | 'untracked';
|
|
17
|
+
available_quantity: number | null;
|
|
18
|
+
image_url: string | null;
|
|
19
|
+
deep_link: string;
|
|
20
|
+
source_type: string;
|
|
21
|
+
/** Whether this shop takes gift orders here (a shop with a public address); Gift shows only then. */
|
|
22
|
+
can_be_gifted?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ShoppingAssistantProposal {
|
|
25
|
+
id: string;
|
|
26
|
+
conversation_id: string | null;
|
|
27
|
+
/** `propose_wishlist_add` · `propose_gift`. */
|
|
28
|
+
tool: string;
|
|
29
|
+
risk: string;
|
|
30
|
+
needs_acknowledgement: boolean;
|
|
31
|
+
summary: BilingualText;
|
|
32
|
+
preview: {
|
|
33
|
+
item?: ShoppingAssistantItem;
|
|
34
|
+
quantity?: number;
|
|
35
|
+
} | null;
|
|
36
|
+
status: string;
|
|
37
|
+
expires_at: string;
|
|
38
|
+
executed_at: string | null;
|
|
39
|
+
result: Record<string, unknown> | null;
|
|
40
|
+
}
|
|
41
|
+
export interface ShoppingAssistantAnswer {
|
|
42
|
+
state: 'ready' | 'unavailable';
|
|
43
|
+
suggestions: {
|
|
44
|
+
answer: string;
|
|
45
|
+
items: ShoppingAssistantItem[];
|
|
46
|
+
proposals: ShoppingAssistantProposal[];
|
|
47
|
+
conversation_id: string;
|
|
48
|
+
dropped_citations: number;
|
|
49
|
+
partial: boolean;
|
|
50
|
+
} | null;
|
|
51
|
+
reason: ShoppingAssistantReason | null;
|
|
52
|
+
message: BilingualText | null;
|
|
53
|
+
retry_after_ms: number | null;
|
|
54
|
+
run_id: string | null;
|
|
55
|
+
ai_generated: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface ShoppingAssistantAskInput {
|
|
58
|
+
message: string;
|
|
59
|
+
conversationId?: string | null;
|
|
60
|
+
locale?: 'en' | 'ar';
|
|
61
|
+
}
|
|
62
|
+
export interface ShoppingAssistantNamespace {
|
|
63
|
+
ask(input: ShoppingAssistantAskInput, options?: PersonDomainCallOptions): Promise<ShoppingAssistantAnswer>;
|
|
64
|
+
}
|
|
65
|
+
export declare function createShoppingAssistantNamespace(http: Http): ShoppingAssistantNamespace;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
export function createShoppingAssistantNamespace(http) {
|
|
3
|
+
return {
|
|
4
|
+
ask: async (input, options) => {
|
|
5
|
+
const body = { message: input.message, opt_in: true };
|
|
6
|
+
if (input.conversationId)
|
|
7
|
+
body.conversation_id = input.conversationId;
|
|
8
|
+
if (input.locale)
|
|
9
|
+
body.locale = input.locale;
|
|
10
|
+
const reply = await http.post('/api/person/shopping-assistant/ask', body, personDomainRequest(options, true));
|
|
11
|
+
return reply.data;
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|