@c9up/rover 0.1.7 → 0.1.8
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/RoverProvider.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
interface RoverContainer {
|
|
6
6
|
singleton(token: unknown, factory: () => unknown): void;
|
|
7
|
-
resolve<T = unknown>(token: unknown): T
|
|
7
|
+
resolve<T = unknown>(token: unknown): Promise<T>;
|
|
8
8
|
}
|
|
9
9
|
interface RoverConfigStore {
|
|
10
10
|
get<T = unknown>(key: string): T | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoverProvider.d.ts","sourceRoot":"","sources":["../src/RoverProvider.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,UAAU,cAAc;IACvB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"RoverProvider.d.ts","sourceRoot":"","sources":["../src/RoverProvider.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,UAAU,cAAc;IACvB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;IACxD,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjD;AACD,UAAU,gBAAgB;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;CAC7C;AACD,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,cAAc,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;CACzB;AAED,MAAM,CAAC,OAAO,OAAO,aAAa;IACrB,SAAS,CAAC,GAAG,EAAE,eAAe;gBAApB,GAAG,EAAE,eAAe;IAE1C,QAAQ;IA0BF,IAAI;IAOJ,QAAQ;CACd"}
|
package/dist/RoverProvider.js
CHANGED
|
@@ -6,7 +6,7 @@ export default class RoverProvider {
|
|
|
6
6
|
this.app = app;
|
|
7
7
|
}
|
|
8
8
|
register() {
|
|
9
|
-
this.app.container.singleton(Mail, () => {
|
|
9
|
+
this.app.container.singleton(Mail, async () => {
|
|
10
10
|
const config = this.app.config.get("mail");
|
|
11
11
|
return new Mail(config ?? {
|
|
12
12
|
default: "log",
|
|
@@ -17,10 +17,10 @@ export default class RoverProvider {
|
|
|
17
17
|
// `QueueManager` is registered in the container, Mail gets
|
|
18
18
|
// queue support for `sendLater()`. If not, `sendLater()`
|
|
19
19
|
// throws `MAIL_QUEUE_REQUIRED` at call time (by design).
|
|
20
|
-
queue: tryResolve(this.app, "QueueManager"),
|
|
20
|
+
queue: await tryResolve(this.app, "QueueManager"),
|
|
21
21
|
// Same pattern for the event bus `Emitter` — enables `mail.sent`
|
|
22
22
|
// / `mail.failed` emission when available.
|
|
23
|
-
emitter: tryResolve(this.app, "Emitter"),
|
|
23
|
+
emitter: await tryResolve(this.app, "Emitter"),
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
this.app.container.singleton("mail", () => {
|
|
@@ -31,7 +31,7 @@ export default class RoverProvider {
|
|
|
31
31
|
// Populate the `@c9up/rover/services/main` singleton with the
|
|
32
32
|
// container-resolved Mail instance so apps can
|
|
33
33
|
// `import mail from '@c9up/rover/services/main'` from anywhere.
|
|
34
|
-
setMail(this.app.container.resolve(Mail));
|
|
34
|
+
setMail(await this.app.container.resolve(Mail));
|
|
35
35
|
}
|
|
36
36
|
async shutdown() { }
|
|
37
37
|
}
|
|
@@ -40,9 +40,9 @@ export default class RoverProvider {
|
|
|
40
40
|
* registered. Rover never hard-depends on Bay or the event bus — both wire-points
|
|
41
41
|
* are purely opt-in.
|
|
42
42
|
*/
|
|
43
|
-
function tryResolve(app, token) {
|
|
43
|
+
async function tryResolve(app, token) {
|
|
44
44
|
try {
|
|
45
|
-
return app.container.resolve(token);
|
|
45
|
+
return await app.container.resolve(token);
|
|
46
46
|
}
|
|
47
47
|
catch {
|
|
48
48
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoverProvider.js","sourceRoot":"","sources":["../src/RoverProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAkB7C,MAAM,CAAC,OAAO,OAAO,aAAa;IACX;IAAtB,YAAsB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;IAAG,CAAC;IAE9C,QAAQ;QACP,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"RoverProvider.js","sourceRoot":"","sources":["../src/RoverProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAkB7C,MAAM,CAAC,OAAO,OAAO,aAAa;IACX;IAAtB,YAAsB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;IAAG,CAAC;IAE9C,QAAQ;QACP,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAa,MAAM,CAAC,CAAC;YACvD,OAAO,IAAI,IAAI,CACd,MAAM,IAAI;gBACT,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,mBAAmB;gBACzB,UAAU,EAAE,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE;aACzC,EACD;gBACC,4DAA4D;gBAC5D,2DAA2D;gBAC3D,yDAAyD;gBACzD,yDAAyD;gBACzD,KAAK,EAAE,MAAM,UAAU,CAAe,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC;gBAC/D,iEAAiE;gBACjE,2CAA2C;gBAC3C,OAAO,EAAE,MAAM,UAAU,CAAc,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC;aAC3D,CACD,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;YACzC,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAO,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI;QACT,8DAA8D;QAC9D,+CAA+C;QAC/C,gEAAgE;QAChE,OAAO,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAO,IAAI,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,QAAQ,KAAI,CAAC;CACnB;AAED;;;;GAIG;AACH,KAAK,UAAU,UAAU,CACxB,GAAoB,EACpB,KAAa;IAEb,IAAI,CAAC;QACJ,OAAO,MAAM,GAAG,CAAC,SAAS,CAAC,OAAO,CAAI,KAAK,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,SAAS,CAAC;IAClB,CAAC;AACF,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
package/src/RoverProvider.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { setMail } from "./services/main.js";
|
|
|
9
9
|
*/
|
|
10
10
|
interface RoverContainer {
|
|
11
11
|
singleton(token: unknown, factory: () => unknown): void;
|
|
12
|
-
resolve<T = unknown>(token: unknown): T
|
|
12
|
+
resolve<T = unknown>(token: unknown): Promise<T>;
|
|
13
13
|
}
|
|
14
14
|
interface RoverConfigStore {
|
|
15
15
|
get<T = unknown>(key: string): T | undefined;
|
|
@@ -23,7 +23,7 @@ export default class RoverProvider {
|
|
|
23
23
|
constructor(protected app: RoverAppContext) {}
|
|
24
24
|
|
|
25
25
|
register() {
|
|
26
|
-
this.app.container.singleton(Mail, () => {
|
|
26
|
+
this.app.container.singleton(Mail, async () => {
|
|
27
27
|
const config = this.app.config.get<MailConfig>("mail");
|
|
28
28
|
return new Mail(
|
|
29
29
|
config ?? {
|
|
@@ -36,10 +36,10 @@ export default class RoverProvider {
|
|
|
36
36
|
// `QueueManager` is registered in the container, Mail gets
|
|
37
37
|
// queue support for `sendLater()`. If not, `sendLater()`
|
|
38
38
|
// throws `MAIL_QUEUE_REQUIRED` at call time (by design).
|
|
39
|
-
queue: tryResolve<BayQueueLike>(this.app, "QueueManager"),
|
|
39
|
+
queue: await tryResolve<BayQueueLike>(this.app, "QueueManager"),
|
|
40
40
|
// Same pattern for the event bus `Emitter` — enables `mail.sent`
|
|
41
41
|
// / `mail.failed` emission when available.
|
|
42
|
-
emitter: tryResolve<EmitterLike>(this.app, "Emitter"),
|
|
42
|
+
emitter: await tryResolve<EmitterLike>(this.app, "Emitter"),
|
|
43
43
|
},
|
|
44
44
|
);
|
|
45
45
|
});
|
|
@@ -52,7 +52,7 @@ export default class RoverProvider {
|
|
|
52
52
|
// Populate the `@c9up/rover/services/main` singleton with the
|
|
53
53
|
// container-resolved Mail instance so apps can
|
|
54
54
|
// `import mail from '@c9up/rover/services/main'` from anywhere.
|
|
55
|
-
setMail(this.app.container.resolve<Mail>(Mail));
|
|
55
|
+
setMail(await this.app.container.resolve<Mail>(Mail));
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
async shutdown() {}
|
|
@@ -63,9 +63,12 @@ export default class RoverProvider {
|
|
|
63
63
|
* registered. Rover never hard-depends on Bay or the event bus — both wire-points
|
|
64
64
|
* are purely opt-in.
|
|
65
65
|
*/
|
|
66
|
-
function tryResolve<T>(
|
|
66
|
+
async function tryResolve<T>(
|
|
67
|
+
app: RoverAppContext,
|
|
68
|
+
token: string,
|
|
69
|
+
): Promise<T | undefined> {
|
|
67
70
|
try {
|
|
68
|
-
return app.container.resolve<T>(token);
|
|
71
|
+
return await app.container.resolve<T>(token);
|
|
69
72
|
} catch {
|
|
70
73
|
return undefined;
|
|
71
74
|
}
|