From 70fa6dc1e4d6f0090100f24cc9e2ad9b22cc895d Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Fri, 20 Sep 2024 19:01:29 +0800 Subject: [PATCH 1/9] 5.1.3-pub --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16bd69a..d3c2f83 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oak-domain", - "version": "5.1.2", + "version": "5.1.3", "author": { "name": "XuChang" }, From 14655b08ff16b596bb97baf8aa057ec5900b02b1 Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Fri, 20 Sep 2024 19:06:28 +0800 Subject: [PATCH 2/9] 5.1.4-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d3c2f83..1aa8246 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oak-domain", - "version": "5.1.3", + "version": "5.1.4", "author": { "name": "XuChang" }, From 8afa88af4f07c6e66ec4fbb243dc1e04f53e5cf2 Mon Sep 17 00:00:00 2001 From: "Xc@centOs" Date: Wed, 25 Sep 2024 12:38:56 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=9C=A8=E6=A3=80=E6=9F=A5updateAt?= =?UTF-8?q?=E7=9F=A9=E9=98=B5=E6=97=B6,=E8=BF=87=E6=BB=A4=E6=8E=89?= =?UTF-8?q?=E4=B8=80=E4=BA=9B=E5=86=85=E7=BD=AE=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/IntrinsicCheckers.js | 10 +++++----- lib/utils/assert.d.ts | 1 - lib/utils/relationPath.js | 2 +- src/store/IntrinsicCheckers.ts | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/store/IntrinsicCheckers.js b/lib/store/IntrinsicCheckers.js index 58b3286..4d8b8e4 100644 --- a/lib/store/IntrinsicCheckers.js +++ b/lib/store/IntrinsicCheckers.js @@ -79,7 +79,7 @@ function createUniqueCheckers(schema) { entity, action: 'create', type: 'logicalData', - priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测 + priority: types_1.CHECKER_MAX_PRIORITY, checker: (operation, context) => { const { data } = operation; if (data instanceof Array) { @@ -95,9 +95,9 @@ function createUniqueCheckers(schema) { } }, { entity, - action: 'update', // 只检查update,其它状态转换的action应该不会涉及unique约束的属性 + action: 'update', type: 'logicalData', - priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测 + priority: types_1.CHECKER_MAX_PRIORITY, checker: (operation, context) => { const { data, filter: operationFilter } = operation; if (data) { @@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) { action: 'create', type: 'logical', entity, - priority: 10, // 优先级要高,先于真正的data检查进行 + priority: 10, checker: (operation) => { const { data } = operation; if (data instanceof Array) { @@ -311,7 +311,7 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) { const checkers = []; for (const entity in attrUpdateMatrix) { const matrix = attrUpdateMatrix[entity]; - const updateAttrs = Object.keys(matrix); + const updateAttrs = [types_1.UpdateAtAttribute, types_1.TriggerDataAttribute, types_1.TriggerUuidAttribute].concat(Object.keys(matrix)); const { actions } = schema[entity]; const updateActions = actions.filter((a) => !action_1.readOnlyActions.concat(['create', 'remove']).includes(a)); /** diff --git a/lib/utils/assert.d.ts b/lib/utils/assert.d.ts index 932ffd1..c502695 100644 --- a/lib/utils/assert.d.ts +++ b/lib/utils/assert.d.ts @@ -1,4 +1,3 @@ -/// /** * 防止assert打包体积过大,从这里引用 */ diff --git a/lib/utils/relationPath.js b/lib/utils/relationPath.js index 03a5133..00c7c5e 100644 --- a/lib/utils/relationPath.js +++ b/lib/utils/relationPath.js @@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) { }, filter: relationFilter, } // as ED['userRelation']['Selection'] - }, // as ED[keyof ED]['Selection']['data'], + }, getData: (d) => { return d.userRelation$entity; }, diff --git a/src/store/IntrinsicCheckers.ts b/src/store/IntrinsicCheckers.ts index 06bb717..11e2b57 100644 --- a/src/store/IntrinsicCheckers.ts +++ b/src/store/IntrinsicCheckers.ts @@ -1,4 +1,4 @@ -import { ActionDefDict, Checker, EntityDict, StorageSchema, RowChecker, OakUniqueViolationException, CHECKER_MAX_PRIORITY, AttrUpdateMatrix, LogicalChecker, OakAttrCantUpdateException } from "../types"; +import { ActionDefDict, Checker, EntityDict, StorageSchema, RowChecker, OakUniqueViolationException, CHECKER_MAX_PRIORITY, AttrUpdateMatrix, LogicalChecker, OakAttrCantUpdateException, UpdateAtAttribute, TriggerDataAttribute, TriggerUuidAttribute } from "../types"; import { SyncContext } from "./SyncRowStore"; import { AsyncContext } from "./AsyncRowStore"; import { pick, intersection, difference, omit } from '../utils/lodash'; @@ -380,7 +380,7 @@ function createAttrUpdateCheckers[] = []; for (const entity in attrUpdateMatrix) { const matrix = attrUpdateMatrix[entity]!; - const updateAttrs = Object.keys(matrix) as string[]; + const updateAttrs = [UpdateAtAttribute, TriggerDataAttribute, TriggerUuidAttribute].concat(Object.keys(matrix)); const { actions } = schema[entity]; const updateActions = actions.filter( (a) => !readOnlyActions.concat(['create', 'remove']).includes(a) From dffda4a34674248a005e44f7c76c43f7b334854c Mon Sep 17 00:00:00 2001 From: lxy Date: Thu, 26 Sep 2024 09:40:51 +0800 Subject: [PATCH 4/9] =?UTF-8?q?createAttrUpdateCheckers=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/IntrinsicCheckers.js | 6 +++--- src/store/IntrinsicCheckers.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/store/IntrinsicCheckers.js b/lib/store/IntrinsicCheckers.js index 4d8b8e4..255d18a 100644 --- a/lib/store/IntrinsicCheckers.js +++ b/lib/store/IntrinsicCheckers.js @@ -328,7 +328,7 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) { throw new types_1.OakAttrCantUpdateException(entity, extras, '更新了不允许的属性'); } const condition = attrs.map(ele => matrix[ele]); - const actions = condition.map(ele => ele.actions).filter(ele => !!ele); + const actions = condition.map(ele => ele?.actions).filter(ele => !!ele); const a = actions.length > 0 && (0, lodash_1.intersection)(actions.flat()); if (a) { if (!a.includes(action)) { @@ -338,10 +338,10 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) { } } const filters = condition.map(ele => { - if (typeof ele.filter === 'function') { + if (typeof ele?.filter === 'function') { return ele.filter(action || 'select'); } - return ele.filter; + return ele?.filter; }).filter(ele => !!ele); const f = filters.length > 0 && (0, filter_1.combineFilters)(entity, schema, filters); if (f) { diff --git a/src/store/IntrinsicCheckers.ts b/src/store/IntrinsicCheckers.ts index 11e2b57..8c5665a 100644 --- a/src/store/IntrinsicCheckers.ts +++ b/src/store/IntrinsicCheckers.ts @@ -326,7 +326,7 @@ function cascadelyCheckUpdateFilters matrix[ele]!); - const actions = condition.map(ele => ele.actions).filter(ele => !!ele); + const actions = condition.map(ele => ele?.actions).filter(ele => !!ele); const a = actions.length > 0 && intersection(actions.flat()); if (a) { if (!a.includes(action)) { @@ -412,10 +412,10 @@ function createAttrUpdateCheckers { - if (typeof ele.filter === 'function') { + if (typeof ele?.filter === 'function') { return ele.filter(action || 'select'); } - return ele.filter; + return ele?.filter; }).filter(ele => !!ele); const f = filters.length > 0 && combineFilters(entity, schema, filters); if (f) { From 9b0a7dc409dddef384f68faae46a77afacdb7b93 Mon Sep 17 00:00:00 2001 From: wkj <278599135@.com> Date: Fri, 27 Sep 2024 11:34:32 +0800 Subject: [PATCH 5/9] =?UTF-8?q?onSynchronized=20=E5=8A=A0=E4=B8=8AremoteEn?= =?UTF-8?q?tity=E3=80=81remoteEntityId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/IntrinsicCheckers.js | 8 ++++---- lib/types/Sync.d.ts | 2 ++ lib/utils/assert.d.ts | 1 + lib/utils/relationPath.js | 2 +- src/types/Sync.ts | 6 ++++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/store/IntrinsicCheckers.js b/lib/store/IntrinsicCheckers.js index 255d18a..b2b5cf6 100644 --- a/lib/store/IntrinsicCheckers.js +++ b/lib/store/IntrinsicCheckers.js @@ -79,7 +79,7 @@ function createUniqueCheckers(schema) { entity, action: 'create', type: 'logicalData', - priority: types_1.CHECKER_MAX_PRIORITY, + priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测 checker: (operation, context) => { const { data } = operation; if (data instanceof Array) { @@ -95,9 +95,9 @@ function createUniqueCheckers(schema) { } }, { entity, - action: 'update', + action: 'update', // 只检查update,其它状态转换的action应该不会涉及unique约束的属性 type: 'logicalData', - priority: types_1.CHECKER_MAX_PRIORITY, + priority: types_1.CHECKER_MAX_PRIORITY, // 优先级要放在最低,所有前置的checker/trigger将数据完整之后再在这里检测 checker: (operation, context) => { const { data, filter: operationFilter } = operation; if (data) { @@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) { action: 'create', type: 'logical', entity, - priority: 10, + priority: 10, // 优先级要高,先于真正的data检查进行 checker: (operation) => { const { data } = operation; if (data instanceof Array) { diff --git a/lib/types/Sync.d.ts b/lib/types/Sync.d.ts index ac0718c..3459fbc 100644 --- a/lib/types/Sync.d.ts +++ b/lib/types/Sync.d.ts @@ -38,6 +38,8 @@ export interface PushEntityDef /** * 防止assert打包体积过大,从这里引用 */ diff --git a/lib/utils/relationPath.js b/lib/utils/relationPath.js index 00c7c5e..03a5133 100644 --- a/lib/utils/relationPath.js +++ b/lib/utils/relationPath.js @@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) { }, filter: relationFilter, } // as ED['userRelation']['Selection'] - }, + }, // as ED[keyof ED]['Selection']['data'], getData: (d) => { return d.userRelation$entity; }, diff --git a/src/types/Sync.ts b/src/types/Sync.ts index 067347d..1ee3ed6 100644 --- a/src/types/Sync.ts +++ b/src/types/Sync.ts @@ -47,6 +47,8 @@ export interface PushEntityDef> { entity: keyof ED; // 对方结点所关联的entity名称(两边一致) endpoint?: string; // 对方结点同步数据的endpoint,默认为/sync/:entity - pathToUser?: string; // entity到对应remote user的路径(如果remote user和enitity之间是relation关系则为空) + pathToUser?: string; // entity到对应remote user的路径(如果remote user和entity之间是relation关系则为空) relationName?: string; // 如果remote user和entity之间是relation关系,此处表达的是relation名称) pushEntities?: Array>; // 在这个entity上需要同步的entities - pullEntities?: Array>; // 从这个entity上可能会接收到的同步entites + pullEntities?: Array>; // 从这个entity上可能会接收到的同步entities }; export interface SyncRemoteConfig> extends SyncRemoteConfigBase { From 357412c5049de5c4e89a17b4c3428c728c825944 Mon Sep 17 00:00:00 2001 From: Xc Date: Mon, 30 Sep 2024 12:11:10 +0800 Subject: [PATCH 6/9] 5.1.5-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1aa8246..5e356f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oak-domain", - "version": "5.1.4", + "version": "5.1.5", "author": { "name": "XuChang" }, From 4acbd88c555259c4a73b908ea1a6a94a0a8068eb Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 8 Oct 2024 21:51:49 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AAcache=E4=B8=AD=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=E7=9A=84=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/store/RelationAuth.js | 7 ++++++- src/store/RelationAuth.ts | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/store/RelationAuth.js b/lib/store/RelationAuth.js index 7f725a4..1bdce47 100644 --- a/lib/store/RelationAuth.js +++ b/lib/store/RelationAuth.js @@ -148,7 +148,7 @@ class RelationAuth { if (!entity2) { entity2 = relations[0]?.entity; } - else { + else if (relations.length) { (0, assert_1.default)(entity2 === relations[0]?.entity); } return relations.map(ele => ele.id); @@ -156,6 +156,7 @@ class RelationAuth { const relationIds = getRelationIds(); if (relationIds instanceof Promise) { return relationIds.then((ids) => { + (0, assert_1.default)(ids.length > 0); return Promise.all(ids.map(ele => checkOnRelationId(entity2, ele, entityFilter))).then((value) => { if (intersection) { return !(value.includes(false)); @@ -164,6 +165,10 @@ class RelationAuth { }); }); } + if (relationIds.length === 0) { + // 如果没有relationId(前端cache中),直接返回false + return false; + } const value = relationIds.map(ele => checkOnRelationId(entity2, ele, entityFilter)); if (intersection) { return !(value.includes(false)); diff --git a/src/store/RelationAuth.ts b/src/store/RelationAuth.ts index acb4c79..7fe8101 100644 --- a/src/store/RelationAuth.ts +++ b/src/store/RelationAuth.ts @@ -217,7 +217,7 @@ export class RelationAuth { if (!entity2) { entity2 = relations[0]?.entity; } - else { + else if (relations.length) { assert(entity2 === relations[0]?.entity); } return relations.map(ele => ele.id!); @@ -227,6 +227,7 @@ export class RelationAuth { if (relationIds instanceof Promise) { return relationIds.then( (ids) => { + assert(ids.length > 0); return Promise.all( ids.map( ele => checkOnRelationId(entity2!, ele, entityFilter) @@ -242,6 +243,11 @@ export class RelationAuth { } ); } + + if (relationIds.length === 0) { + // 如果没有relationId(前端cache中),直接返回false + return false; + } const value = relationIds.map(ele => checkOnRelationId(entity2!, ele, entityFilter)) as boolean[]; if (intersection) { return !(value.includes(false)); From 64ca940278c7b8b93787ecc937158b84d5fc3a07 Mon Sep 17 00:00:00 2001 From: Xc Date: Thu, 10 Oct 2024 18:29:43 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=BE=AE=E8=B0=83=E4=BA=86dependencyBuilde?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compiler/dependencyBuilder.js | 18 +++++++++++++----- src/compiler/dependencyBuilder.ts | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/compiler/dependencyBuilder.js b/lib/compiler/dependencyBuilder.js index 8637b03..3aa9823 100644 --- a/lib/compiler/dependencyBuilder.js +++ b/lib/compiler/dependencyBuilder.js @@ -588,9 +588,17 @@ function outputFeatureIndex(dependencies, briefNames, sourceFile, printer, filen importStatements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("FeatureDict"), factory.createIdentifier(fdName))])), factory.createStringLiteral(dep), undefined)); fdNames.push(fdName); }); - const stmt4 = statements[4], stmt5 = statements[5]; - (0, assert_1.default)(ts.isImportDeclaration(stmt4) && ts.isFunctionDeclaration(stmt5)); - const { name, parameters } = stmt5; + let i = 0; + while (true) { + const stmt = statements[i]; + if (ts.isFunctionDeclaration(stmt)) { + break; + } + i++; + } + const stmt3 = statements[i - 1], stmt4 = statements[i]; + (0, assert_1.default)(ts.isImportDeclaration(stmt3) && ts.isFunctionDeclaration(stmt4)); + const { name, parameters } = stmt4; (0, assert_1.default)(ts.isIdentifier(name) && name.text === 'create' && parameters.length === 1); const [param] = parameters; const { name: paramName, type } = param; @@ -604,9 +612,9 @@ function outputFeatureIndex(dependencies, briefNames, sourceFile, printer, filen ]) }); statements2 = [ - ...statements.slice(0, 5), + ...statements.slice(0, i), ...importStatements, - ...statements.slice(5) + ...statements.slice(i) ]; if (isModule) { statements2.push(factory.createFunctionDeclaration([ diff --git a/src/compiler/dependencyBuilder.ts b/src/compiler/dependencyBuilder.ts index 6f94962..1ad35ef 100644 --- a/src/compiler/dependencyBuilder.ts +++ b/src/compiler/dependencyBuilder.ts @@ -1108,9 +1108,17 @@ function outputFeatureIndex( } ); - const stmt4 = statements[4], stmt5 = statements[5]; - assert(ts.isImportDeclaration(stmt4) && ts.isFunctionDeclaration(stmt5)); - const { name, parameters } = stmt5; + let i = 0; + while (true) { + const stmt = statements[i]; + if (ts.isFunctionDeclaration(stmt)) { + break; + } + i ++; + } + const stmt3 = statements[i-1], stmt4 = statements[i]; + assert(ts.isImportDeclaration(stmt3) && ts.isFunctionDeclaration(stmt4)); + const { name, parameters } = stmt4; assert(ts.isIdentifier(name!) && name.text === 'create' && parameters.length === 1); const [param] = parameters; const { name: paramName, type } = param; @@ -1127,9 +1135,9 @@ function outputFeatureIndex( }); statements2 = [ - ...statements.slice(0, 5), + ...statements.slice(0, i), ...importStatements, - ...statements.slice(5) + ...statements.slice(i) ]; if (isModule) { statements2.push( From f44c5ab6944358ba0667c1c88bf4dbbf0c8bde46 Mon Sep 17 00:00:00 2001 From: Xc Date: Fri, 11 Oct 2024 12:30:29 +0800 Subject: [PATCH 9/9] =?UTF-8?q?dependencyBuilder=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E4=BE=9D=E8=B5=96=E9=A1=B9=E7=9B=AE=E7=9A=84=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=9C=89=E4=B8=AA=E5=B0=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compiler/dependencyBuilder.js | 2 +- src/compiler/dependencyBuilder.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/compiler/dependencyBuilder.js b/lib/compiler/dependencyBuilder.js index 3aa9823..3a48dc6 100644 --- a/lib/compiler/dependencyBuilder.js +++ b/lib/compiler/dependencyBuilder.js @@ -764,7 +764,7 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) { const moduleTemplateDir = join(moduleDir, 'template'); if ((0, fs_1.existsSync)(moduleTemplateDir)) { // data.ts中规定的初始化数据,拷贝到data目录下,并注入到data/index.ts - const dataFile = join(moduleTemplateDir, 'data', 'data.ts'); + const dataFile = join(moduleTemplateDir, 'data.ts'); if ((0, fs_1.existsSync)(dataFile)) { const prjDataFile = join(cwd, 'src', 'data', `${briefNames[idx]}Data.ts`); if (!(0, fs_1.existsSync)(prjDataFile)) { diff --git a/src/compiler/dependencyBuilder.ts b/src/compiler/dependencyBuilder.ts index 1ad35ef..addd061 100644 --- a/src/compiler/dependencyBuilder.ts +++ b/src/compiler/dependencyBuilder.ts @@ -1450,7 +1450,7 @@ function tryCopyModuleTemplateFiles( const moduleTemplateDir = join(moduleDir, 'template'); if (existsSync(moduleTemplateDir)) { // data.ts中规定的初始化数据,拷贝到data目录下,并注入到data/index.ts - const dataFile = join(moduleTemplateDir, 'data', 'data.ts'); + const dataFile = join(moduleTemplateDir, 'data.ts'); if (existsSync(dataFile)) { const prjDataFile = join(cwd, 'src', 'data', `${briefNames[idx]}Data.ts`); if (!existsSync(prjDataFile)) {