[OBJECT_MANIFEST_BREAKING_CHANGE] Sync returns workspace migration (#17918)
# Introduction In this PR we start returning a workspace migration post sync so it can committed and provided within the tarball ## Universal aggregators utils Created two utils ### deleteUniversalFlatEntityForeignKeyAggregators Used when building a universal create action, a newly created actions should not contain any aggregated foreign key so they won't be codegen in the workspace migration but also they are overriden at uninversal to flat transpilation anw ### resetUniversalFlatEntityForeignKeyAggregators Used before validating a new flat entity creation, some validator will consume the fk aggregator in order to validate integrity, but of optimstically provided it can result to errors. To avoid caller responsability we override them here ## create-field-action refactor Refactored the universal and flat field create action to be following the base actions in order to ease typing Also it was tailored to handle unlimited amount of flat field metadata in the same actions whereas in the reality we were always only sending at max 2 ( for relation fields ) Note: relation field has to be provided at the same as if not optimistic would fail to retrieve circular universal identifiers ## ObjectManifest Now always expect a `labelIdentifierFieldMetadataUniversalIdentifier` ## Integration test Created an integration test that creates an app, sync a first manifest and a second implying update workspace migration action generation
This commit is contained in:
@@ -10,6 +10,8 @@ export default defineObject({
|
||||
labelPlural: 'First objects',
|
||||
description: 'First object with duplicate ID',
|
||||
icon: 'IconBox',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'first-field-0000-0000-000000000001',
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: 'first-field-0000-0000-000000000001',
|
||||
|
||||
@@ -10,6 +10,8 @@ export default defineObject({
|
||||
labelPlural: 'Second objects',
|
||||
description: 'Second object with duplicate ID',
|
||||
icon: 'IconBox',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'second-field-0000-0000-000000000001',
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: 'second-field-0000-0000-000000000001',
|
||||
|
||||
+4
@@ -123,6 +123,8 @@ export const EXPECTED_MANIFEST: Manifest = {
|
||||
},
|
||||
],
|
||||
icon: 'IconNote',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'b0b1b2b3-b4b5-4000-8000-000000000002',
|
||||
labelPlural: 'Root notes',
|
||||
labelSingular: 'Root note',
|
||||
namePlural: 'rootNotes',
|
||||
@@ -199,6 +201,8 @@ export const EXPECTED_MANIFEST: Manifest = {
|
||||
},
|
||||
],
|
||||
icon: 'IconMail',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'58a0a314-d7ea-4865-9850-7fb84e72f30b',
|
||||
labelPlural: 'Post cards',
|
||||
labelSingular: 'Post card',
|
||||
namePlural: 'postCards',
|
||||
|
||||
@@ -20,6 +20,8 @@ export default defineObject({
|
||||
labelPlural: 'Post cards',
|
||||
description: 'A post card object',
|
||||
icon: 'IconMail',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
CONTENT_FIELD_UNIVERSAL_IDENTIFIER,
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: CONTENT_FIELD_UNIVERSAL_IDENTIFIER,
|
||||
|
||||
@@ -8,6 +8,8 @@ export default defineObject({
|
||||
labelPlural: 'Root notes',
|
||||
description: 'A simple root-level object',
|
||||
icon: 'IconNote',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'b0b1b2b3-b4b5-4000-8000-000000000002',
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: 'b0b1b2b3-b4b5-4000-8000-000000000002',
|
||||
|
||||
+2
@@ -22,6 +22,8 @@ export const EXPECTED_MANIFEST: Manifest = {
|
||||
labelPlural: 'My notes',
|
||||
description: 'A simple root-level object',
|
||||
icon: 'IconNote',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'e1e2e3e4-e5e6-4000-8000-000000000031',
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: 'e1e2e3e4-e5e6-4000-8000-000000000031',
|
||||
|
||||
@@ -8,6 +8,8 @@ export default defineObject({
|
||||
labelPlural: 'My notes',
|
||||
description: 'A simple root-level object',
|
||||
icon: 'IconNote',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
'e1e2e3e4-e5e6-4000-8000-000000000031',
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: 'e1e2e3e4-e5e6-4000-8000-000000000031',
|
||||
|
||||
+1
@@ -157,6 +157,7 @@ describe('manifestValidate', () => {
|
||||
namePlural: 'myObjects',
|
||||
labelSingular: 'My Object',
|
||||
labelPlural: 'My Objects',
|
||||
labelIdentifierFieldMetadataUniversalIdentifier: sharedId,
|
||||
fields: [
|
||||
{
|
||||
universalIdentifier: sharedId,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type FrontComponentConfig,
|
||||
type LogicFunctionConfig,
|
||||
} from '@/sdk';
|
||||
import { type ObjectConfig } from '@/sdk/objects/object-config';
|
||||
import { glob } from 'fast-glob';
|
||||
import { readFile } from 'fs-extra';
|
||||
import { basename, extname, relative } from 'path';
|
||||
@@ -24,8 +25,8 @@ import {
|
||||
type ObjectManifest,
|
||||
type RoleManifest,
|
||||
} from 'twenty-shared/application';
|
||||
import { assertUnreachable } from 'twenty-shared/utils';
|
||||
import { getInputSchemaFromSourceCode } from 'twenty-shared/logic-function';
|
||||
import { assertUnreachable } from 'twenty-shared/utils';
|
||||
|
||||
const loadSources = async (appPath: string): Promise<string[]> => {
|
||||
return await glob(['**/*.ts', '**/*.tsx'], {
|
||||
@@ -98,11 +99,23 @@ export const buildManifest = async (
|
||||
break;
|
||||
}
|
||||
case ManifestEntityKey.Objects: {
|
||||
const extract = await extractManifestFromFile<ObjectManifest>({
|
||||
const extract = await extractManifestFromFile<ObjectConfig>({
|
||||
appPath,
|
||||
filePath,
|
||||
});
|
||||
objects.push(extract.config);
|
||||
|
||||
const { labelIdentifierFieldMetadataUniversalIdentifier, ...rest } =
|
||||
extract.config;
|
||||
|
||||
const objectManifest: ObjectManifest = {
|
||||
...rest,
|
||||
labelIdentifierFieldMetadataUniversalIdentifier:
|
||||
// TODO replace by system id universal identifier once we've refactored it
|
||||
labelIdentifierFieldMetadataUniversalIdentifier ?? '',
|
||||
};
|
||||
|
||||
objects.push(objectManifest);
|
||||
|
||||
errors.push(...extract.errors);
|
||||
objectsFilePaths.push(relativePath);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user