feat: workspace sync (#3505)
* feat: wip workspace sync * feat: wip lot of debugging * feat: refactor and fix sync * fix: clean fix: clean * feat: add simple comparator tests * fix: remove debug * feat: wip drop table * fix: main merge * fix: some issues, and prepare storage system to handle complex deletion * feat: wip clean and fix * fix: reflect issue when using array instead of map and clean * fix: test & sync * fix: yarn files * fix: unecesary if-else * fix: if condition not needed * fix: remove debug * fix: replace EQUAL by SKIP * fix: sync metadata relation not applied properly * fix: lint issues * fix: merge issue
This commit is contained in:
@ -0,0 +1,46 @@
|
||||
import { FieldMetadataEntity } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
import { RelationMetadataEntity } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
|
||||
import { PartialFieldMetadata } from './partial-field-metadata.interface';
|
||||
import { PartialObjectMetadata } from './partial-object-metadata.interface';
|
||||
|
||||
export const enum ComparatorAction {
|
||||
SKIP = 'SKIP',
|
||||
CREATE = 'CREATE',
|
||||
UPDATE = 'UPDATE',
|
||||
DELETE = 'DELETE',
|
||||
}
|
||||
|
||||
export interface ComparatorSkipResult {
|
||||
action: ComparatorAction.SKIP;
|
||||
}
|
||||
|
||||
export interface ComparatorCreateResult<T> {
|
||||
action: ComparatorAction.CREATE;
|
||||
object: T;
|
||||
}
|
||||
|
||||
export interface ComparatorUpdateResult<T> {
|
||||
action: ComparatorAction.UPDATE;
|
||||
object: T;
|
||||
}
|
||||
|
||||
export interface ComparatorDeleteResult<T> {
|
||||
action: ComparatorAction.DELETE;
|
||||
object: T;
|
||||
}
|
||||
|
||||
export type ObjectComparatorResult =
|
||||
| ComparatorSkipResult
|
||||
| ComparatorCreateResult<PartialObjectMetadata>
|
||||
| ComparatorUpdateResult<Partial<PartialObjectMetadata>>;
|
||||
|
||||
export type FieldComparatorResult =
|
||||
| ComparatorSkipResult
|
||||
| ComparatorCreateResult<PartialFieldMetadata>
|
||||
| ComparatorUpdateResult<Partial<PartialFieldMetadata> & { id: string }>
|
||||
| ComparatorDeleteResult<FieldMetadataEntity>;
|
||||
|
||||
export type RelationComparatorResult =
|
||||
| ComparatorCreateResult<Partial<RelationMetadataEntity>>
|
||||
| ComparatorDeleteResult<RelationMetadataEntity>;
|
||||
@ -2,6 +2,7 @@ import { PartialFieldMetadata } from 'src/workspace/workspace-sync-metadata/inte
|
||||
import { ReflectObjectMetadata } from 'src/workspace/workspace-sync-metadata/interfaces/reflect-object-metadata.interface';
|
||||
|
||||
export type PartialObjectMetadata = ReflectObjectMetadata & {
|
||||
id?: string;
|
||||
workspaceId: string;
|
||||
dataSourceId: string;
|
||||
fields: PartialFieldMetadata[];
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { FieldMetadataDefaultValue } from 'src/metadata/field-metadata/interfaces/field-metadata-default-value.interface';
|
||||
import { GateDecoratorParams } from 'src/workspace/workspace-sync-metadata/interfaces/gate-decorator.interface';
|
||||
import { FieldMetadataOptions } from 'src/metadata/field-metadata/interfaces/field-metadata-options.interface';
|
||||
import { FieldMetadataTargetColumnMap } from 'src/metadata/field-metadata/interfaces/field-metadata-target-column-map.interface';
|
||||
|
||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||
|
||||
@ -23,13 +24,13 @@ export interface ReflectFieldMetadata {
|
||||
> & {
|
||||
name: string;
|
||||
type: FieldMetadataType;
|
||||
targetColumnMap: string;
|
||||
targetColumnMap: FieldMetadataTargetColumnMap<'default'>;
|
||||
isNullable: boolean;
|
||||
isSystem: boolean;
|
||||
isCustom: boolean;
|
||||
description?: string;
|
||||
defaultValue: string | null;
|
||||
defaultValue: FieldMetadataDefaultValue<'default'> | null;
|
||||
gate?: GateDecoratorParams;
|
||||
options?: string | null;
|
||||
options?: FieldMetadataOptions<'default'> | null;
|
||||
};
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
export interface WorkspaceSyncContext {
|
||||
workspaceId: string;
|
||||
dataSourceId: string;
|
||||
}
|
||||
Reference in New Issue
Block a user