@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,381 @@
|
|
|
1
|
+
import { type Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PartyReference, type PartyReferenceString, type PersonDomainCallOptions, type PersonDomainCursorPage, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
import { type ListDeclarationDescription, type ListPage, type ListQueryState } from './list-query.js';
|
|
4
|
+
/** A decimal string at scale ≤ 4. Never a number. */
|
|
5
|
+
export type ListingAmount = string;
|
|
6
|
+
export type ListingStatus = 'draft' | 'active' | 'reserved' | 'sold' | 'exchanged' | 'withdrawn' | 'expired';
|
|
7
|
+
export type ListingPricingMode = 'fixed' | 'open_to_offers' | 'exchange_only' | 'free';
|
|
8
|
+
export type ListingFulfilmentOption = 'pickup' | 'delivery' | 'shipping';
|
|
9
|
+
export type ListingModerationState = 'clear' | 'pending_review' | 'restricted' | 'removed';
|
|
10
|
+
export type ListingVisibility = 'public' | 'link';
|
|
11
|
+
export type ListingSort = 'newest' | 'price_ascending' | 'price_descending' | 'distance';
|
|
12
|
+
export type ListingAlertFrequency = 'off' | 'instant' | 'daily';
|
|
13
|
+
export type ListingReportReason = 'prohibited_item' | 'scam_or_fraud' | 'counterfeit' | 'misleading' | 'duplicate' | 'wrong_category' | 'offensive' | 'already_gone' | 'other';
|
|
14
|
+
export declare const LISTING_REPORT_REASONS: readonly ListingReportReason[];
|
|
15
|
+
/** A grade on a kind's declared condition scale (`new`, `like_new`, `good`, …). */
|
|
16
|
+
export interface ListingConditionGrade {
|
|
17
|
+
key: string;
|
|
18
|
+
label: BilingualText;
|
|
19
|
+
}
|
|
20
|
+
/** A kind of listing a vertical declares, with what its composer may ask for. */
|
|
21
|
+
export interface ListingKind {
|
|
22
|
+
key: string;
|
|
23
|
+
label: BilingualText;
|
|
24
|
+
/** The `App\Platform\Attributes` subject whose declared fields shape this kind, if any. */
|
|
25
|
+
attribute_subject: string | null;
|
|
26
|
+
pricing_modes: ListingPricingMode[];
|
|
27
|
+
condition_scale: ListingConditionGrade[];
|
|
28
|
+
fulfilment_options: ListingFulfilmentOption[];
|
|
29
|
+
maximum_media: number;
|
|
30
|
+
requires_location: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type ListingFilterType = 'text' | 'select' | 'multi_select' | 'money_range' | 'distance' | 'boolean' | 'category';
|
|
33
|
+
export interface ListingFilterOption {
|
|
34
|
+
value: string;
|
|
35
|
+
label: BilingualText;
|
|
36
|
+
}
|
|
37
|
+
/** One filter the server declares for search; a filter panel renders exactly these. */
|
|
38
|
+
export interface ListingFilterDeclaration {
|
|
39
|
+
key: string;
|
|
40
|
+
type: ListingFilterType;
|
|
41
|
+
label: BilingualText;
|
|
42
|
+
options?: ListingFilterOption[];
|
|
43
|
+
}
|
|
44
|
+
export interface ListingSortDeclaration {
|
|
45
|
+
key: ListingSort;
|
|
46
|
+
label: BilingualText;
|
|
47
|
+
requires_location: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface ListingFilters {
|
|
50
|
+
filters: ListingFilterDeclaration[];
|
|
51
|
+
sorts: ListingSortDeclaration[];
|
|
52
|
+
default_sort: ListingSort;
|
|
53
|
+
maximum_radius_km: number;
|
|
54
|
+
/** The declared discovery list (the same `meta.list` as `discover({ describe: true })`). */
|
|
55
|
+
list?: ListDeclarationDescription;
|
|
56
|
+
}
|
|
57
|
+
/** A question to a declared listings list — the generic list-query state. */
|
|
58
|
+
export type ListingListQuery = ListQueryState;
|
|
59
|
+
export interface ListingPricing {
|
|
60
|
+
mode: ListingPricingMode;
|
|
61
|
+
amount: ListingAmount | null;
|
|
62
|
+
currency_code: string | null;
|
|
63
|
+
negotiable: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** What the owner would take in return (consideration types come from Exchanges). */
|
|
66
|
+
export interface ListingWanted {
|
|
67
|
+
consideration_type: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ListingLocation {
|
|
71
|
+
place_label: string | null;
|
|
72
|
+
/** Coarsened decimal strings. */
|
|
73
|
+
latitude: string;
|
|
74
|
+
longitude: string;
|
|
75
|
+
precision_meters: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ListingMedia {
|
|
78
|
+
media_id: string;
|
|
79
|
+
/** A signed, short-lived path; null while the file is still being processed. */
|
|
80
|
+
url: string | null;
|
|
81
|
+
}
|
|
82
|
+
export interface Listing {
|
|
83
|
+
id: string;
|
|
84
|
+
kind: string;
|
|
85
|
+
owner: PartyReference;
|
|
86
|
+
title: string;
|
|
87
|
+
description: string;
|
|
88
|
+
category_id: string | null;
|
|
89
|
+
condition: string | null;
|
|
90
|
+
pricing: ListingPricing;
|
|
91
|
+
wanted: ListingWanted[];
|
|
92
|
+
quantity: number;
|
|
93
|
+
quantity_available: number;
|
|
94
|
+
location: ListingLocation | null;
|
|
95
|
+
distance_meters: number | null;
|
|
96
|
+
fulfilment_options: ListingFulfilmentOption[];
|
|
97
|
+
media: ListingMedia[];
|
|
98
|
+
attributes: Record<string, unknown>;
|
|
99
|
+
visibility: ListingVisibility;
|
|
100
|
+
status: ListingStatus;
|
|
101
|
+
moderation_state: ListingModerationState;
|
|
102
|
+
published_at: string | null;
|
|
103
|
+
expires_at: string | null;
|
|
104
|
+
bumped_at: string | null;
|
|
105
|
+
bump_available_at: string | null;
|
|
106
|
+
renewals_remaining: number | null;
|
|
107
|
+
viewer_is_owner: boolean;
|
|
108
|
+
viewer_favourited: boolean;
|
|
109
|
+
version: number;
|
|
110
|
+
created_at: string;
|
|
111
|
+
updated_at: string;
|
|
112
|
+
}
|
|
113
|
+
/** Search criteria — also what a saved search stores. */
|
|
114
|
+
export interface ListingSearchCriteria {
|
|
115
|
+
q?: string | null;
|
|
116
|
+
kind?: string | null;
|
|
117
|
+
category_id?: string | null;
|
|
118
|
+
include_subcategories?: boolean;
|
|
119
|
+
condition?: string[];
|
|
120
|
+
pricing_mode?: ListingPricingMode[];
|
|
121
|
+
price_minimum?: ListingAmount | null;
|
|
122
|
+
price_maximum?: ListingAmount | null;
|
|
123
|
+
currency_code?: string | null;
|
|
124
|
+
latitude?: number | null;
|
|
125
|
+
longitude?: number | null;
|
|
126
|
+
radius_km?: number | null;
|
|
127
|
+
fulfilment?: ListingFulfilmentOption[];
|
|
128
|
+
owner?: PartyReferenceString | null;
|
|
129
|
+
sort?: ListingSort | null;
|
|
130
|
+
}
|
|
131
|
+
export interface ListingSearchQuery extends ListingSearchCriteria {
|
|
132
|
+
cursor?: string | null;
|
|
133
|
+
limit?: number;
|
|
134
|
+
}
|
|
135
|
+
export interface ListingPricingInput {
|
|
136
|
+
mode: ListingPricingMode;
|
|
137
|
+
amount?: ListingAmount | null;
|
|
138
|
+
currency_code?: string | null;
|
|
139
|
+
negotiable?: boolean;
|
|
140
|
+
}
|
|
141
|
+
export interface ListingLocationInput {
|
|
142
|
+
latitude: number;
|
|
143
|
+
longitude: number;
|
|
144
|
+
place_label?: string | null;
|
|
145
|
+
}
|
|
146
|
+
export interface ListingDraftInput {
|
|
147
|
+
kind: string;
|
|
148
|
+
title: string;
|
|
149
|
+
description: string;
|
|
150
|
+
category_id?: string | null;
|
|
151
|
+
condition?: string | null;
|
|
152
|
+
pricing: ListingPricingInput;
|
|
153
|
+
wanted?: {
|
|
154
|
+
consideration_type: string;
|
|
155
|
+
description: string | null;
|
|
156
|
+
}[];
|
|
157
|
+
quantity?: number;
|
|
158
|
+
location?: ListingLocationInput | null;
|
|
159
|
+
fulfilment_options?: ListingFulfilmentOption[];
|
|
160
|
+
media?: string[];
|
|
161
|
+
attributes?: Record<string, unknown>;
|
|
162
|
+
visibility?: ListingVisibility;
|
|
163
|
+
/** Publish at once instead of saving a draft. */
|
|
164
|
+
publish?: boolean;
|
|
165
|
+
}
|
|
166
|
+
export type ListingUpdateInput = Partial<Omit<ListingDraftInput, 'kind' | 'publish'>> & {
|
|
167
|
+
/** The `version` the edit was made against; a newer one answers `listing_version_stale`. */
|
|
168
|
+
expected_version: number;
|
|
169
|
+
};
|
|
170
|
+
export interface ListingFavouriteAnswer {
|
|
171
|
+
listing_id: string;
|
|
172
|
+
favourited: boolean;
|
|
173
|
+
}
|
|
174
|
+
export interface ListingReport {
|
|
175
|
+
id: string;
|
|
176
|
+
listing_id: string;
|
|
177
|
+
reason: ListingReportReason;
|
|
178
|
+
status: string;
|
|
179
|
+
created_at: string;
|
|
180
|
+
}
|
|
181
|
+
/** The body `POST api/person/exchanges` accepts, pre-filled from a listing. */
|
|
182
|
+
export interface ListingOfferTemplate {
|
|
183
|
+
origin_subject_type: 'listings.listing';
|
|
184
|
+
origin_subject_id: string;
|
|
185
|
+
parties: PartyReferenceString[];
|
|
186
|
+
legs: {
|
|
187
|
+
giver: PartyReferenceString;
|
|
188
|
+
receiver: PartyReferenceString;
|
|
189
|
+
consideration_type: string;
|
|
190
|
+
subject_type?: string;
|
|
191
|
+
subject_id?: string;
|
|
192
|
+
description?: string;
|
|
193
|
+
quantity?: number;
|
|
194
|
+
unit_key?: string;
|
|
195
|
+
amount?: ListingAmount;
|
|
196
|
+
}[];
|
|
197
|
+
/**
|
|
198
|
+
* The listing's bilingual HINT for the person composing the offer (`{en, ar}`), or null. Not the
|
|
199
|
+
* offer's own note: `ListingOfferRequest.note` is the person's words, a plain string.
|
|
200
|
+
*/
|
|
201
|
+
note: {
|
|
202
|
+
en: string;
|
|
203
|
+
ar: string;
|
|
204
|
+
} | null;
|
|
205
|
+
payment?: {
|
|
206
|
+
unit_key: string | null;
|
|
207
|
+
unavailable_reason: {
|
|
208
|
+
en: string;
|
|
209
|
+
ar: string;
|
|
210
|
+
} | null;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* `POST /{id}/offers` body — the template's own shape, so a client may send back what
|
|
215
|
+
* `offerTemplate()` answered after the person edited THEIR side. The listed-item leg, `parties` and
|
|
216
|
+
* the origin may be echoed; the server fixes all three. Omit `legs` to offer the template unchanged.
|
|
217
|
+
*/
|
|
218
|
+
export interface ListingOfferRequest {
|
|
219
|
+
legs?: ListingOfferTemplate['legs'];
|
|
220
|
+
note?: string | null;
|
|
221
|
+
parties?: PartyReferenceString[];
|
|
222
|
+
origin_subject_type?: 'listings.listing';
|
|
223
|
+
origin_subject_id?: string;
|
|
224
|
+
}
|
|
225
|
+
/** `POST /{id}/offers` answer: the exchange the offer became (`replayed` on a retried key). */
|
|
226
|
+
export interface ListingOffer {
|
|
227
|
+
listing_id: string;
|
|
228
|
+
exchange_id: string;
|
|
229
|
+
version_id: string | null;
|
|
230
|
+
replayed: boolean;
|
|
231
|
+
}
|
|
232
|
+
/** @deprecated The link is made by core from the exchange's origin; kept for older callers. */
|
|
233
|
+
export interface ListingExchangeLink {
|
|
234
|
+
listing_id: string;
|
|
235
|
+
exchange_id: string;
|
|
236
|
+
linked_at: string;
|
|
237
|
+
}
|
|
238
|
+
export interface SavedListingSearch {
|
|
239
|
+
id: string;
|
|
240
|
+
name: string;
|
|
241
|
+
criteria: ListingSearchCriteria;
|
|
242
|
+
/** The same search as discovery's declared question — `discover(saved.query)` re-opens it. */
|
|
243
|
+
query?: {
|
|
244
|
+
sort?: string;
|
|
245
|
+
search?: string;
|
|
246
|
+
filter?: Record<string, unknown>;
|
|
247
|
+
near?: {
|
|
248
|
+
latitude: string;
|
|
249
|
+
longitude: string;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
alert_frequency: ListingAlertFrequency;
|
|
253
|
+
last_alerted_at: string | null;
|
|
254
|
+
created_at: string;
|
|
255
|
+
updated_at: string;
|
|
256
|
+
}
|
|
257
|
+
export interface SavedListingSearchInput {
|
|
258
|
+
name: string;
|
|
259
|
+
/** The stored-criteria shape. Give this OR `query`. */
|
|
260
|
+
criteria?: ListingSearchCriteria;
|
|
261
|
+
/**
|
|
262
|
+
* Discovery's declared question as the UI holds it ({@link listingSavedSearchQuery} builds it
|
|
263
|
+
* from a {@link ListQueryState}); refused with the list's own 422s.
|
|
264
|
+
*/
|
|
265
|
+
query?: {
|
|
266
|
+
sort?: string;
|
|
267
|
+
search?: string;
|
|
268
|
+
filter?: Record<string, unknown>;
|
|
269
|
+
near?: {
|
|
270
|
+
latitude: string;
|
|
271
|
+
longitude: string;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
alert_frequency: ListingAlertFrequency;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* A list-query state as a saved-search `query` body: the JSON form of the same question
|
|
278
|
+
* (`near` is the declared point parameter).
|
|
279
|
+
*/
|
|
280
|
+
export declare function listingSavedSearchQuery(state: ListQueryState): NonNullable<SavedListingSearchInput['query']>;
|
|
281
|
+
export declare const LISTING_REFUSAL: {
|
|
282
|
+
readonly notFound: "listing_not_found";
|
|
283
|
+
readonly versionStale: "listing_version_stale";
|
|
284
|
+
readonly invalidTransition: "listing_invalid_transition";
|
|
285
|
+
readonly kindUnknown: "listing_kind_unknown";
|
|
286
|
+
readonly pricingNotAllowed: "listing_pricing_not_allowed";
|
|
287
|
+
readonly prohibitedCategory: "listing_prohibited_category";
|
|
288
|
+
readonly duplicate: "listing_duplicate";
|
|
289
|
+
readonly activeLimitReached: "listing_active_limit_reached";
|
|
290
|
+
readonly bumpTooSoon: "listing_bump_too_soon";
|
|
291
|
+
readonly renewalLimitReached: "listing_renewal_limit_reached";
|
|
292
|
+
readonly locationRequired: "listing_location_required";
|
|
293
|
+
readonly ownListing: "listing_own_listing";
|
|
294
|
+
readonly savedSearchLimitReached: "listing_saved_search_limit_reached";
|
|
295
|
+
readonly alreadyReported: "listing_already_reported";
|
|
296
|
+
};
|
|
297
|
+
export type ListingRefusalReason = (typeof LISTING_REFUSAL)[keyof typeof LISTING_REFUSAL];
|
|
298
|
+
/** The stable `reason` of a refused call, or null. */
|
|
299
|
+
export declare function listingRefusalReason(error: unknown): string | null;
|
|
300
|
+
export declare const LISTING_AMOUNT_PATTERN: RegExp;
|
|
301
|
+
/** Refuses a money value that is not an exact decimal string (a number is already a float). */
|
|
302
|
+
export declare function assertListingMoney(value: unknown, field: string): void;
|
|
303
|
+
/** Criteria → query parameters (booleans as 1/0, arrays repeated, empties dropped). */
|
|
304
|
+
export declare function listingSearchParams(criteria: ListingSearchQuery): Record<string, string | number | boolean | undefined | Array<string | number>>;
|
|
305
|
+
export declare function createListingsNamespace(http: Http): {
|
|
306
|
+
/** GET /kinds — the listing kinds offered here, with what each composer may ask. */
|
|
307
|
+
kinds: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingKind[]>>;
|
|
308
|
+
/** GET /filters — the filters and sorts search accepts; render exactly these. */
|
|
309
|
+
filters: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingFilters>>;
|
|
310
|
+
/** GET / — search active listings (folded text, filters, distance). Cursor page. */
|
|
311
|
+
search: (query?: ListingSearchQuery, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Listing>>;
|
|
312
|
+
/**
|
|
313
|
+
* GET / as the DECLARED list: sort, typed filters, search, `parameters.near`, `describe`.
|
|
314
|
+
* A distance order needs `parameters.near` and `filter.within`; relevance needs `search`.
|
|
315
|
+
*/
|
|
316
|
+
discover: (query?: ListingListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<Listing>>;
|
|
317
|
+
/** GET /mine as the declared list (`filter.status`, `filter.pricing_mode`, search, sorts). */
|
|
318
|
+
listMine: (query?: ListingListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<Listing>>;
|
|
319
|
+
/** GET /favourites as the declared list (`-saved_at`). */
|
|
320
|
+
listFavourites: (query?: ListingListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<Listing>>;
|
|
321
|
+
/** GET /mine — the acting party's own listings, any status. */
|
|
322
|
+
mine: (query?: {
|
|
323
|
+
status?: ListingStatus[];
|
|
324
|
+
q?: string | null;
|
|
325
|
+
cursor?: string | null;
|
|
326
|
+
limit?: number;
|
|
327
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Listing>>;
|
|
328
|
+
/** GET /favourites — listings the acting party saved, still visible to it. */
|
|
329
|
+
favourites: (query?: {
|
|
330
|
+
cursor?: string | null;
|
|
331
|
+
limit?: number;
|
|
332
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<Listing>>;
|
|
333
|
+
/** GET /{id} — one listing as the viewer may see it, else 404. */
|
|
334
|
+
show: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
335
|
+
/** POST / — save a draft, or publish at once with `publish: true`. */
|
|
336
|
+
create: (input: ListingDraftInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
337
|
+
/** PATCH /{id} — edit against `expected_version`; a newer version → `listing_version_stale`. */
|
|
338
|
+
update: (listingId: string, input: ListingUpdateInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
339
|
+
publish: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
340
|
+
withdraw: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
341
|
+
renew: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
342
|
+
bump: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
343
|
+
release: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
344
|
+
/** POST /{id}/reserve — hold it (optionally for a linked exchange). */
|
|
345
|
+
reserve: (listingId: string, request?: {
|
|
346
|
+
exchange_id?: string | null;
|
|
347
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
348
|
+
/** POST /{id}/sold — close it (or reduce the quantity available). */
|
|
349
|
+
markGone: (listingId: string, request?: {
|
|
350
|
+
quantity?: number;
|
|
351
|
+
outcome?: "sold" | "exchanged";
|
|
352
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<Listing>>;
|
|
353
|
+
favourite: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingFavouriteAnswer>>;
|
|
354
|
+
unfavourite: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingFavouriteAnswer>>;
|
|
355
|
+
/** POST /{id}/reports — report a listing to the operators. */
|
|
356
|
+
report: (listingId: string, request: {
|
|
357
|
+
reason: ListingReportReason;
|
|
358
|
+
note?: string | null;
|
|
359
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingReport>>;
|
|
360
|
+
/** GET /{id}/offer-template — the `exchanges.propose()` body for an offer on this listing. */
|
|
361
|
+
offerTemplate: (listingId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingOfferTemplate>>;
|
|
362
|
+
/**
|
|
363
|
+
* POST /{id}/offers — make an offer in ONE call: core proposes the exchange (origin
|
|
364
|
+
* `listings.listing`) through Exchanges and follows it from there. Needs an
|
|
365
|
+
* `Idempotency-Key` (one per intent). 201 new, 200 replayed.
|
|
366
|
+
*/
|
|
367
|
+
makeOffer: (listingId: string, request?: ListingOfferRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingOffer>>;
|
|
368
|
+
linkExchange: (listingId: string, exchangeId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<ListingExchangeLink>>;
|
|
369
|
+
savedSearches: {
|
|
370
|
+
list: (query?: {
|
|
371
|
+
cursor?: string | null;
|
|
372
|
+
limit?: number;
|
|
373
|
+
}, options?: PersonDomainCallOptions) => Promise<PersonDomainCursorPage<SavedListingSearch>>;
|
|
374
|
+
/** GET /saved-searches as the declared list (`filter.alert_frequency`, search by name). */
|
|
375
|
+
query: (query?: ListingListQuery, options?: PersonDomainCallOptions) => Promise<ListPage<SavedListingSearch>>;
|
|
376
|
+
create: (input: SavedListingSearchInput, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<SavedListingSearch>>;
|
|
377
|
+
update: (savedSearchId: string, input: Partial<SavedListingSearchInput>, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<SavedListingSearch>>;
|
|
378
|
+
remove: (savedSearchId: string, options?: PersonDomainCallOptions) => Promise<void>;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
export type ListingsNamespace = ReturnType<typeof createListingsNamespace>;
|
package/dist/listings.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { refusalReason } from './http.js';
|
|
4
|
+
import { personDomainRequest, } from './actors.js';
|
|
5
|
+
import { listQueryParams } from './list-query.js';
|
|
6
|
+
export const LISTING_REPORT_REASONS = [
|
|
7
|
+
'prohibited_item',
|
|
8
|
+
'scam_or_fraud',
|
|
9
|
+
'counterfeit',
|
|
10
|
+
'misleading',
|
|
11
|
+
'duplicate',
|
|
12
|
+
'wrong_category',
|
|
13
|
+
'offensive',
|
|
14
|
+
'already_gone',
|
|
15
|
+
'other',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export function listingSavedSearchQuery(state) {
|
|
19
|
+
const near = state.parameters?.near;
|
|
20
|
+
return {
|
|
21
|
+
...(state.sort ? { sort: state.sort } : {}),
|
|
22
|
+
...(state.search && state.search.trim() !== '' ? { search: state.search.trim() } : {}),
|
|
23
|
+
...(state.filter && Object.keys(state.filter).length > 0 ? { filter: state.filter } : {}),
|
|
24
|
+
...(near ? { near: { latitude: String(near.latitude), longitude: String(near.longitude) } } : {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const LISTING_REFUSAL = {
|
|
28
|
+
notFound: 'listing_not_found',
|
|
29
|
+
versionStale: 'listing_version_stale',
|
|
30
|
+
invalidTransition: 'listing_invalid_transition',
|
|
31
|
+
kindUnknown: 'listing_kind_unknown',
|
|
32
|
+
pricingNotAllowed: 'listing_pricing_not_allowed',
|
|
33
|
+
prohibitedCategory: 'listing_prohibited_category',
|
|
34
|
+
duplicate: 'listing_duplicate',
|
|
35
|
+
activeLimitReached: 'listing_active_limit_reached',
|
|
36
|
+
bumpTooSoon: 'listing_bump_too_soon',
|
|
37
|
+
renewalLimitReached: 'listing_renewal_limit_reached',
|
|
38
|
+
locationRequired: 'listing_location_required',
|
|
39
|
+
ownListing: 'listing_own_listing',
|
|
40
|
+
savedSearchLimitReached: 'listing_saved_search_limit_reached',
|
|
41
|
+
alreadyReported: 'listing_already_reported',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function listingRefusalReason(error) {
|
|
45
|
+
return refusalReason(error);
|
|
46
|
+
}
|
|
47
|
+
export const LISTING_AMOUNT_PATTERN = /^\d{1,15}(\.\d{1,4})?$/;
|
|
48
|
+
const UUID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
49
|
+
function assertIdentifier(value, what) {
|
|
50
|
+
if (typeof value !== 'string' || !UUID.test(value)) {
|
|
51
|
+
throw new TypeError(`listings: ${what} must be a uuid, got ${JSON.stringify(value)}.`);
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function assertListingMoney(value, field) {
|
|
57
|
+
if (value === undefined || value === null || value === '')
|
|
58
|
+
return;
|
|
59
|
+
if (typeof value !== 'string' || !LISTING_AMOUNT_PATTERN.test(value)) {
|
|
60
|
+
throw new TypeError(`listings: ${field} must be a decimal string with at most four decimals, got ${JSON.stringify(value)}.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function listingSearchParams(criteria) {
|
|
65
|
+
assertListingMoney(criteria.price_minimum, 'price_minimum');
|
|
66
|
+
assertListingMoney(criteria.price_maximum, 'price_maximum');
|
|
67
|
+
const text = (value) => (value === null || value === undefined || value.trim() === '' ? undefined : value.trim());
|
|
68
|
+
const list = (value) => (value && value.length > 0 ? value : undefined);
|
|
69
|
+
const number = (value) => (value === null || value === undefined || Number.isNaN(value) ? undefined : value);
|
|
70
|
+
return {
|
|
71
|
+
q: text(criteria.q),
|
|
72
|
+
kind: text(criteria.kind),
|
|
73
|
+
category_id: text(criteria.category_id),
|
|
74
|
+
include_subcategories: criteria.include_subcategories === undefined ? undefined : criteria.include_subcategories,
|
|
75
|
+
condition: list(criteria.condition),
|
|
76
|
+
pricing_mode: list(criteria.pricing_mode),
|
|
77
|
+
price_minimum: text(criteria.price_minimum),
|
|
78
|
+
price_maximum: text(criteria.price_maximum),
|
|
79
|
+
currency_code: text(criteria.currency_code),
|
|
80
|
+
latitude: number(criteria.latitude),
|
|
81
|
+
longitude: number(criteria.longitude),
|
|
82
|
+
radius_km: number(criteria.radius_km),
|
|
83
|
+
fulfilment: list(criteria.fulfilment),
|
|
84
|
+
owner: text(criteria.owner),
|
|
85
|
+
sort: text(criteria.sort),
|
|
86
|
+
cursor: text(criteria.cursor),
|
|
87
|
+
limit: criteria.limit,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const BASE = '/api/person/listings';
|
|
91
|
+
export function createListingsNamespace(http) {
|
|
92
|
+
const read = (options, params) => personDomainRequest(options, false, params);
|
|
93
|
+
const write = (options) => personDomainRequest(options, true);
|
|
94
|
+
const listingPath = (listingId) => `${BASE}/${assertIdentifier(listingId, 'listingId')}`;
|
|
95
|
+
const transition = (action) => (listingId, options) => http.post(`${listingPath(listingId)}/${action}`, undefined, write(options));
|
|
96
|
+
const assertDraftMoney = (input) => assertListingMoney(input.pricing?.amount, 'pricing.amount');
|
|
97
|
+
return {
|
|
98
|
+
|
|
99
|
+
kinds: (options) => http.get(`${BASE}/kinds`, read(options)),
|
|
100
|
+
|
|
101
|
+
filters: (options) => http.get(`${BASE}/filters`, read(options)),
|
|
102
|
+
|
|
103
|
+
search: (query = {}, options) => http.get(BASE, read(options, listingSearchParams(query))),
|
|
104
|
+
|
|
105
|
+
discover: (query = {}, options) => http.get(BASE, read(options, listQueryParams(query))),
|
|
106
|
+
|
|
107
|
+
listMine: (query = {}, options) => http.get(`${BASE}/mine`, read(options, listQueryParams(query))),
|
|
108
|
+
|
|
109
|
+
listFavourites: (query = {}, options) => http.get(`${BASE}/favourites`, read(options, listQueryParams(query))),
|
|
110
|
+
|
|
111
|
+
mine: (query = {}, options) => http.get(`${BASE}/mine`, read(options, {
|
|
112
|
+
status: query.status && query.status.length > 0 ? query.status : undefined,
|
|
113
|
+
q: query.q ?? undefined,
|
|
114
|
+
cursor: query.cursor ?? undefined,
|
|
115
|
+
limit: query.limit,
|
|
116
|
+
})),
|
|
117
|
+
|
|
118
|
+
favourites: (query = {}, options) => http.get(`${BASE}/favourites`, read(options, { cursor: query.cursor ?? undefined, limit: query.limit })),
|
|
119
|
+
|
|
120
|
+
show: (listingId, options) => http.get(listingPath(listingId), read(options)),
|
|
121
|
+
|
|
122
|
+
create: (input, options) => {
|
|
123
|
+
assertDraftMoney(input);
|
|
124
|
+
return http.post(BASE, input, write(options));
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
update: (listingId, input, options) => {
|
|
128
|
+
assertDraftMoney(input);
|
|
129
|
+
return http.patch(listingPath(listingId), input, write(options));
|
|
130
|
+
},
|
|
131
|
+
publish: transition('publish'),
|
|
132
|
+
withdraw: transition('withdraw'),
|
|
133
|
+
renew: transition('renew'),
|
|
134
|
+
bump: transition('bump'),
|
|
135
|
+
release: transition('release'),
|
|
136
|
+
|
|
137
|
+
reserve: (listingId, request = {}, options) => http.post(`${listingPath(listingId)}/reserve`, request.exchange_id ? { exchange_id: assertIdentifier(request.exchange_id, 'exchange_id') } : {}, write(options)),
|
|
138
|
+
|
|
139
|
+
markGone: (listingId, request = {}, options) => http.post(`${listingPath(listingId)}/sold`, request, write(options)),
|
|
140
|
+
favourite: (listingId, options) => http.put(`${listingPath(listingId)}/favourite`, undefined, write(options)),
|
|
141
|
+
unfavourite: (listingId, options) => http.delete(`${listingPath(listingId)}/favourite`, write(options)),
|
|
142
|
+
|
|
143
|
+
report: (listingId, request, options) => http.post(`${listingPath(listingId)}/reports`, request, write(options)),
|
|
144
|
+
|
|
145
|
+
offerTemplate: (listingId, options) => http.get(`${listingPath(listingId)}/offer-template`, read(options)),
|
|
146
|
+
|
|
147
|
+
makeOffer: (listingId, request = {}, options) => {
|
|
148
|
+
for (const [index, leg] of (request.legs ?? []).entries())
|
|
149
|
+
assertListingMoney(leg.amount, `legs[${index}].amount`);
|
|
150
|
+
return http.post(`${listingPath(listingId)}/offers`, request, write(options));
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
linkExchange: (listingId, exchangeId, options) => http.post(`${listingPath(listingId)}/exchanges`, { exchange_id: assertIdentifier(exchangeId, 'exchangeId') }, write(options)),
|
|
154
|
+
savedSearches: {
|
|
155
|
+
list: (query = {}, options) => http.get(`${BASE}/saved-searches`, read(options, { cursor: query.cursor ?? undefined, limit: query.limit })),
|
|
156
|
+
|
|
157
|
+
query: (query = {}, options) => http.get(`${BASE}/saved-searches`, read(options, listQueryParams(query))),
|
|
158
|
+
create: (input, options) => {
|
|
159
|
+
if (!input.criteria && !input.query)
|
|
160
|
+
throw new TypeError('listings: a saved search needs `criteria` or `query`.');
|
|
161
|
+
if (input.criteria)
|
|
162
|
+
listingSearchParams(input.criteria);
|
|
163
|
+
return http.post(`${BASE}/saved-searches`, input, write(options));
|
|
164
|
+
},
|
|
165
|
+
update: (savedSearchId, input, options) => {
|
|
166
|
+
if (input.criteria)
|
|
167
|
+
listingSearchParams(input.criteria);
|
|
168
|
+
return http.patch(`${BASE}/saved-searches/${assertIdentifier(savedSearchId, 'savedSearchId')}`, input, write(options));
|
|
169
|
+
},
|
|
170
|
+
remove: (savedSearchId, options) => http.delete(`${BASE}/saved-searches/${assertIdentifier(savedSearchId, 'savedSearchId')}`, write(options)),
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { Http } from './http.js';
|
|
2
|
+
import { type BilingualText, type PersonDomainCallOptions, type PersonDomainEnvelope } from './actors.js';
|
|
3
|
+
export type LiveShareDuration = 'fifteen_minutes' | 'one_hour' | 'eight_hours';
|
|
4
|
+
export type LiveSharingAllowance = 'off' | 'up_to_fifteen_minutes' | 'up_to_one_hour' | 'up_to_eight_hours';
|
|
5
|
+
export type LocationShareEndReason = 'stopped' | 'expired' | 'replaced' | 'completed';
|
|
6
|
+
export interface LocationSharingOptions {
|
|
7
|
+
/** False when the policy is `off`: offer "share once" only. */
|
|
8
|
+
live_enabled: boolean;
|
|
9
|
+
allowance: LiveSharingAllowance;
|
|
10
|
+
/** The lengths offered, shortest first. */
|
|
11
|
+
durations: Array<{
|
|
12
|
+
value: LiveShareDuration;
|
|
13
|
+
minutes: number;
|
|
14
|
+
label: BilingualText;
|
|
15
|
+
}>;
|
|
16
|
+
retention: 'immediately' | 'twenty_four_hours' | 'seven_days';
|
|
17
|
+
retention_hours: number;
|
|
18
|
+
/** How often to report a position, and to poll a share. */
|
|
19
|
+
update_interval_seconds: number;
|
|
20
|
+
}
|
|
21
|
+
export interface LiveSharePosition {
|
|
22
|
+
/** 7-place decimal strings. */
|
|
23
|
+
latitude: string;
|
|
24
|
+
longitude: string;
|
|
25
|
+
/** Metres. */
|
|
26
|
+
accuracy_metres: number | null;
|
|
27
|
+
/** Degrees clockwise from north. */
|
|
28
|
+
heading_degrees: number | null;
|
|
29
|
+
at: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface LocationShare {
|
|
32
|
+
id: string;
|
|
33
|
+
sharer_person_id: string;
|
|
34
|
+
/** Whether the reader is the sharer (may move and stop it). */
|
|
35
|
+
is_mine: boolean;
|
|
36
|
+
purpose: 'conversation' | 'fulfilment_job';
|
|
37
|
+
conversation_id: string | null;
|
|
38
|
+
message_id: string | null;
|
|
39
|
+
duration_minutes: number;
|
|
40
|
+
position: LiveSharePosition | null;
|
|
41
|
+
started_at: string;
|
|
42
|
+
expires_at: string;
|
|
43
|
+
ended_at: string | null;
|
|
44
|
+
end_reason: LocationShareEndReason | null;
|
|
45
|
+
live: boolean;
|
|
46
|
+
seconds_left: number;
|
|
47
|
+
}
|
|
48
|
+
/** `metadata.live_location` of a `live_location` message. */
|
|
49
|
+
export interface LiveLocationMessageMetadata {
|
|
50
|
+
share_id: string;
|
|
51
|
+
duration: LiveShareDuration;
|
|
52
|
+
started_at: string;
|
|
53
|
+
expires_at: string;
|
|
54
|
+
}
|
|
55
|
+
export interface PositionReport {
|
|
56
|
+
latitude: number;
|
|
57
|
+
longitude: number;
|
|
58
|
+
accuracy_metres?: number | null;
|
|
59
|
+
heading_degrees?: number | null;
|
|
60
|
+
}
|
|
61
|
+
export interface StartLiveShareRequest extends PositionReport {
|
|
62
|
+
duration: LiveShareDuration;
|
|
63
|
+
}
|
|
64
|
+
export interface StartedLiveShare {
|
|
65
|
+
share: LocationShare;
|
|
66
|
+
/** The `live_location` message posted into the conversation. */
|
|
67
|
+
message: Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
export declare function createLocationSharingNamespace(http: Http): {
|
|
70
|
+
/** GET /api/person/location-sharing/options — the share sheet's choices, from the declared policies. */
|
|
71
|
+
options: (options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<LocationSharingOptions>>;
|
|
72
|
+
/** POST /conversations/{id}/live-locations — start sharing live; replaces your previous live share in that room. */
|
|
73
|
+
start: (conversationId: string, request: StartLiveShareRequest, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<StartedLiveShare>>;
|
|
74
|
+
/** GET /conversations/{id}/live-locations — who is sharing live in this room right now (that you may see). */
|
|
75
|
+
liveIn: (conversationId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<LocationShare[]>>;
|
|
76
|
+
/** GET /location-shares/{id} — one share; 404 once it is no longer live (unless it is yours). */
|
|
77
|
+
show: (shareId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<LocationShare>>;
|
|
78
|
+
/** PUT /location-shares/{id}/position — the sharer's latest position; 409 `share_ended` once over. */
|
|
79
|
+
report: (shareId: string, position: PositionReport, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<LocationShare>>;
|
|
80
|
+
/** POST /location-shares/{id}/stop — stop now. Idempotent. */
|
|
81
|
+
stop: (shareId: string, options?: PersonDomainCallOptions) => Promise<PersonDomainEnvelope<LocationShare>>;
|
|
82
|
+
};
|
|
83
|
+
export type LocationSharingNamespace = ReturnType<typeof createLocationSharingNamespace>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { personDomainRequest } from './actors.js';
|
|
2
|
+
export function createLocationSharingNamespace(http) {
|
|
3
|
+
const segment = encodeURIComponent;
|
|
4
|
+
const read = (options) => personDomainRequest(options, false);
|
|
5
|
+
const write = (options) => personDomainRequest(options, true);
|
|
6
|
+
return {
|
|
7
|
+
|
|
8
|
+
options: (options) => http.get('/api/person/location-sharing/options', read(options)),
|
|
9
|
+
|
|
10
|
+
start: (conversationId, request, options) => http.post(`/api/person/conversations/${segment(conversationId)}/live-locations`, request, write(options)),
|
|
11
|
+
|
|
12
|
+
liveIn: (conversationId, options) => http.get(`/api/person/conversations/${segment(conversationId)}/live-locations`, read(options)),
|
|
13
|
+
|
|
14
|
+
show: (shareId, options) => http.get(`/api/person/location-shares/${segment(shareId)}`, read(options)),
|
|
15
|
+
|
|
16
|
+
report: (shareId, position, options) => http.put(`/api/person/location-shares/${segment(shareId)}/position`, position, read(options)),
|
|
17
|
+
|
|
18
|
+
stop: (shareId, options) => http.post(`/api/person/location-shares/${segment(shareId)}/stop`, undefined, write(options)),
|
|
19
|
+
};
|
|
20
|
+
}
|