@fjell/express-router 4.4.14 → 4.4.19
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/README.md +2 -2
- package/build.js +4 -0
- package/dist/CItemRouter.d.ts +5 -4
- package/dist/CItemRouter.d.ts.map +1 -0
- package/dist/CItemRouter.js +63 -92
- package/dist/CItemRouter.js.map +7 -1
- package/dist/Instance.d.ts +5 -4
- package/dist/Instance.d.ts.map +1 -0
- package/dist/Instance.js +12 -22
- package/dist/Instance.js.map +7 -1
- package/dist/InstanceFactory.d.ts +5 -4
- package/dist/InstanceFactory.d.ts.map +1 -0
- package/dist/InstanceFactory.js +10 -18
- package/dist/InstanceFactory.js.map +7 -1
- package/dist/ItemRouter.d.ts +5 -4
- package/dist/ItemRouter.d.ts.map +1 -0
- package/dist/ItemRouter.js +290 -405
- package/dist/ItemRouter.js.map +7 -1
- package/dist/PItemRouter.d.ts +5 -4
- package/dist/PItemRouter.d.ts.map +1 -0
- package/dist/PItemRouter.js +43 -67
- package/dist/PItemRouter.js.map +7 -1
- package/dist/Registry.d.ts +1 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +22 -27
- package/dist/Registry.js.map +7 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +7 -1
- package/dist/logger.d.ts +2 -1
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +6 -5
- package/dist/logger.js.map +7 -1
- package/dist/util/general.d.ts +1 -0
- package/dist/util/general.d.ts.map +1 -0
- package/dist/util/general.js +50 -0
- package/dist/util/general.js.map +7 -0
- package/docs/docs.config.ts +1 -32
- package/docs/package.json +4 -4
- package/docs/public/README.md +2 -2
- package/docs/tsconfig.node.json +2 -11
- package/package.json +25 -28
- package/vitest.config.ts +45 -0
- package/dist/CItemRouter.cjs +0 -100
- package/dist/CItemRouter.cjs.map +0 -1
- package/dist/Instance.cjs +0 -31
- package/dist/Instance.cjs.map +0 -1
- package/dist/InstanceFactory.cjs +0 -25
- package/dist/InstanceFactory.cjs.map +0 -1
- package/dist/ItemRouter.cjs +0 -427
- package/dist/ItemRouter.cjs.map +0 -1
- package/dist/PItemRouter.cjs +0 -75
- package/dist/PItemRouter.cjs.map +0 -1
- package/dist/Registry.cjs +0 -36
- package/dist/Registry.cjs.map +0 -1
- package/dist/index.cjs +0 -657
- package/dist/index.cjs.map +0 -1
- package/dist/logger.cjs +0 -10
- package/dist/logger.cjs.map +0 -1
- package/docs/package-lock.json +0 -5129
- package/docs/src/index.css +0 -21
- package/docs/src/main.tsx +0 -12
- package/docs/src/test/setup.ts +0 -1
- package/docs/src/types.d.ts +0 -4
package/docs/tsconfig.node.json
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "@fjell/docs-template/tsconfig.node.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"composite": true,
|
|
4
|
-
"skipLibCheck": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
|
-
"allowSyntheticDefaultImports": true,
|
|
8
|
-
"strict": true,
|
|
9
4
|
"noEmit": true
|
|
10
|
-
}
|
|
11
|
-
"include": [
|
|
12
|
-
"vite.config.ts",
|
|
13
|
-
"docs.config.ts"
|
|
14
|
-
]
|
|
5
|
+
}
|
|
15
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/express-router",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.19",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"express",
|
|
@@ -11,58 +11,55 @@
|
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=21"
|
|
13
13
|
},
|
|
14
|
-
"main": "dist/index.
|
|
14
|
+
"main": "dist/index.js",
|
|
15
15
|
"module": "dist/index.js",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
|
-
"import": "./dist/index.js"
|
|
20
|
-
"require": "./dist/index.cjs"
|
|
19
|
+
"import": "./dist/index.js"
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
"type": "module",
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run clean && node build.js",
|
|
25
|
+
"dev": "nodemon --watch src --ext ts --exec 'npm run build'",
|
|
26
|
+
"lint": "eslint . --ext .ts --fix",
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"test": "npm run lint && vitest run --coverage",
|
|
29
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
30
|
+
"docs:dev": "cd docs && npm run dev",
|
|
31
|
+
"docs:build": "cd docs && npm run build",
|
|
32
|
+
"docs:preview": "cd docs && npm run preview",
|
|
33
|
+
"docs:test": "cd docs && npm run test"
|
|
34
|
+
},
|
|
24
35
|
"dependencies": {
|
|
25
|
-
"@fjell/core": "^4.4.
|
|
26
|
-
"@fjell/docs-template": "1.0.
|
|
27
|
-
"@fjell/lib": "^4.4.
|
|
28
|
-
"@fjell/logging": "^4.4.
|
|
29
|
-
"@fjell/registry": "^4.4.
|
|
36
|
+
"@fjell/core": "^4.4.25",
|
|
37
|
+
"@fjell/docs-template": "1.0.25",
|
|
38
|
+
"@fjell/lib": "^4.4.26",
|
|
39
|
+
"@fjell/logging": "^4.4.30",
|
|
40
|
+
"@fjell/registry": "^4.4.20",
|
|
30
41
|
"deepmerge": "^4.3.1",
|
|
31
42
|
"express": "^5.1.0"
|
|
32
43
|
},
|
|
33
44
|
"devDependencies": {
|
|
34
45
|
"@eslint/eslintrc": "^3.3.1",
|
|
35
|
-
"@eslint/js": "^9.
|
|
36
|
-
"@fjell/eslint-config": "^1.
|
|
37
|
-
"@swc/core": "^1.13.2",
|
|
46
|
+
"@eslint/js": "^9.32.0",
|
|
47
|
+
"@fjell/eslint-config": "^1.1.3",
|
|
38
48
|
"@tsconfig/recommended": "^1.0.10",
|
|
39
49
|
"@types/express": "^5.0.3",
|
|
40
50
|
"@types/node": "^24.1.0",
|
|
41
51
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
42
52
|
"@typescript-eslint/parser": "^8.38.0",
|
|
43
53
|
"@vitest/coverage-v8": "^3.2.4",
|
|
44
|
-
"
|
|
54
|
+
"esbuild": "^0.25.8",
|
|
55
|
+
"eslint": "^9.32.0",
|
|
45
56
|
"nodemon": "^3.1.10",
|
|
46
57
|
"rimraf": "^6.0.1",
|
|
47
58
|
"typescript": "^5.8.3",
|
|
48
|
-
"vite": "^7.0.5",
|
|
49
|
-
"vite-plugin-dts": "^4.5.4",
|
|
50
|
-
"vite-plugin-node": "^7.0.0",
|
|
51
59
|
"vitest": "^3.2.4"
|
|
52
60
|
},
|
|
53
61
|
"repository": {
|
|
54
62
|
"type": "git",
|
|
55
63
|
"url": "git+https://github.com/getfjell/express-router.git"
|
|
56
|
-
},
|
|
57
|
-
"scripts": {
|
|
58
|
-
"build": "tsc --noEmit && vite build",
|
|
59
|
-
"dev": "nodemon --watch src --ext ts --exec 'pnpm build'",
|
|
60
|
-
"lint": "eslint . --ext .ts --fix",
|
|
61
|
-
"clean": "rimraf dist",
|
|
62
|
-
"test": "pnpm run lint && vitest run --coverage",
|
|
63
|
-
"docs:dev": "cd docs && npm run dev",
|
|
64
|
-
"docs:build": "cd docs && npm run build",
|
|
65
|
-
"docs:preview": "cd docs && npm run preview",
|
|
66
|
-
"docs:test": "cd docs && npm run test"
|
|
67
64
|
}
|
|
68
|
-
}
|
|
65
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
resolve: {
|
|
6
|
+
alias: {
|
|
7
|
+
'@': path.resolve(__dirname, './src'),
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
test: {
|
|
11
|
+
setupFiles: ['./tests/setup.ts'],
|
|
12
|
+
include: [
|
|
13
|
+
'tests/**/*.test.ts',
|
|
14
|
+
'tests/**/*.spec.ts',
|
|
15
|
+
],
|
|
16
|
+
coverage: {
|
|
17
|
+
provider: 'v8',
|
|
18
|
+
reporter: ['text', 'html', 'lcov'],
|
|
19
|
+
reportsDirectory: './coverage',
|
|
20
|
+
include: [
|
|
21
|
+
'src/**/*.ts',
|
|
22
|
+
'examples/**/*.ts',
|
|
23
|
+
],
|
|
24
|
+
exclude: [
|
|
25
|
+
'node_modules/',
|
|
26
|
+
'tests/',
|
|
27
|
+
'src/index.ts',
|
|
28
|
+
'dist/**/*.ts',
|
|
29
|
+
'dist/**/*.js',
|
|
30
|
+
'esbuild.config.js',
|
|
31
|
+
'vitest.config.ts',
|
|
32
|
+
'eslint.config.mjs',
|
|
33
|
+
],
|
|
34
|
+
thresholds: {
|
|
35
|
+
global: {
|
|
36
|
+
branches: 72,
|
|
37
|
+
functions: 100,
|
|
38
|
+
lines: 98,
|
|
39
|
+
statements: 98,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
environment: 'node',
|
|
44
|
+
},
|
|
45
|
+
});
|
package/dist/CItemRouter.cjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const core = require('@fjell/core');
|
|
6
|
-
const ItemRouter = require('./ItemRouter.cjs');
|
|
7
|
-
|
|
8
|
-
function _define_property(obj, key, value) {
|
|
9
|
-
if (key in obj) {
|
|
10
|
-
Object.defineProperty(obj, key, {
|
|
11
|
-
value: value,
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
obj[key] = value;
|
|
18
|
-
}
|
|
19
|
-
return obj;
|
|
20
|
-
}
|
|
21
|
-
class CItemRouter extends ItemRouter.ItemRouter {
|
|
22
|
-
hasParent() {
|
|
23
|
-
return !!this.parentRoute;
|
|
24
|
-
}
|
|
25
|
-
getIk(res) {
|
|
26
|
-
const pri = this.getPk(res);
|
|
27
|
-
const loc = this.getLocations(res);
|
|
28
|
-
return {
|
|
29
|
-
kt: pri.kt,
|
|
30
|
-
pk: pri.pk,
|
|
31
|
-
loc
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
getLKA(res) {
|
|
35
|
-
/**
|
|
36
|
-
* A location key array is passed to a child router to provide contextfor the items it will
|
|
37
|
-
* be working with. It is always a concatenation of "My LKA" + "Parent LKA" which will
|
|
38
|
-
* bubble all the way up to the root Primary.
|
|
39
|
-
*/ let lka = [
|
|
40
|
-
this.getLk(res)
|
|
41
|
-
];
|
|
42
|
-
lka = lka.concat(this.parentRoute.getLKA(res));
|
|
43
|
-
return lka;
|
|
44
|
-
}
|
|
45
|
-
getLocations(res) {
|
|
46
|
-
return this.parentRoute.getLKA(res);
|
|
47
|
-
}
|
|
48
|
-
constructor(lib, type, parentRoute, options = {}){
|
|
49
|
-
super(lib, type, options), _define_property(this, "parentRoute", void 0), _define_property(this, "createItem", async (req, res)=>{
|
|
50
|
-
const libOperations = this.lib.operations;
|
|
51
|
-
this.logger.default('Creating Item', {
|
|
52
|
-
body: req === null || req === void 0 ? void 0 : req.body,
|
|
53
|
-
query: req === null || req === void 0 ? void 0 : req.query,
|
|
54
|
-
params: req === null || req === void 0 ? void 0 : req.params,
|
|
55
|
-
locals: res === null || res === void 0 ? void 0 : res.locals
|
|
56
|
-
});
|
|
57
|
-
const itemToCreate = this.convertDates(req.body);
|
|
58
|
-
let item = core.validatePK(await libOperations.create(itemToCreate, {
|
|
59
|
-
locations: this.getLocations(res)
|
|
60
|
-
}), this.getPkType());
|
|
61
|
-
item = await this.postCreateItem(item);
|
|
62
|
-
this.logger.default('Created Item %j', item);
|
|
63
|
-
res.json(item);
|
|
64
|
-
}), _define_property(this, "findItems", async (req, res)=>{
|
|
65
|
-
const libOperations = this.lib.operations;
|
|
66
|
-
const query = req.query;
|
|
67
|
-
const finder = query['finder'];
|
|
68
|
-
const finderParams = query['finderParams'];
|
|
69
|
-
const one = query['one'];
|
|
70
|
-
let items = [];
|
|
71
|
-
if (finder) {
|
|
72
|
-
// If finder is defined? Call a finder.
|
|
73
|
-
this.logger.default('Finding Items with Finder', {
|
|
74
|
-
finder,
|
|
75
|
-
finderParams,
|
|
76
|
-
one
|
|
77
|
-
});
|
|
78
|
-
if (one === 'true') {
|
|
79
|
-
const item = await this.lib.findOne(finder, JSON.parse(finderParams), this.getLocations(res));
|
|
80
|
-
items = item ? [
|
|
81
|
-
item
|
|
82
|
-
] : [];
|
|
83
|
-
} else {
|
|
84
|
-
items = await libOperations.find(finder, JSON.parse(finderParams), this.getLocations(res));
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
// TODO: This is once of the more important places to perform some validaation and feedback
|
|
88
|
-
const itemQuery = core.paramsToQuery(req.query);
|
|
89
|
-
this.logger.default('Finding Items with Query: %j', itemQuery);
|
|
90
|
-
items = await libOperations.all(itemQuery, this.getLocations(res));
|
|
91
|
-
this.logger.default('Found %d Items with Query', items.length);
|
|
92
|
-
}
|
|
93
|
-
res.json(items.map((item)=>core.validatePK(item, this.getPkType())));
|
|
94
|
-
});
|
|
95
|
-
this.parentRoute = parentRoute;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
exports.CItemRouter = CItemRouter;
|
|
100
|
-
//# sourceMappingURL=CItemRouter.cjs.map
|
package/dist/CItemRouter.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CItemRouter.cjs","sources":["../src/CItemRouter.ts"],"sourcesContent":["import {\n ComKey, Item, ItemQuery, LocKey, LocKeyArray, paramsToQuery, PriKey, QueryParams, validatePK\n} from \"@fjell/core\";\nimport { Request, Response } from \"express\";\nimport { ItemRouter, ItemRouterOptions } from \"@/ItemRouter\";\nimport { Instance } from \"./Instance\";\n\ninterface ParsedQuery {\n [key: string]: undefined | string | string[] | ParsedQuery | ParsedQuery[];\n}\n\nexport class CItemRouter<\n T extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends ItemRouter<S, L1, L2, L3, L4, L5> {\n\n private parentRoute: ItemRouter<L1, L2, L3, L4, L5, never>;\n\n constructor(\n lib: Instance<T, S, L1, L2, L3, L4, L5>,\n type: S,\n parentRoute: ItemRouter<L1, L2, L3, L4, L5, never>,\n options: ItemRouterOptions = {},\n ) {\n super(lib as any, type, options);\n this.parentRoute = parentRoute;\n }\n\n public hasParent(): boolean {\n return !!this.parentRoute;\n }\n\n public getIk(res: Response): ComKey<S, L1, L2, L3, L4, L5> {\n const pri = this.getPk(res) as PriKey<S>;\n const loc = this.getLocations(res) as LocKeyArray<L1, L2, L3, L4, L5>;\n return { kt: pri.kt, pk: pri.pk, loc }\n }\n\n public getLKA(res: Response): LocKeyArray<S, L1, L2, L3, L4> {\n /**\n * A location key array is passed to a child router to provide contextfor the items it will\n * be working with. It is always a concatenation of \"My LKA\" + \"Parent LKA\" which will\n * bubble all the way up to the root Primary.\n */\n let lka: LocKey<S | L1 | L2 | L3 | L4>[] = [this.getLk(res)];\n lka = lka.concat(this.parentRoute.getLKA(res) as LocKey<S | L1 | L2 | L3 | L4>[]);\n return lka as LocKeyArray<S, L1, L2, L3, L4>;\n }\n\n public getLocations(res: Response): LocKeyArray<L1, L2, L3, L4, L5> {\n return this.parentRoute.getLKA(res) as LocKeyArray<L1, L2, L3, L4, L5>;\n }\n\n protected createItem = async (req: Request, res: Response) => {\n const libOperations = this.lib.operations;\n this.logger.default('Creating Item', { body: req?.body, query: req?.query, params: req?.params, locals: res?.locals });\n const itemToCreate = this.convertDates(req.body as Item<S, L1, L2, L3, L4, L5>);\n let item = validatePK(await libOperations.create(\n itemToCreate, { locations: this.getLocations(res) }), this.getPkType()) as Item<S, L1, L2, L3, L4, L5>;\n item = await this.postCreateItem(item);\n this.logger.default('Created Item %j', item);\n res.json(item);\n };\n\n protected findItems = async (req: Request, res: Response) => {\n const libOperations = this.lib.operations;\n const query: ParsedQuery = req.query as unknown as ParsedQuery;\n const finder = query['finder'] as string;\n const finderParams = query['finderParams'] as string;\n const one = query['one'] as string;\n\n let items: Item<S, L1, L2, L3, L4, L5>[] = [];\n\n if (finder) {\n // If finder is defined? Call a finder.\n this.logger.default('Finding Items with Finder', { finder, finderParams, one });\n\n if (one === 'true') {\n const item = await (this.lib as any).findOne(finder, JSON.parse(finderParams), this.getLocations(res));\n items = item ? [item] : [];\n } else {\n items = await libOperations.find(finder, JSON.parse(finderParams), this.getLocations(res));\n }\n } else {\n // TODO: This is once of the more important places to perform some validaation and feedback\n const itemQuery: ItemQuery = paramsToQuery(req.query as QueryParams);\n this.logger.default('Finding Items with Query: %j', itemQuery);\n items = await libOperations.all(itemQuery, this.getLocations(res));\n this.logger.default('Found %d Items with Query', items.length);\n }\n\n res.json(items.map((item: Item<S, L1, L2, L3, L4, L5>) => validatePK(item, this.getPkType())));\n };\n\n}\n"],"names":["CItemRouter","ItemRouter","hasParent","parentRoute","getIk","res","pri","getPk","loc","getLocations","kt","pk","getLKA","lka","getLk","concat","lib","type","options","createItem","req","libOperations","operations","logger","default","body","query","params","locals","itemToCreate","convertDates","item","validatePK","create","locations","getPkType","postCreateItem","json","findItems","finder","finderParams","one","items","findOne","JSON","parse","find","itemQuery","paramsToQuery","all","length","map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAWO,MAAMA,WAAAA,SAQHC,qBAAAA,CAAAA;IAcDC,SAAAA,GAAqB;AAC1B,QAAA,OAAO,CAAC,CAAC,IAAI,CAACC,WAAW;AAC3B,IAAA;AAEOC,IAAAA,KAAAA,CAAMC,GAAa,EAAiC;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AAA,CAAA,CAAA;QAnEE,IAAI,CAAChC,WAAW,GAAGA,WAAAA;AACrB,IAAA;AAoEF;;;;"}
|
package/dist/Instance.cjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const logger$1 = require('./logger.cjs');
|
|
6
|
-
const registry = require('@fjell/registry');
|
|
7
|
-
|
|
8
|
-
const logger = logger$1.default.get("Instance");
|
|
9
|
-
const createInstance = (registry$1, coordinate, router, operations, options)=>{
|
|
10
|
-
logger.debug("createInstance", {
|
|
11
|
-
coordinate,
|
|
12
|
-
router,
|
|
13
|
-
registry: registry$1,
|
|
14
|
-
operations,
|
|
15
|
-
options
|
|
16
|
-
});
|
|
17
|
-
const baseInstance = registry.createInstance(registry$1, coordinate);
|
|
18
|
-
return {
|
|
19
|
-
...baseInstance,
|
|
20
|
-
router,
|
|
21
|
-
operations,
|
|
22
|
-
options: options || {}
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const isInstance = (instance)=>{
|
|
26
|
-
return instance != null && typeof instance === 'object' && instance.coordinate != null && instance.router != null && instance.registry != null && instance.operations != null && instance.options != null;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.createInstance = createInstance;
|
|
30
|
-
exports.isInstance = isInstance;
|
|
31
|
-
//# sourceMappingURL=Instance.cjs.map
|
package/dist/Instance.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.cjs","sources":["../src/Instance.ts"],"sourcesContent":["import LibLogger from \"./logger\";\nimport { Item } from \"@fjell/core\";\nimport { Instance as BaseInstance, Coordinate, createInstance as createBaseInstance, Registry } from \"@fjell/registry\";\nimport { Operations, Options } from \"@fjell/lib\";\nimport { ItemRouter } from \"./ItemRouter\";\n\nconst logger = LibLogger.get(\"Instance\");\n\n/**\n * The Express Router Instance interface represents a router model instance that extends the base Instance\n * from @fjell/registry and adds express router operations for handling HTTP requests.\n *\n * The interface extends the base Instance (which provides coordinate and registry) with:\n * - router: Provides methods for routing HTTP requests and handling CRUD operations\n * - operations: Provides methods for interacting with the data model (get, find, all, etc.)\n * - options: Provides hooks, validators, finders, actions, and facets\n *\n * @template V - The type of the data model item, extending Item\n * @template S - The string literal type representing the model's key type\n * @template L1-L5 - Optional string literal types for location hierarchy levels\n */\nexport interface Instance<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> extends BaseInstance<S, L1, L2, L3, L4, L5> {\n /** The router object that provides methods for handling HTTP requests */\n router: ItemRouter<S, L1, L2, L3, L4, L5>;\n /** The operations object that provides methods for interacting with the data model */\n operations: Operations<V, S, L1, L2, L3, L4, L5>;\n /** The options object that provides hooks, validators, finders, actions, and facets */\n options: Options<V, S, L1, L2, L3, L4, L5>;\n /** The data model item type (for type safety) */\n readonly itemType?: V;\n}\n\nexport const createInstance = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n registry: Registry,\n coordinate: Coordinate<S, L1, L2, L3, L4, L5>,\n router: ItemRouter<S, L1, L2, L3, L4, L5>,\n operations: Operations<V, S, L1, L2, L3, L4, L5>,\n options?: Options<V, S, L1, L2, L3, L4, L5>,\n ): Instance<V, S, L1, L2, L3, L4, L5> => {\n logger.debug(\"createInstance\", { coordinate, router, registry, operations, options });\n const baseInstance = createBaseInstance(registry, coordinate);\n return { ...baseInstance, router, operations, options: options || {} as Options<V, S, L1, L2, L3, L4, L5> };\n}\n\nexport const isInstance = (instance: any): instance is Instance<any, any, any, any, any, any, any> => {\n return instance != null &&\n typeof instance === 'object' &&\n instance.coordinate != null &&\n instance.router != null &&\n instance.registry != null &&\n instance.operations != null &&\n instance.options != null;\n}\n"],"names":["logger","LibLogger","get","createInstance","registry","coordinate","router","operations","options","debug","baseInstance","createBaseInstance","isInstance","instance"],"mappings":";;;;;;;AAMA,MAAMA,MAAAA,GAASC,gBAAAA,CAAUC,GAAG,CAAC,UAAA,CAAA;MAkChBC,cAAAA,GAAiB,CAS1BC,UAAAA,EACAC,UAAAA,EACAC,QACAC,UAAAA,EACAC,OAAAA,GAAAA;IAEFR,MAAAA,CAAOS,KAAK,CAAC,gBAAA,EAAkB;AAAEJ,QAAAA,UAAAA;AAAYC,QAAAA,MAAAA;AAAQF,kBAAAA,UAAAA;AAAUG,QAAAA,UAAAA;AAAYC,QAAAA;AAAQ,KAAA,CAAA;IACnF,MAAME,YAAAA,GAAeC,wBAAmBP,UAAAA,EAAUC,UAAAA,CAAAA;IAClD,OAAO;AAAE,QAAA,GAAGK,YAAY;AAAEJ,QAAAA,MAAAA;AAAQC,QAAAA,UAAAA;AAAYC,QAAAA,OAAAA,EAASA,WAAW;AAAwC,KAAA;AAC5G;AAEO,MAAMI,aAAa,CAACC,QAAAA,GAAAA;IACzB,OAAOA,QAAAA,IAAY,QACjB,OAAOA,QAAAA,KAAa,YACpBA,QAAAA,CAASR,UAAU,IAAI,IAAA,IACvBQ,QAAAA,CAASP,MAAM,IAAI,IAAA,IACnBO,QAAAA,CAAST,QAAQ,IAAI,IAAA,IACrBS,QAAAA,CAASN,UAAU,IAAI,IAAA,IACvBM,QAAAA,CAASL,OAAO,IAAI,IAAA;AACxB;;;;;"}
|
package/dist/InstanceFactory.cjs
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
|
|
5
|
-
const Instance = require('./Instance.cjs');
|
|
6
|
-
const logger$1 = require('./logger.cjs');
|
|
7
|
-
|
|
8
|
-
const logger = logger$1.default.get("InstanceFactory");
|
|
9
|
-
/**
|
|
10
|
-
* Factory function for creating express-router instances
|
|
11
|
-
*/ const createInstanceFactory = (router, operations, options)=>{
|
|
12
|
-
return (coordinate, context)=>{
|
|
13
|
-
logger.debug("Creating express-router instance", {
|
|
14
|
-
coordinate,
|
|
15
|
-
registry: context.registry,
|
|
16
|
-
router,
|
|
17
|
-
operations,
|
|
18
|
-
options
|
|
19
|
-
});
|
|
20
|
-
return Instance.createInstance(context.registry, coordinate, router, operations, options);
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.createInstanceFactory = createInstanceFactory;
|
|
25
|
-
//# sourceMappingURL=InstanceFactory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InstanceFactory.cjs","sources":["../src/InstanceFactory.ts"],"sourcesContent":["import { Item } from \"@fjell/core\";\nimport { ItemRouter } from \"./ItemRouter\";\nimport { InstanceFactory as BaseInstanceFactory, Registry, RegistryHub } from \"@fjell/registry\";\nimport { Operations, Options } from \"@fjell/lib\";\nimport { createInstance, Instance } from \"./Instance\";\nimport { Coordinate } from \"@fjell/registry\";\nimport LibLogger from \"./logger\";\n\nconst logger = LibLogger.get(\"InstanceFactory\");\n\nexport type InstanceFactory<\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n> = (\n router: ItemRouter<S, L1, L2, L3, L4, L5>,\n operations: Operations<V, S, L1, L2, L3, L4, L5>,\n options?: Options<V, S, L1, L2, L3, L4, L5>\n) => BaseInstanceFactory<S, L1, L2, L3, L4, L5> & { readonly _itemType?: V };\n\n/**\n * Factory function for creating express-router instances\n */\nexport const createInstanceFactory = <\n V extends Item<S, L1, L2, L3, L4, L5>,\n S extends string,\n L1 extends string = never,\n L2 extends string = never,\n L3 extends string = never,\n L4 extends string = never,\n L5 extends string = never\n>(\n router: ItemRouter<S, L1, L2, L3, L4, L5>,\n operations: Operations<V, S, L1, L2, L3, L4, L5>,\n options?: Options<V, S, L1, L2, L3, L4, L5>\n ): BaseInstanceFactory<S, L1, L2, L3, L4, L5> => {\n return (coordinate: Coordinate<S, L1, L2, L3, L4, L5>, context: { registry: Registry, registryHub?: RegistryHub }) => {\n logger.debug(\"Creating express-router instance\", { coordinate, registry: context.registry, router, operations, options });\n\n return createInstance(context.registry, coordinate, router, operations, options) as Instance<V, S, L1, L2, L3, L4, L5>;\n };\n};\n"],"names":["logger","LibLogger","get","createInstanceFactory","router","operations","options","coordinate","context","debug","registry","createInstance"],"mappings":";;;;;;;AAQA,MAAMA,MAAAA,GAASC,gBAAAA,CAAUC,GAAG,CAAC,iBAAA,CAAA;AAgB7B;;AAEC,IACM,MAAMC,qBAAAA,GAAwB,CASjCC,QACAC,UAAAA,EACAC,OAAAA,GAAAA;AAEF,IAAA,OAAO,CAACC,UAAAA,EAA+CC,OAAAA,GAAAA;QACrDR,MAAAA,CAAOS,KAAK,CAAC,kCAAA,EAAoC;AAAEF,YAAAA,UAAAA;AAAYG,YAAAA,QAAAA,EAAUF,QAAQE,QAAQ;AAAEN,YAAAA,MAAAA;AAAQC,YAAAA,UAAAA;AAAYC,YAAAA;AAAQ,SAAA,CAAA;AAEvH,QAAA,OAAOK,wBAAeH,OAAAA,CAAQE,QAAQ,EAAEH,UAAAA,EAAYH,QAAQC,UAAAA,EAAYC,OAAAA,CAAAA;AAC1E,IAAA,CAAA;AACF;;;;"}
|