@joai/sdk 7.0.4 → 7.0.6
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 +57 -20
- package/dist/index.mjs +49 -8
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$_joai_core0 from "@joai/core";
|
|
2
|
-
import { Address, AddressCreatePayload, AddressInput, AddressType, AddressUpdatePayload, Affiliate, AffiliateTier, Agent, AgentActionHistoryEntry, AgentPrivate, AgentSettings, AgentTrustedActionRule, AiCostsResponse, Alert, ApiToken, AppEnv, AppIngestion, AppendKvEntryResult, AppointmentAvailability, AppointmentBooking, AppointmentPolicy, AppointmentRequest, Artifact, ArtifactCreatePayload, ArtifactDeliverPayload, ArtifactDelivery, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AuthUser, AuthUser as AuthUser$1, Automation, AutomationActionInput, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationStats, AutomationUpdatePayload, Blueprint, BlueprintSettings, BrandBackend, BrandSiteConfig, BrandSourceConfig, CalendarStatus, Campaign, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignStats, CampaignUpdatePayload, Card, Cart, Cart as Cart$1, ChangelogEntry, Character, CheckoutSnapshot, CheckoutSnapshot as CheckoutSnapshot$1, CheckoutSnapshotRequest, CommissionAgreement, Configuration, Contact, ContactActivity, ContactCreatePayload, ContactFormData, ContactRelation, ContactRelationPayload, ContactRelationUpdatePayload, Content, ContentVersion, Contract, ContractCategoryName, ContractVersion, Coupon, CouponCondition, CouponRestrictedItem, CreateContentInput, CreateHookPayload, CreateHookPayload as CreateHookPayload$1, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, Document, EarnResponse, Element, ElementSpec, ElementVariation, EmbedStatus, Entity, Flow, Fulfillment, FulfillmentLocation, FulfillmentLocation as FulfillmentLocation$1, FulfillmentMethod, GamificationData, Goal, GoalCreatePayload, GuestBuyer, GuestBuyer as GuestBuyer$1, Hook, Hook as Hook$1, HookSample, HookSample as HookSample$1, HookTrigger, HookTriggerCondition, HookTriggerInput, IAppResponse, IHttpService, IRequestOptions, Inquiry, InquiryType, Integration, IntegrationType, Intent, Item, ItemCreatePayload, ItemUpdatePayload, JsonValue, KvEntryPayload, KvField, KvFieldWithEntries, Link, LinkCreatePayload, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LoyaltyAccount, LoyaltyMember, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyTier, LoyaltyTransaction, McpToolCall, Media, MediaAspectRatio, Meeting, MeetingJoinInfo, MeetingSpeakerAssignment, MeetingSummary, Memory, Message, MetricSource, MetricsResult, Mission, MissionCreatePayload, Notification, NotificationChannel, NotificationSetting, OfficeSnapshot, Order, Order as Order$1, OrderContext, OrderPriceMode, OrderPriceMode as OrderPriceMode$1, OrderStatus, OrderStatus as OrderStatus$1, OrderType, PaginatedResponse, Pass, PatchContentInput, PaymentAccount, PaymentAccountOnboarding, PaymentProvider, Plan, PlanFeature, Product, Product as Product$1, ProductRelation, ProductVariation, ProgramSettings, Project, ProjectExportResponse, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectStudioHistoryEntry, Proposal, ProposalAction, ProposalPollOption, PublicFormResults, PurchaseResult, RampProviderInfo, Reactions, RedeemResponse, Reminder, Return, ReturnStatus, Room, RoomKind, Segment, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, Service, SetKvEntryResult, SharedSocialPost, ShippingRate, ShippingRate as ShippingRate$1, ShippingZone, Shortcut, Site, SiteBrand, SiteType, Skill, SkillScopeValue, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreData, StorePriceTier, StorePurchaseResult, Subscription, Swarm, Tag, TagType, Task, Team, TeamAccessConfig, TeamCategory, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureUsage, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPrivate, TeamUsage, TerminalConnectionToken, TerminalPaymentIntent, ToggleKvFieldResult, TranslatableValue, Update, UpdateCreatePayload, UpdateRelation, UpdateStats, UpdateType, UpdateUpdatePayload, Upgrade, UpgradeStatus, UserPrivate, UserRole, UserSettings, VolumePrice, WarpBackend, WarpBackendStatus, WarpExecutionBackend, WebHookTriggerEvent, WorkspaceCloudFile, WorkspaceInfo, XIntegrationStatus } from "@joai/core";
|
|
2
|
+
import { Address, AddressCreatePayload, AddressInput, AddressType, AddressUpdatePayload, Affiliate, AffiliateTier, Agent, AgentActionHistoryEntry, AgentPrivate, AgentSettings, AgentTrustedActionRule, AiCostsResponse, Alert, ApiToken, AppEnv, AppIngestion, AppendKvEntryResult, AppointmentAvailability, AppointmentBooking, AppointmentPolicy, AppointmentRequest, Artifact, ArtifactCreatePayload, ArtifactDeliverPayload, ArtifactDelivery, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AuthUser, AuthUser as AuthUser$1, Automation, AutomationActionInput, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationStats, AutomationUpdatePayload, Blueprint, BlueprintSettings, BrandBackend, BrandSiteConfig, BrandSourceConfig, CalendarStatus, Campaign, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignStats, CampaignUpdatePayload, Card, Cart, Cart as Cart$1, CartLine, ChangelogEntry, Character, CheckoutSnapshot, CheckoutSnapshot as CheckoutSnapshot$1, CheckoutSnapshotRequest, CommissionAgreement, Configuration, Contact, ContactActivity, ContactCreatePayload, ContactFormData, ContactRelation, ContactRelationPayload, ContactRelationUpdatePayload, Content, ContentVersion, Contract, ContractCategoryName, ContractVersion, Coupon, CouponCondition, CouponRestrictedItem, CreateContentInput, CreateHookPayload, CreateHookPayload as CreateHookPayload$1, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, Document, EarnResponse, Element, ElementSpec, ElementVariation, EmbedStatus, Entity, Flow, Fulfillment, FulfillmentLocation, FulfillmentLocation as FulfillmentLocation$1, FulfillmentMethod, GamificationData, Goal, GoalCreatePayload, GuestBuyer, GuestBuyer as GuestBuyer$1, Hook, Hook as Hook$1, HookSample, HookSample as HookSample$1, HookTrigger, HookTriggerCondition, HookTriggerInput, IAppResponse, IHttpService, IRequestOptions, Inquiry, InquiryType, Integration, IntegrationType, Intent, Item, ItemCreatePayload, ItemUpdatePayload, JsonValue, KvEntryPayload, KvField, KvFieldWithEntries, Link, LinkCreatePayload, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LoyaltyAccount, LoyaltyMember, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyTier, LoyaltyTransaction, McpToolCall, Media, MediaAspectRatio, Meeting, MeetingJoinInfo, MeetingSpeakerAssignment, MeetingSummary, Memory, Message, MetricSource, MetricsResult, Mission, MissionCreatePayload, Notification, NotificationChannel, NotificationSetting, OfficeSnapshot, Order, Order as Order$1, OrderContext, OrderPriceMode, OrderPriceMode as OrderPriceMode$1, OrderStatus, OrderStatus as OrderStatus$1, OrderType, PaginatedResponse, Pass, PatchContentInput, PaymentAccount, PaymentAccountOnboarding, PaymentProvider, Plan, PlanFeature, Product, Product as Product$1, ProductRelation, ProductVariation, ProgramSettings, Project, ProjectExportResponse, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectStudioHistoryEntry, Proposal, ProposalAction, ProposalPollOption, PublicFormResults, PurchaseResult, RampProviderInfo, Reactions, RedeemResponse, Reminder, Return, ReturnStatus, Room, RoomKind, Segment, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, Service, SetKvEntryResult, SharedSocialPost, ShippingRate, ShippingRate as ShippingRate$1, ShippingZone, Shortcut, Site, SiteBrand, SiteType, Skill, SkillScopeValue, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreData, StorePriceTier, StorePurchaseResult, Subscription, Swarm, Tag, TagType, Task, Team, TeamAccessConfig, TeamCategory, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureUsage, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPrivate, TeamUsage, TerminalConnectionToken, TerminalPaymentIntent, ToggleKvFieldResult, TranslatableValue, Update, UpdateCreatePayload, UpdateRelation, UpdateStats, UpdateType, UpdateUpdatePayload, Upgrade, UpgradeStatus, UserPrivate, UserRole, UserSettings, VolumePrice, WarpBackend, WarpBackendStatus, WarpExecutionBackend, WebHookTriggerEvent, WorkspaceCloudFile, WorkspaceInfo, XIntegrationStatus } from "@joai/core";
|
|
3
3
|
import { WarpChainName, WarpClient, WarpLocale, WarpText, WarpWalletProvider } from "@joai/warps";
|
|
4
4
|
|
|
5
5
|
//#region src/resources/agents.d.ts
|
|
@@ -71,6 +71,8 @@ declare class AddressesResource {
|
|
|
71
71
|
type PlaceCheckoutOrderRequest = CheckoutSnapshotRequest & {
|
|
72
72
|
guest?: GuestBuyer;
|
|
73
73
|
notes?: string;
|
|
74
|
+
scheduledAt?: string;
|
|
75
|
+
serviceSlug?: string;
|
|
74
76
|
idempotencyKey?: string;
|
|
75
77
|
saveAddresses?: boolean;
|
|
76
78
|
sendConfirmation?: boolean;
|
|
@@ -170,7 +172,7 @@ type ShippingRateInput = {
|
|
|
170
172
|
};
|
|
171
173
|
type FulfillmentLocationInput = {
|
|
172
174
|
name: string;
|
|
173
|
-
addressId?:
|
|
175
|
+
addressId?: string | null;
|
|
174
176
|
instructions?: string | null;
|
|
175
177
|
active?: boolean;
|
|
176
178
|
};
|
|
@@ -186,8 +188,8 @@ declare class ShippingResource {
|
|
|
186
188
|
deleteRate(team: string, zoneId: number, rateId: number): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
187
189
|
locations(team: string): Promise<_$_joai_core0.IAppResponse<FulfillmentLocation$1[]>>;
|
|
188
190
|
createLocation(team: string, data: FulfillmentLocationInput): Promise<_$_joai_core0.IAppResponse<FulfillmentLocation$1>>;
|
|
189
|
-
updateLocation(team: string, locationId:
|
|
190
|
-
deleteLocation(team: string, locationId:
|
|
191
|
+
updateLocation(team: string, locationId: string, data: FulfillmentLocationInput): Promise<_$_joai_core0.IAppResponse<FulfillmentLocation$1>>;
|
|
192
|
+
deleteLocation(team: string, locationId: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
191
193
|
}
|
|
192
194
|
//#endregion
|
|
193
195
|
//#region src/commerce/guest.d.ts
|
|
@@ -199,8 +201,10 @@ type GuestCheckoutDraft<TCart = unknown> = {
|
|
|
199
201
|
cart: TCart;
|
|
200
202
|
fulfillmentMethod: FulfillmentMethod;
|
|
201
203
|
shippingRateId: number | null;
|
|
202
|
-
fulfillmentLocationId:
|
|
203
|
-
couponCode?: string | null;
|
|
204
|
+
fulfillmentLocationId: string | null;
|
|
205
|
+
couponCode?: string | null; /** Pickup appointment start (ISO-8601), required for pickup confirm. */
|
|
206
|
+
scheduledAt?: string | null; /** Bookable service slug when the shop has more than one. */
|
|
207
|
+
serviceSlug?: string | null;
|
|
204
208
|
};
|
|
205
209
|
type GuestCommerceStorageOptions = {
|
|
206
210
|
namespace: string;
|
|
@@ -234,7 +238,7 @@ type GuestCheckoutState<TCart = GuestCheckoutCartItem[]> = GuestCheckoutDraft<TC
|
|
|
234
238
|
identity: GuestBuyer$1;
|
|
235
239
|
address: AddressInput;
|
|
236
240
|
};
|
|
237
|
-
type GuestCheckoutErrorCode = 'empty_cart' | 'missing_identity' | 'missing_pickup_phone' | 'incomplete_shipping_address' | 'pickup_unavailable' | 'missing_shipping_rate' | 'rates_failed' | 'snapshot_failed' | 'review_required' | 'terms_required' | 'review_expired' | 'order_failed' | 'payment_failed';
|
|
241
|
+
type GuestCheckoutErrorCode = 'empty_cart' | 'missing_identity' | 'missing_pickup_phone' | 'missing_scheduled_at' | 'incomplete_shipping_address' | 'pickup_unavailable' | 'missing_shipping_rate' | 'rates_failed' | 'snapshot_failed' | 'review_required' | 'terms_required' | 'review_expired' | 'order_failed' | 'payment_failed';
|
|
238
242
|
declare class GuestCheckoutError extends Error {
|
|
239
243
|
readonly code: GuestCheckoutErrorCode;
|
|
240
244
|
constructor(code: GuestCheckoutErrorCode);
|
|
@@ -260,6 +264,8 @@ type GuestCheckoutClient = {
|
|
|
260
264
|
guest?: GuestBuyer$1;
|
|
261
265
|
idempotencyKey?: string;
|
|
262
266
|
notes?: string;
|
|
267
|
+
scheduledAt?: string;
|
|
268
|
+
serviceSlug?: string;
|
|
263
269
|
sendConfirmation?: boolean;
|
|
264
270
|
}): Promise<IAppResponse<Order$1>>;
|
|
265
271
|
pay(id: string, provider?: PaymentProvider, accessToken?: string): Promise<IAppResponse<{
|
|
@@ -273,10 +279,11 @@ type CreateEmptyGuestCheckoutOptions = {
|
|
|
273
279
|
};
|
|
274
280
|
declare const createEmptyGuestCheckoutState: <TCart = GuestCheckoutCartItem[]>(options?: CreateEmptyGuestCheckoutOptions) => GuestCheckoutState<TCart>;
|
|
275
281
|
declare const toGuestCheckoutDraft: <TCart>(state: GuestCheckoutState<TCart>) => GuestCheckoutDraft<TCart>;
|
|
276
|
-
declare const assertGuestCheckoutReady: (state: GuestCheckoutState, pickupLocationIds?:
|
|
282
|
+
declare const assertGuestCheckoutReady: (state: GuestCheckoutState, pickupLocationIds?: string[]) => void;
|
|
283
|
+
declare const assertGuestPickupSlotReady: (state: GuestCheckoutState) => void;
|
|
277
284
|
declare const buildGuestCheckoutSnapshotRequest: (state: GuestCheckoutState, options?: {
|
|
278
285
|
shippingRates?: ShippingRate$1[];
|
|
279
|
-
pickupLocationIds?:
|
|
286
|
+
pickupLocationIds?: string[];
|
|
280
287
|
}) => CheckoutSnapshotRequest;
|
|
281
288
|
type GuestCheckoutSnapshotResult = {
|
|
282
289
|
snapshot: CheckoutSnapshot$1 & {
|
|
@@ -289,7 +296,7 @@ declare function createGuestCheckoutSnapshot(options: {
|
|
|
289
296
|
client: GuestCheckoutClient;
|
|
290
297
|
team: string;
|
|
291
298
|
state: GuestCheckoutState;
|
|
292
|
-
pickupLocationIds?:
|
|
299
|
+
pickupLocationIds?: string[];
|
|
293
300
|
shippingRates?: ShippingRate$1[];
|
|
294
301
|
}): Promise<GuestCheckoutSnapshotResult>;
|
|
295
302
|
type PlaceGuestCheckoutOrderResult = {
|
|
@@ -317,6 +324,8 @@ declare function placeGuestCheckoutOrder(options: {
|
|
|
317
324
|
guest: GuestBuyer$1;
|
|
318
325
|
acceptedTerms?: boolean;
|
|
319
326
|
notes?: string;
|
|
327
|
+
scheduledAt?: string;
|
|
328
|
+
serviceSlug?: string;
|
|
320
329
|
idempotencyKey?: string;
|
|
321
330
|
pay?: boolean;
|
|
322
331
|
}): Promise<PlaceGuestCheckoutOrderResult>;
|
|
@@ -350,6 +359,16 @@ type GuestCouponClient = {
|
|
|
350
359
|
/** First `couponCode` validation message from an API error payload. */
|
|
351
360
|
declare const guestCouponMessageFromErrors: (errors: unknown) => string | undefined;
|
|
352
361
|
declare const isGuestCouponError: (error: unknown) => error is GuestCouponError;
|
|
362
|
+
type GuestCartAmounts = {
|
|
363
|
+
subtotal: number;
|
|
364
|
+
discount: number;
|
|
365
|
+
total: number;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Merchandise subtotal, coupon discount, and payable total (cents) for a guest cart.
|
|
369
|
+
* Pass the validated preview (or null) so discount and total stay in sync.
|
|
370
|
+
*/
|
|
371
|
+
declare const guestCartAmounts: <T extends CartLine>(cart: T[], preview?: GuestCouponPreview | null) => GuestCartAmounts;
|
|
353
372
|
/**
|
|
354
373
|
* Validates a guest coupon against cart lines. Throws {@link GuestCouponError} when the
|
|
355
374
|
* code is empty, the cart is empty, the API rejects it, or the preview discount is ≤ 0
|
|
@@ -381,6 +400,9 @@ declare function revalidateGuestCoupon(options: {
|
|
|
381
400
|
items: GuestCheckoutCartItem[];
|
|
382
401
|
}): Promise<RevalidateGuestCouponResult>;
|
|
383
402
|
//#endregion
|
|
403
|
+
//#region src/commerce/pickupSlotLabel.d.ts
|
|
404
|
+
declare const formatPickupSlotLabel: (iso: string, locale: string, timeZone: string) => string;
|
|
405
|
+
//#endregion
|
|
384
406
|
//#region src/commerce/index.d.ts
|
|
385
407
|
declare class CommerceResource {
|
|
386
408
|
readonly checkout: CheckoutResource;
|
|
@@ -869,16 +891,23 @@ declare class ContractsResource {
|
|
|
869
891
|
declare class DocumentsResource {
|
|
870
892
|
private readonly http;
|
|
871
893
|
constructor(http: IHttpService);
|
|
872
|
-
list(agent: string,
|
|
894
|
+
list(agent: string, params?: {
|
|
895
|
+
search?: string;
|
|
896
|
+
archived?: boolean;
|
|
897
|
+
}): Promise<_$_joai_core0.IAppResponse<Document[]>>;
|
|
873
898
|
create(agent: string, data: {
|
|
874
899
|
title: string;
|
|
875
900
|
content: string;
|
|
876
901
|
blueprint?: string;
|
|
877
902
|
}): Promise<_$_joai_core0.IAppResponse<Document>>;
|
|
878
903
|
get(id: string): Promise<_$_joai_core0.IAppResponse<Document>>;
|
|
904
|
+
getShared(slug: string): Promise<_$_joai_core0.IAppResponse<Document>>;
|
|
879
905
|
update(id: string, data: {
|
|
880
906
|
title?: string;
|
|
881
907
|
content?: string;
|
|
908
|
+
public?: boolean;
|
|
909
|
+
archived?: boolean;
|
|
910
|
+
meta?: Record<string, unknown>;
|
|
882
911
|
}): Promise<_$_joai_core0.IAppResponse<Document>>;
|
|
883
912
|
delete(id: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
884
913
|
trainFromUrl(agent: string, url: string): Promise<_$_joai_core0.IAppResponse<Document>>;
|
|
@@ -1031,12 +1060,17 @@ declare class IntentsResource {
|
|
|
1031
1060
|
}
|
|
1032
1061
|
//#endregion
|
|
1033
1062
|
//#region src/resources/items.d.ts
|
|
1063
|
+
type ItemListParams = {
|
|
1064
|
+
status?: string;
|
|
1065
|
+
priority?: string;
|
|
1066
|
+
dueToday?: boolean;
|
|
1067
|
+
scope?: 'mine' | 'all';
|
|
1068
|
+
tag?: string;
|
|
1069
|
+
};
|
|
1034
1070
|
declare class ItemsResource {
|
|
1035
1071
|
private readonly http;
|
|
1036
1072
|
constructor(http: IHttpService);
|
|
1037
|
-
list(params?:
|
|
1038
|
-
status?: string;
|
|
1039
|
-
}): Promise<_$_joai_core0.IAppResponse<Item[]>>;
|
|
1073
|
+
list(params?: ItemListParams): Promise<_$_joai_core0.IAppResponse<Item[]>>;
|
|
1040
1074
|
get(id: string): Promise<_$_joai_core0.IAppResponse<Item>>;
|
|
1041
1075
|
create(payload: ItemCreatePayload): Promise<_$_joai_core0.IAppResponse<Item>>;
|
|
1042
1076
|
update(id: string, data: ItemUpdatePayload): Promise<_$_joai_core0.IAppResponse<Item>>;
|
|
@@ -1358,18 +1392,21 @@ declare class OrdersResource {
|
|
|
1358
1392
|
fulfillmentMethod?: FulfillmentMethod;
|
|
1359
1393
|
snapshotId?: string;
|
|
1360
1394
|
snapshotAccessToken?: string;
|
|
1361
|
-
billingAddressId?:
|
|
1362
|
-
shippingAddressId?:
|
|
1395
|
+
billingAddressId?: string;
|
|
1396
|
+
shippingAddressId?: string;
|
|
1363
1397
|
billingAddress?: AddressInput;
|
|
1364
1398
|
shippingAddress?: AddressInput;
|
|
1365
1399
|
shippingRateId?: number;
|
|
1366
|
-
fulfillmentLocationId?:
|
|
1400
|
+
fulfillmentLocationId?: string;
|
|
1367
1401
|
idempotencyKey?: string;
|
|
1368
1402
|
guest?: {
|
|
1369
1403
|
name: string;
|
|
1370
1404
|
email: string;
|
|
1371
1405
|
phone?: string;
|
|
1372
1406
|
};
|
|
1407
|
+
scheduledAt?: string;
|
|
1408
|
+
serviceSlug?: string;
|
|
1409
|
+
couponCode?: string;
|
|
1373
1410
|
}): Promise<_$_joai_core0.IAppResponse<Order$1>>;
|
|
1374
1411
|
update(id: string, data: {
|
|
1375
1412
|
status?: OrderStatus$1;
|
|
@@ -1687,9 +1724,9 @@ declare class SubscriptionsResource {
|
|
|
1687
1724
|
resume(id: string, team: string): Promise<_$_joai_core0.IAppResponse<Subscription>>;
|
|
1688
1725
|
updateDelivery(id: string, data: {
|
|
1689
1726
|
fulfillmentMethod: 'shipping' | 'pickup';
|
|
1690
|
-
shippingAddressId?:
|
|
1727
|
+
shippingAddressId?: string | null;
|
|
1691
1728
|
shippingRateId?: number | null;
|
|
1692
|
-
fulfillmentLocationId?:
|
|
1729
|
+
fulfillmentLocationId?: string | null;
|
|
1693
1730
|
}): Promise<_$_joai_core0.IAppResponse<Subscription>>;
|
|
1694
1731
|
skip(id: string): Promise<_$_joai_core0.IAppResponse<Subscription>>;
|
|
1695
1732
|
pause(id: string): Promise<_$_joai_core0.IAppResponse<Subscription>>;
|
|
@@ -2322,4 +2359,4 @@ declare class DistributionResource {
|
|
|
2322
2359
|
private fetchDistribution;
|
|
2323
2360
|
}
|
|
2324
2361
|
//#endregion
|
|
2325
|
-
export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type AuthUser, AutomationsResource, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, type Cart, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, type CheckoutSnapshot, CommerceResource, ContactsResource, ContentResource, ContractsResource, type CreateEmptyGuestCheckoutOptions, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, type FulfillmentLocation, type FulfillmentLocationInput, FulfillmentsResource, GoalsResource, type GuestBuyer, type GuestCheckoutCartItem, type GuestCheckoutClient, type GuestCheckoutDraft, GuestCheckoutError, type GuestCheckoutErrorCode, type GuestCheckoutSnapshotResult, type GuestCheckoutState, type GuestCommerceStorage, type GuestCommerceStorageOptions, type GuestCouponClient, GuestCouponError, type GuestCouponErrorCode, type GuestCouponPreview, 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, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, type Order, type OrderPriceMode, type OrderStatus, OrdersResource, PersonaResource, type PlaceCheckoutOrderRequest, type PlaceGuestCheckoutOrderResult, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, type RevalidateGuestCouponResult, SegmentsResource, ServicesResource, type ShippingRate, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, assertGuestCheckoutReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, validateGuestCoupon };
|
|
2362
|
+
export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type AuthUser, AutomationsResource, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, type Cart, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, type CheckoutSnapshot, CommerceResource, ContactsResource, ContentResource, ContractsResource, type CreateEmptyGuestCheckoutOptions, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, type FulfillmentLocation, type FulfillmentLocationInput, FulfillmentsResource, GoalsResource, type GuestBuyer, type GuestCartAmounts, type GuestCheckoutCartItem, type GuestCheckoutClient, type GuestCheckoutDraft, GuestCheckoutError, type GuestCheckoutErrorCode, type GuestCheckoutSnapshotResult, type GuestCheckoutState, type GuestCommerceStorage, type GuestCommerceStorageOptions, type GuestCouponClient, GuestCouponError, type GuestCouponErrorCode, type GuestCouponPreview, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, type ItemListParams, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, type Order, type OrderPriceMode, type OrderStatus, OrdersResource, PersonaResource, type PlaceCheckoutOrderRequest, type PlaceGuestCheckoutOrderResult, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, type RevalidateGuestCouponResult, SegmentsResource, ServicesResource, type ShippingRate, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, validateGuestCoupon };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpService, getApiBaseUrl, isCompleteAddressInput } from "@joai/core";
|
|
1
|
+
import { HttpService, cartLineTotal, cartPayableTotal, getApiBaseUrl, isCompleteAddressInput } from "@joai/core";
|
|
2
2
|
import { WarpClient } from "@joai/warps";
|
|
3
3
|
//#region src/resources/agents.ts
|
|
4
4
|
var AgentsResource = class {
|
|
@@ -390,14 +390,18 @@ const createEmptyGuestCheckoutState = (options = {}) => ({
|
|
|
390
390
|
},
|
|
391
391
|
shippingRateId: null,
|
|
392
392
|
fulfillmentLocationId: null,
|
|
393
|
-
couponCode: null
|
|
393
|
+
couponCode: null,
|
|
394
|
+
scheduledAt: null,
|
|
395
|
+
serviceSlug: null
|
|
394
396
|
});
|
|
395
397
|
const toGuestCheckoutDraft = (state) => ({
|
|
396
398
|
cart: state.cart,
|
|
397
399
|
fulfillmentMethod: state.fulfillmentMethod,
|
|
398
400
|
shippingRateId: state.shippingRateId,
|
|
399
401
|
fulfillmentLocationId: state.fulfillmentLocationId,
|
|
400
|
-
couponCode: state.couponCode ?? null
|
|
402
|
+
couponCode: state.couponCode ?? null,
|
|
403
|
+
scheduledAt: state.scheduledAt ?? null,
|
|
404
|
+
serviceSlug: state.serviceSlug ?? null
|
|
401
405
|
});
|
|
402
406
|
const assertGuestCheckoutReady = (state, pickupLocationIds = []) => {
|
|
403
407
|
if (!state.cart.length) throw new GuestCheckoutError("empty_cart");
|
|
@@ -410,6 +414,9 @@ const assertGuestCheckoutReady = (state, pickupLocationIds = []) => {
|
|
|
410
414
|
if (state.fulfillmentMethod === "shipping" && !isCompleteAddressInput(address)) throw new GuestCheckoutError("incomplete_shipping_address");
|
|
411
415
|
if (state.fulfillmentMethod === "pickup" && !state.fulfillmentLocationId && !pickupLocationIds[0]) throw new GuestCheckoutError("pickup_unavailable");
|
|
412
416
|
};
|
|
417
|
+
const assertGuestPickupSlotReady = (state) => {
|
|
418
|
+
if (state.fulfillmentMethod === "pickup" && !state.scheduledAt?.trim()) throw new GuestCheckoutError("missing_scheduled_at");
|
|
419
|
+
};
|
|
413
420
|
const buildGuestCheckoutSnapshotRequest = (state, options = {}) => {
|
|
414
421
|
assertGuestCheckoutReady(state, options.pickupLocationIds ?? []);
|
|
415
422
|
const items = state.cart.map(({ id, type, quantity }) => ({
|
|
@@ -507,6 +514,8 @@ async function placeGuestCheckoutOrder(options) {
|
|
|
507
514
|
guest: options.guest,
|
|
508
515
|
idempotencyKey: options.idempotencyKey ?? crypto.randomUUID(),
|
|
509
516
|
notes: options.notes,
|
|
517
|
+
scheduledAt: options.scheduledAt,
|
|
518
|
+
serviceSlug: options.serviceSlug,
|
|
510
519
|
sendConfirmation: true
|
|
511
520
|
});
|
|
512
521
|
if (!order.ok || !order.data?.id) throw new GuestCheckoutError("order_failed");
|
|
@@ -560,6 +569,19 @@ const toCheckoutItems = (items) => items.map(({ id, type, quantity }) => ({
|
|
|
560
569
|
quantity
|
|
561
570
|
}));
|
|
562
571
|
/**
|
|
572
|
+
* Merchandise subtotal, coupon discount, and payable total (cents) for a guest cart.
|
|
573
|
+
* Pass the validated preview (or null) so discount and total stay in sync.
|
|
574
|
+
*/
|
|
575
|
+
const guestCartAmounts = (cart, preview) => {
|
|
576
|
+
const subtotal = cartLineTotal(cart);
|
|
577
|
+
const discount = Math.max(0, preview?.discount ?? 0);
|
|
578
|
+
return {
|
|
579
|
+
subtotal,
|
|
580
|
+
discount,
|
|
581
|
+
total: cartPayableTotal(cart, discount)
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
563
585
|
* Validates a guest coupon against cart lines. Throws {@link GuestCouponError} when the
|
|
564
586
|
* code is empty, the cart is empty, the API rejects it, or the preview discount is ≤ 0
|
|
565
587
|
* (never treat a no-effect coupon as applied).
|
|
@@ -605,6 +627,16 @@ async function revalidateGuestCoupon(options) {
|
|
|
605
627
|
}
|
|
606
628
|
}
|
|
607
629
|
//#endregion
|
|
630
|
+
//#region src/commerce/pickupSlotLabel.ts
|
|
631
|
+
const formatPickupSlotLabel = (iso, locale, timeZone) => new Intl.DateTimeFormat(locale, {
|
|
632
|
+
timeZone,
|
|
633
|
+
weekday: "short",
|
|
634
|
+
day: "numeric",
|
|
635
|
+
month: "short",
|
|
636
|
+
hour: "2-digit",
|
|
637
|
+
minute: "2-digit"
|
|
638
|
+
}).format(new Date(iso));
|
|
639
|
+
//#endregion
|
|
608
640
|
//#region src/commerce/index.ts
|
|
609
641
|
var CommerceResource = class {
|
|
610
642
|
constructor(http) {
|
|
@@ -1320,10 +1352,12 @@ var DocumentsResource = class {
|
|
|
1320
1352
|
constructor(http) {
|
|
1321
1353
|
this.http = http;
|
|
1322
1354
|
}
|
|
1323
|
-
list(agent,
|
|
1324
|
-
const
|
|
1325
|
-
if (search)
|
|
1326
|
-
|
|
1355
|
+
list(agent, params) {
|
|
1356
|
+
const query = new URLSearchParams();
|
|
1357
|
+
if (params?.search) query.set("search", params.search);
|
|
1358
|
+
if (params?.archived) query.set("archived", "1");
|
|
1359
|
+
const qs = query.toString();
|
|
1360
|
+
return this.http.get(`agents/${agent}/documents${qs ? `?${qs}` : ""}`);
|
|
1327
1361
|
}
|
|
1328
1362
|
create(agent, data) {
|
|
1329
1363
|
return this.http.post(`agents/${agent}/documents`, data);
|
|
@@ -1331,6 +1365,9 @@ var DocumentsResource = class {
|
|
|
1331
1365
|
get(id) {
|
|
1332
1366
|
return this.http.get(`documents/${id}`);
|
|
1333
1367
|
}
|
|
1368
|
+
getShared(slug) {
|
|
1369
|
+
return this.http.get(`documents/shared/${encodeURIComponent(slug)}`);
|
|
1370
|
+
}
|
|
1334
1371
|
update(id, data) {
|
|
1335
1372
|
return this.http.put(`documents/${id}`, data);
|
|
1336
1373
|
}
|
|
@@ -1537,6 +1574,10 @@ var ItemsResource = class {
|
|
|
1537
1574
|
list(params) {
|
|
1538
1575
|
const query = new URLSearchParams();
|
|
1539
1576
|
if (params?.status) query.set("status", params.status);
|
|
1577
|
+
if (params?.priority) query.set("priority", params.priority);
|
|
1578
|
+
if (params?.dueToday) query.set("dueToday", "1");
|
|
1579
|
+
if (params?.scope) query.set("scope", params.scope);
|
|
1580
|
+
if (params?.tag) query.set("tag", params.tag);
|
|
1540
1581
|
const qs = query.toString();
|
|
1541
1582
|
return this.http.get(`items${qs ? "?" + qs : ""}`);
|
|
1542
1583
|
}
|
|
@@ -3520,4 +3561,4 @@ var DistributionResource = class {
|
|
|
3520
3561
|
}
|
|
3521
3562
|
};
|
|
3522
3563
|
//#endregion
|
|
3523
|
-
export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource, AutomationsResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, GuestCheckoutError, GuestCouponError, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, assertGuestCheckoutReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, validateGuestCoupon };
|
|
3564
|
+
export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource, AutomationsResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, GuestCheckoutError, GuestCouponError, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, validateGuestCoupon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joai/sdk",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"description": "JoAi public API SDK — build with your AI agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"test": "jest --config jest.config.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@joai/core": "^4.15.
|
|
38
|
+
"@joai/core": "^4.15.5",
|
|
39
39
|
"@joai/warps": "*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@joai/core": "^4.15.
|
|
42
|
+
"@joai/core": "^4.15.5"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsdown": "^0.21.0",
|