diff --git a/lib/base-app-domain/Modi/Storage.js b/lib/base-app-domain/Modi/Storage.js index 8e91ab0..005fd20 100644 --- a/lib/base-app-domain/Modi/Storage.js +++ b/lib/base-app-domain/Modi/Storage.js @@ -43,6 +43,7 @@ exports.desc = { type: "object" }, iState: { + notNull: true, type: "enum", enumeration: ["active", "applied", "abandoned"] } diff --git a/lib/base-app-domain/Modi/_baseSchema.d.ts b/lib/base-app-domain/Modi/_baseSchema.d.ts index 4a10659..2b78b82 100644 --- a/lib/base-app-domain/Modi/_baseSchema.d.ts +++ b/lib/base-app-domain/Modi/_baseSchema.d.ts @@ -10,7 +10,7 @@ export type OpSchema = EntityShape & { data: Object; filter?: Object | null; extra?: Object | null; - iState?: IState | null; + iState: IState; } & { [A in ExpressionKey]?: any; }; diff --git a/lib/base-app-domain/Oper/Storage.js b/lib/base-app-domain/Oper/Storage.js index 2eb1205..64db6b9 100644 --- a/lib/base-app-domain/Oper/Storage.js +++ b/lib/base-app-domain/Oper/Storage.js @@ -43,6 +43,7 @@ exports.desc = { type: "object" }, iState: { + notNull: true, type: "enum", enumeration: ["normal", "rollbacked"] } diff --git a/lib/base-app-domain/Oper/_baseSchema.d.ts b/lib/base-app-domain/Oper/_baseSchema.d.ts index e5171e7..1877163 100644 --- a/lib/base-app-domain/Oper/_baseSchema.d.ts +++ b/lib/base-app-domain/Oper/_baseSchema.d.ts @@ -13,7 +13,7 @@ export type OpSchema = EntityShape & { bornAt?: Datetime | null; logId?: ForeignKey<"log"> | null; undoData?: Object | null; - iState?: IState | null; + iState: IState; } & { [A in ExpressionKey]?: any; }; diff --git a/lib/compiler/dependencyBuilder.js b/lib/compiler/dependencyBuilder.js index ea3a657..fcf5535 100644 --- a/lib/compiler/dependencyBuilder.js +++ b/lib/compiler/dependencyBuilder.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.analyzeDepedency = analyzeDepedency; -exports.default = buildDependency; +exports.analyzeDepedency = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const path_1 = require("path"); @@ -88,6 +87,7 @@ function analyzeDepedency(cwd) { } while (true); return depGraph; } +exports.analyzeDepedency = analyzeDepedency; function join(...paths) { const path = (0, path_1.join)(...paths); return path.replaceAll('\\', '/'); @@ -1030,3 +1030,4 @@ function buildDependency(rebuild) { tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer, rebuild); } } +exports.default = buildDependency; diff --git a/lib/compiler/localeBuilder.d.ts b/lib/compiler/localeBuilder.d.ts index bc77706..1feef3f 100644 --- a/lib/compiler/localeBuilder.d.ts +++ b/lib/compiler/localeBuilder.d.ts @@ -1,3 +1,4 @@ +/// import { Hash } from 'crypto'; /** * 这个类的作用是把项目和所有相关的模块下的locales编译成为src/data/i18n中的数据 diff --git a/lib/compiler/routerBuilder.js b/lib/compiler/routerBuilder.js index 9dc12ac..6ee7a8b 100644 --- a/lib/compiler/routerBuilder.js +++ b/lib/compiler/routerBuilder.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.buildRouter = buildRouter; +exports.buildRouter = void 0; const tslib_1 = require("tslib"); const path_1 = require("path"); const fs_extra_1 = require("fs-extra"); @@ -254,3 +254,4 @@ function buildRouter(projectDir, startupDir, watch) { watchDir(projectDir, startupDir, type); } } +exports.buildRouter = buildRouter; diff --git a/lib/compiler/schemalBuilder.d.ts b/lib/compiler/schemalBuilder.d.ts index e955b8d..f4cb12b 100644 --- a/lib/compiler/schemalBuilder.d.ts +++ b/lib/compiler/schemalBuilder.d.ts @@ -44,7 +44,6 @@ export declare function registerFixedDestinationPathMap(map: Record): void; export declare const getAnalizedSchema: () => typeof Schema; export declare function analyzeEntities(inputDir: string, relativePath?: string): void; -export declare function buildSchemaBackup(outputDir: string): void; export declare function getProjectionKeys(entity: string): string[]; export declare function buildSchema(outputDir: string): void; export {}; diff --git a/lib/compiler/schemalBuilder.js b/lib/compiler/schemalBuilder.js index 114ed5e..3ff84e3 100644 --- a/lib/compiler/schemalBuilder.js +++ b/lib/compiler/schemalBuilder.js @@ -1,17 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getAnalizedSchema = void 0; -exports.constructAttributes = constructAttributes; -exports.translateLocaleObject = translateLocaleObject; -exports.registerIgnoredForeignKeyMap = registerIgnoredForeignKeyMap; -exports.registerFreeEntities = registerFreeEntities; -exports.registerIgnoredRelationPathMap = registerIgnoredRelationPathMap; -exports.registerFixedDestinationPathMap = registerFixedDestinationPathMap; -exports.registerDeducedRelationMap = registerDeducedRelationMap; -exports.analyzeEntities = analyzeEntities; -exports.buildSchemaBackup = buildSchemaBackup; -exports.getProjectionKeys = getProjectionKeys; -exports.buildSchema = buildSchema; +exports.buildSchema = exports.getProjectionKeys = exports.analyzeEntities = exports.getAnalizedSchema = exports.registerDeducedRelationMap = exports.registerFixedDestinationPathMap = exports.registerIgnoredRelationPathMap = exports.registerFreeEntities = exports.registerIgnoredForeignKeyMap = exports.translateLocaleObject = exports.constructAttributes = void 0; const tslib_1 = require("tslib"); const path_1 = tslib_1.__importDefault(require("path")); const assert_1 = tslib_1.__importDefault(require("assert")); @@ -438,6 +427,13 @@ function dealWithActionTypeNode(moduleName, filename, actionTypeNode, program, s }); pushStatementIntoActionAst(moduleName, factory.createVariableStatement([factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier("actions"), undefined, undefined, factory.createArrayLiteralExpression(actionTexts.map(ele => factory.createStringLiteral(ele)), false))], ts.NodeFlags.Const)), sourceFile); } +/** + * + * @param moduleName + * @param initializer + * @param program + * @returns 返回是否显式定义了is + */ function dealWithActionDefInitializer(moduleName, initializer, program) { if (ts.isIdentifier(initializer) || ts.isCallExpression(initializer)) { // 是从别处的引用,注入到mportActionDefFrom @@ -449,10 +445,18 @@ function dealWithActionDefInitializer(moduleName, initializer, program) { (0, assert_1.default)(ts.isImportSpecifier(declaration), "ActionDef的initializer不是一个ImportSpecifier"); const importDeclartion = declaration.parent.parent.parent; addImportedFrom(moduleName, identifier.text, importDeclartion); + // todo,要去分析外部引用的actionDef中的is,目前只有src/action/action.ts中的makeAbleActionDef,这种情况无法在编译时确定is是否为空,统一设置为空 + return false; } else { // 本地定义的actionDef,不用处理 (0, assert_1.default)(ts.isObjectLiteralExpression(initializer), moduleName); + if (ts.isObjectLiteralExpression(initializer)) { + const { properties } = initializer; + const isProp = properties.find((ele) => ts.isPropertyAssignment(ele) && ts.isIdentifier(ele.name) && ele.name.text === 'is'); + return !!isProp; + } + return false; } } /** @@ -713,7 +717,7 @@ function dealImportedFile(path, fileSpecifierPath, filename, program) { // } // assert(false, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`); // } -function analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, relativePath) { +function analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrDict, enumAttributes, importAttrFrom, relativePath) { let hasEntityAttr = false; let hasEntityIdAttr = false; let toModi = false; @@ -742,7 +746,7 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe extendsFrom.push(from); const [sourceFile, pathName] = dealImportedFile(path, from, filename, program); const relativeFilename = path_1.default.relative(process.cwd(), pathName); - const result = analyzeReferenceSchemaFile(moduleName, path_1.default.basename(relativeFilename), path_1.default.dirname(relativeFilename), sourceFile, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, path_1.default.join(from, '..')); + const result = analyzeReferenceSchemaFile(moduleName, path_1.default.basename(relativeFilename), path_1.default.dirname(relativeFilename), sourceFile, program, referencedSchemas, schemaAttrDict, enumAttributes, importAttrFrom, path_1.default.join(from, '..')); return result; }).filter(ele => !!ele); // assert(['EntityShape'].includes((heritageClauses![0].types![0].expression).text), moduleName); @@ -754,7 +758,9 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe && ts.isIdentifier(type.typeName)) { if ((referencedSchemas.includes(type.typeName.text) || type.typeName.text === 'Schema')) { addRelationship(moduleName, type.typeName.text, attrName, !!questionToken); - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + (0, assert_1.default)(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; } else if (type.typeName.text === 'Array') { // 这是一对多的反向指针的引用,需要特殊处理 @@ -782,7 +788,9 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + (0, assert_1.default)(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; const enumStringValues = tryGetStringLiteralValues(moduleName, filename, `attr-${attrName}`, type, program); if (enumStringValues.length > 0) { enumAttributes[attrName] = enumStringValues; @@ -813,13 +821,17 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + (0, assert_1.default)(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; analyzeExternalAttrImport(type.elementType, program, importAttrFrom, relativePath); // throw new Error(`对象${moduleName}中定义的属性${attrName}是不可识别的数组类别`); } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + (0, assert_1.default)(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; if (ts.isUnionTypeNode(type) && ts.isLiteralTypeNode(type.types[0]) && ts.isStringLiteral(type.types[0].literal)) { (0, assert_1.default)(ts.isIdentifier(name), `「${filename}」中的属性定义不是String类型`); const { types } = type; @@ -893,7 +905,7 @@ function analyzeSchemaDefinition(node, moduleName, filename, path, program, refe extendsFrom, }; } -function analyzeReferenceSchemaFile(moduleName, filename, path, sourceFile, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, relativePath) { +function analyzeReferenceSchemaFile(moduleName, filename, path, sourceFile, program, referencedSchemas, schemaAttrDict, enumAttributes, importAttrFrom, relativePath) { let result; ts.forEachChild(sourceFile, (node) => { if (ts.isImportDeclaration(node)) { @@ -902,7 +914,7 @@ function analyzeReferenceSchemaFile(moduleName, filename, path, sourceFile, prog if (ts.isInterfaceDeclaration(node)) { // schema 定义 if (node.name.text === 'Schema') { - result = analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, relativePath); + result = analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrDict, enumAttributes, importAttrFrom, relativePath); } else if (!node.name.text.endsWith('Relation') && !node.name.text.endsWith('Action') && !node.name.text.endsWith('State')) { // 本地规定的一些形状定义,直接使用 @@ -933,7 +945,8 @@ function analyzeEntity(filename, path, program, relativePath) { } checkNameLegal(filename, moduleName, true); const referencedSchemas = []; - const schemaAttrs = []; + // const schemaAttrs: ts.TypeElement[] = []; + const schemaAttrDict = {}; let hasFulltextIndex = false; let indexes; let beforeSchema = true; @@ -958,7 +971,7 @@ function analyzeEntity(filename, path, program, relativePath) { // schema 定义 if (node.name.text === 'Schema') { beforeSchema = false; - const result = analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, relativePath); + const result = analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrDict, enumAttributes, importAttrFrom, relativePath); if (result.hasEntityAttr && result.hasEntityIdAttr) { (0, lodash_1.assign)(ReversePointerEntities, { [moduleName]: 1, @@ -1112,11 +1125,12 @@ function analyzeEntity(filename, path, program, relativePath) { const enumStateValues = tryGetStringLiteralValues(moduleName, filename, 'state', stateNode, program); (0, assert_1.default)(enumStateValues.length > 0, `文件${filename}中的state${stateNode.typeName.text}定义不是字符串类型`); pushStatementIntoActionAst(moduleName, node, sourceFile); - dealWithActionDefInitializer(moduleName, declaration.initializer, program); + const isDefined = dealWithActionDefInitializer(moduleName, declaration.initializer, program); (0, assert_1.default)(ts.isIdentifier(declaration.name)); const adName = declaration.name.text.slice(0, declaration.name.text.length - 9); const attr = adName.concat('State'); - schemaAttrs.push(factory.createPropertySignature(undefined, (0, string_1.firstLetterLowerCase)(attr), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(attr))); + (0, assert_1.default)(!schemaAttrDict[attr], `文件${filename}中的${attr}有显式定义,与ActionDef需要生成的属性冲突`); + schemaAttrDict[attr] = factory.createPropertySignature(undefined, (0, string_1.firstLetterLowerCase)(attr), isDefined ? undefined : factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(attr)); enumAttributes[(0, string_1.firstLetterLowerCase)(attr)] = enumStateValues; }; const dealWithIndexes = (declaration) => { @@ -1175,7 +1189,7 @@ function analyzeEntity(filename, path, program, relativePath) { }); const indexAttrName = nameProperty.initializer.text; if (!Entity_1.initinctiveAttributes.includes(indexAttrName)) { - const schemaNode = schemaAttrs.find((ele3) => { + const schemaNode = Object.values(schemaAttrDict).find((ele3) => { (0, assert_1.default)(ts.isPropertySignature(ele3)); return ele3.name.text === indexAttrName; }); @@ -1390,6 +1404,7 @@ function analyzeEntity(filename, path, program, relativePath) { if (hasActionDef && actionType !== 'crud') { throw new Error(`${filename}中有Action定义,但却定义了actionType不是crud`); } + const schemaAttrs = Object.values(schemaAttrDict); (0, assert_1.default)(schemaAttrs.length > 0, `对象${moduleName}没有任何属性定义`); const schema = { schemaAttrs, @@ -4083,6 +4098,7 @@ function constructAttributes(entity) { }); return result; } +exports.constructAttributes = constructAttributes; function translateLocaleObject(locale) { const result = {}; locale.properties.forEach((ele) => { @@ -4101,6 +4117,7 @@ function translateLocaleObject(locale) { }); return result; } +exports.translateLocaleObject = translateLocaleObject; function outputLocale(outputDir, printer) { const locales = {}; const entities = []; @@ -4375,6 +4392,7 @@ let FIXED_FOR_ALL_DESTINATION_PATH_ENTITIES = []; function registerIgnoredForeignKeyMap(map) { IGNORED_FOREIGN_KEY_MAP = map; } +exports.registerIgnoredForeignKeyMap = registerIgnoredForeignKeyMap; /** * 此函数不再使用 * @param map @@ -4384,6 +4402,7 @@ function registerFreeEntities(selectFreeEntities = [], createFreeEntities = [], CREATE_FREE_ENTITIES = createFreeEntities; UPDATE_FREE_ENTITIES = updateFreeEntities; } +exports.registerFreeEntities = registerFreeEntities; /** * 此函数不再使用 * @param map @@ -4393,6 +4412,7 @@ function registerIgnoredRelationPathMap(map) { IGNORED_RELATION_PATH_MAP[(0, string_1.firstLetterUpperCase)(k)] = map[k]; } } +exports.registerIgnoredRelationPathMap = registerIgnoredRelationPathMap; /** * 很多路径虽然最后指向同一对象,但不能封掉,封了会导致查询的时候找不到对应的路径path * @param map @@ -4410,6 +4430,7 @@ function registerFixedDestinationPathMap(map) { } } } +exports.registerFixedDestinationPathMap = registerFixedDestinationPathMap; /** * 此函数不再使用 * @param map @@ -4428,6 +4449,7 @@ function registerDeducedRelationMap(map) { DEDUCED_RELATION_MAP[entity] = map[k]; } } +exports.registerDeducedRelationMap = registerDeducedRelationMap; /** * 输出所有和User相关的对象的后继 * 此函数不再使用 @@ -4933,24 +4955,7 @@ function analyzeEntities(inputDir, relativePath) { analyzeInModi(); uniqRelationships(); } -function buildSchemaBackup(outputDir) { - addReverseRelationship(); - // setRelationEntities(); - const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); - resetOutputDir(outputDir); - outputSchema(outputDir, printer); - outputLocale(outputDir, printer); - outputSubQuery(outputDir, printer); - outputAction(outputDir, printer); - outputEntityDict(outputDir, printer); - outputStorage(outputDir, printer); - outputRelation2(outputDir, printer); - outputStyleDict(outputDir, printer); - outputIndexTs(outputDir); - if (!process.env.COMPLING_AS_LIB) { - outputPackageJson(outputDir); - } -} +exports.analyzeEntities = analyzeEntities; function _getAggrKey(entity, foreignKey) { const aggrKey = `${entity}$${foreignKey}`; if (process.env.COMPLING_AS_LIB) { @@ -5690,6 +5695,7 @@ function getProjectionKeys(entity) { } return [...new Set([...keys, ...getOpProjectionKeys(entity)])]; } +exports.getProjectionKeys = getProjectionKeys; function _outputSchema(outputDir, printer) { for (const entity in Schema) { const statements = [ @@ -5724,3 +5730,4 @@ function buildSchema(outputDir) { outputStyleDict(outputDir, printer); outputIndexTs(outputDir); } +exports.buildSchema = buildSchema; diff --git a/lib/store/AsyncRowStore.d.ts b/lib/store/AsyncRowStore.d.ts index f62c380..08d7ecd 100644 --- a/lib/store/AsyncRowStore.d.ts +++ b/lib/store/AsyncRowStore.d.ts @@ -1,3 +1,4 @@ +/// import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo, OakException } from "../types"; import { EntityDict as BaseEntityDict } from '../base-app-domain'; import { IncomingHttpHeaders } from "http"; diff --git a/lib/store/CascadeStore.d.ts b/lib/store/CascadeStore.d.ts index f2c23f0..0cbb218 100644 --- a/lib/store/CascadeStore.d.ts +++ b/lib/store/CascadeStore.d.ts @@ -35,7 +35,7 @@ export declare abstract class CascadeStore>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise>; protected destructCascadeSelect | AsyncContext>(entity: T, projection2: ED[T]['Projection'], context: Cxt, cascadeSelectFn: (entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial[] | Promise[]>, aggregateFn: (entity2: T2, aggregation: ED[T2]['Aggregation'], context: Cxt, op: OP) => AggregationResult | Promise>, option: OP, selectionId?: string): { projection: ED[T]["Projection"]; - cascadeSelectionFns: ((result: Partial[]) => Promise | void)[]; + cascadeSelectionFns: ((result: Partial[]) => Promise | void)[]; }; /** * 级联更新 diff --git a/lib/store/CascadeStore.js b/lib/store/CascadeStore.js index fa33f64..d77a767 100644 --- a/lib/store/CascadeStore.js +++ b/lib/store/CascadeStore.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.CascadeStore = void 0; -exports.polishSelection = polishSelection; +exports.CascadeStore = exports.polishSelection = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const Entity_1 = require("../types/Entity"); @@ -286,6 +285,7 @@ function polishSelection(schema, entity, selection, context, option) { }); } } +exports.polishSelection = polishSelection; /**这个用来处理级联的select和update,对不同能力的 */ class CascadeStore extends RowStore_1.RowStore { constructor(storageSchema) { diff --git a/lib/store/IntrinsicCheckers.js b/lib/store/IntrinsicCheckers.js index cd8d063..326c1b5 100644 --- a/lib/store/IntrinsicCheckers.js +++ b/lib/store/IntrinsicCheckers.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeIntrinsicCheckers = makeIntrinsicCheckers; +exports.makeIntrinsicCheckers = void 0; const tslib_1 = require("tslib"); const types_1 = require("../types"); const lodash_1 = require("../utils/lodash"); @@ -398,3 +398,4 @@ function makeIntrinsicCheckers(schema, actionDefDict, attrUpdateMatrix) { } return checkers; } +exports.makeIntrinsicCheckers = makeIntrinsicCheckers; diff --git a/lib/store/IntrinsicLogics.js b/lib/store/IntrinsicLogics.js index f45dcf7..2bbcfa1 100644 --- a/lib/store/IntrinsicLogics.js +++ b/lib/store/IntrinsicLogics.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeIntrinsicLogics = makeIntrinsicLogics; +exports.makeIntrinsicLogics = void 0; const triggers_1 = require("./triggers"); const modi_1 = require("./modi"); const IntrinsicCheckers_1 = require("./IntrinsicCheckers"); @@ -42,3 +42,4 @@ function makeIntrinsicLogics(schema, actionDefDict, attrUpdateMatrix) { watchers, }; } +exports.makeIntrinsicLogics = makeIntrinsicLogics; diff --git a/lib/store/RelationAuth.js b/lib/store/RelationAuth.js index efc1089..bd538ef 100644 --- a/lib/store/RelationAuth.js +++ b/lib/store/RelationAuth.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.RelationAuth = void 0; -exports.getUserRelationsByActions = getUserRelationsByActions; +exports.getUserRelationsByActions = exports.RelationAuth = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const types_1 = require("../types"); @@ -1244,3 +1243,4 @@ async function getUserRelationsByActions(params, context) { userEntities, }; } +exports.getUserRelationsByActions = getUserRelationsByActions; diff --git a/lib/store/checker.js b/lib/store/checker.js index 7264509..71ab0b1 100644 --- a/lib/store/checker.js +++ b/lib/store/checker.js @@ -1,9 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.translateCheckerInAsyncContext = translateCheckerInAsyncContext; -exports.translateCheckerInSyncContext = translateCheckerInSyncContext; -exports.createRemoveCheckers = createRemoveCheckers; -exports.createCreateCheckers = createCreateCheckers; +exports.createCreateCheckers = exports.createRemoveCheckers = exports.translateCheckerInSyncContext = exports.translateCheckerInAsyncContext = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const filter_1 = require("../store/filter"); @@ -130,6 +127,7 @@ function translateCheckerInAsyncContext(checker, schema) { } } } +exports.translateCheckerInAsyncContext = translateCheckerInAsyncContext; function translateCheckerInSyncContext(checker, schema) { const { entity, type } = checker; const when = 'before'; // 现在create的relation改成提前的expression检查了,原先是先插入再后检查,性能不行,而且select也需要实现前检查 @@ -188,6 +186,7 @@ function translateCheckerInSyncContext(checker, schema) { } } } +exports.translateCheckerInSyncContext = translateCheckerInSyncContext; /** * 对对象的删除,检查其是否会产生其他行上的空指针,不允许这种情况的出现 * @param schema @@ -332,6 +331,7 @@ function createRemoveCheckers(schema) { } return checkers; } +exports.createRemoveCheckers = createRemoveCheckers; function checkAttributeLegal(schema, entity, data) { const { attributes } = schema[entity]; for (const attr in data) { @@ -478,3 +478,4 @@ function createCreateCheckers(schema) { } return checkers; } +exports.createCreateCheckers = createCreateCheckers; diff --git a/lib/store/filter.js b/lib/store/filter.js index d429eea..c92ca0d 100644 --- a/lib/store/filter.js +++ b/lib/store/filter.js @@ -1,17 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.translateCreateDataToFilter = translateCreateDataToFilter; -exports.combineFilters = combineFilters; -exports.judgeValueRelation = judgeValueRelation; -exports.analyzeFilterRelation = analyzeFilterRelation; -exports.contains = contains; -exports.getRelevantIds = getRelevantIds; -exports.same = same; -exports.makeTreeAncestorFilter = makeTreeAncestorFilter; -exports.makeTreeDescendantFilter = makeTreeDescendantFilter; -exports.checkFilterContains = checkFilterContains; -exports.checkFilterRepel = checkFilterRepel; -exports.translateFilterToObjectPredicate = translateFilterToObjectPredicate; +exports.translateFilterToObjectPredicate = exports.checkFilterRepel = exports.checkFilterContains = exports.makeTreeDescendantFilter = exports.makeTreeAncestorFilter = exports.same = exports.getRelevantIds = exports.contains = exports.analyzeFilterRelation = exports.judgeValueRelation = exports.combineFilters = exports.translateCreateDataToFilter = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const types_1 = require("../types"); @@ -47,6 +36,7 @@ function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) { } return data2; } +exports.translateCreateDataToFilter = translateCreateDataToFilter; /** * 尽量合并外键的连接,防止在数据库中join的对象过多 * @param entity @@ -494,6 +484,7 @@ function combineFilters(entity, schema, filters, union) { } return addFilterSegment(entity, schema, ...filters); } +exports.combineFilters = combineFilters; /** * 在以下判断相容或相斥的过程中,相容/相斥的事实标准是:满足两个条件的查询集合是否被包容/互斥,但如果两个filter在逻辑上相容或者相斥,在事实上不一定相容或者相斥 * 例如:{ a: 1 } 和 { a: { $ne: 1 } } 是明显不相容的查询,但如果数据为空集,则这两个查询并不能否定其相容 @@ -912,6 +903,7 @@ function judgeValueRelation(value1, value2, contained) { return false; } } +exports.judgeValueRelation = judgeValueRelation; /** * 判断filter条件对compared条件上的attr键值的条件是否相容或相斥 * @param entity @@ -1300,6 +1292,7 @@ function analyzeFilterRelation(entity, schema, filter, compared, contained) { sureAttributes, }; } +exports.analyzeFilterRelation = analyzeFilterRelation; /** 判断filter条件对compared条件是否相容或相斥 * @param entity * @param schema @@ -1371,6 +1364,7 @@ function contains(entity, schema, filter, contained) { return judgeFilterRelation(entity, schema, filter, contained, true); // return false; } +exports.contains = contains; /** * 判断filter1和filter2是否相斥,即filter1和filter2查询的结果一定没有交集 * filter1 = { @@ -1471,6 +1465,7 @@ function getRelevantIds(filter) { } return result; } +exports.getRelevantIds = getRelevantIds; /** * 判断两个过滤条件是否完全一致 * @param entity @@ -1485,6 +1480,7 @@ function same(entity, schema, filter1, filter2) { } return filter1.id === filter2.id; } +exports.same = same; /** * 寻找在树形结构中满足条件的数据行的上层数据 * 例如在area表中,如果“杭州市”满足这一条件,则希望查到更高层的“浙江省”和“中国”,即可构造出满足条件的filter @@ -1525,6 +1521,7 @@ function makeTreeAncestorFilter(entity, parentKey, filter, level = 1, includeAll } return currentLevelInFilter; } +exports.makeTreeAncestorFilter = makeTreeAncestorFilter; /** * 寻找在树形结构中满足条件的数据行的下层数据 * 例如在area表中,如果“杭州市”满足这一条件,则希望查到更低层的“西湖区”,即可构造出满足条件的filter @@ -1559,6 +1556,7 @@ function makeTreeDescendantFilter(entity, parentKey, filter, level = 1, includeA } return currentLevelInFilter; } +exports.makeTreeDescendantFilter = makeTreeDescendantFilter; function checkDeduceFilters(dfc, context) { const { $and, $or } = dfc; if ($and) { @@ -1644,6 +1642,7 @@ function checkFilterContains(entity, context, contained, filter, dataCompare, wa } return false; } +exports.checkFilterContains = checkFilterContains; function checkFilterRepel(entity, context, filter1, filter2, dataCompare, warningOnDataCompare) { (0, assert_1.default)(filter2); const schema = context.getSchema(); @@ -1659,6 +1658,7 @@ function checkFilterRepel(entity, context, filter1, filter2, dataCompare, warnin } return false; } +exports.checkFilterRepel = checkFilterRepel; /** * 有的场景下将filter当成非结构化属性存储,又想支持对其查询,此时必须将查询的filter进行转换,处理其中$开头的escape * 只要filter是查询数据的标准子集,查询应当能返回true @@ -1682,6 +1682,7 @@ function translateFilterToObjectPredicate(filter) { copyInner(filter, translated); return translated; } +exports.translateFilterToObjectPredicate = translateFilterToObjectPredicate; /* export function getCascadeEntityFilter( filter: NonNullable, attr: keyof NonNullable diff --git a/lib/store/modi.js b/lib/store/modi.js index 403fc26..1e26801 100644 --- a/lib/store/modi.js +++ b/lib/store/modi.js @@ -1,10 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.createOperationsFromModies = createOperationsFromModies; -exports.applyModis = applyModis; -exports.abandonModis = abandonModis; -exports.createModiRelatedCheckers = createModiRelatedCheckers; -exports.createModiRelatedTriggers = createModiRelatedTriggers; +exports.createModiRelatedTriggers = exports.createModiRelatedCheckers = exports.abandonModis = exports.applyModis = exports.createOperationsFromModies = void 0; const tslib_1 = require("tslib"); const types_1 = require("../types"); const action_1 = require("../actions/action"); @@ -24,6 +20,7 @@ function createOperationsFromModies(modies) { }; }); } +exports.createOperationsFromModies = createOperationsFromModies; async function applyModis(filter, context, option) { const closeMode = context.openRootMode(); const result = await context.operate('modi', { @@ -45,6 +42,7 @@ async function applyModis(filter, context, option) { closeMode(); return result; } +exports.applyModis = applyModis; async function abandonModis(filter, context, option) { const closeMode = context.openRootMode(); const result = context.operate('modi', { @@ -66,6 +64,7 @@ async function abandonModis(filter, context, option) { closeMode(); return result; } +exports.abandonModis = abandonModis; function createModiRelatedCheckers(schema) { const checkers = []; for (const entity in schema) { @@ -170,6 +169,7 @@ function createModiRelatedCheckers(schema) { } return checkers; } +exports.createModiRelatedCheckers = createModiRelatedCheckers; function createModiRelatedTriggers(schema) { const triggers = []; for (const entity in schema) { @@ -253,3 +253,4 @@ function createModiRelatedTriggers(schema) { }; return triggers.concat([applyTrigger]); } +exports.createModiRelatedTriggers = createModiRelatedTriggers; diff --git a/lib/store/relation.js b/lib/store/relation.js index c67f4e2..2312740 100644 --- a/lib/store/relation.js +++ b/lib/store/relation.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.judgeRelation = judgeRelation; +exports.judgeRelation = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const Demand_1 = require("../types/Demand"); @@ -71,3 +71,4 @@ function judgeRelation(schema, entity, attr, allowUnrecognized) { } } } +exports.judgeRelation = judgeRelation; diff --git a/lib/timers/oper.js b/lib/timers/oper.js index 69e54d9..a28bb37 100644 --- a/lib/timers/oper.js +++ b/lib/timers/oper.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.vaccumOper = vaccumOper; +exports.vaccumOper = void 0; const Entity_1 = require("../types/Entity"); const vaccum_1 = require("./vaccum"); const filter_1 = require("../store/filter"); @@ -61,3 +61,4 @@ async function vaccumOper(option, context) { ...rest, }, context); } +exports.vaccumOper = vaccumOper; diff --git a/lib/timers/vaccum.js b/lib/timers/vaccum.js index 52b4246..f3171f2 100644 --- a/lib/timers/vaccum.js +++ b/lib/timers/vaccum.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.vaccumEntities = vaccumEntities; +exports.vaccumEntities = void 0; const tslib_1 = require("tslib"); const dayjs_1 = tslib_1.__importDefault(require("dayjs")); const fs_1 = require("fs"); @@ -108,3 +108,4 @@ async function vaccumEntities(option, context) { }, { deletePhysically: true }); } } +exports.vaccumEntities = vaccumEntities; diff --git a/lib/types/AppLoader.d.ts b/lib/types/AppLoader.d.ts index 666712e..a3b2343 100644 --- a/lib/types/AppLoader.d.ts +++ b/lib/types/AppLoader.d.ts @@ -1,3 +1,4 @@ +/// import { IncomingHttpHeaders } from "http"; import { AsyncContext, AsyncRowStore } from "../store/AsyncRowStore"; import { EntityDict, OpRecord } from "./Entity"; diff --git a/lib/types/Connector.d.ts b/lib/types/Connector.d.ts index fa7ae8e..2f376c2 100644 --- a/lib/types/Connector.d.ts +++ b/lib/types/Connector.d.ts @@ -1,3 +1,4 @@ +/// import { IncomingHttpHeaders } from "http"; import { SyncContext } from "../store/SyncRowStore"; import { EntityDict, OpRecord } from "./Entity"; diff --git a/lib/types/Demand.js b/lib/types/Demand.js index b9533ad..18add77 100644 --- a/lib/types/Demand.js +++ b/lib/types/Demand.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SUB_QUERY_PREDICATE_KEYWORD = exports.EXPRESSION_PREFIX = void 0; -exports.isRefAttrNode = isRefAttrNode; +exports.SUB_QUERY_PREDICATE_KEYWORD = exports.isRefAttrNode = exports.EXPRESSION_PREFIX = void 0; exports.EXPRESSION_PREFIX = '$expr'; function isRefAttrNode(node) { return node.hasOwnProperty('#attr') || (node.hasOwnProperty('#refId') && node.hasOwnProperty('#refAttr')); } +exports.isRefAttrNode = isRefAttrNode; ; exports.SUB_QUERY_PREDICATE_KEYWORD = '#sqp'; diff --git a/lib/types/Endpoint.d.ts b/lib/types/Endpoint.d.ts index abb1b18..9571100 100644 --- a/lib/types/Endpoint.d.ts +++ b/lib/types/Endpoint.d.ts @@ -1,3 +1,4 @@ +/// import { IncomingHttpHeaders, IncomingMessage } from "http"; import { AsyncContext } from "../store/AsyncRowStore"; import { EntityDict } from "./Entity"; diff --git a/lib/types/Exception.js b/lib/types/Exception.js index aede0f3..da2cf2e 100644 --- a/lib/types/Exception.js +++ b/lib/types/Exception.js @@ -1,8 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.OakApplicationHasToUpgrade = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakDataInvisibleException = exports.OakOperationUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakSignatureVerificationException = exports.OakInsecureRequestException = exports.OakClockDriftException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakRequestTimeoutException = exports.OakException = void 0; -exports.isOakException = isOakException; -exports.makeException = makeException; +exports.makeException = exports.OakApplicationHasToUpgrade = exports.OakSocketConnectException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakDataInvisibleException = exports.OakOperationUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakSignatureVerificationException = exports.OakInsecureRequestException = exports.OakClockDriftException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakPartialSuccess = exports.OakMakeSureByMySelfException = exports.OakRequestTimeoutException = exports.OakException = exports.isOakException = void 0; const relation_1 = require("../store/relation"); const lodash_1 = require("../utils/lodash"); const OAK_EXCEPTION_SYMBOL = Symbol.for('oak-domain:exception'); @@ -54,6 +52,7 @@ function isOakException(obj, errType) { return false; } } +exports.isOakException = isOakException; class OakException extends Error { opRecords; _module; @@ -619,3 +618,4 @@ function makeException(data) { return e; } } +exports.makeException = makeException; diff --git a/lib/types/Expression.js b/lib/types/Expression.js index 4014424..415d30f 100644 --- a/lib/types/Expression.js +++ b/lib/types/Expression.js @@ -1,17 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isGeoExpression = isGeoExpression; -exports.isDateExpression = isDateExpression; -exports.isLogicExpression = isLogicExpression; -exports.isBoolExpression = isBoolExpression; -exports.isCompareExpression = isCompareExpression; -exports.isMathExpression = isMathExpression; -exports.isStringExpression = isStringExpression; -exports.isAggrExpression = isAggrExpression; -exports.isExpression = isExpression; -exports.opMultipleParams = opMultipleParams; -exports.execOp = execOp; -exports.getAttrRefInExpression = getAttrRefInExpression; +exports.getAttrRefInExpression = exports.execOp = exports.opMultipleParams = exports.isExpression = exports.isAggrExpression = exports.isStringExpression = exports.isMathExpression = exports.isCompareExpression = exports.isBoolExpression = exports.isLogicExpression = exports.isDateExpression = exports.isGeoExpression = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const dayjs_1 = tslib_1.__importDefault(require("dayjs")); @@ -63,6 +52,7 @@ function isGeoExpression(expression) { } return false; } +exports.isGeoExpression = isGeoExpression; function isDateExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -73,6 +63,7 @@ function isDateExpression(expression) { } return false; } +exports.isDateExpression = isDateExpression; function isLogicExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -82,6 +73,7 @@ function isLogicExpression(expression) { } return false; } +exports.isLogicExpression = isLogicExpression; function isBoolExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -91,6 +83,7 @@ function isBoolExpression(expression) { } return false; } +exports.isBoolExpression = isBoolExpression; function isCompareExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -101,6 +94,7 @@ function isCompareExpression(expression) { } return false; } +exports.isCompareExpression = isCompareExpression; function isMathExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -111,6 +105,7 @@ function isMathExpression(expression) { } return false; } +exports.isMathExpression = isMathExpression; function isStringExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -120,6 +115,7 @@ function isStringExpression(expression) { } return false; } +exports.isStringExpression = isStringExpression; function isAggrExpression(expression) { if (Object.keys(expression).length == 1) { const op = Object.keys(expression)[0]; @@ -129,14 +125,17 @@ function isAggrExpression(expression) { } return false; } +exports.isAggrExpression = isAggrExpression; function isExpression(expression) { return typeof expression === 'object' && Object.keys(expression).length === 1 && Object.keys(expression)[0].startsWith('$'); } +exports.isExpression = isExpression; function opMultipleParams(op) { return !['$year', '$month', '$weekday', '$weekOfYear', '$day', '$dayOfMonth', '$dayOfWeek', '$dayOfYear', '$not', '$true', '$false', '$abs', '$round', '$floor', '$ceil', '$$max', '$$min', '$$sum', '$$avg', '$$count'].includes(op); } +exports.opMultipleParams = opMultipleParams; function execOp(op, params) { switch (op) { case '$gt': { @@ -351,6 +350,7 @@ function execOp(op, params) { } } } +exports.execOp = execOp; /** * 检查一个表达式,并分析其涉及到的属性 * @param expression @@ -391,3 +391,4 @@ function getAttrRefInExpression(expression) { check(expression); return result; } +exports.getAttrRefInExpression = getAttrRefInExpression; diff --git a/lib/utils/SimpleConnector.d.ts b/lib/utils/SimpleConnector.d.ts index c97518a..26da38d 100644 --- a/lib/utils/SimpleConnector.d.ts +++ b/lib/utils/SimpleConnector.d.ts @@ -1,3 +1,4 @@ +/// import { IncomingHttpHeaders } from "http"; import { SyncContext } from '../store/SyncRowStore'; import { Connector, EntityDict, OakException, OpRecord } from "../types"; @@ -35,7 +36,7 @@ export default class SimpleConnector> | null; + result: ReadableStream | null; message: string | undefined; opRecords?: undefined; }>; @@ -44,7 +45,7 @@ export default class SimpleConnector> | null; + result: ReadableStream | null; message: string | undefined; opRecords?: undefined; }>; diff --git a/lib/utils/assert.d.ts b/lib/utils/assert.d.ts index c502695..932ffd1 100644 --- a/lib/utils/assert.d.ts +++ b/lib/utils/assert.d.ts @@ -1,3 +1,4 @@ +/// /** * 防止assert打包体积过大,从这里引用 */ diff --git a/lib/utils/date.js b/lib/utils/date.js index a94b1d2..988c318 100644 --- a/lib/utils/date.js +++ b/lib/utils/date.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.excelStringToDate = excelStringToDate; +exports.excelStringToDate = void 0; const tslib_1 = require("tslib"); const dayjs_1 = tslib_1.__importDefault(require("dayjs")); function excelStringToDate(str) { @@ -15,3 +15,4 @@ function excelStringToDate(str) { } return Date.parse(str); } +exports.excelStringToDate = excelStringToDate; diff --git a/lib/utils/domain.js b/lib/utils/domain.js index 3997d92..bd4ce1a 100644 --- a/lib/utils/domain.js +++ b/lib/utils/domain.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.composeUrl = composeUrl; +exports.composeUrl = void 0; function composeUrl(url, params) { const urlSp = new URLSearchParams(params); if (url.includes('?')) { @@ -8,3 +8,4 @@ function composeUrl(url, params) { } return `${url}?${urlSp}`; } +exports.composeUrl = composeUrl; diff --git a/lib/utils/executor.js b/lib/utils/executor.js index 8a0a659..a080147 100644 --- a/lib/utils/executor.js +++ b/lib/utils/executor.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.pipeline = pipeline; +exports.pipeline = void 0; /** * * @param units 各个执行单元,需要流水线执行,可能是同步也可能是异步 @@ -19,3 +19,4 @@ function pipeline(...units) { }; return exec(0); } +exports.pipeline = pipeline; diff --git a/lib/utils/geo.js b/lib/utils/geo.js index cb23f01..022e93d 100644 --- a/lib/utils/geo.js +++ b/lib/utils/geo.js @@ -1,10 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getDistanceBetweenPoints = getDistanceBetweenPoints; -exports.bd09togcj02 = bd09togcj02; -exports.gcj02tobd09 = gcj02tobd09; -exports.wgs84togcj02 = wgs84togcj02; -exports.gcj02towgs84 = gcj02towgs84; +exports.gcj02towgs84 = exports.wgs84togcj02 = exports.gcj02tobd09 = exports.bd09togcj02 = exports.getDistanceBetweenPoints = void 0; /** * 计算地球上两点之间的球面距离(单位:cm) */ @@ -25,6 +21,7 @@ function getDistanceBetweenPoints(lat1, lon1, lat2, lon2) { const d = R * c; return d * 1000; } +exports.getDistanceBetweenPoints = getDistanceBetweenPoints; //定义一些常量 const x_PI = 3.14159265358979324 * 3000.0 / 180.0; const PI = 3.1415926535897932384626; @@ -74,6 +71,7 @@ function bd09togcj02(coord) { const gg_lat = z * Math.sin(theta); return [gg_lng, gg_lat]; } +exports.bd09togcj02 = bd09togcj02; ; /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 @@ -90,6 +88,7 @@ function gcj02tobd09(coord) { const bd_lat = z * Math.sin(theta) + 0.006; return [bd_lng, bd_lat]; } +exports.gcj02tobd09 = gcj02tobd09; ; /** * WGS84转GCj02 @@ -116,6 +115,7 @@ function wgs84togcj02(coord) { return [mglng, mglat]; } } +exports.wgs84togcj02 = wgs84togcj02; ; /** * GCJ02 转换为 WGS84 @@ -142,4 +142,5 @@ function gcj02towgs84(coord) { return [lng * 2 - mglng, lat * 2 - mglat]; } } +exports.gcj02towgs84 = gcj02towgs84; ; diff --git a/lib/utils/lodash.js b/lib/utils/lodash.js index e616258..ce06d78 100644 --- a/lib/utils/lodash.js +++ b/lib/utils/lodash.js @@ -1,8 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.pullAll = exports.unionBy = exports.groupBy = exports.differenceBy = exports.difference = exports.union = exports.isEqual = exports.pick = exports.cloneDeep = exports.mergeWith = exports.merge = exports.omit = exports.intersectionBy = exports.intersection = exports.set = exports.get = exports.uniqBy = exports.uniq = exports.pull = exports.unset = void 0; -exports.mergeConcatArray = mergeConcatArray; -exports.mergeConcatMany = mergeConcatMany; +exports.pullAll = exports.unionBy = exports.groupBy = exports.differenceBy = exports.difference = exports.union = exports.isEqual = exports.pick = exports.cloneDeep = exports.mergeConcatMany = exports.mergeConcatArray = exports.mergeWith = exports.merge = exports.omit = exports.intersectionBy = exports.intersection = exports.set = exports.get = exports.uniqBy = exports.uniq = exports.pull = exports.unset = void 0; const tslib_1 = require("tslib"); /** * 避免lodash打包体积过大 @@ -67,9 +65,11 @@ function mergeConcatArray(object, source) { } }); } +exports.mergeConcatArray = mergeConcatArray; function mergeConcatMany(array) { if (array.length === 0) { return undefined; } return array.reduce((prev, current) => mergeConcatArray(prev, current)); } +exports.mergeConcatMany = mergeConcatMany; diff --git a/lib/utils/module/combine.common.js b/lib/utils/module/combine.common.js index ca343e1..7691367 100644 --- a/lib/utils/module/combine.common.js +++ b/lib/utils/module/combine.common.js @@ -1,6 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = combineBaseModules; const tslib_1 = require("tslib"); const lodash_1 = require("../../utils/lodash"); const assert_1 = tslib_1.__importDefault(require("assert")); @@ -25,3 +24,4 @@ function combineBaseModules(...modules) { common: (0, lodash_1.mergeConcatArray)(prev.common, current.common), })); } +exports.default = combineBaseModules; diff --git a/lib/utils/module/combine.dev.d.ts b/lib/utils/module/combine.dev.d.ts index 7a543a4..35f1e69 100644 --- a/lib/utils/module/combine.dev.d.ts +++ b/lib/utils/module/combine.dev.d.ts @@ -5,7 +5,7 @@ import { EntityDict as BaseEntityDict } from '../../base-app-domain'; import { Aspect, Exportation, Importation, Routine, Timer, Trigger, Watcher } from '../../types'; export default function combineModuleDev, FrontCxt extends SyncContext>(...modules: string[]): { aspectDict: Record>; - data: { [T in keyof ED]?: Array; }; + data: { [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; }; importations: Importation; exportations: Exportation; watchers: Watcher[]; diff --git a/lib/utils/module/combine.dev.js b/lib/utils/module/combine.dev.js index 92f1ca5..d7999d1 100644 --- a/lib/utils/module/combine.dev.js +++ b/lib/utils/module/combine.dev.js @@ -1,6 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = combineModuleDev; const tslib_1 = require("tslib"); const combine_common_1 = tslib_1.__importDefault(require("./combine.common")); const lodash_1 = require("../../utils/lodash"); @@ -53,3 +52,4 @@ function combineModuleDev(...modules) { ...others, }; } +exports.default = combineModuleDev; diff --git a/lib/utils/module/combine.prod.js b/lib/utils/module/combine.prod.js index 39a1544..b3dc6c0 100644 --- a/lib/utils/module/combine.prod.js +++ b/lib/utils/module/combine.prod.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = combineModuleDev; const tslib_1 = require("tslib"); const combine_common_1 = tslib_1.__importDefault(require("./combine.common")); function combineModuleDev(...modules) { return (0, combine_common_1.default)(...modules); } +exports.default = combineModuleDev; diff --git a/lib/utils/module/combine.server.d.ts b/lib/utils/module/combine.server.d.ts index abb7ae7..b007c2a 100644 --- a/lib/utils/module/combine.server.d.ts +++ b/lib/utils/module/combine.server.d.ts @@ -5,7 +5,7 @@ import { EntityDict as BaseEntityDict } from '../../base-app-domain'; import { Aspect, Exportation, Importation, Routine, Timer, Trigger, Watcher } from '../../types'; export default function combineModuleServer, FrontCxt extends SyncContext>(...modules: string[]): { aspectDict: Record>; - data: { [T in keyof ED]?: Array; }; + data: { [T in keyof ED]?: ED[T]["OpSchema"][] | undefined; }; importations: Importation; exportations: Exportation; watchers: Watcher[]; diff --git a/lib/utils/module/combine.server.js b/lib/utils/module/combine.server.js index c4bce2c..34feae2 100644 --- a/lib/utils/module/combine.server.js +++ b/lib/utils/module/combine.server.js @@ -1,6 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = combineModuleServer; const tslib_1 = require("tslib"); const combine_common_1 = tslib_1.__importDefault(require("./combine.common")); const lodash_1 = require("../../utils/lodash"); @@ -53,3 +52,4 @@ function combineModuleServer(...modules) { ...others, }; } +exports.default = combineModuleServer; diff --git a/lib/utils/operationResult.js b/lib/utils/operationResult.js index 8ffa17d..75a5f4d 100644 --- a/lib/utils/operationResult.js +++ b/lib/utils/operationResult.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.mergeOperationResult = mergeOperationResult; +exports.mergeOperationResult = void 0; const lodash_1 = require("../utils/lodash"); function mergeOperationResult(result, toBeMerged) { for (const entity in toBeMerged) { @@ -16,3 +16,4 @@ function mergeOperationResult(result, toBeMerged) { } return result; } +exports.mergeOperationResult = mergeOperationResult; diff --git a/lib/utils/projection.js b/lib/utils/projection.js index 779108a..9ad22e6 100644 --- a/lib/utils/projection.js +++ b/lib/utils/projection.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeProjection = makeProjection; -exports.traverseProjection = traverseProjection; +exports.traverseProjection = exports.makeProjection = void 0; const Entity_1 = require("../types/Entity"); const relation_1 = require("../store/relation"); function makeProjection(entity, schema) { @@ -14,6 +13,7 @@ function makeProjection(entity, schema) { })); return projection; } +exports.makeProjection = makeProjection; function traverseProjection(entity, schema, projection, callback) { const access = (entity2, proj) => { callback(entity2, proj); @@ -32,3 +32,4 @@ function traverseProjection(entity, schema, projection, callback) { }; access(entity, projection); } +exports.traverseProjection = traverseProjection; diff --git a/lib/utils/random/random.js b/lib/utils/random/random.js index 51d523b..a32beb4 100644 --- a/lib/utils/random/random.js +++ b/lib/utils/random/random.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getRandomValues = getRandomValues; +exports.getRandomValues = void 0; const node_crypto_1 = require("node:crypto"); async function getRandomValues(length) { if (length > 65536) { @@ -16,3 +16,4 @@ async function getRandomValues(length) { }); }); } +exports.getRandomValues = getRandomValues; diff --git a/lib/utils/random/random.mp.d.ts b/lib/utils/random/random.mp.d.ts index ce9ddb9..9556b81 100644 --- a/lib/utils/random/random.mp.d.ts +++ b/lib/utils/random/random.mp.d.ts @@ -1 +1 @@ -export declare function getRandomValues(length: number): Promise>; +export declare function getRandomValues(length: number): Promise; diff --git a/lib/utils/random/random.mp.js b/lib/utils/random/random.mp.js index 904198b..071cadd 100644 --- a/lib/utils/random/random.mp.js +++ b/lib/utils/random/random.mp.js @@ -1,7 +1,7 @@ "use strict"; /// Object.defineProperty(exports, "__esModule", { value: true }); -exports.getRandomValues = getRandomValues; +exports.getRandomValues = void 0; async function getRandomValues(length) { if (length > 65536) { throw new Error('Can only request a maximum of 65536 bytes'); @@ -11,3 +11,4 @@ async function getRandomValues(length) { }); return new Uint8Array(randomValues); } +exports.getRandomValues = getRandomValues; diff --git a/lib/utils/random/random.native.d.ts b/lib/utils/random/random.native.d.ts index ce9ddb9..9556b81 100644 --- a/lib/utils/random/random.native.d.ts +++ b/lib/utils/random/random.native.d.ts @@ -1 +1 @@ -export declare function getRandomValues(length: number): Promise>; +export declare function getRandomValues(length: number): Promise; diff --git a/lib/utils/random/random.native.js b/lib/utils/random/random.native.js index cdb3dbf..cf78baa 100644 --- a/lib/utils/random/random.native.js +++ b/lib/utils/random/random.native.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getRandomValues = getRandomValues; +exports.getRandomValues = void 0; const tslib_1 = require("tslib"); const crypto_1 = tslib_1.__importDefault(require("crypto")); async function getRandomValues(length) { @@ -11,3 +11,4 @@ async function getRandomValues(length) { return new Uint8Array(randomValues); ; } +exports.getRandomValues = getRandomValues; diff --git a/lib/utils/random/random.web.d.ts b/lib/utils/random/random.web.d.ts index ce9ddb9..9556b81 100644 --- a/lib/utils/random/random.web.d.ts +++ b/lib/utils/random/random.web.d.ts @@ -1 +1 @@ -export declare function getRandomValues(length: number): Promise>; +export declare function getRandomValues(length: number): Promise; diff --git a/lib/utils/random/random.web.js b/lib/utils/random/random.web.js index ee3715c..d99156a 100644 --- a/lib/utils/random/random.web.js +++ b/lib/utils/random/random.web.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getRandomValues = getRandomValues; +exports.getRandomValues = void 0; async function getRandomValues(length) { if (length > 65536) { throw new Error('Can only request a maximum of 65536 bytes'); @@ -8,3 +8,4 @@ async function getRandomValues(length) { const randomValues = window.crypto.getRandomValues(new Uint8Array(length)); return new Uint8Array(randomValues); } +exports.getRandomValues = getRandomValues; diff --git a/lib/utils/relationPath.js b/lib/utils/relationPath.js index 81adbfb..8ca798a 100644 --- a/lib/utils/relationPath.js +++ b/lib/utils/relationPath.js @@ -1,8 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.destructRelationPath = destructRelationPath; -exports.destructDirectUserPath = destructDirectUserPath; -exports.destructDirectPath = destructDirectPath; +exports.destructDirectPath = exports.destructDirectUserPath = exports.destructRelationPath = void 0; const tslib_1 = require("tslib"); const assert_1 = tslib_1.__importDefault(require("assert")); const relation_1 = require("../store/relation"); @@ -108,6 +106,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) { }; return makeIter(entity, 0); } +exports.destructRelationPath = destructRelationPath; /** * 根据entity的相对path,找到其根结点以及相应的user对象 * @param schema @@ -132,6 +131,7 @@ function destructDirectUserPath(schema, entity, path) { } }; } +exports.destructDirectUserPath = destructDirectUserPath; /** * 根据entity的相对path,找到对应的根结点对象数据行 * @param schema @@ -270,3 +270,4 @@ function destructDirectPath(schema, entity, path) { }; return makeIter(entity, 0); } +exports.destructDirectPath = destructDirectPath; diff --git a/lib/utils/row.js b/lib/utils/row.js index 8174ada..4cab2db 100644 --- a/lib/utils/row.js +++ b/lib/utils/row.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.compareRow = compareRow; -exports.compareRows = compareRows; +exports.compareRows = exports.compareRow = void 0; const tslib_1 = require("tslib"); const lodash_1 = require("./lodash"); const relation_1 = require("../store/relation"); @@ -50,6 +49,7 @@ function compareRow(schema, entity, row1, row2) { } return true; } +exports.compareRow = compareRow; /** * 比较两行数据是否完全相等 * @param entity @@ -72,3 +72,4 @@ function compareRows(schema, entity, rows1, rows2) { } return true; } +exports.compareRows = compareRows; diff --git a/lib/utils/string.js b/lib/utils/string.js index 2f4d112..7f1c17e 100644 --- a/lib/utils/string.js +++ b/lib/utils/string.js @@ -1,15 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.randomPrefixedString = exports.random = exports.template = void 0; -exports.firstLetterLowerCase = firstLetterLowerCase; -exports.firstLetterUpperCase = firstLetterUpperCase; -exports.unescapeUnicode = unescapeUnicode; +exports.unescapeUnicode = exports.randomPrefixedString = exports.random = exports.template = exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0; function firstLetterLowerCase(s) { return s.slice(0, 1).toLowerCase().concat(s.slice(1)); } +exports.firstLetterLowerCase = firstLetterLowerCase; function firstLetterUpperCase(s) { return s.slice(0, 1).toUpperCase().concat(s.slice(1)); } +exports.firstLetterUpperCase = firstLetterUpperCase; /** * 模板字符串 使用 定义const NotFilled = template`${0}未填写`; 调用NotFilled('姓名') 等于姓名未填写 * @param strings @@ -66,4 +65,5 @@ function unescapeUnicode(str) { return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16)); }); } +exports.unescapeUnicode = unescapeUnicode; ; diff --git a/lib/utils/url/index.d.ts b/lib/utils/url/index.d.ts index 3522c70..d8bb525 100644 --- a/lib/utils/url/index.d.ts +++ b/lib/utils/url/index.d.ts @@ -1,3 +1,4 @@ +/// import { URL, URLSearchParams } from 'node:url'; import type { UrlObject } from 'node:url'; declare const url: typeof URL; diff --git a/lib/utils/url/index.native.d.ts b/lib/utils/url/index.native.d.ts index 5cbc99c..018f740 100644 --- a/lib/utils/url/index.native.d.ts +++ b/lib/utils/url/index.native.d.ts @@ -1,13 +1,12 @@ declare const url: { - new (url: string | URL, base?: string | URL): URL; + new (url: string | URL, base?: string | URL | undefined): URL; prototype: URL; - canParse(url: string | URL, base?: string | URL): boolean; + canParse(url: string | URL, base?: string | undefined): boolean; createObjectURL(obj: Blob | MediaSource): string; - parse(url: string | URL, base?: string | URL): URL | null; revokeObjectURL(url: string): void; }; declare const urlSearchParams: { - new (init?: string[][] | Record | string | URLSearchParams): URLSearchParams; + new (init?: string | string[][] | Record | URLSearchParams | undefined): URLSearchParams; prototype: URLSearchParams; }; export { url, urlSearchParams }; diff --git a/lib/utils/url/index.web.d.ts b/lib/utils/url/index.web.d.ts index 5cbc99c..018f740 100644 --- a/lib/utils/url/index.web.d.ts +++ b/lib/utils/url/index.web.d.ts @@ -1,13 +1,12 @@ declare const url: { - new (url: string | URL, base?: string | URL): URL; + new (url: string | URL, base?: string | URL | undefined): URL; prototype: URL; - canParse(url: string | URL, base?: string | URL): boolean; + canParse(url: string | URL, base?: string | undefined): boolean; createObjectURL(obj: Blob | MediaSource): string; - parse(url: string | URL, base?: string | URL): URL | null; revokeObjectURL(url: string): void; }; declare const urlSearchParams: { - new (init?: string[][] | Record | string | URLSearchParams): URLSearchParams; + new (init?: string | string[][] | Record | URLSearchParams | undefined): URLSearchParams; prototype: URLSearchParams; }; export { url, urlSearchParams }; diff --git a/lib/utils/url/whatwg-url/lib/URL-impl.d.ts b/lib/utils/url/whatwg-url/lib/URL-impl.d.ts index 722840c..99b9e2a 100644 --- a/lib/utils/url/whatwg-url/lib/URL-impl.d.ts +++ b/lib/utils/url/whatwg-url/lib/URL-impl.d.ts @@ -1,25 +1,18 @@ declare const _default: { implementation: { new (globalObject: any, constructorArgs: any): { - get href(): string; - set href(v: string); - get origin(): any; - get protocol(): string; - set protocol(v: string); + href: string; + readonly origin: any; + protocol: string; username: any; password: any; - get host(): any; - set host(v: any); - get hostname(): any; - set hostname(v: any); - get port(): string; - set port(v: string); + host: any; + hostname: any; + port: string; pathname: any; - get search(): string; - set search(v: string); + search: string; readonly searchParams: any; - get hash(): string; - set hash(v: string); + hash: string; toJSON(): string; }; }; diff --git a/lib/utils/url/whatwg-url/lib/infra.js b/lib/utils/url/whatwg-url/lib/infra.js index d4b214f..805606f 100644 --- a/lib/utils/url/whatwg-url/lib/infra.js +++ b/lib/utils/url/whatwg-url/lib/infra.js @@ -1,21 +1,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isASCIIDigit = isASCIIDigit; -exports.isASCIIAlpha = isASCIIAlpha; -exports.isASCIIAlphanumeric = isASCIIAlphanumeric; -exports.isASCIIHex = isASCIIHex; +exports.isASCIIHex = exports.isASCIIAlphanumeric = exports.isASCIIAlpha = exports.isASCIIDigit = void 0; function isASCIIDigit(c) { return c >= 0x30 && c <= 0x39; } +exports.isASCIIDigit = isASCIIDigit; function isASCIIAlpha(c) { return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); } +exports.isASCIIAlpha = isASCIIAlpha; function isASCIIAlphanumeric(c) { return isASCIIAlpha(c) || isASCIIDigit(c); } +exports.isASCIIAlphanumeric = isASCIIAlphanumeric; function isASCIIHex(c) { return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); } +exports.isASCIIHex = isASCIIHex; exports.default = { isASCIIDigit, isASCIIAlpha, diff --git a/lib/utils/url/whatwg-url/lib/urlencoded.d.ts b/lib/utils/url/whatwg-url/lib/urlencoded.d.ts index 76f9344..00201c3 100644 --- a/lib/utils/url/whatwg-url/lib/urlencoded.d.ts +++ b/lib/utils/url/whatwg-url/lib/urlencoded.d.ts @@ -1,6 +1,8 @@ +/// +/// import { Buffer, WithImplicitCoercion } from 'buffer'; declare function percentEncode(c: number): string; -declare function percentDecode(input: Buffer): Buffer; +declare function percentDecode(input: Buffer): Buffer; declare function serializeUrlencoded(tuples: any[], encodingOverride?: undefined): string; declare function parseUrlencoded(input: WithImplicitCoercion): string[][]; declare function ucs2decode(string: string): number[]; diff --git a/lib/utils/url/whatwg-url/lib/utils.d.ts b/lib/utils/url/whatwg-url/lib/utils.d.ts index 9b9cd74..6ab82e5 100644 --- a/lib/utils/url/whatwg-url/lib/utils.d.ts +++ b/lib/utils/url/whatwg-url/lib/utils.d.ts @@ -1,4 +1,4 @@ -declare function isObject(value: null): value is never; +declare function isObject(value: null): boolean; declare function hasOwn(obj: any, prop: PropertyKey): boolean; declare function getSameObject(wrapper: any, prop: string, creator: () => any): any; declare function wrapperForImpl(impl: any): any; diff --git a/lib/utils/uuid.js b/lib/utils/uuid.js index e954226..e16c851 100644 --- a/lib/utils/uuid.js +++ b/lib/utils/uuid.js @@ -1,15 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.sequentialUuid = sequentialUuid; -exports.shrinkUuidTo32Bytes = shrinkUuidTo32Bytes; -exports.expandUuidTo36Bytes = expandUuidTo36Bytes; -exports.generateNewIdAsync = generateNewIdAsync; -exports.produceIds = produceIds; -exports.setGenerateIdOption = setGenerateIdOption; -exports.generateNewId = generateNewId; -exports.formUuid = formUuid; -exports.compressTo32 = compressTo32; -exports.decompressFrom32 = decompressFrom32; +exports.decompressFrom32 = exports.compressTo32 = exports.formUuid = exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0; // import { v4 } from 'uuid'; const random_1 = require("./random/random"); let _nodeId; @@ -109,12 +100,15 @@ function sequentialUuid({ random }) { } return unsafeStringify(b); } +exports.sequentialUuid = sequentialUuid; function shrinkUuidTo32Bytes(uuid) { return uuid.replace(/\-/g, ''); } +exports.shrinkUuidTo32Bytes = shrinkUuidTo32Bytes; function expandUuidTo36Bytes(uuidShrinked) { return `${uuidShrinked.slice(0, 8)}-${uuidShrinked.slice(8, 12)}-${uuidShrinked.slice(12, 16)}-${uuidShrinked.slice(16, 20)}-${uuidShrinked.slice(20)}`; } +exports.expandUuidTo36Bytes = expandUuidTo36Bytes; // 直接生成uuid的接口,为了适配各种环境,写成异步 async function generateNewIdAsync(option) { const option2 = option || ID_OPTION; @@ -123,6 +117,7 @@ async function generateNewIdAsync(option) { } */ return sequentialUuid({ random: await (0, random_1.getRandomValues)(16) }); } +exports.generateNewIdAsync = generateNewIdAsync; // 实现同步的id缓存接口,以便于前台使用 const ID_BUFFER = []; let ID_OPTION = {}; @@ -132,12 +127,14 @@ async function produceIds() { ID_BUFFER.push(await generateNewIdAsync()); } } +exports.produceIds = produceIds; produceIds(); function setGenerateIdOption(option) { ID_OPTION = option; ID_BUFFER.splice(0, ID_BUFFER.length); return produceIds(); } +exports.setGenerateIdOption = setGenerateIdOption; function generateNewId() { if (ID_BUFFER.length > 0) { const id = ID_BUFFER.pop(); @@ -159,6 +156,7 @@ function generateNewId() { return sequentialUuid({ random }); } } +exports.generateNewId = generateNewId; function stringToArrayBuffer(str) { var bytes = new Array(); var len, c; @@ -217,9 +215,11 @@ function formUuid(...input) { } while (i < 16); return unsafeStringify(b); } +exports.formUuid = formUuid; function compressTo32(uuid) { return uuid.replace(/-/g, ''); } +exports.compressTo32 = compressTo32; function decompressFrom32(compressed) { return [ compressed.slice(0, 8), @@ -229,3 +229,4 @@ function decompressFrom32(compressed) { compressed.slice(20) ].join('-'); } +exports.decompressFrom32 = decompressFrom32; diff --git a/lib/utils/validator.js b/lib/utils/validator.js index 6bbe544..0b9e763 100644 --- a/lib/utils/validator.js +++ b/lib/utils/validator.js @@ -3,9 +3,7 @@ */ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.isDomain = exports.isIP = exports.isIPV6 = exports.isIPV4 = exports.isEmail = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isTel = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0; -exports.checkAttributesNotNull = checkAttributesNotNull; -exports.checkAttributesScope = checkAttributesScope; +exports.isDomain = exports.isIP = exports.isIPV6 = exports.isIPV4 = exports.checkAttributesScope = exports.checkAttributesNotNull = exports.isEmail = exports.isVehicleNumber = exports.isMoney = exports.isNumber = exports.isTel = exports.isPhone = exports.isDigital = exports.isSizedCaptcha = exports.isNickname = exports.isUrl = exports.isSoldierNumber = exports.isBirthNumber = exports.isTwCardNumber = exports.isAmCardNumber = exports.isHkCardNumber = exports.isPassportNumber = exports.isIdCardNumber = exports.isCaptcha = exports.isPassword = exports.isMobile = void 0; const types_1 = require("../types"); const isMobile = (text) => { return ((text) && (typeof text === "string") && ((/^1[3|4|5|6|7|8|9]\d{9}$/.test(text)))); @@ -124,6 +122,7 @@ function checkAttributesNotNull(entity, data, attributes, allowEmpty) { throw new types_1.OakAttrNotNullException(entity, attrs, 'error::attributesNull'); } } +exports.checkAttributesNotNull = checkAttributesNotNull; ; function checkAttributesScope(entity, data, attributes) { const attrs = attributes.filter(attr => !data.hasOwnProperty(attr)); @@ -131,6 +130,7 @@ function checkAttributesScope(entity, data, attributes) { throw new types_1.OakInputIllegalException(entity, attrs, 'error::attributesCantUpdate'); } } +exports.checkAttributesScope = checkAttributesScope; const isIPV4 = (ip) => { // IPv4正则 const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; diff --git a/lib/utils/version.js b/lib/utils/version.js index 0ded9a4..7c7846b 100644 --- a/lib/utils/version.js +++ b/lib/utils/version.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.compareVersion = compareVersion; -exports.isVersion = isVersion; +exports.isVersion = exports.compareVersion = void 0; /** * 版本比较 * @param curVersion 当前版本 @@ -19,6 +18,7 @@ function compareVersion(curVersion, reqVersion) { } return 0; } +exports.compareVersion = compareVersion; ; /** * 是不是一个有效的版本号 @@ -28,3 +28,4 @@ function compareVersion(curVersion, reqVersion) { function isVersion(version) { return /([1-9][0-9]*|[0-9])\.([1-9][0-9]*|[0-9])*\.([1-9][0-9]*|[0-9])*(\-[0-9A-Za-z-](\.[0-9A-Za-z-])*)*/g.test(version); } +exports.isVersion = isVersion; diff --git a/src/compiler/schemalBuilder.ts b/src/compiler/schemalBuilder.ts index 8b78989..cc36017 100644 --- a/src/compiler/schemalBuilder.ts +++ b/src/compiler/schemalBuilder.ts @@ -646,6 +646,13 @@ function dealWithActionTypeNode(moduleName: string, filename: string, actionType ); } +/** + * + * @param moduleName + * @param initializer + * @param program + * @returns 返回是否显式定义了is + */ function dealWithActionDefInitializer(moduleName: string, initializer: ts.Expression, program: ts.Program) { if (ts.isIdentifier(initializer) || ts.isCallExpression(initializer)) { // 是从别处的引用,注入到mportActionDefFrom @@ -659,10 +666,22 @@ function dealWithActionDefInitializer(moduleName: string, initializer: ts.Expres const importDeclartion = declaration.parent.parent.parent; addImportedFrom(moduleName, identifier.text, importDeclartion as ts.ImportDeclaration); + + // todo,要去分析外部引用的actionDef中的is,目前只有src/action/action.ts中的makeAbleActionDef,这种情况无法在编译时确定is是否为空,统一设置为空 + return false; } else { // 本地定义的actionDef,不用处理 assert(ts.isObjectLiteralExpression(initializer), moduleName); + if (ts.isObjectLiteralExpression(initializer)) { + const { properties } = initializer; + const isProp = properties.find( + (ele) => ts.isPropertyAssignment(ele) && ts.isIdentifier(ele.name) && ele.name.text === 'is' + ); + + return !!isProp; + } + return false; } } @@ -973,7 +992,7 @@ function analyzeSchemaDefinition( path: string, program: ts.Program, referencedSchemas: string[], - schemaAttrs: ts.TypeElement[], + schemaAttrDict: Record, enumAttributes: Record, importAttrFrom: Record, relativePath?: string @@ -1020,7 +1039,7 @@ function analyzeSchemaDefinition( sourceFile, program, referencedSchemas, - schemaAttrs, + schemaAttrDict, enumAttributes, importAttrFrom, PathLib.join(from, '..') @@ -1041,7 +1060,9 @@ function analyzeSchemaDefinition( && ts.isIdentifier(type.typeName)) { if ((referencedSchemas.includes(type.typeName.text) || type.typeName.text === 'Schema')) { addRelationship(moduleName, type.typeName.text, attrName, !!questionToken); - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + assert(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; } else if (type.typeName.text === 'Array') { // 这是一对多的反向指针的引用,需要特殊处理 @@ -1071,7 +1092,9 @@ function analyzeSchemaDefinition( } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + assert(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; const enumStringValues = tryGetStringLiteralValues(moduleName, filename, `attr-${attrName}`, type, program); if (enumStringValues.length > 0) { enumAttributes[attrName] = enumStringValues; @@ -1104,13 +1127,17 @@ function analyzeSchemaDefinition( } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + assert(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; analyzeExternalAttrImport(type.elementType, program, importAttrFrom, relativePath); // throw new Error(`对象${moduleName}中定义的属性${attrName}是不可识别的数组类别`); } } else { - schemaAttrs.push(attrNode); + // schemaAttrs.push(attrNode); + assert(!schemaAttrDict[attrName], `「${filename}」的属性定义「${attrName}」发生了重复`); + schemaAttrDict[attrName] = attrNode; if (ts.isUnionTypeNode(type!) && ts.isLiteralTypeNode(type.types[0]) && ts.isStringLiteral(type.types[0].literal)) { assert(ts.isIdentifier(name), `「${filename}」中的属性定义不是String类型`); const { types } = type; @@ -1203,7 +1230,7 @@ function analyzeReferenceSchemaFile( sourceFile: ts.SourceFile, program: ts.Program, referencedSchemas: string[], - schemaAttrs: ts.TypeElement[], + schemaAttrDict: Record, enumAttributes: Record, importAttrFrom: Record, relativePath: string) { @@ -1223,7 +1250,7 @@ function analyzeReferenceSchemaFile( path, program, referencedSchemas, - schemaAttrs, + schemaAttrDict, enumAttributes, importAttrFrom, relativePath @@ -1263,7 +1290,8 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela checkNameLegal(filename, moduleName, true); const referencedSchemas: string[] = []; - const schemaAttrs: ts.TypeElement[] = []; + // const schemaAttrs: ts.TypeElement[] = []; + const schemaAttrDict: Record = {}; let hasFulltextIndex: boolean = false; let indexes: ts.ArrayLiteralExpression; let beforeSchema = true; @@ -1297,7 +1325,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela path, program, referencedSchemas, - schemaAttrs, + schemaAttrDict, enumAttributes, importAttrFrom, relativePath @@ -1494,21 +1522,20 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela assert(enumStateValues.length > 0, `文件${filename}中的state${(stateNode.typeName).text}定义不是字符串类型`) pushStatementIntoActionAst(moduleName, node, sourceFile!); - dealWithActionDefInitializer(moduleName, declaration.initializer!, program); + const isDefined = dealWithActionDefInitializer(moduleName, declaration.initializer!, program); assert(ts.isIdentifier(declaration.name)); const adName = declaration.name.text.slice(0, declaration.name.text.length - 9); const attr = adName.concat('State'); - schemaAttrs.push( - factory.createPropertySignature( + assert(!schemaAttrDict[attr], `文件${filename}中的${attr}有显式定义,与ActionDef需要生成的属性冲突`); + schemaAttrDict[attr] = factory.createPropertySignature( undefined, firstLetterLowerCase(attr), - factory.createToken(ts.SyntaxKind.QuestionToken), + isDefined ? undefined : factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode( attr, ) - ) - ); + ); enumAttributes[firstLetterLowerCase(attr)] = enumStateValues; }; const dealWithIndexes = (declaration: ts.ArrayLiteralExpression) => { @@ -1586,7 +1613,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela const indexAttrName = (nameProperty.initializer!).text; if (!initinctiveAttributes.includes(indexAttrName)) { - const schemaNode = schemaAttrs.find( + const schemaNode = Object.values(schemaAttrDict).find( (ele3) => { assert(ts.isPropertySignature(ele3)); return (ele3.name).text === indexAttrName; @@ -1859,6 +1886,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela if (hasActionDef && actionType !== 'crud') { throw new Error(`${filename}中有Action定义,但却定义了actionType不是crud`); } + const schemaAttrs = Object.values(schemaAttrDict); assert(schemaAttrs.length > 0, `对象${moduleName}没有任何属性定义`); const schema = { schemaAttrs, @@ -9003,26 +9031,6 @@ export function analyzeEntities(inputDir: string, relativePath?: string) { uniqRelationships(); } -export function buildSchemaBackup(outputDir: string): void { - addReverseRelationship(); - // setRelationEntities(); - const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed }); - resetOutputDir(outputDir); - outputSchema(outputDir, printer); - outputLocale(outputDir, printer); - outputSubQuery(outputDir, printer); - outputAction(outputDir, printer); - outputEntityDict(outputDir, printer); - outputStorage(outputDir, printer); - outputRelation2(outputDir, printer); - outputStyleDict(outputDir, printer); - outputIndexTs(outputDir); - - - if (!process.env.COMPLING_AS_LIB) { - outputPackageJson(outputDir); - } -} function _getAggrKey(entity: string, foreignKey: string) { const aggrKey = `${entity}$${foreignKey}`; diff --git a/test/test.ts b/test/test.ts index d1af39a..d6c6b7d 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,15 +1,7 @@ -type A = { - name?: string; -} +const a = new RegExp('(varchar|char)\\((\\d+)\\)'); -function test(a: A) { +console.log('a', a.exec('varchar(64)')); -} +const b = /(varchar|char)\((\d+)\)/; -type B = { - [A in 'name' | 'age']?: string; -} - -const b : B = {}; - -test(b); \ No newline at end of file +console.log('b:', b.exec('varchar(64)')) \ No newline at end of file