@inlang/sdk 0.1.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 (170) hide show
  1. package/README.md +25 -0
  2. package/dist/adapter/solidAdapter.d.ts +32 -0
  3. package/dist/adapter/solidAdapter.d.ts.map +1 -0
  4. package/dist/adapter/solidAdapter.js +39 -0
  5. package/dist/adapter/solidAdapter.test.d.ts +2 -0
  6. package/dist/adapter/solidAdapter.test.d.ts.map +1 -0
  7. package/dist/adapter/solidAdapter.test.js +284 -0
  8. package/dist/api.d.ts +88 -0
  9. package/dist/api.d.ts.map +1 -0
  10. package/dist/api.js +1 -0
  11. package/dist/createMessageLintReportsQuery.d.ts +9 -0
  12. package/dist/createMessageLintReportsQuery.d.ts.map +1 -0
  13. package/dist/createMessageLintReportsQuery.js +48 -0
  14. package/dist/createMessagesQuery.d.ts +7 -0
  15. package/dist/createMessagesQuery.d.ts.map +1 -0
  16. package/dist/createMessagesQuery.js +57 -0
  17. package/dist/createMessagesQuery.test.d.ts +2 -0
  18. package/dist/createMessagesQuery.test.d.ts.map +1 -0
  19. package/dist/createMessagesQuery.test.js +304 -0
  20. package/dist/errors.d.ts +22 -0
  21. package/dist/errors.d.ts.map +1 -0
  22. package/dist/errors.js +39 -0
  23. package/dist/index.d.ts +15 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +13 -0
  26. package/dist/lint/index.d.ts +3 -0
  27. package/dist/lint/index.d.ts.map +1 -0
  28. package/dist/lint/index.js +2 -0
  29. package/dist/lint/message/errors.d.ts +7 -0
  30. package/dist/lint/message/errors.d.ts.map +1 -0
  31. package/dist/lint/message/errors.js +9 -0
  32. package/dist/lint/message/lintMessages.d.ts +17 -0
  33. package/dist/lint/message/lintMessages.d.ts.map +1 -0
  34. package/dist/lint/message/lintMessages.js +12 -0
  35. package/dist/lint/message/lintMessages.test.d.ts +2 -0
  36. package/dist/lint/message/lintMessages.test.d.ts.map +1 -0
  37. package/dist/lint/message/lintMessages.test.js +105 -0
  38. package/dist/lint/message/lintSingleMessage.d.ts +23 -0
  39. package/dist/lint/message/lintSingleMessage.d.ts.map +1 -0
  40. package/dist/lint/message/lintSingleMessage.js +36 -0
  41. package/dist/lint/message/lintSingleMessage.test.d.ts +2 -0
  42. package/dist/lint/message/lintSingleMessage.test.d.ts.map +1 -0
  43. package/dist/lint/message/lintSingleMessage.test.js +155 -0
  44. package/dist/messages/errors.d.ts +13 -0
  45. package/dist/messages/errors.d.ts.map +1 -0
  46. package/dist/messages/errors.js +18 -0
  47. package/dist/messages/index.d.ts +3 -0
  48. package/dist/messages/index.d.ts.map +1 -0
  49. package/dist/messages/index.js +2 -0
  50. package/dist/messages/variant.d.ts +46 -0
  51. package/dist/messages/variant.d.ts.map +1 -0
  52. package/dist/messages/variant.js +177 -0
  53. package/dist/messages/variant.test.d.ts +2 -0
  54. package/dist/messages/variant.test.d.ts.map +1 -0
  55. package/dist/messages/variant.test.js +379 -0
  56. package/dist/openInlangProject.d.ts +18 -0
  57. package/dist/openInlangProject.d.ts.map +1 -0
  58. package/dist/openInlangProject.js +226 -0
  59. package/dist/openInlangProject.test.d.ts +2 -0
  60. package/dist/openInlangProject.test.d.ts.map +1 -0
  61. package/dist/openInlangProject.test.js +627 -0
  62. package/dist/parseConfig.d.ts +8 -0
  63. package/dist/parseConfig.d.ts.map +1 -0
  64. package/dist/parseConfig.js +26 -0
  65. package/dist/reactivity/map.d.ts +66 -0
  66. package/dist/reactivity/map.d.ts.map +1 -0
  67. package/dist/reactivity/map.js +143 -0
  68. package/dist/reactivity/solid.d.ts +12 -0
  69. package/dist/reactivity/solid.d.ts.map +1 -0
  70. package/dist/reactivity/solid.js +13 -0
  71. package/dist/reactivity/trigger.d.ts +11 -0
  72. package/dist/reactivity/trigger.d.ts.map +1 -0
  73. package/dist/reactivity/trigger.js +46 -0
  74. package/dist/resolve-modules/errors.d.ts +34 -0
  75. package/dist/resolve-modules/errors.d.ts.map +1 -0
  76. package/dist/resolve-modules/errors.js +35 -0
  77. package/dist/resolve-modules/import.d.ts +35 -0
  78. package/dist/resolve-modules/import.d.ts.map +1 -0
  79. package/dist/resolve-modules/import.js +40 -0
  80. package/dist/resolve-modules/import.test.d.ts +2 -0
  81. package/dist/resolve-modules/import.test.d.ts.map +1 -0
  82. package/dist/resolve-modules/import.test.js +45 -0
  83. package/dist/resolve-modules/index.d.ts +3 -0
  84. package/dist/resolve-modules/index.d.ts.map +1 -0
  85. package/dist/resolve-modules/index.js +2 -0
  86. package/dist/resolve-modules/message-lint-rules/errors.d.ts +8 -0
  87. package/dist/resolve-modules/message-lint-rules/errors.d.ts.map +1 -0
  88. package/dist/resolve-modules/message-lint-rules/errors.js +8 -0
  89. package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts +9 -0
  90. package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts.map +1 -0
  91. package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +21 -0
  92. package/dist/resolve-modules/plugins/errors.d.ts +28 -0
  93. package/dist/resolve-modules/plugins/errors.d.ts.map +1 -0
  94. package/dist/resolve-modules/plugins/errors.js +44 -0
  95. package/dist/resolve-modules/plugins/resolvePlugins.d.ts +3 -0
  96. package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +1 -0
  97. package/dist/resolve-modules/plugins/resolvePlugins.js +108 -0
  98. package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts +2 -0
  99. package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts.map +1 -0
  100. package/dist/resolve-modules/plugins/resolvePlugins.test.js +289 -0
  101. package/dist/resolve-modules/plugins/types.d.ts +60 -0
  102. package/dist/resolve-modules/plugins/types.d.ts.map +1 -0
  103. package/dist/resolve-modules/plugins/types.js +1 -0
  104. package/dist/resolve-modules/plugins/types.test.d.ts +2 -0
  105. package/dist/resolve-modules/plugins/types.test.d.ts.map +1 -0
  106. package/dist/resolve-modules/plugins/types.test.js +49 -0
  107. package/dist/resolve-modules/resolveModules.d.ts +3 -0
  108. package/dist/resolve-modules/resolveModules.d.ts.map +1 -0
  109. package/dist/resolve-modules/resolveModules.js +70 -0
  110. package/dist/resolve-modules/resolveModules.test.d.ts +2 -0
  111. package/dist/resolve-modules/resolveModules.test.d.ts.map +1 -0
  112. package/dist/resolve-modules/resolveModules.test.js +143 -0
  113. package/dist/resolve-modules/types.d.ts +62 -0
  114. package/dist/resolve-modules/types.d.ts.map +1 -0
  115. package/dist/resolve-modules/types.js +1 -0
  116. package/dist/test-utilities/createMessage.d.ts +17 -0
  117. package/dist/test-utilities/createMessage.d.ts.map +1 -0
  118. package/dist/test-utilities/createMessage.js +16 -0
  119. package/dist/test-utilities/createMessage.test.d.ts +2 -0
  120. package/dist/test-utilities/createMessage.test.d.ts.map +1 -0
  121. package/dist/test-utilities/createMessage.test.js +91 -0
  122. package/dist/test-utilities/index.d.ts +2 -0
  123. package/dist/test-utilities/index.d.ts.map +1 -0
  124. package/dist/test-utilities/index.js +1 -0
  125. package/dist/versionedInterfaces.d.ts +8 -0
  126. package/dist/versionedInterfaces.d.ts.map +1 -0
  127. package/dist/versionedInterfaces.js +8 -0
  128. package/package.json +58 -0
  129. package/src/adapter/solidAdapter.test.ts +363 -0
  130. package/src/adapter/solidAdapter.ts +77 -0
  131. package/src/api.ts +86 -0
  132. package/src/createMessageLintReportsQuery.ts +77 -0
  133. package/src/createMessagesQuery.test.ts +435 -0
  134. package/src/createMessagesQuery.ts +64 -0
  135. package/src/errors.ts +46 -0
  136. package/src/index.ts +29 -0
  137. package/src/lint/index.ts +2 -0
  138. package/src/lint/message/errors.ts +9 -0
  139. package/src/lint/message/lintMessages.test.ts +122 -0
  140. package/src/lint/message/lintMessages.ts +33 -0
  141. package/src/lint/message/lintSingleMessage.test.ts +183 -0
  142. package/src/lint/message/lintSingleMessage.ts +62 -0
  143. package/src/messages/errors.ts +25 -0
  144. package/src/messages/index.ts +2 -0
  145. package/src/messages/variant.test.ts +444 -0
  146. package/src/messages/variant.ts +242 -0
  147. package/src/openInlangProject.test.ts +734 -0
  148. package/src/openInlangProject.ts +337 -0
  149. package/src/parseConfig.ts +33 -0
  150. package/src/reactivity/map.ts +135 -0
  151. package/src/reactivity/solid.ts +36 -0
  152. package/src/reactivity/trigger.ts +46 -0
  153. package/src/resolve-modules/errors.ts +39 -0
  154. package/src/resolve-modules/import.test.ts +58 -0
  155. package/src/resolve-modules/import.ts +69 -0
  156. package/src/resolve-modules/index.ts +2 -0
  157. package/src/resolve-modules/message-lint-rules/errors.ts +9 -0
  158. package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +24 -0
  159. package/src/resolve-modules/plugins/errors.ts +57 -0
  160. package/src/resolve-modules/plugins/resolvePlugins.test.ts +340 -0
  161. package/src/resolve-modules/plugins/resolvePlugins.ts +170 -0
  162. package/src/resolve-modules/plugins/types.test.ts +57 -0
  163. package/src/resolve-modules/plugins/types.ts +77 -0
  164. package/src/resolve-modules/resolveModules.test.ts +176 -0
  165. package/src/resolve-modules/resolveModules.ts +97 -0
  166. package/src/resolve-modules/types.ts +71 -0
  167. package/src/test-utilities/createMessage.test.ts +100 -0
  168. package/src/test-utilities/createMessage.ts +20 -0
  169. package/src/test-utilities/index.ts +1 -0
  170. package/src/versionedInterfaces.ts +9 -0
@@ -0,0 +1,143 @@
1
+ import { expect, it } from "vitest";
2
+ import { ModuleError, ModuleExportIsInvalidError, ModuleHasNoExportsError, ModuleImportError, } from "./errors.js";
3
+ import { resolveModules } from "./resolveModules.js";
4
+ it("should return an error if a plugin cannot be imported", async () => {
5
+ const config = {
6
+ sourceLanguageTag: "en",
7
+ languageTags: ["de", "en"],
8
+ modules: ["https://myplugin.com/index.js"],
9
+ settings: {},
10
+ };
11
+ const resolved = await resolveModules({
12
+ config,
13
+ nodeishFs: {},
14
+ _import: () => {
15
+ throw new ModuleImportError("Could not import", {
16
+ module: config.modules[0],
17
+ cause: new Error("Could not import"),
18
+ });
19
+ },
20
+ });
21
+ expect(resolved.errors[0]).toBeInstanceOf(ModuleImportError);
22
+ });
23
+ it("should resolve plugins and message lint rules successfully", async () => {
24
+ // Define mock data
25
+ const mockPlugin = {
26
+ meta: {
27
+ id: "plugin.namespace.mock",
28
+ description: { en: "Mock plugin description" },
29
+ displayName: { en: "Mock Plugin" },
30
+ },
31
+ loadMessages: () => undefined,
32
+ saveMessages: () => undefined,
33
+ addCustomApi: () => ({
34
+ "app.inlang.ideExtension": {
35
+ messageReferenceMatcher: () => undefined,
36
+ },
37
+ }),
38
+ };
39
+ 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,
46
+ };
47
+ const config = {
48
+ sourceLanguageTag: "en",
49
+ languageTags: ["de", "en"],
50
+ modules: ["lint-rule.js", "plugin.js"],
51
+ settings: {},
52
+ };
53
+ const _import = async (name) => {
54
+ if (name === "lint-rule.js") {
55
+ return {
56
+ default: mockMessageLintRule,
57
+ };
58
+ }
59
+ else {
60
+ return {
61
+ default: mockPlugin,
62
+ };
63
+ }
64
+ };
65
+ // Call the function
66
+ const resolved = await resolveModules({ config, _import, nodeishFs: {} });
67
+ // Assert results
68
+ expect(resolved.errors).toHaveLength(0);
69
+ // Check for the meta data of the plugin
70
+ expect(resolved.plugins.some((module) => module.meta.id === mockPlugin.meta.id)).toBeDefined();
71
+ // Check for the app specific api
72
+ expect(resolved.resolvedPluginApi["customApi"]?.["app.inlang.ideExtension"]).toBeDefined();
73
+ // Check for the lint rule
74
+ expect(resolved.messageLintRules[0]?.meta.id).toBe(mockMessageLintRule.meta.id);
75
+ });
76
+ it("should return an error if a module cannot be imported", async () => {
77
+ const config = {
78
+ sourceLanguageTag: "en",
79
+ languageTags: ["de", "en"],
80
+ modules: ["https://myplugin.com/index.js"],
81
+ settings: {},
82
+ };
83
+ const _import = async () => {
84
+ throw new ModuleImportError("Could not import", {
85
+ module: config.modules[0],
86
+ cause: new Error(),
87
+ });
88
+ };
89
+ // Call the function
90
+ const resolved = await resolveModules({ config, _import, nodeishFs: {} });
91
+ // Assert results
92
+ expect(resolved.errors[0]).toBeInstanceOf(ModuleImportError);
93
+ });
94
+ it("should return an error if a module does not export any plugins or lint rules", async () => {
95
+ const config = {
96
+ sourceLanguageTag: "en",
97
+ languageTags: ["de", "en"],
98
+ modules: ["https://myplugin.com/index.js"],
99
+ settings: {},
100
+ };
101
+ const _import = async () => ({
102
+ default: {},
103
+ });
104
+ // Call the function
105
+ const resolved = await resolveModules({ config, _import, nodeishFs: {} });
106
+ // Assert results
107
+ expect(resolved.errors[0]).toBeInstanceOf(ModuleHasNoExportsError);
108
+ });
109
+ it("should return an error if a module exports an invalid plugin or lint rule", async () => {
110
+ const config = {
111
+ sourceLanguageTag: "en",
112
+ languageTags: ["de", "en"],
113
+ modules: ["https://myplugin.com/index.js"],
114
+ settings: {},
115
+ };
116
+ const _import = async () => ({
117
+ default: {
118
+ // @ts-expect-error - invalid meta of a plugin
119
+ meta: {
120
+ id: "plugin.namespace.mock",
121
+ description: { en: "Mock plugin description" },
122
+ },
123
+ },
124
+ });
125
+ const resolved = await resolveModules({ config, _import, nodeishFs: {} });
126
+ expect(resolved.errors[0]).toBeInstanceOf(ModuleExportIsInvalidError);
127
+ });
128
+ it("should handle other unhandled errors during plugin resolution", async () => {
129
+ const errorMessage = "Unhandled error during plugin resolution";
130
+ const config = {
131
+ sourceLanguageTag: "en",
132
+ languageTags: ["de", "en"],
133
+ modules: ["https://myplugin.com/index.js"],
134
+ settings: {},
135
+ };
136
+ const _import = async () => {
137
+ throw new Error(errorMessage);
138
+ };
139
+ // Call the function
140
+ const resolved = await resolveModules({ config, _import, nodeishFs: {} });
141
+ // Assert results
142
+ expect(resolved.errors[0]).toBeInstanceOf(ModuleError);
143
+ });
@@ -0,0 +1,62 @@
1
+ import type { ProjectConfig } from "@inlang/project-config";
2
+ import type { MessageLintRule } from "@inlang/message-lint-rule";
3
+ import type { Plugin } from "@inlang/plugin";
4
+ import type { NodeishFilesystemSubset, ResolvePluginsFunction, ResolvedPluginApi } from "./plugins/types.js";
5
+ import type { ModuleHasNoExportsError, ModuleImportError } from "./errors.js";
6
+ import type { ImportFunction } from "./import.js";
7
+ import type { resolveMessageLintRules } from "./message-lint-rules/resolveMessageLintRules.js";
8
+ /**
9
+ * Function that resolves modules from the config.
10
+ *
11
+ * Pass a custom `_import` function to override the default import function.
12
+ */
13
+ export type ResolveModuleFunction = (args: {
14
+ config: ProjectConfig;
15
+ nodeishFs: NodeishFilesystemSubset;
16
+ _import?: ImportFunction;
17
+ }) => Promise<{
18
+ /**
19
+ * Metadata about the resolved module.
20
+ *
21
+ * @example
22
+ * [{
23
+ * id: "plugin.inlang.json",
24
+ * module: "https://myplugin.com/index.js"
25
+ * }]
26
+ */
27
+ meta: Array<{
28
+ /**
29
+ * The module link.
30
+ *
31
+ * @example "https://myplugin.com/index.js"
32
+ */
33
+ module: string;
34
+ /**
35
+ * The resolved item id of the module.
36
+ */
37
+ id: Plugin["meta"]["id"] | MessageLintRule["meta"]["id"];
38
+ }>;
39
+ /**
40
+ * The resolved plugins.
41
+ */
42
+ plugins: Array<Plugin>;
43
+ /**
44
+ * The resolved message lint rules.
45
+ */
46
+ messageLintRules: Array<MessageLintRule>;
47
+ /**
48
+ * The resolved api provided by plugins.
49
+ */
50
+ resolvedPluginApi: ResolvedPluginApi;
51
+ /**
52
+ * Errors during the resolution process.
53
+ *
54
+ * This includes errors from:
55
+ * - importing module
56
+ * - resolving plugins
57
+ * - resolving lint rules
58
+ * - resolving the runtime plugin api
59
+ */
60
+ errors: Array<ModuleHasNoExportsError | ModuleImportError | Awaited<ReturnType<ResolvePluginsFunction>>["errors"][number] | Awaited<ReturnType<typeof resolveMessageLintRules>>["errors"][number]>;
61
+ }>;
62
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAA;AAE9F;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,aAAa,CAAA;IACrB,SAAS,EAAE,uBAAuB,CAAA;IAClC,OAAO,CAAC,EAAE,cAAc,CAAA;CACxB,KAAK,OAAO,CAAC;IACb;;;;;;;;OAQG;IACH,IAAI,EAAE,KAAK,CAAC;QACX;;;;WAIG;QACH,MAAM,EAAE,MAAM,CAAA;QACd;;WAEG;QACH,EAAE,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAA;KACxD,CAAC,CAAA;IACF;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACtB;;OAEG;IACH,gBAAgB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAA;IACxC;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAA;IACpC;;;;;;;;OAQG;IACH,MAAM,EAAE,KAAK,CACV,uBAAuB,GACvB,iBAAiB,GACjB,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAC7D,OAAO,CAAC,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CACvE,CAAA;CACD,CAAC,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { Pattern } from "@inlang/message";
2
+ export declare const createMessage: (id: string, patterns: Record<string, Pattern | string>) => {
3
+ id: string;
4
+ selectors: never[];
5
+ variants: {
6
+ languageTag: string;
7
+ match: {};
8
+ pattern: ({
9
+ type: "Text";
10
+ value: string;
11
+ } | {
12
+ name: string;
13
+ type: "VariableReference";
14
+ })[];
15
+ }[];
16
+ };
17
+ //# sourceMappingURL=createMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMessage.d.ts","sourceRoot":"","sources":["../../src/test-utilities/createMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEvD,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAY,OAAO,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;;;;;;;;;;;;;;CAiB/D,CAAA"}
@@ -0,0 +1,16 @@
1
+ export const createMessage = (id, patterns) => ({
2
+ id,
3
+ selectors: [],
4
+ variants: Object.entries(patterns).map(([languageTag, patterns]) => ({
5
+ languageTag,
6
+ match: {},
7
+ pattern: typeof patterns === "string"
8
+ ? [
9
+ {
10
+ type: "Text",
11
+ value: patterns,
12
+ },
13
+ ]
14
+ : patterns,
15
+ })),
16
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=createMessage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createMessage.test.d.ts","sourceRoot":"","sources":["../../src/test-utilities/createMessage.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,91 @@
1
+ import { expect, test } from "vitest";
2
+ import { createMessage } from "./createMessage.js";
3
+ test("should create a simple message", () => {
4
+ expect(createMessage("welcome", {
5
+ de: "Hallo inlang",
6
+ })).toMatchInlineSnapshot(`
7
+ {
8
+ "id": "welcome",
9
+ "selectors": [],
10
+ "variants": [
11
+ {
12
+ "languageTag": "de",
13
+ "match": {},
14
+ "pattern": [
15
+ {
16
+ "type": "Text",
17
+ "value": "Hallo inlang",
18
+ },
19
+ ],
20
+ },
21
+ ],
22
+ }
23
+ `);
24
+ });
25
+ test("should create a message with pattern", () => {
26
+ expect(createMessage("greeting", {
27
+ en: [
28
+ { type: "Text", value: "Hi " },
29
+ { type: "VariableReference", name: "name" },
30
+ { type: "Text", value: '"' },
31
+ ],
32
+ })).toMatchInlineSnapshot(`
33
+ {
34
+ "id": "greeting",
35
+ "selectors": [],
36
+ "variants": [
37
+ {
38
+ "languageTag": "en",
39
+ "match": {},
40
+ "pattern": [
41
+ {
42
+ "type": "Text",
43
+ "value": "Hi ",
44
+ },
45
+ {
46
+ "name": "name",
47
+ "type": "VariableReference",
48
+ },
49
+ {
50
+ "type": "Text",
51
+ "value": "\\"",
52
+ },
53
+ ],
54
+ },
55
+ ],
56
+ }
57
+ `);
58
+ });
59
+ test("should create a message with a pattern", () => {
60
+ expect(createMessage("welcome", {
61
+ en: "hello inlang",
62
+ de: [{ type: "Text", value: "Hallo inlang" }],
63
+ })).toMatchInlineSnapshot(`
64
+ {
65
+ "id": "welcome",
66
+ "selectors": [],
67
+ "variants": [
68
+ {
69
+ "languageTag": "en",
70
+ "match": {},
71
+ "pattern": [
72
+ {
73
+ "type": "Text",
74
+ "value": "hello inlang",
75
+ },
76
+ ],
77
+ },
78
+ {
79
+ "languageTag": "de",
80
+ "match": {},
81
+ "pattern": [
82
+ {
83
+ "type": "Text",
84
+ "value": "Hallo inlang",
85
+ },
86
+ ],
87
+ },
88
+ ],
89
+ }
90
+ `);
91
+ });
@@ -0,0 +1,2 @@
1
+ export { createMessage } from "./createMessage.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-utilities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1 @@
1
+ export { createMessage } from "./createMessage.js";
@@ -0,0 +1,8 @@
1
+ export * from "@inlang/json-types";
2
+ export * from "@inlang/language-tag";
3
+ export * from "@inlang/message-lint-rule";
4
+ export * from "@inlang/message";
5
+ export * from "@inlang/plugin";
6
+ export * from "@inlang/project-config";
7
+ export * from "@inlang/translatable";
8
+ //# sourceMappingURL=versionedInterfaces.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,8 @@
1
+ // Re-exporting for easier importing
2
+ export * from "@inlang/json-types";
3
+ export * from "@inlang/language-tag";
4
+ export * from "@inlang/message-lint-rule";
5
+ export * from "@inlang/message";
6
+ export * from "@inlang/plugin";
7
+ export * from "@inlang/project-config";
8
+ export * from "@inlang/translatable";
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@inlang/sdk",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "license": "Apache-2.0",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "exports": {
10
+ ".": "./dist/index.js",
11
+ "./test-utilities": "./dist/test-utilities/index.js",
12
+ "./lint": "./dist/lint/index.js",
13
+ "./messages": "./dist/messages/index.js"
14
+ },
15
+ "files": [
16
+ "./dist",
17
+ "./src"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc --build",
21
+ "dev": "tsc --watch",
22
+ "test": "tsc --noEmit && vitest run --passWithNoTests --coverage",
23
+ "lint": "eslint ./src --fix",
24
+ "format": "prettier ./src --write",
25
+ "clean": "rm -rf ./dist ./.turbo ./node_modules"
26
+ },
27
+ "engines": {
28
+ "node": ">=18.0.0"
29
+ },
30
+ "dependencies": {
31
+ "@inlang/json-types": "*",
32
+ "@inlang/translatable": "*",
33
+ "@inlang/message-lint-rule": "*",
34
+ "@inlang/module": "*",
35
+ "@inlang/language-tag": "*",
36
+ "@inlang/message": "*",
37
+ "@inlang/plugin": "*",
38
+ "@inlang/project-config": "*",
39
+ "@inlang/result": "*",
40
+ "@lix-js/fs": "*",
41
+ "@sinclair/typebox": "^0.31.0",
42
+ "deepmerge-ts": "^5.1.0",
43
+ "solid-js": "1.6.12",
44
+ "throttle-debounce": "5.0.0",
45
+ "ts-dedent": "2.2.0"
46
+ },
47
+ "devDependencies": {
48
+ "@placeholder-company/js-code-style": "*",
49
+ "@lix-js/fs": "*",
50
+ "@types/throttle-debounce": "5.0.0",
51
+ "@vitest/coverage-v8": "^0.33.0",
52
+ "jsdom": "22.1.0",
53
+ "patch-package": "6.5.1",
54
+ "tsd": "^0.25.0",
55
+ "typescript": "5.2.2",
56
+ "vitest": "^0.33.0"
57
+ }
58
+ }