@inlang/sdk 0.34.4 → 0.34.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.
@@ -0,0 +1,411 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ /**
3
+ * Follows the IETF BCP 47 language tag schema.
4
+ *
5
+ * @see https://www.ietf.org/rfc/bcp/bcp47.txt
6
+ * @see https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
7
+ */
8
+ export type LanguageTag = Static<typeof LanguageTag>;
9
+ /**
10
+ * Follows the IETF BCP 47 language tag schema with modifications.
11
+ * @see REAMDE.md file for more information on the validation.
12
+ */
13
+ export declare const pattern = "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?))(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*))$";
14
+ export declare const LanguageTag: import("@sinclair/typebox").TString;
15
+ export type Literal = Static<typeof Literal>;
16
+ export declare const Literal: import("@sinclair/typebox").TObject<{
17
+ type: import("@sinclair/typebox").TLiteral<"literal">;
18
+ value: import("@sinclair/typebox").TString;
19
+ }>;
20
+ /**
21
+ * A (text) element that is translatable and rendered to the UI.
22
+ */
23
+ export type Text = Static<typeof Text>;
24
+ export declare const Text: import("@sinclair/typebox").TObject<{
25
+ type: import("@sinclair/typebox").TLiteral<"text">;
26
+ value: import("@sinclair/typebox").TString;
27
+ }>;
28
+ export type VariableReference = Static<typeof VariableReference>;
29
+ export declare const VariableReference: import("@sinclair/typebox").TObject<{
30
+ type: import("@sinclair/typebox").TLiteral<"variable">;
31
+ name: import("@sinclair/typebox").TString;
32
+ }>;
33
+ export type Option = Static<typeof Option>;
34
+ export declare const Option: import("@sinclair/typebox").TObject<{
35
+ name: import("@sinclair/typebox").TString;
36
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
37
+ type: import("@sinclair/typebox").TLiteral<"literal">;
38
+ value: import("@sinclair/typebox").TString;
39
+ }>, import("@sinclair/typebox").TObject<{
40
+ type: import("@sinclair/typebox").TLiteral<"variable">;
41
+ name: import("@sinclair/typebox").TString;
42
+ }>]>;
43
+ }>;
44
+ export type FunctionAnnotation = Static<typeof FunctionAnnotation>;
45
+ export declare const FunctionAnnotation: import("@sinclair/typebox").TObject<{
46
+ type: import("@sinclair/typebox").TLiteral<"function">;
47
+ name: import("@sinclair/typebox").TString;
48
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
49
+ name: import("@sinclair/typebox").TString;
50
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
51
+ type: import("@sinclair/typebox").TLiteral<"literal">;
52
+ value: import("@sinclair/typebox").TString;
53
+ }>, import("@sinclair/typebox").TObject<{
54
+ type: import("@sinclair/typebox").TLiteral<"variable">;
55
+ name: import("@sinclair/typebox").TString;
56
+ }>]>;
57
+ }>>;
58
+ }>;
59
+ /**
60
+ * An expression is a reference to a variable or a function.
61
+ *
62
+ * Think of expressions as elements that are rendered to a
63
+ * text value during runtime.
64
+ */
65
+ export type Expression = Static<typeof Expression>;
66
+ export declare const Expression: import("@sinclair/typebox").TObject<{
67
+ type: import("@sinclair/typebox").TLiteral<"expression">;
68
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
69
+ type: import("@sinclair/typebox").TLiteral<"literal">;
70
+ value: import("@sinclair/typebox").TString;
71
+ }>, import("@sinclair/typebox").TObject<{
72
+ type: import("@sinclair/typebox").TLiteral<"variable">;
73
+ name: import("@sinclair/typebox").TString;
74
+ }>]>;
75
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
76
+ type: import("@sinclair/typebox").TLiteral<"function">;
77
+ name: import("@sinclair/typebox").TString;
78
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
79
+ name: import("@sinclair/typebox").TString;
80
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
81
+ type: import("@sinclair/typebox").TLiteral<"literal">;
82
+ value: import("@sinclair/typebox").TString;
83
+ }>, import("@sinclair/typebox").TObject<{
84
+ type: import("@sinclair/typebox").TLiteral<"variable">;
85
+ name: import("@sinclair/typebox").TString;
86
+ }>]>;
87
+ }>>;
88
+ }>>;
89
+ }>;
90
+ /**
91
+ * A pattern is a sequence of elements that comprise
92
+ * a message that is rendered to the UI.
93
+ */
94
+ export type Pattern = Static<typeof Pattern>;
95
+ export declare const Pattern: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
96
+ type: import("@sinclair/typebox").TLiteral<"text">;
97
+ value: import("@sinclair/typebox").TString;
98
+ }>, import("@sinclair/typebox").TObject<{
99
+ type: import("@sinclair/typebox").TLiteral<"expression">;
100
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
101
+ type: import("@sinclair/typebox").TLiteral<"literal">;
102
+ value: import("@sinclair/typebox").TString;
103
+ }>, import("@sinclair/typebox").TObject<{
104
+ type: import("@sinclair/typebox").TLiteral<"variable">;
105
+ name: import("@sinclair/typebox").TString;
106
+ }>]>;
107
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
108
+ type: import("@sinclair/typebox").TLiteral<"function">;
109
+ name: import("@sinclair/typebox").TString;
110
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
111
+ name: import("@sinclair/typebox").TString;
112
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
113
+ type: import("@sinclair/typebox").TLiteral<"literal">;
114
+ value: import("@sinclair/typebox").TString;
115
+ }>, import("@sinclair/typebox").TObject<{
116
+ type: import("@sinclair/typebox").TLiteral<"variable">;
117
+ name: import("@sinclair/typebox").TString;
118
+ }>]>;
119
+ }>>;
120
+ }>>;
121
+ }>]>>;
122
+ /**
123
+ * A variant contains a pattern that is rendered to the UI.
124
+ */
125
+ export type Variant = Static<typeof Variant>;
126
+ export declare const Variant: import("@sinclair/typebox").TObject<{
127
+ /**
128
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
129
+ *
130
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
131
+ */
132
+ match: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
133
+ pattern: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
134
+ type: import("@sinclair/typebox").TLiteral<"text">;
135
+ value: import("@sinclair/typebox").TString;
136
+ }>, import("@sinclair/typebox").TObject<{
137
+ type: import("@sinclair/typebox").TLiteral<"expression">;
138
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
139
+ type: import("@sinclair/typebox").TLiteral<"literal">;
140
+ value: import("@sinclair/typebox").TString;
141
+ }>, import("@sinclair/typebox").TObject<{
142
+ type: import("@sinclair/typebox").TLiteral<"variable">;
143
+ name: import("@sinclair/typebox").TString;
144
+ }>]>;
145
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
146
+ type: import("@sinclair/typebox").TLiteral<"function">;
147
+ name: import("@sinclair/typebox").TString;
148
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
149
+ name: import("@sinclair/typebox").TString;
150
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
151
+ type: import("@sinclair/typebox").TLiteral<"literal">;
152
+ value: import("@sinclair/typebox").TString;
153
+ }>, import("@sinclair/typebox").TObject<{
154
+ type: import("@sinclair/typebox").TLiteral<"variable">;
155
+ name: import("@sinclair/typebox").TString;
156
+ }>]>;
157
+ }>>;
158
+ }>>;
159
+ }>]>>;
160
+ }>;
161
+ export type InputDeclaration = Static<typeof InputDeclaration>;
162
+ export declare const InputDeclaration: import("@sinclair/typebox").TObject<{
163
+ type: import("@sinclair/typebox").TLiteral<"input">;
164
+ name: import("@sinclair/typebox").TString;
165
+ value: import("@sinclair/typebox").TObject<{
166
+ type: import("@sinclair/typebox").TLiteral<"expression">;
167
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
168
+ type: import("@sinclair/typebox").TLiteral<"literal">;
169
+ value: import("@sinclair/typebox").TString;
170
+ }>, import("@sinclair/typebox").TObject<{
171
+ type: import("@sinclair/typebox").TLiteral<"variable">;
172
+ name: import("@sinclair/typebox").TString;
173
+ }>]>;
174
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
175
+ type: import("@sinclair/typebox").TLiteral<"function">;
176
+ name: import("@sinclair/typebox").TString;
177
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
178
+ name: import("@sinclair/typebox").TString;
179
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
180
+ type: import("@sinclair/typebox").TLiteral<"literal">;
181
+ value: import("@sinclair/typebox").TString;
182
+ }>, import("@sinclair/typebox").TObject<{
183
+ type: import("@sinclair/typebox").TLiteral<"variable">;
184
+ name: import("@sinclair/typebox").TString;
185
+ }>]>;
186
+ }>>;
187
+ }>>;
188
+ }>;
189
+ }>;
190
+ export type Declaration = Static<typeof Declaration>;
191
+ export declare const Declaration: import("@sinclair/typebox").TObject<{
192
+ type: import("@sinclair/typebox").TLiteral<"input">;
193
+ name: import("@sinclair/typebox").TString;
194
+ value: import("@sinclair/typebox").TObject<{
195
+ type: import("@sinclair/typebox").TLiteral<"expression">;
196
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
197
+ type: import("@sinclair/typebox").TLiteral<"literal">;
198
+ value: import("@sinclair/typebox").TString;
199
+ }>, import("@sinclair/typebox").TObject<{
200
+ type: import("@sinclair/typebox").TLiteral<"variable">;
201
+ name: import("@sinclair/typebox").TString;
202
+ }>]>;
203
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
204
+ type: import("@sinclair/typebox").TLiteral<"function">;
205
+ name: import("@sinclair/typebox").TString;
206
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
207
+ name: import("@sinclair/typebox").TString;
208
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
209
+ type: import("@sinclair/typebox").TLiteral<"literal">;
210
+ value: import("@sinclair/typebox").TString;
211
+ }>, import("@sinclair/typebox").TObject<{
212
+ type: import("@sinclair/typebox").TLiteral<"variable">;
213
+ name: import("@sinclair/typebox").TString;
214
+ }>]>;
215
+ }>>;
216
+ }>>;
217
+ }>;
218
+ }>;
219
+ export type Message = Static<typeof Message>;
220
+ export declare const Message: import("@sinclair/typebox").TObject<{
221
+ locale: import("@sinclair/typebox").TString;
222
+ declarations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
223
+ type: import("@sinclair/typebox").TLiteral<"input">;
224
+ name: import("@sinclair/typebox").TString;
225
+ value: import("@sinclair/typebox").TObject<{
226
+ type: import("@sinclair/typebox").TLiteral<"expression">;
227
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
228
+ type: import("@sinclair/typebox").TLiteral<"literal">;
229
+ value: import("@sinclair/typebox").TString;
230
+ }>, import("@sinclair/typebox").TObject<{
231
+ type: import("@sinclair/typebox").TLiteral<"variable">;
232
+ name: import("@sinclair/typebox").TString;
233
+ }>]>;
234
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
235
+ type: import("@sinclair/typebox").TLiteral<"function">;
236
+ name: import("@sinclair/typebox").TString;
237
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
238
+ name: import("@sinclair/typebox").TString;
239
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
240
+ type: import("@sinclair/typebox").TLiteral<"literal">;
241
+ value: import("@sinclair/typebox").TString;
242
+ }>, import("@sinclair/typebox").TObject<{
243
+ type: import("@sinclair/typebox").TLiteral<"variable">;
244
+ name: import("@sinclair/typebox").TString;
245
+ }>]>;
246
+ }>>;
247
+ }>>;
248
+ }>;
249
+ }>>;
250
+ /**
251
+ * The order in which the selectors are placed determines the precedence of patterns.
252
+ */
253
+ selectors: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
254
+ type: import("@sinclair/typebox").TLiteral<"expression">;
255
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
256
+ type: import("@sinclair/typebox").TLiteral<"literal">;
257
+ value: import("@sinclair/typebox").TString;
258
+ }>, import("@sinclair/typebox").TObject<{
259
+ type: import("@sinclair/typebox").TLiteral<"variable">;
260
+ name: import("@sinclair/typebox").TString;
261
+ }>]>;
262
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
263
+ type: import("@sinclair/typebox").TLiteral<"function">;
264
+ name: import("@sinclair/typebox").TString;
265
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
266
+ name: import("@sinclair/typebox").TString;
267
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
268
+ type: import("@sinclair/typebox").TLiteral<"literal">;
269
+ value: import("@sinclair/typebox").TString;
270
+ }>, import("@sinclair/typebox").TObject<{
271
+ type: import("@sinclair/typebox").TLiteral<"variable">;
272
+ name: import("@sinclair/typebox").TString;
273
+ }>]>;
274
+ }>>;
275
+ }>>;
276
+ }>>;
277
+ variants: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
278
+ /**
279
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
280
+ *
281
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
282
+ */
283
+ match: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
284
+ pattern: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
285
+ type: import("@sinclair/typebox").TLiteral<"text">;
286
+ value: import("@sinclair/typebox").TString;
287
+ }>, import("@sinclair/typebox").TObject<{
288
+ type: import("@sinclair/typebox").TLiteral<"expression">;
289
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
290
+ type: import("@sinclair/typebox").TLiteral<"literal">;
291
+ value: import("@sinclair/typebox").TString;
292
+ }>, import("@sinclair/typebox").TObject<{
293
+ type: import("@sinclair/typebox").TLiteral<"variable">;
294
+ name: import("@sinclair/typebox").TString;
295
+ }>]>;
296
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
297
+ type: import("@sinclair/typebox").TLiteral<"function">;
298
+ name: import("@sinclair/typebox").TString;
299
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
300
+ name: import("@sinclair/typebox").TString;
301
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
302
+ type: import("@sinclair/typebox").TLiteral<"literal">;
303
+ value: import("@sinclair/typebox").TString;
304
+ }>, import("@sinclair/typebox").TObject<{
305
+ type: import("@sinclair/typebox").TLiteral<"variable">;
306
+ name: import("@sinclair/typebox").TString;
307
+ }>]>;
308
+ }>>;
309
+ }>>;
310
+ }>]>>;
311
+ }>>;
312
+ }>;
313
+ export type MessageBundle = Static<typeof MessageBundle>;
314
+ export declare const MessageBundle: import("@sinclair/typebox").TObject<{
315
+ id: import("@sinclair/typebox").TString;
316
+ alias: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
317
+ messages: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
318
+ locale: import("@sinclair/typebox").TString;
319
+ declarations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
320
+ type: import("@sinclair/typebox").TLiteral<"input">;
321
+ name: import("@sinclair/typebox").TString;
322
+ value: import("@sinclair/typebox").TObject<{
323
+ type: import("@sinclair/typebox").TLiteral<"expression">;
324
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
325
+ type: import("@sinclair/typebox").TLiteral<"literal">;
326
+ value: import("@sinclair/typebox").TString;
327
+ }>, import("@sinclair/typebox").TObject<{
328
+ type: import("@sinclair/typebox").TLiteral<"variable">;
329
+ name: import("@sinclair/typebox").TString;
330
+ }>]>;
331
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
332
+ type: import("@sinclair/typebox").TLiteral<"function">;
333
+ name: import("@sinclair/typebox").TString;
334
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
335
+ name: import("@sinclair/typebox").TString;
336
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
337
+ type: import("@sinclair/typebox").TLiteral<"literal">;
338
+ value: import("@sinclair/typebox").TString;
339
+ }>, import("@sinclair/typebox").TObject<{
340
+ type: import("@sinclair/typebox").TLiteral<"variable">;
341
+ name: import("@sinclair/typebox").TString;
342
+ }>]>;
343
+ }>>;
344
+ }>>;
345
+ }>;
346
+ }>>;
347
+ /**
348
+ * The order in which the selectors are placed determines the precedence of patterns.
349
+ */
350
+ selectors: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
351
+ type: import("@sinclair/typebox").TLiteral<"expression">;
352
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
353
+ type: import("@sinclair/typebox").TLiteral<"literal">;
354
+ value: import("@sinclair/typebox").TString;
355
+ }>, import("@sinclair/typebox").TObject<{
356
+ type: import("@sinclair/typebox").TLiteral<"variable">;
357
+ name: import("@sinclair/typebox").TString;
358
+ }>]>;
359
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
360
+ type: import("@sinclair/typebox").TLiteral<"function">;
361
+ name: import("@sinclair/typebox").TString;
362
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
363
+ name: import("@sinclair/typebox").TString;
364
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
365
+ type: import("@sinclair/typebox").TLiteral<"literal">;
366
+ value: import("@sinclair/typebox").TString;
367
+ }>, import("@sinclair/typebox").TObject<{
368
+ type: import("@sinclair/typebox").TLiteral<"variable">;
369
+ name: import("@sinclair/typebox").TString;
370
+ }>]>;
371
+ }>>;
372
+ }>>;
373
+ }>>;
374
+ variants: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
375
+ /**
376
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
377
+ *
378
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
379
+ */
380
+ match: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
381
+ pattern: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
382
+ type: import("@sinclair/typebox").TLiteral<"text">;
383
+ value: import("@sinclair/typebox").TString;
384
+ }>, import("@sinclair/typebox").TObject<{
385
+ type: import("@sinclair/typebox").TLiteral<"expression">;
386
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
387
+ type: import("@sinclair/typebox").TLiteral<"literal">;
388
+ value: import("@sinclair/typebox").TString;
389
+ }>, import("@sinclair/typebox").TObject<{
390
+ type: import("@sinclair/typebox").TLiteral<"variable">;
391
+ name: import("@sinclair/typebox").TString;
392
+ }>]>;
393
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
394
+ type: import("@sinclair/typebox").TLiteral<"function">;
395
+ name: import("@sinclair/typebox").TString;
396
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
397
+ name: import("@sinclair/typebox").TString;
398
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
399
+ type: import("@sinclair/typebox").TLiteral<"literal">;
400
+ value: import("@sinclair/typebox").TString;
401
+ }>, import("@sinclair/typebox").TObject<{
402
+ type: import("@sinclair/typebox").TLiteral<"variable">;
403
+ name: import("@sinclair/typebox").TString;
404
+ }>]>;
405
+ }>>;
406
+ }>>;
407
+ }>]>>;
408
+ }>>;
409
+ }>>;
410
+ }>;
411
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/v2/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AACpD;;;GAGG;AAEH,eAAO,MAAM,OAAO,sbACga,CAAA;AAEpb,eAAO,MAAM,WAAW,qCAItB,CAAA;AAEF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAA;AAC5C,eAAO,MAAM,OAAO;;;EAGlB,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,IAAI,CAAC,CAAA;AACtC,eAAO,MAAM,IAAI;;;EAGf,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAChE,eAAO,MAAM,iBAAiB;;;EAG5B,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,MAAM,CAAC,CAAA;AAC1C,eAAO,MAAM,MAAM;;;;;;;;;EAGjB,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAClE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;EAI7B,CAAA;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA;AAClD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;EAIrB,CAAA;AASF;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAA;AAC5C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;KAA6C,CAAA;AAEjE;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAA;AAC5C,eAAO,MAAM,OAAO;IACnB;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIF,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAC9D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM3B,CAAA;AAgBF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,CAAA;AACpD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAiC,CAAA;AAEzD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,OAAO,CAAC,CAAA;AAC5C,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGnB;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;;QA1CH;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCF,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,aAAa,CAAC,CAAA;AACxD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QARzB;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;YA1CH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDF,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { Type } from "@sinclair/typebox";
2
+ /**
3
+ * Follows the IETF BCP 47 language tag schema with modifications.
4
+ * @see REAMDE.md file for more information on the validation.
5
+ */
6
+ export const pattern = "^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?))(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*))$";
7
+ export const LanguageTag = Type.String({
8
+ pattern: pattern,
9
+ description: "The language tag must be a valid IETF BCP 47 language tag.",
10
+ examples: ["en", "de", "en-US", "zh-Hans", "es-419"],
11
+ });
12
+ export const Literal = Type.Object({
13
+ type: Type.Literal("literal"),
14
+ value: Type.String(),
15
+ });
16
+ export const Text = Type.Object({
17
+ type: Type.Literal("text"),
18
+ value: Type.String(),
19
+ });
20
+ export const VariableReference = Type.Object({
21
+ type: Type.Literal("variable"),
22
+ name: Type.String(),
23
+ });
24
+ export const Option = Type.Object({
25
+ name: Type.String(),
26
+ value: Type.Union([Literal, VariableReference]),
27
+ });
28
+ export const FunctionAnnotation = Type.Object({
29
+ type: Type.Literal("function"),
30
+ name: Type.String(),
31
+ options: Type.Array(Option),
32
+ });
33
+ export const Expression = Type.Object({
34
+ type: Type.Literal("expression"),
35
+ arg: Type.Union([Literal, VariableReference]),
36
+ annotation: Type.Optional(FunctionAnnotation),
37
+ });
38
+ export const Pattern = Type.Array(Type.Union([Text, Expression]));
39
+ export const Variant = Type.Object({
40
+ /**
41
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
42
+ *
43
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
44
+ */
45
+ // a match can always only be string-based because a string is what is rendered to the UI
46
+ match: Type.Array(Type.String()),
47
+ pattern: Pattern,
48
+ });
49
+ export const InputDeclaration = Type.Object({
50
+ type: Type.Literal("input"),
51
+ name: Type.String(),
52
+ //TODO make this generic so that only Variable-Ref Expressions are allowed
53
+ value: Expression,
54
+ });
55
+ export const Declaration = Type.Union([InputDeclaration]);
56
+ export const Message = Type.Object({
57
+ locale: LanguageTag,
58
+ declarations: Type.Array(Declaration),
59
+ /**
60
+ * The order in which the selectors are placed determines the precedence of patterns.
61
+ */
62
+ selectors: Type.Array(Expression),
63
+ variants: Type.Array(Variant),
64
+ });
65
+ export const MessageBundle = Type.Object({
66
+ id: Type.String(),
67
+ alias: Type.Record(Type.String(), Type.String()),
68
+ messages: Type.Array(Message),
69
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
3
  "type": "module",
4
- "version": "0.34.4",
4
+ "version": "0.34.6",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -15,7 +15,8 @@
15
15
  ".": "./dist/index.js",
16
16
  "./test-utilities": "./dist/test-utilities/index.js",
17
17
  "./lint": "./dist/lint/index.js",
18
- "./messages": "./dist/messages/index.js"
18
+ "./messages": "./dist/messages/index.js",
19
+ "./v2": "./dist/v2/index.js"
19
20
  },
20
21
  "files": [
21
22
  "./dist",
@@ -32,14 +33,14 @@
32
33
  "murmurhash3js": "^3.0.1",
33
34
  "solid-js": "1.6.12",
34
35
  "throttle-debounce": "^5.0.0",
35
- "@inlang/language-tag": "1.5.1",
36
36
  "@inlang/json-types": "1.1.0",
37
+ "@inlang/language-tag": "1.5.1",
38
+ "@inlang/message": "2.1.0",
37
39
  "@inlang/message-lint-rule": "1.4.7",
38
- "@inlang/project-settings": "2.4.2",
39
40
  "@inlang/plugin": "2.4.11",
40
- "@inlang/message": "2.1.0",
41
- "@inlang/result": "1.1.0",
42
41
  "@inlang/module": "1.2.11",
42
+ "@inlang/project-settings": "2.4.2",
43
+ "@inlang/result": "1.1.0",
43
44
  "@inlang/translatable": "1.3.1",
44
45
  "@lix-js/client": "1.4.0",
45
46
  "@lix-js/fs": "1.0.0"
package/src/api.ts CHANGED
@@ -10,6 +10,7 @@ import type {
10
10
  MessageLintReport,
11
11
  } from "./versionedInterfaces.js"
12
12
  import type { ResolvedPluginApi } from "./resolve-modules/plugins/types.js"
13
+ import type * as V2 from "./v2/types.js"
13
14
 
14
15
  export type InstalledPlugin = {
15
16
  id: Plugin["id"]
@@ -55,6 +56,20 @@ export type InlangProject = {
55
56
  messages: MessageQueryApi
56
57
  messageLintReports: MessageLintReportsQueryApi
57
58
  }
59
+ // WIP V2 message apis
60
+ // use with project settings: experimental.persistence = true
61
+ messageBundles?: Query<V2.MessageBundle>
62
+ messages?: Query<V2.Message>
63
+ variants?: Query<V2.Variant>
64
+ }
65
+
66
+ /**
67
+ * WIP template for async V2 crud interfaces
68
+ * E.g. `project.messageBundles.get({ id: "..." })`
69
+ **/
70
+ interface Query<T> {
71
+ get: (args: unknown) => Promise<T>
72
+ getAll: () => Promise<T[]>
58
73
  }
59
74
 
60
75
  // const x = {} as InlangProject
@@ -66,6 +81,14 @@ export type Subscribable<Value> = {
66
81
  subscribe: (callback: (value: Value) => void) => void
67
82
  }
68
83
 
84
+ export type MessageQueryDelegate = {
85
+ onMessageCreate: (messageId: string, message: Message) => void
86
+ onMessageUpdate: (messageId: string, message: Message) => void
87
+ onMessageDelete: (messageId: string) => void
88
+ onLoaded: (messages: Message[]) => void
89
+ onCleanup: () => void
90
+ }
91
+
69
92
  export type MessageQueryApi = {
70
93
  create: (args: { data: Message }) => boolean
71
94
  get: ((args: { where: { id: Message["id"] } }) => Readonly<Message>) & {
@@ -86,6 +109,7 @@ export type MessageQueryApi = {
86
109
  update: (args: { where: { id: Message["id"] }; data: Partial<Message> }) => boolean
87
110
  upsert: (args: { where: { id: Message["id"] }; data: Message }) => void
88
111
  delete: (args: { where: { id: Message["id"] } }) => boolean
112
+ setDelegate: (delegate: MessageQueryDelegate) => void
89
113
  }
90
114
 
91
115
  export type MessageLintReportsQueryApi = {