@teamscala/service-boot 0.23.409 → 0.23.410
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/package.json
CHANGED
|
@@ -19,8 +19,8 @@ const SEND_CALLS: Array<{ url: string; headers: Record<string, string>; body: un
|
|
|
19
19
|
|
|
20
20
|
mock.module("@teamscala/db/registry/load-config", () => ({
|
|
21
21
|
loadRegistryConfig: async (type: string, slug: string) => {
|
|
22
|
-
if (type === "
|
|
23
|
-
return {
|
|
22
|
+
if (type === "config" && slug === "messaging-service-internal-url") {
|
|
23
|
+
return { internalBaseUrl: "http://scala-messaging-rust.railway.internal:8080" };
|
|
24
24
|
}
|
|
25
25
|
if (type === "secret" && slug === "railway-scala-messaging-whatsapp-webhook-secret") {
|
|
26
26
|
return { token: "test-token" };
|
|
@@ -73,7 +73,7 @@ const client = createRouterClient(
|
|
|
73
73
|
) as { messagingWhatsappSend: (a: unknown) => Promise<unknown> };
|
|
74
74
|
|
|
75
75
|
describe("fn.messagingWhatsappSend", () => {
|
|
76
|
-
test("derives the URL from
|
|
76
|
+
test("derives the URL from the config row, sends with the decrypted header value, returns the message_id", async () => {
|
|
77
77
|
SEND_CALLS.length = 0;
|
|
78
78
|
const result = await client.messagingWhatsappSend({
|
|
79
79
|
phone: "61428193498",
|
|
@@ -82,7 +82,7 @@ describe("fn.messagingWhatsappSend", () => {
|
|
|
82
82
|
|
|
83
83
|
expect(SEND_CALLS).toHaveLength(1);
|
|
84
84
|
expect(SEND_CALLS[0]?.url).toBe(
|
|
85
|
-
"http://scala-messaging-
|
|
85
|
+
"http://scala-messaging-rust.railway.internal:8080/api/messaging/whatsapp/send",
|
|
86
86
|
);
|
|
87
87
|
expect(SEND_CALLS[0]?.headers["x-webhook-secret"]).toBe("test-token");
|
|
88
88
|
expect(SEND_CALLS[0]?.body).toEqual({ phone: "61428193498", message: "migration probe" });
|
|
@@ -61,29 +61,34 @@ const authed = os.$context<Context>().use(async (opt) => {
|
|
|
61
61
|
return await opt.next({ context: { ...context, user } });
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Derive the messaging service base URL. The single source is the
|
|
66
|
+
* config/messaging-service-internal-url row (the Railway private domain is a
|
|
67
|
+
* Railway fact — the registry slug and the Railway service name differ, e.g.
|
|
68
|
+
* scala-messaging-service vs scala-messaging-rust — so the resolved URL lives
|
|
69
|
+
* in ONE registry row instead of being spelled per-caller).
|
|
70
|
+
*/
|
|
71
|
+
const MessagingUrlSchema = v.looseObject({
|
|
72
|
+
internalBaseUrl: v.string(),
|
|
68
73
|
});
|
|
69
74
|
|
|
70
75
|
/** The sealed webhook-secret row shape (value is decryptSecretConfig input). */
|
|
71
76
|
const MessagingSecretSchema = v.looseObject({});
|
|
72
77
|
|
|
73
|
-
/** Derive the messaging service base URL from its service_install row. */
|
|
74
78
|
async function resolveMessagingBaseUrl(): Promise<string> {
|
|
75
|
-
const
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
+
const row = await loadRegistryConfig(
|
|
80
|
+
"config",
|
|
81
|
+
"messaging-service-internal-url",
|
|
82
|
+
MessagingUrlSchema,
|
|
79
83
|
);
|
|
80
|
-
|
|
84
|
+
const url = row.internalBaseUrl.trim().replace(/\/+$/, "");
|
|
85
|
+
if (!url.startsWith("http")) {
|
|
81
86
|
throw new Error(
|
|
82
|
-
|
|
83
|
-
"the
|
|
87
|
+
"config/messaging-service-internal-url.internalBaseUrl must be an http(s) URL — " +
|
|
88
|
+
"the fn router refuses to guess a messaging service address.",
|
|
84
89
|
);
|
|
85
90
|
}
|
|
86
|
-
return
|
|
91
|
+
return url;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
const sendSchema = v.object({
|