@joai/sdk 14.0.4 → 14.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/README.md +26 -2
- package/dist/index.d.mts +109 -2
- package/dist/index.mjs +191 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -95,9 +95,9 @@ Set `compression: false` or `dimensions: false` to disable only that stage, or `
|
|
|
95
95
|
|
|
96
96
|
## Session storage
|
|
97
97
|
|
|
98
|
-
`useContentSession` and `createSessionTokenStore` are exported for custom shells. A custom `SessionTokenStore` can be injected when a host needs a different persistence mechanism. The
|
|
98
|
+
`useContentSession` and `createSessionTokenStore` are exported for custom shells. A custom `SessionTokenStore` can be injected when a host needs a different persistence mechanism. The one-time authorization code is removed from the URL before the session token is persisted.
|
|
99
99
|
|
|
100
|
-
The managed editor
|
|
100
|
+
The managed editor starts the app authorization-code flow for reauthentication and stores the PKCE secret in local storage. Override `reauthenticateUrl` only when a host has a dedicated login callback.
|
|
101
101
|
|
|
102
102
|
`createContentDraftStore` uses `sessionStorage` by default. `ManagedContentEditor` wires it automatically so unsaved values survive refreshes and expired-session reauthentication without being shared across browser sessions.
|
|
103
103
|
|
|
@@ -113,3 +113,27 @@ The managed editor automatically adds `platform=app` to its reauthentication ret
|
|
|
113
113
|
- Expired authorization offers a sign-in action and restores locally persisted edits afterwards.
|
|
114
114
|
- Version conflicts load the latest version while preserving local edits.
|
|
115
115
|
- Public content cache entries are invalidated after authenticated mutations.
|
|
116
|
+
|
|
117
|
+
## App authorization code
|
|
118
|
+
|
|
119
|
+
Apps that keep the bearer token on their server can use the SDK's PKCE helpers instead of implementing the flow themselves:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
import { createAppAuthRequest, exchangeAppAuthCode } from '@joai/sdk'
|
|
123
|
+
|
|
124
|
+
const auth = await createAppAuthRequest({
|
|
125
|
+
callbackUrl: 'https://app.example/api/auth/callback',
|
|
126
|
+
team: 'team-slug',
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// Store auth.state and auth.codeVerifier in a short-lived HttpOnly cookie,
|
|
130
|
+
// then redirect the browser to auth.url.
|
|
131
|
+
|
|
132
|
+
const response = await exchangeAppAuthCode({
|
|
133
|
+
code: callbackCode,
|
|
134
|
+
redirectUri: auth.redirectUri,
|
|
135
|
+
codeVerifier: storedVerifier,
|
|
136
|
+
})
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The callback origin must be registered for the team. The code is single-use, short-lived, bound to the canonical `redirectUri`, and verified with PKCE `S256`.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$_joai_core0 from "@joai/core";
|
|
2
|
-
import { Address, AddressCreatePayload, AddressInput, AddressInput as AddressInput$1, AddressType, AddressUpdatePayload, Affiliate, AffiliateTier, Agent, AgentActionHistoryEntry, AgentPrivate, AgentSettings, AgentTrustedActionRule, AiCostsResponse, Alert, AnalyticsConfiguration, ApiToken, AppEnv, AppEnv as AppEnv$1, AppIngestion, AppendKvEntryResult, AppointmentAvailability, AppointmentAvailabilitySlot, AppointmentBooking, AppointmentPolicy, AppointmentPolicyUpsert, AppointmentRequest, Artifact, ArtifactCreatePayload, ArtifactDeliverPayload, ArtifactDelivery, ArtifactDeliveryPreview, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AuthUser, AuthUser as AuthUser$1, Automation, AutomationActionInput, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationStats, AutomationUpdatePayload, Blueprint, BlueprintSettings, BrandBackend, BrandSiteConfig, BrandSourceConfig, CalendarFeed, CalendarFeedInput, CalendarFeedSyncResult, CalendarStatus, Campaign, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignSendTestDraftPayload, CampaignStats, CampaignUpdatePayload, Card, Cart, Cart as Cart$1, CartItem, CartLine, ChangelogEntry, Character, CheckoutSnapshot, CheckoutSnapshot as CheckoutSnapshot$1, CheckoutSnapshotRequest, CheckoutSnapshotRequest as CheckoutSnapshotRequest$1, ClientProposal, CommissionAgreement, Configuration, Contact, ContactActivity, ContactCreatePayload, ContactFormData, ContactRelation, ContactRelationPayload, ContactRelationUpdatePayload, Content, ContentValue, ContentVersion, Contract, ContractCategoryName, ContractVersion, Coupon, CouponCondition, CouponRestrictedItem, CreateContentInput, CreateHookPayload, CreateHookPayload as CreateHookPayload$1, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, Document, EarnResponse, Element, ElementSpec, ElementType, ElementVariation, EmbedStatus, Entity, Flow, FollowListParams, FollowPayload, Fulfillment, FulfillmentLocation, FulfillmentLocation as FulfillmentLocation$1, FulfillmentMethod, GamificationData, Goal, GoalCreatePayload, GuestBuyer, GuestBuyer as GuestBuyer$1, HashidInput, HashidInput as HashidInput$1, Hook, Hook as Hook$1, HookSample, HookSample as HookSample$1, HookTrigger, HookTriggerCondition, HookTriggerInput, IAppResponse, IAppResponse as IAppResponse$1, IHttpService, IRequestOptions, IdentifiedSiteEvent, Inquiry, InquiryType, Install, InstallClaimPayload, InstallOptOutPayload, InstallRegisterPayload, Integration, IntegrationType, Intent, Item, ItemCreatePayload, ItemUpdatePayload, JsonValue, KvEntryPayload, KvField, KvFieldWithEntries, Link, LinkCreatePayload, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LoyaltyAccount, LoyaltyCollectPointInput, LoyaltyCollectResponse, LoyaltyJoinResponse, LoyaltyMember, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyTier, LoyaltyTransaction, LoyaltyWalletAccount, 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, ProductDetailSection, ProductDetailSection as ProductDetailSection$1, ProductDetailText, ProductRelation, ProductRelationType, ProductVariation, ProductVariationExternalReference, ProductVariationExternalSource, ProgramSettings, Project, ProjectExportResponse, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectStudioHistoryEntry, Proposal, ProposalAction, ProposalCreateInput, ProposalPollOption, ProposalPricing, ProposalStats, ProposalUpdateInput, PublicFormResults, PurchaseResult, RampProviderInfo, Reactions, RedeemResponse, Reminder, Return, ReturnStatus, Room, RoomKind, Segment, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, Service, SetKvEntryResult, SharedArtifact, SharedProposal, SharedSocialPost, ShippingCarrierOption, ShippingRate, ShippingRate as ShippingRate$1, ShippingZone, Shortcut, Site, SiteBrand, SiteType, SiteUptime, Skill, SkillScopeValue, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostScheduleSlot, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreData, StorePriceTier, StorePurchaseResult, Subscription, Swarm, Tag, TagType, Task, TaxClass, Team, TeamAccessConfig, TeamCategory, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureUsage, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPrivate, TeamSubscriptionStats, TeamUsage, TemplateMode, TemplateOverrides, TemplateSpec, TerminalConnectionToken, TerminalPaymentIntent, ToggleKvFieldResult, TranslatableValue, TranslatableValue as TranslatableValue$1, 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, AddressInput as AddressInput$1, AddressType, AddressUpdatePayload, Affiliate, AffiliateTier, Agent, AgentActionHistoryEntry, AgentPrivate, AgentSettings, AgentTrustedActionRule, AiCostsResponse, Alert, AnalyticsConfiguration, ApiToken, AppEnv, AppEnv as AppEnv$1, AppIngestion, AppendKvEntryResult, AppointmentAvailability, AppointmentAvailabilitySlot, AppointmentBooking, AppointmentPolicy, AppointmentPolicyUpsert, AppointmentRequest, Artifact, ArtifactCreatePayload, ArtifactDeliverPayload, ArtifactDelivery, ArtifactDeliveryPreview, ArtifactStatus, ArtifactType, ArtifactUpdatePayload, AuthUser, AuthUser as AuthUser$1, Automation, AutomationActionInput, AutomationAudiencePreview, AutomationCreatePayload, AutomationEnrollment, AutomationStats, AutomationUpdatePayload, Blueprint, BlueprintSettings, BrandBackend, BrandSiteConfig, BrandSourceConfig, CalendarFeed, CalendarFeedInput, CalendarFeedSyncResult, CalendarStatus, Campaign, CampaignAudiencePreview, CampaignAudiencePreviewPayload, CampaignCreatePayload, CampaignRecipient, CampaignRecipientStatus, CampaignSendTestDraftPayload, CampaignStats, CampaignUpdatePayload, Card, Cart, Cart as Cart$1, CartItem, CartLine, ChangelogEntry, Character, CheckoutSnapshot, CheckoutSnapshot as CheckoutSnapshot$1, CheckoutSnapshotRequest, CheckoutSnapshotRequest as CheckoutSnapshotRequest$1, ClientProposal, CommissionAgreement, Configuration, Contact, ContactActivity, ContactCreatePayload, ContactFormData, ContactRelation, ContactRelationPayload, ContactRelationUpdatePayload, Content, ContentValue, ContentVersion, Contract, ContractCategoryName, ContractVersion, Coupon, CouponCondition, CouponRestrictedItem, CreateContentInput, CreateHookPayload, CreateHookPayload as CreateHookPayload$1, CreateInboundHookPayload, CreateInternalHookPayload, CreateKvFieldPayload, CreateWarpLinkedHookPayload, CreateWebHookPayload, Document, EarnResponse, Element, ElementSpec, ElementType, ElementVariation, EmbedStatus, Entity, Flow, FollowListParams, FollowPayload, Fulfillment, FulfillmentLocation, FulfillmentLocation as FulfillmentLocation$1, FulfillmentMethod, GamificationData, Goal, GoalCreatePayload, GuestBuyer, GuestBuyer as GuestBuyer$1, HashidInput, HashidInput as HashidInput$1, Hook, Hook as Hook$1, HookSample, HookSample as HookSample$1, HookTrigger, HookTriggerCondition, HookTriggerInput, IAppResponse, IAppResponse as IAppResponse$1, IHttpService, IRequestOptions, IdentifiedSiteEvent, Inquiry, InquiryType, Install, InstallClaimPayload, InstallOptOutPayload, InstallRegisterPayload, Integration, IntegrationType, Intent, Item, ItemCreatePayload, ItemUpdatePayload, JsonValue, KvEntryPayload, KvField, KvFieldWithEntries, Link, LinkCreatePayload, LinkStats, LinkUpdatePayload, LinkVariation, LinkVariationBatchCreatePayload, LinkVariationCreatePayload, LoyaltyAccount, LoyaltyCollectPointInput, LoyaltyCollectResponse, LoyaltyJoinResponse, LoyaltyMember, LoyaltyProgram, LoyaltyPromotion, LoyaltyReward, LoyaltyTier, LoyaltyTransaction, LoyaltyWalletAccount, 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, ProductDetailSection, ProductDetailSection as ProductDetailSection$1, ProductDetailText, ProductRelation, ProductRelationType, ProductVariation, ProductVariationExternalReference, ProductVariationExternalSource, ProgramSettings, Project, ProjectExportResponse, ProjectInputAssistIntent, ProjectInputAssistResponse, ProjectMutation, ProjectOutputPreset, ProjectOutputType, ProjectStudioHistoryEntry, Proposal, ProposalAction, ProposalCreateInput, ProposalItemInput, ProposalItemUpdateInput, ProposalPollOption, ProposalPricing, ProposalStats, ProposalUpdateInput, PublicFormResults, PurchaseResult, RampProviderInfo, Reactions, RedeemResponse, Reminder, Return, ReturnStatus, Room, RoomKind, Segment, SegmentCountPayload, SegmentCountResult, SegmentCreatePayload, Service, SetKvEntryResult, SharedArtifact, SharedProposal, SharedSocialPost, ShippingCarrierOption, ShippingRate, ShippingRate as ShippingRate$1, ShippingZone, Shortcut, Site, SiteBrand, SiteType, SiteUptime, Skill, SkillScopeValue, SnmInventoryImportResult, SocialAuthProvider, SocialBot, SocialPlatform, SocialPost, SocialPostConnection, SocialPostCreatePayload, SocialPostGenerateCaptionPayload, SocialPostGeneratedCaption, SocialPostPlatform, SocialPostScheduleSlot, SocialPostStatus, SocialPostUpdatePayload, StampResponse, StoreAgent, StoreData, StorePriceTier, StorePurchaseResult, Subscription, Swarm, Tag, TagType, Task, TaxClass, Team, TeamAccessConfig, TeamCategory, TeamEarning, TeamEarningsBalance, TeamFeature, TeamFeatureUsage, TeamMember, TeamMeta, TeamOrderStats, TeamPayout, TeamPayoutAddress, TeamPrivate, TeamSubscriptionStats, TeamUsage, TemplateMode, TemplateOverrides, TemplateSpec, TerminalConnectionToken, TerminalPaymentIntent, ToggleKvFieldResult, TranslatableValue, TranslatableValue as TranslatableValue$1, 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
|
|
@@ -21,8 +21,16 @@ declare class AgentsResource {
|
|
|
21
21
|
delete(uuid: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
22
22
|
updatePassword(uuid: string, password: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
23
23
|
storePassword(uuid: string, password: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
24
|
+
verifyPassword(uuid: string, password: string): Promise<_$_joai_core0.IAppResponse<{
|
|
25
|
+
valid: boolean;
|
|
26
|
+
}>>;
|
|
27
|
+
walletKey(uuid: string): Promise<_$_joai_core0.IAppResponse<{
|
|
28
|
+
secKey: string;
|
|
29
|
+
}>>;
|
|
24
30
|
updateSetting<K extends keyof AgentSettings>(uuid: string, key: K, value: AgentSettings[K]): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
25
31
|
updateMeta(uuid: string, key: string, value: unknown): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
32
|
+
cloneVoice(uuid: string, name: string, samples: File[], description?: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
33
|
+
deleteVoice(uuid: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
26
34
|
publish(uuid: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
27
35
|
unpublish(uuid: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
28
36
|
moveToTeam(uuid: string, teamSlug: string): Promise<_$_joai_core0.IAppResponse<AgentPrivate>>;
|
|
@@ -798,6 +806,9 @@ type AuthApiTokenResponse = {
|
|
|
798
806
|
type AuthPortalSessionResponse = {
|
|
799
807
|
url: string;
|
|
800
808
|
};
|
|
809
|
+
type AuthAppTokenResponse = {
|
|
810
|
+
token: string;
|
|
811
|
+
};
|
|
801
812
|
declare class AuthResource {
|
|
802
813
|
private http;
|
|
803
814
|
constructor(http: IHttpService);
|
|
@@ -809,6 +820,7 @@ declare class AuthResource {
|
|
|
809
820
|
}): Promise<IAppResponse$1<AuthLoginResponse>>;
|
|
810
821
|
loginWithSocialAccessToken(provider: NativeSocialAuthProvider, accessToken: string): Promise<IAppResponse$1<AuthLoginResponse>>;
|
|
811
822
|
exchangeNativeSession(token: string): Promise<IAppResponse$1<AuthNativeSessionResponse>>;
|
|
823
|
+
exchangeAppAuthCode(code: string, redirectUri: string, codeVerifier: string): Promise<IAppResponse$1<AuthAppTokenResponse>>;
|
|
812
824
|
me(): Promise<IAppResponse$1<AuthUser$1>>;
|
|
813
825
|
logout(): Promise<IAppResponse$1<void>>;
|
|
814
826
|
createApiToken(): Promise<IAppResponse$1<AuthApiTokenResponse>>;
|
|
@@ -1219,6 +1231,8 @@ declare class IntegrationsResource {
|
|
|
1219
1231
|
deleteCalendarFeed(id: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1220
1232
|
syncCalendarFeed(id: string): Promise<_$_joai_core0.IAppResponse<CalendarFeedSyncResult>>;
|
|
1221
1233
|
setup(type: IntegrationType, agent: string, data?: Record<string, unknown>): Promise<_$_joai_core0.IAppResponse<Integration>>;
|
|
1234
|
+
uploadSnmInventory(agent: string, file: File, syncAt?: string): Promise<_$_joai_core0.IAppResponse<SnmInventoryImportResult>>;
|
|
1235
|
+
rotateSnmKey(agent: string): Promise<_$_joai_core0.IAppResponse<Integration>>;
|
|
1222
1236
|
}
|
|
1223
1237
|
//#endregion
|
|
1224
1238
|
//#region src/resources/intents.d.ts
|
|
@@ -1520,6 +1534,14 @@ declare class MemoriesResource {
|
|
|
1520
1534
|
}
|
|
1521
1535
|
//#endregion
|
|
1522
1536
|
//#region src/resources/messages.d.ts
|
|
1537
|
+
type PendingMediaImport = {
|
|
1538
|
+
provider: string;
|
|
1539
|
+
agentId: string;
|
|
1540
|
+
roomId: string;
|
|
1541
|
+
messageId: string;
|
|
1542
|
+
action: string;
|
|
1543
|
+
content: string;
|
|
1544
|
+
};
|
|
1523
1545
|
type PendingApprovalMessage = Message & {
|
|
1524
1546
|
team?: {
|
|
1525
1547
|
slug: string;
|
|
@@ -1538,6 +1560,7 @@ declare class MessagesResource {
|
|
|
1538
1560
|
search(team: string, search: string): Promise<_$_joai_core0.IAppResponse<Message[]>>;
|
|
1539
1561
|
delete(messageId: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1540
1562
|
pendingApprovals(teams: string[]): Promise<_$_joai_core0.IAppResponse<PendingApprovalMessage[]>>;
|
|
1563
|
+
pendingMediaImports(team: string): Promise<_$_joai_core0.IAppResponse<PendingMediaImport[]>>;
|
|
1541
1564
|
generateAudio(messageId: string): Promise<_$_joai_core0.IAppResponse<{
|
|
1542
1565
|
audioUrl: string;
|
|
1543
1566
|
}>>;
|
|
@@ -1830,6 +1853,7 @@ declare class ProjectsResource {
|
|
|
1830
1853
|
type ProposalListParams = {
|
|
1831
1854
|
page?: number;
|
|
1832
1855
|
perPage?: number;
|
|
1856
|
+
includeArchived?: boolean;
|
|
1833
1857
|
};
|
|
1834
1858
|
/**
|
|
1835
1859
|
* Team-scoped proposal endpoints. Create the client with `createClient({ team })`
|
|
@@ -1843,6 +1867,15 @@ declare class ProposalsResource {
|
|
|
1843
1867
|
get(id: string): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1844
1868
|
create(data: ProposalCreateInput): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1845
1869
|
update(id: string, data: ProposalUpdateInput): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1870
|
+
delete(id: string): Promise<_$_joai_core0.IAppResponse<{
|
|
1871
|
+
deleted: boolean;
|
|
1872
|
+
}>>;
|
|
1873
|
+
archive(id: string): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1874
|
+
publish(id: string): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1875
|
+
setItems(id: string, items: ProposalItemInput[]): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1876
|
+
addItem(id: string, item: ProposalItemInput): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1877
|
+
updateItem(id: string, itemId: string, data: ProposalItemUpdateInput): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1878
|
+
removeItem(id: string, itemId: string): Promise<_$_joai_core0.IAppResponse<ClientProposal>>;
|
|
1846
1879
|
getShared(slug: string, password?: string): Promise<_$_joai_core0.IAppResponse<SharedProposal>>;
|
|
1847
1880
|
pricing(slug: string, password: string | undefined, itemIds: string[]): Promise<_$_joai_core0.IAppResponse<ProposalPricing>>;
|
|
1848
1881
|
confirm(slug: string, password: string | undefined, itemIds: string[]): Promise<_$_joai_core0.IAppResponse<SharedProposal>>;
|
|
@@ -1964,6 +1997,7 @@ declare class SitesResource {
|
|
|
1964
1997
|
resolve(teamSlug: string, brandSlug?: string): Promise<_$_joai_core0.IAppResponse<Site>>;
|
|
1965
1998
|
resolveByDomain(domain: string): Promise<_$_joai_core0.IAppResponse<Site>>;
|
|
1966
1999
|
uptime(siteId: HashidInput$1): Promise<_$_joai_core0.IAppResponse<SiteUptime>>;
|
|
2000
|
+
verifyCustomDomain(siteId: HashidInput$1): Promise<_$_joai_core0.IAppResponse<Site>>;
|
|
1967
2001
|
update(siteId: HashidInput$1, data: {
|
|
1968
2002
|
customDomain?: string | null;
|
|
1969
2003
|
enabled?: boolean;
|
|
@@ -2553,6 +2587,10 @@ declare class HooksResource {
|
|
|
2553
2587
|
list(agentId: string): Promise<_$_joai_core0.IAppResponse<Hook$1[]>>;
|
|
2554
2588
|
create(agentId: string, payload: CreateHookPayload$1): Promise<_$_joai_core0.IAppResponse<Hook$1>>;
|
|
2555
2589
|
sample(agentId: string, source: string): Promise<_$_joai_core0.IAppResponse<HookSample$1>>;
|
|
2590
|
+
secret(agentId: string, source: string): Promise<_$_joai_core0.IAppResponse<{
|
|
2591
|
+
source: string;
|
|
2592
|
+
secret: string;
|
|
2593
|
+
}>>;
|
|
2556
2594
|
toggle(agentId: string, hookId: string): Promise<_$_joai_core0.IAppResponse<Hook$1>>;
|
|
2557
2595
|
removeByHook(agentId: string, hookId: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
2558
2596
|
removeByWarp(agentId: string, warpIdentifier: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
@@ -2579,6 +2617,7 @@ interface JoAiClientConfig {
|
|
|
2579
2617
|
declare class JoAiClient {
|
|
2580
2618
|
readonly http: IHttpService;
|
|
2581
2619
|
private readonly env;
|
|
2620
|
+
private readonly config;
|
|
2582
2621
|
isReady: boolean;
|
|
2583
2622
|
hasApiToken: boolean;
|
|
2584
2623
|
readonly agents: AgentsResource;
|
|
@@ -2660,6 +2699,8 @@ declare class JoAiClient {
|
|
|
2660
2699
|
readonly hooks: HooksResource;
|
|
2661
2700
|
readonly workspace: WorkspaceResource;
|
|
2662
2701
|
constructor(config: JoAiClientConfig);
|
|
2702
|
+
/** Team-scoped client without mutating this instance. */
|
|
2703
|
+
withTeam(team?: string | null): JoAiClient;
|
|
2663
2704
|
clearCache(): void;
|
|
2664
2705
|
warps(locale?: WarpLocale, currentUrl?: string): WarpClient;
|
|
2665
2706
|
}
|
|
@@ -2697,6 +2738,72 @@ declare class CachedHttpService implements IHttpService {
|
|
|
2697
2738
|
private bust;
|
|
2698
2739
|
}
|
|
2699
2740
|
//#endregion
|
|
2741
|
+
//#region src/auth/browser-app-code.d.ts
|
|
2742
|
+
declare const DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY = "joai:app-auth";
|
|
2743
|
+
type BeginBrowserAppAuthOptions = {
|
|
2744
|
+
callbackUrl: string;
|
|
2745
|
+
env?: AppEnv$1;
|
|
2746
|
+
team?: string;
|
|
2747
|
+
brand?: string;
|
|
2748
|
+
storageKey?: string;
|
|
2749
|
+
};
|
|
2750
|
+
type CompleteBrowserAppAuthOptions = {
|
|
2751
|
+
url: string;
|
|
2752
|
+
env?: AppEnv$1;
|
|
2753
|
+
storageKey?: string;
|
|
2754
|
+
};
|
|
2755
|
+
/** Starts a browser app authorization-code flow and persists the PKCE secret in localStorage. */
|
|
2756
|
+
declare const beginBrowserAppAuth: ({
|
|
2757
|
+
callbackUrl,
|
|
2758
|
+
env,
|
|
2759
|
+
team,
|
|
2760
|
+
brand,
|
|
2761
|
+
storageKey
|
|
2762
|
+
}: BeginBrowserAppAuthOptions) => Promise<string>;
|
|
2763
|
+
/** Completes a browser app authorization-code flow and returns the exchanged bearer token. */
|
|
2764
|
+
declare const completeBrowserAppAuth: ({
|
|
2765
|
+
url,
|
|
2766
|
+
env,
|
|
2767
|
+
storageKey
|
|
2768
|
+
}: CompleteBrowserAppAuthOptions) => Promise<string | null>;
|
|
2769
|
+
//#endregion
|
|
2770
|
+
//#region src/auth/app-code.d.ts
|
|
2771
|
+
type AppAuthRequest = {
|
|
2772
|
+
/** JoAi login URL to navigate to. */url: string; /** Canonical callback URL that must be sent to the token exchange. */
|
|
2773
|
+
redirectUri: string;
|
|
2774
|
+
state: string;
|
|
2775
|
+
codeVerifier: string;
|
|
2776
|
+
};
|
|
2777
|
+
type CreateAppAuthRequestOptions = {
|
|
2778
|
+
callbackUrl: string;
|
|
2779
|
+
env?: AppEnv$1;
|
|
2780
|
+
team?: string;
|
|
2781
|
+
brand?: string;
|
|
2782
|
+
};
|
|
2783
|
+
type ExchangeAppAuthCodeOptions = {
|
|
2784
|
+
code: string;
|
|
2785
|
+
redirectUri: string;
|
|
2786
|
+
codeVerifier: string;
|
|
2787
|
+
env?: AppEnv$1;
|
|
2788
|
+
};
|
|
2789
|
+
/**
|
|
2790
|
+
* Creates a PKCE authorization-code request for a browser app with a server-side callback.
|
|
2791
|
+
* The callback origin must be a registered JoAi app origin.
|
|
2792
|
+
*/
|
|
2793
|
+
declare const createAppAuthRequest: ({
|
|
2794
|
+
callbackUrl,
|
|
2795
|
+
env,
|
|
2796
|
+
team,
|
|
2797
|
+
brand
|
|
2798
|
+
}: CreateAppAuthRequestOptions) => Promise<AppAuthRequest>;
|
|
2799
|
+
/** Exchanges a one-time app authorization code for a bearer token. */
|
|
2800
|
+
declare const exchangeAppAuthCode: ({
|
|
2801
|
+
code,
|
|
2802
|
+
redirectUri,
|
|
2803
|
+
codeVerifier,
|
|
2804
|
+
env
|
|
2805
|
+
}: ExchangeAppAuthCodeOptions) => Promise<IAppResponse$1<AuthAppTokenResponse>>;
|
|
2806
|
+
//#endregion
|
|
2700
2807
|
//#region src/auth/portal.d.ts
|
|
2701
2808
|
declare const getAuthFragmentToken: (url: string) => string | null;
|
|
2702
2809
|
declare const isPortalCallbackUrl: (url: string, env?: AppEnv$1) => boolean;
|
|
@@ -2730,4 +2837,4 @@ declare class DistributionResource {
|
|
|
2730
2837
|
private fetchDistribution;
|
|
2731
2838
|
}
|
|
2732
2839
|
//#endregion
|
|
2733
|
-
export { type AddressInput, AddressesResource, AgentsResource, AlertsResource, AnalyticsResource, ApiTokensResource, type AppEnv, type AppointmentAvailabilitySlot, AppointmentsResource, type AttachedMedia, type AuditLogEvent, type AuditLogListParams, AuditLogsResource, 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, type CartItem, CartsResource, type CatalogExportFormat, type CatalogExportRequest, type CatalogExportResource, ChangelogResource, CharactersResource, CheckoutResource, type CheckoutSnapshot, type CheckoutSnapshotRequest, CommerceResource, ContactsResource, ContentResource, ContractsResource, type CreateEmptyGuestCheckoutOptions, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, type DeleteUserParams, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, ExportsResource, FlowsResource, FollowsResource, 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 HashidInput, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, type IAppResponse, IngestionsResource, InquiriesResource, InstallsResource, 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 ProductCategories, type ProductDetailSection, type ProductDetailText, type ProductFacets, type ProductRelationType, type ProductVariation, type ProductsListParams, ProductsResource, type ProductsSort, ProjectsResource, type ProposalListParams, ProposalsResource, type RecentlyViewedStorage, type RecentlyViewedStorageOptions, RemindersResource, ReturnsResource, type RevalidateGuestCouponResult, SegmentsResource, type ServicesListParams, ServicesResource, type ShippingRate, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TaxClassInput, TaxClassesResource, type TeamInviteInfo, TeamsResource, type TranslatableValue, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, createRecentlyViewedStorage, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, getRecentlyViewedSlugs, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, trackRecentlyViewed, validateGuestCoupon };
|
|
2840
|
+
export { type AddressInput, AddressesResource, AgentsResource, AlertsResource, AnalyticsResource, ApiTokensResource, type AppAuthRequest, type AppEnv, type AppointmentAvailabilitySlot, AppointmentsResource, type AttachedMedia, type AuditLogEvent, type AuditLogListParams, AuditLogsResource, type AuthAppTokenResponse, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type AuthUser, AutomationsResource, type BackendWarp, type BackendWarpBrand, type BeginBrowserAppAuthOptions, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, type Cart, type CartItem, CartsResource, type CatalogExportFormat, type CatalogExportRequest, type CatalogExportResource, ChangelogResource, CharactersResource, CheckoutResource, type CheckoutSnapshot, type CheckoutSnapshotRequest, CommerceResource, type CompleteBrowserAppAuthOptions, ContactsResource, ContentResource, ContractsResource, type CreateAppAuthRequestOptions, type CreateEmptyGuestCheckoutOptions, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY, type DeleteUserParams, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, type ExchangeAppAuthCodeOptions, ExportsResource, FlowsResource, FollowsResource, 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 HashidInput, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, type IAppResponse, IngestionsResource, InquiriesResource, InstallsResource, 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 ProductCategories, type ProductDetailSection, type ProductDetailText, type ProductFacets, type ProductRelationType, type ProductVariation, type ProductsListParams, ProductsResource, type ProductsSort, ProjectsResource, type ProposalListParams, ProposalsResource, type RecentlyViewedStorage, type RecentlyViewedStorageOptions, RemindersResource, ReturnsResource, type RevalidateGuestCouponResult, SegmentsResource, type ServicesListParams, ServicesResource, type ShippingRate, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TaxClassInput, TaxClassesResource, type TeamInviteInfo, TeamsResource, type TranslatableValue, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, beginBrowserAppAuth, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completeBrowserAppAuth, completePortalSession, createAppAuthRequest, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, createRecentlyViewedStorage, exchangeAppAuthCode, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, getRecentlyViewedSlugs, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, trackRecentlyViewed, validateGuestCoupon };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpService, cartLineTotal, cartPayableTotal, firstValidationMessage, getApiBaseUrl, getCortexBaseUrl, isCompleteAddressInput, validationMessageFor } from "@joai/core";
|
|
1
|
+
import { HttpService, cartLineTotal, cartPayableTotal, firstValidationMessage, getApiBaseUrl, getCortexBaseUrl, getLoginUrl, isCompleteAddressInput, validationMessageFor } from "@joai/core";
|
|
2
2
|
import { WarpClient } from "@joai/warps";
|
|
3
3
|
//#region src/resources/agents.ts
|
|
4
4
|
var AgentsResource = class {
|
|
@@ -34,12 +34,28 @@ var AgentsResource = class {
|
|
|
34
34
|
storePassword(uuid, password) {
|
|
35
35
|
return this.http.post(`agents/${uuid}/password`, { password });
|
|
36
36
|
}
|
|
37
|
+
verifyPassword(uuid, password) {
|
|
38
|
+
return this.http.post(`agents/${uuid}/password/verify`, { password });
|
|
39
|
+
}
|
|
40
|
+
walletKey(uuid) {
|
|
41
|
+
return this.http.get(`agents/${uuid}/wallet-key`);
|
|
42
|
+
}
|
|
37
43
|
updateSetting(uuid, key, value) {
|
|
38
44
|
return this.http.put(`agents/${uuid}/settings/${key}`, { value });
|
|
39
45
|
}
|
|
40
46
|
updateMeta(uuid, key, value) {
|
|
41
47
|
return this.http.put(`agents/${uuid}/meta/${key}`, { value });
|
|
42
48
|
}
|
|
49
|
+
cloneVoice(uuid, name, samples, description) {
|
|
50
|
+
const formData = new FormData();
|
|
51
|
+
formData.append("name", name);
|
|
52
|
+
if (description) formData.append("description", description);
|
|
53
|
+
samples.forEach((sample) => formData.append("samples[]", sample, sample.name));
|
|
54
|
+
return this.http.post(`agents/${uuid}/voice/clone`, formData, { isJson: false });
|
|
55
|
+
}
|
|
56
|
+
deleteVoice(uuid) {
|
|
57
|
+
return this.http.delete(`agents/${uuid}/voice/clone`);
|
|
58
|
+
}
|
|
43
59
|
publish(uuid) {
|
|
44
60
|
return this.http.post(`agents/${uuid}/publish`, {});
|
|
45
61
|
}
|
|
@@ -1141,6 +1157,13 @@ var AuthResource = class {
|
|
|
1141
1157
|
exchangeNativeSession(token) {
|
|
1142
1158
|
return this.http.post("auth/verify", { token });
|
|
1143
1159
|
}
|
|
1160
|
+
exchangeAppAuthCode(code, redirectUri, codeVerifier) {
|
|
1161
|
+
return this.http.post("auth/app/token", {
|
|
1162
|
+
code,
|
|
1163
|
+
redirect_uri: redirectUri,
|
|
1164
|
+
code_verifier: codeVerifier
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1144
1167
|
me() {
|
|
1145
1168
|
return this.http.get("auth/me");
|
|
1146
1169
|
}
|
|
@@ -1768,6 +1791,14 @@ var IntegrationsResource = class {
|
|
|
1768
1791
|
setup(type, agent, data) {
|
|
1769
1792
|
return this.http.post(`integrations/${type}/${agent}/setup`, data ?? {});
|
|
1770
1793
|
}
|
|
1794
|
+
uploadSnmInventory(agent, file, syncAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
1795
|
+
const form = new FormData();
|
|
1796
|
+
form.append("file", file);
|
|
1797
|
+
return this.http.post(`integrations/snm/${agent}/inventory/upload`, form, { headers: { "X-SNM-Sync-At": syncAt } });
|
|
1798
|
+
}
|
|
1799
|
+
rotateSnmKey(agent) {
|
|
1800
|
+
return this.http.post(`integrations/snm/${agent}/rotate-key`);
|
|
1801
|
+
}
|
|
1771
1802
|
};
|
|
1772
1803
|
//#endregion
|
|
1773
1804
|
//#region src/resources/intents.ts
|
|
@@ -2256,6 +2287,9 @@ var MessagesResource = class {
|
|
|
2256
2287
|
teams.forEach((t) => params.append("teams[]", t));
|
|
2257
2288
|
return this.http.get(`messages/pending-approvals?${params.toString()}`);
|
|
2258
2289
|
}
|
|
2290
|
+
pendingMediaImports(team) {
|
|
2291
|
+
return this.http.get(`media-imports/pending?team=${encodeURIComponent(team)}`, { headers: { "X-Team": team } });
|
|
2292
|
+
}
|
|
2259
2293
|
generateAudio(messageId) {
|
|
2260
2294
|
return this.http.post(`messages/${messageId}/audio`, {});
|
|
2261
2295
|
}
|
|
@@ -2570,6 +2604,7 @@ var ProposalsResource = class {
|
|
|
2570
2604
|
const query = new URLSearchParams();
|
|
2571
2605
|
if (params?.page != null) query.set("page", String(params.page));
|
|
2572
2606
|
if (params?.perPage != null) query.set("perPage", String(params.perPage));
|
|
2607
|
+
if (params?.includeArchived != null) query.set("includeArchived", String(params.includeArchived));
|
|
2573
2608
|
const qs = query.toString();
|
|
2574
2609
|
return this.http.get(`proposals${qs ? `?${qs}` : ""}`);
|
|
2575
2610
|
}
|
|
@@ -2585,6 +2620,27 @@ var ProposalsResource = class {
|
|
|
2585
2620
|
update(id, data) {
|
|
2586
2621
|
return this.http.put(`proposals/${id}`, data);
|
|
2587
2622
|
}
|
|
2623
|
+
delete(id) {
|
|
2624
|
+
return this.http.delete(`proposals/${id}`);
|
|
2625
|
+
}
|
|
2626
|
+
archive(id) {
|
|
2627
|
+
return this.http.post(`proposals/${id}/archive`);
|
|
2628
|
+
}
|
|
2629
|
+
publish(id) {
|
|
2630
|
+
return this.http.post(`proposals/${id}/publish`);
|
|
2631
|
+
}
|
|
2632
|
+
setItems(id, items) {
|
|
2633
|
+
return this.http.put(`proposals/${id}/items`, { items });
|
|
2634
|
+
}
|
|
2635
|
+
addItem(id, item) {
|
|
2636
|
+
return this.http.post(`proposals/${id}/items`, item);
|
|
2637
|
+
}
|
|
2638
|
+
updateItem(id, itemId, data) {
|
|
2639
|
+
return this.http.put(`proposals/${id}/items/${itemId}`, data);
|
|
2640
|
+
}
|
|
2641
|
+
removeItem(id, itemId) {
|
|
2642
|
+
return this.http.delete(`proposals/${id}/items/${itemId}`);
|
|
2643
|
+
}
|
|
2588
2644
|
getShared(slug, password) {
|
|
2589
2645
|
return this.http.get(`proposals/shared/${encodeURIComponent(slug)}`, access(password));
|
|
2590
2646
|
}
|
|
@@ -2758,6 +2814,9 @@ var SitesResource = class {
|
|
|
2758
2814
|
uptime(siteId) {
|
|
2759
2815
|
return this.http.get(`sites/${siteId}/uptime`);
|
|
2760
2816
|
}
|
|
2817
|
+
verifyCustomDomain(siteId) {
|
|
2818
|
+
return this.http.post(`sites/${siteId}/custom-domain/verify`);
|
|
2819
|
+
}
|
|
2761
2820
|
update(siteId, data) {
|
|
2762
2821
|
return this.http.put(`sites/${siteId}`, data);
|
|
2763
2822
|
}
|
|
@@ -3678,6 +3737,9 @@ var HooksResource = class {
|
|
|
3678
3737
|
sample(agentId, source) {
|
|
3679
3738
|
return this.http.get(`hooks/sample?agent=${agentId}&source=${encodeURIComponent(source)}`);
|
|
3680
3739
|
}
|
|
3740
|
+
secret(agentId, source) {
|
|
3741
|
+
return this.http.get(`agents/${agentId}/hooks/${encodeURIComponent(source)}/secret`);
|
|
3742
|
+
}
|
|
3681
3743
|
toggle(agentId, hookId) {
|
|
3682
3744
|
return this.http.post(`hooks/${hookId}/toggle?agent=${agentId}`);
|
|
3683
3745
|
}
|
|
@@ -3850,10 +3912,11 @@ function toWarpEnv(env) {
|
|
|
3850
3912
|
if (env === "testnet") return "testnet";
|
|
3851
3913
|
return "mainnet";
|
|
3852
3914
|
}
|
|
3853
|
-
var JoAiClient = class {
|
|
3915
|
+
var JoAiClient = class JoAiClient {
|
|
3854
3916
|
constructor(config) {
|
|
3855
3917
|
this.isReady = true;
|
|
3856
3918
|
this.hasApiToken = false;
|
|
3919
|
+
this.config = config;
|
|
3857
3920
|
this.env = config.env ?? "mainnet";
|
|
3858
3921
|
const apiBaseUrl = getApiBaseUrl(config.env ?? "mainnet");
|
|
3859
3922
|
const headers = {};
|
|
@@ -3947,6 +4010,21 @@ var JoAiClient = class {
|
|
|
3947
4010
|
this.hooks = new HooksResource(this.http);
|
|
3948
4011
|
this.workspace = new WorkspaceResource(this.http);
|
|
3949
4012
|
}
|
|
4013
|
+
/** Team-scoped client without mutating this instance. */
|
|
4014
|
+
withTeam(team) {
|
|
4015
|
+
const client = new JoAiClient({
|
|
4016
|
+
...this.config,
|
|
4017
|
+
team: team ?? void 0
|
|
4018
|
+
});
|
|
4019
|
+
client.isReady = this.isReady;
|
|
4020
|
+
client.hasApiToken = this.hasApiToken;
|
|
4021
|
+
client.http.onNetworkError = this.http.onNetworkError;
|
|
4022
|
+
client.http.onUnauthorized = this.http.onUnauthorized;
|
|
4023
|
+
client.http.onSuccessfulResponse = this.http.onSuccessfulResponse;
|
|
4024
|
+
client.http.onMaintenanceMode = this.http.onMaintenanceMode;
|
|
4025
|
+
client.http.onTooManyRequests = this.http.onTooManyRequests;
|
|
4026
|
+
return client;
|
|
4027
|
+
}
|
|
3950
4028
|
clearCache() {
|
|
3951
4029
|
if (this.http instanceof CachedHttpService) this.http.clearCache();
|
|
3952
4030
|
}
|
|
@@ -3962,6 +4040,116 @@ function createClient(config) {
|
|
|
3962
4040
|
return new JoAiClient(config);
|
|
3963
4041
|
}
|
|
3964
4042
|
//#endregion
|
|
4043
|
+
//#region src/auth/app-code.ts
|
|
4044
|
+
const CONTROL_PARAMS = [
|
|
4045
|
+
"code",
|
|
4046
|
+
"state",
|
|
4047
|
+
"joai_auth",
|
|
4048
|
+
"code_challenge",
|
|
4049
|
+
"code_challenge_method"
|
|
4050
|
+
];
|
|
4051
|
+
const base64Url = (bytes) => {
|
|
4052
|
+
let binary = "";
|
|
4053
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
4054
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
4055
|
+
};
|
|
4056
|
+
const random = (bytes) => crypto.getRandomValues(new Uint8Array(bytes));
|
|
4057
|
+
const sha256 = async (value) => new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value)));
|
|
4058
|
+
/**
|
|
4059
|
+
* Creates a PKCE authorization-code request for a browser app with a server-side callback.
|
|
4060
|
+
* The callback origin must be a registered JoAi app origin.
|
|
4061
|
+
*/
|
|
4062
|
+
const createAppAuthRequest = async ({ callbackUrl, env = "mainnet", team, brand }) => {
|
|
4063
|
+
const callback = new URL(callbackUrl);
|
|
4064
|
+
callback.hash = "";
|
|
4065
|
+
for (const param of CONTROL_PARAMS) callback.searchParams.delete(param);
|
|
4066
|
+
const redirectUri = callback.toString();
|
|
4067
|
+
const state = base64Url(random(24));
|
|
4068
|
+
const codeVerifier = base64Url(random(48));
|
|
4069
|
+
const codeChallenge = base64Url(await sha256(codeVerifier));
|
|
4070
|
+
callback.searchParams.set("joai_auth", "code");
|
|
4071
|
+
callback.searchParams.set("state", state);
|
|
4072
|
+
callback.searchParams.set("code_challenge", codeChallenge);
|
|
4073
|
+
callback.searchParams.set("code_challenge_method", "S256");
|
|
4074
|
+
return {
|
|
4075
|
+
url: getLoginUrl(env, callback.toString(), team ? {
|
|
4076
|
+
team,
|
|
4077
|
+
brand
|
|
4078
|
+
} : void 0),
|
|
4079
|
+
redirectUri,
|
|
4080
|
+
state,
|
|
4081
|
+
codeVerifier
|
|
4082
|
+
};
|
|
4083
|
+
};
|
|
4084
|
+
/** Exchanges a one-time app authorization code for a bearer token. */
|
|
4085
|
+
const exchangeAppAuthCode = ({ code, redirectUri, codeVerifier, env = "mainnet" }) => createClient({
|
|
4086
|
+
env,
|
|
4087
|
+
cache: { enabled: false }
|
|
4088
|
+
}).auth.exchangeAppAuthCode(code, redirectUri, codeVerifier);
|
|
4089
|
+
//#endregion
|
|
4090
|
+
//#region src/auth/browser-app-code.ts
|
|
4091
|
+
const DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY = "joai:app-auth";
|
|
4092
|
+
const storage = () => {
|
|
4093
|
+
if (typeof window === "undefined") return null;
|
|
4094
|
+
try {
|
|
4095
|
+
return window.localStorage;
|
|
4096
|
+
} catch {
|
|
4097
|
+
return null;
|
|
4098
|
+
}
|
|
4099
|
+
};
|
|
4100
|
+
const stateKey = (storageKey, state) => `${storageKey}:${state}`;
|
|
4101
|
+
const readState = (key) => {
|
|
4102
|
+
try {
|
|
4103
|
+
const raw = storage()?.getItem(key);
|
|
4104
|
+
if (!raw) return null;
|
|
4105
|
+
const parsed = JSON.parse(raw);
|
|
4106
|
+
if (!parsed.redirectUri || !parsed.state || !parsed.codeVerifier) return null;
|
|
4107
|
+
return parsed;
|
|
4108
|
+
} catch {
|
|
4109
|
+
return null;
|
|
4110
|
+
}
|
|
4111
|
+
};
|
|
4112
|
+
/** Starts a browser app authorization-code flow and persists the PKCE secret in localStorage. */
|
|
4113
|
+
const beginBrowserAppAuth = async ({ callbackUrl, env, team, brand, storageKey = DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY }) => {
|
|
4114
|
+
const auth = await createAppAuthRequest({
|
|
4115
|
+
callbackUrl,
|
|
4116
|
+
env,
|
|
4117
|
+
team,
|
|
4118
|
+
brand
|
|
4119
|
+
});
|
|
4120
|
+
const target = storage();
|
|
4121
|
+
if (!target) throw new Error("Local storage is unavailable.");
|
|
4122
|
+
target.setItem(stateKey(storageKey, auth.state), JSON.stringify({
|
|
4123
|
+
redirectUri: auth.redirectUri,
|
|
4124
|
+
state: auth.state,
|
|
4125
|
+
codeVerifier: auth.codeVerifier
|
|
4126
|
+
}));
|
|
4127
|
+
return auth.url;
|
|
4128
|
+
};
|
|
4129
|
+
/** Completes a browser app authorization-code flow and returns the exchanged bearer token. */
|
|
4130
|
+
const completeBrowserAppAuth = async ({ url, env, storageKey = DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY }) => {
|
|
4131
|
+
const parsed = new URL(url);
|
|
4132
|
+
const code = parsed.searchParams.get("code");
|
|
4133
|
+
if (!code) return null;
|
|
4134
|
+
const state = parsed.searchParams.get("state");
|
|
4135
|
+
if (!state) throw new Error("Invalid app auth state.");
|
|
4136
|
+
const key = stateKey(storageKey, state);
|
|
4137
|
+
const stored = readState(key);
|
|
4138
|
+
if (!stored || state !== stored.state) {
|
|
4139
|
+
storage()?.removeItem(key);
|
|
4140
|
+
throw new Error("Invalid app auth state.");
|
|
4141
|
+
}
|
|
4142
|
+
const response = await exchangeAppAuthCode({
|
|
4143
|
+
code,
|
|
4144
|
+
redirectUri: stored.redirectUri,
|
|
4145
|
+
codeVerifier: stored.codeVerifier,
|
|
4146
|
+
env
|
|
4147
|
+
});
|
|
4148
|
+
storage()?.removeItem(key);
|
|
4149
|
+
if (!response.ok || !response.data?.token) throw new Error("App auth code exchange failed.");
|
|
4150
|
+
return response.data.token;
|
|
4151
|
+
};
|
|
4152
|
+
//#endregion
|
|
3965
4153
|
//#region src/auth/portal.ts
|
|
3966
4154
|
const getAuthFragmentToken = (url) => {
|
|
3967
4155
|
try {
|
|
@@ -4052,4 +4240,4 @@ var DistributionResource = class {
|
|
|
4052
4240
|
}
|
|
4053
4241
|
};
|
|
4054
4242
|
//#endregion
|
|
4055
|
-
export { AddressesResource, AgentsResource, AlertsResource, AnalyticsResource, ApiTokensResource, AppointmentsResource, AuditLogsResource, AuthResource, AutomationsResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, ExportsResource, FlowsResource, FollowsResource, FulfillmentsResource, GoalsResource, GuestCheckoutError, GuestCouponError, HooksResource, IngestionsResource, InquiriesResource, InstallsResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, ProposalsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TaxClassesResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completePortalSession, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, createRecentlyViewedStorage, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, getRecentlyViewedSlugs, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, trackRecentlyViewed, validateGuestCoupon };
|
|
4243
|
+
export { AddressesResource, AgentsResource, AlertsResource, AnalyticsResource, ApiTokensResource, AppointmentsResource, AuditLogsResource, AuthResource, AutomationsResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, DEFAULT_BROWSER_APP_AUTH_STORAGE_KEY, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, ExportsResource, FlowsResource, FollowsResource, FulfillmentsResource, GoalsResource, GuestCheckoutError, GuestCouponError, HooksResource, IngestionsResource, InquiriesResource, InstallsResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, ProposalsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, SocialPostsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TaxClassesResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, assertGuestCheckoutReady, assertGuestPickupSlotReady, beginBrowserAppAuth, buildGuestCheckoutSnapshotRequest, buildGuestOrderReturnUrl, completeBrowserAppAuth, completePortalSession, createAppAuthRequest, createClient, createEmptyGuestCheckoutState, createGuestCheckoutSnapshot, createGuestCommerceStorage, createRecentlyViewedStorage, exchangeAppAuthCode, formatOpeningHours, formatPickupSlotLabel, getAuthFragmentToken, getRecentlyViewedSlugs, guestCartAmounts, guestCouponMessageFromErrors, isAllowedRedirectUrl, isGuestCheckoutError, isGuestCouponError, isPortalCallbackUrl, openPortalSession, placeGuestCheckoutOrder, readGuestOrderReturnAccess, revalidateGuestCoupon, sanitizePortalCallbackUrl, stripGuestOrderReturnToken, toGuestCheckoutDraft, trackRecentlyViewed, validateGuestCoupon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joai/sdk",
|
|
3
|
-
"version": "14.0
|
|
3
|
+
"version": "14.2.0",
|
|
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": "^5.4.
|
|
38
|
+
"@joai/core": "^5.4.11",
|
|
39
39
|
"@joai/warps": "*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@joai/core": "^5.4.
|
|
42
|
+
"@joai/core": "^5.4.11"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsdown": "^0.21.0",
|