From 98210ef15c908b33c901066d8459ef0394243cb4 Mon Sep 17 00:00:00 2001 From: sshelgwezz Date: Wed, 29 Oct 2025 15:01:32 +0800 Subject: [PATCH] v0.1 --- .../GwezzChangdunovel.node.ts | 26 +++----- nodes/GwezzChangdunovel/gwezz.dark.svg | 1 + nodes/GwezzChangdunovel/gwezz.svg | 1 + .../gwezzChangdunovel.dark.svg | 13 ---- nodes/GwezzChangdunovel/gwezzChangdunovel.svg | 13 ---- .../resources/company/getAll.ts | 61 ------------------- .../resources/company/index.ts | 34 ----------- .../distribution/contentBooMetaV1.ts | 26 ++++++++ .../resources/distribution/index.ts | 33 ++++++++++ .../resources/user/create.ts | 26 -------- nodes/GwezzChangdunovel/resources/user/get.ts | 17 ------ .../GwezzChangdunovel/resources/user/index.ts | 60 ------------------ 12 files changed, 71 insertions(+), 240 deletions(-) create mode 100644 nodes/GwezzChangdunovel/gwezz.dark.svg create mode 100644 nodes/GwezzChangdunovel/gwezz.svg delete mode 100644 nodes/GwezzChangdunovel/gwezzChangdunovel.dark.svg delete mode 100644 nodes/GwezzChangdunovel/gwezzChangdunovel.svg delete mode 100644 nodes/GwezzChangdunovel/resources/company/getAll.ts delete mode 100644 nodes/GwezzChangdunovel/resources/company/index.ts create mode 100644 nodes/GwezzChangdunovel/resources/distribution/contentBooMetaV1.ts create mode 100644 nodes/GwezzChangdunovel/resources/distribution/index.ts delete mode 100644 nodes/GwezzChangdunovel/resources/user/create.ts delete mode 100644 nodes/GwezzChangdunovel/resources/user/get.ts delete mode 100644 nodes/GwezzChangdunovel/resources/user/index.ts diff --git a/nodes/GwezzChangdunovel/GwezzChangdunovel.node.ts b/nodes/GwezzChangdunovel/GwezzChangdunovel.node.ts index 1776d94..f26123c 100644 --- a/nodes/GwezzChangdunovel/GwezzChangdunovel.node.ts +++ b/nodes/GwezzChangdunovel/GwezzChangdunovel.node.ts @@ -1,18 +1,17 @@ import { type INodeType, type INodeTypeDescription } from 'n8n-workflow'; -import { userDescription } from './resources/user'; -import { companyDescription } from './resources/company'; +import { distributionDescription } from './resources/distribution'; export class GwezzChangdunovel implements INodeType { description: INodeTypeDescription = { - displayName: 'Gwezz Changdunovel', + displayName: 'Gwezz 常读分销', name: 'gwezzChangdunovel', - icon: { light: 'file:gwezzChangdunovel.svg', dark: 'file:gwezzChangdunovel.dark.svg' }, + icon: { light: 'file:gwezz.svg', dark: 'file:gwezz.dark.svg' }, group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Interact with the Gwezz Changdunovel API', + description: 'Interact with the Changdunovel API', defaults: { - name: 'Gwezz Changdunovel', + name: 'Gwezz 常读分销', }, usableAsTool: true, inputs: ['main'], @@ -27,24 +26,19 @@ export class GwezzChangdunovel implements INodeType { }, properties: [ { - displayName: 'Resource', + displayName: '资源', name: 'resource', type: 'options', noDataExpression: true, options: [ { - name: 'User', - value: 'user', - }, - { - name: 'Company', - value: 'company', + name: '分销', + value: 'distribution', }, ], - default: 'user', + default: 'distribution', }, - ...userDescription, - ...companyDescription, + ...distributionDescription, ], }; } diff --git a/nodes/GwezzChangdunovel/gwezz.dark.svg b/nodes/GwezzChangdunovel/gwezz.dark.svg new file mode 100644 index 0000000..66ccfa5 --- /dev/null +++ b/nodes/GwezzChangdunovel/gwezz.dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nodes/GwezzChangdunovel/gwezz.svg b/nodes/GwezzChangdunovel/gwezz.svg new file mode 100644 index 0000000..66ccfa5 --- /dev/null +++ b/nodes/GwezzChangdunovel/gwezz.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/nodes/GwezzChangdunovel/gwezzChangdunovel.dark.svg b/nodes/GwezzChangdunovel/gwezzChangdunovel.dark.svg deleted file mode 100644 index c07cb10..0000000 --- a/nodes/GwezzChangdunovel/gwezzChangdunovel.dark.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/nodes/GwezzChangdunovel/gwezzChangdunovel.svg b/nodes/GwezzChangdunovel/gwezzChangdunovel.svg deleted file mode 100644 index 703e1fe..0000000 --- a/nodes/GwezzChangdunovel/gwezzChangdunovel.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - diff --git a/nodes/GwezzChangdunovel/resources/company/getAll.ts b/nodes/GwezzChangdunovel/resources/company/getAll.ts deleted file mode 100644 index d67638a..0000000 --- a/nodes/GwezzChangdunovel/resources/company/getAll.ts +++ /dev/null @@ -1,61 +0,0 @@ -import type { INodeProperties } from 'n8n-workflow'; - -const showOnlyForCompanyGetMany = { - operation: ['getAll'], - resource: ['company'], -}; - -export const companyGetManyDescription: INodeProperties[] = [ - { - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - ...showOnlyForCompanyGetMany, - returnAll: [false], - }, - }, - typeOptions: { - minValue: 1, - maxValue: 100, - }, - default: 50, - routing: { - send: { - type: 'query', - property: 'limit', - }, - output: { - maxResults: '={{$value}}', - }, - }, - description: 'Max number of results to return', - }, - { - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: showOnlyForCompanyGetMany, - }, - default: false, - description: 'Whether to return all results or only up to a given limit', - routing: { - send: { - paginate: '={{ $value }}', - }, - operations: { - pagination: { - type: 'offset', - properties: { - limitParameter: 'limit', - offsetParameter: 'offset', - pageSize: 100, - type: 'query', - }, - }, - }, - }, - }, -]; diff --git a/nodes/GwezzChangdunovel/resources/company/index.ts b/nodes/GwezzChangdunovel/resources/company/index.ts deleted file mode 100644 index 53267ed..0000000 --- a/nodes/GwezzChangdunovel/resources/company/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { INodeProperties } from 'n8n-workflow'; -import { companyGetManyDescription } from './getAll'; - -const showOnlyForCompanies = { - resource: ['company'], -}; - -export const companyDescription: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: showOnlyForCompanies, - }, - options: [ - { - name: 'Get Many', - value: 'getAll', - action: 'Get companies', - description: 'Get companies', - routing: { - request: { - method: 'GET', - url: '/companies', - }, - }, - }, - ], - default: 'getAll', - }, - ...companyGetManyDescription, -]; diff --git a/nodes/GwezzChangdunovel/resources/distribution/contentBooMetaV1.ts b/nodes/GwezzChangdunovel/resources/distribution/contentBooMetaV1.ts new file mode 100644 index 0000000..cfe7485 --- /dev/null +++ b/nodes/GwezzChangdunovel/resources/distribution/contentBooMetaV1.ts @@ -0,0 +1,26 @@ +import type { INodeProperties } from 'n8n-workflow'; + +const showOnlyForDistributionContentBookMetaV1 = { + operation: ['contentBookMetaV1'], + resource: ['distribution'], +}; + +export const contentBookMetaV1Description: INodeProperties[] = [ + { + displayName: '书籍 ID', + name: 'bookId', + type: 'string', + required: true, + default: '', + displayOptions: { + show: showOnlyForDistributionContentBookMetaV1, + }, + routing: { + send: { + type: 'query', + property: 'book_id', + }, + }, + description: '要查询信息的书籍 ID', + }, +]; diff --git a/nodes/GwezzChangdunovel/resources/distribution/index.ts b/nodes/GwezzChangdunovel/resources/distribution/index.ts new file mode 100644 index 0000000..24007fb --- /dev/null +++ b/nodes/GwezzChangdunovel/resources/distribution/index.ts @@ -0,0 +1,33 @@ +import type { INodeProperties } from 'n8n-workflow'; +import { contentBookMetaV1Description } from './contentBooMetaV1'; + +const showOnlyForDistributions = { + resource: ['distribution'], +}; + +export const distributionDescription: INodeProperties[] = [ + { + displayName: '操作', + name: 'operation', + type: 'options', + noDataExpression: true, + displayOptions: { + show: showOnlyForDistributions, + }, + options: [ + { + name: '获取书籍信息', + value: 'contentBookMetaV1', + action: 'Get content book metadata', + routing: { + request: { + method: 'GET', + url: '/content/book_meta/v1/', + }, + }, + }, + ], + default: 'contentBookMetaV1', + }, + ...contentBookMetaV1Description, +]; diff --git a/nodes/GwezzChangdunovel/resources/user/create.ts b/nodes/GwezzChangdunovel/resources/user/create.ts deleted file mode 100644 index 7cfcf15..0000000 --- a/nodes/GwezzChangdunovel/resources/user/create.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { INodeProperties } from 'n8n-workflow'; - -const showOnlyForUserCreate = { - operation: ['create'], - resource: ['user'], -}; - -export const userCreateDescription: INodeProperties[] = [ - { - displayName: 'Name', - name: 'name', - type: 'string', - default: '', - required: true, - displayOptions: { - show: showOnlyForUserCreate, - }, - description: 'The name of the user', - routing: { - send: { - type: 'body', - property: 'name', - }, - }, - }, -]; diff --git a/nodes/GwezzChangdunovel/resources/user/get.ts b/nodes/GwezzChangdunovel/resources/user/get.ts deleted file mode 100644 index e73681f..0000000 --- a/nodes/GwezzChangdunovel/resources/user/get.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { INodeProperties } from 'n8n-workflow'; - -const showOnlyForUserGet = { - operation: ['get'], - resource: ['user'], -}; - -export const userGetDescription: INodeProperties[] = [ - { - displayName: 'User ID', - name: 'userId', - type: 'string', - displayOptions: { show: showOnlyForUserGet }, - default: '', - description: "The user's ID to retrieve", - }, -]; diff --git a/nodes/GwezzChangdunovel/resources/user/index.ts b/nodes/GwezzChangdunovel/resources/user/index.ts deleted file mode 100644 index 954130e..0000000 --- a/nodes/GwezzChangdunovel/resources/user/index.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { INodeProperties } from 'n8n-workflow'; -import { userCreateDescription } from './create'; -import { userGetDescription } from './get'; - -const showOnlyForUsers = { - resource: ['user'], -}; - -export const userDescription: INodeProperties[] = [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - displayOptions: { - show: showOnlyForUsers, - }, - options: [ - { - name: 'Get Many', - value: 'getAll', - action: 'Get users', - description: 'Get many users', - routing: { - request: { - method: 'GET', - url: '/users', - }, - }, - }, - { - name: 'Get', - value: 'get', - action: 'Get a user', - description: 'Get the data of a single user', - routing: { - request: { - method: 'GET', - url: '=/users/{{$parameter.userId}}', - }, - }, - }, - { - name: 'Create', - value: 'create', - action: 'Create a new user', - description: 'Create a new user', - routing: { - request: { - method: 'POST', - url: '/users', - }, - }, - }, - ], - default: 'getAll', - }, - ...userGetDescription, - ...userCreateDescription, -];