@embeddable.com/sdk-core 3.12.2 → 3.12.3
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/lib/defineConfig.d.ts +3 -1
- package/lib/index.esm.js +33 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +33 -6
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/defineConfig.test.ts +56 -0
- package/src/defineConfig.ts +41 -5
package/package.json
CHANGED
package/src/defineConfig.test.ts
CHANGED
|
@@ -79,4 +79,60 @@ describe("defineConfig", () => {
|
|
|
79
79
|
}
|
|
80
80
|
`);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
describe("region configuration", () => {
|
|
84
|
+
it("uses legacy-US region by default", () => {
|
|
85
|
+
const config = defineConfig({ plugins: [] });
|
|
86
|
+
|
|
87
|
+
expect(config.pushBaseUrl).toBe("https://api.embeddable.com");
|
|
88
|
+
expect(config.audienceUrl).toBe("https://auth.embeddable.com");
|
|
89
|
+
expect(config.previewBaseUrl).toBe("https://app.embeddable.com");
|
|
90
|
+
expect(config.authDomain).toBe("auth.embeddable.com");
|
|
91
|
+
expect(config.authClientId).toBe("dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("configures EU region correctly", () => {
|
|
95
|
+
const config = defineConfig({ plugins: [], region: "EU" });
|
|
96
|
+
|
|
97
|
+
expect(config.pushBaseUrl).toBe("https://api.eu.embeddable.com");
|
|
98
|
+
expect(config.audienceUrl).toBe("https://auth.eu.embeddable.com");
|
|
99
|
+
expect(config.previewBaseUrl).toBe("https://app.eu.embeddable.com");
|
|
100
|
+
expect(config.authDomain).toBe("auth.eu.embeddable.com");
|
|
101
|
+
expect(config.authClientId).toBe("6OGPwIQsVmtrBKhNrwAaXh4ePb0kBGV");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("configures US region correctly", () => {
|
|
105
|
+
const config = defineConfig({ plugins: [], region: "US" });
|
|
106
|
+
|
|
107
|
+
expect(config.pushBaseUrl).toBe("https://api.us.embeddable.com");
|
|
108
|
+
expect(config.audienceUrl).toBe("https://auth.embeddable.com");
|
|
109
|
+
expect(config.previewBaseUrl).toBe("https://app.us.embeddable.com");
|
|
110
|
+
expect(config.authDomain).toBe("auth.embeddable.com");
|
|
111
|
+
expect(config.authClientId).toBe("dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("allows overriding region-specific values", () => {
|
|
115
|
+
const config = defineConfig({
|
|
116
|
+
plugins: [],
|
|
117
|
+
region: "EU",
|
|
118
|
+
pushBaseUrl: "custom-push-url",
|
|
119
|
+
authClientId: "custom-client-id",
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(config.pushBaseUrl).toBe("custom-push-url");
|
|
123
|
+
expect(config.authClientId).toBe("custom-client-id");
|
|
124
|
+
// Other values should still be from EU region
|
|
125
|
+
expect(config.audienceUrl).toBe("https://auth.eu.embeddable.com");
|
|
126
|
+
expect(config.previewBaseUrl).toBe("https://app.eu.embeddable.com");
|
|
127
|
+
expect(config.authDomain).toBe("auth.eu.embeddable.com");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("throws error for invalid region", () => {
|
|
131
|
+
expect(() =>
|
|
132
|
+
defineConfig({ plugins: [], region: "INVALID" as any }),
|
|
133
|
+
).toThrow(
|
|
134
|
+
"Unsupported region: INVALID. Supported regions are: EU, US, legacy-US",
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
82
138
|
});
|
package/src/defineConfig.ts
CHANGED
|
@@ -2,6 +2,8 @@ import * as path from "node:path";
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { RollupOptions } from "rollup";
|
|
4
4
|
|
|
5
|
+
export type Region = "EU" | "US" | "legacy-US";
|
|
6
|
+
|
|
5
7
|
export type EmbeddableConfig = {
|
|
6
8
|
plugins: (() => {
|
|
7
9
|
pluginName: string;
|
|
@@ -27,10 +29,36 @@ export type EmbeddableConfig = {
|
|
|
27
29
|
};
|
|
28
30
|
};
|
|
29
31
|
rollupOptions?: RollupOptions;
|
|
32
|
+
region?: Region;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const REGION_CONFIGS = {
|
|
36
|
+
EU: {
|
|
37
|
+
pushBaseUrl: "https://api.eu.embeddable.com",
|
|
38
|
+
audienceUrl: "https://auth.eu.embeddable.com",
|
|
39
|
+
previewBaseUrl: "https://app.eu.embeddable.com",
|
|
40
|
+
authDomain: "auth.eu.embeddable.com",
|
|
41
|
+
authClientId: "6OGPwIQsVmtrBKhNrwAaXh4ePb0kBGV",
|
|
42
|
+
},
|
|
43
|
+
US: {
|
|
44
|
+
pushBaseUrl: "https://api.us.embeddable.com",
|
|
45
|
+
audienceUrl: "https://auth.embeddable.com",
|
|
46
|
+
previewBaseUrl: "https://app.us.embeddable.com",
|
|
47
|
+
authDomain: "auth.embeddable.com",
|
|
48
|
+
authClientId: "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
|
|
49
|
+
},
|
|
50
|
+
"legacy-US": {
|
|
51
|
+
pushBaseUrl: "https://api.embeddable.com",
|
|
52
|
+
audienceUrl: "https://auth.embeddable.com",
|
|
53
|
+
previewBaseUrl: "https://app.embeddable.com",
|
|
54
|
+
authDomain: "auth.embeddable.com",
|
|
55
|
+
authClientId: "dygrSUmI6HmgY5ymVbEAoLDEBxIOyr1V",
|
|
56
|
+
},
|
|
30
57
|
};
|
|
31
58
|
|
|
32
59
|
export default ({
|
|
33
60
|
plugins,
|
|
61
|
+
region = "legacy-US",
|
|
34
62
|
pushBaseUrl,
|
|
35
63
|
audienceUrl,
|
|
36
64
|
authDomain,
|
|
@@ -46,6 +74,14 @@ export default ({
|
|
|
46
74
|
viteConfig = {},
|
|
47
75
|
rollupOptions = {},
|
|
48
76
|
}: EmbeddableConfig) => {
|
|
77
|
+
if (region && !REGION_CONFIGS[region]) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Unsupported region: ${region}. Supported regions are: ${Object.keys(REGION_CONFIGS).join(", ")}`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const regionConfig = REGION_CONFIGS[region];
|
|
84
|
+
|
|
49
85
|
const coreRoot = path.resolve(__dirname, "..");
|
|
50
86
|
const clientRoot = process.cwd();
|
|
51
87
|
|
|
@@ -107,11 +143,11 @@ export default ({
|
|
|
107
143
|
outputOptions: {
|
|
108
144
|
typesEntryPointFilename: "embeddable-types-entry-point.js",
|
|
109
145
|
},
|
|
110
|
-
pushBaseUrl: pushBaseUrl ??
|
|
111
|
-
audienceUrl: audienceUrl ??
|
|
112
|
-
previewBaseUrl: previewBaseUrl ??
|
|
113
|
-
authDomain: authDomain ??
|
|
114
|
-
authClientId: authClientId ??
|
|
146
|
+
pushBaseUrl: pushBaseUrl ?? regionConfig.pushBaseUrl,
|
|
147
|
+
audienceUrl: audienceUrl ?? regionConfig.audienceUrl,
|
|
148
|
+
previewBaseUrl: previewBaseUrl ?? regionConfig.previewBaseUrl,
|
|
149
|
+
authDomain: authDomain ?? regionConfig.authDomain,
|
|
150
|
+
authClientId: authClientId ?? regionConfig.authClientId,
|
|
115
151
|
applicationEnvironment: applicationEnvironment ?? "production",
|
|
116
152
|
rollbarAccessToken:
|
|
117
153
|
rollbarAccessToken ?? "5c6028038d844bf1835a0f4db5f55d9e",
|