Zapier add description to labels (#3787)

* Use object metadata graphql api to fetch input fields

* Clean code

* Clean code

* Remove targetColumnMap

* Remove duplicated testing

* Fix labels
This commit is contained in:
martmull
2024-02-13 22:22:47 +01:00
committed by GitHub
parent e011ecbd6f
commit 15a5fec545
11 changed files with 451 additions and 165 deletions

View File

@ -1,17 +1,36 @@
import { Bundle, HttpRequestOptions, ZObject } from 'zapier-platform-core';
export const requestSchema = async (z: ZObject, bundle: Bundle) => {
const options = {
url: `${process.env.SERVER_BASE_URL}/open-api`,
method: 'GET',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `Bearer ${bundle.authData.apiKey}`,
},
} satisfies HttpRequestOptions;
import { Schema } from '../utils/data.types';
return z.request(options).then((response) => response.json);
export const requestSchema = async (
z: ZObject,
bundle: Bundle,
): Promise<Schema> => {
const query = `query GetObjects {
objects(paging: {first: 1000}, filter: {isActive: {is:true}}) {
edges {
node {
nameSingular
namePlural
labelSingular
fields(paging: {first: 1000}, filter: {isActive: {is:true}}) {
edges {
node {
type
name
label
description
isNullable
defaultValue
}
}
}
}
}
}
}`;
const endpoint = 'metadata';
return await requestDb(z, bundle, query, endpoint);
};
const requestDb = async (