@kanjijs/store 0.2.0-beta.1 → 0.2.0-beta.10
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/index.js +59 -55
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1028,69 +1028,73 @@ var methodMetadataStore = new WeakMap;
|
|
|
1028
1028
|
var controllerMetadataStore = new WeakMap;
|
|
1029
1029
|
var moduleMetadataStore = new WeakMap;
|
|
1030
1030
|
var injectionMetadataStore = new WeakMap;
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
methods =
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
methods = new Map;
|
|
1045
|
-
methodMetadataStore.set(target, methods);
|
|
1046
|
-
}
|
|
1047
|
-
const existing = methods.get(methodName) || {};
|
|
1048
|
-
existing.contract = contract;
|
|
1049
|
-
methods.set(methodName, existing);
|
|
1050
|
-
},
|
|
1051
|
-
addMiddleware(target, middleware, methodName) {
|
|
1052
|
-
if (methodName) {
|
|
1031
|
+
var globalStore = globalThis;
|
|
1032
|
+
if (!globalStore.KANJI_METADATA_STORAGE) {
|
|
1033
|
+
globalStore.KANJI_METADATA_STORAGE = {
|
|
1034
|
+
addRoute(target, methodName, meta) {
|
|
1035
|
+
let methods = methodMetadataStore.get(target);
|
|
1036
|
+
if (!methods) {
|
|
1037
|
+
methods = new Map;
|
|
1038
|
+
methodMetadataStore.set(target, methods);
|
|
1039
|
+
}
|
|
1040
|
+
const existing = methods.get(methodName) || {};
|
|
1041
|
+
methods.set(methodName, { ...existing, ...meta });
|
|
1042
|
+
},
|
|
1043
|
+
addContract(target, methodName, contract) {
|
|
1053
1044
|
let methods = methodMetadataStore.get(target);
|
|
1054
1045
|
if (!methods) {
|
|
1055
1046
|
methods = new Map;
|
|
1056
1047
|
methodMetadataStore.set(target, methods);
|
|
1057
1048
|
}
|
|
1058
1049
|
const existing = methods.get(methodName) || {};
|
|
1059
|
-
existing.
|
|
1050
|
+
existing.contract = contract;
|
|
1060
1051
|
methods.set(methodName, existing);
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1052
|
+
},
|
|
1053
|
+
addMiddleware(target, middleware, methodName) {
|
|
1054
|
+
if (methodName) {
|
|
1055
|
+
let methods = methodMetadataStore.get(target);
|
|
1056
|
+
if (!methods) {
|
|
1057
|
+
methods = new Map;
|
|
1058
|
+
methodMetadataStore.set(target, methods);
|
|
1059
|
+
}
|
|
1060
|
+
const existing = methods.get(methodName) || {};
|
|
1061
|
+
existing.middlewares = [...existing.middlewares || [], middleware];
|
|
1062
|
+
methods.set(methodName, existing);
|
|
1063
|
+
} else {
|
|
1064
|
+
const existing = controllerMetadataStore.get(target) || { prefix: "/" };
|
|
1065
|
+
existing.middlewares = [...existing.middlewares || [], middleware];
|
|
1066
|
+
controllerMetadataStore.set(target, existing);
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
getRoutes(target) {
|
|
1070
|
+
return methodMetadataStore.get(target);
|
|
1071
|
+
},
|
|
1072
|
+
setController(target, meta) {
|
|
1073
|
+
controllerMetadataStore.set(target, meta);
|
|
1074
|
+
},
|
|
1075
|
+
getController(target) {
|
|
1076
|
+
return controllerMetadataStore.get(target);
|
|
1077
|
+
},
|
|
1078
|
+
defineModule(target, meta) {
|
|
1079
|
+
moduleMetadataStore.set(target, meta);
|
|
1080
|
+
},
|
|
1081
|
+
getModule(target) {
|
|
1082
|
+
return moduleMetadataStore.get(target);
|
|
1083
|
+
},
|
|
1084
|
+
addInjection(target, index, token) {
|
|
1085
|
+
let injections = injectionMetadataStore.get(target);
|
|
1086
|
+
if (!injections) {
|
|
1087
|
+
injections = new Map;
|
|
1088
|
+
injectionMetadataStore.set(target, injections);
|
|
1089
|
+
}
|
|
1090
|
+
injections.set(index, token);
|
|
1091
|
+
},
|
|
1092
|
+
getInjections(target) {
|
|
1093
|
+
return injectionMetadataStore.get(target);
|
|
1087
1094
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
return injectionMetadataStore.get(target);
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
var MetadataStorage = globalStore.KANJI_METADATA_STORAGE;
|
|
1094
1098
|
function Module(metadata) {
|
|
1095
1099
|
return (target) => {
|
|
1096
1100
|
MetadataStorage.defineModule(target, metadata);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanjijs/store",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
"build": "bun build src/index.ts --outdir dist --target bun"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@kanjijs/core": "workspace:*",
|
|
17
16
|
"drizzle-orm": "^0.30.0",
|
|
18
17
|
"postgres": "^3.4.3"
|
|
19
18
|
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@kanjijs/core": "^0.2.0-beta.10"
|
|
21
|
+
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"bun-types": "latest"
|
|
22
24
|
}
|