breeze-client icon indicating copy to clipboard operation
breeze-client copied to clipboard

Migration from 1.x Documentation Incomplete

Open Prinsn opened this issue 3 years ago • 13 comments

I'm currently in the process of migrating from Net Core 3.x to 5.0 and while it seems my backend is fully functional, my frontend (which, to be fair, is inherited) is having some problems.

My presumption is that by upgrading the BreezePersistanceManager and not the Breezeclient might lead to a problem, and so I am trying to upgrade the breeze-client.

However, the documentation appears to be incomplete as to the degree of changes, one of the most obvious ones is that the IProperty interface no longer exists, which seems like a pretty huge migration for anything that extends or uses this to not have a major replacement.

Further, the package itself fails compilation in Angular 7 (trying to upgrade one thing at a time, not sure if this is a failure point) giving

    ERROR in node_modules/breeze-client/src/entity-metadata.d.ts(936,9): error TS1086: An accessor cannot be declared in an ambient context.

So it is unclear how someone should mitigate these things when migrating.

Sample snippet that is giving a majority of the problems

//Original code being migrated without modification just as an example of where a singular point of difficulty lies
import { Entity, EntityType, IProperty, EntityAspect, EntityStateSymbol, MetadataStore, PropertyChangedEventArgs, EntityError, HttpResponse } from "breeze-client";

export interface MetaEntityType extends EntityType {
    displayName: string;
    meta: MetaInfo;
    props: {};
}

export interface MetaProperty extends IProperty {
    displayName: string;
    meta: MetaInfo;
}

//...
import { BreezeValidatorsService } from '../breeze-validators/breeze-validators.service';
import DefaultBreezeValidators from '../breeze-validators/default-breeze-validators';
import * as breeze from 'breeze-client';
import 'breeze-client-labs/breeze.savequeuing';

    private parseAnnotatedMetadata(data: Array<AnnotatedMetadata>) {
        const entityManager = this.masterManager;
        const metadataStore = entityManager.metadataStore;

        data.forEach((metaEntity: AnnotatedMetadata) => {
            const entityType = <MetaEntityType>metadataStore.getEntityType(metaEntity.key, true);

            if (entityType) {
                metadataStore[entityType.shortName] = function () {
                    return entityType;
                };

                entityType.displayName = metaEntity.value.meta.displayName;
                entityType.meta = metaEntity.value.meta;
                entityType.props = {};

                const entityProps = <MetaProperty[]>entityType.getProperties();
                entityProps.forEach((entityProp: MetaProperty) => {
                    entityType.props[entityProp.name] = function () {
                        return entityProp;
                    };

                    const metaProp = metaEntity.value.properties[entityProp.name];

                    if (metaProp) {
                        entityProp.displayName = metaProp.displayName;
                        entityProp.meta = metaProp;

                        DefaultBreezeValidators.setupEFValidators(entityProp.validators, entityProp.meta);
                    }
                }, this);
            }
        });

        this.breezeValidators.setupCustomValidators(data, entityManager);
    }

Prinsn avatar Apr 08 '21 16:04 Prinsn