@betterstore/sdk 0.3.35 → 0.3.37
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +23 -1
- package/dist/index.mjs +25 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -99,14 +99,27 @@ interface LineItem {
|
|
|
99
99
|
value: string;
|
|
100
100
|
}[];
|
|
101
101
|
discountId?: string;
|
|
102
|
-
product?: Pick<Product, "title" | "priceInCents" | "images"
|
|
102
|
+
product?: Pick<Product, "title" | "priceInCents" | "images" | "id" | "description" | "category" | "tags"> & {
|
|
103
|
+
productVariants: {
|
|
104
|
+
variantOptions: {
|
|
105
|
+
name: string;
|
|
106
|
+
value: string;
|
|
107
|
+
}[];
|
|
108
|
+
priceInCents: number;
|
|
109
|
+
images: string[];
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
103
112
|
metadata?: string;
|
|
104
113
|
}
|
|
114
|
+
interface LineItemCreate extends Omit<LineItem, "product" | "metadata"> {
|
|
115
|
+
product?: Pick<Product, "title" | "priceInCents" | "images">;
|
|
116
|
+
metadata?: RecursiveRecord;
|
|
117
|
+
}
|
|
105
118
|
type Currency = string;
|
|
106
119
|
interface CheckoutCreateParams {
|
|
107
120
|
type: "hosted" | "embed";
|
|
108
121
|
customerId?: string;
|
|
109
|
-
lineItems:
|
|
122
|
+
lineItems: LineItemCreate[];
|
|
110
123
|
currency?: Currency;
|
|
111
124
|
}
|
|
112
125
|
interface CheckoutUpdateParams {
|
|
@@ -139,6 +152,9 @@ interface CheckoutSession {
|
|
|
139
152
|
email?: string;
|
|
140
153
|
};
|
|
141
154
|
}
|
|
155
|
+
type RecursiveRecord = {
|
|
156
|
+
[key: string]: string | number | boolean | null | RecursiveRecord | RecursiveRecord[];
|
|
157
|
+
};
|
|
142
158
|
|
|
143
159
|
declare class Checkout {
|
|
144
160
|
private apiClient;
|
|
@@ -248,4 +264,4 @@ declare function createStoreHelpers(config?: {
|
|
|
248
264
|
proxy?: string;
|
|
249
265
|
}): Helpers;
|
|
250
266
|
|
|
251
|
-
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
267
|
+
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -99,14 +99,27 @@ interface LineItem {
|
|
|
99
99
|
value: string;
|
|
100
100
|
}[];
|
|
101
101
|
discountId?: string;
|
|
102
|
-
product?: Pick<Product, "title" | "priceInCents" | "images"
|
|
102
|
+
product?: Pick<Product, "title" | "priceInCents" | "images" | "id" | "description" | "category" | "tags"> & {
|
|
103
|
+
productVariants: {
|
|
104
|
+
variantOptions: {
|
|
105
|
+
name: string;
|
|
106
|
+
value: string;
|
|
107
|
+
}[];
|
|
108
|
+
priceInCents: number;
|
|
109
|
+
images: string[];
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
103
112
|
metadata?: string;
|
|
104
113
|
}
|
|
114
|
+
interface LineItemCreate extends Omit<LineItem, "product" | "metadata"> {
|
|
115
|
+
product?: Pick<Product, "title" | "priceInCents" | "images">;
|
|
116
|
+
metadata?: RecursiveRecord;
|
|
117
|
+
}
|
|
105
118
|
type Currency = string;
|
|
106
119
|
interface CheckoutCreateParams {
|
|
107
120
|
type: "hosted" | "embed";
|
|
108
121
|
customerId?: string;
|
|
109
|
-
lineItems:
|
|
122
|
+
lineItems: LineItemCreate[];
|
|
110
123
|
currency?: Currency;
|
|
111
124
|
}
|
|
112
125
|
interface CheckoutUpdateParams {
|
|
@@ -139,6 +152,9 @@ interface CheckoutSession {
|
|
|
139
152
|
email?: string;
|
|
140
153
|
};
|
|
141
154
|
}
|
|
155
|
+
type RecursiveRecord = {
|
|
156
|
+
[key: string]: string | number | boolean | null | RecursiveRecord | RecursiveRecord[];
|
|
157
|
+
};
|
|
142
158
|
|
|
143
159
|
declare class Checkout {
|
|
144
160
|
private apiClient;
|
|
@@ -248,4 +264,4 @@ declare function createStoreHelpers(config?: {
|
|
|
248
264
|
proxy?: string;
|
|
249
265
|
}): Helpers;
|
|
250
266
|
|
|
251
|
-
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
|
267
|
+
export { type Address, type CheckoutCreateParams, type CheckoutSession, type CheckoutUpdateParams, type Currency, type Customer$1 as Customer, type CustomerCreateParams, type CustomerUpdateParams, type LineItem, type LineItemCreate, type Product, type ProductOption, ProductStatus, type ProductVariant, type ProductWithoutVariants, type ShippingRate, type VariantOption, createStoreClient, createStoreHelpers, createBetterStore as default };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8
25
|
var __export = (target, all) => {
|
|
9
26
|
for (var name in all)
|
|
10
27
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -111,9 +128,14 @@ var Checkout = class {
|
|
|
111
128
|
*/
|
|
112
129
|
create(params) {
|
|
113
130
|
return __async(this, null, function* () {
|
|
131
|
+
const formattedParams = __spreadProps(__spreadValues({}, params), {
|
|
132
|
+
lineItems: params.lineItems.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
133
|
+
metadata: JSON.stringify(item.metadata)
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
114
136
|
const data = yield this.apiClient.post(
|
|
115
137
|
"/checkout",
|
|
116
|
-
|
|
138
|
+
formattedParams
|
|
117
139
|
);
|
|
118
140
|
return data;
|
|
119
141
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1
20
|
var __async = (__this, __arguments, generator) => {
|
|
2
21
|
return new Promise((resolve, reject) => {
|
|
3
22
|
var fulfilled = (value) => {
|
|
@@ -73,9 +92,14 @@ var Checkout = class {
|
|
|
73
92
|
*/
|
|
74
93
|
create(params) {
|
|
75
94
|
return __async(this, null, function* () {
|
|
95
|
+
const formattedParams = __spreadProps(__spreadValues({}, params), {
|
|
96
|
+
lineItems: params.lineItems.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
97
|
+
metadata: JSON.stringify(item.metadata)
|
|
98
|
+
}))
|
|
99
|
+
});
|
|
76
100
|
const data = yield this.apiClient.post(
|
|
77
101
|
"/checkout",
|
|
78
|
-
|
|
102
|
+
formattedParams
|
|
79
103
|
);
|
|
80
104
|
return data;
|
|
81
105
|
});
|