@usethrottle/discounts 0.3.0 → 0.4.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/CLAUDE.md +7 -0
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +7 -9
- package/package.json +4 -1
package/CLAUDE.md
CHANGED
|
@@ -15,6 +15,13 @@ Headless public SDK for Throttle discount and promotion code APIs.
|
|
|
15
15
|
`DELETE /api/v1/carts/:cartId/discount`.
|
|
16
16
|
- Never encourage exposing `THROTTLE_API_KEY` to buyer browsers.
|
|
17
17
|
|
|
18
|
+
## Errors
|
|
19
|
+
|
|
20
|
+
`ThrottleDiscountsError` extends the shared `ThrottleError` from
|
|
21
|
+
`@usethrottle/errors` (a `dependency`, `workspace:^`); the package re-exports
|
|
22
|
+
`ThrottleError` + `isThrottleError`. Keep it a subclass so a single
|
|
23
|
+
`instanceof ThrottleError` catches errors from every Throttle SDK.
|
|
24
|
+
|
|
18
25
|
## Testing
|
|
19
26
|
|
|
20
27
|
Focused commands:
|
package/dist/index.cjs
CHANGED
|
@@ -22,21 +22,19 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
DiscountsClient: () => DiscountsClient,
|
|
24
24
|
ThrottleDiscountsError: () => ThrottleDiscountsError,
|
|
25
|
-
|
|
25
|
+
ThrottleError: () => import_errors2.ThrottleError,
|
|
26
|
+
createDiscountsClient: () => createDiscountsClient,
|
|
27
|
+
isThrottleError: () => import_errors2.isThrottleError
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(index_exports);
|
|
28
30
|
|
|
29
31
|
// src/errors.ts
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
details;
|
|
32
|
+
var import_errors = require("@usethrottle/errors");
|
|
33
|
+
var import_errors2 = require("@usethrottle/errors");
|
|
34
|
+
var ThrottleDiscountsError = class extends import_errors.ThrottleError {
|
|
34
35
|
constructor(args) {
|
|
35
|
-
super(args
|
|
36
|
+
super(args);
|
|
36
37
|
this.name = "ThrottleDiscountsError";
|
|
37
|
-
this.code = args.code;
|
|
38
|
-
this.statusCode = args.statusCode;
|
|
39
|
-
this.details = args.details;
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
40
|
|
|
@@ -160,5 +158,7 @@ function serializeDates(input) {
|
|
|
160
158
|
0 && (module.exports = {
|
|
161
159
|
DiscountsClient,
|
|
162
160
|
ThrottleDiscountsError,
|
|
163
|
-
|
|
161
|
+
ThrottleError,
|
|
162
|
+
createDiscountsClient,
|
|
163
|
+
isThrottleError
|
|
164
164
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ThrottleError } from '@usethrottle/errors';
|
|
2
|
+
export { ThrottleError, isThrottleError } from '@usethrottle/errors';
|
|
3
|
+
|
|
1
4
|
type DiscountType = 'percentage' | 'fixed_amount';
|
|
2
5
|
interface Discount {
|
|
3
6
|
id: string;
|
|
@@ -130,10 +133,14 @@ declare class DiscountsClient {
|
|
|
130
133
|
}
|
|
131
134
|
declare function createDiscountsClient(opts: DiscountsClientOptions): DiscountsClient;
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Thrown on a non-2xx response from the Throttle Discounts API.
|
|
138
|
+
*
|
|
139
|
+
* Extends the shared {@link ThrottleError} so a single
|
|
140
|
+
* `catch (e) { if (e instanceof ThrottleError) … }` covers errors from every
|
|
141
|
+
* Throttle SDK. `instanceof ThrottleDiscountsError` keeps working.
|
|
142
|
+
*/
|
|
143
|
+
declare class ThrottleDiscountsError extends ThrottleError {
|
|
137
144
|
constructor(args: {
|
|
138
145
|
code: string;
|
|
139
146
|
message: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ThrottleError } from '@usethrottle/errors';
|
|
2
|
+
export { ThrottleError, isThrottleError } from '@usethrottle/errors';
|
|
3
|
+
|
|
1
4
|
type DiscountType = 'percentage' | 'fixed_amount';
|
|
2
5
|
interface Discount {
|
|
3
6
|
id: string;
|
|
@@ -130,10 +133,14 @@ declare class DiscountsClient {
|
|
|
130
133
|
}
|
|
131
134
|
declare function createDiscountsClient(opts: DiscountsClientOptions): DiscountsClient;
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Thrown on a non-2xx response from the Throttle Discounts API.
|
|
138
|
+
*
|
|
139
|
+
* Extends the shared {@link ThrottleError} so a single
|
|
140
|
+
* `catch (e) { if (e instanceof ThrottleError) … }` covers errors from every
|
|
141
|
+
* Throttle SDK. `instanceof ThrottleDiscountsError` keeps working.
|
|
142
|
+
*/
|
|
143
|
+
declare class ThrottleDiscountsError extends ThrottleError {
|
|
137
144
|
constructor(args: {
|
|
138
145
|
code: string;
|
|
139
146
|
message: string;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
// src/errors.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
details;
|
|
2
|
+
import { ThrottleError } from "@usethrottle/errors";
|
|
3
|
+
import { ThrottleError as ThrottleError2, isThrottleError } from "@usethrottle/errors";
|
|
4
|
+
var ThrottleDiscountsError = class extends ThrottleError {
|
|
6
5
|
constructor(args) {
|
|
7
|
-
super(args
|
|
6
|
+
super(args);
|
|
8
7
|
this.name = "ThrottleDiscountsError";
|
|
9
|
-
this.code = args.code;
|
|
10
|
-
this.statusCode = args.statusCode;
|
|
11
|
-
this.details = args.details;
|
|
12
8
|
}
|
|
13
9
|
};
|
|
14
10
|
|
|
@@ -131,5 +127,7 @@ function serializeDates(input) {
|
|
|
131
127
|
export {
|
|
132
128
|
DiscountsClient,
|
|
133
129
|
ThrottleDiscountsError,
|
|
134
|
-
|
|
130
|
+
ThrottleError2 as ThrottleError,
|
|
131
|
+
createDiscountsClient,
|
|
132
|
+
isThrottleError
|
|
135
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/discounts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Headless TypeScript client for Throttle discount and promotion code APIs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
"README.md",
|
|
19
19
|
"CLAUDE.md"
|
|
20
20
|
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@usethrottle/errors": "^1.0.0"
|
|
23
|
+
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"tsup": "^8.0.0",
|
|
23
26
|
"typescript": "^5.7.0",
|