Expand Taiga node (#1970)

*  Expand Taiga node

*  Make projectId consistent

* 🔥 Remove logging

* 🔨 Fix user story statuses loader

*  Add epics loader

* 🔨 Make projectId required for updates

* 🔨 Refactor credentials

*  Small change

*  Update credentials in trigger

* 🔥 Remove old unused credentials

* ✏️ Write breaking changes

Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
Iván Ovejero
2021-07-15 00:02:30 +02:00
committed by GitHub
parent bf6ef3bbc0
commit a1f0fff9fc
19 changed files with 2872 additions and 694 deletions

View File

@@ -60,16 +60,7 @@ export async function taigaApiRequest(
uri?: string | undefined,
option = {},
): Promise<any> { // tslint:disable-line:no-any
const version = this.getNodeParameter('version', 0, 'cloud') as string;
let credentials;
if (version === 'server') {
credentials = this.getCredentials('taigaServerApi') as ICredentialDataDecryptedObject;
} else {
credentials = this.getCredentials('taigaCloudApi') as ICredentialDataDecryptedObject;
}
const credentials = this.getCredentials('taigaApi') as ICredentialDataDecryptedObject;
const authToken = await getAuthorization.call(this, credentials);
@@ -124,3 +115,44 @@ export function getAutomaticSecret(credentials: ICredentialDataDecryptedObject)
const data = `${credentials.username},${credentials.password}`;
return createHash('md5').update(data).digest('hex');
}
export async function handleListing(
this: IExecuteFunctions,
method: string,
endpoint: string,
body: IDataObject = {},
qs: IDataObject = {},
i: number,
) {
let responseData;
qs.project = this.getNodeParameter('projectId', i) as number;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll) {
return await taigaApiRequestAllItems.call(this, method, endpoint, body, qs);
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await taigaApiRequestAllItems.call(this, method, endpoint, body, qs);
return responseData.splice(0, qs.limit);
}
}
export const toOptions = (items: LoadedResource[]) =>
items.map(({ name, id }) => ({ name, value: id }));
export function throwOnEmptyUpdate(
this: IExecuteFunctions,
resource: Resource,
) {
throw new NodeOperationError(
this.getNode(),
`Please enter at least one field to update for the ${resource}.`,
);
}
export async function getVersionForUpdate(
this: IExecuteFunctions,
endpoint: string,
) {
return await taigaApiRequest.call(this, 'GET', endpoint).then(response => response.version);
}