move appModel to root dir

This commit is contained in:
Bowen Tan 2021-12-27 15:25:08 +08:00
parent 26300bff0c
commit 6bcee65a54
22 changed files with 40 additions and 43 deletions

View File

@ -1,8 +1,8 @@
import { ApplicationModel } from '../../src/operations/AppModel/AppModel';
import { ApplicationModel } from '../../src/AppModel/AppModel';
import {
ComponentId,
ComponentType,
} from '../../src/operations/AppModel/IAppModel';
} from '../../src/AppModel/IAppModel';
import {AppSchema} from './schema'
describe('AppModel test', () => {

View File

@ -1,10 +1,10 @@
import { ApplicationModel } from '../../src/operations/AppModel/AppModel';
import { ApplicationModel } from '../../src/AppModel/AppModel';
import {
ComponentId,
ComponentType,
SlotName,
TraitType,
} from '../../src/operations/AppModel/IAppModel';
} from '../../src/AppModel/IAppModel';
import { AppSchema } from './schema';
describe('ComponentModel test', () => {

View File

@ -1,5 +1,5 @@
import { ApplicationComponent, RuntimeComponentSpec } from '@sunmao-ui/core';
import { registry } from '../../setup';
import { ApplicationComponent, MethodSchema, RuntimeComponentSpec } from '@sunmao-ui/core';
import { registry } from '../setup';
import { genComponent, genTrait } from './utils';
import {
ComponentId,
@ -8,7 +8,6 @@ import {
IComponentModel,
SlotName,
StyleSlotName,
MethodName,
StateKey,
ITraitModel,
IFieldModel,
@ -76,10 +75,10 @@ export class ComponentModel implements IComponentModel {
get methods() {
if (!this.spec) return [];
const componentMethods = this.spec.spec.methods as any;
const traitMethods: MethodName[] = this.traits.reduce(
const componentMethods = this.spec.spec.methods;
const traitMethods: MethodSchema[] = this.traits.reduce(
(acc, t) => acc.concat(t.methods),
[] as any
[] as MethodSchema[]
);
return [...componentMethods, ...traitMethods];
}

View File

@ -1,5 +1,4 @@
import { JSONSchema7 } from 'json-schema';
import { ApplicationComponent, ComponentTrait } from '@sunmao-ui/core';
import { ApplicationComponent, ComponentTrait, MethodSchema } from '@sunmao-ui/core';
export type ComponentId = string & {
kind: 'componentId';
@ -68,7 +67,7 @@ export interface IComponentModel {
stateKeys: StateKey[];
slots: SlotName[];
styleSlots: StyleSlotName[];
methods: Array<{name: MethodName, parameters: JSONSchema7}>;
methods: MethodSchema[];
events: EventName[];
allComponents: IComponentModel[];
nextSilbing: IComponentModel | null;
@ -98,7 +97,7 @@ export interface ITraitModel {
type: TraitType;
rawProperties: Record<string, any>;
properties: Record<string, IFieldModel>;
methods: Array<{name: MethodName, parameters: JSONSchema7}>;
methods: MethodSchema[];
stateKeys: StateKey[];
_isDirty: boolean;
toSchema(): ComponentTrait;

View File

@ -1,8 +1,7 @@
import { ComponentTrait, RuntimeTraitSpec } from '@sunmao-ui/core';
import { registry } from '../../setup';
import { registry } from '../setup';
import {
IComponentModel,
MethodName,
TraitType,
ITraitModel,
IFieldModel,
@ -44,7 +43,7 @@ export class TraitModel implements ITraitModel {
}
get methods() {
return this.spec ? this.spec.spec.methods as any : []
return this.spec ? this.spec.spec.methods : []
}
get stateKeys() {

View File

@ -1,5 +1,5 @@
import { ApplicationComponent, ComponentTrait } from '@sunmao-ui/core';
import { registry } from '../../setup';
import { registry } from '../setup';
export function genComponent(
type: string,

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import produce from 'immer';
import { ComponentId, SlotName } from '../AppModel/IAppModel';
import { ComponentId, SlotName } from '../../AppModel/IAppModel';
import {
CreateComponentLeafOperation,
ModifyComponentPropertiesLeafOperation,

View File

@ -1,7 +1,7 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import produce from 'immer';
import { ApplicationModel } from '../AppModel/AppModel';
import { ComponentId } from '../AppModel/IAppModel';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId } from '../../AppModel/IAppModel';
import {
ModifyComponentPropertiesLeafOperation,
RemoveComponentLeafOperation,

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type AdjustComponentOrderLeafOperationContext = {
orientation: 'up' | 'down';

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId, ComponentType, IComponentModel, SlotName } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId, ComponentType, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type CreateComponentLeafOperationContext = {

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type ModifyComponentIdLeafOperationContext = {

View File

@ -1,8 +1,8 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { BaseLeafOperation } from '../../type';
import _ from 'lodash-es';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId } from '../../../AppModel/IAppModel';
export type ModifyComponentPropertiesLeafOperationContext = {
componentId: string;
properties: Record<string, any | (<T = any>(prev: T) => T)>;

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId, IComponentModel, SlotName } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type PasteComponentLeafOperationContext = {

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId, IComponentModel, SlotName } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type RemoveComponentLeafOperationContext = {

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId, TraitId, TraitType } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId, TraitId, TraitType } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type CreateTraitLeafOperationContext = {

View File

@ -1,8 +1,8 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import _ from 'lodash-es';
import { BaseLeafOperation } from '../../type';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId } from '../../../AppModel/IAppModel';
export type ModifyTraitPropertiesLeafOperationContext = {
componentId: string;

View File

@ -1,6 +1,6 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { ApplicationModel } from '../../AppModel/AppModel';
import { ComponentId, ITraitModel } from '../../AppModel/IAppModel';
import { ApplicationModel } from '../../../AppModel/AppModel';
import { ComponentId, ITraitModel } from '../../../AppModel/IAppModel';
import { BaseLeafOperation } from '../../type';
export type RemoveTraitLeafOperationContext = {

View File

@ -1,7 +1,7 @@
import { ApplicationComponent, RuntimeComponentSpec } from '@sunmao-ui/core';
import { Registry } from '@sunmao-ui/runtime';
import Ajv from 'ajv';
import { ApplicationModel } from '../operations/AppModel/AppModel';
import { ApplicationModel } from '../AppModel/AppModel';
import {
ISchemaValidator,
ComponentValidatorRule,

View File

@ -1,7 +1,7 @@
import { ApplicationComponent } from '@sunmao-ui/core';
import { Registry } from '@sunmao-ui/runtime';
import Ajv, { ValidateFunction } from 'ajv';
import { IApplicationModel, IComponentModel, ITraitModel } from '../operations/AppModel/IAppModel';
import { IApplicationModel, IComponentModel, ITraitModel } from '../AppModel/IAppModel';
export interface ValidatorMap {
components: Record<string, ValidateFunction>;
@ -12,7 +12,7 @@ interface BaseValidateContext {
validators: ValidatorMap;
registry: Registry;
appModel: IApplicationModel;
ajv: Ajv
ajv: Ajv;
}
export interface ComponentValidateContext extends BaseValidateContext {

View File

@ -6,7 +6,7 @@ import {
} from '../interfaces';
import { EventHandlerSchema } from '@sunmao-ui/runtime';
import { isExpression } from '../utils';
import { ComponentId, EventName } from '../../operations/AppModel/IAppModel';
import { ComponentId, EventName } from '../../AppModel/IAppModel';
class TraitPropertyValidatorRule implements TraitValidatorRule {
kind: 'trait' = 'trait';