@@ -0,0 +1,60 @@
|
||||
name: CI Zapier
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
|
||||
|
||||
jobs:
|
||||
changed-files-check:
|
||||
uses: ./.github/workflows/changed-files.yaml
|
||||
with:
|
||||
files: |
|
||||
packages/twenty-zapier/**
|
||||
packages/twenty-server/**
|
||||
!packages/twenty-zapier/package.json
|
||||
!packages/twenty-zapier/CHANGELOG.md
|
||||
zapier-test:
|
||||
needs: changed-files-check
|
||||
if: needs.changed-files-check.outputs.any_changed == 'true'
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
task: [lint, typecheck, test, validate]
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.11.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
- name: Fetch custom Github Actions and base branch history
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/yarn-install
|
||||
- name: Build
|
||||
run: npx nx build twenty-zapier
|
||||
- name: Run ${{ matrix.task }} task
|
||||
uses: ./.github/actions/nx-affected
|
||||
with:
|
||||
tag: scope:zapier
|
||||
tasks: ${{ matrix.task }}
|
||||
ci-zapier-status-check:
|
||||
if: always() && !cancelled()
|
||||
timeout-minutes: 5
|
||||
runs-on: ubuntu-latest
|
||||
needs: [changed-files-check, zapier-test]
|
||||
steps:
|
||||
- name: Fail job if any needs failed
|
||||
if: contains(needs.*.result, 'failure')
|
||||
run: exit 1
|
||||
@@ -83,6 +83,10 @@ export default [
|
||||
sourceTag: 'scope:frontend',
|
||||
onlyDependOnLibsWithTags: ['scope:shared', 'scope:frontend'],
|
||||
},
|
||||
{
|
||||
sourceTag: 'scope:zapier',
|
||||
onlyDependOnLibsWithTags: ['scope:shared', 'scope:zapier'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const jestConfig = {
|
||||
displayName: 'twenty-cli',
|
||||
displayName: 'create-twenty-app',
|
||||
preset: '../../jest.preset.js',
|
||||
testEnvironment: 'node',
|
||||
transformIgnorePatterns: ['../../node_modules/'],
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
## 2.2.0
|
||||
* Fix authentication issue
|
||||
|
||||
## 2.1.1
|
||||
* Add changelog
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import reactPlugin from 'eslint-plugin-react';
|
||||
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
||||
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
|
||||
import baseConfig from '../../eslint.config.mjs';
|
||||
|
||||
export default [
|
||||
...baseConfig,
|
||||
{
|
||||
ignores: ['**/dist/**'],
|
||||
},
|
||||
{
|
||||
files: ['**/*.{js,jsx,ts,tsx}'],
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
'react-hooks': reactHooksPlugin,
|
||||
'react-refresh': reactRefreshPlugin,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'prettier/prettier': 'error',
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'react/jsx-key': 'off',
|
||||
'react/display-name': 'off',
|
||||
'react/jsx-uses-react': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-no-useless-fragment': 'off',
|
||||
'react/jsx-props-no-spreading': [
|
||||
'error',
|
||||
{
|
||||
explicitSpread: 'ignore',
|
||||
},
|
||||
],
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
},
|
||||
ignores: ['src/**/*.ts', '!src/cli/**/*.ts'],
|
||||
},
|
||||
];
|
||||
@@ -1 +1 @@
|
||||
module.exports = require('./lib').default;
|
||||
module.exports = require('./lib/index.cjs').default;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { pathsToModuleNameMapper } from 'ts-jest';
|
||||
|
||||
export default {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
'^.+\\.ts?$': 'ts-jest',
|
||||
},
|
||||
moduleFileExtensions: ['ts', 'js'],
|
||||
transformIgnorePatterns: ['/node_modules/'],
|
||||
rootDir: './src',
|
||||
testMatch: ['**/__tests__/**/*.test.ts'],
|
||||
moduleNameMapper: pathsToModuleNameMapper(
|
||||
{ 'src/*': ['./src/*'] },
|
||||
{ prefix: '<rootDir>/../' },
|
||||
),
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "twenty-zapier",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "Effortlessly sync Twenty with 3000+ apps. Automate tasks, boost productivity, and supercharge your customer relationships!",
|
||||
"main": "src/index.ts",
|
||||
"main": "lib/index.cjs",
|
||||
"engines": {
|
||||
"node": "^24.5.0",
|
||||
"npm": "please-use-yarn",
|
||||
@@ -22,9 +22,10 @@
|
||||
"devDependencies": {
|
||||
"jest": "29.7.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"twenty-shared": "workspace:*",
|
||||
"vite": "^7.0.0",
|
||||
"vite-plugin-dts": "^4.5.4",
|
||||
"vite-tsconfig-paths": "^4.2.1",
|
||||
"zapier-platform-cli": "^15.4.1"
|
||||
},
|
||||
"installConfig": {
|
||||
"hoistingLimits": "dependencies"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": ["tsc"]
|
||||
"commands": ["npx vite build"]
|
||||
},
|
||||
"dependsOn": ["clean","^build"]
|
||||
"dependsOn": ["clean", "^build"]
|
||||
},
|
||||
"format": {
|
||||
"executor": "nx:run-commands",
|
||||
@@ -23,16 +23,27 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": ["NODE_ENV=test && nx run twenty-zapier:build && jest --testTimeout 10000 --rootDir ./lib/test"]
|
||||
"commands": [
|
||||
"NODE_ENV=test jest --testTimeout 10000"
|
||||
]
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"options": {
|
||||
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"],
|
||||
"maxWarnings": 0
|
||||
},
|
||||
"dependsOn": ["build"]
|
||||
"configurations": {
|
||||
"ci": { "lintFilePatterns": ["{projectRoot}/**/*.{ts,json}"] },
|
||||
"fix": {}
|
||||
}
|
||||
},
|
||||
"typecheck": {},
|
||||
"validate": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": ["nx run twenty-zapier:build && zapier validate"]
|
||||
"commands": ["zapier validate"]
|
||||
},
|
||||
"dependsOn": ["build"]
|
||||
},
|
||||
@@ -40,10 +51,11 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": ["nx run twenty-zapier:build && zapier versions"]
|
||||
}
|
||||
"commands": ["zapier versions"]
|
||||
},
|
||||
"dependsOn": ["build"]
|
||||
},
|
||||
"watch":{
|
||||
"watch": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
@@ -55,16 +67,14 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": ["rimraf ./lib ./build"]
|
||||
"commands": ["rimraf ./lib"]
|
||||
}
|
||||
},
|
||||
"deploy": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": [
|
||||
"nx run twenty-zapier:build && zapier push --disable-dependency-detection"
|
||||
]
|
||||
"commands": ["zapier push --disable-dependency-detection"]
|
||||
},
|
||||
"dependsOn": ["build"]
|
||||
},
|
||||
@@ -72,9 +82,7 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "{projectRoot}",
|
||||
"commands": [
|
||||
"zapier promote"
|
||||
]
|
||||
"commands": ["zapier promote"]
|
||||
},
|
||||
"dependsOn": ["build"]
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { createAppTester, tools } from 'zapier-platform-core';
|
||||
|
||||
import App from '../index';
|
||||
import getBundle from '../utils/getBundle';
|
||||
import App from 'src/index';
|
||||
import { getBundle } from 'src/utils/getBundle';
|
||||
const appTester = createAppTester(App);
|
||||
tools.env.inject();
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import type { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import requestDb from './utils/requestDb';
|
||||
import requestDb from 'src/utils/requestDb';
|
||||
|
||||
const testAuthentication = async (z: ZObject, bundle: Bundle) => {
|
||||
return await requestDb(
|
||||
return await requestDb({
|
||||
z,
|
||||
bundle,
|
||||
'query currentWorkspace {currentWorkspace {id displayName}}',
|
||||
);
|
||||
query: 'query currentWorkspace {currentWorkspace {id displayName}}',
|
||||
endpoint: 'metadata',
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
|
||||
+17
-17
@@ -5,11 +5,11 @@ import {
|
||||
type ZObject,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
import { crudRecordKey } from '../../creates/crud_record';
|
||||
import App from '../../index';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import requestDb from '../../utils/requestDb';
|
||||
import { DatabaseEventAction } from '../../utils/triggers/triggers.utils';
|
||||
import { crudRecordKey } from 'src/creates/crud_record';
|
||||
import App from 'src/index';
|
||||
import { getBundle } from 'src/utils/getBundle';
|
||||
import requestDb from 'src/utils/requestDb';
|
||||
import { DatabaseEventAction } from 'src/utils/triggers/triggers.utils';
|
||||
const appTester = createAppTester(App);
|
||||
tools.env.inject();
|
||||
|
||||
@@ -49,11 +49,11 @@ describe('creates.create_company', () => {
|
||||
expect(result.data?.createCompany?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query findCompany {company(filter: {id: {eq: "${result.data.createCompany.id}"}}){id annualRecurringRevenue{amountMicros currencyCode}}}`,
|
||||
),
|
||||
query: `query findCompany {company(filter: {id: {eq: "${result.data.createCompany.id}"}}){id annualRecurringRevenue{amountMicros currencyCode}}}`,
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
expect(
|
||||
@@ -83,11 +83,11 @@ describe('creates.create_company', () => {
|
||||
expect(result.data?.createPerson?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query findPerson {person(filter: {id: {eq: "${result.data.createPerson.id}"}}){phones{primaryPhoneNumber}}}`,
|
||||
),
|
||||
query: `query findPerson {person(filter: {id: {eq: "${result.data.createPerson.id}"}}){phones{primaryPhoneNumber}}}`,
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
expect(checkDbResult.data.person.phones.primaryPhoneNumber).toEqual(
|
||||
@@ -128,11 +128,11 @@ describe('creates.update_company', () => {
|
||||
expect(updateResult.data?.updateCompany?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query findCompany {company(filter: {id: {eq: "${companyId}"}}){id name}}`,
|
||||
),
|
||||
query: `query findCompany {company(filter: {id: {eq: "${companyId}"}}){id name}}`,
|
||||
}),
|
||||
updateBundle,
|
||||
);
|
||||
expect(checkDbResult.data.company.name).toEqual('Updated Company Name');
|
||||
@@ -170,11 +170,11 @@ describe('creates.delete_company', () => {
|
||||
expect(deleteResult.data?.deleteCompany?.id).toBeDefined();
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query findCompanies {companies(filter: {id: {eq: "${companyId}"}}){edges{node{id}}}}`,
|
||||
),
|
||||
query: `query findCompanies {companies(filter: {id: {eq: "${companyId}"}}){edges{node{id}}}}`,
|
||||
}),
|
||||
deleteBundle,
|
||||
);
|
||||
expect(checkDbResult.data.companies.edges.length).toEqual(0);
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { Bundle, ZObject } from 'zapier-platform-core';
|
||||
import { findObjectNamesSingularKey } from '../triggers/find_object_names_singular';
|
||||
import { listRecordIdsKey } from '../triggers/list_record_ids';
|
||||
import { computeInputFields } from '../utils/computeInputFields';
|
||||
import { type InputData } from '../utils/data.types';
|
||||
import handleQueryParams from '../utils/handleQueryParams';
|
||||
import requestDb, { requestSchema } from '../utils/requestDb';
|
||||
import { DatabaseEventAction } from '../utils/triggers/triggers.utils';
|
||||
import { findObjectNamesSingularKey } from 'src/triggers/find_object_names_singular';
|
||||
import { listRecordIdsKey } from 'src/triggers/list_record_ids';
|
||||
import { computeInputFields } from 'src/utils/computeInputFields';
|
||||
import { type InputData } from 'src/utils/data.types';
|
||||
import handleQueryParams from 'src/utils/handleQueryParams';
|
||||
import requestDb, { requestSchema } from 'src/utils/requestDb';
|
||||
import { DatabaseEventAction } from 'src/utils/triggers/triggers.utils';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
const capitalize = (stringToCapitalize: string) => {
|
||||
@@ -103,7 +103,7 @@ const perform = async (z: ZObject, bundle: Bundle) => {
|
||||
)
|
||||
{id}
|
||||
}`;
|
||||
return await requestDb(z, bundle, query);
|
||||
return await requestDb({ z, bundle, query });
|
||||
};
|
||||
|
||||
export const crudRecordKey = 'crud_record';
|
||||
|
||||
@@ -2,15 +2,15 @@ import { version as platformVersion } from 'zapier-platform-core';
|
||||
|
||||
import 'dotenv/config';
|
||||
|
||||
const { version } = require('../package.json');
|
||||
import { version } from '../package.json';
|
||||
|
||||
import crudRecord, { crudRecordKey } from './creates/crud_record';
|
||||
import crudRecord, { crudRecordKey } from 'src/creates/crud_record';
|
||||
import findObjectNamesSingular, {
|
||||
findObjectNamesSingularKey,
|
||||
} from './triggers/find_object_names_singular';
|
||||
import listRecordIds, { listRecordIdsKey } from './triggers/list_record_ids';
|
||||
import triggerRecord, { triggerRecordKey } from './triggers/trigger_record';
|
||||
import authentication from './authentication';
|
||||
} from 'src/triggers/find_object_names_singular';
|
||||
import listRecordIds, { listRecordIdsKey } from 'src/triggers/list_record_ids';
|
||||
import triggerRecord, { triggerRecordKey } from 'src/triggers/trigger_record';
|
||||
import authentication from 'src/authentication';
|
||||
|
||||
export default {
|
||||
version,
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import { createAppTester, tools } from 'zapier-platform-core';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import App from '../../index';
|
||||
import { findObjectNamesSingularKey } from '../../triggers/find_object_names_singular';
|
||||
import { getBundle } from 'src/utils/getBundle';
|
||||
import App from 'src/index';
|
||||
import { findObjectNamesSingularKey } from 'src/triggers/find_object_names_singular';
|
||||
tools.env.inject();
|
||||
|
||||
const appTester = createAppTester(App);
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
import { createAppTester, tools } from 'zapier-platform-core';
|
||||
|
||||
import App from '../../index';
|
||||
import { listRecordIdsKey } from '../../triggers/list_record_ids';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import App from 'src/index';
|
||||
import { listRecordIdsKey } from 'src/triggers/list_record_ids';
|
||||
import { getBundle } from 'src/utils/getBundle';
|
||||
tools.env.inject();
|
||||
|
||||
const appTester = createAppTester(App);
|
||||
+35
-17
@@ -4,11 +4,11 @@ import {
|
||||
type ZObject,
|
||||
} from 'zapier-platform-core';
|
||||
|
||||
import App from '../../index';
|
||||
import { triggerRecordKey } from '../../triggers/trigger_record';
|
||||
import getBundle from '../../utils/getBundle';
|
||||
import requestDb from '../../utils/requestDb';
|
||||
import { DatabaseEventAction } from '../../utils/triggers/triggers.utils';
|
||||
import App from 'src/index';
|
||||
import { triggerRecordKey } from 'src/triggers/trigger_record';
|
||||
import { getBundle } from 'src/utils/getBundle';
|
||||
import requestDb from 'src/utils/requestDb';
|
||||
import { DatabaseEventAction } from 'src/utils/triggers/triggers.utils';
|
||||
const appTester = createAppTester(App);
|
||||
|
||||
describe('triggers.trigger_record.created', () => {
|
||||
@@ -29,11 +29,12 @@ describe('triggers.trigger_record.created', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query webhook {webhook(input: {id: "${result.id}"}){id operations}}`,
|
||||
),
|
||||
query: `query webhook {webhook(id: "${result.id}"){id operations}}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
|
||||
@@ -65,7 +66,12 @@ describe('triggers.trigger_record.created', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(z, bundle, `query webhook {webhooks {id}}`),
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
query: `query webhook {webhooks {id}}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
expect(
|
||||
@@ -141,11 +147,12 @@ describe('triggers.trigger_record.update', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query webhook {webhook(input: {id: "${result.id}"}){id operations}}`,
|
||||
),
|
||||
query: `query webhook {webhook(id: "${result.id}"){id operations }}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
|
||||
@@ -176,7 +183,12 @@ describe('triggers.trigger_record.update', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(z, bundle, `query webhook {webhooks {id}}`),
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
query: `query webhook {webhooks {id}}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
expect(
|
||||
@@ -223,11 +235,12 @@ describe('triggers.trigger_record.delete', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`query webhook {webhook(input: {id: "${result.id}"}){id operations}}`,
|
||||
),
|
||||
query: `query webhook {webhook(id: "${result.id}"){id operations }}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
|
||||
@@ -258,7 +271,12 @@ describe('triggers.trigger_record.delete', () => {
|
||||
|
||||
const checkDbResult = await appTester(
|
||||
(z: ZObject, bundle: Bundle) =>
|
||||
requestDb(z, bundle, `query webhook {webhooks {id}}`),
|
||||
requestDb({
|
||||
z,
|
||||
bundle,
|
||||
query: `query webhook {webhooks {id}}`,
|
||||
endpoint: 'metadata',
|
||||
}),
|
||||
bundle,
|
||||
);
|
||||
expect(
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { requestSchema } from '../utils/requestDb';
|
||||
import { requestSchema } from 'src/utils/requestDb';
|
||||
|
||||
const objectListRequest = async (z: ZObject, bundle: Bundle) => {
|
||||
const schema = await requestSchema(z, bundle);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { performList } from '../utils/triggers/triggers.utils';
|
||||
import { performList } from 'src/utils/triggers/triggers.utils';
|
||||
|
||||
export const listRecordIdsKey = 'list_record_ids';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { findObjectNamesSingularKey } from '../triggers/find_object_names_singular';
|
||||
import { findObjectNamesSingularKey } from 'src/triggers/find_object_names_singular';
|
||||
import {
|
||||
performSubscribe,
|
||||
performUnsubscribe,
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
export enum FieldMetadataType {
|
||||
UUID = 'UUID',
|
||||
TEXT = 'TEXT',
|
||||
PHONES = 'PHONES',
|
||||
EMAILS = 'EMAILS',
|
||||
DATE_TIME = 'DATE_TIME',
|
||||
DATE = 'DATE',
|
||||
BOOLEAN = 'BOOLEAN',
|
||||
NUMBER = 'NUMBER',
|
||||
NUMERIC = 'NUMERIC',
|
||||
LINKS = 'LINKS',
|
||||
CURRENCY = 'CURRENCY',
|
||||
FULL_NAME = 'FULL_NAME',
|
||||
RATING = 'RATING',
|
||||
SELECT = 'SELECT',
|
||||
MULTI_SELECT = 'MULTI_SELECT',
|
||||
RELATION = 'RELATION',
|
||||
MORPH_RELATION = 'MORPH_RELATION',
|
||||
POSITION = 'POSITION',
|
||||
ADDRESS = 'ADDRESS',
|
||||
RAW_JSON = 'RAW_JSON',
|
||||
RICH_TEXT = 'RICH_TEXT',
|
||||
RICH_TEXT_V2 = 'RICH_TEXT_V2',
|
||||
ACTOR = 'ACTOR',
|
||||
ARRAY = 'ARRAY',
|
||||
TS_VECTOR = 'TS_VECTOR',
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { FieldMetadataType } from '../../types/FieldMetadataType';
|
||||
import { computeInputFields } from '../../utils/computeInputFields';
|
||||
import { type InputField } from '../../utils/data.types';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { computeInputFields } from 'src/utils/computeInputFields';
|
||||
import { type InputField } from 'src/utils/data.types';
|
||||
|
||||
describe('computeInputFields', () => {
|
||||
test('should create Person input fields properly', () => {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import handleQueryParams from '../../utils/handleQueryParams';
|
||||
import handleQueryParams from 'src/utils/handleQueryParams';
|
||||
|
||||
describe('utils.handleQueryParams', () => {
|
||||
test('should handle empty values', () => {
|
||||
@@ -1,9 +1,9 @@
|
||||
import { FieldMetadataType } from '../types/FieldMetadataType';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import {
|
||||
type InputField,
|
||||
type Node,
|
||||
type NodeField,
|
||||
} from '../utils/data.types';
|
||||
} from 'src/utils/data.types';
|
||||
|
||||
const getListFromFieldMetadataType = (fieldMetadataType: FieldMetadataType) => {
|
||||
return fieldMetadataType === FieldMetadataType.ARRAY;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type FieldMetadataType } from '../types/FieldMetadataType';
|
||||
import { type FieldMetadataType } from 'twenty-shared/types';
|
||||
|
||||
export type InputData = { [x: string]: any };
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type Bundle } from 'zapier-platform-core';
|
||||
|
||||
import { type InputData } from '../utils/data.types';
|
||||
import { type InputData } from 'src/utils/data.types';
|
||||
|
||||
const getBundle = (inputData?: InputData): Bundle => {
|
||||
export const getBundle = (inputData?: InputData): Bundle => {
|
||||
return {
|
||||
authData: { apiKey: String(process.env.API_KEY) },
|
||||
inputData: inputData || {},
|
||||
@@ -19,4 +19,3 @@ const getBundle = (inputData?: InputData): Bundle => {
|
||||
},
|
||||
};
|
||||
};
|
||||
export default getBundle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type InputData } from '../utils/data.types';
|
||||
import { type InputData } from 'src/utils/data.types';
|
||||
|
||||
const OBJECT_SUBFIELD_NAMES = ['secondaryLinks', 'additionalPhones'];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Bundle, HttpRequestOptions, ZObject } from 'zapier-platform-core';
|
||||
|
||||
import { type Schema } from '../utils/data.types';
|
||||
import { type Schema } from 'src/utils/data.types';
|
||||
|
||||
export const requestSchema = async (
|
||||
z: ZObject,
|
||||
@@ -29,16 +29,20 @@ export const requestSchema = async (
|
||||
}
|
||||
}
|
||||
}`;
|
||||
const endpoint = 'metadata';
|
||||
return await requestDb(z, bundle, query, endpoint);
|
||||
return await requestDb({ z, bundle, query, endpoint: 'metadata' });
|
||||
};
|
||||
|
||||
const requestDb = async (
|
||||
z: ZObject,
|
||||
bundle: Bundle,
|
||||
query: string,
|
||||
const requestDb = async ({
|
||||
z,
|
||||
bundle,
|
||||
query,
|
||||
endpoint = 'graphql',
|
||||
) => {
|
||||
}: {
|
||||
z: ZObject;
|
||||
bundle: Bundle;
|
||||
query: string;
|
||||
endpoint?: string;
|
||||
}) => {
|
||||
const options = {
|
||||
url: `${bundle.authData.apiUrl || process.env.SERVER_BASE_URL}/${endpoint}`,
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type Bundle, type ZObject } from 'zapier-platform-core';
|
||||
|
||||
import handleQueryParams from '../../utils/handleQueryParams';
|
||||
import requestDb, {
|
||||
requestDbViaRestApi,
|
||||
requestSchema,
|
||||
} from '../../utils/requestDb';
|
||||
} from 'src/utils/requestDb';
|
||||
import handleQueryParams from 'src/utils/handleQueryParams';
|
||||
|
||||
export enum DatabaseEventAction {
|
||||
CREATED = 'created',
|
||||
@@ -20,14 +20,14 @@ export const performSubscribe = async (z: ZObject, bundle: Bundle) => {
|
||||
],
|
||||
secret: '',
|
||||
};
|
||||
const result = await requestDb(
|
||||
const result = await requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`mutation createWebhook {createWebhook(input:{${handleQueryParams(
|
||||
query: `mutation createWebhook {createWebhook(input:{${handleQueryParams(
|
||||
data,
|
||||
)}}) {id}}`,
|
||||
'metadata',
|
||||
);
|
||||
endpoint: 'metadata',
|
||||
});
|
||||
return result.data.createWebhook;
|
||||
};
|
||||
|
||||
@@ -36,12 +36,12 @@ export const performUnsubscribe = async (
|
||||
bundle: Bundle,
|
||||
): Promise<boolean> => {
|
||||
const data = { id: bundle.subscribeData?.id };
|
||||
const result = await requestDb(
|
||||
const result = await requestDb({
|
||||
z,
|
||||
bundle,
|
||||
`mutation deleteWebhook {deleteWebhook(input: {${handleQueryParams(data)}})}`,
|
||||
'metadata',
|
||||
);
|
||||
query: `mutation deleteWebhook {deleteWebhook(${handleQueryParams(data)}) {id}}`,
|
||||
endpoint: 'metadata',
|
||||
});
|
||||
return result.data.deleteWebhook;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"target": "es2019",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"lib": ["esnext"],
|
||||
"outDir": "./lib",
|
||||
"rootDir": "./src",
|
||||
"outDir": "lib",
|
||||
"rootDir": ".",
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"paths": {
|
||||
"src/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"jest.config.mjs"
|
||||
]
|
||||
"exclude": ["node_modules", "lib"]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
import tsconfigPaths from 'vite-tsconfig-paths';
|
||||
import packageJson from './package.json';
|
||||
import type { PackageJson } from 'type-fest';
|
||||
|
||||
const entryFileNames = (chunk: any, extension: 'cjs') => {
|
||||
if (!chunk.isEntry) {
|
||||
throw new Error(
|
||||
`Should never occurs, encountered a non entry chunk ${chunk.facadeModuleId}`,
|
||||
);
|
||||
}
|
||||
|
||||
const splitFaceModuleId = chunk.facadeModuleId?.split('/');
|
||||
if (splitFaceModuleId === undefined) {
|
||||
throw new Error(
|
||||
`Should never occurs splitFaceModuleId is undefined ${chunk.facadeModuleId}`,
|
||||
);
|
||||
}
|
||||
|
||||
const moduleDirectory = splitFaceModuleId[splitFaceModuleId?.length - 2];
|
||||
if (moduleDirectory === 'src') {
|
||||
return `${chunk.name}.${extension}`;
|
||||
}
|
||||
return `${moduleDirectory}.${extension}`;
|
||||
};
|
||||
|
||||
export default defineConfig(() => {
|
||||
return {
|
||||
root: __dirname,
|
||||
cacheDir: '../../node_modules/.vite/packages/twenty-zapier',
|
||||
plugins: [
|
||||
tsconfigPaths({
|
||||
root: __dirname,
|
||||
}),
|
||||
],
|
||||
build: {
|
||||
emptyOutDir: false,
|
||||
outDir: 'lib',
|
||||
lib: { entry: 'src/index.ts', name: 'twenty-zapier' },
|
||||
rollupOptions: {
|
||||
external: (id: string) => {
|
||||
if (/^node:/.test(id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const builtins = ['path', 'fs', 'child_process', 'util'];
|
||||
|
||||
if (builtins.includes(id)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const deps = Object.keys(
|
||||
(packageJson as PackageJson).dependencies || {},
|
||||
);
|
||||
|
||||
return deps.some((dep) => id === dep || id.startsWith(dep + '/'));
|
||||
},
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
interop: 'auto',
|
||||
esModule: true,
|
||||
exports: 'named',
|
||||
entryFileNames: (chunk) => entryFileNames(chunk, 'cjs'),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
logLevel: 'warn',
|
||||
};
|
||||
});
|
||||
@@ -59113,6 +59113,10 @@ __metadata:
|
||||
jest: "npm:29.7.0"
|
||||
libphonenumber-js: "npm:^1.10.26"
|
||||
rimraf: "npm:^3.0.2"
|
||||
twenty-shared: "workspace:*"
|
||||
vite: "npm:^7.0.0"
|
||||
vite-plugin-dts: "npm:^4.5.4"
|
||||
vite-tsconfig-paths: "npm:^4.2.1"
|
||||
zapier-platform-cli: "npm:^15.4.1"
|
||||
zapier-platform-core: "npm:15.5.1"
|
||||
zod: "npm:^4.1.11"
|
||||
|
||||
Reference in New Issue
Block a user