@fjell/core 4.4.2 → 4.4.4
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/.kodrdriv/config.yaml +10 -0
- package/.kodrdriv/context/content.md +1 -0
- package/commit.sh +8 -0
- package/dist/cjs/AItemService.js +42 -0
- package/dist/cjs/AItemService.js.map +1 -0
- package/dist/cjs/dictionary.js +71 -0
- package/dist/cjs/dictionary.js.map +1 -0
- package/dist/cjs/index.js +57 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/item/IFactory.js +93 -0
- package/dist/cjs/item/IFactory.js.map +1 -0
- package/dist/cjs/item/IQFactory.js +154 -0
- package/dist/cjs/item/IQFactory.js.map +1 -0
- package/dist/cjs/item/IQUtils.js +316 -0
- package/dist/cjs/item/IQUtils.js.map +1 -0
- package/dist/cjs/item/IUtils.js +76 -0
- package/dist/cjs/item/IUtils.js.map +1 -0
- package/dist/cjs/item/ItemQuery.js +10 -0
- package/dist/cjs/item/ItemQuery.js.map +1 -0
- package/dist/cjs/key/KUtils.js +298 -0
- package/dist/cjs/key/KUtils.js.map +1 -0
- package/dist/cjs/logger.js +10 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/esm/AItemService.js.map +1 -0
- package/dist/esm/dictionary.js.map +1 -0
- package/dist/esm/item/IFactory.js.map +1 -0
- package/dist/esm/item/IQFactory.js.map +1 -0
- package/dist/esm/item/IQUtils.js.map +1 -0
- package/dist/esm/item/IUtils.js +69 -0
- package/dist/esm/item/IUtils.js.map +1 -0
- package/dist/esm/item/ItemQuery.js.map +1 -0
- package/dist/{key → esm/key}/KUtils.js +8 -8
- package/dist/esm/key/KUtils.js.map +1 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/item/IUtils.d.ts +7 -3
- package/dist/items.d.ts +18 -10
- package/dist/key/KUtils.d.ts +8 -8
- package/package.json +24 -23
- package/release.sh +103 -0
- package/src/item/IUtils.ts +67 -55
- package/src/items.ts +35 -26
- package/src/key/KUtils.ts +13 -13
- package/vitest.config.ts +37 -0
- package/dist/AItemService.js.map +0 -1
- package/dist/dictionary.js.map +0 -1
- package/dist/item/IFactory.js.map +0 -1
- package/dist/item/IQFactory.js.map +0 -1
- package/dist/item/IQUtils.js.map +0 -1
- package/dist/item/IUtils.js +0 -77
- package/dist/item/IUtils.js.map +0 -1
- package/dist/item/ItemQuery.js.map +0 -1
- package/dist/key/KUtils.js.map +0 -1
- package/dist/logger.js.map +0 -1
- /package/dist/{AItemService.js → esm/AItemService.js} +0 -0
- /package/dist/{dictionary.js → esm/dictionary.js} +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{index.js.map → esm/index.js.map} +0 -0
- /package/dist/{item → esm/item}/IFactory.js +0 -0
- /package/dist/{item → esm/item}/IQFactory.js +0 -0
- /package/dist/{item → esm/item}/IQUtils.js +0 -0
- /package/dist/{item → esm/item}/ItemQuery.js +0 -0
- /package/dist/{logger.js → esm/logger.js} +0 -0
package/src/items.ts
CHANGED
|
@@ -16,8 +16,6 @@ export type Identified<S extends string,
|
|
|
16
16
|
key: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export type Propertied = { [key: string]: any };
|
|
20
|
-
|
|
21
19
|
/**
|
|
22
20
|
* This is a generic item event, and it's designed to make sure we have the ability to define not just
|
|
23
21
|
* the required fields, but also the optional fields.
|
|
@@ -48,29 +46,6 @@ export interface Deletable extends Partial<Evented> {
|
|
|
48
46
|
|
|
49
47
|
export type ManagedEvents = Timestamped & Deletable;
|
|
50
48
|
|
|
51
|
-
export type ItemProperties<
|
|
52
|
-
S extends string,
|
|
53
|
-
L1 extends string = never,
|
|
54
|
-
L2 extends string = never,
|
|
55
|
-
L3 extends string = never,
|
|
56
|
-
L4 extends string = never,
|
|
57
|
-
L5 extends string = never> =
|
|
58
|
-
Omit<Item<S, L1, L2, L3, L4, L5>, 'events' | 'key'> & {
|
|
59
|
-
events?: Evented;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export type TypesProperties<
|
|
63
|
-
V extends Item<S, L1, L2, L3, L4, L5>,
|
|
64
|
-
S extends string,
|
|
65
|
-
L1 extends string = never,
|
|
66
|
-
L2 extends string = never,
|
|
67
|
-
L3 extends string = never,
|
|
68
|
-
L4 extends string = never,
|
|
69
|
-
L5 extends string = never> =
|
|
70
|
-
Omit<V, 'events' | 'key'> & {
|
|
71
|
-
events?: Evented;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
49
|
export type References = Record<
|
|
75
50
|
string,
|
|
76
51
|
ComKey<string, string | never, string | never, string | never, string | never, string | never> |
|
|
@@ -94,9 +69,43 @@ export interface Item<S extends string = never,
|
|
|
94
69
|
L2 extends string = never,
|
|
95
70
|
L3 extends string = never,
|
|
96
71
|
L4 extends string = never,
|
|
97
|
-
L5 extends string = never> extends Identified<S, L1, L2, L3, L4, L5
|
|
72
|
+
L5 extends string = never> extends Identified<S, L1, L2, L3, L4, L5> {
|
|
98
73
|
events: ManagedEvents & Evented;
|
|
99
74
|
// TODO: This is a bit of a hack to get around the fact that we don't want to pass all these generics
|
|
100
75
|
aggs?: ReferenceItems;
|
|
101
76
|
refs?: References;
|
|
77
|
+
[key: string]: any
|
|
102
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Interface for properties that can be added to items
|
|
82
|
+
*/
|
|
83
|
+
export interface Propertied {
|
|
84
|
+
name: string;
|
|
85
|
+
value: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Type for item properties without the key - equivalent to Partial<Item> without the key
|
|
90
|
+
*/
|
|
91
|
+
export type ItemProperties<
|
|
92
|
+
S extends string = never,
|
|
93
|
+
L1 extends string = never,
|
|
94
|
+
L2 extends string = never,
|
|
95
|
+
L3 extends string = never,
|
|
96
|
+
L4 extends string = never,
|
|
97
|
+
L5 extends string = never
|
|
98
|
+
> = Partial<Omit<Item<S, L1, L2, L3, L4, L5>, 'key'>>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Type for item properties without the key - equivalent to Partial<Item> without the key
|
|
102
|
+
* This is an alias for ItemProperties for backward compatibility
|
|
103
|
+
*/
|
|
104
|
+
export type TypesProperties<
|
|
105
|
+
S extends string = never,
|
|
106
|
+
L1 extends string = never,
|
|
107
|
+
L2 extends string = never,
|
|
108
|
+
L3 extends string = never,
|
|
109
|
+
L4 extends string = never,
|
|
110
|
+
L5 extends string = never
|
|
111
|
+
> = Partial<Omit<Item<S, L1, L2, L3, L4, L5>, 'key'>>;
|
package/src/key/KUtils.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const isItemKeyEqual = <
|
|
|
23
23
|
if (isComKey(a) && isComKey(b)) {
|
|
24
24
|
return isComKeyEqual(a as ComKey<S, L1, L2, L3, L4, L5>, b as ComKey<S, L1, L2, L3, L4, L5>);
|
|
25
25
|
} else if (isPriKey(a) && isPriKey(b)) {
|
|
26
|
-
if(isComKey(a) || isComKey(b)) {
|
|
26
|
+
if (isComKey(a) || isComKey(b)) {
|
|
27
27
|
return false;
|
|
28
28
|
} else {
|
|
29
29
|
return isPriKeyEqual(a as PriKey<S>, b as PriKey<S>);
|
|
@@ -163,7 +163,7 @@ export const toKeyTypeArray = <
|
|
|
163
163
|
logger.trace('toKeyTypeArray', { ik });
|
|
164
164
|
if (isComKey(ik)) {
|
|
165
165
|
const ck = ik as ComKey<S, L1, L2, L3, L4, L5>;
|
|
166
|
-
return [ck.kt, ...ck.loc.map((l
|
|
166
|
+
return [ck.kt, ...ck.loc.map((l: LocKey<L1 | L2 | L3 | L4 | L5>) => l.kt)];
|
|
167
167
|
} else {
|
|
168
168
|
return [(ik as PriKey<S>).kt];
|
|
169
169
|
}
|
|
@@ -178,10 +178,10 @@ export const abbrevIK = <
|
|
|
178
178
|
L5 extends string = never
|
|
179
179
|
>(ik: ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>): string => {
|
|
180
180
|
logger.trace('abbrevIK', { ik });
|
|
181
|
-
if(ik) {
|
|
181
|
+
if (ik) {
|
|
182
182
|
if (isComKey(ik)) {
|
|
183
183
|
const ck = ik as ComKey<S, L1, L2, L3, L4, L5>;
|
|
184
|
-
return `${ck.kt}:${ck.pk}:${ck.loc.map((l
|
|
184
|
+
return `${ck.kt}:${ck.pk}:${ck.loc.map((l: LocKey<L1 | L2 | L3 | L4 | L5>) => `${l.kt}:${l.lk}`).join(',')}`;
|
|
185
185
|
} else {
|
|
186
186
|
return `${(ik as PriKey<S>).kt}:${(ik as PriKey<S>).pk}`;
|
|
187
187
|
}
|
|
@@ -228,10 +228,10 @@ export const primaryType = <
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
*
|
|
232
|
+
* @param ik ItemKey to be used as a basis for a location
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
235
|
export const itemKeyToLocKeyArray =
|
|
236
236
|
<
|
|
237
237
|
S extends string,
|
|
@@ -257,10 +257,10 @@ export const itemKeyToLocKeyArray =
|
|
|
257
257
|
export const ikToLKA = itemKeyToLocKeyArray;
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
* Sometimes you need to take a location key array and convert it to the item key that points to the containing item.
|
|
261
|
+
* @param lka A location key array
|
|
262
|
+
* @returns An item key corresponding to the containing item this location refers to.
|
|
263
|
+
*/
|
|
264
264
|
export const locKeyArrayToItemKey =
|
|
265
265
|
<
|
|
266
266
|
L1 extends string,
|
|
@@ -272,7 +272,7 @@ export const locKeyArrayToItemKey =
|
|
|
272
272
|
PriKey<L1> | ComKey<L1, L2, L3, L4, L5> => {
|
|
273
273
|
logger.trace('locKeyArrayToItemKey', { lka: abbrevLKA(lka as Array<LocKey<L1 | L2 | L3 | L4 | L5>>) });
|
|
274
274
|
|
|
275
|
-
if(lka && lka.length === 1) {
|
|
275
|
+
if (lka && lka.length === 1) {
|
|
276
276
|
const priKey = cPK(lka[0].lk, lka[0].kt);
|
|
277
277
|
return priKey as PriKey<L1>;
|
|
278
278
|
} else if (lka && lka.length > 1 && lka[0] !== undefined) {
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
'@': path.resolve(__dirname, './src'),
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
test: {
|
|
11
|
+
globals: true,
|
|
12
|
+
environment: 'node',
|
|
13
|
+
include: ['tests/**/*.test.ts'],
|
|
14
|
+
coverage: {
|
|
15
|
+
provider: 'v8',
|
|
16
|
+
all: true,
|
|
17
|
+
include: ['src/**/*.{ts,tsx}'],
|
|
18
|
+
exclude: [
|
|
19
|
+
'src/index.ts',
|
|
20
|
+
'tests/**',
|
|
21
|
+
'**/*.d.ts',
|
|
22
|
+
'node_modules/**',
|
|
23
|
+
'dist/**',
|
|
24
|
+
],
|
|
25
|
+
reportsDirectory: './coverage',
|
|
26
|
+
reporter: ['text', 'html', 'clover', 'json'],
|
|
27
|
+
thresholds: {
|
|
28
|
+
global: {
|
|
29
|
+
branches: 91,
|
|
30
|
+
functions: 100,
|
|
31
|
+
lines: 98,
|
|
32
|
+
statements: 98,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
package/dist/AItemService.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AItemService.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/dictionary.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IFactory.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IQFactory.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/item/IQUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IQUtils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/item/IUtils.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { toKeyTypeArray, isPriKey, isComKey } from '../key/KUtils.js';
|
|
2
|
-
import LibLogger from '../logger.js';
|
|
3
|
-
|
|
4
|
-
const logger = LibLogger.get('IUtils');
|
|
5
|
-
const validatePK = (input, pkType)=>{
|
|
6
|
-
logger.trace('Checking Return Type', {
|
|
7
|
-
input
|
|
8
|
-
});
|
|
9
|
-
if (Array.isArray(input)) {
|
|
10
|
-
const itemArray = input;
|
|
11
|
-
return itemArray.map((item)=>validatePK(item, pkType));
|
|
12
|
-
} else {
|
|
13
|
-
const item = input;
|
|
14
|
-
if (item) {
|
|
15
|
-
if (item.key) {
|
|
16
|
-
const keyTypeArray = toKeyTypeArray(item.key);
|
|
17
|
-
const match = keyTypeArray[0] === pkType;
|
|
18
|
-
if (!match) {
|
|
19
|
-
logger.error('Key Type Array Mismatch', {
|
|
20
|
-
keyTypeArray,
|
|
21
|
-
pkType
|
|
22
|
-
});
|
|
23
|
-
throw new Error('Item does not have the correct primary key type');
|
|
24
|
-
} else {
|
|
25
|
-
return item;
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
logger.error('Validating PK, Item does not have a key', {
|
|
29
|
-
item
|
|
30
|
-
});
|
|
31
|
-
throw new Error('Validating PK, Item does not have a key');
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
logger.error('Validating PK, Item is undefined', {
|
|
35
|
-
item
|
|
36
|
-
});
|
|
37
|
-
throw new Error('Validating PK, Item is undefined');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const validateKeys = (item, keyTypes)=>{
|
|
42
|
-
logger.trace('Checking Return Type', {
|
|
43
|
-
item
|
|
44
|
-
});
|
|
45
|
-
if (item) {
|
|
46
|
-
if (item.key) {
|
|
47
|
-
const keyTypeArray = toKeyTypeArray(item.key);
|
|
48
|
-
if (keyTypeArray.length !== keyTypes.length) {
|
|
49
|
-
throw new Error('Item does not have the correct number of keys');
|
|
50
|
-
} else {
|
|
51
|
-
const match = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);
|
|
52
|
-
if (!match) {
|
|
53
|
-
logger.error('Key Type Array Mismatch', {
|
|
54
|
-
keyTypeArray,
|
|
55
|
-
thisKeyTypes: keyTypes
|
|
56
|
-
});
|
|
57
|
-
throw new Error('Item does not have the correct key types');
|
|
58
|
-
} else {
|
|
59
|
-
return item;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error('validating keys, item does not have a key: ' + JSON.stringify(item));
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
throw new Error('validating keys, item is undefined');
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const isPriItem = (item)=>{
|
|
70
|
-
return item && item.key ? isPriKey(item.key) : false;
|
|
71
|
-
};
|
|
72
|
-
const isComItem = (item)=>{
|
|
73
|
-
return item && item.key ? isComKey(item.key) : false;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export { isComItem, isPriItem, validateKeys, validatePK };
|
|
77
|
-
//# sourceMappingURL=IUtils.js.map
|
package/dist/item/IUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IUtils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ItemQuery.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/dist/key/KUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"KUtils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|