mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-10-29 14:22:26 -05:00
new folder structure
This commit is contained in:
parent
1b79d21dbd
commit
5831230d13
14 changed files with 262 additions and 96 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,3 +6,4 @@ dist
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn.lock
|
yarn.lock
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
.env
|
||||||
51
local-files/automations/generate_zip.py
Normal file
51
local-files/automations/generate_zip.py
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
from pathlib import Path
|
||||||
|
from zipfile import ZipFile
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
|
||||||
|
# ====== CONFIGURACIÓN ======
|
||||||
|
carpeta_origen = Path(r"D:\Users\aleja\Code\n8n-nodes-starter-s4ds\local-files\images")
|
||||||
|
archivo_zip = carpeta_origen.parent / f"queue_{datetime.date.today()}.zip"
|
||||||
|
|
||||||
|
# Extensiones de imagen a eliminar después del zip
|
||||||
|
extensiones_imagen = {".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp", ".tiff"}
|
||||||
|
|
||||||
|
# ====== OBTENER ARCHIVOS ======
|
||||||
|
archivos_a_comprimir = list(carpeta_origen.glob("*")) # Solo archivos del nivel actual
|
||||||
|
|
||||||
|
archivo_queue_json = carpeta_origen / "queue.json"
|
||||||
|
|
||||||
|
# ====== CREAR ZIP ======
|
||||||
|
if archivos_a_comprimir:
|
||||||
|
with ZipFile(archivo_zip, 'w') as zipf:
|
||||||
|
for archivo in archivos_a_comprimir:
|
||||||
|
if archivo.is_file():
|
||||||
|
zipf.write(archivo, arcname=archivo.name)
|
||||||
|
print(f"📦 Añadido al zip: {archivo.name}")
|
||||||
|
print(f"\n✅ ZIP creado en: {archivo_zip}")
|
||||||
|
else:
|
||||||
|
print("⚠️ No hay archivos para comprimir.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# ====== ELIMINAR IMÁGENES ======
|
||||||
|
eliminados = 0
|
||||||
|
for archivo in archivos_a_comprimir:
|
||||||
|
if archivo.suffix.lower() in extensiones_imagen:
|
||||||
|
try:
|
||||||
|
archivo.unlink()
|
||||||
|
print(f"🗑️ Imagen eliminada: {archivo.name}")
|
||||||
|
eliminados += 1
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Error al eliminar {archivo.name}: {e}")
|
||||||
|
|
||||||
|
print(f"\n🧹 Eliminación finalizada. Total imágenes eliminadas: {eliminados}")
|
||||||
|
|
||||||
|
# ====== LIMPIAR queue.json ======
|
||||||
|
if archivo_queue_json.exists():
|
||||||
|
try:
|
||||||
|
archivo_queue_json.write_text("[]", encoding="utf-8")
|
||||||
|
print(f"\n✅ queue.json limpiado correctamente.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Error al limpiar queue.json: {e}")
|
||||||
|
else:
|
||||||
|
print("⚠️ queue.json no se encontró en la carpeta.")
|
||||||
39
local-files/automations/videos_search.py
Normal file
39
local-files/automations/videos_search.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
from pathlib import Path
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
# ====== CONFIGURACIÓN ======
|
||||||
|
carpeta_base = Path(r"D:\Users\aleja\AppData\Local\Temp\gradio")
|
||||||
|
carpeta_destino = Path(r"D:\Users\aleja\Code\n8n-nodes-starter-s4ds\local-files\videos")
|
||||||
|
buscar_recursivamente = True
|
||||||
|
|
||||||
|
# ====== CALCULAR HORA LÍMITE ======
|
||||||
|
ahora = datetime.now()
|
||||||
|
una_hora_atras = ahora - timedelta(hours=1)
|
||||||
|
|
||||||
|
# ====== BÚSQUEDA ======
|
||||||
|
archivos = carpeta_base.rglob("*.mp4") if buscar_recursivamente else carpeta_base.glob("*.mp4")
|
||||||
|
encontrados = []
|
||||||
|
|
||||||
|
for archivo in archivos:
|
||||||
|
try:
|
||||||
|
modificado = datetime.fromtimestamp(archivo.stat().st_mtime)
|
||||||
|
if modificado >= una_hora_atras:
|
||||||
|
encontrados.append(archivo)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ Error al leer {archivo.name}: {e}")
|
||||||
|
|
||||||
|
# ====== COPIAR ARCHIVOS ======
|
||||||
|
if encontrados:
|
||||||
|
carpeta_destino.mkdir(parents=True, exist_ok=True)
|
||||||
|
print(f"\n🎯 Archivos .mp4 modificados en la última hora:\n")
|
||||||
|
|
||||||
|
for archivo in encontrados:
|
||||||
|
destino = carpeta_destino / archivo.name
|
||||||
|
try:
|
||||||
|
shutil.copy2(archivo, destino)
|
||||||
|
print(f"✅ Copiado: {archivo.name}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Error al copiar {archivo.name}: {e}")
|
||||||
|
else:
|
||||||
|
print("\n⚠️ No se encontraron archivos .mp4 recientes.")
|
||||||
1
local-files/images/queue.json
Normal file
1
local-files/images/queue.json
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
||||||
|
|
@ -1,6 +1,14 @@
|
||||||
|
// If you see type errors for 'fs' or 'path', install @types/node as a dev dependency.
|
||||||
|
// npm install --save-dev @types/node
|
||||||
import { INodeProperties, NodePropertyTypes } from 'n8n-workflow';
|
import { INodeProperties, NodePropertyTypes } from 'n8n-workflow';
|
||||||
import * as apiDefinitions from './api-definitions.json';
|
|
||||||
import * as dtoDefinitions from './dto-definitions.json';
|
import * as dtoDefinitions from './dto-definitions.json';
|
||||||
|
// Remove fs and path imports
|
||||||
|
// Import all service JSON files directly
|
||||||
|
import generateToken from './actions/authentication/generateToken.json';
|
||||||
|
import getProductCount from './actions/products/getProductCount.json';
|
||||||
|
import getCustomerByDocument from './actions/customers/getCustomerByDocument.json';
|
||||||
|
import createCustomer from './actions/customers/createCustomer.json';
|
||||||
|
import updateCustomer from './actions/customers/updateCustomer.json';
|
||||||
|
|
||||||
export interface ApiDefinition {
|
export interface ApiDefinition {
|
||||||
method: string;
|
method: string;
|
||||||
|
|
@ -42,10 +50,30 @@ export interface DtoDefinition {
|
||||||
properties: Record<string, DtoProperty>;
|
properties: Record<string, DtoProperty>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build static API definitions object
|
||||||
|
const staticApiDefinitions: Record<string, Record<string, ApiDefinition>> = {
|
||||||
|
authentication: {
|
||||||
|
generateToken: generateToken as ApiDefinition,
|
||||||
|
},
|
||||||
|
products: {
|
||||||
|
getProductCount: getProductCount as ApiDefinition,
|
||||||
|
},
|
||||||
|
customers: {
|
||||||
|
getCustomerByDocument: getCustomerByDocument as ApiDefinition,
|
||||||
|
createCustomer: createCustomer as ApiDefinition,
|
||||||
|
updateCustomer: updateCustomer as ApiDefinition,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export class ApiHelper {
|
export class ApiHelper {
|
||||||
static getApiDefinitions(): Record<string, Record<string, ApiDefinition>> {
|
// Return the static API definitions
|
||||||
return apiDefinitions as any;
|
static getApiDefinitions(): Record<string, Record<string, ApiDefinition>> {
|
||||||
}
|
return staticApiDefinitions;
|
||||||
|
}
|
||||||
|
// Return a single API definition
|
||||||
|
static getApiDefinition(group: string, service: string): ApiDefinition | null {
|
||||||
|
return staticApiDefinitions[group]?.[service] || null;
|
||||||
|
}
|
||||||
|
|
||||||
static getResources(): INodeProperties[] {
|
static getResources(): INodeProperties[] {
|
||||||
const definitions = this.getApiDefinitions();
|
const definitions = this.getApiDefinitions();
|
||||||
|
|
@ -259,11 +287,6 @@ export class ApiHelper {
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getApiDefinition(resource: string, operation: string): ApiDefinition | null {
|
|
||||||
const definitions = this.getApiDefinitions();
|
|
||||||
return definitions[resource]?.[operation] || null;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getDtoDefinitions(): Record<string, DtoDefinition> {
|
static getDtoDefinitions(): Record<string, DtoDefinition> {
|
||||||
return dtoDefinitions as any;
|
return dtoDefinitions as any;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ export class S4DSMain implements INodeType {
|
||||||
const resource = this.getNodeParameter('resource', i) as string;
|
const resource = this.getNodeParameter('resource', i) as string;
|
||||||
const operation = this.getNodeParameter('operation', i) as string;
|
const operation = this.getNodeParameter('operation', i) as string;
|
||||||
|
|
||||||
// Obtener definición de la API
|
// Get API definition (now async)
|
||||||
const apiDefinition = ApiHelper.getApiDefinition(resource, operation);
|
const apiDefinition = await ApiHelper.getApiDefinition(resource, operation);
|
||||||
if (!apiDefinition) {
|
if (!apiDefinition) {
|
||||||
throw new Error(`API definition not found for resource: ${resource}, operation: ${operation}`);
|
throw new Error(`API definition not found for resource: ${resource}, operation: ${operation}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
nodes/S4DSMain/actions/authentication/generateToken.json
Normal file
16
nodes/S4DSMain/actions/authentication/generateToken.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "generateToken",
|
||||||
|
"method": "POST",
|
||||||
|
"endpoint": "/login/generateToken",
|
||||||
|
"description": "Generate authentication token using credentials.",
|
||||||
|
"parameters": [],
|
||||||
|
"requiresAuth": false,
|
||||||
|
"response": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"token": "string",
|
||||||
|
"token_type": "string",
|
||||||
|
"expires_in": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
nodes/S4DSMain/actions/customers/createCustomer.json
Normal file
18
nodes/S4DSMain/actions/customers/createCustomer.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "createCustomer",
|
||||||
|
"method": "POST",
|
||||||
|
"endpoint": "/customer",
|
||||||
|
"description": "Create a new customer.",
|
||||||
|
"parameters": [],
|
||||||
|
"requiresAuth": true,
|
||||||
|
"requestBody": {
|
||||||
|
"schema": "SetNewCustomerDTO",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"customer": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
nodes/S4DSMain/actions/customers/getCustomerByDocument.json
Normal file
29
nodes/S4DSMain/actions/customers/getCustomerByDocument.json
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "getCustomerByDocument",
|
||||||
|
"method": "GET",
|
||||||
|
"endpoint": "/customer/specificCustomer",
|
||||||
|
"description": "Get customer information by document ID and type.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "documentId",
|
||||||
|
"type": "string",
|
||||||
|
"required": false,
|
||||||
|
"description": "Document ID of the customer.",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "documentType",
|
||||||
|
"type": "string",
|
||||||
|
"required": false,
|
||||||
|
"description": "Type of document (e.g., CC, CE, NIT).",
|
||||||
|
"in": "query"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requiresAuth": true,
|
||||||
|
"response": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"customer": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
nodes/S4DSMain/actions/customers/updateCustomer.json
Normal file
18
nodes/S4DSMain/actions/customers/updateCustomer.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "updateCustomer",
|
||||||
|
"method": "PATCH",
|
||||||
|
"endpoint": "/customer",
|
||||||
|
"description": "Update an existing customer.",
|
||||||
|
"parameters": [],
|
||||||
|
"requiresAuth": true,
|
||||||
|
"requestBody": {
|
||||||
|
"schema": "SetNewCustomerDTO",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
"response": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"result": "object"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
nodes/S4DSMain/actions/products/getProductCount.json
Normal file
14
nodes/S4DSMain/actions/products/getProductCount.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "getProductCount",
|
||||||
|
"method": "GET",
|
||||||
|
"endpoint": "/product/count",
|
||||||
|
"description": "Get the total count of products.",
|
||||||
|
"parameters": [],
|
||||||
|
"requiresAuth": true,
|
||||||
|
"response": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"count": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,98 +1,34 @@
|
||||||
{
|
{
|
||||||
"authentication": {
|
"authentication": {
|
||||||
"generateToken": {
|
"services": [
|
||||||
"method": "POST",
|
{
|
||||||
"endpoint": "/login/generateToken",
|
"name": "generateToken",
|
||||||
"description": "Generate authentication token using credentials",
|
"file": "actions/authentication/generateToken.json"
|
||||||
"parameters": [],
|
|
||||||
"requiresAuth": false,
|
|
||||||
"response": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"token": "string",
|
|
||||||
"token_type": "string",
|
|
||||||
"expires_in": "number"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"products": {
|
"products": {
|
||||||
"getProductCount": {
|
"services": [
|
||||||
"method": "GET",
|
{
|
||||||
"endpoint": "/product/count",
|
"name": "getProductCount",
|
||||||
"description": "Get the total count of products",
|
"file": "actions/products/getProductCount.json"
|
||||||
"parameters": [],
|
|
||||||
"requiresAuth": true,
|
|
||||||
"response": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"count": "number"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
"customers": {
|
"customers": {
|
||||||
"getCustomerByDocument": {
|
"services": [
|
||||||
"method": "GET",
|
{
|
||||||
"endpoint": "/customer/specificCustomer",
|
"name": "getCustomerByDocument",
|
||||||
"description": "Get customer information by document ID and type",
|
"file": "actions/customers/getCustomerByDocument.json"
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "documentId",
|
|
||||||
"type": "string",
|
|
||||||
"required": false,
|
|
||||||
"description": "Document ID of the customer",
|
|
||||||
"in": "query"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "documentType",
|
|
||||||
"type": "string",
|
|
||||||
"required": false,
|
|
||||||
"description": "Type of document (e.g., CC, CE, NIT)",
|
|
||||||
"in": "query"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"requiresAuth": true,
|
|
||||||
"response": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"customer": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"createCustomer": {
|
|
||||||
"method": "POST",
|
|
||||||
"endpoint": "/customer",
|
|
||||||
"description": "Create a new customer",
|
|
||||||
"parameters": [],
|
|
||||||
"requiresAuth": true,
|
|
||||||
"requestBody": {
|
|
||||||
"schema": "SetNewCustomerDTO",
|
|
||||||
"required": true
|
|
||||||
},
|
},
|
||||||
"response": {
|
{
|
||||||
"type": "object",
|
"name": "createCustomer",
|
||||||
"properties": {
|
"file": "actions/customers/createCustomer.json"
|
||||||
"customer": "object"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"updateCustomer": {
|
|
||||||
"method": "PATCH",
|
|
||||||
"endpoint": "/customer",
|
|
||||||
"description": "Update an existing customer",
|
|
||||||
"parameters": [],
|
|
||||||
"requiresAuth": true,
|
|
||||||
"requestBody": {
|
|
||||||
"schema": "SetNewCustomerDTO",
|
|
||||||
"required": true
|
|
||||||
},
|
},
|
||||||
"response": {
|
{
|
||||||
"type": "object",
|
"name": "updateCustomer",
|
||||||
"properties": {
|
"file": "actions/customers/updateCustomer.json"
|
||||||
"result": "object"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
19
package-lock.json
generated
19
package-lock.json
generated
|
|
@ -9,10 +9,12 @@
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.1.0",
|
||||||
"@typescript-eslint/parser": "~8.32.0",
|
"@typescript-eslint/parser": "~8.32.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-cli": "^2.3.0",
|
||||||
"prettier": "^3.5.3",
|
"prettier": "^3.5.3",
|
||||||
"typescript": "^5.8.2"
|
"typescript": "^5.8.2"
|
||||||
},
|
},
|
||||||
|
|
@ -288,6 +290,16 @@
|
||||||
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "24.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
|
||||||
|
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~7.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/semver": {
|
"node_modules/@types/semver": {
|
||||||
"version": "7.7.0",
|
"version": "7.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz",
|
||||||
|
|
@ -6851,6 +6863,13 @@
|
||||||
"integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==",
|
"integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "7.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||||
|
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/union-value": {
|
"node_modules/union-value": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.1.0",
|
||||||
"@typescript-eslint/parser": "~8.32.0",
|
"@typescript-eslint/parser": "~8.32.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
"eslint-plugin-n8n-nodes-base": "^1.16.3",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue