@cimplify/sdk 0.28.0 → 0.30.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.
@@ -1,2 +1,2 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, N as CimplifyElement, M as CimplifyElements, Y as ELEMENT_TYPES, X as EVENT_TYPES, a0 as ElementEventType, _ as ElementOptions, $ as ElementType, Z as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, W as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, V as createElements, m as generateIdempotencyKey } from './index-ClrQ0yTH.mjs';
2
- import './payment-k8feV7r8.mjs';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-DaXyvlxk.mjs';
2
+ import './payment-DnU_eLuT.mjs';
@@ -1,2 +1,2 @@
1
- export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, N as CimplifyElement, M as CimplifyElements, Y as ELEMENT_TYPES, X as EVENT_TYPES, a0 as ElementEventType, _ as ElementOptions, $ as ElementType, Z as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, W as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, V as createElements, m as generateIdempotencyKey } from './index-iHKILmG9.js';
2
- import './payment-k8feV7r8.js';
1
+ export { A as AuthService, B as BusinessService, j as CartOperations, b as CatalogueQueries, l as CheckoutOperations, l as CheckoutService, a7 as CimplifyElement, a6 as CimplifyElements, ab as ELEMENT_TYPES, aa as EVENT_TYPES, af as ElementEventType, ad as ElementOptions, ae as ElementType, ac as ElementsOptions, F as FetchQuoteInput, s as FxService, G as GetProductsOptions, I as InventoryService, L as LinkService, r as LiteService, a9 as MESSAGE_TYPES, O as OrderQueries, P as PriceQuote, d as QuoteBundleSelectionInput, Q as QuoteCompositeSelectionInput, f as QuoteDynamicBuckets, e as QuoteStatus, g as QuoteUiMessage, R as RefreshQuoteInput, i as RefreshQuoteResult, q as SchedulingService, a8 as createElements, m as generateIdempotencyKey } from './index-DTdtu4OO.js';
2
+ import './payment-DnU_eLuT.js';
@@ -96,6 +96,84 @@ var SubscriptionService = class {
96
96
  }
97
97
  };
98
98
 
99
+ // src/uploads.ts
100
+ var UploadService = class {
101
+ constructor(client) {
102
+ this.client = client;
103
+ }
104
+ async init(filename, contentType, sizeBytes) {
105
+ return chunk2CGA3MUW_js.safe(
106
+ this.client.post("/api/v1/uploads/init", {
107
+ filename,
108
+ content_type: contentType,
109
+ size_bytes: sizeBytes
110
+ })
111
+ );
112
+ }
113
+ async confirm(uploadId) {
114
+ return chunk2CGA3MUW_js.safe(
115
+ this.client.post("/api/v1/uploads/confirm", {
116
+ upload_id: uploadId
117
+ })
118
+ );
119
+ }
120
+ async upload(file) {
121
+ const initResult = await this.init(file.name, file.type, file.size);
122
+ if (!initResult.ok) return initResult;
123
+ const { upload_id, upload_url } = initResult.value;
124
+ try {
125
+ const uploadResponse = await fetch(upload_url, {
126
+ method: "PUT",
127
+ body: file,
128
+ headers: { "Content-Type": file.type }
129
+ });
130
+ if (!uploadResponse.ok) {
131
+ return {
132
+ ok: false,
133
+ error: new chunkPEDLCL72_js.CimplifyError(
134
+ "UPLOAD_FAILED",
135
+ `Upload failed with status ${uploadResponse.status}`,
136
+ true
137
+ )
138
+ };
139
+ }
140
+ } catch (error) {
141
+ return {
142
+ ok: false,
143
+ error: new chunkPEDLCL72_js.CimplifyError(
144
+ "UPLOAD_FAILED",
145
+ error instanceof Error ? error.message : "Upload failed",
146
+ true
147
+ )
148
+ };
149
+ }
150
+ return this.confirm(upload_id);
151
+ }
152
+ };
153
+
154
+ // src/places.ts
155
+ var PlacesService = class {
156
+ constructor(client) {
157
+ this.client = client;
158
+ }
159
+ async autocomplete(input, sessionToken) {
160
+ return chunk2CGA3MUW_js.safe(
161
+ this.client.post("/api/v1/places/autocomplete", {
162
+ input,
163
+ sessionToken
164
+ })
165
+ );
166
+ }
167
+ async details(placeId, sessionToken) {
168
+ return chunk2CGA3MUW_js.safe(
169
+ this.client.post("/api/v1/places/details", {
170
+ place_id: placeId,
171
+ sessionToken
172
+ })
173
+ );
174
+ }
175
+ };
176
+
99
177
  // src/delivery.ts
100
178
  var DeliveryService = class {
101
179
  constructor(client) {
@@ -112,6 +190,36 @@ var DeliveryService = class {
112
190
  }
113
191
  };
114
192
 
193
+ // src/support.ts
194
+ var SupportService = class {
195
+ constructor(client) {
196
+ this.client = client;
197
+ }
198
+ /** Open (or resume) the customer's widget conversation. */
199
+ async openConversation() {
200
+ return chunk2CGA3MUW_js.safe(
201
+ this.client.post("/api/v1/support/conversation")
202
+ );
203
+ }
204
+ /** Send a message in the active conversation. */
205
+ async sendMessage(content) {
206
+ return chunk2CGA3MUW_js.safe(
207
+ this.client.post("/api/v1/support/conversation/messages", {
208
+ content
209
+ })
210
+ );
211
+ }
212
+ /** Poll for new messages since the given cursor. */
213
+ async getMessages(options = {}) {
214
+ const params = new URLSearchParams();
215
+ if (options.after) params.set("after", options.after);
216
+ if (options.limit) params.set("limit", String(options.limit));
217
+ const query = params.toString();
218
+ const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
219
+ return chunk2CGA3MUW_js.safe(this.client.get(path));
220
+ }
221
+ };
222
+
115
223
  // src/client.ts
116
224
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
117
225
  var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
@@ -665,6 +773,18 @@ var CimplifyClient = class {
665
773
  }
666
774
  return this._subscriptions;
667
775
  }
776
+ get uploads() {
777
+ if (!this._uploads) {
778
+ this._uploads = new UploadService(this);
779
+ }
780
+ return this._uploads;
781
+ }
782
+ get places() {
783
+ if (!this._places) {
784
+ this._places = new PlacesService(this);
785
+ }
786
+ return this._places;
787
+ }
668
788
  get link() {
669
789
  if (!this._link) {
670
790
  this._link = new chunk2CGA3MUW_js.LinkService(this);
@@ -719,6 +839,12 @@ var CimplifyClient = class {
719
839
  }
720
840
  return this._delivery;
721
841
  }
842
+ get support() {
843
+ if (!this._support) {
844
+ this._support = new SupportService(this);
845
+ }
846
+ return this._support;
847
+ }
722
848
  elements(businessId, options) {
723
849
  if (businessId) {
724
850
  this.setBusinessId(businessId);
@@ -789,13 +915,39 @@ var DURATION_UNIT = {
789
915
  Months: "months",
790
916
  Years: "years"
791
917
  };
918
+ var INPUT_FIELD_TYPE = {
919
+ Text: "text",
920
+ Textarea: "textarea",
921
+ Number: "number",
922
+ Select: "select",
923
+ Radio: "radio",
924
+ Checkbox: "checkbox",
925
+ Color: "color",
926
+ Date: "date",
927
+ File: "file",
928
+ Image: "image",
929
+ Url: "url",
930
+ Address: "address",
931
+ Phone: "phone",
932
+ Email: "email",
933
+ DateTime: "date_time",
934
+ Time: "time",
935
+ Signature: "signature",
936
+ MultiSelect: "multi_select",
937
+ DateRange: "date_range",
938
+ Location: "location"
939
+ };
792
940
 
793
941
  exports.ActivityService = ActivityService;
794
942
  exports.CimplifyClient = CimplifyClient;
795
943
  exports.DURATION_UNIT = DURATION_UNIT;
796
944
  exports.DeliveryService = DeliveryService;
945
+ exports.INPUT_FIELD_TYPE = INPUT_FIELD_TYPE;
797
946
  exports.PRODUCT_TYPE = PRODUCT_TYPE;
947
+ exports.PlacesService = PlacesService;
798
948
  exports.RENDER_HINT = RENDER_HINT;
799
949
  exports.SubscriptionService = SubscriptionService;
950
+ exports.SupportService = SupportService;
951
+ exports.UploadService = UploadService;
800
952
  exports.createCimplifyClient = createCimplifyClient;
801
953
  exports.getVariantDisplayName = getVariantDisplayName;
@@ -94,6 +94,84 @@ var SubscriptionService = class {
94
94
  }
95
95
  };
96
96
 
97
+ // src/uploads.ts
98
+ var UploadService = class {
99
+ constructor(client) {
100
+ this.client = client;
101
+ }
102
+ async init(filename, contentType, sizeBytes) {
103
+ return safe(
104
+ this.client.post("/api/v1/uploads/init", {
105
+ filename,
106
+ content_type: contentType,
107
+ size_bytes: sizeBytes
108
+ })
109
+ );
110
+ }
111
+ async confirm(uploadId) {
112
+ return safe(
113
+ this.client.post("/api/v1/uploads/confirm", {
114
+ upload_id: uploadId
115
+ })
116
+ );
117
+ }
118
+ async upload(file) {
119
+ const initResult = await this.init(file.name, file.type, file.size);
120
+ if (!initResult.ok) return initResult;
121
+ const { upload_id, upload_url } = initResult.value;
122
+ try {
123
+ const uploadResponse = await fetch(upload_url, {
124
+ method: "PUT",
125
+ body: file,
126
+ headers: { "Content-Type": file.type }
127
+ });
128
+ if (!uploadResponse.ok) {
129
+ return {
130
+ ok: false,
131
+ error: new CimplifyError(
132
+ "UPLOAD_FAILED",
133
+ `Upload failed with status ${uploadResponse.status}`,
134
+ true
135
+ )
136
+ };
137
+ }
138
+ } catch (error) {
139
+ return {
140
+ ok: false,
141
+ error: new CimplifyError(
142
+ "UPLOAD_FAILED",
143
+ error instanceof Error ? error.message : "Upload failed",
144
+ true
145
+ )
146
+ };
147
+ }
148
+ return this.confirm(upload_id);
149
+ }
150
+ };
151
+
152
+ // src/places.ts
153
+ var PlacesService = class {
154
+ constructor(client) {
155
+ this.client = client;
156
+ }
157
+ async autocomplete(input, sessionToken) {
158
+ return safe(
159
+ this.client.post("/api/v1/places/autocomplete", {
160
+ input,
161
+ sessionToken
162
+ })
163
+ );
164
+ }
165
+ async details(placeId, sessionToken) {
166
+ return safe(
167
+ this.client.post("/api/v1/places/details", {
168
+ place_id: placeId,
169
+ sessionToken
170
+ })
171
+ );
172
+ }
173
+ };
174
+
97
175
  // src/delivery.ts
98
176
  var DeliveryService = class {
99
177
  constructor(client) {
@@ -110,6 +188,36 @@ var DeliveryService = class {
110
188
  }
111
189
  };
112
190
 
191
+ // src/support.ts
192
+ var SupportService = class {
193
+ constructor(client) {
194
+ this.client = client;
195
+ }
196
+ /** Open (or resume) the customer's widget conversation. */
197
+ async openConversation() {
198
+ return safe(
199
+ this.client.post("/api/v1/support/conversation")
200
+ );
201
+ }
202
+ /** Send a message in the active conversation. */
203
+ async sendMessage(content) {
204
+ return safe(
205
+ this.client.post("/api/v1/support/conversation/messages", {
206
+ content
207
+ })
208
+ );
209
+ }
210
+ /** Poll for new messages since the given cursor. */
211
+ async getMessages(options = {}) {
212
+ const params = new URLSearchParams();
213
+ if (options.after) params.set("after", options.after);
214
+ if (options.limit) params.set("limit", String(options.limit));
215
+ const query = params.toString();
216
+ const path = query ? `/api/v1/support/conversation/messages?${query}` : "/api/v1/support/conversation/messages";
217
+ return safe(this.client.get(path));
218
+ }
219
+ };
220
+
113
221
  // src/client.ts
114
222
  var ACCESS_TOKEN_STORAGE_KEY = "cimplify_access_token";
115
223
  var SESSION_TOKEN_STORAGE_KEY = "cimplify_session_token";
@@ -663,6 +771,18 @@ var CimplifyClient = class {
663
771
  }
664
772
  return this._subscriptions;
665
773
  }
774
+ get uploads() {
775
+ if (!this._uploads) {
776
+ this._uploads = new UploadService(this);
777
+ }
778
+ return this._uploads;
779
+ }
780
+ get places() {
781
+ if (!this._places) {
782
+ this._places = new PlacesService(this);
783
+ }
784
+ return this._places;
785
+ }
666
786
  get link() {
667
787
  if (!this._link) {
668
788
  this._link = new LinkService(this);
@@ -717,6 +837,12 @@ var CimplifyClient = class {
717
837
  }
718
838
  return this._delivery;
719
839
  }
840
+ get support() {
841
+ if (!this._support) {
842
+ this._support = new SupportService(this);
843
+ }
844
+ return this._support;
845
+ }
720
846
  elements(businessId, options) {
721
847
  if (businessId) {
722
848
  this.setBusinessId(businessId);
@@ -787,5 +913,27 @@ var DURATION_UNIT = {
787
913
  Months: "months",
788
914
  Years: "years"
789
915
  };
916
+ var INPUT_FIELD_TYPE = {
917
+ Text: "text",
918
+ Textarea: "textarea",
919
+ Number: "number",
920
+ Select: "select",
921
+ Radio: "radio",
922
+ Checkbox: "checkbox",
923
+ Color: "color",
924
+ Date: "date",
925
+ File: "file",
926
+ Image: "image",
927
+ Url: "url",
928
+ Address: "address",
929
+ Phone: "phone",
930
+ Email: "email",
931
+ DateTime: "date_time",
932
+ Time: "time",
933
+ Signature: "signature",
934
+ MultiSelect: "multi_select",
935
+ DateRange: "date_range",
936
+ Location: "location"
937
+ };
790
938
 
791
- export { ActivityService, CimplifyClient, DURATION_UNIT, DeliveryService, PRODUCT_TYPE, RENDER_HINT, SubscriptionService, createCimplifyClient, getVariantDisplayName };
939
+ export { ActivityService, CimplifyClient, DURATION_UNIT, DeliveryService, INPUT_FIELD_TYPE, PRODUCT_TYPE, PlacesService, RENDER_HINT, SubscriptionService, SupportService, UploadService, createCimplifyClient, getVariantDisplayName };
@@ -1,5 +1,5 @@
1
- import { M as Money, a as CurrencyCode, aW as PricePathTaxInfo, Q as QuantityPricingTier, N as Product, U as ProductWithDetails, bH as PaymentErrorDetails, bF as PaymentResponse, bG as PaymentStatusResponse } from './payment-k8feV7r8.mjs';
2
- import { P as ProductWithPrice } from './price-Den0zv61.mjs';
1
+ import { M as Money, a as CurrencyCode, b5 as PricePathTaxInfo, a3 as QuantityPricingTier, O as Product, a5 as ProductWithDetails, bS as PaymentErrorDetails, bQ as PaymentResponse, bR as PaymentStatusResponse } from './payment-DnU_eLuT.js';
2
+ import { P as ProductWithPrice } from './price-DUVmRTaz.js';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  declare const CURRENCY_SYMBOLS: Record<string, string>;
@@ -1,5 +1,5 @@
1
- import { M as Money, a as CurrencyCode, aW as PricePathTaxInfo, Q as QuantityPricingTier, N as Product, U as ProductWithDetails, bH as PaymentErrorDetails, bF as PaymentResponse, bG as PaymentStatusResponse } from './payment-k8feV7r8.js';
2
- import { P as ProductWithPrice } from './price-4EK-0zF5.js';
1
+ import { M as Money, a as CurrencyCode, b5 as PricePathTaxInfo, a3 as QuantityPricingTier, O as Product, a5 as ProductWithDetails, bS as PaymentErrorDetails, bQ as PaymentResponse, bR as PaymentStatusResponse } from './payment-DnU_eLuT.mjs';
2
+ import { P as ProductWithPrice } from './price-D-hso3np.mjs';
3
3
  import { CountryCode } from 'libphonenumber-js';
4
4
 
5
5
  declare const CURRENCY_SYMBOLS: Record<string, string>;