moost 0.6.25 → 0.6.27
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 +21 -44
- package/dist/index.cjs +11 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +11 -13
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,66 +1,43 @@
|
|
|
1
1
|
# moost
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<img src="
|
|
4
|
+
<img src="https://raw.githubusercontent.com/moostjs/moostjs/main/moost-logo.png" width="450px"><br>
|
|
5
5
|
<a href="https://github.com/moostjs/moostjs/blob/main/LICENSE">
|
|
6
6
|
<img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" />
|
|
7
7
|
</a>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
`moost` is the core of [Moostjs](https://github.com/moostjs/moostjs) — a metadata-driven Event Processing Framework inspired by [NestJS](https://nestjs.com/) and powered by [Wooks](https://wooks.moost.org). This package provides the `Moost` application class, the decorator system (`@Controller`, `@Injectable`, `@Intercept`, `@Pipe`, ...), dependency injection, interceptors, and pipes shared by every event adapter (`@moostjs/event-http`, `@moostjs/event-cli`, `@moostjs/event-ws`, `@moostjs/event-wf`).
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Quick Start
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
```ts
|
|
15
|
+
import { Moost, Controller, Param } from 'moost'
|
|
16
|
+
import { MoostHttp, Get } from '@moostjs/event-http'
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
@Controller()
|
|
19
|
+
class AppController {
|
|
20
|
+
@Get('hello/:name')
|
|
21
|
+
greet(@Param('name') name: string) {
|
|
22
|
+
return `Hello, ${name}!`
|
|
23
|
+
}
|
|
24
|
+
}
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
5. Does not use Express or Fastify, but these can be employed with an adapter.
|
|
23
|
-
6. Currently, Moost does not support additional techniques like ORMs, Queues, etc.
|
|
26
|
+
const app = new Moost()
|
|
27
|
+
void app.adapter(new MoostHttp()).listen(3000)
|
|
28
|
+
void app.registerControllers(AppController).init()
|
|
29
|
+
```
|
|
24
30
|
|
|
25
31
|
## [Official Documentation](https://moost.org/)
|
|
26
32
|
|
|
27
|
-
## AI Agent
|
|
33
|
+
## AI Agent Skill
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
A unified AI agent skill with framework guidance across all Moost packages is available for AI coding assistants (Claude Code, Cursor, Windsurf, Codex, OpenCode):
|
|
30
36
|
|
|
31
37
|
```bash
|
|
32
|
-
|
|
33
|
-
npx moost-skill
|
|
34
|
-
|
|
35
|
-
# Global (available across all your projects)
|
|
36
|
-
npx moost-skill --global
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
To auto-install on `npm install`, add to your `package.json`:
|
|
40
|
-
```json
|
|
41
|
-
{
|
|
42
|
-
"scripts": {
|
|
43
|
-
"postinstall": "moost-skill --postinstall"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
38
|
+
npx skills add moostjs/moostjs
|
|
46
39
|
```
|
|
47
40
|
|
|
48
41
|
## Contributing
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
Here are some basic steps to get you started:
|
|
53
|
-
|
|
54
|
-
1. **Fork the Repo:** Navigate to [moostjs](https://github.com/moostjs/moostjs) and fork the repository to your own GitHub account.
|
|
55
|
-
|
|
56
|
-
2. **Clone the Repo:** Clone the forked repository to your local machine.
|
|
57
|
-
|
|
58
|
-
3. **Create a Branch:** Make a new branch for your feature or bug fix.
|
|
59
|
-
|
|
60
|
-
4. **Make your Changes:** Implement your feature or fix the bug and commit the changes to your branch.
|
|
61
|
-
|
|
62
|
-
5. **Make a Pull Request:** Navigate back to your forked repo and press the "New pull request" button.
|
|
63
|
-
|
|
64
|
-
Don't hesitate to ask for help if you need it. We believe in fostering a friendly and respectful environment for all contributors.
|
|
65
|
-
|
|
66
|
-
Thank you for your interest in Moostjs. We look forward to building something amazing together!
|
|
43
|
+
See the [repository README](https://github.com/moostjs/moostjs#contributing) for motivation and contribution guidelines.
|
package/dist/index.cjs
CHANGED
|
@@ -175,10 +175,8 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
175
175
|
}
|
|
176
176
|
let logger;
|
|
177
177
|
try {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
logger = typeof withTopic.topic === "function" ? withTopic.topic(INFACT_BANNER) : ctxLogger;
|
|
181
|
-
} catch (error) {
|
|
178
|
+
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : (0, _wooksjs_event_core.useLogger)(INFACT_BANNER);
|
|
179
|
+
} catch {
|
|
182
180
|
logger = getDefaultLogger(INFACT_BANNER);
|
|
183
181
|
}
|
|
184
182
|
const instance = `[4m${targetClass.name}[24m`;
|
|
@@ -325,8 +323,7 @@ function nextScopeId() {
|
|
|
325
323
|
return () => {
|
|
326
324
|
const ctx = (0, _wooksjs_event_core.current)();
|
|
327
325
|
const scopeId = useScopeId(ctx);
|
|
328
|
-
const
|
|
329
|
-
const logger = typeof ctxLogger.topic === "function" ? ctxLogger.topic(options.loggerTitle) : ctxLogger;
|
|
326
|
+
const logger = (0, _wooksjs_event_core.useLogger)(options.loggerTitle, ctx);
|
|
330
327
|
const unscope = registerEventScope(scopeId);
|
|
331
328
|
let response;
|
|
332
329
|
let hookOptions;
|
|
@@ -426,9 +423,11 @@ function nextScopeId() {
|
|
|
426
423
|
}
|
|
427
424
|
function cleanup() {
|
|
428
425
|
if (interceptorHandler?.countAfter || interceptorHandler?.countOnError) {
|
|
426
|
+
const raisedResponse = response;
|
|
429
427
|
const afterResult = ci ? ci.with("Interceptors:after", () => interceptorHandler?.fireAfter(response)) : interceptorHandler?.fireAfter(response);
|
|
430
428
|
if (isThenable(afterResult)) return afterResult.then((r) => {
|
|
431
429
|
response = r;
|
|
430
|
+
if (raise && response !== raisedResponse) raise = false;
|
|
432
431
|
return finalize();
|
|
433
432
|
}, (error) => {
|
|
434
433
|
if (options.logErrors) logger.error(String(error));
|
|
@@ -436,6 +435,7 @@ function nextScopeId() {
|
|
|
436
435
|
throw error;
|
|
437
436
|
});
|
|
438
437
|
response = afterResult;
|
|
438
|
+
if (raise && response !== raisedResponse) raise = false;
|
|
439
439
|
}
|
|
440
440
|
return finalize();
|
|
441
441
|
}
|
|
@@ -854,20 +854,17 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
|
854
854
|
* @param topic
|
|
855
855
|
* @returns Resolver to '@wooksjs/event-core' (Logger)
|
|
856
856
|
*/ function InjectEventLogger(topic) {
|
|
857
|
-
return Resolve(() =>
|
|
858
|
-
const l = (0, _wooksjs_event_core.useLogger)();
|
|
859
|
-
return topic && typeof l.topic === "function" ? l.topic(topic) : l;
|
|
860
|
-
});
|
|
857
|
+
return Resolve(() => topic ? (0, _wooksjs_event_core.useLogger)(topic) : (0, _wooksjs_event_core.useLogger)());
|
|
861
858
|
}
|
|
862
859
|
/**
|
|
863
860
|
* Resolves app-level logger
|
|
864
|
-
* @param topic - logger topic (
|
|
861
|
+
* @param topic - logger topic (falls back to @LoggerTopic, then to class @Id)
|
|
865
862
|
* @returns
|
|
866
863
|
*/ function InjectMoostLogger(topic) {
|
|
867
864
|
return Resolve(async (metas) => {
|
|
868
865
|
const moostApp = await resolveMoost();
|
|
869
866
|
const meta = metas.classMeta;
|
|
870
|
-
return moostApp.getLogger(meta?.loggerTopic ||
|
|
867
|
+
return moostApp.getLogger(topic || meta?.loggerTopic || meta?.id);
|
|
871
868
|
});
|
|
872
869
|
}
|
|
873
870
|
/**
|
|
@@ -945,7 +942,8 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
|
945
942
|
* (For optional values use with @Optional())
|
|
946
943
|
* @param type - string or class constructor
|
|
947
944
|
*/ function Inject(type) {
|
|
948
|
-
|
|
945
|
+
const key = typeof type === "string" ? type : Symbol.for(String(type));
|
|
946
|
+
return getMoostMate().decorate("inject", key);
|
|
949
947
|
}
|
|
950
948
|
/**
|
|
951
949
|
* Injects instance from scope
|
package/dist/index.d.ts
CHANGED
|
@@ -710,7 +710,7 @@ declare function Response(): ParameterDecorator;
|
|
|
710
710
|
declare function InjectEventLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
711
711
|
/**
|
|
712
712
|
* Resolves app-level logger
|
|
713
|
-
* @param topic - logger topic (
|
|
713
|
+
* @param topic - logger topic (falls back to @LoggerTopic, then to class @Id)
|
|
714
714
|
* @returns
|
|
715
715
|
*/
|
|
716
716
|
declare function InjectMoostLogger(topic?: string): ParameterDecorator & PropertyDecorator;
|
|
@@ -860,6 +860,7 @@ interface TMoostEventHandlerHookOptions<T> {
|
|
|
860
860
|
}
|
|
861
861
|
/** Configuration for `defineMoostEventHandler`, describing how to resolve and invoke a handler. */
|
|
862
862
|
interface TMoostEventHandlerOptions<T> {
|
|
863
|
+
/** @deprecated unused since wooks v0.7 — the event kind comes from the wooks adapter */
|
|
863
864
|
contextType?: string | string[];
|
|
864
865
|
loggerTitle: string;
|
|
865
866
|
getIterceptorHandler: () => InterceptorHandler | undefined;
|
package/dist/index.mjs
CHANGED
|
@@ -174,10 +174,8 @@ const scopeVarsMap = /* @__PURE__ */ new Map();
|
|
|
174
174
|
}
|
|
175
175
|
let logger;
|
|
176
176
|
try {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
logger = typeof withTopic.topic === "function" ? withTopic.topic(INFACT_BANNER) : ctxLogger;
|
|
180
|
-
} catch (error) {
|
|
177
|
+
logger = event === "error" ? getDefaultLogger(INFACT_BANNER) : useLogger$1(INFACT_BANNER);
|
|
178
|
+
} catch {
|
|
181
179
|
logger = getDefaultLogger(INFACT_BANNER);
|
|
182
180
|
}
|
|
183
181
|
const instance = `[4m${targetClass.name}[24m`;
|
|
@@ -324,8 +322,7 @@ function nextScopeId() {
|
|
|
324
322
|
return () => {
|
|
325
323
|
const ctx = current$1();
|
|
326
324
|
const scopeId = useScopeId(ctx);
|
|
327
|
-
const
|
|
328
|
-
const logger = typeof ctxLogger.topic === "function" ? ctxLogger.topic(options.loggerTitle) : ctxLogger;
|
|
325
|
+
const logger = useLogger$1(options.loggerTitle, ctx);
|
|
329
326
|
const unscope = registerEventScope(scopeId);
|
|
330
327
|
let response;
|
|
331
328
|
let hookOptions;
|
|
@@ -425,9 +422,11 @@ function nextScopeId() {
|
|
|
425
422
|
}
|
|
426
423
|
function cleanup() {
|
|
427
424
|
if (interceptorHandler?.countAfter || interceptorHandler?.countOnError) {
|
|
425
|
+
const raisedResponse = response;
|
|
428
426
|
const afterResult = ci ? ci.with("Interceptors:after", () => interceptorHandler?.fireAfter(response)) : interceptorHandler?.fireAfter(response);
|
|
429
427
|
if (isThenable(afterResult)) return afterResult.then((r) => {
|
|
430
428
|
response = r;
|
|
429
|
+
if (raise && response !== raisedResponse) raise = false;
|
|
431
430
|
return finalize();
|
|
432
431
|
}, (error) => {
|
|
433
432
|
if (options.logErrors) logger.error(String(error));
|
|
@@ -435,6 +434,7 @@ function nextScopeId() {
|
|
|
435
434
|
throw error;
|
|
436
435
|
});
|
|
437
436
|
response = afterResult;
|
|
437
|
+
if (raise && response !== raisedResponse) raise = false;
|
|
438
438
|
}
|
|
439
439
|
return finalize();
|
|
440
440
|
}
|
|
@@ -853,20 +853,17 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
|
853
853
|
* @param topic
|
|
854
854
|
* @returns Resolver to '@wooksjs/event-core' (Logger)
|
|
855
855
|
*/ function InjectEventLogger(topic) {
|
|
856
|
-
return Resolve(() =>
|
|
857
|
-
const l = useLogger$1();
|
|
858
|
-
return topic && typeof l.topic === "function" ? l.topic(topic) : l;
|
|
859
|
-
});
|
|
856
|
+
return Resolve(() => topic ? useLogger$1(topic) : useLogger$1());
|
|
860
857
|
}
|
|
861
858
|
/**
|
|
862
859
|
* Resolves app-level logger
|
|
863
|
-
* @param topic - logger topic (
|
|
860
|
+
* @param topic - logger topic (falls back to @LoggerTopic, then to class @Id)
|
|
864
861
|
* @returns
|
|
865
862
|
*/ function InjectMoostLogger(topic) {
|
|
866
863
|
return Resolve(async (metas) => {
|
|
867
864
|
const moostApp = await resolveMoost();
|
|
868
865
|
const meta = metas.classMeta;
|
|
869
|
-
return moostApp.getLogger(meta?.loggerTopic ||
|
|
866
|
+
return moostApp.getLogger(topic || meta?.loggerTopic || meta?.id);
|
|
870
867
|
});
|
|
871
868
|
}
|
|
872
869
|
/**
|
|
@@ -944,7 +941,8 @@ var TInterceptorPriority = /* @__PURE__ */ function(TInterceptorPriority) {
|
|
|
944
941
|
* (For optional values use with @Optional())
|
|
945
942
|
* @param type - string or class constructor
|
|
946
943
|
*/ function Inject(type) {
|
|
947
|
-
|
|
944
|
+
const key = typeof type === "string" ? type : Symbol.for(String(type));
|
|
945
|
+
return getMoostMate().decorate("inject", key);
|
|
948
946
|
}
|
|
949
947
|
/**
|
|
950
948
|
* Injects instance from scope
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"@prostojs/infact": "^0.4.1",
|
|
42
42
|
"@prostojs/logger": "^0.4.3",
|
|
43
43
|
"@prostojs/mate": "^0.4.0",
|
|
44
|
-
"@wooksjs/event-core": "^0.7.
|
|
44
|
+
"@wooksjs/event-core": "^0.7.19",
|
|
45
45
|
"hookable": "^5.5.3",
|
|
46
|
-
"wooks": "^0.7.
|
|
46
|
+
"wooks": "^0.7.19"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@wooksjs/event-http": "^0.7.
|
|
50
|
-
"@wooksjs/http-body": "^0.7.
|
|
49
|
+
"@wooksjs/event-http": "^0.7.19",
|
|
50
|
+
"@wooksjs/http-body": "^0.7.19",
|
|
51
51
|
"vitest": "3.2.4",
|
|
52
|
-
"@moostjs/event-http": "^0.6.
|
|
52
|
+
"@moostjs/event-http": "^0.6.27"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"pub": "pnpm publish --access public",
|