@lobehub/edge-contract 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +19 -2
- package/dist/acquisition-context.d.ts +12 -0
- package/dist/acquisition-context.js +175 -0
- package/dist/landing-locales.d.ts +4 -0
- package/dist/landing-locales.js +22 -0
- package/dist/last-workspace-cookie.d.ts +7 -0
- package/dist/last-workspace-cookie.js +30 -0
- package/dist/request-locale.d.ts +13 -0
- package/dist/request-locale.js +97 -0
- package/dist/seo-topics.d.ts +261 -0
- package/dist/seo-topics.js +269 -0
- package/fixtures/acquisition-context.json +257 -0
- package/fixtures/last-workspace-cookie.json +141 -0
- package/fixtures/request-locale.json +262 -0
- package/package.json +49 -3
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
{
|
|
2
|
+
"authority": "lobe-chat@0f9d2f1e41 packages/locales/src/requestLocale.ts resolveRequestLocale",
|
|
3
|
+
"cases": [
|
|
4
|
+
{
|
|
5
|
+
"expected": "en-US",
|
|
6
|
+
"input": {
|
|
7
|
+
"url": "https://app.lobehub.com/"
|
|
8
|
+
},
|
|
9
|
+
"name": "nothing to go on"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"expected": "ja-JP",
|
|
13
|
+
"input": {
|
|
14
|
+
"url": "https://app.lobehub.com/?hl=ja-JP"
|
|
15
|
+
},
|
|
16
|
+
"name": "hl exact"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"expected": "zh-CN",
|
|
20
|
+
"input": {
|
|
21
|
+
"url": "https://app.lobehub.com/?hl=zh-cn"
|
|
22
|
+
},
|
|
23
|
+
"name": "hl lower-case"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"expected": "ja-JP",
|
|
27
|
+
"input": {
|
|
28
|
+
"url": "https://app.lobehub.com/?hl=ja"
|
|
29
|
+
},
|
|
30
|
+
"name": "hl language only"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"expected": "en-US",
|
|
34
|
+
"input": {
|
|
35
|
+
"url": "https://app.lobehub.com/?hl=xx-YY"
|
|
36
|
+
},
|
|
37
|
+
"name": "hl unsupported"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"expected": "zh-CN",
|
|
41
|
+
"input": {
|
|
42
|
+
"headers": {
|
|
43
|
+
"accept-language": "zh-CN"
|
|
44
|
+
},
|
|
45
|
+
"url": "https://app.lobehub.com/?hl=auto"
|
|
46
|
+
},
|
|
47
|
+
"name": "hl auto defers to the browser"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"expected": "ko-KR",
|
|
51
|
+
"input": {
|
|
52
|
+
"headers": {
|
|
53
|
+
"cookie": "LOBE_LOCALE=ko-KR"
|
|
54
|
+
},
|
|
55
|
+
"url": "https://app.lobehub.com/"
|
|
56
|
+
},
|
|
57
|
+
"name": "cookie"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"expected": "de-DE",
|
|
61
|
+
"input": {
|
|
62
|
+
"headers": {
|
|
63
|
+
"cookie": "a=1; LOBE_LOCALE=de-DE; b=2"
|
|
64
|
+
},
|
|
65
|
+
"url": "https://app.lobehub.com/"
|
|
66
|
+
},
|
|
67
|
+
"name": "cookie among others"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"expected": "en-US",
|
|
71
|
+
"input": {
|
|
72
|
+
"headers": {
|
|
73
|
+
"cookie": "LOBE_LOCALE=%E0%A4%A"
|
|
74
|
+
},
|
|
75
|
+
"url": "https://app.lobehub.com/"
|
|
76
|
+
},
|
|
77
|
+
"name": "cookie malformed escape"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"expected": "fr-FR",
|
|
81
|
+
"input": {
|
|
82
|
+
"headers": {
|
|
83
|
+
"accept-language": "fr",
|
|
84
|
+
"cookie": "LOBE_LOCALE=auto"
|
|
85
|
+
},
|
|
86
|
+
"url": "https://app.lobehub.com/"
|
|
87
|
+
},
|
|
88
|
+
"name": "cookie auto defers to the browser"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"expected": "ja-JP",
|
|
92
|
+
"input": {
|
|
93
|
+
"headers": {
|
|
94
|
+
"cookie": "LOBE_LOCALE=ko-KR"
|
|
95
|
+
},
|
|
96
|
+
"url": "https://app.lobehub.com/?hl=ja-JP"
|
|
97
|
+
},
|
|
98
|
+
"name": "hl beats cookie"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"expected": "zh-CN",
|
|
102
|
+
"input": {
|
|
103
|
+
"headers": {
|
|
104
|
+
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8"
|
|
105
|
+
},
|
|
106
|
+
"url": "https://app.lobehub.com/"
|
|
107
|
+
},
|
|
108
|
+
"name": "accept zh-CN first"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"expected": "de-DE",
|
|
112
|
+
"input": {
|
|
113
|
+
"headers": {
|
|
114
|
+
"accept-language": "fr;q=0.5, de;q=0.9"
|
|
115
|
+
},
|
|
116
|
+
"url": "https://app.lobehub.com/"
|
|
117
|
+
},
|
|
118
|
+
"name": "accept weighted"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"expected": "ja-JP",
|
|
122
|
+
"input": {
|
|
123
|
+
"headers": {
|
|
124
|
+
"accept-language": "ja"
|
|
125
|
+
},
|
|
126
|
+
"url": "https://app.lobehub.com/"
|
|
127
|
+
},
|
|
128
|
+
"name": "accept language only"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"expected": "zh-TW",
|
|
132
|
+
"input": {
|
|
133
|
+
"headers": {
|
|
134
|
+
"accept-language": "zh-Hant"
|
|
135
|
+
},
|
|
136
|
+
"url": "https://app.lobehub.com/"
|
|
137
|
+
},
|
|
138
|
+
"name": "accept zh-Hant"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"expected": "zh-CN",
|
|
142
|
+
"input": {
|
|
143
|
+
"headers": {
|
|
144
|
+
"accept-language": "zh-Hans-CN"
|
|
145
|
+
},
|
|
146
|
+
"url": "https://app.lobehub.com/"
|
|
147
|
+
},
|
|
148
|
+
"name": "accept zh-Hans"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"expected": "zh-TW",
|
|
152
|
+
"input": {
|
|
153
|
+
"headers": {
|
|
154
|
+
"accept-language": "zh-TW"
|
|
155
|
+
},
|
|
156
|
+
"url": "https://app.lobehub.com/"
|
|
157
|
+
},
|
|
158
|
+
"name": "accept zh-TW"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"expected": "pt-BR",
|
|
162
|
+
"input": {
|
|
163
|
+
"headers": {
|
|
164
|
+
"accept-language": "pt"
|
|
165
|
+
},
|
|
166
|
+
"url": "https://app.lobehub.com/"
|
|
167
|
+
},
|
|
168
|
+
"name": "accept pt"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"expected": "en-US",
|
|
172
|
+
"input": {
|
|
173
|
+
"headers": {
|
|
174
|
+
"accept-language": "es-419"
|
|
175
|
+
},
|
|
176
|
+
"url": "https://app.lobehub.com/"
|
|
177
|
+
},
|
|
178
|
+
"name": "accept es-419"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"expected": "ar",
|
|
182
|
+
"input": {
|
|
183
|
+
"headers": {
|
|
184
|
+
"accept-language": "ar-EG"
|
|
185
|
+
},
|
|
186
|
+
"url": "https://app.lobehub.com/"
|
|
187
|
+
},
|
|
188
|
+
"name": "accept ar-EG"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"expected": "fa-IR",
|
|
192
|
+
"input": {
|
|
193
|
+
"headers": {
|
|
194
|
+
"accept-language": "fa"
|
|
195
|
+
},
|
|
196
|
+
"url": "https://app.lobehub.com/"
|
|
197
|
+
},
|
|
198
|
+
"name": "accept fa"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"expected": "zh-CN",
|
|
202
|
+
"input": {
|
|
203
|
+
"headers": {
|
|
204
|
+
"accept-language": "cn"
|
|
205
|
+
},
|
|
206
|
+
"url": "https://app.lobehub.com/"
|
|
207
|
+
},
|
|
208
|
+
"name": "accept legacy cn"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"expected": "en-US",
|
|
212
|
+
"input": {
|
|
213
|
+
"headers": {
|
|
214
|
+
"accept-language": "*"
|
|
215
|
+
},
|
|
216
|
+
"url": "https://app.lobehub.com/"
|
|
217
|
+
},
|
|
218
|
+
"name": "accept wildcard"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"expected": "en-US",
|
|
222
|
+
"input": {
|
|
223
|
+
"headers": {
|
|
224
|
+
"accept-language": "xx, en-GB;q=0.8"
|
|
225
|
+
},
|
|
226
|
+
"url": "https://app.lobehub.com/"
|
|
227
|
+
},
|
|
228
|
+
"name": "accept unsupported then en"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"expected": "en-US",
|
|
232
|
+
"input": {
|
|
233
|
+
"headers": {
|
|
234
|
+
"accept-language": "en-us"
|
|
235
|
+
},
|
|
236
|
+
"url": "https://app.lobehub.com/"
|
|
237
|
+
},
|
|
238
|
+
"name": "accept lower-case region"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"defaultLocale": "en-US",
|
|
242
|
+
"tags": [
|
|
243
|
+
"ar",
|
|
244
|
+
"bg-BG",
|
|
245
|
+
"de-DE",
|
|
246
|
+
"en-US",
|
|
247
|
+
"es-ES",
|
|
248
|
+
"fr-FR",
|
|
249
|
+
"ja-JP",
|
|
250
|
+
"ko-KR",
|
|
251
|
+
"pt-BR",
|
|
252
|
+
"ru-RU",
|
|
253
|
+
"tr-TR",
|
|
254
|
+
"zh-CN",
|
|
255
|
+
"zh-TW",
|
|
256
|
+
"vi-VN",
|
|
257
|
+
"fa-IR",
|
|
258
|
+
"it-IT",
|
|
259
|
+
"pl-PL",
|
|
260
|
+
"nl-NL"
|
|
261
|
+
]
|
|
262
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/edge-contract",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "One implementation of the edge logic shared by the LobeHub gateway, landing, cloud and lobe-chat, plus golden fixtures every copy is tested against.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lobehub/edge-contract.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
"./landing-locales": {
|
|
14
|
+
"types": "./dist/landing-locales.d.ts",
|
|
15
|
+
"default": "./dist/landing-locales.js"
|
|
16
|
+
},
|
|
17
|
+
"./seo-topics": {
|
|
18
|
+
"types": "./dist/seo-topics.d.ts",
|
|
19
|
+
"default": "./dist/seo-topics.js"
|
|
20
|
+
},
|
|
21
|
+
"./request-locale": {
|
|
22
|
+
"types": "./dist/request-locale.d.ts",
|
|
23
|
+
"default": "./dist/request-locale.js"
|
|
24
|
+
},
|
|
25
|
+
"./last-workspace-cookie": {
|
|
26
|
+
"types": "./dist/last-workspace-cookie.d.ts",
|
|
27
|
+
"default": "./dist/last-workspace-cookie.js"
|
|
28
|
+
},
|
|
29
|
+
"./acquisition-context": {
|
|
30
|
+
"types": "./dist/acquisition-context.d.ts",
|
|
31
|
+
"default": "./dist/acquisition-context.js"
|
|
32
|
+
},
|
|
33
|
+
"./fixtures/*": "./fixtures/*"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"fixtures"
|
|
38
|
+
],
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^26.6.6",
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"vitest": "3.2.7"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -p tsconfig.build.json",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
}
|
|
6
52
|
}
|