@fjell/core 4.3.4 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -10
- package/src/logger.ts +1 -1
- package/vite.config.ts +55 -0
- package/dist/src/AItemService.d.ts +0 -8
- package/dist/src/AItemService.js +0 -21
- package/dist/src/AItemService.js.map +0 -1
- package/dist/src/dictionary.d.ts +0 -16
- package/dist/src/dictionary.js +0 -44
- package/dist/src/dictionary.js.map +0 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.js +0 -12
- package/dist/src/index.js.map +0 -1
- package/dist/src/item/IFactory.d.ts +0 -16
- package/dist/src/item/IFactory.js +0 -64
- package/dist/src/item/IFactory.js.map +0 -1
- package/dist/src/item/IQFactory.d.ts +0 -23
- package/dist/src/item/IQFactory.js +0 -129
- package/dist/src/item/IQFactory.js.map +0 -1
- package/dist/src/item/IQUtils.d.ts +0 -35
- package/dist/src/item/IQUtils.js +0 -278
- package/dist/src/item/IQUtils.js.map +0 -1
- package/dist/src/item/IUtils.d.ts +0 -6
- package/dist/src/item/IUtils.js +0 -68
- package/dist/src/item/IUtils.js.map +0 -1
- package/dist/src/item/ItemQuery.d.ts +0 -62
- package/dist/src/item/ItemQuery.js +0 -10
- package/dist/src/item/ItemQuery.js.map +0 -1
- package/dist/src/items.d.ts +0 -51
- package/dist/src/items.js +0 -4
- package/dist/src/items.js.map +0 -1
- package/dist/src/key/KUtils.d.ts +0 -35
- package/dist/src/key/KUtils.js +0 -223
- package/dist/src/key/KUtils.js.map +0 -1
- package/dist/src/keys.d.ts +0 -66
- package/dist/src/keys.js +0 -5
- package/dist/src/keys.js.map +0 -1
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/logger.js +0 -4
- package/dist/src/logger.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/core",
|
|
3
3
|
"description": "Core Items for Fjell",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
7
7
|
"exports": {
|
|
@@ -12,35 +12,42 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"lint": "eslint .",
|
|
17
|
-
"dev": "concurrently \"tsc --watch\" \"tsc-alias -w\"",
|
|
18
|
-
"build": "yarn run lint && tsc --build --verbose --force && tsc-alias -p tsconfig.json",
|
|
19
|
-
"clean": "rimraf dist",
|
|
20
|
-
"test": "yarn run lint && yarn run jest --coverage"
|
|
21
|
-
},
|
|
22
15
|
"dependencies": {
|
|
16
|
+
"@eslint/js": "^9.27.0",
|
|
23
17
|
"@fjell/logging": "^4.3",
|
|
18
|
+
"deepmerge": "^4.3.1",
|
|
24
19
|
"flatted": "^3.3.3",
|
|
25
20
|
"luxon": "^3.5.0"
|
|
26
21
|
},
|
|
27
22
|
"devDependencies": {
|
|
23
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
24
|
+
"@swc/core": "^1.11.24",
|
|
28
25
|
"@tsconfig/recommended": "^1.0.8",
|
|
29
26
|
"@types/jest": "^29.5.14",
|
|
30
27
|
"@types/luxon": "^3.4.2",
|
|
31
28
|
"@typescript-eslint/eslint-plugin": "^8.24.1",
|
|
32
29
|
"@typescript-eslint/parser": "^8.24.1",
|
|
33
30
|
"concurrently": "^9.1.2",
|
|
31
|
+
"copyfiles": "^2.4.1",
|
|
34
32
|
"eslint": "^9.21.0",
|
|
35
33
|
"jest": "^29.7.0",
|
|
36
34
|
"rimraf": "^6.0.1",
|
|
37
35
|
"ts-jest": "^29.2.5",
|
|
38
36
|
"tsc-alias": "^1.8.10",
|
|
39
|
-
"typescript": "^5.7.3"
|
|
37
|
+
"typescript": "^5.7.3",
|
|
38
|
+
"vite": "^6.3.5",
|
|
39
|
+
"vite-plugin-dts": "^4.5.4",
|
|
40
|
+
"vite-plugin-node": "^5.0.1"
|
|
40
41
|
},
|
|
41
|
-
"packageManager": "yarn@4.6.0",
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
|
44
44
|
"url": "git+https://github.com/getfjell/core.git"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"lint": "eslint . --ext .ts --fix",
|
|
48
|
+
"dev": "concurrently \"tsc --watch\" \"tsc-alias -w\"",
|
|
49
|
+
"build": "tsc --noEmit && vite build",
|
|
50
|
+
"clean": "rimraf dist",
|
|
51
|
+
"test": "pnpm run lint && jest --coverage"
|
|
45
52
|
}
|
|
46
53
|
}
|
package/src/logger.ts
CHANGED
package/vite.config.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import { VitePluginNode } from 'vite-plugin-node';
|
|
3
|
+
import dts from 'vite-plugin-dts';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
server: {
|
|
8
|
+
port: 3000
|
|
9
|
+
},
|
|
10
|
+
plugins: [
|
|
11
|
+
...VitePluginNode({
|
|
12
|
+
adapter: 'express',
|
|
13
|
+
appPath: './src/index.ts',
|
|
14
|
+
exportName: 'viteNodeApp',
|
|
15
|
+
tsCompiler: 'swc',
|
|
16
|
+
}),
|
|
17
|
+
// visualizer({
|
|
18
|
+
// template: 'network',
|
|
19
|
+
// filename: 'network.html',
|
|
20
|
+
// projectRoot: process.cwd(),
|
|
21
|
+
// }),
|
|
22
|
+
dts({
|
|
23
|
+
entryRoot: 'src',
|
|
24
|
+
outDir: 'dist',
|
|
25
|
+
exclude: ['./tests/**/*.ts'],
|
|
26
|
+
include: ['./src/**/*.ts'],
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
resolve: {
|
|
30
|
+
alias: {
|
|
31
|
+
'@': path.resolve(__dirname, './src'),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
build: {
|
|
35
|
+
target: 'esnext',
|
|
36
|
+
outDir: 'dist',
|
|
37
|
+
lib: {
|
|
38
|
+
entry: './src/index.ts',
|
|
39
|
+
formats: ['es'],
|
|
40
|
+
},
|
|
41
|
+
rollupOptions: {
|
|
42
|
+
input: 'src/index.ts',
|
|
43
|
+
output: {
|
|
44
|
+
format: 'esm',
|
|
45
|
+
entryFileNames: '[name].js',
|
|
46
|
+
preserveModules: true,
|
|
47
|
+
exports: 'named',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
// Make sure Vite generates ESM-compatible code
|
|
51
|
+
modulePreload: false,
|
|
52
|
+
minify: false,
|
|
53
|
+
sourcemap: true
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AllItemTypeArrays } from "./keys";
|
|
2
|
-
export declare class AItemService<S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
3
|
-
private pkType;
|
|
4
|
-
private parentService;
|
|
5
|
-
constructor(pkType: S, parentService?: AItemService<L1, L2, L3, L4, L5, never>);
|
|
6
|
-
getPkType: () => S;
|
|
7
|
-
getKeyTypes: () => AllItemTypeArrays<S, L1, L2, L3, L4, L5>;
|
|
8
|
-
}
|
package/dist/src/AItemService.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class AItemService {
|
|
2
|
-
pkType;
|
|
3
|
-
parentService = null;
|
|
4
|
-
constructor(pkType, parentService) {
|
|
5
|
-
this.pkType = pkType;
|
|
6
|
-
if (parentService) {
|
|
7
|
-
this.parentService = parentService;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
getPkType = () => {
|
|
11
|
-
return this.pkType;
|
|
12
|
-
};
|
|
13
|
-
getKeyTypes = () => {
|
|
14
|
-
let keyTypes = [this.getPkType()];
|
|
15
|
-
if (this.parentService) {
|
|
16
|
-
keyTypes = keyTypes.concat(this.parentService.getKeyTypes());
|
|
17
|
-
}
|
|
18
|
-
return keyTypes;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=AItemService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AItemService.js","sourceRoot":"","sources":["../../src/AItemService.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,YAAY;IASf,MAAM,CAAI;IACV,aAAa,GAAmD,IAAI,CAAC;IAE7E,YACE,MAAS,EACT,aAAuD;QAEvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACrC,CAAC;IACH,CAAC;IAEM,SAAS,GAAG,GAAM,EAAE;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC,CAAA;IAEM,WAAW,GAAG,GAA6C,EAAE;QAClE,IAAI,QAAQ,GAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAErD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO,QAAoD,CAAC;IAC9D,CAAC,CAAA;CAEF"}
|
package/dist/src/dictionary.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare class Dictionary<T, V> {
|
|
2
|
-
protected map: {
|
|
3
|
-
[key: string]: V;
|
|
4
|
-
};
|
|
5
|
-
protected hashFunction: (key: T) => string;
|
|
6
|
-
constructor(map?: {
|
|
7
|
-
[key: string]: V;
|
|
8
|
-
}, hashFunction?: (key: T) => string);
|
|
9
|
-
set(key: T, item: V): void;
|
|
10
|
-
get(key: T): V | null;
|
|
11
|
-
delete(key: T): void;
|
|
12
|
-
keys(): T[];
|
|
13
|
-
values(): V[];
|
|
14
|
-
includesKey(key: T): boolean;
|
|
15
|
-
clone(): Dictionary<T, V>;
|
|
16
|
-
}
|
package/dist/src/dictionary.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import LibLogger from "./logger";
|
|
2
|
-
const logger = LibLogger.get("Dictionary");
|
|
3
|
-
export class Dictionary {
|
|
4
|
-
map = {};
|
|
5
|
-
hashFunction = (key) => JSON.stringify(key);
|
|
6
|
-
constructor(map, hashFunction) {
|
|
7
|
-
if (map) {
|
|
8
|
-
this.map = map;
|
|
9
|
-
}
|
|
10
|
-
if (hashFunction) {
|
|
11
|
-
this.hashFunction = hashFunction;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
set(key, item) {
|
|
15
|
-
logger.trace('set', { key, item });
|
|
16
|
-
const hashedKey = this.hashFunction(key);
|
|
17
|
-
this.map[hashedKey] = item;
|
|
18
|
-
}
|
|
19
|
-
get(key) {
|
|
20
|
-
logger.trace('get', { key });
|
|
21
|
-
const hashedKey = this.hashFunction(key);
|
|
22
|
-
return this.map[hashedKey] || null;
|
|
23
|
-
}
|
|
24
|
-
delete(key) {
|
|
25
|
-
logger.trace('delete', { key });
|
|
26
|
-
const hashedKey = this.hashFunction(key);
|
|
27
|
-
delete this.map[hashedKey];
|
|
28
|
-
}
|
|
29
|
-
keys() {
|
|
30
|
-
return Object.keys(this.map).map(key => JSON.parse(key));
|
|
31
|
-
}
|
|
32
|
-
values() {
|
|
33
|
-
return Object.values(this.map);
|
|
34
|
-
}
|
|
35
|
-
includesKey(key) {
|
|
36
|
-
return Object.keys(this.map).includes(this.hashFunction(key));
|
|
37
|
-
}
|
|
38
|
-
clone() {
|
|
39
|
-
const clonedMap = Object.assign({}, this.map);
|
|
40
|
-
const clone = new Dictionary(clonedMap, this.hashFunction);
|
|
41
|
-
return clone;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=dictionary.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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AAC,CAAA;IAC5B,CAAC;IAEM,IAAI;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEM,MAAM;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;IAEM,WAAW,CAAC,GAAM;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,CAAC;IAEM,KAAK;QACV,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAE9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAO,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./dictionary";
|
|
2
|
-
export * from "./keys";
|
|
3
|
-
export * from "./items";
|
|
4
|
-
export { IFactory } from "./item/IFactory";
|
|
5
|
-
export { AItemService } from "./AItemService";
|
|
6
|
-
export * from './key/KUtils';
|
|
7
|
-
export * from './item/IFactory';
|
|
8
|
-
export * from './item/IQFactory';
|
|
9
|
-
export * from './item/IQUtils';
|
|
10
|
-
export * from './item/IUtils';
|
|
11
|
-
export * from './item/ItemQuery';
|
package/dist/src/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./dictionary";
|
|
2
|
-
export * from "./keys";
|
|
3
|
-
export * from "./items";
|
|
4
|
-
export { IFactory } from "./item/IFactory";
|
|
5
|
-
export { AItemService } from "./AItemService";
|
|
6
|
-
export * from './key/KUtils';
|
|
7
|
-
export * from './item/IFactory';
|
|
8
|
-
export * from './item/IQFactory';
|
|
9
|
-
export * from './item/IQUtils';
|
|
10
|
-
export * from './item/IUtils';
|
|
11
|
-
export * from './item/ItemQuery';
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,cAAc,cAAc,CAAC;AAE7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Item } from '../items';
|
|
2
|
-
import { ComKey, PriKey } from '../keys';
|
|
3
|
-
export declare class IFactory<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> {
|
|
4
|
-
private item;
|
|
5
|
-
constructor(props?: Record<string, any>);
|
|
6
|
-
addRef(i: Item<any, any | never, any | never, any | never, any | never, any | never>, name?: string): this;
|
|
7
|
-
static addRef<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(i: V, name?: string): IFactory<V, S, L1, L2, L3, L4, L5>;
|
|
8
|
-
addDefaultEvents(): this;
|
|
9
|
-
addEvent(name: string, at: Date | null, by?: ComKey<any, any | never, any | never, any | never, any | never, any | never> | PriKey<any>): this;
|
|
10
|
-
static addEvent<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(name: string, at: Date | null, by?: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): IFactory<V, S, L1, L2, L3, L4, L5>;
|
|
11
|
-
addProp(name: string, value: string | number | boolean | Date): this;
|
|
12
|
-
static addProp<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(name: string, value: string | number | boolean | Date): IFactory<V, S, L1, L2, L3, L4, L5>;
|
|
13
|
-
addProps(props: Record<string, any>): this;
|
|
14
|
-
static addProps<V extends Item<S, L1, L2, L3, L4, L5>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(props: Record<string, any>): IFactory<V, S, L1, L2, L3, L4, L5>;
|
|
15
|
-
toItem(): V;
|
|
16
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import deepmerge from 'deepmerge';
|
|
2
|
-
import { primaryType } from '../key/KUtils';
|
|
3
|
-
export class IFactory {
|
|
4
|
-
item = {};
|
|
5
|
-
constructor(props = {}) {
|
|
6
|
-
this.item = deepmerge(this.item, props);
|
|
7
|
-
}
|
|
8
|
-
addRef(i, name) {
|
|
9
|
-
const ik = i.key;
|
|
10
|
-
const refName = name || primaryType(ik);
|
|
11
|
-
if (!this.item.refs) {
|
|
12
|
-
this.item.refs = {};
|
|
13
|
-
}
|
|
14
|
-
this.item.refs[refName] = ik;
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
static addRef(i, name) {
|
|
18
|
-
return new IFactory().addRef(i, name);
|
|
19
|
-
}
|
|
20
|
-
addDefaultEvents() {
|
|
21
|
-
if (!this.item.events) {
|
|
22
|
-
this.item.events = {};
|
|
23
|
-
}
|
|
24
|
-
const now = new Date();
|
|
25
|
-
if (!this.item.events.created) {
|
|
26
|
-
this.item.events.created = { at: now };
|
|
27
|
-
}
|
|
28
|
-
if (!this.item.events.updated) {
|
|
29
|
-
this.item.events.updated = { at: now };
|
|
30
|
-
}
|
|
31
|
-
if (!this.item.events.deleted) {
|
|
32
|
-
this.item.events.deleted = { at: null };
|
|
33
|
-
}
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
addEvent(name, at, by) {
|
|
37
|
-
if (!this.item.events) {
|
|
38
|
-
this.item.events = {};
|
|
39
|
-
}
|
|
40
|
-
this.item.events[name] = { at, by };
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
static addEvent(name, at, by) {
|
|
44
|
-
return new IFactory().addEvent(name, at, by);
|
|
45
|
-
}
|
|
46
|
-
addProp(name, value) {
|
|
47
|
-
this.item[name] = value;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
static addProp(name, value) {
|
|
51
|
-
return new IFactory().addProp(name, value);
|
|
52
|
-
}
|
|
53
|
-
addProps(props) {
|
|
54
|
-
this.item = deepmerge(this.item, props);
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
static addProps(props) {
|
|
58
|
-
return new IFactory().addProps(props);
|
|
59
|
-
}
|
|
60
|
-
toItem() {
|
|
61
|
-
return this.item;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=IFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFactory.js","sourceRoot":"","sources":["../../../src/item/IFactory.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,OAAO,QAAQ;IAQX,IAAI,GAAQ,EACnB,CAAC;IAEF,YAAmB,QAA6B,EAAE;QAChD,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,CAAmE,EAAE,IAAa;Q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,CAAC;IAEM,QAAQ,CACb,IAAY,EACZ,EAAe,EACf,EAAqF;QAErF,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACxB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,QAAQ,CAQpB,IAAY,EAAE,EAAe,EAAE,EAA8C;QAC7E,OAAO,IAAI,QAAQ,EAA4B,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAEM,OAAO,CAAC,IAAY,EAAE,KAAuC;QAClE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,OAAO,CAQnB,IAAY,EAAE,KAAuC;QACrD,OAAO,IAAI,QAAQ,EAA4B,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACvE,CAAC;IAEM,QAAQ,CAAC,KAA0B;QACxC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,QAAQ,CAQpB,KAA0B;QAC1B,OAAO,IAAI,QAAQ,EAA4B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClE,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAS,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CompoundType, Condition, ConditionOperator, EventQuery, ItemQuery, OrderDirection } from "./ItemQuery";
|
|
2
|
-
export declare class IQFactory {
|
|
3
|
-
private query;
|
|
4
|
-
constructor(query?: ItemQuery);
|
|
5
|
-
orderBy(field: string, direction?: OrderDirection): this;
|
|
6
|
-
agg(name: string, query: ItemQuery): this;
|
|
7
|
-
event(name: string, query: EventQuery): this;
|
|
8
|
-
conditions(conditions: Condition[], compoundType?: CompoundType): this;
|
|
9
|
-
limit(limit: number): this;
|
|
10
|
-
offset(offset: number): this;
|
|
11
|
-
pk(kt: string, pk: string, name?: string): this;
|
|
12
|
-
condition(column: string, value: string[] | string | number[] | number | boolean | Date, operator?: ConditionOperator): this;
|
|
13
|
-
static all(): IQFactory;
|
|
14
|
-
static orderBy(field: string, direction?: OrderDirection): IQFactory;
|
|
15
|
-
static agg(name: string, query: ItemQuery): IQFactory;
|
|
16
|
-
static event(name: string, query: EventQuery): IQFactory;
|
|
17
|
-
static limit(limit: number): IQFactory;
|
|
18
|
-
static offset(offset: number): IQFactory;
|
|
19
|
-
static pk(kt: string, pk: string, name?: string): IQFactory;
|
|
20
|
-
static condition(column: string, value: string[] | string | number[] | number | boolean | Date, operator?: ConditionOperator): IQFactory;
|
|
21
|
-
static conditions(conditions: Condition[], compoundType?: CompoundType): IQFactory;
|
|
22
|
-
toQuery(): ItemQuery;
|
|
23
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { cPK } from '../key/KUtils';
|
|
2
|
-
import { isCondition } from "./ItemQuery";
|
|
3
|
-
export class IQFactory {
|
|
4
|
-
query = {};
|
|
5
|
-
constructor(query = {}) {
|
|
6
|
-
this.query = query;
|
|
7
|
-
}
|
|
8
|
-
orderBy(field, direction = 'asc') {
|
|
9
|
-
if (!this.query.orderBy) {
|
|
10
|
-
this.query.orderBy = [];
|
|
11
|
-
}
|
|
12
|
-
this.query.orderBy.push({ field, direction });
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
agg(name, query) {
|
|
16
|
-
if (!this.query.aggs) {
|
|
17
|
-
this.query.aggs = {};
|
|
18
|
-
}
|
|
19
|
-
this.query.aggs[name] = query;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
event(name, query) {
|
|
23
|
-
if (!this.query.events) {
|
|
24
|
-
this.query.events = {};
|
|
25
|
-
}
|
|
26
|
-
this.query.events[name] = query;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
conditions(conditions, compoundType = 'AND') {
|
|
30
|
-
for (const condition of conditions) {
|
|
31
|
-
if (!isCondition(condition)) {
|
|
32
|
-
throw new Error(`Invalid condition: ${JSON.stringify(condition)}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (!this.query.compoundCondition) {
|
|
36
|
-
// If there is no top-level compound condition, create one
|
|
37
|
-
// with the given compound type. This will mostly likely be the most common case.
|
|
38
|
-
this.query.compoundCondition = {
|
|
39
|
-
compoundType,
|
|
40
|
-
conditions: conditions,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// If there is already a top-level compound condition, create a new compound condition
|
|
45
|
-
// and add it to the conditions array of the top-level compound condition.
|
|
46
|
-
const compoundCondition = {
|
|
47
|
-
compoundType,
|
|
48
|
-
conditions,
|
|
49
|
-
};
|
|
50
|
-
this.query.compoundCondition.conditions.push(compoundCondition);
|
|
51
|
-
}
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
limit(limit) {
|
|
55
|
-
this.query.limit = limit;
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
offset(offset) {
|
|
59
|
-
this.query.offset = offset;
|
|
60
|
-
return this;
|
|
61
|
-
}
|
|
62
|
-
// TODO: right now, we're only supporting PK refs for queries. Should add support for CKs
|
|
63
|
-
pk(kt, pk, name) {
|
|
64
|
-
if (!this.query.refs) {
|
|
65
|
-
this.query.refs = {};
|
|
66
|
-
}
|
|
67
|
-
const refName = name || kt;
|
|
68
|
-
this.query.refs[refName] = cPK(pk, kt);
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
condition(column, value, operator = '==') {
|
|
72
|
-
const condition = { column, value, operator };
|
|
73
|
-
if (isCondition(condition)) {
|
|
74
|
-
if (!this.query.compoundCondition) {
|
|
75
|
-
// If there is no top-level compound condition, create one
|
|
76
|
-
// with the default compound type of 'AND'.
|
|
77
|
-
this.query.compoundCondition = {
|
|
78
|
-
compoundType: 'AND',
|
|
79
|
-
conditions: [],
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
this.query.compoundCondition.conditions.push(condition);
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
throw new Error(`Invalid condition: ${JSON.stringify(condition)}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
static all() {
|
|
90
|
-
const iqFactory = new IQFactory();
|
|
91
|
-
return iqFactory;
|
|
92
|
-
}
|
|
93
|
-
static orderBy(field, direction = 'asc') {
|
|
94
|
-
const iqFactory = new IQFactory();
|
|
95
|
-
return iqFactory.orderBy(field, direction);
|
|
96
|
-
}
|
|
97
|
-
static agg(name, query) {
|
|
98
|
-
const iqFactory = new IQFactory();
|
|
99
|
-
return iqFactory.agg(name, query);
|
|
100
|
-
}
|
|
101
|
-
static event(name, query) {
|
|
102
|
-
const iqFactory = new IQFactory();
|
|
103
|
-
return iqFactory.event(name, query);
|
|
104
|
-
}
|
|
105
|
-
static limit(limit) {
|
|
106
|
-
const iqFactory = new IQFactory();
|
|
107
|
-
return iqFactory.limit(limit);
|
|
108
|
-
}
|
|
109
|
-
static offset(offset) {
|
|
110
|
-
const iqFactory = new IQFactory();
|
|
111
|
-
return iqFactory.offset(offset);
|
|
112
|
-
}
|
|
113
|
-
static pk(kt, pk, name) {
|
|
114
|
-
const iqFactory = new IQFactory();
|
|
115
|
-
return iqFactory.pk(kt, pk, name);
|
|
116
|
-
}
|
|
117
|
-
static condition(column, value, operator = '==') {
|
|
118
|
-
const iqFactory = new IQFactory();
|
|
119
|
-
return iqFactory.condition(column, value, operator);
|
|
120
|
-
}
|
|
121
|
-
static conditions(conditions, compoundType = 'AND') {
|
|
122
|
-
const iqFactory = new IQFactory();
|
|
123
|
-
return iqFactory.conditions(conditions, compoundType);
|
|
124
|
-
}
|
|
125
|
-
toQuery() {
|
|
126
|
-
return this.query;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=IQFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IQFactory.js","sourceRoot":"","sources":["../../../src/item/IQFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAKL,WAAW,EAGZ,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,SAAS;IAEZ,KAAK,GAAc,EAAE,CAAC;IAE9B,YAAmB,QAAmB,EAAE;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEM,OAAO,CAAC,KAAa,EAAE,YAA4B,KAAK;QAC7D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,GAAG,CAAC,IAAY,EAAE,KAAgB;QACvC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAY,EAAE,KAAiB;QAC1C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACvB,IAAI,CAAC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;CACF"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Item } from "../items";
|
|
2
|
-
import { ComKey, PriKey } from "../keys";
|
|
3
|
-
import { CompoundCondition, Condition, ItemQuery, QueryParams } from "./ItemQuery";
|
|
4
|
-
/**
|
|
5
|
-
* When we query or search, we're sending a GET request. This converts everything in ItemQuery into a flat
|
|
6
|
-
* object that can be sent over a GET request.
|
|
7
|
-
*
|
|
8
|
-
* Note that there is some discussion about this. Evidently Elastic supports search with POST, but that also
|
|
9
|
-
* feels like a bit of a hack. It's not a RESTful way to do things. So we're sticking with GET for now.
|
|
10
|
-
*
|
|
11
|
-
* For reference, look at RFC 9110 "HTTP Semantics", June which clarified on top of and RFC 7231. It's possible
|
|
12
|
-
* but there are so many caveats and conditions in the standard, it's not worth it.
|
|
13
|
-
*
|
|
14
|
-
* Anticipating the next question - "isn't there a limit to the length of a URL?" The specification does not
|
|
15
|
-
* specify a limit, and there are limits in various browsers and servers - Apache is 4,000 chars, Chrome is 2M chars.
|
|
16
|
-
* Short answer is that if this query is being used to craft something that complex, it is probably a better idea
|
|
17
|
-
* to provide an action or a custom query endpoint on the server.
|
|
18
|
-
*
|
|
19
|
-
* @param query
|
|
20
|
-
* @returns QueryParams ready to be get over a GET request.
|
|
21
|
-
*/
|
|
22
|
-
export declare const queryToParams: (query: ItemQuery) => QueryParams;
|
|
23
|
-
/**
|
|
24
|
-
* This method translates from a flat QueryParams object with stringify'd JSON back to a full ItemQuery.
|
|
25
|
-
*
|
|
26
|
-
* @param params Parameters sent over a GET request
|
|
27
|
-
* @returns A fully hydrated ItemQuery object.
|
|
28
|
-
*/
|
|
29
|
-
export declare const paramsToQuery: (params: QueryParams) => ItemQuery;
|
|
30
|
-
export declare const isQueryMatch: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Item<S, L1, L2, L3, L4, L5>, query: ItemQuery) => boolean;
|
|
31
|
-
export declare const abbrevQuery: (query: ItemQuery | null | undefined) => string;
|
|
32
|
-
export declare const abbrevRef: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(key: string, ref: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>) => string;
|
|
33
|
-
export declare const abbrevAgg: (key: string, agg: ItemQuery) => string;
|
|
34
|
-
export declare const abbrevCompoundCondition: (compoundCondition: CompoundCondition) => string;
|
|
35
|
-
export declare const abbrevCondition: (condition: Condition | CompoundCondition) => string;
|