@ecomweb/sdk 0.10.0 → 0.12.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.ts +40 -6
- package/dist/index.js +29 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -408,6 +408,7 @@ declare const storeConfigSchema: z.ZodObject<{
|
|
|
408
408
|
store_id: z.ZodInt32;
|
|
409
409
|
subdomain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
410
410
|
custom_domain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
411
|
+
verified: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
411
412
|
created_at: z.ZodISODateTime;
|
|
412
413
|
updated_at: z.ZodISODateTime;
|
|
413
414
|
}, z.core.$strip>;
|
|
@@ -430,6 +431,9 @@ declare const storeSettingsSchema: z.ZodObject<{
|
|
|
430
431
|
tagline: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
431
432
|
blog_title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
432
433
|
is_blog_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
434
|
+
blog_description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
435
|
+
posts_per_page: z.ZodNullable<z.ZodOptional<z.ZodInt32>>;
|
|
436
|
+
allow_comments: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
433
437
|
currency_code: z.ZodNullable<z.ZodOptional<z.ZodDefault<z.ZodString>>>;
|
|
434
438
|
review_requests_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
435
439
|
order_number_prefix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -474,10 +478,12 @@ declare const createStoreConfigSchema: z.ZodObject<{
|
|
|
474
478
|
store_id: z.ZodInt32;
|
|
475
479
|
subdomain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
476
480
|
custom_domain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
481
|
+
verified: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
477
482
|
}, z.core.$strip>;
|
|
478
483
|
declare const updateStoreConfigSchema: z.ZodObject<{
|
|
479
484
|
subdomain: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
480
485
|
custom_domain: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
486
|
+
verified: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodBoolean>>>;
|
|
481
487
|
}, z.core.$strip>;
|
|
482
488
|
declare const createStoreSettingsSchema: z.ZodObject<{
|
|
483
489
|
email_accent_color: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -505,6 +511,9 @@ declare const createStoreSettingsSchema: z.ZodObject<{
|
|
|
505
511
|
tagline: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
506
512
|
blog_title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
507
513
|
is_blog_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
514
|
+
blog_description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
515
|
+
posts_per_page: z.ZodNullable<z.ZodOptional<z.ZodInt32>>;
|
|
516
|
+
allow_comments: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
508
517
|
currency_code: z.ZodNullable<z.ZodOptional<z.ZodDefault<z.ZodString>>>;
|
|
509
518
|
review_requests_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
510
519
|
order_number_prefix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -535,6 +544,9 @@ declare const updateStoreSettingsSchema: z.ZodObject<{
|
|
|
535
544
|
tagline: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
536
545
|
blog_title: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
537
546
|
is_blog_enabled: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodBoolean>>>;
|
|
547
|
+
blog_description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
548
|
+
posts_per_page: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodInt32>>>;
|
|
549
|
+
allow_comments: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodBoolean>>>;
|
|
538
550
|
currency_code: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodDefault<z.ZodString>>>>;
|
|
539
551
|
review_requests_enabled: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodBoolean>>>;
|
|
540
552
|
order_number_prefix: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
@@ -558,6 +570,7 @@ declare const storeWithRelationsSchema: z.ZodObject<{
|
|
|
558
570
|
store_id: z.ZodInt32;
|
|
559
571
|
subdomain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
560
572
|
custom_domain: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
573
|
+
verified: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
561
574
|
created_at: z.ZodISODateTime;
|
|
562
575
|
updated_at: z.ZodISODateTime;
|
|
563
576
|
}, z.core.$strip>>>;
|
|
@@ -575,6 +588,9 @@ declare const storeWithRelationsSchema: z.ZodObject<{
|
|
|
575
588
|
tagline: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
576
589
|
blog_title: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
577
590
|
is_blog_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
591
|
+
blog_description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
592
|
+
posts_per_page: z.ZodNullable<z.ZodOptional<z.ZodInt32>>;
|
|
593
|
+
allow_comments: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
578
594
|
currency_code: z.ZodNullable<z.ZodOptional<z.ZodDefault<z.ZodString>>>;
|
|
579
595
|
review_requests_enabled: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
580
596
|
order_number_prefix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -618,6 +634,10 @@ type Store = {
|
|
|
618
634
|
updated_at: string;
|
|
619
635
|
deleted_at: string | null;
|
|
620
636
|
embedded_scripts?: EmbeddedScript[];
|
|
637
|
+
/** Contract "Storefront": true until the merchant opens the store. Absent on older APIs. */
|
|
638
|
+
coming_soon?: boolean;
|
|
639
|
+
/** Contract "Storefront": when the store first opened, null if never. Absent on older APIs. */
|
|
640
|
+
first_opened_at?: string | null;
|
|
621
641
|
};
|
|
622
642
|
type StoreConfig = z.infer<typeof storeConfigSchema>;
|
|
623
643
|
type StoreSettings = z.infer<typeof storeSettingsSchema>;
|
|
@@ -2571,10 +2591,10 @@ declare const createBlogCommentSchema: z.ZodObject<{
|
|
|
2571
2591
|
}, z.core.$strip>;
|
|
2572
2592
|
declare const createBlogSettingsSchema: z.ZodObject<{
|
|
2573
2593
|
blog_title: z.ZodDefault<z.ZodString>;
|
|
2574
|
-
is_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2575
2594
|
blog_description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
2576
2595
|
posts_per_page: z.ZodDefault<z.ZodInt32>;
|
|
2577
2596
|
allow_comments: z.ZodDefault<z.ZodBoolean>;
|
|
2597
|
+
is_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
2578
2598
|
moderate_comments: z.ZodDefault<z.ZodBoolean>;
|
|
2579
2599
|
show_author: z.ZodDefault<z.ZodBoolean>;
|
|
2580
2600
|
show_reading_time: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -2626,10 +2646,10 @@ declare const updateBlogCommentSchema: z.ZodObject<{
|
|
|
2626
2646
|
}, z.core.$strip>;
|
|
2627
2647
|
declare const updateBlogSettingsSchema: z.ZodObject<{
|
|
2628
2648
|
blog_title: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
2629
|
-
is_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2630
2649
|
blog_description: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodString>>>;
|
|
2631
2650
|
posts_per_page: z.ZodOptional<z.ZodDefault<z.ZodInt32>>;
|
|
2632
2651
|
allow_comments: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2652
|
+
is_enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2633
2653
|
moderate_comments: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2634
2654
|
show_author: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2635
2655
|
show_reading_time: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
@@ -4307,6 +4327,13 @@ type StoreByDomainInfo = StoreConfigurationInfo & {
|
|
|
4307
4327
|
* shown there, never the live one. Absent from older APIs.
|
|
4308
4328
|
*/
|
|
4309
4329
|
preview_slug?: string | null;
|
|
4330
|
+
/**
|
|
4331
|
+
* A short-lived (1 h) store preview token, sent back as `X-Store-Preview`
|
|
4332
|
+
* in place of the preview cookie. Set only on a theme's preview host,
|
|
4333
|
+
* p-<slug>, while the store is coming soon; null otherwise. Absent from
|
|
4334
|
+
* older APIs.
|
|
4335
|
+
*/
|
|
4336
|
+
store_preview_token?: string | null;
|
|
4310
4337
|
};
|
|
4311
4338
|
|
|
4312
4339
|
declare class StoresApi {
|
|
@@ -4316,9 +4343,13 @@ declare class StoresApi {
|
|
|
4316
4343
|
includeConfig?: boolean;
|
|
4317
4344
|
includeSettings?: boolean;
|
|
4318
4345
|
includeEmbeddedScripts?: boolean;
|
|
4319
|
-
}): Promise<StoreConfigurationInfo | null>;
|
|
4346
|
+
}, requestOptions?: RequestOptions): Promise<StoreConfigurationInfo | null>;
|
|
4320
4347
|
getBySubdomain(subdomain: string): Promise<Store | null>;
|
|
4321
|
-
|
|
4348
|
+
/**
|
|
4349
|
+
* The store `domain` serves. `options` (e.g. an `x-store-preview` header,
|
|
4350
|
+
* which opens a coming soon store) is passed to the client only when given.
|
|
4351
|
+
*/
|
|
4352
|
+
getByDomain(domain: string, options?: RequestOptions): Promise<StoreByDomainInfo | null>;
|
|
4322
4353
|
}
|
|
4323
4354
|
|
|
4324
4355
|
declare class ThemesApi {
|
|
@@ -5073,7 +5104,8 @@ interface UrlRedirect {
|
|
|
5073
5104
|
declare class RedirectsApi {
|
|
5074
5105
|
private http;
|
|
5075
5106
|
constructor(http: IHttpClient);
|
|
5076
|
-
|
|
5107
|
+
/** `options` (request options) are passed to the client only when given. */
|
|
5108
|
+
lookup(storeRef: string, path: string, options?: RequestOptions): Promise<UrlRedirect | null>;
|
|
5077
5109
|
}
|
|
5078
5110
|
|
|
5079
5111
|
/** Mirrors AuthTokensResult in customer-auth. Nullable by design: register
|
|
@@ -5167,7 +5199,9 @@ interface ChangedResult {
|
|
|
5167
5199
|
}
|
|
5168
5200
|
/** Stable codes from the backend. Frontends branch on these and supply their
|
|
5169
5201
|
* own copy — backend messages are English and not shopper-facing. */
|
|
5170
|
-
type AuthErrorCode = "AUTH_INVALID_CREDENTIALS" | "AUTH_ACCOUNT_LOCKED"
|
|
5202
|
+
type AuthErrorCode = "AUTH_INVALID_CREDENTIALS" | "AUTH_ACCOUNT_LOCKED"
|
|
5203
|
+
/** The merchant marked this customer inactive (403). */
|
|
5204
|
+
| "AUTH_ACCOUNT_DISABLED" | "AUTH_EMAIL_NOT_VERIFIED" | "AUTH_METHOD_DISABLED" | "AUTH_TOKEN_INVALID" | "AUTH_TOKEN_EXPIRED" | "AUTH_SESSION_EXPIRED" | "AUTH_WEAK_PASSWORD" | "AUTH_RATE_LIMITED" | "AUTH_STORE_MISMATCH" | "AUTH_EMAIL_TAKEN";
|
|
5171
5205
|
|
|
5172
5206
|
/**
|
|
5173
5207
|
* One store's auth surface.
|
package/dist/index.js
CHANGED
|
@@ -280,7 +280,12 @@ var storeConfigSchema = z5.object({
|
|
|
280
280
|
id: idSchema,
|
|
281
281
|
store_id: idSchema,
|
|
282
282
|
subdomain: z5.string().optional().nullable(),
|
|
283
|
-
custom_domain: z5.string().optional().nullable()
|
|
283
|
+
custom_domain: z5.string().optional().nullable(),
|
|
284
|
+
/**
|
|
285
|
+
* True once the custom domain's DNS works. The storefront redirects the
|
|
286
|
+
* free subdomain to the custom domain only then.
|
|
287
|
+
*/
|
|
288
|
+
verified: z5.boolean().optional().nullable()
|
|
284
289
|
}).extend(timestampSchema.shape);
|
|
285
290
|
var legalLinksSchema = z5.object({
|
|
286
291
|
terms: z5.string().optional().nullable(),
|
|
@@ -300,6 +305,14 @@ var storeSettingsSchema = z5.object({
|
|
|
300
305
|
tagline: z5.string().optional().nullable(),
|
|
301
306
|
blog_title: z5.string().optional().nullable(),
|
|
302
307
|
is_blog_enabled: z5.boolean().optional().nullable(),
|
|
308
|
+
/**
|
|
309
|
+
* The rest of blog_settings the storefront renders. Absent from older
|
|
310
|
+
* APIs: readers fall back to the platform defaults (built-in blurb, 12
|
|
311
|
+
* posts a page, comments on).
|
|
312
|
+
*/
|
|
313
|
+
blog_description: z5.string().optional().nullable(),
|
|
314
|
+
posts_per_page: z5.int32().optional().nullable(),
|
|
315
|
+
allow_comments: z5.boolean().optional().nullable(),
|
|
303
316
|
currency_code: z5.string().min(3).max(3).default("VND").optional().nullable(),
|
|
304
317
|
review_requests_enabled: z5.boolean().optional().nullable(),
|
|
305
318
|
/**
|
|
@@ -1401,7 +1414,7 @@ function themeDefaults(schema) {
|
|
|
1401
1414
|
return out;
|
|
1402
1415
|
}
|
|
1403
1416
|
var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "textarea", "richtext"]);
|
|
1404
|
-
var SAFE_URL = /^(?:https?:\/\/[^\s\\]+|\/(?![
|
|
1417
|
+
var SAFE_URL = /^(?:https?:\/\/[^\s\\]+|\/(?![/\\])[^\s\\]*)$/i;
|
|
1405
1418
|
function checkValue(setting, value) {
|
|
1406
1419
|
switch (setting.type) {
|
|
1407
1420
|
case "checkbox":
|
|
@@ -3177,16 +3190,15 @@ var StoresApi = class {
|
|
|
3177
3190
|
constructor(http) {
|
|
3178
3191
|
this.http = http;
|
|
3179
3192
|
}
|
|
3180
|
-
async getById(storeRef, options) {
|
|
3193
|
+
async getById(storeRef, options, requestOptions) {
|
|
3181
3194
|
const params = new URLSearchParams();
|
|
3182
3195
|
if (options?.includeConfig ?? true) params.set("include_config", "1");
|
|
3183
3196
|
if (options?.includeSettings ?? true) params.set("include_settings", "1");
|
|
3184
3197
|
if (options?.includeEmbeddedScripts ?? true)
|
|
3185
3198
|
params.set("include_embedded_scripts", "1");
|
|
3186
3199
|
const qs = params.toString();
|
|
3187
|
-
const
|
|
3188
|
-
|
|
3189
|
-
);
|
|
3200
|
+
const url = `/public/stores/${storeRef}${qs ? `?${qs}` : ""}`;
|
|
3201
|
+
const res = requestOptions ? await this.http.get(url, requestOptions) : await this.http.get(url);
|
|
3190
3202
|
return unwrapOrNull(res);
|
|
3191
3203
|
}
|
|
3192
3204
|
async getBySubdomain(subdomain) {
|
|
@@ -3195,10 +3207,13 @@ var StoresApi = class {
|
|
|
3195
3207
|
);
|
|
3196
3208
|
return unwrapOrNull(res);
|
|
3197
3209
|
}
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3210
|
+
/**
|
|
3211
|
+
* The store `domain` serves. `options` (e.g. an `x-store-preview` header,
|
|
3212
|
+
* which opens a coming soon store) is passed to the client only when given.
|
|
3213
|
+
*/
|
|
3214
|
+
async getByDomain(domain, options) {
|
|
3215
|
+
const url = `/public/stores/domain/${domain}`;
|
|
3216
|
+
const res = options ? await this.http.get(url, options) : await this.http.get(url);
|
|
3202
3217
|
return unwrapOrNull(res);
|
|
3203
3218
|
}
|
|
3204
3219
|
};
|
|
@@ -3542,12 +3557,12 @@ var RedirectsApi = class {
|
|
|
3542
3557
|
constructor(http) {
|
|
3543
3558
|
this.http = http;
|
|
3544
3559
|
}
|
|
3545
|
-
|
|
3560
|
+
/** `options` (request options) are passed to the client only when given. */
|
|
3561
|
+
async lookup(storeRef, path, options) {
|
|
3546
3562
|
const params = new URLSearchParams();
|
|
3547
3563
|
params.set("path", path);
|
|
3548
|
-
const
|
|
3549
|
-
|
|
3550
|
-
);
|
|
3564
|
+
const url = `/public/stores/${storeRef}/url-redirects/lookup?${params.toString()}`;
|
|
3565
|
+
const res = options ? await this.http.get(url, options) : await this.http.get(url);
|
|
3551
3566
|
const result = unwrapOrNull(res);
|
|
3552
3567
|
return result?.data ?? null;
|
|
3553
3568
|
}
|