@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.
- package/LICENSE +21 -0
- package/README.md +601 -0
- package/dist/application/Application.d.ts +73 -0
- package/dist/application/Application.d.ts.map +1 -0
- package/dist/application/Application.js +196 -0
- package/dist/application/Application.js.map +1 -0
- package/dist/config/Repository.d.ts +41 -0
- package/dist/config/Repository.d.ts.map +1 -0
- package/dist/config/Repository.js +140 -0
- package/dist/config/Repository.js.map +1 -0
- package/dist/container/Container.d.ts +39 -0
- package/dist/container/Container.d.ts.map +1 -0
- package/dist/container/Container.js +73 -0
- package/dist/container/Container.js.map +1 -0
- package/dist/contracts/Application.d.ts +15 -0
- package/dist/contracts/Application.d.ts.map +1 -0
- package/dist/contracts/Application.js +3 -0
- package/dist/contracts/Application.js.map +1 -0
- package/dist/contracts/Kernel.d.ts +24 -0
- package/dist/contracts/Kernel.d.ts.map +1 -0
- package/dist/contracts/Kernel.js +3 -0
- package/dist/contracts/Kernel.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/ServiceProvider.d.ts +25 -0
- package/dist/providers/ServiceProvider.d.ts.map +1 -0
- package/dist/providers/ServiceProvider.js +26 -0
- package/dist/providers/ServiceProvider.js.map +1 -0
- package/dist/support/EnvLoader.d.ts +15 -0
- package/dist/support/EnvLoader.d.ts.map +1 -0
- package/dist/support/EnvLoader.js +58 -0
- package/dist/support/EnvLoader.js.map +1 -0
- package/dist/support/config.d.ts +18 -0
- package/dist/support/config.d.ts.map +1 -0
- package/dist/support/config.js +29 -0
- package/dist/support/config.js.map +1 -0
- package/dist/support/env.d.ts +9 -0
- package/dist/support/env.d.ts.map +1 -0
- package/dist/support/env.js +32 -0
- package/dist/support/env.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,196 @@
|
|
|
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.Application = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const Container_1 = require("../container/Container");
|
|
39
|
+
const ServiceProvider_1 = require("../providers/ServiceProvider");
|
|
40
|
+
const Repository_1 = require("../config/Repository");
|
|
41
|
+
const EnvLoader_1 = require("../support/EnvLoader");
|
|
42
|
+
const config_1 = require("../support/config");
|
|
43
|
+
/**
|
|
44
|
+
* Application is the core runtime of ArikaJS.
|
|
45
|
+
*
|
|
46
|
+
* It manages:
|
|
47
|
+
* - Service container
|
|
48
|
+
* - Service providers
|
|
49
|
+
* - Configuration
|
|
50
|
+
* - Application lifecycle (register → boot → run)
|
|
51
|
+
*/
|
|
52
|
+
class Application {
|
|
53
|
+
constructor(basePath) {
|
|
54
|
+
this.providers = [];
|
|
55
|
+
this.booted = false;
|
|
56
|
+
this.basePath = path.resolve(basePath);
|
|
57
|
+
this.container = new Container_1.Container();
|
|
58
|
+
this.configRepository = new Repository_1.Repository();
|
|
59
|
+
// Register the config repository in the global support helper
|
|
60
|
+
(0, config_1.setConfigRepository)(this.configRepository);
|
|
61
|
+
// Register the application, container, and config for injection
|
|
62
|
+
this.container.instance(Application, this);
|
|
63
|
+
this.container.instance(Container_1.Container, this.container);
|
|
64
|
+
this.container.instance(Repository_1.Repository, this.configRepository);
|
|
65
|
+
// Load environment variables from .env if it exists
|
|
66
|
+
EnvLoader_1.EnvLoader.load(this.basePath);
|
|
67
|
+
// Load configuration from config directory
|
|
68
|
+
const configPath = path.join(this.basePath, 'config');
|
|
69
|
+
this.configRepository.loadConfigDirectory(configPath);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get the base path of the application.
|
|
73
|
+
*/
|
|
74
|
+
getBasePath() {
|
|
75
|
+
return this.basePath;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Access the underlying container.
|
|
79
|
+
*/
|
|
80
|
+
getContainer() {
|
|
81
|
+
return this.container;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Access the configuration repository.
|
|
85
|
+
*/
|
|
86
|
+
config() {
|
|
87
|
+
return this.configRepository;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Register a service provider.
|
|
91
|
+
* Can accept a class (will be instantiated) or an instance.
|
|
92
|
+
*/
|
|
93
|
+
register(provider) {
|
|
94
|
+
if (this.booted) {
|
|
95
|
+
throw new Error('Cannot register providers after the application has been booted.');
|
|
96
|
+
}
|
|
97
|
+
const providerInstance = provider instanceof ServiceProvider_1.ServiceProvider
|
|
98
|
+
? provider
|
|
99
|
+
: new provider(this);
|
|
100
|
+
this.providers.push(providerInstance);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Boot all registered service providers.
|
|
104
|
+
* First runs all register() methods, then all boot() methods.
|
|
105
|
+
*/
|
|
106
|
+
async boot() {
|
|
107
|
+
if (this.booted) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Phase 1: Register all providers
|
|
111
|
+
for (const provider of this.providers) {
|
|
112
|
+
await provider.register();
|
|
113
|
+
}
|
|
114
|
+
// Phase 2: Boot all providers
|
|
115
|
+
for (const provider of this.providers) {
|
|
116
|
+
await provider.boot();
|
|
117
|
+
}
|
|
118
|
+
// Phase 3: Apply runtime configuration
|
|
119
|
+
// Validate APP_KEY
|
|
120
|
+
if (!this.configRepository.get('app.key')) {
|
|
121
|
+
throw new Error('Application key (APP_KEY) is not set. Please run "arika key:generate" to generate one.');
|
|
122
|
+
}
|
|
123
|
+
// Apply timezone from config to the Node.js process
|
|
124
|
+
const timezone = this.configRepository.get('app.timezone');
|
|
125
|
+
if (timezone) {
|
|
126
|
+
process.env.TZ = timezone;
|
|
127
|
+
}
|
|
128
|
+
// Mark config as booted (read-only)
|
|
129
|
+
this.configRepository.markAsBooted();
|
|
130
|
+
this.booted = true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Run the application.
|
|
134
|
+
* This is intentionally minimal in foundation - higher layers
|
|
135
|
+
* (HTTP/CLI) will override or extend this behavior.
|
|
136
|
+
*/
|
|
137
|
+
async run() {
|
|
138
|
+
if (!this.booted) {
|
|
139
|
+
await this.boot();
|
|
140
|
+
}
|
|
141
|
+
// In foundation, run() is a no-op
|
|
142
|
+
// HTTP/CLI kernels will implement actual run logic
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Bind a transient service.
|
|
146
|
+
*/
|
|
147
|
+
bind(token, factory) {
|
|
148
|
+
this.container.bind(token, factory);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Bind a singleton service.
|
|
152
|
+
*/
|
|
153
|
+
singleton(token, factory) {
|
|
154
|
+
this.container.singleton(token, factory);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Register an existing instance.
|
|
158
|
+
*/
|
|
159
|
+
instance(token, value) {
|
|
160
|
+
this.container.instance(token, value);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Resolve a service from the container.
|
|
164
|
+
*/
|
|
165
|
+
make(token) {
|
|
166
|
+
// If the token is already in the container, use it
|
|
167
|
+
if (this.container.has(token)) {
|
|
168
|
+
return this.container.make(token);
|
|
169
|
+
}
|
|
170
|
+
// Otherwise, if it's a config token (e.g. 'config.app.name'),
|
|
171
|
+
// try to resolve it from the configuration repository
|
|
172
|
+
if (typeof token === 'string' && token.startsWith('config.')) {
|
|
173
|
+
const configKey = token.substring(7);
|
|
174
|
+
const value = this.configRepository.get(configKey);
|
|
175
|
+
if (value !== undefined) {
|
|
176
|
+
return value;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Fall back to standard container resolution (which might throw)
|
|
180
|
+
return this.container.make(token);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Alias for make() - resolves a service from the container.
|
|
184
|
+
*/
|
|
185
|
+
resolve(token) {
|
|
186
|
+
return this.container.resolve(token);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Check if the application has been booted.
|
|
190
|
+
*/
|
|
191
|
+
isBooted() {
|
|
192
|
+
return this.booted;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.Application = Application;
|
|
196
|
+
//# sourceMappingURL=Application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"","sources":["../../src/application/Application.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,sDAAmE;AACnE,kEAA+D;AAC/D,qDAAkD;AAClD,oDAAiD;AACjD,8CAAwD;AAExD;;;;;;;;GAQG;AACH,MAAa,WAAW;IAOtB,YAAY,QAAgB;QAHpB,cAAS,GAAsB,EAAE,CAAC;QAClC,WAAM,GAAG,KAAK,CAAC;QAGrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAU,EAAE,CAAC;QAEzC,8DAA8D;QAC9D,IAAA,4BAAmB,EAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE3C,gEAAgE;QAChE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAS,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,uBAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAE3D,oDAAoD;QACpD,qBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE9B,2CAA2C;QAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACtD,IAAI,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,C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U,CAAC;YACpB,CAAC;QACH,CAAC;QAED,iEAAiE;QACjE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,OAAO,CAAI,KAAe;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAtLD,kCAsLC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration repository for ArikaJS.
|
|
3
|
+
*
|
|
4
|
+
* Loads configuration files from the /config directory and provides
|
|
5
|
+
* read-only access to configuration values.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Repository {
|
|
8
|
+
private config;
|
|
9
|
+
private booted;
|
|
10
|
+
/**
|
|
11
|
+
* Load configuration files from the config directory.
|
|
12
|
+
*/
|
|
13
|
+
loadConfigDirectory(configPath: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Get a configuration value using dot notation.
|
|
16
|
+
* Example: get('app.name') returns config.app.name
|
|
17
|
+
*/
|
|
18
|
+
get<T = any>(key: string, defaultValue?: T): T | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Check if a configuration key exists.
|
|
21
|
+
*/
|
|
22
|
+
has(key: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Set a configuration value using dot notation.
|
|
25
|
+
* Example: set('app.key', 'value')
|
|
26
|
+
*/
|
|
27
|
+
set(key: string, value: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Get all configuration.
|
|
30
|
+
*/
|
|
31
|
+
all(): Record<string, any>;
|
|
32
|
+
/**
|
|
33
|
+
* Mark the repository as booted (read-only).
|
|
34
|
+
*/
|
|
35
|
+
markAsBooted(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the repository has been booted.
|
|
38
|
+
*/
|
|
39
|
+
isBooted(): boolean;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.d.ts","sourceRoot":"","sources":["../../src/config/Repository.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAAS;IAEvB;;OAEG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAkC7C;;;OAGG;IACH,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAc1D;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAmBlC;;OAEG;IACH,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI1B;;OAEG;IACH,YAAY,IAAI,IAAI;IAIpB;;OAEG;IACH,QAAQ,IAAI,OAAO;CAGpB"}
|
|
@@ -0,0 +1,140 @@
|
|
|
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.Repository = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Configuration repository for ArikaJS.
|
|
41
|
+
*
|
|
42
|
+
* Loads configuration files from the /config directory and provides
|
|
43
|
+
* read-only access to configuration values.
|
|
44
|
+
*/
|
|
45
|
+
class Repository {
|
|
46
|
+
constructor() {
|
|
47
|
+
this.config = {};
|
|
48
|
+
this.booted = false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Load configuration files from the config directory.
|
|
52
|
+
*/
|
|
53
|
+
loadConfigDirectory(configPath) {
|
|
54
|
+
if (this.booted) {
|
|
55
|
+
throw new Error('Configuration cannot be modified after boot.');
|
|
56
|
+
}
|
|
57
|
+
if (!fs.existsSync(configPath)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const files = fs.readdirSync(configPath);
|
|
61
|
+
const configFiles = files.filter((file) => file.endsWith('.js') || file.endsWith('.ts'));
|
|
62
|
+
for (const file of configFiles) {
|
|
63
|
+
const filePath = path.join(configPath, file);
|
|
64
|
+
const configName = path.basename(file, path.extname(file));
|
|
65
|
+
try {
|
|
66
|
+
// Load config file - expects compiled JS in production
|
|
67
|
+
// For TS files, they should be pre-compiled to JS
|
|
68
|
+
const configModule = require(filePath);
|
|
69
|
+
const configValue = configModule.default || configModule;
|
|
70
|
+
if (typeof configValue === 'object' && configValue !== null) {
|
|
71
|
+
this.config[configName] = configValue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// Silently skip files that can't be loaded
|
|
76
|
+
// In production, you might want to log this
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get a configuration value using dot notation.
|
|
82
|
+
* Example: get('app.name') returns config.app.name
|
|
83
|
+
*/
|
|
84
|
+
get(key, defaultValue) {
|
|
85
|
+
const keys = key.split('.');
|
|
86
|
+
let value = this.config;
|
|
87
|
+
for (const k of keys) {
|
|
88
|
+
if (value === undefined || value === null) {
|
|
89
|
+
return defaultValue;
|
|
90
|
+
}
|
|
91
|
+
value = value[k];
|
|
92
|
+
}
|
|
93
|
+
return value !== undefined ? value : defaultValue;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if a configuration key exists.
|
|
97
|
+
*/
|
|
98
|
+
has(key) {
|
|
99
|
+
return this.get(key) !== undefined;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Set a configuration value using dot notation.
|
|
103
|
+
* Example: set('app.key', 'value')
|
|
104
|
+
*/
|
|
105
|
+
set(key, value) {
|
|
106
|
+
if (this.booted) {
|
|
107
|
+
throw new Error('Configuration cannot be modified after boot.');
|
|
108
|
+
}
|
|
109
|
+
const keys = key.split('.');
|
|
110
|
+
let current = this.config;
|
|
111
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
112
|
+
const k = keys[i];
|
|
113
|
+
if (!(k in current) || typeof current[k] !== 'object' || current[k] === null) {
|
|
114
|
+
current[k] = {};
|
|
115
|
+
}
|
|
116
|
+
current = current[k];
|
|
117
|
+
}
|
|
118
|
+
current[keys[keys.length - 1]] = value;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get all configuration.
|
|
122
|
+
*/
|
|
123
|
+
all() {
|
|
124
|
+
return { ...this.config };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Mark the repository as booted (read-only).
|
|
128
|
+
*/
|
|
129
|
+
markAsBooted() {
|
|
130
|
+
this.booted = true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Check if the repository has been booted.
|
|
134
|
+
*/
|
|
135
|
+
isBooted() {
|
|
136
|
+
return this.booted;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Repository = Repository;
|
|
140
|
+
//# sourceMappingURL=Repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Repository.js","sourceRoot":"","sources":["../../src/config/Repository.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAK7B;;;;;GAKG;AACH,MAAa,UAAU;IAAvB;QACU,WAAM,GAAwB,EAAE,CAAC;QACjC,WAAM,GAAG,KAAK,CAAC;IA2GzB,CAAC;IAzGC;;OAEG;IACH,mBAAmB,CAAC,UAAkB;QACpC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAA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AC;IACrB,CAAC;CACF;AA7GD,gCA6GC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type Token<T = any> = string | symbol | (new (...args: any[]) => T);
|
|
2
|
+
export type Factory<T = any> = (container: Container) => T;
|
|
3
|
+
/**
|
|
4
|
+
* Lightweight dependency injection container for ArikaJS.
|
|
5
|
+
*
|
|
6
|
+
* Responsible for:
|
|
7
|
+
* - Registering bindings and singletons
|
|
8
|
+
* - Resolving services on demand
|
|
9
|
+
* - Holding pre-built instances
|
|
10
|
+
*/
|
|
11
|
+
export declare class Container {
|
|
12
|
+
private bindings;
|
|
13
|
+
/**
|
|
14
|
+
* Bind a token to a factory. Produces a new instance on every resolution.
|
|
15
|
+
*/
|
|
16
|
+
bind<T>(token: Token<T>, factory: Factory<T>): void;
|
|
17
|
+
/**
|
|
18
|
+
* Bind a token as a singleton. The factory runs once and the
|
|
19
|
+
* same instance is returned for all subsequent resolutions.
|
|
20
|
+
*/
|
|
21
|
+
singleton<T>(token: Token<T>, factory: Factory<T>): void;
|
|
22
|
+
/**
|
|
23
|
+
* Directly register an existing instance for a token.
|
|
24
|
+
*/
|
|
25
|
+
instance<T>(token: Token<T>, value: T): void;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a token from the container.
|
|
28
|
+
*/
|
|
29
|
+
make<T>(token: Token<T>): T;
|
|
30
|
+
/**
|
|
31
|
+
* Alias for make() - resolves a token from the container.
|
|
32
|
+
*/
|
|
33
|
+
resolve<T>(token: Token<T>): T;
|
|
34
|
+
/**
|
|
35
|
+
* Check whether a token has been registered.
|
|
36
|
+
*/
|
|
37
|
+
has(token: Token): boolean;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=Container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../src/container/Container.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,GAAG,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAQ3D;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAA6B;IAE7C;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAInD;;;OAGG;IACH,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI;IAIxD;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAQ5C;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAuB3B;;OAEG;IACH,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAI9B;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;CAG3B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Container = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight dependency injection container for ArikaJS.
|
|
6
|
+
*
|
|
7
|
+
* Responsible for:
|
|
8
|
+
* - Registering bindings and singletons
|
|
9
|
+
* - Resolving services on demand
|
|
10
|
+
* - Holding pre-built instances
|
|
11
|
+
*/
|
|
12
|
+
class Container {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.bindings = new Map();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Bind a token to a factory. Produces a new instance on every resolution.
|
|
18
|
+
*/
|
|
19
|
+
bind(token, factory) {
|
|
20
|
+
this.bindings.set(token, { factory, singleton: false });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Bind a token as a singleton. The factory runs once and the
|
|
24
|
+
* same instance is returned for all subsequent resolutions.
|
|
25
|
+
*/
|
|
26
|
+
singleton(token, factory) {
|
|
27
|
+
this.bindings.set(token, { factory, singleton: true });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Directly register an existing instance for a token.
|
|
31
|
+
*/
|
|
32
|
+
instance(token, value) {
|
|
33
|
+
this.bindings.set(token, {
|
|
34
|
+
factory: () => value,
|
|
35
|
+
singleton: true,
|
|
36
|
+
instance: value,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a token from the container.
|
|
41
|
+
*/
|
|
42
|
+
make(token) {
|
|
43
|
+
let binding = this.bindings.get(token);
|
|
44
|
+
if (!binding) {
|
|
45
|
+
// If it's a class/constructor, try to instantiate it
|
|
46
|
+
if (typeof token === 'function') {
|
|
47
|
+
return new token(this);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Container: no binding found for token "${String(token)}"`);
|
|
50
|
+
}
|
|
51
|
+
if (binding.singleton) {
|
|
52
|
+
if (binding.instance === undefined) {
|
|
53
|
+
binding.instance = binding.factory(this);
|
|
54
|
+
}
|
|
55
|
+
return binding.instance;
|
|
56
|
+
}
|
|
57
|
+
return binding.factory(this);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Alias for make() - resolves a token from the container.
|
|
61
|
+
*/
|
|
62
|
+
resolve(token) {
|
|
63
|
+
return this.make(token);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Check whether a token has been registered.
|
|
67
|
+
*/
|
|
68
|
+
has(token) {
|
|
69
|
+
return this.bindings.has(token);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.Container = Container;
|
|
73
|
+
//# sourceMappingURL=Container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../src/container/Container.ts"],"names":[],"mappings":";;;AAUA;;;;;;;GAOG;AACH,MAAa,SAAS;IAAtB;QACU,aAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAmE/C,CAAC;IAjEC;;OAEG;IACH,IAAI,CAAI,KAAe,EAAE,OAAmB;QAC1C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,SAAS,CAAI,KAAe,EAAE,OAAmB;QAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,QAAQ,CAAI,KAAe,EAAE,KAAQ;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE;YACvB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK;YACpB,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,KAAK;SAChB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,CAAI,KAAe;QACrB,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,qDAAqD;YACrD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;gBAChC,OAAO,IAAK,KAAa,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,0CAA0C,MAAM,CAAC,KAAK,CAAC,GAAG,CAC3D,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;YACtB,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACnC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;YACD,OAAO,OAAO,CAAC,QAAa,CAAC;QAC/B,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,OAAO,CAAI,KAAe;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,KAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;CACF;AApED,8BAoEC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Application {
|
|
2
|
+
getBasePath(): string;
|
|
3
|
+
getContainer(): any;
|
|
4
|
+
config(): any;
|
|
5
|
+
register(provider: any): void;
|
|
6
|
+
boot(): Promise<void>;
|
|
7
|
+
run(): Promise<void>;
|
|
8
|
+
bind(token: any, factory: any): void;
|
|
9
|
+
singleton(token: any, factory: any): void;
|
|
10
|
+
instance(token: any, value: any): void;
|
|
11
|
+
make<T = any>(token: any): T;
|
|
12
|
+
resolve<T = any>(token: any): T;
|
|
13
|
+
isBooted(): boolean;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Application.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../../src/contracts/Application.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,WAAW;IACxB,WAAW,IAAI,MAAM,CAAC;IACtB,YAAY,IAAI,GAAG,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC;IACd,QAAQ,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI,CAAC;IAC9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IACrC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IACvC,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC;IAChC,QAAQ,IAAI,OAAO,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"","sources":["../../src/contracts/Application.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel contract for ArikaJS.
|
|
3
|
+
*
|
|
4
|
+
* Kernels are responsible for handling requests in different contexts:
|
|
5
|
+
* - HTTP kernel handles web requests
|
|
6
|
+
* - CLI kernel handles command-line commands
|
|
7
|
+
* - Queue kernel handles background jobs
|
|
8
|
+
*
|
|
9
|
+
* Foundation only defines the contract - implementations live in
|
|
10
|
+
* higher-level packages like @arikajs/http, @arikajs/cli, etc.
|
|
11
|
+
*/
|
|
12
|
+
export interface Kernel {
|
|
13
|
+
/**
|
|
14
|
+
* Bootstrap the kernel.
|
|
15
|
+
* Called once when the kernel is initialized.
|
|
16
|
+
*/
|
|
17
|
+
bootstrap(): Promise<void> | void;
|
|
18
|
+
/**
|
|
19
|
+
* Handle a request/command/job.
|
|
20
|
+
* The exact signature depends on the kernel type.
|
|
21
|
+
*/
|
|
22
|
+
handle(...args: any[]): Promise<any> | any;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.d.ts","sourceRoot":"","sources":["../../src/contracts/Kernel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;CAC5C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kernel.js","sourceRoot":"","sources":["../../src/contracts/Kernel.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Application } from './application/Application';
|
|
2
|
+
export * from './container/Container';
|
|
3
|
+
export * from './providers/ServiceProvider';
|
|
4
|
+
export * from './config/Repository';
|
|
5
|
+
export { Application as ApplicationContract } from './contracts/Application';
|
|
6
|
+
export { Kernel as KernelContract } from './contracts/Kernel';
|
|
7
|
+
export * from './support/env';
|
|
8
|
+
export * from './support/config';
|
|
9
|
+
export * from './support/EnvLoader';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,cAAc,uBAAuB,CAAC;AAGtC,cAAc,6BAA6B,CAAC;AAG5C,cAAc,qBAAqB,CAAC;AAGpC,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG9D,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Application = void 0;
|
|
18
|
+
// Application
|
|
19
|
+
var Application_1 = require("./application/Application");
|
|
20
|
+
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return Application_1.Application; } });
|
|
21
|
+
// Container
|
|
22
|
+
__exportStar(require("./container/Container"), exports);
|
|
23
|
+
// Service Providers
|
|
24
|
+
__exportStar(require("./providers/ServiceProvider"), exports);
|
|
25
|
+
// Configuration
|
|
26
|
+
__exportStar(require("./config/Repository"), exports);
|
|
27
|
+
// Support
|
|
28
|
+
__exportStar(require("./support/env"), exports);
|
|
29
|
+
__exportStar(require("./support/config"), exports);
|
|
30
|
+
__exportStar(require("./support/EnvLoader"), exports);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,cAAc;AACd,yDAAwD;AAA/C,0GAAA,WAAW,OAAA;AAEpB,YAAY;AACZ,wDAAsC;AAEtC,oBAAoB;AACpB,8DAA4C;AAE5C,gBAAgB;AAChB,sDAAoC;AAMpC,UAAU;AACV,gDAA8B;AAC9B,mDAAiC;AACjC,sDAAoC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Application } from '../contracts/Application';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for service providers in ArikaJS.
|
|
4
|
+
*
|
|
5
|
+
* Service providers are the primary way to package and register features.
|
|
6
|
+
* They follow a two-phase lifecycle:
|
|
7
|
+
* - register(): Bind services to the container (no heavy side-effects)
|
|
8
|
+
* - boot(): Perform runtime logic after all providers are registered
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class ServiceProvider<T extends Application = Application> {
|
|
11
|
+
protected readonly app: T;
|
|
12
|
+
constructor(app: T);
|
|
13
|
+
/**
|
|
14
|
+
* Register services to the container.
|
|
15
|
+
* This method is called for all providers before any boot() methods run.
|
|
16
|
+
*/
|
|
17
|
+
abstract register(): void | Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Boot the service provider.
|
|
20
|
+
* This method is called after all providers have been registered.
|
|
21
|
+
* Safe to resolve other services here.
|
|
22
|
+
*/
|
|
23
|
+
boot(): void | Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ServiceProvider.d.ts.map
|