@jovian/type-tools
Version:
TypeTools is a Typescript library for providing extensible tooling runtime validations and type helpers.
99 lines • 3.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseGlobalId = exports.getGlobalId = exports.typeFullName = exports.upstreamRuntime = exports.defaultUpstreamRoute = exports.defaultUpstreamPath = exports.defaultUpstreamUniverse = exports.defaultUpstreamTxDataTable = exports.defaultUpstreamMetadataTable = exports.defaultUpstreamDatabaseName = exports.DESC = exports.ASC = exports.UpstreamComparisonType = void 0;
exports.UpstreamComparisonType = Object.freeze({
'greater than': '__GT',
GT: '__GT',
'greater than or equal to': '__GTE',
GTE: '__GTE',
'less than': '__LT',
LT: '__LT',
'less than or equal to': '__LTE',
LTE: '__LTE',
'not in': '__NOT_IN',
'none of': '__NOT_IN',
'is none of': '__NOT_IN',
NOT_IN: '__NOT_IN',
NIN: '__NOT_IN',
'any of': '__IN',
'is any of': '__IN',
ANY_OF: '__IN',
IN: '__IN',
is: '__EQ',
EQ: '__EQ',
'equal to': '__EQ',
'is not': '__NEQ',
NEQ: '__NEQ',
'not equal to': '__NEQ',
});
;
exports.ASC = 1;
exports.DESC = -1;
exports.defaultUpstreamDatabaseName = 'upstream_data';
exports.defaultUpstreamMetadataTable = '__upstream_meta';
exports.defaultUpstreamTxDataTable = '__upstream_tx';
exports.defaultUpstreamUniverse = 'local';
exports.defaultUpstreamPath = 'local';
exports.defaultUpstreamRoute = '__upstream_df_route';
exports.upstreamRuntime = {
skipMetaChecks: false,
trackLastInsertIds: true,
};
function aliasedName(type) {
if (type.importedName) {
return type.importedName;
}
var path = type.path;
if (!path) {
return type.name;
}
var prefix = path.namespace ? "".concat(path.namespace, ".") : '';
if (path.importedName) {
return prefix + path.importedName;
}
else {
return prefix + type.name;
}
}
function typeFullName(type) {
var typeAny = type;
if (typeAny.globalName) {
return typeAny.globalName;
}
if (typeAny === null || typeAny === void 0 ? void 0 : typeAny.nscInfo) {
var season = typeAny.nscInfo.season ? typeAny.nscInfo.season : 1;
typeAny.globalName = "".concat(typeAny.nscInfo.name, ".s").concat(season, ".").concat(typeAny.nameAtDef ? typeAny.nameAtDef : typeAny.name);
}
else {
typeAny.globalName = aliasedName(type);
}
return typeAny.globalName;
}
exports.typeFullName = typeFullName;
function getGlobalId(type, path, localId) {
type = typeof type === 'string' ? type : typeFullName(type);
if (type.indexOf('.') === -1) {
type = "local.s1.".concat(type);
}
if (path) {
return "$ref.".concat(type, "/").concat(path, "/").concat(localId);
}
else {
return "$ref.".concat(type, "/").concat(localId);
}
}
exports.getGlobalId = getGlobalId;
function parseGlobalId(glid) {
var lit = glid.split('/');
var header = lit[0];
lit[0] = '';
var localId = lit.pop();
var path = lit.filter(function (a) { return a; }).join('/');
return {
typeFullName: header.substring(4),
path: path,
localId: localId,
};
}
exports.parseGlobalId = parseGlobalId;
//# sourceMappingURL=common.iface.js.map
;