Merge branch 'release'
This commit is contained in:
commit
74eafdea3b
|
|
@ -124,7 +124,13 @@ class LocaleBuilder {
|
|||
const content = fs_1.default.readFileSync(filepath, {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
return JSON.parse(content);
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(`parse ${filepath} error`, err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
parseFile(module, namespace, position, filename, filepath, watch) {
|
||||
const language = (filename.split('.')[0]).replace('_', '-'); // 历史原因,会命名成zh_CN.json
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ function getImportedFilePath(path, fileSpecifierPath, filename) {
|
|||
return '';
|
||||
};
|
||||
if (fileSpecifierPath.startsWith('.')) {
|
||||
importedFilepath = path_1.default.join(process.cwd(), path, fileSpecifierPath);
|
||||
importedFilepath = path_1.default.join(path, fileSpecifierPath);
|
||||
const importedFilename = getExistedFileName();
|
||||
(0, assert_1.default)(importedFilename, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`);
|
||||
return importedFilename;
|
||||
|
|
@ -2236,7 +2236,7 @@ function constructOperations(statements, entity) {
|
|||
}
|
||||
if (manyToOneSet) {
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[1])) {
|
||||
if (one[1] !== 'entity') {
|
||||
foreignKeyAttr.push(`${one[1]}Id`);
|
||||
}
|
||||
}
|
||||
|
|
@ -2260,7 +2260,7 @@ function constructOperations(statements, entity) {
|
|||
*/
|
||||
const upsertOneNodes = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
const oneEntity = one[0];
|
||||
const cascadeCreateNode = factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(undefined, factory.createIdentifier(`${one[1]}Id`), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)),
|
||||
|
|
@ -2472,7 +2472,7 @@ function constructOperations(statements, entity) {
|
|||
}
|
||||
if (manyToOneSet) {
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[1])) {
|
||||
if (one[1] !== 'entity') {
|
||||
foreignKeyAttr.push(`${one[1]}Id`);
|
||||
}
|
||||
}
|
||||
|
|
@ -2494,7 +2494,7 @@ function constructOperations(statements, entity) {
|
|||
*/
|
||||
const upsertOneNodes = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
const cascadeCreateNode = factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(undefined, factory.createIdentifier(one[1]), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(createForeignRef(entity, one[0], 'CreateSingleOperation'))),
|
||||
factory.createPropertySignature(undefined, factory.createIdentifier(`${one[1]}Id`), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)),
|
||||
|
|
@ -2777,7 +2777,7 @@ function constructOperations(statements, entity) {
|
|||
*/
|
||||
const upsertOneNodes = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
if (!Schema[one[0]].static) {
|
||||
switch (Schema[one[0]].actionType) {
|
||||
case 'crud': {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|||
const fn = (async ({ operation }, context, option) => {
|
||||
const { filter: operationFilter, data, action, bornAt } = operation;
|
||||
const filter2 = typeof filter === 'function' ? await filter(operation, context, option) : filter;
|
||||
if (!filter2) {
|
||||
return 0;
|
||||
}
|
||||
if (['select', 'count', 'stat'].includes(action)) {
|
||||
operation.filter = (0, filter_1.combineFilters)(entity, context.getSchema(), [operationFilter, filter2]);
|
||||
return 0;
|
||||
|
|
@ -142,6 +145,9 @@ function translateCheckerInSyncContext(checker, schema) {
|
|||
const fn = (operation, context, option) => {
|
||||
const { filter: operationFilter, data, action, bornAt } = operation;
|
||||
const filter2 = typeof filter === 'function' ? filter(operation, context, option) : filter;
|
||||
if (!filter2) {
|
||||
return;
|
||||
}
|
||||
let operationFilter2 = operationFilter;
|
||||
if (action === 'create') {
|
||||
if (data) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReadOnlyAction } from "../actions/action";
|
||||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { EntityDict, OperationResult } from "./Entity";
|
||||
type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
|
||||
|
|
@ -5,7 +6,7 @@ export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|||
name: string;
|
||||
entity: T;
|
||||
filter: ED[T]['Selection']['filter'] | (() => ED[T]['Selection']['filter']);
|
||||
action: ED[T]['Operation']['action'];
|
||||
action: Omit<ED[T]['Action'], 'create' | ReadOnlyAction>;
|
||||
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
||||
}
|
||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "oak-domain",
|
||||
"version": "5.0.8",
|
||||
"version": "5.0.9",
|
||||
"author": {
|
||||
"name": "XuChang"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -208,7 +208,13 @@ export default class LocaleBuilder {
|
|||
const content = fs.readFileSync(filepath, {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
return JSON.parse(content);
|
||||
try {
|
||||
return JSON.parse(content);
|
||||
}
|
||||
catch (err) {
|
||||
console.error(`parse ${filepath} error`, err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
private parseFile(module: string, namespace: string, position: string, filename: string, filepath: string, watch?: boolean) {
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ function getImportedFilePath(path: string, fileSpecifierPath: string, filename:
|
|||
};
|
||||
|
||||
if (fileSpecifierPath.startsWith('.')) {
|
||||
importedFilepath = PathLib.join(process.cwd(), path, fileSpecifierPath);
|
||||
importedFilepath = PathLib.join(path, fileSpecifierPath);
|
||||
const importedFilename = getExistedFileName();
|
||||
assert(importedFilename, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`);
|
||||
return importedFilename;
|
||||
|
|
@ -3567,7 +3567,7 @@ function constructOperations(statements: Array<ts.Statement>, entity: string) {
|
|||
}
|
||||
if (manyToOneSet) {
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[1])) {
|
||||
if (one[1] !== 'entity') {
|
||||
foreignKeyAttr.push(`${one[1]}Id`);
|
||||
}
|
||||
}
|
||||
|
|
@ -3607,7 +3607,7 @@ function constructOperations(statements: Array<ts.Statement>, entity: string) {
|
|||
*/
|
||||
const upsertOneNodes: ts.TypeNode[] = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
const oneEntity = one[0];
|
||||
const cascadeCreateNode = factory.createTypeLiteralNode(
|
||||
[
|
||||
|
|
@ -4081,7 +4081,7 @@ function constructOperations(statements: Array<ts.Statement>, entity: string) {
|
|||
}
|
||||
if (manyToOneSet) {
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[1])) {
|
||||
if (one[1] !== 'entity') {
|
||||
foreignKeyAttr.push(`${one[1]}Id`);
|
||||
}
|
||||
}
|
||||
|
|
@ -4117,7 +4117,7 @@ function constructOperations(statements: Array<ts.Statement>, entity: string) {
|
|||
*/
|
||||
const upsertOneNodes: ts.TypeNode[] = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
const cascadeCreateNode = factory.createTypeLiteralNode(
|
||||
[
|
||||
factory.createPropertySignature(
|
||||
|
|
@ -4734,7 +4734,7 @@ function constructOperations(statements: Array<ts.Statement>, entity: string) {
|
|||
*/
|
||||
const upsertOneNodes: ts.TypeNode[] = [];
|
||||
for (const one of manyToOneSet) {
|
||||
if (!ReversePointerRelations[entity] || !ReversePointerRelations[entity].includes(one[0])) {
|
||||
if (one[1] !== 'entity') {
|
||||
if (!Schema[one[0]].static) {
|
||||
switch (Schema[one[0]].actionType) {
|
||||
case 'crud': {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ function createExpiredWatchers<ED extends EntityDict & BaseEntityDict>(schema: S
|
|||
},
|
||||
};
|
||||
},
|
||||
action: 'update',
|
||||
action: 'update' as any,
|
||||
actionData: {
|
||||
expired: true,
|
||||
} as ED[keyof ED]['Update']['data'],
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ export function translateCheckerInAsyncContext<
|
|||
const fn = (async ({ operation }, context, option) => {
|
||||
const { filter: operationFilter, data, action, bornAt } = operation;
|
||||
const filter2 = typeof filter === 'function' ? await filter(operation, context, option) : filter;
|
||||
if (!filter2) {
|
||||
return 0;
|
||||
}
|
||||
if (['select', 'count', 'stat'].includes(action)) {
|
||||
operation.filter = combineFilters(entity, context.getSchema(), [operationFilter, filter2]);
|
||||
return 0;
|
||||
|
|
@ -163,6 +166,9 @@ export function translateCheckerInSyncContext<
|
|||
const fn = (operation: ED[T]['Operation'], context: Cxt, option: OperateOption | SelectOption) => {
|
||||
const { filter: operationFilter, data, action, bornAt } = operation;
|
||||
const filter2 = typeof filter === 'function' ? filter(operation, context, option) : filter;
|
||||
if (!filter2) {
|
||||
return;
|
||||
}
|
||||
let operationFilter2 = operationFilter;
|
||||
if (action === 'create') {
|
||||
if (data) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { ReadOnlyAction } from "../actions/action";
|
||||
import { AsyncContext } from "../store/AsyncRowStore";
|
||||
import { SyncContext } from "../store/SyncRowStore";
|
||||
import { EntityDict, OperationResult } from "./Entity";
|
||||
|
|
@ -8,7 +9,7 @@ export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|||
name: string;
|
||||
entity: T;
|
||||
filter: ED[T]['Selection']['filter'] | (() => ED[T]['Selection']['filter']);
|
||||
action: ED[T]['Operation']['action'];
|
||||
action: Omit<ED[T]['Action'], 'create' | ReadOnlyAction>;
|
||||
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
||||
};
|
||||
|
||||
|
|
|
|||
10
test/test.ts
10
test/test.ts
|
|
@ -6,12 +6,8 @@ while (iter > 0) {
|
|||
console.log(generateNewId());
|
||||
iter --;
|
||||
} */
|
||||
import { compressTo32, decompressFrom32 } from '../src/utils/uuid';
|
||||
import dayJs from 'dayjs';
|
||||
|
||||
const uuid = "cce4044b-72bc-4c7d-a5a5-fc660eb2d8a7";
|
||||
const d = dayJs('2018-06-08T10:34:56+08:00');
|
||||
|
||||
console.log(uuid, uuid.length);
|
||||
const compressed = compressTo32(uuid);
|
||||
console.log(compressed, compressed.length);
|
||||
const decompressed = decompressFrom32(compressed);
|
||||
console.log(decompressed, decompressed.length);
|
||||
console.log(d.year());
|
||||
Loading…
Reference in New Issue