kmore-types
Advanced tools
Comparing version 0.14.0 to 0.15.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.15.0](https://github.com/waitingsong/kmore/compare/v0.14.0...v0.15.0) (2020-03-20) | ||
### Features | ||
* **kmore:** rb.tb_foo() support generics parameters ([58f8e32](https://github.com/waitingsong/kmore/commit/58f8e3216131a76e069b4d08e258a3dec9e5b7cf)) | ||
* types, parameters, scopedColumns ([46ef95d](https://github.com/waitingsong/kmore/commit/46ef95d11fd50b8313034f3e395f3c337c15b561)) | ||
# [0.14.0](https://github.com/waitingsong/kmore/compare/v0.13.1...v0.14.0) (2020-01-16) | ||
@@ -8,0 +20,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 0.13.1 | ||
* @version 0.14.0 | ||
* @author waiting | ||
@@ -28,3 +28,4 @@ * @license MIT | ||
...initGenTbListFromTypeOpts, | ||
exportVarPrefix: 'tbs', | ||
exportVarPrefix: 'tbs_', | ||
exportVarColsSuffix: '_cols', | ||
forceLoadTbListJs: false, | ||
@@ -50,6 +51,8 @@ forceLoadTbListJsPathReplaceRules: null, | ||
DbPropKeys["tables"] = "tables"; | ||
DbPropKeys["columns"] = "columns"; | ||
DbPropKeys["scopedColumns"] = "scopedColumns"; | ||
DbPropKeys["refTables"] = "rb"; | ||
})(exports.DbPropKeys || (exports.DbPropKeys = {})); | ||
const defaultPropDescriptor = { | ||
configurable: false, | ||
configurable: true, | ||
enumerable: true, | ||
@@ -61,2 +64,3 @@ writable: false, | ||
tbListMap: new Map(), | ||
tbColListMap: new Map(), | ||
/** CallerId -> LocalTypeId */ | ||
@@ -68,2 +72,8 @@ callerIdToLocalTypeIdMap: new Map(), | ||
(function (ColumnExtPropKeys) { | ||
ColumnExtPropKeys["tableAlias"] = "_tableAlias"; | ||
ColumnExtPropKeys["tablesRef"] = "_tablesRef"; | ||
ColumnExtPropKeys["sColsCacheMap"] = "_scopedColsCacheMap"; | ||
})(exports.ColumnExtPropKeys || (exports.ColumnExtPropKeys = {})); | ||
/** Allow empty Object */ | ||
@@ -199,2 +209,59 @@ function validateParamTables(tbs) { | ||
} | ||
/** Build DbTableCols from TableColListTagMap */ | ||
function buildTbColListParam(tagMap) { | ||
const ret = createNullObject(); | ||
if (tagMap && tagMap.size) { | ||
tagMap.forEach((colListTagMap, tb) => { | ||
const cols = createNullObject(); | ||
colListTagMap.forEach((_tags, col) => { | ||
Object.defineProperty(cols, col, { | ||
...defaultPropDescriptor, | ||
value: col, | ||
}); | ||
}); | ||
Object.defineProperty(ret, tb, { | ||
...defaultPropDescriptor, | ||
value: cols, | ||
}); | ||
}); | ||
} | ||
else { | ||
throw new TypeError('Value of tagMap invalid.'); | ||
} | ||
return ret; | ||
} | ||
/** Build DbTableScopedCols from TableColListTagMap */ | ||
// export function buildTbScopedColListParam<T extends TTables>( | ||
// tagMap: TbColListTagMap, | ||
// tables: DbTables<T>, | ||
// ): DbTableScopedCols<T> { | ||
// const ret = createNullObject() | ||
// if (! tables || ! Object.keys(tables).length) { | ||
// return ret | ||
// } | ||
// if (tagMap && tagMap.size) { | ||
// tagMap.forEach((colListTagMap, tbAlias) => { | ||
// const tb = tbAlias as keyof DbTables<T> | ||
// if (typeof tables[tb] !== 'string') { | ||
// return | ||
// } | ||
// const tbName = tables[tb] | ||
// const cols = createNullObject() | ||
// colListTagMap.forEach((_tags, colAlias) => { | ||
// Object.defineProperty(cols, colAlias, { | ||
// ...defaultPropDescriptor, | ||
// value: `${tbName}.${colAlias}`, | ||
// }) | ||
// }) | ||
// Object.defineProperty(ret, tbAlias, { | ||
// ...defaultPropDescriptor, | ||
// value: cols, | ||
// }) | ||
// }) | ||
// } | ||
// else { | ||
// throw new TypeError('Value of tagMap invalid.') | ||
// } | ||
// return ret | ||
// } | ||
function isCallerNameMatched(name, matchFuncNameSet) { | ||
@@ -225,3 +292,3 @@ if (!name) { | ||
function genVarName(exportVarPrefix, line, column) { | ||
const varName = `${exportVarPrefix}_${line}_${column}`; | ||
const varName = `${exportVarPrefix}${line}_${column}`; | ||
return varName; | ||
@@ -239,7 +306,24 @@ } | ||
} | ||
function loadVarFromFile(path, caller, options) { | ||
const varName = genVarName(options.exportVarPrefix, caller.line, caller.column); | ||
function loadTableVarFromFile(loadOpts) { | ||
const kTables = loadVarFromFile(loadOpts); | ||
return kTables.tables; | ||
} | ||
function loadColumnVarFromFile(loadOpts) { | ||
const kTables = loadVarFromFile(loadOpts); | ||
return kTables.columns; | ||
} | ||
/** | ||
* Load kTables var from a js file | ||
*/ | ||
function loadVarFromFile(loadOpts) { | ||
const { path, caller, options } = loadOpts; | ||
const tbVarName = genVarName(options.exportVarPrefix, caller.line, caller.column); | ||
const colVarName = `${tbVarName}${options.exportVarColsSuffix}`; | ||
const mods = loadFile(path); | ||
if (mods && typeof mods[varName] === 'object') { | ||
return mods[varName]; | ||
if (mods && typeof mods[tbVarName] === 'object') { | ||
const tables = mods[tbVarName]; | ||
const columns = typeof mods[colVarName] === 'object' | ||
? mods[colVarName] | ||
: {}; | ||
return { tables, columns }; | ||
} | ||
@@ -361,10 +445,15 @@ throw new TypeError(`Load tables failed, path: "${path}"`); | ||
} | ||
function genCallerTypeMapFromNodeSet(nodes, checker, sourceFile, path) { | ||
function genCallerTypeMapFromNodeSet(nodes, checker, sourceFile, // sourceFileObject | ||
path) { | ||
const retMap = new Map(); | ||
nodes.forEach((node) => { | ||
const obj = genInfoFromNode({ | ||
node, checker, sourceFile, retMap, path, | ||
checker, | ||
node, | ||
path, | ||
sourceFile, | ||
}); | ||
if (obj) { | ||
retMap.set(obj.id, obj.tagMap); | ||
const { callerTypeId, tbTagMap, tbColTagMap } = obj; | ||
retMap.set(callerTypeId, [tbTagMap, tbColTagMap]); | ||
} | ||
@@ -375,25 +464,31 @@ }); | ||
function genInfoFromNode(options) { | ||
const { node, checker, sourceFile, retMap, path, } = options; | ||
const { node, checker, sourceFile, path, } = options; | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
/* istanbul ignore else */ | ||
if (node) { | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
/* istanbul ignore else */ | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (!sym) { | ||
return; | ||
} | ||
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); | ||
const inputTypeName = sym.getName(); | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:4:1:typeid-TbListModel" | ||
const callerTypeId = `${path}:${line + 1}:${character + 1}:typeid-${inputTypeName}`; | ||
// @ts-ignore | ||
// const gTypeId: number = typeof gType.id === 'number' ? gType.id : Math.random() | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:typeid-76" | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:typeid-TbListModel" | ||
const localTypeId = `${path}:typeid-${inputTypeName}`; | ||
const { tbTagMap, tbColTagMap } = genTbListTagMapFromSymbol(gType.symbol, checker); | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
// @ts-ignore | ||
const typeid = typeof gType.id === 'number' ? gType.id : Math.random(); | ||
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); | ||
const localTypeId = `${path}:${line + 1}:${character + 1}:typeid-${typeid}`; | ||
if (retMap.has(localTypeId)) { | ||
return; | ||
} | ||
else { | ||
const tagMap = genTbListTagMapFromSymbol(gType.symbol); | ||
/* istanbul ignore else */ | ||
if (tagMap.size) { | ||
return { id: localTypeId, tagMap }; | ||
} | ||
} | ||
if (tbTagMap.size) { | ||
return { | ||
callerTypeId, | ||
localTypeId, | ||
tbTagMap, | ||
tbColTagMap, | ||
}; | ||
} | ||
@@ -404,17 +499,57 @@ } | ||
// ---- compiler --- | ||
function genTbListTagMapFromSymbol(symbol) { | ||
function genTbListTagMapFromSymbol(symbol, checker) { | ||
const { members } = symbol; | ||
// Map<TableAlias, Map<TagName, TagComment> > | ||
const symbolTagMap = new Map(); | ||
const tbTagMap = new Map(); | ||
const tbColTagMap = new Map(); | ||
// const tbScopedColTagMap: TbScopedColListTagMap = new Map() | ||
/* istanbul ignore else */ | ||
if (members) { | ||
members.forEach((member) => { | ||
const name = member.getName(); | ||
const tags = member.getJsDocTags(); | ||
members.forEach((tbSym) => { | ||
const { name: tbName, tags } = retrieveInfoFromSymbolObject(tbSym); | ||
// tags can be empty array | ||
symbolTagMap.set(name, tags); | ||
tbTagMap.set(tbName, tags); | ||
const nodes = tbSym.getDeclarations(); | ||
if (nodes && nodes.length) { | ||
const colTagMap = genColListTagMapFromTbSymbol(nodes, checker); | ||
tbColTagMap.set(tbName, colTagMap); | ||
} | ||
}); | ||
} | ||
return symbolTagMap; | ||
return { tbTagMap, tbColTagMap }; | ||
} | ||
function genColListTagMapFromTbSymbol(nodes, checker) { | ||
const ret = new Map(); | ||
const [node] = nodes; // use only one | ||
const { type: typeRef } = node; | ||
if (typeRef && typeRef.getText()) { | ||
return retrieveMembersFromTypeRef(typeRef, checker); | ||
} | ||
return ret; | ||
} | ||
function retrieveMembersFromTypeRef(typeRef, // TypeReference | ||
checker) { | ||
const ret = new Map(); | ||
const gType = checker.getTypeAtLocation(typeRef); | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (sym) { | ||
const { members } = sym; | ||
if (members) { | ||
members.forEach((member) => { | ||
const { name: colName, tags } = retrieveInfoFromSymbolObject(member); | ||
ret.set(colName, tags); | ||
}); | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
function retrieveInfoFromSymbolObject(symbol) { | ||
return { | ||
name: symbol.getName(), | ||
tags: symbol.getJsDocTags(), | ||
}; | ||
} | ||
function retrieveGenericsIdentifierFromTypeArguments(node) { | ||
@@ -530,3 +665,3 @@ /* istanbul ignore else */ | ||
/** | ||
* Build tables in ts from generics type for specified file | ||
* Build tables in ts from generics type for specified ts file | ||
* | ||
@@ -540,3 +675,3 @@ * @returns file path if src file need parsed | ||
}; | ||
const ret = retrieveTypeFromFile(file); | ||
const ret = retrieveTypeFromTsFile(file); | ||
if (ret && ret.size) { | ||
@@ -550,3 +685,3 @@ const path = await saveFile(ret, opts); | ||
} | ||
function retrieveTypeFromFile(file) { | ||
function retrieveTypeFromTsFile(file) { | ||
const path = sharedCore.pathResolve(file).replace(/\\/gu, '/'); | ||
@@ -561,5 +696,6 @@ const { checker, sourceFile } = matchSourceFileWithFilePath(path); | ||
const callerTypeMap = genCallerTypeMapFromNodeSet(nodeSet, checker, sourceFile, path); | ||
callerTypeMap.forEach((tagMap, callerTypeId) => { | ||
const tbs = buildTbListParam(tagMap); | ||
ret.set(callerTypeId, tbs); | ||
callerTypeMap.forEach(([tbListTagMap, tbColListTagMap], callerTypeId) => { | ||
const tbs = buildTbListParam(tbListTagMap); | ||
const tbCols = buildTbColListParam(tbColListTagMap); | ||
ret.set(callerTypeId, [tbs, tbCols]); | ||
}); | ||
@@ -570,6 +706,6 @@ } | ||
function genTsCodeFromTypes(inputMap, options) { | ||
const { exportVarPrefix, outputFileNameSuffix } = options; | ||
const { exportVarPrefix, exportVarColsSuffix, outputFileNameSuffix, } = options; | ||
let targetPath = ''; | ||
const sourceArr = []; | ||
inputMap.forEach((arr, key) => { | ||
inputMap.forEach(([tbs, tbCols], key) => { | ||
const { path, line, column } = pickInfoFromCallerTypeId(key); | ||
@@ -580,4 +716,6 @@ if (!targetPath) { | ||
} | ||
const varName = genVarName(exportVarPrefix, line, column); | ||
sourceArr.push(`export const ${varName} = ${JSON.stringify(arr, null, 2)} as const`); | ||
const tbVarName = genVarName(exportVarPrefix, line, column); | ||
const tbColVarName = `${tbVarName}${exportVarColsSuffix}`; | ||
sourceArr.push(`export const ${tbVarName} = ${JSON.stringify(tbs, null, 2)} as const`); | ||
sourceArr.push(`export const ${tbColVarName} = ${JSON.stringify(tbCols, null, 2)} as const`); | ||
}); | ||
@@ -598,3 +736,3 @@ return [targetPath, sourceArr.join('\n\n')]; | ||
/** | ||
* Generate DbTables from generics type T | ||
* Generate KTables from generics type T | ||
*/ | ||
@@ -624,59 +762,55 @@ function genTbListFromType(options) { | ||
}; | ||
// "/kmore-mono/packages/kmore-types/test/test.config.ts:13:23" | ||
const callerId = `${caller.path}:${caller.line}:${caller.column}`; | ||
const localTypeId = opts.cacheMap.callerIdToLocalTypeIdMap.get(callerId); | ||
let ret = {}; | ||
if (localTypeId) { | ||
const tbListTagMap = opts.cacheMap.localTypeMap.get(localTypeId); | ||
if (!tbListTagMap) { | ||
if (localTypeId) { // from cache | ||
const tagsMapArr = opts.cacheMap.localTypeMap.get(localTypeId); | ||
if (tagsMapArr && tagsMapArr.length) { | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr); | ||
} | ||
else { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${localTypeId}".`); | ||
} | ||
else if (!tbListTagMap.size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${localTypeId}" value empty.`); | ||
} | ||
ret = buildTbListParam(tbListTagMap); | ||
} | ||
else { | ||
const localTypeMap = retrieveLocalTypeMapFromType(opts); | ||
const localTypeItem = retrieveLocalTypeItemFromType(opts); | ||
if (!localTypeItem) { | ||
throw new Error(`retrieveLocalTypeMapFromType() return empty with key: "${localTypeId}".`); | ||
} | ||
// id is localTypeId | ||
// map maybe empty | ||
localTypeMap.forEach((map, id) => { | ||
opts.cacheMap.callerIdToLocalTypeIdMap.set(callerId, id); | ||
// map can be empty as cached result | ||
if (map.size) { | ||
opts.cacheMap.localTypeMap.set(id, map); | ||
ret = buildTbListParam(map); | ||
// map maybe empty, so try from cache | ||
const { localTypeId: id, tagsMapArr } = localTypeItem; | ||
opts.cacheMap.callerIdToLocalTypeIdMap.set(callerId, id); | ||
if (tagsMapArr && tagsMapArr[0] && tagsMapArr[0].size) { | ||
opts.cacheMap.localTypeMap.set(id, tagsMapArr); | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr); | ||
} | ||
else { // retrieved only localTypeId, then try from cache | ||
const tagsMapArr2 = opts.cacheMap.localTypeMap.get(id); | ||
if (!tagsMapArr2) { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${id}" or value empty.`); | ||
} | ||
else { | ||
const cMap = opts.cacheMap.localTypeMap.get(id); | ||
if (!cMap) { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${id}" or value empty.`); | ||
} | ||
else if (!cMap.size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${id}" value empty.`); | ||
} | ||
ret = buildTbListParam(cMap); | ||
else if (!tagsMapArr2[0].size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${id}" value empty.`); | ||
} | ||
}); | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr2); | ||
} | ||
} | ||
} | ||
function buildKTablesBaseFromTagsMapArr(tagsMapArr) { | ||
const [tbListTagMap, tbColListTagMap] = tagsMapArr; | ||
const ret = { | ||
tables: buildTbListParam(tbListTagMap), | ||
columns: buildTbColListParam(tbColListTagMap), | ||
}; | ||
return ret; | ||
} | ||
function retrieveLocalTypeMapFromType(options) { | ||
const { checker, sourceFile } = matchSourceFileWithFilePath(options.caller.path); | ||
if (sourceFile) { | ||
const localTypeMap = genGenericsArgMap({ | ||
...options, | ||
sourceFile, | ||
checker, | ||
}); | ||
/* istanbul ignore else */ | ||
if (localTypeMap.size) { | ||
return localTypeMap; // retrieve succeed | ||
} | ||
function retrieveLocalTypeItemFromType(options) { | ||
const { caller } = options; | ||
const { checker, sourceFile } = matchSourceFileWithFilePath(caller.path); | ||
/* istanbul ignore else */ | ||
if (!sourceFile) { | ||
// throw new Error(`Can not retrieve generics type info from file: "${caller.path}"`) | ||
return; | ||
} | ||
// throw new Error(`Can not retrieve generics type info from file: "${caller.path}"`) | ||
return new Map(); | ||
} | ||
function genGenericsArgMap(options) { | ||
const retMap = new Map(); | ||
const { cacheMap, sourceFile, checker, caller, } = options; | ||
const node = walkNodeWithPosition({ | ||
@@ -690,32 +824,24 @@ sourceFile, | ||
if (node) { | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
/* istanbul ignore else */ | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
// const symbol = checker.getSymbolAtLocation(typeName) | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (sym) { | ||
const inputTypeName = sym.getName(); | ||
// might be type alias name so we use typdid | ||
// const genericsArgName: GenericsArgName = typeName.text | ||
// @ts-ignore | ||
// const typeid: number = typeof gType.id === 'number' ? gType.id : Math.random() | ||
const localTypeId = `${caller.path}:typeid-${inputTypeName}`; | ||
if (retMap.has(localTypeId)) { | ||
return retMap; | ||
} | ||
else if (cacheMap.localTypeMap.has(localTypeId)) { | ||
retMap.set(localTypeId, new Map()); // empty map, pick from resolved data later. | ||
} | ||
else { | ||
const tagMap = genTbListTagMapFromSymbol(gType.symbol); | ||
tagMap.size && retMap.set(localTypeId, tagMap); | ||
} | ||
} | ||
const nodeInfo = genInfoFromNode({ | ||
checker, | ||
node, | ||
path: caller.path, | ||
sourceFile, | ||
}); | ||
if (nodeInfo) { | ||
const { localTypeId, tbTagMap, tbColTagMap } = nodeInfo; | ||
if (tbTagMap.size) { | ||
// localTypeId: "/kmore-mono/packages/kmore-types/test/test.config.ts:typeid-TbListModel" | ||
return { | ||
localTypeId, | ||
tagsMapArr: [tbTagMap, tbColTagMap], | ||
}; | ||
} | ||
else { | ||
return { | ||
localTypeId, | ||
}; | ||
} | ||
} | ||
} | ||
return retMap; | ||
} | ||
@@ -735,2 +861,3 @@ // function transformerFactory<T extends ts.Node>(ctx: ts.TransformationContext): ts.Transformer<T> { | ||
exports.buildSrcTablesFile = buildSrcTablesFile; | ||
exports.buildTbColListParam = buildTbColListParam; | ||
exports.buildTbListParam = buildTbListParam; | ||
@@ -741,6 +868,5 @@ exports.cacheMap = cacheMap; | ||
exports.genCallerTypeMapFromNodeSet = genCallerTypeMapFromNodeSet; | ||
exports.genGenericsArgMap = genGenericsArgMap; | ||
exports.genInfoFromNode = genInfoFromNode; | ||
exports.genTbListFromCaller = genTbListFromCaller; | ||
exports.genTbListFromType = genTbListFromType; | ||
exports.genTbListTagMapFromSymbol = genTbListTagMapFromSymbol; | ||
exports.genTbListTsFilePath = genTbListTsFilePath; | ||
@@ -757,3 +883,5 @@ exports.genVarName = genVarName; | ||
exports.isTsFile = isTsFile; | ||
exports.loadColumnVarFromFile = loadColumnVarFromFile; | ||
exports.loadFile = loadFile; | ||
exports.loadTableVarFromFile = loadTableVarFromFile; | ||
exports.loadVarFromFile = loadVarFromFile; | ||
@@ -765,4 +893,3 @@ exports.matchSourceFileWithFilePath = matchSourceFileWithFilePath; | ||
exports.reservedTbListKeys = reservedTbListKeys; | ||
exports.retrieveGenericsIdentifierFromTypeArguments = retrieveGenericsIdentifierFromTypeArguments; | ||
exports.retrieveLocalTypeMapFromType = retrieveLocalTypeMapFromType; | ||
exports.retrieveLocalTypeItemFromType = retrieveLocalTypeItemFromType; | ||
exports.validateDuplicateProp = validateDuplicateProp; | ||
@@ -769,0 +896,0 @@ exports.validateParamTables = validateParamTables; |
export * from './lib/config'; | ||
export * from './lib/model'; | ||
export * from './lib/build'; | ||
@@ -6,2 +7,1 @@ export * from './lib/compiler'; | ||
export * from './lib/util'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsY0FBYyxjQUFjLENBQUE7QUFFNUIsY0FBYyxhQUFhLENBQUE7QUFDM0IsY0FBYyxnQkFBZ0IsQ0FBQTtBQUM5QixjQUFjLGVBQWUsQ0FBQTtBQUM3QixjQUFjLFlBQVksQ0FBQSJ9 |
import { Observable } from 'rxjs'; | ||
import { TTableListModel, FilePath, BuildSrcOpts } from './model'; | ||
import { TTables, FilePath, BuildSrcOpts } from './model'; | ||
/** | ||
@@ -9,6 +9,6 @@ * Generate tables .ts files, | ||
/** | ||
* Build tables in ts from generics type for specified file | ||
* Build tables in ts from generics type for specified ts file | ||
* | ||
* @returns file path if src file need parsed | ||
*/ | ||
export declare function buildSrcTablesFile<T extends TTableListModel>(file: string, options: BuildSrcOpts): Promise<FilePath>; | ||
export declare function buildSrcTablesFile<T extends TTables>(file: string, options: BuildSrcOpts): Promise<FilePath>; |
import { pathResolve, writeFileAsync } from '@waiting/shared-core'; | ||
import { mergeMap } from 'rxjs/operators'; | ||
import { defer } from 'rxjs'; | ||
import { buildTbListParam, genTbListTsFilePath, genVarName, walkDirForCallerFuncTsFiles, } from './util'; | ||
import { buildTbListParam, genTbListTsFilePath, genVarName, walkDirForCallerFuncTsFiles, buildTbColListParam, } from './util'; | ||
import { initBuildSrcOpts, globalCallerFuncNameSet } from './config'; | ||
@@ -23,3 +23,3 @@ import { pickInfoFromCallerTypeId, genCallerTypeMapFromNodeSet, matchSourceFileWithFilePath, walkNode, } from './ts-util'; | ||
/** | ||
* Build tables in ts from generics type for specified file | ||
* Build tables in ts from generics type for specified ts file | ||
* | ||
@@ -33,3 +33,3 @@ * @returns file path if src file need parsed | ||
}; | ||
const ret = retrieveTypeFromFile(file); | ||
const ret = retrieveTypeFromTsFile(file); | ||
if (ret && ret.size) { | ||
@@ -43,3 +43,3 @@ const path = await saveFile(ret, opts); | ||
} | ||
function retrieveTypeFromFile(file) { | ||
function retrieveTypeFromTsFile(file) { | ||
const path = pathResolve(file).replace(/\\/gu, '/'); | ||
@@ -54,5 +54,6 @@ const { checker, sourceFile } = matchSourceFileWithFilePath(path); | ||
const callerTypeMap = genCallerTypeMapFromNodeSet(nodeSet, checker, sourceFile, path); | ||
callerTypeMap.forEach((tagMap, callerTypeId) => { | ||
const tbs = buildTbListParam(tagMap); | ||
ret.set(callerTypeId, tbs); | ||
callerTypeMap.forEach(([tbListTagMap, tbColListTagMap], callerTypeId) => { | ||
const tbs = buildTbListParam(tbListTagMap); | ||
const tbCols = buildTbColListParam(tbColListTagMap); | ||
ret.set(callerTypeId, [tbs, tbCols]); | ||
}); | ||
@@ -63,6 +64,6 @@ } | ||
function genTsCodeFromTypes(inputMap, options) { | ||
const { exportVarPrefix, outputFileNameSuffix } = options; | ||
const { exportVarPrefix, exportVarColsSuffix, outputFileNameSuffix, } = options; | ||
let targetPath = ''; | ||
const sourceArr = []; | ||
inputMap.forEach((arr, key) => { | ||
inputMap.forEach(([tbs, tbCols], key) => { | ||
const { path, line, column } = pickInfoFromCallerTypeId(key); | ||
@@ -73,4 +74,6 @@ if (!targetPath) { | ||
} | ||
const varName = genVarName(exportVarPrefix, line, column); | ||
sourceArr.push(`export const ${varName} = ${JSON.stringify(arr, null, 2)} as const`); | ||
const tbVarName = genVarName(exportVarPrefix, line, column); | ||
const tbColVarName = `${tbVarName}${exportVarColsSuffix}`; | ||
sourceArr.push(`export const ${tbVarName} = ${JSON.stringify(tbs, null, 2)} as const`); | ||
sourceArr.push(`export const ${tbColVarName} = ${JSON.stringify(tbCols, null, 2)} as const`); | ||
}); | ||
@@ -89,2 +92,1 @@ return [targetPath, sourceArr.join('\n\n')]; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2J1aWxkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxXQUFXLEVBQUUsY0FBYyxFQUFFLE1BQU0sc0JBQXNCLENBQUE7QUFDbEUsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGdCQUFnQixDQUFBO0FBQ3pDLE9BQU8sRUFBYyxLQUFLLEVBQUUsTUFBTSxNQUFNLENBQUE7QUFTeEMsT0FBTyxFQUNMLGdCQUFnQixFQUNoQixtQkFBbUIsRUFDb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NQUFNLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxHQUFHLGtCQUFrQixDQUFJLFFBQVEsRUFBRSxPQUFPLENBQUMsQ0FBQTtJQUM3RCxNQUFNLE9BQU8sR0FBRyxZQUFZO1FBQzFCLENBQUMsQ0FBQyxHQUFHLFlBQVksT0FBTyxJQUFJLE1BQU07UUFDbEMsQ0FBQyxDQUFDLEdBQUcsSUFBSSxNQUFNLENBQUE7SUFFakIsTUFBTSxjQUFjLENBQUMsSUFBSSxFQUFFLE9BQU8sQ0FBQyxDQUFBO0lBQ25DLE9BQU8sSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLEVBQUUsR0FBRyxDQUFDLENBQUE7QUFDbEMsQ0FBQyJ9 |
@@ -1,8 +0,7 @@ | ||
import { GenGenericsArgMapOpts, LocalTypeMap, RetrieveInfoFromTypeOpts, CallerInfo, GenTbListFromTypeOpts, DbTables, TTableListModel } from './model'; | ||
import { RetrieveInfoFromTypeOpts, CallerInfo, GenTbListFromTypeOpts, TTables, KTablesBase, LocalTypeItem } from './model'; | ||
/** | ||
* Generate DbTables from generics type T | ||
* Generate KTables from generics type T | ||
*/ | ||
export declare function genTbListFromType<T extends TTableListModel>(options?: Partial<GenTbListFromTypeOpts>): DbTables<T>; | ||
export declare function genTbListFromCaller<T extends TTableListModel>(caller: CallerInfo, options: GenTbListFromTypeOpts): DbTables<T>; | ||
export declare function retrieveLocalTypeMapFromType(options: RetrieveInfoFromTypeOpts): LocalTypeMap; | ||
export declare function genGenericsArgMap(options: GenGenericsArgMapOpts): LocalTypeMap; | ||
export declare function genTbListFromType<T extends TTables>(options?: Partial<GenTbListFromTypeOpts>): KTablesBase<T>; | ||
export declare function genTbListFromCaller<T extends TTables>(caller: CallerInfo, options: GenTbListFromTypeOpts): KTablesBase<T>; | ||
export declare function retrieveLocalTypeItemFromType(options: RetrieveInfoFromTypeOpts): LocalTypeItem | void; |
@@ -1,8 +0,6 @@ | ||
import { buildTbListParam, isTsFile, getCallerStack } from './util'; | ||
import { genTbListTagMapFromSymbol, retrieveGenericsIdentifierFromTypeArguments, matchSourceFileWithFilePath, walkNodeWithPosition, } from './ts-util'; | ||
import { cacheMap as cacheMapTop, | ||
// initOptions, | ||
initGenTbListFromTypeOpts, globalCallerFuncNameSet, } from './config'; | ||
import { buildTbListParam, buildTbColListParam, getCallerStack, isTsFile, } from './util'; | ||
import { genInfoFromNode, matchSourceFileWithFilePath, walkNodeWithPosition, } from './ts-util'; | ||
import { cacheMap as cacheMapTop, initGenTbListFromTypeOpts, globalCallerFuncNameSet, } from './config'; | ||
/** | ||
* Generate DbTables from generics type T | ||
* Generate KTables from generics type T | ||
*/ | ||
@@ -32,59 +30,55 @@ export function genTbListFromType(options) { | ||
}; | ||
// "/kmore-mono/packages/kmore-types/test/test.config.ts:13:23" | ||
const callerId = `${caller.path}:${caller.line}:${caller.column}`; | ||
const localTypeId = opts.cacheMap.callerIdToLocalTypeIdMap.get(callerId); | ||
let ret = {}; | ||
if (localTypeId) { | ||
const tbListTagMap = opts.cacheMap.localTypeMap.get(localTypeId); | ||
if (!tbListTagMap) { | ||
if (localTypeId) { // from cache | ||
const tagsMapArr = opts.cacheMap.localTypeMap.get(localTypeId); | ||
if (tagsMapArr && tagsMapArr.length) { | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr); | ||
} | ||
else { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${localTypeId}".`); | ||
} | ||
else if (!tbListTagMap.size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${localTypeId}" value empty.`); | ||
} | ||
ret = buildTbListParam(tbListTagMap); | ||
} | ||
else { | ||
const localTypeMap = retrieveLocalTypeMapFromType(opts); | ||
const localTypeItem = retrieveLocalTypeItemFromType(opts); | ||
if (!localTypeItem) { | ||
throw new Error(`retrieveLocalTypeMapFromType() return empty with key: "${localTypeId}".`); | ||
} | ||
// id is localTypeId | ||
// map maybe empty | ||
localTypeMap.forEach((map, id) => { | ||
opts.cacheMap.callerIdToLocalTypeIdMap.set(callerId, id); | ||
// map can be empty as cached result | ||
if (map.size) { | ||
opts.cacheMap.localTypeMap.set(id, map); | ||
ret = buildTbListParam(map); | ||
// map maybe empty, so try from cache | ||
const { localTypeId: id, tagsMapArr } = localTypeItem; | ||
opts.cacheMap.callerIdToLocalTypeIdMap.set(callerId, id); | ||
if (tagsMapArr && tagsMapArr[0] && tagsMapArr[0].size) { | ||
opts.cacheMap.localTypeMap.set(id, tagsMapArr); | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr); | ||
} | ||
else { // retrieved only localTypeId, then try from cache | ||
const tagsMapArr2 = opts.cacheMap.localTypeMap.get(id); | ||
if (!tagsMapArr2) { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${id}" or value empty.`); | ||
} | ||
else { | ||
const cMap = opts.cacheMap.localTypeMap.get(id); | ||
if (!cMap) { | ||
throw new Error(`cacheMap.localTypeMap not contains key: "${id}" or value empty.`); | ||
} | ||
else if (!cMap.size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${id}" value empty.`); | ||
} | ||
ret = buildTbListParam(cMap); | ||
else if (!tagsMapArr2[0].size) { | ||
throw new Error(`cacheMap.localTypeMap key: "${id}" value empty.`); | ||
} | ||
}); | ||
return buildKTablesBaseFromTagsMapArr(tagsMapArr2); | ||
} | ||
} | ||
} | ||
function buildKTablesBaseFromTagsMapArr(tagsMapArr) { | ||
const [tbListTagMap, tbColListTagMap] = tagsMapArr; | ||
const ret = { | ||
tables: buildTbListParam(tbListTagMap), | ||
columns: buildTbColListParam(tbColListTagMap), | ||
}; | ||
return ret; | ||
} | ||
export function retrieveLocalTypeMapFromType(options) { | ||
const { checker, sourceFile } = matchSourceFileWithFilePath(options.caller.path); | ||
if (sourceFile) { | ||
const localTypeMap = genGenericsArgMap({ | ||
...options, | ||
sourceFile, | ||
checker, | ||
}); | ||
/* istanbul ignore else */ | ||
if (localTypeMap.size) { | ||
return localTypeMap; // retrieve succeed | ||
} | ||
export function retrieveLocalTypeItemFromType(options) { | ||
const { caller } = options; | ||
const { checker, sourceFile } = matchSourceFileWithFilePath(caller.path); | ||
/* istanbul ignore else */ | ||
if (!sourceFile) { | ||
// throw new Error(`Can not retrieve generics type info from file: "${caller.path}"`) | ||
return; | ||
} | ||
// throw new Error(`Can not retrieve generics type info from file: "${caller.path}"`) | ||
return new Map(); | ||
} | ||
export function genGenericsArgMap(options) { | ||
const retMap = new Map(); | ||
const { cacheMap, sourceFile, checker, caller, } = options; | ||
const node = walkNodeWithPosition({ | ||
@@ -98,32 +92,24 @@ sourceFile, | ||
if (node) { | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
/* istanbul ignore else */ | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
// const symbol = checker.getSymbolAtLocation(typeName) | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (sym) { | ||
const inputTypeName = sym.getName(); | ||
// might be type alias name so we use typdid | ||
// const genericsArgName: GenericsArgName = typeName.text | ||
// @ts-ignore | ||
// const typeid: number = typeof gType.id === 'number' ? gType.id : Math.random() | ||
const localTypeId = `${caller.path}:typeid-${inputTypeName}`; | ||
if (retMap.has(localTypeId)) { | ||
return retMap; | ||
} | ||
else if (cacheMap.localTypeMap.has(localTypeId)) { | ||
retMap.set(localTypeId, new Map()); // empty map, pick from resolved data later. | ||
} | ||
else { | ||
const tagMap = genTbListTagMapFromSymbol(gType.symbol); | ||
tagMap.size && retMap.set(localTypeId, tagMap); | ||
} | ||
} | ||
const nodeInfo = genInfoFromNode({ | ||
checker, | ||
node, | ||
path: caller.path, | ||
sourceFile, | ||
}); | ||
if (nodeInfo) { | ||
const { localTypeId, tbTagMap, tbColTagMap } = nodeInfo; | ||
if (tbTagMap.size) { | ||
// localTypeId: "/kmore-mono/packages/kmore-types/test/test.config.ts:typeid-TbListModel" | ||
return { | ||
localTypeId, | ||
tagsMapArr: [tbTagMap, tbColTagMap], | ||
}; | ||
} | ||
else { | ||
return { | ||
localTypeId, | ||
}; | ||
} | ||
} | ||
} | ||
return retMap; | ||
} | ||
@@ -140,2 +126,1 @@ // function transformerFactory<T extends ts.Node>(ctx: ts.TransformationContext): ts.Transformer<T> { | ||
// } | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2NvbXBpbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxRQUFRLEVBQUUsY0FBYyxFQUFFLE1BQU0sUUFBUSxDQUFBO0FBQ25FLE9BQU8sRUFDTCx5QkFBeUIsRUFDekIsMkNBQTJDLEVBQzNDLDJCQUEyQixFQUMzQixvQkFBb0IsR0FDckIsTUFBTSxXQUFXLENBQUE7QUFDbEIsT0FBTyxFQUNMLFFBQVEsSUFBSSxXQUFXO0FBQ3ZCLGVBQWU7QUFDZix5QkFBeUIsRUFDekIsdUJBQXVCLEdBQ3hCLE1BQU0sVUFBVSxDQUFBO0FBR2pCOztHQUVHO0FBQ0gsTUFBTSxVQUFVLGlCQUFpQixDQUMvQixPQUF3QztJQUd4QyxNQUFNLElBQUksR0FBMEIsT0FBTztRQUN6QyxDQUFDLENBQUMsRUFBRSxHQUFHLHlCQUF5QixFQUFFLEdBQUcsT0FBTyxFQUFFO1FBQzlDLENBQUMsQ0FBQyxFQUFFLEdBQUcseUJBQXlCLEVBQUUsQ0FBQTtJQUVwQyxNQUFNLEtBQUssR0FBRyxPQUFPLElBQUksQ0FBQyxjQUFjLEtBQUssUUFBUSxJQUFJLElBQUksQ0FBQyxjQUFjLEdBQUcsQ0FBQztRQUM5RSxDQUFDLENBQUMsSUFBSSxDQUFDLGNBQWM7UUFDckIsQ0FBQyxDQUFDLENBQUMsQ0FBQTtJQUNMLE1BQU0sT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yxHQUFHLENBQUMsV0FBVyxFQUFFLE1BQU0sQ0FBQyxDQUFBO3FCQUMvQztpQkFDRjthQUNGO1NBQ0Y7S0FDRjtJQUVELE9BQU8sTUFBTSxDQUFBO0FBQ2YsQ0FBQztBQUdELHFHQUFxRztBQUNyRywyQ0FBMkM7QUFDM0MsbUVBQW1FO0FBQ25FLDhEQUE4RDtBQUM5RCxvQkFBb0I7QUFDcEIsUUFBUTtBQUNSLDJDQUEyQztBQUUzQyxNQUFNO0FBQ04sdUJBQXVCO0FBQ3ZCLElBQUkifQ== |
@@ -10,2 +10,4 @@ import { BuildSrcOpts, CacheMap, CallerFuncNameSet, GenTbListFromTypeOpts, Options } from './model'; | ||
'tables' = "tables", | ||
'columns' = "columns", | ||
'scopedColumns' = "scopedColumns", | ||
'refTables' = "rb" | ||
@@ -12,0 +14,0 @@ } |
@@ -7,3 +7,4 @@ export const globalCallerFuncNameSet = new Set(['genTbListFromType', 'kmore']); | ||
...initGenTbListFromTypeOpts, | ||
exportVarPrefix: 'tbs', | ||
exportVarPrefix: 'tbs_', | ||
exportVarColsSuffix: '_cols', | ||
forceLoadTbListJs: false, | ||
@@ -30,6 +31,8 @@ forceLoadTbListJsPathReplaceRules: null, | ||
DbPropKeys["tables"] = "tables"; | ||
DbPropKeys["columns"] = "columns"; | ||
DbPropKeys["scopedColumns"] = "scopedColumns"; | ||
DbPropKeys["refTables"] = "rb"; | ||
})(DbPropKeys || (DbPropKeys = {})); | ||
export const defaultPropDescriptor = { | ||
configurable: false, | ||
configurable: true, | ||
enumerable: true, | ||
@@ -41,2 +44,3 @@ writable: false, | ||
tbListMap: new Map(), | ||
tbColListMap: new Map(), | ||
/** CallerId -> LocalTypeId */ | ||
@@ -47,2 +51,1 @@ callerIdToLocalTypeIdMap: new Map(), | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOls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WUFBWSxFQUFFLEtBQUs7SUFDbkIsVUFBVSxFQUFFLElBQUk7SUFDaEIsUUFBUSxFQUFFLEtBQUs7Q0FDUCxDQUFBO0FBR1YsTUFBTSxDQUFDLE1BQU0sUUFBUSxHQUFhO0lBQ2hDLDhCQUE4QjtJQUM5QixTQUFTLEVBQUUsSUFBSSxHQUFHLEVBQUU7SUFDcEIsOEJBQThCO0lBQzlCLHdCQUF3QixFQUFFLElBQUksR0FBRyxFQUFFO0lBQ25DLHFDQUFxQztJQUNyQyxZQUFZLEVBQUUsSUFBSSxHQUFHLEVBQUU7Q0FDeEIsQ0FBQSJ9 |
"use strict"; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== |
import { CallExpression, JSDocTagInfo, SourceFile, TypeChecker } from 'typescript'; | ||
import { JsonType, Spread } from '@waiting/shared-types'; | ||
export interface Options extends GenTbListFromTypeOpts { | ||
/** Exported vaiable name preifx. Default is "tbs", result will be "tbs_m_n" */ | ||
/** Exported table vaiable name prefix. Default is "tbs_", result will be "tbs_m_n" */ | ||
exportVarPrefix: string; | ||
/** Exported column vaiable name suffix. Default is "_cols", result will be "tbs_m_n_cols" */ | ||
exportVarColsSuffix: string; | ||
/** | ||
@@ -46,7 +49,8 @@ * Load js under ts env for debug, | ||
export declare type CallerFuncName = string; | ||
export declare type TTableListModel = object; | ||
export declare type TTables = object; | ||
/** | ||
* Database Tables Tag Map generated by generics type passing to genTbListFromGenerics<T>() | ||
*/ | ||
export declare type TbListMap = Map<CallerId, DbTables<object>>; | ||
export declare type TbListMap = Map<CallerId, Tables<object>>; | ||
export declare type TbColListMap = Map<CallerId, TableCols<object>>; | ||
/** Define what's genericsTypeId at the callexpression position */ | ||
@@ -60,7 +64,28 @@ export declare type CallerIdToLocalTypeIdMap = Map<CallerId, LocalTypeId>; | ||
export declare type CallerTypeId = string; | ||
export declare type CallerTbListMap<T extends TTableListModel> = Map<CallerTypeId, DbTables<T>>; | ||
export declare type CallerTbListMap<T extends TTables> = Map<CallerTypeId, TablesMapArr<T>>; | ||
export interface TablesMapArr<T extends TTables> extends Array<Tables<T> | TableCols<T> | TableScopedCols<T>> { | ||
0: Tables<T>; | ||
1: TableCols<T>; | ||
length: 2; | ||
} | ||
/** GenericsTypeId scope in the file */ | ||
export declare type LocalTypeMap = Map<LocalTypeId, TbListTagMap>; | ||
export declare type CallerTypeMap = Map<CallerTypeId, TbListTagMap>; | ||
export declare type LocalTypeMap = Map<LocalTypeId, TagsMapArr>; | ||
export declare type CallerTypeMap = Map<CallerTypeId, TagsMapArr>; | ||
export declare type TbListTagMap = Map<TableAlias, JSDocTagInfo[]>; | ||
export declare type TbColListTagMap = Map<TableAlias, ColListTagMap>; | ||
export declare type TbScopedColListTagMap = Map<TableAlias, ColListTagMap>; | ||
export declare type ColListTagMap = Map<TableColAlias, JSDocTagInfo[]>; | ||
export interface TbTagsMap { | ||
tbTagMap: TbListTagMap; | ||
tbColTagMap: TbColListTagMap; | ||
} | ||
export interface LocalTypeItem { | ||
localTypeId: string; | ||
tagsMapArr?: TagsMapArr; | ||
} | ||
export interface TagsMapArr extends Array<TbListTagMap | TbColListTagMap> { | ||
0: TbListTagMap; | ||
1: TbColListTagMap; | ||
length: 2; | ||
} | ||
export declare type GenericsArgName = string; | ||
@@ -77,28 +102,65 @@ export interface CallerInfo { | ||
/** | ||
* K(more)Tables array contains: | ||
* tables: tables name | ||
* columns: columns name of the tables | ||
*/ | ||
export interface KTablesBase<T extends TTables> { | ||
/** | ||
* Tables alias/name pairs | ||
* { tb_alias: "tb_name" } | ||
*/ | ||
tables: Tables<T>; | ||
/** | ||
* Columns mapping object, tb_name w/o table prefix | ||
* ```json | ||
* { | ||
* tb_alias: { col_alias: "col_name", ..., } | ||
* } | ||
* ``` | ||
*/ | ||
columns: TableCols<T>; | ||
} | ||
/** | ||
* Type of db.tables | ||
*/ | ||
export declare type DbTables<T extends TTableListModel> = T extends void ? EmptyTbList : T extends never ? EmptyTbList : Record<keyof T, string>; | ||
export declare type Tables<T extends TTables> = T extends void ? EmptyTbList : T extends never ? EmptyTbList : Record<keyof T, string>; | ||
export interface EmptyTbList { | ||
readonly [key: string]: never; | ||
} | ||
/** | ||
* Type of db.tableCols.tb_foo.col_bar | ||
*/ | ||
export declare type TableCols<T extends TTables> = T extends void ? EmptyTbList : T extends never ? EmptyTbList : Columns<T>; | ||
export declare enum ColumnExtPropKeys { | ||
tableAlias = "_tableAlias", | ||
tablesRef = "_tablesRef", | ||
sColsCacheMap = "_scopedColsCacheMap" | ||
} | ||
export declare type Columns<T extends TTables> = ScopedColumns<T> & { | ||
readonly [ColumnExtPropKeys.tableAlias]: TableAlias; | ||
readonly [ColumnExtPropKeys.tablesRef]: KTablesBase<T>['tables']; | ||
readonly [ColumnExtPropKeys.sColsCacheMap]: Map<TableAlias, ScopedColumns<T>>; | ||
}; | ||
/** | ||
* Type of db.tableCols.tb_foo.col_bar, | ||
* value wiht table prefix, eg. `tb_foo.col_name` | ||
*/ | ||
export declare type TableScopedCols<T extends TTables> = T extends void ? EmptyTbList : T extends never ? EmptyTbList : ScopedColumns<T>; | ||
export declare type ScopedColumns<T extends TTables> = { | ||
readonly [tbAlias in keyof T]: { | ||
readonly [colAlias in keyof T[tbAlias]]: string; | ||
}; | ||
}; | ||
export declare type TableAlias = string; | ||
export declare type TableColAlias = string; | ||
export declare type TableName = string; | ||
export declare type FilePath = string; | ||
export declare type FileName = string; | ||
export declare type ColumnType = boolean | number | string | null | JsonType | Date; | ||
export interface BaseTbType { | ||
[colName: string]: ColumnType | ColumnType[]; | ||
} | ||
export interface BaseTbListType { | ||
[tbAlias: string]: BaseTbType; | ||
} | ||
/** Value of key-value pairs object */ | ||
export declare type PlainJsonValueType = boolean | number | string | null | undefined; | ||
/** | ||
* Typeof JSON object parsed from Response data | ||
* simple key-value pairs object. | ||
*/ | ||
export interface JsonType { | ||
[key: string]: PlainJsonValueType | PlainJsonValueType[] | JsonType | JsonType[]; | ||
export interface BaseTbType { | ||
[colName: string]: ColumnType | ColumnType[]; | ||
} | ||
export declare type ColumnType = boolean | number | string | null | JsonType | Date | bigint; | ||
export interface GenTbListFromTypeOpts { | ||
@@ -115,8 +177,5 @@ /** | ||
} | ||
export interface GenGenericsArgMapOpts extends RetrieveInfoFromTypeOpts { | ||
checker: TypeChecker; | ||
sourceFile: SourceFile; | ||
} | ||
export interface CacheMap { | ||
readonly tbListMap: TbListMap; | ||
readonly tbColListMap: TbColListMap; | ||
readonly callerIdToLocalTypeIdMap: CallerIdToLocalTypeIdMap; | ||
@@ -147,3 +206,2 @@ readonly localTypeMap: LocalTypeMap; | ||
path: string; | ||
retMap: LocalTypeMap; | ||
} | ||
@@ -154,1 +212,7 @@ export interface MatchedSourceFile { | ||
} | ||
export interface LoadVarFromFileOpts { | ||
path: string; | ||
caller: CallerInfo; | ||
options: Options; | ||
} | ||
export declare type JointTable<L, R, KeyExcludeOptional = void> = Spread<L, R, KeyExcludeOptional>; |
@@ -1,1 +0,6 @@ | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL21vZGVsLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIifQ== | ||
export var ColumnExtPropKeys; | ||
(function (ColumnExtPropKeys) { | ||
ColumnExtPropKeys["tableAlias"] = "_tableAlias"; | ||
ColumnExtPropKeys["tablesRef"] = "_tablesRef"; | ||
ColumnExtPropKeys["sColsCacheMap"] = "_scopedColsCacheMap"; | ||
})(ColumnExtPropKeys || (ColumnExtPropKeys = {})); |
@@ -1,3 +0,3 @@ | ||
import { CallExpression, Identifier, SourceFile, Symbol as TsSymbol, TypeChecker } from 'typescript'; | ||
import { CallerTypeIdInfo, CallerTypeId, CallerTypeMap, TbListTagMap, MatchedSourceFile, WalkNodeWithPositionOps, WalkNodeOps } from './model'; | ||
import { CallExpression, SourceFile, TypeChecker } from 'typescript'; | ||
import { CallerTypeIdInfo, CallerTypeId, CallerTypeMap, GenInfoFromNodeOps, LocalTypeId, MatchedSourceFile, WalkNodeWithPositionOps, WalkNodeOps, TbTagsMap } from './model'; | ||
/** | ||
@@ -8,5 +8,9 @@ * | ||
export declare function pickInfoFromCallerTypeId(id: CallerTypeId): CallerTypeIdInfo; | ||
export declare function genCallerTypeMapFromNodeSet(nodes: Set<CallExpression>, checker: TypeChecker, sourceFile: SourceFile, path: string): CallerTypeMap; | ||
export declare function genTbListTagMapFromSymbol(symbol: TsSymbol): TbListTagMap; | ||
export declare function retrieveGenericsIdentifierFromTypeArguments(node: CallExpression): Identifier | void; | ||
export declare function genCallerTypeMapFromNodeSet(nodes: Set<CallExpression>, checker: TypeChecker, sourceFile: SourceFile, // sourceFileObject | ||
path: string): CallerTypeMap; | ||
interface GenInfoFromNodeRet extends Omit<TbTagsMap, 'tbScopedColTagMap'> { | ||
callerTypeId: CallerTypeId; | ||
localTypeId: LocalTypeId; | ||
} | ||
export declare function genInfoFromNode(options: GenInfoFromNodeOps): GenInfoFromNodeRet | void; | ||
export declare function matchSourceFileWithFilePath(path: string): MatchedSourceFile; | ||
@@ -17,1 +21,2 @@ /** Retrieve node with specified position from caller */ | ||
export declare function walkNode(options: WalkNodeOps): Set<CallExpression>; | ||
export {}; |
@@ -20,10 +20,15 @@ import { pathResolve } from '@waiting/shared-core'; | ||
} | ||
export function genCallerTypeMapFromNodeSet(nodes, checker, sourceFile, path) { | ||
export function genCallerTypeMapFromNodeSet(nodes, checker, sourceFile, // sourceFileObject | ||
path) { | ||
const retMap = new Map(); | ||
nodes.forEach((node) => { | ||
const obj = genInfoFromNode({ | ||
node, checker, sourceFile, retMap, path, | ||
checker, | ||
node, | ||
path, | ||
sourceFile, | ||
}); | ||
if (obj) { | ||
retMap.set(obj.id, obj.tagMap); | ||
const { callerTypeId, tbTagMap, tbColTagMap } = obj; | ||
retMap.set(callerTypeId, [tbTagMap, tbColTagMap]); | ||
} | ||
@@ -33,26 +38,32 @@ }); | ||
} | ||
function genInfoFromNode(options) { | ||
const { node, checker, sourceFile, retMap, path, } = options; | ||
export function genInfoFromNode(options) { | ||
const { node, checker, sourceFile, path, } = options; | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
/* istanbul ignore else */ | ||
if (node) { | ||
const typeName = retrieveGenericsIdentifierFromTypeArguments(node); | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
/* istanbul ignore else */ | ||
if (typeName && typeName.getText()) { | ||
const gType = checker.getTypeAtLocation(typeName); | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (!sym) { | ||
return; | ||
} | ||
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); | ||
const inputTypeName = sym.getName(); | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:4:1:typeid-TbListModel" | ||
const callerTypeId = `${path}:${line + 1}:${character + 1}:typeid-${inputTypeName}`; | ||
// @ts-ignore | ||
// const gTypeId: number = typeof gType.id === 'number' ? gType.id : Math.random() | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:typeid-76" | ||
// "/kmore-mono/packages/kmore-types/test/config/test.config2.ts:typeid-TbListModel" | ||
const localTypeId = `${path}:typeid-${inputTypeName}`; | ||
const { tbTagMap, tbColTagMap } = genTbListTagMapFromSymbol(gType.symbol, checker); | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
// @ts-ignore | ||
const typeid = typeof gType.id === 'number' ? gType.id : Math.random(); | ||
const { line, character } = sourceFile.getLineAndCharacterOfPosition(node.getStart()); | ||
const localTypeId = `${path}:${line + 1}:${character + 1}:typeid-${typeid}`; | ||
if (retMap.has(localTypeId)) { | ||
return; | ||
} | ||
else { | ||
const tagMap = genTbListTagMapFromSymbol(gType.symbol); | ||
/* istanbul ignore else */ | ||
if (tagMap.size) { | ||
return { id: localTypeId, tagMap }; | ||
} | ||
} | ||
if (tbTagMap.size) { | ||
return { | ||
callerTypeId, | ||
localTypeId, | ||
tbTagMap, | ||
tbColTagMap, | ||
}; | ||
} | ||
@@ -63,19 +74,59 @@ } | ||
// ---- compiler --- | ||
export function genTbListTagMapFromSymbol(symbol) { | ||
function genTbListTagMapFromSymbol(symbol, checker) { | ||
const { members } = symbol; | ||
// Map<TableAlias, Map<TagName, TagComment> > | ||
const symbolTagMap = new Map(); | ||
const tbTagMap = new Map(); | ||
const tbColTagMap = new Map(); | ||
// const tbScopedColTagMap: TbScopedColListTagMap = new Map() | ||
/* istanbul ignore else */ | ||
if (members) { | ||
members.forEach((member) => { | ||
const name = member.getName(); | ||
const tags = member.getJsDocTags(); | ||
members.forEach((tbSym) => { | ||
const { name: tbName, tags } = retrieveInfoFromSymbolObject(tbSym); | ||
// tags can be empty array | ||
symbolTagMap.set(name, tags); | ||
tbTagMap.set(tbName, tags); | ||
const nodes = tbSym.getDeclarations(); | ||
if (nodes && nodes.length) { | ||
const colTagMap = genColListTagMapFromTbSymbol(nodes, checker); | ||
tbColTagMap.set(tbName, colTagMap); | ||
} | ||
}); | ||
} | ||
return symbolTagMap; | ||
return { tbTagMap, tbColTagMap }; | ||
} | ||
export function retrieveGenericsIdentifierFromTypeArguments(node) { | ||
function genColListTagMapFromTbSymbol(nodes, checker) { | ||
const ret = new Map(); | ||
const [node] = nodes; // use only one | ||
const { type: typeRef } = node; | ||
if (typeRef && typeRef.getText()) { | ||
return retrieveMembersFromTypeRef(typeRef, checker); | ||
} | ||
return ret; | ||
} | ||
function retrieveMembersFromTypeRef(typeRef, // TypeReference | ||
checker) { | ||
const ret = new Map(); | ||
const gType = checker.getTypeAtLocation(typeRef); | ||
/* istanbul ignore else */ | ||
if (gType && gType.symbol) { | ||
const sym = gType.getSymbol(); | ||
if (sym) { | ||
const { members } = sym; | ||
if (members) { | ||
members.forEach((member) => { | ||
const { name: colName, tags } = retrieveInfoFromSymbolObject(member); | ||
ret.set(colName, tags); | ||
}); | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
function retrieveInfoFromSymbolObject(symbol) { | ||
return { | ||
name: symbol.getName(), | ||
tags: symbol.getJsDocTags(), | ||
}; | ||
} | ||
function retrieveGenericsIdentifierFromTypeArguments(node) { | ||
/* istanbul ignore else */ | ||
if (!node.typeArguments || node.typeArguments.length !== 1) { | ||
@@ -172,2 +223,1 @@ return; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHMtdXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvdHMtdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFjQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0sc0JBQXNCLENBQUE7QUFFbEQsT0FBTyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sUUFBUSxDQUFBO0FBYzVDOzs7R0FHRztBQUNILE1BQU0sVUFBVSx3QkFBd0IsQ0FBQyxFQUFnQjtJQUN2RCxNQUFNLE9BQU8sR0FBRyxFQUFFLENBQUMsS0FBSyxDQUFDLHNDQUFzQyxDQUFDLENBQUE7SUFFaEUsSUFBSSxPQUFPLElBQUksT0FBTyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDbkMsTUFBTSxHQUFHLEdBQXFCO1lBQzVCLElBQUksRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLElBQUksRUFBRSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDakIsTUFBTSxFQUFFLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQztZQUNuQixNQUFNLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQztTQUNu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BQUNaLENBQUMifQ== |
import { Observable } from 'rxjs'; | ||
import { BuildSrcOpts, CallerInfo, CallerFuncName, DbTables, FilePath, Options, TbListTagMap, TTableListModel, CallerFuncNameSet } from './model'; | ||
import { BuildSrcOpts, CallerInfo, CallerFuncName, CallerFuncNameSet, Tables, TableCols, FilePath, KTablesBase, LoadVarFromFileOpts, Options, TbListTagMap, TbColListTagMap, TTables } from './model'; | ||
/** Allow empty Object */ | ||
@@ -14,3 +14,6 @@ export declare function validateParamTables(tbs: unknown): void; | ||
/** Build DbTables from TableListTagMap */ | ||
export declare function buildTbListParam<T extends TTableListModel>(tagMap: TbListTagMap): DbTables<T>; | ||
export declare function buildTbListParam<T extends TTables>(tagMap: TbListTagMap): Tables<T>; | ||
/** Build DbTableCols from TableColListTagMap */ | ||
export declare function buildTbColListParam<T extends TTables>(tagMap: TbColListTagMap): TableCols<T>; | ||
/** Build DbTableScopedCols from TableColListTagMap */ | ||
export declare function isCallerNameMatched(name: string, matchFuncNameSet: CallerFuncNameSet): boolean; | ||
@@ -21,3 +24,8 @@ export declare function createNullObject(): any; | ||
export declare function reWriteLoadingPath(path: FilePath, rules: Options['forceLoadTbListJsPathReplaceRules']): FilePath; | ||
export declare function loadVarFromFile<T extends TTableListModel>(path: string, caller: CallerInfo, options: Options): DbTables<T>; | ||
export declare function loadTableVarFromFile<T extends TTables>(loadOpts: LoadVarFromFileOpts): Tables<T>; | ||
export declare function loadColumnVarFromFile<T extends TTables>(loadOpts: LoadVarFromFileOpts): TableCols<T>; | ||
/** | ||
* Load kTables var from a js file | ||
*/ | ||
export declare function loadVarFromFile<T extends TTables>(loadOpts: LoadVarFromFileOpts): KTablesBase<T>; | ||
export declare function loadFile(path: string): any; | ||
@@ -24,0 +32,0 @@ /** |
@@ -137,2 +137,59 @@ import * as sourceMapSupport from 'source-map-support'; | ||
} | ||
/** Build DbTableCols from TableColListTagMap */ | ||
export function buildTbColListParam(tagMap) { | ||
const ret = createNullObject(); | ||
if (tagMap && tagMap.size) { | ||
tagMap.forEach((colListTagMap, tb) => { | ||
const cols = createNullObject(); | ||
colListTagMap.forEach((_tags, col) => { | ||
Object.defineProperty(cols, col, { | ||
...defaultPropDescriptor, | ||
value: col, | ||
}); | ||
}); | ||
Object.defineProperty(ret, tb, { | ||
...defaultPropDescriptor, | ||
value: cols, | ||
}); | ||
}); | ||
} | ||
else { | ||
throw new TypeError('Value of tagMap invalid.'); | ||
} | ||
return ret; | ||
} | ||
/** Build DbTableScopedCols from TableColListTagMap */ | ||
// export function buildTbScopedColListParam<T extends TTables>( | ||
// tagMap: TbColListTagMap, | ||
// tables: DbTables<T>, | ||
// ): DbTableScopedCols<T> { | ||
// const ret = createNullObject() | ||
// if (! tables || ! Object.keys(tables).length) { | ||
// return ret | ||
// } | ||
// if (tagMap && tagMap.size) { | ||
// tagMap.forEach((colListTagMap, tbAlias) => { | ||
// const tb = tbAlias as keyof DbTables<T> | ||
// if (typeof tables[tb] !== 'string') { | ||
// return | ||
// } | ||
// const tbName = tables[tb] | ||
// const cols = createNullObject() | ||
// colListTagMap.forEach((_tags, colAlias) => { | ||
// Object.defineProperty(cols, colAlias, { | ||
// ...defaultPropDescriptor, | ||
// value: `${tbName}.${colAlias}`, | ||
// }) | ||
// }) | ||
// Object.defineProperty(ret, tbAlias, { | ||
// ...defaultPropDescriptor, | ||
// value: cols, | ||
// }) | ||
// }) | ||
// } | ||
// else { | ||
// throw new TypeError('Value of tagMap invalid.') | ||
// } | ||
// return ret | ||
// } | ||
export function isCallerNameMatched(name, matchFuncNameSet) { | ||
@@ -163,3 +220,3 @@ if (!name) { | ||
export function genVarName(exportVarPrefix, line, column) { | ||
const varName = `${exportVarPrefix}_${line}_${column}`; | ||
const varName = `${exportVarPrefix}${line}_${column}`; | ||
return varName; | ||
@@ -177,7 +234,24 @@ } | ||
} | ||
export function loadVarFromFile(path, caller, options) { | ||
const varName = genVarName(options.exportVarPrefix, caller.line, caller.column); | ||
export function loadTableVarFromFile(loadOpts) { | ||
const kTables = loadVarFromFile(loadOpts); | ||
return kTables.tables; | ||
} | ||
export function loadColumnVarFromFile(loadOpts) { | ||
const kTables = loadVarFromFile(loadOpts); | ||
return kTables.columns; | ||
} | ||
/** | ||
* Load kTables var from a js file | ||
*/ | ||
export function loadVarFromFile(loadOpts) { | ||
const { path, caller, options } = loadOpts; | ||
const tbVarName = genVarName(options.exportVarPrefix, caller.line, caller.column); | ||
const colVarName = `${tbVarName}${options.exportVarColsSuffix}`; | ||
const mods = loadFile(path); | ||
if (mods && typeof mods[varName] === 'object') { | ||
return mods[varName]; | ||
if (mods && typeof mods[tbVarName] === 'object') { | ||
const tables = mods[tbVarName]; | ||
const columns = typeof mods[colVarName] === 'object' | ||
? mods[colVarName] | ||
: {}; | ||
return { tables, columns }; | ||
} | ||
@@ -281,2 +355,1 @@ throw new TypeError(`Load tables failed, path: "${path}"`); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssZ0JBQWdCLE1BQU0sb0JBQW9CLENBQUE7QUFDdEQsT0FBTyxFQUFFLElBQUksRUFBYSxNQUFNLFVBQVUsQ0FBQTtBQUMxQyxPQUFPLEVBQUUsSUFBSSxJQUFJLEtBQUssRUFBRSxFQUFFLEVBQWMsR0FBRyxFQUFFLE1BQU0sRUFBRSxNQUFNLE1BQU0sQ0FBQTtBQUNqRSxPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sRUFBRSxRQUFRLEVBQUUsVUFBVSxFQUFFLElBQUksRUFBRSxNQUFNLGdCQUFnQixDQUFBO0FBQ3hFLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQTtBQUVyRCxPQUFPLEVBQ0wscUJBQXFCLEVB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FDLE1BQU0sRUFBRTtRQUM3QyxLQUFLLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEdBQUcsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFBO0tBQ3BDO1NBQ0k7UUFDSCxNQUFNLElBQUksU0FBUyxDQUFDLHlCQUF5QixDQUFDLENBQUE7S0FDL0M7SUFFRCxPQUFPLEVBQUUsQ0FBQTtBQUNYLENBQUMifQ== |
{ | ||
"name": "kmore-types", | ||
"author": "waiting", | ||
"version": "0.14.0", | ||
"version": "0.15.0", | ||
"description": "Retrieve types info from ts file", | ||
@@ -36,3 +36,4 @@ "keywords": [ | ||
"@types/source-map-support": "*", | ||
"cross-env": "6" | ||
"cross-env": "7", | ||
"typescript": "3" | ||
}, | ||
@@ -56,3 +57,3 @@ "peerDependencies": { | ||
"rp:w": "npm run tsc:w | rollup -wc rollup.config.js", | ||
"test": "cross-env TS_NODE_PROJECT=test/tsconfig.json mocha --opts test/mocha.opts", | ||
"test": "cross-env TS_NODE_PROJECT=test/tsconfig.json mocha", | ||
"test:browser": "cd .config && npm run browser && cd ..", | ||
@@ -88,3 +89,3 @@ "tsc": "tsc -p tsconfig.json", | ||
}, | ||
"gitHead": "3a48cf8a1438b9c06135e16540c42af50dbd1912" | ||
"gitHead": "c67e60f8b5d6c1feed58816c2890eb54ed00347a" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2013
135988
3