@playdrop/playdrop-cli 0.11.5 → 0.11.6
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/config/client-meta.json +1 -1
- package/node_modules/@playdrop/api-client/dist/client.d.ts +0 -10
- package/node_modules/@playdrop/api-client/dist/client.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts +0 -10
- package/node_modules/@playdrop/api-client/dist/domains/admin.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/domains/admin.js +0 -58
- package/node_modules/@playdrop/api-client/dist/index.d.ts +0 -10
- package/node_modules/@playdrop/api-client/dist/index.d.ts.map +1 -1
- package/node_modules/@playdrop/api-client/dist/index.js +0 -20
- package/node_modules/@playdrop/config/client-meta.json +1 -1
- package/node_modules/@playdrop/config/dist/src/runtime-client-meta.d.ts +7 -0
- package/node_modules/@playdrop/config/dist/src/runtime-client-meta.d.ts.map +1 -0
- package/node_modules/@playdrop/config/dist/src/runtime-client-meta.js +21 -0
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts +43 -0
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.d.ts.map +1 -0
- package/node_modules/@playdrop/config/dist/src/runtime-service-origins.js +217 -0
- package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.d.ts +2 -0
- package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.d.ts.map +1 -0
- package/node_modules/@playdrop/config/dist/test/runtime-service-origins.test.js +50 -0
- package/node_modules/@playdrop/config/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@playdrop/config/package.json +8 -0
- package/node_modules/@playdrop/types/dist/api.d.ts +1 -0
- package/node_modules/@playdrop/types/dist/api.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const RUNTIME_SERVICE_DEFAULT_PORTS: {
|
|
2
|
+
readonly www: 8080;
|
|
3
|
+
readonly api: 4000;
|
|
4
|
+
readonly play: 3000;
|
|
5
|
+
readonly admin: 8081;
|
|
6
|
+
readonly ai: 8083;
|
|
7
|
+
readonly assets: 8082;
|
|
8
|
+
readonly engine: 3001;
|
|
9
|
+
};
|
|
10
|
+
export type RuntimeServiceName = keyof typeof RUNTIME_SERVICE_DEFAULT_PORTS;
|
|
11
|
+
export type PlaydropSurface = "prod" | "preview" | "blue" | "green";
|
|
12
|
+
export declare function resolvePlaydropSurface(hostname: string): PlaydropSurface | null;
|
|
13
|
+
export declare function buildPlaydropServiceOrigin(input: {
|
|
14
|
+
protocol: string;
|
|
15
|
+
service: string;
|
|
16
|
+
surface: PlaydropSurface;
|
|
17
|
+
}): string;
|
|
18
|
+
export declare function resolveRuntimeServiceBaseUrl(input: {
|
|
19
|
+
protocol: string;
|
|
20
|
+
hostname: string;
|
|
21
|
+
service: string;
|
|
22
|
+
envValue?: string | null;
|
|
23
|
+
defaultPorts?: Partial<Record<string, number>>;
|
|
24
|
+
}): string;
|
|
25
|
+
export declare function resolveRuntimeApiBaseUrl(input: {
|
|
26
|
+
protocol: string;
|
|
27
|
+
hostname: string;
|
|
28
|
+
envValue?: string | null;
|
|
29
|
+
}): string;
|
|
30
|
+
export declare function resolveRuntimeRealtimeBaseUrl(input: {
|
|
31
|
+
protocol: string;
|
|
32
|
+
hostname: string;
|
|
33
|
+
envValue?: string | null;
|
|
34
|
+
}): string;
|
|
35
|
+
export declare function resolveRuntimeAssetsBaseUrl(input: {
|
|
36
|
+
protocol: string;
|
|
37
|
+
hostname: string;
|
|
38
|
+
envValue?: string | null;
|
|
39
|
+
}): string;
|
|
40
|
+
export declare function resolveBrowserApiBaseUrl(): string;
|
|
41
|
+
export declare function resolveBrowserRealtimeBaseUrl(): string;
|
|
42
|
+
export declare function resolveBrowserAssetsBaseUrl(): string;
|
|
43
|
+
//# sourceMappingURL=runtime-service-origins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-service-origins.d.ts","sourceRoot":"","sources":["../../src/runtime-service-origins.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;;CAQhC,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,6BAA6B,CAAC;AAC5E,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAgDpE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA0B/E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;CAC1B,GAAG,MAAM,CAQT;AA2BD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,GAAG,MAAM,CAgCT;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAOT;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAkCT;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAmBT;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAUjD;AAED,wBAAgB,6BAA6B,IAAI,MAAM,CAUtD;AAED,wBAAgB,2BAA2B,IAAI,MAAM,CAUpD"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME_SERVICE_DEFAULT_PORTS = void 0;
|
|
4
|
+
exports.resolvePlaydropSurface = resolvePlaydropSurface;
|
|
5
|
+
exports.buildPlaydropServiceOrigin = buildPlaydropServiceOrigin;
|
|
6
|
+
exports.resolveRuntimeServiceBaseUrl = resolveRuntimeServiceBaseUrl;
|
|
7
|
+
exports.resolveRuntimeApiBaseUrl = resolveRuntimeApiBaseUrl;
|
|
8
|
+
exports.resolveRuntimeRealtimeBaseUrl = resolveRuntimeRealtimeBaseUrl;
|
|
9
|
+
exports.resolveRuntimeAssetsBaseUrl = resolveRuntimeAssetsBaseUrl;
|
|
10
|
+
exports.resolveBrowserApiBaseUrl = resolveBrowserApiBaseUrl;
|
|
11
|
+
exports.resolveBrowserRealtimeBaseUrl = resolveBrowserRealtimeBaseUrl;
|
|
12
|
+
exports.resolveBrowserAssetsBaseUrl = resolveBrowserAssetsBaseUrl;
|
|
13
|
+
exports.RUNTIME_SERVICE_DEFAULT_PORTS = {
|
|
14
|
+
www: 8080,
|
|
15
|
+
api: 4000,
|
|
16
|
+
play: 3000,
|
|
17
|
+
admin: 8081,
|
|
18
|
+
ai: 8083,
|
|
19
|
+
assets: 8082,
|
|
20
|
+
engine: 3001,
|
|
21
|
+
};
|
|
22
|
+
const PLAYDROP_SURFACES = new Set(["prod", "preview", "blue", "green"]);
|
|
23
|
+
const PLAYDROP_SERVICE_PREFIXES = new Set([
|
|
24
|
+
"www",
|
|
25
|
+
"api",
|
|
26
|
+
"play",
|
|
27
|
+
"admin",
|
|
28
|
+
"ai",
|
|
29
|
+
"assets",
|
|
30
|
+
"engine",
|
|
31
|
+
]);
|
|
32
|
+
function trimTrailingSlash(value) {
|
|
33
|
+
return value.replace(/\/+$/, "");
|
|
34
|
+
}
|
|
35
|
+
function normalizeHostname(value) {
|
|
36
|
+
return value.trim().toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
function normalizeHttpProtocol(value) {
|
|
39
|
+
return value === "https:" || value === "https" ? "https:" : "http:";
|
|
40
|
+
}
|
|
41
|
+
function isLoopbackHostname(hostname) {
|
|
42
|
+
return hostname === "localhost"
|
|
43
|
+
|| hostname === "127.0.0.1"
|
|
44
|
+
|| hostname === "0.0.0.0";
|
|
45
|
+
}
|
|
46
|
+
function resolveDefaultPort(service, defaultPorts = exports.RUNTIME_SERVICE_DEFAULT_PORTS) {
|
|
47
|
+
return defaultPorts[service]
|
|
48
|
+
?? exports.RUNTIME_SERVICE_DEFAULT_PORTS[service]
|
|
49
|
+
?? exports.RUNTIME_SERVICE_DEFAULT_PORTS.www;
|
|
50
|
+
}
|
|
51
|
+
function stripKnownServicePrefix(hostname) {
|
|
52
|
+
const parts = hostname.split(".");
|
|
53
|
+
if (parts.length > 1 && PLAYDROP_SERVICE_PREFIXES.has(parts[0] ?? "")) {
|
|
54
|
+
return parts.slice(1).join(".");
|
|
55
|
+
}
|
|
56
|
+
return hostname;
|
|
57
|
+
}
|
|
58
|
+
function resolvePlaydropSurface(hostname) {
|
|
59
|
+
const normalized = normalizeHostname(hostname);
|
|
60
|
+
const suffix = ".playdrop.ai";
|
|
61
|
+
if (normalized === "playdrop.ai") {
|
|
62
|
+
return "prod";
|
|
63
|
+
}
|
|
64
|
+
if (!normalized.endsWith(suffix)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const prefixParts = normalized.slice(0, -suffix.length).split(".").filter(Boolean);
|
|
68
|
+
if (prefixParts.length === 0) {
|
|
69
|
+
return "prod";
|
|
70
|
+
}
|
|
71
|
+
const surfaceCandidate = prefixParts[prefixParts.length - 1];
|
|
72
|
+
if (surfaceCandidate && PLAYDROP_SURFACES.has(surfaceCandidate) && surfaceCandidate !== "prod") {
|
|
73
|
+
return surfaceCandidate;
|
|
74
|
+
}
|
|
75
|
+
if (prefixParts.length === 1 && PLAYDROP_SERVICE_PREFIXES.has(prefixParts[0] ?? "")) {
|
|
76
|
+
return "prod";
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function buildPlaydropServiceOrigin(input) {
|
|
81
|
+
const protocol = normalizeHttpProtocol(input.protocol);
|
|
82
|
+
const service = input.service.trim().toLowerCase() || "www";
|
|
83
|
+
const surface = input.surface;
|
|
84
|
+
const hostname = service === "www"
|
|
85
|
+
? surface === "prod" ? "www.playdrop.ai" : `${surface}.playdrop.ai`
|
|
86
|
+
: surface === "prod" ? `${service}.playdrop.ai` : `${service}.${surface}.playdrop.ai`;
|
|
87
|
+
return `${protocol}//${hostname}`;
|
|
88
|
+
}
|
|
89
|
+
function resolveLocalDomainServiceOrigin(input) {
|
|
90
|
+
const { protocol, hostname, service } = input;
|
|
91
|
+
if (hostname === "www.localhost") {
|
|
92
|
+
return service === "www" ? `${protocol}//www.localhost` : `${protocol}//${service}.localhost`;
|
|
93
|
+
}
|
|
94
|
+
if (hostname === "play.local") {
|
|
95
|
+
return service === "www" ? `${protocol}//www.local` : `${protocol}//${service}.local`;
|
|
96
|
+
}
|
|
97
|
+
if (hostname.endsWith(".localhost")) {
|
|
98
|
+
const domain = stripKnownServicePrefix(hostname);
|
|
99
|
+
return service === "www" ? `${protocol}//www.${domain}` : `${protocol}//${service}.${domain}`;
|
|
100
|
+
}
|
|
101
|
+
if (hostname.endsWith(".local")) {
|
|
102
|
+
const domain = stripKnownServicePrefix(hostname);
|
|
103
|
+
return service === "www" ? `${protocol}//www.${domain}` : `${protocol}//${service}.${domain}`;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
function resolveRuntimeServiceBaseUrl(input) {
|
|
108
|
+
const protocol = normalizeHttpProtocol(input.protocol);
|
|
109
|
+
const hostname = normalizeHostname(input.hostname);
|
|
110
|
+
const service = input.service.trim().toLowerCase() || "www";
|
|
111
|
+
if (isLoopbackHostname(hostname)) {
|
|
112
|
+
const port = resolveDefaultPort(service, input.defaultPorts);
|
|
113
|
+
return `${protocol}//${hostname}:${port}`;
|
|
114
|
+
}
|
|
115
|
+
const localDomainOrigin = resolveLocalDomainServiceOrigin({ protocol, hostname, service });
|
|
116
|
+
if (localDomainOrigin) {
|
|
117
|
+
return localDomainOrigin;
|
|
118
|
+
}
|
|
119
|
+
const playdropSurface = resolvePlaydropSurface(hostname);
|
|
120
|
+
if (playdropSurface) {
|
|
121
|
+
return buildPlaydropServiceOrigin({ protocol, service, surface: playdropSurface });
|
|
122
|
+
}
|
|
123
|
+
const envValue = (input.envValue ?? "").trim();
|
|
124
|
+
if (envValue) {
|
|
125
|
+
return trimTrailingSlash(envValue);
|
|
126
|
+
}
|
|
127
|
+
if (hostname.includes(".")) {
|
|
128
|
+
const domain = stripKnownServicePrefix(hostname);
|
|
129
|
+
return service === "www" ? `${protocol}//www.${domain}` : `${protocol}//${service}.${domain}`;
|
|
130
|
+
}
|
|
131
|
+
const port = resolveDefaultPort(service, input.defaultPorts);
|
|
132
|
+
return `${protocol}//${hostname}:${port}`;
|
|
133
|
+
}
|
|
134
|
+
function resolveRuntimeApiBaseUrl(input) {
|
|
135
|
+
return resolveRuntimeServiceBaseUrl({
|
|
136
|
+
protocol: input.protocol,
|
|
137
|
+
hostname: input.hostname,
|
|
138
|
+
service: "api",
|
|
139
|
+
envValue: input.envValue ?? process.env["NEXT_PUBLIC_API_BASE"] ?? null,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function resolveRuntimeRealtimeBaseUrl(input) {
|
|
143
|
+
const protocol = normalizeHttpProtocol(input.protocol);
|
|
144
|
+
const hostname = normalizeHostname(input.hostname);
|
|
145
|
+
if (isLoopbackHostname(hostname)) {
|
|
146
|
+
return "ws://localhost:3000/ws";
|
|
147
|
+
}
|
|
148
|
+
const envValue = (input.envValue ?? process.env["NEXT_PUBLIC_REALTIME_BASE"] ?? "").trim();
|
|
149
|
+
const localDomainOrigin = resolveLocalDomainServiceOrigin({ protocol, hostname, service: "play" });
|
|
150
|
+
if (localDomainOrigin) {
|
|
151
|
+
const wsOrigin = localDomainOrigin.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
152
|
+
return `${trimTrailingSlash(wsOrigin)}/ws`;
|
|
153
|
+
}
|
|
154
|
+
const playdropSurface = resolvePlaydropSurface(hostname);
|
|
155
|
+
if (playdropSurface) {
|
|
156
|
+
const serviceOrigin = buildPlaydropServiceOrigin({ protocol, service: "play", surface: playdropSurface });
|
|
157
|
+
const wsOrigin = serviceOrigin.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
158
|
+
return `${trimTrailingSlash(wsOrigin)}/ws`;
|
|
159
|
+
}
|
|
160
|
+
if (envValue) {
|
|
161
|
+
return trimTrailingSlash(envValue);
|
|
162
|
+
}
|
|
163
|
+
const serviceOrigin = resolveRuntimeServiceBaseUrl({
|
|
164
|
+
protocol,
|
|
165
|
+
hostname,
|
|
166
|
+
service: "play",
|
|
167
|
+
});
|
|
168
|
+
const wsOrigin = serviceOrigin.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
|
|
169
|
+
return `${trimTrailingSlash(wsOrigin)}/ws`;
|
|
170
|
+
}
|
|
171
|
+
function resolveRuntimeAssetsBaseUrl(input) {
|
|
172
|
+
const protocol = normalizeHttpProtocol(input.protocol);
|
|
173
|
+
const hostname = normalizeHostname(input.hostname);
|
|
174
|
+
if (isLoopbackHostname(hostname)) {
|
|
175
|
+
return "http://localhost:8082";
|
|
176
|
+
}
|
|
177
|
+
const playdropSurface = resolvePlaydropSurface(hostname);
|
|
178
|
+
if (playdropSurface) {
|
|
179
|
+
return buildPlaydropServiceOrigin({ protocol, service: "assets", surface: "prod" });
|
|
180
|
+
}
|
|
181
|
+
return resolveRuntimeServiceBaseUrl({
|
|
182
|
+
protocol,
|
|
183
|
+
hostname,
|
|
184
|
+
service: "assets",
|
|
185
|
+
envValue: input.envValue ?? process.env["NEXT_PUBLIC_ASSETS_BASE"] ?? null,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function resolveBrowserApiBaseUrl() {
|
|
189
|
+
if (typeof window === "undefined") {
|
|
190
|
+
const envValue = (process.env["NEXT_PUBLIC_API_BASE"] ?? "").trim();
|
|
191
|
+
return envValue ? trimTrailingSlash(envValue) : "http://localhost:4000";
|
|
192
|
+
}
|
|
193
|
+
return resolveRuntimeApiBaseUrl({
|
|
194
|
+
protocol: window.location.protocol,
|
|
195
|
+
hostname: window.location.hostname,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function resolveBrowserRealtimeBaseUrl() {
|
|
199
|
+
if (typeof window === "undefined") {
|
|
200
|
+
const envValue = (process.env["NEXT_PUBLIC_REALTIME_BASE"] ?? "").trim();
|
|
201
|
+
return envValue ? trimTrailingSlash(envValue) : "ws://localhost:3000/ws";
|
|
202
|
+
}
|
|
203
|
+
return resolveRuntimeRealtimeBaseUrl({
|
|
204
|
+
protocol: window.location.protocol,
|
|
205
|
+
hostname: window.location.hostname,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function resolveBrowserAssetsBaseUrl() {
|
|
209
|
+
if (typeof window === "undefined") {
|
|
210
|
+
const envValue = (process.env["NEXT_PUBLIC_ASSETS_BASE"] ?? "").trim();
|
|
211
|
+
return envValue ? trimTrailingSlash(envValue) : "http://localhost:8082";
|
|
212
|
+
}
|
|
213
|
+
return resolveRuntimeAssetsBaseUrl({
|
|
214
|
+
protocol: window.location.protocol,
|
|
215
|
+
hostname: window.location.hostname,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-service-origins.test.d.ts","sourceRoot":"","sources":["../../test/runtime-service-origins.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
|
+
const node_test_1 = __importDefault(require("node:test"));
|
|
8
|
+
const runtime_service_origins_1 = require("../src/runtime-service-origins");
|
|
9
|
+
(0, node_test_1.default)("resolveRuntimeServiceBaseUrl uses local service ports for loopback hosts", () => {
|
|
10
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "http:", hostname: "localhost", service: "api" }), "http://localhost:4000");
|
|
11
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "http:", hostname: "localhost", service: "admin" }), "http://localhost:8081");
|
|
12
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "http:", hostname: "localhost", service: "unknown" }), "http://localhost:8080");
|
|
13
|
+
});
|
|
14
|
+
(0, node_test_1.default)("resolveRuntimeServiceBaseUrl maps generic service subdomains behind real domains", () => {
|
|
15
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "https:", hostname: "www.playdrop.test", service: "api" }), "https://api.playdrop.test");
|
|
16
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "https:", hostname: "admin.playdrop.test", service: "assets" }), "https://assets.playdrop.test");
|
|
17
|
+
});
|
|
18
|
+
(0, node_test_1.default)("resolveRuntimeServiceBaseUrl understands PlayDrop deployment surfaces", () => {
|
|
19
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolvePlaydropSurface)("admin.blue.playdrop.ai"), "blue");
|
|
20
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "https:", hostname: "admin.blue.playdrop.ai", service: "www" }), "https://blue.playdrop.ai");
|
|
21
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "https:", hostname: "admin.blue.playdrop.ai", service: "api" }), "https://api.blue.playdrop.ai");
|
|
22
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeServiceBaseUrl)({ protocol: "https:", hostname: "admin.green.playdrop.ai", service: "play" }), "https://play.green.playdrop.ai");
|
|
23
|
+
});
|
|
24
|
+
(0, node_test_1.default)("runtime app-specific resolvers preserve web surface behavior", () => {
|
|
25
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeApiBaseUrl)({ protocol: "https:", hostname: "blue.playdrop.ai" }), "https://api.blue.playdrop.ai");
|
|
26
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeRealtimeBaseUrl)({ protocol: "https:", hostname: "green.playdrop.ai" }), "wss://play.green.playdrop.ai/ws");
|
|
27
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeAssetsBaseUrl)({ protocol: "https:", hostname: "green.playdrop.ai" }), "https://assets.playdrop.ai");
|
|
28
|
+
});
|
|
29
|
+
(0, node_test_1.default)("runtime realtime resolver preserves explicit env endpoints on generic hosts", () => {
|
|
30
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeRealtimeBaseUrl)({
|
|
31
|
+
protocol: "https:",
|
|
32
|
+
hostname: "admin.example.test",
|
|
33
|
+
envValue: "wss://play.example.test/ws/",
|
|
34
|
+
}), "wss://play.example.test/ws");
|
|
35
|
+
});
|
|
36
|
+
(0, node_test_1.default)("browser API resolver uses explicit env value on the server", () => {
|
|
37
|
+
const previous = process.env["NEXT_PUBLIC_API_BASE"];
|
|
38
|
+
process.env["NEXT_PUBLIC_API_BASE"] = "https://api.example.test/";
|
|
39
|
+
try {
|
|
40
|
+
strict_1.default.equal((0, runtime_service_origins_1.resolveBrowserApiBaseUrl)(), "https://api.example.test");
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
if (previous === undefined) {
|
|
44
|
+
delete process.env["NEXT_PUBLIC_API_BASE"];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
process.env["NEXT_PUBLIC_API_BASE"] = previous;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|