Move schemas to constant folder (#15207)

- move schemas to constants
- increase npm package version
This commit is contained in:
martmull
2025-10-20 15:41:53 +02:00
committed by GitHub
parent 3aa448d951
commit 7723fa70a4
13 changed files with 27 additions and 23 deletions
+1 -1
View File
@@ -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": {
+2 -1
View File
@@ -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"]
@@ -7,6 +7,7 @@ import { CURRENT_EXECUTION_DIRECTORY } from '../constants/current-execution-dire
import { 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);
@@ -1,6 +0,0 @@
import { join } from 'path';
export const BASE_APPLICATION_PROJECT_PATH = join(
__dirname,
'../constants/base-application-project',
);
@@ -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');
+1 -1
View File
@@ -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`;
@@ -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",
@@ -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"
}
}
},
@@ -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",
@@ -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"],
@@ -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": {
@@ -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';
@@ -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) {