@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.
Files changed (42) hide show
  1. package/dist/adapter/solidAdapter.test.js +6 -6
  2. package/dist/createMessagesQuery.test.js +9 -0
  3. package/dist/loadProject.d.ts.map +1 -1
  4. package/dist/loadProject.js +8 -4
  5. package/dist/loadProject.test.js +14 -15
  6. package/dist/messages/variant.d.ts +4 -4
  7. package/dist/messages/variant.d.ts.map +1 -1
  8. package/dist/messages/variant.js +55 -55
  9. package/dist/messages/variant.test.js +102 -45
  10. package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +1 -1
  11. package/dist/resolve-modules/plugins/resolvePlugins.js +3 -5
  12. package/dist/resolve-modules/plugins/resolvePlugins.test.js +79 -49
  13. package/dist/resolve-modules/plugins/types.d.ts +4 -5
  14. package/dist/resolve-modules/plugins/types.d.ts.map +1 -1
  15. package/dist/test-utilities/createMessage.d.ts +1 -1
  16. package/dist/test-utilities/createMessage.js +1 -1
  17. package/dist/test-utilities/createMessage.test.js +4 -4
  18. package/package.json +1 -1
  19. package/src/adapter/solidAdapter.test.ts +14 -14
  20. package/src/adapter/solidAdapter.ts +1 -1
  21. package/src/api.ts +2 -2
  22. package/src/createMessageLintReportsQuery.ts +4 -4
  23. package/src/createMessagesQuery.test.ts +30 -17
  24. package/src/createMessagesQuery.ts +2 -2
  25. package/src/lint/message/lintMessages.ts +1 -1
  26. package/src/lint/message/lintSingleMessage.test.ts +1 -1
  27. package/src/lint/message/lintSingleMessage.ts +2 -2
  28. package/src/loadProject.test.ts +24 -27
  29. package/src/loadProject.ts +20 -16
  30. package/src/messages/errors.ts +2 -2
  31. package/src/messages/variant.test.ts +113 -49
  32. package/src/messages/variant.ts +73 -67
  33. package/src/parseConfig.ts +2 -2
  34. package/src/resolve-modules/import.test.ts +2 -2
  35. package/src/resolve-modules/import.ts +1 -1
  36. package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +1 -1
  37. package/src/resolve-modules/plugins/resolvePlugins.test.ts +96 -64
  38. package/src/resolve-modules/plugins/resolvePlugins.ts +19 -21
  39. package/src/resolve-modules/plugins/types.ts +4 -8
  40. package/src/resolve-modules/resolveModules.ts +4 -4
  41. package/src/test-utilities/createMessage.test.ts +7 -7
  42. 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: Record<Plugin["id"], JSONObject>
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
- languageTags: LanguageTag[]
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",
@@ -6,7 +6,7 @@ export const createMessage = (id: string, patterns: Record<string, Pattern | str
6
6
  selectors: [],
7
7
  variants: Object.entries(patterns).map(([languageTag, patterns]) => ({
8
8
  languageTag,
9
- match: {},
9
+ match: [],
10
10
  pattern:
11
11
  typeof patterns === "string"
12
12
  ? [