n8n-nodes-lemonsqueezy 0.2.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.
@@ -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');
@@ -0,0 +1,3 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const subscriptionInvoiceOperations: INodeProperties[];
3
+ export declare const subscriptionInvoiceFields: INodeProperties[];
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscriptionInvoiceFields = exports.subscriptionInvoiceOperations = void 0;
4
+ exports.subscriptionInvoiceOperations = [
5
+ {
6
+ displayName: 'Operation',
7
+ name: 'operation',
8
+ type: 'options',
9
+ noDataExpression: true,
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['subscriptionInvoice'],
13
+ },
14
+ },
15
+ options: [
16
+ {
17
+ name: 'Get',
18
+ value: 'get',
19
+ description: 'Get a subscription invoice by ID',
20
+ action: 'Get a subscription invoice',
21
+ },
22
+ {
23
+ name: 'Get Many',
24
+ value: 'getAll',
25
+ description: 'Get many subscription invoices',
26
+ action: 'Get many subscription invoices',
27
+ },
28
+ ],
29
+ default: 'getAll',
30
+ },
31
+ ];
32
+ exports.subscriptionInvoiceFields = [
33
+ // Get
34
+ {
35
+ displayName: 'Subscription Invoice ID',
36
+ name: 'subscriptionInvoiceId',
37
+ type: 'string',
38
+ required: true,
39
+ default: '',
40
+ displayOptions: {
41
+ show: {
42
+ resource: ['subscriptionInvoice'],
43
+ operation: ['get'],
44
+ },
45
+ },
46
+ description: 'The ID of the subscription invoice to retrieve',
47
+ },
48
+ // Get All
49
+ {
50
+ displayName: 'Return All',
51
+ name: 'returnAll',
52
+ type: 'boolean',
53
+ default: false,
54
+ displayOptions: {
55
+ show: {
56
+ resource: ['subscriptionInvoice'],
57
+ operation: ['getAll'],
58
+ },
59
+ },
60
+ description: 'Whether to return all results or only up to a given limit',
61
+ },
62
+ {
63
+ displayName: 'Limit',
64
+ name: 'limit',
65
+ type: 'number',
66
+ default: 50,
67
+ typeOptions: {
68
+ minValue: 1,
69
+ maxValue: 100,
70
+ },
71
+ displayOptions: {
72
+ show: {
73
+ resource: ['subscriptionInvoice'],
74
+ operation: ['getAll'],
75
+ returnAll: [false],
76
+ },
77
+ },
78
+ description: 'Max number of results to return',
79
+ },
80
+ {
81
+ displayName: 'Filters',
82
+ name: 'filters',
83
+ type: 'collection',
84
+ placeholder: 'Add Filter',
85
+ default: {},
86
+ displayOptions: {
87
+ show: {
88
+ resource: ['subscriptionInvoice'],
89
+ operation: ['getAll'],
90
+ },
91
+ },
92
+ options: [
93
+ {
94
+ displayName: 'Store ID',
95
+ name: 'storeId',
96
+ type: 'string',
97
+ default: '',
98
+ description: 'Filter by store ID',
99
+ },
100
+ {
101
+ displayName: 'Subscription ID',
102
+ name: 'subscriptionId',
103
+ type: 'string',
104
+ default: '',
105
+ description: 'Filter by subscription ID',
106
+ },
107
+ {
108
+ displayName: 'Status',
109
+ name: 'status',
110
+ type: 'options',
111
+ default: '',
112
+ options: [
113
+ { name: 'Pending', value: 'pending' },
114
+ { name: 'Paid', value: 'paid' },
115
+ { name: 'Void', value: 'void' },
116
+ { name: 'Refunded', value: 'refunded' },
117
+ ],
118
+ description: 'Filter by invoice status',
119
+ },
120
+ {
121
+ displayName: 'Refunded',
122
+ name: 'refunded',
123
+ type: 'boolean',
124
+ default: false,
125
+ description: 'Whether to filter by refunded invoices',
126
+ },
127
+ ],
128
+ },
129
+ ];
@@ -0,0 +1,3 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const usageRecordOperations: INodeProperties[];
3
+ export declare const usageRecordFields: INodeProperties[];
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usageRecordFields = exports.usageRecordOperations = void 0;
4
+ exports.usageRecordOperations = [
5
+ {
6
+ displayName: 'Operation',
7
+ name: 'operation',
8
+ type: 'options',
9
+ noDataExpression: true,
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['usageRecord'],
13
+ },
14
+ },
15
+ options: [
16
+ {
17
+ name: 'Get',
18
+ value: 'get',
19
+ description: 'Get a usage record by ID',
20
+ action: 'Get a usage record',
21
+ },
22
+ {
23
+ name: 'Get Many',
24
+ value: 'getAll',
25
+ description: 'Get many usage records',
26
+ action: 'Get many usage records',
27
+ },
28
+ ],
29
+ default: 'getAll',
30
+ },
31
+ ];
32
+ exports.usageRecordFields = [
33
+ // Get
34
+ {
35
+ displayName: 'Usage Record ID',
36
+ name: 'usageRecordId',
37
+ type: 'string',
38
+ required: true,
39
+ default: '',
40
+ displayOptions: {
41
+ show: {
42
+ resource: ['usageRecord'],
43
+ operation: ['get'],
44
+ },
45
+ },
46
+ description: 'The ID of the usage record to retrieve',
47
+ },
48
+ // Get All
49
+ {
50
+ displayName: 'Return All',
51
+ name: 'returnAll',
52
+ type: 'boolean',
53
+ default: false,
54
+ displayOptions: {
55
+ show: {
56
+ resource: ['usageRecord'],
57
+ operation: ['getAll'],
58
+ },
59
+ },
60
+ description: 'Whether to return all results or only up to a given limit',
61
+ },
62
+ {
63
+ displayName: 'Limit',
64
+ name: 'limit',
65
+ type: 'number',
66
+ default: 50,
67
+ typeOptions: {
68
+ minValue: 1,
69
+ maxValue: 100,
70
+ },
71
+ displayOptions: {
72
+ show: {
73
+ resource: ['usageRecord'],
74
+ operation: ['getAll'],
75
+ returnAll: [false],
76
+ },
77
+ },
78
+ description: 'Max number of results to return',
79
+ },
80
+ {
81
+ displayName: 'Filters',
82
+ name: 'filters',
83
+ type: 'collection',
84
+ placeholder: 'Add Filter',
85
+ default: {},
86
+ displayOptions: {
87
+ show: {
88
+ resource: ['usageRecord'],
89
+ operation: ['getAll'],
90
+ },
91
+ },
92
+ options: [
93
+ {
94
+ displayName: 'Subscription Item ID',
95
+ name: 'subscriptionItemId',
96
+ type: 'string',
97
+ default: '',
98
+ description: 'Filter by subscription item ID',
99
+ },
100
+ ],
101
+ },
102
+ ];
@@ -0,0 +1,3 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const userOperations: INodeProperties[];
3
+ export declare const userFields: INodeProperties[];
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.userFields = exports.userOperations = void 0;
4
+ exports.userOperations = [
5
+ {
6
+ displayName: 'Operation',
7
+ name: 'operation',
8
+ type: 'options',
9
+ noDataExpression: true,
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['user'],
13
+ },
14
+ },
15
+ options: [
16
+ {
17
+ name: 'Get Current',
18
+ value: 'getCurrent',
19
+ description: 'Get the currently authenticated user',
20
+ action: 'Get current user',
21
+ },
22
+ ],
23
+ default: 'getCurrent',
24
+ },
25
+ ];
26
+ exports.userFields = [];
@@ -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
- event_name: WebhookEventType;
352
- custom_data?: IDataObject;
353
- test_mode: boolean;
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
- data: IDataObject;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-lemonsqueezy",
3
- "version": "0.2.0",
3
+ "version": "0.5.0",
4
4
  "description": "n8n community node for Lemon Squeezy - digital products and subscriptions platform",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",