@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/builder.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { frameToRunEvent, describeAiError } from './ai.js';
|
|
4
|
+
import { isAbortError, openEventStream } from './event-stream.js';
|
|
5
|
+
const segment = encodeURIComponent;
|
|
6
|
+
export function createBuilderNamespace(http, config) {
|
|
7
|
+
async function* askAsEvents(id, message, locale, options = {}) {
|
|
8
|
+
try {
|
|
9
|
+
for await (const frame of openEventStream(config, `/api/builder/sessions/${segment(id)}/ask/stream`, {
|
|
10
|
+
body: { message, ...(locale ? { locale } : {}) },
|
|
11
|
+
signal: options.signal,
|
|
12
|
+
headers: options.headers,
|
|
13
|
+
})) {
|
|
14
|
+
const event = frameToRunEvent(frame.event, frame.data);
|
|
15
|
+
if (event)
|
|
16
|
+
yield event;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (isAbortError(error) || options.signal?.aborted)
|
|
21
|
+
return;
|
|
22
|
+
yield { type: 'error', error: describeAiError(error) };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
catalog: (query = {}, options) => http.get('/api/builder/catalog', { ...options, params: { ...query } }),
|
|
27
|
+
keyCheck: (key, blueprintId, options) => http.get('/api/builder/key-check', { ...options, params: { key, ...(blueprintId ? { blueprint_id: blueprintId } : {}) } }),
|
|
28
|
+
sessions: {
|
|
29
|
+
list: (query = {}, options) => http.get('/api/builder/sessions', {
|
|
30
|
+
...options,
|
|
31
|
+
params: {
|
|
32
|
+
...(query.filter ? { filter: query.filter } : {}),
|
|
33
|
+
...(query.search ? { search: query.search } : {}),
|
|
34
|
+
...(query.cursor ? { cursor: query.cursor } : {}),
|
|
35
|
+
...(query.limit ? { limit: query.limit } : {}),
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
start: (input, options) => http.post('/api/builder/sessions', input, options),
|
|
39
|
+
connectSandbox: (id, organisationId, options) => http.put(`/api/builder/sessions/${segment(id)}/sandbox`, { organisation_id: organisationId }, options),
|
|
40
|
+
sampleShopper: (id, options) => http.get(`/api/builder/sessions/${segment(id)}/sample-shopper`, options),
|
|
41
|
+
sampleShopperAssistant: async (id, input, options) => {
|
|
42
|
+
const body = { message: input.message };
|
|
43
|
+
if (input.locale)
|
|
44
|
+
body.locale = input.locale;
|
|
45
|
+
if (input.conversationId)
|
|
46
|
+
body.conversation_id = input.conversationId;
|
|
47
|
+
if (input.history && input.history.length > 0)
|
|
48
|
+
body.history = input.history.slice(-10);
|
|
49
|
+
const reply = await http.post(`/api/builder/sessions/${segment(id)}/sample-shopper/assistant`, body, options);
|
|
50
|
+
return reply.data;
|
|
51
|
+
},
|
|
52
|
+
get: (id, options) => http.get(`/api/builder/sessions/${segment(id)}`, options),
|
|
53
|
+
update: (id, input, options) => http.patch(`/api/builder/sessions/${segment(id)}`, input, options),
|
|
54
|
+
remove: (id, discardDraft = false, options) => http.delete(`/api/builder/sessions/${segment(id)}`, { ...options, params: discardDraft ? { discard_draft: 1 } : {} }),
|
|
55
|
+
close: (id, options) => http.post(`/api/builder/sessions/${segment(id)}/close`, {}, options),
|
|
56
|
+
editBlueprint: (id, sections, expectedVersion, options) => http.patch(`/api/builder/sessions/${segment(id)}/blueprint`, { sections, expected_version: expectedVersion }, options),
|
|
57
|
+
askAsEvents,
|
|
58
|
+
},
|
|
59
|
+
changes: {
|
|
60
|
+
confirm: (id, options) => http.post(`/api/builder/changes/${segment(id)}/confirm`, {}, options),
|
|
61
|
+
reject: (id, options) => http.post(`/api/builder/changes/${segment(id)}/reject`, {}, options),
|
|
62
|
+
undo: (id, options) => http.post(`/api/builder/changes/${segment(id)}/undo`, {}, options),
|
|
63
|
+
confirmAll: (sessionId, ids, options) => http.post(`/api/builder/sessions/${segment(sessionId)}/changes/confirm-all`, ids ? { ids } : {}, options),
|
|
64
|
+
undoAll: (sessionId, ids, options) => http.post(`/api/builder/sessions/${segment(sessionId)}/changes/undo-all`, { ids }, options),
|
|
65
|
+
},
|
|
66
|
+
preview: {
|
|
67
|
+
list: (blueprintId, pack, options) => http.get(`/api/builder/blueprints/${segment(blueprintId)}/preview/${pack}`, options),
|
|
68
|
+
create: (blueprintId, pack, fields, options) => http.post(`/api/builder/blueprints/${segment(blueprintId)}/preview/${pack}`, { fields }, options),
|
|
69
|
+
update: (blueprintId, pack, recordId, fields, options) => http.patch(`/api/builder/blueprints/${segment(blueprintId)}/preview/${pack}/${segment(recordId)}`, { fields }, options),
|
|
70
|
+
remove: async (blueprintId, pack, recordId, options) => {
|
|
71
|
+
await http.delete(`/api/builder/blueprints/${segment(blueprintId)}/preview/${pack}/${segment(recordId)}`, options);
|
|
72
|
+
},
|
|
73
|
+
loadSamples: (blueprintId, options) => http.post(`/api/builder/blueprints/${segment(blueprintId)}/preview-sample-data`, {}, options),
|
|
74
|
+
removeSamples: (blueprintId, options) => http.delete(`/api/builder/blueprints/${segment(blueprintId)}/preview-sample-data`, options),
|
|
75
|
+
},
|
|
76
|
+
blueprints: {
|
|
77
|
+
list: (status, options) => http.get('/api/builder/blueprints', { ...options, params: status ? { 'filter[status]': status } : {} }),
|
|
78
|
+
duplicate: (id, input, options) => http.post(`/api/builder/blueprints/${segment(id)}/duplicate`, input, options),
|
|
79
|
+
archive: (id, options) => http.post(`/api/builder/blueprints/${segment(id)}/archive`, {}, options),
|
|
80
|
+
restore: (id, options) => http.post(`/api/builder/blueprints/${segment(id)}/restore`, {}, options),
|
|
81
|
+
get: (id, options) => http.get(`/api/builder/blueprints/${segment(id)}`, options),
|
|
82
|
+
versions: (id, options) => http.get(`/api/builder/blueprints/${segment(id)}/versions`, options),
|
|
83
|
+
version: (id, version, options) => http.get(`/api/builder/blueprints/${segment(id)}/versions/${version}`, options),
|
|
84
|
+
revert: (id, version, options) => http.post(`/api/builder/blueprints/${segment(id)}/revert`, { version }, options),
|
|
85
|
+
submit: (id, input = {}, options) => http.post(`/api/builder/blueprints/${segment(id)}/submit`, input, options),
|
|
86
|
+
withdraw: (id, options) => http.post(`/api/builder/blueprints/${segment(id)}/withdraw`, {}, options),
|
|
87
|
+
},
|
|
88
|
+
coreGaps: {
|
|
89
|
+
list: (blueprintId, options) => http.get('/api/builder/core-gaps', { ...options, params: blueprintId ? { blueprint_id: blueprintId } : {} }),
|
|
90
|
+
record: (input, options) => http.post('/api/builder/core-gaps', input, options),
|
|
91
|
+
},
|
|
92
|
+
compose: {
|
|
93
|
+
catalogue: (options) => http.get('/api/builder/compose/catalogue', options),
|
|
94
|
+
operations: (query = {}, options) => http.get('/api/builder/compose/operations', {
|
|
95
|
+
...options,
|
|
96
|
+
params: { ...(query.search ? { search: query.search } : {}), ...(query.kind ? { kind: query.kind } : {}), ...(query.public_only ? { public_only: 1 } : {}) },
|
|
97
|
+
}),
|
|
98
|
+
resolve: (input, options) => http.post('/api/builder/compose/resolve', input, options),
|
|
99
|
+
run: (input, options = {}) => {
|
|
100
|
+
const { idempotencyKey, ...rest } = options;
|
|
101
|
+
return http.post('/api/builder/compose/run', input, idempotencyKey ? { ...rest, headers: { ...(rest.headers ?? {}), 'Idempotency-Key': idempotencyKey } } : rest);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import type { LaravelResourceCollection } from './types.js';
|
|
3
|
+
/** The delivery channels a campaign can fan out over. */
|
|
4
|
+
export type CampaignChannel = 'push' | 'email' | 'sms' | 'whatsapp';
|
|
5
|
+
/** One campaign with its per-status delivery rollup (the broadcast-center overview row). */
|
|
6
|
+
export interface CampaignRollup {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: string;
|
|
10
|
+
channels: string[];
|
|
11
|
+
rollup: {
|
|
12
|
+
pending: number;
|
|
13
|
+
sent: number;
|
|
14
|
+
failed: number;
|
|
15
|
+
skipped: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A full campaign, as core serialises the `Campaign` model (no API Resource — all
|
|
20
|
+
* columns). `recipients_count` appears on `show`/`attachSegment` via `withCount`/
|
|
21
|
+
* `loadCount`, and `channels` is a decoded array.
|
|
22
|
+
*/
|
|
23
|
+
export interface Campaign {
|
|
24
|
+
id: string;
|
|
25
|
+
tenant_id?: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
status: string;
|
|
29
|
+
channels: CampaignChannel[];
|
|
30
|
+
message_title: string | null;
|
|
31
|
+
message_body: string;
|
|
32
|
+
scheduled_at: string | null;
|
|
33
|
+
launched_at: string | null;
|
|
34
|
+
completed_at: string | null;
|
|
35
|
+
created_by: string | null;
|
|
36
|
+
segment_id: string | null;
|
|
37
|
+
created_at?: string;
|
|
38
|
+
updated_at?: string;
|
|
39
|
+
recipients_count?: number;
|
|
40
|
+
}
|
|
41
|
+
/** The fields `StoreCampaignRequest` accepts (and `UpdateCampaignRequest`, all `sometimes`). */
|
|
42
|
+
export interface CreateCampaignInput {
|
|
43
|
+
name: string;
|
|
44
|
+
message_body: string;
|
|
45
|
+
channels: CampaignChannel[];
|
|
46
|
+
message_title?: string | null;
|
|
47
|
+
description?: string | null;
|
|
48
|
+
scheduled_at?: string | null;
|
|
49
|
+
}
|
|
50
|
+
/** A draft campaign update — every field optional, nullables clear to `null`. */
|
|
51
|
+
export type UpdateCampaignInput = Partial<CreateCampaignInput>;
|
|
52
|
+
/** An audience segment, as `SegmentResource` serialises it (`{data}` envelope). */
|
|
53
|
+
export interface Segment {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
name_ar: string | null;
|
|
57
|
+
description: string | null;
|
|
58
|
+
criteria: Record<string, unknown>;
|
|
59
|
+
created_at: string;
|
|
60
|
+
updated_at: string;
|
|
61
|
+
}
|
|
62
|
+
/** The result of materialising a segment's audience into a campaign's recipients. */
|
|
63
|
+
export interface AttachSegmentResult {
|
|
64
|
+
campaign: Campaign;
|
|
65
|
+
attached: number;
|
|
66
|
+
skipped_no_channel: number;
|
|
67
|
+
total_matched: number;
|
|
68
|
+
}
|
|
69
|
+
/** An active broadcast alert rule (metric threshold that triggers outreach). */
|
|
70
|
+
export interface BroadcastAlertRule {
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
metric_key: string;
|
|
74
|
+
operator: string;
|
|
75
|
+
/** Server decimal string. */
|
|
76
|
+
threshold: string;
|
|
77
|
+
severity: string;
|
|
78
|
+
}
|
|
79
|
+
/** The broadcast-center hub payload. */
|
|
80
|
+
export interface BroadcastCenterOverview {
|
|
81
|
+
campaigns: CampaignRollup[];
|
|
82
|
+
alert_rules: BroadcastAlertRule[];
|
|
83
|
+
channels: string[];
|
|
84
|
+
}
|
|
85
|
+
export declare function createCampaignsNamespace(http: Http): {
|
|
86
|
+
/** GET /api/campaigns/center/overview — the broadcast hub payload. */
|
|
87
|
+
centerOverview: () => Promise<BroadcastCenterOverview>;
|
|
88
|
+
/** POST /api/campaigns — create a draft campaign owned by the current identity. */
|
|
89
|
+
create: (input: CreateCampaignInput) => Promise<Campaign>;
|
|
90
|
+
/** GET /api/campaigns/{id} — one campaign with its recipient count. */
|
|
91
|
+
get: (id: string) => Promise<Campaign>;
|
|
92
|
+
/** PATCH /api/campaigns/{id} — update a draft campaign (422 once not draft). */
|
|
93
|
+
update: (id: string, input: UpdateCampaignInput) => Promise<Campaign>;
|
|
94
|
+
/** DELETE /api/campaigns/{id} — delete a draft campaign (422 once not draft). */
|
|
95
|
+
destroy: (id: string) => Promise<void>;
|
|
96
|
+
/** POST /api/campaigns/{id}/launch — dispatch to recipients (draft/scheduled only). */
|
|
97
|
+
launch: (id: string) => Promise<Campaign>;
|
|
98
|
+
/** POST /api/campaigns/{id}/attach-segment — materialise a segment's audience. */
|
|
99
|
+
attachSegment: (id: string, segmentId: string, replace?: boolean) => Promise<AttachSegmentResult>;
|
|
100
|
+
segments: {
|
|
101
|
+
/** GET /api/campaigns/segments — audience segments (Resource collection envelope). */
|
|
102
|
+
list: () => Promise<LaravelResourceCollection<Segment>>;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export type CampaignsNamespace = ReturnType<typeof createCampaignsNamespace>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function createCampaignsNamespace(http) {
|
|
2
|
+
return {
|
|
3
|
+
|
|
4
|
+
centerOverview: () => http.get('/api/campaigns/center/overview'),
|
|
5
|
+
|
|
6
|
+
create: (input) => http.post('/api/campaigns', input),
|
|
7
|
+
|
|
8
|
+
get: (id) => http.get(`/api/campaigns/${id}`),
|
|
9
|
+
|
|
10
|
+
update: (id, input) => http.patch(`/api/campaigns/${id}`, input),
|
|
11
|
+
|
|
12
|
+
destroy: (id) => http.delete(`/api/campaigns/${id}`),
|
|
13
|
+
|
|
14
|
+
launch: (id) => http.post(`/api/campaigns/${id}/launch`),
|
|
15
|
+
|
|
16
|
+
attachSegment: (id, segmentId, replace = true) => http.post(`/api/campaigns/${id}/attach-segment`, {
|
|
17
|
+
segment_id: segmentId,
|
|
18
|
+
replace,
|
|
19
|
+
}),
|
|
20
|
+
segments: {
|
|
21
|
+
|
|
22
|
+
list: () => http.get('/api/campaigns/segments'),
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions } from './actors.js';
|
|
3
|
+
import { type ListPage, type ListQueryState } from './list-query.js';
|
|
4
|
+
/** A decimal string at scale 4. Never a number. */
|
|
5
|
+
export type CatalogAmount = string;
|
|
6
|
+
export type CatalogAvailability = 'available' | 'limited' | 'unavailable' | 'untracked';
|
|
7
|
+
export interface CatalogProfile {
|
|
8
|
+
id: string;
|
|
9
|
+
handle: string | null;
|
|
10
|
+
display_name: BilingualText;
|
|
11
|
+
avatar_url: string | null;
|
|
12
|
+
verified: boolean;
|
|
13
|
+
open_now?: boolean;
|
|
14
|
+
coordinates?: {
|
|
15
|
+
latitude: number;
|
|
16
|
+
longitude: number;
|
|
17
|
+
} | null;
|
|
18
|
+
}
|
|
19
|
+
export interface CatalogAction {
|
|
20
|
+
key: string;
|
|
21
|
+
shape: 'ask' | 'signal' | 'act';
|
|
22
|
+
weight_class: 'strong' | 'medium' | 'light';
|
|
23
|
+
label: BilingualText;
|
|
24
|
+
}
|
|
25
|
+
export interface CatalogEntry {
|
|
26
|
+
id: string;
|
|
27
|
+
actor_id: string;
|
|
28
|
+
title: BilingualText;
|
|
29
|
+
description: BilingualText | null;
|
|
30
|
+
category_key: string | null;
|
|
31
|
+
price: CatalogAmount | null;
|
|
32
|
+
compare_at_price: CatalogAmount | null;
|
|
33
|
+
currency_code: string | null;
|
|
34
|
+
availability: CatalogAvailability;
|
|
35
|
+
available_quantity: number | null;
|
|
36
|
+
can_add_to_selection: boolean;
|
|
37
|
+
image_url: string | null;
|
|
38
|
+
source_type: string;
|
|
39
|
+
deep_link: string;
|
|
40
|
+
distance_metres?: number | null;
|
|
41
|
+
profile?: CatalogProfile | null;
|
|
42
|
+
actions?: CatalogAction[];
|
|
43
|
+
collection_ids?: string[];
|
|
44
|
+
viewer_is_member?: boolean;
|
|
45
|
+
updated_at: string;
|
|
46
|
+
}
|
|
47
|
+
export interface CatalogCollection {
|
|
48
|
+
id: string;
|
|
49
|
+
actor_id: string;
|
|
50
|
+
title: BilingualText;
|
|
51
|
+
position: number;
|
|
52
|
+
entry_count: number;
|
|
53
|
+
}
|
|
54
|
+
export interface CatalogSelectionLine {
|
|
55
|
+
entry_id: string;
|
|
56
|
+
title: BilingualText;
|
|
57
|
+
quantity: number;
|
|
58
|
+
unit_price: CatalogAmount | null;
|
|
59
|
+
current_price: CatalogAmount | null;
|
|
60
|
+
currency_code: string | null;
|
|
61
|
+
price_changed: boolean;
|
|
62
|
+
available: boolean;
|
|
63
|
+
image_url: string | null;
|
|
64
|
+
deep_link: string;
|
|
65
|
+
}
|
|
66
|
+
export type CatalogSelectionStatus = 'open' | 'shared' | 'converted' | 'withdrawn' | 'expired';
|
|
67
|
+
export interface CatalogSelection {
|
|
68
|
+
id: string;
|
|
69
|
+
status: CatalogSelectionStatus;
|
|
70
|
+
actor_id: string;
|
|
71
|
+
profile: CatalogProfile | null;
|
|
72
|
+
/** Who sent the selection — the business's view only; null for the customer, or when the profile hides it. */
|
|
73
|
+
requester?: {
|
|
74
|
+
handle: string | null;
|
|
75
|
+
display_name: BilingualText;
|
|
76
|
+
avatar_url: string | null;
|
|
77
|
+
} | null;
|
|
78
|
+
viewer_role: 'requester' | 'profile';
|
|
79
|
+
note: string | null;
|
|
80
|
+
lines: CatalogSelectionLine[];
|
|
81
|
+
totals: Array<{
|
|
82
|
+
currency_code: string;
|
|
83
|
+
amount: CatalogAmount;
|
|
84
|
+
}>;
|
|
85
|
+
item_count: number;
|
|
86
|
+
can_edit: boolean;
|
|
87
|
+
can_share: boolean;
|
|
88
|
+
can_withdraw: boolean;
|
|
89
|
+
can_convert: boolean;
|
|
90
|
+
/** What the accepting source created, by its own reference (e.g. a shop order). */
|
|
91
|
+
result: {
|
|
92
|
+
source_type: string;
|
|
93
|
+
reference: string;
|
|
94
|
+
id: string;
|
|
95
|
+
} | null;
|
|
96
|
+
expires_at: string | null;
|
|
97
|
+
shared_at: string | null;
|
|
98
|
+
converted_at: string | null;
|
|
99
|
+
created_at: string;
|
|
100
|
+
updated_at: string;
|
|
101
|
+
deep_link: string;
|
|
102
|
+
}
|
|
103
|
+
export type CatalogHandoff = {
|
|
104
|
+
kind: 'selection';
|
|
105
|
+
selection: CatalogSelection;
|
|
106
|
+
} | {
|
|
107
|
+
kind: 'actor_conversation';
|
|
108
|
+
actor_id: string;
|
|
109
|
+
share: {
|
|
110
|
+
subject_type: string;
|
|
111
|
+
subject_id: string;
|
|
112
|
+
};
|
|
113
|
+
question: BilingualText;
|
|
114
|
+
};
|
|
115
|
+
export interface CatalogEngagement {
|
|
116
|
+
action: string;
|
|
117
|
+
shape: 'ask' | 'signal' | 'act';
|
|
118
|
+
weight_class: string;
|
|
119
|
+
handoff: CatalogHandoff;
|
|
120
|
+
}
|
|
121
|
+
export interface CatalogsNamespace {
|
|
122
|
+
discover(query?: ListQueryState, options?: PersonDomainCallOptions): Promise<ListPage<CatalogEntry>>;
|
|
123
|
+
profileEntries(actorId: string, query?: ListQueryState, options?: PersonDomainCallOptions): Promise<ListPage<CatalogEntry>>;
|
|
124
|
+
entry(entryId: string, options?: PersonDomainCallOptions): Promise<CatalogEntry>;
|
|
125
|
+
recordView(entryId: string, options?: PersonDomainCallOptions): Promise<void>;
|
|
126
|
+
engage(entryId: string, action: string, input?: {
|
|
127
|
+
question?: string;
|
|
128
|
+
quantity?: number;
|
|
129
|
+
}, options?: PersonDomainCallOptions): Promise<CatalogEngagement>;
|
|
130
|
+
collections(actorId: string, options?: PersonDomainCallOptions): Promise<CatalogCollection[]>;
|
|
131
|
+
createCollection(actorId: string, title: Partial<BilingualText>, options?: PersonDomainCallOptions): Promise<CatalogCollection>;
|
|
132
|
+
updateCollection(actorId: string, collectionId: string, changes: {
|
|
133
|
+
title?: Partial<BilingualText>;
|
|
134
|
+
position?: number;
|
|
135
|
+
}, options?: PersonDomainCallOptions): Promise<CatalogCollection>;
|
|
136
|
+
deleteCollection(actorId: string, collectionId: string, options?: PersonDomainCallOptions): Promise<void>;
|
|
137
|
+
setCollectionEntries(actorId: string, collectionId: string, entryIds: string[], options?: PersonDomainCallOptions): Promise<CatalogCollection>;
|
|
138
|
+
mySelections(query?: ListQueryState, options?: PersonDomainCallOptions): Promise<ListPage<CatalogSelection>>;
|
|
139
|
+
incomingSelections(query?: ListQueryState, options?: PersonDomainCallOptions): Promise<ListPage<CatalogSelection>>;
|
|
140
|
+
selection(selectionId: string, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
141
|
+
addLine(entryId: string, quantity?: number, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
142
|
+
changeLine(selectionId: string, entryId: string, quantity: number, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
143
|
+
note(selectionId: string, note: string | null, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
144
|
+
withdraw(selectionId: string, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
145
|
+
convert(selectionId: string, options?: PersonDomainCallOptions): Promise<CatalogSelection>;
|
|
146
|
+
/**
|
|
147
|
+
* AI-W2 plain-words search: `POST /api/person/catalog/assist/interpret`. Turns words ("a cheap
|
|
148
|
+
* red dress open now") into the declared `catalogs.discovery` parameters, each with a chip the
|
|
149
|
+
* screen shows and the reader can remove; the screen then runs the ordinary {@link discover}
|
|
150
|
+
* with them. Always answers; `unavailable` (off, allowance spent) is a normal answer with
|
|
151
|
+
* words to show, and the plain search keeps working.
|
|
152
|
+
*/
|
|
153
|
+
interpretSearch(words: string, input?: {
|
|
154
|
+
currency?: string | null;
|
|
155
|
+
locale?: 'en' | 'ar';
|
|
156
|
+
}, options?: PersonDomainCallOptions): Promise<CatalogSearchInterpretationAnswer>;
|
|
157
|
+
}
|
|
158
|
+
/** What `interpretSearch` proposes: the declared discovery parameters the words ask for. */
|
|
159
|
+
export interface CatalogSearchInterpretation {
|
|
160
|
+
/** The words left for the text search once the filters were taken out; null when nothing is left. */
|
|
161
|
+
search: string | null;
|
|
162
|
+
filters: {
|
|
163
|
+
/** A category KEY (what the `category` filter expects), not a taxonomy id. */
|
|
164
|
+
category?: string;
|
|
165
|
+
price?: {
|
|
166
|
+
minimum?: string;
|
|
167
|
+
maximum?: string;
|
|
168
|
+
};
|
|
169
|
+
currency?: string;
|
|
170
|
+
available?: boolean;
|
|
171
|
+
open_now?: boolean;
|
|
172
|
+
};
|
|
173
|
+
chips: Array<{
|
|
174
|
+
key: string;
|
|
175
|
+
label: BilingualText;
|
|
176
|
+
}>;
|
|
177
|
+
}
|
|
178
|
+
export interface CatalogSearchInterpretationAnswer {
|
|
179
|
+
state: 'ready' | 'unavailable';
|
|
180
|
+
suggestions: CatalogSearchInterpretation | null;
|
|
181
|
+
/** `ai_off`, `budget`, `nothing_useful`, `failed` when `unavailable`. */
|
|
182
|
+
reason: string | null;
|
|
183
|
+
message: BilingualText | null;
|
|
184
|
+
retry_after_ms: number | null;
|
|
185
|
+
run_id: string | null;
|
|
186
|
+
ai_generated: boolean;
|
|
187
|
+
}
|
|
188
|
+
export declare function createCatalogsNamespace(http: Http): CatalogsNamespace;
|
package/dist/catalogs.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { personDomainRequest, } from './actors.js';
|
|
2
|
+
import { listQueryParams } from './list-query.js';
|
|
3
|
+
const BASE = '/api/person/catalog';
|
|
4
|
+
const segment = encodeURIComponent;
|
|
5
|
+
|
|
6
|
+
function asProfile(actorId, options = {}) {
|
|
7
|
+
return { ...options, actingAs: options.actingAs ?? `actor:${actorId}` };
|
|
8
|
+
}
|
|
9
|
+
export function createCatalogsNamespace(http) {
|
|
10
|
+
const data = async (promise) => (await promise).data;
|
|
11
|
+
return {
|
|
12
|
+
discover: (query = {}, options) => http.get(`${BASE}/entries`, personDomainRequest(options, false, listQueryParams(query))),
|
|
13
|
+
profileEntries: (actorId, query = {}, options) => http.get(`${BASE}/profiles/${segment(actorId)}/entries`, personDomainRequest(options, false, listQueryParams(query))),
|
|
14
|
+
entry: (entryId, options) => data(http.get(`${BASE}/entries/${segment(entryId)}`, personDomainRequest(options))),
|
|
15
|
+
recordView: async (entryId, options) => {
|
|
16
|
+
await http.post(`${BASE}/entries/${segment(entryId)}/views`, undefined, personDomainRequest(options, true));
|
|
17
|
+
},
|
|
18
|
+
engage: (entryId, action, input = {}, options) => data(http.post(`${BASE}/entries/${segment(entryId)}/engagements`, { action, ...input }, personDomainRequest(options, true))),
|
|
19
|
+
collections: (actorId, options) => data(http.get(`${BASE}/profiles/${segment(actorId)}/collections`, personDomainRequest(options))),
|
|
20
|
+
createCollection: (actorId, title, options) => data(http.post(`${BASE}/profiles/${segment(actorId)}/collections`, { title }, personDomainRequest(asProfile(actorId, options), true))),
|
|
21
|
+
updateCollection: (actorId, collectionId, changes, options) => data(http.patch(`${BASE}/profiles/${segment(actorId)}/collections/${segment(collectionId)}`, changes, personDomainRequest(asProfile(actorId, options), true))),
|
|
22
|
+
deleteCollection: async (actorId, collectionId, options) => {
|
|
23
|
+
await http.delete(`${BASE}/profiles/${segment(actorId)}/collections/${segment(collectionId)}`, personDomainRequest(asProfile(actorId, options), true));
|
|
24
|
+
},
|
|
25
|
+
setCollectionEntries: (actorId, collectionId, entryIds, options) => data(http.put(`${BASE}/profiles/${segment(actorId)}/collections/${segment(collectionId)}/entries`, { entry_ids: entryIds }, personDomainRequest(asProfile(actorId, options), true))),
|
|
26
|
+
mySelections: (query = {}, options) => http.get(`${BASE}/selections`, personDomainRequest(options, false, listQueryParams(query))),
|
|
27
|
+
incomingSelections: (query = {}, options) => http.get(`${BASE}/incoming-selections`, personDomainRequest(options, false, listQueryParams(query))),
|
|
28
|
+
selection: (selectionId, options) => data(http.get(`${BASE}/selections/${segment(selectionId)}`, personDomainRequest(options))),
|
|
29
|
+
addLine: (entryId, quantity = 1, options) => data(http.post(`${BASE}/selections/lines`, { entry_id: entryId, quantity }, personDomainRequest(options, true))),
|
|
30
|
+
changeLine: (selectionId, entryId, quantity, options) => data(http.put(`${BASE}/selections/${segment(selectionId)}/lines/${segment(entryId)}`, { quantity }, personDomainRequest(options, true))),
|
|
31
|
+
note: (selectionId, note, options) => data(http.put(`${BASE}/selections/${segment(selectionId)}/note`, { note }, personDomainRequest(options, true))),
|
|
32
|
+
withdraw: (selectionId, options) => data(http.post(`${BASE}/selections/${segment(selectionId)}/withdraw`, undefined, personDomainRequest(options, true))),
|
|
33
|
+
interpretSearch: async (words, input = {}, options) => (await http.post(`${BASE}/assist/interpret`, { words, opt_in: true, ...(input.currency ? { currency: input.currency } : {}), ...(input.locale ? { locale: input.locale } : {}) }, personDomainRequest(options, true))).data,
|
|
34
|
+
convert: (selectionId, options) => data(http.post(`${BASE}/selections/${segment(selectionId)}/convert`, undefined, personDomainRequest(options, true))),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions } from './actors.js';
|
|
3
|
+
import type { ShoppingAssistantItem } from './shopping-assistant.js';
|
|
4
|
+
/** The Assist answer every commerce AI call returns. */
|
|
5
|
+
export interface CommerceAssistAnswer<T> {
|
|
6
|
+
state: 'ready' | 'unavailable';
|
|
7
|
+
suggestions: T | null;
|
|
8
|
+
/** `ai_off` · `budget` · `failed` · `not_an_image` · `nothing_useful` · `not_a_recommendation_request`. */
|
|
9
|
+
reason: string | null;
|
|
10
|
+
message: BilingualText | null;
|
|
11
|
+
/** When `reason` is `budget`: how long until the allowance refills. */
|
|
12
|
+
retry_after_ms: number | null;
|
|
13
|
+
/** The audited AI run, for support and feedback. */
|
|
14
|
+
run_id: string | null;
|
|
15
|
+
ai_generated: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface RecommendationAction {
|
|
18
|
+
/** `for_someone_else` (open the recipient-order composer; only when the shop takes such orders) · `view` (preview the entry). */
|
|
19
|
+
key: 'for_someone_else' | 'view';
|
|
20
|
+
kind: 'navigate' | 'preview';
|
|
21
|
+
label: BilingualText;
|
|
22
|
+
/** The composer address, or the catalogue entry id. */
|
|
23
|
+
target: string;
|
|
24
|
+
}
|
|
25
|
+
export interface RecommendedItem {
|
|
26
|
+
item: ShoppingAssistantItem;
|
|
27
|
+
/** Why it fits, in the shopper's language. */
|
|
28
|
+
why: string;
|
|
29
|
+
actions: RecommendationAction[];
|
|
30
|
+
}
|
|
31
|
+
export interface RecommendationSuggestions {
|
|
32
|
+
reply: string | null;
|
|
33
|
+
criteria: {
|
|
34
|
+
beneficiary: string | null;
|
|
35
|
+
interests: BilingualText[];
|
|
36
|
+
search_words: string[];
|
|
37
|
+
budget: {
|
|
38
|
+
minimum: string | null;
|
|
39
|
+
maximum: string | null;
|
|
40
|
+
searched_up_to: string | null;
|
|
41
|
+
approximate: boolean;
|
|
42
|
+
currency_code: string;
|
|
43
|
+
} | null;
|
|
44
|
+
needed_by: string | null;
|
|
45
|
+
city: string | null;
|
|
46
|
+
language: 'en' | 'ar';
|
|
47
|
+
};
|
|
48
|
+
recommendations: RecommendedItem[];
|
|
49
|
+
/** Only when nothing fits the budget: the cheapest close matches, above it. */
|
|
50
|
+
above_budget: RecommendedItem[];
|
|
51
|
+
nothing_found: boolean;
|
|
52
|
+
/** `delivery_not_checked` · `budget_margin` · `stock_not_checked`. */
|
|
53
|
+
caveats: Array<{
|
|
54
|
+
key: string;
|
|
55
|
+
message: BilingualText;
|
|
56
|
+
}>;
|
|
57
|
+
dropped_choices: number;
|
|
58
|
+
}
|
|
59
|
+
/** The moment it is for. Occasion keys and relation labels come from declarations. */
|
|
60
|
+
export interface RecommendationOccasion {
|
|
61
|
+
/** A saved occasion's id (resolved server-side once Occasions publishes its read contract). */
|
|
62
|
+
id?: string | null;
|
|
63
|
+
key?: string | null;
|
|
64
|
+
label?: BilingualText | null;
|
|
65
|
+
/** `YYYY-MM-DD`. */
|
|
66
|
+
date?: string | null;
|
|
67
|
+
relation_label?: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface RecommendationInput {
|
|
70
|
+
/** 2–600 characters: who it is for, what they like, a budget, when. */
|
|
71
|
+
message: string;
|
|
72
|
+
/** The app's language; the answer follows the language the person wrote in. */
|
|
73
|
+
locale?: 'en' | 'ar';
|
|
74
|
+
occasion?: RecommendationOccasion | null;
|
|
75
|
+
}
|
|
76
|
+
export interface ProductDraft {
|
|
77
|
+
name: {
|
|
78
|
+
en: string | null;
|
|
79
|
+
ar: string | null;
|
|
80
|
+
};
|
|
81
|
+
description: {
|
|
82
|
+
en: string | null;
|
|
83
|
+
ar: string | null;
|
|
84
|
+
};
|
|
85
|
+
category_key: string | null;
|
|
86
|
+
category_label: BilingualText | null;
|
|
87
|
+
option_groups: Array<{
|
|
88
|
+
name: {
|
|
89
|
+
en: string;
|
|
90
|
+
ar: string | null;
|
|
91
|
+
};
|
|
92
|
+
values: Array<{
|
|
93
|
+
en: string;
|
|
94
|
+
ar: string | null;
|
|
95
|
+
}>;
|
|
96
|
+
}>;
|
|
97
|
+
price_range: {
|
|
98
|
+
minimum: string;
|
|
99
|
+
maximum: string;
|
|
100
|
+
currency_code: string;
|
|
101
|
+
basis: 'own_catalogue' | 'estimate';
|
|
102
|
+
} | null;
|
|
103
|
+
/** 0–1, the model's own confidence; a hint, not a guarantee. */
|
|
104
|
+
confidence: number;
|
|
105
|
+
photo_count: number;
|
|
106
|
+
}
|
|
107
|
+
export interface ProductFromPhotosInput {
|
|
108
|
+
/** One to three distinct tokens from `POST /api/shop/staged-uploads/item-images/upload-temp`. */
|
|
109
|
+
stagedUploadTokens: string[];
|
|
110
|
+
/** Up to 300 characters the photo cannot show (sizes, material). */
|
|
111
|
+
words?: string;
|
|
112
|
+
locale?: 'en' | 'ar';
|
|
113
|
+
}
|
|
114
|
+
export interface WeeklyItemName {
|
|
115
|
+
en: string | null;
|
|
116
|
+
ar: string | null;
|
|
117
|
+
}
|
|
118
|
+
export interface ShopWeeklyInsights {
|
|
119
|
+
facts: {
|
|
120
|
+
window: {
|
|
121
|
+
from: string;
|
|
122
|
+
to: string;
|
|
123
|
+
days: number;
|
|
124
|
+
};
|
|
125
|
+
totals: {
|
|
126
|
+
units: number;
|
|
127
|
+
units_before: number;
|
|
128
|
+
revenue: string;
|
|
129
|
+
orders: number;
|
|
130
|
+
};
|
|
131
|
+
selling: Array<{
|
|
132
|
+
item_id: string;
|
|
133
|
+
name: WeeklyItemName;
|
|
134
|
+
units: number;
|
|
135
|
+
units_before: number;
|
|
136
|
+
revenue: string;
|
|
137
|
+
}>;
|
|
138
|
+
restock: Array<{
|
|
139
|
+
item_id: string;
|
|
140
|
+
name: WeeklyItemName;
|
|
141
|
+
available: number;
|
|
142
|
+
units: number;
|
|
143
|
+
}>;
|
|
144
|
+
price_check: Array<{
|
|
145
|
+
item_id: string;
|
|
146
|
+
name: WeeklyItemName;
|
|
147
|
+
views: number;
|
|
148
|
+
units: number;
|
|
149
|
+
price: string;
|
|
150
|
+
currency_code: string;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
153
|
+
note: CommerceAssistAnswer<{
|
|
154
|
+
headline: string;
|
|
155
|
+
summary: string;
|
|
156
|
+
}>;
|
|
157
|
+
}
|
|
158
|
+
export interface CommerceAiNamespace {
|
|
159
|
+
/**
|
|
160
|
+
* Recommend real catalogue entries for someone.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* const answer = await nuwah.commerceAi.recommend({ message: 'My sister loves baking, about 20 JD', locale: 'en' });
|
|
164
|
+
* if (answer.state === 'ready') answer.suggestions!.recommendations.forEach((r) => console.log(r.item.title.en, r.why));
|
|
165
|
+
*/
|
|
166
|
+
recommend(input: RecommendationInput, options?: PersonDomainCallOptions): Promise<CommerceAssistAnswer<RecommendationSuggestions>>;
|
|
167
|
+
/**
|
|
168
|
+
* Propose a new product from staged photos (shop owner). Nothing is saved.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* const draft = await nuwah.commerceAi.productFromPhotos({ stagedUploadTokens: [token], locale: 'ar' });
|
|
172
|
+
*/
|
|
173
|
+
productFromPhotos(input: ProductFromPhotosInput): Promise<CommerceAssistAnswer<ProductDraft>>;
|
|
174
|
+
/**
|
|
175
|
+
* This week's shop facts and a short grounded note (shop owner).
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* const { facts, note } = await nuwah.commerceAi.weeklyInsights('en');
|
|
179
|
+
*/
|
|
180
|
+
weeklyInsights(locale?: 'en' | 'ar'): Promise<ShopWeeklyInsights>;
|
|
181
|
+
}
|
|
182
|
+
export declare function createCommerceAiNamespace(http: Http): CommerceAiNamespace;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
export function createCommerceAiNamespace(http) {
|
|
3
|
+
return {
|
|
4
|
+
recommend: async (input, options) => {
|
|
5
|
+
const body = { message: input.message, opt_in: true };
|
|
6
|
+
if (input.locale)
|
|
7
|
+
body.locale = input.locale;
|
|
8
|
+
if (input.occasion)
|
|
9
|
+
body.occasion = input.occasion;
|
|
10
|
+
const reply = await http.post('/api/person/shopping-assistant/recommendations', body, personDomainRequest(options, true));
|
|
11
|
+
return reply.data;
|
|
12
|
+
},
|
|
13
|
+
productFromPhotos: async (input) => {
|
|
14
|
+
const reply = await http.post('/api/shop/items/assist/draft-from-photos', {
|
|
15
|
+
opt_in: true,
|
|
16
|
+
staged_upload_tokens: input.stagedUploadTokens,
|
|
17
|
+
words: input.words ?? null,
|
|
18
|
+
locale: input.locale,
|
|
19
|
+
});
|
|
20
|
+
return reply.data;
|
|
21
|
+
},
|
|
22
|
+
weeklyInsights: async (locale) => {
|
|
23
|
+
const reply = await http.get(`/api/shop/insights/weekly${locale ? `?locale=${locale}` : ''}`);
|
|
24
|
+
return reply.data;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|