n8n-nodes-lemonsqueezy 0.4.0 → 0.5.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/README.md +90 -1
- package/dist/nodes/LemonSqueezy/LemonSqueezy.node.js +34 -5
- package/dist/nodes/LemonSqueezy/LemonSqueezyTrigger.node.js +78 -33
- package/dist/nodes/LemonSqueezy/helpers.d.ts +312 -17
- package/dist/nodes/LemonSqueezy/helpers.js +360 -24
- package/dist/nodes/LemonSqueezy/resources/index.js +9 -0
- package/dist/nodes/LemonSqueezy/resources/shared.d.ts +64 -0
- package/dist/nodes/LemonSqueezy/resources/shared.js +196 -0
- package/dist/nodes/LemonSqueezy/types.d.ts +63 -7
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.discountAdvancedOptions = exports.checkoutAdvancedOptions = exports.variantAdvancedOptions = exports.productAdvancedOptions = exports.licenseKeyAdvancedOptions = exports.customerAdvancedOptions = exports.subscriptionAdvancedOptions = exports.orderAdvancedOptions = exports.RESOURCE_INCLUDES = exports.COMMON_SORT_FIELDS = exports.SORT_DIRECTIONS = void 0;
|
|
4
|
+
exports.createReturnAllField = createReturnAllField;
|
|
5
|
+
exports.createLimitField = createLimitField;
|
|
6
|
+
exports.createIdField = createIdField;
|
|
7
|
+
exports.createAdvancedOptionsField = createAdvancedOptionsField;
|
|
8
|
+
/**
|
|
9
|
+
* Shared field definitions for advanced query options
|
|
10
|
+
* Used across multiple resources for consistent sorting and relationship expansion
|
|
11
|
+
*
|
|
12
|
+
* This module reduces code duplication by providing reusable field definitions
|
|
13
|
+
* for common patterns like pagination (returnAll, limit), sorting, and filtering.
|
|
14
|
+
*/
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Common Field Generators
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Creates a 'Return All' toggle field for a resource
|
|
20
|
+
* @param resource - The resource name (e.g., 'product', 'order')
|
|
21
|
+
* @param operations - Operations where this field applies (default: ['getAll'])
|
|
22
|
+
*/
|
|
23
|
+
function createReturnAllField(resource, operations = ['getAll']) {
|
|
24
|
+
return {
|
|
25
|
+
displayName: 'Return All',
|
|
26
|
+
name: 'returnAll',
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
default: false,
|
|
29
|
+
description: 'Whether to return all results or only up to a given limit',
|
|
30
|
+
displayOptions: {
|
|
31
|
+
show: { resource: [resource], operation: operations },
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a 'Limit' number field for a resource
|
|
37
|
+
* @param resource - The resource name
|
|
38
|
+
* @param operations - Operations where this field applies
|
|
39
|
+
*/
|
|
40
|
+
function createLimitField(resource, operations = ['getAll']) {
|
|
41
|
+
return {
|
|
42
|
+
displayName: 'Limit',
|
|
43
|
+
name: 'limit',
|
|
44
|
+
type: 'number',
|
|
45
|
+
default: 50,
|
|
46
|
+
description: 'Max number of results to return',
|
|
47
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
48
|
+
displayOptions: {
|
|
49
|
+
show: { resource: [resource], operation: operations, returnAll: [false] },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a resource ID field
|
|
55
|
+
* @param resource - The resource name
|
|
56
|
+
* @param idName - The parameter name for the ID (e.g., 'productId')
|
|
57
|
+
* @param displayName - Display name shown in UI
|
|
58
|
+
* @param operations - Operations where this field applies
|
|
59
|
+
*/
|
|
60
|
+
function createIdField(resource, idName, displayName, operations = ['get', 'delete']) {
|
|
61
|
+
return {
|
|
62
|
+
displayName,
|
|
63
|
+
name: idName,
|
|
64
|
+
type: 'string',
|
|
65
|
+
required: true,
|
|
66
|
+
default: '',
|
|
67
|
+
description: `The ID of the ${resource}`,
|
|
68
|
+
displayOptions: {
|
|
69
|
+
show: { resource: [resource], operation: operations },
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Sort Options
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Sort direction options for API queries
|
|
78
|
+
*/
|
|
79
|
+
exports.SORT_DIRECTIONS = [
|
|
80
|
+
{ name: 'Ascending', value: 'asc' },
|
|
81
|
+
{ name: 'Descending', value: 'desc' },
|
|
82
|
+
];
|
|
83
|
+
/**
|
|
84
|
+
* Common sortable fields across resources
|
|
85
|
+
*/
|
|
86
|
+
exports.COMMON_SORT_FIELDS = [
|
|
87
|
+
{ name: 'Created At', value: 'created_at' },
|
|
88
|
+
{ name: 'Updated At', value: 'updated_at' },
|
|
89
|
+
];
|
|
90
|
+
/**
|
|
91
|
+
* Resource-specific includable relationships
|
|
92
|
+
*/
|
|
93
|
+
exports.RESOURCE_INCLUDES = {
|
|
94
|
+
order: [
|
|
95
|
+
{ name: 'Store', value: 'store' },
|
|
96
|
+
{ name: 'Customer', value: 'customer' },
|
|
97
|
+
{ name: 'Order Items', value: 'order-items' },
|
|
98
|
+
{ name: 'Subscriptions', value: 'subscriptions' },
|
|
99
|
+
{ name: 'License Keys', value: 'license-keys' },
|
|
100
|
+
{ name: 'Discount Redemptions', value: 'discount-redemptions' },
|
|
101
|
+
],
|
|
102
|
+
subscription: [
|
|
103
|
+
{ name: 'Store', value: 'store' },
|
|
104
|
+
{ name: 'Customer', value: 'customer' },
|
|
105
|
+
{ name: 'Order', value: 'order' },
|
|
106
|
+
{ name: 'Order Item', value: 'order-item' },
|
|
107
|
+
{ name: 'Product', value: 'product' },
|
|
108
|
+
{ name: 'Variant', value: 'variant' },
|
|
109
|
+
],
|
|
110
|
+
customer: [
|
|
111
|
+
{ name: 'Store', value: 'store' },
|
|
112
|
+
{ name: 'Orders', value: 'orders' },
|
|
113
|
+
{ name: 'Subscriptions', value: 'subscriptions' },
|
|
114
|
+
{ name: 'License Keys', value: 'license-keys' },
|
|
115
|
+
],
|
|
116
|
+
licenseKey: [
|
|
117
|
+
{ name: 'Store', value: 'store' },
|
|
118
|
+
{ name: 'Customer', value: 'customer' },
|
|
119
|
+
{ name: 'Order', value: 'order' },
|
|
120
|
+
{ name: 'Order Item', value: 'order-item' },
|
|
121
|
+
{ name: 'Product', value: 'product' },
|
|
122
|
+
{ name: 'License Key Instances', value: 'license-key-instances' },
|
|
123
|
+
],
|
|
124
|
+
product: [
|
|
125
|
+
{ name: 'Store', value: 'store' },
|
|
126
|
+
{ name: 'Variants', value: 'variants' },
|
|
127
|
+
],
|
|
128
|
+
variant: [
|
|
129
|
+
{ name: 'Product', value: 'product' },
|
|
130
|
+
{ name: 'Files', value: 'files' },
|
|
131
|
+
],
|
|
132
|
+
checkout: [
|
|
133
|
+
{ name: 'Store', value: 'store' },
|
|
134
|
+
{ name: 'Variant', value: 'variant' },
|
|
135
|
+
],
|
|
136
|
+
discount: [
|
|
137
|
+
{ name: 'Store', value: 'store' },
|
|
138
|
+
{ name: 'Discount Redemptions', value: 'discount-redemptions' },
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Generate advanced options field for a specific resource
|
|
143
|
+
*/
|
|
144
|
+
function createAdvancedOptionsField(resource, operations = ['getAll']) {
|
|
145
|
+
const includes = exports.RESOURCE_INCLUDES[resource] || [];
|
|
146
|
+
const options = [
|
|
147
|
+
{
|
|
148
|
+
displayName: 'Sort Field',
|
|
149
|
+
name: 'sortField',
|
|
150
|
+
type: 'options',
|
|
151
|
+
options: exports.COMMON_SORT_FIELDS,
|
|
152
|
+
default: '',
|
|
153
|
+
description: 'Field to sort results by',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
displayName: 'Sort Direction',
|
|
157
|
+
name: 'sortDirection',
|
|
158
|
+
type: 'options',
|
|
159
|
+
options: exports.SORT_DIRECTIONS,
|
|
160
|
+
default: 'desc',
|
|
161
|
+
description: 'Direction to sort results',
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
if (includes.length > 0) {
|
|
165
|
+
options.push({
|
|
166
|
+
displayName: 'Include Related',
|
|
167
|
+
name: 'include',
|
|
168
|
+
type: 'multiOptions',
|
|
169
|
+
options: includes,
|
|
170
|
+
default: [],
|
|
171
|
+
description: 'Related resources to include in the response',
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
displayName: 'Advanced Options',
|
|
176
|
+
name: 'advancedOptions',
|
|
177
|
+
type: 'collection',
|
|
178
|
+
placeholder: 'Add Option',
|
|
179
|
+
default: {},
|
|
180
|
+
displayOptions: {
|
|
181
|
+
show: { resource: [resource], operation: operations },
|
|
182
|
+
},
|
|
183
|
+
options,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Pre-built advanced options fields for each resource
|
|
188
|
+
*/
|
|
189
|
+
exports.orderAdvancedOptions = createAdvancedOptionsField('order');
|
|
190
|
+
exports.subscriptionAdvancedOptions = createAdvancedOptionsField('subscription');
|
|
191
|
+
exports.customerAdvancedOptions = createAdvancedOptionsField('customer');
|
|
192
|
+
exports.licenseKeyAdvancedOptions = createAdvancedOptionsField('licenseKey');
|
|
193
|
+
exports.productAdvancedOptions = createAdvancedOptionsField('product');
|
|
194
|
+
exports.variantAdvancedOptions = createAdvancedOptionsField('variant');
|
|
195
|
+
exports.checkoutAdvancedOptions = createAdvancedOptionsField('checkout');
|
|
196
|
+
exports.discountAdvancedOptions = createAdvancedOptionsField('discount');
|
|
@@ -344,15 +344,71 @@ export type LicenseKeyInstance = JsonApiResource<'license-key-instances', Licens
|
|
|
344
344
|
*/
|
|
345
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
346
|
/**
|
|
347
|
-
* Webhook payload
|
|
347
|
+
* Webhook payload received from Lemon Squeezy
|
|
348
348
|
*/
|
|
349
|
-
export interface WebhookPayload {
|
|
350
|
-
meta:
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
349
|
+
export interface WebhookPayload<T = IDataObject> {
|
|
350
|
+
meta: WebhookMeta;
|
|
351
|
+
data: T;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Webhook metadata
|
|
355
|
+
*/
|
|
356
|
+
export interface WebhookMeta {
|
|
357
|
+
event_name: WebhookEventType;
|
|
358
|
+
custom_data?: IDataObject;
|
|
359
|
+
test_mode: boolean;
|
|
360
|
+
webhook_id?: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* API Error response structure
|
|
364
|
+
*/
|
|
365
|
+
export interface ApiError {
|
|
366
|
+
errors: ApiErrorDetail[];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Individual API error detail
|
|
370
|
+
*/
|
|
371
|
+
export interface ApiErrorDetail {
|
|
372
|
+
detail: string;
|
|
373
|
+
title?: string;
|
|
374
|
+
status?: string;
|
|
375
|
+
source?: {
|
|
376
|
+
pointer?: string;
|
|
377
|
+
parameter?: string;
|
|
354
378
|
};
|
|
355
|
-
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Pagination metadata from API responses
|
|
382
|
+
*/
|
|
383
|
+
export interface PaginationMeta {
|
|
384
|
+
page: {
|
|
385
|
+
currentPage: number;
|
|
386
|
+
from: number;
|
|
387
|
+
lastPage: number;
|
|
388
|
+
perPage: number;
|
|
389
|
+
to: number;
|
|
390
|
+
total: number;
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Pagination links from API responses
|
|
395
|
+
*/
|
|
396
|
+
export interface PaginationLinks {
|
|
397
|
+
first?: string;
|
|
398
|
+
last?: string;
|
|
399
|
+
next?: string;
|
|
400
|
+
prev?: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Options for paginated requests
|
|
404
|
+
*/
|
|
405
|
+
export interface PaginationOptions {
|
|
406
|
+
/** Maximum number of items to fetch (default: no limit) */
|
|
407
|
+
maxItems?: number;
|
|
408
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
409
|
+
timeout?: number;
|
|
410
|
+
/** Page size for each request (default: 100) */
|
|
411
|
+
pageSize?: number;
|
|
356
412
|
}
|
|
357
413
|
/**
|
|
358
414
|
* Resource name to endpoint mapping
|