@nuwah/vertical-sdk 0.0.0-stage → 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +229 -2
- package/bin/nuwah-contract-check-rules.d.mts +41 -0
- package/bin/nuwah-contract-check-rules.mjs +333 -0
- package/bin/nuwah-contract-check.mjs +64 -0
- package/dist/accounting.d.ts +1417 -0
- package/dist/accounting.js +274 -0
- package/dist/active-org.d.ts +13 -0
- package/dist/active-org.js +59 -0
- package/dist/actors.d.ts +448 -0
- package/dist/actors.js +143 -0
- package/dist/ai.d.ts +359 -0
- package/dist/ai.js +229 -0
- package/dist/analytics.d.ts +37 -0
- package/dist/analytics.js +8 -0
- package/dist/atlas.d.ts +291 -0
- package/dist/atlas.js +78 -0
- package/dist/audit.d.ts +193 -0
- package/dist/audit.js +26 -0
- package/dist/authentication.d.ts +119 -0
- package/dist/authentication.js +83 -0
- package/dist/awards.d.ts +38 -0
- package/dist/awards.js +10 -0
- package/dist/blueprint/document.d.ts +178 -0
- package/dist/blueprint/document.js +17 -0
- package/dist/blueprint/index.d.ts +3 -0
- package/dist/blueprint/index.js +5 -0
- package/dist/blueprint/manifest.d.ts +105 -0
- package/dist/blueprint/manifest.js +11 -0
- package/dist/blueprint/validate.d.ts +14 -0
- package/dist/blueprint/validate.js +416 -0
- package/dist/bookings-directory.d.ts +118 -0
- package/dist/bookings-directory.js +289 -0
- package/dist/bookings-extra.d.ts +1448 -0
- package/dist/bookings-extra.js +582 -0
- package/dist/bookings.d.ts +1365 -0
- package/dist/bookings.js +305 -0
- package/dist/builder-code.d.ts +164 -0
- package/dist/builder-code.js +12 -0
- package/dist/builder-core-gaps.d.ts +83 -0
- package/dist/builder-core-gaps.js +8 -0
- package/dist/builder-repos.d.ts +73 -0
- package/dist/builder-repos.js +37 -0
- package/dist/builder.d.ts +730 -0
- package/dist/builder.js +105 -0
- package/dist/campaigns.d.ts +105 -0
- package/dist/campaigns.js +25 -0
- package/dist/catalogs.d.ts +188 -0
- package/dist/catalogs.js +36 -0
- package/dist/commerce-ai.d.ts +182 -0
- package/dist/commerce-ai.js +27 -0
- package/dist/connections.d.ts +278 -0
- package/dist/connections.js +96 -0
- package/dist/content-control.d.ts +121 -0
- package/dist/content-control.js +23 -0
- package/dist/contributions.d.ts +560 -0
- package/dist/contributions.js +140 -0
- package/dist/conversation-assist.d.ts +154 -0
- package/dist/conversation-assist.js +51 -0
- package/dist/conversation-info.d.ts +219 -0
- package/dist/conversation-info.js +43 -0
- package/dist/crm.d.ts +533 -0
- package/dist/crm.js +142 -0
- package/dist/dashboards.d.ts +119 -0
- package/dist/dashboards.js +22 -0
- package/dist/delegations.d.ts +161 -0
- package/dist/delegations.js +39 -0
- package/dist/docs.d.ts +289 -0
- package/dist/docs.js +49 -0
- package/dist/documents.d.ts +317 -0
- package/dist/documents.js +84 -0
- package/dist/drafts.d.ts +132 -0
- package/dist/drafts.js +56 -0
- package/dist/engagements.d.ts +133 -0
- package/dist/engagements.js +15 -0
- package/dist/event-stream.d.ts +54 -0
- package/dist/event-stream.js +228 -0
- package/dist/exchanges.d.ts +447 -0
- package/dist/exchanges.js +145 -0
- package/dist/exports.d.ts +113 -0
- package/dist/exports.js +81 -0
- package/dist/feeds.d.ts +228 -0
- package/dist/feeds.js +52 -0
- package/dist/files.d.ts +56 -0
- package/dist/files.js +55 -0
- package/dist/finance-insights.d.ts +41 -0
- package/dist/finance-insights.js +61 -0
- package/dist/fixed-assets.d.ts +155 -0
- package/dist/fixed-assets.js +28 -0
- package/dist/fulfilment-jobs.d.ts +405 -0
- package/dist/fulfilment-jobs.js +76 -0
- package/dist/fulfilment.d.ts +205 -0
- package/dist/fulfilment.js +39 -0
- package/dist/hr.d.ts +350 -0
- package/dist/hr.js +94 -0
- package/dist/http.d.ts +124 -0
- package/dist/http.js +392 -0
- package/dist/inbox.d.ts +206 -0
- package/dist/inbox.js +36 -0
- package/dist/index.d.ts +384 -0
- package/dist/index.js +294 -0
- package/dist/insights.d.ts +176 -0
- package/dist/insights.js +52 -0
- package/dist/inventory.d.ts +797 -0
- package/dist/inventory.js +120 -0
- package/dist/list-query.d.ts +211 -0
- package/dist/list-query.js +158 -0
- package/dist/listings.d.ts +381 -0
- package/dist/listings.js +173 -0
- package/dist/location-sharing.d.ts +83 -0
- package/dist/location-sharing.js +20 -0
- package/dist/marketplace.d.ts +268 -0
- package/dist/marketplace.js +59 -0
- package/dist/matching.d.ts +103 -0
- package/dist/matching.js +22 -0
- package/dist/media.d.ts +221 -0
- package/dist/media.js +239 -0
- package/dist/metrics.d.ts +125 -0
- package/dist/metrics.js +45 -0
- package/dist/moderation.d.ts +240 -0
- package/dist/moderation.js +40 -0
- package/dist/money.d.ts +41 -0
- package/dist/money.js +79 -0
- package/dist/my-data.d.ts +266 -0
- package/dist/my-data.js +32 -0
- package/dist/names.d.ts +14 -0
- package/dist/names.js +17 -0
- package/dist/occasions.d.ts +256 -0
- package/dist/occasions.js +40 -0
- package/dist/onboarding.d.ts +88 -0
- package/dist/onboarding.js +38 -0
- package/dist/pagination.d.ts +204 -0
- package/dist/pagination.js +141 -0
- package/dist/party-baseline-attributes.d.ts +245 -0
- package/dist/party-baseline-attributes.js +36 -0
- package/dist/party.d.ts +401 -0
- package/dist/party.js +56 -0
- package/dist/patient.d.ts +161 -0
- package/dist/patient.js +45 -0
- package/dist/payroll.d.ts +378 -0
- package/dist/payroll.js +60 -0
- package/dist/person-addresses.d.ts +88 -0
- package/dist/person-addresses.js +18 -0
- package/dist/person-cart.d.ts +250 -0
- package/dist/person-cart.js +63 -0
- package/dist/person-chat-assist.d.ts +47 -0
- package/dist/person-chat-assist.js +13 -0
- package/dist/person-data-webhooks.d.ts +72 -0
- package/dist/person-data-webhooks.js +86 -0
- package/dist/person-data.d.ts +212 -0
- package/dist/person-data.js +162 -0
- package/dist/person-locations.d.ts +54 -0
- package/dist/person-locations.js +6 -0
- package/dist/person-messaging.d.ts +405 -0
- package/dist/person-messaging.js +112 -0
- package/dist/person-notifications.d.ts +319 -0
- package/dist/person-notifications.js +164 -0
- package/dist/personalisation.d.ts +21 -0
- package/dist/personalisation.js +8 -0
- package/dist/platform.d.ts +63 -0
- package/dist/platform.js +45 -0
- package/dist/portfolio.d.ts +163 -0
- package/dist/portfolio.js +28 -0
- package/dist/pos.d.ts +743 -0
- package/dist/pos.js +129 -0
- package/dist/procurement.d.ts +664 -0
- package/dist/procurement.js +157 -0
- package/dist/promotions.d.ts +169 -0
- package/dist/promotions.js +39 -0
- package/dist/publications.d.ts +583 -0
- package/dist/publications.js +164 -0
- package/dist/ranking.d.ts +43 -0
- package/dist/ranking.js +34 -0
- package/dist/ratings.d.ts +293 -0
- package/dist/ratings.js +109 -0
- package/dist/reactions.d.ts +123 -0
- package/dist/reactions.js +41 -0
- package/dist/recipient-orders.d.ts +294 -0
- package/dist/recipient-orders.js +73 -0
- package/dist/relationships.d.ts +18 -0
- package/dist/relationships.js +8 -0
- package/dist/reporting.d.ts +107 -0
- package/dist/reporting.js +56 -0
- package/dist/sales.d.ts +270 -0
- package/dist/sales.js +66 -0
- package/dist/shares.d.ts +105 -0
- package/dist/shares.js +27 -0
- package/dist/shop.d.ts +993 -0
- package/dist/shop.js +215 -0
- package/dist/shopping-assistant.d.ts +65 -0
- package/dist/shopping-assistant.js +14 -0
- package/dist/spaces.d.ts +422 -0
- package/dist/spaces.js +118 -0
- package/dist/stored-value.d.ts +754 -0
- package/dist/stored-value.js +177 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +2 -0
- package/dist/vault.d.ts +290 -0
- package/dist/vault.js +55 -0
- package/dist/vertical-runtime.d.ts +17 -0
- package/dist/vertical-runtime.js +8 -0
- package/dist/vite/build-manifest-plugin.d.ts +42 -0
- package/dist/vite/build-manifest-plugin.js +42 -0
- package/dist/vite/first-paint-plugin.d.ts +26 -0
- package/dist/vite/first-paint-plugin.js +57 -0
- package/dist/wishlists.d.ts +591 -0
- package/dist/wishlists.js +188 -0
- package/dist/workbench.d.ts +114 -0
- package/dist/workbench.js +22 -0
- package/dist/workspace.d.ts +190 -0
- package/dist/workspace.js +41 -0
- package/package.json +52 -4
- package/templates/extension-image.Dockerfile +38 -0
- package/templates/nuwah-vertical.yml +102 -0
- package/templates/vertical-app/.env.example +34 -0
- package/templates/vertical-app/README.md +108 -0
- package/templates/vertical-app/github/workflows/ci.yml +51 -0
- package/templates/vertical-app/gitignore +5 -0
- package/templates/vertical-app/index.html +12 -0
- package/templates/vertical-app/package.json +28 -0
- package/templates/vertical-app/src/App.tsx +64 -0
- package/templates/vertical-app/src/blueprint/blueprint.ts +45 -0
- package/templates/vertical-app/src/blueprint/screens.ts +15 -0
- package/templates/vertical-app/src/env.d.ts +18 -0
- package/templates/vertical-app/src/index.css +139 -0
- package/templates/vertical-app/src/lib/i18n.ts +5 -0
- package/templates/vertical-app/src/lib/iam.ts +19 -0
- package/templates/vertical-app/src/lib/operations.ts +93 -0
- package/templates/vertical-app/src/lib/router.ts +24 -0
- package/templates/vertical-app/src/lib/sdk.ts +21 -0
- package/templates/vertical-app/src/lib/theme.ts +18 -0
- package/templates/vertical-app/src/lib/words.ts +39 -0
- package/templates/vertical-app/src/main.tsx +25 -0
- package/templates/vertical-app/src/pages/AppScreens.tsx +71 -0
- package/templates/vertical-app/src/pages/AuthCallback.tsx +44 -0
- package/templates/vertical-app/src/pages/Home.tsx +36 -0
- package/templates/vertical-app/tsconfig.json +24 -0
- package/templates/vertical-app/vite.config.ts +23 -0
- package/templates/vertical-ci.yml +192 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { singleRecord } from './pagination.js';
|
|
2
|
+
|
|
3
|
+
async function singleRecordOf(request) {
|
|
4
|
+
return singleRecord(await request);
|
|
5
|
+
}
|
|
6
|
+
export function createProcurementNamespace(http) {
|
|
7
|
+
return {
|
|
8
|
+
vendors: {
|
|
9
|
+
|
|
10
|
+
list: (query) => http.get('/api/procurement/vendors', { params: query }),
|
|
11
|
+
|
|
12
|
+
get: (id) => singleRecordOf(http.get(`/api/procurement/vendors/${id}`)),
|
|
13
|
+
|
|
14
|
+
create: (input) => singleRecordOf(http.post('/api/procurement/vendors', input)),
|
|
15
|
+
|
|
16
|
+
update: (id, input) => singleRecordOf(http.put(`/api/procurement/vendors/${id}`, input)),
|
|
17
|
+
|
|
18
|
+
deactivate: (id) => singleRecordOf(http.post(`/api/procurement/vendors/${id}/deactivate`)),
|
|
19
|
+
},
|
|
20
|
+
purchaseOrders: {
|
|
21
|
+
|
|
22
|
+
list: (query) => http.get('/api/procurement/orders', { params: query }),
|
|
23
|
+
|
|
24
|
+
get: (id) => singleRecordOf(http.get(`/api/procurement/orders/${id}`)),
|
|
25
|
+
|
|
26
|
+
create: (input) => singleRecordOf(http.post('/api/procurement/orders', input)),
|
|
27
|
+
|
|
28
|
+
update: (id, input) => singleRecordOf(http.put(`/api/procurement/orders/${id}`, input)),
|
|
29
|
+
|
|
30
|
+
remove: (id) => http.delete(`/api/procurement/orders/${id}`),
|
|
31
|
+
|
|
32
|
+
approve: (id) => singleRecordOf(http.post(`/api/procurement/orders/${id}/approve`)),
|
|
33
|
+
|
|
34
|
+
send: (id) => singleRecordOf(http.post(`/api/procurement/orders/${id}/send`)),
|
|
35
|
+
|
|
36
|
+
cancel: (id) => singleRecordOf(http.post(`/api/procurement/orders/${id}/cancel`)),
|
|
37
|
+
|
|
38
|
+
addLine: (orderId, input) => singleRecordOf(http.post(`/api/procurement/orders/${orderId}/lines`, input)),
|
|
39
|
+
|
|
40
|
+
updateLine: (orderId, lineId, input) => singleRecordOf(http.put(`/api/procurement/orders/${orderId}/lines/${lineId}`, input)),
|
|
41
|
+
|
|
42
|
+
removeLine: (orderId, lineId) => http.delete(`/api/procurement/orders/${orderId}/lines/${lineId}`),
|
|
43
|
+
},
|
|
44
|
+
receiving: {
|
|
45
|
+
|
|
46
|
+
listReceipts: (poId) => http.get(`/api/procurement/purchase-orders/${poId}/receipts`),
|
|
47
|
+
|
|
48
|
+
getReceipt: (id) => singleRecordOf(http.get(`/api/procurement/receipts/${id}`)),
|
|
49
|
+
|
|
50
|
+
updateReceiptLineMeasures: (receiptId, lineId, input) => singleRecordOf(http.patch(`/api/procurement/receipts/${receiptId}/lines/${lineId}`, input)),
|
|
51
|
+
|
|
52
|
+
receive: (poId, input) => singleRecordOf(http.post(`/api/procurement/purchase-orders/${poId}/receipts`, input ?? {})),
|
|
53
|
+
},
|
|
54
|
+
landedCosts: {
|
|
55
|
+
|
|
56
|
+
list: (query) => http.get('/api/procurement/landed-costs', {
|
|
57
|
+
params: query,
|
|
58
|
+
}),
|
|
59
|
+
|
|
60
|
+
get: (id) => http.get(`/api/procurement/landed-costs/${id}`),
|
|
61
|
+
|
|
62
|
+
forReceipt: (receiptId) => http.get(`/api/procurement/receipts/${receiptId}/landed-costs`),
|
|
63
|
+
|
|
64
|
+
create: (input) => http.post('/api/procurement/landed-costs', input),
|
|
65
|
+
|
|
66
|
+
update: (id, input) => http.patch(`/api/procurement/landed-costs/${id}`, input),
|
|
67
|
+
|
|
68
|
+
remove: (id) => http.delete(`/api/procurement/landed-costs/${id}`),
|
|
69
|
+
|
|
70
|
+
post: (id) => http.post(`/api/procurement/landed-costs/${id}/post`),
|
|
71
|
+
|
|
72
|
+
cancel: (id, reason) => http.post(`/api/procurement/landed-costs/${id}/cancel`, { reason: reason ?? null }),
|
|
73
|
+
},
|
|
74
|
+
billing: {
|
|
75
|
+
|
|
76
|
+
getBill: (poId) => singleRecordOf(http.get(`/api/procurement/purchase-orders/${poId}/bill`)),
|
|
77
|
+
|
|
78
|
+
bill: (poId, input) => singleRecordOf(http.post(`/api/procurement/purchase-orders/${poId}/bill`, input ?? {})),
|
|
79
|
+
},
|
|
80
|
+
requisitions: {
|
|
81
|
+
|
|
82
|
+
list: (query) => http.get('/api/procurement/requisitions', {
|
|
83
|
+
params: query,
|
|
84
|
+
}),
|
|
85
|
+
|
|
86
|
+
get: (id) => singleRecordOf(http.get(`/api/procurement/requisitions/${id}`)),
|
|
87
|
+
|
|
88
|
+
create: (input) => singleRecordOf(http.post('/api/procurement/requisitions', input)),
|
|
89
|
+
|
|
90
|
+
update: (id, input) => singleRecordOf(http.put(`/api/procurement/requisitions/${id}`, input)),
|
|
91
|
+
|
|
92
|
+
remove: (id) => http.delete(`/api/procurement/requisitions/${id}`),
|
|
93
|
+
|
|
94
|
+
submit: (id) => singleRecordOf(http.post(`/api/procurement/requisitions/${id}/submit`)),
|
|
95
|
+
|
|
96
|
+
approve: (id) => singleRecordOf(http.post(`/api/procurement/requisitions/${id}/approve`)),
|
|
97
|
+
|
|
98
|
+
reject: (id, input) => singleRecordOf(http.post(`/api/procurement/requisitions/${id}/reject`, input ?? {})),
|
|
99
|
+
|
|
100
|
+
convert: (id, input) => singleRecordOf(http.post(`/api/procurement/requisitions/${id}/convert`, input)),
|
|
101
|
+
|
|
102
|
+
addLine: (requisitionId, input) => singleRecordOf(http.post(`/api/procurement/requisitions/${requisitionId}/lines`, input)),
|
|
103
|
+
|
|
104
|
+
removeLine: (requisitionId, lineId) => http.delete(`/api/procurement/requisitions/${requisitionId}/lines/${lineId}`),
|
|
105
|
+
},
|
|
106
|
+
rfqs: {
|
|
107
|
+
|
|
108
|
+
list: (query) => http.get('/api/procurement/rfqs', { params: query }),
|
|
109
|
+
|
|
110
|
+
get: async (id) => (await http.get(`/api/procurement/rfqs/${id}`)).data,
|
|
111
|
+
|
|
112
|
+
create: (input) => singleRecordOf(http.post('/api/procurement/rfqs', input)),
|
|
113
|
+
|
|
114
|
+
update: (id, input) => singleRecordOf(http.put(`/api/procurement/rfqs/${id}`, input)),
|
|
115
|
+
|
|
116
|
+
remove: (id) => http.delete(`/api/procurement/rfqs/${id}`),
|
|
117
|
+
|
|
118
|
+
send: (id, input) => singleRecordOf(http.post(`/api/procurement/rfqs/${id}/send`, input)),
|
|
119
|
+
|
|
120
|
+
recordQuote: (id, input) => singleRecordOf(http.post(`/api/procurement/rfqs/${id}/quotes`, input)),
|
|
121
|
+
|
|
122
|
+
award: (id, input) => singleRecordOf(http.post(`/api/procurement/rfqs/${id}/award`, input)),
|
|
123
|
+
|
|
124
|
+
addLine: (rfqId, input) => singleRecordOf(http.post(`/api/procurement/rfqs/${rfqId}/lines`, input)),
|
|
125
|
+
|
|
126
|
+
publish: async (id, input) => (await http.post(`/api/procurement/rfqs/${id}/publish`, input)).data,
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
sourcingPolicy: {
|
|
130
|
+
|
|
131
|
+
get: async () => (await http.get('/api/procurement/sourcing-policy')).data,
|
|
132
|
+
|
|
133
|
+
set: async (input) => (await http.put('/api/procurement/sourcing-policy', input)).data,
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
receivingPolicy: {
|
|
137
|
+
|
|
138
|
+
get: async () => (await http.get('/api/procurement/receiving-policy')).data,
|
|
139
|
+
|
|
140
|
+
set: async (input) => (await http.put('/api/procurement/receiving-policy', input)).data,
|
|
141
|
+
},
|
|
142
|
+
reports: {
|
|
143
|
+
|
|
144
|
+
summary: (query) => http.get('/api/procurement/reports/summary', {
|
|
145
|
+
params: query,
|
|
146
|
+
}),
|
|
147
|
+
|
|
148
|
+
byVendor: (query) => http.get('/api/procurement/reports/by-vendor', { params: query }),
|
|
149
|
+
|
|
150
|
+
byProduct: (query) => http.get('/api/procurement/reports/by-product', { params: query }),
|
|
151
|
+
|
|
152
|
+
byPeriod: (query) => http.get('/api/procurement/reports/by-period', { params: query }),
|
|
153
|
+
|
|
154
|
+
openOrders: (query) => http.get('/api/procurement/reports/open-orders', { params: query }),
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions } from './actors.js';
|
|
3
|
+
export type CampaignStatus = 'draft' | 'screening' | 'in_review' | 'active' | 'paused' | 'ended' | 'rejected';
|
|
4
|
+
export type CampaignPausedReason = 'advertiser' | 'subject_unavailable' | 'advertiser_standing' | 'moderation';
|
|
5
|
+
export type PromotionHideScope = 'campaign' | 'advertiser';
|
|
6
|
+
/** Refusal reasons a campaign write or estimate can answer with (`reason` in the error body). */
|
|
7
|
+
export type PromotionsRefusalReason = 'promotions_unavailable' | 'cannot_advertise_as' | 'campaign_not_found' | 'version_conflict' | 'campaign_not_editable' | 'transition_refused' | 'subject_not_promotable' | 'sensitive_targeting_refused' | 'exact_area_refused' | 'surface_refused' | 'audience_too_small' | 'interest_targeting_off' | 'screening_unavailable' | 'billing_unavailable' | 'advertiser_restricted' | 'too_many_campaigns';
|
|
8
|
+
/**
|
|
9
|
+
* Who sees it. Surfaces are `feed:<key>` (e.g. `feed:public.explore`); areas are a country, region
|
|
10
|
+
* or city key (`jo`, `jo.amman`) — never an exact place. `interest_categories` work only for people
|
|
11
|
+
* who granted advertising use of their activity.
|
|
12
|
+
*/
|
|
13
|
+
export interface CampaignTargeting {
|
|
14
|
+
surfaces: string[];
|
|
15
|
+
area_keys: string[];
|
|
16
|
+
taxonomy_categories: string[];
|
|
17
|
+
languages: string[];
|
|
18
|
+
interest_categories: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface Campaign {
|
|
21
|
+
id: string;
|
|
22
|
+
advertiser: {
|
|
23
|
+
kind: 'person' | 'actor';
|
|
24
|
+
id: string | null;
|
|
25
|
+
};
|
|
26
|
+
subject: {
|
|
27
|
+
type: string;
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
name: BilingualText;
|
|
31
|
+
status: CampaignStatus;
|
|
32
|
+
status_label: BilingualText;
|
|
33
|
+
paused_reason: CampaignPausedReason | null;
|
|
34
|
+
paused_reason_label: BilingualText | null;
|
|
35
|
+
starts_at: string | null;
|
|
36
|
+
ends_at: string | null;
|
|
37
|
+
/** ISO 4217, stored on the campaign. */
|
|
38
|
+
currency: string;
|
|
39
|
+
budget_total_minor: number;
|
|
40
|
+
daily_budget_minor: number | null;
|
|
41
|
+
bid_per_thousand_minor: number;
|
|
42
|
+
spent_minor: number;
|
|
43
|
+
frequency_cap_per_day: number;
|
|
44
|
+
audience_estimate: number | null;
|
|
45
|
+
screening_decision: string | null;
|
|
46
|
+
rejection_reason: string | null;
|
|
47
|
+
targeting: CampaignTargeting;
|
|
48
|
+
/** Send back on update; a stale one answers 409 `version_conflict`. */
|
|
49
|
+
version: number;
|
|
50
|
+
submitted_at: string | null;
|
|
51
|
+
activated_at: string | null;
|
|
52
|
+
ended_at: string | null;
|
|
53
|
+
created_at: string | null;
|
|
54
|
+
updated_at: string | null;
|
|
55
|
+
can: {
|
|
56
|
+
edit: boolean;
|
|
57
|
+
submit: boolean;
|
|
58
|
+
pause: boolean;
|
|
59
|
+
resume: boolean;
|
|
60
|
+
end: boolean;
|
|
61
|
+
delete: boolean;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface CampaignInput {
|
|
65
|
+
subject: {
|
|
66
|
+
type: string;
|
|
67
|
+
id: string;
|
|
68
|
+
};
|
|
69
|
+
name: Partial<BilingualText>;
|
|
70
|
+
currency: string;
|
|
71
|
+
budget_total_minor: number;
|
|
72
|
+
daily_budget_minor?: number | null;
|
|
73
|
+
bid_per_thousand_minor: number;
|
|
74
|
+
frequency_cap_per_day?: number;
|
|
75
|
+
starts_at?: string | null;
|
|
76
|
+
ends_at?: string | null;
|
|
77
|
+
targeting?: Partial<CampaignTargeting>;
|
|
78
|
+
/** Required on update. */
|
|
79
|
+
version?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface CampaignPage {
|
|
82
|
+
data: Campaign[];
|
|
83
|
+
next_cursor: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface AudienceEstimate {
|
|
86
|
+
/** Rounded down to tens; null while under `minimum` — the exact small number is never shown. */
|
|
87
|
+
estimate: number | null;
|
|
88
|
+
meets_minimum: boolean;
|
|
89
|
+
minimum: number;
|
|
90
|
+
window_days: number;
|
|
91
|
+
}
|
|
92
|
+
export interface CampaignReportCell {
|
|
93
|
+
day: string;
|
|
94
|
+
surface: string;
|
|
95
|
+
/** True when the cell is under `cell_minimum`: its numbers are null. */
|
|
96
|
+
suppressed: boolean;
|
|
97
|
+
impressions: number | null;
|
|
98
|
+
clicks: number | null;
|
|
99
|
+
spend_minor: number | null;
|
|
100
|
+
}
|
|
101
|
+
export interface CampaignReport {
|
|
102
|
+
campaign_id: string;
|
|
103
|
+
currency: string;
|
|
104
|
+
budget_total_minor: number;
|
|
105
|
+
spent_minor: number;
|
|
106
|
+
cell_minimum: number;
|
|
107
|
+
cells: CampaignReportCell[];
|
|
108
|
+
suppressed_cells: number;
|
|
109
|
+
totals: {
|
|
110
|
+
suppressed: boolean;
|
|
111
|
+
impressions: number | null;
|
|
112
|
+
clicks: number | null;
|
|
113
|
+
click_rate: number | null;
|
|
114
|
+
spend_minor?: number | null;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export interface PromotionWhyCriterion {
|
|
118
|
+
/** `context` · `language` · `area` · `interest` · `broad` */
|
|
119
|
+
key: string;
|
|
120
|
+
label: BilingualText;
|
|
121
|
+
values: Array<{
|
|
122
|
+
key: string;
|
|
123
|
+
label: BilingualText;
|
|
124
|
+
}>;
|
|
125
|
+
}
|
|
126
|
+
export interface PromotionWhy {
|
|
127
|
+
campaign_id: string;
|
|
128
|
+
advertiser: {
|
|
129
|
+
reference: string;
|
|
130
|
+
name?: BilingualText | string | null;
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
};
|
|
133
|
+
criteria: PromotionWhyCriterion[];
|
|
134
|
+
interest_targeting_used: boolean;
|
|
135
|
+
language: string | null;
|
|
136
|
+
/** The fixed promises, in words. */
|
|
137
|
+
never: BilingualText[];
|
|
138
|
+
controls: {
|
|
139
|
+
hide_campaign: boolean;
|
|
140
|
+
hide_advertiser: boolean;
|
|
141
|
+
report: boolean;
|
|
142
|
+
advertising_grant: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface CampaignListQuery {
|
|
146
|
+
status?: CampaignStatus;
|
|
147
|
+
cursor?: string | null;
|
|
148
|
+
limit?: number;
|
|
149
|
+
}
|
|
150
|
+
export interface PromotionsNamespace {
|
|
151
|
+
list(query: CampaignListQuery, options: PersonDomainCallOptions): Promise<CampaignPage>;
|
|
152
|
+
get(campaignId: string, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
153
|
+
create(input: CampaignInput, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
154
|
+
update(campaignId: string, input: CampaignInput, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
155
|
+
remove(campaignId: string, options: PersonDomainCallOptions): Promise<void>;
|
|
156
|
+
/** Screens, then queues for review. A 503 `screening_unavailable` leaves it in `screening`; submit again. */
|
|
157
|
+
submit(campaignId: string, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
158
|
+
pause(campaignId: string, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
159
|
+
resume(campaignId: string, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
160
|
+
end(campaignId: string, options: PersonDomainCallOptions): Promise<Campaign>;
|
|
161
|
+
report(campaignId: string, options: PersonDomainCallOptions): Promise<CampaignReport>;
|
|
162
|
+
estimateAudience(targeting: Partial<CampaignTargeting>, options: PersonDomainCallOptions): Promise<AudienceEstimate>;
|
|
163
|
+
/** Takes effect from the very next page. */
|
|
164
|
+
hide(campaignKey: string, scope: PromotionHideScope, options?: PersonDomainCallOptions): Promise<void>;
|
|
165
|
+
why(campaignKey: string, options?: PersonDomainCallOptions): Promise<PromotionWhy>;
|
|
166
|
+
/** Counted once, only for an item served today, never the advertiser's own. */
|
|
167
|
+
click(campaignKey: string, surface: string, options?: PersonDomainCallOptions): Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
export declare function createPromotionsNamespace(http: Http): PromotionsNamespace;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
const BASE = '/api/person/promotions';
|
|
3
|
+
const segment = encodeURIComponent;
|
|
4
|
+
export function createPromotionsNamespace(http) {
|
|
5
|
+
const campaign = (campaignId) => `${BASE}/campaigns/${segment(campaignId)}`;
|
|
6
|
+
const data = async (promise) => (await promise).data;
|
|
7
|
+
const transition = (verb) => (campaignId, options) => data(http.post(`${campaign(campaignId)}/${verb}`, undefined, personDomainRequest(options, true)));
|
|
8
|
+
return {
|
|
9
|
+
list: (query, options) => {
|
|
10
|
+
const params = {};
|
|
11
|
+
if (query.status)
|
|
12
|
+
params.status = query.status;
|
|
13
|
+
if (query.cursor)
|
|
14
|
+
params.cursor = query.cursor;
|
|
15
|
+
if (query.limit)
|
|
16
|
+
params.limit = query.limit;
|
|
17
|
+
return http.get(`${BASE}/campaigns`, personDomainRequest(options, false, params));
|
|
18
|
+
},
|
|
19
|
+
get: (campaignId, options) => data(http.get(campaign(campaignId), personDomainRequest(options))),
|
|
20
|
+
create: (input, options) => data(http.post(`${BASE}/campaigns`, input, personDomainRequest(options, true))),
|
|
21
|
+
update: (campaignId, input, options) => data(http.put(campaign(campaignId), input, personDomainRequest(options, true))),
|
|
22
|
+
remove: async (campaignId, options) => {
|
|
23
|
+
await http.delete(campaign(campaignId), personDomainRequest(options, true));
|
|
24
|
+
},
|
|
25
|
+
submit: transition('submit'),
|
|
26
|
+
pause: transition('pause'),
|
|
27
|
+
resume: transition('resume'),
|
|
28
|
+
end: transition('end'),
|
|
29
|
+
report: (campaignId, options) => data(http.get(`${campaign(campaignId)}/report`, personDomainRequest(options))),
|
|
30
|
+
estimateAudience: (targeting, options) => data(http.post(`${BASE}/audience-estimate`, { targeting }, personDomainRequest(options, true))),
|
|
31
|
+
hide: async (campaignKey, scope, options = {}) => {
|
|
32
|
+
await http.post(`${BASE}/hide`, { campaign_key: campaignKey, scope }, personDomainRequest(options, true));
|
|
33
|
+
},
|
|
34
|
+
why: (campaignKey, options = {}) => data(http.get(`${BASE}/why/${segment(campaignKey)}`, personDomainRequest(options))),
|
|
35
|
+
click: async (campaignKey, surface, options = {}) => {
|
|
36
|
+
await http.post(`${BASE}/click`, { campaign_key: campaignKey, surface }, personDomainRequest(options, true));
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|