v0.1
This commit is contained in:
@@ -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,
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
1
nodes/GwezzChangdunovel/gwezz.dark.svg
Normal file
1
nodes/GwezzChangdunovel/gwezz.dark.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 20 KiB |
1
nodes/GwezzChangdunovel/gwezz.svg
Normal file
1
nodes/GwezzChangdunovel/gwezz.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 20 KiB |
@@ -1,13 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="aquamarine"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-cpu">
|
||||
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
|
||||
<rect x="9" y="9" width="6" height="6"></rect>
|
||||
<line x1="9" y1="1" x2="9" y2="4"></line>
|
||||
<line x1="15" y1="1" x2="15" y2="4"></line>
|
||||
<line x1="9" y1="20" x2="9" y2="23"></line>
|
||||
<line x1="15" y1="20" x2="15" y2="23"></line>
|
||||
<line x1="20" y1="9" x2="23" y2="9"></line>
|
||||
<line x1="20" y1="14" x2="23" y2="14"></line>
|
||||
<line x1="1" y1="9" x2="4" y2="9"></line>
|
||||
<line x1="1" y1="14" x2="4" y2="14"></line>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 698 B |
@@ -1,13 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="darkblue"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-cpu">
|
||||
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
|
||||
<rect x="9" y="9" width="6" height="6"></rect>
|
||||
<line x1="9" y1="1" x2="9" y2="4"></line>
|
||||
<line x1="15" y1="1" x2="15" y2="4"></line>
|
||||
<line x1="9" y1="20" x2="9" y2="23"></line>
|
||||
<line x1="15" y1="20" x2="15" y2="23"></line>
|
||||
<line x1="20" y1="9" x2="23" y2="9"></line>
|
||||
<line x1="20" y1="14" x2="23" y2="14"></line>
|
||||
<line x1="1" y1="9" x2="4" y2="9"></line>
|
||||
<line x1="1" y1="14" x2="4" y2="14"></line>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 696 B |
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -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,
|
||||
];
|
||||
@@ -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',
|
||||
},
|
||||
];
|
||||
33
nodes/GwezzChangdunovel/resources/distribution/index.ts
Normal file
33
nodes/GwezzChangdunovel/resources/distribution/index.ts
Normal file
@@ -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,
|
||||
];
|
||||
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -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",
|
||||
},
|
||||
];
|
||||
@@ -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,
|
||||
];
|
||||
Reference in New Issue
Block a user