@warlock.js/core 5.12.0 → 5.13.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/CHANGELOG.md +73 -54
- package/esm/database/utils.d.mts +5 -1
- package/esm/database/utils.d.mts.map +1 -1
- package/esm/database/utils.mjs +7 -3
- package/esm/database/utils.mjs.map +1 -1
- package/esm/dev-server/file-event-handler.mjs +23 -5
- package/esm/dev-server/file-event-handler.mjs.map +1 -1
- package/esm/dev-server/translation-type-generator.mjs +28 -0
- package/esm/dev-server/translation-type-generator.mjs.map +1 -0
- package/esm/dev-server/tsconfig-manager.mjs +1 -0
- package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
- package/esm/dev-server/type-generator.mjs +41 -5
- package/esm/dev-server/type-generator.mjs.map +1 -1
- package/esm/encryption/index.mjs +1 -1
- package/esm/generations/features/auth-google.feature.mjs +18 -0
- package/esm/generations/features/auth-google.feature.mjs.map +1 -0
- package/esm/generations/features/auth-passkeys.feature.mjs +19 -0
- package/esm/generations/features/auth-passkeys.feature.mjs.map +1 -0
- package/esm/generations/features/index.mjs +6 -0
- package/esm/generations/features/index.mjs.map +1 -1
- package/esm/generations/features/queue.feature.mjs +67 -0
- package/esm/generations/features/queue.feature.mjs.map +1 -0
- package/esm/index.mjs +1 -1
- package/llms-full.txt +24 -21
- package/package.json +11 -12
- package/skills/use-localization/SKILL.md +24 -21
package/package.json
CHANGED
|
@@ -25,13 +25,12 @@
|
|
|
25
25
|
"@mongez/slug": "^1.0.7",
|
|
26
26
|
"@mongez/supportive-is": "^2.1.4",
|
|
27
27
|
"@mongez/time-wizard": "^1.0.6",
|
|
28
|
-
"@warlock.js/
|
|
29
|
-
"@warlock.js/
|
|
30
|
-
"@warlock.js/
|
|
31
|
-
"@warlock.js/
|
|
32
|
-
"@warlock.js/
|
|
33
|
-
"@warlock.js/
|
|
34
|
-
"@warlock.js/fs": "5.12.0",
|
|
28
|
+
"@warlock.js/cache": "5.13.0",
|
|
29
|
+
"@warlock.js/cascade": "5.13.0",
|
|
30
|
+
"@warlock.js/context": "5.13.0",
|
|
31
|
+
"@warlock.js/logger": "5.13.0",
|
|
32
|
+
"@warlock.js/seal": "5.13.0",
|
|
33
|
+
"@warlock.js/fs": "5.13.0",
|
|
35
34
|
"chokidar": "^5.0.0",
|
|
36
35
|
"dayjs": "^1.11.19",
|
|
37
36
|
"es-module-lexer": "^2.0.0",
|
|
@@ -57,10 +56,10 @@
|
|
|
57
56
|
"react": "^19.2.3",
|
|
58
57
|
"react-dom": "^19.2.3",
|
|
59
58
|
"@react-email/render": "^2.0.5",
|
|
60
|
-
"@warlock.js/herald": "5.
|
|
61
|
-
"@warlock.js/ai": "5.
|
|
62
|
-
"@warlock.js/access": "5.
|
|
63
|
-
"@warlock.js/notifications": "5.
|
|
59
|
+
"@warlock.js/herald": "5.13.0",
|
|
60
|
+
"@warlock.js/ai": "5.13.0",
|
|
61
|
+
"@warlock.js/access": "5.13.0",
|
|
62
|
+
"@warlock.js/notifications": "5.13.0"
|
|
64
63
|
},
|
|
65
64
|
"peerDependenciesMeta": {
|
|
66
65
|
"sharp": {
|
|
@@ -123,7 +122,7 @@
|
|
|
123
122
|
],
|
|
124
123
|
"author": "hassanzohdy",
|
|
125
124
|
"license": "MIT",
|
|
126
|
-
"version": "5.
|
|
125
|
+
"version": "5.13.0",
|
|
127
126
|
"type": "module",
|
|
128
127
|
"main": "./esm/index.mjs",
|
|
129
128
|
"module": "./esm/index.mjs",
|
|
@@ -20,7 +20,7 @@ import { groupedTranslations } from "@mongez/localization";
|
|
|
20
20
|
|
|
21
21
|
groupedTranslations("products", {
|
|
22
22
|
notFound: { en: "Product not found", ar: "المنتج غير موجود" },
|
|
23
|
-
created:
|
|
23
|
+
created: { en: "Product created", ar: "تم إنشاء المنتج" },
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// 2. Look up in a controller / service
|
|
@@ -45,11 +45,11 @@ Every module owns its translation namespace under `src/app/<module>/utils/locale
|
|
|
45
45
|
import { groupedTranslations } from "@mongez/localization";
|
|
46
46
|
|
|
47
47
|
groupedTranslations("products", {
|
|
48
|
-
notFound:
|
|
49
|
-
outOfStock:
|
|
50
|
-
created:
|
|
51
|
-
updated:
|
|
52
|
-
deleted:
|
|
48
|
+
notFound: { en: "Product not found", ar: "المنتج غير موجود" },
|
|
49
|
+
outOfStock: { en: "Product out of stock", ar: "المنتج غير متوفر" },
|
|
50
|
+
created: { en: "Product created", ar: "تم إنشاء المنتج" },
|
|
51
|
+
updated: { en: "Product updated", ar: "تم تحديث المنتج" },
|
|
52
|
+
deleted: { en: "Product deleted", ar: "تم حذف المنتج" },
|
|
53
53
|
});
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -96,6 +96,10 @@ request.trans("products.notFound");
|
|
|
96
96
|
|
|
97
97
|
All three lookups go through `@mongez/localization`'s `trans()` under the hood, with the locale pulled from the request context (or the global default).
|
|
98
98
|
|
|
99
|
+
### Web `useTrans()` key checking
|
|
100
|
+
|
|
101
|
+
When an app uses `@warlock.js/web`, `warlock dev` writes `.warlock/typings/translations.d.ts` from literal `groupedTranslations("group", { key: ... })` registrations. It augments web's `TranslationKeyRegistry`, so `useTrans()("products.notFound")` is checked against registered keys and a typo fails TypeScript. Before the generated file exists, `useTrans()` accepts `string` for a non-breaking first boot. Dynamic groups/keys and placeholders are not inferred.
|
|
102
|
+
|
|
99
103
|
### Locale on a specific lookup
|
|
100
104
|
|
|
101
105
|
```ts
|
|
@@ -123,7 +127,7 @@ Configure the default:
|
|
|
123
127
|
|
|
124
128
|
```ts title="src/config/app.ts"
|
|
125
129
|
export default {
|
|
126
|
-
localeCode: "en",
|
|
130
|
+
localeCode: "en", // app-wide default
|
|
127
131
|
// ...
|
|
128
132
|
};
|
|
129
133
|
```
|
|
@@ -142,20 +146,19 @@ When a column stores per-locale values as an array:
|
|
|
142
146
|
|
|
143
147
|
```ts
|
|
144
148
|
// Schema (Seal):
|
|
145
|
-
name_translations: v.array(
|
|
149
|
+
name_translations: (v.array(
|
|
146
150
|
v.object({
|
|
147
|
-
localeCode: v.string(),
|
|
151
|
+
localeCode: v.string(), // "en", "ar", ...
|
|
148
152
|
value: v.string(),
|
|
149
|
-
})
|
|
153
|
+
}),
|
|
150
154
|
),
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
155
|
+
// Stored row (DB):
|
|
156
|
+
{
|
|
157
|
+
name_translations: [
|
|
158
|
+
{ localeCode: "en", value: "Hello World" },
|
|
159
|
+
{ localeCode: "ar", value: "مرحبا" },
|
|
160
|
+
],
|
|
161
|
+
});
|
|
159
162
|
```
|
|
160
163
|
|
|
161
164
|
Pick the right one for the current request:
|
|
@@ -179,12 +182,12 @@ getLocalized(
|
|
|
179
182
|
```
|
|
180
183
|
|
|
181
184
|
- **`values`** — the localized-array column.
|
|
182
|
-
- **`localeCode`**
|
|
183
|
-
- **`key`**
|
|
185
|
+
- **`localeCode`** _(optional)_ — pin to a specific locale. Defaults to the current request's locale (reads via `useRequestStore()`).
|
|
186
|
+
- **`key`** _(default `"value"`)_ — which property of the matched entry to return. Use a different key if your localized objects store the value under a different name.
|
|
184
187
|
|
|
185
188
|
```ts
|
|
186
189
|
const slug = getLocalized(product.get("slug_translations"), undefined, "value");
|
|
187
|
-
const tagline = getLocalized(product.get("name_translations"), "fr");
|
|
190
|
+
const tagline = getLocalized(product.get("name_translations"), "fr"); // force French
|
|
188
191
|
```
|
|
189
192
|
|
|
190
193
|
### Use inside a resource for clean per-locale responses
|