The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Move schemas to constant folder (#15207)
martmull7723fa70a469
diff --git a/packages/twenty-cli/package.json b/packages/twenty-cli/package.jsonindex 1eb6494b47d..3a49f659597 100644--- a/packages/twenty-cli/package.json+++ b/packages/twenty-cli/package.json@@ -1,6 +1,6 @@{"name": "twenty-cli",- "version": "0.1.2-beta",+ "version": "0.1.2-gamma","description": "Command-line interface for Twenty application development","main": "dist/cli.js","bin": {diff --git a/packages/twenty-cli/project.json b/packages/twenty-cli/project.jsonindex d8fce929b93..26aed8e04ad 100644--- a/packages/twenty-cli/project.json+++ b/packages/twenty-cli/project.json@@ -19,7 +19,8 @@"options": {"cwd": "packages/twenty-cli","commands": [- "cp -R src/constants/base-application-project dist/constants"+ "cp -R src/constants/base-application-project dist/constants",+ "cp -R src/constants/schemas dist/constants"]},"dependsOn": ["after-build"]diff --git a/packages/twenty-cli/src/commands/app-add.command.ts b/packages/twenty-cli/src/commands/app-add.command.tsindex 0fde5bcbb89..db88709e85b 100644--- a/packages/twenty-cli/src/commands/app-add.command.ts+++ b/packages/twenty-cli/src/commands/app-add.command.ts@@ -7,6 +7,7 @@ import { CURRENT_EXECUTION_DIRECTORY } from '../constants/current-execution-direimport { HTTPMethod } from '../types/config.types';import { parseJsoncFile, writeJsoncFile } from '../utils/jsonc-parser';import { getSchemaUrls } from '../utils/schema-validator';+import { BASE_SCHEMAS_PATH } from '../constants/constants-path';export enum SyncableEntity {AGENT = 'agent',@@ -156,9 +157,7 @@ export class AppAddCommand {entityToCreateData.standardId = uuid;}- const schemasDir = path.join(__dirname, '../../schemas');-- const schemaPath = path.join(schemasDir, `${entity}.schema.json`);+ const schemaPath = path.join(BASE_SCHEMAS_PATH, `${entity}.schema.json`);const schema = await fs.readJson(schemaPath);diff --git a/packages/twenty-cli/src/constants/base-application-project-path.ts b/packages/twenty-cli/src/constants/base-application-project-path.tsdeleted file mode 100644index fa694131a9a..00000000000--- a/packages/twenty-cli/src/constants/base-application-project-path.ts+++ /dev/null@@ -1,6 +0,0 @@-import { join } from 'path';--export const BASE_APPLICATION_PROJECT_PATH = join(- __dirname,- '../constants/base-application-project',-);diff --git a/packages/twenty-cli/src/constants/constants-path.ts b/packages/twenty-cli/src/constants/constants-path.tsnew file mode 100644index 00000000000..82d7a5a6ace--- /dev/null+++ b/packages/twenty-cli/src/constants/constants-path.ts@@ -0,0 +1,10 @@+import { join } from 'path';++const BASE_PATH = join(__dirname, '../constants');++export const BASE_APPLICATION_PROJECT_PATH = join(+ BASE_PATH,+ 'base-application-project',+);++export const BASE_SCHEMAS_PATH = join(BASE_PATH, 'schemas');diff --git a/packages/twenty-cli/src/constants/schemas.ts b/packages/twenty-cli/src/constants/schemas.tsindex 39dbbdebbfe..988bbcae5ee 100644--- a/packages/twenty-cli/src/constants/schemas.ts+++ b/packages/twenty-cli/src/constants/schemas.ts@@ -1,5 +1,5 @@const SCHEMA_BASE_URL =- 'https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas';+ 'https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas';export const APP_MANIFEST_SCHEMA_URL = `${SCHEMA_BASE_URL}/appManifest.schema.json`;export const AGENT_SCHEMA_URL = `${SCHEMA_BASE_URL}/agent.schema.json`;diff --git a/packages/twenty-cli/schemas/agent.schema.json b/packages/twenty-cli/src/constants/schemas/agent.schema.jsonsimilarity index 98%rename from packages/twenty-cli/schemas/agent.schema.jsonrename to packages/twenty-cli/src/constants/schemas/agent.schema.jsonindex a2cae83d345..d173dc28c8b 100644--- a/packages/twenty-cli/schemas/agent.schema.json+++ b/packages/twenty-cli/src/constants/schemas/agent.schema.json@@ -1,6 +1,6 @@{"$schema": "http://json-schema.org/draft-07/schema#",- "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/agent.schema.json",+ "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/agent.schema.json","title": "Twenty Agent Manifest","description": "Schema for Twenty AI agent configuration files","type": "object",diff --git a/packages/twenty-cli/schemas/appManifest.schema.json b/packages/twenty-cli/src/constants/schemas/appManifest.schema.jsonsimilarity index 95%rename from packages/twenty-cli/schemas/appManifest.schema.jsonrename to packages/twenty-cli/src/constants/schemas/appManifest.schema.jsonindex 410e9b60c5d..2e70fec378b 100644--- a/packages/twenty-cli/schemas/appManifest.schema.json+++ b/packages/twenty-cli/src/constants/schemas/appManifest.schema.json@@ -1,6 +1,6 @@{"$schema": "http://json-schema.org/draft-07/schema#",- "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/appManifest.schema.json",+ "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/appManifest.schema.json","title": "Twenty App Manifest","description": "Schema for Twenty application manifest files","type": "object",@@ -94,7 +94,7 @@"items": {"type": "object","description": "Inline agent definition",- "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/agent.schema.json"+ "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/agent.schema.json"}},"objects": {@@ -103,7 +103,7 @@"items": {"type": "object","description": "Inline object definition",- "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/object.schema.json"+ "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/object.schema.json"}}},diff --git a/packages/twenty-cli/schemas/object.schema.json b/packages/twenty-cli/src/constants/schemas/object.schema.jsonsimilarity index 97%rename from packages/twenty-cli/schemas/object.schema.jsonrename to packages/twenty-cli/src/constants/schemas/object.schema.jsonindex 2354f7bbae4..d11839ad509 100644--- a/packages/twenty-cli/schemas/object.schema.json+++ b/packages/twenty-cli/src/constants/schemas/object.schema.json@@ -1,6 +1,6 @@{"$schema": "http://json-schema.org/draft-07/schema#",- "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/object.schema.json",+ "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/object.schema.json","title": "Twenty Object Manifest","description": "Schema for Twenty AI object configuration files","type": "object",diff --git a/packages/twenty-cli/schemas/serverlessFunction.schema.json b/packages/twenty-cli/src/constants/schemas/serverlessFunction.schema.jsonsimilarity index 95%rename from packages/twenty-cli/schemas/serverlessFunction.schema.jsonrename to packages/twenty-cli/src/constants/schemas/serverlessFunction.schema.jsonindex 7d52216f186..e2de1574355 100644--- a/packages/twenty-cli/schemas/serverlessFunction.schema.json+++ b/packages/twenty-cli/src/constants/schemas/serverlessFunction.schema.json@@ -1,6 +1,6 @@{"$schema": "http://json-schema.org/draft-07/schema#",- "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/serverlessFunction.schema.json",+ "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/serverlessFunction.schema.json","title": "Twenty Serverless Function Manifest","description": "Schema for Twenty AI serverless function configuration files","type": "object",@@ -41,7 +41,7 @@"description": "Serverless function's triggers","items": {"anyOf": [- { "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/trigger.schema.json" },+ { "$ref": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/trigger.schema.json" },{"type": "object","required": ["$ref"],diff --git a/packages/twenty-cli/schemas/trigger.schema.json b/packages/twenty-cli/src/constants/schemas/trigger.schema.jsonsimilarity index 94%rename from packages/twenty-cli/schemas/trigger.schema.jsonrename to packages/twenty-cli/src/constants/schemas/trigger.schema.jsonindex 7ee88f13c43..1d1e5db4e13 100644--- a/packages/twenty-cli/schemas/trigger.schema.json+++ b/packages/twenty-cli/src/constants/schemas/trigger.schema.json@@ -1,5 +1,5 @@{- "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/schemas/trigger.schema.json",+ "$id": "https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-cli/src/constants/schemas/trigger.schema.json","type": "object","required": ["universalIdentifier", "type"],"properties": {diff --git a/packages/twenty-cli/src/utils/app-template.ts b/packages/twenty-cli/src/utils/app-template.tsindex 5dd0957329f..59eb28bc069 100644--- a/packages/twenty-cli/src/utils/app-template.ts+++ b/packages/twenty-cli/src/utils/app-template.ts@@ -1,7 +1,7 @@import { randomUUID } from 'crypto';import { getSchemaUrls } from './schema-validator';import * as fs from 'fs-extra';-import { BASE_APPLICATION_PROJECT_PATH } from '../constants/base-application-project-path';+import { BASE_APPLICATION_PROJECT_PATH } from '../constants/constants-path';import { writeJsoncFile } from '../utils/jsonc-parser';import { join } from 'path';import path from 'path';diff --git a/packages/twenty-cli/src/utils/schema-validator.ts b/packages/twenty-cli/src/utils/schema-validator.tsindex 6eedf577f67..1dbc82ad325 100644--- a/packages/twenty-cli/src/utils/schema-validator.ts+++ b/packages/twenty-cli/src/utils/schema-validator.ts@@ -8,6 +8,7 @@ import {SERVERLESS_FUNCTION_SCHEMA_URL,TRIGGER_SCHEMA_URL,} from '../constants/schemas';+import { BASE_SCHEMAS_PATH } from '../constants/constants-path';export class SchemaValidationError extends Error {constructor(@@ -49,8 +50,7 @@ export const validateSchema = async (let schema;for (const name of Object.keys(schemaUrls) as (keyof typeof schemaUrls)[]) {- const schemasDir = path.join(__dirname, '../../schemas');- const schemaPath = path.join(schemasDir, `${name}.schema.json`);+ const schemaPath = path.join(BASE_SCHEMAS_PATH, `${name}.schema.json`);ajv.addSchema(await fs.readJson(schemaPath));if (name === schemaName) {