@inlang/sdk 0.36.4 → 2.0.0-beta.2
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/README.md +1 -1
- package/dist/database/initDb.d.ts +7 -0
- package/dist/database/initDb.d.ts.map +1 -0
- package/dist/database/initDb.js +36 -0
- package/dist/database/initDb.js.map +1 -0
- package/dist/database/initDbAndSchema.test.d.ts +2 -0
- package/dist/database/initDbAndSchema.test.d.ts.map +1 -0
- package/dist/database/initDbAndSchema.test.js +110 -0
- package/dist/database/initDbAndSchema.test.js.map +1 -0
- package/dist/database/jsonbPlugin.d.ts +20 -0
- package/dist/database/jsonbPlugin.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.js +183 -0
- package/dist/database/jsonbPlugin.js.map +1 -0
- package/dist/database/jsonbPlugin.test.d.ts +2 -0
- package/dist/database/jsonbPlugin.test.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.test.js +119 -0
- package/dist/database/jsonbPlugin.test.js.map +1 -0
- package/dist/database/schema.d.ts +74 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +45 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/helper.d.ts +71 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +91 -0
- package/dist/helper.js.map +1 -0
- package/dist/human-id/human-id.d.ts +3 -0
- package/dist/human-id/human-id.d.ts.map +1 -0
- package/dist/human-id/human-id.js +12 -0
- package/dist/human-id/human-id.js.map +1 -0
- package/dist/human-id/words.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.js +4 -0
- package/dist/human-id/words.js.map +1 -0
- package/dist/human-id/words.test.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.test.js +4 -0
- package/dist/human-id/words.test.js.map +1 -0
- package/dist/import-export/exportFiles.d.ts +11 -0
- package/dist/import-export/exportFiles.d.ts.map +1 -0
- package/dist/import-export/exportFiles.js +26 -0
- package/dist/import-export/exportFiles.js.map +1 -0
- package/dist/import-export/importFiles.d.ts +13 -0
- package/dist/import-export/importFiles.d.ts.map +1 -0
- package/dist/import-export/importFiles.js +124 -0
- package/dist/import-export/importFiles.js.map +1 -0
- package/dist/import-export/importFiles.test.d.ts +2 -0
- package/dist/import-export/importFiles.test.d.ts.map +1 -0
- package/dist/import-export/importFiles.test.js +179 -0
- package/dist/import-export/importFiles.test.js.map +1 -0
- package/dist/import-export/roundtrip.test.d.ts +2 -0
- package/dist/import-export/roundtrip.test.d.ts.map +1 -0
- package/dist/import-export/roundtrip.test.js +273 -0
- package/dist/import-export/roundtrip.test.js.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts +4 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js +58 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -0
- package/dist/index.d.ts +21 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js +84 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts +86 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.js +35 -0
- package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js +67 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -0
- package/dist/json-schema/pattern.d.ts +190 -0
- package/dist/json-schema/pattern.d.ts.map +1 -0
- package/dist/json-schema/pattern.js +43 -0
- package/dist/json-schema/pattern.js.map +1 -0
- package/dist/json-schema/settings.d.ts +31 -0
- package/dist/json-schema/settings.d.ts.map +1 -0
- package/dist/json-schema/settings.js +96 -0
- package/dist/json-schema/settings.js.map +1 -0
- package/dist/json-schema/settings.test-d.d.ts +2 -0
- package/dist/json-schema/settings.test-d.d.ts.map +1 -0
- package/dist/json-schema/settings.test-d.js +20 -0
- package/dist/json-schema/settings.test-d.js.map +1 -0
- package/dist/lix-plugin/applyChanges.d.ts +3 -0
- package/dist/lix-plugin/applyChanges.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.js +127 -0
- package/dist/lix-plugin/applyChanges.js.map +1 -0
- package/dist/lix-plugin/applyChanges.test.d.ts +2 -0
- package/dist/lix-plugin/applyChanges.test.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.test.js +135 -0
- package/dist/lix-plugin/applyChanges.test.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.d.ts +3 -0
- package/dist/lix-plugin/detectConflicts.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.js +47 -0
- package/dist/lix-plugin/detectConflicts.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts +2 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.js +251 -0
- package/dist/lix-plugin/detectConflicts.test.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts +8 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.js +109 -0
- package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts +2 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js +418 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -0
- package/dist/lix-plugin/merge.test.d.ts +2 -0
- package/dist/lix-plugin/merge.test.d.ts.map +1 -0
- package/dist/lix-plugin/merge.test.js +120 -0
- package/dist/lix-plugin/merge.test.js.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts +2 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js +176 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -0
- package/dist/migrations/v2/createMessageV1.d.ts +28 -0
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -0
- package/dist/migrations/v2/createMessageV1.js +31 -0
- package/dist/migrations/v2/createMessageV1.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts +9 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +31 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts +2 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +45 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -0
- package/dist/plugin/cache.d.ts +6 -0
- package/dist/plugin/cache.d.ts.map +1 -0
- package/dist/plugin/cache.js +59 -0
- package/dist/plugin/cache.js.map +1 -0
- package/dist/plugin/cache.test.d.ts +2 -0
- package/dist/plugin/cache.test.d.ts.map +1 -0
- package/dist/plugin/cache.test.js +61 -0
- package/dist/plugin/cache.test.js.map +1 -0
- package/dist/plugin/errors.d.ts +41 -0
- package/dist/plugin/errors.d.ts.map +1 -0
- package/dist/plugin/errors.js +48 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/importPlugins.d.ts +19 -0
- package/dist/plugin/importPlugins.d.ts.map +1 -0
- package/dist/plugin/importPlugins.js +43 -0
- package/dist/plugin/importPlugins.js.map +1 -0
- package/dist/plugin/importPlugins.test.d.ts +2 -0
- package/dist/plugin/importPlugins.test.d.ts.map +1 -0
- package/dist/plugin/importPlugins.test.js +95 -0
- package/dist/plugin/importPlugins.test.js.map +1 -0
- package/dist/plugin/meta/ideExtension.d.ts +54 -0
- package/dist/plugin/meta/ideExtension.d.ts.map +1 -0
- package/dist/plugin/meta/ideExtension.js +5 -0
- package/dist/plugin/meta/ideExtension.js.map +1 -0
- package/dist/plugin/schema.d.ts +152 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/schema.js +5 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/project/api.d.ts +74 -0
- package/dist/project/api.d.ts.map +1 -0
- package/dist/project/api.js +5 -0
- package/dist/project/api.js.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts +14 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.js +87 -0
- package/dist/project/initHandleSaveToLixOnChange.js.map +1 -0
- package/dist/project/loadProject.d.ts +53 -0
- package/dist/project/loadProject.d.ts.map +1 -0
- package/dist/project/loadProject.js +168 -0
- package/dist/project/loadProject.js.map +1 -0
- package/dist/project/loadProject.test.d.ts.map +1 -0
- package/dist/project/loadProject.test.js +146 -0
- package/dist/project/loadProject.test.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.d.ts +77 -0
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.js +584 -0
- package/dist/project/loadProjectFromDirectory.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts +2 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.js +663 -0
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -0
- package/dist/project/loadProjectInMemory.d.ts +8 -0
- package/dist/project/loadProjectInMemory.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.js +32 -0
- package/dist/project/loadProjectInMemory.js.map +1 -0
- package/dist/project/loadProjectInMemory.test.d.ts +2 -0
- package/dist/project/loadProjectInMemory.test.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.test.js +27 -0
- package/dist/project/loadProjectInMemory.test.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.d.ts +15 -0
- package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.js +58 -0
- package/dist/project/maybeCaptureTelemetry.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts +2 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.js +71 -0
- package/dist/project/maybeCaptureTelemetry.test.js.map +1 -0
- package/dist/project/newProject.d.ts +17 -0
- package/dist/project/newProject.d.ts.map +1 -0
- package/dist/project/newProject.js +71 -0
- package/dist/project/newProject.js.map +1 -0
- package/dist/project/newProject.test.d.ts +2 -0
- package/dist/project/newProject.test.d.ts.map +1 -0
- package/dist/project/newProject.test.js +37 -0
- package/dist/project/newProject.test.js.map +1 -0
- package/dist/project/saveProjectToDirectory.d.ts +8 -0
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.js +86 -0
- package/dist/project/saveProjectToDirectory.js.map +1 -0
- package/dist/project/saveProjectToDirectory.test.d.ts +2 -0
- package/dist/project/saveProjectToDirectory.test.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.test.js +245 -0
- package/dist/project/saveProjectToDirectory.test.js.map +1 -0
- package/dist/project/state/id$.d.ts +6 -0
- package/dist/project/state/id$.d.ts.map +1 -0
- package/dist/project/state/id$.js +19 -0
- package/dist/project/state/id$.js.map +1 -0
- package/dist/project/state/id$.test.d.ts +2 -0
- package/dist/project/state/id$.test.d.ts.map +1 -0
- package/dist/project/state/id$.test.js +36 -0
- package/dist/project/state/id$.test.js.map +1 -0
- package/dist/project/state/setSettings.d.ts +7 -0
- package/dist/project/state/setSettings.d.ts.map +1 -0
- package/dist/project/state/setSettings.js +16 -0
- package/dist/project/state/setSettings.js.map +1 -0
- package/dist/project/state/setSettings.test.d.ts +2 -0
- package/dist/project/state/setSettings.test.d.ts.map +1 -0
- package/dist/project/state/setSettings.test.js +58 -0
- package/dist/project/state/setSettings.test.js.map +1 -0
- package/dist/project/state/settings$.d.ts +7 -0
- package/dist/project/state/settings$.d.ts.map +1 -0
- package/dist/project/state/settings$.js +21 -0
- package/dist/project/state/settings$.js.map +1 -0
- package/dist/project/state/settings$.test.d.ts +2 -0
- package/dist/project/state/settings$.test.d.ts.map +1 -0
- package/dist/project/state/settings$.test.js +51 -0
- package/dist/project/state/settings$.test.js.map +1 -0
- package/dist/project/state/state.d.ts +58 -0
- package/dist/project/state/state.d.ts.map +1 -0
- package/dist/project/state/state.js +67 -0
- package/dist/project/state/state.js.map +1 -0
- package/dist/project/state/state.test.d.ts +2 -0
- package/dist/project/state/state.test.d.ts.map +1 -0
- package/dist/project/state/state.test.js +103 -0
- package/dist/project/state/state.test.js.map +1 -0
- package/dist/query-utilities/index.d.ts +5 -0
- package/dist/query-utilities/index.d.ts.map +1 -0
- package/dist/query-utilities/index.js +8 -0
- package/dist/query-utilities/index.js.map +1 -0
- package/dist/query-utilities/insertBundleNested.d.ts +4 -0
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/insertBundleNested.js +39 -0
- package/dist/query-utilities/insertBundleNested.js.map +1 -0
- package/dist/query-utilities/pollQuery.d.ts +14 -0
- package/dist/query-utilities/pollQuery.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.js +22 -0
- package/dist/query-utilities/pollQuery.js.map +1 -0
- package/dist/query-utilities/pollQuery.test.d.ts +2 -0
- package/dist/query-utilities/pollQuery.test.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.test.js +67 -0
- package/dist/query-utilities/pollQuery.test.js.map +1 -0
- package/dist/query-utilities/selectBundleNested.d.ts +107 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/selectBundleNested.js +43 -0
- package/dist/query-utilities/selectBundleNested.js.map +1 -0
- package/dist/query-utilities/updateBundleNested.d.ts +12 -0
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/updateBundleNested.js +25 -0
- package/dist/query-utilities/updateBundleNested.js.map +1 -0
- package/dist/query-utilities/upsertBundleNested.d.ts +4 -0
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/upsertBundleNested.js +50 -0
- package/dist/query-utilities/upsertBundleNested.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +6 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +9 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/error-reporting/index.d.ts +15 -0
- package/dist/services/error-reporting/index.d.ts.map +1 -0
- package/dist/services/error-reporting/index.js +30 -0
- package/dist/services/error-reporting/index.js.map +1 -0
- package/dist/{telemetry → services/telemetry}/capture.d.ts +5 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +76 -0
- package/dist/services/telemetry/capture.js.map +1 -0
- package/dist/services/telemetry/capture.test.d.ts +2 -0
- package/dist/services/telemetry/capture.test.d.ts.map +1 -0
- package/dist/services/telemetry/capture.test.js +46 -0
- package/dist/services/telemetry/capture.test.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.d.ts +11 -0
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.js +83 -0
- package/dist/utilities/detectJsonFormatting.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts +2 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.js +33 -0
- package/dist/utilities/detectJsonFormatting.test.js.map +1 -0
- package/package.json +32 -40
- package/src/database/initDb.ts +34 -0
- package/src/database/initDbAndSchema.test.ts +125 -0
- package/src/database/jsonbPlugin.test.ts +154 -0
- package/src/database/jsonbPlugin.ts +215 -0
- package/src/database/schema.ts +127 -0
- package/src/helper.ts +113 -0
- package/src/human-id/human-id.ts +14 -0
- package/src/{storage/human-id → human-id}/words.test.ts +14 -14
- package/src/{storage/human-id → human-id}/words.ts +4 -4
- package/src/import-export/exportFiles.ts +36 -0
- package/src/import-export/importFiles.test.ts +211 -0
- package/src/import-export/importFiles.ts +142 -0
- package/src/import-export/roundtrip.test.ts +313 -0
- package/src/import-export/upsertBundleNestedMatchByProperties.ts +74 -0
- package/src/index.ts +29 -37
- package/src/json-schema/old-v1-message/README.md +1 -0
- package/src/json-schema/old-v1-message/fromMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/fromMessageV1.ts +99 -0
- package/src/json-schema/old-v1-message/schemaV1.ts +66 -0
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +79 -0
- package/src/json-schema/pattern.ts +59 -0
- package/src/json-schema/settings.test-d.ts +21 -0
- package/src/json-schema/settings.ts +138 -0
- package/src/lix-plugin/applyChanges.test.ts +150 -0
- package/src/lix-plugin/applyChanges.ts +171 -0
- package/src/lix-plugin/detectConflicts.test.ts +286 -0
- package/src/lix-plugin/detectConflicts.ts +62 -0
- package/src/lix-plugin/inlangLixPluginV1.test.ts +439 -0
- package/src/lix-plugin/inlangLixPluginV1.ts +132 -0
- package/src/lix-plugin/merge.test.ts +133 -0
- package/src/lix-plugin/resolveConflictBySelecting.test.ts +188 -0
- package/src/migrations/v2/createMessageV1.ts +37 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.test.ts +51 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.ts +31 -0
- package/src/plugin/cache.test.ts +83 -0
- package/src/plugin/cache.ts +79 -0
- package/src/plugin/errors.ts +67 -0
- package/src/plugin/importPlugins.test.ts +107 -0
- package/src/plugin/importPlugins.ts +60 -0
- package/src/plugin/meta/ideExtension.ts +56 -0
- package/src/plugin/schema.ts +165 -0
- package/src/project/api.ts +77 -0
- package/src/project/initHandleSaveToLixOnChange.ts +93 -0
- package/src/project/loadProject.test.ts +176 -0
- package/src/project/loadProject.ts +246 -0
- package/src/project/loadProjectFromDirectory.test.ts +854 -0
- package/src/project/loadProjectFromDirectory.ts +752 -0
- package/src/project/loadProjectInMemory.test.ts +29 -0
- package/src/project/loadProjectInMemory.ts +36 -0
- package/src/project/maybeCaptureTelemetry.test.ts +79 -0
- package/src/project/maybeCaptureTelemetry.ts +69 -0
- package/src/project/newProject.test.ts +36 -0
- package/src/project/newProject.ts +78 -0
- package/src/project/saveProjectToDirectory.test.ts +310 -0
- package/src/project/saveProjectToDirectory.ts +100 -0
- package/src/query-utilities/index.ts +4 -0
- package/src/query-utilities/insertBundleNested.ts +46 -0
- package/src/query-utilities/selectBundleNested.ts +46 -0
- package/src/query-utilities/updateBundleNested.ts +35 -0
- package/src/query-utilities/upsertBundleNested.ts +61 -0
- package/src/services/env-variables/createIndexFile.js +40 -0
- package/src/{env-variables → services/env-variables}/index.d.ts +8 -5
- package/src/services/error-reporting/index.ts +28 -0
- package/src/services/telemetry/capture.test.ts +50 -0
- package/src/services/telemetry/capture.ts +99 -0
- package/src/utilities/detectJsonFormatting.test.ts +38 -0
- package/src/utilities/detectJsonFormatting.ts +109 -0
- package/dist/adapter/solidAdapter.d.ts +0 -33
- package/dist/adapter/solidAdapter.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.js +0 -40
- package/dist/adapter/solidAdapter.test.d.ts +0 -2
- package/dist/adapter/solidAdapter.test.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.test.js +0 -356
- package/dist/api.d.ts +0 -113
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -1
- package/dist/api.test-d.d.ts +0 -2
- package/dist/api.test-d.d.ts.map +0 -1
- package/dist/api.test-d.js +0 -4
- package/dist/createMessageLintReportsQuery.d.ts +0 -12
- package/dist/createMessageLintReportsQuery.d.ts.map +0 -1
- package/dist/createMessageLintReportsQuery.js +0 -176
- package/dist/createMessagesQuery.d.ts +0 -19
- package/dist/createMessagesQuery.d.ts.map +0 -1
- package/dist/createMessagesQuery.js +0 -451
- package/dist/createMessagesQuery.test.d.ts +0 -2
- package/dist/createMessagesQuery.test.d.ts.map +0 -1
- package/dist/createMessagesQuery.test.js +0 -402
- package/dist/createNewProject.d.ts +0 -12
- package/dist/createNewProject.d.ts.map +0 -1
- package/dist/createNewProject.js +0 -38
- package/dist/createNewProject.test.d.ts +0 -2
- package/dist/createNewProject.test.d.ts.map +0 -1
- package/dist/createNewProject.test.js +0 -91
- package/dist/createNodeishFsWithAbsolutePaths.d.ts +0 -12
- package/dist/createNodeishFsWithAbsolutePaths.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.js +0 -38
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts +0 -2
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.test.js +0 -44
- package/dist/createNodeishFsWithWatcher.d.ts +0 -14
- package/dist/createNodeishFsWithWatcher.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.js +0 -75
- package/dist/createNodeishFsWithWatcher.test.d.ts +0 -2
- package/dist/createNodeishFsWithWatcher.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.test.js +0 -38
- package/dist/defaultProjectSettings.d.ts +0 -14
- package/dist/defaultProjectSettings.d.ts.map +0 -1
- package/dist/defaultProjectSettings.js +0 -22
- package/dist/env-variables/index.d.ts +0 -4
- package/dist/env-variables/index.d.ts.map +0 -1
- package/dist/env-variables/index.js +0 -3
- package/dist/errors.d.ts +0 -48
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -62
- package/dist/lint/index.d.ts +0 -3
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -2
- package/dist/lint/message/errors.d.ts +0 -7
- package/dist/lint/message/errors.d.ts.map +0 -1
- package/dist/lint/message/errors.js +0 -9
- package/dist/lint/message/lintMessages.d.ts +0 -13
- package/dist/lint/message/lintMessages.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.js +0 -12
- package/dist/lint/message/lintMessages.test.d.ts +0 -2
- package/dist/lint/message/lintMessages.test.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.test.js +0 -107
- package/dist/lint/message/lintSingleMessage.d.ts +0 -19
- package/dist/lint/message/lintSingleMessage.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.js +0 -38
- package/dist/lint/message/lintSingleMessage.test.d.ts +0 -2
- package/dist/lint/message/lintSingleMessage.test.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.test.js +0 -161
- package/dist/listProjects.d.ts +0 -5
- package/dist/listProjects.d.ts.map +0 -1
- package/dist/listProjects.js +0 -38
- package/dist/listProjects.test.d.ts +0 -2
- package/dist/listProjects.test.d.ts.map +0 -1
- package/dist/listProjects.test.js +0 -72
- package/dist/loadProject.d.ts +0 -19
- package/dist/loadProject.d.ts.map +0 -1
- package/dist/loadProject.js +0 -343
- package/dist/loadProject.test.d.ts.map +0 -1
- package/dist/loadProject.test.js +0 -975
- package/dist/messages/errors.d.ts +0 -13
- package/dist/messages/errors.d.ts.map +0 -1
- package/dist/messages/errors.js +0 -18
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -2
- package/dist/messages/variant.d.ts +0 -46
- package/dist/messages/variant.d.ts.map +0 -1
- package/dist/messages/variant.js +0 -176
- package/dist/messages/variant.test.d.ts +0 -2
- package/dist/messages/variant.test.d.ts.map +0 -1
- package/dist/messages/variant.test.js +0 -439
- package/dist/migrations/maybeAddModuleCache.d.ts +0 -6
- package/dist/migrations/maybeAddModuleCache.d.ts.map +0 -1
- package/dist/migrations/maybeAddModuleCache.js +0 -62
- package/dist/migrations/maybeCreateFirstProjectId.d.ts +0 -16
- package/dist/migrations/maybeCreateFirstProjectId.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.js +0 -46
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts +0 -2
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.test.js +0 -24
- package/dist/migrations/migrateToDirectory.d.ts +0 -10
- package/dist/migrations/migrateToDirectory.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.js +0 -48
- package/dist/migrations/migrateToDirectory.test.d.ts +0 -2
- package/dist/migrations/migrateToDirectory.test.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.test.js +0 -48
- package/dist/parseConfig.d.ts +0 -8
- package/dist/parseConfig.d.ts.map +0 -1
- package/dist/parseConfig.js +0 -26
- package/dist/persistence/batchedIO.d.ts +0 -11
- package/dist/persistence/batchedIO.d.ts.map +0 -1
- package/dist/persistence/batchedIO.js +0 -49
- package/dist/persistence/batchedIO.test.d.ts +0 -2
- package/dist/persistence/batchedIO.test.d.ts.map +0 -1
- package/dist/persistence/batchedIO.test.js +0 -56
- package/dist/persistence/filelock/acquireFileLock.d.ts +0 -3
- package/dist/persistence/filelock/acquireFileLock.d.ts.map +0 -1
- package/dist/persistence/filelock/acquireFileLock.js +0 -111
- package/dist/persistence/filelock/releaseLock.d.ts +0 -3
- package/dist/persistence/filelock/releaseLock.d.ts.map +0 -1
- package/dist/persistence/filelock/releaseLock.js +0 -24
- package/dist/persistence/store.d.ts +0 -107
- package/dist/persistence/store.d.ts.map +0 -1
- package/dist/persistence/store.js +0 -99
- package/dist/persistence/store.test.d.ts +0 -2
- package/dist/persistence/store.test.d.ts.map +0 -1
- package/dist/persistence/store.test.js +0 -79
- package/dist/persistence/storeApi.d.ts +0 -22
- package/dist/persistence/storeApi.d.ts.map +0 -1
- package/dist/persistence/storeApi.js +0 -1
- package/dist/reactivity/map.d.ts +0 -67
- package/dist/reactivity/map.d.ts.map +0 -1
- package/dist/reactivity/map.js +0 -143
- package/dist/reactivity/solid.d.ts +0 -14
- package/dist/reactivity/solid.d.ts.map +0 -1
- package/dist/reactivity/solid.js +0 -15
- package/dist/reactivity/solid.test.d.ts +0 -2
- package/dist/reactivity/solid.test.d.ts.map +0 -1
- package/dist/reactivity/solid.test.js +0 -189
- package/dist/reactivity/trigger.d.ts +0 -11
- package/dist/reactivity/trigger.d.ts.map +0 -1
- package/dist/reactivity/trigger.js +0 -46
- package/dist/resolve-modules/cache.d.ts +0 -6
- package/dist/resolve-modules/cache.d.ts.map +0 -1
- package/dist/resolve-modules/cache.js +0 -58
- package/dist/resolve-modules/errors.d.ts +0 -41
- package/dist/resolve-modules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/errors.js +0 -45
- package/dist/resolve-modules/import.d.ts +0 -19
- package/dist/resolve-modules/import.d.ts.map +0 -1
- package/dist/resolve-modules/import.js +0 -102
- package/dist/resolve-modules/import.test.d.ts +0 -2
- package/dist/resolve-modules/import.test.d.ts.map +0 -1
- package/dist/resolve-modules/import.test.js +0 -47
- package/dist/resolve-modules/index.d.ts +0 -3
- package/dist/resolve-modules/index.d.ts.map +0 -1
- package/dist/resolve-modules/index.js +0 -2
- package/dist/resolve-modules/message-lint-rules/errors.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/errors.js +0 -6
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +0 -24
- package/dist/resolve-modules/plugins/errors.d.ts +0 -33
- package/dist/resolve-modules/plugins/errors.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/errors.js +0 -38
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts +0 -3
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.js +0 -92
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.test.js +0 -252
- package/dist/resolve-modules/plugins/types.d.ts +0 -57
- package/dist/resolve-modules/plugins/types.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.js +0 -1
- package/dist/resolve-modules/plugins/types.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/types.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.test.js +0 -45
- package/dist/resolve-modules/resolveModules.d.ts +0 -3
- package/dist/resolve-modules/resolveModules.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.js +0 -80
- package/dist/resolve-modules/resolveModules.test.d.ts +0 -2
- package/dist/resolve-modules/resolveModules.test.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.test.js +0 -185
- package/dist/resolve-modules/types.d.ts +0 -63
- package/dist/resolve-modules/types.d.ts.map +0 -1
- package/dist/resolve-modules/types.js +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.d.ts +0 -2
- package/dist/resolve-modules/validateModuleSettings.test.d.ts.map +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.js +0 -71
- package/dist/resolve-modules/validatedModuleSettings.d.ts +0 -7
- package/dist/resolve-modules/validatedModuleSettings.d.ts.map +0 -1
- package/dist/resolve-modules/validatedModuleSettings.js +0 -11
- package/dist/storage/helper.d.ts +0 -11
- package/dist/storage/helper.d.ts.map +0 -1
- package/dist/storage/helper.js +0 -63
- package/dist/storage/helpers.test.d.ts +0 -2
- package/dist/storage/helpers.test.d.ts.map +0 -1
- package/dist/storage/helpers.test.js +0 -84
- package/dist/storage/human-id/human-readable-id.d.ts +0 -3
- package/dist/storage/human-id/human-readable-id.d.ts.map +0 -1
- package/dist/storage/human-id/human-readable-id.js +0 -20
- package/dist/storage/human-id/words.d.ts.map +0 -1
- package/dist/storage/human-id/words.test.d.ts.map +0 -1
- package/dist/telemetry/capture.d.ts.map +0 -1
- package/dist/telemetry/capture.js +0 -39
- package/dist/telemetry/groupIdentify.d.ts +0 -13
- package/dist/telemetry/groupIdentify.d.ts.map +0 -1
- package/dist/telemetry/groupIdentify.js +0 -35
- package/dist/test-utilities/createMessage.d.ts +0 -18
- package/dist/test-utilities/createMessage.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.js +0 -17
- package/dist/test-utilities/createMessage.test.d.ts +0 -2
- package/dist/test-utilities/createMessage.test.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.test.js +0 -106
- package/dist/test-utilities/index.d.ts +0 -3
- package/dist/test-utilities/index.d.ts.map +0 -1
- package/dist/test-utilities/index.js +0 -2
- package/dist/test-utilities/sleep.d.ts +0 -4
- package/dist/test-utilities/sleep.d.ts.map +0 -1
- package/dist/test-utilities/sleep.js +0 -9
- package/dist/v2/helper.d.ts +0 -43
- package/dist/v2/helper.d.ts.map +0 -1
- package/dist/v2/helper.js +0 -75
- package/dist/v2/helper.test.d.ts +0 -2
- package/dist/v2/helper.test.d.ts.map +0 -1
- package/dist/v2/helper.test.js +0 -92
- package/dist/v2/index.d.ts +0 -4
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -2
- package/dist/v2/mocks/index.d.ts +0 -3
- package/dist/v2/mocks/index.d.ts.map +0 -1
- package/dist/v2/mocks/index.js +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts +0 -3
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.js +0 -194
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.test.js +0 -10
- package/dist/v2/mocks/plural/bundle.d.ts +0 -3
- package/dist/v2/mocks/plural/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.js +0 -162
- package/dist/v2/mocks/plural/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/plural/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.test.js +0 -15
- package/dist/v2/shim.d.ts +0 -12
- package/dist/v2/shim.d.ts.map +0 -1
- package/dist/v2/shim.js +0 -151
- package/dist/v2/shim.test.d.ts +0 -2
- package/dist/v2/shim.test.d.ts.map +0 -1
- package/dist/v2/shim.test.js +0 -49
- package/dist/v2/stubQueryApi.d.ts +0 -9
- package/dist/v2/stubQueryApi.d.ts.map +0 -1
- package/dist/v2/stubQueryApi.js +0 -38
- package/dist/v2/types.d.ts +0 -521
- package/dist/v2/types.d.ts.map +0 -1
- package/dist/v2/types.js +0 -78
- package/dist/validateProjectPath.d.ts +0 -17
- package/dist/validateProjectPath.d.ts.map +0 -1
- package/dist/validateProjectPath.js +0 -31
- package/dist/validateProjectPath.test.d.ts +0 -2
- package/dist/validateProjectPath.test.d.ts.map +0 -1
- package/dist/validateProjectPath.test.js +0 -40
- package/dist/versionedInterfaces.d.ts +0 -8
- package/dist/versionedInterfaces.d.ts.map +0 -1
- package/dist/versionedInterfaces.js +0 -8
- package/src/adapter/solidAdapter.test.ts +0 -472
- package/src/adapter/solidAdapter.ts +0 -79
- package/src/api.test-d.ts +0 -8
- package/src/api.ts +0 -116
- package/src/createMessageLintReportsQuery.ts +0 -225
- package/src/createMessagesQuery.test.ts +0 -538
- package/src/createMessagesQuery.ts +0 -635
- package/src/createNewProject.test.ts +0 -105
- package/src/createNewProject.ts +0 -46
- package/src/createNodeishFsWithAbsolutePaths.test.ts +0 -55
- package/src/createNodeishFsWithAbsolutePaths.ts +0 -52
- package/src/createNodeishFsWithWatcher.test.ts +0 -50
- package/src/createNodeishFsWithWatcher.ts +0 -85
- package/src/defaultProjectSettings.ts +0 -26
- package/src/env-variables/.prettierignore +0 -1
- package/src/env-variables/createIndexFile.js +0 -28
- package/src/errors.ts +0 -84
- package/src/lint/index.ts +0 -2
- package/src/lint/message/errors.ts +0 -9
- package/src/lint/message/lintMessages.test.ts +0 -126
- package/src/lint/message/lintMessages.ts +0 -25
- package/src/lint/message/lintSingleMessage.test.ts +0 -191
- package/src/lint/message/lintSingleMessage.ts +0 -57
- package/src/listProjects.test.ts +0 -91
- package/src/listProjects.ts +0 -48
- package/src/loadProject.test.ts +0 -1173
- package/src/loadProject.ts +0 -460
- package/src/messages/errors.ts +0 -25
- package/src/messages/index.ts +0 -2
- package/src/messages/variant.test.ts +0 -511
- package/src/messages/variant.ts +0 -247
- package/src/migrations/maybeAddModuleCache.ts +0 -68
- package/src/migrations/maybeCreateFirstProjectId.test.ts +0 -31
- package/src/migrations/maybeCreateFirstProjectId.ts +0 -51
- package/src/migrations/migrateToDirectory.test.ts +0 -54
- package/src/migrations/migrateToDirectory.ts +0 -62
- package/src/parseConfig.ts +0 -35
- package/src/persistence/batchedIO.test.ts +0 -63
- package/src/persistence/batchedIO.ts +0 -64
- package/src/persistence/filelock/acquireFileLock.ts +0 -129
- package/src/persistence/filelock/releaseLock.ts +0 -29
- package/src/persistence/store.test.ts +0 -102
- package/src/persistence/store.ts +0 -119
- package/src/persistence/storeApi.ts +0 -19
- package/src/reactivity/map.ts +0 -135
- package/src/reactivity/solid.test.ts +0 -222
- package/src/reactivity/solid.ts +0 -42
- package/src/reactivity/trigger.ts +0 -46
- package/src/resolve-modules/cache.ts +0 -89
- package/src/resolve-modules/errors.ts +0 -69
- package/src/resolve-modules/import.test.ts +0 -62
- package/src/resolve-modules/import.ts +0 -133
- package/src/resolve-modules/index.ts +0 -2
- package/src/resolve-modules/message-lint-rules/errors.ts +0 -9
- package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +0 -27
- package/src/resolve-modules/plugins/errors.ts +0 -56
- package/src/resolve-modules/plugins/resolvePlugins.test.ts +0 -301
- package/src/resolve-modules/plugins/resolvePlugins.ts +0 -129
- package/src/resolve-modules/plugins/types.test.ts +0 -53
- package/src/resolve-modules/plugins/types.ts +0 -76
- package/src/resolve-modules/resolveModules.test.ts +0 -224
- package/src/resolve-modules/resolveModules.ts +0 -113
- package/src/resolve-modules/types.ts +0 -72
- package/src/resolve-modules/validateModuleSettings.test.ts +0 -85
- package/src/resolve-modules/validatedModuleSettings.ts +0 -19
- package/src/storage/helper.ts +0 -74
- package/src/storage/helpers.test.ts +0 -95
- package/src/storage/human-id/human-readable-id.ts +0 -27
- package/src/telemetry/capture.ts +0 -49
- package/src/telemetry/groupIdentify.ts +0 -41
- package/src/test-utilities/createMessage.test.ts +0 -118
- package/src/test-utilities/createMessage.ts +0 -21
- package/src/test-utilities/index.ts +0 -2
- package/src/test-utilities/sleep.ts +0 -11
- package/src/v2/helper.test.ts +0 -95
- package/src/v2/helper.ts +0 -98
- package/src/v2/index.ts +0 -3
- package/src/v2/mocks/index.ts +0 -2
- package/src/v2/mocks/multipleMatcher/bundle.test.ts +0 -11
- package/src/v2/mocks/multipleMatcher/bundle.ts +0 -196
- package/src/v2/mocks/plural/bundle.test.ts +0 -18
- package/src/v2/mocks/plural/bundle.ts +0 -164
- package/src/v2/shim.test.ts +0 -56
- package/src/v2/shim.ts +0 -173
- package/src/v2/stubQueryApi.ts +0 -43
- package/src/v2/types.ts +0 -159
- package/src/validateProjectPath.test.ts +0 -50
- package/src/validateProjectPath.ts +0 -38
- package/src/versionedInterfaces.ts +0 -9
- /package/dist/{storage/human-id → human-id}/words.d.ts +0 -0
- /package/dist/{storage/human-id → human-id}/words.test.d.ts +0 -0
- /package/dist/{loadProject.test.d.ts → project/loadProject.test.d.ts} +0 -0
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
|
|
3
|
+
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
4
|
+
import { ProjectSettings } from "../json-schema/settings.js";
|
|
5
|
+
import { fs, vol, Volume } from "memfs";
|
|
6
|
+
import {
|
|
7
|
+
loadProjectFromDirectory,
|
|
8
|
+
ResourceFileImportError,
|
|
9
|
+
WarningDeprecatedLintRule,
|
|
10
|
+
} from "./loadProjectFromDirectory.js";
|
|
11
|
+
import { selectBundleNested } from "../query-utilities/selectBundleNested.js";
|
|
12
|
+
import { Text } from "../json-schema/pattern.js";
|
|
13
|
+
import type { InlangPlugin } from "../plugin/schema.js";
|
|
14
|
+
import type {
|
|
15
|
+
MessageV1,
|
|
16
|
+
VariantV1,
|
|
17
|
+
} from "../json-schema/old-v1-message/schemaV1.js";
|
|
18
|
+
import { saveProjectToDirectory } from "./saveProjectToDirectory.js";
|
|
19
|
+
import { insertBundleNested } from "../query-utilities/insertBundleNested.js";
|
|
20
|
+
|
|
21
|
+
test("plugin.loadMessages and plugin.saveMessages must not be configured together with import export", async () => {
|
|
22
|
+
const mockLegacyPlugin: InlangPlugin = {
|
|
23
|
+
key: "mock-legacy-plugin",
|
|
24
|
+
loadMessages: async () => {
|
|
25
|
+
return [];
|
|
26
|
+
},
|
|
27
|
+
saveMessages: async () => {},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const mockLegacyPlugin2: InlangPlugin = {
|
|
31
|
+
key: "mock-legacy-plugin-2",
|
|
32
|
+
loadMessages: async () => {
|
|
33
|
+
return [];
|
|
34
|
+
},
|
|
35
|
+
saveMessages: async () => {},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const mockImportExportPlugin: InlangPlugin = {
|
|
39
|
+
key: "mock-import-export-plugin",
|
|
40
|
+
exportFiles: () => {
|
|
41
|
+
return [];
|
|
42
|
+
},
|
|
43
|
+
importFiles: () => {
|
|
44
|
+
return {} as any;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await expect(
|
|
49
|
+
(async () => {
|
|
50
|
+
await loadProjectFromDirectory({
|
|
51
|
+
fs: Volume.fromJSON({
|
|
52
|
+
"./project.inlang/settings.json": JSON.stringify({
|
|
53
|
+
baseLocale: "en",
|
|
54
|
+
locales: ["en", "de"],
|
|
55
|
+
modules: [],
|
|
56
|
+
} satisfies ProjectSettings),
|
|
57
|
+
}) as any,
|
|
58
|
+
path: "./project.inlang",
|
|
59
|
+
providePlugins: [
|
|
60
|
+
mockLegacyPlugin,
|
|
61
|
+
mockLegacyPlugin2,
|
|
62
|
+
mockImportExportPlugin,
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
})()
|
|
66
|
+
).rejects.toThrowError();
|
|
67
|
+
|
|
68
|
+
await expect(
|
|
69
|
+
(async () => {
|
|
70
|
+
await loadProjectFromDirectory({
|
|
71
|
+
fs: Volume.fromJSON({
|
|
72
|
+
"./project.inlang/settings.json": JSON.stringify({
|
|
73
|
+
baseLocale: "en",
|
|
74
|
+
locales: ["en", "de"],
|
|
75
|
+
modules: [],
|
|
76
|
+
} satisfies ProjectSettings),
|
|
77
|
+
}) as any,
|
|
78
|
+
path: "./project.inlang",
|
|
79
|
+
providePlugins: [
|
|
80
|
+
mockLegacyPlugin,
|
|
81
|
+
mockLegacyPlugin2,
|
|
82
|
+
mockImportExportPlugin,
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
})()
|
|
86
|
+
).rejects.toThrowError();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("plugin.loadMessages and plugin.saveMessages should work for legacy purposes", async () => {
|
|
90
|
+
const mockLegacyPlugin: InlangPlugin = {
|
|
91
|
+
id: "mock-legacy-plugin",
|
|
92
|
+
// @ts-expect-error - id is deprecated, key can be undefined
|
|
93
|
+
key: undefined,
|
|
94
|
+
loadMessages: async ({ nodeishFs, settings }) => {
|
|
95
|
+
const pathPattern = settings["plugin.mock-plugin"]?.pathPattern as string;
|
|
96
|
+
|
|
97
|
+
const messages: MessageV1[] = [];
|
|
98
|
+
|
|
99
|
+
// @ts-expect-error - language tag is always given by the sdk v2
|
|
100
|
+
for (const languageTag of settings.languageTags) {
|
|
101
|
+
const data = await nodeishFs.readFile(
|
|
102
|
+
pathPattern.replace("{languageTag}", languageTag)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
for (const [key, value] of Object.entries(
|
|
106
|
+
JSON.parse(data.toString())
|
|
107
|
+
)) {
|
|
108
|
+
const exisitngMessage = messages.find(
|
|
109
|
+
(message) => message.id === key
|
|
110
|
+
);
|
|
111
|
+
const variant = {
|
|
112
|
+
languageTag: languageTag,
|
|
113
|
+
match: [],
|
|
114
|
+
pattern: [{ type: "Text", value: value }],
|
|
115
|
+
} as VariantV1;
|
|
116
|
+
if (exisitngMessage !== undefined) {
|
|
117
|
+
exisitngMessage.variants.push(variant);
|
|
118
|
+
} else {
|
|
119
|
+
messages.push({
|
|
120
|
+
alias: {},
|
|
121
|
+
id: key,
|
|
122
|
+
selectors: [],
|
|
123
|
+
variants: [variant],
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return messages;
|
|
130
|
+
},
|
|
131
|
+
saveMessages: async ({ messages, nodeishFs, settings }) => {
|
|
132
|
+
const pathPattern = settings["plugin.mock-plugin"]?.pathPattern as string;
|
|
133
|
+
for (const languageTag of settings.languageTags!) {
|
|
134
|
+
const messagesInLanguage = {} as Record<string, string>;
|
|
135
|
+
for (const message of messages) {
|
|
136
|
+
const variantsInLanguage = message.variants.filter(
|
|
137
|
+
(variant) => variant.languageTag === languageTag
|
|
138
|
+
);
|
|
139
|
+
if (variantsInLanguage.length > 1) {
|
|
140
|
+
// data will get lost during export => throw?
|
|
141
|
+
} else if (variantsInLanguage.length === 1) {
|
|
142
|
+
if (
|
|
143
|
+
variantsInLanguage[0]!.pattern.length != 1 ||
|
|
144
|
+
variantsInLanguage[0]!.pattern[0]?.type !== "Text"
|
|
145
|
+
) {
|
|
146
|
+
// throw?
|
|
147
|
+
}
|
|
148
|
+
messagesInLanguage[message.id] = (
|
|
149
|
+
variantsInLanguage[0]!.pattern[0]! as any
|
|
150
|
+
).value;
|
|
151
|
+
}
|
|
152
|
+
// else no-op
|
|
153
|
+
}
|
|
154
|
+
await nodeishFs.writeFile(
|
|
155
|
+
pathPattern.replace("{languageTag}", languageTag),
|
|
156
|
+
JSON.stringify(messagesInLanguage, null, 2)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
const mockRepo = {
|
|
162
|
+
"./README.md": "# Hello World",
|
|
163
|
+
"./src/index.js": "console.log('Hello World')",
|
|
164
|
+
"./src/translations/en.json": JSON.stringify({
|
|
165
|
+
key1: "value1",
|
|
166
|
+
key2: "value2",
|
|
167
|
+
}),
|
|
168
|
+
"./src/translations/de.json": JSON.stringify({
|
|
169
|
+
key1: "wert1",
|
|
170
|
+
key2: "wert2",
|
|
171
|
+
}),
|
|
172
|
+
"./project.inlang/settings.json": JSON.stringify({
|
|
173
|
+
baseLocale: "en",
|
|
174
|
+
locales: ["en", "de"],
|
|
175
|
+
modules: ["./mock-module.js"],
|
|
176
|
+
"plugin.mock-plugin": {
|
|
177
|
+
pathPattern: "./src/translations/{languageTag}.json",
|
|
178
|
+
},
|
|
179
|
+
} satisfies ProjectSettings),
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const fs = Volume.fromJSON(mockRepo);
|
|
183
|
+
|
|
184
|
+
let project = await loadProjectFromDirectory({
|
|
185
|
+
fs: fs as any,
|
|
186
|
+
path: "./project.inlang",
|
|
187
|
+
providePlugins: [mockLegacyPlugin],
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
await insertBundleNested(project.db, {
|
|
191
|
+
id: "key-id",
|
|
192
|
+
messages: [
|
|
193
|
+
{
|
|
194
|
+
id: "mock-message",
|
|
195
|
+
bundleId: "mock-bundle",
|
|
196
|
+
locale: "en",
|
|
197
|
+
selectors: [],
|
|
198
|
+
variants: [
|
|
199
|
+
{
|
|
200
|
+
messageId: "mock-message",
|
|
201
|
+
pattern: [
|
|
202
|
+
{
|
|
203
|
+
type: "text",
|
|
204
|
+
value: "JOJO",
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await saveProjectToDirectory({
|
|
214
|
+
fs: fs.promises as any,
|
|
215
|
+
path: "./project.inlang",
|
|
216
|
+
project,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
project = await loadProjectFromDirectory({
|
|
220
|
+
fs: fs as any,
|
|
221
|
+
path: "./project.inlang",
|
|
222
|
+
providePlugins: [mockLegacyPlugin],
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const bundles = await selectBundleNested(project.db).execute();
|
|
226
|
+
|
|
227
|
+
const bundlesOrdered = bundles.sort((a, b) => a.id.localeCompare(b.id));
|
|
228
|
+
|
|
229
|
+
expect(bundles.length).toBe(3);
|
|
230
|
+
expect(bundlesOrdered[0]?.messages[0]?.locale).toBe("en");
|
|
231
|
+
expect(
|
|
232
|
+
(bundlesOrdered[0]?.messages[0]?.variants[0]?.pattern[0] as Text)?.value
|
|
233
|
+
).toBe("JOJO");
|
|
234
|
+
|
|
235
|
+
// TODO fix
|
|
236
|
+
// expect(bundlesOrdered[0]?.messages[9]?.locale).toBe("en");
|
|
237
|
+
// expect(
|
|
238
|
+
// (bundlesOrdered[0]?.messages[1]?.variants[0]?.pattern[0] as Text)?.value
|
|
239
|
+
// ).toBe("wert1");
|
|
240
|
+
|
|
241
|
+
// expect(bundlesOrdered[1]?.messages[0]?.locale).toBe("en");
|
|
242
|
+
// expect(
|
|
243
|
+
// (bundlesOrdered[1]?.messages[0]?.variants[0]?.pattern[0] as Text)?.value
|
|
244
|
+
// ).toBe("value2");
|
|
245
|
+
|
|
246
|
+
// expect(bundlesOrdered[1]?.messages[1]?.locale).toBe("de");
|
|
247
|
+
// expect(
|
|
248
|
+
// (bundlesOrdered[1]?.messages[1]?.variants[0]?.pattern[0] as Text)?.value
|
|
249
|
+
// ).toBe("wert2");
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
const mockSettings = {
|
|
253
|
+
baseLocale: "en",
|
|
254
|
+
locales: ["en", "de"],
|
|
255
|
+
modules: [],
|
|
256
|
+
} satisfies ProjectSettings;
|
|
257
|
+
|
|
258
|
+
const mockDirectory = {
|
|
259
|
+
"/project.inlang/cache/plugin/29j49j2": "cache value",
|
|
260
|
+
"/project.inlang/.gitignore": "git value",
|
|
261
|
+
"/project.inlang/prettierrc.json": "prettier value",
|
|
262
|
+
"/project.inlang/README.md": "readme value",
|
|
263
|
+
"/project.inlang/settings.json": JSON.stringify(mockSettings),
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
describe("it should keep files between the inlang directory and lix in sync", async () => {
|
|
267
|
+
test("files from directory should be available via lix after project has been loaded from directory", async () => {
|
|
268
|
+
const syncInterval = 100;
|
|
269
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
270
|
+
|
|
271
|
+
const project = await loadProjectFromDirectory({
|
|
272
|
+
fs: fs as any,
|
|
273
|
+
path: "/project.inlang",
|
|
274
|
+
syncInterval: syncInterval,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const files = await project.lix.db.selectFrom("file").selectAll().execute();
|
|
278
|
+
|
|
279
|
+
expect(files.length).toBe(
|
|
280
|
+
5 + 1 /* the db.sqlite file */ + 1 /* project_id */
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const filesByPath = files.reduce((acc, file) => {
|
|
284
|
+
acc[file.path] = new TextDecoder().decode(file.data);
|
|
285
|
+
return acc;
|
|
286
|
+
}, {} as any);
|
|
287
|
+
|
|
288
|
+
expect(filesByPath["/cache/plugin/29j49j2"]).toBe("cache value");
|
|
289
|
+
expect(filesByPath["/.gitignore"]).toBe("git value");
|
|
290
|
+
expect(filesByPath["/prettierrc.json"]).toBe("prettier value");
|
|
291
|
+
expect(filesByPath["/README.md"]).toBe("readme value");
|
|
292
|
+
expect(filesByPath["/settings.json"]).toBe(JSON.stringify(mockSettings));
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("file created in fs should be avaialable in lix ", async () => {
|
|
296
|
+
const syncInterval = 100;
|
|
297
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
298
|
+
|
|
299
|
+
const project = await loadProjectFromDirectory({
|
|
300
|
+
fs: fs as any,
|
|
301
|
+
path: "/project.inlang",
|
|
302
|
+
syncInterval: syncInterval,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
fs.writeFileSync(
|
|
306
|
+
"/project.inlang/file-created-on-fs.txt",
|
|
307
|
+
"value written by fs",
|
|
308
|
+
{
|
|
309
|
+
encoding: "utf-8",
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
// lets wait a seconds to allow the sync process catch up
|
|
314
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
315
|
+
|
|
316
|
+
const randomFileInLix = await project.lix.db
|
|
317
|
+
.selectFrom("file")
|
|
318
|
+
.selectAll()
|
|
319
|
+
.where("path", "=", "/file-created-on-fs.txt")
|
|
320
|
+
.executeTakeFirstOrThrow();
|
|
321
|
+
|
|
322
|
+
expect(new TextDecoder().decode(randomFileInLix.data)).toBe(
|
|
323
|
+
"value written by fs"
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test("file updated in fs should be avaialable in lix ", async () => {
|
|
328
|
+
const syncInterval = 100;
|
|
329
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
330
|
+
|
|
331
|
+
const project = await loadProjectFromDirectory({
|
|
332
|
+
fs: fs as any,
|
|
333
|
+
path: "/project.inlang",
|
|
334
|
+
syncInterval: syncInterval,
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// "changes to a file on disk should reflect in lix
|
|
338
|
+
fs.writeFileSync(
|
|
339
|
+
"/project.inlang/settings.json",
|
|
340
|
+
JSON.stringify({
|
|
341
|
+
...mockSettings,
|
|
342
|
+
baseLocale: "brand-new-locale-written-to-fs-file",
|
|
343
|
+
})
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
// console.log("wrting fs settings");
|
|
347
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
348
|
+
const fileInLix = await project.lix.db
|
|
349
|
+
.selectFrom("file")
|
|
350
|
+
.selectAll()
|
|
351
|
+
.where("path", "=", "/settings.json")
|
|
352
|
+
.executeTakeFirstOrThrow();
|
|
353
|
+
|
|
354
|
+
const settingsAfterUpdateOnDisk = JSON.parse(
|
|
355
|
+
new TextDecoder().decode(fileInLix.data)
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
expect(settingsAfterUpdateOnDisk.baseLocale).toBe(
|
|
359
|
+
"brand-new-locale-written-to-fs-file"
|
|
360
|
+
);
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
test("file deleted in fs should be droped from lix ", async () => {
|
|
364
|
+
const syncInterval = 100;
|
|
365
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
366
|
+
|
|
367
|
+
const project = await loadProjectFromDirectory({
|
|
368
|
+
fs: fs as any,
|
|
369
|
+
path: "/project.inlang",
|
|
370
|
+
syncInterval: syncInterval,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const filesInLixBefore = await project.lix.db
|
|
374
|
+
.selectFrom("file")
|
|
375
|
+
.selectAll()
|
|
376
|
+
.where("path", "=", "/README.md")
|
|
377
|
+
.execute();
|
|
378
|
+
|
|
379
|
+
expect(filesInLixBefore.length).toBe(1);
|
|
380
|
+
|
|
381
|
+
// "changes to a file on disk should reflect in lix
|
|
382
|
+
fs.unlinkSync("/project.inlang/README.md");
|
|
383
|
+
|
|
384
|
+
// console.log("wrting fs settings");
|
|
385
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
386
|
+
const fileInLixAfter = await project.lix.db
|
|
387
|
+
.selectFrom("file")
|
|
388
|
+
.selectAll()
|
|
389
|
+
.where("path", "=", "/README.md")
|
|
390
|
+
.execute();
|
|
391
|
+
|
|
392
|
+
expect(fileInLixAfter.length).toBe(0);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
test("file created in lix should be avaialable in fs ", async () => {
|
|
396
|
+
const syncInterval = 100;
|
|
397
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
398
|
+
|
|
399
|
+
const project = await loadProjectFromDirectory({
|
|
400
|
+
fs: fs as any,
|
|
401
|
+
path: "/project.inlang",
|
|
402
|
+
syncInterval: syncInterval,
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
await project.lix.db
|
|
406
|
+
.insertInto("file")
|
|
407
|
+
.values({
|
|
408
|
+
path: "/file-created-in.lix.txt",
|
|
409
|
+
data: new TextEncoder().encode("random value lix"),
|
|
410
|
+
})
|
|
411
|
+
.execute();
|
|
412
|
+
|
|
413
|
+
// lets wait a seconds to allow the sync process catch up
|
|
414
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
415
|
+
|
|
416
|
+
const randomFileOnDiskContent = fs
|
|
417
|
+
.readFileSync("/project.inlang/file-created-in.lix.txt")
|
|
418
|
+
.toString();
|
|
419
|
+
expect(randomFileOnDiskContent).toBe("random value lix");
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
test("file updated in lix should be avaialable in fs ", async () => {
|
|
423
|
+
const syncInterval = 100;
|
|
424
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
425
|
+
|
|
426
|
+
const project = await loadProjectFromDirectory({
|
|
427
|
+
fs: fs as any,
|
|
428
|
+
path: "/project.inlang",
|
|
429
|
+
syncInterval: syncInterval,
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
// console.log("wrting lix settings");
|
|
433
|
+
// changes to a file in lix should reflect in the project directory
|
|
434
|
+
await project.lix.db
|
|
435
|
+
.updateTable("file")
|
|
436
|
+
.where("path", "=", "/settings.json")
|
|
437
|
+
.set({
|
|
438
|
+
data: new TextEncoder().encode(
|
|
439
|
+
JSON.stringify({ ...mockSettings, baseLocale: "brand-new-locale2" })
|
|
440
|
+
),
|
|
441
|
+
})
|
|
442
|
+
.execute();
|
|
443
|
+
|
|
444
|
+
// lets wait a seconds to allow the sync process catch up
|
|
445
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
446
|
+
|
|
447
|
+
const fileOnDisk = fs.readFileSync("/project.inlang/settings.json");
|
|
448
|
+
const settings = JSON.parse(fileOnDisk.toString());
|
|
449
|
+
|
|
450
|
+
expect(settings.baseLocale).toBe("brand-new-locale2");
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
test("file deleted in lix should be gone in fs as awell", async () => {
|
|
454
|
+
const syncInterval = 100;
|
|
455
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
456
|
+
|
|
457
|
+
const project = await loadProjectFromDirectory({
|
|
458
|
+
fs: fs as any,
|
|
459
|
+
path: "/project.inlang",
|
|
460
|
+
syncInterval: syncInterval,
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
// console.log("wrting lix settings");
|
|
464
|
+
// changes to a file in lix should reflect in the project directory
|
|
465
|
+
await project.lix.db
|
|
466
|
+
.deleteFrom("file")
|
|
467
|
+
.where("path", "=", "/.gitignore")
|
|
468
|
+
.execute();
|
|
469
|
+
|
|
470
|
+
// lets wait a seconds to allow the sync process catch up
|
|
471
|
+
await new Promise((resolve) => setTimeout(resolve, syncInterval + 10));
|
|
472
|
+
|
|
473
|
+
const fileExistsOnDisk = fs.existsSync("/project.inlang/.gitignore");
|
|
474
|
+
|
|
475
|
+
expect(fileExistsOnDisk).toBe(false);
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
test("file updated in fs and lix (conflicting) should result in the fs state", async () => {
|
|
479
|
+
const syncInterval = 100;
|
|
480
|
+
const fs = Volume.fromJSON(mockDirectory);
|
|
481
|
+
|
|
482
|
+
const project = await loadProjectFromDirectory({
|
|
483
|
+
fs: fs as any,
|
|
484
|
+
path: "/project.inlang",
|
|
485
|
+
syncInterval: syncInterval,
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// console.log("wrting fs settings simultanous");
|
|
489
|
+
// changes to a file on disk and lix at the same time should lead to the fs version
|
|
490
|
+
fs.writeFileSync(
|
|
491
|
+
"/project.inlang/settings.json",
|
|
492
|
+
JSON.stringify({ ...mockSettings, baseLocale: "fs-version" })
|
|
493
|
+
);
|
|
494
|
+
|
|
495
|
+
// console.log("wrting lix settings simultanous");
|
|
496
|
+
await project.lix.db
|
|
497
|
+
.updateTable("file")
|
|
498
|
+
.where("path", "=", "/settings.json")
|
|
499
|
+
.set({
|
|
500
|
+
data: new TextEncoder().encode(
|
|
501
|
+
JSON.stringify({ ...mockSettings, baseLocale: "lix-version" })
|
|
502
|
+
),
|
|
503
|
+
})
|
|
504
|
+
.execute();
|
|
505
|
+
|
|
506
|
+
// lets wait a seconds to allow the sync process catch up
|
|
507
|
+
await new Promise((resolve) => setTimeout(resolve, 1010));
|
|
508
|
+
|
|
509
|
+
const fileOnDiskUpdated = fs.readFileSync("/project.inlang/settings.json");
|
|
510
|
+
const settingsUpdated = JSON.parse(fileOnDiskUpdated.toString());
|
|
511
|
+
|
|
512
|
+
expect(settingsUpdated.baseLocale).toBe("fs-version");
|
|
513
|
+
|
|
514
|
+
const fileInLixUpdated = await project.lix.db
|
|
515
|
+
.selectFrom("file")
|
|
516
|
+
.selectAll()
|
|
517
|
+
.where("path", "=", "/settings.json")
|
|
518
|
+
.executeTakeFirstOrThrow();
|
|
519
|
+
|
|
520
|
+
const settingsAfterUpdateOnDiskAndLix = JSON.parse(
|
|
521
|
+
new TextDecoder().decode(fileInLixUpdated.data)
|
|
522
|
+
);
|
|
523
|
+
|
|
524
|
+
expect(settingsAfterUpdateOnDiskAndLix.baseLocale).toBe("fs-version");
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test("errors from importing translation files should be shown", async () => {
|
|
529
|
+
const mock = {
|
|
530
|
+
"/project.inlang/settings.json": JSON.stringify({
|
|
531
|
+
baseLocale: "en",
|
|
532
|
+
locales: ["en", "de"],
|
|
533
|
+
modules: [],
|
|
534
|
+
} satisfies ProjectSettings),
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
const fs = Volume.fromJSON(mock);
|
|
538
|
+
|
|
539
|
+
const proxiedFs = new Proxy(fs, {
|
|
540
|
+
get: (target, prop) => {
|
|
541
|
+
if (prop === "promises") {
|
|
542
|
+
// Intercept the 'promises' object
|
|
543
|
+
return new Proxy(target.promises, {
|
|
544
|
+
get: (promisesTarget, promisesProp) => {
|
|
545
|
+
if (promisesProp === "readFile") {
|
|
546
|
+
// @ts-expect-error - we are mocking the fs
|
|
547
|
+
return (path, ...args) => {
|
|
548
|
+
if (path.endsWith("some-file.json")) {
|
|
549
|
+
throw new Error("MOCK ERROR");
|
|
550
|
+
}
|
|
551
|
+
return promisesTarget.readFile(path, ...args);
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
return Reflect.get(promisesTarget, promisesProp);
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return Reflect.get(target, prop);
|
|
559
|
+
},
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
const mockPlugin: InlangPlugin = {
|
|
563
|
+
key: "mock-plugin",
|
|
564
|
+
importFiles: async () => {
|
|
565
|
+
return { bundles: [], messages: [], variants: [] };
|
|
566
|
+
},
|
|
567
|
+
toBeImportedFiles: async () => {
|
|
568
|
+
return [{ path: "./some-file.json", locale: "mock" }];
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
const project = await loadProjectFromDirectory({
|
|
573
|
+
fs: proxiedFs as any,
|
|
574
|
+
path: "/project.inlang",
|
|
575
|
+
providePlugins: [mockPlugin],
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
const errors = await project.errors.get();
|
|
579
|
+
// TODO deactivated for now - we need to proxy fs.promises or change the signature of loadProject
|
|
580
|
+
expect(errors).toHaveLength(1);
|
|
581
|
+
expect(errors[0]).toBeInstanceOf(ResourceFileImportError);
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
// it happens often that a resource file doesn't exist yet on import
|
|
585
|
+
test("errors from importing translation files that are ENOENT should not be shown", async () => {
|
|
586
|
+
const mock = {
|
|
587
|
+
"/project.inlang/settings.json": JSON.stringify({
|
|
588
|
+
baseLocale: "en",
|
|
589
|
+
locales: ["en", "de"],
|
|
590
|
+
modules: [],
|
|
591
|
+
} satisfies ProjectSettings),
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
const fs = Volume.fromJSON(mock);
|
|
595
|
+
|
|
596
|
+
const mockPlugin: InlangPlugin = {
|
|
597
|
+
key: "mock-plugin",
|
|
598
|
+
importFiles: async () => {
|
|
599
|
+
return { bundles: [], messages: [], variants: [] };
|
|
600
|
+
},
|
|
601
|
+
toBeImportedFiles: async () => {
|
|
602
|
+
return [{ path: "./some-non-existing-file.json", locale: "mock" }];
|
|
603
|
+
},
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
const project = await loadProjectFromDirectory({
|
|
607
|
+
fs: fs as any,
|
|
608
|
+
path: "/project.inlang",
|
|
609
|
+
providePlugins: [mockPlugin],
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
const errors = await project.errors.get();
|
|
613
|
+
expect(errors).toHaveLength(0);
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
// it happens often that a resource file doesn't exist yet on import
|
|
617
|
+
test("it should pass toBeImportedMetadata on import", async () => {
|
|
618
|
+
const mock = {
|
|
619
|
+
"/foo/en.json": JSON.stringify({}),
|
|
620
|
+
"/project.inlang/settings.json": JSON.stringify({
|
|
621
|
+
baseLocale: "en",
|
|
622
|
+
locales: ["en", "de"],
|
|
623
|
+
} satisfies ProjectSettings),
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
const fs = Volume.fromJSON(mock);
|
|
627
|
+
|
|
628
|
+
const mockPlugin: InlangPlugin = {
|
|
629
|
+
key: "mock-plugin",
|
|
630
|
+
toBeImportedFiles: async () => {
|
|
631
|
+
return [
|
|
632
|
+
{
|
|
633
|
+
path: "/foo/en.json",
|
|
634
|
+
locale: "mock",
|
|
635
|
+
metadata: {
|
|
636
|
+
foo: "bar",
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
];
|
|
640
|
+
},
|
|
641
|
+
importFiles: async () => {
|
|
642
|
+
return { bundles: [], messages: [], variants: [] };
|
|
643
|
+
},
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
const toBeSpy = vi.spyOn(mockPlugin, "toBeImportedFiles");
|
|
647
|
+
const importSpy = vi.spyOn(mockPlugin, "importFiles");
|
|
648
|
+
|
|
649
|
+
const project = await loadProjectFromDirectory({
|
|
650
|
+
fs: fs as any,
|
|
651
|
+
path: "/project.inlang",
|
|
652
|
+
providePlugins: [mockPlugin],
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
expect(toBeSpy).toHaveBeenCalled();
|
|
656
|
+
|
|
657
|
+
expect(importSpy).toHaveBeenCalledWith(
|
|
658
|
+
expect.objectContaining({
|
|
659
|
+
files: [
|
|
660
|
+
expect.objectContaining({
|
|
661
|
+
name: "en.json",
|
|
662
|
+
toBeImportedFilesMetadata: {
|
|
663
|
+
foo: "bar",
|
|
664
|
+
},
|
|
665
|
+
}),
|
|
666
|
+
],
|
|
667
|
+
})
|
|
668
|
+
);
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
test("it should provide plugins from disk for backwards compatibility but warn that those plugins are not portable", async () => {
|
|
672
|
+
const mockRepo = {
|
|
673
|
+
"/local-plugins/mock-plugin.js": "export default { key: 'mock-plugin' }",
|
|
674
|
+
"/local-plugins/mock-rule.js":
|
|
675
|
+
"export default { id: 'messageLintRule.mock }",
|
|
676
|
+
"/website/project.inlang/settings.json": JSON.stringify({
|
|
677
|
+
baseLocale: "en",
|
|
678
|
+
locales: ["en", "de"],
|
|
679
|
+
modules: [
|
|
680
|
+
"../local-plugins/mock-plugin.js",
|
|
681
|
+
"../local-plugins/mock-rule.js",
|
|
682
|
+
],
|
|
683
|
+
} satisfies ProjectSettings),
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const fs = Volume.fromJSON(mockRepo);
|
|
687
|
+
|
|
688
|
+
const project = await loadProjectFromDirectory({
|
|
689
|
+
fs: fs as any,
|
|
690
|
+
path: "/website/project.inlang",
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
const plugins = await project.plugins.get();
|
|
694
|
+
const errors = await project.errors.get();
|
|
695
|
+
const settings = await project.settings.get();
|
|
696
|
+
|
|
697
|
+
expect(plugins.length).toBe(1);
|
|
698
|
+
expect(plugins[0]?.key).toBe("mock-plugin");
|
|
699
|
+
|
|
700
|
+
expect(errors.length).toBe(1);
|
|
701
|
+
expect(errors[0]).toBeInstanceOf(WarningDeprecatedLintRule);
|
|
702
|
+
|
|
703
|
+
// it should not remove the module from the settings
|
|
704
|
+
// else roundtrips would not work
|
|
705
|
+
expect(settings.modules?.[0]).toBe("../local-plugins/mock-plugin.js");
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// https://github.com/opral/inlang-sdk/issues/174
|
|
709
|
+
test("plugin calls that use fs should be intercepted to use an absolute path", async () => {
|
|
710
|
+
process.cwd = () => "/";
|
|
711
|
+
|
|
712
|
+
const mockRepo = {
|
|
713
|
+
"/messages/en.json": JSON.stringify({
|
|
714
|
+
key1: "value1",
|
|
715
|
+
key2: "value2",
|
|
716
|
+
}),
|
|
717
|
+
"/project.inlang/settings.json": JSON.stringify({
|
|
718
|
+
baseLocale: "en",
|
|
719
|
+
locales: ["en", "de"],
|
|
720
|
+
"plugin.mock-plugin": {
|
|
721
|
+
pathPattern: "./messages/{locale}.json",
|
|
722
|
+
},
|
|
723
|
+
} satisfies ProjectSettings),
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const mockPlugin: InlangPlugin = {
|
|
727
|
+
key: "mock-plugin",
|
|
728
|
+
loadMessages: async ({ nodeishFs, settings }) => {
|
|
729
|
+
const pathPattern = settings["plugin.mock-plugin"]?.pathPattern.replace(
|
|
730
|
+
"{locale}",
|
|
731
|
+
"en"
|
|
732
|
+
) as string;
|
|
733
|
+
const file = await nodeishFs.readFile(pathPattern);
|
|
734
|
+
// reading the file should be possible without an error
|
|
735
|
+
expect(file.toString()).toBe(
|
|
736
|
+
JSON.stringify({
|
|
737
|
+
key1: "value1",
|
|
738
|
+
key2: "value2",
|
|
739
|
+
})
|
|
740
|
+
);
|
|
741
|
+
return [];
|
|
742
|
+
},
|
|
743
|
+
saveMessages: async ({ nodeishFs, settings }) => {
|
|
744
|
+
const pathPattern = settings["plugin.mock-plugin"]?.pathPattern.replace(
|
|
745
|
+
"{locale}",
|
|
746
|
+
"en"
|
|
747
|
+
) as string;
|
|
748
|
+
const file = new TextEncoder().encode(
|
|
749
|
+
JSON.stringify({
|
|
750
|
+
key1: "value1",
|
|
751
|
+
key2: "value2",
|
|
752
|
+
key3: "value3",
|
|
753
|
+
})
|
|
754
|
+
);
|
|
755
|
+
await nodeishFs.writeFile(pathPattern, file.buffer as ArrayBuffer);
|
|
756
|
+
},
|
|
757
|
+
toBeImportedFiles: async ({ settings }) => {
|
|
758
|
+
const pathPattern = settings["plugin.mock-plugin"]?.pathPattern.replace(
|
|
759
|
+
"{locale}",
|
|
760
|
+
"en"
|
|
761
|
+
) as string;
|
|
762
|
+
return [
|
|
763
|
+
{
|
|
764
|
+
path: pathPattern,
|
|
765
|
+
locale: "en",
|
|
766
|
+
},
|
|
767
|
+
];
|
|
768
|
+
},
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
const fs = Volume.fromJSON(mockRepo);
|
|
772
|
+
|
|
773
|
+
const loadMessagesSpy = vi.spyOn(mockPlugin, "loadMessages");
|
|
774
|
+
const saveMessagesSpy = vi.spyOn(mockPlugin, "saveMessages");
|
|
775
|
+
const toBeImportedFilesSpy = vi.spyOn(mockPlugin, "toBeImportedFiles");
|
|
776
|
+
const fsReadFileSpy = vi.spyOn(fs.promises, "readFile");
|
|
777
|
+
const fsWriteFileSpy = vi.spyOn(fs.promises, "writeFile");
|
|
778
|
+
|
|
779
|
+
const project = await loadProjectFromDirectory({
|
|
780
|
+
fs: fs as any,
|
|
781
|
+
path: "/project.inlang",
|
|
782
|
+
providePlugins: [mockPlugin],
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
expect(loadMessagesSpy).toHaveBeenCalled();
|
|
786
|
+
expect(fsReadFileSpy).toHaveBeenCalledWith("/messages/en.json", undefined);
|
|
787
|
+
|
|
788
|
+
// todo test that saveMessages works too.
|
|
789
|
+
// await project.db.insertInto("bundle").defaultValues().execute();
|
|
790
|
+
|
|
791
|
+
// const translationFile = await fs.readFile("/messages/en.json", "utf-8");
|
|
792
|
+
|
|
793
|
+
// expect(translationFile).toBe(
|
|
794
|
+
// JSON.stringify({
|
|
795
|
+
// key1: "value1",
|
|
796
|
+
// key2: "value2",
|
|
797
|
+
// key3: "value3",
|
|
798
|
+
// })
|
|
799
|
+
// );
|
|
800
|
+
|
|
801
|
+
// expect(fsWriteFileSpy).toHaveBeenCalledWith(
|
|
802
|
+
// "/messages/en.json",
|
|
803
|
+
// JSON.stringify({
|
|
804
|
+
// key1: "value1",
|
|
805
|
+
// key2: "value2",
|
|
806
|
+
// key3: "value3",
|
|
807
|
+
// }),
|
|
808
|
+
// "utf-8"
|
|
809
|
+
// );
|
|
810
|
+
|
|
811
|
+
// expect(saveMessagesSpy).toHaveBeenCalled();
|
|
812
|
+
// expect(toBeImportedFilesSpy).toHaveBeenCalled();
|
|
813
|
+
});
|
|
814
|
+
|
|
815
|
+
test("it can import plugins via http", async () => {
|
|
816
|
+
const mockRepo = {
|
|
817
|
+
"/project.inlang/settings.json": JSON.stringify({
|
|
818
|
+
baseLocale: "en",
|
|
819
|
+
locales: ["en"],
|
|
820
|
+
modules: ["https://example.com/plugin.js"],
|
|
821
|
+
} satisfies ProjectSettings),
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
const fs = Volume.fromJSON(mockRepo);
|
|
825
|
+
|
|
826
|
+
const mockPluginModule = `export default {
|
|
827
|
+
key: "mock-plugin"
|
|
828
|
+
}`;
|
|
829
|
+
|
|
830
|
+
global.fetch = vi.fn(() => Promise.resolve(new Response(mockPluginModule)));
|
|
831
|
+
|
|
832
|
+
const project = await loadProjectFromDirectory({
|
|
833
|
+
fs: fs as any,
|
|
834
|
+
path: "/project.inlang",
|
|
835
|
+
});
|
|
836
|
+
|
|
837
|
+
const plugins = await project.plugins.get();
|
|
838
|
+
|
|
839
|
+
expect(global.fetch).toHaveBeenCalledWith("https://example.com/plugin.js");
|
|
840
|
+
expect(plugins.length).toBe(1);
|
|
841
|
+
|
|
842
|
+
const pluginCache = await project.lix.db
|
|
843
|
+
.selectFrom("file")
|
|
844
|
+
.selectAll()
|
|
845
|
+
.where("path", "like", "/cache/plugins/%")
|
|
846
|
+
.execute();
|
|
847
|
+
|
|
848
|
+
expect(
|
|
849
|
+
pluginCache.some(
|
|
850
|
+
(file) => new TextDecoder().decode(file.data) === mockPluginModule
|
|
851
|
+
),
|
|
852
|
+
"expecting the plugin to be cached"
|
|
853
|
+
).toBe(true);
|
|
854
|
+
});
|