new folder structure

This commit is contained in:
MrMatiz2 2025-07-22 08:19:06 -05:00
commit 5831230d13
14 changed files with 262 additions and 96 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ dist
npm-debug.log*
yarn.lock
.vscode/launch.json
.env

View 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.")

View 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.")

View file

@ -0,0 +1 @@
[]

View file

@ -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 * as apiDefinitions from './api-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 {
method: string;
@ -42,10 +50,30 @@ export interface DtoDefinition {
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 {
static getApiDefinitions(): Record<string, Record<string, ApiDefinition>> {
return apiDefinitions as any;
}
// Return the static API definitions
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[] {
const definitions = this.getApiDefinitions();
@ -259,11 +287,6 @@ export class ApiHelper {
.trim();
}
static getApiDefinition(resource: string, operation: string): ApiDefinition | null {
const definitions = this.getApiDefinitions();
return definitions[resource]?.[operation] || null;
}
static getDtoDefinitions(): Record<string, DtoDefinition> {
return dtoDefinitions as any;
}

View file

@ -45,8 +45,8 @@ export class S4DSMain implements INodeType {
const resource = this.getNodeParameter('resource', i) as string;
const operation = this.getNodeParameter('operation', i) as string;
// Obtener definición de la API
const apiDefinition = ApiHelper.getApiDefinition(resource, operation);
// Get API definition (now async)
const apiDefinition = await ApiHelper.getApiDefinition(resource, operation);
if (!apiDefinition) {
throw new Error(`API definition not found for resource: ${resource}, operation: ${operation}`);
}

View 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"
}
}
}

View 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"
}
}
}

View 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"
}
}
}

View 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"
}
}
}

View 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"
}
}
}

View file

@ -1,98 +1,34 @@
{
"authentication": {
"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"
}
"services": [
{
"name": "generateToken",
"file": "actions/authentication/generateToken.json"
}
}
]
},
"products": {
"getProductCount": {
"method": "GET",
"endpoint": "/product/count",
"description": "Get the total count of products",
"parameters": [],
"requiresAuth": true,
"response": {
"type": "object",
"properties": {
"count": "number"
}
"services": [
{
"name": "getProductCount",
"file": "actions/products/getProductCount.json"
}
}
]
},
"customers": {
"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"
}
}
},
"createCustomer": {
"method": "POST",
"endpoint": "/customer",
"description": "Create a new customer",
"parameters": [],
"requiresAuth": true,
"requestBody": {
"schema": "SetNewCustomerDTO",
"required": true
"services": [
{
"name": "getCustomerByDocument",
"file": "actions/customers/getCustomerByDocument.json"
},
"response": {
"type": "object",
"properties": {
"customer": "object"
}
}
},
"updateCustomer": {
"method": "PATCH",
"endpoint": "/customer",
"description": "Update an existing customer",
"parameters": [],
"requiresAuth": true,
"requestBody": {
"schema": "SetNewCustomerDTO",
"required": true
{
"name": "createCustomer",
"file": "actions/customers/createCustomer.json"
},
"response": {
"type": "object",
"properties": {
"result": "object"
}
{
"name": "updateCustomer",
"file": "actions/customers/updateCustomer.json"
}
}
]
}
}

19
package-lock.json generated
View file

@ -9,10 +9,12 @@
"version": "0.1.0",
"license": "MIT",
"devDependencies": {
"@types/node": "^24.1.0",
"@typescript-eslint/parser": "~8.32.0",
"eslint": "^8.57.0",
"eslint-plugin-n8n-nodes-base": "^1.16.3",
"gulp": "^4.0.2",
"gulp-cli": "^2.3.0",
"prettier": "^3.5.3",
"typescript": "^5.8.2"
},
@ -288,6 +290,16 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"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": {
"version": "7.7.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz",
@ -6851,6 +6863,13 @@
"integrity": "sha512-Ia0sQNrMPXXkqVFt6w6M1n1oKo3NfKs+mvaV811Jwir7vAk9a6PVV9VPYf6X3BU97QiLEmuW3uXH9u87zDFfdw==",
"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": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz",

View file

@ -40,6 +40,7 @@
]
},
"devDependencies": {
"@types/node": "^24.1.0",
"@typescript-eslint/parser": "~8.32.0",
"eslint": "^8.57.0",
"eslint-plugin-n8n-nodes-base": "^1.16.3",