@inlang/sdk 0.35.4 → 0.35.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.
Files changed (111) hide show
  1. package/dist/adapter/solidAdapter.test.js +1 -1
  2. package/dist/api.d.ts +2 -13
  3. package/dist/api.d.ts.map +1 -1
  4. package/dist/createMessagesQuery.d.ts.map +1 -1
  5. package/dist/createMessagesQuery.js +68 -82
  6. package/dist/createNewProject.test.js +1 -3
  7. package/dist/loadProject.d.ts.map +1 -1
  8. package/dist/loadProject.js +67 -32
  9. package/dist/loadProject.test.js +6 -2
  10. package/dist/persistence/batchedIO.d.ts +11 -0
  11. package/dist/persistence/batchedIO.d.ts.map +1 -0
  12. package/dist/persistence/batchedIO.js +49 -0
  13. package/dist/persistence/batchedIO.test.d.ts +2 -0
  14. package/dist/persistence/batchedIO.test.d.ts.map +1 -0
  15. package/dist/persistence/batchedIO.test.js +56 -0
  16. package/dist/persistence/filelock/acquireFileLock.d.ts.map +1 -1
  17. package/dist/persistence/filelock/acquireFileLock.js +3 -1
  18. package/dist/persistence/filelock/releaseLock.d.ts.map +1 -1
  19. package/dist/persistence/filelock/releaseLock.js +2 -1
  20. package/dist/persistence/store.d.ts +107 -0
  21. package/dist/persistence/store.d.ts.map +1 -0
  22. package/dist/persistence/store.js +99 -0
  23. package/dist/persistence/store.test.d.ts +2 -0
  24. package/dist/persistence/store.test.d.ts.map +1 -0
  25. package/dist/persistence/store.test.js +79 -0
  26. package/dist/persistence/storeApi.d.ts +22 -0
  27. package/dist/persistence/storeApi.d.ts.map +1 -0
  28. package/dist/persistence/storeApi.js +1 -0
  29. package/dist/reactivity/solid.test.js +1 -6
  30. package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +1 -1
  31. package/dist/resolve-modules/plugins/resolvePlugins.js +3 -10
  32. package/dist/test-utilities/sleep.d.ts +4 -0
  33. package/dist/test-utilities/sleep.d.ts.map +1 -0
  34. package/dist/test-utilities/sleep.js +9 -0
  35. package/dist/v2/helper.d.ts +131 -0
  36. package/dist/v2/helper.d.ts.map +1 -0
  37. package/dist/v2/helper.js +75 -0
  38. package/dist/v2/helper.test.d.ts +2 -0
  39. package/dist/v2/helper.test.d.ts.map +1 -0
  40. package/dist/v2/{createMessageBundle.test.js → helper.test.js} +1 -1
  41. package/dist/v2/index.d.ts +2 -0
  42. package/dist/v2/index.d.ts.map +1 -1
  43. package/dist/v2/index.js +2 -1
  44. package/dist/v2/mocks/index.d.ts +3 -0
  45. package/dist/v2/mocks/index.d.ts.map +1 -0
  46. package/dist/v2/mocks/index.js +2 -0
  47. package/dist/v2/mocks/multipleMatcher/bundle.d.ts +3 -0
  48. package/dist/v2/mocks/multipleMatcher/bundle.d.ts.map +1 -0
  49. package/dist/v2/mocks/multipleMatcher/bundle.js +194 -0
  50. package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts +2 -0
  51. package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts.map +1 -0
  52. package/dist/v2/mocks/multipleMatcher/bundle.test.js +10 -0
  53. package/dist/v2/mocks/plural/bundle.d.ts +1 -1
  54. package/dist/v2/mocks/plural/bundle.d.ts.map +1 -1
  55. package/dist/v2/mocks/plural/bundle.js +1 -1
  56. package/dist/v2/mocks/plural/bundle.test.js +6 -6
  57. package/dist/v2/shim.d.ts +12 -0
  58. package/dist/v2/shim.d.ts.map +1 -0
  59. package/dist/v2/shim.js +151 -0
  60. package/dist/v2/shim.test.d.ts +2 -0
  61. package/dist/v2/shim.test.d.ts.map +1 -0
  62. package/dist/v2/shim.test.js +49 -0
  63. package/dist/v2/stubQueryApi.d.ts +9 -0
  64. package/dist/v2/stubQueryApi.d.ts.map +1 -0
  65. package/dist/v2/stubQueryApi.js +38 -0
  66. package/dist/v2/types.d.ts +110 -0
  67. package/dist/v2/types.d.ts.map +1 -1
  68. package/dist/v2/types.js +9 -0
  69. package/package.json +9 -8
  70. package/src/adapter/solidAdapter.test.ts +1 -1
  71. package/src/api.ts +2 -13
  72. package/src/createMessagesQuery.ts +80 -99
  73. package/src/createNewProject.test.ts +1 -4
  74. package/src/loadProject.test.ts +6 -2
  75. package/src/loadProject.ts +86 -45
  76. package/src/persistence/batchedIO.test.ts +63 -0
  77. package/src/persistence/batchedIO.ts +64 -0
  78. package/src/persistence/filelock/acquireFileLock.ts +5 -2
  79. package/src/persistence/filelock/releaseLock.ts +2 -1
  80. package/src/persistence/store.test.ts +102 -0
  81. package/src/persistence/store.ts +119 -0
  82. package/src/persistence/storeApi.ts +19 -0
  83. package/src/reactivity/solid.test.ts +1 -8
  84. package/src/resolve-modules/plugins/resolvePlugins.ts +4 -13
  85. package/src/test-utilities/sleep.ts +11 -0
  86. package/src/v2/{createMessageBundle.test.ts → helper.test.ts} +1 -1
  87. package/src/v2/helper.ts +98 -0
  88. package/src/v2/index.ts +2 -0
  89. package/src/v2/mocks/index.ts +2 -0
  90. package/src/v2/mocks/multipleMatcher/bundle.test.ts +11 -0
  91. package/src/v2/mocks/multipleMatcher/bundle.ts +196 -0
  92. package/src/v2/mocks/plural/bundle.test.ts +6 -6
  93. package/src/v2/mocks/plural/bundle.ts +1 -1
  94. package/src/v2/shim.test.ts +56 -0
  95. package/src/v2/shim.ts +173 -0
  96. package/src/v2/stubQueryApi.ts +43 -0
  97. package/src/v2/types.ts +17 -0
  98. package/dist/persistence/plugin.d.ts +0 -31
  99. package/dist/persistence/plugin.d.ts.map +0 -1
  100. package/dist/persistence/plugin.js +0 -42
  101. package/dist/persistence/plugin.test.d.ts +0 -2
  102. package/dist/persistence/plugin.test.d.ts.map +0 -1
  103. package/dist/persistence/plugin.test.js +0 -49
  104. package/dist/v2/createMessageBundle.d.ts +0 -25
  105. package/dist/v2/createMessageBundle.d.ts.map +0 -1
  106. package/dist/v2/createMessageBundle.js +0 -36
  107. package/dist/v2/createMessageBundle.test.d.ts +0 -2
  108. package/dist/v2/createMessageBundle.test.d.ts.map +0 -1
  109. package/src/persistence/plugin.test.ts +0 -60
  110. package/src/persistence/plugin.ts +0 -56
  111. package/src/v2/createMessageBundle.ts +0 -43
@@ -0,0 +1,194 @@
1
+ export const multipleMatcherBundle = {
2
+ id: "mock-bundle-human-id",
3
+ alias: {
4
+ default: "mock-bundle-alias",
5
+ },
6
+ messages: [
7
+ {
8
+ locale: "en",
9
+ declarations: [],
10
+ selectors: [
11
+ {
12
+ type: "expression",
13
+ arg: {
14
+ type: "variable",
15
+ name: "count",
16
+ },
17
+ annotation: { type: "function", name: "plural", options: [] },
18
+ },
19
+ ],
20
+ variants: [
21
+ {
22
+ match: ["one"],
23
+ pattern: [
24
+ {
25
+ type: "text",
26
+ value: "Show ",
27
+ },
28
+ {
29
+ type: "expression",
30
+ arg: {
31
+ type: "variable",
32
+ name: "count",
33
+ },
34
+ },
35
+ {
36
+ type: "text",
37
+ value: " message.",
38
+ },
39
+ ],
40
+ },
41
+ {
42
+ match: ["many"],
43
+ pattern: [
44
+ {
45
+ type: "text",
46
+ value: "Show ",
47
+ },
48
+ {
49
+ type: "expression",
50
+ arg: {
51
+ type: "variable",
52
+ name: "count",
53
+ },
54
+ },
55
+ {
56
+ type: "text",
57
+ value: " messages.",
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ match: ["*"],
63
+ pattern: [
64
+ {
65
+ type: "text",
66
+ value: "Show ",
67
+ },
68
+ {
69
+ type: "expression",
70
+ arg: {
71
+ type: "variable",
72
+ name: "count",
73
+ },
74
+ },
75
+ ],
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ locale: "de",
81
+ declarations: [],
82
+ selectors: [
83
+ {
84
+ type: "expression",
85
+ arg: {
86
+ type: "variable",
87
+ name: "count",
88
+ },
89
+ annotation: { type: "function", name: "plural", options: [] },
90
+ },
91
+ {
92
+ type: "expression",
93
+ arg: {
94
+ type: "variable",
95
+ name: "formal",
96
+ },
97
+ annotation: { type: "function", name: "bool", options: [] },
98
+ },
99
+ ],
100
+ variants: [
101
+ {
102
+ match: ["one", "formal"],
103
+ pattern: [
104
+ {
105
+ type: "text",
106
+ value: "Zeigen Sie bitte Ihre Nachricht.",
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ match: ["one", "informal"],
112
+ pattern: [
113
+ {
114
+ type: "text",
115
+ value: "Zeigen Deine Nachricht.",
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ match: ["many", "formal"],
121
+ pattern: [
122
+ {
123
+ type: "text",
124
+ value: "Zeigen Sie bitte Ihre ",
125
+ },
126
+ {
127
+ type: "expression",
128
+ arg: {
129
+ type: "variable",
130
+ name: "count",
131
+ },
132
+ },
133
+ {
134
+ type: "text",
135
+ value: " Nachrichten.",
136
+ },
137
+ ],
138
+ },
139
+ {
140
+ match: ["many", "informal"],
141
+ pattern: [
142
+ {
143
+ type: "text",
144
+ value: "Zeigen Deine ",
145
+ },
146
+ {
147
+ type: "expression",
148
+ arg: {
149
+ type: "variable",
150
+ name: "count",
151
+ },
152
+ },
153
+ {
154
+ type: "text",
155
+ value: " Nachrichten.",
156
+ },
157
+ ],
158
+ },
159
+ {
160
+ match: ["many", "*"],
161
+ pattern: [
162
+ {
163
+ type: "expression",
164
+ arg: {
165
+ type: "variable",
166
+ name: "count",
167
+ },
168
+ },
169
+ {
170
+ type: "text",
171
+ value: " Nachrichten zeigen.",
172
+ },
173
+ ],
174
+ },
175
+ {
176
+ match: ["*"],
177
+ pattern: [
178
+ {
179
+ type: "text",
180
+ value: "Zeige ",
181
+ },
182
+ {
183
+ type: "expression",
184
+ arg: {
185
+ type: "variable",
186
+ name: "count",
187
+ },
188
+ },
189
+ ],
190
+ },
191
+ ],
192
+ },
193
+ ],
194
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bundle.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.test.d.ts","sourceRoot":"","sources":["../../../../src/v2/mocks/multipleMatcher/bundle.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { multipleMatcherBundle } from "./bundle.js";
3
+ import { MessageBundle } from "../../types.js";
4
+ import { Value } from "@sinclair/typebox/value";
5
+ describe("mock plural messageBundle", () => {
6
+ it("is valid", () => {
7
+ const messageBundle = multipleMatcherBundle;
8
+ expect(Value.Check(MessageBundle, messageBundle)).toBe(true);
9
+ });
10
+ });
@@ -1,3 +1,3 @@
1
1
  import type { MessageBundle } from "../../types.js";
2
- export declare const bundle: MessageBundle;
2
+ export declare const pluralBundle: MessageBundle;
3
3
  //# sourceMappingURL=bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../src/v2/mocks/plural/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,eAAO,MAAM,MAAM,EAAE,aA2IpB,CAAA"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../src/v2/mocks/plural/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,eAAO,MAAM,YAAY,EAAE,aA2I1B,CAAA"}
@@ -1,4 +1,4 @@
1
- export const bundle = {
1
+ export const pluralBundle = {
2
2
  id: "mock_bundle_human_id",
3
3
  alias: {
4
4
  default: "mock_bundle_alias",
@@ -1,15 +1,15 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
2
  import { describe, it, expect } from "vitest";
3
- import { bundle } from "./bundle.js";
3
+ import { pluralBundle } from "./bundle.js";
4
4
  import { MessageBundle } from "../../types.js";
5
5
  import { Value } from "@sinclair/typebox/value";
6
6
  describe("mock plural messageBundle", () => {
7
7
  it("is valid", () => {
8
- const messageBundle = bundle;
8
+ const messageBundle = pluralBundle;
9
9
  expect(Value.Check(MessageBundle, messageBundle)).toBe(true);
10
- expect(bundle.messages.length).toBe(2);
11
- expect(bundle.messages[0].declarations.length).toBe(1);
12
- expect(bundle.messages[0].selectors.length).toBe(1);
13
- expect(bundle.messages[0].variants.length).toBe(3);
10
+ expect(pluralBundle.messages.length).toBe(2);
11
+ expect(pluralBundle.messages[0].declarations.length).toBe(1);
12
+ expect(pluralBundle.messages[0].selectors.length).toBe(1);
13
+ expect(pluralBundle.messages[0].variants.length).toBe(3);
14
14
  });
15
15
  });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Convert between v1 Message and v2 MessageBundle formats.
3
+ * Code adapted from https://github.com/opral/monorepo/pull/2655 legacy.ts
4
+ */
5
+ import * as V2 from "./types.js";
6
+ import * as V1 from "@inlang/message";
7
+ /**
8
+ * @throws If the message cannot be represented in the v1 format
9
+ */
10
+ export declare function toV1Message(bundle: V2.MessageBundle): V1.Message;
11
+ export declare function fromV1Message(v1Message: V1.Message): V2.MessageBundle;
12
+ //# sourceMappingURL=shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shim.d.ts","sourceRoot":"","sources":["../../src/v2/shim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAErC;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,GAAG,EAAE,CAAC,OAAO,CA+BhE;AAwCD,wBAAgB,aAAa,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,aAAa,CAgErE"}
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Convert between v1 Message and v2 MessageBundle formats.
3
+ * Code adapted from https://github.com/opral/monorepo/pull/2655 legacy.ts
4
+ */
5
+ import * as V2 from "./types.js";
6
+ import * as V1 from "@inlang/message";
7
+ /**
8
+ * @throws If the message cannot be represented in the v1 format
9
+ */
10
+ export function toV1Message(bundle) {
11
+ const variants = [];
12
+ const selectorNames = new Set();
13
+ for (const message of bundle.messages) {
14
+ // collect all selector names
15
+ for (const selector of message.selectors.map(toV1Expression)) {
16
+ selectorNames.add(selector.name);
17
+ }
18
+ // collect all variants
19
+ for (const variant of message.variants) {
20
+ variants.push({
21
+ languageTag: message.locale,
22
+ match: variant.match,
23
+ pattern: toV1Pattern(variant.pattern),
24
+ });
25
+ }
26
+ }
27
+ const selectors = [...selectorNames].map((name) => ({
28
+ type: "VariableReference",
29
+ name,
30
+ }));
31
+ return {
32
+ id: bundle.id,
33
+ alias: bundle.alias,
34
+ variants,
35
+ selectors,
36
+ };
37
+ }
38
+ /**
39
+ * @throws If the pattern cannot be represented in the v1 format
40
+ */
41
+ function toV1Pattern(pattern) {
42
+ return pattern.map((element) => {
43
+ switch (element.type) {
44
+ case "text": {
45
+ return {
46
+ type: "Text",
47
+ value: element.value,
48
+ };
49
+ }
50
+ case "expression": {
51
+ return toV1Expression(element);
52
+ }
53
+ default: {
54
+ throw new Error(`Unsupported pattern element type`);
55
+ }
56
+ }
57
+ });
58
+ }
59
+ function toV1Expression(expression) {
60
+ if (expression.annotation !== undefined)
61
+ throw new Error("Cannot convert an expression with an annotation to the v1 format");
62
+ if (expression.arg.type !== "variable") {
63
+ throw new Error("Can only convert variable references to the v1 format");
64
+ }
65
+ return {
66
+ type: "VariableReference",
67
+ name: expression.arg.name,
68
+ };
69
+ }
70
+ export function fromV1Message(v1Message) {
71
+ const languages = dedup(v1Message.variants.map((variant) => variant.languageTag));
72
+ const messages = languages.map((language) => {
73
+ //All variants that will be part of this message
74
+ const v1Variants = v1Message.variants.filter((variant) => variant.languageTag === language);
75
+ //find all selector names
76
+ const selectorNames = new Set();
77
+ for (const v1Selector of v1Message.selectors) {
78
+ selectorNames.add(v1Selector.name);
79
+ }
80
+ const selectors = [...selectorNames].map((name) => ({
81
+ type: "expression",
82
+ annotation: undefined,
83
+ arg: {
84
+ type: "variable",
85
+ name: name,
86
+ },
87
+ }));
88
+ //The set of variables that need to be defined - Certainly includes the selectors
89
+ const variableNames = new Set(selectorNames);
90
+ const variants = [];
91
+ for (const v1Variant of v1Variants) {
92
+ for (const element of v1Variant.pattern) {
93
+ if (element.type === "VariableReference") {
94
+ variableNames.add(element.name);
95
+ }
96
+ }
97
+ variants.push({
98
+ match: v1Variant.match,
99
+ pattern: fromV1Pattern(v1Variant.pattern),
100
+ });
101
+ }
102
+ //Create an input declaration for each variable and selector we need
103
+ const declarations = [...variableNames].map((name) => ({
104
+ type: "input",
105
+ name,
106
+ value: {
107
+ type: "expression",
108
+ annotation: undefined,
109
+ arg: {
110
+ type: "variable",
111
+ name,
112
+ },
113
+ },
114
+ }));
115
+ return {
116
+ locale: language,
117
+ declarations,
118
+ selectors,
119
+ variants,
120
+ };
121
+ });
122
+ return {
123
+ id: v1Message.id,
124
+ alias: v1Message.alias,
125
+ messages,
126
+ };
127
+ }
128
+ function fromV1Pattern(pattern) {
129
+ return pattern.map((element) => {
130
+ switch (element.type) {
131
+ case "Text": {
132
+ return {
133
+ type: "text",
134
+ value: element.value,
135
+ };
136
+ }
137
+ case "VariableReference":
138
+ return {
139
+ type: "expression",
140
+ arg: {
141
+ type: "variable",
142
+ name: element.name,
143
+ },
144
+ };
145
+ }
146
+ });
147
+ }
148
+ /**
149
+ * Dedups an array by converting it to a set and back
150
+ */
151
+ const dedup = (arr) => [...new Set(arr)];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shim.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shim.test.d.ts","sourceRoot":"","sources":["../../src/v2/shim.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ import { test, expect } from "vitest";
2
+ import * as V2 from "./types.js";
3
+ import * as V1 from "@inlang/message";
4
+ import { createMessageBundle, createMessage } from "./helper.js";
5
+ import { toV1Message, fromV1Message } from "./shim.js";
6
+ import { Value } from "@sinclair/typebox/value";
7
+ const bundle = createMessageBundle({
8
+ id: "hello_world",
9
+ messages: [
10
+ createMessage({ locale: "en", text: "Hello World!" }),
11
+ createMessage({ locale: "de", text: "Hallo Welt!" }),
12
+ ],
13
+ });
14
+ test("toV1Message and fromV1Message", () => {
15
+ expect(Value.Check(V2.MessageBundle, bundle)).toBe(true);
16
+ const v1Message = toV1Message(bundle);
17
+ expect(Value.Check(V1.Message, v1Message)).toBe(true);
18
+ expect(v1Message).toEqual({
19
+ id: "hello_world",
20
+ alias: {},
21
+ variants: [
22
+ {
23
+ languageTag: "en",
24
+ match: [],
25
+ pattern: [
26
+ {
27
+ type: "Text",
28
+ value: "Hello World!",
29
+ },
30
+ ],
31
+ },
32
+ {
33
+ languageTag: "de",
34
+ match: [],
35
+ pattern: [
36
+ {
37
+ type: "Text",
38
+ value: "Hallo Welt!",
39
+ },
40
+ ],
41
+ },
42
+ ],
43
+ selectors: [],
44
+ });
45
+ const v2MessageBundle = fromV1Message(v1Message);
46
+ expect(Value.Check(V2.MessageBundle, v2MessageBundle)).toBe(true);
47
+ expect(v2MessageBundle).toEqual(bundle);
48
+ });
49
+ test.todo("with variable references", () => { });
@@ -0,0 +1,9 @@
1
+ import type { MessageQueryApi, MessageLintReportsQueryApi } from "../api.js";
2
+ /**
3
+ * noop implementation of the message query api for use with experimental.persistence = true.
4
+ * NOTE: If we implemented v2 shims for the old api we could use existing tests and make apps
5
+ * backwards compatible.
6
+ */
7
+ export declare const stubMessagesQuery: MessageQueryApi;
8
+ export declare const stubMessageLintReportsQuery: MessageLintReportsQueryApi;
9
+ //# sourceMappingURL=stubQueryApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubQueryApi.d.ts","sourceRoot":"","sources":["../../src/v2/stubQueryApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAE5E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,eAc/B,CAAA;AAED,eAAO,MAAM,2BAA2B,EAAE,0BAKzC,CAAA"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * noop implementation of the message query api for use with experimental.persistence = true.
3
+ * NOTE: If we implemented v2 shims for the old api we could use existing tests and make apps
4
+ * backwards compatible.
5
+ */
6
+ export const stubMessagesQuery = {
7
+ create: () => false,
8
+ // @ts-expect-error
9
+ get: subscribable(() => undefined),
10
+ // @ts-expect-error
11
+ getByDefaultAlias: subscribable(() => undefined),
12
+ // @ts-expect-error
13
+ includedMessageIds: subscribable(() => []),
14
+ // @ts-expect-error
15
+ getAll: subscribable(() => []),
16
+ update: () => false,
17
+ upsert: () => { },
18
+ delete: () => false,
19
+ setDelegate: () => { },
20
+ };
21
+ export const stubMessageLintReportsQuery = {
22
+ // @ts-expect-error
23
+ get: subscribable(() => []),
24
+ // @ts-expect-error
25
+ getAll: settleable(subscribable(() => [])),
26
+ };
27
+ // eslint-disable-next-line @typescript-eslint/ban-types
28
+ function subscribable(fn) {
29
+ return Object.assign(fn, {
30
+ subscribe: () => { },
31
+ });
32
+ }
33
+ // eslint-disable-next-line @typescript-eslint/ban-types
34
+ function settleable(fn) {
35
+ return Object.assign(fn, {
36
+ settled: async () => { },
37
+ });
38
+ }
@@ -408,4 +408,114 @@ export declare const MessageBundle: import("@sinclair/typebox").TObject<{
408
408
  }>>;
409
409
  }>>;
410
410
  }>;
411
+ /**
412
+ * A MessageSlot is a placeholder for a message with a locale.
413
+ * This is useful to avoid merge conflicts when translations are added.
414
+ */
415
+ export type MessageSlot = Static<typeof MessageSlot>;
416
+ export declare const MessageSlot: import("@sinclair/typebox").TObject<{
417
+ locale: import("@sinclair/typebox").TString;
418
+ slot: import("@sinclair/typebox").TLiteral<true>;
419
+ }>;
420
+ export type MessageBundleWithSlots = Static<typeof MessageBundleWithSlots>;
421
+ export declare const MessageBundleWithSlots: import("@sinclair/typebox").TObject<{
422
+ id: import("@sinclair/typebox").TString;
423
+ alias: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
424
+ messages: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
425
+ locale: import("@sinclair/typebox").TString;
426
+ declarations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
427
+ type: import("@sinclair/typebox").TLiteral<"input">;
428
+ name: import("@sinclair/typebox").TString;
429
+ value: import("@sinclair/typebox").TObject<{
430
+ type: import("@sinclair/typebox").TLiteral<"expression">;
431
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
432
+ type: import("@sinclair/typebox").TLiteral<"literal">;
433
+ value: import("@sinclair/typebox").TString;
434
+ }>, import("@sinclair/typebox").TObject<{
435
+ type: import("@sinclair/typebox").TLiteral<"variable">;
436
+ name: import("@sinclair/typebox").TString;
437
+ }>]>;
438
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
439
+ type: import("@sinclair/typebox").TLiteral<"function">;
440
+ name: import("@sinclair/typebox").TString;
441
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
442
+ name: import("@sinclair/typebox").TString;
443
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
444
+ type: import("@sinclair/typebox").TLiteral<"literal">;
445
+ value: import("@sinclair/typebox").TString;
446
+ }>, import("@sinclair/typebox").TObject<{
447
+ type: import("@sinclair/typebox").TLiteral<"variable">;
448
+ name: import("@sinclair/typebox").TString;
449
+ }>]>;
450
+ }>>;
451
+ }>>;
452
+ }>;
453
+ }>>;
454
+ /**
455
+ * The order in which the selectors are placed determines the precedence of patterns.
456
+ */
457
+ selectors: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
458
+ type: import("@sinclair/typebox").TLiteral<"expression">;
459
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
460
+ type: import("@sinclair/typebox").TLiteral<"literal">;
461
+ value: import("@sinclair/typebox").TString;
462
+ }>, import("@sinclair/typebox").TObject<{
463
+ type: import("@sinclair/typebox").TLiteral<"variable">;
464
+ name: import("@sinclair/typebox").TString;
465
+ }>]>;
466
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
467
+ type: import("@sinclair/typebox").TLiteral<"function">;
468
+ name: import("@sinclair/typebox").TString;
469
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
470
+ name: import("@sinclair/typebox").TString;
471
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
472
+ type: import("@sinclair/typebox").TLiteral<"literal">;
473
+ value: import("@sinclair/typebox").TString;
474
+ }>, import("@sinclair/typebox").TObject<{
475
+ type: import("@sinclair/typebox").TLiteral<"variable">;
476
+ name: import("@sinclair/typebox").TString;
477
+ }>]>;
478
+ }>>;
479
+ }>>;
480
+ }>>;
481
+ variants: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
482
+ /**
483
+ * The number of keys in each variant match MUST equal the number of expressions in the selectors.
484
+ *
485
+ * Inspired by: https://github.com/unicode-org/message-format-wg/blob/main/spec/formatting.md#pattern-selection
486
+ */
487
+ match: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
488
+ pattern: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
489
+ type: import("@sinclair/typebox").TLiteral<"text">;
490
+ value: import("@sinclair/typebox").TString;
491
+ }>, import("@sinclair/typebox").TObject<{
492
+ type: import("@sinclair/typebox").TLiteral<"expression">;
493
+ arg: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
494
+ type: import("@sinclair/typebox").TLiteral<"literal">;
495
+ value: import("@sinclair/typebox").TString;
496
+ }>, import("@sinclair/typebox").TObject<{
497
+ type: import("@sinclair/typebox").TLiteral<"variable">;
498
+ name: import("@sinclair/typebox").TString;
499
+ }>]>;
500
+ annotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
501
+ type: import("@sinclair/typebox").TLiteral<"function">;
502
+ name: import("@sinclair/typebox").TString;
503
+ options: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
504
+ name: import("@sinclair/typebox").TString;
505
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
506
+ type: import("@sinclair/typebox").TLiteral<"literal">;
507
+ value: import("@sinclair/typebox").TString;
508
+ }>, import("@sinclair/typebox").TObject<{
509
+ type: import("@sinclair/typebox").TLiteral<"variable">;
510
+ name: import("@sinclair/typebox").TString;
511
+ }>]>;
512
+ }>>;
513
+ }>>;
514
+ }>]>>;
515
+ }>>;
516
+ }>, import("@sinclair/typebox").TObject<{
517
+ locale: import("@sinclair/typebox").TString;
518
+ slot: import("@sinclair/typebox").TLiteral<true>;
519
+ }>]>>;
520
+ }>;
411
521
  //# sourceMappingURL=types.d.ts.map
@@ -1 +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,kB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