@inlang/sdk 0.36.4 → 2.0.0-beta.1
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 +167 -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 +13 -0
- package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.js +53 -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 +65 -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 +4 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +77 -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 +44 -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 +177 -0
- package/src/project/loadProject.ts +245 -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 +72 -0
- package/src/project/maybeCaptureTelemetry.ts +61 -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 +48 -0
- package/src/services/telemetry/capture.ts +98 -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,188 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
import { test, expect } from "vitest";
|
|
5
|
+
import { newProject } from "../project/newProject.js";
|
|
6
|
+
import { loadProjectInMemory } from "../project/loadProjectInMemory.js";
|
|
7
|
+
import {
|
|
8
|
+
isInSimulatedCurrentBranch,
|
|
9
|
+
resolveConflictBySelecting,
|
|
10
|
+
} from "@lix-js/sdk";
|
|
11
|
+
import { contentFromDatabase } from "sqlite-wasm-kysely";
|
|
12
|
+
|
|
13
|
+
test.skip("it should resolve a conflict with the selected change", async () => {
|
|
14
|
+
const project = await loadProjectInMemory({ blob: await newProject() });
|
|
15
|
+
|
|
16
|
+
const dbFile = await project.lix.db
|
|
17
|
+
.selectFrom("file")
|
|
18
|
+
.select("id")
|
|
19
|
+
.where("path", "=", "/db.sqlite")
|
|
20
|
+
.executeTakeFirstOrThrow();
|
|
21
|
+
|
|
22
|
+
const changes = await project.lix.db
|
|
23
|
+
.insertInto("change")
|
|
24
|
+
.values([
|
|
25
|
+
{
|
|
26
|
+
id: "e59b2fc6-612d-4087-9790-03b2ab724274",
|
|
27
|
+
author: "Anonymous",
|
|
28
|
+
file_id: dbFile.id,
|
|
29
|
+
plugin_key: "inlang-lix-plugin-v1",
|
|
30
|
+
operation: "create",
|
|
31
|
+
type: "bundle",
|
|
32
|
+
value: {
|
|
33
|
+
id: "even_hour_mule_drum",
|
|
34
|
+
},
|
|
35
|
+
created_at: "2024-08-28 20:58:04",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: "c0c9e3f3-0eba-4233-813f-e1901401a653",
|
|
39
|
+
author: "Anonymous",
|
|
40
|
+
file_id: dbFile.id,
|
|
41
|
+
plugin_key: "inlang-lix-plugin-v1",
|
|
42
|
+
operation: "create",
|
|
43
|
+
type: "message",
|
|
44
|
+
value: {
|
|
45
|
+
id: "c2684c3d-3e14-47e4-96b7-8d33579bb7e9",
|
|
46
|
+
bundleId: "even_hour_mule_drum",
|
|
47
|
+
locale: "en",
|
|
48
|
+
selectors: [],
|
|
49
|
+
},
|
|
50
|
+
created_at: "2024-08-28 20:58:04",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "b92a634f-1e25-410f-af5a-e8702cc92ef0",
|
|
54
|
+
author: "Anonymous",
|
|
55
|
+
file_id: dbFile.id,
|
|
56
|
+
plugin_key: "inlang-lix-plugin-v1",
|
|
57
|
+
operation: "create",
|
|
58
|
+
type: "variant",
|
|
59
|
+
value: {
|
|
60
|
+
id: "6a860f96-0cf3-477c-80ad-7893d8fde852",
|
|
61
|
+
messageId: "c2684c3d-3e14-47e4-96b7-8d33579bb7e9",
|
|
62
|
+
matches: [],
|
|
63
|
+
pattern: [
|
|
64
|
+
{
|
|
65
|
+
type: "text",
|
|
66
|
+
value: "My Awesome Todo App",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
created_at: "2024-08-28 20:58:04",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "samuels-change",
|
|
74
|
+
author: "Samuel",
|
|
75
|
+
parent_id: "b92a634f-1e25-410f-af5a-e8702cc92ef0",
|
|
76
|
+
file_id: dbFile.id,
|
|
77
|
+
plugin_key: "inlang-lix-plugin-v1",
|
|
78
|
+
operation: "update",
|
|
79
|
+
type: "variant",
|
|
80
|
+
value: {
|
|
81
|
+
id: "6a860f96-0cf3-477c-80ad-7893d8fde852",
|
|
82
|
+
messageId: "c2684c3d-3e14-47e4-96b7-8d33579bb7e9",
|
|
83
|
+
matches: [],
|
|
84
|
+
pattern: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
value: "My awesome lix app",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
meta: {
|
|
92
|
+
id: "6a860f96-0cf3-477c-80ad-7893d8fde852",
|
|
93
|
+
},
|
|
94
|
+
created_at: "2024-08-28 21:29:05",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "peters-change",
|
|
98
|
+
author: "Peter",
|
|
99
|
+
parent_id: "b92a634f-1e25-410f-af5a-e8702cc92ef0",
|
|
100
|
+
file_id: dbFile.id,
|
|
101
|
+
plugin_key: "inlang-lix-plugin-v1",
|
|
102
|
+
operation: "update",
|
|
103
|
+
type: "variant",
|
|
104
|
+
value: {
|
|
105
|
+
id: "6a860f96-0cf3-477c-80ad-7893d8fde852",
|
|
106
|
+
messageId: "c2684c3d-3e14-47e4-96b7-8d33579bb7e9",
|
|
107
|
+
matches: [],
|
|
108
|
+
pattern: [
|
|
109
|
+
{
|
|
110
|
+
type: "text",
|
|
111
|
+
value: "You are building an app",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
meta: {
|
|
116
|
+
id: "6a860f96-0cf3-477c-80ad-7893d8fde852",
|
|
117
|
+
},
|
|
118
|
+
created_at: "2024-08-28 21:29:35",
|
|
119
|
+
},
|
|
120
|
+
])
|
|
121
|
+
.returningAll()
|
|
122
|
+
.execute();
|
|
123
|
+
|
|
124
|
+
// ---------------
|
|
125
|
+
// Todo inlang sdk should auto write file to lix and differ must be
|
|
126
|
+
// fault tolerant. without this code, the differ captures an old
|
|
127
|
+
// change again
|
|
128
|
+
|
|
129
|
+
for (const change of changes) {
|
|
130
|
+
await project.db
|
|
131
|
+
.insertInto(change.type as any)
|
|
132
|
+
.values(change.value as any)
|
|
133
|
+
.onConflict((c) => c.doNothing())
|
|
134
|
+
.execute();
|
|
135
|
+
}
|
|
136
|
+
await project.lix.db
|
|
137
|
+
.updateTable("file")
|
|
138
|
+
.set({ data: contentFromDatabase(project._sqlite) })
|
|
139
|
+
.where("path", "=", "/db.sqlite")
|
|
140
|
+
.execute();
|
|
141
|
+
// ---------------
|
|
142
|
+
|
|
143
|
+
const conflicts = await project.lix.db
|
|
144
|
+
.insertInto("conflict")
|
|
145
|
+
.values([
|
|
146
|
+
{
|
|
147
|
+
change_id: "samuels-change",
|
|
148
|
+
conflicting_change_id: "peters-change",
|
|
149
|
+
reason: "",
|
|
150
|
+
},
|
|
151
|
+
])
|
|
152
|
+
.returningAll()
|
|
153
|
+
.execute();
|
|
154
|
+
|
|
155
|
+
const changesInCurrentBranchBefore = await project.lix.db
|
|
156
|
+
.selectFrom("change")
|
|
157
|
+
.selectAll()
|
|
158
|
+
.where(isInSimulatedCurrentBranch)
|
|
159
|
+
.execute();
|
|
160
|
+
|
|
161
|
+
expect(changesInCurrentBranchBefore.map((c) => c.id)).toEqual([
|
|
162
|
+
changes[0]?.id,
|
|
163
|
+
changes[1]?.id,
|
|
164
|
+
changes[2]?.id,
|
|
165
|
+
"samuels-change",
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
await resolveConflictBySelecting({
|
|
169
|
+
lix: project.lix,
|
|
170
|
+
conflict: conflicts[0]!,
|
|
171
|
+
selectChangeId: "peters-change",
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
await project.lix.settled();
|
|
175
|
+
|
|
176
|
+
const changesInCurrentBranch = await project.lix.db
|
|
177
|
+
.selectFrom("change")
|
|
178
|
+
.selectAll()
|
|
179
|
+
.where(isInSimulatedCurrentBranch)
|
|
180
|
+
.execute();
|
|
181
|
+
|
|
182
|
+
expect(changesInCurrentBranch.map((c) => c.id)).toEqual([
|
|
183
|
+
changes[0]?.id,
|
|
184
|
+
changes[1]?.id,
|
|
185
|
+
changes[2]?.id,
|
|
186
|
+
"peters-change",
|
|
187
|
+
]);
|
|
188
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MessageV1,
|
|
3
|
+
PatternV1,
|
|
4
|
+
} from "../../json-schema/old-v1-message/schemaV1.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated don't use the messageV1 type anymore.
|
|
8
|
+
*
|
|
9
|
+
* This function exists to ease migrations of v1 plugins to v2 plugins.
|
|
10
|
+
* The tests can call `createMessageV1` to create a message object that satisfies the v1 schema.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* - createMessage("id", { "en": "Hello" })
|
|
14
|
+
* + createMessageV1("id", { "en": "Hello" })
|
|
15
|
+
*/
|
|
16
|
+
export const createMessageV1 = (
|
|
17
|
+
id: string,
|
|
18
|
+
patterns: Record<string, PatternV1 | string>
|
|
19
|
+
) =>
|
|
20
|
+
({
|
|
21
|
+
id,
|
|
22
|
+
alias: {},
|
|
23
|
+
selectors: [],
|
|
24
|
+
variants: Object.entries(patterns).map(([languageTag, patterns]) => ({
|
|
25
|
+
languageTag,
|
|
26
|
+
match: [],
|
|
27
|
+
pattern:
|
|
28
|
+
typeof patterns === "string"
|
|
29
|
+
? [
|
|
30
|
+
{
|
|
31
|
+
type: "Text",
|
|
32
|
+
value: patterns,
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
: patterns,
|
|
36
|
+
})),
|
|
37
|
+
}) satisfies MessageV1;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
import type { ProjectSettings } from "../../json-schema/settings.js";
|
|
3
|
+
import { withLanguageTagToLocaleMigration } from "./withLanguageTagToLocaleMigration.js";
|
|
4
|
+
|
|
5
|
+
test("it should set sourceLanguageTag and languageTags if non-existent to make v1 plugins work", async () => {
|
|
6
|
+
const settings: ProjectSettings = {
|
|
7
|
+
baseLocale: "en",
|
|
8
|
+
locales: ["en", "de"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const withMigration = withLanguageTagToLocaleMigration(settings);
|
|
12
|
+
|
|
13
|
+
expect(withMigration.baseLocale).toBe("en");
|
|
14
|
+
expect(withMigration.sourceLanguageTag).toBe("en");
|
|
15
|
+
expect(withMigration.locales).toEqual(["en", "de"]);
|
|
16
|
+
expect(withMigration.languageTags).toEqual(["en", "de"]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("it should set baseLocale and locales if non-existent to ensure first load of an old project works", async () => {
|
|
20
|
+
const settings: ProjectSettings = {
|
|
21
|
+
sourceLanguageTag: "en",
|
|
22
|
+
languageTags: ["en", "de"],
|
|
23
|
+
} as ProjectSettings;
|
|
24
|
+
|
|
25
|
+
const withMigration = withLanguageTagToLocaleMigration(settings);
|
|
26
|
+
|
|
27
|
+
expect(withMigration.baseLocale).toBe("en");
|
|
28
|
+
expect(withMigration.sourceLanguageTag).toBe("en");
|
|
29
|
+
expect(withMigration.languageTags).toEqual(["en", "de"]);
|
|
30
|
+
expect(withMigration.locales).toEqual(["en", "de"]);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Users are expected to treat baseLocale and locales as the source of truth.
|
|
35
|
+
* The alternative is complicated merging logic which is not worth the effort.
|
|
36
|
+
*/
|
|
37
|
+
test("it should treat baseLocale and locales as source of truth", async () => {
|
|
38
|
+
const settings: ProjectSettings = {
|
|
39
|
+
baseLocale: "de",
|
|
40
|
+
locales: ["de", "en", "fr", "es"],
|
|
41
|
+
sourceLanguageTag: "en",
|
|
42
|
+
languageTags: ["en", "nl"],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const withMigration = withLanguageTagToLocaleMigration(settings);
|
|
46
|
+
|
|
47
|
+
expect(withMigration.baseLocale).toBe("de");
|
|
48
|
+
expect(withMigration.sourceLanguageTag).toBe("de");
|
|
49
|
+
expect(withMigration.languageTags).toEqual(["de", "en", "fr", "es"]);
|
|
50
|
+
expect(withMigration.locales).toEqual(["de", "en", "fr", "es"]);
|
|
51
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ProjectSettings } from "../../json-schema/settings.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Change introduced in v2.
|
|
5
|
+
*
|
|
6
|
+
* The sourceLanguageTag and languageTags are now deprecated
|
|
7
|
+
* in favor of baseLocale and locales.
|
|
8
|
+
*/
|
|
9
|
+
export function withLanguageTagToLocaleMigration(
|
|
10
|
+
settings: ProjectSettings
|
|
11
|
+
): ProjectSettings {
|
|
12
|
+
if (settings.sourceLanguageTag === undefined) {
|
|
13
|
+
settings.sourceLanguageTag = settings.baseLocale;
|
|
14
|
+
}
|
|
15
|
+
if (settings.languageTags === undefined) {
|
|
16
|
+
settings.languageTags = settings.locales;
|
|
17
|
+
}
|
|
18
|
+
if (settings.baseLocale === undefined) {
|
|
19
|
+
settings.baseLocale = settings.sourceLanguageTag;
|
|
20
|
+
}
|
|
21
|
+
if (settings.locales === undefined) {
|
|
22
|
+
settings.locales = settings.languageTags;
|
|
23
|
+
}
|
|
24
|
+
if (settings.sourceLanguageTag !== settings.baseLocale) {
|
|
25
|
+
settings.sourceLanguageTag = settings.baseLocale;
|
|
26
|
+
}
|
|
27
|
+
if (settings.languageTags !== settings.locales) {
|
|
28
|
+
settings.languageTags = settings.locales;
|
|
29
|
+
}
|
|
30
|
+
return settings;
|
|
31
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { test, expect, vi } from "vitest";
|
|
2
|
+
import { withCache } from "./cache.js";
|
|
3
|
+
import { newLixFile, openLixInMemory } from "@lix-js/sdk";
|
|
4
|
+
import { sql } from "kysely";
|
|
5
|
+
|
|
6
|
+
test("it should be network-first", async () => {
|
|
7
|
+
const mockLoader = vi
|
|
8
|
+
.fn()
|
|
9
|
+
.mockResolvedValueOnce("module content 1")
|
|
10
|
+
.mockResolvedValueOnce("module content 2");
|
|
11
|
+
|
|
12
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
13
|
+
|
|
14
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
15
|
+
|
|
16
|
+
const result1 = await withCache(mockLoader, lix)(mockModulePath);
|
|
17
|
+
|
|
18
|
+
expect(mockLoader).toHaveBeenCalledTimes(1);
|
|
19
|
+
expect(result1).toBe("module content 1");
|
|
20
|
+
|
|
21
|
+
const cachedPlugins = await lix.db
|
|
22
|
+
.selectFrom("file")
|
|
23
|
+
.selectAll()
|
|
24
|
+
// @ts-expect-error - kysely doesn't know about GLOB
|
|
25
|
+
.where(sql`path GLOB '/cache/plugins/*'`)
|
|
26
|
+
.execute();
|
|
27
|
+
|
|
28
|
+
expect(cachedPlugins.length).toBe(1);
|
|
29
|
+
|
|
30
|
+
const parsed = new TextDecoder().decode(cachedPlugins[0]!.data);
|
|
31
|
+
|
|
32
|
+
expect(parsed).toBe("module content 1");
|
|
33
|
+
|
|
34
|
+
const result2 = await withCache(mockLoader, lix)(mockModulePath);
|
|
35
|
+
|
|
36
|
+
expect(mockLoader).toHaveBeenCalledTimes(2);
|
|
37
|
+
expect(result2).toBe("module content 2");
|
|
38
|
+
|
|
39
|
+
const cachedPlugins2 = await lix.db
|
|
40
|
+
.selectFrom("file")
|
|
41
|
+
.selectAll()
|
|
42
|
+
// @ts-expect-error - kysely doesn't know about GLOB
|
|
43
|
+
.where(sql`path GLOB '/cache/plugins/*'`)
|
|
44
|
+
.execute();
|
|
45
|
+
|
|
46
|
+
expect(cachedPlugins2.length).toBe(1);
|
|
47
|
+
|
|
48
|
+
const parsed2 = new TextDecoder().decode(cachedPlugins2[0]!.data);
|
|
49
|
+
|
|
50
|
+
expect(parsed2).toBe("module content 2");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("it should throw the error from the loader if the cache does not exist", async () => {
|
|
54
|
+
const mockLoader = vi.fn().mockRejectedValueOnce(new Error("Network error"));
|
|
55
|
+
|
|
56
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
57
|
+
|
|
58
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
async () => await withCache(mockLoader, lix)(mockModulePath)
|
|
62
|
+
).rejects.toThrowError("Network error");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("it should fallback to the cache if the loader fails", async () => {
|
|
66
|
+
const mockLoader = vi.fn().mockRejectedValueOnce(new Error("Network error"));
|
|
67
|
+
|
|
68
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
69
|
+
const mockModuleCachePath = "/cache/plugins/31i1etp0l413h";
|
|
70
|
+
|
|
71
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
72
|
+
|
|
73
|
+
await lix.db
|
|
74
|
+
.insertInto("file")
|
|
75
|
+
.values({
|
|
76
|
+
path: mockModuleCachePath,
|
|
77
|
+
data: new TextEncoder().encode("cached module content"),
|
|
78
|
+
})
|
|
79
|
+
.execute();
|
|
80
|
+
|
|
81
|
+
const result = await withCache(mockLoader, lix)(mockModulePath);
|
|
82
|
+
expect(result).toBe("cached module content");
|
|
83
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Lix } from "@lix-js/sdk";
|
|
2
|
+
|
|
3
|
+
function escape(url: string) {
|
|
4
|
+
const bytes = new TextEncoder().encode(url);
|
|
5
|
+
|
|
6
|
+
// 64-bit FNV1a hash to make the file-names shorter
|
|
7
|
+
// https://en.wikipedia.org/wiki/FNV-1a
|
|
8
|
+
const hash = bytes.reduce(
|
|
9
|
+
(hash, byte) =>
|
|
10
|
+
BigInt.asUintN(64, (hash ^ BigInt(byte)) * 1_099_511_628_211n),
|
|
11
|
+
14_695_981_039_346_656_037n
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
return hash.toString(36);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function readModuleFromCache(
|
|
18
|
+
moduleURI: string,
|
|
19
|
+
lix: Lix
|
|
20
|
+
): Promise<string | undefined> {
|
|
21
|
+
const moduleHash = escape(moduleURI);
|
|
22
|
+
const filePath = `/cache/plugins/${moduleHash}`;
|
|
23
|
+
|
|
24
|
+
const file = await lix.db
|
|
25
|
+
.selectFrom("file")
|
|
26
|
+
.where("path", "=", filePath)
|
|
27
|
+
.selectAll()
|
|
28
|
+
.executeTakeFirst();
|
|
29
|
+
|
|
30
|
+
if (file) {
|
|
31
|
+
return new TextDecoder().decode(file.data);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function writeModuleToCache(
|
|
37
|
+
moduleURI: string,
|
|
38
|
+
moduleContent: string,
|
|
39
|
+
lix: Lix
|
|
40
|
+
): Promise<void> {
|
|
41
|
+
const moduleHash = escape(moduleURI);
|
|
42
|
+
const filePath = `/cache/plugins/${moduleHash}`;
|
|
43
|
+
|
|
44
|
+
await lix.db
|
|
45
|
+
.insertInto("file")
|
|
46
|
+
.values({
|
|
47
|
+
path: filePath,
|
|
48
|
+
data: new TextEncoder().encode(moduleContent),
|
|
49
|
+
})
|
|
50
|
+
// update the cache
|
|
51
|
+
.onConflict((oc) =>
|
|
52
|
+
oc.doUpdateSet({ data: new TextEncoder().encode(moduleContent) })
|
|
53
|
+
)
|
|
54
|
+
.execute();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Implements a "Network-First" caching strategy.
|
|
59
|
+
*/
|
|
60
|
+
export function withCache(
|
|
61
|
+
moduleLoader: (uri: string) => Promise<string>,
|
|
62
|
+
lix: Lix
|
|
63
|
+
): (uri: string) => Promise<string> {
|
|
64
|
+
return async (uri: string) => {
|
|
65
|
+
try {
|
|
66
|
+
const moduleAsText = await moduleLoader(uri);
|
|
67
|
+
await writeModuleToCache(uri, moduleAsText, lix);
|
|
68
|
+
return moduleAsText;
|
|
69
|
+
} catch (e) {
|
|
70
|
+
// network fetch failed, try to read from cache
|
|
71
|
+
const cacheResult = await readModuleFromCache(uri, lix);
|
|
72
|
+
if (cacheResult) {
|
|
73
|
+
return cacheResult;
|
|
74
|
+
} else {
|
|
75
|
+
throw e;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ValueError } from "@sinclair/typebox/errors";
|
|
2
|
+
|
|
3
|
+
export class PluginError extends Error {
|
|
4
|
+
public readonly plugin: string;
|
|
5
|
+
|
|
6
|
+
constructor(message: string, options: { plugin: string; cause?: Error }) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "PluginError";
|
|
9
|
+
this.plugin = options.plugin;
|
|
10
|
+
this.cause = options.cause;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Error when a plugin cannot be imported.
|
|
16
|
+
*/
|
|
17
|
+
export class PluginImportError extends PluginError {
|
|
18
|
+
constructor(options: { plugin: string; cause: Error }) {
|
|
19
|
+
super(
|
|
20
|
+
`Couldn't import the plugin "${options.plugin}":\n\n${options.cause}`,
|
|
21
|
+
options
|
|
22
|
+
);
|
|
23
|
+
this.name = "PluginImportError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class PluginSettingsAreInvalidError extends PluginError {
|
|
28
|
+
constructor(options: { plugin: string; errors: ValueError[] }) {
|
|
29
|
+
super(
|
|
30
|
+
`The settings of "${options.plugin}" are invalid:\n\n${options.errors
|
|
31
|
+
.map(
|
|
32
|
+
(error) =>
|
|
33
|
+
`Path "${error.path}" with value "${JSON.stringify(
|
|
34
|
+
error.value,
|
|
35
|
+
undefined,
|
|
36
|
+
2
|
|
37
|
+
)}": "${error.message}"`
|
|
38
|
+
)
|
|
39
|
+
.join("\n")}`,
|
|
40
|
+
options
|
|
41
|
+
);
|
|
42
|
+
this.name = "PluginSettingsAreInvalidError";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Error when a plugin does not implement a required function
|
|
48
|
+
*/
|
|
49
|
+
export class PluginDoesNotImplementFunctionError extends PluginError {
|
|
50
|
+
constructor(options: { plugin: string; function: string }) {
|
|
51
|
+
super(
|
|
52
|
+
`The plugin "${options.plugin}" does not implement the "${options.function}" function.`,
|
|
53
|
+
options
|
|
54
|
+
);
|
|
55
|
+
this.name = "PluginDoesNotImplementFunction";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Error when a plugin was expected to exist, but doesn't
|
|
61
|
+
*/
|
|
62
|
+
export class PluginMissingError extends PluginError {
|
|
63
|
+
constructor(options: { plugin: string }) {
|
|
64
|
+
super(`The plugin "${options.plugin}" does not exist`, options);
|
|
65
|
+
this.name = "PluginMissingError";
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { test, expect, vi } from "vitest";
|
|
2
|
+
import { importPlugins } from "./importPlugins.js";
|
|
3
|
+
import { PluginImportError } from "./errors.js";
|
|
4
|
+
import { newLixFile, openLixInMemory } from "@lix-js/sdk";
|
|
5
|
+
|
|
6
|
+
test("it should preprocess a plugin", async () => {
|
|
7
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
8
|
+
ok: true,
|
|
9
|
+
text: vi.fn().mockResolvedValue("export default { key: 'mock' }"),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
13
|
+
const result = await importPlugins({
|
|
14
|
+
lix,
|
|
15
|
+
settings: {
|
|
16
|
+
baseLocale: "en",
|
|
17
|
+
locales: ["en"],
|
|
18
|
+
modules: ["https://mock.com/module.js"],
|
|
19
|
+
},
|
|
20
|
+
preprocessPluginBeforeImport: async (moduleText) => {
|
|
21
|
+
return moduleText.replace("mock", "preprocessed");
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
26
|
+
expect(result.plugins.length).toBe(1);
|
|
27
|
+
expect(result.errors.length).toBe(0);
|
|
28
|
+
expect(result.plugins[0]?.key).toBe("preprocessed");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("if a fetch fails, a plugin import error is expected", async () => {
|
|
32
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
33
|
+
ok: false,
|
|
34
|
+
statusText: "HTTP 404",
|
|
35
|
+
});
|
|
36
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
37
|
+
|
|
38
|
+
const result = await importPlugins({
|
|
39
|
+
lix,
|
|
40
|
+
settings: {
|
|
41
|
+
baseLocale: "en",
|
|
42
|
+
locales: ["en"],
|
|
43
|
+
modules: ["https://mock.com/module.js"],
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
48
|
+
expect(result.plugins.length).toBe(0);
|
|
49
|
+
expect(result.errors.length).toBe(1);
|
|
50
|
+
expect(result.errors[0]).toBeInstanceOf(PluginImportError);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("it should filter message lint rules for legacy reasons", async () => {
|
|
54
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
55
|
+
ok: true,
|
|
56
|
+
text: vi
|
|
57
|
+
.fn()
|
|
58
|
+
.mockResolvedValue("export default { id: 'messageLintRule.something' }"),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
62
|
+
|
|
63
|
+
const result = await importPlugins({
|
|
64
|
+
lix,
|
|
65
|
+
settings: {
|
|
66
|
+
baseLocale: "en",
|
|
67
|
+
locales: ["en"],
|
|
68
|
+
modules: ["https://mock.com/module.js"],
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(result.plugins.length).toBe(0);
|
|
73
|
+
expect(result.errors.length).toBe(0);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// more tests are found in cache.test.ts
|
|
77
|
+
test("cache should work", async () => {
|
|
78
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
79
|
+
ok: false,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
83
|
+
const mockModuleCachePath = "/cache/plugins/31i1etp0l413h";
|
|
84
|
+
|
|
85
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
86
|
+
|
|
87
|
+
await lix.db
|
|
88
|
+
.insertInto("file")
|
|
89
|
+
.values({
|
|
90
|
+
path: mockModuleCachePath,
|
|
91
|
+
data: new TextEncoder().encode("export default { key: 'mock' }"),
|
|
92
|
+
})
|
|
93
|
+
.execute();
|
|
94
|
+
|
|
95
|
+
const result = await importPlugins({
|
|
96
|
+
lix,
|
|
97
|
+
settings: {
|
|
98
|
+
baseLocale: "en",
|
|
99
|
+
locales: ["en"],
|
|
100
|
+
modules: [mockModulePath],
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(result.errors).lengthOf(0);
|
|
105
|
+
expect(result.plugins).lengthOf(1);
|
|
106
|
+
expect(result.plugins[0]?.key).toBe("mock");
|
|
107
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Lix } from "@lix-js/sdk";
|
|
2
|
+
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
3
|
+
import { PluginError, PluginImportError } from "./errors.js";
|
|
4
|
+
import type { InlangPlugin } from "./schema.js";
|
|
5
|
+
import { withCache } from "./cache.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Function that preprocesses the plugin before importing it.
|
|
9
|
+
*
|
|
10
|
+
* - used by sherlock to convert ESM to CJS
|
|
11
|
+
*/
|
|
12
|
+
export type PreprocessPluginBeforeImportFunction = (
|
|
13
|
+
moduleText: string
|
|
14
|
+
) => Promise<string> | string;
|
|
15
|
+
|
|
16
|
+
export async function importPlugins(args: {
|
|
17
|
+
lix: Lix;
|
|
18
|
+
settings: ProjectSettings;
|
|
19
|
+
preprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
plugins: InlangPlugin[];
|
|
22
|
+
errors: PluginError[];
|
|
23
|
+
}> {
|
|
24
|
+
const plugins: InlangPlugin[] = [];
|
|
25
|
+
const errors: PluginError[] = [];
|
|
26
|
+
for (const uri of args.settings.modules ?? []) {
|
|
27
|
+
try {
|
|
28
|
+
let moduleAsText = await withCache(fetchPlugin, args.lix)(uri);
|
|
29
|
+
if (args.preprocessPluginBeforeImport) {
|
|
30
|
+
moduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);
|
|
31
|
+
}
|
|
32
|
+
const moduleWithMimeType =
|
|
33
|
+
"data:application/javascript," + encodeURIComponent(moduleAsText);
|
|
34
|
+
const { default: module } = await import(
|
|
35
|
+
/* @vite-ignore */ moduleWithMimeType
|
|
36
|
+
);
|
|
37
|
+
// old legacy message lint rules are not supported
|
|
38
|
+
// and ingored for backwards compatibility
|
|
39
|
+
if (module.id?.includes("messageLintRule")) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
plugins.push(module);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
errors.push(new PluginImportError({ plugin: uri, cause: e as Error }));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { plugins, errors };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function fetchPlugin(uri: string): Promise<string> {
|
|
51
|
+
try {
|
|
52
|
+
const response = await fetch(uri);
|
|
53
|
+
return await response.text();
|
|
54
|
+
} catch (error) {
|
|
55
|
+
throw new PluginImportError({
|
|
56
|
+
plugin: uri,
|
|
57
|
+
cause: error as Error,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|