mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
🔀 Merge branch 'master' of https://github.com/thorstenfreitag/n8n into thorstenfreitag-master
This commit is contained in:
commit
9d972b2fb9
|
@ -29,6 +29,10 @@ export class GristApi implements ICredentialType {
|
||||||
name: 'Paid',
|
name: 'Paid',
|
||||||
value: 'paid',
|
value: 'paid',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Self-hosted',
|
||||||
|
value: 'selfhosted',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -46,5 +50,20 @@ export class GristApi implements ICredentialType {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Self-hosted URL',
|
||||||
|
name: 'selfHostedUrl',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
description: 'URL of your Grist instance (include http/https without /api and no trailing slash)',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
planType: [
|
||||||
|
'selfhosted',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,19 @@ export async function gristApiRequest(
|
||||||
apiKey,
|
apiKey,
|
||||||
planType,
|
planType,
|
||||||
customSubdomain,
|
customSubdomain,
|
||||||
|
selfHostedUrl,
|
||||||
} = await this.getCredentials('gristApi') as GristCredentials;
|
} = await this.getCredentials('gristApi') as GristCredentials;
|
||||||
|
|
||||||
const subdomain = planType === 'free' ? 'docs' : customSubdomain;
|
const gristapiurl = (planType === 'free') ? `https://docs.getgrist.com/api${endpoint}` :
|
||||||
|
(planType === 'paid') ? `https://${customSubdomain}.getgrist.com/api${endpoint}` :
|
||||||
|
`${selfHostedUrl}/api${endpoint}`;
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${apiKey}`,
|
Authorization: `Bearer ${apiKey}`,
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
uri: `https://${subdomain}.getgrist.com/api${endpoint}`,
|
uri: gristapiurl,
|
||||||
qs,
|
qs,
|
||||||
body,
|
body,
|
||||||
json: true,
|
json: true,
|
||||||
|
|
|
@ -85,18 +85,21 @@ export class Grist implements INodeType {
|
||||||
apiKey,
|
apiKey,
|
||||||
planType,
|
planType,
|
||||||
customSubdomain,
|
customSubdomain,
|
||||||
|
selfHostedUrl,
|
||||||
} = credential.data as GristCredentials;
|
} = credential.data as GristCredentials;
|
||||||
|
|
||||||
const subdomain = planType === 'free' ? 'docs' : customSubdomain;
|
|
||||||
|
|
||||||
const endpoint = '/orgs';
|
const endpoint = '/orgs';
|
||||||
|
|
||||||
|
const gristapiurl = (planType === 'free') ? `https://docs.getgrist.com/api${endpoint}` :
|
||||||
|
(planType === 'paid') ? `https://${customSubdomain}.getgrist.com/api${endpoint}` :
|
||||||
|
`${selfHostedUrl}/api${endpoint}`;
|
||||||
|
|
||||||
const options: OptionsWithUri = {
|
const options: OptionsWithUri = {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${apiKey}`,
|
Authorization: `Bearer ${apiKey}`,
|
||||||
},
|
},
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
uri: `https://${subdomain}.getgrist.com/api${endpoint}`,
|
uri: gristapiurl,
|
||||||
qs: { limit: 1 },
|
qs: { limit: 1 },
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
3
packages/nodes-base/nodes/Grist/types.d.ts
vendored
3
packages/nodes-base/nodes/Grist/types.d.ts
vendored
|
@ -1,7 +1,8 @@
|
||||||
export type GristCredentials = {
|
export type GristCredentials = {
|
||||||
apiKey: string;
|
apiKey: string;
|
||||||
planType: 'free' | 'paid';
|
planType: 'free' | 'paid' | 'selfhosted';
|
||||||
customSubdomain?: string;
|
customSubdomain?: string;
|
||||||
|
selfHostedUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GristColumns = {
|
export type GristColumns = {
|
||||||
|
|
Loading…
Reference in a new issue