From cc40dfd72797621035e713d12f090a056dc50f6e Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Fri, 28 Jun 2024 16:12:13 +0800 Subject: [PATCH 1/3] 5.2.6-dev --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4176c12f..6dda00ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oak-frontend-base", - "version": "5.2.5", + "version": "5.2.6", "description": "oak框架中前端与业务逻辑无关的平台部分", "author": { "name": "XuChang" @@ -23,9 +23,9 @@ "keepalive-for-react": "^2.0.7", "node-schedule": "^2.1.1", "nprogress": "^0.2.0", - "oak-common-aspect": "~3.0.0", - "oak-domain": "~5.0.13", - "oak-memory-tree-store": "~3.3.1", + "oak-common-aspect": "file:../oak-common-aspect", + "oak-domain": "file:../oak-domain", + "oak-memory-tree-store": "file:../oak-memory-tree-store", "ol": "^7.3.0", "react-activation": "^0.12.4", "react-native-device-info": "^10.12.0", From c735a7462337036288a525f4b1c7f8b311378b97 Mon Sep 17 00:00:00 2001 From: wenjiarui Date: Fri, 28 Jun 2024 17:55:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?runningTree=E9=87=8D=E7=BD=AE=E4=BA=86setId?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=8E=B0=E5=9C=A8=E4=B8=8D=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E5=90=8E=E8=AE=BEoakId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/features/cache.js | 2 +- es/features/runningTree.js | 25 +++++---------- es/locales/common/zh_CN.json | 2 +- es/page.react.d.ts | 12 +++---- src/features/runningTree.ts | 61 ++++++++++++++++++------------------ 5 files changed, 47 insertions(+), 55 deletions(-) diff --git a/es/features/cache.js b/es/features/cache.js index 65d4a03d..6f752b1f 100644 --- a/es/features/cache.js +++ b/es/features/cache.js @@ -349,7 +349,7 @@ export class Cache extends Feature { opers.forEach((oper) => { const { entity, operation } = oper; this.cacheStore.operate(entity, operation, this.context, { - checkerTypes: ['logical'], // 这里不能检查data,不然在数据没填完前会有大量异常 + checkerTypes: ['logical'], dontCollect: true, }); }); diff --git a/es/features/runningTree.js b/es/features/runningTree.js index a81817bf..1096d17a 100644 --- a/es/features/runningTree.js +++ b/es/features/runningTree.js @@ -6,6 +6,7 @@ import { judgeRelation } from "oak-domain/lib/store/relation"; import { Feature } from '../types/Feature'; import { generateNewId } from 'oak-domain/lib/utils/uuid'; export const MODI_NEXT_PATH_SUFFIX = ':next'; +const START_LSN = 100; function mergeOperation(schema, entity, oper1, oper2) { const { action, data } = oper2; const operMerged = cloneDeep(oper1); @@ -90,7 +91,7 @@ class UpdateLogManager { constructor(schema, entity, maxLsn) { this.schema = schema, this.entity = entity, - this.maxLsn = maxLsn || 0; + this.maxLsn = maxLsn || START_LSN; } /** * 合并两个filter完全一致的更新 @@ -165,7 +166,7 @@ class UpdateLogManager { rollback(lsn) { const newLogs = this.logs.filter(ele => ele.lsn <= lsn); this.logs = newLogs; - this.maxLsn = lsn; + this.maxLsn = lsn || START_LSN; } makeOperations() { const opers = {}; @@ -783,7 +784,6 @@ class ListNode extends Node { * @param afterExecute */ updateItem(lsn, data, id, action) { - // 如果数据键值是一个空字符串则更新成null const undefinedAttrs = []; // 如果数据键值是一个空字符串则更新成null,undefined则unset掉 for (const k in data) { @@ -796,10 +796,7 @@ class ListNode extends Node { undefinedAttrs.push(k); } } - - undefinedAttrs.forEach( - (attr) => unset(data, attr) - ); + undefinedAttrs.forEach((attr) => unset(data, attr)); this.ulManager.push(lsn, { action: action || 'update', data, @@ -1219,7 +1216,6 @@ class SingleNode extends Node { update(lsn, data, action) { // 如果数据键值是一个空字符串则更新成null,如果是undefined则取消此键值 const undefinedAttrs = []; - // 如果数据键值是一个空字符串则更新成null,undefined则unset掉 for (const k in data) { if (data[k] === '') { Object.assign(data, { @@ -1230,10 +1226,7 @@ class SingleNode extends Node { undefinedAttrs.push(k); } } - - undefinedAttrs.forEach( - (attr) => unset(data, attr) - ); + undefinedAttrs.forEach((attr) => unset(data, attr)); this.ulManager.push(lsn, { action: action || 'update', data, @@ -1323,12 +1316,10 @@ class SingleNode extends Node { const operations = this.ulManager.makeOperations(); this.ulManager.rollback(lsnMax); assert(operations.length <= 1); - const [ operation ] = operations; - + const [operation] = operations; if (operation) { const { filter, ...rest } = operation; const intrinsticFilter = this.getIntrinsticFilters(); - return [ { entity: this.entity, @@ -1441,7 +1432,7 @@ class SingleNode extends Node { saveRefreshResult(data) { const ids = Object.keys(data); assert(ids.length === 1); - this.id = ids[0]; + this.setId(ids[0]); this.sr = data[ids[0]]; this.passRsToChild(); // this.publish(); @@ -1753,7 +1744,7 @@ export class RunningTree extends Feature { this.nodeCountDict = {}; this.pageNodeStack = {}; this.singletonDict = {}; - this.logSerailNumber = 100; + this.logSerailNumber = START_LSN; } increaseNodeCount(path) { if (!this.nodeCountDict[path]) { diff --git a/es/locales/common/zh_CN.json b/es/locales/common/zh_CN.json index 0e5acccc..3958e428 100644 --- a/es/locales/common/zh_CN.json +++ b/es/locales/common/zh_CN.json @@ -42,4 +42,4 @@ "false": "否", "other": "其他", "money": "¥%{value}" -} +} diff --git a/es/page.react.d.ts b/es/page.react.d.ts index 08d09cbd..4d480728 100644 --- a/es/page.react.d.ts +++ b/es/page.react.d.ts @@ -48,20 +48,20 @@ export declare function createComponent(options: { url: string; } & OakNavigateToParameters, state?: Record | undefined, disableNamespace?: boolean | undefined): Promise; - addItem(data: Omit & { + addItem(data: Omit & { id?: string | undefined; }, path?: string | undefined): string; - addItems(data: (Omit & { + addItems(data: (Omit & { id?: string | undefined; })[], path?: string | undefined): string[]; removeItem(id: string, path?: string | undefined): void; removeItems(ids: string[], path?: string | undefined): void; - updateItem(data: ED[T_3]["Update"]["data"], id: string, action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void; + updateItem(data: ED[T_2]["Update"]["data"], id: string, action?: ED[T_2]["Action"] | undefined, path?: string | undefined): void; recoverItem(id: string, path?: string | undefined): void; recoverItems(ids: string[], path?: string | undefined): void; resetItem(id: string, path?: string | undefined): void; - update(data: ED[T_4]["Update"]["data"], action?: ED[T_4]["Action"] | undefined, path?: string | undefined): void; - create(data: Omit, path?: string | undefined): void; + update(data: ED[T_3]["Update"]["data"], action?: ED[T_3]["Action"] | undefined, path?: string | undefined): void; + create(data: Omit, path?: string | undefined): void; remove(path?: string | undefined): void; isCreation(path?: string | undefined): boolean; clean(lsn?: number | undefined, dontPublish?: true | undefined, path?: string | undefined): void; @@ -75,7 +75,7 @@ export declare function createComponent | Partial[] | undefined; checkOperation(entity: T2_2, operation: Omit, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean | import("oak-domain/lib/types").OakUserException; tryExecute(path?: string | undefined, action?: string | undefined): boolean | import("oak-domain/lib/types").OakUserException; - getOperations(path?: string | undefined): { + getOperations(path?: string | undefined): { entity: keyof ED; operation: ED[keyof ED]["Operation"]; }[] | undefined; diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index b58edeb0..8c7e578e 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -15,10 +15,11 @@ import { ActionDef } from '../types/Page'; import { generateNewId } from 'oak-domain/lib/utils/uuid'; export const MODI_NEXT_PATH_SUFFIX = ':next'; +const START_LSN = 100; type LegalOperation = ED[T]['CreateSingle'] -| ED[T]['Update'] -| ED[T]['Remove']; + | ED[T]['Update'] + | ED[T]['Remove']; type UpdateLog = { lsn: number; @@ -26,7 +27,7 @@ type UpdateLog = { }; -function mergeOperation ( +function mergeOperation( schema: StorageSchema, entity: T, oper1: LegalOperation, @@ -83,7 +84,7 @@ function mergeOperation, entity: T, maxLsn?: number) { this.schema = schema, - this.entity = entity, - this.maxLsn = maxLsn || 0; + this.entity = entity, + this.maxLsn = maxLsn || START_LSN; } /** * 合并两个filter完全一致的更新 @@ -213,7 +214,7 @@ class UpdateLogManager ele.lsn <= lsn ); this.logs = newLogs; - this.maxLsn = lsn; + this.maxLsn = lsn || START_LSN; } makeOperations() { @@ -981,7 +982,7 @@ class ListNode< undefinedAttrs.push(k); } } - + undefinedAttrs.forEach( (attr) => unset(data, attr) ); @@ -1017,16 +1018,16 @@ class ListNode< if (childOperations) { childOperations.forEach( (childOperation) => this.ulManager.push(ulmLsn + 100, childOperation.operation as any) - ); + ); } } - + const operations = this.ulManager.makeOperations(); this.ulManager.rollback(ulmLsn); return operations.map( (operation) => { - const { filter, ...rest} = operation; + const { filter, ...rest } = operation; return { entity: this.entity, operation: { @@ -1389,7 +1390,7 @@ class SingleNode unset(data, attr) ); - this.ulManager.push(lsn, { + this.ulManager.push(lsn, { action: action || 'update', data, filter: { id: this.getId()!, } } as unknown as Omit); - + // 处理外键,如果update的数据中有相应的外键,其子对象上的动作应当被clean掉 // 并将sr传递到子组件上 @@ -1544,7 +1545,7 @@ class SingleNode); @@ -1558,7 +1559,7 @@ class SingleNode); super.setDirty(); @@ -1579,7 +1580,7 @@ class SingleNode operation - ), + ), }, filter: { id: this.getId(), @@ -1607,12 +1608,12 @@ class SingleNode) { const ids = Object.keys(data); assert(ids.length === 1); - this.id = ids[0]; + this.setId(ids[0]); this.sr = data[ids[0]!]; this.passRsToChild(); @@ -1784,7 +1785,7 @@ class SingleNode extends Feature { for (const ele in this.children) { this.children[ele].clean(lsn, dontPublish); } - + if (!lsn) { this.dirty = false; } @@ -2107,7 +2108,7 @@ export class RunningTree extends Feature this.nodeCountDict = {}; this.pageNodeStack = {}; this.singletonDict = {}; - this.logSerailNumber = 100; + this.logSerailNumber = START_LSN; } private increaseNodeCount(path: string) { @@ -2799,10 +2800,10 @@ export class RunningTree extends Feature throw err; } } - + savePoint() { const lsn = this.logSerailNumber; - this.logSerailNumber ++; + this.logSerailNumber++; return lsn; } @@ -2812,7 +2813,7 @@ export class RunningTree extends Feature * @param lsn 要清除到某个指定的savepoint,不设则完全清空 * @param dontPublish */ - clean(path: string, lsn?:number, dontPublish?: true) { + clean(path: string, lsn?: number, dontPublish?: true) { const node = this.findNode(path)!; node.clean(lsn, dontPublish); From bf01c18d142d423f728fa3a6bc05bbbbdcf3aab3 Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Fri, 28 Jun 2024 18:45:24 +0800 Subject: [PATCH 3/3] 5.2.6-pub --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6dda00ea..ca3829c2 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,9 @@ "keepalive-for-react": "^2.0.7", "node-schedule": "^2.1.1", "nprogress": "^0.2.0", - "oak-common-aspect": "file:../oak-common-aspect", - "oak-domain": "file:../oak-domain", - "oak-memory-tree-store": "file:../oak-memory-tree-store", + "oak-common-aspect": "~3.0.0", + "oak-domain": "~5.0.13", + "oak-memory-tree-store": "~3.3.1", "ol": "^7.3.0", "react-activation": "^0.12.4", "react-native-device-info": "^10.12.0",