@wopr-network/platform-ui-core 1.1.7 → 1.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/package.json +1 -1
- package/src/__tests__/auto-topup-card.test.tsx +10 -2
- package/src/__tests__/onboarding-store-urls.test.ts +24 -0
- package/src/__tests__/provider-docs.test.ts +35 -0
- package/src/__tests__/suspension-banner.test.tsx +20 -4
- package/src/config/provider-docs.ts +12 -1
- package/src/lib/onboarding-store.ts +6 -5
package/package.json
CHANGED
|
@@ -35,6 +35,14 @@ vi.mock("better-auth/react", () => ({
|
|
|
35
35
|
}),
|
|
36
36
|
}));
|
|
37
37
|
|
|
38
|
+
/** Return an ISO-8601 UTC date string N days from now, truncated to midnight. */
|
|
39
|
+
function daysFromNow(n: number): string {
|
|
40
|
+
const d = new Date();
|
|
41
|
+
d.setUTCDate(d.getUTCDate() + n);
|
|
42
|
+
d.setUTCHours(0, 0, 0, 0);
|
|
43
|
+
return d.toISOString();
|
|
44
|
+
}
|
|
45
|
+
|
|
38
46
|
const MOCK_SETTINGS: AutoTopupSettings = {
|
|
39
47
|
usageBased: {
|
|
40
48
|
enabled: false,
|
|
@@ -61,7 +69,7 @@ const MOCK_SETTINGS_ENABLED: AutoTopupSettings = {
|
|
|
61
69
|
enabled: true,
|
|
62
70
|
amountCents: 2000,
|
|
63
71
|
interval: "weekly",
|
|
64
|
-
nextChargeDate:
|
|
72
|
+
nextChargeDate: daysFromNow(7),
|
|
65
73
|
},
|
|
66
74
|
paymentMethodLast4: "4242",
|
|
67
75
|
paymentMethodBrand: "Visa",
|
|
@@ -89,7 +97,7 @@ const MOCK_SETTINGS_MONTHLY: AutoTopupSettings = {
|
|
|
89
97
|
enabled: true,
|
|
90
98
|
amountCents: 2000,
|
|
91
99
|
interval: "monthly",
|
|
92
|
-
nextChargeDate:
|
|
100
|
+
nextChargeDate: daysFromNow(14),
|
|
93
101
|
},
|
|
94
102
|
};
|
|
95
103
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { PROVIDER_DOC_URLS } from "../config/provider-docs";
|
|
3
|
+
|
|
4
|
+
describe("AI_PROVIDERS keyHelpUrl consolidation", () => {
|
|
5
|
+
it("all keyHelpUrl values match PROVIDER_DOC_URLS entries", async () => {
|
|
6
|
+
const { AI_PROVIDERS } = await import("../lib/onboarding-store");
|
|
7
|
+
|
|
8
|
+
const urlToProviderDocKey: Record<string, string> = {
|
|
9
|
+
[PROVIDER_DOC_URLS.anthropic]: "anthropic",
|
|
10
|
+
[PROVIDER_DOC_URLS.openai]: "openai",
|
|
11
|
+
[PROVIDER_DOC_URLS.google]: "google",
|
|
12
|
+
[PROVIDER_DOC_URLS.xai]: "xai",
|
|
13
|
+
[PROVIDER_DOC_URLS.local]: "local",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
for (const provider of AI_PROVIDERS) {
|
|
17
|
+
expect(
|
|
18
|
+
provider.keyHelpUrl in urlToProviderDocKey ||
|
|
19
|
+
Object.values(PROVIDER_DOC_URLS).includes(provider.keyHelpUrl as never),
|
|
20
|
+
`${provider.id} keyHelpUrl "${provider.keyHelpUrl}" should come from PROVIDER_DOC_URLS`,
|
|
21
|
+
).toBe(true);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { PROVIDER_DOC_URLS } from "../config/provider-docs";
|
|
3
|
+
|
|
4
|
+
describe("PROVIDER_DOC_URLS", () => {
|
|
5
|
+
it("contains all expected provider keys", () => {
|
|
6
|
+
const expectedKeys = [
|
|
7
|
+
"openai",
|
|
8
|
+
"openrouter",
|
|
9
|
+
"anthropic",
|
|
10
|
+
"replicate",
|
|
11
|
+
"elevenlabs",
|
|
12
|
+
"elevenlabsHome",
|
|
13
|
+
"deepgram",
|
|
14
|
+
"discord",
|
|
15
|
+
"slack",
|
|
16
|
+
"telegram",
|
|
17
|
+
"whatsapp",
|
|
18
|
+
"msTeams",
|
|
19
|
+
"moonshot",
|
|
20
|
+
"github",
|
|
21
|
+
"google",
|
|
22
|
+
"xai",
|
|
23
|
+
"local",
|
|
24
|
+
];
|
|
25
|
+
for (const key of expectedKeys) {
|
|
26
|
+
expect(PROVIDER_DOC_URLS).toHaveProperty(key);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("all values are valid https or http URLs", () => {
|
|
31
|
+
for (const [key, url] of Object.entries(PROVIDER_DOC_URLS)) {
|
|
32
|
+
expect(url, `${key} should be a valid URL`).toMatch(/^https?:\/\//);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -19,6 +19,22 @@ vi.mock("better-auth/react", () => ({
|
|
|
19
19
|
}),
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
+
/** Return an ISO-8601 UTC date string N days from now, truncated to midnight. */
|
|
23
|
+
function daysFromNow(n: number): string {
|
|
24
|
+
const d = new Date();
|
|
25
|
+
d.setUTCDate(d.getUTCDate() + n);
|
|
26
|
+
d.setUTCHours(0, 0, 0, 0);
|
|
27
|
+
return d.toISOString();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Return an ISO-8601 UTC date string N days from now, at end-of-day. */
|
|
31
|
+
function endOfDayFromNow(n: number): string {
|
|
32
|
+
const d = new Date();
|
|
33
|
+
d.setUTCDate(d.getUTCDate() + n);
|
|
34
|
+
d.setUTCHours(23, 59, 59, 0);
|
|
35
|
+
return d.toISOString();
|
|
36
|
+
}
|
|
37
|
+
|
|
22
38
|
const MOCK_BALANCE: CreditBalance = {
|
|
23
39
|
balance: 0.5,
|
|
24
40
|
dailyBurn: 0.33,
|
|
@@ -32,8 +48,8 @@ vi.mock("@/lib/api", async (importOriginal) => {
|
|
|
32
48
|
getCreditBalance: vi.fn().mockResolvedValue(MOCK_BALANCE),
|
|
33
49
|
getAccountStatus: vi.fn().mockResolvedValue(null),
|
|
34
50
|
getBillingUsageSummary: vi.fn().mockResolvedValue({
|
|
35
|
-
periodStart:
|
|
36
|
-
periodEnd:
|
|
51
|
+
periodStart: daysFromNow(-30),
|
|
52
|
+
periodEnd: endOfDayFromNow(0),
|
|
37
53
|
totalSpend: 30,
|
|
38
54
|
includedCredit: 50,
|
|
39
55
|
amountDue: 0,
|
|
@@ -105,8 +121,8 @@ describe("SuspensionBanner", () => {
|
|
|
105
121
|
runway: 5,
|
|
106
122
|
});
|
|
107
123
|
vi.mocked(api.getBillingUsageSummary).mockResolvedValueOnce({
|
|
108
|
-
periodStart:
|
|
109
|
-
periodEnd:
|
|
124
|
+
periodStart: daysFromNow(-30),
|
|
125
|
+
periodEnd: endOfDayFromNow(0),
|
|
110
126
|
totalSpend: 120,
|
|
111
127
|
includedCredit: 50,
|
|
112
128
|
amountDue: 70,
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* External provider documentation URLs used in onboarding config fields.
|
|
3
|
+
*
|
|
4
|
+
* These are intentional external links to provider API key dashboards —
|
|
5
|
+
* no secret material. They live in code (not fetched from the API) because
|
|
6
|
+
* major provider dashboard URLs change extremely rarely (years, not weeks).
|
|
7
|
+
* The cost of an API round-trip, loading state, and DB migration is not
|
|
8
|
+
* justified. If a URL changes, update this map and publish a new version.
|
|
9
|
+
*/
|
|
2
10
|
export const PROVIDER_DOC_URLS = {
|
|
3
11
|
openai: "https://platform.openai.com/api-keys",
|
|
4
12
|
openrouter: "https://openrouter.ai/keys",
|
|
@@ -14,4 +22,7 @@ export const PROVIDER_DOC_URLS = {
|
|
|
14
22
|
msTeams: "https://dev.teams.microsoft.com/",
|
|
15
23
|
moonshot: "https://platform.moonshot.cn/",
|
|
16
24
|
github: "https://github.com/settings/tokens",
|
|
25
|
+
google: "https://aistudio.google.com/apikey",
|
|
26
|
+
xai: "https://console.x.ai/",
|
|
27
|
+
local: "https://ollama.com/download",
|
|
17
28
|
} as const;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Client-side onboarding state with localStorage persistence.
|
|
3
3
|
* Enables resume from last completed step.
|
|
4
4
|
*/
|
|
5
|
+
import { PROVIDER_DOC_URLS } from "../config/provider-docs";
|
|
5
6
|
import { storageKey } from "./brand-config";
|
|
6
7
|
|
|
7
8
|
export interface ProviderConfig {
|
|
@@ -137,7 +138,7 @@ export const AI_PROVIDERS = [
|
|
|
137
138
|
recommended: true,
|
|
138
139
|
keyPattern: "^sk-ant-[a-zA-Z0-9_-]+$",
|
|
139
140
|
keyPlaceholder: "sk-ant-api03-...",
|
|
140
|
-
keyHelpUrl:
|
|
141
|
+
keyHelpUrl: PROVIDER_DOC_URLS.anthropic,
|
|
141
142
|
},
|
|
142
143
|
{
|
|
143
144
|
id: "openai",
|
|
@@ -148,7 +149,7 @@ export const AI_PROVIDERS = [
|
|
|
148
149
|
recommended: false,
|
|
149
150
|
keyPattern: "^sk-[a-zA-Z0-9_-]+$",
|
|
150
151
|
keyPlaceholder: "sk-proj-...",
|
|
151
|
-
keyHelpUrl:
|
|
152
|
+
keyHelpUrl: PROVIDER_DOC_URLS.openai,
|
|
152
153
|
},
|
|
153
154
|
{
|
|
154
155
|
id: "google",
|
|
@@ -159,7 +160,7 @@ export const AI_PROVIDERS = [
|
|
|
159
160
|
recommended: false,
|
|
160
161
|
keyPattern: "^AIza[a-zA-Z0-9_-]+$",
|
|
161
162
|
keyPlaceholder: "AIzaSy...",
|
|
162
|
-
keyHelpUrl:
|
|
163
|
+
keyHelpUrl: PROVIDER_DOC_URLS.google,
|
|
163
164
|
},
|
|
164
165
|
{
|
|
165
166
|
id: "xai",
|
|
@@ -170,7 +171,7 @@ export const AI_PROVIDERS = [
|
|
|
170
171
|
recommended: false,
|
|
171
172
|
keyPattern: "^xai-[a-zA-Z0-9_-]+$",
|
|
172
173
|
keyPlaceholder: "xai-...",
|
|
173
|
-
keyHelpUrl:
|
|
174
|
+
keyHelpUrl: PROVIDER_DOC_URLS.xai,
|
|
174
175
|
},
|
|
175
176
|
{
|
|
176
177
|
id: "local",
|
|
@@ -181,7 +182,7 @@ export const AI_PROVIDERS = [
|
|
|
181
182
|
recommended: false,
|
|
182
183
|
keyPattern: ".*",
|
|
183
184
|
keyPlaceholder: "http://localhost:11434",
|
|
184
|
-
keyHelpUrl:
|
|
185
|
+
keyHelpUrl: PROVIDER_DOC_URLS.local,
|
|
185
186
|
},
|
|
186
187
|
] as const;
|
|
187
188
|
|