@joai/sdk 4.5.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -16,6 +16,7 @@ interface IHttpService {
16
16
  onUnauthorized: (response: IAppResponse<any>) => void;
17
17
  onSuccessfulResponse: (response: IAppResponse<any>) => void;
18
18
  onMaintenanceMode: (response: IAppResponse<any>) => void;
19
+ onTooManyRequests: (response: IAppResponse<any>) => void;
19
20
  get: <T>(url: string, options?: IRequestOptions) => Promise<IAppResponse<T>>;
20
21
  post: <T>(url: string, data?: any, options?: IRequestOptions) => Promise<IAppResponse<T>>;
21
22
  put: <T>(url: string, data?: any, options?: IRequestOptions) => Promise<IAppResponse<T>>;
@@ -394,6 +395,37 @@ type ContactFormData = {
394
395
  type ContactCreatePayload = ContactFormData & {
395
396
  name: string;
396
397
  wallets?: WalletList;
398
+ };
399
+ type ContactRelationType = 'parent_of' | 'child_of' | 'spouse_of' | 'sibling_of' | 'aunt_of' | 'nibling_of' | 'manages' | 'reports_to' | 'colleague_of' | 'partner_of' | 'client_of' | 'supplier_of' | 'referred_by' | 'referred';
400
+ type ContactRelationCategory = 'family' | 'organization' | 'business' | 'referral';
401
+ type ContactRelationDirection = 'outgoing' | 'incoming';
402
+ type ContactRelationContact = {
403
+ id: string;
404
+ name: string;
405
+ avatar: string | null;
406
+ company: string | null;
407
+ title: string | null;
408
+ };
409
+ type ContactRelation = {
410
+ id: string;
411
+ type: ContactRelationType;
412
+ category: ContactRelationCategory;
413
+ direction: ContactRelationDirection;
414
+ contact: ContactRelationContact;
415
+ meta: Record<string, JsonValue> | null;
416
+ notes: string | null;
417
+ createdAt: string;
418
+ };
419
+ type ContactRelationPayload = {
420
+ relatedContactId: string;
421
+ type: ContactRelationType;
422
+ notes?: string;
423
+ meta?: Record<string, JsonValue>;
424
+ };
425
+ type ContactRelationUpdatePayload = {
426
+ type?: ContactRelationType;
427
+ notes?: string;
428
+ meta?: Record<string, JsonValue>;
397
429
  }; //#endregion
398
430
  //#region src/media/types.d.ts
399
431
  type MediaLibraryAttributes = {
@@ -996,9 +1028,12 @@ type Order = {
996
1028
  justCreated?: boolean;
997
1029
  createdAt: string;
998
1030
  invoiceDate: string;
1031
+ serviceDate: string;
999
1032
  meta: Record<string, JsonValue> | null;
1000
1033
  contactId: string | null;
1001
1034
  contact?: Contact | null;
1035
+ invoiceContactId?: string | null;
1036
+ invoiceContact?: Contact | null;
1002
1037
  source: OrderSource | null;
1003
1038
  context: OrderContext | null;
1004
1039
  paymentMode: string | null;
@@ -1014,6 +1049,7 @@ type Order = {
1014
1049
  } | null;
1015
1050
  shippingFee?: number;
1016
1051
  fulfillments?: Fulfillment[];
1052
+ returns?: Return[];
1017
1053
  subscription?: Subscription | null;
1018
1054
  configuration?: OrderConfigurationItem[];
1019
1055
  items: OrderItem[];
@@ -1098,7 +1134,7 @@ type Skill = {
1098
1134
  screenshots: string[];
1099
1135
  }; //#endregion
1100
1136
  //#region src/integration/types.d.ts
1101
- type IntegrationType = 'none' | 'webhook' | 'api-token' | 'telegram' | 'slack' | 'whatsapp' | 'whatsapp-personal' | 'twilio' | 'sms' | 'n8n' | 'apple-health' | 'mcp' | 'x' | 'xchat' | 'instagram' | 'grok' | 'email' | 'calendar' | 'embed' | 'discord' | 'github' | 'push' | 'sentry' | 'readwise';
1137
+ type IntegrationType = 'none' | 'webhook' | 'api-token' | 'telegram' | 'slack' | 'whatsapp' | 'whatsapp-personal' | 'twilio' | 'sms' | 'n8n' | 'apple-health' | 'mcp' | 'x' | 'xchat' | 'instagram' | 'grok' | 'cloudflare' | 'email' | 'calendar' | 'embed' | 'discord' | 'github' | 'push' | 'sentry' | 'readwise';
1102
1138
  type IntegrationDetails = {
1103
1139
  type: IntegrationType;
1104
1140
  name: string;
@@ -1634,6 +1670,12 @@ type ArtifactLink = {
1634
1670
  url: string;
1635
1671
  label?: string | null;
1636
1672
  };
1673
+ type ArtifactBlockType = 'heading' | 'richText' | 'metrics' | 'table' | 'callout' | 'actions' | 'media' | 'divider';
1674
+ type ArtifactBlock = {
1675
+ id: string;
1676
+ type: ArtifactBlockType;
1677
+ data: Record<string, unknown>;
1678
+ };
1637
1679
  type ArtifactContactSummary = {
1638
1680
  id: string;
1639
1681
  name: string | null;
@@ -1646,9 +1688,11 @@ type Artifact = {
1646
1688
  status: ArtifactStatus;
1647
1689
  title: string;
1648
1690
  summary: string | null;
1691
+ blocks: ArtifactBlock[] | null;
1649
1692
  url: string | null;
1650
1693
  password: string | null;
1651
1694
  links: ArtifactLink[];
1695
+ media: Media[];
1652
1696
  meta: Record<string, unknown> | null;
1653
1697
  contactId: string | null;
1654
1698
  orderId: string | null;
@@ -1662,22 +1706,27 @@ type ArtifactCreatePayload = {
1662
1706
  type: ArtifactType;
1663
1707
  status?: ArtifactStatus;
1664
1708
  summary?: string;
1709
+ blocks?: ArtifactBlock[];
1665
1710
  url?: string;
1666
1711
  password?: string;
1667
1712
  links?: ArtifactLink[];
1668
1713
  extraLinkUrl?: string;
1669
1714
  extraLinkLabel?: string;
1715
+ media?: string[];
1670
1716
  meta?: Record<string, unknown>;
1671
1717
  contactId?: string;
1672
1718
  orderId?: string;
1673
1719
  };
1674
- type ArtifactUpdatePayload = Partial<ArtifactCreatePayload>;
1720
+ type ArtifactUpdatePayload = Omit<Partial<ArtifactCreatePayload>, 'blocks'> & {
1721
+ blocks?: ArtifactBlock[] | null;
1722
+ };
1675
1723
  type ArtifactDeliverPayload = {
1676
1724
  artifactIds: string[];
1677
1725
  message: string;
1678
1726
  integration: ArtifactDeliverIntegration;
1679
1727
  subject?: string;
1680
1728
  contactIds?: string[];
1729
+ agentId?: string;
1681
1730
  };
1682
1731
  type ArtifactDelivery = {
1683
1732
  id: string;
@@ -1849,6 +1898,88 @@ type AppointmentRequest = {
1849
1898
  configuration?: Configuration;
1850
1899
  createdAt: string;
1851
1900
  }; //#endregion
1901
+ //#region src/automation/types.d.ts
1902
+ type AutomationTriggerType = 'prop' | 'segment' | 'manual';
1903
+ type AutomationActionType = 'wait' | 'send_email' | 'halt';
1904
+ type AutomationSendMode = 'direct' | 'campaign';
1905
+ type AutomationEnrollmentStatus = 'active' | 'completed' | 'skipped';
1906
+ type AutomationSkipReason = 'pending_consent' | 'opted_out' | 'missing_channel' | 'automation_disabled' | 'already_completed';
1907
+ type AutomationTriggerConfig = {
1908
+ propKey?: string;
1909
+ propValue?: string | number | boolean;
1910
+ segmentId?: string;
1911
+ };
1912
+ type AutomationActionConfig = {
1913
+ delayMinutes?: number;
1914
+ sendMode?: AutomationSendMode;
1915
+ campaignId?: string;
1916
+ subject?: string;
1917
+ body?: string;
1918
+ contentHtml?: boolean;
1919
+ sentPropKey?: string;
1920
+ [key: string]: unknown;
1921
+ };
1922
+ type AutomationAction = {
1923
+ id: string;
1924
+ position: number;
1925
+ type: AutomationActionType;
1926
+ config: AutomationActionConfig;
1927
+ };
1928
+ type Automation = {
1929
+ id: string;
1930
+ name: string;
1931
+ triggerType: AutomationTriggerType;
1932
+ triggerConfig: AutomationTriggerConfig;
1933
+ enabled: boolean;
1934
+ agent: AgentSimple | null;
1935
+ actions?: AutomationAction[];
1936
+ createdAt: string;
1937
+ updatedAt: string;
1938
+ };
1939
+ type AutomationEnrollment = {
1940
+ id: string;
1941
+ automationId: string;
1942
+ contactId: string | null;
1943
+ contact?: {
1944
+ id: string;
1945
+ name: string | null;
1946
+ email: string | null;
1947
+ };
1948
+ status: AutomationEnrollmentStatus;
1949
+ currentPosition: number;
1950
+ enteredAt: string | null;
1951
+ eligibleAt: string | null;
1952
+ sentAt: string | null;
1953
+ completedAt: string | null;
1954
+ skippedAt: string | null;
1955
+ skipReason: AutomationSkipReason | null;
1956
+ error: string | null;
1957
+ createdAt: string;
1958
+ updatedAt: string;
1959
+ };
1960
+ type AutomationActionInput = {
1961
+ type: AutomationActionType;
1962
+ config?: AutomationActionConfig;
1963
+ };
1964
+ type AutomationCreatePayload = {
1965
+ name: string;
1966
+ triggerType: AutomationTriggerType;
1967
+ triggerConfig?: AutomationTriggerConfig;
1968
+ actions?: AutomationActionInput[];
1969
+ enabled?: boolean;
1970
+ agentId?: string;
1971
+ };
1972
+ type AutomationUpdatePayload = {
1973
+ name?: string;
1974
+ triggerType?: AutomationTriggerType;
1975
+ triggerConfig?: AutomationTriggerConfig;
1976
+ enabled?: boolean;
1977
+ agentId?: string | null;
1978
+ };
1979
+ type AutomationAudiencePreview = {
1980
+ count: number;
1981
+ sampleContactIds: string[];
1982
+ }; //#endregion
1852
1983
  //#region src/content/types.d.ts
1853
1984
  type ContentStatus = 'draft' | 'published' | 'archived';
1854
1985
  type ContentFieldType = 'text' | 'richText' | 'number' | 'boolean' | 'url' | 'image' | 'media' | 'list' | 'object' | 'reference';
@@ -2227,6 +2358,20 @@ type McpToolCall = {
2227
2358
  createdAt: string;
2228
2359
  };
2229
2360
  //#endregion
2361
+ //#region src/metric/types.d.ts
2362
+ type MetricSource = 'cloudflare';
2363
+ type Metric = {
2364
+ key: string;
2365
+ value: number;
2366
+ unit: string;
2367
+ };
2368
+ type MetricsResult = {
2369
+ source: MetricSource;
2370
+ resource: string;
2371
+ from: string;
2372
+ to: string;
2373
+ metrics: Metric[];
2374
+ }; //#endregion
2230
2375
  //#region src/memory/types.d.ts
2231
2376
  type Memory = {
2232
2377
  id: string;
@@ -2729,9 +2874,14 @@ type SiteAgent = {
2729
2874
  };
2730
2875
  type Site = {
2731
2876
  id: number;
2732
- brandSlug: string;
2877
+ slug: string;
2878
+ brandSlug: string | null;
2733
2879
  customDomain: string | null;
2734
2880
  enabled: boolean;
2881
+ contactId?: string | null;
2882
+ metricsSource?: string | null;
2883
+ metricsResource?: string | null;
2884
+ monthlyReport?: boolean;
2735
2885
  team: SiteTeam | null;
2736
2886
  agent: SiteAgent | null;
2737
2887
  settings: Record<string, JsonValue>;
@@ -2920,7 +3070,7 @@ type LoyaltyMember = {
2920
3070
  updatedAt: string;
2921
3071
  }; //#endregion
2922
3072
  //#region src/segment/types.d.ts
2923
- type SegmentConditionType = 'tag' | 'has_email' | 'has_phone' | 'has_user' | 'last_purchase_after' | 'last_purchase_before' | 'total_order_amount' | 'order_count_at_least' | 'never_purchased' | 'avg_order_value_at_least' | 'last_contact_after' | 'last_contact_before' | 'waiting_on' | 'created_after' | 'created_before' | 'email_contains';
3073
+ type SegmentConditionType = 'tag' | 'has_email' | 'has_phone' | 'has_user' | 'last_purchase_after' | 'last_purchase_before' | 'total_order_amount' | 'order_count_at_least' | 'never_purchased' | 'avg_order_value_at_least' | 'last_contact_after' | 'last_contact_before' | 'waiting_on' | 'created_after' | 'created_before' | 'email_contains' | 'prop' | 'marketing_opt_out';
2924
3074
  type SegmentCondition = {
2925
3075
  type: SegmentConditionType;
2926
3076
  value: string | boolean;
@@ -2952,10 +3102,24 @@ type SegmentCountResult = {
2952
3102
  }; //#endregion
2953
3103
  //#region src/campaign/types.d.ts
2954
3104
  type CampaignChannel = 'email' | 'whatsapp' | 'sms' | 'push';
2955
- type CampaignStatus = 'draft' | 'pending' | 'approved' | 'rejected' | 'sending' | 'completed' | 'failed';
3105
+ type CampaignStatus = 'draft' | 'pending' | 'approved' | 'rejected' | 'scheduled' | 'sending' | 'completed' | 'failed';
2956
3106
  type CampaignCategory = 'MARKETING' | 'UTILITY' | 'AUTHENTICATION';
2957
3107
  type CampaignSkipReason = 'pending_consent' | 'opted_out' | 'missing_channel' | 'approval_skipped';
2958
3108
  type CampaignSkipReasons = Record<CampaignSkipReason, number>;
3109
+ type CampaignRecipientStatus = 'sent' | 'failed' | 'skipped' | 'pending';
3110
+ type CampaignRecipient = {
3111
+ id: string;
3112
+ name: string | null;
3113
+ email: string | null;
3114
+ phone: string | null;
3115
+ status: CampaignRecipientStatus;
3116
+ error: string | null;
3117
+ skipReason: CampaignSkipReason | null;
3118
+ retryable: boolean;
3119
+ sentAt: string | null;
3120
+ openedAt: string | null;
3121
+ clickedAt: string | null;
3122
+ };
2959
3123
  type CampaignAudiencePreview = {
2960
3124
  total: number;
2961
3125
  sendable: number;
@@ -2977,9 +3141,15 @@ type Campaign = {
2977
3141
  channel: CampaignChannel;
2978
3142
  subject: string | null;
2979
3143
  content: string;
3144
+ contentHtml?: boolean;
3145
+ scheduledAt?: string | null;
3146
+ openedCount?: number;
3147
+ clickedCount?: number;
2980
3148
  approval: CampaignApproval;
2981
3149
  agent: AgentSimple | null;
2982
3150
  tags: string[];
3151
+ segmentId?: string | null;
3152
+ contactIds?: string[];
2983
3153
  status: CampaignStatus;
2984
3154
  totalCount: number;
2985
3155
  remainingCount: number;
@@ -2996,6 +3166,7 @@ type CampaignCreatePayload = {
2996
3166
  channel: CampaignChannel;
2997
3167
  subject?: string;
2998
3168
  content: string;
3169
+ contentHtml?: boolean;
2999
3170
  language?: string;
3000
3171
  category?: CampaignCategory;
3001
3172
  templateParams?: Record<string, string>;
@@ -3009,11 +3180,15 @@ type CampaignUpdatePayload = {
3009
3180
  name: string;
3010
3181
  subject?: string;
3011
3182
  content: string;
3183
+ contentHtml?: boolean;
3012
3184
  language?: string;
3013
3185
  category?: CampaignCategory;
3014
3186
  templateParams?: Record<string, string>;
3015
3187
  aiParams?: Record<string, string>;
3016
3188
  agentId?: string;
3189
+ tags?: string[];
3190
+ contactIds?: string[];
3191
+ segmentId?: string;
3017
3192
  };
3018
3193
  type CampaignAudiencePreviewPayload = {
3019
3194
  campaignId: string;
@@ -3027,9 +3202,11 @@ type CampaignStats = {
3027
3202
  totalCampaigns: number;
3028
3203
  draftCampaigns: number;
3029
3204
  totalSent: number;
3205
+ totalOpened?: number;
3206
+ totalClicked?: number;
3030
3207
  }; //#endregion
3031
3208
  //#region src/update/types.d.ts
3032
- type UpdateType = 'deal' | 'event' | 'news';
3209
+ type UpdateType = 'deal' | 'event' | 'news' | 'article';
3033
3210
  type UpdateStatus = 'draft' | 'published' | 'archived';
3034
3211
  type UpdateRelation = 'team';
3035
3212
  type Update = {
@@ -3065,6 +3242,7 @@ type UpdateStats = {
3065
3242
  dealsCount: number;
3066
3243
  eventsCount: number;
3067
3244
  newsCount: number;
3245
+ articlesCount: number;
3068
3246
  publishedCount: number;
3069
3247
  draftCount: number;
3070
3248
  archivedCount: number;
@@ -3865,6 +4043,10 @@ declare class ContactsResource {
3865
4043
  deleteActivity(id: string, activityId: string): Promise<IAppResponse<void>>;
3866
4044
  send(id: string, message: string, subject?: string, integration?: IntegrationType | 'preferred'): Promise<IAppResponse<void>>;
3867
4045
  setProperty(id: string, key: string, value: string): Promise<IAppResponse<void>>;
4046
+ listRelations(id: string): Promise<IAppResponse<ContactRelation[]>>;
4047
+ createRelation(id: string, data: ContactRelationPayload): Promise<IAppResponse<ContactRelation>>;
4048
+ updateRelation(id: string, relationId: string, data: ContactRelationUpdatePayload): Promise<IAppResponse<ContactRelation>>;
4049
+ deleteRelation(id: string, relationId: string): Promise<IAppResponse<void>>;
3868
4050
  }
3869
4051
  //#endregion
3870
4052
  //#region src/resources/contracts.d.ts
@@ -4247,6 +4429,19 @@ declare class MediaResource {
4247
4429
  download(team: string, mediaId: string, name: string, mime: string): Promise<File>;
4248
4430
  }
4249
4431
  //#endregion
4432
+ //#region src/resources/metrics.d.ts
4433
+ type MetricsQuery = {
4434
+ source: MetricSource;
4435
+ resource: string;
4436
+ from: string;
4437
+ to: string;
4438
+ };
4439
+ declare class MetricsResource {
4440
+ private readonly http;
4441
+ constructor(http: IHttpService);
4442
+ query(params: MetricsQuery): Promise<IAppResponse<MetricsResult>>;
4443
+ }
4444
+ //#endregion
4250
4445
  //#region src/resources/meetings.d.ts
4251
4446
  declare class MeetingsResource {
4252
4447
  private readonly http;
@@ -4361,6 +4556,7 @@ declare class OrdersResource {
4361
4556
  get(id: string, accessToken?: string): Promise<IAppResponse<Order>>;
4362
4557
  create(data: {
4363
4558
  contactId?: string;
4559
+ invoiceContactId?: string;
4364
4560
  notes?: string;
4365
4561
  team: string;
4366
4562
  fresh?: boolean;
@@ -4370,6 +4566,8 @@ declare class OrdersResource {
4370
4566
  priceMode?: string;
4371
4567
  type?: OrderType;
4372
4568
  sendConfirmation?: boolean;
4569
+ invoiceDate?: string;
4570
+ serviceDate?: string;
4373
4571
  items?: {
4374
4572
  id?: string;
4375
4573
  type: 'product' | 'service' | 'coupon' | 'custom';
@@ -4396,7 +4594,9 @@ declare class OrdersResource {
4396
4594
  update(id: string, data: {
4397
4595
  status?: OrderStatus;
4398
4596
  date?: string;
4597
+ serviceDate?: string;
4399
4598
  type?: OrderType;
4599
+ invoiceContactId?: string | null;
4400
4600
  }): Promise<IAppResponse<Order>>;
4401
4601
  convertToOrder(id: string): Promise<IAppResponse<Order>>;
4402
4602
  delete(id: string): Promise<IAppResponse<void>>;
@@ -4601,13 +4801,25 @@ declare class SitesResource {
4601
4801
  constructor(http: IHttpService);
4602
4802
  brands(): Promise<IAppResponse<SiteBrand[]>>;
4603
4803
  listMine(teamSlug: string): Promise<IAppResponse<Site[]>>;
4804
+ create(teamSlug: string, slug: string, data?: {
4805
+ contactId?: string | null;
4806
+ metricsSource?: string | null;
4807
+ metricsResource?: string | null;
4808
+ }): Promise<IAppResponse<Site>>;
4809
+ provision(teamSlug: string, brandSlug: string, data?: {
4810
+ settings?: Record<string, unknown>;
4811
+ }): Promise<IAppResponse<Site>>;
4604
4812
  resolve(teamSlug: string, brandSlug?: string): Promise<IAppResponse<Site>>;
4605
4813
  resolveByDomain(domain: string): Promise<IAppResponse<Site>>;
4606
4814
  update(siteId: number, data: {
4607
4815
  customDomain?: string | null;
4608
4816
  enabled?: boolean;
4609
4817
  modules?: string[];
4610
- }): Promise<IAppResponse<void>>;
4818
+ contactId?: string | null;
4819
+ metricsSource?: string | null;
4820
+ metricsResource?: string | null;
4821
+ monthlyReport?: boolean;
4822
+ }): Promise<IAppResponse<Site>>;
4611
4823
  }
4612
4824
  //#endregion
4613
4825
  //#region src/resources/skills.d.ts
@@ -4832,18 +5044,55 @@ declare class CampaignsResource {
4832
5044
  archived?: boolean;
4833
5045
  }): Promise<IAppResponse<Campaign[]>>;
4834
5046
  get(id: string): Promise<IAppResponse<Campaign>>;
5047
+ recipients(id: string, params?: {
5048
+ status?: CampaignRecipientStatus;
5049
+ page?: number;
5050
+ perPage?: number;
5051
+ }): Promise<IAppResponse<CampaignRecipient[]>>;
5052
+ retry(id: string, payload?: {
5053
+ contactIds?: string[];
5054
+ }): Promise<IAppResponse<{
5055
+ retried: number;
5056
+ }>>;
4835
5057
  previewAudience(payload: CampaignAudiencePreviewPayload): Promise<IAppResponse<CampaignAudiencePreview>>;
4836
5058
  create(payload: CampaignCreatePayload): Promise<IAppResponse<Campaign>>;
4837
5059
  update(id: string, payload: CampaignUpdatePayload): Promise<IAppResponse<Campaign>>;
4838
5060
  submitForApproval(id: string): Promise<IAppResponse<Campaign>>;
4839
5061
  refreshApproval(id: string): Promise<IAppResponse<Campaign>>;
4840
- send(id: string): Promise<IAppResponse<Campaign>>;
5062
+ send(id: string, payload?: {
5063
+ scheduledAt?: string;
5064
+ }): Promise<IAppResponse<Campaign>>;
5065
+ sendTest(id: string, payload: {
5066
+ contactId: string;
5067
+ }): Promise<IAppResponse<void>>;
5068
+ cancelSchedule(id: string): Promise<IAppResponse<Campaign>>;
4841
5069
  cancel(id: string): Promise<IAppResponse<Campaign>>;
4842
5070
  archive(id: string): Promise<IAppResponse<Campaign>>;
4843
5071
  unarchive(id: string): Promise<IAppResponse<Campaign>>;
4844
5072
  delete(id: string): Promise<IAppResponse<void>>;
4845
5073
  }
4846
5074
  //#endregion
5075
+ //#region src/resources/automations.d.ts
5076
+ declare class AutomationsResource {
5077
+ private readonly http;
5078
+ constructor(http: IHttpService);
5079
+ list(): Promise<IAppResponse<Automation[]>>;
5080
+ get(id: string): Promise<IAppResponse<Automation>>;
5081
+ create(payload: AutomationCreatePayload): Promise<IAppResponse<Automation>>;
5082
+ update(id: string, payload: AutomationUpdatePayload): Promise<IAppResponse<Automation>>;
5083
+ setActions(id: string, actions: AutomationActionInput[]): Promise<IAppResponse<Automation>>;
5084
+ delete(id: string): Promise<IAppResponse<void>>;
5085
+ enrollments(id: string, params?: {
5086
+ page?: number;
5087
+ perPage?: number;
5088
+ }): Promise<IAppResponse<AutomationEnrollment[]>>;
5089
+ run(id: string, payload: {
5090
+ contactId: string;
5091
+ }): Promise<IAppResponse<AutomationEnrollment>>;
5092
+ retryEnrollment(id: string, enrollmentId: string): Promise<IAppResponse<AutomationEnrollment>>;
5093
+ previewAudience(id: string): Promise<IAppResponse<AutomationAudiencePreview>>;
5094
+ }
5095
+ //#endregion
4847
5096
  //#region src/resources/segments.d.ts
4848
5097
  declare class SegmentsResource {
4849
5098
  private readonly http;
@@ -4853,7 +5102,10 @@ declare class SegmentsResource {
4853
5102
  update(id: string, payload: SegmentCreatePayload): Promise<IAppResponse<Segment>>;
4854
5103
  delete(id: string): Promise<IAppResponse<void>>;
4855
5104
  count(payload: SegmentCountPayload): Promise<IAppResponse<SegmentCountResult>>;
4856
- contacts(id: string): Promise<IAppResponse<Contact[]>>;
5105
+ contacts(id: string, params?: {
5106
+ page?: number;
5107
+ perPage?: number;
5108
+ }): Promise<IAppResponse<Contact[]>>;
4857
5109
  }
4858
5110
  //#endregion
4859
5111
  //#region src/resources/updates.d.ts
@@ -4867,6 +5119,10 @@ declare class UpdatesResource {
4867
5119
  active?: boolean;
4868
5120
  tags?: string;
4869
5121
  with?: UpdateRelation[];
5122
+ sort?: string;
5123
+ limit?: number;
5124
+ upcoming?: boolean;
5125
+ past?: boolean;
4870
5126
  }): Promise<IAppResponse<Update[]>>;
4871
5127
  create(payload: UpdateCreatePayload): Promise<IAppResponse<Update>>;
4872
5128
  update(id: string, payload: UpdateUpdatePayload): Promise<IAppResponse<Update>>;
@@ -5143,6 +5399,7 @@ declare class JoAiClient {
5143
5399
  readonly loyalty: LoyaltyResource;
5144
5400
  readonly store: StoreResource;
5145
5401
  readonly media: MediaResource;
5402
+ readonly metrics: MetricsResource;
5146
5403
  readonly meetings: MeetingsResource;
5147
5404
  readonly memories: MemoriesResource;
5148
5405
  readonly messages: MessagesResource;
@@ -5171,6 +5428,7 @@ declare class JoAiClient {
5171
5428
  readonly teams: TeamsResource;
5172
5429
  readonly artifacts: ArtifactsResource;
5173
5430
  readonly campaigns: CampaignsResource;
5431
+ readonly automations: AutomationsResource;
5174
5432
  readonly segments: SegmentsResource;
5175
5433
  readonly updates: UpdatesResource;
5176
5434
  readonly upgrades: UpgradesResource;
@@ -5195,12 +5453,17 @@ declare class CachedHttpService implements IHttpService {
5195
5453
  private ttlMap;
5196
5454
  private defaultTtl;
5197
5455
  private cacheVersion;
5198
- onNetworkError: (error: Error) => void;
5199
- onUnauthorized: (response: IAppResponse<JsonValue>) => void;
5200
- onSuccessfulResponse: (response: IAppResponse<JsonValue>) => void;
5201
- onMaintenanceMode: (response: IAppResponse<JsonValue>) => void;
5202
- onTooManyRequests: (response: IAppResponse<JsonValue>) => void;
5203
5456
  constructor(inner: IHttpService, overrides?: TtlMap, defaultTtl?: number);
5457
+ get onNetworkError(): (error: Error) => void;
5458
+ set onNetworkError(fn: (error: Error) => void);
5459
+ get onUnauthorized(): (response: IAppResponse<JsonValue>) => void;
5460
+ set onUnauthorized(fn: (response: IAppResponse<JsonValue>) => void);
5461
+ get onSuccessfulResponse(): (response: IAppResponse<JsonValue>) => void;
5462
+ set onSuccessfulResponse(fn: (response: IAppResponse<JsonValue>) => void);
5463
+ get onMaintenanceMode(): (response: IAppResponse<JsonValue>) => void;
5464
+ set onMaintenanceMode(fn: (response: IAppResponse<JsonValue>) => void);
5465
+ get onTooManyRequests(): (response: IAppResponse<JsonValue>) => void;
5466
+ set onTooManyRequests(fn: (response: IAppResponse<JsonValue>) => void);
5204
5467
  clearCache(): void;
5205
5468
  get<T>(url: string, options?: IRequestOptions): Promise<IAppResponse<T>>;
5206
5469
  post<T>(url: string, data?: JsonValue | FormData, options?: IRequestOptions): Promise<IAppResponse<T>>;
@@ -5245,4 +5508,4 @@ declare class DistributionResource {
5245
5508
  private fetchDistribution;
5246
5509
  }
5247
5510
  //#endregion
5248
- export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, type FulfillmentLocationInput, FulfillmentsResource, GoalsResource, type GuestBuyer, type GuestCheckoutDraft, type GuestCommerceStorageOptions, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type PlaceCheckoutOrderRequest, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
5511
+ export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, type AttachedMedia, type AuthConfirmCodeRequest, type AuthConfirmCodeResponse, type AuthNativeSessionResponse, type AuthPortalSessionResponse, AuthResource, type AuthSendCodeRequest, AutomationsResource, type BackendWarp, type BackendWarpBrand, BillingResource, BlueprintsResource, type CacheConfig, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, type CreateHookPayload, type CreateInboundHookPayload, type CreateInternalHookPayload, type CreateWarpLinkedHookPayload, type CreateWebHookPayload, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, type FulfillmentLocationInput, FulfillmentsResource, GoalsResource, type GuestBuyer, type GuestCheckoutDraft, type GuestCommerceStorageOptions, type GuestOrderAccess, type Hook, type HookSample, type HookTrigger, type HookTriggerCondition, type HookTriggerInput, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, type JoAiClientConfig, KvResource, LinksResource, LoyaltyResource, McpResource, type MediaUploadType, MeetingsResource, MemoriesResource, MessagesResource, MetricsResource, MissionsResource, NotificationsResource, OfficeResource, type OpenPortalSessionOptions, type OpeningHoursEntry, type OpeningHoursFormatOptions, OrdersResource, PersonaResource, type PlaceCheckoutOrderRequest, type Product, type ProductVariation, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, type ShippingRateInput, ShippingResource, type ShippingZoneInput, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, type TeamInviteInfo, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, type WebHookTriggerEvent, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
package/dist/index.mjs CHANGED
@@ -1127,6 +1127,18 @@ var ContactsResource = class {
1127
1127
  value
1128
1128
  });
1129
1129
  }
1130
+ listRelations(id) {
1131
+ return this.http.get(`contacts/${id}/relations`);
1132
+ }
1133
+ createRelation(id, data) {
1134
+ return this.http.post(`contacts/${id}/relations`, data);
1135
+ }
1136
+ updateRelation(id, relationId, data) {
1137
+ return this.http.put(`contacts/${id}/relations/${relationId}`, data);
1138
+ }
1139
+ deleteRelation(id, relationId) {
1140
+ return this.http.delete(`contacts/${id}/relations/${relationId}`);
1141
+ }
1130
1142
  };
1131
1143
  //#endregion
1132
1144
  //#region src/resources/contracts.ts
@@ -1722,6 +1734,17 @@ var MediaResource = class {
1722
1734
  }
1723
1735
  };
1724
1736
  //#endregion
1737
+ //#region src/resources/metrics.ts
1738
+ var MetricsResource = class {
1739
+ constructor(http) {
1740
+ this.http = http;
1741
+ }
1742
+ query(params) {
1743
+ const query = new URLSearchParams(params);
1744
+ return this.http.get(`metrics?${query}`);
1745
+ }
1746
+ };
1747
+ //#endregion
1725
1748
  //#region src/resources/meetings.ts
1726
1749
  var MeetingsResource = class {
1727
1750
  constructor(http, config) {
@@ -2152,6 +2175,16 @@ var SitesResource = class {
2152
2175
  listMine(teamSlug) {
2153
2176
  return this.http.get(`sites/mine?team=${encodeURIComponent(teamSlug)}`);
2154
2177
  }
2178
+ create(teamSlug, slug, data) {
2179
+ return this.http.post("sites", {
2180
+ team: teamSlug,
2181
+ slug,
2182
+ ...data
2183
+ });
2184
+ }
2185
+ provision(teamSlug, brandSlug, data) {
2186
+ return this.http.post(`sites/${encodeURIComponent(brandSlug)}/provision`, data ?? {}, { headers: { "X-Team": teamSlug } });
2187
+ }
2155
2188
  resolve(teamSlug, brandSlug) {
2156
2189
  const query = brandSlug ? `team=${encodeURIComponent(teamSlug)}&brand=${encodeURIComponent(brandSlug)}` : `team=${encodeURIComponent(teamSlug)}`;
2157
2190
  return this.http.get(`sites/resolve?${query}`);
@@ -2509,6 +2542,17 @@ var CampaignsResource = class {
2509
2542
  get(id) {
2510
2543
  return this.http.get(`campaigns/${id}`);
2511
2544
  }
2545
+ recipients(id, params) {
2546
+ const search = new URLSearchParams();
2547
+ if (params?.status) search.set("status", params.status);
2548
+ if (params?.page) search.set("page", String(params.page));
2549
+ if (params?.perPage) search.set("perPage", String(params.perPage));
2550
+ const query = search.toString();
2551
+ return this.http.get(`campaigns/${id}/recipients${query ? `?${query}` : ""}`);
2552
+ }
2553
+ retry(id, payload) {
2554
+ return this.http.post(`campaigns/${id}/retry`, payload ?? {});
2555
+ }
2512
2556
  previewAudience(payload) {
2513
2557
  return this.http.get(`campaigns/audience-preview${audiencePreviewQuery(payload)}`);
2514
2558
  }
@@ -2524,8 +2568,14 @@ var CampaignsResource = class {
2524
2568
  refreshApproval(id) {
2525
2569
  return this.http.post(`campaigns/${id}/refresh`);
2526
2570
  }
2527
- send(id) {
2528
- return this.http.post(`campaigns/${id}/send`);
2571
+ send(id, payload) {
2572
+ return this.http.post(`campaigns/${id}/send`, payload ?? {});
2573
+ }
2574
+ sendTest(id, payload) {
2575
+ return this.http.post(`campaigns/${id}/send-test`, payload);
2576
+ }
2577
+ cancelSchedule(id) {
2578
+ return this.http.post(`campaigns/${id}/cancel-schedule`);
2529
2579
  }
2530
2580
  cancel(id) {
2531
2581
  return this.http.post(`campaigns/${id}/cancel`);
@@ -2553,6 +2603,47 @@ const audiencePreviewQuery = (payload) => {
2553
2603
  return query ? `?${query}` : "";
2554
2604
  };
2555
2605
  //#endregion
2606
+ //#region src/resources/automations.ts
2607
+ var AutomationsResource = class {
2608
+ constructor(http) {
2609
+ this.http = http;
2610
+ }
2611
+ list() {
2612
+ return this.http.get("automations");
2613
+ }
2614
+ get(id) {
2615
+ return this.http.get(`automations/${id}`);
2616
+ }
2617
+ create(payload) {
2618
+ return this.http.post("automations", payload);
2619
+ }
2620
+ update(id, payload) {
2621
+ return this.http.put(`automations/${id}`, payload);
2622
+ }
2623
+ setActions(id, actions) {
2624
+ return this.http.put(`automations/${id}/actions`, { actions });
2625
+ }
2626
+ delete(id) {
2627
+ return this.http.delete(`automations/${id}`);
2628
+ }
2629
+ enrollments(id, params) {
2630
+ const search = new URLSearchParams();
2631
+ if (params?.page) search.set("page", String(params.page));
2632
+ if (params?.perPage) search.set("perPage", String(params.perPage));
2633
+ const query = search.toString();
2634
+ return this.http.get(`automations/${id}/enrollments${query ? `?${query}` : ""}`);
2635
+ }
2636
+ run(id, payload) {
2637
+ return this.http.post(`automations/${id}/run`, payload);
2638
+ }
2639
+ retryEnrollment(id, enrollmentId) {
2640
+ return this.http.post(`automations/${id}/enrollments/${enrollmentId}/retry`);
2641
+ }
2642
+ previewAudience(id) {
2643
+ return this.http.get(`automations/${id}/audience-preview`);
2644
+ }
2645
+ };
2646
+ //#endregion
2556
2647
  //#region src/resources/segments.ts
2557
2648
  var SegmentsResource = class {
2558
2649
  constructor(http) {
@@ -2573,8 +2664,12 @@ var SegmentsResource = class {
2573
2664
  count(payload) {
2574
2665
  return this.http.post("segments/count", payload);
2575
2666
  }
2576
- contacts(id) {
2577
- return this.http.get(`segments/${id}/contacts`);
2667
+ contacts(id, params) {
2668
+ const search = new URLSearchParams();
2669
+ if (params?.page != null) search.set("page", String(params.page));
2670
+ if (params?.perPage != null) search.set("perPage", String(params.perPage));
2671
+ const query = search.toString();
2672
+ return this.http.get(`segments/${id}/contacts${query ? `?${query}` : ""}`);
2578
2673
  }
2579
2674
  };
2580
2675
  //#endregion
@@ -2591,6 +2686,10 @@ var UpdatesResource = class {
2591
2686
  if (params?.active != null) query.set("active", String(params.active));
2592
2687
  if (params?.tags) query.set("tags", params.tags);
2593
2688
  if (params?.with?.length) query.set("with", params.with.join(","));
2689
+ if (params?.sort) query.set("sort", params.sort);
2690
+ if (params?.limit != null) query.set("limit", String(params.limit));
2691
+ if (params?.upcoming) query.set("filter[upcoming]", "1");
2692
+ if (params?.past) query.set("filter[past]", "1");
2594
2693
  const qs = query.toString();
2595
2694
  return this.http.get(`updates${qs ? "?" + qs : ""}`);
2596
2695
  }
@@ -2979,11 +3078,6 @@ var CachedHttpService = class {
2979
3078
  this.inner = inner;
2980
3079
  this.cache = new MemoryCache();
2981
3080
  this.cacheVersion = 0;
2982
- this.onNetworkError = () => {};
2983
- this.onUnauthorized = () => {};
2984
- this.onSuccessfulResponse = () => {};
2985
- this.onMaintenanceMode = () => {};
2986
- this.onTooManyRequests = () => {};
2987
3081
  this.baseUrl = inner.baseUrl;
2988
3082
  this.authToken = inner.authToken;
2989
3083
  this.ttlMap = {
@@ -2992,6 +3086,36 @@ var CachedHttpService = class {
2992
3086
  };
2993
3087
  this.defaultTtl = defaultTtl ?? DEFAULT_TTL;
2994
3088
  }
3089
+ get onNetworkError() {
3090
+ return this.inner.onNetworkError;
3091
+ }
3092
+ set onNetworkError(fn) {
3093
+ this.inner.onNetworkError = fn;
3094
+ }
3095
+ get onUnauthorized() {
3096
+ return this.inner.onUnauthorized;
3097
+ }
3098
+ set onUnauthorized(fn) {
3099
+ this.inner.onUnauthorized = fn;
3100
+ }
3101
+ get onSuccessfulResponse() {
3102
+ return this.inner.onSuccessfulResponse;
3103
+ }
3104
+ set onSuccessfulResponse(fn) {
3105
+ this.inner.onSuccessfulResponse = fn;
3106
+ }
3107
+ get onMaintenanceMode() {
3108
+ return this.inner.onMaintenanceMode;
3109
+ }
3110
+ set onMaintenanceMode(fn) {
3111
+ this.inner.onMaintenanceMode = fn;
3112
+ }
3113
+ get onTooManyRequests() {
3114
+ return this.inner.onTooManyRequests;
3115
+ }
3116
+ set onTooManyRequests(fn) {
3117
+ this.inner.onTooManyRequests = fn;
3118
+ }
2995
3119
  clearCache() {
2996
3120
  this.cacheVersion++;
2997
3121
  this.cache.clear();
@@ -3086,6 +3210,7 @@ var JoAiClient = class {
3086
3210
  this.loyalty = new LoyaltyResource(this.http);
3087
3211
  this.store = new StoreResource(this.http);
3088
3212
  this.media = new MediaResource(this.http);
3213
+ this.metrics = new MetricsResource(this.http);
3089
3214
  this.meetings = new MeetingsResource(this.http, config);
3090
3215
  this.memories = new MemoriesResource(this.http);
3091
3216
  this.messages = new MessagesResource(this.http);
@@ -3114,6 +3239,7 @@ var JoAiClient = class {
3114
3239
  this.teams = new TeamsResource(this.http);
3115
3240
  this.artifacts = new ArtifactsResource(this.http);
3116
3241
  this.campaigns = new CampaignsResource(this.http);
3242
+ this.automations = new AutomationsResource(this.http);
3117
3243
  this.segments = new SegmentsResource(this.http);
3118
3244
  this.updates = new UpdatesResource(this.http);
3119
3245
  this.upgrades = new UpgradesResource(this.http);
@@ -3229,4 +3355,4 @@ var DistributionResource = class {
3229
3355
  }
3230
3356
  };
3231
3357
  //#endregion
3232
- export { AddressesResource, AgentsResource, AlertsResource, ApiTokensResource, AppointmentsResource, AuthResource, BillingResource, BlueprintsResource, CachedHttpService, CampaignsResource, CardsResource, CartsResource, ChangelogResource, CharactersResource, CheckoutResource, CommerceResource, ContactsResource, ContentResource, ContractsResource, DeskResource, DistributionResource, DocumentsResource, ElementsResource, EntitiesResource, FlowsResource, FulfillmentsResource, GoalsResource, HooksResource, IngestionsResource, InquiriesResource, IntegrationsResource, IntentsResource, ItemsResource, JoAiClient, KvResource, LinksResource, LoyaltyResource, McpResource, MeetingsResource, MemoriesResource, MessagesResource, MissionsResource, NotificationsResource, OfficeResource, OrdersResource, PersonaResource, ProductsResource, ProjectsResource, RemindersResource, ReturnsResource, SegmentsResource, ServicesResource, ShippingResource, ShortcutsResource, SitesResource, SkillsResource, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
3358
+ 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, 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, StatsResource, StoreResource, SubscriptionsResource, SwarmsResource, TagsResource, TasksResource, TeamsResource, UpdatesResource, UpgradesResource, UsersResource, VoiceResource, WalletsResource, WarpsResource, WorkspaceResource, completePortalSession, createClient, createGuestCommerceStorage, formatOpeningHours, getAuthFragmentToken, isAllowedRedirectUrl, isPortalCallbackUrl, openPortalSession, sanitizePortalCallbackUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/sdk",
3
- "version": "4.5.0",
3
+ "version": "4.7.0",
4
4
  "description": "JoAi public API SDK — build with your AI agents",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "@joai/warps": "*"
39
39
  },
40
40
  "devDependencies": {
41
- "@joai/core": "^4.10.0",
41
+ "@joai/core": "^4.12.0",
42
42
  "tsdown": "^0.21.0",
43
43
  "typescript": "^5.9.3"
44
44
  }