n8n-nodes-wix 1.0.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,127 @@
1
+ import { INodeType, INodeTypeDescription, IExecuteFunctions, INodeExecutionData, NodeOperationError } from 'n8n-workflow'
2
+ import { IDataObject } from 'n8n-workflow'
3
+ import axios, { AxiosRequestConfig } from 'axios'
4
+
5
+ export class WixSiteList implements INodeType {
6
+ description: INodeTypeDescription = {
7
+ displayName: 'Wix Site List',
8
+ name: 'wixSiteList',
9
+ icon: 'file:wix.png', // coloque um ícone do Wix se quiser
10
+ group: ['transform'],
11
+ version: 1,
12
+ description: 'Retrieve a list of Wix sites dynamically',
13
+ defaults: {
14
+ name: 'Wix Site List',
15
+ color: '#1A73E8', // azul Wix
16
+ },
17
+ inputs: ['main'],
18
+ outputs: ['main'],
19
+ properties: [
20
+ {
21
+ displayName: 'API Key',
22
+ name: 'apiKey',
23
+ type: 'string',
24
+ default: '',
25
+ required: true,
26
+ description: 'Your Wix account-level API key or OAuth token',
27
+ },
28
+ {
29
+ displayName: 'Filter',
30
+ name: 'filter',
31
+ type: 'json',
32
+ default: {},
33
+ description:
34
+ 'JSON object to filter the sites. Example: {"displayName":"my-site"}',
35
+ },
36
+ {
37
+ displayName: 'Limit',
38
+ name: 'limit',
39
+ type: 'number',
40
+ default: 100,
41
+ description: 'Maximum number of sites to return (max 1000)',
42
+ },
43
+ {
44
+ displayName: 'Cursor',
45
+ name: 'cursor',
46
+ type: 'string',
47
+ default: '',
48
+ description: 'Cursor for paging. Leave empty for the first request',
49
+ },
50
+ {
51
+ displayName: 'Sort',
52
+ name: 'sort',
53
+ type: 'json',
54
+ default: [],
55
+ description:
56
+ 'JSON array of objects for sorting. Example: [{"fieldName":"displayName","order":"ASC"}]',
57
+ },
58
+ {
59
+ displayName: 'Fields',
60
+ name: 'fields',
61
+ type: 'json',
62
+ default: {},
63
+ description:
64
+ 'Specify which fields to return for each site. Leave empty for all fields',
65
+ }
66
+ ]
67
+ }
68
+
69
+ // Função principal do node
70
+ async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
71
+ const items = this.getInputData() // dados recebidos de outros nodes
72
+ const returnData: INodeExecutionData[] = []
73
+
74
+ // Pegando valores dos parâmetros do node
75
+ const apiKey = this.getNodeParameter('apiKey', 0) as string
76
+ const filter = this.getNodeParameter('filter', 0) as IDataObject
77
+ const limit = this.getNodeParameter('limit', 0) as number
78
+ const cursor = this.getNodeParameter('cursor', 0) as string
79
+ const sort = this.getNodeParameter('sort', 0) as IDataObject[]
80
+ const fields = this.getNodeParameter('fields', 0) as IDataObject
81
+
82
+ // Montando o corpo da requisição
83
+ const body: IDataObject = {
84
+ query: {
85
+ filter,
86
+ cursorPaging: {
87
+ limit,
88
+ cursor: cursor || undefined,
89
+ },
90
+ sort,
91
+ fields,
92
+ }
93
+ }
94
+
95
+ // Configuração da requisição HTTP
96
+ const config: AxiosRequestConfig = {
97
+ method: 'POST',
98
+ url: 'https://www.wixapis.com/site-list/v2/sites/query',
99
+ headers: {
100
+ Authorization: `Bearer ${apiKey}`,
101
+ 'Content-Type': 'application/json',
102
+ },
103
+ data: body,
104
+ validateStatus: (status) => status >= 200 && status < 300,
105
+ }
106
+
107
+ // Executando a requisição
108
+ let responseData: IDataObject
109
+ try {
110
+ const response = await axios(config)
111
+ responseData = response.data as IDataObject
112
+ } catch (error) {
113
+ throw new NodeOperationError(this.getNode(), error as Error)
114
+ }
115
+
116
+ // Retornando os sites como output
117
+ if (responseData.sites && Array.isArray(responseData.sites)) {
118
+ for (const site of responseData.sites) {
119
+ returnData.push({
120
+ json: site as IDataObject
121
+ })
122
+ }
123
+ }
124
+
125
+ return [returnData]
126
+ }
127
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "n8n-nodes-wix",
3
+ "version": "1.0.0",
4
+ "description": "Wix sites node for n8n",
5
+ "keywords": ["wix","api"],
6
+ "license": "MIT",
7
+ "author": "Snoorky",
8
+ "type": "commonjs",
9
+ "main": "nodes/sites.js",
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "dependencies": {
14
+ "axios": "^1.6.0",
15
+ "n8n-core": "^2.5.0",
16
+ "n8n-workflow": "^2.5.0"
17
+ },
18
+ "devDependencies": {
19
+ "typescript": "^5.2.2"
20
+ }
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true,
8
+ "esModuleInterop": true
9
+ },
10
+ "include": ["nodes/**/*.ts"]
11
+ }