@joai/sdk 4.1.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 +411 -43
- package/dist/index.mjs +303 -32
- package/package.json +1 -1
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
|
|
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;
|
|
@@ -251,6 +250,7 @@ declare const NativeApps: {
|
|
|
251
250
|
readonly Shop: "shop";
|
|
252
251
|
readonly SmartLinks: "smart-links";
|
|
253
252
|
readonly Contacts: "contacts";
|
|
253
|
+
readonly Forms: "forms";
|
|
254
254
|
readonly Appointments: "appointments";
|
|
255
255
|
readonly Workspace: "workspace";
|
|
256
256
|
readonly Meeting: "meeting";
|
|
@@ -442,6 +442,160 @@ type AiCostsResponse = {
|
|
|
442
442
|
};
|
|
443
443
|
};
|
|
444
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
|
|
445
599
|
//#region src/json/types.d.ts
|
|
446
600
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
447
601
|
[key: string]: JsonValue;
|
|
@@ -563,7 +717,7 @@ type OrderType = 'order' | 'quote';
|
|
|
563
717
|
type SubscriptionStatus = 'active' | 'canceled' | 'past_due' | 'pending';
|
|
564
718
|
type SubscriptionInterval = 'weekly' | 'biweekly' | 'monthly' | 'quarterly' | 'yearly';
|
|
565
719
|
type PricingModel = 'free' | 'one-time' | 'weekly' | 'biweekly' | 'monthly' | 'quarterly' | 'yearly' | 'per-run';
|
|
566
|
-
type
|
|
720
|
+
type Subscription = {
|
|
567
721
|
id: string;
|
|
568
722
|
orderId: string;
|
|
569
723
|
teamId: string;
|
|
@@ -576,6 +730,7 @@ type AppSubscription = {
|
|
|
576
730
|
meta: Record<string, JsonValue> | null;
|
|
577
731
|
createdAt: string;
|
|
578
732
|
updatedAt: string;
|
|
733
|
+
delivery?: SubscriptionDelivery | null;
|
|
579
734
|
};
|
|
580
735
|
type PaymentProvider = 'xmoney' | 'lemonsqueezy' | 'stripe' | 'stripe-connect' | 'mollie' | 'mollie-connect' | 'apple' | 'google' | 'blockchain' | 'offline';
|
|
581
736
|
type PaymentAccount = {
|
|
@@ -614,16 +769,6 @@ type PlanExtra = {
|
|
|
614
769
|
price: number;
|
|
615
770
|
unitName: string;
|
|
616
771
|
};
|
|
617
|
-
type BillingAddress = {
|
|
618
|
-
name: string;
|
|
619
|
-
addressOne: string | null;
|
|
620
|
-
city: string | null;
|
|
621
|
-
state: string | null;
|
|
622
|
-
zipCode: string | null;
|
|
623
|
-
country: string;
|
|
624
|
-
vatId: string | null;
|
|
625
|
-
isEU: boolean;
|
|
626
|
-
};
|
|
627
772
|
type PlanInterval = 'weekly' | 'monthly' | 'yearly' | 'lifetime';
|
|
628
773
|
type Plan = {
|
|
629
774
|
resource: 'plan';
|
|
@@ -778,6 +923,17 @@ type Order = {
|
|
|
778
923
|
paymentMode: string | null;
|
|
779
924
|
linkVariationId: string | null;
|
|
780
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;
|
|
781
937
|
configuration?: OrderConfigurationItem[];
|
|
782
938
|
items: OrderItem[];
|
|
783
939
|
coupon?: Coupon | null;
|
|
@@ -1429,7 +1585,8 @@ type Meeting = {
|
|
|
1429
1585
|
captureMode: 'desktop_local' | null;
|
|
1430
1586
|
transcriptUrl: string | null;
|
|
1431
1587
|
summaryUrl: string | null;
|
|
1432
|
-
participants?: MeetingParticipant[];
|
|
1588
|
+
participants?: MeetingParticipant[]; /** The customer associated with an appointment booking, when available. */
|
|
1589
|
+
contact?: Contact | null;
|
|
1433
1590
|
speakerAssignments?: MeetingSpeakerAssignment[] | null;
|
|
1434
1591
|
scheduledAt: string | null;
|
|
1435
1592
|
calendarEventId: number | null;
|
|
@@ -1507,6 +1664,7 @@ type AppointmentPolicy = {
|
|
|
1507
1664
|
bookingCapacity?: number | null;
|
|
1508
1665
|
bookingCapacityUnit?: 'booking' | 'person' | null;
|
|
1509
1666
|
requireApproval?: boolean | null;
|
|
1667
|
+
notificationEmail?: string | null;
|
|
1510
1668
|
sync?: AppointmentPolicySync | null;
|
|
1511
1669
|
agent?: Agent | null;
|
|
1512
1670
|
agentUuid?: string | null;
|
|
@@ -1546,7 +1704,7 @@ type AppointmentRequest = {
|
|
|
1546
1704
|
configuration?: Configuration;
|
|
1547
1705
|
createdAt: string;
|
|
1548
1706
|
}; //#endregion
|
|
1549
|
-
//#region src/
|
|
1707
|
+
//#region src/commerce/helpers.d.ts
|
|
1550
1708
|
//#endregion
|
|
1551
1709
|
//#region src/card/types.d.ts
|
|
1552
1710
|
type Card = {
|
|
@@ -2890,6 +3048,166 @@ declare class AgentsResource {
|
|
|
2890
3048
|
}): Promise<IAppResponse<unknown>>;
|
|
2891
3049
|
}
|
|
2892
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
|
|
2893
3211
|
//#region src/resources/alerts.d.ts
|
|
2894
3212
|
declare class AlertsResource {
|
|
2895
3213
|
private readonly http;
|
|
@@ -3100,11 +3418,21 @@ type NativeSocialAuthProvider = Extract<SocialAuthProvider, 'apple' | 'google'>;
|
|
|
3100
3418
|
type AuthSendCodeRequest = {
|
|
3101
3419
|
name: string;
|
|
3102
3420
|
phone?: string;
|
|
3421
|
+
email: string;
|
|
3422
|
+
team?: string;
|
|
3423
|
+
table?: string;
|
|
3424
|
+
};
|
|
3425
|
+
type AuthConfirmCodeRequest = {
|
|
3426
|
+
code: string;
|
|
3427
|
+
phone?: string;
|
|
3103
3428
|
email?: string;
|
|
3104
3429
|
team?: string;
|
|
3105
3430
|
table?: string;
|
|
3106
3431
|
};
|
|
3107
|
-
type
|
|
3432
|
+
type AuthConfirmCodeResponse = {
|
|
3433
|
+
authUrl: string;
|
|
3434
|
+
};
|
|
3435
|
+
type AuthNativeSessionResponse = {
|
|
3108
3436
|
token: string;
|
|
3109
3437
|
user: AuthUser;
|
|
3110
3438
|
team: {
|
|
@@ -3121,37 +3449,24 @@ type AuthLoginResponse = {
|
|
|
3121
3449
|
type AuthApiTokenResponse = {
|
|
3122
3450
|
plainTextToken: string;
|
|
3123
3451
|
};
|
|
3452
|
+
type AuthPortalSessionResponse = {
|
|
3453
|
+
url: string;
|
|
3454
|
+
};
|
|
3124
3455
|
declare class AuthResource {
|
|
3125
3456
|
private http;
|
|
3126
3457
|
constructor(http: IHttpService);
|
|
3127
3458
|
sendCode(data: AuthSendCodeRequest): Promise<IAppResponse<void>>;
|
|
3459
|
+
confirmCode(data: AuthConfirmCodeRequest): Promise<IAppResponse<AuthConfirmCodeResponse>>;
|
|
3128
3460
|
requestEmail(email: string, redirect?: string): Promise<IAppResponse<AuthLoginResponse>>;
|
|
3129
3461
|
loginWithSocialAccessToken(provider: NativeSocialAuthProvider, accessToken: string): Promise<IAppResponse<AuthLoginResponse>>;
|
|
3130
|
-
|
|
3462
|
+
exchangeNativeSession(token: string): Promise<IAppResponse<AuthNativeSessionResponse>>;
|
|
3131
3463
|
me(): Promise<IAppResponse<AuthUser>>;
|
|
3132
3464
|
logout(): Promise<IAppResponse<void>>;
|
|
3133
3465
|
createApiToken(): Promise<IAppResponse<AuthApiTokenResponse>>;
|
|
3466
|
+
createPortalSession(redirect: string): Promise<IAppResponse<AuthPortalSessionResponse>>;
|
|
3134
3467
|
verifyWallet(accessToken: string, withMobileApiToken?: boolean): Promise<IAppResponse<UserPrivate>>;
|
|
3135
3468
|
}
|
|
3136
3469
|
//#endregion
|
|
3137
|
-
//#region src/resources/billing-addresses.d.ts
|
|
3138
|
-
declare class BillingAddressesResource {
|
|
3139
|
-
private readonly http;
|
|
3140
|
-
constructor(http: IHttpService);
|
|
3141
|
-
get(contact?: string, team?: string): Promise<IAppResponse<BillingAddress | null>>;
|
|
3142
|
-
store(data: {
|
|
3143
|
-
name: string;
|
|
3144
|
-
addressOne?: string;
|
|
3145
|
-
city?: string;
|
|
3146
|
-
state?: string;
|
|
3147
|
-
zipCode?: string;
|
|
3148
|
-
country: string;
|
|
3149
|
-
vatId?: string;
|
|
3150
|
-
contact?: string;
|
|
3151
|
-
team?: string;
|
|
3152
|
-
}): Promise<IAppResponse<BillingAddress>>;
|
|
3153
|
-
}
|
|
3154
|
-
//#endregion
|
|
3155
3470
|
//#region src/resources/billing.d.ts
|
|
3156
3471
|
type IapReceipt = {
|
|
3157
3472
|
productId: string;
|
|
@@ -3780,7 +4095,7 @@ declare class OrdersResource {
|
|
|
3780
4095
|
private readonly http;
|
|
3781
4096
|
constructor(http: IHttpService);
|
|
3782
4097
|
list(team: string): Promise<IAppResponse<Order[]>>;
|
|
3783
|
-
get(id: string): Promise<IAppResponse<Order>>;
|
|
4098
|
+
get(id: string, accessToken?: string): Promise<IAppResponse<Order>>;
|
|
3784
4099
|
create(data: {
|
|
3785
4100
|
contactId?: string;
|
|
3786
4101
|
notes?: string;
|
|
@@ -3798,6 +4113,20 @@ declare class OrdersResource {
|
|
|
3798
4113
|
quantity: number;
|
|
3799
4114
|
configuration?: Configuration;
|
|
3800
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
|
+
};
|
|
3801
4130
|
}): Promise<IAppResponse<Order>>;
|
|
3802
4131
|
update(id: string, data: {
|
|
3803
4132
|
status?: OrderStatus;
|
|
@@ -3806,7 +4135,7 @@ declare class OrdersResource {
|
|
|
3806
4135
|
}): Promise<IAppResponse<Order>>;
|
|
3807
4136
|
convertToOrder(id: string): Promise<IAppResponse<Order>>;
|
|
3808
4137
|
delete(id: string): Promise<IAppResponse<void>>;
|
|
3809
|
-
pay(id: string, provider?: PaymentProvider): Promise<IAppResponse<{
|
|
4138
|
+
pay(id: string, provider?: PaymentProvider, accessToken?: string): Promise<IAppResponse<{
|
|
3810
4139
|
url: string;
|
|
3811
4140
|
}>>;
|
|
3812
4141
|
notify(id: string, type?: string): Promise<IAppResponse<{
|
|
@@ -3828,6 +4157,7 @@ declare class ProductsResource {
|
|
|
3828
4157
|
constructor(http: IHttpService);
|
|
3829
4158
|
list(params?: {
|
|
3830
4159
|
includePrivate?: boolean;
|
|
4160
|
+
team?: string;
|
|
3831
4161
|
}): Promise<IAppResponse<Product[]>>;
|
|
3832
4162
|
get(id: string): Promise<IAppResponse<Product>>;
|
|
3833
4163
|
create(data: {
|
|
@@ -4085,10 +4415,19 @@ declare class KvResource {
|
|
|
4085
4415
|
declare class SubscriptionsResource {
|
|
4086
4416
|
private readonly http;
|
|
4087
4417
|
constructor(http: IHttpService);
|
|
4088
|
-
list(team
|
|
4089
|
-
get(id: string): Promise<IAppResponse<
|
|
4090
|
-
cancel(id: string): Promise<IAppResponse<
|
|
4091
|
-
resume(id: string): Promise<IAppResponse<
|
|
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>>;
|
|
4092
4431
|
cancelPlan(team: string): Promise<IAppResponse<void>>;
|
|
4093
4432
|
resumePlan(team: string): Promise<IAppResponse<void>>;
|
|
4094
4433
|
}
|
|
@@ -4476,6 +4815,8 @@ declare class JoAiClient {
|
|
|
4476
4815
|
isReady: boolean;
|
|
4477
4816
|
hasApiToken: boolean;
|
|
4478
4817
|
readonly agents: AgentsResource;
|
|
4818
|
+
readonly addresses: AddressesResource;
|
|
4819
|
+
readonly commerce: CommerceResource;
|
|
4479
4820
|
readonly alerts: AlertsResource;
|
|
4480
4821
|
readonly apiTokens: ApiTokensResource;
|
|
4481
4822
|
readonly characters: CharactersResource;
|
|
@@ -4486,7 +4827,6 @@ declare class JoAiClient {
|
|
|
4486
4827
|
readonly appointments: AppointmentsResource;
|
|
4487
4828
|
readonly auth: AuthResource;
|
|
4488
4829
|
readonly billing: BillingResource;
|
|
4489
|
-
readonly billingAddresses: BillingAddressesResource;
|
|
4490
4830
|
readonly blueprints: BlueprintsResource;
|
|
4491
4831
|
readonly cards: CardsResource;
|
|
4492
4832
|
readonly cart: CartsResource;
|
|
@@ -4573,10 +4913,38 @@ declare class CachedHttpService implements IHttpService {
|
|
|
4573
4913
|
private bust;
|
|
4574
4914
|
}
|
|
4575
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
|
|
4576
4944
|
//#region src/resources/distribution.d.ts
|
|
4577
4945
|
declare class DistributionResource {
|
|
4578
4946
|
getBrandSiteConfig(env: AppEnv, brandSlug: string): Promise<BrandSiteConfig | null>;
|
|
4579
4947
|
private fetchDistribution;
|
|
4580
4948
|
}
|
|
4581
4949
|
//#endregion
|
|
4582
|
-
export { AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia,
|
|
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
|
@@ -115,6 +115,7 @@ Object.values({
|
|
|
115
115
|
Shop: "shop",
|
|
116
116
|
SmartLinks: "smart-links",
|
|
117
117
|
Contacts: "contacts",
|
|
118
|
+
Forms: "forms",
|
|
118
119
|
Appointments: "appointments",
|
|
119
120
|
Workspace: "workspace",
|
|
120
121
|
Meeting: "meeting",
|
|
@@ -217,6 +218,207 @@ var AgentsResource = class {
|
|
|
217
218
|
}
|
|
218
219
|
};
|
|
219
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
|
|
220
422
|
//#region src/resources/alerts.ts
|
|
221
423
|
var AlertsResource = class {
|
|
222
424
|
constructor(http) {
|
|
@@ -501,6 +703,9 @@ var AuthResource = class {
|
|
|
501
703
|
sendCode(data) {
|
|
502
704
|
return this.http.post("auth/send-code", data);
|
|
503
705
|
}
|
|
706
|
+
confirmCode(data) {
|
|
707
|
+
return this.http.post("auth/confirm-code", data);
|
|
708
|
+
}
|
|
504
709
|
requestEmail(email, redirect) {
|
|
505
710
|
return this.http.post("auth/email/request", {
|
|
506
711
|
email,
|
|
@@ -510,8 +715,8 @@ var AuthResource = class {
|
|
|
510
715
|
loginWithSocialAccessToken(provider, accessToken) {
|
|
511
716
|
return this.http.post(`auth/social/${provider}/login`, { accessToken });
|
|
512
717
|
}
|
|
513
|
-
|
|
514
|
-
return this.http.
|
|
718
|
+
exchangeNativeSession(token) {
|
|
719
|
+
return this.http.post("auth/verify", { token });
|
|
515
720
|
}
|
|
516
721
|
me() {
|
|
517
722
|
return this.http.get("auth/me");
|
|
@@ -522,6 +727,9 @@ var AuthResource = class {
|
|
|
522
727
|
createApiToken() {
|
|
523
728
|
return this.http.post("auth/api-tokens");
|
|
524
729
|
}
|
|
730
|
+
createPortalSession(redirect) {
|
|
731
|
+
return this.http.post("auth/portal-sessions", { redirect });
|
|
732
|
+
}
|
|
525
733
|
verifyWallet(accessToken, withMobileApiToken) {
|
|
526
734
|
return this.http.post("auth/wallet/verify", {
|
|
527
735
|
accessToken,
|
|
@@ -530,23 +738,6 @@ var AuthResource = class {
|
|
|
530
738
|
}
|
|
531
739
|
};
|
|
532
740
|
//#endregion
|
|
533
|
-
//#region src/resources/billing-addresses.ts
|
|
534
|
-
var BillingAddressesResource = class {
|
|
535
|
-
constructor(http) {
|
|
536
|
-
this.http = http;
|
|
537
|
-
}
|
|
538
|
-
get(contact, team) {
|
|
539
|
-
const params = new URLSearchParams();
|
|
540
|
-
if (contact) params.set("contact", contact);
|
|
541
|
-
if (team) params.set("team", team);
|
|
542
|
-
const qs = params.toString();
|
|
543
|
-
return this.http.get(`billing/addresses${qs ? "?" + qs : ""}`);
|
|
544
|
-
}
|
|
545
|
-
store(data) {
|
|
546
|
-
return this.http.post("billing/addresses", data);
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
//#endregion
|
|
550
741
|
//#region src/resources/billing.ts
|
|
551
742
|
var BillingResource = class {
|
|
552
743
|
constructor(http) {
|
|
@@ -1559,6 +1750,7 @@ var OfficeResource = class {
|
|
|
1559
1750
|
};
|
|
1560
1751
|
//#endregion
|
|
1561
1752
|
//#region src/resources/orders.ts
|
|
1753
|
+
const orderAccessHeaders = (accessToken) => accessToken ? { headers: { "X-Order-Access-Token": accessToken } } : void 0;
|
|
1562
1754
|
var OrdersResource = class {
|
|
1563
1755
|
constructor(http) {
|
|
1564
1756
|
this.http = http;
|
|
@@ -1566,11 +1758,11 @@ var OrdersResource = class {
|
|
|
1566
1758
|
list(team) {
|
|
1567
1759
|
return this.http.get("orders", { headers: { "X-Team": team } });
|
|
1568
1760
|
}
|
|
1569
|
-
get(id) {
|
|
1570
|
-
return this.http.get(`orders/${id}
|
|
1761
|
+
get(id, accessToken) {
|
|
1762
|
+
return this.http.get(`orders/${id}`, orderAccessHeaders(accessToken));
|
|
1571
1763
|
}
|
|
1572
1764
|
create(data) {
|
|
1573
|
-
return this.http.post("orders", data
|
|
1765
|
+
return this.http.post("orders", data);
|
|
1574
1766
|
}
|
|
1575
1767
|
update(id, data) {
|
|
1576
1768
|
return this.http.put(`orders/${id}`, data);
|
|
@@ -1581,8 +1773,8 @@ var OrdersResource = class {
|
|
|
1581
1773
|
delete(id) {
|
|
1582
1774
|
return this.http.delete(`orders/${id}`);
|
|
1583
1775
|
}
|
|
1584
|
-
pay(id, provider) {
|
|
1585
|
-
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));
|
|
1586
1778
|
}
|
|
1587
1779
|
notify(id, type = "confirmation") {
|
|
1588
1780
|
return this.http.post(`orders/${id}/notify`, { type });
|
|
@@ -1612,7 +1804,10 @@ var ProductsResource = class {
|
|
|
1612
1804
|
}
|
|
1613
1805
|
list(params) {
|
|
1614
1806
|
let url = "products";
|
|
1615
|
-
|
|
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()}`;
|
|
1616
1811
|
return this.http.get(url);
|
|
1617
1812
|
}
|
|
1618
1813
|
get(id) {
|
|
@@ -1921,16 +2116,28 @@ var SubscriptionsResource = class {
|
|
|
1921
2116
|
this.http = http;
|
|
1922
2117
|
}
|
|
1923
2118
|
list(team) {
|
|
1924
|
-
return this.http.get("subscriptions");
|
|
2119
|
+
return team ? this.http.get("subscriptions", { headers: { "X-Team": team } }) : this.http.get("subscriptions");
|
|
1925
2120
|
}
|
|
1926
2121
|
get(id) {
|
|
1927
2122
|
return this.http.get(`subscriptions/${id}`);
|
|
1928
2123
|
}
|
|
1929
|
-
cancel(id) {
|
|
1930
|
-
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 } });
|
|
1931
2126
|
}
|
|
1932
|
-
resume(id) {
|
|
1933
|
-
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`);
|
|
1934
2141
|
}
|
|
1935
2142
|
cancelPlan(team) {
|
|
1936
2143
|
return this.http.post("billing/plans/cancel", { team });
|
|
@@ -2642,6 +2849,8 @@ var JoAiClient = class {
|
|
|
2642
2849
|
const cache = config.cache;
|
|
2643
2850
|
this.http = cache?.enabled !== false ? new CachedHttpService(http, cache?.overrides, cache?.defaultTtl) : http;
|
|
2644
2851
|
this.agents = new AgentsResource(this.http);
|
|
2852
|
+
this.addresses = new AddressesResource(this.http);
|
|
2853
|
+
this.commerce = new CommerceResource(this.http);
|
|
2645
2854
|
this.alerts = new AlertsResource(this.http);
|
|
2646
2855
|
this.apiTokens = new ApiTokensResource(this.http);
|
|
2647
2856
|
this.characters = new CharactersResource(this.http);
|
|
@@ -2652,7 +2861,6 @@ var JoAiClient = class {
|
|
|
2652
2861
|
this.appointments = new AppointmentsResource(this.http, config);
|
|
2653
2862
|
this.auth = new AuthResource(this.http);
|
|
2654
2863
|
this.billing = new BillingResource(this.http);
|
|
2655
|
-
this.billingAddresses = new BillingAddressesResource(this.http);
|
|
2656
2864
|
this.blueprints = new BlueprintsResource(this.http);
|
|
2657
2865
|
this.cards = new CardsResource(this.http);
|
|
2658
2866
|
this.cart = new CartsResource(this.http);
|
|
@@ -2723,6 +2931,69 @@ function createClient(config) {
|
|
|
2723
2931
|
return new JoAiClient(config);
|
|
2724
2932
|
}
|
|
2725
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
|
|
2726
2997
|
//#region src/resources/distribution.ts
|
|
2727
2998
|
const DISTRIBUTION_URLS = {
|
|
2728
2999
|
local: "https://raw.githubusercontent.com/JoAiHQ/warps/refs/heads/dev/catalog/devnet/distribution.json",
|
|
@@ -2751,4 +3022,4 @@ var DistributionResource = class {
|
|
|
2751
3022
|
}
|
|
2752
3023
|
};
|
|
2753
3024
|
//#endregion
|
|
2754
|
-
export { AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource,
|
|
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 };
|