@fjell/core 4.4.3 → 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/commit.sh +8 -0
- package/dist/cjs/AItemService.js.map +1 -1
- package/dist/cjs/dictionary.js.map +1 -1
- package/dist/cjs/item/IFactory.js.map +1 -1
- package/dist/cjs/item/IQFactory.js.map +1 -1
- package/dist/cjs/item/IQUtils.js.map +1 -1
- package/dist/cjs/item/IUtils.js +44 -52
- package/dist/cjs/item/IUtils.js.map +1 -1
- package/dist/cjs/item/ItemQuery.js.map +1 -1
- package/dist/cjs/key/KUtils.js +8 -8
- package/dist/cjs/key/KUtils.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/esm/AItemService.js.map +1 -1
- package/dist/esm/dictionary.js.map +1 -1
- package/dist/esm/item/IFactory.js.map +1 -1
- package/dist/esm/item/IQFactory.js.map +1 -1
- package/dist/esm/item/IQUtils.js.map +1 -1
- package/dist/esm/item/IUtils.js +44 -52
- package/dist/esm/item/IUtils.js.map +1 -1
- package/dist/esm/item/ItemQuery.js.map +1 -1
- package/dist/esm/key/KUtils.js +8 -8
- package/dist/esm/key/KUtils.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/index.cjs +52 -60
- package/dist/index.cjs.map +1 -1
- 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 +12 -12
- 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 +1 -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.
|
|
4
|
+
"version": "4.4.4",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
@@ -14,30 +14,30 @@
|
|
|
14
14
|
},
|
|
15
15
|
"type": "module",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@fjell/logging": "^4.4.
|
|
17
|
+
"@fjell/logging": "^4.4.4",
|
|
18
18
|
"deepmerge": "^4.3.1",
|
|
19
19
|
"flatted": "^3.3.3",
|
|
20
20
|
"luxon": "^3.6.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@eslint/eslintrc": "^3.3.1",
|
|
24
|
-
"@eslint/js": "^9.
|
|
25
|
-
"@swc/core": "^1.12.
|
|
26
|
-
"@tsconfig/recommended": "^1.0.
|
|
24
|
+
"@eslint/js": "^9.30.0",
|
|
25
|
+
"@swc/core": "^1.12.7",
|
|
26
|
+
"@tsconfig/recommended": "^1.0.10",
|
|
27
27
|
"@types/luxon": "^3.6.2",
|
|
28
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
29
|
-
"@typescript-eslint/parser": "^8.
|
|
30
|
-
"@vitest/coverage-v8": "3.
|
|
31
|
-
"concurrently": "^9.
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
29
|
+
"@typescript-eslint/parser": "^8.35.0",
|
|
30
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
31
|
+
"concurrently": "^9.2.0",
|
|
32
32
|
"copyfiles": "^2.4.1",
|
|
33
|
-
"eslint": "^9.
|
|
33
|
+
"eslint": "^9.30.0",
|
|
34
34
|
"rimraf": "^6.0.1",
|
|
35
35
|
"tsc-alias": "^1.8.16",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"vite": "^
|
|
37
|
+
"vite": "^7.0.0",
|
|
38
38
|
"vite-plugin-dts": "^4.5.4",
|
|
39
39
|
"vite-plugin-node": "^5.0.1",
|
|
40
|
-
"vitest": "3.
|
|
40
|
+
"vitest": "3.2.4"
|
|
41
41
|
},
|
|
42
42
|
"repository": {
|
|
43
43
|
"type": "git",
|
package/release.sh
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
echo "Preparing for release: switching from workspace to remote dependencies."
|
|
6
|
+
if [ -f "pnpm-workspace.yaml" ]; then
|
|
7
|
+
echo "Renaming pnpm-workspace.yaml to prevent workspace-protocol resolution"
|
|
8
|
+
mv pnpm-workspace.yaml pnpm-workspace.yaml.bak
|
|
9
|
+
else
|
|
10
|
+
echo "pnpm-workspace.yaml not found, skipping rename."
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
echo "Updating dependencies to latest versions from registry"
|
|
14
|
+
pnpm update --latest
|
|
15
|
+
|
|
16
|
+
echo "Staging changes for release commit"
|
|
17
|
+
git add package.json pnpm-lock.yaml
|
|
18
|
+
if [ -f "pnpm-workspace.yaml.bak" ]; then
|
|
19
|
+
git add pnpm-workspace.yaml.bak
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
echo "Running clean, lint, build, and test..."
|
|
23
|
+
pnpm run clean && pnpm run lint && pnpm run build && pnpm run test
|
|
24
|
+
|
|
25
|
+
./commit.sh
|
|
26
|
+
|
|
27
|
+
echo "Bumping version..."
|
|
28
|
+
pnpm version patch
|
|
29
|
+
|
|
30
|
+
echo "Generating release notes..."
|
|
31
|
+
pnpm dlx @eldrforge/kodrdriv release > RELEASE_NOTES.md
|
|
32
|
+
|
|
33
|
+
echo "Pushing to origin..."
|
|
34
|
+
git push --follow-tags
|
|
35
|
+
|
|
36
|
+
echo "Creating GitHub pull request..."
|
|
37
|
+
PR_URL=$(gh pr create --fill)
|
|
38
|
+
PR_NUM=$(echo "$PR_URL" | grep -o '[0-9]*$')
|
|
39
|
+
echo "Pull request created: $PR_URL"
|
|
40
|
+
|
|
41
|
+
echo "Waiting for PR #$PR_NUM checks to complete..."
|
|
42
|
+
while true; do
|
|
43
|
+
STATUS=$(gh pr view "$PR_NUM" --json statusCheckRollup -q '.statusCheckRollup.state' | cat || echo "FAILURE")
|
|
44
|
+
echo "PR status: $STATUS"
|
|
45
|
+
if [[ "$STATUS" == "SUCCESS" ]]; then
|
|
46
|
+
echo "All checks passed!"
|
|
47
|
+
break
|
|
48
|
+
elif [[ "$STATUS" == "FAILURE" || "$STATUS" == "ERROR" ]]; then
|
|
49
|
+
echo "PR checks failed."
|
|
50
|
+
gh pr checks "$PR_NUM" | cat
|
|
51
|
+
exit 1
|
|
52
|
+
elif [[ "$STATUS" == "PENDING" ]]; then
|
|
53
|
+
echo "Checks are pending... waiting 30 seconds."
|
|
54
|
+
sleep 10
|
|
55
|
+
else
|
|
56
|
+
echo "Unknown PR status: $STATUS. Waiting 30 seconds."
|
|
57
|
+
sleep 10
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
echo "Merging PR #$PR_NUM..."
|
|
62
|
+
gh pr merge "$PR_NUM" --merge --delete-branch
|
|
63
|
+
|
|
64
|
+
echo "Checking out main branch..."
|
|
65
|
+
git checkout main
|
|
66
|
+
git pull origin main
|
|
67
|
+
|
|
68
|
+
echo "Creating GitHub release..."
|
|
69
|
+
TAG_NAME="v$(jq -r .version package.json)"
|
|
70
|
+
gh release create "$TAG_NAME" --notes-file RELEASE_NOTES.md
|
|
71
|
+
|
|
72
|
+
echo "Creating next release branch..."
|
|
73
|
+
CURRENT_VERSION=$(jq -r .version package.json)
|
|
74
|
+
IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION"
|
|
75
|
+
NEXT_PATCH=$((version_parts[2] + 1))
|
|
76
|
+
NEXT_VERSION="${version_parts[0]}.${version_parts[1]}.$NEXT_PATCH"
|
|
77
|
+
|
|
78
|
+
echo "Next version is $NEXT_VERSION"
|
|
79
|
+
git checkout -b "release/v$NEXT_VERSION"
|
|
80
|
+
pnpm version "$NEXT_VERSION" --no-git-tag-version --allow-same-version
|
|
81
|
+
git add package.json pnpm-lock.yaml
|
|
82
|
+
git commit -m "feat: Start release v$NEXT_VERSION"
|
|
83
|
+
git push -u origin "release/v$NEXT_VERSION"
|
|
84
|
+
|
|
85
|
+
echo "Restoring workspace configuration"
|
|
86
|
+
if [ -f "pnpm-workspace.yaml.bak" ]; then
|
|
87
|
+
echo "Restoring pnpm-workspace.yaml"
|
|
88
|
+
mv pnpm-workspace.yaml.bak pnpm-workspace.yaml
|
|
89
|
+
git add pnpm-workspace.yaml
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
echo "Restoring package.json from main branch"
|
|
93
|
+
git checkout main -- package.json
|
|
94
|
+
git add package.json
|
|
95
|
+
|
|
96
|
+
echo "Updating lockfile with workspace dependencies"
|
|
97
|
+
pnpm install
|
|
98
|
+
git add pnpm-lock.yaml
|
|
99
|
+
|
|
100
|
+
git commit -m "chore: Restore workspace configuration for development"
|
|
101
|
+
git push
|
|
102
|
+
|
|
103
|
+
echo "Release process completed."
|
package/src/item/IUtils.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable indent */
|
|
2
|
+
/* eslint-disable max-len */
|
|
1
3
|
import { Item } from "@/items";
|
|
2
4
|
import { isComKey, isPriKey, toKeyTypeArray } from "@/key/KUtils";
|
|
3
5
|
import { AllItemTypeArrays, ComKey, PriKey } from "@/keys";
|
|
@@ -6,42 +8,48 @@ import LibLogger from '@/logger';
|
|
|
6
8
|
|
|
7
9
|
const logger = LibLogger.get('IUtils');
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
const validatePKForItem = <
|
|
10
12
|
S extends string,
|
|
11
13
|
L1 extends string = never,
|
|
12
14
|
L2 extends string = never,
|
|
13
15
|
L3 extends string = never,
|
|
14
16
|
L4 extends string = never,
|
|
15
|
-
L5 extends string = never
|
|
16
|
-
>(
|
|
17
|
-
|
|
17
|
+
L5 extends string = never,
|
|
18
|
+
>(item: Item<S, L1, L2, L3, L4, L5>, pkType: S): Item<S, L1, L2, L3, L4, L5> => {
|
|
19
|
+
if (!item) {
|
|
20
|
+
logger.error('Validating PK, Item is undefined', { item });
|
|
21
|
+
throw new Error('Validating PK, Item is undefined');
|
|
22
|
+
}
|
|
23
|
+
if (!item.key) {
|
|
24
|
+
logger.error('Validating PK, Item does not have a key', { item });
|
|
25
|
+
throw new Error('Validating PK, Item does not have a key');
|
|
26
|
+
}
|
|
18
27
|
|
|
28
|
+
const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);
|
|
29
|
+
if (keyTypeArray[0] !== pkType) {
|
|
30
|
+
logger.error('Key Type Array Mismatch', { keyTypeArray, pkType });
|
|
31
|
+
throw new Error(`Item does not have the correct primary key type. Expected ${pkType}, got ${keyTypeArray[0]}`);
|
|
32
|
+
}
|
|
33
|
+
return item;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const validatePK = <
|
|
37
|
+
S extends string,
|
|
38
|
+
L1 extends string = never,
|
|
39
|
+
L2 extends string = never,
|
|
40
|
+
L3 extends string = never,
|
|
41
|
+
L4 extends string = never,
|
|
42
|
+
L5 extends string = never,
|
|
43
|
+
>(
|
|
44
|
+
input: Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[],
|
|
45
|
+
pkType: S,
|
|
46
|
+
): Item<S, L1, L2, L3, L4, L5> | Item<S, L1, L2, L3, L4, L5>[] => {
|
|
19
47
|
logger.trace('Checking Return Type', { input });
|
|
20
48
|
|
|
21
49
|
if (Array.isArray(input)) {
|
|
22
|
-
|
|
23
|
-
return itemArray.map((item) => validatePK(item, pkType)) as Item<S, L1, L2, L3, L4, L5>[];
|
|
24
|
-
} else {
|
|
25
|
-
const item = input as Item<S, L1, L2, L3, L4, L5>;
|
|
26
|
-
if( item ) {
|
|
27
|
-
if (item.key) {
|
|
28
|
-
const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);
|
|
29
|
-
const match: boolean = keyTypeArray[0] === pkType;
|
|
30
|
-
if (!match) {
|
|
31
|
-
logger.error('Key Type Array Mismatch', { keyTypeArray, pkType });
|
|
32
|
-
throw new Error('Item does not have the correct primary key type');
|
|
33
|
-
} else {
|
|
34
|
-
return item;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
logger.error('Validating PK, Item does not have a key', { item });
|
|
38
|
-
throw new Error('Validating PK, Item does not have a key');
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
logger.error('Validating PK, Item is undefined', { item });
|
|
42
|
-
throw new Error('Validating PK, Item is undefined');
|
|
43
|
-
}
|
|
50
|
+
return input.map((item) => validatePKForItem(item, pkType));
|
|
44
51
|
}
|
|
52
|
+
return validatePKForItem(input, pkType);
|
|
45
53
|
};
|
|
46
54
|
|
|
47
55
|
export const validateKeys = <
|
|
@@ -50,30 +58,30 @@ export const validateKeys = <
|
|
|
50
58
|
L2 extends string = never,
|
|
51
59
|
L3 extends string = never,
|
|
52
60
|
L4 extends string = never,
|
|
53
|
-
L5 extends string = never
|
|
54
|
-
>(
|
|
55
|
-
Item<S, L1, L2, L3, L4, L5
|
|
61
|
+
L5 extends string = never,
|
|
62
|
+
>(
|
|
63
|
+
item: Item<S, L1, L2, L3, L4, L5>,
|
|
64
|
+
keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>,
|
|
65
|
+
): Item<S, L1, L2, L3, L4, L5> => {
|
|
56
66
|
logger.trace('Checking Return Type', { item });
|
|
57
|
-
if(
|
|
58
|
-
if (item.key) {
|
|
59
|
-
const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);
|
|
60
|
-
if (keyTypeArray.length !== keyTypes.length) {
|
|
61
|
-
throw new Error('Item does not have the correct number of keys');
|
|
62
|
-
} else {
|
|
63
|
-
const match: boolean = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);
|
|
64
|
-
if (!match) {
|
|
65
|
-
logger.error('Key Type Array Mismatch', { keyTypeArray, thisKeyTypes: keyTypes });
|
|
66
|
-
throw new Error('Item does not have the correct key types');
|
|
67
|
-
} else {
|
|
68
|
-
return item;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
} else {
|
|
72
|
-
throw new Error('validating keys, item does not have a key: ' + JSON.stringify(item));
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
67
|
+
if (!item) {
|
|
75
68
|
throw new Error('validating keys, item is undefined');
|
|
76
69
|
}
|
|
70
|
+
if (!item.key) {
|
|
71
|
+
throw new Error('validating keys, item does not have a key: ' + JSON.stringify(item));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const keyTypeArray = toKeyTypeArray(item.key as ComKey<S, L1, L2, L3, L4, L5> | PriKey<S>);
|
|
75
|
+
if (keyTypeArray.length !== keyTypes.length) {
|
|
76
|
+
throw new Error(`Item does not have the correct number of keys. Expected ${keyTypes.length}, but got ${keyTypeArray.length}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const match: boolean = JSON.stringify(keyTypeArray) === JSON.stringify(keyTypes);
|
|
80
|
+
if (!match) {
|
|
81
|
+
logger.error('Key Type Array Mismatch', { keyTypeArray, thisKeyTypes: keyTypes });
|
|
82
|
+
throw new Error(`Item does not have the correct key types. Expected [${keyTypes.join(', ')}], but got [${keyTypeArray.join(', ')}]`);
|
|
83
|
+
}
|
|
84
|
+
return item;
|
|
77
85
|
};
|
|
78
86
|
|
|
79
87
|
export const isPriItem = <
|
|
@@ -82,10 +90,12 @@ export const isPriItem = <
|
|
|
82
90
|
L2 extends string = never,
|
|
83
91
|
L3 extends string = never,
|
|
84
92
|
L4 extends string = never,
|
|
85
|
-
L5 extends string = never
|
|
86
|
-
>(
|
|
87
|
-
|
|
88
|
-
}
|
|
93
|
+
L5 extends string = never,
|
|
94
|
+
>(
|
|
95
|
+
item: Item<S, L1, L2, L3, L4, L5>,
|
|
96
|
+
): item is Item<S> & { key: PriKey<S> } => {
|
|
97
|
+
return !!(item && item.key && isPriKey(item.key));
|
|
98
|
+
};
|
|
89
99
|
|
|
90
100
|
export const isComItem = <
|
|
91
101
|
S extends string,
|
|
@@ -93,7 +103,9 @@ export const isComItem = <
|
|
|
93
103
|
L2 extends string = never,
|
|
94
104
|
L3 extends string = never,
|
|
95
105
|
L4 extends string = never,
|
|
96
|
-
L5 extends string = never
|
|
97
|
-
>(
|
|
98
|
-
|
|
99
|
-
}
|
|
106
|
+
L5 extends string = never,
|
|
107
|
+
>(
|
|
108
|
+
item: Item<S, L1, L2, L3, L4, L5>,
|
|
109
|
+
): item is Item<S, L1, L2, L3, L4, L5> & { key: ComKey<S, L1, L2, L3, L4, L5> } => {
|
|
110
|
+
return !!(item && item.key && isComKey(item.key));
|
|
111
|
+
};
|
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
CHANGED