@inlang/sdk 0.7.0 → 0.9.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 +6 -6
- package/dist/createMessagesQuery.test.js +9 -0
- package/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +8 -4
- package/dist/loadProject.test.js +14 -15
- 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/resolve-modules/plugins/resolvePlugins.d.ts.map +1 -1
- package/dist/resolve-modules/plugins/resolvePlugins.js +3 -5
- package/dist/resolve-modules/plugins/resolvePlugins.test.js +79 -49
- package/dist/resolve-modules/plugins/types.d.ts +4 -5
- package/dist/resolve-modules/plugins/types.d.ts.map +1 -1
- 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 +14 -14
- 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 +24 -27
- package/src/loadProject.ts +20 -16
- 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 +96 -64
- package/src/resolve-modules/plugins/resolvePlugins.ts +19 -21
- package/src/resolve-modules/plugins/types.ts +4 -8
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { LanguageTag } from "@inlang/language-tag"
|
|
2
1
|
import type { NodeishFilesystem as LisaNodeishFilesystem } from "@lix-js/fs"
|
|
3
2
|
import type {
|
|
4
3
|
PluginReturnedInvalidCustomApiError,
|
|
@@ -10,8 +9,8 @@ import type {
|
|
|
10
9
|
PluginsDoNotProvideLoadOrSaveMessagesError,
|
|
11
10
|
} from "./errors.js"
|
|
12
11
|
import type { Message } from "@inlang/message"
|
|
13
|
-
import type { JSONObject } from "@inlang/json-types"
|
|
14
12
|
import type { CustomApiInlangIdeExtension, Plugin } from "@inlang/plugin"
|
|
13
|
+
import type { ProjectSettings } from "@inlang/project-settings"
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* The filesystem is a subset of project lisa's nodeish filesystem.
|
|
@@ -28,7 +27,7 @@ export type NodeishFilesystemSubset = Pick<
|
|
|
28
27
|
*/
|
|
29
28
|
export type ResolvePluginsFunction = (args: {
|
|
30
29
|
plugins: Array<Plugin>
|
|
31
|
-
settings:
|
|
30
|
+
settings: ProjectSettings
|
|
32
31
|
nodeishFs: NodeishFilesystemSubset
|
|
33
32
|
}) => Promise<{
|
|
34
33
|
data: ResolvedPluginApi
|
|
@@ -47,11 +46,8 @@ export type ResolvePluginsFunction = (args: {
|
|
|
47
46
|
* The API after resolving the plugins.
|
|
48
47
|
*/
|
|
49
48
|
export type ResolvedPluginApi = {
|
|
50
|
-
loadMessages: (args: {
|
|
51
|
-
|
|
52
|
-
sourceLanguageTag: LanguageTag
|
|
53
|
-
}) => Promise<Message[]> | Message[]
|
|
54
|
-
saveMessages: (args: { messages: Message[] }) => Promise<void> | void
|
|
49
|
+
loadMessages: (args: { settings: ProjectSettings }) => Promise<Message[]> | Message[]
|
|
50
|
+
saveMessages: (args: { settings: ProjectSettings; messages: Message[] }) => Promise<void> | void
|
|
55
51
|
/**
|
|
56
52
|
* App specific APIs.
|
|
57
53
|
*
|
|
@@ -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",
|