@joshuanode/n8n-nodes-scalepad 0.0.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.
Files changed (30) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +218 -0
  3. package/dist/credentials/ScalePadCoreApi.credentials.d.ts +9 -0
  4. package/dist/credentials/ScalePadCoreApi.credentials.js +60 -0
  5. package/dist/nodes/ScalePadCore/ScalePadCore.node.d.ts +6 -0
  6. package/dist/nodes/ScalePadCore/ScalePadCore.node.js +344 -0
  7. package/dist/nodes/ScalePadCore/descriptions/ClientDescription.d.ts +3 -0
  8. package/dist/nodes/ScalePadCore/descriptions/ClientDescription.js +227 -0
  9. package/dist/nodes/ScalePadCore/descriptions/ContactDescription.d.ts +3 -0
  10. package/dist/nodes/ScalePadCore/descriptions/ContactDescription.js +107 -0
  11. package/dist/nodes/ScalePadCore/descriptions/ContractDescription.d.ts +3 -0
  12. package/dist/nodes/ScalePadCore/descriptions/ContractDescription.js +121 -0
  13. package/dist/nodes/ScalePadCore/descriptions/HardwareAssetDescription.d.ts +3 -0
  14. package/dist/nodes/ScalePadCore/descriptions/HardwareAssetDescription.js +125 -0
  15. package/dist/nodes/ScalePadCore/descriptions/HardwareLifecycleDescription.d.ts +3 -0
  16. package/dist/nodes/ScalePadCore/descriptions/HardwareLifecycleDescription.js +142 -0
  17. package/dist/nodes/ScalePadCore/descriptions/MemberDescription.d.ts +3 -0
  18. package/dist/nodes/ScalePadCore/descriptions/MemberDescription.js +131 -0
  19. package/dist/nodes/ScalePadCore/descriptions/OpportunityDescription.d.ts +3 -0
  20. package/dist/nodes/ScalePadCore/descriptions/OpportunityDescription.js +129 -0
  21. package/dist/nodes/ScalePadCore/descriptions/SaasDescription.d.ts +3 -0
  22. package/dist/nodes/ScalePadCore/descriptions/SaasDescription.js +121 -0
  23. package/dist/nodes/ScalePadCore/descriptions/TicketDescription.d.ts +3 -0
  24. package/dist/nodes/ScalePadCore/descriptions/TicketDescription.js +146 -0
  25. package/dist/nodes/ScalePadCore/scalepad.svg +4 -0
  26. package/dist/nodes/shared/GenericFunctions.d.ts +17 -0
  27. package/dist/nodes/shared/GenericFunctions.js +101 -0
  28. package/dist/nodes/shared/types.d.ts +31 -0
  29. package/dist/nodes/shared/types.js +2 -0
  30. package/package.json +59 -0
@@ -0,0 +1,17 @@
1
+ import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, IDataObject, IHttpRequestMethods } from 'n8n-workflow';
2
+ /**
3
+ * Make an authenticated API request to ScalePad Core API
4
+ */
5
+ export declare function scalePadCoreApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject): Promise<any>;
6
+ /**
7
+ * Make an authenticated API request to ScalePad Core API with automatic pagination
8
+ */
9
+ export declare function scalePadCoreApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, endpoint: string, body?: IDataObject, qs?: IDataObject): Promise<any[]>;
10
+ /**
11
+ * Build filter query string for ScalePad Core API
12
+ */
13
+ export declare function buildCoreApiFilters(filters: IDataObject): IDataObject;
14
+ /**
15
+ * Build sort parameter for ScalePad Core API
16
+ */
17
+ export declare function buildCoreApiSort(field: string, direction: 'ASC' | 'DESC'): string;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scalePadCoreApiRequest = scalePadCoreApiRequest;
4
+ exports.scalePadCoreApiRequestAllItems = scalePadCoreApiRequestAllItems;
5
+ exports.buildCoreApiFilters = buildCoreApiFilters;
6
+ exports.buildCoreApiSort = buildCoreApiSort;
7
+ const n8n_workflow_1 = require("n8n-workflow");
8
+ /**
9
+ * Make an authenticated API request to ScalePad Core API
10
+ */
11
+ async function scalePadCoreApiRequest(method, endpoint, body = {}, qs = {}) {
12
+ const credentials = await this.getCredentials('scalePadCoreApi');
13
+ const environment = credentials.environment;
14
+ const baseUrl = environment === 'production'
15
+ ? 'https://api.scalepad.com'
16
+ : 'https://api-sandbox.scalepad.com';
17
+ const options = {
18
+ method,
19
+ body,
20
+ qs,
21
+ uri: `${baseUrl}${endpoint}`,
22
+ json: true,
23
+ };
24
+ try {
25
+ return await this.helpers.requestWithAuthentication.call(this, 'scalePadCoreApi', options);
26
+ }
27
+ catch (error) {
28
+ // Handle rate limiting with exponential backoff
29
+ if (error.statusCode === 429) {
30
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
31
+ message: 'Rate limit exceeded. ScalePad Core API allows 50 requests per 5 seconds.',
32
+ description: 'Please reduce request frequency or implement delays between operations.',
33
+ });
34
+ }
35
+ // Handle authentication errors
36
+ if (error.statusCode === 401) {
37
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
38
+ message: 'Authentication failed. Please check your API key.',
39
+ description: 'Ensure your API key is valid and has not expired.',
40
+ });
41
+ }
42
+ // Handle not found errors
43
+ if (error.statusCode === 404) {
44
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
45
+ message: 'Resource not found.',
46
+ description: 'The requested resource does not exist or you do not have access to it.',
47
+ });
48
+ }
49
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error);
50
+ }
51
+ }
52
+ /**
53
+ * Make an authenticated API request to ScalePad Core API with automatic pagination
54
+ */
55
+ async function scalePadCoreApiRequestAllItems(method, endpoint, body = {}, qs = {}) {
56
+ var _a, _b;
57
+ const returnData = [];
58
+ let cursor;
59
+ let hasMore = true;
60
+ // Set default limit if not specified
61
+ if (!qs.limit) {
62
+ qs.limit = 200; // Maximum allowed by API
63
+ }
64
+ while (hasMore) {
65
+ if (cursor) {
66
+ qs.cursor = cursor;
67
+ }
68
+ const response = await scalePadCoreApiRequest.call(this, method, endpoint, body, qs);
69
+ if (response.data && Array.isArray(response.data)) {
70
+ returnData.push(...response.data);
71
+ }
72
+ // Check for cursor-based pagination
73
+ cursor = (_b = (_a = response.meta) === null || _a === void 0 ? void 0 : _a.pagination) === null || _b === void 0 ? void 0 : _b.cursor;
74
+ hasMore = !!cursor;
75
+ // Safety check to prevent infinite loops
76
+ if (returnData.length > 10000) {
77
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Too many results returned. Please use filters to limit the results.');
78
+ }
79
+ }
80
+ return returnData;
81
+ }
82
+ /**
83
+ * Build filter query string for ScalePad Core API
84
+ */
85
+ function buildCoreApiFilters(filters) {
86
+ const qs = {};
87
+ for (const [field, value] of Object.entries(filters)) {
88
+ if (value !== undefined && value !== null && value !== '') {
89
+ // Format: filter[field]=operator:value
90
+ qs[`filter[${field}]`] = value;
91
+ }
92
+ }
93
+ return qs;
94
+ }
95
+ /**
96
+ * Build sort parameter for ScalePad Core API
97
+ */
98
+ function buildCoreApiSort(field, direction) {
99
+ // Format: +field for ascending, -field for descending
100
+ return direction === 'ASC' ? `+${field}` : `-${field}`;
101
+ }
@@ -0,0 +1,31 @@
1
+ import { IDataObject } from 'n8n-workflow';
2
+ export interface IScalePadError {
3
+ key?: string;
4
+ title?: string;
5
+ detail?: string;
6
+ status?: number;
7
+ message?: string;
8
+ }
9
+ export interface IScalePadCoreResponse {
10
+ data: IDataObject[];
11
+ meta?: {
12
+ pagination?: {
13
+ cursor?: string;
14
+ total?: number;
15
+ count?: number;
16
+ };
17
+ };
18
+ }
19
+ export type SortOrder = 'ASC' | 'DESC';
20
+ export interface IPaginationOptions {
21
+ limit?: number;
22
+ offset?: number;
23
+ cursor?: string;
24
+ }
25
+ export interface IFilterOptions {
26
+ [key: string]: string;
27
+ }
28
+ export interface ISortOptions {
29
+ field: string;
30
+ direction: SortOrder;
31
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@joshuanode/n8n-nodes-scalepad",
3
+ "version": "0.0.1",
4
+ "description": "n8n community node for ScalePad Core API and Lifecycle Manager",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "n8n",
8
+ "scalepad",
9
+ "lifecycle-manager",
10
+ "msp",
11
+ "psa"
12
+ ],
13
+ "license": "MIT",
14
+ "homepage": "https://github.com/ajoshuasmith/n8n-nodes-scalepad",
15
+ "author": {
16
+ "name": "Joshua Smith"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/ajoshuasmith/n8n-nodes-scalepad.git"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "main": "index.js",
26
+ "scripts": {
27
+ "build": "tsc && gulp build:icons",
28
+ "dev": "tsc --watch",
29
+ "format": "prettier nodes credentials --write",
30
+ "lint": "eslint nodes credentials",
31
+ "lintfix": "eslint nodes credentials --fix",
32
+ "prepublishOnly": "npm run build && npm run lint"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "n8n": {
38
+ "n8nNodesApiVersion": 1,
39
+ "credentials": [
40
+ "dist/credentials/ScalePadCoreApi.credentials.js"
41
+ ],
42
+ "nodes": [
43
+ "dist/nodes/ScalePadCore/ScalePadCore.node.js"
44
+ ]
45
+ },
46
+ "devDependencies": {
47
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
48
+ "@typescript-eslint/parser": "^5.45.0",
49
+ "eslint": "^8.29.0",
50
+ "eslint-plugin-n8n-nodes-base": "^1.11.0",
51
+ "gulp": "^4.0.2",
52
+ "n8n-workflow": "^1.0.0",
53
+ "prettier": "^2.7.1",
54
+ "typescript": "~5.5"
55
+ },
56
+ "peerDependencies": {
57
+ "n8n-workflow": "*"
58
+ }
59
+ }