@fjell/lib-sequelize 4.4.83 → 4.4.85
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/LICENSE +1 -1
- package/dist/Options.d.ts +11 -0
- package/dist/Options.d.ts.map +1 -1
- package/dist/SequelizeLibrary.d.ts.map +1 -1
- package/dist/contained/SequelizeLibrary.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +215 -11
- package/dist/index.js.map +4 -4
- package/dist/primary/SequelizeLibrary.d.ts.map +1 -1
- package/dist/util/SequelizeInstanceWrapper.d.ts +52 -0
- package/dist/util/SequelizeInstanceWrapper.d.ts.map +1 -0
- package/guide/index.md +30 -0
- package/guide/integration.md +32 -0
- package/guide/usage.md +43 -0
- package/package.json +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SequelizeLibrary.d.ts","sourceRoot":"","sources":["../../src/primary/SequelizeLibrary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAiB,OAAO,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SequelizeLibrary.d.ts","sourceRoot":"","sources":["../../src/primary/SequelizeLibrary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAiB,OAAO,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAW7D,MAAM,WAAW,gBAAgB,CAC/B,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EACjB,CAAC,SAAS,MAAM;IAEhB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;CAC5B;AAED,wBAAgB,sBAAsB,CACpC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,EACjB,CAAC,SAAS,MAAM,EAEhB,OAAO,EAAE,CAAC,EACV,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,EAC1B,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAK,EACvC,MAAM,EAAE,MAAM,EAAE,YAAK,EACrB,QAAQ,EAAE,QAAQ,GACjB,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAwCxB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Model, ModelStatic } from 'sequelize';
|
|
2
|
+
export type DirectSaveBehavior = 'warn-and-throw' | 'warn-only';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for Sequelize instance wrapping behavior
|
|
5
|
+
*/
|
|
6
|
+
export interface SequelizeWrapperConfig {
|
|
7
|
+
/**
|
|
8
|
+
* Behavior when save() or update() is called directly on a Sequelize instance
|
|
9
|
+
* - 'warn-and-throw': Log a warning and throw an error (default)
|
|
10
|
+
* - 'warn-only': Log a warning but allow the operation to proceed
|
|
11
|
+
*/
|
|
12
|
+
directSaveBehavior?: DirectSaveBehavior;
|
|
13
|
+
/**
|
|
14
|
+
* The item type (kt) for better error messages
|
|
15
|
+
*/
|
|
16
|
+
itemType?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether hooks are defined for this library
|
|
19
|
+
*/
|
|
20
|
+
hasHooks?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a Sequelize Model instance to intercept direct save() and update() calls
|
|
24
|
+
* that would bypass Fjell hooks.
|
|
25
|
+
*
|
|
26
|
+
* @param instance - The Sequelize Model instance to wrap
|
|
27
|
+
* @param config - Configuration for wrapper behavior
|
|
28
|
+
* @returns A wrapped instance that intercepts save() and update() calls
|
|
29
|
+
*/
|
|
30
|
+
export declare function wrapSequelizeInstance<T extends Model>(instance: T, config?: SequelizeWrapperConfig): T;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a Sequelize library has hooks defined
|
|
33
|
+
*/
|
|
34
|
+
export declare function hasHooksDefined(options: {
|
|
35
|
+
hooks?: any;
|
|
36
|
+
validators?: any;
|
|
37
|
+
}): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Wraps a Sequelize ModelStatic class so that queries return wrapped instances.
|
|
40
|
+
* This ensures that when actions/facets query models directly via library.models,
|
|
41
|
+
* they receive wrapped instances that intercept direct save()/update() calls.
|
|
42
|
+
*
|
|
43
|
+
* @param modelClass - The Sequelize ModelStatic class to wrap
|
|
44
|
+
* @param config - Configuration for wrapper behavior
|
|
45
|
+
* @returns A wrapped ModelStatic that returns wrapped instances from queries
|
|
46
|
+
*/
|
|
47
|
+
export declare function wrapSequelizeModel<T extends ModelStatic<Model>>(modelClass: T, config?: SequelizeWrapperConfig): T;
|
|
48
|
+
/**
|
|
49
|
+
* Wraps an array of Sequelize ModelStatic classes
|
|
50
|
+
*/
|
|
51
|
+
export declare function wrapSequelizeModels(models: ModelStatic<any>[], config?: SequelizeWrapperConfig): ModelStatic<any>[];
|
|
52
|
+
//# sourceMappingURL=SequelizeInstanceWrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SequelizeInstanceWrapper.d.ts","sourceRoot":"","sources":["../../src/util/SequelizeInstanceWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAK/C,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAcD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,KAAK,EACnD,QAAQ,EAAE,CAAC,EACX,MAAM,GAAE,sBAA2B,GAClC,CAAC,CAoHH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,OAAO,CAYnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,CAAC,KAAK,CAAC,EAC7D,UAAU,EAAE,CAAC,EACb,MAAM,GAAE,sBAA2B,GAClC,CAAC,CAgFH;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,EAC1B,MAAM,GAAE,sBAA2B,GAClC,WAAW,CAAC,GAAG,CAAC,EAAE,CAEpB"}
|
package/guide/index.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @fjell/lib-sequelize - Agentic Guide
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Sequelize-backed Fjell library implementation for relational database persistence.
|
|
6
|
+
|
|
7
|
+
This guide is optimized for AI-assisted code generation and integration workflows.
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
- **[Usage Guide](./usage.md)** - API-oriented usage patterns and model-safe examples
|
|
12
|
+
- **[Integration Guide](./integration.md)** - Architecture placement, composition rules, and implementation guidance
|
|
13
|
+
|
|
14
|
+
## Key Capabilities
|
|
15
|
+
|
|
16
|
+
- Implements primary and contained operations on Sequelize models
|
|
17
|
+
- Provides definition and coordinate helpers for relational mappings
|
|
18
|
+
- Includes reference builder and Sequelize instance wrapper utilities
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @fjell/lib-sequelize
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Public API Highlights
|
|
27
|
+
|
|
28
|
+
- `SequelizeLibrary` and `SequelizeLibraryFactory`
|
|
29
|
+
- `createCoordinate`, `SCOPE_SEQUELIZE`, and definition/options exports
|
|
30
|
+
- `ReferenceBuilder` and `SequelizeInstanceWrapper` utilities
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Integration Guide
|
|
2
|
+
|
|
3
|
+
Guide for integrating `@fjell/lib-sequelize` into larger Fjell-based systems.
|
|
4
|
+
|
|
5
|
+
## Where It Fits
|
|
6
|
+
|
|
7
|
+
Sequelize-backed Fjell library implementation for relational database persistence.
|
|
8
|
+
|
|
9
|
+
## Recommended Integration Pattern
|
|
10
|
+
|
|
11
|
+
- Coordinate Sequelize model definitions with Fjell key conventions before first deployment
|
|
12
|
+
- Use transaction boundaries around multi-step provider operations
|
|
13
|
+
- Tune eager/lazy loading and indexing for predictable query performance
|
|
14
|
+
|
|
15
|
+
## System Composition Checklist
|
|
16
|
+
|
|
17
|
+
- Define package boundaries: schema/types, transport, operations, adapters, and UI.
|
|
18
|
+
- Keep contracts stable by sharing @fjell/types interfaces where applicable.
|
|
19
|
+
- Centralize retries/timeouts/logging around infrastructure-facing operations.
|
|
20
|
+
- Validate inputs at API boundaries before invoking persistence or provider layers.
|
|
21
|
+
- Add contract and integration tests for every generated workflow.
|
|
22
|
+
|
|
23
|
+
## Cross-Library Pairings
|
|
24
|
+
|
|
25
|
+
- Pair with @fjell/types for shared contracts.
|
|
26
|
+
- Pair with @fjell/validation for input and schema checks.
|
|
27
|
+
- Pair with @fjell/logging for observability in integration flows.
|
|
28
|
+
- Pair with storage/router/provider packages based on your runtime architecture.
|
|
29
|
+
|
|
30
|
+
## Integration Example Shape
|
|
31
|
+
|
|
32
|
+
Use this package behind an application service layer that exposes stable domain methods. Generated code should call those service methods, not raw infrastructure primitives, unless your architecture intentionally keeps infrastructure at the edge.
|
package/guide/usage.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Usage Guide
|
|
2
|
+
|
|
3
|
+
Comprehensive usage guidance for `@fjell/lib-sequelize`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fjell/lib-sequelize
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## API Highlights
|
|
12
|
+
|
|
13
|
+
- `SequelizeLibrary` and `SequelizeLibraryFactory`
|
|
14
|
+
- `createCoordinate`, `SCOPE_SEQUELIZE`, and definition/options exports
|
|
15
|
+
- `ReferenceBuilder` and `SequelizeInstanceWrapper` utilities
|
|
16
|
+
|
|
17
|
+
## Quick Example
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { SequelizeLibraryFactory } from "@fjell/lib-sequelize";
|
|
21
|
+
|
|
22
|
+
const factory = new SequelizeLibraryFactory({
|
|
23
|
+
sequelize,
|
|
24
|
+
tablePrefix: "fjell",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const library = factory.createPrimaryLibrary();
|
|
28
|
+
await library.save({ pri: { pk: "widget#1", sk: "meta" }, name: "Widget One" });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Model Consumption Rules
|
|
32
|
+
|
|
33
|
+
1. Import from the package root (`@fjell/lib-sequelize`) instead of deep-internal paths unless explicitly documented.
|
|
34
|
+
2. Keep usage aligned with exported public symbols listed in this guide.
|
|
35
|
+
3. Prefer explicit typing at package boundaries so generated code remains robust during upgrades.
|
|
36
|
+
4. Keep error handling deterministic and map infrastructure failures into domain-level errors.
|
|
37
|
+
5. Co-locate integration wrappers in your app so model-generated code has one canonical entry point.
|
|
38
|
+
|
|
39
|
+
## Best Practices
|
|
40
|
+
|
|
41
|
+
- Keep examples and abstractions consistent with existing Fjell package conventions.
|
|
42
|
+
- Favor composable wrappers over one-off inline integration logic.
|
|
43
|
+
- Add targeted tests around generated integration code paths.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/lib-sequelize",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.85",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"library",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"guide"
|
|
29
30
|
],
|
|
30
31
|
"scripts": {
|
|
31
32
|
"build": "npm run lint && node build.js",
|
|
@@ -41,12 +42,12 @@
|
|
|
41
42
|
"docs:test": "cd docs && npm run test"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@fjell/core": "^4.4.
|
|
45
|
-
"@fjell/lib": "^4.4.
|
|
46
|
-
"@fjell/logging": "^4.4.
|
|
47
|
-
"@fjell/registry": "^4.4.
|
|
48
|
-
"@fjell/types": "^4.4.
|
|
49
|
-
"@fjell/validation": "^4.4.
|
|
45
|
+
"@fjell/core": "^4.4.79",
|
|
46
|
+
"@fjell/lib": "^4.4.89",
|
|
47
|
+
"@fjell/logging": "^4.4.72",
|
|
48
|
+
"@fjell/registry": "^4.4.86",
|
|
49
|
+
"@fjell/types": "^4.4.9",
|
|
50
|
+
"@fjell/validation": "^4.4.6",
|
|
50
51
|
"dayjs": "^1.11.13",
|
|
51
52
|
"deepmerge": "^4.3.1",
|
|
52
53
|
"sequelize": "^6.37.7",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@eslint/eslintrc": "^3.3.1",
|
|
57
58
|
"@eslint/js": "^9.32.0",
|
|
58
|
-
"@fjell/common-config": "^1.1.
|
|
59
|
+
"@fjell/common-config": "^1.1.38",
|
|
59
60
|
"@swc/core": "^1.13.2",
|
|
60
61
|
"@tsconfig/recommended": "^1.0.10",
|
|
61
62
|
"@types/node": "^24.1.0",
|
|
@@ -72,6 +73,6 @@
|
|
|
72
73
|
},
|
|
73
74
|
"repository": {
|
|
74
75
|
"type": "git",
|
|
75
|
-
"url": "git+https://github.com/
|
|
76
|
+
"url": "git+https://github.com/fjellgrunn/lib-sequelize.git"
|
|
76
77
|
}
|
|
77
78
|
}
|