@joai/sdk 8.0.0 → 9.0.1
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 +115 -0
- package/dist/index.d.mts +38 -8
- package/dist/index.mjs +55 -5
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @joai/sdk
|
|
2
|
+
|
|
3
|
+
The React entry point contains reusable building blocks for editable content on client websites. The components stay domain-neutral: sites provide identifiers, copy, styling hooks, and rendered fields; the SDK owns session handoff and the editing lifecycle.
|
|
4
|
+
|
|
5
|
+
## Managed content editor
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ManagedContentEditor } from '@joai/react'
|
|
9
|
+
|
|
10
|
+
<ManagedContentEditor
|
|
11
|
+
config={{
|
|
12
|
+
contentId: 'content-id',
|
|
13
|
+
publicSlug: 'website-content',
|
|
14
|
+
sessionStorageKey: 'website-content-session',
|
|
15
|
+
team: 'team-slug',
|
|
16
|
+
}}
|
|
17
|
+
initialContent={content}
|
|
18
|
+
title="Inhalte bearbeiten"
|
|
19
|
+
labels={{
|
|
20
|
+
edit: 'Bearbeiten',
|
|
21
|
+
save: 'Entwurf speichern',
|
|
22
|
+
saving: 'Wird gespeichert …',
|
|
23
|
+
publish: 'Veröffentlichen',
|
|
24
|
+
publishing: 'Wird veröffentlicht …',
|
|
25
|
+
cancel: 'Abbrechen',
|
|
26
|
+
toolbar: 'Inhaltseditor',
|
|
27
|
+
unsaved: 'Nicht gespeicherte Änderungen',
|
|
28
|
+
}}
|
|
29
|
+
messages={{
|
|
30
|
+
conflict: 'Der Inhalt wurde zwischenzeitlich geändert. Deine Eingaben bleiben erhalten. Bitte prüfe sie und versuche es erneut.',
|
|
31
|
+
loadError: 'Der Inhalt konnte nicht geladen werden.',
|
|
32
|
+
publishError: 'Die Änderungen konnten nicht veröffentlicht werden.',
|
|
33
|
+
published: 'Die Änderungen wurden veröffentlicht.',
|
|
34
|
+
saveError: 'Der Entwurf konnte nicht gespeichert werden.',
|
|
35
|
+
saved: 'Der Entwurf wurde gespeichert.',
|
|
36
|
+
sessionExpired: 'Deine Sitzung ist abgelaufen.',
|
|
37
|
+
unsavedNavigation: 'Du hast nicht gespeicherte Änderungen. Seite wirklich verlassen?',
|
|
38
|
+
}}
|
|
39
|
+
imagePickerLabels={{
|
|
40
|
+
applyCrop: 'Zuschnitt übernehmen',
|
|
41
|
+
back: 'Zurück',
|
|
42
|
+
choose: 'Bild auswählen',
|
|
43
|
+
close: 'Schließen',
|
|
44
|
+
cropDescription: 'Passe Bildausschnitt und Zoom vor dem Hochladen an.',
|
|
45
|
+
cropTitle: 'Bild zuschneiden',
|
|
46
|
+
dimensionsTooLarge: 'Die Bildabmessungen sind zu groß.',
|
|
47
|
+
dimensionsTooSmall: 'Die Bildabmessungen sind zu klein.',
|
|
48
|
+
drop: 'Bild hier ablegen',
|
|
49
|
+
empty: 'Noch keine Bilder vorhanden.',
|
|
50
|
+
field: 'Bearbeitbares Bild',
|
|
51
|
+
invalidType: 'Bitte wähle eine Bilddatei.',
|
|
52
|
+
libraryDescription: 'Wähle ein vorhandenes Bild oder lade ein neues hoch.',
|
|
53
|
+
libraryTitle: 'Bildmediathek',
|
|
54
|
+
loadError: 'Bilder konnten nicht geladen werden.',
|
|
55
|
+
loading: 'Bilder werden geladen …',
|
|
56
|
+
positionHorizontal: 'Horizontale Position',
|
|
57
|
+
positionVertical: 'Vertikale Position',
|
|
58
|
+
processing: 'Bild wird vorbereitet …',
|
|
59
|
+
retry: 'Erneut versuchen',
|
|
60
|
+
tooLarge: 'Das Bild ist zu groß.',
|
|
61
|
+
upload: 'Bild hochladen',
|
|
62
|
+
uploadError: 'Das Bild konnte nicht hochgeladen werden.',
|
|
63
|
+
uploading: 'Wird hochgeladen …',
|
|
64
|
+
zoom: 'Zoom',
|
|
65
|
+
}}
|
|
66
|
+
reauthenticateLabel="Anmeldung erneuern"
|
|
67
|
+
sessionExpiredMessage="Deine Sitzung ist abgelaufen. Deine lokalen Änderungen bleiben erhalten."
|
|
68
|
+
confirmCancel={() => window.confirm('Nicht gespeicherte Änderungen verwerfen?')}
|
|
69
|
+
confirmLeave={() => window.confirm('Du hast nicht gespeicherte Änderungen. Seite wirklich verlassen?')}
|
|
70
|
+
confirmPublish={() => window.confirm('Änderungen jetzt veröffentlichen?')}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</ManagedContentEditor>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Use `EditableContent`, `EditableImage`, and `useContentValue` from `@joai/react` inside the editor. Pass server-fetched public content as `initialContent` to avoid a client-side loading state for visitors.
|
|
77
|
+
|
|
78
|
+
Configure each image field as a reusable, domain-neutral building block. Images are compressed to WebP at up to 2560 × 2560 pixels by default, while animated GIF and SVG files retain their original format. Cropping is opt-in per field:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<EditableImage
|
|
82
|
+
field="heroImage"
|
|
83
|
+
label="Titelbild"
|
|
84
|
+
maxSourceBytes={40 * 1024 * 1024}
|
|
85
|
+
maxUploadBytes={5 * 1024 * 1024}
|
|
86
|
+
processing={{
|
|
87
|
+
crop: { aspectRatio: 16 / 9, outputWidth: 1920 },
|
|
88
|
+
compression: { maxWidth: 1920, maxHeight: 1080, mimeType: 'image/webp', quality: 0.84 },
|
|
89
|
+
dimensions: { minWidth: 1280, minHeight: 720, maxPixels: 50_000_000 },
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Set `compression: false` or `dimensions: false` to disable only that stage, or `processing={false}` to upload the original image without client-side decoding, validation, cropping, or compression.
|
|
95
|
+
|
|
96
|
+
## Session storage
|
|
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 URL fragment containing the one-time handoff token is removed before it is exchanged and persisted.
|
|
99
|
+
|
|
100
|
+
The managed editor automatically adds `platform=app` to its reauthentication return URL so JoAi returns a one-time handoff token. Override `reauthenticateUrl` only when a host has a dedicated login callback.
|
|
101
|
+
|
|
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
|
+
|
|
104
|
+
## Editing behavior
|
|
105
|
+
|
|
106
|
+
- Cancel restores the currently loaded version.
|
|
107
|
+
- Save is disabled when there are no local changes.
|
|
108
|
+
- A dirty publish saves and publishes with one request.
|
|
109
|
+
- Network failures keep local edits available for retry.
|
|
110
|
+
- Refresh, close, and link/navigation attempts warn while edits are unsaved.
|
|
111
|
+
- Editable text and image fields are visibly labelled in edit mode.
|
|
112
|
+
- The image library supports loading, empty, error, byte/dimension validation, cropping, compression, keyboard, focus, and drag-and-drop states.
|
|
113
|
+
- Expired authorization offers a sign-in action and restores locally persisted edits afterwards.
|
|
114
|
+
- Version conflicts load the latest version while preserving local edits.
|
|
115
|
+
- Public content cache entries are invalidated after authenticated mutations.
|
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, AppointmentPolicyUpsert, 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, ProductDetailSection, 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, ShippingCarrierOption, 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, TaxClass, 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, 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, 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, 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, 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, ShippingCarrierOption, 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, TaxClass, 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
|
|
@@ -135,10 +135,11 @@ declare class FulfillmentsResource {
|
|
|
135
135
|
declare class ReturnsResource {
|
|
136
136
|
private readonly http;
|
|
137
137
|
constructor(http: IHttpService);
|
|
138
|
+
listForTeam(team?: string): Promise<_$_joai_core0.IAppResponse<Return[]>>;
|
|
138
139
|
list(orderId: string, accessToken?: string): Promise<_$_joai_core0.IAppResponse<Return[]>>;
|
|
139
140
|
create(orderId: string, data: {
|
|
140
141
|
reason: string;
|
|
141
|
-
fulfillmentId?:
|
|
142
|
+
fulfillmentId?: string;
|
|
142
143
|
items: {
|
|
143
144
|
orderItemId: number;
|
|
144
145
|
quantity: number;
|
|
@@ -1143,12 +1144,37 @@ declare class LinksResource {
|
|
|
1143
1144
|
declare class LoyaltyResource {
|
|
1144
1145
|
private readonly http;
|
|
1145
1146
|
constructor(http: IHttpService);
|
|
1147
|
+
/**
|
|
1148
|
+
* Program of a team. Without `team` (staff, X-Team set): every collect point; daily ones include `codeToday` and
|
|
1149
|
+
* `codeValidUntil` for signed-in team members (never for agent auth keys). With `team`: public / customer view, active
|
|
1150
|
+
* points only and never today's code; a customer token adds `collected`, `collectedAt` and `nextAvailableAt`.
|
|
1151
|
+
*/
|
|
1146
1152
|
getProgram(params?: {
|
|
1147
1153
|
team?: string;
|
|
1148
1154
|
}): Promise<_$_joai_core0.IAppResponse<LoyaltyProgram>>;
|
|
1155
|
+
/** Customer: join a team's program with the signed-in user's own contact. Idempotent. */
|
|
1156
|
+
join(params: {
|
|
1157
|
+
team: string;
|
|
1158
|
+
}): Promise<_$_joai_core0.IAppResponse<LoyaltyJoinResponse>>;
|
|
1159
|
+
/** Customer: all loyalty accounts of the signed-in user across teams. */
|
|
1160
|
+
getWallet(): Promise<_$_joai_core0.IAppResponse<LoyaltyWalletAccount[]>>;
|
|
1161
|
+
/** Customer: the signed-in user's own transactions on a team's program. */
|
|
1162
|
+
getWalletHistory(params: {
|
|
1163
|
+
team: string;
|
|
1164
|
+
page?: number;
|
|
1165
|
+
}): Promise<_$_joai_core0.IAppResponse<LoyaltyTransaction[]>>;
|
|
1166
|
+
/** Customer: collect at a collect point. Joins the program if needed; replays return `already: true`. */
|
|
1167
|
+
collect(params: {
|
|
1168
|
+
team: string;
|
|
1169
|
+
key: string;
|
|
1170
|
+
code?: string;
|
|
1171
|
+
}): Promise<_$_joai_core0.IAppResponse<LoyaltyCollectResponse>>;
|
|
1172
|
+
/** Staff: update the program. `settings.collect_points` replaces the collect point list (see LoyaltyCollectPointInput). */
|
|
1149
1173
|
updateProgram(data: {
|
|
1150
1174
|
name?: string;
|
|
1151
|
-
settings?: ProgramSettings
|
|
1175
|
+
settings?: ProgramSettings & {
|
|
1176
|
+
collect_points?: LoyaltyCollectPointInput[];
|
|
1177
|
+
};
|
|
1152
1178
|
}): Promise<_$_joai_core0.IAppResponse<LoyaltyProgram>>;
|
|
1153
1179
|
getRewards(): Promise<_$_joai_core0.IAppResponse<LoyaltyReward[]>>;
|
|
1154
1180
|
createReward(data: {
|
|
@@ -1360,6 +1386,8 @@ declare class MessagesResource {
|
|
|
1360
1386
|
generateAudio(messageId: string): Promise<_$_joai_core0.IAppResponse<{
|
|
1361
1387
|
audioUrl: string;
|
|
1362
1388
|
}>>;
|
|
1389
|
+
attachMedia(messageId: string, file: File): Promise<_$_joai_core0.IAppResponse<Message>>;
|
|
1390
|
+
completeMediaImport(messageId: string, file?: File | null): Promise<_$_joai_core0.IAppResponse<Message>>;
|
|
1363
1391
|
storeFeedback(agent: string, message: string, positive: boolean, inquiry: Inquiry | null): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1364
1392
|
toggleReaction(messageId: string, emoji: string): Promise<_$_joai_core0.IAppResponse<{
|
|
1365
1393
|
reactions: Reactions | null;
|
|
@@ -1651,8 +1679,9 @@ declare class ServicesResource {
|
|
|
1651
1679
|
taxClassId?: string | null;
|
|
1652
1680
|
pricingModel?: string;
|
|
1653
1681
|
settings?: Record<string, unknown> | null;
|
|
1682
|
+
order?: number | null;
|
|
1654
1683
|
}): Promise<_$_joai_core0.IAppResponse<Service>>;
|
|
1655
|
-
update(id: string, data: Partial<Pick<Service, 'name' | 'price' | 'description' | 'active' | 'digital' | 'public' | 'bookable' | 'taxClassId'>> & {
|
|
1684
|
+
update(id: string, data: Partial<Pick<Service, 'name' | 'price' | 'description' | 'active' | 'digital' | 'public' | 'bookable' | 'taxClassId' | 'order'>> & {
|
|
1656
1685
|
durationMinutes?: number | null;
|
|
1657
1686
|
settings?: Record<string, unknown> | null;
|
|
1658
1687
|
}): Promise<_$_joai_core0.IAppResponse<Service>>;
|
|
@@ -1883,6 +1912,7 @@ declare class TeamsResource {
|
|
|
1883
1912
|
}): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1884
1913
|
inviteMember(teamSlug: string, email: string, role: UserRole): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1885
1914
|
removeMember(teamSlug: string, memberId: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1915
|
+
updateMemberRole(teamSlug: string, memberId: string, role: UserRole): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1886
1916
|
listMembers(teamSlug: string): Promise<_$_joai_core0.IAppResponse<TeamMember[]>>;
|
|
1887
1917
|
updateLogo(teamSlug: string, logo: string[]): Promise<_$_joai_core0.IAppResponse<TeamPrivate>>;
|
|
1888
1918
|
updateCover(teamSlug: string, cover: string[]): Promise<_$_joai_core0.IAppResponse<TeamPrivate>>;
|
|
@@ -1922,6 +1952,7 @@ declare class ArtifactsResource {
|
|
|
1922
1952
|
update(id: string, payload: ArtifactUpdatePayload): Promise<_$_joai_core0.IAppResponse<Artifact>>;
|
|
1923
1953
|
delete(id: string): Promise<_$_joai_core0.IAppResponse<void>>;
|
|
1924
1954
|
deliver(payload: ArtifactDeliverPayload): Promise<_$_joai_core0.IAppResponse<ArtifactDelivery[]>>;
|
|
1955
|
+
previewDelivery(payload: ArtifactDeliverPayload): Promise<_$_joai_core0.IAppResponse<ArtifactDeliveryPreview>>;
|
|
1925
1956
|
}
|
|
1926
1957
|
//#endregion
|
|
1927
1958
|
//#region src/resources/campaigns.d.ts
|
|
@@ -2404,16 +2435,15 @@ type OpenPortalSessionOptions = {
|
|
|
2404
2435
|
client: PortalClient;
|
|
2405
2436
|
redirect: string;
|
|
2406
2437
|
allowedOrigins: string[];
|
|
2407
|
-
env?: AppEnv;
|
|
2408
|
-
fetcher?: typeof fetch;
|
|
2409
|
-
onNavigate?: (
|
|
2438
|
+
env?: AppEnv; /** @deprecated Unused — exchange happens via same-origin blade form after navigation. */
|
|
2439
|
+
fetcher?: typeof fetch; /** Receives the API callback URL (with fragment token), not the final portal redirect. */
|
|
2440
|
+
onNavigate?: (callbackUrl: string) => void;
|
|
2410
2441
|
};
|
|
2411
2442
|
declare const openPortalSession: ({
|
|
2412
2443
|
client,
|
|
2413
2444
|
redirect,
|
|
2414
2445
|
allowedOrigins,
|
|
2415
2446
|
env,
|
|
2416
|
-
fetcher,
|
|
2417
2447
|
onNavigate
|
|
2418
2448
|
}: OpenPortalSessionOptions) => Promise<boolean>;
|
|
2419
2449
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -180,6 +180,9 @@ var ReturnsResource = class {
|
|
|
180
180
|
constructor(http) {
|
|
181
181
|
this.http = http;
|
|
182
182
|
}
|
|
183
|
+
listForTeam(team) {
|
|
184
|
+
return this.http.get("returns", team ? { headers: { "X-Team": team } } : void 0);
|
|
185
|
+
}
|
|
183
186
|
list(orderId, accessToken) {
|
|
184
187
|
return this.http.get(`orders/${orderId}/returns`, orderAccessHeaders$2(accessToken));
|
|
185
188
|
}
|
|
@@ -1736,10 +1739,33 @@ var LoyaltyResource = class {
|
|
|
1736
1739
|
constructor(http) {
|
|
1737
1740
|
this.http = http;
|
|
1738
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Program of a team. Without `team` (staff, X-Team set): every collect point; daily ones include `codeToday` and
|
|
1744
|
+
* `codeValidUntil` for signed-in team members (never for agent auth keys). With `team`: public / customer view, active
|
|
1745
|
+
* points only and never today's code; a customer token adds `collected`, `collectedAt` and `nextAvailableAt`.
|
|
1746
|
+
*/
|
|
1739
1747
|
getProgram(params) {
|
|
1740
1748
|
const query = params?.team ? `?team=${encodeURIComponent(params.team)}` : "";
|
|
1741
1749
|
return this.http.get(`loyalty/program${query}`);
|
|
1742
1750
|
}
|
|
1751
|
+
/** Customer: join a team's program with the signed-in user's own contact. Idempotent. */
|
|
1752
|
+
join(params) {
|
|
1753
|
+
return this.http.post("loyalty/join", { team: params.team });
|
|
1754
|
+
}
|
|
1755
|
+
/** Customer: all loyalty accounts of the signed-in user across teams. */
|
|
1756
|
+
getWallet() {
|
|
1757
|
+
return this.http.get("loyalty/wallet");
|
|
1758
|
+
}
|
|
1759
|
+
/** Customer: the signed-in user's own transactions on a team's program. */
|
|
1760
|
+
getWalletHistory(params) {
|
|
1761
|
+
const query = params.page ? `?page=${params.page}` : "";
|
|
1762
|
+
return this.http.get(`loyalty/wallet/${encodeURIComponent(params.team)}/history${query}`);
|
|
1763
|
+
}
|
|
1764
|
+
/** Customer: collect at a collect point. Joins the program if needed; replays return `already: true`. */
|
|
1765
|
+
collect(params) {
|
|
1766
|
+
return this.http.post("loyalty/collect", params);
|
|
1767
|
+
}
|
|
1768
|
+
/** Staff: update the program. `settings.collect_points` replaces the collect point list (see LoyaltyCollectPointInput). */
|
|
1743
1769
|
updateProgram(data) {
|
|
1744
1770
|
return this.http.patch("loyalty/program", data);
|
|
1745
1771
|
}
|
|
@@ -2067,6 +2093,17 @@ var MessagesResource = class {
|
|
|
2067
2093
|
generateAudio(messageId) {
|
|
2068
2094
|
return this.http.post(`messages/${messageId}/audio`, {});
|
|
2069
2095
|
}
|
|
2096
|
+
attachMedia(messageId, file) {
|
|
2097
|
+
const form = new FormData();
|
|
2098
|
+
form.append("file", file, file.name);
|
|
2099
|
+
return this.http.post(`messages/${messageId}/media`, form, { isJson: false });
|
|
2100
|
+
}
|
|
2101
|
+
completeMediaImport(messageId, file) {
|
|
2102
|
+
if (!file) return this.http.post(`messages/${messageId}/media-import`, {});
|
|
2103
|
+
const form = new FormData();
|
|
2104
|
+
form.append("file", file, file.name);
|
|
2105
|
+
return this.http.post(`messages/${messageId}/media-import`, form, { isJson: false });
|
|
2106
|
+
}
|
|
2070
2107
|
storeFeedback(agent, message, positive, inquiry) {
|
|
2071
2108
|
return this.http.post("feedback", {
|
|
2072
2109
|
agent,
|
|
@@ -2688,6 +2725,12 @@ var TeamsResource = class {
|
|
|
2688
2725
|
removeMember(teamSlug, memberId) {
|
|
2689
2726
|
return this.http.post(`teams/${teamSlug}/members/remove`, { member: memberId });
|
|
2690
2727
|
}
|
|
2728
|
+
updateMemberRole(teamSlug, memberId, role) {
|
|
2729
|
+
return this.http.post(`teams/${teamSlug}/members/role`, {
|
|
2730
|
+
member: memberId,
|
|
2731
|
+
role
|
|
2732
|
+
});
|
|
2733
|
+
}
|
|
2691
2734
|
listMembers(teamSlug) {
|
|
2692
2735
|
return this.http.get(`teams/${teamSlug}/members`);
|
|
2693
2736
|
}
|
|
@@ -2771,6 +2814,9 @@ var ArtifactsResource = class {
|
|
|
2771
2814
|
deliver(payload) {
|
|
2772
2815
|
return this.http.post("artifacts/deliver", payload);
|
|
2773
2816
|
}
|
|
2817
|
+
previewDelivery(payload) {
|
|
2818
|
+
return this.http.post("artifacts/preview-delivery", payload);
|
|
2819
|
+
}
|
|
2774
2820
|
};
|
|
2775
2821
|
//#endregion
|
|
2776
2822
|
//#region src/resources/campaigns.ts
|
|
@@ -3340,7 +3386,7 @@ var MemoryCache = class {
|
|
|
3340
3386
|
this.store.clear();
|
|
3341
3387
|
}
|
|
3342
3388
|
bust(prefix) {
|
|
3343
|
-
for (const key of this.store.keys()) if (key.startsWith(prefix)) this.store.delete(key);
|
|
3389
|
+
for (const key of this.store.keys()) if (key.startsWith(prefix) || key.startsWith(`/${prefix}`)) this.store.delete(key);
|
|
3344
3390
|
}
|
|
3345
3391
|
};
|
|
3346
3392
|
//#endregion
|
|
@@ -3364,6 +3410,10 @@ const DEFAULTS = {
|
|
|
3364
3410
|
agents: 1e4,
|
|
3365
3411
|
rooms: 1e4
|
|
3366
3412
|
};
|
|
3413
|
+
const RELATED_PREFIXES = {
|
|
3414
|
+
content: ["contents"],
|
|
3415
|
+
contents: ["content"]
|
|
3416
|
+
};
|
|
3367
3417
|
function getTtl(url, ttlMap, defaultTtl) {
|
|
3368
3418
|
for (const [prefix, ttl] of Object.entries(ttlMap)) if (url.startsWith(prefix) || url.startsWith(`/${prefix}`)) return ttl;
|
|
3369
3419
|
return defaultTtl;
|
|
@@ -3451,6 +3501,7 @@ var CachedHttpService = class {
|
|
|
3451
3501
|
bust(prefix) {
|
|
3452
3502
|
this.cacheVersion++;
|
|
3453
3503
|
this.cache.bust(prefix);
|
|
3504
|
+
for (const relatedPrefix of RELATED_PREFIXES[prefix] ?? []) this.cache.bust(relatedPrefix);
|
|
3454
3505
|
}
|
|
3455
3506
|
};
|
|
3456
3507
|
//#endregion
|
|
@@ -3611,19 +3662,18 @@ const completePortalSession = async (callbackUrl, fetcher = fetch) => {
|
|
|
3611
3662
|
return false;
|
|
3612
3663
|
}
|
|
3613
3664
|
};
|
|
3614
|
-
const openPortalSession = async ({ client, redirect, allowedOrigins, env = "mainnet",
|
|
3665
|
+
const openPortalSession = async ({ client, redirect, allowedOrigins, env = "mainnet", onNavigate }) => {
|
|
3615
3666
|
if (!isAllowedRedirectUrl(redirect, allowedOrigins)) return false;
|
|
3616
3667
|
const response = await client.auth.createPortalSession(redirect);
|
|
3617
3668
|
const callbackUrl = sanitizePortalCallbackUrl(response.ok ? response.data?.url : null, env);
|
|
3618
3669
|
if (!callbackUrl) return false;
|
|
3619
|
-
if (!await completePortalSession(callbackUrl, fetcher)) return false;
|
|
3620
3670
|
if (!isAllowedRedirectUrl(redirect, allowedOrigins)) return false;
|
|
3621
3671
|
if (onNavigate) {
|
|
3622
|
-
onNavigate(
|
|
3672
|
+
onNavigate(callbackUrl);
|
|
3623
3673
|
return true;
|
|
3624
3674
|
}
|
|
3625
3675
|
if (typeof window !== "undefined") {
|
|
3626
|
-
window.location.assign(
|
|
3676
|
+
window.location.assign(callbackUrl);
|
|
3627
3677
|
return true;
|
|
3628
3678
|
}
|
|
3629
3679
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joai/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
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": "^
|
|
38
|
+
"@joai/core": "^5.0.1",
|
|
39
39
|
"@joai/warps": "*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@joai/core": "^
|
|
42
|
+
"@joai/core": "^5.0.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"tsdown": "^0.21.0",
|