1750 extensibility twenty sdk v2 use twenty sdk to define an object (#15230)
We maintain jsonc object definition but will deprecate them pretty soon ## Before <img width="1512" height="575" alt="image" src="https://github.com/user-attachments/assets/d2fa6ca4-c456-4aa9-a1e3-845b61839718" /> ## After <img width="1260" height="555" alt="image" src="https://github.com/user-attachments/assets/ba72f4cf-d443-4967-913c-029bc71f3f48" />
This commit is contained in:
@@ -3,11 +3,13 @@ import { randomUUID } from 'crypto';
|
||||
import * as fs from 'fs-extra';
|
||||
import inquirer from 'inquirer';
|
||||
import path from 'path';
|
||||
import camelcase from 'lodash.camelcase';
|
||||
import { CURRENT_EXECUTION_DIRECTORY } from '../constants/current-execution-directory';
|
||||
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';
|
||||
import { getDecoratedClass } from '../utils/get-decorated-class';
|
||||
|
||||
export enum SyncableEntity {
|
||||
AGENT = 'agent',
|
||||
@@ -56,6 +58,22 @@ export class AppAddCommand {
|
||||
|
||||
const entityData = await this.getEntityToCreateData(entity, entityName);
|
||||
|
||||
if (entity === SyncableEntity.OBJECT) {
|
||||
delete entityData['standardId'];
|
||||
delete entityData['$schema'];
|
||||
|
||||
const objectFileName = `${camelcase(entityName)}.ts`;
|
||||
|
||||
const decoratedObject = getDecoratedClass({
|
||||
data: entityData,
|
||||
name: entityName,
|
||||
});
|
||||
|
||||
await fs.writeFile(path.join(appPath, objectFileName), decoratedObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const folderName = getFolderName(entity);
|
||||
|
||||
const entitiesDir = path.join(appPath, folderName, entityName);
|
||||
|
||||
Reference in New Issue
Block a user