mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡ Minor improvements to Contentful-Node
This commit is contained in:
parent
322b94255a
commit
9be3b97cc3
|
@ -192,26 +192,6 @@ export const fields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: ' Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.',
|
description: ' Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.',
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Options',
|
|
||||||
name: 'options',
|
|
||||||
type: 'collection',
|
|
||||||
placeholder: 'Select Option',
|
|
||||||
default: {},
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
resource.value,
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'getAll',
|
|
||||||
'get'
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
{
|
||||||
displayName: 'RAW Data',
|
displayName: 'RAW Data',
|
||||||
name: 'rawData',
|
name: 'rawData',
|
||||||
|
|
|
@ -67,10 +67,10 @@ export const fields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Additional Fields',
|
||||||
name: 'options',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Select Option',
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
|
|
@ -118,11 +118,11 @@ export class Contentful implements INodeType {
|
||||||
|
|
||||||
const id = this.getNodeParameter('contentTypeId', 0) as string;
|
const id = this.getNodeParameter('contentTypeId', 0) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/content_types/${id}`);
|
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/content_types/${id}`);
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!additionalFields.rawData) {
|
||||||
responseData = responseData.fields;
|
responseData = responseData.fields;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,11 +137,11 @@ export class Contentful implements INodeType {
|
||||||
|
|
||||||
const id = this.getNodeParameter('entryId', 0) as string;
|
const id = this.getNodeParameter('entryId', 0) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries/${id}`, {}, qs);
|
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries/${id}`, {}, qs);
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!additionalFields.rawData) {
|
||||||
responseData = responseData.fields;
|
responseData = responseData.fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +151,11 @@ export class Contentful implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
const rawData = additionalFields.rawData;
|
||||||
|
additionalFields.rawData = undefined;
|
||||||
|
|
||||||
const env = this.getNodeParameter('environmentId', i) as string;
|
const env = this.getNodeParameter('environmentId', i) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
|
||||||
|
|
||||||
Object.assign(qs, additionalFields);
|
Object.assign(qs, additionalFields);
|
||||||
|
|
||||||
if (qs.equal) {
|
if (qs.equal) {
|
||||||
|
@ -185,7 +185,7 @@ export class Contentful implements INodeType {
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs);
|
responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs);
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!rawData) {
|
||||||
const assets : IDataObject[] = [];
|
const assets : IDataObject[] = [];
|
||||||
// tslint:disable-next-line: no-any
|
// tslint:disable-next-line: no-any
|
||||||
responseData.map((asset : any) => {
|
responseData.map((asset : any) => {
|
||||||
|
@ -199,7 +199,7 @@ export class Contentful implements INodeType {
|
||||||
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs);
|
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs);
|
||||||
responseData = responseData.items;
|
responseData = responseData.items;
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!rawData) {
|
||||||
const assets : IDataObject[] = [];
|
const assets : IDataObject[] = [];
|
||||||
// tslint:disable-next-line: no-any
|
// tslint:disable-next-line: no-any
|
||||||
responseData.map((asset : any) => {
|
responseData.map((asset : any) => {
|
||||||
|
@ -219,11 +219,11 @@ export class Contentful implements INodeType {
|
||||||
|
|
||||||
const id = this.getNodeParameter('assetId', 0) as string;
|
const id = this.getNodeParameter('assetId', 0) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
|
||||||
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets/${id}`, {}, qs);
|
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets/${id}`, {}, qs);
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!additionalFields.rawData) {
|
||||||
responseData = responseData.fields;
|
responseData = responseData.fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,11 +234,11 @@ export class Contentful implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||||
|
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
const rawData = additionalFields.rawData;
|
||||||
|
additionalFields.rawData = undefined;
|
||||||
|
|
||||||
const env = this.getNodeParameter('environmentId', i) as string;
|
const env = this.getNodeParameter('environmentId', i) as string;
|
||||||
|
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
|
||||||
|
|
||||||
Object.assign(qs, additionalFields);
|
Object.assign(qs, additionalFields);
|
||||||
|
|
||||||
if (qs.equal) {
|
if (qs.equal) {
|
||||||
|
@ -268,7 +268,7 @@ export class Contentful implements INodeType {
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs);
|
responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs);
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!rawData) {
|
||||||
const assets : IDataObject[] = [];
|
const assets : IDataObject[] = [];
|
||||||
// tslint:disable-next-line: no-any
|
// tslint:disable-next-line: no-any
|
||||||
responseData.map((asset : any) => {
|
responseData.map((asset : any) => {
|
||||||
|
@ -277,12 +277,12 @@ export class Contentful implements INodeType {
|
||||||
responseData = assets;
|
responseData = assets;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const limit = this.getNodeParameter('limit', 0) as number;
|
const limit = this.getNodeParameter('limit', i) as number;
|
||||||
qs.limit = limit;
|
qs.limit = limit;
|
||||||
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs);
|
responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs);
|
||||||
responseData = responseData.items;
|
responseData = responseData.items;
|
||||||
|
|
||||||
if (!options.rawData) {
|
if (!rawData) {
|
||||||
const assets : IDataObject[] = [];
|
const assets : IDataObject[] = [];
|
||||||
// tslint:disable-next-line: no-any
|
// tslint:disable-next-line: no-any
|
||||||
responseData.map((asset : any) => {
|
responseData.map((asset : any) => {
|
||||||
|
|
|
@ -182,6 +182,13 @@ export const fields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: ' Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.',
|
description: ' Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'RAW Data',
|
||||||
|
name: 'rawData',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: 'If the data should be returned RAW instead of parsed.',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -201,31 +208,4 @@ export const fields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Options',
|
|
||||||
name: 'options',
|
|
||||||
type: 'collection',
|
|
||||||
placeholder: 'Select Option',
|
|
||||||
default: {},
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
resource: [
|
|
||||||
resource.value,
|
|
||||||
],
|
|
||||||
operation: [
|
|
||||||
'get',
|
|
||||||
'getAll',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
displayName: 'RAW Data',
|
|
||||||
name: 'rawData',
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
description: 'If the data should be returned RAW instead of parsed.',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
Loading…
Reference in a new issue