@proveanything/smartlinks 2.1.34 → 2.1.37

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.
@@ -548,8 +548,12 @@ export interface AuthKitConfig {
548
548
  afterSignInUrl?: string;
549
549
  /** Extra domains emailed links may return to (the collection's own domains are always allowed). */
550
550
  allowedRedirectDomains?: string[];
551
- /** Wording on the screens. */
551
+ /** Wording on the screens, in the language `textsLanguage` names (English when not set). */
552
552
  texts?: Partial<Record<AuthKitTextKey, string>>;
553
+ /** The language `texts` is written in ("en", "de", ...): only visitors in that language see it. */
554
+ textsLanguage?: string;
555
+ /** The same wording per language, e.g. `{ fr: { signInTitle: 'Connexion' } }`; wins over `texts`. */
556
+ textsByLanguage?: Record<string, Partial<Record<AuthKitTextKey, string>>>;
553
557
  /** Wording of the account emails, per email. Preview with {@link authKit.previewEmail}. */
554
558
  emailTemplates?: Partial<Record<AuthKitEmailKind, AuthKitEmailTemplate>>;
555
559
  /** The account emails' look. The sender is the collection's email settings (verified domain). */
@@ -13,7 +13,8 @@ export type ContainerStatus = 'active' | 'archived' | string;
13
13
  * Types of items that can be placed inside a container.
14
14
  * A `container` item type allows containers to nest inside other containers.
15
15
  */
16
- export type ContainerItemType = 'tag' | 'proof' | 'serial' | 'order_item' | 'container';
16
+ /** What a container holds: items (proofs) and tags. A container goes inside another by its parent, never as an entry. */
17
+ export type ContainerItemType = 'tag' | 'proof';
17
18
  /**
18
19
  * A physical or logical container entity.
19
20
  *
@@ -76,6 +77,8 @@ export interface ContainerItem {
76
77
  productId?: string;
77
78
  /** Convenience denormalisation — proof / serial UUID if applicable */
78
79
  proofId?: string;
80
+ /** The item's global id (`itm_…`) for itemType 'proof': how the platform tells same-id items under different products apart */
81
+ itemUid?: string | null;
79
82
  /** ISO 8601 — when the item was placed into the container */
80
83
  addedAt: string;
81
84
  /** ISO 8601 — when the item was removed; `null` / `undefined` = still inside */
@@ -191,6 +194,8 @@ export interface ListContainerItemsParams {
191
194
  export interface FindContainersForItemParams {
192
195
  /** Required */
193
196
  itemType: ContainerItemType;
194
- /** Required */
197
+ /** Required: a tag's id, or an item's proof id (or its uid, `itm_…`) */
195
198
  itemId: string;
199
+ /** For an item: its product. Needed when the proof id repeats across products (else 400 AMBIGUOUS_ITEM). */
200
+ productId?: string;
196
201
  }
@@ -42,6 +42,7 @@ export * from "./ai.js";
42
42
  export * from "./appManifest.js";
43
43
  export * from "./appObjects.js";
44
44
  export * from "./bookings.js";
45
+ export * from "./shop.js";
45
46
  export * from "./loyalty.js";
46
47
  export * from "./translations.js";
47
48
  export * from "./integrations.js";
@@ -44,6 +44,7 @@ export * from "./ai.js";
44
44
  export * from "./appManifest.js";
45
45
  export * from "./appObjects.js";
46
46
  export * from "./bookings.js";
47
+ export * from "./shop.js";
47
48
  export * from "./loyalty.js";
48
49
  export * from "./translations.js";
49
50
  export * from "./integrations.js";
@@ -62,6 +62,11 @@ export interface ProductQueryRequest {
62
62
  includeDeleted?: boolean;
63
63
  }
64
64
  export interface Product extends ProductKey {
65
+ /**
66
+ * The product's global id (`prd_` + 14 characters): never changes, unique everywhere. Identity only, not an
67
+ * address: links keep using `id`. Accepted wherever a product id goes in a path. Ids can't start with prd_ / itm_.
68
+ */
69
+ uid?: string | null;
65
70
  orgId?: string | null;
66
71
  name: string;
67
72
  description?: string | null;
@@ -26,6 +26,11 @@ export interface Proof {
26
26
  createdAt: string;
27
27
  /** Unique identifier for the proof */
28
28
  id: string;
29
+ /**
30
+ * The item's global id (`itm_` + 14 characters): never changes, unique everywhere. Identity only, not an
31
+ * address: links, QR codes and tags keep using `productId` + `id`. Accepted wherever a proof id goes in a path.
32
+ */
33
+ uid?: string | null;
29
34
  /** Unique identifier for the product */
30
35
  productId: string;
31
36
  /** Unique identifier for the token */
@@ -0,0 +1,377 @@
1
+ /** How a price is delivered: shipped, or delivered when paid. */
2
+ export type ShopDelivery = 'physical' | 'digital';
3
+ /**
4
+ * How a digital price is delivered:
5
+ * - `proof` a proof of ownership minted for the buyer (needs a signed-in buyer)
6
+ * - `download` files from the product's assets
7
+ * - `access` membership of a user group (needs a signed-in buyer)
8
+ * - `app` an app delivers it on `order.paid` and marks the line delivered
9
+ */
10
+ export type ShopDigitalKind = 'proof' | 'download' | 'access' | 'app';
11
+ export type ShopDeliveryConfig = {
12
+ kind: 'proof';
13
+ productId?: string;
14
+ } | {
15
+ kind: 'download';
16
+ assetIds: string[];
17
+ maxDownloads?: number;
18
+ } | {
19
+ kind: 'access';
20
+ userGroupId: string;
21
+ } | {
22
+ kind: 'app';
23
+ appId: string;
24
+ };
25
+ /** One price: a product (or variant) for sale in one currency. For sale = has an active price. */
26
+ export interface ShopPrice {
27
+ id: string;
28
+ collectionId: string;
29
+ productId: string;
30
+ variantId: string | null;
31
+ /** The app that put it on sale ('shop' unless another app did). SmartLinks' fee follows it. */
32
+ appId: string;
33
+ currency: string;
34
+ /** Minor units, VAT included. */
35
+ amount: number;
36
+ /** A "was" price to show crossed out. */
37
+ compareAtAmount: number | null;
38
+ delivery: ShopDelivery;
39
+ deliveryConfig: ShopDeliveryConfig | Record<string, never>;
40
+ /** Sell only what stock says is available; it's held while the buyer pays. */
41
+ trackStock: boolean;
42
+ active: boolean;
43
+ sort: number;
44
+ metadata: Record<string, any>;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ }
48
+ export interface ShopPriceInput {
49
+ productId: string;
50
+ variantId?: string | null;
51
+ /** The app putting it on sale. Must be installed in the collection; 'shop' by default. */
52
+ appId?: string;
53
+ /** Defaults to the shop's currency. */
54
+ currency?: string;
55
+ amount: number;
56
+ compareAtAmount?: number | null;
57
+ delivery?: ShopDelivery;
58
+ deliveryConfig?: ShopDeliveryConfig;
59
+ trackStock?: boolean;
60
+ active?: boolean;
61
+ sort?: number;
62
+ metadata?: Record<string, any>;
63
+ }
64
+ export type ShopPriceUpdate = Partial<Omit<ShopPriceInput, 'productId' | 'variantId' | 'currency'>>;
65
+ export interface ShopPriceListParams {
66
+ productId?: string;
67
+ currency?: string;
68
+ active?: boolean;
69
+ appId?: string;
70
+ limit?: number;
71
+ offset?: number;
72
+ }
73
+ export interface ShopShippingRate {
74
+ id: string;
75
+ label: string;
76
+ /** Minor units. */
77
+ amount: number;
78
+ /** "2-3 working days" */
79
+ days?: string;
80
+ }
81
+ /** The shop's settings (admin). Nothing here is secret; SmartLinks' own Stripe keys are server-side. */
82
+ export interface ShopSettings {
83
+ currency: string;
84
+ /** The app whose flows run on order events (emails, staff alerts). */
85
+ appId: string;
86
+ /** Shown to buyers before they pay (UK law: name, address, a way to get in touch). */
87
+ seller: {
88
+ name?: string;
89
+ address?: string;
90
+ email?: string;
91
+ phone?: string;
92
+ vatNumber?: string;
93
+ };
94
+ vat: {
95
+ registered: boolean;
96
+ rate: number;
97
+ };
98
+ shipping: {
99
+ rates: ShopShippingRate[];
100
+ /** Free delivery from this subtotal (minor units). */
101
+ freeOver: number | null;
102
+ /** Offer collection in person. */
103
+ collection: {
104
+ label: string;
105
+ } | null;
106
+ };
107
+ policies: {
108
+ returns?: string;
109
+ terms?: string;
110
+ privacy?: string;
111
+ };
112
+ /** Set by connecting Stripe (`shop.admin.connect`), never directly. */
113
+ stripe: {
114
+ accountId: string | null;
115
+ };
116
+ /** Where shop stock is held (any container with stock when not set). */
117
+ stockContainerId: string | null;
118
+ checkout: {
119
+ /** Where Stripe sends the buyer after paying; `?session_id=` is added. */
120
+ successUrl: string | null;
121
+ cancelUrl: string | null;
122
+ /** How long stock is held for an unpaid checkout: 30 to 1440 minutes. */
123
+ expiresMinutes: number;
124
+ /** Other hosts the checkout may return to (beyond smartlinks.app, smartlinks.host and the pages above). */
125
+ allowedHosts: string[];
126
+ };
127
+ digital: {
128
+ euBuyers: boolean;
129
+ };
130
+ /** Record a purchase interaction when an order is paid. */
131
+ interaction: {
132
+ interactionId: string | null;
133
+ };
134
+ }
135
+ /** What's still needed before the shop can take money. */
136
+ export interface ShopReadiness {
137
+ ready: boolean;
138
+ missing: {
139
+ key: string;
140
+ text: string;
141
+ }[];
142
+ }
143
+ /** GET /shop/settings: the settings, what's missing, and what SmartLinks takes (read-only). */
144
+ export interface ShopSettingsView extends ShopSettings {
145
+ readiness: ShopReadiness;
146
+ fee: {
147
+ appId: string;
148
+ bps: number;
149
+ percent: number;
150
+ };
151
+ }
152
+ /** A settings change: merged into what's stored; shipping rates are replaced as a whole. */
153
+ export type ShopSettingsPatch = Partial<Omit<ShopSettings, 'stripe' | 'shipping' | 'checkout' | 'vat' | 'seller' | 'digital' | 'interaction'>> & {
154
+ seller?: Partial<ShopSettings['seller']>;
155
+ vat?: Partial<ShopSettings['vat']>;
156
+ shipping?: Partial<ShopSettings['shipping']>;
157
+ checkout?: Partial<ShopSettings['checkout']>;
158
+ digital?: Partial<ShopSettings['digital']>;
159
+ interaction?: Partial<ShopSettings['interaction']>;
160
+ };
161
+ export interface ShopConnectStatus {
162
+ connected: boolean;
163
+ chargesEnabled?: boolean;
164
+ detailsSubmitted?: boolean;
165
+ payoutsEnabled?: boolean;
166
+ id?: string;
167
+ }
168
+ /** What a shop front reads: nothing private. */
169
+ export interface ShopPublicConfig {
170
+ currency: string;
171
+ seller: {
172
+ name: string | null;
173
+ address: string | null;
174
+ email: string | null;
175
+ vatNumber?: string;
176
+ };
177
+ vat: {
178
+ registered: boolean;
179
+ rate: number;
180
+ };
181
+ shipping: ShopSettings['shipping'];
182
+ policies: ShopSettings['policies'];
183
+ digital: {
184
+ euBuyers: boolean;
185
+ };
186
+ /** false until the shop can take payments. */
187
+ ready: boolean;
188
+ }
189
+ /** One thing for sale, as a shop front shows it. */
190
+ export interface ShopProduct {
191
+ priceId: string;
192
+ productId: string;
193
+ variantId: string | null;
194
+ name: string;
195
+ description: string | null;
196
+ heroImage: any;
197
+ amount: number;
198
+ compareAtAmount: number | null;
199
+ currency: string;
200
+ delivery: ShopDelivery;
201
+ deliveryKind: ShopDigitalKind | null;
202
+ /** A proof or access goes to an account: the buyer must sign in before checking out. */
203
+ needsSignIn: boolean;
204
+ /** How many can be bought now (tracked stock), or null when stock isn't tracked. */
205
+ available: number | null;
206
+ inStock: boolean;
207
+ }
208
+ export interface ShopCheckoutLine {
209
+ productId: string;
210
+ variantId?: string | null;
211
+ quantity?: number;
212
+ }
213
+ export interface ShopCheckoutInput {
214
+ lines: ShopCheckoutLine[];
215
+ /** Needed for physical items when the shop has several rates (collection is `'collection'`). */
216
+ shippingRateId?: string;
217
+ /** Pre-fills Stripe's form; the order's email comes from the payment. */
218
+ email?: string;
219
+ /** Defaults to the shop's checkout pages. Must be on an allowed host. */
220
+ successUrl?: string;
221
+ cancelUrl?: string;
222
+ /** Digital items: the buyer agreed to delivery straight away, ending the 14-day right to cancel. Required for them. */
223
+ acceptances?: {
224
+ digitalImmediate?: boolean;
225
+ };
226
+ }
227
+ export interface ShopCheckoutResult {
228
+ orderId: string;
229
+ /** Send the buyer here (Stripe's hosted checkout). */
230
+ checkoutUrl: string;
231
+ /** The stock is held until then. */
232
+ expiresAt: string;
233
+ total: number;
234
+ currency: string;
235
+ }
236
+ export type ShopOrderStatus = 'pending-payment' | 'paid' | 'fulfilled' | 'partly-refunded' | 'refunded' | 'expired';
237
+ export interface ShopOrderLine {
238
+ id: string;
239
+ productId: string;
240
+ variantId: string | null;
241
+ name: string | null;
242
+ quantity: number;
243
+ unitAmount: number | null;
244
+ lineTotal: number | null;
245
+ delivery: ShopDelivery | null;
246
+ deliveryKind: ShopDigitalKind | null;
247
+ /** Shipped, or delivered. */
248
+ quantityDone: number;
249
+ quantityRefunded: number;
250
+ priceId: string | null;
251
+ appId: string;
252
+ /** Asset ids, for a download line. */
253
+ files?: string[];
254
+ /** Admin only: SmartLinks' fee on this line. */
255
+ fee?: {
256
+ bps: number;
257
+ amount: number;
258
+ };
259
+ }
260
+ export interface ShopShipment {
261
+ id: string;
262
+ at: string;
263
+ lines: {
264
+ itemId: string;
265
+ quantity: number;
266
+ }[];
267
+ carrier?: string;
268
+ trackingNumber?: string;
269
+ trackingUrl?: string;
270
+ }
271
+ export interface ShopOrder {
272
+ id: string;
273
+ collectionId: string;
274
+ orderRef: string | null;
275
+ status: ShopOrderStatus;
276
+ source: 'shop';
277
+ contactId: string | null;
278
+ currency: string;
279
+ subtotal: number | null;
280
+ shipping: number | null;
281
+ /** VAT inside the total, for the receipt. */
282
+ tax: number | null;
283
+ total: number | null;
284
+ refunded: number;
285
+ paidAt: string | null;
286
+ expiresAt: string | null;
287
+ createdAt: string;
288
+ updatedAt: string;
289
+ email: string | null;
290
+ shippingChoice: ShopShippingRate | null;
291
+ shippingAddress: Record<string, any> | null;
292
+ shipments: ShopShipment[];
293
+ lines: ShopOrderLine[];
294
+ }
295
+ /** The seller's view: payment, refunds, anything that needs a look, and SmartLinks' fee. */
296
+ export interface ShopAdminOrder extends ShopOrder {
297
+ payment: {
298
+ provider: 'stripe';
299
+ sessionId: string;
300
+ paymentIntentId: string | null;
301
+ amount: number;
302
+ currency: string;
303
+ } | null;
304
+ refunds: {
305
+ id: string;
306
+ amount: number;
307
+ at: string;
308
+ lines: {
309
+ itemId: string;
310
+ quantity: number;
311
+ }[];
312
+ shipping?: number;
313
+ restock?: boolean;
314
+ reason?: string;
315
+ external?: boolean;
316
+ }[];
317
+ /** AMOUNT_MISMATCH, STOCK_SHORT, DELIVERY_FAILED, PROOF_NOT_WITHDRAWN… */
318
+ attention: {
319
+ code: string;
320
+ text: string;
321
+ itemId?: string;
322
+ }[];
323
+ acceptances: {
324
+ digitalImmediate?: boolean;
325
+ at: string;
326
+ } | null;
327
+ paymentRef: string | null;
328
+ fee: {
329
+ amount: number;
330
+ };
331
+ }
332
+ /** The buyer's view, with links for bought files once paid. */
333
+ export interface ShopBuyerOrder extends ShopOrder {
334
+ downloads: {
335
+ name: string;
336
+ url: string;
337
+ }[];
338
+ }
339
+ export interface ShopOrderListParams {
340
+ /** One status or several, comma-separated. Unpaid and expired checkouts are left out unless asked for. */
341
+ status?: string;
342
+ contactId?: string;
343
+ includeExpired?: boolean;
344
+ limit?: number;
345
+ offset?: number;
346
+ }
347
+ export interface ShopPage<T> {
348
+ items: T[];
349
+ total: number;
350
+ limit: number;
351
+ offset: number;
352
+ }
353
+ export interface ShopShipInput {
354
+ /** Which lines and how many; all that's left when omitted. */
355
+ lines?: {
356
+ itemId: string;
357
+ quantity?: number;
358
+ }[];
359
+ carrier?: string;
360
+ trackingNumber?: string;
361
+ /** https only. */
362
+ trackingUrl?: string;
363
+ }
364
+ export interface ShopRefundInput {
365
+ /** Lines and quantities at the price sold. With no lines and no amount: everything left, shipping included. */
366
+ lines?: {
367
+ itemId: string;
368
+ quantity?: number;
369
+ }[];
370
+ /** Refund the shipping too (with `lines`). */
371
+ shipping?: boolean;
372
+ /** A goodwill amount instead of lines (minor units). */
373
+ amount?: number;
374
+ /** Unsent held stock goes back to available. Default true. */
375
+ restock?: boolean;
376
+ reason?: string;
377
+ }
@@ -0,0 +1,5 @@
1
+ // src/types/shop.ts
2
+ // Basic commerce: prices, the shop's settings, checkout and shop orders — see docs/shop.md.
3
+ //
4
+ // Money is always a whole number of MINOR units (pence, cents): 1299 = £12.99. Prices include VAT.
5
+ export {};
@@ -19,12 +19,16 @@ export interface Tag {
19
19
  batchId: string | null;
20
20
  proofId: string | null;
21
21
  /**
22
- * Polymorphic ref type: `'app_record'`, `'app_case'`, `'app_thread'`, `'container'`, etc.
23
- * Always paired with `refId`.
22
+ * Polymorphic ref type: `'app_record'`, `'app_case'`, `'app_thread'`, etc.
23
+ * Always paired with `refId`. The label on a container is `containerId`, not a ref.
24
24
  */
25
25
  refType: string | null;
26
26
  /** UUID of the referenced object. Always paired with `refType`. */
27
27
  refId: string | null;
28
+ /** The container this tag is the label on (a box, a cask): never where the tag is. Not with `proofId`. */
29
+ containerId?: string | null;
30
+ /** The item's global id when the tag is on an item */
31
+ itemUid?: string | null;
28
32
  metadata: Record<string, any>;
29
33
  createdAt: string;
30
34
  updatedAt: string;
@@ -77,6 +81,7 @@ export interface CreateTagRequest {
77
81
  useSerialNumber?: boolean;
78
82
  refType?: string;
79
83
  refId?: string;
84
+ containerId?: string;
80
85
  metadata?: Record<string, any>;
81
86
  force?: boolean;
82
87
  }
@@ -95,6 +100,8 @@ export interface UpdateTagRequest {
95
100
  refType?: string | null;
96
101
  /** Pass `null` to clear the polymorphic ref. Must be paired with `refType`. */
97
102
  refId?: string | null;
103
+ /** The label on this container; `null` to clear. Putting the tag on an item clears it. */
104
+ containerId?: string | null;
98
105
  metadata?: Record<string, any>;
99
106
  }
100
107
  /** Returned when creating a single tag (`wasUpdated: true` when force triggered an update). */
@@ -46,6 +46,11 @@ export interface WalletPassContent {
46
46
  /** The QR value; the pass's own code unless you give one. */
47
47
  barcode?: string;
48
48
  }
49
+ export interface WalletInWallet {
50
+ saved: boolean;
51
+ savedAt?: string | null;
52
+ removedAt?: string;
53
+ }
49
54
  /** "Add to Wallet" links that work for this pass now (a wallet that isn't set up is left out). */
50
55
  export interface WalletPassLinks {
51
56
  google?: string;
@@ -79,6 +84,11 @@ export interface WalletPass {
79
84
  body: string;
80
85
  at: string;
81
86
  };
87
+ /** Whether the person has it in each wallet (Apple: a phone registered it; Google: Google's save / delete callback). */
88
+ inWallet?: {
89
+ apple?: WalletInWallet;
90
+ google?: WalletInWallet;
91
+ };
82
92
  voidReason?: string | null;
83
93
  links?: WalletPassLinks;
84
94
  createdAt?: string;