n8n-nodes-lemonsqueezy 0.2.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/LICENSE +21 -0
- package/README.md +216 -0
- package/dist/credentials/LemonSqueezyApi.credentials.d.ts +10 -0
- package/dist/credentials/LemonSqueezyApi.credentials.js +41 -0
- package/dist/nodes/LemonSqueezy/LemonSqueezy.node.d.ts +5 -0
- package/dist/nodes/LemonSqueezy/LemonSqueezy.node.js +358 -0
- package/dist/nodes/LemonSqueezy/LemonSqueezyTrigger.node.d.ts +12 -0
- package/dist/nodes/LemonSqueezy/LemonSqueezyTrigger.node.js +230 -0
- package/dist/nodes/LemonSqueezy/constants.d.ts +89 -0
- package/dist/nodes/LemonSqueezy/constants.js +207 -0
- package/dist/nodes/LemonSqueezy/helpers.d.ts +28 -0
- package/dist/nodes/LemonSqueezy/helpers.js +241 -0
- package/dist/nodes/LemonSqueezy/lemonSqueezy.svg +20 -0
- package/dist/nodes/LemonSqueezy/resources/checkout.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/checkout.js +272 -0
- package/dist/nodes/LemonSqueezy/resources/customer.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/customer.js +242 -0
- package/dist/nodes/LemonSqueezy/resources/discount.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/discount.js +210 -0
- package/dist/nodes/LemonSqueezy/resources/index.d.ts +15 -0
- package/dist/nodes/LemonSqueezy/resources/index.js +76 -0
- package/dist/nodes/LemonSqueezy/resources/licenseKey.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/licenseKey.js +209 -0
- package/dist/nodes/LemonSqueezy/resources/order.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/order.js +113 -0
- package/dist/nodes/LemonSqueezy/resources/product.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/product.js +93 -0
- package/dist/nodes/LemonSqueezy/resources/store.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/store.js +64 -0
- package/dist/nodes/LemonSqueezy/resources/subscription.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/subscription.js +196 -0
- package/dist/nodes/LemonSqueezy/resources/variant.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/variant.js +96 -0
- package/dist/nodes/LemonSqueezy/resources/webhook.d.ts +3 -0
- package/dist/nodes/LemonSqueezy/resources/webhook.js +206 -0
- package/dist/nodes/LemonSqueezy/types.d.ts +364 -0
- package/dist/nodes/LemonSqueezy/types.js +2 -0
- package/package.json +71 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.variantFields = exports.variantOperations = void 0;
|
|
4
|
+
exports.variantOperations = {
|
|
5
|
+
displayName: 'Operation',
|
|
6
|
+
name: 'operation',
|
|
7
|
+
type: 'options',
|
|
8
|
+
noDataExpression: true,
|
|
9
|
+
displayOptions: {
|
|
10
|
+
show: { resource: ['variant'] },
|
|
11
|
+
},
|
|
12
|
+
options: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Get',
|
|
15
|
+
value: 'get',
|
|
16
|
+
action: 'Get a variant',
|
|
17
|
+
description: 'Retrieve a single variant by ID',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'Get Many',
|
|
21
|
+
value: 'getAll',
|
|
22
|
+
action: 'Get many variants',
|
|
23
|
+
description: 'Retrieve multiple variants',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
default: 'getAll',
|
|
27
|
+
};
|
|
28
|
+
exports.variantFields = [
|
|
29
|
+
// Variant ID for Get operation
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Variant ID',
|
|
32
|
+
name: 'variantId',
|
|
33
|
+
type: 'string',
|
|
34
|
+
required: true,
|
|
35
|
+
default: '',
|
|
36
|
+
description: 'The ID of the variant to retrieve',
|
|
37
|
+
displayOptions: {
|
|
38
|
+
show: { resource: ['variant'], operation: ['get'] },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
// Return All
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Return All',
|
|
44
|
+
name: 'returnAll',
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: false,
|
|
47
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
48
|
+
displayOptions: {
|
|
49
|
+
show: { resource: ['variant'], operation: ['getAll'] },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
// Limit
|
|
53
|
+
{
|
|
54
|
+
displayName: 'Limit',
|
|
55
|
+
name: 'limit',
|
|
56
|
+
type: 'number',
|
|
57
|
+
default: 50,
|
|
58
|
+
description: 'Max number of results to return',
|
|
59
|
+
typeOptions: { minValue: 1 },
|
|
60
|
+
displayOptions: {
|
|
61
|
+
show: { resource: ['variant'], operation: ['getAll'], returnAll: [false] },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
// Filters
|
|
65
|
+
{
|
|
66
|
+
displayName: 'Filters',
|
|
67
|
+
name: 'filters',
|
|
68
|
+
type: 'collection',
|
|
69
|
+
placeholder: 'Add Filter',
|
|
70
|
+
default: {},
|
|
71
|
+
displayOptions: {
|
|
72
|
+
show: { resource: ['variant'], operation: ['getAll'] },
|
|
73
|
+
},
|
|
74
|
+
options: [
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Product ID',
|
|
77
|
+
name: 'productId',
|
|
78
|
+
type: 'string',
|
|
79
|
+
default: '',
|
|
80
|
+
description: 'Filter by product ID',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Status',
|
|
84
|
+
name: 'status',
|
|
85
|
+
type: 'options',
|
|
86
|
+
options: [
|
|
87
|
+
{ name: 'Pending', value: 'pending' },
|
|
88
|
+
{ name: 'Draft', value: 'draft' },
|
|
89
|
+
{ name: 'Published', value: 'published' },
|
|
90
|
+
],
|
|
91
|
+
default: '',
|
|
92
|
+
description: 'Filter by variant status',
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
];
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webhookFields = exports.webhookOperations = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
exports.webhookOperations = {
|
|
6
|
+
displayName: 'Operation',
|
|
7
|
+
name: 'operation',
|
|
8
|
+
type: 'options',
|
|
9
|
+
noDataExpression: true,
|
|
10
|
+
displayOptions: {
|
|
11
|
+
show: { resource: ['webhook'] },
|
|
12
|
+
},
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
name: 'Create',
|
|
16
|
+
value: 'create',
|
|
17
|
+
action: 'Create a webhook',
|
|
18
|
+
description: 'Create a new webhook',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Delete',
|
|
22
|
+
value: 'delete',
|
|
23
|
+
action: 'Delete a webhook',
|
|
24
|
+
description: 'Delete a webhook',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'Get',
|
|
28
|
+
value: 'get',
|
|
29
|
+
action: 'Get a webhook',
|
|
30
|
+
description: 'Retrieve a single webhook by ID',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'Get Many',
|
|
34
|
+
value: 'getAll',
|
|
35
|
+
action: 'Get many webhooks',
|
|
36
|
+
description: 'Retrieve multiple webhooks',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Update',
|
|
40
|
+
value: 'update',
|
|
41
|
+
action: 'Update a webhook',
|
|
42
|
+
description: 'Update a webhook',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
default: 'getAll',
|
|
46
|
+
};
|
|
47
|
+
exports.webhookFields = [
|
|
48
|
+
// Webhook ID for Get/Update/Delete operations
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Webhook ID',
|
|
51
|
+
name: 'webhookId',
|
|
52
|
+
type: 'string',
|
|
53
|
+
required: true,
|
|
54
|
+
default: '',
|
|
55
|
+
description: 'The ID of the webhook',
|
|
56
|
+
displayOptions: {
|
|
57
|
+
show: { resource: ['webhook'], operation: ['get', 'update', 'delete'] },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
// Create Fields
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Store ID',
|
|
63
|
+
name: 'webhookStoreId',
|
|
64
|
+
type: 'string',
|
|
65
|
+
required: true,
|
|
66
|
+
default: '',
|
|
67
|
+
description: 'The ID of the store this webhook belongs to',
|
|
68
|
+
displayOptions: {
|
|
69
|
+
show: { resource: ['webhook'], operation: ['create'] },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
displayName: 'URL',
|
|
74
|
+
name: 'webhookUrl',
|
|
75
|
+
type: 'string',
|
|
76
|
+
required: true,
|
|
77
|
+
default: '',
|
|
78
|
+
placeholder: 'https://your-app.com/webhooks/lemonsqueezy',
|
|
79
|
+
description: 'The URL to send webhook events to',
|
|
80
|
+
displayOptions: {
|
|
81
|
+
show: { resource: ['webhook'], operation: ['create'] },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Events',
|
|
86
|
+
name: 'webhookEvents',
|
|
87
|
+
type: 'multiOptions',
|
|
88
|
+
required: true,
|
|
89
|
+
options: constants_1.WEBHOOK_EVENTS,
|
|
90
|
+
default: [],
|
|
91
|
+
description: 'The events to subscribe to',
|
|
92
|
+
displayOptions: {
|
|
93
|
+
show: { resource: ['webhook'], operation: ['create'] },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
displayName: 'Secret',
|
|
98
|
+
name: 'webhookSecret',
|
|
99
|
+
type: 'string',
|
|
100
|
+
required: true,
|
|
101
|
+
default: '',
|
|
102
|
+
typeOptions: { password: true },
|
|
103
|
+
description: 'A secret string used to sign webhook payloads for verification',
|
|
104
|
+
displayOptions: {
|
|
105
|
+
show: { resource: ['webhook'], operation: ['create'] },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Additional Options',
|
|
110
|
+
name: 'additionalOptions',
|
|
111
|
+
type: 'collection',
|
|
112
|
+
placeholder: 'Add Option',
|
|
113
|
+
default: {},
|
|
114
|
+
displayOptions: {
|
|
115
|
+
show: { resource: ['webhook'], operation: ['create'] },
|
|
116
|
+
},
|
|
117
|
+
options: [
|
|
118
|
+
{
|
|
119
|
+
displayName: 'Test Mode',
|
|
120
|
+
name: 'testMode',
|
|
121
|
+
type: 'boolean',
|
|
122
|
+
default: false,
|
|
123
|
+
description: 'Whether this webhook should only receive test events',
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
// Update Fields
|
|
128
|
+
{
|
|
129
|
+
displayName: 'Update Fields',
|
|
130
|
+
name: 'updateFields',
|
|
131
|
+
type: 'collection',
|
|
132
|
+
placeholder: 'Add Field',
|
|
133
|
+
default: {},
|
|
134
|
+
displayOptions: {
|
|
135
|
+
show: { resource: ['webhook'], operation: ['update'] },
|
|
136
|
+
},
|
|
137
|
+
options: [
|
|
138
|
+
{
|
|
139
|
+
displayName: 'URL',
|
|
140
|
+
name: 'url',
|
|
141
|
+
type: 'string',
|
|
142
|
+
default: '',
|
|
143
|
+
description: 'The URL to send webhook events to',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
displayName: 'Events',
|
|
147
|
+
name: 'events',
|
|
148
|
+
type: 'multiOptions',
|
|
149
|
+
options: constants_1.WEBHOOK_EVENTS,
|
|
150
|
+
default: [],
|
|
151
|
+
description: 'The events to subscribe to',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
displayName: 'Secret',
|
|
155
|
+
name: 'secret',
|
|
156
|
+
type: 'string',
|
|
157
|
+
typeOptions: { password: true },
|
|
158
|
+
default: '',
|
|
159
|
+
description: 'A secret string used to sign webhook payloads',
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
// Return All
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Return All',
|
|
166
|
+
name: 'returnAll',
|
|
167
|
+
type: 'boolean',
|
|
168
|
+
default: false,
|
|
169
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
170
|
+
displayOptions: {
|
|
171
|
+
show: { resource: ['webhook'], operation: ['getAll'] },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
// Limit
|
|
175
|
+
{
|
|
176
|
+
displayName: 'Limit',
|
|
177
|
+
name: 'limit',
|
|
178
|
+
type: 'number',
|
|
179
|
+
default: 50,
|
|
180
|
+
description: 'Max number of results to return',
|
|
181
|
+
typeOptions: { minValue: 1 },
|
|
182
|
+
displayOptions: {
|
|
183
|
+
show: { resource: ['webhook'], operation: ['getAll'], returnAll: [false] },
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
// Filters
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Filters',
|
|
189
|
+
name: 'filters',
|
|
190
|
+
type: 'collection',
|
|
191
|
+
placeholder: 'Add Filter',
|
|
192
|
+
default: {},
|
|
193
|
+
displayOptions: {
|
|
194
|
+
show: { resource: ['webhook'], operation: ['getAll'] },
|
|
195
|
+
},
|
|
196
|
+
options: [
|
|
197
|
+
{
|
|
198
|
+
displayName: 'Store ID',
|
|
199
|
+
name: 'storeId',
|
|
200
|
+
type: 'string',
|
|
201
|
+
default: '',
|
|
202
|
+
description: 'Filter by store ID',
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
},
|
|
206
|
+
];
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import type { IDataObject } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Lemon Squeezy API response wrapper
|
|
4
|
+
*/
|
|
5
|
+
export interface LemonSqueezyResponse<T = IDataObject> {
|
|
6
|
+
data: T | T[];
|
|
7
|
+
meta?: {
|
|
8
|
+
page: {
|
|
9
|
+
currentPage: number;
|
|
10
|
+
from: number;
|
|
11
|
+
lastPage: number;
|
|
12
|
+
perPage: number;
|
|
13
|
+
to: number;
|
|
14
|
+
total: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
links?: {
|
|
18
|
+
first?: string;
|
|
19
|
+
last?: string;
|
|
20
|
+
next?: string;
|
|
21
|
+
prev?: string;
|
|
22
|
+
};
|
|
23
|
+
jsonapi?: {
|
|
24
|
+
version: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Base attributes shared across resources
|
|
29
|
+
*/
|
|
30
|
+
export interface BaseAttributes {
|
|
31
|
+
created_at: string;
|
|
32
|
+
updated_at: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* JSON:API resource object
|
|
36
|
+
*/
|
|
37
|
+
export interface JsonApiResource<T extends string, A extends BaseAttributes> {
|
|
38
|
+
type: T;
|
|
39
|
+
id: string;
|
|
40
|
+
attributes: A;
|
|
41
|
+
relationships?: Record<string, JsonApiRelationship>;
|
|
42
|
+
links?: {
|
|
43
|
+
self: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* JSON:API relationship
|
|
48
|
+
*/
|
|
49
|
+
export interface JsonApiRelationship {
|
|
50
|
+
links?: {
|
|
51
|
+
related: string;
|
|
52
|
+
self: string;
|
|
53
|
+
};
|
|
54
|
+
data?: {
|
|
55
|
+
type: string;
|
|
56
|
+
id: string;
|
|
57
|
+
} | null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Store attributes
|
|
61
|
+
*/
|
|
62
|
+
export interface StoreAttributes extends BaseAttributes {
|
|
63
|
+
name: string;
|
|
64
|
+
slug: string;
|
|
65
|
+
domain: string;
|
|
66
|
+
url: string;
|
|
67
|
+
avatar_url: string;
|
|
68
|
+
plan: string;
|
|
69
|
+
country: string;
|
|
70
|
+
country_nicename: string;
|
|
71
|
+
currency: string;
|
|
72
|
+
total_sales: number;
|
|
73
|
+
total_revenue: number;
|
|
74
|
+
thirty_day_sales: number;
|
|
75
|
+
thirty_day_revenue: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Product attributes
|
|
79
|
+
*/
|
|
80
|
+
export interface ProductAttributes extends BaseAttributes {
|
|
81
|
+
store_id: number;
|
|
82
|
+
name: string;
|
|
83
|
+
slug: string;
|
|
84
|
+
description: string;
|
|
85
|
+
status: 'draft' | 'published';
|
|
86
|
+
status_formatted: string;
|
|
87
|
+
thumb_url: string | null;
|
|
88
|
+
large_thumb_url: string | null;
|
|
89
|
+
price: number;
|
|
90
|
+
price_formatted: string;
|
|
91
|
+
from_price: number | null;
|
|
92
|
+
to_price: number | null;
|
|
93
|
+
pay_what_you_want: boolean;
|
|
94
|
+
buy_now_url: string;
|
|
95
|
+
test_mode: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Variant attributes
|
|
99
|
+
*/
|
|
100
|
+
export interface VariantAttributes extends BaseAttributes {
|
|
101
|
+
product_id: number;
|
|
102
|
+
name: string;
|
|
103
|
+
slug: string;
|
|
104
|
+
description: string;
|
|
105
|
+
price: number;
|
|
106
|
+
is_subscription: boolean;
|
|
107
|
+
interval: 'day' | 'week' | 'month' | 'year' | null;
|
|
108
|
+
interval_count: number | null;
|
|
109
|
+
has_free_trial: boolean;
|
|
110
|
+
trial_interval: 'day' | 'week' | 'month' | 'year';
|
|
111
|
+
trial_interval_count: number;
|
|
112
|
+
pay_what_you_want: boolean;
|
|
113
|
+
min_price: number;
|
|
114
|
+
suggested_price: number;
|
|
115
|
+
has_license_keys: boolean;
|
|
116
|
+
license_activation_limit: number;
|
|
117
|
+
is_license_limit_unlimited: boolean;
|
|
118
|
+
license_length_value: number | null;
|
|
119
|
+
license_length_unit: 'days' | 'months' | 'years';
|
|
120
|
+
sort: number;
|
|
121
|
+
status: 'pending' | 'draft' | 'published';
|
|
122
|
+
status_formatted: string;
|
|
123
|
+
test_mode: boolean;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Customer attributes
|
|
127
|
+
*/
|
|
128
|
+
export interface CustomerAttributes extends BaseAttributes {
|
|
129
|
+
store_id: number;
|
|
130
|
+
name: string;
|
|
131
|
+
email: string;
|
|
132
|
+
status: 'subscribed' | 'unsubscribed' | 'archived' | 'requires_verification' | 'invalid_email' | 'bounced';
|
|
133
|
+
status_formatted: string;
|
|
134
|
+
city: string | null;
|
|
135
|
+
region: string | null;
|
|
136
|
+
country: string | null;
|
|
137
|
+
total_revenue_currency: number;
|
|
138
|
+
mrr: number;
|
|
139
|
+
urls: {
|
|
140
|
+
customer_portal: string;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Order attributes
|
|
145
|
+
*/
|
|
146
|
+
export interface OrderAttributes extends BaseAttributes {
|
|
147
|
+
store_id: number;
|
|
148
|
+
customer_id: number;
|
|
149
|
+
identifier: string;
|
|
150
|
+
order_number: number;
|
|
151
|
+
user_name: string;
|
|
152
|
+
user_email: string;
|
|
153
|
+
currency: string;
|
|
154
|
+
currency_rate: string;
|
|
155
|
+
subtotal: number;
|
|
156
|
+
discount_total: number;
|
|
157
|
+
tax: number;
|
|
158
|
+
total: number;
|
|
159
|
+
subtotal_usd: number;
|
|
160
|
+
discount_total_usd: number;
|
|
161
|
+
tax_usd: number;
|
|
162
|
+
total_usd: number;
|
|
163
|
+
tax_name: string | null;
|
|
164
|
+
tax_rate: string;
|
|
165
|
+
status: 'pending' | 'failed' | 'paid' | 'refunded';
|
|
166
|
+
status_formatted: string;
|
|
167
|
+
refunded: boolean;
|
|
168
|
+
refunded_at: string | null;
|
|
169
|
+
subtotal_formatted: string;
|
|
170
|
+
discount_total_formatted: string;
|
|
171
|
+
tax_formatted: string;
|
|
172
|
+
total_formatted: string;
|
|
173
|
+
first_order_item: IDataObject;
|
|
174
|
+
urls: {
|
|
175
|
+
receipt: string;
|
|
176
|
+
};
|
|
177
|
+
test_mode: boolean;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Subscription attributes
|
|
181
|
+
*/
|
|
182
|
+
export interface SubscriptionAttributes extends BaseAttributes {
|
|
183
|
+
store_id: number;
|
|
184
|
+
customer_id: number;
|
|
185
|
+
order_id: number;
|
|
186
|
+
order_item_id: number;
|
|
187
|
+
product_id: number;
|
|
188
|
+
variant_id: number;
|
|
189
|
+
product_name: string;
|
|
190
|
+
variant_name: string;
|
|
191
|
+
user_name: string;
|
|
192
|
+
user_email: string;
|
|
193
|
+
status: 'on_trial' | 'active' | 'paused' | 'past_due' | 'unpaid' | 'cancelled' | 'expired';
|
|
194
|
+
status_formatted: string;
|
|
195
|
+
card_brand: string | null;
|
|
196
|
+
card_last_four: string | null;
|
|
197
|
+
pause: {
|
|
198
|
+
mode: 'void' | 'free';
|
|
199
|
+
resumes_at: string | null;
|
|
200
|
+
} | null;
|
|
201
|
+
cancelled: boolean;
|
|
202
|
+
trial_ends_at: string | null;
|
|
203
|
+
billing_anchor: number;
|
|
204
|
+
first_subscription_item: IDataObject;
|
|
205
|
+
urls: {
|
|
206
|
+
update_payment_method: string;
|
|
207
|
+
customer_portal: string;
|
|
208
|
+
};
|
|
209
|
+
renews_at: string;
|
|
210
|
+
ends_at: string | null;
|
|
211
|
+
test_mode: boolean;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* License Key attributes
|
|
215
|
+
*/
|
|
216
|
+
export interface LicenseKeyAttributes extends BaseAttributes {
|
|
217
|
+
store_id: number;
|
|
218
|
+
customer_id: number;
|
|
219
|
+
order_id: number;
|
|
220
|
+
order_item_id: number;
|
|
221
|
+
product_id: number;
|
|
222
|
+
user_name: string;
|
|
223
|
+
user_email: string;
|
|
224
|
+
key: string;
|
|
225
|
+
key_short: string;
|
|
226
|
+
activation_limit: number;
|
|
227
|
+
instances_count: number;
|
|
228
|
+
disabled: boolean;
|
|
229
|
+
status: 'inactive' | 'active' | 'expired' | 'disabled';
|
|
230
|
+
status_formatted: string;
|
|
231
|
+
expires_at: string | null;
|
|
232
|
+
test_mode: boolean;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Discount attributes
|
|
236
|
+
*/
|
|
237
|
+
export interface DiscountAttributes extends BaseAttributes {
|
|
238
|
+
store_id: number;
|
|
239
|
+
name: string;
|
|
240
|
+
code: string;
|
|
241
|
+
amount: number;
|
|
242
|
+
amount_type: 'percent' | 'fixed';
|
|
243
|
+
is_limited_to_products: boolean;
|
|
244
|
+
is_limited_redemptions: boolean;
|
|
245
|
+
max_redemptions: number;
|
|
246
|
+
starts_at: string | null;
|
|
247
|
+
expires_at: string | null;
|
|
248
|
+
duration: 'once' | 'repeating' | 'forever';
|
|
249
|
+
duration_in_months: number | null;
|
|
250
|
+
status: 'draft' | 'published';
|
|
251
|
+
status_formatted: string;
|
|
252
|
+
test_mode: boolean;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Checkout attributes
|
|
256
|
+
*/
|
|
257
|
+
export interface CheckoutAttributes extends BaseAttributes {
|
|
258
|
+
store_id: number;
|
|
259
|
+
variant_id: number;
|
|
260
|
+
custom_price: number | null;
|
|
261
|
+
product_options: {
|
|
262
|
+
name: string;
|
|
263
|
+
description: string;
|
|
264
|
+
media: string[];
|
|
265
|
+
redirect_url: string;
|
|
266
|
+
receipt_button_text: string;
|
|
267
|
+
receipt_link_url: string;
|
|
268
|
+
receipt_thank_you_note: string;
|
|
269
|
+
enabled_variants: number[];
|
|
270
|
+
};
|
|
271
|
+
checkout_options: {
|
|
272
|
+
embed: boolean;
|
|
273
|
+
media: boolean;
|
|
274
|
+
logo: boolean;
|
|
275
|
+
desc: boolean;
|
|
276
|
+
discount: boolean;
|
|
277
|
+
dark: boolean;
|
|
278
|
+
subscription_preview: boolean;
|
|
279
|
+
button_color: string;
|
|
280
|
+
};
|
|
281
|
+
checkout_data: {
|
|
282
|
+
email: string;
|
|
283
|
+
name: string;
|
|
284
|
+
billing_address: IDataObject;
|
|
285
|
+
tax_number: string;
|
|
286
|
+
discount_code: string;
|
|
287
|
+
custom: IDataObject;
|
|
288
|
+
variant_quantities: IDataObject[];
|
|
289
|
+
};
|
|
290
|
+
preview: {
|
|
291
|
+
currency: string;
|
|
292
|
+
currency_rate: number;
|
|
293
|
+
subtotal: number;
|
|
294
|
+
discount_total: number;
|
|
295
|
+
tax: number;
|
|
296
|
+
total: number;
|
|
297
|
+
subtotal_usd: number;
|
|
298
|
+
discount_total_usd: number;
|
|
299
|
+
tax_usd: number;
|
|
300
|
+
total_usd: number;
|
|
301
|
+
subtotal_formatted: string;
|
|
302
|
+
discount_total_formatted: string;
|
|
303
|
+
tax_formatted: string;
|
|
304
|
+
total_formatted: string;
|
|
305
|
+
};
|
|
306
|
+
expires_at: string | null;
|
|
307
|
+
url: string;
|
|
308
|
+
test_mode: boolean;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Webhook attributes
|
|
312
|
+
*/
|
|
313
|
+
export interface WebhookAttributes extends BaseAttributes {
|
|
314
|
+
store_id: number;
|
|
315
|
+
url: string;
|
|
316
|
+
events: string[];
|
|
317
|
+
last_sent_at: string | null;
|
|
318
|
+
test_mode: boolean;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* License Key Instance attributes
|
|
322
|
+
*/
|
|
323
|
+
export interface LicenseKeyInstanceAttributes extends BaseAttributes {
|
|
324
|
+
license_key_id: number;
|
|
325
|
+
identifier: string;
|
|
326
|
+
name: string;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Resource types
|
|
330
|
+
*/
|
|
331
|
+
export type Store = JsonApiResource<'stores', StoreAttributes>;
|
|
332
|
+
export type Product = JsonApiResource<'products', ProductAttributes>;
|
|
333
|
+
export type Variant = JsonApiResource<'variants', VariantAttributes>;
|
|
334
|
+
export type Customer = JsonApiResource<'customers', CustomerAttributes>;
|
|
335
|
+
export type Order = JsonApiResource<'orders', OrderAttributes>;
|
|
336
|
+
export type Subscription = JsonApiResource<'subscriptions', SubscriptionAttributes>;
|
|
337
|
+
export type LicenseKey = JsonApiResource<'license-keys', LicenseKeyAttributes>;
|
|
338
|
+
export type Discount = JsonApiResource<'discounts', DiscountAttributes>;
|
|
339
|
+
export type Checkout = JsonApiResource<'checkouts', CheckoutAttributes>;
|
|
340
|
+
export type Webhook = JsonApiResource<'webhooks', WebhookAttributes>;
|
|
341
|
+
export type LicenseKeyInstance = JsonApiResource<'license-key-instances', LicenseKeyInstanceAttributes>;
|
|
342
|
+
/**
|
|
343
|
+
* Webhook event types
|
|
344
|
+
*/
|
|
345
|
+
export type WebhookEventType = 'order_created' | 'order_refunded' | 'subscription_created' | 'subscription_updated' | 'subscription_cancelled' | 'subscription_resumed' | 'subscription_expired' | 'subscription_paused' | 'subscription_unpaused' | 'subscription_payment_success' | 'subscription_payment_failed' | 'subscription_payment_recovered' | 'subscription_payment_refunded' | 'license_key_created' | 'license_key_updated';
|
|
346
|
+
/**
|
|
347
|
+
* Webhook payload
|
|
348
|
+
*/
|
|
349
|
+
export interface WebhookPayload {
|
|
350
|
+
meta: {
|
|
351
|
+
event_name: WebhookEventType;
|
|
352
|
+
custom_data?: IDataObject;
|
|
353
|
+
test_mode: boolean;
|
|
354
|
+
};
|
|
355
|
+
data: IDataObject;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Resource name to endpoint mapping
|
|
359
|
+
*/
|
|
360
|
+
export type ResourceName = 'product' | 'order' | 'subscription' | 'customer' | 'licenseKey' | 'discount' | 'store' | 'variant' | 'checkout' | 'webhook' | 'licenseKeyInstance';
|
|
361
|
+
/**
|
|
362
|
+
* Operation types
|
|
363
|
+
*/
|
|
364
|
+
export type OperationType = 'get' | 'getAll' | 'create' | 'update' | 'delete' | 'cancel' | 'activate' | 'deactivate' | 'validate';
|