Fix zapier (#3688)

* Fix zapier testing

* Fix zapier create action

* Add timezone to dates
This commit is contained in:
martmull 2024-02-01 15:19:42 +01:00 committed by GitHub
parent 8abd5be4b5
commit 68e65e9526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 7 deletions

View File

@ -27,6 +27,8 @@
"zapier-platform-core": "15.5.1"
},
"devDependencies": {
"jest": "29.7.0",
"rimraf": "^3.0.2",
"zapier-platform-cli": "^15.4.1"
},
"installConfig": {

View File

@ -1,5 +1,6 @@
import App from '../index';
import { Bundle, createAppTester, tools, ZObject } from 'zapier-platform-core';
import App from '../index';
import getBundle from '../utils/getBundle';
import handleQueryParams from '../utils/handleQueryParams';
import requestDb from '../utils/requestDb';
@ -43,7 +44,7 @@ describe('custom auth', () => {
try {
await appTester(App.authentication.test, bundle);
} catch (error: any) {
expect(error.message).toContain('Unauthorized');
expect(error.message).toContain('Unauthenticated');
return;
}
throw new Error('appTester should have thrown');
@ -70,7 +71,7 @@ describe('custom auth', () => {
try {
await appTester(App.authentication.test, bundleWithExpiredApiKey);
} catch (error: any) {
expect(error.message).toContain('Unauthorized');
expect(error.message).toContain('Unauthenticated');
return;
}
throw new Error('appTester should have thrown');

View File

@ -52,12 +52,10 @@ export default {
sample: {
id: 'f75f6b2e-9442-4c72-aa95-47d8e5ec8cb3',
createdAt: '2023-10-19T07:37:25.306Z',
workspaceId: 'c8b070fc-c969-4ca5-837a-e7c3735734d2',
},
outputFields: [
{ key: 'id', label: 'ID' },
{ key: 'createdAt', label: 'Created At' },
{ key: 'workspaceId', label: 'Workspace ID' },
],
},
};

View File

@ -2,6 +2,7 @@ import { Bundle, ZObject } from 'zapier-platform-core';
import { computeInputFields } from '../../utils/computeInputFields';
import { requestSchema } from '../../utils/requestDb';
import { capitalize } from '../capitalize';
export const recordInputFields = async (
z: ZObject,
@ -9,7 +10,8 @@ export const recordInputFields = async (
idRequired = false,
) => {
const schema = await requestSchema(z, bundle);
const infos = schema.components.schemas[bundle.inputData.nameSingular];
const infos =
schema.components.schemas[capitalize(bundle.inputData.nameSingular)];
return computeInputFields(infos, idRequired);
};

View File

@ -40,7 +40,20 @@ export const performUnsubscribe = async (z: ZObject, bundle: Bundle) => {
};
export const perform = (z: ZObject, bundle: Bundle) => {
return [bundle.cleanedRequest.record];
const record = bundle.cleanedRequest.record;
if (record.createdAt) {
record.createdAt = record.createdAt + 'Z';
}
if (record.updatedAt) {
record.updatedAt = record.updatedAt + 'Z';
}
if (record.revokedAt) {
record.revokedAt = record.revokedAt + 'Z';
}
if (record.expiresAt) {
record.expiresAt = record.expiresAt + 'Z';
}
return [record];
};
const getNamePluralFromNameSingular = async (

View File

@ -43225,6 +43225,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "twenty-zapier@workspace:packages/twenty-zapier"
dependencies:
jest: "npm:29.7.0"
rimraf: "npm:^3.0.2"
zapier-platform-cli: "npm:^15.4.1"
zapier-platform-core: "npm:15.5.1"
languageName: unknown