@kanjijs/config 0.2.0-beta.12 → 0.2.0-beta.13

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.
@@ -0,0 +1,14 @@
1
+ import { type DynamicModule } from "@kanjijs/core";
2
+ import type { ZodSchema } from "zod";
3
+ export interface ConfigModuleOptions {
4
+ envFilePath?: string;
5
+ schema?: ZodSchema;
6
+ }
7
+ export declare class ConfigService<T = any> {
8
+ private readonly internalConfig;
9
+ constructor(internalConfig: T);
10
+ get<K extends keyof T>(key: K): T[K];
11
+ }
12
+ export declare class ConfigModule {
13
+ static forRoot(options?: ConfigModuleOptions): DynamicModule;
14
+ }
package/dist/index.js CHANGED
@@ -1402,69 +1402,73 @@ var methodMetadataStore = new WeakMap;
1402
1402
  var controllerMetadataStore = new WeakMap;
1403
1403
  var moduleMetadataStore = new WeakMap;
1404
1404
  var injectionMetadataStore = new WeakMap;
1405
- var MetadataStorage = {
1406
- addRoute(target, methodName, meta) {
1407
- let methods = methodMetadataStore.get(target);
1408
- if (!methods) {
1409
- methods = new Map;
1410
- methodMetadataStore.set(target, methods);
1411
- }
1412
- const existing = methods.get(methodName) || {};
1413
- methods.set(methodName, { ...existing, ...meta });
1414
- },
1415
- addContract(target, methodName, contract) {
1416
- let methods = methodMetadataStore.get(target);
1417
- if (!methods) {
1418
- methods = new Map;
1419
- methodMetadataStore.set(target, methods);
1420
- }
1421
- const existing = methods.get(methodName) || {};
1422
- existing.contract = contract;
1423
- methods.set(methodName, existing);
1424
- },
1425
- addMiddleware(target, middleware, methodName) {
1426
- if (methodName) {
1405
+ var globalStore = globalThis;
1406
+ if (!globalStore.KANJI_METADATA_STORAGE) {
1407
+ globalStore.KANJI_METADATA_STORAGE = {
1408
+ addRoute(target, methodName, meta) {
1409
+ let methods = methodMetadataStore.get(target);
1410
+ if (!methods) {
1411
+ methods = new Map;
1412
+ methodMetadataStore.set(target, methods);
1413
+ }
1414
+ const existing = methods.get(methodName) || {};
1415
+ methods.set(methodName, { ...existing, ...meta });
1416
+ },
1417
+ addContract(target, methodName, contract) {
1427
1418
  let methods = methodMetadataStore.get(target);
1428
1419
  if (!methods) {
1429
1420
  methods = new Map;
1430
1421
  methodMetadataStore.set(target, methods);
1431
1422
  }
1432
1423
  const existing = methods.get(methodName) || {};
1433
- existing.middlewares = [...existing.middlewares || [], middleware];
1424
+ existing.contract = contract;
1434
1425
  methods.set(methodName, existing);
1435
- } else {
1436
- const existing = controllerMetadataStore.get(target) || { prefix: "/" };
1437
- existing.middlewares = [...existing.middlewares || [], middleware];
1438
- controllerMetadataStore.set(target, existing);
1439
- }
1440
- },
1441
- getRoutes(target) {
1442
- return methodMetadataStore.get(target);
1443
- },
1444
- setController(target, meta) {
1445
- controllerMetadataStore.set(target, meta);
1446
- },
1447
- getController(target) {
1448
- return controllerMetadataStore.get(target);
1449
- },
1450
- defineModule(target, meta) {
1451
- moduleMetadataStore.set(target, meta);
1452
- },
1453
- getModule(target) {
1454
- return moduleMetadataStore.get(target);
1455
- },
1456
- addInjection(target, index, token) {
1457
- let injections = injectionMetadataStore.get(target);
1458
- if (!injections) {
1459
- injections = new Map;
1460
- injectionMetadataStore.set(target, injections);
1426
+ },
1427
+ addMiddleware(target, middleware, methodName) {
1428
+ if (methodName) {
1429
+ let methods = methodMetadataStore.get(target);
1430
+ if (!methods) {
1431
+ methods = new Map;
1432
+ methodMetadataStore.set(target, methods);
1433
+ }
1434
+ const existing = methods.get(methodName) || {};
1435
+ existing.middlewares = [...existing.middlewares || [], middleware];
1436
+ methods.set(methodName, existing);
1437
+ } else {
1438
+ const existing = controllerMetadataStore.get(target) || { prefix: "/" };
1439
+ existing.middlewares = [...existing.middlewares || [], middleware];
1440
+ controllerMetadataStore.set(target, existing);
1441
+ }
1442
+ },
1443
+ getRoutes(target) {
1444
+ return methodMetadataStore.get(target);
1445
+ },
1446
+ setController(target, meta) {
1447
+ controllerMetadataStore.set(target, meta);
1448
+ },
1449
+ getController(target) {
1450
+ return controllerMetadataStore.get(target);
1451
+ },
1452
+ defineModule(target, meta) {
1453
+ moduleMetadataStore.set(target, meta);
1454
+ },
1455
+ getModule(target) {
1456
+ return moduleMetadataStore.get(target);
1457
+ },
1458
+ addInjection(target, index, token) {
1459
+ let injections = injectionMetadataStore.get(target);
1460
+ if (!injections) {
1461
+ injections = new Map;
1462
+ injectionMetadataStore.set(target, injections);
1463
+ }
1464
+ injections.set(index, token);
1465
+ },
1466
+ getInjections(target) {
1467
+ return injectionMetadataStore.get(target);
1461
1468
  }
1462
- injections.set(index, token);
1463
- },
1464
- getInjections(target) {
1465
- return injectionMetadataStore.get(target);
1466
- }
1467
- };
1469
+ };
1470
+ }
1471
+ var MetadataStorage = globalStore.KANJI_METADATA_STORAGE;
1468
1472
  function Module(metadata) {
1469
1473
  return (target) => {
1470
1474
  MetadataStorage.defineModule(target, metadata);
@@ -1658,7 +1662,7 @@ class ModuleCompiler {
1658
1662
  const paramTypes = Reflect.getMetadata("design:paramtypes", clazz) || [];
1659
1663
  const injectionTokens = MetadataStorage.getInjections(clazz) || new Map;
1660
1664
  dependencies = paramTypes.map((t, i) => injectionTokens.get(i) || t);
1661
- } else if ("useFactory" in provider && provider.useFactory) {
1665
+ } else if ("useFactory" in provider) {
1662
1666
  targetName = provider.provide?.name || String(provider.provide);
1663
1667
  dependencies = provider.inject || [];
1664
1668
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanjijs/config",
3
- "version": "0.2.0-beta.12",
3
+ "version": "0.2.0-beta.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -10,10 +10,10 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "scripts": {
13
- "build": "bun build src/index.ts --outdir dist --target bun"
13
+ "build": "bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist"
14
14
  },
15
15
  "dependencies": {
16
- "@kanjijs/core": "^0.2.0-beta.12",
16
+ "@kanjijs/core": "^0.2.0-beta.13",
17
17
  "dotenv": "^16.4.1",
18
18
  "zod": "^3.22.4"
19
19
  },