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"
|
"zapier-platform-core": "15.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"jest": "29.7.0",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
"zapier-platform-cli": "^15.4.1"
|
"zapier-platform-cli": "^15.4.1"
|
||||||
},
|
},
|
||||||
"installConfig": {
|
"installConfig": {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import App from '../index';
|
|
||||||
import { Bundle, createAppTester, tools, ZObject } from 'zapier-platform-core';
|
import { Bundle, createAppTester, tools, ZObject } from 'zapier-platform-core';
|
||||||
|
|
||||||
|
import App from '../index';
|
||||||
import getBundle from '../utils/getBundle';
|
import getBundle from '../utils/getBundle';
|
||||||
import handleQueryParams from '../utils/handleQueryParams';
|
import handleQueryParams from '../utils/handleQueryParams';
|
||||||
import requestDb from '../utils/requestDb';
|
import requestDb from '../utils/requestDb';
|
||||||
@ -43,7 +44,7 @@ describe('custom auth', () => {
|
|||||||
try {
|
try {
|
||||||
await appTester(App.authentication.test, bundle);
|
await appTester(App.authentication.test, bundle);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
expect(error.message).toContain('Unauthorized');
|
expect(error.message).toContain('Unauthenticated');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new Error('appTester should have thrown');
|
throw new Error('appTester should have thrown');
|
||||||
@ -70,7 +71,7 @@ describe('custom auth', () => {
|
|||||||
try {
|
try {
|
||||||
await appTester(App.authentication.test, bundleWithExpiredApiKey);
|
await appTester(App.authentication.test, bundleWithExpiredApiKey);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
expect(error.message).toContain('Unauthorized');
|
expect(error.message).toContain('Unauthenticated');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new Error('appTester should have thrown');
|
throw new Error('appTester should have thrown');
|
||||||
|
@ -52,12 +52,10 @@ export default {
|
|||||||
sample: {
|
sample: {
|
||||||
id: 'f75f6b2e-9442-4c72-aa95-47d8e5ec8cb3',
|
id: 'f75f6b2e-9442-4c72-aa95-47d8e5ec8cb3',
|
||||||
createdAt: '2023-10-19T07:37:25.306Z',
|
createdAt: '2023-10-19T07:37:25.306Z',
|
||||||
workspaceId: 'c8b070fc-c969-4ca5-837a-e7c3735734d2',
|
|
||||||
},
|
},
|
||||||
outputFields: [
|
outputFields: [
|
||||||
{ key: 'id', label: 'ID' },
|
{ key: 'id', label: 'ID' },
|
||||||
{ key: 'createdAt', label: 'Created At' },
|
{ 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 { computeInputFields } from '../../utils/computeInputFields';
|
||||||
import { requestSchema } from '../../utils/requestDb';
|
import { requestSchema } from '../../utils/requestDb';
|
||||||
|
import { capitalize } from '../capitalize';
|
||||||
|
|
||||||
export const recordInputFields = async (
|
export const recordInputFields = async (
|
||||||
z: ZObject,
|
z: ZObject,
|
||||||
@ -9,7 +10,8 @@ export const recordInputFields = async (
|
|||||||
idRequired = false,
|
idRequired = false,
|
||||||
) => {
|
) => {
|
||||||
const schema = await requestSchema(z, bundle);
|
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);
|
return computeInputFields(infos, idRequired);
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,20 @@ export const performUnsubscribe = async (z: ZObject, bundle: Bundle) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const perform = (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 (
|
const getNamePluralFromNameSingular = async (
|
||||||
|
@ -43225,6 +43225,8 @@ __metadata:
|
|||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "twenty-zapier@workspace:packages/twenty-zapier"
|
resolution: "twenty-zapier@workspace:packages/twenty-zapier"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
jest: "npm:29.7.0"
|
||||||
|
rimraf: "npm:^3.0.2"
|
||||||
zapier-platform-cli: "npm:^15.4.1"
|
zapier-platform-cli: "npm:^15.4.1"
|
||||||
zapier-platform-core: "npm:15.5.1"
|
zapier-platform-core: "npm:15.5.1"
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
|
Loading…
Reference in New Issue
Block a user