@fjell/lib-sequelize 4.4.16 → 4.4.18
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/dist/AggregationBuilder.d.ts +5 -0
- package/dist/EventCoordinator.d.ts +6 -0
- package/dist/KeyMaster.d.ts +4 -0
- package/dist/OperationContext.d.ts +72 -0
- package/dist/QueryBuilder.d.ts +12 -0
- package/dist/ReferenceBuilder.d.ts +4 -0
- package/dist/RowProcessor.d.ts +6 -0
- package/dist/contained/SequelizeLibrary.d.ts +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/primary/SequelizeLibrary.d.ts +1 -1
- package/dist/util/general.d.ts +4 -0
- package/dist/util/relationshipUtils.d.ts +21 -0
- package/package.json +10 -10
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Item } from "@fjell/core";
|
|
2
|
+
import * as Library from "@fjell/lib";
|
|
3
|
+
import { AggregationDefinition } from "./Options";
|
|
4
|
+
import { OperationContext } from "./OperationContext";
|
|
5
|
+
export declare const buildAggregation: (item: Item, aggregationDefinition: AggregationDefinition, registry: Library.Registry, context?: OperationContext) => Promise<any>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Item } from '@fjell/core';
|
|
2
|
+
export declare const createEvents: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
3
|
+
export declare const updateEvents: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
4
|
+
export declare const populateEvents: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
5
|
+
export declare const extractEvents: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
6
|
+
export declare const removeEvents: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AllItemTypeArrays, Item } from '@fjell/core';
|
|
2
|
+
import { Model } from 'sequelize';
|
|
3
|
+
export declare const removeKey: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(item: Partial<Item<S, L1, L2, L3, L4, L5>>) => Partial<Item<S, L1, L2, L3, L4, L5>>;
|
|
4
|
+
export declare const addKey: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(model: Model<any, any>, item: Partial<Item<S, L1, L2, L3, L4, L5>>, keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>) => Item<S, L1, L2, L3, L4, L5>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ComKey, Item, PriKey } from "@fjell/core";
|
|
2
|
+
export type ItemKey = PriKey<any> | ComKey<any, any, any, any, any, any>;
|
|
3
|
+
export interface OperationContext {
|
|
4
|
+
/**
|
|
5
|
+
* Set of serialized keys that are currently being processed.
|
|
6
|
+
* Used to detect circular dependencies.
|
|
7
|
+
*/
|
|
8
|
+
inProgress: Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Cache of fully loaded objects keyed by serialized key.
|
|
11
|
+
* Used to avoid duplicate work and provide already-loaded objects.
|
|
12
|
+
* Can store individual items, arrays, or any other values.
|
|
13
|
+
*/
|
|
14
|
+
cache: Map<string, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Add a key to the in-progress set
|
|
17
|
+
*/
|
|
18
|
+
markInProgress(key: ItemKey): void;
|
|
19
|
+
/**
|
|
20
|
+
* Remove a key from the in-progress set
|
|
21
|
+
*/
|
|
22
|
+
markComplete(key: ItemKey): void;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a key is currently being processed (cycle detection)
|
|
25
|
+
*/
|
|
26
|
+
isInProgress(key: ItemKey): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get a cached object by key
|
|
29
|
+
*/
|
|
30
|
+
getCached(key: ItemKey): Item<any, any, any, any, any, any> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Cache a loaded object by key
|
|
33
|
+
*/
|
|
34
|
+
setCached(key: ItemKey, item: Item<any, any, any, any, any, any>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Check if an object is cached
|
|
37
|
+
*/
|
|
38
|
+
isCached(key: ItemKey): boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Serialize an ItemKey to a string for use in sets and maps
|
|
42
|
+
*/
|
|
43
|
+
export declare const serializeKey: (key: ItemKey) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new OperationContext
|
|
46
|
+
*/
|
|
47
|
+
export declare const createOperationContext: () => OperationContext;
|
|
48
|
+
/**
|
|
49
|
+
* Context Manager for sharing context across operations without changing public interfaces
|
|
50
|
+
*/
|
|
51
|
+
declare class ContextManager {
|
|
52
|
+
private contexts;
|
|
53
|
+
private currentContextId;
|
|
54
|
+
/**
|
|
55
|
+
* Set the current context for the current operation chain
|
|
56
|
+
*/
|
|
57
|
+
setCurrentContext(context: OperationContext): string;
|
|
58
|
+
/**
|
|
59
|
+
* Get the current context if one is set
|
|
60
|
+
*/
|
|
61
|
+
getCurrentContext(): OperationContext | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Clear the current context
|
|
64
|
+
*/
|
|
65
|
+
clearCurrentContext(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Execute a function with a specific context set as current
|
|
68
|
+
*/
|
|
69
|
+
withContext<T>(context: OperationContext, fn: () => Promise<T>): Promise<T>;
|
|
70
|
+
}
|
|
71
|
+
export declare const contextManager: ContextManager;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompoundCondition, Condition, ItemQuery } from '@fjell/core';
|
|
2
|
+
import { ModelStatic } from 'sequelize';
|
|
3
|
+
export type QueryOptions = {
|
|
4
|
+
where: Record<string, any>;
|
|
5
|
+
limit?: number;
|
|
6
|
+
offset?: number;
|
|
7
|
+
order?: Array<[string, string]>;
|
|
8
|
+
include?: Array<any>;
|
|
9
|
+
};
|
|
10
|
+
export declare const addCompoundCondition: (options: any, compoundCondition: CompoundCondition, model: ModelStatic<any>) => any;
|
|
11
|
+
export declare const addCondition: (conditions: Record<string, any>, condition: Condition, model: ModelStatic<any>) => Record<string, any>;
|
|
12
|
+
export declare const buildQuery: (itemQuery: ItemQuery, model: ModelStatic<any>) => any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ReferenceDefinition } from "./Options";
|
|
2
|
+
import * as Library from "@fjell/lib";
|
|
3
|
+
import { OperationContext } from "./OperationContext";
|
|
4
|
+
export declare const buildReference: (item: any, referenceDefinition: ReferenceDefinition, registry: Library.Registry, context?: OperationContext) => Promise<any>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AllItemTypeArrays, Item } from "@fjell/core";
|
|
2
|
+
import { Model } from "sequelize";
|
|
3
|
+
import { AggregationDefinition, ReferenceDefinition } from "./Options";
|
|
4
|
+
import * as Library from "@fjell/lib";
|
|
5
|
+
import { OperationContext } from "./OperationContext";
|
|
6
|
+
export declare const processRow: <S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never>(row: Model<any, any>, keyTypes: AllItemTypeArrays<S, L1, L2, L3, L4, L5>, referenceDefinitions: ReferenceDefinition[], aggregationDefinitions: AggregationDefinition[], registry: Library.Registry, context?: OperationContext) => Promise<Item<S, L1, L2, L3, L4, L5>>;
|
|
@@ -6,6 +6,6 @@ import { Options } from '@/Options';
|
|
|
6
6
|
export interface SequelizeLibrary<V extends Item<S>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends AbstractSequelizeLibrary<V, S, L1, L2, L3, L4, L5> {
|
|
7
7
|
models: ModelStatic<any>[];
|
|
8
8
|
}
|
|
9
|
-
export declare function createSequelizeLibrary<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>(keyTypes: ItemTypeArray<S, L1, L2, L3, L4, L5>, models: ModelStatic<any>[], libOptions: Partial<Options<V, S, L1, L2, L3, L4, L5
|
|
9
|
+
export declare function createSequelizeLibrary<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>(keyTypes: ItemTypeArray<S, L1, L2, L3, L4, L5>, models: ModelStatic<any>[], libOptions: Partial<Options<V, S, L1, L2, L3, L4, L5>> | undefined, scopes: string[] | undefined, registry: Registry): SequelizeLibrary<V, S, L1, L2, L3, L4, L5>;
|
|
10
10
|
export declare const createInstance: typeof createSequelizeLibrary;
|
|
11
11
|
export type Instance<V extends Item<S>, S extends string, L1 extends string = never, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> = SequelizeLibrary<V, S, L1, L2, L3, L4, L5>;
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const LibLogger:
|
|
1
|
+
declare const LibLogger: import("@fjell/logging").Logger;
|
|
2
2
|
export default LibLogger;
|
|
@@ -6,6 +6,6 @@ import { Registry } from '@/Registry';
|
|
|
6
6
|
export interface SequelizeLibrary<V extends Item<S>, S extends string> extends AbstractSequelizeLibrary<V, S> {
|
|
7
7
|
models: ModelStatic<any>[];
|
|
8
8
|
}
|
|
9
|
-
export declare function createSequelizeLibrary<V extends Item<S>, S extends string>(keyType: S, models: ModelStatic<any>[], libOptions: Partial<Options<V, S
|
|
9
|
+
export declare function createSequelizeLibrary<V extends Item<S>, S extends string>(keyType: S, models: ModelStatic<any>[], libOptions: Partial<Options<V, S>> | undefined, scopes: string[] | undefined, registry: Registry): SequelizeLibrary<V, S>;
|
|
10
10
|
export declare const createInstance: typeof createSequelizeLibrary;
|
|
11
11
|
export type Instance<V extends Item<S>, S extends string> = SequelizeLibrary<V, S>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModelStatic } from 'sequelize';
|
|
2
|
+
export interface RelationshipChainResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
path?: string;
|
|
5
|
+
includes?: any[];
|
|
6
|
+
}
|
|
7
|
+
export interface RelationshipPathResult {
|
|
8
|
+
found: boolean;
|
|
9
|
+
path?: string;
|
|
10
|
+
includes?: any[];
|
|
11
|
+
isDirect?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Helper function to build relationship chain includes
|
|
15
|
+
*/
|
|
16
|
+
export declare const buildRelationshipChain: (targetModel: ModelStatic<any>, kta: string[], currentIndex: number, targetIndex: number) => RelationshipChainResult;
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to build relationship path for a locator
|
|
19
|
+
* @param includeIsDirect Whether to include the isDirect flag in the result
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildRelationshipPath: (targetModel: ModelStatic<any>, locatorType: string, kta: string[], includeIsDirect?: boolean) => RelationshipPathResult;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/lib-sequelize",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.18",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"library",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@fjell/core": "^4.4.
|
|
32
|
-
"@fjell/lib": "^4.4.
|
|
33
|
-
"@fjell/logging": "^4.4.
|
|
34
|
-
"@fjell/registry": "^4.4.
|
|
31
|
+
"@fjell/core": "^4.4.25",
|
|
32
|
+
"@fjell/lib": "^4.4.26",
|
|
33
|
+
"@fjell/logging": "^4.4.30",
|
|
34
|
+
"@fjell/registry": "^4.4.20",
|
|
35
35
|
"dayjs": "^1.11.13",
|
|
36
36
|
"deepmerge": "^4.3.1",
|
|
37
37
|
"sequelize": "^6.37.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@eslint/eslintrc": "^3.3.1",
|
|
41
|
-
"@eslint/js": "^9.
|
|
42
|
-
"@fjell/eslint-config": "^1.
|
|
41
|
+
"@eslint/js": "^9.32.0",
|
|
42
|
+
"@fjell/eslint-config": "^1.1.3",
|
|
43
43
|
"@swc/core": "^1.13.2",
|
|
44
44
|
"@tsconfig/recommended": "^1.0.10",
|
|
45
45
|
"@types/node": "^24.1.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@vitest/coverage-v8": "^3.2.4",
|
|
49
49
|
"@vitest/ui": "^3.2.4",
|
|
50
50
|
"esbuild": "^0.25.8",
|
|
51
|
-
"eslint": "^9.
|
|
51
|
+
"eslint": "^9.32.0",
|
|
52
52
|
"rimraf": "^6.0.1",
|
|
53
53
|
"ts-node": "^10.9.2",
|
|
54
54
|
"tsc-alias": "^1.8.16",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"url": "git+https://github.com/getfjell/lib-sequelize.git"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
|
-
"build": "pnpm run lint && node
|
|
64
|
-
"dev": "node
|
|
63
|
+
"build": "pnpm run lint && node build.js",
|
|
64
|
+
"dev": "node build.js --watch",
|
|
65
65
|
"lint": "eslint . --ext .ts --fix",
|
|
66
66
|
"clean": "rimraf dist",
|
|
67
67
|
"test": "vitest run --coverage",
|