@inlang/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/solidAdapter.test.js +5 -5
- package/dist/createMessagesQuery.test.js +9 -0
- package/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +3 -1
- package/dist/loadProject.test.js +10 -10
- package/dist/messages/variant.d.ts +4 -4
- package/dist/messages/variant.d.ts.map +1 -1
- package/dist/messages/variant.js +55 -55
- package/dist/messages/variant.test.js +102 -45
- package/dist/test-utilities/createMessage.d.ts +1 -1
- package/dist/test-utilities/createMessage.js +1 -1
- package/dist/test-utilities/createMessage.test.js +4 -4
- package/package.json +1 -1
- package/src/adapter/solidAdapter.test.ts +13 -13
- package/src/adapter/solidAdapter.ts +1 -1
- package/src/api.ts +2 -2
- package/src/createMessageLintReportsQuery.ts +4 -4
- package/src/createMessagesQuery.test.ts +30 -17
- package/src/createMessagesQuery.ts +2 -2
- package/src/lint/message/lintMessages.ts +1 -1
- package/src/lint/message/lintSingleMessage.test.ts +1 -1
- package/src/lint/message/lintSingleMessage.ts +2 -2
- package/src/loadProject.test.ts +14 -14
- package/src/loadProject.ts +15 -13
- package/src/messages/errors.ts +2 -2
- package/src/messages/variant.test.ts +113 -49
- package/src/messages/variant.ts +73 -67
- package/src/parseConfig.ts +2 -2
- package/src/resolve-modules/import.test.ts +2 -2
- package/src/resolve-modules/import.ts +1 -1
- package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +1 -1
- package/src/resolve-modules/plugins/resolvePlugins.test.ts +2 -2
- package/src/resolve-modules/plugins/resolvePlugins.ts +16 -16
- package/src/resolve-modules/resolveModules.ts +4 -4
- package/src/test-utilities/createMessage.test.ts +7 -7
- package/src/test-utilities/createMessage.ts +1 -1
|
@@ -12,7 +12,7 @@ describe("$import", async () => {
|
|
|
12
12
|
export function hello() {
|
|
13
13
|
return "hello";
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
`
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
// mock module in a directory
|
|
@@ -23,7 +23,7 @@ describe("$import", async () => {
|
|
|
23
23
|
export function hello() {
|
|
24
24
|
return "world";
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
`
|
|
27
27
|
)
|
|
28
28
|
|
|
29
29
|
const _import = createImport({
|
|
@@ -91,7 +91,7 @@ describe("loadMessages", () => {
|
|
|
91
91
|
await resolved.data.loadMessages!({
|
|
92
92
|
languageTags: ["en"],
|
|
93
93
|
sourceLanguageTag: "en",
|
|
94
|
-
})
|
|
94
|
+
})
|
|
95
95
|
).toEqual([{ id: "test", expressions: [], selectors: [], variants: [] }])
|
|
96
96
|
})
|
|
97
97
|
|
|
@@ -298,7 +298,7 @@ describe("addCustomApi", () => {
|
|
|
298
298
|
|
|
299
299
|
expect(resolved.data.customApi).toHaveProperty("app.inlang.placeholder")
|
|
300
300
|
expect(
|
|
301
|
-
(resolved.data.customApi?.["app.inlang.placeholder"] as any).messageReferenceMatcher()
|
|
301
|
+
(resolved.data.customApi?.["app.inlang.placeholder"] as any).messageReferenceMatcher()
|
|
302
302
|
).toEqual({
|
|
303
303
|
hello: "world",
|
|
304
304
|
})
|
|
@@ -45,8 +45,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
45
45
|
result.errors.push(
|
|
46
46
|
new PluginHasInvalidIdError(
|
|
47
47
|
`Plugin ${plugin.id} has an invalid id "${plugin.id}". It must be kebap-case and contain a namespace like project.my-plugin.`,
|
|
48
|
-
{ plugin: plugin.id }
|
|
49
|
-
)
|
|
48
|
+
{ plugin: plugin.id }
|
|
49
|
+
)
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -57,8 +57,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
57
57
|
`Plugin ${plugin.id} uses reserved namespace 'inlang'.`,
|
|
58
58
|
{
|
|
59
59
|
plugin: plugin.id,
|
|
60
|
-
}
|
|
61
|
-
)
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
62
|
)
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -70,8 +70,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
70
70
|
{
|
|
71
71
|
plugin: plugin.id,
|
|
72
72
|
cause: errors,
|
|
73
|
-
}
|
|
74
|
-
)
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
75
|
)
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -80,8 +80,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
80
80
|
result.errors.push(
|
|
81
81
|
new PluginLoadMessagesFunctionAlreadyDefinedError(
|
|
82
82
|
`Plugin ${plugin.id} defines the loadMessages function, but it was already defined by another plugin.`,
|
|
83
|
-
{ plugin: plugin.id }
|
|
84
|
-
)
|
|
83
|
+
{ plugin: plugin.id }
|
|
84
|
+
)
|
|
85
85
|
)
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -89,8 +89,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
89
89
|
result.errors.push(
|
|
90
90
|
new PluginSaveMessagesFunctionAlreadyDefinedError(
|
|
91
91
|
`Plugin ${plugin.id} defines the saveMessages function, but it was already defined by another plugin.`,
|
|
92
|
-
{ plugin: plugin.id }
|
|
93
|
-
)
|
|
92
|
+
{ plugin: plugin.id }
|
|
93
|
+
)
|
|
94
94
|
)
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -100,7 +100,7 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
100
100
|
const { data: customApi, error } = tryCatch(() =>
|
|
101
101
|
plugin.addCustomApi!({
|
|
102
102
|
settings: args.settings?.[plugin.id] ?? {},
|
|
103
|
-
})
|
|
103
|
+
})
|
|
104
104
|
)
|
|
105
105
|
if (error) {
|
|
106
106
|
// @ts-ignore
|
|
@@ -111,8 +111,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
111
111
|
result.errors.push(
|
|
112
112
|
new PluginReturnedInvalidCustomApiError(
|
|
113
113
|
`Plugin ${plugin.id} defines the addCustomApi function, but it does not return an object.`,
|
|
114
|
-
{ plugin: plugin.id, cause: error }
|
|
115
|
-
)
|
|
114
|
+
{ plugin: plugin.id, cause: error }
|
|
115
|
+
)
|
|
116
116
|
)
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -148,7 +148,7 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
148
148
|
const { data: customApi } = tryCatch(() =>
|
|
149
149
|
plugin.addCustomApi!({
|
|
150
150
|
settings: args.settings?.[plugin.id] ?? {},
|
|
151
|
-
})
|
|
151
|
+
})
|
|
152
152
|
)
|
|
153
153
|
if (customApi) {
|
|
154
154
|
result.data.customApi = deepmerge(result.data.customApi, customApi)
|
|
@@ -164,8 +164,8 @@ export const resolvePlugins: ResolvePluginsFunction = async (args) => {
|
|
|
164
164
|
result.errors.push(
|
|
165
165
|
new PluginsDoNotProvideLoadOrSaveMessagesError(
|
|
166
166
|
"It seems you did not install any plugin that handles messages. Please add one to make inlang work. See https://inlang.com/documentation/plugins/registry.",
|
|
167
|
-
{ plugin: undefined }
|
|
168
|
-
)
|
|
167
|
+
{ plugin: undefined }
|
|
168
|
+
)
|
|
169
169
|
)
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -38,7 +38,7 @@ export const resolveModules: ResolveModuleFunction = async (args) => {
|
|
|
38
38
|
new ModuleImportError(`Couldn't import the plugin "${module}"`, {
|
|
39
39
|
module: module,
|
|
40
40
|
cause: importedModule.error as Error,
|
|
41
|
-
})
|
|
41
|
+
})
|
|
42
42
|
)
|
|
43
43
|
continue
|
|
44
44
|
}
|
|
@@ -48,7 +48,7 @@ export const resolveModules: ResolveModuleFunction = async (args) => {
|
|
|
48
48
|
moduleErrors.push(
|
|
49
49
|
new ModuleHasNoExportsError(`Module "${module}" has no exports.`, {
|
|
50
50
|
module: module,
|
|
51
|
-
})
|
|
51
|
+
})
|
|
52
52
|
)
|
|
53
53
|
continue
|
|
54
54
|
}
|
|
@@ -57,12 +57,12 @@ export const resolveModules: ResolveModuleFunction = async (args) => {
|
|
|
57
57
|
|
|
58
58
|
if (isValidModule === false) {
|
|
59
59
|
const errors = [...ModuleCompiler.Errors(importedModule.data)].map(
|
|
60
|
-
(e) => `${e.path} ${e.message}
|
|
60
|
+
(e) => `${e.path} ${e.message}`
|
|
61
61
|
)
|
|
62
62
|
moduleErrors.push(
|
|
63
63
|
new ModuleExportIsInvalidError(`Module "${module}" is invalid: ` + errors.join("\n"), {
|
|
64
64
|
module: module,
|
|
65
|
-
})
|
|
65
|
+
})
|
|
66
66
|
)
|
|
67
67
|
continue
|
|
68
68
|
}
|
|
@@ -5,7 +5,7 @@ test("should create a simple message", () => {
|
|
|
5
5
|
expect(
|
|
6
6
|
createMessage("welcome", {
|
|
7
7
|
de: "Hallo inlang",
|
|
8
|
-
})
|
|
8
|
+
})
|
|
9
9
|
).toMatchInlineSnapshot(`
|
|
10
10
|
{
|
|
11
11
|
"id": "welcome",
|
|
@@ -13,7 +13,7 @@ test("should create a simple message", () => {
|
|
|
13
13
|
"variants": [
|
|
14
14
|
{
|
|
15
15
|
"languageTag": "de",
|
|
16
|
-
"match":
|
|
16
|
+
"match": [],
|
|
17
17
|
"pattern": [
|
|
18
18
|
{
|
|
19
19
|
"type": "Text",
|
|
@@ -34,7 +34,7 @@ test("should create a message with pattern", () => {
|
|
|
34
34
|
{ type: "VariableReference", name: "name" },
|
|
35
35
|
{ type: "Text", value: '"' },
|
|
36
36
|
],
|
|
37
|
-
})
|
|
37
|
+
})
|
|
38
38
|
).toMatchInlineSnapshot(`
|
|
39
39
|
{
|
|
40
40
|
"id": "greeting",
|
|
@@ -42,7 +42,7 @@ test("should create a message with pattern", () => {
|
|
|
42
42
|
"variants": [
|
|
43
43
|
{
|
|
44
44
|
"languageTag": "en",
|
|
45
|
-
"match":
|
|
45
|
+
"match": [],
|
|
46
46
|
"pattern": [
|
|
47
47
|
{
|
|
48
48
|
"type": "Text",
|
|
@@ -68,7 +68,7 @@ test("should create a message with a pattern", () => {
|
|
|
68
68
|
createMessage("welcome", {
|
|
69
69
|
en: "hello inlang",
|
|
70
70
|
de: [{ type: "Text", value: "Hallo inlang" }],
|
|
71
|
-
})
|
|
71
|
+
})
|
|
72
72
|
).toMatchInlineSnapshot(`
|
|
73
73
|
{
|
|
74
74
|
"id": "welcome",
|
|
@@ -76,7 +76,7 @@ test("should create a message with a pattern", () => {
|
|
|
76
76
|
"variants": [
|
|
77
77
|
{
|
|
78
78
|
"languageTag": "en",
|
|
79
|
-
"match":
|
|
79
|
+
"match": [],
|
|
80
80
|
"pattern": [
|
|
81
81
|
{
|
|
82
82
|
"type": "Text",
|
|
@@ -86,7 +86,7 @@ test("should create a message with a pattern", () => {
|
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
"languageTag": "de",
|
|
89
|
-
"match":
|
|
89
|
+
"match": [],
|
|
90
90
|
"pattern": [
|
|
91
91
|
{
|
|
92
92
|
"type": "Text",
|