@stigg/typescript 0.1.0-alpha.3 → 0.1.0-alpha.7
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 +61 -0
- package/README.md +9 -0
- package/client.d.mts +6 -8
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -8
- package/client.d.ts.map +1 -1
- package/client.js +16 -21
- package/client.js.map +1 -1
- package/client.mjs +17 -22
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/package.json +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/v1/coupons.d.mts +55 -96
- package/resources/v1/coupons.d.mts.map +1 -1
- package/resources/v1/coupons.d.ts +55 -96
- package/resources/v1/coupons.d.ts.map +1 -1
- package/resources/v1/coupons.js +4 -3
- package/resources/v1/coupons.js.map +1 -1
- package/resources/v1/coupons.mjs +4 -3
- package/resources/v1/coupons.mjs.map +1 -1
- package/resources/v1/customers/customers.d.mts +170 -46
- package/resources/v1/customers/customers.d.mts.map +1 -1
- package/resources/v1/customers/customers.d.ts +170 -46
- package/resources/v1/customers/customers.d.ts.map +1 -1
- package/resources/v1/customers/customers.js +32 -15
- package/resources/v1/customers/customers.js.map +1 -1
- package/resources/v1/customers/customers.mjs +32 -15
- package/resources/v1/customers/customers.mjs.map +1 -1
- package/resources/v1/customers/index.d.mts +2 -2
- package/resources/v1/customers/index.d.mts.map +1 -1
- package/resources/v1/customers/index.d.ts +2 -2
- package/resources/v1/customers/index.d.ts.map +1 -1
- package/resources/v1/customers/index.js +3 -3
- package/resources/v1/customers/index.js.map +1 -1
- package/resources/v1/customers/index.mjs +1 -1
- package/resources/v1/customers/index.mjs.map +1 -1
- package/resources/v1/customers/payment-method.d.mts +4 -2
- package/resources/v1/customers/payment-method.d.mts.map +1 -1
- package/resources/v1/customers/payment-method.d.ts +4 -2
- package/resources/v1/customers/payment-method.d.ts.map +1 -1
- package/resources/v1/customers/payment-method.js +4 -2
- package/resources/v1/customers/payment-method.js.map +1 -1
- package/resources/v1/customers/payment-method.mjs +4 -2
- package/resources/v1/customers/payment-method.mjs.map +1 -1
- package/resources/v1/customers/promotional-entitlements.d.mts +352 -0
- package/resources/v1/customers/promotional-entitlements.d.mts.map +1 -0
- package/resources/v1/customers/promotional-entitlements.d.ts +352 -0
- package/resources/v1/customers/promotional-entitlements.d.ts.map +1 -0
- package/resources/v1/customers/promotional-entitlements.js +25 -0
- package/resources/v1/customers/promotional-entitlements.js.map +1 -0
- package/resources/v1/customers/promotional-entitlements.mjs +21 -0
- package/resources/v1/customers/promotional-entitlements.mjs.map +1 -0
- package/resources/v1/events.d.mts +63 -0
- package/resources/v1/events.d.mts.map +1 -0
- package/resources/v1/events.d.ts +63 -0
- package/resources/v1/events.d.ts.map +1 -0
- package/resources/v1/events.js +16 -0
- package/resources/v1/events.js.map +1 -0
- package/resources/v1/events.mjs +12 -0
- package/resources/v1/events.mjs.map +1 -0
- package/resources/v1/index.d.mts +7 -4
- package/resources/v1/index.d.mts.map +1 -1
- package/resources/v1/index.d.ts +7 -4
- package/resources/v1/index.d.ts.map +1 -1
- package/resources/v1/index.js +7 -1
- package/resources/v1/index.js.map +1 -1
- package/resources/v1/index.mjs +4 -1
- package/resources/v1/index.mjs.map +1 -1
- package/resources/v1/products.d.mts +126 -0
- package/resources/v1/products.d.mts.map +1 -0
- package/resources/v1/products.d.ts +126 -0
- package/resources/v1/products.d.ts.map +1 -0
- package/resources/v1/products.js +19 -0
- package/resources/v1/products.js.map +1 -0
- package/resources/v1/products.mjs +15 -0
- package/resources/v1/products.mjs.map +1 -0
- package/resources/v1/subscriptions/future-update.d.mts +9 -22
- package/resources/v1/subscriptions/future-update.d.mts.map +1 -1
- package/resources/v1/subscriptions/future-update.d.ts +9 -22
- package/resources/v1/subscriptions/future-update.d.ts.map +1 -1
- package/resources/v1/subscriptions/future-update.js +3 -2
- package/resources/v1/subscriptions/future-update.js.map +1 -1
- package/resources/v1/subscriptions/future-update.mjs +3 -2
- package/resources/v1/subscriptions/future-update.mjs.map +1 -1
- package/resources/v1/subscriptions/index.d.mts +2 -2
- package/resources/v1/subscriptions/index.d.mts.map +1 -1
- package/resources/v1/subscriptions/index.d.ts +2 -2
- package/resources/v1/subscriptions/index.d.ts.map +1 -1
- package/resources/v1/subscriptions/index.js.map +1 -1
- package/resources/v1/subscriptions/index.mjs +1 -1
- package/resources/v1/subscriptions/index.mjs.map +1 -1
- package/resources/v1/subscriptions/subscriptions.d.mts +987 -949
- package/resources/v1/subscriptions/subscriptions.d.mts.map +1 -1
- package/resources/v1/subscriptions/subscriptions.d.ts +987 -949
- package/resources/v1/subscriptions/subscriptions.d.ts.map +1 -1
- package/resources/v1/subscriptions/subscriptions.js +39 -11
- package/resources/v1/subscriptions/subscriptions.js.map +1 -1
- package/resources/v1/subscriptions/subscriptions.mjs +40 -12
- package/resources/v1/subscriptions/subscriptions.mjs.map +1 -1
- package/resources/v1/usage.d.mts +230 -0
- package/resources/v1/usage.d.mts.map +1 -0
- package/resources/v1/usage.d.ts +230 -0
- package/resources/v1/usage.d.ts.map +1 -0
- package/resources/v1/usage.js +24 -0
- package/resources/v1/usage.js.map +1 -0
- package/resources/v1/usage.mjs +20 -0
- package/resources/v1/usage.mjs.map +1 -0
- package/resources/v1/v1.d.mts +18 -172
- package/resources/v1/v1.d.mts.map +1 -1
- package/resources/v1/v1.d.ts +18 -172
- package/resources/v1/v1.d.ts.map +1 -1
- package/resources/v1/v1.js +12 -12
- package/resources/v1/v1.js.map +1 -1
- package/resources/v1/v1.mjs +12 -12
- package/resources/v1/v1.mjs.map +1 -1
- package/src/client.ts +25 -40
- package/src/internal/parse.ts +6 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/resources/index.ts +1 -7
- package/src/resources/v1/coupons.ts +63 -231
- package/src/resources/v1/customers/customers.ts +234 -60
- package/src/resources/v1/customers/index.ts +13 -2
- package/src/resources/v1/customers/payment-method.ts +4 -2
- package/src/resources/v1/customers/promotional-entitlements.ts +468 -0
- package/src/resources/v1/events.ts +74 -0
- package/src/resources/v1/index.ts +28 -15
- package/src/resources/v1/products.ts +162 -0
- package/src/resources/v1/subscriptions/future-update.ts +9 -30
- package/src/resources/v1/subscriptions/index.ts +8 -11
- package/src/resources/v1/subscriptions/subscriptions.ts +2699 -2280
- package/src/resources/v1/usage.ts +284 -0
- package/src/resources/v1/v1.ts +72 -220
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/v1/customers/usage.d.mts +0 -4
- package/resources/v1/customers/usage.d.mts.map +0 -1
- package/resources/v1/customers/usage.d.ts +0 -4
- package/resources/v1/customers/usage.d.ts.map +0 -1
- package/resources/v1/customers/usage.js +0 -9
- package/resources/v1/customers/usage.js.map +0 -1
- package/resources/v1/customers/usage.mjs +0 -5
- package/resources/v1/customers/usage.mjs.map +0 -1
- package/src/resources/v1/customers/usage.ts +0 -5
package/resources/v1/v1.d.ts
CHANGED
|
@@ -1,184 +1,30 @@
|
|
|
1
1
|
import { APIResource } from "../../core/resource.js";
|
|
2
2
|
import * as CouponsAPI from "./coupons.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Coupon, CouponCreateParams, CouponListParams, CouponListResponse, CouponListResponsesMyCursorIDPage, Coupons } from "./coupons.js";
|
|
4
|
+
import * as EventsAPI from "./events.js";
|
|
5
|
+
import { EventReportParams, EventReportResponse, Events } from "./events.js";
|
|
6
|
+
import * as ProductsAPI from "./products.js";
|
|
7
|
+
import { ProductListProductsParams, ProductListProductsResponse, ProductListProductsResponsesMyCursorIDPage, Products } from "./products.js";
|
|
8
|
+
import * as UsageAPI from "./usage.js";
|
|
9
|
+
import { Usage, UsageHistoryParams, UsageHistoryResponse, UsageReportParams, UsageReportResponse } from "./usage.js";
|
|
4
10
|
import * as CustomersAPI from "./customers/customers.js";
|
|
5
|
-
import {
|
|
11
|
+
import { CustomerImportParams, CustomerImportResponse, CustomerListParams, CustomerListResourcesParams, CustomerListResourcesResponse, CustomerListResourcesResponsesMyCursorIDPage, CustomerListResponse, CustomerListResponsesMyCursorIDPage, CustomerProvisionParams, CustomerResponse, CustomerUpdateParams, Customers } from "./customers/customers.js";
|
|
6
12
|
import * as SubscriptionsAPI from "./subscriptions/subscriptions.js";
|
|
7
|
-
import {
|
|
8
|
-
import { APIPromise } from "../../core/api-promise.js";
|
|
9
|
-
import { RequestOptions } from "../../internal/request-options.js";
|
|
13
|
+
import { Subscription, SubscriptionCancelParams, SubscriptionDelegateParams, SubscriptionImportParams, SubscriptionImportResponse, SubscriptionListParams, SubscriptionListResponse, SubscriptionListResponsesMyCursorIDPage, SubscriptionMigrateParams, SubscriptionPreviewParams, SubscriptionPreviewResponse, SubscriptionProvisionParams, SubscriptionProvisionResponse, SubscriptionTransferParams, SubscriptionUpdateParams, Subscriptions } from "./subscriptions/subscriptions.js";
|
|
10
14
|
export declare class V1 extends APIResource {
|
|
11
15
|
customers: CustomersAPI.Customers;
|
|
12
16
|
subscriptions: SubscriptionsAPI.Subscriptions;
|
|
13
17
|
coupons: CouponsAPI.Coupons;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
createEvent(body: V1CreateEventParams, options?: RequestOptions): APIPromise<V1CreateEventResponse>;
|
|
18
|
-
/**
|
|
19
|
-
* Report usage measurements
|
|
20
|
-
*/
|
|
21
|
-
createUsage(body: V1CreateUsageParams, options?: RequestOptions): APIPromise<V1CreateUsageResponse>;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Response object
|
|
25
|
-
*/
|
|
26
|
-
export interface V1CreateEventResponse {
|
|
27
|
-
/**
|
|
28
|
-
* Empty success response confirming that events were successfully ingested and
|
|
29
|
-
* queued for processing by Stigg's metering system.
|
|
30
|
-
*/
|
|
31
|
-
data: unknown;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Response containing reported usage measurements with current usage values,
|
|
35
|
-
* period information, and reset dates for each measurement.
|
|
36
|
-
*/
|
|
37
|
-
export interface V1CreateUsageResponse {
|
|
38
|
-
/**
|
|
39
|
-
* Array of usage measurements with current values and period info
|
|
40
|
-
*/
|
|
41
|
-
data: Array<V1CreateUsageResponse.Data>;
|
|
42
|
-
}
|
|
43
|
-
export declare namespace V1CreateUsageResponse {
|
|
44
|
-
/**
|
|
45
|
-
* Recorded usage with period info
|
|
46
|
-
*/
|
|
47
|
-
interface Data {
|
|
48
|
-
/**
|
|
49
|
-
* Unique identifier for the entity
|
|
50
|
-
*/
|
|
51
|
-
id: string;
|
|
52
|
-
/**
|
|
53
|
-
* Timestamp of when the record was created
|
|
54
|
-
*/
|
|
55
|
-
createdAt: string;
|
|
56
|
-
/**
|
|
57
|
-
* Customer id
|
|
58
|
-
*/
|
|
59
|
-
customerId: string;
|
|
60
|
-
/**
|
|
61
|
-
* Feature id
|
|
62
|
-
*/
|
|
63
|
-
featureId: string;
|
|
64
|
-
/**
|
|
65
|
-
* Timestamp
|
|
66
|
-
*/
|
|
67
|
-
timestamp: string;
|
|
68
|
-
/**
|
|
69
|
-
* The usage measurement record
|
|
70
|
-
*/
|
|
71
|
-
value: number;
|
|
72
|
-
/**
|
|
73
|
-
* The current measured usage value
|
|
74
|
-
*/
|
|
75
|
-
currentUsage?: number | null;
|
|
76
|
-
/**
|
|
77
|
-
* The date when the next usage reset will occur
|
|
78
|
-
*/
|
|
79
|
-
nextResetDate?: string | null;
|
|
80
|
-
/**
|
|
81
|
-
* Resource id
|
|
82
|
-
*/
|
|
83
|
-
resourceId?: string | null;
|
|
84
|
-
/**
|
|
85
|
-
* The end date of the usage period in which this measurement resides (for
|
|
86
|
-
* entitlements with a reset period)
|
|
87
|
-
*/
|
|
88
|
-
usagePeriodEnd?: string | null;
|
|
89
|
-
/**
|
|
90
|
-
* The start date of the usage period in which this measurement resides (for
|
|
91
|
-
* entitlements with a reset period)
|
|
92
|
-
*/
|
|
93
|
-
usagePeriodStart?: string | null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export interface V1CreateEventParams {
|
|
97
|
-
/**
|
|
98
|
-
* A list of usage events to report
|
|
99
|
-
*/
|
|
100
|
-
events: Array<V1CreateEventParams.Event>;
|
|
101
|
-
}
|
|
102
|
-
export declare namespace V1CreateEventParams {
|
|
103
|
-
/**
|
|
104
|
-
* Raw usage event
|
|
105
|
-
*/
|
|
106
|
-
interface Event {
|
|
107
|
-
/**
|
|
108
|
-
* Customer id
|
|
109
|
-
*/
|
|
110
|
-
customerId: string;
|
|
111
|
-
/**
|
|
112
|
-
* The name of the usage event
|
|
113
|
-
*/
|
|
114
|
-
eventName: string;
|
|
115
|
-
/**
|
|
116
|
-
* Idempotency key
|
|
117
|
-
*/
|
|
118
|
-
idempotencyKey: string;
|
|
119
|
-
/**
|
|
120
|
-
* Dimensions associated with the usage event
|
|
121
|
-
*/
|
|
122
|
-
dimensions?: {
|
|
123
|
-
[key: string]: string | number | boolean;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Resource id
|
|
127
|
-
*/
|
|
128
|
-
resourceId?: string | null;
|
|
129
|
-
/**
|
|
130
|
-
* Timestamp
|
|
131
|
-
*/
|
|
132
|
-
timestamp?: string;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
export interface V1CreateUsageParams {
|
|
136
|
-
/**
|
|
137
|
-
* A list of usage reports to be submitted in bulk
|
|
138
|
-
*/
|
|
139
|
-
usages: Array<V1CreateUsageParams.Usage>;
|
|
140
|
-
}
|
|
141
|
-
export declare namespace V1CreateUsageParams {
|
|
142
|
-
/**
|
|
143
|
-
* Single usage measurement
|
|
144
|
-
*/
|
|
145
|
-
interface Usage {
|
|
146
|
-
/**
|
|
147
|
-
* Customer id
|
|
148
|
-
*/
|
|
149
|
-
customerId: string;
|
|
150
|
-
/**
|
|
151
|
-
* Feature id
|
|
152
|
-
*/
|
|
153
|
-
featureId: string;
|
|
154
|
-
/**
|
|
155
|
-
* The value to report for usage
|
|
156
|
-
*/
|
|
157
|
-
value: number;
|
|
158
|
-
/**
|
|
159
|
-
* Timestamp of when the record was created
|
|
160
|
-
*/
|
|
161
|
-
createdAt?: string;
|
|
162
|
-
/**
|
|
163
|
-
* Additional dimensions for the usage report
|
|
164
|
-
*/
|
|
165
|
-
dimensions?: {
|
|
166
|
-
[key: string]: string | number | boolean;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Resource id
|
|
170
|
-
*/
|
|
171
|
-
resourceId?: string | null;
|
|
172
|
-
/**
|
|
173
|
-
* The method by which the usage value should be updated
|
|
174
|
-
*/
|
|
175
|
-
updateBehavior?: 'DELTA' | 'SET';
|
|
176
|
-
}
|
|
18
|
+
events: EventsAPI.Events;
|
|
19
|
+
usage: UsageAPI.Usage;
|
|
20
|
+
products: ProductsAPI.Products;
|
|
177
21
|
}
|
|
178
22
|
export declare namespace V1 {
|
|
179
|
-
export { type
|
|
180
|
-
export {
|
|
181
|
-
export {
|
|
182
|
-
export {
|
|
23
|
+
export { Customers as Customers, type CustomerResponse as CustomerResponse, type CustomerListResponse as CustomerListResponse, type CustomerImportResponse as CustomerImportResponse, type CustomerListResourcesResponse as CustomerListResourcesResponse, type CustomerListResponsesMyCursorIDPage as CustomerListResponsesMyCursorIDPage, type CustomerListResourcesResponsesMyCursorIDPage as CustomerListResourcesResponsesMyCursorIDPage, type CustomerUpdateParams as CustomerUpdateParams, type CustomerListParams as CustomerListParams, type CustomerImportParams as CustomerImportParams, type CustomerListResourcesParams as CustomerListResourcesParams, type CustomerProvisionParams as CustomerProvisionParams, };
|
|
24
|
+
export { Subscriptions as Subscriptions, type Subscription as Subscription, type SubscriptionListResponse as SubscriptionListResponse, type SubscriptionImportResponse as SubscriptionImportResponse, type SubscriptionPreviewResponse as SubscriptionPreviewResponse, type SubscriptionProvisionResponse as SubscriptionProvisionResponse, type SubscriptionListResponsesMyCursorIDPage as SubscriptionListResponsesMyCursorIDPage, type SubscriptionUpdateParams as SubscriptionUpdateParams, type SubscriptionListParams as SubscriptionListParams, type SubscriptionCancelParams as SubscriptionCancelParams, type SubscriptionDelegateParams as SubscriptionDelegateParams, type SubscriptionImportParams as SubscriptionImportParams, type SubscriptionMigrateParams as SubscriptionMigrateParams, type SubscriptionPreviewParams as SubscriptionPreviewParams, type SubscriptionProvisionParams as SubscriptionProvisionParams, type SubscriptionTransferParams as SubscriptionTransferParams, };
|
|
25
|
+
export { Coupons as Coupons, type Coupon as Coupon, type CouponListResponse as CouponListResponse, type CouponListResponsesMyCursorIDPage as CouponListResponsesMyCursorIDPage, type CouponCreateParams as CouponCreateParams, type CouponListParams as CouponListParams, };
|
|
26
|
+
export { Events as Events, type EventReportResponse as EventReportResponse, type EventReportParams as EventReportParams, };
|
|
27
|
+
export { Usage as Usage, type UsageHistoryResponse as UsageHistoryResponse, type UsageReportResponse as UsageReportResponse, type UsageHistoryParams as UsageHistoryParams, type UsageReportParams as UsageReportParams, };
|
|
28
|
+
export { Products as Products, type ProductListProductsResponse as ProductListProductsResponse, type ProductListProductsResponsesMyCursorIDPage as ProductListProductsResponsesMyCursorIDPage, type ProductListProductsParams as ProductListProductsParams, };
|
|
183
29
|
}
|
|
184
30
|
//# sourceMappingURL=v1.d.ts.map
|
package/resources/v1/v1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,UAAU;OACf,EACL,kBAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":"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"}
|
package/resources/v1/v1.js
CHANGED
|
@@ -6,6 +6,12 @@ const tslib_1 = require("../../internal/tslib.js");
|
|
|
6
6
|
const resource_1 = require("../../core/resource.js");
|
|
7
7
|
const CouponsAPI = tslib_1.__importStar(require("./coupons.js"));
|
|
8
8
|
const coupons_1 = require("./coupons.js");
|
|
9
|
+
const EventsAPI = tslib_1.__importStar(require("./events.js"));
|
|
10
|
+
const events_1 = require("./events.js");
|
|
11
|
+
const ProductsAPI = tslib_1.__importStar(require("./products.js"));
|
|
12
|
+
const products_1 = require("./products.js");
|
|
13
|
+
const UsageAPI = tslib_1.__importStar(require("./usage.js"));
|
|
14
|
+
const usage_1 = require("./usage.js");
|
|
9
15
|
const CustomersAPI = tslib_1.__importStar(require("./customers/customers.js"));
|
|
10
16
|
const customers_1 = require("./customers/customers.js");
|
|
11
17
|
const SubscriptionsAPI = tslib_1.__importStar(require("./subscriptions/subscriptions.js"));
|
|
@@ -16,22 +22,16 @@ class V1 extends resource_1.APIResource {
|
|
|
16
22
|
this.customers = new CustomersAPI.Customers(this._client);
|
|
17
23
|
this.subscriptions = new SubscriptionsAPI.Subscriptions(this._client);
|
|
18
24
|
this.coupons = new CouponsAPI.Coupons(this._client);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
createEvent(body, options) {
|
|
24
|
-
return this._client.post('/api/v1/events', { body, ...options });
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Report usage measurements
|
|
28
|
-
*/
|
|
29
|
-
createUsage(body, options) {
|
|
30
|
-
return this._client.post('/api/v1/usage', { body, ...options });
|
|
25
|
+
this.events = new EventsAPI.Events(this._client);
|
|
26
|
+
this.usage = new UsageAPI.Usage(this._client);
|
|
27
|
+
this.products = new ProductsAPI.Products(this._client);
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
30
|
exports.V1 = V1;
|
|
34
31
|
V1.Customers = customers_1.Customers;
|
|
35
32
|
V1.Subscriptions = subscriptions_1.Subscriptions;
|
|
36
33
|
V1.Coupons = coupons_1.Coupons;
|
|
34
|
+
V1.Events = events_1.Events;
|
|
35
|
+
V1.Usage = usage_1.Usage;
|
|
36
|
+
V1.Products = products_1.Products;
|
|
37
37
|
//# sourceMappingURL=v1.js.map
|
package/resources/v1/v1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.js","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAClD,iEAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"v1.js","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,qDAAkD;AAClD,iEAAwC;AACxC,0CAOmB;AACnB,+DAAsC;AACtC,wCAA0E;AAC1E,mEAA0C;AAC1C,4CAKoB;AACpB,6DAAoC;AACpC,sCAMiB;AACjB,+EAAsD;AACtD,wDAa+B;AAC/B,2FAAkE;AAClE,oEAiBuC;AAEvC,MAAa,EAAG,SAAQ,sBAAW;IAAnC;;QACE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,kBAAa,GAAmC,IAAI,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjG,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,WAAM,GAAqB,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAPD,gBAOC;AAED,EAAE,CAAC,SAAS,GAAG,qBAAS,CAAC;AACzB,EAAE,CAAC,aAAa,GAAG,6BAAa,CAAC;AACjC,EAAE,CAAC,OAAO,GAAG,iBAAO,CAAC;AACrB,EAAE,CAAC,MAAM,GAAG,eAAM,CAAC;AACnB,EAAE,CAAC,KAAK,GAAG,aAAK,CAAC;AACjB,EAAE,CAAC,QAAQ,GAAG,mBAAQ,CAAC"}
|
package/resources/v1/v1.mjs
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
import { APIResource } from "../../core/resource.mjs";
|
|
3
3
|
import * as CouponsAPI from "./coupons.mjs";
|
|
4
4
|
import { Coupons, } from "./coupons.mjs";
|
|
5
|
+
import * as EventsAPI from "./events.mjs";
|
|
6
|
+
import { Events } from "./events.mjs";
|
|
7
|
+
import * as ProductsAPI from "./products.mjs";
|
|
8
|
+
import { Products, } from "./products.mjs";
|
|
9
|
+
import * as UsageAPI from "./usage.mjs";
|
|
10
|
+
import { Usage, } from "./usage.mjs";
|
|
5
11
|
import * as CustomersAPI from "./customers/customers.mjs";
|
|
6
12
|
import { Customers, } from "./customers/customers.mjs";
|
|
7
13
|
import * as SubscriptionsAPI from "./subscriptions/subscriptions.mjs";
|
|
@@ -12,21 +18,15 @@ export class V1 extends APIResource {
|
|
|
12
18
|
this.customers = new CustomersAPI.Customers(this._client);
|
|
13
19
|
this.subscriptions = new SubscriptionsAPI.Subscriptions(this._client);
|
|
14
20
|
this.coupons = new CouponsAPI.Coupons(this._client);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
createEvent(body, options) {
|
|
20
|
-
return this._client.post('/api/v1/events', { body, ...options });
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Report usage measurements
|
|
24
|
-
*/
|
|
25
|
-
createUsage(body, options) {
|
|
26
|
-
return this._client.post('/api/v1/usage', { body, ...options });
|
|
21
|
+
this.events = new EventsAPI.Events(this._client);
|
|
22
|
+
this.usage = new UsageAPI.Usage(this._client);
|
|
23
|
+
this.products = new ProductsAPI.Products(this._client);
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
V1.Customers = Customers;
|
|
30
27
|
V1.Subscriptions = Subscriptions;
|
|
31
28
|
V1.Coupons = Coupons;
|
|
29
|
+
V1.Events = Events;
|
|
30
|
+
V1.Usage = Usage;
|
|
31
|
+
V1.Products = Products;
|
|
32
32
|
//# sourceMappingURL=v1.mjs.map
|
package/resources/v1/v1.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.mjs","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,UAAU;OACf,
|
|
1
|
+
{"version":3,"file":"v1.mjs","sourceRoot":"","sources":["../../src/resources/v1/v1.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,UAAU;OACf,EAML,OAAO,GACR;OACM,KAAK,SAAS;OACd,EAA0C,MAAM,EAAE;OAClD,KAAK,WAAW;OAChB,EAIL,QAAQ,GACT;OACM,KAAK,QAAQ;OACb,EACL,KAAK,GAKN;OACM,KAAK,YAAY;OACjB,EAYL,SAAS,GACV;OACM,KAAK,gBAAgB;OACrB,EAgBL,aAAa,GACd;AAED,MAAM,OAAO,EAAG,SAAQ,WAAW;IAAnC;;QACE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,kBAAa,GAAmC,IAAI,gBAAgB,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjG,YAAO,GAAuB,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,WAAM,GAAqB,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9D,UAAK,GAAmB,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,aAAQ,GAAyB,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;CAAA;AAED,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC;AACzB,EAAE,CAAC,aAAa,GAAG,aAAa,CAAC;AACjC,EAAE,CAAC,OAAO,GAAG,OAAO,CAAC;AACrB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;AACnB,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC;AACjB,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC"}
|
package/src/client.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { APIResponseProps } from './internal/parse';
|
|
|
11
11
|
import { getPlatformHeaders } from './internal/detect-platform';
|
|
12
12
|
import * as Shims from './internal/shims';
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
|
+
import * as qs from './internal/qs';
|
|
14
15
|
import { VERSION } from './version';
|
|
15
16
|
import * as Errors from './core/error';
|
|
16
17
|
import * as Pagination from './core/pagination';
|
|
@@ -18,13 +19,7 @@ import { AbstractPage, type MyCursorIDPageParams, MyCursorIDPageResponse } from
|
|
|
18
19
|
import * as Uploads from './core/uploads';
|
|
19
20
|
import * as API from './resources/index';
|
|
20
21
|
import { APIPromise } from './core/api-promise';
|
|
21
|
-
import {
|
|
22
|
-
V1,
|
|
23
|
-
V1CreateEventParams,
|
|
24
|
-
V1CreateEventResponse,
|
|
25
|
-
V1CreateUsageParams,
|
|
26
|
-
V1CreateUsageResponse,
|
|
27
|
-
} from './resources/v1/v1';
|
|
22
|
+
import { V1 } from './resources/v1/v1';
|
|
28
23
|
import { type Fetch } from './internal/builtin-types';
|
|
29
24
|
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
|
|
30
25
|
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
|
|
@@ -135,7 +130,7 @@ export class Stigg {
|
|
|
135
130
|
* API Client for interfacing with the Stigg API.
|
|
136
131
|
*
|
|
137
132
|
* @param {string | undefined} [opts.apiKey=process.env['STIGG_API_KEY'] ?? undefined]
|
|
138
|
-
* @param {string} [opts.baseURL=process.env['STIGG_BASE_URL'] ?? https://api.
|
|
133
|
+
* @param {string} [opts.baseURL=process.env['STIGG_BASE_URL'] ?? https://api.stigg.io] - Override the default base URL for the API.
|
|
139
134
|
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
140
135
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
141
136
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -157,7 +152,7 @@ export class Stigg {
|
|
|
157
152
|
const options: ClientOptions = {
|
|
158
153
|
apiKey,
|
|
159
154
|
...opts,
|
|
160
|
-
baseURL: baseURL || `https://api.
|
|
155
|
+
baseURL: baseURL || `https://api.stigg.io`,
|
|
161
156
|
};
|
|
162
157
|
|
|
163
158
|
this.baseURL = options.baseURL!;
|
|
@@ -203,7 +198,7 @@ export class Stigg {
|
|
|
203
198
|
* Check whether the base URL is set to its default.
|
|
204
199
|
*/
|
|
205
200
|
#baseURLOverridden(): boolean {
|
|
206
|
-
return this.baseURL !== 'https://api.
|
|
201
|
+
return this.baseURL !== 'https://api.stigg.io';
|
|
207
202
|
}
|
|
208
203
|
|
|
209
204
|
protected defaultQuery(): Record<string, string | undefined> | undefined {
|
|
@@ -218,24 +213,8 @@ export class Stigg {
|
|
|
218
213
|
return buildHeaders([{ 'X-API-KEY': this.apiKey }]);
|
|
219
214
|
}
|
|
220
215
|
|
|
221
|
-
/**
|
|
222
|
-
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
223
|
-
*/
|
|
224
216
|
protected stringifyQuery(query: Record<string, unknown>): string {
|
|
225
|
-
return
|
|
226
|
-
.filter(([_, value]) => typeof value !== 'undefined')
|
|
227
|
-
.map(([key, value]) => {
|
|
228
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
229
|
-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
230
|
-
}
|
|
231
|
-
if (value === null) {
|
|
232
|
-
return `${encodeURIComponent(key)}=`;
|
|
233
|
-
}
|
|
234
|
-
throw new Errors.StiggError(
|
|
235
|
-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
|
|
236
|
-
);
|
|
237
|
-
})
|
|
238
|
-
.join('&');
|
|
217
|
+
return qs.stringify(query, { arrayFormat: 'comma' });
|
|
239
218
|
}
|
|
240
219
|
|
|
241
220
|
private getUserAgent(): string {
|
|
@@ -456,7 +435,7 @@ export class Stigg {
|
|
|
456
435
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
457
436
|
|
|
458
437
|
const errText = await response.text().catch((err: any) => castToError(err).message);
|
|
459
|
-
const errJSON = safeJSON(errText);
|
|
438
|
+
const errJSON = safeJSON(errText) as any;
|
|
460
439
|
const errMessage = errJSON ? undefined : errText;
|
|
461
440
|
|
|
462
441
|
loggerFor(this).debug(
|
|
@@ -493,9 +472,14 @@ export class Stigg {
|
|
|
493
472
|
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
494
473
|
path: string,
|
|
495
474
|
Page: new (...args: any[]) => PageClass,
|
|
496
|
-
opts?: RequestOptions
|
|
475
|
+
opts?: PromiseOrValue<RequestOptions>,
|
|
497
476
|
): Pagination.PagePromise<PageClass, Item> {
|
|
498
|
-
return this.requestAPIList(
|
|
477
|
+
return this.requestAPIList(
|
|
478
|
+
Page,
|
|
479
|
+
opts && 'then' in opts ?
|
|
480
|
+
opts.then((opts) => ({ method: 'get', path, ...opts }))
|
|
481
|
+
: { method: 'get', path, ...opts },
|
|
482
|
+
);
|
|
499
483
|
}
|
|
500
484
|
|
|
501
485
|
requestAPIList<
|
|
@@ -503,7 +487,7 @@ export class Stigg {
|
|
|
503
487
|
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
504
488
|
>(
|
|
505
489
|
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
506
|
-
options: FinalRequestOptions
|
|
490
|
+
options: PromiseOrValue<FinalRequestOptions>,
|
|
507
491
|
): Pagination.PagePromise<PageClass, Item> {
|
|
508
492
|
const request = this.makeRequest(options, null, undefined);
|
|
509
493
|
return new Pagination.PagePromise<PageClass, Item>(this as any as Stigg, request, Page);
|
|
@@ -516,9 +500,10 @@ export class Stigg {
|
|
|
516
500
|
controller: AbortController,
|
|
517
501
|
): Promise<Response> {
|
|
518
502
|
const { signal, method, ...options } = init || {};
|
|
519
|
-
|
|
503
|
+
const abort = this._makeAbort(controller);
|
|
504
|
+
if (signal) signal.addEventListener('abort', abort, { once: true });
|
|
520
505
|
|
|
521
|
-
const timeout = setTimeout(
|
|
506
|
+
const timeout = setTimeout(abort, ms);
|
|
522
507
|
|
|
523
508
|
const isReadableBody =
|
|
524
509
|
((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
|
|
@@ -685,6 +670,12 @@ export class Stigg {
|
|
|
685
670
|
return headers.values;
|
|
686
671
|
}
|
|
687
672
|
|
|
673
|
+
private _makeAbort(controller: AbortController) {
|
|
674
|
+
// note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
|
|
675
|
+
// would capture all request options, and cause a memory leak.
|
|
676
|
+
return () => controller.abort();
|
|
677
|
+
}
|
|
678
|
+
|
|
688
679
|
private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
|
|
689
680
|
bodyHeaders: HeadersLike;
|
|
690
681
|
body: BodyInit | undefined;
|
|
@@ -755,11 +746,5 @@ export declare namespace Stigg {
|
|
|
755
746
|
type MyCursorIDPageResponse as MyCursorIDPageResponse,
|
|
756
747
|
};
|
|
757
748
|
|
|
758
|
-
export {
|
|
759
|
-
V1 as V1,
|
|
760
|
-
type V1CreateEventResponse as V1CreateEventResponse,
|
|
761
|
-
type V1CreateUsageResponse as V1CreateUsageResponse,
|
|
762
|
-
type V1CreateEventParams as V1CreateEventParams,
|
|
763
|
-
type V1CreateUsageParams as V1CreateUsageParams,
|
|
764
|
-
};
|
|
749
|
+
export { V1 as V1 };
|
|
765
750
|
}
|
package/src/internal/parse.ts
CHANGED
|
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Stigg, props: APIResponseP
|
|
|
29
29
|
const mediaType = contentType?.split(';')[0]?.trim();
|
|
30
30
|
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
|
|
31
31
|
if (isJSON) {
|
|
32
|
+
const contentLength = response.headers.get('content-length');
|
|
33
|
+
if (contentLength === '0') {
|
|
34
|
+
// if there is no content we can't do anything
|
|
35
|
+
return undefined as T;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
const json = await response.json();
|
|
33
39
|
return json as T;
|
|
34
40
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
10
|
+
|
|
11
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Format } from './types';
|
|
2
|
+
|
|
3
|
+
export const default_format: Format = 'RFC3986';
|
|
4
|
+
export const default_formatter = (v: PropertyKey) => String(v);
|
|
5
|
+
export const formatters: Record<Format, (str: PropertyKey) => string> = {
|
|
6
|
+
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
|
|
7
|
+
RFC3986: default_formatter,
|
|
8
|
+
};
|
|
9
|
+
export const RFC1738 = 'RFC1738';
|
|
10
|
+
export const RFC3986 = 'RFC3986';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { default_format, formatters, RFC1738, RFC3986 } from './formats';
|
|
2
|
+
|
|
3
|
+
const formats = {
|
|
4
|
+
formatters,
|
|
5
|
+
RFC1738,
|
|
6
|
+
RFC3986,
|
|
7
|
+
default: default_format,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { stringify } from './stringify';
|
|
11
|
+
export { formats };
|
|
12
|
+
|
|
13
|
+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';
|