@joai/sdk 7.0.2 → 7.0.4

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
@@ -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, 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, 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
@@ -322,6 +322,65 @@ declare function placeGuestCheckoutOrder(options: {
322
322
  }): Promise<PlaceGuestCheckoutOrderResult>;
323
323
  declare const isGuestCheckoutError: (error: unknown) => error is GuestCheckoutError;
324
324
  //#endregion
325
+ //#region src/commerce/guestCoupon.d.ts
326
+ type GuestCouponPreview = {
327
+ code: string;
328
+ discount: number;
329
+ eligibleSubtotal: number;
330
+ };
331
+ type GuestCouponErrorCode = 'empty_code' | 'empty_cart' | 'invalid' | 'not_applicable';
332
+ declare class GuestCouponError extends Error {
333
+ readonly code: GuestCouponErrorCode;
334
+ /** Localized API message when present. */
335
+ readonly serverMessage?: string | undefined;
336
+ constructor(code: GuestCouponErrorCode, /** Localized API message when present. */
337
+
338
+ serverMessage?: string | undefined);
339
+ }
340
+ type GuestCouponClient = {
341
+ commerce: {
342
+ checkout: {
343
+ validateCoupon(team: string, data: {
344
+ couponCode: string;
345
+ items: GuestCheckoutCartItem[];
346
+ }): Promise<IAppResponse<GuestCouponPreview>>;
347
+ };
348
+ };
349
+ };
350
+ /** First `couponCode` validation message from an API error payload. */
351
+ declare const guestCouponMessageFromErrors: (errors: unknown) => string | undefined;
352
+ declare const isGuestCouponError: (error: unknown) => error is GuestCouponError;
353
+ /**
354
+ * Validates a guest coupon against cart lines. Throws {@link GuestCouponError} when the
355
+ * code is empty, the cart is empty, the API rejects it, or the preview discount is ≤ 0
356
+ * (never treat a no-effect coupon as applied).
357
+ */
358
+ declare function validateGuestCoupon(options: {
359
+ client: GuestCouponClient;
360
+ team: string;
361
+ couponCode: string;
362
+ items: GuestCheckoutCartItem[];
363
+ }): Promise<GuestCouponPreview>;
364
+ type RevalidateGuestCouponResult = {
365
+ status: 'none';
366
+ } | {
367
+ status: 'applied';
368
+ preview: GuestCouponPreview;
369
+ } | {
370
+ status: 'rejected';
371
+ error: GuestCouponError;
372
+ };
373
+ /**
374
+ * Re-checks a stored coupon against the current cart (hydrate / cart sync).
375
+ * Never throws — use `status` to clear or re-apply the draft code.
376
+ */
377
+ declare function revalidateGuestCoupon(options: {
378
+ client: GuestCouponClient;
379
+ team: string;
380
+ couponCode?: string | null;
381
+ items: GuestCheckoutCartItem[];
382
+ }): Promise<RevalidateGuestCouponResult>;
383
+ //#endregion
325
384
  //#region src/commerce/index.d.ts
326
385
  declare class CommerceResource {
327
386
  readonly checkout: CheckoutResource;
@@ -1877,6 +1936,9 @@ declare class SocialPostsResource {
1877
1936
  schedule(id: string, scheduledAt?: string | null): Promise<_$_joai_core0.IAppResponse<SocialPost>>;
1878
1937
  cancel(id: string): Promise<_$_joai_core0.IAppResponse<SocialPost>>;
1879
1938
  retry(id: string): Promise<_$_joai_core0.IAppResponse<SocialPost>>;
1939
+ share(id: string): Promise<_$_joai_core0.IAppResponse<SocialPost>>;
1940
+ revokeShare(id: string): Promise<_$_joai_core0.IAppResponse<SocialPost>>;
1941
+ getShared(token: string): Promise<_$_joai_core0.IAppResponse<SharedSocialPost>>;
1880
1942
  delete(id: string): Promise<_$_joai_core0.IAppResponse<void>>;
1881
1943
  }
1882
1944
  //#endregion
@@ -2106,6 +2168,7 @@ interface JoAiClientConfig {
2106
2168
  apiToken?: string;
2107
2169
  team?: string;
2108
2170
  env?: AppEnv;
2171
+ locale?: string;
2109
2172
  agentAuthKey?: string;
2110
2173
  cache?: CacheConfig;
2111
2174
  buildSecret?: string;
@@ -2259,4 +2322,4 @@ declare class DistributionResource {
2259
2322
  private fetchDistribution;
2260
2323
  }
2261
2324
  //#endregion
2262
- 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 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, 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, isAllowedRedirectUrl, isGuestCheckoutError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft };
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 };
package/dist/index.mjs CHANGED
@@ -534,6 +534,77 @@ const isGuestCheckoutError = (error) => {
534
534
  return typeof error === "object" && error !== null && error.name === "GuestCheckoutError" && typeof error.code === "string";
535
535
  };
536
536
  //#endregion
537
+ //#region src/commerce/guestCoupon.ts
538
+ var GuestCouponError = class extends Error {
539
+ constructor(code, serverMessage) {
540
+ super(serverMessage ?? code);
541
+ this.code = code;
542
+ this.serverMessage = serverMessage;
543
+ this.name = "GuestCouponError";
544
+ }
545
+ };
546
+ /** First `couponCode` validation message from an API error payload. */
547
+ const guestCouponMessageFromErrors = (errors) => {
548
+ if (!errors || typeof errors !== "object" || Array.isArray(errors)) return void 0;
549
+ const couponError = errors.couponCode;
550
+ if (Array.isArray(couponError) && typeof couponError[0] === "string") return couponError[0];
551
+ if (typeof couponError === "string") return couponError;
552
+ };
553
+ const isGuestCouponError = (error) => {
554
+ if (error instanceof GuestCouponError) return true;
555
+ return typeof error === "object" && error !== null && error.name === "GuestCouponError" && typeof error.code === "string";
556
+ };
557
+ const toCheckoutItems = (items) => items.map(({ id, type, quantity }) => ({
558
+ id,
559
+ type,
560
+ quantity
561
+ }));
562
+ /**
563
+ * Validates a guest coupon against cart lines. Throws {@link GuestCouponError} when the
564
+ * code is empty, the cart is empty, the API rejects it, or the preview discount is ≤ 0
565
+ * (never treat a no-effect coupon as applied).
566
+ */
567
+ async function validateGuestCoupon(options) {
568
+ const code = options.couponCode.trim();
569
+ if (!code) throw new GuestCouponError("empty_code");
570
+ if (!options.items.length) throw new GuestCouponError("empty_cart");
571
+ const response = await options.client.commerce.checkout.validateCoupon(options.team, {
572
+ couponCode: code,
573
+ items: toCheckoutItems(options.items)
574
+ });
575
+ if (!response.ok || !response.data?.code) throw new GuestCouponError("invalid", guestCouponMessageFromErrors(response.errors));
576
+ if (response.data.discount <= 0) throw new GuestCouponError("not_applicable", guestCouponMessageFromErrors(response.errors));
577
+ return response.data;
578
+ }
579
+ /**
580
+ * Re-checks a stored coupon against the current cart (hydrate / cart sync).
581
+ * Never throws — use `status` to clear or re-apply the draft code.
582
+ */
583
+ async function revalidateGuestCoupon(options) {
584
+ const code = options.couponCode?.trim();
585
+ if (!code || !options.items.length) return { status: "none" };
586
+ try {
587
+ return {
588
+ status: "applied",
589
+ preview: await validateGuestCoupon({
590
+ client: options.client,
591
+ team: options.team,
592
+ couponCode: code,
593
+ items: options.items
594
+ })
595
+ };
596
+ } catch (error) {
597
+ if (isGuestCouponError(error)) return {
598
+ status: "rejected",
599
+ error
600
+ };
601
+ return {
602
+ status: "rejected",
603
+ error: new GuestCouponError("invalid")
604
+ };
605
+ }
606
+ }
607
+ //#endregion
537
608
  //#region src/commerce/index.ts
538
609
  var CommerceResource = class {
539
610
  constructor(http) {
@@ -2785,6 +2856,15 @@ var SocialPostsResource = class {
2785
2856
  retry(id) {
2786
2857
  return this.http.post(`social-posts/${id}/retry`, {});
2787
2858
  }
2859
+ share(id) {
2860
+ return this.http.post(`social-posts/${id}/share`, {});
2861
+ }
2862
+ revokeShare(id) {
2863
+ return this.http.delete(`social-posts/${id}/share`);
2864
+ }
2865
+ getShared(token) {
2866
+ return this.http.get(`social-posts/shared/${token}`);
2867
+ }
2788
2868
  delete(id) {
2789
2869
  return this.http.delete(`social-posts/${id}`);
2790
2870
  }
@@ -3251,6 +3331,7 @@ var JoAiClient = class {
3251
3331
  const apiBaseUrl = getApiBaseUrl(config.env ?? "mainnet");
3252
3332
  const headers = {};
3253
3333
  if (config.team) headers["X-Team"] = config.team;
3334
+ if (config.locale) headers["Accept-Language"] = config.locale;
3254
3335
  if (config.agentAuthKey) headers["X-Agent-Auth-Key"] = config.agentAuthKey;
3255
3336
  if (config.buildSecret) headers["X-Build-Secret"] = config.buildSecret;
3256
3337
  const http = new HttpService(`${apiBaseUrl}/v1`, void 0, config.apiToken, {
@@ -3439,4 +3520,4 @@ var DistributionResource = class {
3439
3520
  }
3440
3521
  };
3441
3522
  //#endregion
3442
- 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, 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, isAllowedRedirectUrl, isGuestCheckoutError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/sdk",
3
- "version": "7.0.2",
3
+ "version": "7.0.4",
4
4
  "description": "JoAi public API SDK — build with your AI agents",
5
5
  "license": "MIT",
6
6
  "type": "module",