@relai-team/access-sdk 0.14.0 → 0.16.0
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/README.md +17 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.cts +74 -1
- package/dist/index.d.ts +74 -1
- package/dist/index.js +42 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -451,6 +451,23 @@ There is deliberately no `payment.authorized`: Relai checkout intents capture
|
|
|
451
451
|
immediately, so success IS the capture. The published contract listed one until
|
|
452
452
|
0.13.0, and omitted `order.abandoned`, which really is delivered.
|
|
453
453
|
|
|
454
|
+
## Listing orders
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
// Signed in: only this user's orders, as sender or recipient.
|
|
458
|
+
const open = await relai.orders.list({ status: "open" });
|
|
459
|
+
|
|
460
|
+
// Every page, cursors handled for you.
|
|
461
|
+
for await (const order of relai.orders.all({ status: "open" })) {
|
|
462
|
+
render(order);
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
A secret key lists every order of the app. A publishable key needs a signed-in
|
|
467
|
+
end user and returns only theirs, because a publishable key ships inside your
|
|
468
|
+
binary. Guest identities are refused: guest mode is one shared user per app, so
|
|
469
|
+
there is no identity to scope by, and a guest app has to keep its own order ids.
|
|
470
|
+
|
|
454
471
|
## When a payment gate is broken, not declined
|
|
455
472
|
|
|
456
473
|
`unlock()` presents the Stripe Payment Sheet when the platform answers 402
|
package/dist/index.cjs
CHANGED
|
@@ -420,6 +420,48 @@ var OrdersModule = class {
|
|
|
420
420
|
constructor(http) {
|
|
421
421
|
this.http = http;
|
|
422
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
* The caller's orders, newest first (0.15.0).
|
|
425
|
+
*
|
|
426
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
427
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
428
|
+
* made the user's physical belongings unreachable from the app.
|
|
429
|
+
*
|
|
430
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
431
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
432
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
433
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
434
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
435
|
+
* has to keep its own order ids.
|
|
436
|
+
*/
|
|
437
|
+
async page(input) {
|
|
438
|
+
const query = {};
|
|
439
|
+
if (input?.status !== void 0) query["status"] = input.status;
|
|
440
|
+
if (input?.role !== void 0) query["role"] = input.role;
|
|
441
|
+
if (input?.exchangeZoneId !== void 0) query["ez_id"] = input.exchangeZoneId;
|
|
442
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
443
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
444
|
+
return this.http.request({ path: "/orders", query });
|
|
445
|
+
}
|
|
446
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
447
|
+
async list(input) {
|
|
448
|
+
return (await this.page(input)).data;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Every order, following cursors for you.
|
|
452
|
+
*
|
|
453
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
454
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
455
|
+
*/
|
|
456
|
+
async *all(input) {
|
|
457
|
+
let cursor = input?.cursor;
|
|
458
|
+
for (; ; ) {
|
|
459
|
+
const page = await this.page({ ...input, ...cursor ? { cursor } : {} });
|
|
460
|
+
for (const order of page.data) yield order;
|
|
461
|
+
if (!page.next_cursor) return;
|
|
462
|
+
cursor = page.next_cursor;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
423
465
|
/**
|
|
424
466
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
425
467
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
package/dist/index.d.cts
CHANGED
|
@@ -225,8 +225,43 @@ interface ExchangeZone {
|
|
|
225
225
|
placement: "inside" | "outside" | "both" | "na";
|
|
226
226
|
/** IANA timezone of the location, for presenting local times. */
|
|
227
227
|
timezone: string;
|
|
228
|
+
/**
|
|
229
|
+
* True when this Exchange Zone has no operating hours and is always open.
|
|
230
|
+
* Every Exchange Zone is 24/7 unless its host sets hours, so this is usually
|
|
231
|
+
* true and `operating_hours` is usually null.
|
|
232
|
+
*/
|
|
233
|
+
open_24_7: boolean;
|
|
234
|
+
/** The weekly schedule, or null when `open_24_7`. An absent or null day is closed. */
|
|
235
|
+
operating_hours: OperatingHours | null;
|
|
236
|
+
/**
|
|
237
|
+
* Computed server-side in THIS Exchange Zone's timezone, daylight saving
|
|
238
|
+
* included. Trust it rather than comparing `operating_hours` against the
|
|
239
|
+
* device clock: the device is in the user's timezone, which is not
|
|
240
|
+
* necessarily the Exchange Zone's, and the arithmetic across a DST boundary
|
|
241
|
+
* is where hand-rolled versions go wrong.
|
|
242
|
+
*/
|
|
243
|
+
is_open_now: boolean;
|
|
244
|
+
/** When it next opens. Null when open now, and null when it never opens. */
|
|
245
|
+
next_open_at: string | null;
|
|
228
246
|
is_simulated: boolean;
|
|
229
247
|
}
|
|
248
|
+
/** A day's window in the Exchange Zone's local time. Null means closed. */
|
|
249
|
+
interface DayWindow {
|
|
250
|
+
/** `HH:MM`, 24-hour, local to the Exchange Zone. */
|
|
251
|
+
open: string;
|
|
252
|
+
/** `HH:MM`. At or before `open` means the window runs through midnight. */
|
|
253
|
+
close: string;
|
|
254
|
+
}
|
|
255
|
+
/** A week of operating hours. A day that is absent or null is closed. */
|
|
256
|
+
interface OperatingHours {
|
|
257
|
+
sun?: DayWindow | null;
|
|
258
|
+
mon?: DayWindow | null;
|
|
259
|
+
tue?: DayWindow | null;
|
|
260
|
+
wed?: DayWindow | null;
|
|
261
|
+
thu?: DayWindow | null;
|
|
262
|
+
fri?: DayWindow | null;
|
|
263
|
+
sat?: DayWindow | null;
|
|
264
|
+
}
|
|
230
265
|
/**
|
|
231
266
|
* One page of Exchange Zones, and the cursor to continue.
|
|
232
267
|
*
|
|
@@ -307,6 +342,11 @@ interface TelemetryEvent {
|
|
|
307
342
|
transport?: "ble" | "simulated";
|
|
308
343
|
at: string;
|
|
309
344
|
}
|
|
345
|
+
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
346
|
+
interface OrderPage {
|
|
347
|
+
data: Order[];
|
|
348
|
+
next_cursor: string | null;
|
|
349
|
+
}
|
|
310
350
|
type PushPlatform = "expo" | "ios" | "android" | "web";
|
|
311
351
|
type SandboxFault = "jammed_door" | "dead_battery" | "out_of_service" | "clear";
|
|
312
352
|
interface SandboxFaultResult {
|
|
@@ -545,6 +585,39 @@ declare class ExchangeZonesModule {
|
|
|
545
585
|
declare class OrdersModule {
|
|
546
586
|
private readonly http;
|
|
547
587
|
constructor(http: HttpClient);
|
|
588
|
+
/**
|
|
589
|
+
* The caller's orders, newest first (0.15.0).
|
|
590
|
+
*
|
|
591
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
592
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
593
|
+
* made the user's physical belongings unreachable from the app.
|
|
594
|
+
*
|
|
595
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
596
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
597
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
598
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
599
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
600
|
+
* has to keep its own order ids.
|
|
601
|
+
*/
|
|
602
|
+
page(input?: {
|
|
603
|
+
status?: "open" | "completed" | "cancelled";
|
|
604
|
+
/** Signed-in calls only: orders you SENT, or ones you are receiving. */
|
|
605
|
+
role?: "initiator" | "recipient";
|
|
606
|
+
exchangeZoneId?: string;
|
|
607
|
+
/** 1 to 100. Defaults to 25. */
|
|
608
|
+
limit?: number;
|
|
609
|
+
/** `next_cursor` from a previous page. */
|
|
610
|
+
cursor?: string;
|
|
611
|
+
}): Promise<OrderPage>;
|
|
612
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
613
|
+
list(input?: Parameters<OrdersModule["page"]>[0]): Promise<Order[]>;
|
|
614
|
+
/**
|
|
615
|
+
* Every order, following cursors for you.
|
|
616
|
+
*
|
|
617
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
618
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
619
|
+
*/
|
|
620
|
+
all(input?: Parameters<OrdersModule["page"]>[0]): AsyncGenerator<Order>;
|
|
548
621
|
/**
|
|
549
622
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
550
623
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -1440,4 +1513,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1440
1513
|
constructor(message: string);
|
|
1441
1514
|
}
|
|
1442
1515
|
|
|
1443
|
-
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
|
1516
|
+
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DayWindow, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type OperatingHours, type Order, type OrderPage, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -225,8 +225,43 @@ interface ExchangeZone {
|
|
|
225
225
|
placement: "inside" | "outside" | "both" | "na";
|
|
226
226
|
/** IANA timezone of the location, for presenting local times. */
|
|
227
227
|
timezone: string;
|
|
228
|
+
/**
|
|
229
|
+
* True when this Exchange Zone has no operating hours and is always open.
|
|
230
|
+
* Every Exchange Zone is 24/7 unless its host sets hours, so this is usually
|
|
231
|
+
* true and `operating_hours` is usually null.
|
|
232
|
+
*/
|
|
233
|
+
open_24_7: boolean;
|
|
234
|
+
/** The weekly schedule, or null when `open_24_7`. An absent or null day is closed. */
|
|
235
|
+
operating_hours: OperatingHours | null;
|
|
236
|
+
/**
|
|
237
|
+
* Computed server-side in THIS Exchange Zone's timezone, daylight saving
|
|
238
|
+
* included. Trust it rather than comparing `operating_hours` against the
|
|
239
|
+
* device clock: the device is in the user's timezone, which is not
|
|
240
|
+
* necessarily the Exchange Zone's, and the arithmetic across a DST boundary
|
|
241
|
+
* is where hand-rolled versions go wrong.
|
|
242
|
+
*/
|
|
243
|
+
is_open_now: boolean;
|
|
244
|
+
/** When it next opens. Null when open now, and null when it never opens. */
|
|
245
|
+
next_open_at: string | null;
|
|
228
246
|
is_simulated: boolean;
|
|
229
247
|
}
|
|
248
|
+
/** A day's window in the Exchange Zone's local time. Null means closed. */
|
|
249
|
+
interface DayWindow {
|
|
250
|
+
/** `HH:MM`, 24-hour, local to the Exchange Zone. */
|
|
251
|
+
open: string;
|
|
252
|
+
/** `HH:MM`. At or before `open` means the window runs through midnight. */
|
|
253
|
+
close: string;
|
|
254
|
+
}
|
|
255
|
+
/** A week of operating hours. A day that is absent or null is closed. */
|
|
256
|
+
interface OperatingHours {
|
|
257
|
+
sun?: DayWindow | null;
|
|
258
|
+
mon?: DayWindow | null;
|
|
259
|
+
tue?: DayWindow | null;
|
|
260
|
+
wed?: DayWindow | null;
|
|
261
|
+
thu?: DayWindow | null;
|
|
262
|
+
fri?: DayWindow | null;
|
|
263
|
+
sat?: DayWindow | null;
|
|
264
|
+
}
|
|
230
265
|
/**
|
|
231
266
|
* One page of Exchange Zones, and the cursor to continue.
|
|
232
267
|
*
|
|
@@ -307,6 +342,11 @@ interface TelemetryEvent {
|
|
|
307
342
|
transport?: "ble" | "simulated";
|
|
308
343
|
at: string;
|
|
309
344
|
}
|
|
345
|
+
/** One page of orders, newest first. `next_cursor` is null on the last page. */
|
|
346
|
+
interface OrderPage {
|
|
347
|
+
data: Order[];
|
|
348
|
+
next_cursor: string | null;
|
|
349
|
+
}
|
|
310
350
|
type PushPlatform = "expo" | "ios" | "android" | "web";
|
|
311
351
|
type SandboxFault = "jammed_door" | "dead_battery" | "out_of_service" | "clear";
|
|
312
352
|
interface SandboxFaultResult {
|
|
@@ -545,6 +585,39 @@ declare class ExchangeZonesModule {
|
|
|
545
585
|
declare class OrdersModule {
|
|
546
586
|
private readonly http;
|
|
547
587
|
constructor(http: HttpClient);
|
|
588
|
+
/**
|
|
589
|
+
* The caller's orders, newest first (0.15.0).
|
|
590
|
+
*
|
|
591
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
592
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
593
|
+
* made the user's physical belongings unreachable from the app.
|
|
594
|
+
*
|
|
595
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
596
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
597
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
598
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
599
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
600
|
+
* has to keep its own order ids.
|
|
601
|
+
*/
|
|
602
|
+
page(input?: {
|
|
603
|
+
status?: "open" | "completed" | "cancelled";
|
|
604
|
+
/** Signed-in calls only: orders you SENT, or ones you are receiving. */
|
|
605
|
+
role?: "initiator" | "recipient";
|
|
606
|
+
exchangeZoneId?: string;
|
|
607
|
+
/** 1 to 100. Defaults to 25. */
|
|
608
|
+
limit?: number;
|
|
609
|
+
/** `next_cursor` from a previous page. */
|
|
610
|
+
cursor?: string;
|
|
611
|
+
}): Promise<OrderPage>;
|
|
612
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
613
|
+
list(input?: Parameters<OrdersModule["page"]>[0]): Promise<Order[]>;
|
|
614
|
+
/**
|
|
615
|
+
* Every order, following cursors for you.
|
|
616
|
+
*
|
|
617
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
618
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
619
|
+
*/
|
|
620
|
+
all(input?: Parameters<OrdersModule["page"]>[0]): AsyncGenerator<Order>;
|
|
548
621
|
/**
|
|
549
622
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
550
623
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
|
@@ -1440,4 +1513,4 @@ declare class RelaiTransportError extends RelaiError {
|
|
|
1440
1513
|
constructor(message: string);
|
|
1441
1514
|
}
|
|
1442
1515
|
|
|
1443
|
-
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type Order, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
|
1516
|
+
export { type AccessLinkTarget, AccessLinksModule, type AnyWebhookEvent, type ApiEnvironment, type ApiErrorBody, AppModule, type AppSelf, AuthModule, type BleDeviceLike, type BleManagerLike, BleTransport, type BleTransportOptions, type CommandAck, type DayWindow, type DeliverOptions, type DiscoveredParent, type EndUser, type EndUserPage, EndUsersModule, type ExchangeZone, type ExchangeZoneDetail, type ExchangeZonePage, ExchangeZonesModule, type GrantAlgorithm, GrantsModule, type HandoffMode, type Intent, Intents, type KeyValueStorage, type Me, MemoryTelemetryQueue, MemoryTokenStorage, type MintedCommand, type NotifyLine, type Open, type OperatingHours, type Order, type OrderPage, type OrderStatusFields, OrdersModule, type OverrideLink, OverrideLinksModule, type ParentTransport, type PaymentRequiredDetails, PushModule, type PushPlatform, type QueuedTelemetry, REJECT_REASONS, RELAI_RX_CHAR, RELAI_TX_CHAR, RELAI_UART_SERVICE, type RecipientMatch, RecipientsModule, RelaiApiError, RelaiClient, type RelaiClientOptions, RelaiConfigError, RelaiError, type RelaiErrorContext, RelaiLateFeeDue, RelaiMissingKeyError, RelaiNetworkError, RelaiTransportError, RelaiUnlockRejected, type SandboxFault, type SandboxFaultResult, SandboxModule, type SelfBillingChoice, type Session, SimAuthenticatedTransport, type SimAuthenticatedTransportOptions, type SimulatedParentConfig, SimulatedTransport, StorageTelemetryQueue, type StorageTelemetryQueueOptions, type StripeSdk, type TelemetryAction, type TelemetryEvent, TelemetryModule, type TelemetryPayload, type TelemetryQueue, TelemetryUploader, type TokenPair, type TokenStorage, type Tower, type TowerNode, type TowerTelemetry, type UnlockDeps, type UnlockGrant, type UnlockInput, type UnlockResult, type VerifyWebhookInput, type WebhookEvent, type WebhookEventOf, type WebhookEventType, type WebhookPayloads, asPaymentRequired, deliverOpen, isStripePublishableKey, parseNotifyLine, presentRelaiPaymentSheet, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -266,6 +266,48 @@ var OrdersModule = class {
|
|
|
266
266
|
constructor(http) {
|
|
267
267
|
this.http = http;
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* The caller's orders, newest first (0.15.0).
|
|
271
|
+
*
|
|
272
|
+
* Until this existed `/v1` could create an order and fetch one by id but not
|
|
273
|
+
* list them, so an app had to persist order ids on the device: reinstalling
|
|
274
|
+
* made the user's physical belongings unreachable from the app.
|
|
275
|
+
*
|
|
276
|
+
* WHAT YOU GET BACK depends on the key. A secret key lists every order of the
|
|
277
|
+
* app. A publishable key REQUIRES a signed-in end user and returns only orders
|
|
278
|
+
* where they are the sender or the recipient, because a publishable key ships
|
|
279
|
+
* inside your binary. Guest identities are refused: guest mode is one shared
|
|
280
|
+
* user per app, so there is no identity to scope by, and an app in guest mode
|
|
281
|
+
* has to keep its own order ids.
|
|
282
|
+
*/
|
|
283
|
+
async page(input) {
|
|
284
|
+
const query = {};
|
|
285
|
+
if (input?.status !== void 0) query["status"] = input.status;
|
|
286
|
+
if (input?.role !== void 0) query["role"] = input.role;
|
|
287
|
+
if (input?.exchangeZoneId !== void 0) query["ez_id"] = input.exchangeZoneId;
|
|
288
|
+
if (input?.limit !== void 0) query["limit"] = input.limit;
|
|
289
|
+
if (input?.cursor !== void 0) query["cursor"] = input.cursor;
|
|
290
|
+
return this.http.request({ path: "/orders", query });
|
|
291
|
+
}
|
|
292
|
+
/** First page only. Use `page()` when you need the cursor. */
|
|
293
|
+
async list(input) {
|
|
294
|
+
return (await this.page(input)).data;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Every order, following cursors for you.
|
|
298
|
+
*
|
|
299
|
+
* `for await (const order of relai.orders.all({ status: "open" }))`. Stops on
|
|
300
|
+
* the first page with a null cursor, so it terminates even if a page is empty.
|
|
301
|
+
*/
|
|
302
|
+
async *all(input) {
|
|
303
|
+
let cursor = input?.cursor;
|
|
304
|
+
for (; ; ) {
|
|
305
|
+
const page = await this.page({ ...input, ...cursor ? { cursor } : {} });
|
|
306
|
+
for (const order of page.data) yield order;
|
|
307
|
+
if (!page.next_cursor) return;
|
|
308
|
+
cursor = page.next_cursor;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
269
311
|
/**
|
|
270
312
|
* Create an order. On DIRECTED-handoff apps, name the pick-up recipient by
|
|
271
313
|
* `recipient` (exact email or `@access-tag`) or by `recipientUserId` (from
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relai-team/access-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Official Relai Access SDK, open Relai Exchange Zone nodes over BLE, backed by the Relai Access platform (server-owns-trust).",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|