@joai/sdk 4.0.0 → 4.2.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/dist/index.d.mts CHANGED
@@ -38,7 +38,7 @@ type SocialAuthProvider = 'github' | 'apple' | 'google' | 'x' | 'telegram' | 'sl
38
38
  //#region src/config/types.d.ts
39
39
  type AppEnv = 'mainnet' | 'testnet' | 'devnet' | 'local'; //#endregion
40
40
  //#region src/auth/token.d.ts
41
- /** One-time native/deep-link handoff param (exchanged for a Bearer via API). */
41
+ /** One-time native/deep-link handoff fragment key (exchanged for a Bearer via POST). */
42
42
  //#endregion
43
43
  //#region src/ingestion/types.d.ts
44
44
  type IngestionSourceType = 'note' | 'meeting' | 'article' | 'email' | 'chat' | 'post' | 'webhook';
@@ -191,7 +191,6 @@ type UserPrivate = {
191
191
  socials: UserSocialAccount[];
192
192
  justCreated: boolean;
193
193
  affiliate: Affiliate | null;
194
- billingAddress: BillingAddress | null;
195
194
  betaRestricted: boolean;
196
195
  kyc?: Kyc | null;
197
196
  settings: UserSettings;
@@ -245,6 +244,26 @@ type AffiliateTier = {
245
244
  type AffiliateStatus = 'pending' | 'approved' | 'rejected' | 'suspended' | 'demoted'; //#endregion
246
245
  //#region src/team/constants.d.ts
247
246
  declare const teamCategories: readonly ["general", "food-drink", "retail", "beauty-wellness", "health", "sports-fitness", "trades-services", "professional-services", "education-culture", "clubs-organizations", "leisure-tourism"]; //#endregion
247
+ //#region src/team/apps.d.ts
248
+ declare const NativeApps: {
249
+ readonly Board: "board";
250
+ readonly Shop: "shop";
251
+ readonly SmartLinks: "smart-links";
252
+ readonly Contacts: "contacts";
253
+ readonly Forms: "forms";
254
+ readonly Appointments: "appointments";
255
+ readonly Workspace: "workspace";
256
+ readonly Meeting: "meeting";
257
+ readonly VoiceDictation: "voice-dictation";
258
+ readonly Heartbeats: "heartbeats";
259
+ readonly Wallets: "wallets";
260
+ readonly Campaigns: "campaigns";
261
+ readonly News: "news";
262
+ readonly Sites: "sites";
263
+ readonly Contracts: "contracts";
264
+ };
265
+ type NativeApp = (typeof NativeApps)[keyof typeof NativeApps];
266
+ //#endregion
248
267
  //#region src/team/types.d.ts
249
268
  type TeamCategory = (typeof teamCategories)[number];
250
269
  type TeamFeature = 'shop' | 'appointments';
@@ -270,7 +289,9 @@ type TeamMeta = {
270
289
  'stock.enabled'?: boolean;
271
290
  contactPropertyMaskWarp?: string;
272
291
  branding?: TeamBrand | null;
273
- settings: Record<string, unknown>;
292
+ settings: Record<string, unknown> & {
293
+ apps?: NativeApp[];
294
+ };
274
295
  };
275
296
  type TeamPlace = {
276
297
  provider: 'google';
@@ -421,6 +442,160 @@ type AiCostsResponse = {
421
442
  };
422
443
  };
423
444
  }; //#endregion
445
+ //#region src/address/types.d.ts
446
+ type AddressType = 'shipping' | 'billing';
447
+ type Address = {
448
+ id: string;
449
+ type: AddressType;
450
+ name: string;
451
+ company: string | null;
452
+ addressOne: string;
453
+ addressTwo: string | null;
454
+ city: string;
455
+ state: string | null;
456
+ zipCode: string;
457
+ country: string;
458
+ phone: string | null;
459
+ isDefault: boolean;
460
+ business: boolean;
461
+ vatId: string | null;
462
+ isEU: boolean;
463
+ isEEA: boolean;
464
+ };
465
+ type AddressSnapshot = Pick<Address, 'name' | 'company' | 'addressOne' | 'addressTwo' | 'city' | 'state' | 'zipCode' | 'country' | 'phone' | 'business' | 'vatId'>;
466
+ type AddressInput = {
467
+ name: string;
468
+ addressOne: string;
469
+ city: string;
470
+ zipCode: string;
471
+ country: string;
472
+ type?: AddressType;
473
+ company?: string | null;
474
+ addressTwo?: string | null;
475
+ state?: string | null;
476
+ phone?: string | null;
477
+ business?: boolean;
478
+ vatId?: string | null;
479
+ };
480
+ type AddressCreatePayload = {
481
+ name: string;
482
+ country: string;
483
+ type?: AddressType;
484
+ email?: string | null;
485
+ company?: string | null;
486
+ addressOne?: string | null;
487
+ addressTwo?: string | null;
488
+ city?: string | null;
489
+ state?: string | null;
490
+ zipCode?: string | null;
491
+ vatId?: string | null;
492
+ phone?: string | null;
493
+ isDefault?: boolean;
494
+ contact?: string;
495
+ team?: string;
496
+ };
497
+ type AddressUpdatePayload = Partial<Omit<AddressCreatePayload, 'contact' | 'team'>>; //#endregion
498
+ //#region src/commerce/types.d.ts
499
+ type FulfillmentMethod = 'shipping' | 'pickup';
500
+ type ShippingRate = {
501
+ id: number;
502
+ name: string;
503
+ price: number;
504
+ fee?: number;
505
+ freeShippingThreshold?: number | null;
506
+ minOrderValue?: number | null;
507
+ maxOrderValue?: number | null;
508
+ minWeight?: number | null;
509
+ maxWeight?: number | null;
510
+ estimatedMinDays?: number | null;
511
+ estimatedMaxDays?: number | null;
512
+ active?: boolean;
513
+ position?: number;
514
+ };
515
+ type CheckoutSnapshot = {
516
+ id: string;
517
+ fulfillmentMethod: FulfillmentMethod;
518
+ totals: {
519
+ subtotal: number;
520
+ shippingFee: number;
521
+ total: number;
522
+ };
523
+ expiresAt: string;
524
+ accessToken?: string | null;
525
+ };
526
+ type CheckoutSnapshotRequest = {
527
+ fulfillmentMethod: FulfillmentMethod;
528
+ items: {
529
+ id: string;
530
+ type: 'product' | 'service' | 'coupon';
531
+ quantity: number;
532
+ }[];
533
+ billingAddressId?: number | null;
534
+ shippingAddressId?: number | null;
535
+ billingAddress?: AddressInput;
536
+ shippingAddress?: AddressInput;
537
+ shippingRateId?: number | null;
538
+ fulfillmentLocationId?: number | null;
539
+ };
540
+ type ShippingZone = {
541
+ id: number;
542
+ name: string;
543
+ countries: string[];
544
+ postal_code_rules: string[] | null;
545
+ active: boolean;
546
+ position: number;
547
+ rates: ShippingRate[];
548
+ };
549
+ type FulfillmentLocation = {
550
+ id: number;
551
+ name: string;
552
+ address_id: number | null;
553
+ address: Address | null;
554
+ instructions: string | null;
555
+ active: boolean;
556
+ };
557
+ type FulfillmentStatus = 'pending' | 'ready_for_pickup' | 'shipped' | 'delivered' | 'cancelled';
558
+ type Fulfillment = {
559
+ id: string;
560
+ orderId: number;
561
+ method: FulfillmentMethod;
562
+ status: FulfillmentStatus;
563
+ carrierCode: string | null;
564
+ trackingNumber: string | null;
565
+ trackingUrl: string | null;
566
+ items: {
567
+ orderItemId: number;
568
+ quantity: number;
569
+ }[];
570
+ shippedAt: string | null;
571
+ readyForPickupAt: string | null;
572
+ deliveredAt: string | null;
573
+ };
574
+ type ReturnStatus = 'requested' | 'approved' | 'rejected' | 'received' | 'closed';
575
+ type Return = {
576
+ id: string;
577
+ orderId: number;
578
+ status: ReturnStatus;
579
+ reason: string;
580
+ merchantNote: string | null;
581
+ items: {
582
+ orderItemId: number;
583
+ quantity: number;
584
+ condition: string | null;
585
+ }[];
586
+ refundAmount: number | null;
587
+ };
588
+ type SubscriptionDelivery = {
589
+ fulfillmentMethod: FulfillmentMethod | null;
590
+ nextOrderAt: string | null;
591
+ pausedAt: string | null;
592
+ shippingAddress?: AddressSnapshot | null;
593
+ shippingRate?: Pick<ShippingRate, 'name' | 'price'> | null;
594
+ fulfillmentLocation?: {
595
+ name: string;
596
+ instructions: string | null;
597
+ } | null;
598
+ }; //#endregion
424
599
  //#region src/json/types.d.ts
425
600
  type JsonValue = string | number | boolean | null | JsonValue[] | {
426
601
  [key: string]: JsonValue;
@@ -542,7 +717,7 @@ type OrderType = 'order' | 'quote';
542
717
  type SubscriptionStatus = 'active' | 'canceled' | 'past_due' | 'pending';
543
718
  type SubscriptionInterval = 'weekly' | 'biweekly' | 'monthly' | 'quarterly' | 'yearly';
544
719
  type PricingModel = 'free' | 'one-time' | 'weekly' | 'biweekly' | 'monthly' | 'quarterly' | 'yearly' | 'per-run';
545
- type AppSubscription = {
720
+ type Subscription = {
546
721
  id: string;
547
722
  orderId: string;
548
723
  teamId: string;
@@ -555,6 +730,7 @@ type AppSubscription = {
555
730
  meta: Record<string, JsonValue> | null;
556
731
  createdAt: string;
557
732
  updatedAt: string;
733
+ delivery?: SubscriptionDelivery | null;
558
734
  };
559
735
  type PaymentProvider = 'xmoney' | 'lemonsqueezy' | 'stripe' | 'stripe-connect' | 'mollie' | 'mollie-connect' | 'apple' | 'google' | 'blockchain' | 'offline';
560
736
  type PaymentAccount = {
@@ -593,16 +769,6 @@ type PlanExtra = {
593
769
  price: number;
594
770
  unitName: string;
595
771
  };
596
- type BillingAddress = {
597
- name: string;
598
- addressOne: string | null;
599
- city: string | null;
600
- state: string | null;
601
- zipCode: string | null;
602
- country: string;
603
- vatId: string | null;
604
- isEU: boolean;
605
- };
606
772
  type PlanInterval = 'weekly' | 'monthly' | 'yearly' | 'lifetime';
607
773
  type Plan = {
608
774
  resource: 'plan';
@@ -757,6 +923,17 @@ type Order = {
757
923
  paymentMode: string | null;
758
924
  linkVariationId: string | null;
759
925
  notes: string | null;
926
+ fulfillmentMethod?: FulfillmentMethod | null;
927
+ address?: AddressSnapshot | null;
928
+ shippingAddress?: AddressSnapshot | null;
929
+ shippingRate?: Pick<ShippingRate, 'name' | 'price' | 'estimatedMinDays' | 'estimatedMaxDays'> | null;
930
+ fulfillmentLocation?: {
931
+ name: string;
932
+ instructions?: string | null;
933
+ } | null;
934
+ shippingFee?: number;
935
+ fulfillments?: Fulfillment[];
936
+ subscription?: Subscription | null;
760
937
  configuration?: OrderConfigurationItem[];
761
938
  items: OrderItem[];
762
939
  coupon?: Coupon | null;
@@ -1408,7 +1585,8 @@ type Meeting = {
1408
1585
  captureMode: 'desktop_local' | null;
1409
1586
  transcriptUrl: string | null;
1410
1587
  summaryUrl: string | null;
1411
- participants?: MeetingParticipant[];
1588
+ participants?: MeetingParticipant[]; /** The customer associated with an appointment booking, when available. */
1589
+ contact?: Contact | null;
1412
1590
  speakerAssignments?: MeetingSpeakerAssignment[] | null;
1413
1591
  scheduledAt: string | null;
1414
1592
  calendarEventId: number | null;
@@ -1486,6 +1664,7 @@ type AppointmentPolicy = {
1486
1664
  bookingCapacity?: number | null;
1487
1665
  bookingCapacityUnit?: 'booking' | 'person' | null;
1488
1666
  requireApproval?: boolean | null;
1667
+ notificationEmail?: string | null;
1489
1668
  sync?: AppointmentPolicySync | null;
1490
1669
  agent?: Agent | null;
1491
1670
  agentUuid?: string | null;
@@ -1525,7 +1704,7 @@ type AppointmentRequest = {
1525
1704
  configuration?: Configuration;
1526
1705
  createdAt: string;
1527
1706
  }; //#endregion
1528
- //#region src/budget/types.d.ts
1707
+ //#region src/commerce/helpers.d.ts
1529
1708
  //#endregion
1530
1709
  //#region src/card/types.d.ts
1531
1710
  type Card = {
@@ -2869,6 +3048,166 @@ declare class AgentsResource {
2869
3048
  }): Promise<IAppResponse<unknown>>;
2870
3049
  }
2871
3050
  //#endregion
3051
+ //#region src/address/addresses.d.ts
3052
+ type AddressQuery = {
3053
+ contact?: string;
3054
+ team?: string;
3055
+ type?: AddressType;
3056
+ };
3057
+ declare class AddressesResource {
3058
+ private readonly http;
3059
+ constructor(http: IHttpService);
3060
+ list(params?: AddressQuery): Promise<IAppResponse<Address[]>>;
3061
+ get(params?: Omit<AddressQuery, 'type'>): Promise<IAppResponse<Address | null>>;
3062
+ create(data: AddressCreatePayload): Promise<IAppResponse<Address>>;
3063
+ update(id: string, data: AddressUpdatePayload): Promise<IAppResponse<Address>>;
3064
+ delete(id: string): Promise<IAppResponse<void>>;
3065
+ }
3066
+ //#endregion
3067
+ //#region src/commerce/checkout.d.ts
3068
+ type PlaceCheckoutOrderRequest = CheckoutSnapshotRequest & {
3069
+ guest?: {
3070
+ name: string;
3071
+ email: string;
3072
+ };
3073
+ notes?: string;
3074
+ idempotencyKey?: string;
3075
+ saveAddresses?: boolean;
3076
+ sendConfirmation?: boolean;
3077
+ };
3078
+ declare class CheckoutResource {
3079
+ private readonly http;
3080
+ constructor(http: IHttpService);
3081
+ snapshot(team: string, data: CheckoutSnapshotRequest): Promise<IAppResponse<CheckoutSnapshot>>;
3082
+ placeOrder(team: string, data: PlaceCheckoutOrderRequest): Promise<IAppResponse<Order>>;
3083
+ locations(team: string): Promise<IAppResponse<FulfillmentLocation[]>>;
3084
+ shippingRates(team: string, data: {
3085
+ address: {
3086
+ country: string;
3087
+ zipCode?: string;
3088
+ };
3089
+ items: {
3090
+ id: string;
3091
+ type: 'product' | 'service' | 'coupon';
3092
+ quantity: number;
3093
+ }[];
3094
+ }): Promise<IAppResponse<ShippingRate[]>>;
3095
+ }
3096
+ //#endregion
3097
+ //#region src/commerce/fulfillments.d.ts
3098
+ declare class FulfillmentsResource {
3099
+ private readonly http;
3100
+ constructor(http: IHttpService);
3101
+ list(orderId: string): Promise<IAppResponse<Fulfillment[]>>;
3102
+ create(orderId: string, data: {
3103
+ items: {
3104
+ orderItemId: number;
3105
+ quantity: number;
3106
+ }[];
3107
+ carrierCode?: string;
3108
+ trackingNumber?: string;
3109
+ trackingUrl?: string;
3110
+ status?: Fulfillment['status'];
3111
+ }): Promise<IAppResponse<Fulfillment>>;
3112
+ update(orderId: string, fulfillmentId: string, status: Fulfillment['status']): Promise<IAppResponse<Fulfillment>>;
3113
+ }
3114
+ //#endregion
3115
+ //#region src/commerce/returns.d.ts
3116
+ declare class ReturnsResource {
3117
+ private readonly http;
3118
+ constructor(http: IHttpService);
3119
+ list(orderId: string, accessToken?: string): Promise<IAppResponse<Return[]>>;
3120
+ create(orderId: string, data: {
3121
+ reason: string;
3122
+ fulfillmentId?: number;
3123
+ items: {
3124
+ orderItemId: number;
3125
+ quantity: number;
3126
+ condition?: string;
3127
+ }[];
3128
+ }, accessToken?: string): Promise<IAppResponse<Return>>;
3129
+ update(id: string, data: {
3130
+ status: Exclude<ReturnStatus, 'requested'>;
3131
+ merchantNote?: string;
3132
+ refundAmount?: number;
3133
+ resolution?: number;
3134
+ returnShippingCostPayer?: number;
3135
+ }): Promise<IAppResponse<Return>>;
3136
+ }
3137
+ //#endregion
3138
+ //#region src/commerce/shipping.d.ts
3139
+ type ZoneInput = {
3140
+ name: string;
3141
+ countries: string[];
3142
+ postalCodeRules?: string[];
3143
+ active?: boolean;
3144
+ position?: number;
3145
+ };
3146
+ type RateInput = {
3147
+ name: string;
3148
+ price: number;
3149
+ freeShippingThreshold?: number;
3150
+ minOrderValue?: number;
3151
+ maxOrderValue?: number;
3152
+ minWeight?: number;
3153
+ maxWeight?: number;
3154
+ estimatedMinDays?: number;
3155
+ estimatedMaxDays?: number;
3156
+ active?: boolean;
3157
+ position?: number;
3158
+ };
3159
+ declare class ShippingResource {
3160
+ private readonly http;
3161
+ constructor(http: IHttpService);
3162
+ zones(team: string): Promise<IAppResponse<ShippingZone[]>>;
3163
+ createZone(team: string, data: ZoneInput): Promise<IAppResponse<ShippingZone>>;
3164
+ updateZone(team: string, zoneId: number, data: Partial<ZoneInput>): Promise<IAppResponse<ShippingZone>>;
3165
+ deleteZone(team: string, zoneId: number): Promise<IAppResponse<void>>;
3166
+ createRate(team: string, zoneId: number, data: RateInput): Promise<IAppResponse<ShippingRate>>;
3167
+ locations(team: string): Promise<IAppResponse<FulfillmentLocation[]>>;
3168
+ createLocation(team: string, data: {
3169
+ name: string;
3170
+ addressId?: number;
3171
+ instructions?: string;
3172
+ active?: boolean;
3173
+ }): Promise<IAppResponse<FulfillmentLocation>>;
3174
+ }
3175
+ //#endregion
3176
+ //#region src/commerce/guest.d.ts
3177
+ type GuestOrderAccess = {
3178
+ orderId: string;
3179
+ accessToken: string | null;
3180
+ };
3181
+ type GuestCheckoutDraft<TCart = unknown> = {
3182
+ cart: TCart;
3183
+ fulfillmentMethod: FulfillmentMethod;
3184
+ shippingRateId: number | null;
3185
+ fulfillmentLocationId: number | null;
3186
+ };
3187
+ type GuestCommerceStorageOptions = {
3188
+ namespace: string;
3189
+ maxOrders?: number;
3190
+ };
3191
+ declare function createGuestCommerceStorage(options: GuestCommerceStorageOptions): {
3192
+ saveCheckoutDraft<TCart>(draft: GuestCheckoutDraft<TCart>): void;
3193
+ readCheckoutDraft<TCart>(fallback: GuestCheckoutDraft<TCart>): GuestCheckoutDraft<TCart>;
3194
+ saveOrderAccess({
3195
+ orderId,
3196
+ accessToken
3197
+ }: GuestOrderAccess): void;
3198
+ readOrderAccess(orderId: string): string | null;
3199
+ listOrderAccess(): GuestOrderAccess[];
3200
+ };
3201
+ //#endregion
3202
+ //#region src/commerce/index.d.ts
3203
+ declare class CommerceResource {
3204
+ readonly checkout: CheckoutResource;
3205
+ readonly shipping: ShippingResource;
3206
+ readonly fulfillments: FulfillmentsResource;
3207
+ readonly returns: ReturnsResource;
3208
+ constructor(http: IHttpService);
3209
+ }
3210
+ //#endregion
2872
3211
  //#region src/resources/alerts.d.ts
2873
3212
  declare class AlertsResource {
2874
3213
  private readonly http;
@@ -3079,11 +3418,21 @@ type NativeSocialAuthProvider = Extract<SocialAuthProvider, 'apple' | 'google'>;
3079
3418
  type AuthSendCodeRequest = {
3080
3419
  name: string;
3081
3420
  phone?: string;
3421
+ email: string;
3422
+ team?: string;
3423
+ table?: string;
3424
+ };
3425
+ type AuthConfirmCodeRequest = {
3426
+ code: string;
3427
+ phone?: string;
3082
3428
  email?: string;
3083
3429
  team?: string;
3084
3430
  table?: string;
3085
3431
  };
3086
- type AuthVerifyResponse = {
3432
+ type AuthConfirmCodeResponse = {
3433
+ authUrl: string;
3434
+ };
3435
+ type AuthNativeSessionResponse = {
3087
3436
  token: string;
3088
3437
  user: AuthUser;
3089
3438
  team: {
@@ -3100,37 +3449,24 @@ type AuthLoginResponse = {
3100
3449
  type AuthApiTokenResponse = {
3101
3450
  plainTextToken: string;
3102
3451
  };
3452
+ type AuthPortalSessionResponse = {
3453
+ url: string;
3454
+ };
3103
3455
  declare class AuthResource {
3104
3456
  private http;
3105
3457
  constructor(http: IHttpService);
3106
3458
  sendCode(data: AuthSendCodeRequest): Promise<IAppResponse<void>>;
3459
+ confirmCode(data: AuthConfirmCodeRequest): Promise<IAppResponse<AuthConfirmCodeResponse>>;
3107
3460
  requestEmail(email: string, redirect?: string): Promise<IAppResponse<AuthLoginResponse>>;
3108
3461
  loginWithSocialAccessToken(provider: NativeSocialAuthProvider, accessToken: string): Promise<IAppResponse<AuthLoginResponse>>;
3109
- verify(token: string): Promise<IAppResponse<AuthVerifyResponse>>;
3462
+ exchangeNativeSession(token: string): Promise<IAppResponse<AuthNativeSessionResponse>>;
3110
3463
  me(): Promise<IAppResponse<AuthUser>>;
3111
3464
  logout(): Promise<IAppResponse<void>>;
3112
3465
  createApiToken(): Promise<IAppResponse<AuthApiTokenResponse>>;
3466
+ createPortalSession(redirect: string): Promise<IAppResponse<AuthPortalSessionResponse>>;
3113
3467
  verifyWallet(accessToken: string, withMobileApiToken?: boolean): Promise<IAppResponse<UserPrivate>>;
3114
3468
  }
3115
3469
  //#endregion
3116
- //#region src/resources/billing-addresses.d.ts
3117
- declare class BillingAddressesResource {
3118
- private readonly http;
3119
- constructor(http: IHttpService);
3120
- get(contact?: string, team?: string): Promise<IAppResponse<BillingAddress | null>>;
3121
- store(data: {
3122
- name: string;
3123
- addressOne?: string;
3124
- city?: string;
3125
- state?: string;
3126
- zipCode?: string;
3127
- country: string;
3128
- vatId?: string;
3129
- contact?: string;
3130
- team?: string;
3131
- }): Promise<IAppResponse<BillingAddress>>;
3132
- }
3133
- //#endregion
3134
3470
  //#region src/resources/billing.d.ts
3135
3471
  type IapReceipt = {
3136
3472
  productId: string;
@@ -3734,6 +4070,9 @@ declare class NotificationsResource {
3734
4070
  constructor(http: IHttpService);
3735
4071
  list(page?: number): Promise<IAppResponse<Notification[]>>;
3736
4072
  getUnread(): Promise<IAppResponse<Notification[]>>;
4073
+ getDismissedPushKeys(): Promise<IAppResponse<{
4074
+ notificationKeys: string[];
4075
+ }>>;
3737
4076
  getSettings(): Promise<IAppResponse<NotificationSetting[]>>;
3738
4077
  updateSettings(notificationType: string, channel: NotificationChannel): Promise<IAppResponse<NotificationSetting[]>>;
3739
4078
  getAgentSettings(): Promise<IAppResponse<{
@@ -3756,7 +4095,7 @@ declare class OrdersResource {
3756
4095
  private readonly http;
3757
4096
  constructor(http: IHttpService);
3758
4097
  list(team: string): Promise<IAppResponse<Order[]>>;
3759
- get(id: string): Promise<IAppResponse<Order>>;
4098
+ get(id: string, accessToken?: string): Promise<IAppResponse<Order>>;
3760
4099
  create(data: {
3761
4100
  contactId?: string;
3762
4101
  notes?: string;
@@ -3774,6 +4113,20 @@ declare class OrdersResource {
3774
4113
  quantity: number;
3775
4114
  configuration?: Configuration;
3776
4115
  }[];
4116
+ fulfillmentMethod?: FulfillmentMethod;
4117
+ snapshotId?: string;
4118
+ snapshotAccessToken?: string;
4119
+ billingAddressId?: number;
4120
+ shippingAddressId?: number;
4121
+ billingAddress?: AddressInput;
4122
+ shippingAddress?: AddressInput;
4123
+ shippingRateId?: number;
4124
+ fulfillmentLocationId?: number;
4125
+ idempotencyKey?: string;
4126
+ guest?: {
4127
+ name: string;
4128
+ email: string;
4129
+ };
3777
4130
  }): Promise<IAppResponse<Order>>;
3778
4131
  update(id: string, data: {
3779
4132
  status?: OrderStatus;
@@ -3782,7 +4135,7 @@ declare class OrdersResource {
3782
4135
  }): Promise<IAppResponse<Order>>;
3783
4136
  convertToOrder(id: string): Promise<IAppResponse<Order>>;
3784
4137
  delete(id: string): Promise<IAppResponse<void>>;
3785
- pay(id: string, provider?: PaymentProvider): Promise<IAppResponse<{
4138
+ pay(id: string, provider?: PaymentProvider, accessToken?: string): Promise<IAppResponse<{
3786
4139
  url: string;
3787
4140
  }>>;
3788
4141
  notify(id: string, type?: string): Promise<IAppResponse<{
@@ -3804,6 +4157,7 @@ declare class ProductsResource {
3804
4157
  constructor(http: IHttpService);
3805
4158
  list(params?: {
3806
4159
  includePrivate?: boolean;
4160
+ team?: string;
3807
4161
  }): Promise<IAppResponse<Product[]>>;
3808
4162
  get(id: string): Promise<IAppResponse<Product>>;
3809
4163
  create(data: {
@@ -4061,10 +4415,19 @@ declare class KvResource {
4061
4415
  declare class SubscriptionsResource {
4062
4416
  private readonly http;
4063
4417
  constructor(http: IHttpService);
4064
- list(team: string): Promise<IAppResponse<AppSubscription[]>>;
4065
- get(id: string): Promise<IAppResponse<AppSubscription>>;
4066
- cancel(id: string): Promise<IAppResponse<AppSubscription>>;
4067
- resume(id: string): Promise<IAppResponse<AppSubscription>>;
4418
+ list(team?: string): Promise<IAppResponse<Subscription[]>>;
4419
+ get(id: string): Promise<IAppResponse<Subscription>>;
4420
+ cancel(id: string, team: string): Promise<IAppResponse<Subscription>>;
4421
+ resume(id: string, team: string): Promise<IAppResponse<Subscription>>;
4422
+ updateDelivery(id: string, data: {
4423
+ fulfillmentMethod: 'shipping' | 'pickup';
4424
+ shippingAddressId?: number | null;
4425
+ shippingRateId?: number | null;
4426
+ fulfillmentLocationId?: number | null;
4427
+ }): Promise<IAppResponse<Subscription>>;
4428
+ skip(id: string): Promise<IAppResponse<Subscription>>;
4429
+ pause(id: string): Promise<IAppResponse<Subscription>>;
4430
+ resumeDelivery(id: string): Promise<IAppResponse<Subscription>>;
4068
4431
  cancelPlan(team: string): Promise<IAppResponse<void>>;
4069
4432
  resumePlan(team: string): Promise<IAppResponse<void>>;
4070
4433
  }
@@ -4452,6 +4815,8 @@ declare class JoAiClient {
4452
4815
  isReady: boolean;
4453
4816
  hasApiToken: boolean;
4454
4817
  readonly agents: AgentsResource;
4818
+ readonly addresses: AddressesResource;
4819
+ readonly commerce: CommerceResource;
4455
4820
  readonly alerts: AlertsResource;
4456
4821
  readonly apiTokens: ApiTokensResource;
4457
4822
  readonly characters: CharactersResource;
@@ -4462,7 +4827,6 @@ declare class JoAiClient {
4462
4827
  readonly appointments: AppointmentsResource;
4463
4828
  readonly auth: AuthResource;
4464
4829
  readonly billing: BillingResource;
4465
- readonly billingAddresses: BillingAddressesResource;
4466
4830
  readonly blueprints: BlueprintsResource;
4467
4831
  readonly cards: CardsResource;
4468
4832
  readonly cart: CartsResource;
@@ -4549,10 +4913,38 @@ declare class CachedHttpService implements IHttpService {
4549
4913
  private bust;
4550
4914
  }
4551
4915
  //#endregion
4916
+ //#region src/auth/portal.d.ts
4917
+ declare const getAuthFragmentToken: (url: string) => string | null;
4918
+ declare const isPortalCallbackUrl: (url: string, env?: AppEnv) => boolean;
4919
+ declare const sanitizePortalCallbackUrl: (url: string | null | undefined, env?: AppEnv) => string | null;
4920
+ declare const isAllowedRedirectUrl: (redirect: string, allowedOrigins: string[]) => boolean;
4921
+ declare const completePortalSession: (callbackUrl: string, fetcher?: typeof fetch) => Promise<boolean>;
4922
+ type PortalClient = {
4923
+ auth: {
4924
+ createPortalSession: (redirect: string) => Promise<IAppResponse<AuthPortalSessionResponse>>;
4925
+ };
4926
+ };
4927
+ type OpenPortalSessionOptions = {
4928
+ client: PortalClient;
4929
+ redirect: string;
4930
+ allowedOrigins: string[];
4931
+ env?: AppEnv;
4932
+ fetcher?: typeof fetch;
4933
+ onNavigate?: (redirect: string) => void;
4934
+ };
4935
+ declare const openPortalSession: ({
4936
+ client,
4937
+ redirect,
4938
+ allowedOrigins,
4939
+ env,
4940
+ fetcher,
4941
+ onNavigate
4942
+ }: OpenPortalSessionOptions) => Promise<boolean>;
4943
+ //#endregion
4552
4944
  //#region src/resources/distribution.d.ts
4553
4945
  declare class DistributionResource {
4554
4946
  getBrandSiteConfig(env: AppEnv, brandSlug: string): Promise<BrandSiteConfig | null>;
4555
4947
  private fetchDistribution;
4556
4948
  }
4557
4949
  //#endregion
4558
- export { AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, AuthResource, type AuthSendCodeRequest, type AuthVerifyResponse, type BackendWarp, type BackendWarpBrand, BillingAddressesResource, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, ContactsResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, GoalsResource, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, SegmentsResource, ServicesResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, createClient, formatOpeningHours };
4950
+ export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, type GuestCheckoutDraft, type GuestCommerceStorageOptions, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
package/dist/index.mjs CHANGED
@@ -110,6 +110,23 @@ var HttpService = class {
110
110
  };
111
111
  }
112
112
  };
113
+ Object.values({
114
+ Board: "board",
115
+ Shop: "shop",
116
+ SmartLinks: "smart-links",
117
+ Contacts: "contacts",
118
+ Forms: "forms",
119
+ Appointments: "appointments",
120
+ Workspace: "workspace",
121
+ Meeting: "meeting",
122
+ VoiceDictation: "voice-dictation",
123
+ Heartbeats: "heartbeats",
124
+ Wallets: "wallets",
125
+ Campaigns: "campaigns",
126
+ News: "news",
127
+ Sites: "sites",
128
+ Contracts: "contracts"
129
+ });
113
130
  //#endregion
114
131
  //#region src/resources/agents.ts
115
132
  var AgentsResource = class {
@@ -201,6 +218,207 @@ var AgentsResource = class {
201
218
  }
202
219
  };
203
220
  //#endregion
221
+ //#region src/address/addresses.ts
222
+ var AddressesResource = class {
223
+ constructor(http) {
224
+ this.http = http;
225
+ }
226
+ list(params) {
227
+ return this.http.get(`addresses${query(params)}`);
228
+ }
229
+ get(params) {
230
+ return this.list({
231
+ ...params,
232
+ type: "billing"
233
+ }).then((response) => ({
234
+ ...response,
235
+ data: response.ok ? response.data[0] ?? null : null
236
+ }));
237
+ }
238
+ create(data) {
239
+ return this.http.post("addresses", data);
240
+ }
241
+ update(id, data) {
242
+ return this.http.patch(`addresses/${id}`, data);
243
+ }
244
+ delete(id) {
245
+ return this.http.delete(`addresses/${id}`);
246
+ }
247
+ };
248
+ const query = (params) => {
249
+ const search = new URLSearchParams();
250
+ if (params?.contact) search.set("contact", params.contact);
251
+ if (params?.team) search.set("team", params.team);
252
+ if (params?.type) search.set("type", params.type);
253
+ const value = search.toString();
254
+ return value ? `?${value}` : "";
255
+ };
256
+ //#endregion
257
+ //#region src/commerce/checkout.ts
258
+ var CheckoutResource = class {
259
+ constructor(http) {
260
+ this.http = http;
261
+ }
262
+ snapshot(team, data) {
263
+ return this.http.post(`shops/${encodeURIComponent(team)}/checkout/snapshots`, data);
264
+ }
265
+ placeOrder(team, data) {
266
+ return this.http.post(`shops/${encodeURIComponent(team)}/checkout/orders`, data);
267
+ }
268
+ locations(team) {
269
+ return this.http.get(`shops/${encodeURIComponent(team)}/checkout/fulfillment-locations`);
270
+ }
271
+ shippingRates(team, data) {
272
+ return this.http.post(`shops/${encodeURIComponent(team)}/checkout/shipping-rates`, data);
273
+ }
274
+ };
275
+ //#endregion
276
+ //#region src/commerce/fulfillments.ts
277
+ var FulfillmentsResource = class {
278
+ constructor(http) {
279
+ this.http = http;
280
+ }
281
+ list(orderId) {
282
+ return this.http.get(`orders/${orderId}/fulfillments`);
283
+ }
284
+ create(orderId, data) {
285
+ return this.http.post(`orders/${orderId}/fulfillments`, data);
286
+ }
287
+ update(orderId, fulfillmentId, status) {
288
+ return this.http.patch(`orders/${orderId}/fulfillments/${fulfillmentId}`, { status });
289
+ }
290
+ };
291
+ //#endregion
292
+ //#region src/commerce/returns.ts
293
+ const orderAccessHeaders$1 = (accessToken) => accessToken ? { headers: { "X-Order-Access-Token": accessToken } } : void 0;
294
+ var ReturnsResource = class {
295
+ constructor(http) {
296
+ this.http = http;
297
+ }
298
+ list(orderId, accessToken) {
299
+ return this.http.get(`orders/${orderId}/returns`, orderAccessHeaders$1(accessToken));
300
+ }
301
+ create(orderId, data, accessToken) {
302
+ return this.http.post(`orders/${orderId}/returns`, data, orderAccessHeaders$1(accessToken));
303
+ }
304
+ update(id, data) {
305
+ return this.http.patch(`returns/${id}`, data);
306
+ }
307
+ };
308
+ //#endregion
309
+ //#region src/commerce/shipping.ts
310
+ var ShippingResource = class {
311
+ constructor(http) {
312
+ this.http = http;
313
+ }
314
+ zones(team) {
315
+ return this.http.get(`teams/${team}/shipping-zones`);
316
+ }
317
+ createZone(team, data) {
318
+ return this.http.post(`teams/${team}/shipping-zones`, data);
319
+ }
320
+ updateZone(team, zoneId, data) {
321
+ return this.http.patch(`teams/${team}/shipping-zones/${zoneId}`, data);
322
+ }
323
+ deleteZone(team, zoneId) {
324
+ return this.http.delete(`teams/${team}/shipping-zones/${zoneId}`);
325
+ }
326
+ createRate(team, zoneId, data) {
327
+ return this.http.post(`teams/${team}/shipping-zones/${zoneId}/rates`, data);
328
+ }
329
+ locations(team) {
330
+ return this.http.get(`teams/${team}/fulfillment-locations`);
331
+ }
332
+ createLocation(team, data) {
333
+ return this.http.post(`teams/${team}/fulfillment-locations`, data);
334
+ }
335
+ };
336
+ //#endregion
337
+ //#region src/commerce/guest.ts
338
+ const orderAccessPrefix = "joai:order-access:";
339
+ const checkoutKey = (namespace) => `joai:guest-checkout:${namespace}`;
340
+ const ordersKey = (namespace) => `joai:guest-orders:${namespace}`;
341
+ const orderAccessKey = (namespace, orderId) => `${orderAccessPrefix}${namespace}:${orderId}`;
342
+ const safeGet = (key) => {
343
+ if (typeof localStorage === "undefined") return null;
344
+ try {
345
+ return localStorage.getItem(key);
346
+ } catch {
347
+ return null;
348
+ }
349
+ };
350
+ const safeSet = (key, value) => {
351
+ if (typeof localStorage === "undefined") return;
352
+ try {
353
+ localStorage.setItem(key, value);
354
+ } catch {}
355
+ };
356
+ const parseGuestOrderAccess = (entry) => {
357
+ if (!entry || typeof entry !== "object") return null;
358
+ const record = entry;
359
+ if (typeof record.orderId !== "string") return null;
360
+ if (record.accessToken !== null && typeof record.accessToken !== "string") return null;
361
+ return {
362
+ orderId: record.orderId,
363
+ accessToken: record.accessToken ?? null
364
+ };
365
+ };
366
+ const readOrderList = (namespace) => {
367
+ try {
368
+ const saved = JSON.parse(safeGet(ordersKey(namespace)) || "[]");
369
+ if (!Array.isArray(saved)) return [];
370
+ return saved.map(parseGuestOrderAccess).filter((entry) => entry !== null);
371
+ } catch {
372
+ return [];
373
+ }
374
+ };
375
+ function createGuestCommerceStorage(options) {
376
+ const maxOrders = options.maxOrders ?? 10;
377
+ return {
378
+ saveCheckoutDraft(draft) {
379
+ safeSet(checkoutKey(options.namespace), JSON.stringify(draft));
380
+ },
381
+ readCheckoutDraft(fallback) {
382
+ try {
383
+ const saved = JSON.parse(safeGet(checkoutKey(options.namespace)) || "");
384
+ return {
385
+ ...fallback,
386
+ ...saved,
387
+ cart: Array.isArray(saved.cart) ? saved.cart : fallback.cart
388
+ };
389
+ } catch {
390
+ return fallback;
391
+ }
392
+ },
393
+ saveOrderAccess({ orderId, accessToken }) {
394
+ const key = orderAccessKey(options.namespace, orderId);
395
+ if (accessToken) safeSet(key, accessToken);
396
+ const orders = readOrderList(options.namespace).filter((entry) => entry.orderId !== orderId);
397
+ orders.unshift({
398
+ orderId,
399
+ accessToken
400
+ });
401
+ safeSet(ordersKey(options.namespace), JSON.stringify(orders.slice(0, maxOrders)));
402
+ },
403
+ readOrderAccess(orderId) {
404
+ return safeGet(orderAccessKey(options.namespace, orderId));
405
+ },
406
+ listOrderAccess() {
407
+ return readOrderList(options.namespace);
408
+ }
409
+ };
410
+ }
411
+ //#endregion
412
+ //#region src/commerce/index.ts
413
+ var CommerceResource = class {
414
+ constructor(http) {
415
+ this.checkout = new CheckoutResource(http);
416
+ this.shipping = new ShippingResource(http);
417
+ this.fulfillments = new FulfillmentsResource(http);
418
+ this.returns = new ReturnsResource(http);
419
+ }
420
+ };
421
+ //#endregion
204
422
  //#region src/resources/alerts.ts
205
423
  var AlertsResource = class {
206
424
  constructor(http) {
@@ -485,6 +703,9 @@ var AuthResource = class {
485
703
  sendCode(data) {
486
704
  return this.http.post("auth/send-code", data);
487
705
  }
706
+ confirmCode(data) {
707
+ return this.http.post("auth/confirm-code", data);
708
+ }
488
709
  requestEmail(email, redirect) {
489
710
  return this.http.post("auth/email/request", {
490
711
  email,
@@ -494,8 +715,8 @@ var AuthResource = class {
494
715
  loginWithSocialAccessToken(provider, accessToken) {
495
716
  return this.http.post(`auth/social/${provider}/login`, { accessToken });
496
717
  }
497
- verify(token) {
498
- return this.http.get("auth/verify?token=" + token);
718
+ exchangeNativeSession(token) {
719
+ return this.http.post("auth/verify", { token });
499
720
  }
500
721
  me() {
501
722
  return this.http.get("auth/me");
@@ -506,6 +727,9 @@ var AuthResource = class {
506
727
  createApiToken() {
507
728
  return this.http.post("auth/api-tokens");
508
729
  }
730
+ createPortalSession(redirect) {
731
+ return this.http.post("auth/portal-sessions", { redirect });
732
+ }
509
733
  verifyWallet(accessToken, withMobileApiToken) {
510
734
  return this.http.post("auth/wallet/verify", {
511
735
  accessToken,
@@ -514,23 +738,6 @@ var AuthResource = class {
514
738
  }
515
739
  };
516
740
  //#endregion
517
- //#region src/resources/billing-addresses.ts
518
- var BillingAddressesResource = class {
519
- constructor(http) {
520
- this.http = http;
521
- }
522
- get(contact, team) {
523
- const params = new URLSearchParams();
524
- if (contact) params.set("contact", contact);
525
- if (team) params.set("team", team);
526
- const qs = params.toString();
527
- return this.http.get(`billing/addresses${qs ? "?" + qs : ""}`);
528
- }
529
- store(data) {
530
- return this.http.post("billing/addresses", data);
531
- }
532
- };
533
- //#endregion
534
741
  //#region src/resources/billing.ts
535
742
  var BillingResource = class {
536
743
  constructor(http) {
@@ -1512,6 +1719,9 @@ var NotificationsResource = class {
1512
1719
  getUnread() {
1513
1720
  return this.http.get("notifications?unread");
1514
1721
  }
1722
+ getDismissedPushKeys() {
1723
+ return this.http.get("notifications/dismissed-push-keys");
1724
+ }
1515
1725
  getSettings() {
1516
1726
  return this.http.get("notifications/settings");
1517
1727
  }
@@ -1540,6 +1750,7 @@ var OfficeResource = class {
1540
1750
  };
1541
1751
  //#endregion
1542
1752
  //#region src/resources/orders.ts
1753
+ const orderAccessHeaders = (accessToken) => accessToken ? { headers: { "X-Order-Access-Token": accessToken } } : void 0;
1543
1754
  var OrdersResource = class {
1544
1755
  constructor(http) {
1545
1756
  this.http = http;
@@ -1547,11 +1758,11 @@ var OrdersResource = class {
1547
1758
  list(team) {
1548
1759
  return this.http.get("orders", { headers: { "X-Team": team } });
1549
1760
  }
1550
- get(id) {
1551
- return this.http.get(`orders/${id}`);
1761
+ get(id, accessToken) {
1762
+ return this.http.get(`orders/${id}`, orderAccessHeaders(accessToken));
1552
1763
  }
1553
1764
  create(data) {
1554
- return this.http.post("orders", data, { headers: { "X-Team": data.team } });
1765
+ return this.http.post("orders", data);
1555
1766
  }
1556
1767
  update(id, data) {
1557
1768
  return this.http.put(`orders/${id}`, data);
@@ -1562,8 +1773,8 @@ var OrdersResource = class {
1562
1773
  delete(id) {
1563
1774
  return this.http.delete(`orders/${id}`);
1564
1775
  }
1565
- pay(id, provider) {
1566
- return this.http.post(`orders/${id}/pay`, provider ? { provider } : {});
1776
+ pay(id, provider, accessToken) {
1777
+ return this.http.post(`orders/${id}/pay`, provider ? { provider } : {}, orderAccessHeaders(accessToken));
1567
1778
  }
1568
1779
  notify(id, type = "confirmation") {
1569
1780
  return this.http.post(`orders/${id}/notify`, { type });
@@ -1593,7 +1804,10 @@ var ProductsResource = class {
1593
1804
  }
1594
1805
  list(params) {
1595
1806
  let url = "products";
1596
- if (params?.includePrivate) url += "?includePrivate=1";
1807
+ const search = new URLSearchParams();
1808
+ if (params?.includePrivate) search.set("includePrivate", "1");
1809
+ if (params?.team) search.set("team", params.team);
1810
+ if (search.size) url += `?${search.toString()}`;
1597
1811
  return this.http.get(url);
1598
1812
  }
1599
1813
  get(id) {
@@ -1902,16 +2116,28 @@ var SubscriptionsResource = class {
1902
2116
  this.http = http;
1903
2117
  }
1904
2118
  list(team) {
1905
- return this.http.get("subscriptions");
2119
+ return team ? this.http.get("subscriptions", { headers: { "X-Team": team } }) : this.http.get("subscriptions");
1906
2120
  }
1907
2121
  get(id) {
1908
2122
  return this.http.get(`subscriptions/${id}`);
1909
2123
  }
1910
- cancel(id) {
1911
- return this.http.post(`subscriptions/${id}/cancel`);
2124
+ cancel(id, team) {
2125
+ return this.http.post(`subscriptions/${id}/cancel`, void 0, { headers: { "X-Team": team } });
1912
2126
  }
1913
- resume(id) {
1914
- return this.http.post(`subscriptions/${id}/resume`);
2127
+ resume(id, team) {
2128
+ return this.http.post(`subscriptions/${id}/resume`, void 0, { headers: { "X-Team": team } });
2129
+ }
2130
+ updateDelivery(id, data) {
2131
+ return this.http.patch(`subscriptions/${id}/delivery`, data);
2132
+ }
2133
+ skip(id) {
2134
+ return this.http.post(`subscriptions/${id}/skip`);
2135
+ }
2136
+ pause(id) {
2137
+ return this.http.post(`subscriptions/${id}/pause`);
2138
+ }
2139
+ resumeDelivery(id) {
2140
+ return this.http.post(`subscriptions/${id}/resume-delivery`);
1915
2141
  }
1916
2142
  cancelPlan(team) {
1917
2143
  return this.http.post("billing/plans/cancel", { team });
@@ -2623,6 +2849,8 @@ var JoAiClient = class {
2623
2849
  const cache = config.cache;
2624
2850
  this.http = cache?.enabled !== false ? new CachedHttpService(http, cache?.overrides, cache?.defaultTtl) : http;
2625
2851
  this.agents = new AgentsResource(this.http);
2852
+ this.addresses = new AddressesResource(this.http);
2853
+ this.commerce = new CommerceResource(this.http);
2626
2854
  this.alerts = new AlertsResource(this.http);
2627
2855
  this.apiTokens = new ApiTokensResource(this.http);
2628
2856
  this.characters = new CharactersResource(this.http);
@@ -2633,7 +2861,6 @@ var JoAiClient = class {
2633
2861
  this.appointments = new AppointmentsResource(this.http, config);
2634
2862
  this.auth = new AuthResource(this.http);
2635
2863
  this.billing = new BillingResource(this.http);
2636
- this.billingAddresses = new BillingAddressesResource(this.http);
2637
2864
  this.blueprints = new BlueprintsResource(this.http);
2638
2865
  this.cards = new CardsResource(this.http);
2639
2866
  this.cart = new CartsResource(this.http);
@@ -2704,6 +2931,69 @@ function createClient(config) {
2704
2931
  return new JoAiClient(config);
2705
2932
  }
2706
2933
  //#endregion
2934
+ //#region src/auth/portal.ts
2935
+ const getAuthFragmentToken = (url) => {
2936
+ try {
2937
+ return new URLSearchParams(new URL(url).hash.slice(1)).get("token");
2938
+ } catch {
2939
+ return null;
2940
+ }
2941
+ };
2942
+ const isPortalCallbackUrl = (url, env = "mainnet") => {
2943
+ try {
2944
+ const callbackUrl = new URL(url);
2945
+ const apiCallback = new URL("/v1/auth/callback", getApiBaseUrl(env));
2946
+ return callbackUrl.origin === apiCallback.origin && callbackUrl.pathname === apiCallback.pathname && !callbackUrl.search && Boolean(getAuthFragmentToken(url));
2947
+ } catch {
2948
+ return false;
2949
+ }
2950
+ };
2951
+ const sanitizePortalCallbackUrl = (url, env = "mainnet") => url && isPortalCallbackUrl(url, env) ? url : null;
2952
+ const isAllowedRedirectUrl = (redirect, allowedOrigins) => {
2953
+ try {
2954
+ return allowedOrigins.includes(new URL(redirect).origin);
2955
+ } catch {
2956
+ return false;
2957
+ }
2958
+ };
2959
+ const completePortalSession = async (callbackUrl, fetcher = fetch) => {
2960
+ const token = getAuthFragmentToken(callbackUrl);
2961
+ if (!token) return false;
2962
+ try {
2963
+ const callback = new URL(callbackUrl);
2964
+ const response = await fetcher(`${callback.origin}${callback.pathname}`, {
2965
+ method: "POST",
2966
+ headers: {
2967
+ Accept: "application/json",
2968
+ "Content-Type": "application/json"
2969
+ },
2970
+ body: JSON.stringify({ token }),
2971
+ credentials: "include",
2972
+ redirect: "manual"
2973
+ });
2974
+ return response.ok || response.type === "opaqueredirect";
2975
+ } catch {
2976
+ return false;
2977
+ }
2978
+ };
2979
+ const openPortalSession = async ({ client, redirect, allowedOrigins, env = "mainnet", fetcher = fetch, onNavigate }) => {
2980
+ if (!isAllowedRedirectUrl(redirect, allowedOrigins)) return false;
2981
+ const response = await client.auth.createPortalSession(redirect);
2982
+ const callbackUrl = sanitizePortalCallbackUrl(response.ok ? response.data?.url : null, env);
2983
+ if (!callbackUrl) return false;
2984
+ if (!await completePortalSession(callbackUrl, fetcher)) return false;
2985
+ if (!isAllowedRedirectUrl(redirect, allowedOrigins)) return false;
2986
+ if (onNavigate) {
2987
+ onNavigate(redirect);
2988
+ return true;
2989
+ }
2990
+ if (typeof window !== "undefined") {
2991
+ window.location.assign(redirect);
2992
+ return true;
2993
+ }
2994
+ return false;
2995
+ };
2996
+ //#endregion
2707
2997
  //#region src/resources/distribution.ts
2708
2998
  const DISTRIBUTION_URLS = {
2709
2999
  local: "https://raw.githubusercontent.com/JoAiHQ/warps/refs/heads/dev/catalog/devnet/distribution.json",
@@ -2732,4 +3022,4 @@ var DistributionResource = class {
2732
3022
  }
2733
3023
  };
2734
3024
  //#endregion
2735
- export { AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource, BillingAddressesResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, ContactsResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, GoalsResource, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, RemindersResource, SegmentsResource, ServicesResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, createClient, formatOpeningHours };
3025
+ export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/sdk",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "JoAi public API SDK — build with your AI agents",
5
5
  "license": "MIT",
6
6
  "type": "module",