refactor: 将data-source,dep,schema,utils收敛到core,将form,table,stage,design,util收敛到editor
This commit is contained in:
@@ -33,15 +33,12 @@
|
||||
"data-source"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tmagic/dep": "workspace:*",
|
||||
"deep-state-observer": "^5.5.13",
|
||||
"events": "^3.3.0",
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tmagic/core": "workspace:*",
|
||||
"@tmagic/schema": "workspace:*",
|
||||
"@tmagic/utils": "workspace:*",
|
||||
"typescript": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
|
||||
@@ -20,9 +20,8 @@ import EventEmitter from 'events';
|
||||
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import type { default as TMagicApp } from '@tmagic/core';
|
||||
import type { DataSourceSchema, DisplayCond, Id, MNode, NODE_CONDS_KEY } from '@tmagic/schema';
|
||||
import { compiledNode } from '@tmagic/utils';
|
||||
import type { DataSourceSchema, default as TMagicApp, DisplayCond, Id, MNode, NODE_CONDS_KEY } from '@tmagic/core';
|
||||
import { compiledNode } from '@tmagic/core';
|
||||
|
||||
import { SimpleObservedData } from './observed-data/SimpleObservedData';
|
||||
import { DataSource, HttpDataSource } from './data-sources';
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import { union } from 'lodash-es';
|
||||
|
||||
import type { default as TMagicApp } from '@tmagic/core';
|
||||
import { getDepNodeIds, getNodes, isPage } from '@tmagic/utils';
|
||||
import { getDepNodeIds, getNodes, isPage } from '@tmagic/core';
|
||||
|
||||
import DataSourceManager from './DataSourceManager';
|
||||
import type { ChangeEvent, DataSourceManagerData } from './types';
|
||||
|
||||
@@ -19,9 +19,8 @@ import EventEmitter from 'events';
|
||||
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import type { default as TMagicApp } from '@tmagic/core';
|
||||
import type { CodeBlockContent, DataSchema, DataSourceSchema } from '@tmagic/schema';
|
||||
import { getDefaultValueFromFields } from '@tmagic/utils';
|
||||
import type { CodeBlockContent, DataSchema, DataSourceSchema, default as TMagicApp } from '@tmagic/core';
|
||||
import { getDefaultValueFromFields } from '@tmagic/core';
|
||||
|
||||
import { ObservedData } from '@data-source/observed-data/ObservedData';
|
||||
import { SimpleObservedData } from '@data-source/observed-data/SimpleObservedData';
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { HttpOptions, RequestFunction } from '@tmagic/schema';
|
||||
import { getValueByKeyPath } from '@tmagic/utils';
|
||||
import type { HttpOptions, RequestFunction } from '@tmagic/core';
|
||||
import { getValueByKeyPath } from '@tmagic/core';
|
||||
|
||||
import { DataSourceOptions, HttpDataSourceSchema } from '@data-source/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { isDataSourceCondTarget, isDataSourceTarget, Target, Watcher } from '@tmagic/dep';
|
||||
import type { DataSourceSchema, MNode } from '@tmagic/schema';
|
||||
import { DSL_NODE_KEY_COPY_PREFIX } from '@tmagic/utils';
|
||||
import type { DataSourceSchema, MNode } from '@tmagic/core';
|
||||
import { DSL_NODE_KEY_COPY_PREFIX, isDataSourceCondTarget, isDataSourceTarget, Target, Watcher } from '@tmagic/core';
|
||||
|
||||
const cache = new Map();
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export { default as DataSourceManager } from './DataSourceManager';
|
||||
export * from './data-sources';
|
||||
export * from './createDataSourceManager';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
import { getValueByKeyPath, setValueByKeyPath } from '@tmagic/utils';
|
||||
import { getValueByKeyPath, setValueByKeyPath } from '@tmagic/core';
|
||||
|
||||
import { ObservedData } from './ObservedData';
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { default as TMagicApp } from '@tmagic/core';
|
||||
import type { DataSourceSchema, HttpOptions, RequestFunction } from '@tmagic/schema';
|
||||
import type { DataSourceSchema, default as TMagicApp, HttpOptions, RequestFunction } from '@tmagic/core';
|
||||
|
||||
import type DataSource from './data-sources/Base';
|
||||
import type HttpDataSource from './data-sources/Http';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
|
||||
import type { DepData, DisplayCond, DisplayCondItem, MApp, MNode, MPage, MPageFragment } from '@tmagic/schema';
|
||||
import { NODE_CONDS_KEY } from '@tmagic/schema';
|
||||
import type { DepData, DisplayCond, DisplayCondItem, MApp, MNode, MPage, MPageFragment } from '@tmagic/core';
|
||||
import {
|
||||
compiledCond,
|
||||
compiledNode,
|
||||
@@ -10,8 +9,9 @@ import {
|
||||
getValueByKeyPath,
|
||||
isPage,
|
||||
isPageFragment,
|
||||
NODE_CONDS_KEY,
|
||||
replaceChildNode,
|
||||
} from '@tmagic/utils';
|
||||
} from '@tmagic/core';
|
||||
|
||||
import type { AsyncDataSourceResolveResult, DataSourceManagerData } from './types';
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import App from '@tmagic/core';
|
||||
import { NodeType } from '@tmagic/schema';
|
||||
import TMagicApp, { NodeType } from '@tmagic/core';
|
||||
|
||||
import { DataSource, DataSourceManager } from '@data-source/index';
|
||||
|
||||
const app = new App({
|
||||
const app = new TMagicApp({
|
||||
config: {
|
||||
type: NodeType.ROOT,
|
||||
id: '1',
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
import { MApp, NodeType } from '@tmagic/schema';
|
||||
import TMagicApp, { type MApp, NodeType } from '@tmagic/core';
|
||||
|
||||
import { createDataSourceManager, DataSourceManager } from '@data-source/index';
|
||||
|
||||
class Core {
|
||||
public dsl?: MApp;
|
||||
|
||||
constructor(options: any) {
|
||||
this.dsl = options.config;
|
||||
}
|
||||
}
|
||||
|
||||
const dsl: MApp = {
|
||||
type: NodeType.ROOT,
|
||||
id: 'app_1',
|
||||
@@ -46,13 +38,14 @@ const dsl: MApp = {
|
||||
},
|
||||
],
|
||||
methods: [],
|
||||
events: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe('createDataSourceManager', () => {
|
||||
test('instance', () => {
|
||||
const manager = createDataSourceManager(new Core({ config: dsl }));
|
||||
const manager = createDataSourceManager(new TMagicApp({ config: dsl }));
|
||||
expect(manager).toBeInstanceOf(DataSourceManager);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user