@arikajs/foundation 0.0.1

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +601 -0
  3. package/dist/application/Application.d.ts +73 -0
  4. package/dist/application/Application.d.ts.map +1 -0
  5. package/dist/application/Application.js +196 -0
  6. package/dist/application/Application.js.map +1 -0
  7. package/dist/config/Repository.d.ts +41 -0
  8. package/dist/config/Repository.d.ts.map +1 -0
  9. package/dist/config/Repository.js +140 -0
  10. package/dist/config/Repository.js.map +1 -0
  11. package/dist/container/Container.d.ts +39 -0
  12. package/dist/container/Container.d.ts.map +1 -0
  13. package/dist/container/Container.js +73 -0
  14. package/dist/container/Container.js.map +1 -0
  15. package/dist/contracts/Application.d.ts +15 -0
  16. package/dist/contracts/Application.d.ts.map +1 -0
  17. package/dist/contracts/Application.js +3 -0
  18. package/dist/contracts/Application.js.map +1 -0
  19. package/dist/contracts/Kernel.d.ts +24 -0
  20. package/dist/contracts/Kernel.d.ts.map +1 -0
  21. package/dist/contracts/Kernel.js +3 -0
  22. package/dist/contracts/Kernel.js.map +1 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +31 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/providers/ServiceProvider.d.ts +25 -0
  28. package/dist/providers/ServiceProvider.d.ts.map +1 -0
  29. package/dist/providers/ServiceProvider.js +26 -0
  30. package/dist/providers/ServiceProvider.js.map +1 -0
  31. package/dist/support/EnvLoader.d.ts +15 -0
  32. package/dist/support/EnvLoader.d.ts.map +1 -0
  33. package/dist/support/EnvLoader.js +58 -0
  34. package/dist/support/EnvLoader.js.map +1 -0
  35. package/dist/support/config.d.ts +18 -0
  36. package/dist/support/config.d.ts.map +1 -0
  37. package/dist/support/config.js +29 -0
  38. package/dist/support/config.js.map +1 -0
  39. package/dist/support/env.d.ts +9 -0
  40. package/dist/support/env.d.ts.map +1 -0
  41. package/dist/support/env.js +32 -0
  42. package/dist/support/env.js.map +1 -0
  43. package/package.json +53 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;;;;;GAOG;AACH,8BAAsB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC3D,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;gBAAN,GAAG,EAAE,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAEzC;;;;OAIG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServiceProvider = void 0;
4
+ /**
5
+ * Base class for service providers in ArikaJS.
6
+ *
7
+ * Service providers are the primary way to package and register features.
8
+ * They follow a two-phase lifecycle:
9
+ * - register(): Bind services to the container (no heavy side-effects)
10
+ * - boot(): Perform runtime logic after all providers are registered
11
+ */
12
+ class ServiceProvider {
13
+ constructor(app) {
14
+ this.app = app;
15
+ }
16
+ /**
17
+ * Boot the service provider.
18
+ * This method is called after all providers have been registered.
19
+ * Safe to resolve other services here.
20
+ */
21
+ boot() {
22
+ // Optional to override
23
+ }
24
+ }
25
+ exports.ServiceProvider = ServiceProvider;
26
+ //# sourceMappingURL=ServiceProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceProvider.js","sourceRoot":"","sources":["../../src/providers/ServiceProvider.ts"],"names":[],"mappings":";;;AAEA;;;;;;;GAOG;AACH,MAAsB,eAAe;IACnC,YAA+B,GAAM;QAAN,QAAG,GAAH,GAAG,CAAG;IAAI,CAAC;IAQ1C;;;;OAIG;IACH,IAAI;QACF,uBAAuB;IACzB,CAAC;CACF;AAjBD,0CAiBC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Environment variable loader for ArikaJS.
3
+ *
4
+ * Uses dotenv to load key=value pairs from a .env file
5
+ * and injects them into process.env.
6
+ */
7
+ export declare class EnvLoader {
8
+ /**
9
+ * Load the .env file from the given directory.
10
+ *
11
+ * @param directory The directory where the .env file is located
12
+ */
13
+ static load(directory: string): void;
14
+ }
15
+ //# sourceMappingURL=EnvLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvLoader.d.ts","sourceRoot":"","sources":["../../src/support/EnvLoader.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,qBAAa,SAAS;IAClB;;;;OAIG;WACW,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAM9C"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EnvLoader = void 0;
37
+ const dotenv = __importStar(require("dotenv"));
38
+ const path = __importStar(require("path"));
39
+ /**
40
+ * Environment variable loader for ArikaJS.
41
+ *
42
+ * Uses dotenv to load key=value pairs from a .env file
43
+ * and injects them into process.env.
44
+ */
45
+ class EnvLoader {
46
+ /**
47
+ * Load the .env file from the given directory.
48
+ *
49
+ * @param directory The directory where the .env file is located
50
+ */
51
+ static load(directory) {
52
+ const envPath = path.join(directory, '.env');
53
+ // Use dotenv to load environment variables
54
+ dotenv.config({ path: envPath });
55
+ }
56
+ }
57
+ exports.EnvLoader = EnvLoader;
58
+ //# sourceMappingURL=EnvLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvLoader.js","sourceRoot":"","sources":["../../src/support/EnvLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,2CAA6B;AAE7B;;;;;GAKG;AACH,MAAa,SAAS;IAClB;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAAC,SAAiB;QAChC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAE7C,2CAA2C;QAC3C,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;CACJ;AAZD,8BAYC"}
@@ -0,0 +1,18 @@
1
+ import { Repository } from '../config/Repository';
2
+ /**
3
+ * Set the active configuration repository.
4
+ *
5
+ * This is used by the config() helper to find the current configuration.
6
+ *
7
+ * @param repo The repository instance
8
+ */
9
+ export declare function setConfigRepository(repo: Repository): void;
10
+ /**
11
+ * Get a configuration value.
12
+ *
13
+ * @param key The configuration key (dot notation)
14
+ * @param defaultValue The default value if the key is not found
15
+ * @returns The configuration value or the default value
16
+ */
17
+ export declare function config<T = any>(key: string, defaultValue?: T): T | undefined;
18
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/support/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAM5E"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setConfigRepository = setConfigRepository;
4
+ exports.config = config;
5
+ let activeRepo = null;
6
+ /**
7
+ * Set the active configuration repository.
8
+ *
9
+ * This is used by the config() helper to find the current configuration.
10
+ *
11
+ * @param repo The repository instance
12
+ */
13
+ function setConfigRepository(repo) {
14
+ activeRepo = repo;
15
+ }
16
+ /**
17
+ * Get a configuration value.
18
+ *
19
+ * @param key The configuration key (dot notation)
20
+ * @param defaultValue The default value if the key is not found
21
+ * @returns The configuration value or the default value
22
+ */
23
+ function config(key, defaultValue) {
24
+ if (!activeRepo) {
25
+ return defaultValue;
26
+ }
27
+ return activeRepo.get(key, defaultValue);
28
+ }
29
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/support/config.ts"],"names":[],"mappings":";;AAWA,kDAEC;AASD,wBAMC;AA1BD,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC;;;;;;GAMG;AACH,SAAgB,mBAAmB,CAAC,IAAgB;IAChD,UAAU,GAAG,IAAI,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,MAAM,CAAU,GAAW,EAAE,YAAgB;IACzD,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,OAAO,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the value of an environment variable.
3
+ *
4
+ * @param key The environment variable key
5
+ * @param defaultValue The default value if the key is not set
6
+ * @returns The environment variable value or the default value
7
+ */
8
+ export declare function env<T = string>(key: string, defaultValue?: T): T;
9
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/support/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CA0BhE"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.env = env;
4
+ /**
5
+ * Get the value of an environment variable.
6
+ *
7
+ * @param key The environment variable key
8
+ * @param defaultValue The default value if the key is not set
9
+ * @returns The environment variable value or the default value
10
+ */
11
+ function env(key, defaultValue) {
12
+ const value = process.env[key];
13
+ if (value === undefined) {
14
+ return defaultValue;
15
+ }
16
+ // Handle common boolean strings
17
+ if (value.toLowerCase() === 'true') {
18
+ return true;
19
+ }
20
+ if (value.toLowerCase() === 'false') {
21
+ return false;
22
+ }
23
+ // Handle common null/empty strings
24
+ if (value.toLowerCase() === 'null') {
25
+ return null;
26
+ }
27
+ if (value.toLowerCase() === '(empty)') {
28
+ return '';
29
+ }
30
+ return value;
31
+ }
32
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/support/env.ts"],"names":[],"mappings":";;AAOA,kBA0BC;AAjCD;;;;;;GAMG;AACH,SAAgB,GAAG,CAAa,GAAW,EAAE,YAAgB;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,YAAiB,CAAC;IAC3B,CAAC;IAED,gCAAgC;IAChC,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,IAAW,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QACpC,OAAO,KAAY,CAAC;IACtB,CAAC;IAED,mCAAmC;IACnC,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QACnC,OAAO,IAAW,CAAC;IACrB,CAAC;IAED,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,OAAO,KAAY,CAAC;AACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@arikajs/foundation",
3
+ "version": "0.0.1",
4
+ "description": "Core application and service container layer for the ArikaJS framework.",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -p tsconfig.json",
10
+ "build:tests": "tsc -p tsconfig.test.json",
11
+ "clean": "rm -rf dist",
12
+ "prepare": "echo skip",
13
+ "lint": "eslint src --ext .ts",
14
+ "test": "npm run build && npm run build:tests && node scripts/fix-test-imports.js && node --test 'dist/tests/**/*.test.js'",
15
+ "test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'",
16
+ "example": "npm run build && node dist/examples/basic.js"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "keywords": [
22
+ "arika",
23
+ "arika-js",
24
+ "framework",
25
+ "foundation",
26
+ "dependency-injection",
27
+ "container",
28
+ "application-kernel"
29
+ ],
30
+ "engines": {
31
+ "node": ">=20.0.0"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/arikajs/foundation.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/arikajs/foundation/issues"
39
+ },
40
+ "homepage": "https://github.com/arikajs/foundation#readme",
41
+ "dependencies": {
42
+ "dotenv": "^16.4.7"
43
+ },
44
+ "devDependencies": {
45
+ "@arikajs/logging": "^0.0.1",
46
+ "@arikajs/http": "^0.0.1",
47
+ "@arikajs/database": "^0.0.1",
48
+ "@arikajs/cache": "^0.0.1",
49
+ "@types/node": "^20.19.31",
50
+ "typescript": "^5.7.0"
51
+ },
52
+ "author": "Prakash Tank"
53
+ }