@onflay/node 0.1.1
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/README.md +87 -0
- package/dist/client.d.ts +65 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +215 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +61 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +132 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/onflay.d.ts +42 -0
- package/dist/onflay.d.ts.map +1 -0
- package/dist/onflay.js +60 -0
- package/dist/onflay.js.map +1 -0
- package/dist/pagination.d.ts +19 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +61 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/checkout-sessions.d.ts +11 -0
- package/dist/resources/checkout-sessions.d.ts.map +1 -0
- package/dist/resources/checkout-sessions.js +20 -0
- package/dist/resources/checkout-sessions.js.map +1 -0
- package/dist/resources/customers.d.ts +17 -0
- package/dist/resources/customers.d.ts.map +1 -0
- package/dist/resources/customers.js +39 -0
- package/dist/resources/customers.js.map +1 -0
- package/dist/resources/payments.d.ts +11 -0
- package/dist/resources/payments.d.ts.map +1 -0
- package/dist/resources/payments.js +27 -0
- package/dist/resources/payments.js.map +1 -0
- package/dist/resources/prices.d.ts +24 -0
- package/dist/resources/prices.d.ts.map +1 -0
- package/dist/resources/prices.js +46 -0
- package/dist/resources/prices.js.map +1 -0
- package/dist/resources/products.d.ts +18 -0
- package/dist/resources/products.d.ts.map +1 -0
- package/dist/resources/products.js +40 -0
- package/dist/resources/products.js.map +1 -0
- package/dist/resources/subscriptions.d.ts +39 -0
- package/dist/resources/subscriptions.d.ts.map +1 -0
- package/dist/resources/subscriptions.js +62 -0
- package/dist/resources/subscriptions.js.map +1 -0
- package/dist/resources/usage.d.ts +26 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +43 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/resources/webhook-endpoints.d.ts +20 -0
- package/dist/resources/webhook-endpoints.d.ts.map +1 -0
- package/dist/resources/webhook-endpoints.js +47 -0
- package/dist/resources/webhook-endpoints.js.map +1 -0
- package/dist/types/checkout-sessions.d.ts +39 -0
- package/dist/types/checkout-sessions.d.ts.map +1 -0
- package/dist/types/checkout-sessions.js +3 -0
- package/dist/types/checkout-sessions.js.map +1 -0
- package/dist/types/customers.d.ts +28 -0
- package/dist/types/customers.d.ts.map +1 -0
- package/dist/types/customers.js +3 -0
- package/dist/types/customers.js.map +1 -0
- package/dist/types/events.d.ts +55 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +23 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/payments.d.ts +25 -0
- package/dist/types/payments.d.ts.map +1 -0
- package/dist/types/payments.js +3 -0
- package/dist/types/payments.js.map +1 -0
- package/dist/types/prices.d.ts +57 -0
- package/dist/types/prices.d.ts.map +1 -0
- package/dist/types/prices.js +3 -0
- package/dist/types/prices.js.map +1 -0
- package/dist/types/products.d.ts +29 -0
- package/dist/types/products.d.ts.map +1 -0
- package/dist/types/products.js +3 -0
- package/dist/types/products.js.map +1 -0
- package/dist/types/shared.d.ts +34 -0
- package/dist/types/shared.d.ts.map +1 -0
- package/dist/types/shared.js +4 -0
- package/dist/types/shared.js.map +1 -0
- package/dist/types/subscriptions.d.ts +85 -0
- package/dist/types/subscriptions.d.ts.map +1 -0
- package/dist/types/subscriptions.js +3 -0
- package/dist/types/subscriptions.js.map +1 -0
- package/dist/types/usage.d.ts +35 -0
- package/dist/types/usage.d.ts.map +1 -0
- package/dist/types/usage.js +3 -0
- package/dist/types/usage.js.map +1 -0
- package/dist/types/webhook-endpoints.d.ts +48 -0
- package/dist/types/webhook-endpoints.d.ts.map +1 -0
- package/dist/types/webhook-endpoints.js +3 -0
- package/dist/types/webhook-endpoints.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscriptionsResource = void 0;
|
|
4
|
+
const pagination_1 = require("../pagination");
|
|
5
|
+
class SubscriptionsResource {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async create(params, options) {
|
|
11
|
+
return this.client.request('POST', '/v1/subscriptions', {
|
|
12
|
+
body: params,
|
|
13
|
+
...(options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async retrieve(subscriptionId) {
|
|
17
|
+
return this.client.request('GET', `/v1/subscriptions/${encodeURIComponent(subscriptionId)}`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Update a subscription's items, cancellation policy, or metadata.
|
|
21
|
+
*
|
|
22
|
+
* Proration semantics (see `prorationBehavior` on the params type):
|
|
23
|
+
* - `create_prorations` (default) — issue a prorated charge or
|
|
24
|
+
* credit immediately when items change. Best for upgrades.
|
|
25
|
+
* - `none` — switch to the new items at the next renewal with
|
|
26
|
+
* no immediate billing impact. Best for downgrades scheduled
|
|
27
|
+
* for end-of-period.
|
|
28
|
+
* - `always_invoice` — prorate AND invoice now (no preview step).
|
|
29
|
+
*
|
|
30
|
+
* The recommended upgrade flow when paired with the CLI catalog:
|
|
31
|
+
* 1. `prices.create({...new amount})` → fresh `priceId`
|
|
32
|
+
* 2. `prices.update(oldPriceId, { active: false })`
|
|
33
|
+
* 3. `subscriptions.update(subId, { items: [{ priceId: NEW }],
|
|
34
|
+
* prorationBehavior: 'create_prorations' })`
|
|
35
|
+
* which keeps existing subscribers grandfathered until they
|
|
36
|
+
* explicitly upgrade.
|
|
37
|
+
*/
|
|
38
|
+
async update(subscriptionId, params, options) {
|
|
39
|
+
return this.client.request('PATCH', `/v1/subscriptions/${encodeURIComponent(subscriptionId)}`, {
|
|
40
|
+
body: params,
|
|
41
|
+
...(options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async cancel(subscriptionId, params = {}, options) {
|
|
45
|
+
return this.client.request('POST', `/v1/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {
|
|
46
|
+
body: params,
|
|
47
|
+
...(options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async list(params = {}) {
|
|
51
|
+
return this.client.request('GET', '/v1/subscriptions', { query: params });
|
|
52
|
+
}
|
|
53
|
+
listAll(params = {}) {
|
|
54
|
+
return (0, pagination_1.autoPaginate)({
|
|
55
|
+
client: this.client,
|
|
56
|
+
path: '/v1/subscriptions',
|
|
57
|
+
initialParams: params,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.SubscriptionsResource = SubscriptionsResource;
|
|
62
|
+
//# sourceMappingURL=subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../../src/resources/subscriptions.ts"],"names":[],"mappings":";;;AACA,8CAA6C;AAU7C,MAAa,qBAAqB;IACH;IAA7B,YAA6B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAErD,KAAK,CAAC,MAAM,CACV,MAAgC,EAChC,OAAqC;QAErC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB,MAAM,EAAE,mBAAmB,EAAE;YAC1E,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OA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AAI,CAAC,MAAM;YACnB,IAAI,EAAE,mBAAmB;YACzB,aAAa,EAAE,MAAM;SACtB,CAAC,CAAC;IACL,CAAC;CACF;AAtFD,sDAsFC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { OnflayClient } from '../client';
|
|
2
|
+
import type { CreateMeterParams, OnflayMeter, ReportUsageParams, ReportUsageResponse } from '../types/usage';
|
|
3
|
+
/**
|
|
4
|
+
* Usage metering surface. Mirrors Stripe's `subscriptionItems.createUsageRecord`
|
|
5
|
+
* shape but uses creator-defined `Meter` rows so a single subscription can
|
|
6
|
+
* accumulate several independent usage streams (e.g. API calls + storage).
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* await onflay.usage.report({
|
|
10
|
+
* subscriptionId: 'sub_abc',
|
|
11
|
+
* meter: 'api_calls',
|
|
12
|
+
* quantity: 1500,
|
|
13
|
+
* idempotencyKey: 'usage_2026_04_06_batch1',
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class UsageResource {
|
|
18
|
+
private readonly client;
|
|
19
|
+
constructor(client: OnflayClient);
|
|
20
|
+
createMeter(params: CreateMeterParams): Promise<OnflayMeter>;
|
|
21
|
+
listMeters(): Promise<{
|
|
22
|
+
data: OnflayMeter[];
|
|
23
|
+
}>;
|
|
24
|
+
report(params: ReportUsageParams): Promise<ReportUsageResponse>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EACV,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;GAaG;AACH,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAE3C,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5D,UAAU,IAAI,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;IAI9C,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAatE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Usage metering surface. Mirrors Stripe's `subscriptionItems.createUsageRecord`
|
|
6
|
+
* shape but uses creator-defined `Meter` rows so a single subscription can
|
|
7
|
+
* accumulate several independent usage streams (e.g. API calls + storage).
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* await onflay.usage.report({
|
|
11
|
+
* subscriptionId: 'sub_abc',
|
|
12
|
+
* meter: 'api_calls',
|
|
13
|
+
* quantity: 1500,
|
|
14
|
+
* idempotencyKey: 'usage_2026_04_06_batch1',
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
class UsageResource {
|
|
19
|
+
client;
|
|
20
|
+
constructor(client) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
async createMeter(params) {
|
|
24
|
+
return this.client.request('POST', '/v1/meters', { body: params });
|
|
25
|
+
}
|
|
26
|
+
async listMeters() {
|
|
27
|
+
return this.client.request('GET', '/v1/meters');
|
|
28
|
+
}
|
|
29
|
+
async report(params) {
|
|
30
|
+
const body = {
|
|
31
|
+
...params,
|
|
32
|
+
timestamp: params.timestamp instanceof Date
|
|
33
|
+
? params.timestamp.toISOString()
|
|
34
|
+
: params.timestamp,
|
|
35
|
+
};
|
|
36
|
+
return this.client.request('POST', '/v1/usage/records', {
|
|
37
|
+
body,
|
|
38
|
+
idempotencyKey: params.idempotencyKey,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.UsageResource = UsageResource;
|
|
43
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/resources/usage.ts"],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IACK;IAA7B,YAA6B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAErD,KAAK,CAAC,WAAW,CAAC,MAAyB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAc,MAAM,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAA0B,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAyB;QACpC,MAAM,IAAI,GAAG;YACX,GAAG,MAAM;YACT,SAAS,EACP,MAAM,CAAC,SAAS,YAAY,IAAI;gBAC9B,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;gBAChC,CAAC,CAAC,MAAM,CAAC,SAAS;SACvB,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAsB,MAAM,EAAE,mBAAmB,EAAE;YAC3E,IAAI;YACJ,cAAc,EAAE,MAAM,CAAC,cAAc;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AAxBD,sCAwBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { OnflayClient } from '../client';
|
|
2
|
+
import type { ListIterator, PaginatedList } from '../types/shared';
|
|
3
|
+
import type { CreatedOnflayWebhookEndpoint, CreateWebhookEndpointParams, ListWebhookDeliveriesParams, OnflayWebhookDelivery, OnflayWebhookEndpoint, UpdateWebhookEndpointParams } from '../types/webhook-endpoints';
|
|
4
|
+
export declare class WebhookEndpointsResource {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: OnflayClient);
|
|
7
|
+
create(params: CreateWebhookEndpointParams, options?: {
|
|
8
|
+
idempotencyKey?: string;
|
|
9
|
+
}): Promise<CreatedOnflayWebhookEndpoint>;
|
|
10
|
+
retrieve(endpointId: string): Promise<OnflayWebhookEndpoint>;
|
|
11
|
+
update(endpointId: string, params: UpdateWebhookEndpointParams): Promise<OnflayWebhookEndpoint>;
|
|
12
|
+
delete(endpointId: string): Promise<void>;
|
|
13
|
+
list(): Promise<PaginatedList<OnflayWebhookEndpoint>>;
|
|
14
|
+
/** List recent deliveries from `WebhookDelivery` (used by `onflay events …`). */
|
|
15
|
+
listDeliveries(params?: ListWebhookDeliveriesParams): Promise<PaginatedList<OnflayWebhookDelivery>>;
|
|
16
|
+
listAllDeliveries(params?: Omit<ListWebhookDeliveriesParams, 'cursor'>): ListIterator<OnflayWebhookDelivery>;
|
|
17
|
+
getDelivery(deliveryId: string): Promise<OnflayWebhookDelivery>;
|
|
18
|
+
resendDelivery(deliveryId: string): Promise<OnflayWebhookDelivery>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=webhook-endpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-endpoints.d.ts","sourceRoot":"","sources":["../../src/resources/webhook-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EACV,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,4BAA4B,CAAC;AAEpC,qBAAa,wBAAwB;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAE3C,MAAM,CACV,MAAM,EAAE,2BAA2B,EACnC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GACpC,OAAO,CAAC,4BAA4B,CAAC;IAWlC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAO5D,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAQ3B,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC,IAAI,IAAI,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAO3D,iFAAiF;IAC3E,cAAc,CAClB,MAAM,GAAE,2BAAgC,GACvC,OAAO,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;IAQhD,iBAAiB,CACf,MAAM,GAAE,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAM,GACvD,YAAY,CAAC,qBAAqB,CAAC;IAQhC,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAO/D,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAMzE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhookEndpointsResource = void 0;
|
|
4
|
+
const pagination_1 = require("../pagination");
|
|
5
|
+
class WebhookEndpointsResource {
|
|
6
|
+
client;
|
|
7
|
+
constructor(client) {
|
|
8
|
+
this.client = client;
|
|
9
|
+
}
|
|
10
|
+
async create(params, options) {
|
|
11
|
+
return this.client.request('POST', '/v1/webhook-endpoints', {
|
|
12
|
+
body: params,
|
|
13
|
+
...(options?.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
async retrieve(endpointId) {
|
|
17
|
+
return this.client.request('GET', `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}`);
|
|
18
|
+
}
|
|
19
|
+
async update(endpointId, params) {
|
|
20
|
+
return this.client.request('PATCH', `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}`, { body: params });
|
|
21
|
+
}
|
|
22
|
+
async delete(endpointId) {
|
|
23
|
+
await this.client.request('DELETE', `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}`);
|
|
24
|
+
}
|
|
25
|
+
async list() {
|
|
26
|
+
return this.client.request('GET', '/v1/webhook-endpoints');
|
|
27
|
+
}
|
|
28
|
+
/** List recent deliveries from `WebhookDelivery` (used by `onflay events …`). */
|
|
29
|
+
async listDeliveries(params = {}) {
|
|
30
|
+
return this.client.request('GET', '/v1/webhook-deliveries', { query: params });
|
|
31
|
+
}
|
|
32
|
+
listAllDeliveries(params = {}) {
|
|
33
|
+
return (0, pagination_1.autoPaginate)({
|
|
34
|
+
client: this.client,
|
|
35
|
+
path: '/v1/webhook-deliveries',
|
|
36
|
+
initialParams: params,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async getDelivery(deliveryId) {
|
|
40
|
+
return this.client.request('GET', `/v1/webhook-deliveries/${encodeURIComponent(deliveryId)}`);
|
|
41
|
+
}
|
|
42
|
+
async resendDelivery(deliveryId) {
|
|
43
|
+
return this.client.request('POST', `/v1/webhook-deliveries/${encodeURIComponent(deliveryId)}/resend`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.WebhookEndpointsResource = WebhookEndpointsResource;
|
|
47
|
+
//# sourceMappingURL=webhook-endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-endpoints.js","sourceRoot":"","sources":["../../src/resources/webhook-endpoints.ts"],"names":[],"mappings":";;;AACA,8CAA6C;AAW7C,MA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CACf,SAAsD,EAAE;QAExD,OAAO,IAAA,yBAAY,EAAqD;YACtE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,wBAAwB;YAC9B,aAAa,EAAE,MAAM;SACtB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,0BAA0B,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAC3D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,0BAA0B,kBAAkB,CAAC,UAAU,CAAC,SAAS,CAClE,CAAC;IACJ,CAAC;CACF;AAnFD,4DAmFC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { OnflayMetadata } from './shared';
|
|
2
|
+
export interface CheckoutLineItem {
|
|
3
|
+
priceId: string;
|
|
4
|
+
quantity?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface OnflayCheckoutSession {
|
|
7
|
+
id: string;
|
|
8
|
+
object: 'checkout_session';
|
|
9
|
+
url: string;
|
|
10
|
+
status: 'open' | 'complete' | 'expired';
|
|
11
|
+
paymentStatus: 'unpaid' | 'paid' | 'no_payment_required';
|
|
12
|
+
customer?: string | null;
|
|
13
|
+
amountSubtotal?: number | null;
|
|
14
|
+
amountTotal?: number | null;
|
|
15
|
+
currency?: string;
|
|
16
|
+
metadata?: OnflayMetadata;
|
|
17
|
+
successUrl?: string;
|
|
18
|
+
cancelUrl?: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
expiresAt?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateCheckoutSessionParams {
|
|
23
|
+
/** Backend-supported alias when targeting a single listing/variant. */
|
|
24
|
+
listingId?: string;
|
|
25
|
+
/** Variant identifier within the targeted listing, when applicable. */
|
|
26
|
+
variantId?: string;
|
|
27
|
+
/** Stripe-style line items keyed by `priceId`. */
|
|
28
|
+
lineItems?: CheckoutLineItem[];
|
|
29
|
+
customerEmail?: string;
|
|
30
|
+
customerId?: string;
|
|
31
|
+
successUrl: string;
|
|
32
|
+
cancelUrl: string;
|
|
33
|
+
metadata?: OnflayMetadata;
|
|
34
|
+
/** Optional discount or promotion code. */
|
|
35
|
+
promotionCode?: string;
|
|
36
|
+
/** Defaults to the platform's primary currency for the listing. */
|
|
37
|
+
currency?: string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=checkout-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-sessions.d.ts","sourceRoot":"","sources":["../../src/types/checkout-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,kBAAkB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACxC,aAAa,EAAE,QAAQ,GAAG,MAAM,GAAG,qBAAqB,CAAC;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IAC1C,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,2CAA2C;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-sessions.js","sourceRoot":"","sources":["../../src/types/checkout-sessions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { OnflayMetadata } from './shared';
|
|
2
|
+
export interface OnflayCustomer {
|
|
3
|
+
id: string;
|
|
4
|
+
object: 'customer';
|
|
5
|
+
email: string | null;
|
|
6
|
+
name: string | null;
|
|
7
|
+
countryCode: string | null;
|
|
8
|
+
metadata?: OnflayMetadata;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CreateCustomerParams {
|
|
12
|
+
email: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
countryCode?: string;
|
|
15
|
+
metadata?: OnflayMetadata;
|
|
16
|
+
}
|
|
17
|
+
export interface UpdateCustomerParams {
|
|
18
|
+
email?: string;
|
|
19
|
+
name?: string | null;
|
|
20
|
+
countryCode?: string | null;
|
|
21
|
+
metadata?: OnflayMetadata;
|
|
22
|
+
}
|
|
23
|
+
export interface ListCustomersParams {
|
|
24
|
+
email?: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
cursor?: string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=customers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.d.ts","sourceRoot":"","sources":["../../src/types/customers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customers.js","sourceRoot":"","sources":["../../src/types/customers.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { OnflayPayment } from './payments';
|
|
2
|
+
import type { OnflaySubscription } from './subscriptions';
|
|
3
|
+
import type { OnflayMetadata } from './shared';
|
|
4
|
+
/**
|
|
5
|
+
* Public webhook event names. These are the values consumers should pin
|
|
6
|
+
* their handlers to. Adding a new value here is a breaking change for
|
|
7
|
+
* receivers that exhaustively `switch` on `event.type` — bump the SDK
|
|
8
|
+
* minor and call it out in the changelog.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ONFLAY_EVENT_TYPES: readonly ["payment.completed", "payment.refunded", "payout.scheduled", "payout.completed", "payout.failed", "dispute.opened", "dispute.resolved", "subscription.renewed", "subscription.canceled", "subscription.expired", "subscription.dunning"];
|
|
11
|
+
export type OnflayEventType = (typeof ONFLAY_EVENT_TYPES)[number];
|
|
12
|
+
export interface OnflayWebhookEnvelope<TData = unknown> {
|
|
13
|
+
/** Public event ID (`evt_...`). */
|
|
14
|
+
id: string;
|
|
15
|
+
type: OnflayEventType | string;
|
|
16
|
+
/** Unix seconds. */
|
|
17
|
+
createdAt: number;
|
|
18
|
+
/** `false` for sandbox, `true` for production. */
|
|
19
|
+
livemode: boolean;
|
|
20
|
+
/** Schema version of `data`. */
|
|
21
|
+
apiVersion: string;
|
|
22
|
+
data: TData;
|
|
23
|
+
}
|
|
24
|
+
export interface PayoutEventData {
|
|
25
|
+
payoutId: string;
|
|
26
|
+
creatorId: string;
|
|
27
|
+
amountInCents: number;
|
|
28
|
+
externalTransferId?: string;
|
|
29
|
+
scheduledFor?: string;
|
|
30
|
+
failureReason?: string;
|
|
31
|
+
metadata?: OnflayMetadata;
|
|
32
|
+
}
|
|
33
|
+
export interface DisputeEventData {
|
|
34
|
+
disputeId: string;
|
|
35
|
+
transactionId: string;
|
|
36
|
+
externalDisputeId?: string;
|
|
37
|
+
amountInCents: number;
|
|
38
|
+
resolution?: string;
|
|
39
|
+
metadata?: OnflayMetadata;
|
|
40
|
+
}
|
|
41
|
+
export interface SubscriptionEventData extends OnflaySubscription {
|
|
42
|
+
/** Sub-event detail surfaced by the dispatch listener (e.g. dunning attempt #). */
|
|
43
|
+
detail?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export type PaymentEventData = OnflayPayment;
|
|
46
|
+
export type OnflayEvent = (OnflayWebhookEnvelope<PaymentEventData> & {
|
|
47
|
+
type: 'payment.completed' | 'payment.refunded';
|
|
48
|
+
}) | (OnflayWebhookEnvelope<PayoutEventData> & {
|
|
49
|
+
type: 'payout.scheduled' | 'payout.completed' | 'payout.failed';
|
|
50
|
+
}) | (OnflayWebhookEnvelope<DisputeEventData> & {
|
|
51
|
+
type: 'dispute.opened' | 'dispute.resolved';
|
|
52
|
+
}) | (OnflayWebhookEnvelope<SubscriptionEventData> & {
|
|
53
|
+
type: 'subscription.renewed' | 'subscription.canceled' | 'subscription.expired' | 'subscription.dunning';
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,oPAYrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,MAAM,WAAW,qBAAqB,CAAC,KAAK,GAAG,OAAO;IACpD,mCAAmC;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC;IAC/B,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,S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TYPES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Public webhook event names. These are the values consumers should pin
|
|
6
|
+
* their handlers to. Adding a new value here is a breaking change for
|
|
7
|
+
* receivers that exhaustively `switch` on `event.type` — bump the SDK
|
|
8
|
+
* minor and call it out in the changelog.
|
|
9
|
+
*/
|
|
10
|
+
exports.ONFLAY_EVENT_TYPES = [
|
|
11
|
+
'payment.completed',
|
|
12
|
+
'payment.refunded',
|
|
13
|
+
'payout.scheduled',
|
|
14
|
+
'payout.completed',
|
|
15
|
+
'payout.failed',
|
|
16
|
+
'dispute.opened',
|
|
17
|
+
'dispute.resolved',
|
|
18
|
+
'subscription.renewed',
|
|
19
|
+
'subscription.canceled',
|
|
20
|
+
'subscription.expired',
|
|
21
|
+
'subscription.dunning',
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":";;;AAIA;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG;IAChC,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAClB,sBAAsB;IACtB,uBAAuB;IACvB,sBAAsB;IACtB,sBAAsB;CACd,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OnflayMetadata } from './shared';
|
|
2
|
+
export type PaymentStatus = 'requires_payment' | 'processing' | 'succeeded' | 'refunded' | 'partially_refunded' | 'failed' | 'canceled';
|
|
3
|
+
export interface OnflayPayment {
|
|
4
|
+
id: string;
|
|
5
|
+
object: 'payment';
|
|
6
|
+
amount: number;
|
|
7
|
+
currency: string;
|
|
8
|
+
status: PaymentStatus;
|
|
9
|
+
customerId?: string | null;
|
|
10
|
+
description?: string | null;
|
|
11
|
+
metadata?: OnflayMetadata;
|
|
12
|
+
refundedAmount?: number;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ListPaymentsParams {
|
|
16
|
+
customerId?: string;
|
|
17
|
+
status?: PaymentStatus;
|
|
18
|
+
limit?: number;
|
|
19
|
+
cursor?: string;
|
|
20
|
+
/** ISO-8601 lower bound, inclusive. */
|
|
21
|
+
createdAfter?: string;
|
|
22
|
+
/** ISO-8601 upper bound, exclusive. */
|
|
23
|
+
createdBefore?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/types/payments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,aAAa,GACrB,kBAAkB,GAClB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,oBAAoB,GACpB,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.js","sourceRoot":"","sources":["../../src/types/payments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { OnflayMetadata } from './shared';
|
|
2
|
+
export type BillingScheme = 'flat' | 'tiered' | 'usage_based';
|
|
3
|
+
export type TiersMode = 'graduated' | 'volume';
|
|
4
|
+
export type RecurringInterval = 'day' | 'week' | 'month' | 'year';
|
|
5
|
+
export interface RecurringConfig {
|
|
6
|
+
interval: RecurringInterval;
|
|
7
|
+
intervalCount?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface PriceTierConfig {
|
|
10
|
+
/** Inclusive upper bound for this tier (`'inf'` for the catch-all). */
|
|
11
|
+
upTo: number | 'inf';
|
|
12
|
+
unitAmountInCents: number;
|
|
13
|
+
flatAmountInCents?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface OnflayPrice {
|
|
16
|
+
id: string;
|
|
17
|
+
object: 'price';
|
|
18
|
+
product: string;
|
|
19
|
+
currency: string;
|
|
20
|
+
active: boolean;
|
|
21
|
+
billingScheme: BillingScheme;
|
|
22
|
+
unitAmount: number | null;
|
|
23
|
+
recurring?: RecurringConfig | null;
|
|
24
|
+
tiersMode?: TiersMode | null;
|
|
25
|
+
tiers?: PriceTierConfig[];
|
|
26
|
+
metadata?: OnflayMetadata;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CreatePriceParams {
|
|
30
|
+
productId: string;
|
|
31
|
+
currency: string;
|
|
32
|
+
/** Required for `billingScheme: 'flat'`. */
|
|
33
|
+
unitAmountInCents?: number;
|
|
34
|
+
billingScheme?: BillingScheme;
|
|
35
|
+
tiersMode?: TiersMode;
|
|
36
|
+
tiers?: PriceTierConfig[];
|
|
37
|
+
recurring?: RecurringConfig;
|
|
38
|
+
active?: boolean;
|
|
39
|
+
metadata?: OnflayMetadata;
|
|
40
|
+
}
|
|
41
|
+
export interface UpdatePriceParams {
|
|
42
|
+
/**
|
|
43
|
+
* Note: only mutable fields are accepted. Fields that affect billing
|
|
44
|
+
* (`unitAmountInCents`, `currency`, `recurring`, tiers) are immutable
|
|
45
|
+
* once a price is referenced by a subscription. Use the catalog
|
|
46
|
+
* `apply` flow or create a fresh price when those need to change.
|
|
47
|
+
*/
|
|
48
|
+
active?: boolean;
|
|
49
|
+
metadata?: OnflayMetadata;
|
|
50
|
+
}
|
|
51
|
+
export interface ListPricesParams {
|
|
52
|
+
productId?: string;
|
|
53
|
+
active?: boolean;
|
|
54
|
+
limit?: number;
|
|
55
|
+
cursor?: string;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=prices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prices.d.ts","sourceRoot":"","sources":["../../src/types/prices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;AAC9D,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAC/C,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prices.js","sourceRoot":"","sources":["../../src/types/prices.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OnflayMetadata } from './shared';
|
|
2
|
+
export interface OnflayProduct {
|
|
3
|
+
id: string;
|
|
4
|
+
object: 'product';
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
active: boolean;
|
|
8
|
+
metadata?: OnflayMetadata;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateProductParams {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
metadata?: OnflayMetadata;
|
|
17
|
+
}
|
|
18
|
+
export interface UpdateProductParams {
|
|
19
|
+
name?: string;
|
|
20
|
+
description?: string | null;
|
|
21
|
+
active?: boolean;
|
|
22
|
+
metadata?: OnflayMetadata;
|
|
23
|
+
}
|
|
24
|
+
export interface ListProductsParams {
|
|
25
|
+
active?: boolean;
|
|
26
|
+
limit?: number;
|
|
27
|
+
cursor?: string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=products.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/types/products.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"products.js","sourceRoot":"","sources":["../../src/types/products.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Common types shared across resources. */
|
|
2
|
+
export interface OnflayMetadata {
|
|
3
|
+
[key: string]: string | number | boolean | null;
|
|
4
|
+
}
|
|
5
|
+
export interface PaginationParams {
|
|
6
|
+
limit?: number;
|
|
7
|
+
cursor?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface PageMeta {
|
|
10
|
+
nextCursor: string | null;
|
|
11
|
+
hasMore?: boolean;
|
|
12
|
+
total?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Canonical paginated list shape returned by collection endpoints. Resources
|
|
16
|
+
* may also return cursor-less arrays; helpers in `pagination.ts` smooth
|
|
17
|
+
* over both shapes.
|
|
18
|
+
*/
|
|
19
|
+
export interface PaginatedList<T> {
|
|
20
|
+
data: T[];
|
|
21
|
+
meta?: PageMeta;
|
|
22
|
+
nextCursor?: string | null;
|
|
23
|
+
hasMore?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ListIterator<T> {
|
|
26
|
+
/**
|
|
27
|
+
* Async iterable that walks every page of the list, transparently
|
|
28
|
+
* paginating until the API reports no more results.
|
|
29
|
+
*/
|
|
30
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
31
|
+
/** Materialise the entire list. Use with care on large collections. */
|
|
32
|
+
toArray(): Promise<T[]>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/types/shared.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B;;;OAGG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;IAC3C,uEAAuE;IACvE,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/types/shared.ts"],"names":[],"mappings":";AAAA,4CAA4C"}
|