@inlang/sdk 0.34.3 → 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/LICENSE +201 -0
- package/dist/adapter/solidAdapter.test.js +1 -1
- package/dist/api.d.ts +13 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/createMessagesQuery.d.ts +14 -2
- package/dist/createMessagesQuery.d.ts.map +1 -1
- package/dist/createMessagesQuery.js +338 -6
- package/dist/createMessagesQuery.test.js +133 -88
- package/dist/createNodeishFsWithWatcher.d.ts +1 -0
- package/dist/createNodeishFsWithWatcher.d.ts.map +1 -1
- package/dist/createNodeishFsWithWatcher.js +2 -2
- package/dist/createNodeishFsWithWatcher.test.js +8 -0
- package/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +21 -487
- package/dist/persistence/filelock/acquireFileLock.d.ts +3 -0
- package/dist/persistence/filelock/acquireFileLock.d.ts.map +1 -0
- package/dist/persistence/filelock/acquireFileLock.js +109 -0
- package/dist/persistence/filelock/releaseLock.d.ts +3 -0
- package/dist/persistence/filelock/releaseLock.d.ts.map +1 -0
- package/dist/persistence/filelock/releaseLock.js +23 -0
- package/dist/v2/index.d.ts +2 -0
- package/dist/v2/index.d.ts.map +1 -0
- package/dist/v2/index.js +1 -0
- package/dist/v2/types.d.ts +411 -0
- package/dist/v2/types.d.ts.map +1 -0
- package/dist/v2/types.js +69 -0
- package/package.json +8 -7
- package/src/adapter/solidAdapter.test.ts +1 -1
- package/src/api.ts +15 -0
- package/src/createMessagesQuery.test.ts +147 -109
- package/src/createMessagesQuery.ts +477 -8
- package/src/createNodeishFsWithWatcher.test.ts +13 -0
- package/src/createNodeishFsWithWatcher.ts +2 -2
- package/src/loadProject.ts +20 -666
- package/src/persistence/filelock/acquireFileLock.ts +124 -0
- package/src/persistence/filelock/releaseLock.ts +28 -0
- package/src/v2/index.ts +1 -0
- package/src/v2/types.ts +142 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {} from "@lix-js/fs";
|
|
2
|
+
import _debug from "debug";
|
|
3
|
+
const debug = _debug("sdk:acquireFileLock");
|
|
4
|
+
const maxRetries = 10;
|
|
5
|
+
const nProbes = 50;
|
|
6
|
+
const probeInterval = 100;
|
|
7
|
+
export async function acquireFileLock(fs, lockDirPath, lockOrigin, tryCount = 0) {
|
|
8
|
+
if (tryCount > maxRetries) {
|
|
9
|
+
throw new Error(lockOrigin + " exceeded maximum Retries (5) to acquire lockfile " + tryCount);
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
debug(lockOrigin + " tries to acquire a lockfile Retry Nr.: " + tryCount);
|
|
13
|
+
await fs.mkdir(lockDirPath);
|
|
14
|
+
const stats = await fs.stat(lockDirPath);
|
|
15
|
+
debug(lockOrigin + " acquired a lockfile Retry Nr.: " + tryCount);
|
|
16
|
+
return stats.mtimeMs;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code !== "EEXIST") {
|
|
20
|
+
// we only expect the error that the file exists already (locked by other process)
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let currentLockTime;
|
|
25
|
+
try {
|
|
26
|
+
const stats = await fs.stat(lockDirPath);
|
|
27
|
+
currentLockTime = stats.mtimeMs;
|
|
28
|
+
}
|
|
29
|
+
catch (fstatError) {
|
|
30
|
+
if (fstatError.code === "ENOENT") {
|
|
31
|
+
// lock file seems to be gone :) - lets try again
|
|
32
|
+
debug(lockOrigin + " tryCount++ lock file seems to be gone :) - lets try again " + tryCount);
|
|
33
|
+
return acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
34
|
+
}
|
|
35
|
+
throw fstatError;
|
|
36
|
+
}
|
|
37
|
+
debug(lockOrigin +
|
|
38
|
+
" tries to acquire a lockfile - lock currently in use... starting probe phase " +
|
|
39
|
+
tryCount);
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
let probeCounts = 0;
|
|
42
|
+
const scheduleProbationTimeout = () => {
|
|
43
|
+
setTimeout(async () => {
|
|
44
|
+
probeCounts += 1;
|
|
45
|
+
let lockFileStats = undefined;
|
|
46
|
+
try {
|
|
47
|
+
debug(lockOrigin + " tries to acquire a lockfile - check if the lock is free now " + tryCount);
|
|
48
|
+
// alright lets give it another try
|
|
49
|
+
lockFileStats = await fs.stat(lockDirPath);
|
|
50
|
+
}
|
|
51
|
+
catch (fstatError) {
|
|
52
|
+
if (fstatError.code === "ENOENT") {
|
|
53
|
+
debug(lockOrigin +
|
|
54
|
+
" tryCount++ in Promise - tries to acquire a lockfile - lock file seems to be free now - try to acquire " +
|
|
55
|
+
tryCount);
|
|
56
|
+
const lock = acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
57
|
+
return resolve(lock);
|
|
58
|
+
}
|
|
59
|
+
return reject(fstatError);
|
|
60
|
+
}
|
|
61
|
+
// still the same locker! -
|
|
62
|
+
if (lockFileStats.mtimeMs === currentLockTime) {
|
|
63
|
+
if (probeCounts >= nProbes) {
|
|
64
|
+
// ok maximum lock time ran up (we waitetd nProbes * probeInterval) - we consider the lock to be stale
|
|
65
|
+
debug(lockOrigin +
|
|
66
|
+
" tries to acquire a lockfile - lock not free - but stale lets drop it" +
|
|
67
|
+
tryCount);
|
|
68
|
+
try {
|
|
69
|
+
await fs.rmdir(lockDirPath);
|
|
70
|
+
}
|
|
71
|
+
catch (rmLockError) {
|
|
72
|
+
if (rmLockError.code === "ENOENT") {
|
|
73
|
+
// lock already gone?
|
|
74
|
+
// Option 1: The "stale process" decided to get rid of it
|
|
75
|
+
// Option 2: Another process acquiring the lock and detected a stale one as well
|
|
76
|
+
}
|
|
77
|
+
return reject(rmLockError);
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
debug(lockOrigin +
|
|
81
|
+
" tryCount++ same locker - try to acquire again after removing stale lock " +
|
|
82
|
+
tryCount);
|
|
83
|
+
const lock = await acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
84
|
+
return resolve(lock);
|
|
85
|
+
}
|
|
86
|
+
catch (lockAquireException) {
|
|
87
|
+
return reject(lockAquireException);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// lets schedule a new probation
|
|
92
|
+
return scheduleProbationTimeout();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
try {
|
|
97
|
+
debug(lockOrigin + " tryCount++ different locker - try to acquire again " + tryCount);
|
|
98
|
+
const lock = await acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
99
|
+
return resolve(lock);
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return reject(error);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, probeInterval);
|
|
106
|
+
};
|
|
107
|
+
scheduleProbationTimeout();
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"releaseLock.d.ts","sourceRoot":"","sources":["../../../src/persistence/filelock/releaseLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,wBAAsB,WAAW,CAChC,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,iBAmBhB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {} from "@lix-js/fs";
|
|
2
|
+
import _debug from "debug";
|
|
3
|
+
const debug = _debug("sdk:releaseLock");
|
|
4
|
+
export async function releaseLock(fs, lockDirPath, lockOrigin, lockTime) {
|
|
5
|
+
debug(lockOrigin + " releasing the lock ");
|
|
6
|
+
try {
|
|
7
|
+
const stats = await fs.stat(lockDirPath);
|
|
8
|
+
if (stats.mtimeMs === lockTime) {
|
|
9
|
+
// this can be corrupt as welll since the last getStat and the current a modification could have occured :-/
|
|
10
|
+
await fs.rmdir(lockDirPath);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (statError) {
|
|
14
|
+
debug(lockOrigin + " couldn't release the lock");
|
|
15
|
+
if (statError.code === "ENOENT") {
|
|
16
|
+
// ok seeks like the log was released by someone else
|
|
17
|
+
debug(lockOrigin + " WARNING - the lock was released by a different process");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
debug(statError);
|
|
21
|
+
throw statError;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v2/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAA"}
|
package/dist/v2/index.js
ADDED
|
@@ -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;;;;;;;;;;;;;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"}
|
package/dist/v2/types.js
ADDED
|
@@ -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
|
+
});
|