mirror of
https://github.com/twentyhq/twenty.git
synced 2024-10-27 03:33:21 +03:00
Fix zapier (#3688)
* Fix zapier testing * Fix zapier create action * Add timezone to dates
This commit is contained in:
parent
8abd5be4b5
commit
68e65e9526
@ -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": {
|
||||
|
@ -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');
|
||||
|
@ -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' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user