@inlang/sdk 0.34.4 → 0.34.5

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/dist/api.d.ts CHANGED
@@ -3,6 +3,7 @@ import type * as RuntimeError from "./errors.js";
3
3
  import type * as ModuleResolutionError from "./resolve-modules/errors.js";
4
4
  import type { MessageLintLevel, MessageLintRule, Message, Plugin, ProjectSettings, MessageLintReport } from "./versionedInterfaces.js";
5
5
  import type { ResolvedPluginApi } from "./resolve-modules/plugins/types.js";
6
+ import type * as V2 from "./v2/types.js";
6
7
  export type InstalledPlugin = {
7
8
  id: Plugin["id"];
8
9
  displayName: Plugin["displayName"];
@@ -41,7 +42,18 @@ export type InlangProject = {
41
42
  messages: MessageQueryApi;
42
43
  messageLintReports: MessageLintReportsQueryApi;
43
44
  };
45
+ messageBundles?: Query<V2.MessageBundle>;
46
+ messages?: Query<V2.Message>;
47
+ variants?: Query<V2.Variant>;
44
48
  };
49
+ /**
50
+ * WIP template for async V2 crud interfaces
51
+ * E.g. `project.messageBundles.get({ id: "..." })`
52
+ **/
53
+ interface Query<T> {
54
+ get: (args: unknown) => Promise<T>;
55
+ getAll: () => Promise<T[]>;
56
+ }
45
57
  export type Subscribable<Value> = {
46
58
  (): Value;
47
59
  subscribe: (callback: (value: Value) => void) => void;
@@ -92,4 +104,5 @@ export type MessageLintReportsQueryApi = {
92
104
  };
93
105
  }) => Promise<Readonly<MessageLintReport[]>>;
94
106
  };
107
+ export {};
95
108
  //# sourceMappingURL=api.d.ts.map
package/dist/api.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,KAAK,YAAY,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,KAAK,qBAAqB,MAAM,6BAA6B,CAAA;AACzE,OAAO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+ export type * from "./types.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -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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DF,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.5",
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,17 +33,17 @@
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/message-lint-rule": "1.4.7",
38
- "@inlang/project-settings": "2.4.2",
39
- "@inlang/plugin": "2.4.11",
40
37
  "@inlang/message": "2.1.0",
41
- "@inlang/result": "1.1.0",
38
+ "@inlang/language-tag": "1.5.1",
42
39
  "@inlang/module": "1.2.11",
43
- "@inlang/translatable": "1.3.1",
40
+ "@inlang/plugin": "2.4.11",
41
+ "@inlang/project-settings": "2.4.2",
42
+ "@inlang/result": "1.1.0",
43
+ "@inlang/message-lint-rule": "1.4.7",
44
44
  "@lix-js/client": "1.4.0",
45
- "@lix-js/fs": "1.0.0"
45
+ "@lix-js/fs": "1.0.0",
46
+ "@inlang/translatable": "1.3.1"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@types/debug": "^4.1.12",
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
@@ -0,0 +1 @@
1
+ export type * from "./types.js"
@@ -0,0 +1,142 @@
1
+ import { Type, type Static } from "@sinclair/typebox"
2
+
3
+ /**
4
+ * Follows the IETF BCP 47 language tag schema.
5
+ *
6
+ * @see https://www.ietf.org/rfc/bcp/bcp47.txt
7
+ * @see https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
8
+ */
9
+ export type LanguageTag = Static<typeof LanguageTag>
10
+ /**
11
+ * Follows the IETF BCP 47 language tag schema with modifications.
12
+ * @see REAMDE.md file for more information on the validation.
13
+ */
14
+
15
+ export const pattern =
16
+ "^((?<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}))*))$"
17
+
18
+ export const LanguageTag = Type.String({
19
+ pattern: pattern,
20
+ description: "The language tag must be a valid IETF BCP 47 language tag.",
21
+ examples: ["en", "de", "en-US", "zh-Hans", "es-419"],
22
+ })
23
+
24
+ export type Literal = Static<typeof Literal>
25
+ export const Literal = Type.Object({
26
+ type: Type.Literal("literal"),
27
+ value: Type.String(),
28
+ })
29
+
30
+ /**
31
+ * A (text) element that is translatable and rendered to the UI.
32
+ */
33
+ export type Text = Static<typeof Text>
34
+ export const Text = Type.Object({
35
+ type: Type.Literal("text"),
36
+ value: Type.String(),
37
+ })
38
+
39
+ export type VariableReference = Static<typeof VariableReference>
40
+ export const VariableReference = Type.Object({
41
+ type: Type.Literal("variable"),
42
+ name: Type.String(),
43
+ })
44
+
45
+ export type Option = Static<typeof Option>
46
+ export const Option = Type.Object({
47
+ name: Type.String(),
48
+ value: Type.Union([Literal, VariableReference]),
49
+ })
50
+
51
+ export type FunctionAnnotation = Static<typeof FunctionAnnotation>
52
+ export const FunctionAnnotation = Type.Object({
53
+ type: Type.Literal("function"),
54
+ name: Type.String(),
55
+ options: Type.Array(Option),
56
+ })
57
+
58
+ /**
59
+ * An expression is a reference to a variable or a function.
60
+ *
61
+ * Think of expressions as elements that are rendered to a
62
+ * text value during runtime.
63
+ */
64
+ export type Expression = Static<typeof Expression>
65
+ export const Expression = Type.Object({
66
+ type: Type.Literal("expression"),
67
+ arg: Type.Union([Literal, VariableReference]),
68
+ annotation: Type.Optional(FunctionAnnotation),
69
+ })
70
+
71
+ // export type FunctionReference = {
72
+ // type: "function"
73
+ // name: string
74
+ // operand?: Text | VariableReference
75
+ // options?: Option[]
76
+ // }
77
+
78
+ /**
79
+ * A pattern is a sequence of elements that comprise
80
+ * a message that is rendered to the UI.
81
+ */
82
+ export type Pattern = Static<typeof Pattern>
83
+ export const Pattern = Type.Array(Type.Union([Text, Expression]))
84
+
85
+ /**
86
+ * A variant contains a pattern that is rendered to the UI.
87
+ */
88
+ export type Variant = Static<typeof Variant>
89
+ export const Variant = Type.Object({
90
+ /**
91
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
92
+ *
93
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
94
+ */
95
+ // a match can always only be string-based because a string is what is rendered to the UI
96
+ match: Type.Array(Type.String()),
97
+ pattern: Pattern,
98
+ })
99
+
100
+ export type InputDeclaration = Static<typeof InputDeclaration>
101
+ export const InputDeclaration = Type.Object({
102
+ type: Type.Literal("input"),
103
+ name: Type.String(),
104
+
105
+ //TODO make this generic so that only Variable-Ref Expressions are allowed
106
+ value: Expression,
107
+ })
108
+
109
+ // local declarations are not supported.
110
+ // Will only add when required. See discussion:
111
+ // https://github.com/opral/monorepo/pull/2700#discussion_r1591070701
112
+ //
113
+ // export type LocalDeclaration = Static<typeof InputDeclaration>
114
+ // export const LocalDeclaration = Type.Object({
115
+ // type: Type.Literal("local"),
116
+ // name: Type.String(),
117
+ // value: Expression,
118
+ // })
119
+ //
120
+ // export type Declaration = Static<typeof Declaration>
121
+ // export const Declaration = Type.Union([LocalDeclaration, InputDeclaration])
122
+
123
+ export type Declaration = Static<typeof Declaration>
124
+ export const Declaration = Type.Union([InputDeclaration])
125
+
126
+ export type Message = Static<typeof Message>
127
+ export const Message = Type.Object({
128
+ locale: LanguageTag,
129
+ declarations: Type.Array(Declaration),
130
+ /**
131
+ * The order in which the selectors are placed determines the precedence of patterns.
132
+ */
133
+ selectors: Type.Array(Expression),
134
+ variants: Type.Array(Variant),
135
+ })
136
+
137
+ export type MessageBundle = Static<typeof MessageBundle>
138
+ export const MessageBundle = Type.Object({
139
+ id: Type.String(),
140
+ alias: Type.Record(Type.String(), Type.String()),
141
+ messages: Type.Array(Message),
142
+ })