add resource

This commit is contained in:
2025-10-30 18:11:19 +08:00
parent 6883edbeb7
commit 61796ab57d
7 changed files with 23 additions and 204 deletions

View File

@@ -12,6 +12,27 @@ export class GwezzOceanengineOAuth2Api implements ICredentialType {
documentationUrl = 'https://gitea.gwezz.com/n8n-nodes/n8n-nodes-gwezz-oceanengine/wiki';
properties: INodeProperties[] = [
{
displayName: 'APP_ID',
name: 'appId',
type: 'string',
default: '',
},
{
displayName: 'Secret',
name: 'secret',
type: 'string',
typeOptions: {
password: true,
},
default: '',
},
{
displayName: 'Redirect URI',
name: 'redirectUri',
type: 'hidden',
default: '={{$oauth2.redirectUrl}}',
},
{
displayName: 'Grant Type',
name: 'grantType',
@@ -22,13 +43,13 @@ export class GwezzOceanengineOAuth2Api implements ICredentialType {
displayName: 'Authorization URL',
name: 'authUrl',
type: 'hidden',
default: 'https://api.example.com/oauth/authorize',
default: 'https://ad.oceanengine.com/openapi/audit/oauth.html',
},
{
displayName: 'Access Token URL',
name: 'accessTokenUrl',
type: 'hidden',
default: 'https://api.example.com/oauth/token',
default: 'https://ad.oceanengine.com/open_api/oauth2/access_token/',
},
{
displayName: 'Auth URI Query Parameters',

View File

@@ -1,6 +1,4 @@
import { type INodeType, type INodeTypeDescription } from 'n8n-workflow';
import { userDescription } from './resources/user';
import { companyDescription } from './resources/company';
export class GwezzOceanengine implements INodeType {
description: INodeTypeDescription = {
@@ -36,8 +34,6 @@ export class GwezzOceanengine implements INodeType {
],
default: 'user',
},
...userDescription,
...companyDescription,
],
};
}

View File

@@ -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',
},
},
},
},
},
];

View File

@@ -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,
];

View File

@@ -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',
},
},
},
];

View File

@@ -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",
},
];

View File

@@ -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,
];