@inlang/sdk 0.3.0 → 0.5.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 (82) hide show
  1. package/dist/adapter/solidAdapter.d.ts +2 -2
  2. package/dist/adapter/solidAdapter.d.ts.map +1 -1
  3. package/dist/adapter/solidAdapter.js +2 -2
  4. package/dist/adapter/solidAdapter.test.js +68 -78
  5. package/dist/api.d.ts +10 -6
  6. package/dist/api.d.ts.map +1 -1
  7. package/dist/api.test-d.d.ts +2 -0
  8. package/dist/api.test-d.d.ts.map +1 -0
  9. package/dist/api.test-d.js +4 -0
  10. package/dist/createMessageLintReportsQuery.d.ts +2 -2
  11. package/dist/createMessageLintReportsQuery.d.ts.map +1 -1
  12. package/dist/createMessageLintReportsQuery.js +11 -11
  13. package/dist/createMessagesQuery.js +1 -1
  14. package/dist/errors.d.ts +3 -3
  15. package/dist/errors.d.ts.map +1 -1
  16. package/dist/errors.js +6 -6
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/lint/message/lintMessages.d.ts +3 -7
  21. package/dist/lint/message/lintMessages.d.ts.map +1 -1
  22. package/dist/lint/message/lintMessages.test.js +38 -36
  23. package/dist/lint/message/lintSingleMessage.d.ts +3 -7
  24. package/dist/lint/message/lintSingleMessage.d.ts.map +1 -1
  25. package/dist/lint/message/lintSingleMessage.js +10 -10
  26. package/dist/lint/message/lintSingleMessage.test.js +71 -65
  27. package/dist/{openInlangProject.d.ts → loadProject.d.ts} +3 -3
  28. package/dist/loadProject.d.ts.map +1 -0
  29. package/dist/{openInlangProject.js → loadProject.js} +70 -66
  30. package/dist/loadProject.test.d.ts +2 -0
  31. package/dist/loadProject.test.d.ts.map +1 -0
  32. package/dist/{openInlangProject.test.js → loadProject.test.js} +160 -176
  33. package/dist/parseConfig.d.ts +2 -2
  34. package/dist/parseConfig.d.ts.map +1 -1
  35. package/dist/parseConfig.js +3 -3
  36. package/dist/resolve-modules/import.js +1 -1
  37. package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +1 -1
  38. package/dist/resolve-modules/plugins/errors.d.ts +1 -1
  39. package/dist/resolve-modules/plugins/errors.d.ts.map +1 -1
  40. package/dist/resolve-modules/plugins/resolvePlugins.js +15 -15
  41. package/dist/resolve-modules/plugins/resolvePlugins.test.js +55 -94
  42. package/dist/resolve-modules/plugins/types.d.ts +1 -1
  43. package/dist/resolve-modules/plugins/types.d.ts.map +1 -1
  44. package/dist/resolve-modules/plugins/types.test.js +10 -14
  45. package/dist/resolve-modules/resolveModules.d.ts.map +1 -1
  46. package/dist/resolve-modules/resolveModules.js +9 -9
  47. package/dist/resolve-modules/resolveModules.test.js +28 -42
  48. package/dist/resolve-modules/types.d.ts +3 -3
  49. package/dist/resolve-modules/types.d.ts.map +1 -1
  50. package/dist/versionedInterfaces.d.ts +1 -1
  51. package/dist/versionedInterfaces.d.ts.map +1 -1
  52. package/dist/versionedInterfaces.js +1 -1
  53. package/package.json +3 -3
  54. package/src/adapter/solidAdapter.test.ts +77 -87
  55. package/src/adapter/solidAdapter.ts +4 -4
  56. package/src/api.test-d.ts +8 -0
  57. package/src/api.ts +10 -6
  58. package/src/createMessageLintReportsQuery.ts +15 -20
  59. package/src/createMessagesQuery.ts +1 -1
  60. package/src/errors.ts +6 -6
  61. package/src/index.ts +4 -4
  62. package/src/lint/message/lintMessages.test.ts +38 -36
  63. package/src/lint/message/lintMessages.ts +3 -11
  64. package/src/lint/message/lintSingleMessage.test.ts +71 -65
  65. package/src/lint/message/lintSingleMessage.ts +13 -21
  66. package/src/{openInlangProject.test.ts → loadProject.test.ts} +165 -181
  67. package/src/{openInlangProject.ts → loadProject.ts} +81 -82
  68. package/src/parseConfig.ts +5 -3
  69. package/src/resolve-modules/import.ts +1 -1
  70. package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +1 -1
  71. package/src/resolve-modules/plugins/errors.ts +1 -1
  72. package/src/resolve-modules/plugins/resolvePlugins.test.ts +55 -94
  73. package/src/resolve-modules/plugins/resolvePlugins.ts +19 -19
  74. package/src/resolve-modules/plugins/types.test.ts +11 -15
  75. package/src/resolve-modules/plugins/types.ts +1 -1
  76. package/src/resolve-modules/resolveModules.test.ts +29 -43
  77. package/src/resolve-modules/resolveModules.ts +11 -9
  78. package/src/resolve-modules/types.ts +3 -3
  79. package/src/versionedInterfaces.ts +1 -1
  80. package/dist/openInlangProject.d.ts.map +0 -1
  81. package/dist/openInlangProject.test.d.ts +0 -2
  82. package/dist/openInlangProject.test.d.ts.map +0 -1
@@ -2,18 +2,17 @@ import { expect, it } from "vitest";
2
2
  import { ModuleError, ModuleExportIsInvalidError, ModuleHasNoExportsError, ModuleImportError, } from "./errors.js";
3
3
  import { resolveModules } from "./resolveModules.js";
4
4
  it("should return an error if a plugin cannot be imported", async () => {
5
- const config = {
5
+ const settings = {
6
6
  sourceLanguageTag: "en",
7
7
  languageTags: ["de", "en"],
8
8
  modules: ["https://myplugin.com/index.js"],
9
- settings: {},
10
9
  };
11
10
  const resolved = await resolveModules({
12
- config,
11
+ settings,
13
12
  nodeishFs: {},
14
13
  _import: () => {
15
14
  throw new ModuleImportError("Could not import", {
16
- module: config.modules[0],
15
+ module: settings.modules[0],
17
16
  cause: new Error("Could not import"),
18
17
  });
19
18
  },
@@ -23,11 +22,9 @@ it("should return an error if a plugin cannot be imported", async () => {
23
22
  it("should resolve plugins and message lint rules successfully", async () => {
24
23
  // Define mock data
25
24
  const mockPlugin = {
26
- meta: {
27
- id: "plugin.namespace.mock",
28
- description: { en: "Mock plugin description" },
29
- displayName: { en: "Mock Plugin" },
30
- },
25
+ id: "plugin.namespace.mock",
26
+ description: { en: "Mock plugin description" },
27
+ displayName: { en: "Mock Plugin" },
31
28
  loadMessages: () => undefined,
32
29
  saveMessages: () => undefined,
33
30
  addCustomApi: () => ({
@@ -37,18 +34,15 @@ it("should resolve plugins and message lint rules successfully", async () => {
37
34
  }),
38
35
  };
39
36
  const mockMessageLintRule = {
40
- meta: {
41
- id: "messageLintRule.namespace.mock",
42
- description: { en: "Mock lint rule description" },
43
- displayName: { en: "Mock Lint Rule" },
44
- },
45
- message: () => undefined,
37
+ id: "messageLintRule.namespace.mock",
38
+ description: { en: "Mock lint rule description" },
39
+ displayName: { en: "Mock Lint Rule" },
40
+ run: () => undefined,
46
41
  };
47
- const config = {
42
+ const settings = {
48
43
  sourceLanguageTag: "en",
49
44
  languageTags: ["de", "en"],
50
45
  modules: ["lint-rule.js", "plugin.js"],
51
- settings: {},
52
46
  };
53
47
  const _import = async (name) => {
54
48
  if (name === "lint-rule.js") {
@@ -63,81 +57,73 @@ it("should resolve plugins and message lint rules successfully", async () => {
63
57
  }
64
58
  };
65
59
  // Call the function
66
- const resolved = await resolveModules({ config, _import, nodeishFs: {} });
60
+ const resolved = await resolveModules({ settings, _import, nodeishFs: {} });
67
61
  // Assert results
68
62
  expect(resolved.errors).toHaveLength(0);
69
63
  // Check for the meta data of the plugin
70
- expect(resolved.plugins.some((module) => module.meta.id === mockPlugin.meta.id)).toBeDefined();
64
+ expect(resolved.plugins.some((module) => module.id === mockPlugin.id)).toBeDefined();
71
65
  // Check for the app specific api
72
66
  expect(resolved.resolvedPluginApi["customApi"]?.["app.inlang.ideExtension"]).toBeDefined();
73
67
  // Check for the lint rule
74
- expect(resolved.messageLintRules[0]?.meta.id).toBe(mockMessageLintRule.meta.id);
68
+ expect(resolved.messageLintRules[0]?.id).toBe(mockMessageLintRule.id);
75
69
  });
76
70
  it("should return an error if a module cannot be imported", async () => {
77
- const config = {
71
+ const settings = {
78
72
  sourceLanguageTag: "en",
79
73
  languageTags: ["de", "en"],
80
74
  modules: ["https://myplugin.com/index.js"],
81
- settings: {},
82
75
  };
83
76
  const _import = async () => {
84
77
  throw new ModuleImportError("Could not import", {
85
- module: config.modules[0],
78
+ module: settings.modules[0],
86
79
  cause: new Error(),
87
80
  });
88
81
  };
89
82
  // Call the function
90
- const resolved = await resolveModules({ config, _import, nodeishFs: {} });
83
+ const resolved = await resolveModules({ settings, _import, nodeishFs: {} });
91
84
  // Assert results
92
85
  expect(resolved.errors[0]).toBeInstanceOf(ModuleImportError);
93
86
  });
94
- it("should return an error if a module does not export any plugins or lint rules", async () => {
95
- const config = {
87
+ it("should return an error if a module does not export anything", async () => {
88
+ const settings = {
96
89
  sourceLanguageTag: "en",
97
90
  languageTags: ["de", "en"],
98
91
  modules: ["https://myplugin.com/index.js"],
99
- settings: {},
100
92
  };
101
- const _import = async () => ({
102
- default: {},
103
- });
93
+ const _import = async () => ({});
104
94
  // Call the function
105
- const resolved = await resolveModules({ config, _import, nodeishFs: {} });
95
+ const resolved = await resolveModules({ settings, _import, nodeishFs: {} });
106
96
  // Assert results
107
97
  expect(resolved.errors[0]).toBeInstanceOf(ModuleHasNoExportsError);
108
98
  });
109
99
  it("should return an error if a module exports an invalid plugin or lint rule", async () => {
110
- const config = {
100
+ const settings = {
111
101
  sourceLanguageTag: "en",
112
102
  languageTags: ["de", "en"],
113
103
  modules: ["https://myplugin.com/index.js"],
114
- settings: {},
115
104
  };
116
105
  const _import = async () => ({
106
+ // @ts-expect-error - invalid meta of a plugin
117
107
  default: {
118
- // @ts-expect-error - invalid meta of a plugin
119
- meta: {
120
- id: "plugin.namespace.mock",
121
- description: { en: "Mock plugin description" },
122
- },
108
+ id: "plugin.namespace.mock",
109
+ description: { en: "Mock plugin description" },
123
110
  },
124
111
  });
125
- const resolved = await resolveModules({ config, _import, nodeishFs: {} });
112
+ const resolved = await resolveModules({ settings, _import, nodeishFs: {} });
126
113
  expect(resolved.errors[0]).toBeInstanceOf(ModuleExportIsInvalidError);
127
114
  });
128
115
  it("should handle other unhandled errors during plugin resolution", async () => {
129
116
  const errorMessage = "Unhandled error during plugin resolution";
130
- const config = {
117
+ const settings = {
131
118
  sourceLanguageTag: "en",
132
119
  languageTags: ["de", "en"],
133
120
  modules: ["https://myplugin.com/index.js"],
134
- settings: {},
135
121
  };
136
122
  const _import = async () => {
137
123
  throw new Error(errorMessage);
138
124
  };
139
125
  // Call the function
140
- const resolved = await resolveModules({ config, _import, nodeishFs: {} });
126
+ const resolved = await resolveModules({ settings, _import, nodeishFs: {} });
141
127
  // Assert results
142
128
  expect(resolved.errors[0]).toBeInstanceOf(ModuleError);
143
129
  });
@@ -1,4 +1,4 @@
1
- import type { ProjectConfig } from "@inlang/project-config";
1
+ import type { ProjectSettings } from "@inlang/project-settings";
2
2
  import type { MessageLintRule } from "@inlang/message-lint-rule";
3
3
  import type { Plugin } from "@inlang/plugin";
4
4
  import type { NodeishFilesystemSubset, ResolvePluginsFunction, ResolvedPluginApi } from "./plugins/types.js";
@@ -11,7 +11,7 @@ import type { resolveMessageLintRules } from "./message-lint-rules/resolveMessag
11
11
  * Pass a custom `_import` function to override the default import function.
12
12
  */
13
13
  export type ResolveModuleFunction = (args: {
14
- config: ProjectConfig;
14
+ settings: ProjectSettings;
15
15
  nodeishFs: NodeishFilesystemSubset;
16
16
  _import?: ImportFunction;
17
17
  }) => Promise<{
@@ -34,7 +34,7 @@ export type ResolveModuleFunction = (args: {
34
34
  /**
35
35
  * The resolved item id of the module.
36
36
  */
37
- id: Plugin["meta"]["id"] | MessageLintRule["meta"]["id"];
37
+ id: Plugin["id"] | MessageLintRule["id"];
38
38
  }>;
39
39
  /**
40
40
  * The resolved plugins.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/resolve-modules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EACX,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,E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5
5
  export * from "@inlang/plugin";
6
- export * from "@inlang/project-config";
6
+ export * from "@inlang/project-settings";
7
7
  export * from "@inlang/translatable";
8
8
  //# sourceMappingURL=versionedInterfaces.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"versionedInterfaces.d.ts","sourceRoot":"","sources":["../src/versionedInterfaces.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA"}
1
+ {"version":3,"file":"versionedInterfaces.d.ts","sourceRoot":"","sources":["../src/versionedInterfaces.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA"}
@@ -4,5 +4,5 @@ export * from "@inlang/language-tag";
4
4
  export * from "@inlang/message-lint-rule";
5
5
  export * from "@inlang/message";
6
6
  export * from "@inlang/plugin";
7
- export * from "@inlang/project-config";
7
+ export * from "@inlang/project-settings";
8
8
  export * from "@inlang/translatable";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.5.0",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -35,14 +35,14 @@
35
35
  "@inlang/language-tag": "*",
36
36
  "@inlang/message": "*",
37
37
  "@inlang/plugin": "*",
38
- "@inlang/project-config": "*",
38
+ "@inlang/project-settings": "*",
39
39
  "@inlang/result": "*",
40
40
  "@lix-js/fs": "*",
41
41
  "@sinclair/typebox": "^0.31.0",
42
42
  "deepmerge-ts": "^5.1.0",
43
43
  "solid-js": "1.6.12",
44
44
  "throttle-debounce": "5.0.0",
45
- "ts-dedent": "2.2.0"
45
+ "dedent": "1.5.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@lix-js/fs": "*",
@@ -3,11 +3,11 @@ import { describe, it, expect } from "vitest"
3
3
  import type { ImportFunction } from "../resolve-modules/index.js"
4
4
  import { createEffect, from, createRoot } from "../reactivity/solid.js"
5
5
  import { solidAdapter } from "./solidAdapter.js"
6
- import { openInlangProject } from "../openInlangProject.js"
6
+ import { loadProject } from "../loadProject.js"
7
7
  import { createNodeishMemoryFs } from "@lix-js/fs"
8
8
  import type {
9
9
  Message,
10
- ProjectConfig,
10
+ ProjectSettings,
11
11
  Plugin,
12
12
  MessageLintRule,
13
13
  Text,
@@ -15,27 +15,23 @@ import type {
15
15
 
16
16
  // ------------------------------------------------------------------------------------------------
17
17
 
18
- const config: ProjectConfig = {
18
+ const config: ProjectSettings = {
19
19
  sourceLanguageTag: "en",
20
20
  languageTags: ["en"],
21
21
  modules: ["plugin.js", "plugin2.js"],
22
- settings: {
23
- "project.messageLintRuleLevels": {
24
- "messageLintRule.inlang.missingTranslation": "error",
25
- },
26
- "plugin.inlang.i18next": {
27
- pathPattern: "./examples/example01/{languageTag}.json",
28
- variableReferencePattern: ["{", "}"],
29
- },
22
+ messageLintRuleLevels: {
23
+ "messageLintRule.project.missingTranslation": "error",
24
+ },
25
+ "plugin.project.i18next": {
26
+ pathPattern: "./examples/example01/{languageTag}.json",
27
+ variableReferencePattern: ["{", "}"],
30
28
  },
31
29
  }
32
30
 
33
31
  const mockPlugin: Plugin = {
34
- meta: {
35
- id: "plugin.inlang.i18next",
36
- description: { en: "Mock plugin description" },
37
- displayName: { en: "Mock Plugin" },
38
- },
32
+ id: "plugin.project.i18next",
33
+ description: { en: "Mock plugin description" },
34
+ displayName: { en: "Mock Plugin" },
39
35
  loadMessages: () => exampleMessages,
40
36
  saveMessages: () => undefined,
41
37
  }
@@ -77,12 +73,10 @@ const exampleMessages: Message[] = [
77
73
  ]
78
74
 
79
75
  const mockLintRule: MessageLintRule = {
80
- meta: {
81
- id: "messageLintRule.namespace.mock",
82
- description: { en: "Mock lint rule description" },
83
- displayName: { en: "Mock Lint Rule" },
84
- },
85
- message: () => undefined,
76
+ id: "messageLintRule.namespace.mock",
77
+ description: { en: "Mock lint rule description" },
78
+ displayName: { en: "Mock Lint Rule" },
79
+ run: () => undefined,
86
80
  }
87
81
 
88
82
  const $import: ImportFunction = async (name) => ({
@@ -95,9 +89,9 @@ describe("config", () => {
95
89
  it("should react to changes in config", async () => {
96
90
  const fs = createNodeishMemoryFs()
97
91
  await fs.writeFile("./project.inlang.json", JSON.stringify(config))
98
- const inlang = solidAdapter(
99
- await openInlangProject({
100
- projectFilePath: "./project.inlang.json",
92
+ const project = solidAdapter(
93
+ await loadProject({
94
+ settingsFilePath: "./project.inlang.json",
101
95
  nodeishFs: fs,
102
96
  _import: $import,
103
97
  }),
@@ -106,18 +100,18 @@ describe("config", () => {
106
100
 
107
101
  let counter = 0
108
102
  createEffect(() => {
109
- inlang.config()
103
+ project.settings()
110
104
  counter += 1
111
105
  })
112
106
 
113
107
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
114
- const newConfig = { ...inlang.config()!, languageTags: ["en", "de"] }
108
+ const newConfig = { ...project.settings()!, languageTags: ["en", "de"] }
115
109
 
116
- inlang.setConfig(newConfig)
110
+ project.setSettings(newConfig)
117
111
  // TODO: how can we await `setConfig` correctly
118
112
  await new Promise((resolve) => setTimeout(resolve, 0))
119
113
  expect(counter).toBe(2) // 2 times because effect creation + set
120
- expect(inlang.config()).toStrictEqual(newConfig)
114
+ expect(project.settings()).toStrictEqual(newConfig)
121
115
  })
122
116
  })
123
117
 
@@ -125,9 +119,9 @@ describe("installed", () => {
125
119
  it("react to changes that are unrelated to installed items", async () => {
126
120
  const fs = createNodeishMemoryFs()
127
121
  await fs.writeFile("./project.inlang.json", JSON.stringify(config))
128
- const inlang = solidAdapter(
129
- await openInlangProject({
130
- projectFilePath: "./project.inlang.json",
122
+ const project = solidAdapter(
123
+ await loadProject({
124
+ settingsFilePath: "./project.inlang.json",
131
125
  nodeishFs: fs,
132
126
  _import: $import,
133
127
  }),
@@ -137,16 +131,16 @@ describe("installed", () => {
137
131
  let counterLint = 0
138
132
 
139
133
  createEffect(() => {
140
- inlang.installed.plugins()
134
+ project.installed.plugins()
141
135
  counterPlugins += 1
142
136
  })
143
137
 
144
138
  createEffect(() => {
145
- inlang.installed.messageLintRules()
139
+ project.installed.messageLintRules()
146
140
  counterLint += 1
147
141
  })
148
142
 
149
- inlang.setConfig({ ...inlang.config()!, languageTags: ["en", "fr"] })
143
+ project.setSettings({ ...project.settings()!, languageTags: ["en", "fr"] })
150
144
 
151
145
  // TODO: how can we await `setConfig` correctly
152
146
  await new Promise((resolve) => setTimeout(resolve, 0))
@@ -159,31 +153,27 @@ describe("installed", () => {
159
153
  describe("messages", () => {
160
154
  it("should react to changes in config", async () => {
161
155
  const fs = createNodeishMemoryFs()
162
- const mockConfig: ProjectConfig = {
156
+ const mockConfig: ProjectSettings = {
163
157
  sourceLanguageTag: "en",
164
158
  languageTags: ["en", "de"],
165
159
  modules: ["./plugin-a.js"],
166
- settings: {
167
- "library.inlang.paraglideJsSveltekit": {
168
- languageNegotiation: {
169
- strategies: [
170
- {
171
- type: "localStorage",
172
- } as any,
173
- ],
174
- },
160
+ "library.project.paraglideJsSveltekit": {
161
+ languageNegotiation: {
162
+ strategies: [
163
+ {
164
+ type: "localStorage",
165
+ } as any,
166
+ ],
175
167
  },
176
168
  },
177
169
  }
178
170
  const mockPlugin: Plugin = {
179
- meta: {
180
- id: "plugin.mock.id",
181
- displayName: {
182
- en: "hello",
183
- },
184
- description: {
185
- en: "wo",
186
- },
171
+ id: "plugin.mock.id",
172
+ displayName: {
173
+ en: "hello",
174
+ },
175
+ description: {
176
+ en: "wo",
187
177
  },
188
178
  loadMessages: ({ languageTags }) => (languageTags.length ? exampleMessages : []),
189
179
  saveMessages: () => undefined,
@@ -192,9 +182,9 @@ describe("messages", () => {
192
182
  const mockImport: ImportFunction = async () => ({ default: mockPlugin })
193
183
 
194
184
  await fs.writeFile("./project.inlang.json", JSON.stringify(mockConfig))
195
- const inlang = solidAdapter(
196
- await openInlangProject({
197
- projectFilePath: "./project.inlang.json",
185
+ const project = solidAdapter(
186
+ await loadProject({
187
+ settingsFilePath: "./project.inlang.json",
198
188
  nodeishFs: fs,
199
189
  _import: mockImport,
200
190
  }),
@@ -203,27 +193,27 @@ describe("messages", () => {
203
193
 
204
194
  let counter = 0
205
195
  createEffect(() => {
206
- inlang.query.messages.getAll()
196
+ project.query.messages.getAll()
207
197
  counter += 1
208
198
  })
209
199
 
210
- expect(Object.values(inlang.query.messages.getAll()).length).toBe(2)
200
+ expect(Object.values(project.query.messages.getAll()).length).toBe(2)
211
201
 
212
- inlang.setConfig({ ...inlang.config()!, languageTags: [] })
202
+ project.setSettings({ ...project.settings()!, languageTags: [] })
213
203
 
214
204
  // TODO: how can we await `setConfig` correctly
215
205
  await new Promise((resolve) => setTimeout(resolve, 0))
216
206
 
217
207
  expect(counter).toBe(2) // 2 times because effect creation + set
218
- expect(Object.values(inlang.query.messages.getAll()).length).toBe(0)
208
+ expect(Object.values(project.query.messages.getAll()).length).toBe(0)
219
209
  })
220
210
 
221
211
  it("should react to changes in messages", async () => {
222
212
  const fs = createNodeishMemoryFs()
223
213
  await fs.writeFile("./project.inlang.json", JSON.stringify(config))
224
- const inlang = solidAdapter(
225
- await openInlangProject({
226
- projectFilePath: "./project.inlang.json",
214
+ const project = solidAdapter(
215
+ await loadProject({
216
+ settingsFilePath: "./project.inlang.json",
227
217
  nodeishFs: fs,
228
218
  _import: $import,
229
219
  }),
@@ -232,11 +222,11 @@ describe("messages", () => {
232
222
 
233
223
  let counter = 0
234
224
  createEffect(() => {
235
- inlang.query.messages.getAll()
225
+ project.query.messages.getAll()
236
226
  counter += 1
237
227
  })
238
228
 
239
- const messagesBefore = inlang.query.messages.getAll
229
+ const messagesBefore = project.query.messages.getAll
240
230
  expect(Object.values(messagesBefore()).length).toBe(2)
241
231
  expect(
242
232
  (
@@ -245,7 +235,7 @@ describe("messages", () => {
245
235
  ).value,
246
236
  ).toBe("test")
247
237
 
248
- inlang.query.messages.update({
238
+ project.query.messages.update({
249
239
  where: { id: "a" },
250
240
  // TODO: use `createMessage` utility
251
241
  data: {
@@ -266,7 +256,7 @@ describe("messages", () => {
266
256
  })
267
257
 
268
258
  expect(counter).toBe(2) // 2 times because effect creation + set
269
- const messagesAfter = inlang.query.messages.getAll
259
+ const messagesAfter = project.query.messages.getAll
270
260
  expect(Object.values(messagesAfter()).length).toBe(2)
271
261
  expect(
272
262
  (
@@ -281,10 +271,10 @@ describe("lint", () => {
281
271
  it.todo("should react to changes in config", async () => {
282
272
  await createRoot(async () => {
283
273
  const fs = createNodeishMemoryFs()
284
- await fs.writeFile("./inlang.config.json", JSON.stringify(config))
285
- const inlang = solidAdapter(
286
- await openInlangProject({
287
- projectFilePath: "./inlang.config.json",
274
+ await fs.writeFile("./project.config.json", JSON.stringify(config))
275
+ const project = solidAdapter(
276
+ await loadProject({
277
+ settingsFilePath: "./project.config.json",
288
278
  nodeishFs: fs,
289
279
  _import: $import,
290
280
  }),
@@ -293,23 +283,23 @@ describe("lint", () => {
293
283
 
294
284
  let counter = 0
295
285
  createEffect(() => {
296
- inlang.query.messageLintReports.getAll()
286
+ project.query.messageLintReports.getAll()
297
287
  counter += 1
298
288
  })
299
289
 
300
- const newConfig = { ...inlang.config()!, languageTags: ["en", "de"] }
301
- inlang.setConfig(newConfig)
290
+ const newConfig = { ...project.settings()!, languageTags: ["en", "de"] }
291
+ project.setSettings(newConfig)
302
292
 
303
293
  expect(counter).toBe(1)
304
- expect(inlang.query.messageLintReports.getAll()).toEqual([])
294
+ expect(project.query.messageLintReports.getAll()).toEqual([])
305
295
 
306
296
  await new Promise((resolve) => setTimeout(resolve, 510))
307
297
 
308
- const newConfig2 = { ...inlang.config()!, languageTags: ["en", "de", "fr"] }
309
- inlang.setConfig(newConfig2)
298
+ const newConfig2 = { ...project.settings()!, languageTags: ["en", "de", "fr"] }
299
+ project.setSettings(newConfig2)
310
300
 
311
301
  expect(counter).toBe(9)
312
- expect(inlang.query.messageLintReports.getAll()).toEqual([])
302
+ expect(project.query.messageLintReports.getAll()).toEqual([])
313
303
  })
314
304
  })
315
305
 
@@ -319,10 +309,10 @@ describe("lint", () => {
319
309
  it.todo("should react to changes to messages", async () => {
320
310
  await createRoot(async () => {
321
311
  const fs = createNodeishMemoryFs()
322
- await fs.writeFile("./inlang.config.json", JSON.stringify(config))
323
- const inlang = solidAdapter(
324
- await openInlangProject({
325
- projectFilePath: "./inlang.config.json",
312
+ await fs.writeFile("./project.config.json", JSON.stringify(config))
313
+ const project = solidAdapter(
314
+ await loadProject({
315
+ settingsFilePath: "./project.config.json",
326
316
  nodeishFs: fs,
327
317
  _import: $import,
328
318
  }),
@@ -331,11 +321,11 @@ describe("lint", () => {
331
321
 
332
322
  let counter = 0
333
323
  createEffect(() => {
334
- inlang.query.messageLintReports.getAll()
324
+ project.query.messageLintReports.getAll()
335
325
  counter += 1
336
326
  })
337
327
 
338
- inlang.query.messages.update({
328
+ project.query.messages.update({
339
329
  where: { id: "a" },
340
330
  data: {
341
331
  ...exampleMessages[0],
@@ -344,11 +334,11 @@ describe("lint", () => {
344
334
  })
345
335
 
346
336
  expect(counter).toBe(1)
347
- expect(inlang.query.messageLintReports.getAll()).toEqual([])
337
+ expect(project.query.messageLintReports.getAll()).toEqual([])
348
338
 
349
339
  await new Promise((resolve) => setTimeout(resolve, 510))
350
340
 
351
- inlang.query.messages.update({
341
+ project.query.messages.update({
352
342
  where: { id: "a" },
353
343
  data: {
354
344
  ...exampleMessages[0],
@@ -357,7 +347,7 @@ describe("lint", () => {
357
347
  })
358
348
 
359
349
  expect(counter).toBe(6)
360
- expect(inlang.query.messageLintReports.getAll()).toEqual([])
350
+ expect(project.query.messageLintReports.getAll()).toEqual([])
361
351
  })
362
352
  })
363
353
  })
@@ -14,13 +14,13 @@ export const solidAdapter = (
14
14
 
15
15
  return {
16
16
  customApi: convert(project.customApi),
17
- config: convert(project.config),
17
+ settings: convert(project.settings),
18
18
  errors: convert(project.errors),
19
19
  installed: {
20
20
  messageLintRules: convert(project.installed.messageLintRules),
21
21
  plugins: convert(project.installed.plugins),
22
22
  },
23
- setConfig: project.setConfig,
23
+ setSettings: project.setSettings,
24
24
  query: {
25
25
  messages: {
26
26
  create: project.query.messages.create,
@@ -51,8 +51,8 @@ export type InlangProjectWithSolidAdapter = {
51
51
  messageLintRules: () => ReturnType<InlangProject["installed"]["messageLintRules"]>
52
52
  }
53
53
  errors: () => ReturnType<InlangProject["errors"]>
54
- config: () => ReturnType<InlangProject["config"]>
55
- setConfig: InlangProject["setConfig"]
54
+ settings: () => ReturnType<InlangProject["settings"]>
55
+ setSettings: InlangProject["setSettings"]
56
56
  query: {
57
57
  messages: {
58
58
  create: MessageQueryApi["create"]
@@ -0,0 +1,8 @@
1
+ import type { ProjectSettings } from "@inlang/project-settings"
2
+ import type { InlangProject } from "./api.js"
3
+ import { expectType } from "tsd"
4
+
5
+ const project: InlangProject = {} as any
6
+
7
+ // it should not have potentially undefined settings.
8
+ expectType<ProjectSettings>(project.settings())