@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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrateToDirectory.test.d.ts","sourceRoot":"","sources":["../../src/migrations/migrateToDirectory.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { test, expect, vi } from "vitest";
|
|
2
|
-
import { maybeMigrateToDirectory } from "./migrateToDirectory.js";
|
|
3
|
-
import { createNodeishMemoryFs } from "@lix-js/fs";
|
|
4
|
-
test("it should return if the settings file has an error (let loadProject handle it)", async () => {
|
|
5
|
-
const projectPath = "./project.inlang";
|
|
6
|
-
const mockFs = {
|
|
7
|
-
stat: vi.fn(() => { }),
|
|
8
|
-
readFile: vi.fn(() => {
|
|
9
|
-
throw Error();
|
|
10
|
-
}),
|
|
11
|
-
};
|
|
12
|
-
await maybeMigrateToDirectory({ nodeishFs: mockFs, projectPath });
|
|
13
|
-
// something goes wrong in readFile
|
|
14
|
-
expect(mockFs.readFile).toHaveBeenCalled();
|
|
15
|
-
});
|
|
16
|
-
test("it should create the project directory if it does not exist and a project settings file exists", async () => {
|
|
17
|
-
const projectPath = "./project.inlang";
|
|
18
|
-
const mockFs = {
|
|
19
|
-
readFile: vi.fn(() => `{
|
|
20
|
-
"sourceLanguageTag": "en",
|
|
21
|
-
"languageTags": ["en", "de"],
|
|
22
|
-
"modules": []
|
|
23
|
-
}`),
|
|
24
|
-
stat: vi.fn(() => {
|
|
25
|
-
throw Error();
|
|
26
|
-
}),
|
|
27
|
-
mkdir: vi.fn(),
|
|
28
|
-
writeFile: vi.fn(),
|
|
29
|
-
};
|
|
30
|
-
await maybeMigrateToDirectory({ nodeishFs: mockFs, projectPath });
|
|
31
|
-
expect(mockFs.mkdir).toHaveBeenCalled();
|
|
32
|
-
expect(mockFs.writeFile).toHaveBeenCalled();
|
|
33
|
-
});
|
|
34
|
-
test("it should write the settings file to the new path", async () => {
|
|
35
|
-
const fs = createNodeishMemoryFs();
|
|
36
|
-
const mockSettings = {
|
|
37
|
-
sourceLanguageTag: "en",
|
|
38
|
-
languageTags: ["en", "de"],
|
|
39
|
-
modules: [],
|
|
40
|
-
};
|
|
41
|
-
await fs.writeFile("./project.inlang.json", JSON.stringify(mockSettings));
|
|
42
|
-
await maybeMigrateToDirectory({ nodeishFs: fs, projectPath: "./project.inlang" });
|
|
43
|
-
const migratedSettingsFile = await fs.readFile("./project.inlang/settings.json", {
|
|
44
|
-
encoding: "utf-8",
|
|
45
|
-
});
|
|
46
|
-
expect(migratedSettingsFile).toEqual(JSON.stringify(mockSettings));
|
|
47
|
-
expect(await fs.stat("./project.inlang.README.md")).toBeDefined();
|
|
48
|
-
});
|
package/dist/parseConfig.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ProjectSettings } from "./versionedInterfaces.js";
|
|
2
|
-
import type { Result } from "@inlang/result";
|
|
3
|
-
export declare class ParseConfigError extends Error {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(message: string, cause?: string);
|
|
6
|
-
}
|
|
7
|
-
export declare const parseSettings: (config: ProjectSettings) => Result<ProjectSettings, ParseConfigError>;
|
|
8
|
-
//# sourceMappingURL=parseConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseConfig.d.ts","sourceRoot":"","sources":["../src/parseConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG5C,qBAAa,gBAAiB,SAAQ,KAAK;;gBAG9B,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAK3C;AAKD,eAAO,MAAM,aAAa,WACjB,eAAe,KACrB,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAe1C,CAAA"}
|
package/dist/parseConfig.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ProjectSettings } from "./versionedInterfaces.js";
|
|
2
|
-
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
3
|
-
export class ParseConfigError extends Error {
|
|
4
|
-
#id = "ParseConfigException";
|
|
5
|
-
constructor(message, cause) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = this.#id;
|
|
8
|
-
this.cause = cause;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
// @ts-ignore - fix after refactor
|
|
12
|
-
const ConfigCompiler = TypeCompiler.Compile(ProjectSettings);
|
|
13
|
-
export const parseSettings = (config) => {
|
|
14
|
-
if (ConfigCompiler.Check(config)) {
|
|
15
|
-
return {
|
|
16
|
-
data: config,
|
|
17
|
-
error: undefined,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return {
|
|
22
|
-
error: new ParseConfigError("The inlang config is not valid.", [...ConfigCompiler.Errors(config)].toString()),
|
|
23
|
-
data: undefined,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State machine to convert async save() into batched async save()
|
|
3
|
-
* states = idle -> acquiring -> saving -> idle
|
|
4
|
-
* idle = nothing queued, ready to acquire lock.
|
|
5
|
-
* aquiring = waiting to acquire a lock: requests go into the queue.
|
|
6
|
-
* saving = lock is acquired, save has begun: new requests go into the next batch.
|
|
7
|
-
* The next batch should not acquire the lock while current save is in progress.
|
|
8
|
-
* Queued requests are only resolved when the save completes.
|
|
9
|
-
*/
|
|
10
|
-
export declare function batchedIO(acquireLock: () => Promise<number>, releaseLock: (lock: number) => Promise<void>, save: () => Promise<void>): (id: string) => Promise<string>;
|
|
11
|
-
//# sourceMappingURL=batchedIO.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batchedIO.d.ts","sourceRoot":"","sources":["../../src/persistence/batchedIO.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACxB,WAAW,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EAClC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAC5C,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GACvB,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CA+CjC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import _debug from "debug";
|
|
2
|
-
const debug = _debug("sdk:batchedIO");
|
|
3
|
-
/**
|
|
4
|
-
* State machine to convert async save() into batched async save()
|
|
5
|
-
* states = idle -> acquiring -> saving -> idle
|
|
6
|
-
* idle = nothing queued, ready to acquire lock.
|
|
7
|
-
* aquiring = waiting to acquire a lock: requests go into the queue.
|
|
8
|
-
* saving = lock is acquired, save has begun: new requests go into the next batch.
|
|
9
|
-
* The next batch should not acquire the lock while current save is in progress.
|
|
10
|
-
* Queued requests are only resolved when the save completes.
|
|
11
|
-
*/
|
|
12
|
-
export function batchedIO(acquireLock, releaseLock, save) {
|
|
13
|
-
// 3-state machine
|
|
14
|
-
let state = "idle";
|
|
15
|
-
const queue = [];
|
|
16
|
-
// initialize nextBatch lazily, reset after saving
|
|
17
|
-
let nextBatch = undefined;
|
|
18
|
-
// batched save function
|
|
19
|
-
return async (id) => {
|
|
20
|
-
if (state === "idle") {
|
|
21
|
-
state = "acquiring";
|
|
22
|
-
const lock = await acquireLock();
|
|
23
|
-
state = "saving";
|
|
24
|
-
await save();
|
|
25
|
-
await releaseLock(lock);
|
|
26
|
-
resolveQueued();
|
|
27
|
-
nextBatch = undefined;
|
|
28
|
-
state = "idle";
|
|
29
|
-
return id;
|
|
30
|
-
}
|
|
31
|
-
else if (state === "acquiring") {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
queue.push({ id, resolve, reject });
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// state === "saving"
|
|
38
|
-
nextBatch = nextBatch ?? batchedIO(acquireLock, releaseLock, save);
|
|
39
|
-
return await nextBatch(id);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
function resolveQueued() {
|
|
43
|
-
debug("batched", queue.length + 1);
|
|
44
|
-
for (const { id, resolve } of queue) {
|
|
45
|
-
resolve(id);
|
|
46
|
-
}
|
|
47
|
-
queue.length = 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"batchedIO.test.d.ts","sourceRoot":"","sources":["../../src/persistence/batchedIO.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import { sleep } from "../test-utilities/sleep.js";
|
|
3
|
-
import { batchedIO } from "./batchedIO.js";
|
|
4
|
-
let locked = false;
|
|
5
|
-
const instrumentAquireLockStart = vi.fn();
|
|
6
|
-
async function mockAquireLock() {
|
|
7
|
-
instrumentAquireLockStart();
|
|
8
|
-
let pollCount = 0;
|
|
9
|
-
while (locked && pollCount++ < 100) {
|
|
10
|
-
await sleep(10);
|
|
11
|
-
}
|
|
12
|
-
if (locked) {
|
|
13
|
-
throw new Error("Timeout acquiring lock");
|
|
14
|
-
}
|
|
15
|
-
await sleep(10);
|
|
16
|
-
locked = true;
|
|
17
|
-
return 69;
|
|
18
|
-
}
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
async function mockReleaseLock(_) {
|
|
21
|
-
sleep(10);
|
|
22
|
-
locked = false;
|
|
23
|
-
}
|
|
24
|
-
const instrumentSaveStart = vi.fn();
|
|
25
|
-
const instrumentSaveEnd = vi.fn();
|
|
26
|
-
async function mockSave() {
|
|
27
|
-
instrumentSaveStart();
|
|
28
|
-
await sleep(50);
|
|
29
|
-
instrumentSaveEnd();
|
|
30
|
-
}
|
|
31
|
-
describe("batchedIO", () => {
|
|
32
|
-
it("queues 2 requests while waiting for lock and pushes 2 more to the next batch", async () => {
|
|
33
|
-
const save = batchedIO(mockAquireLock, mockReleaseLock, mockSave);
|
|
34
|
-
const p1 = save("1");
|
|
35
|
-
const p2 = save("2");
|
|
36
|
-
await sleep(5);
|
|
37
|
-
expect(instrumentAquireLockStart).toHaveBeenCalledTimes(1);
|
|
38
|
-
expect(instrumentSaveStart).not.toHaveBeenCalled();
|
|
39
|
-
await sleep(10);
|
|
40
|
-
expect(instrumentSaveStart).toHaveBeenCalled();
|
|
41
|
-
expect(instrumentSaveEnd).not.toHaveBeenCalled();
|
|
42
|
-
const p3 = save("3");
|
|
43
|
-
const p4 = save("4");
|
|
44
|
-
expect(instrumentAquireLockStart).toHaveBeenCalledTimes(2);
|
|
45
|
-
expect(locked).toBe(true);
|
|
46
|
-
await sleep(50);
|
|
47
|
-
expect(instrumentSaveEnd).toHaveBeenCalled();
|
|
48
|
-
expect(await p1).toBe("1");
|
|
49
|
-
expect(await p2).toBe("2");
|
|
50
|
-
expect(instrumentSaveStart).toHaveBeenCalledTimes(1);
|
|
51
|
-
expect(await p3).toBe("3");
|
|
52
|
-
expect(await p4).toBe("4");
|
|
53
|
-
expect(instrumentAquireLockStart).toHaveBeenCalledTimes(2);
|
|
54
|
-
expect(instrumentSaveStart).toHaveBeenCalledTimes(2);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"acquireFileLock.d.ts","sourceRoot":"","sources":["../../../src/persistence/filelock/acquireFileLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAQnD,wBAAsB,eAAe,CACpC,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAmHjB"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {} from "@lix-js/fs";
|
|
2
|
-
import _debug from "debug";
|
|
3
|
-
const debug = _debug("sdk:fileLock");
|
|
4
|
-
const maxRetries = 10;
|
|
5
|
-
const nProbes = 50;
|
|
6
|
-
const probeInterval = 100;
|
|
7
|
-
export async function acquireFileLock(fs, lockDirPath, lockOrigin, tryCount = 0) {
|
|
8
|
-
if (tryCount > maxRetries) {
|
|
9
|
-
throw new Error(`${lockOrigin} exceeded maximum retries (${maxRetries}) to acquire lockfile ${tryCount}`);
|
|
10
|
-
}
|
|
11
|
-
try {
|
|
12
|
-
debug(lockOrigin + " tries to acquire a lockfile Retry Nr.: " + tryCount);
|
|
13
|
-
await fs.mkdir(lockDirPath);
|
|
14
|
-
// NOTE: fs.stat does not need to be atomic since mkdir would crash atomically - if we are here its save to consider the lock held by this process
|
|
15
|
-
const stats = await fs.stat(lockDirPath);
|
|
16
|
-
debug(lockOrigin + " acquired a lockfile Retry Nr.: " + tryCount);
|
|
17
|
-
return stats.mtimeMs;
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
if (error.code !== "EEXIST") {
|
|
21
|
-
// NOTE in case we have an EEXIST - this is an expected error: the folder existed - another process already acquired the lock. Rethrow all other errors
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// land here if the lockDirPath already exists => lock is held by other process
|
|
26
|
-
let currentLockTime;
|
|
27
|
-
try {
|
|
28
|
-
const stats = await fs.stat(lockDirPath);
|
|
29
|
-
currentLockTime = stats.mtimeMs;
|
|
30
|
-
}
|
|
31
|
-
catch (fstatError) {
|
|
32
|
-
if (fstatError.code === "ENOENT") {
|
|
33
|
-
// lock file seems to be gone :) - lets try again
|
|
34
|
-
debug(lockOrigin + " tryCount++ lock file seems to be gone :) - lets try again " + tryCount);
|
|
35
|
-
return acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
36
|
-
}
|
|
37
|
-
throw fstatError;
|
|
38
|
-
}
|
|
39
|
-
debug(lockOrigin +
|
|
40
|
-
" tries to acquire a lockfile - lock currently in use... starting probe phase " +
|
|
41
|
-
tryCount);
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
let probeCounts = 0;
|
|
44
|
-
const scheduleProbationTimeout = () => {
|
|
45
|
-
setTimeout(async () => {
|
|
46
|
-
probeCounts += 1;
|
|
47
|
-
let lockFileStats = undefined;
|
|
48
|
-
try {
|
|
49
|
-
debug(lockOrigin + " tries to acquire a lockfile - check if the lock is free now " + tryCount);
|
|
50
|
-
// alright lets give it another try
|
|
51
|
-
lockFileStats = await fs.stat(lockDirPath);
|
|
52
|
-
}
|
|
53
|
-
catch (fstatError) {
|
|
54
|
-
if (fstatError.code === "ENOENT") {
|
|
55
|
-
debug(lockOrigin +
|
|
56
|
-
" tryCount++ in Promise - tries to acquire a lockfile - lock file seems to be free now - try to acquire " +
|
|
57
|
-
tryCount);
|
|
58
|
-
const lock = acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
59
|
-
return resolve(lock);
|
|
60
|
-
}
|
|
61
|
-
return reject(fstatError);
|
|
62
|
-
}
|
|
63
|
-
// still the same locker! -
|
|
64
|
-
if (lockFileStats.mtimeMs === currentLockTime) {
|
|
65
|
-
if (probeCounts >= nProbes) {
|
|
66
|
-
// ok maximum lock time ran up (we waitetd nProbes * probeInterval) - we consider the lock to be stale
|
|
67
|
-
debug(lockOrigin +
|
|
68
|
-
" tries to acquire a lockfile - lock not free - but stale lets drop it" +
|
|
69
|
-
tryCount);
|
|
70
|
-
try {
|
|
71
|
-
await fs.rmdir(lockDirPath);
|
|
72
|
-
}
|
|
73
|
-
catch (rmLockError) {
|
|
74
|
-
if (rmLockError.code === "ENOENT") {
|
|
75
|
-
// lock already gone?
|
|
76
|
-
// Option 1: The "stale process" decided to get rid of it
|
|
77
|
-
// Option 2: Another process acquiring the lock and detected a stale one as well
|
|
78
|
-
}
|
|
79
|
-
return reject(rmLockError);
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
debug(lockOrigin +
|
|
83
|
-
" tryCount++ same locker - try to acquire again after removing stale lock " +
|
|
84
|
-
tryCount);
|
|
85
|
-
const lock = await acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
86
|
-
return resolve(lock);
|
|
87
|
-
}
|
|
88
|
-
catch (lockAquireException) {
|
|
89
|
-
return reject(lockAquireException);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
// lets schedule a new probation
|
|
94
|
-
return scheduleProbationTimeout();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
try {
|
|
99
|
-
debug(lockOrigin + " tryCount++ different locker - try to acquire again " + tryCount);
|
|
100
|
-
const lock = await acquireFileLock(fs, lockDirPath, lockOrigin, tryCount + 1);
|
|
101
|
-
return resolve(lock);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return reject(error);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, probeInterval);
|
|
108
|
-
};
|
|
109
|
-
scheduleProbationTimeout();
|
|
110
|
-
});
|
|
111
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"releaseLock.d.ts","sourceRoot":"","sources":["../../../src/persistence/filelock/releaseLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,wBAAsB,WAAW,CAChC,EAAE,EAAE,iBAAiB,EACrB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,iBAoBhB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {} from "@lix-js/fs";
|
|
2
|
-
import _debug from "debug";
|
|
3
|
-
const debug = _debug("sdk:fileLock");
|
|
4
|
-
export async function releaseLock(fs, lockDirPath, lockOrigin, lockTime) {
|
|
5
|
-
debug(lockOrigin + " releasing the lock ");
|
|
6
|
-
try {
|
|
7
|
-
const stats = await fs.stat(lockDirPath);
|
|
8
|
-
// I believe this check associates the lock with the aquirer
|
|
9
|
-
if (stats.mtimeMs === lockTime) {
|
|
10
|
-
// NOTE: since we have to use a timeout for stale detection (uTimes is not exposed via mermoryfs) the check for the locktime is not sufficient and can fail in rare cases when another process accuires a lock that was identifiert as tale between call to fs.state and rmDir
|
|
11
|
-
await fs.rmdir(lockDirPath);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
catch (statError) {
|
|
15
|
-
debug(lockOrigin + " couldn't release the lock");
|
|
16
|
-
if (statError.code === "ENOENT") {
|
|
17
|
-
// ok seeks like the log was released by someone else
|
|
18
|
-
debug(lockOrigin + " WARNING - the lock was released by a different process");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
debug(statError);
|
|
22
|
-
throw statError;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import type { MessageBundle } from "../v2/types.js";
|
|
2
|
-
import { type NodeishFilesystem } from "@lix-js/fs";
|
|
3
|
-
import type { StoreApi } from "./storeApi.js";
|
|
4
|
-
export declare function openStore(args: {
|
|
5
|
-
projectPath: string;
|
|
6
|
-
nodeishFs: NodeishFilesystem;
|
|
7
|
-
locales: string[];
|
|
8
|
-
}): Promise<StoreApi>;
|
|
9
|
-
export declare function readJSON(args: {
|
|
10
|
-
filePath: string;
|
|
11
|
-
nodeishFs: NodeishFilesystem;
|
|
12
|
-
}): Promise<{
|
|
13
|
-
id: string;
|
|
14
|
-
alias: Record<string, string>;
|
|
15
|
-
messages: {
|
|
16
|
-
selectors: {
|
|
17
|
-
annotation?: {
|
|
18
|
-
type: "function";
|
|
19
|
-
name: string;
|
|
20
|
-
options: {
|
|
21
|
-
name: string;
|
|
22
|
-
value: {
|
|
23
|
-
type: "literal";
|
|
24
|
-
value: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: "variable";
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
}[];
|
|
30
|
-
} | undefined;
|
|
31
|
-
type: "expression";
|
|
32
|
-
arg: {
|
|
33
|
-
type: "literal";
|
|
34
|
-
value: string;
|
|
35
|
-
} | {
|
|
36
|
-
type: "variable";
|
|
37
|
-
name: string;
|
|
38
|
-
};
|
|
39
|
-
}[];
|
|
40
|
-
variants: {
|
|
41
|
-
match: string[];
|
|
42
|
-
pattern: ({
|
|
43
|
-
type: "text";
|
|
44
|
-
value: string;
|
|
45
|
-
} | {
|
|
46
|
-
annotation?: {
|
|
47
|
-
type: "function";
|
|
48
|
-
name: string;
|
|
49
|
-
options: {
|
|
50
|
-
name: string;
|
|
51
|
-
value: {
|
|
52
|
-
type: "literal";
|
|
53
|
-
value: string;
|
|
54
|
-
} | {
|
|
55
|
-
type: "variable";
|
|
56
|
-
name: string;
|
|
57
|
-
};
|
|
58
|
-
}[];
|
|
59
|
-
} | undefined;
|
|
60
|
-
type: "expression";
|
|
61
|
-
arg: {
|
|
62
|
-
type: "literal";
|
|
63
|
-
value: string;
|
|
64
|
-
} | {
|
|
65
|
-
type: "variable";
|
|
66
|
-
name: string;
|
|
67
|
-
};
|
|
68
|
-
})[];
|
|
69
|
-
}[];
|
|
70
|
-
locale: string;
|
|
71
|
-
declarations: {
|
|
72
|
-
type: "input";
|
|
73
|
-
name: string;
|
|
74
|
-
value: {
|
|
75
|
-
annotation?: {
|
|
76
|
-
type: "function";
|
|
77
|
-
name: string;
|
|
78
|
-
options: {
|
|
79
|
-
name: string;
|
|
80
|
-
value: {
|
|
81
|
-
type: "literal";
|
|
82
|
-
value: string;
|
|
83
|
-
} | {
|
|
84
|
-
type: "variable";
|
|
85
|
-
name: string;
|
|
86
|
-
};
|
|
87
|
-
}[];
|
|
88
|
-
} | undefined;
|
|
89
|
-
type: "expression";
|
|
90
|
-
arg: {
|
|
91
|
-
type: "literal";
|
|
92
|
-
value: string;
|
|
93
|
-
} | {
|
|
94
|
-
type: "variable";
|
|
95
|
-
name: string;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
}[];
|
|
99
|
-
}[];
|
|
100
|
-
}[]>;
|
|
101
|
-
export declare function writeJSON(args: {
|
|
102
|
-
filePath: string;
|
|
103
|
-
nodeishFs: NodeishFilesystem;
|
|
104
|
-
messages: MessageBundle[];
|
|
105
|
-
locales: string[];
|
|
106
|
-
}): Promise<void>;
|
|
107
|
-
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/persistence/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAI/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAK7C,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA0DpB;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KActF;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,iBAAiB,CAAA;IAC5B,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,OAAO,EAAE,MAAM,EAAE,CAAA;CACjB,iBAYA"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { addSlots, removeSlots, injectJSONNewlines } from "../v2/helper.js";
|
|
2
|
-
import { getDirname } from "@lix-js/fs";
|
|
3
|
-
import { acquireFileLock } from "./filelock/acquireFileLock.js";
|
|
4
|
-
import { releaseLock } from "./filelock/releaseLock.js";
|
|
5
|
-
import { batchedIO } from "./batchedIO.js";
|
|
6
|
-
import _debug from "debug";
|
|
7
|
-
const debug = _debug("sdk:store");
|
|
8
|
-
export async function openStore(args) {
|
|
9
|
-
const nodeishFs = args.nodeishFs;
|
|
10
|
-
const filePath = args.projectPath + "/messages.json";
|
|
11
|
-
const lockDirPath = args.projectPath + "/messagelock";
|
|
12
|
-
// the index holds the in-memory state
|
|
13
|
-
// TODO: reload when file changes on disk
|
|
14
|
-
// https://github.com/opral/inlang-message-sdk/issues/80
|
|
15
|
-
let index = await load();
|
|
16
|
-
const batchedSave = batchedIO(acquireSaveLock, releaseSaveLock, save);
|
|
17
|
-
return {
|
|
18
|
-
messageBundles: {
|
|
19
|
-
reload: async () => {
|
|
20
|
-
index.clear();
|
|
21
|
-
index = await load();
|
|
22
|
-
},
|
|
23
|
-
get: async (args) => {
|
|
24
|
-
return index.get(args.id);
|
|
25
|
-
},
|
|
26
|
-
set: async (args) => {
|
|
27
|
-
index.set(args.data.id, args.data);
|
|
28
|
-
await batchedSave(args.data.id);
|
|
29
|
-
},
|
|
30
|
-
delete: async (args) => {
|
|
31
|
-
index.delete(args.id);
|
|
32
|
-
await batchedSave(args.id);
|
|
33
|
-
},
|
|
34
|
-
getAll: async () => {
|
|
35
|
-
return [...index.values()];
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
// load and save messages from file system atomically
|
|
40
|
-
// using a lock file to prevent partial reads and writes
|
|
41
|
-
async function load() {
|
|
42
|
-
const lockTime = await acquireFileLock(nodeishFs, lockDirPath, "load");
|
|
43
|
-
const messages = await readJSON({ filePath, nodeishFs: nodeishFs });
|
|
44
|
-
const index = new Map(messages.map((message) => [message.id, message]));
|
|
45
|
-
await releaseLock(nodeishFs, lockDirPath, "load", lockTime);
|
|
46
|
-
return index;
|
|
47
|
-
}
|
|
48
|
-
async function acquireSaveLock() {
|
|
49
|
-
return await acquireFileLock(nodeishFs, lockDirPath, "save");
|
|
50
|
-
}
|
|
51
|
-
async function releaseSaveLock(lock) {
|
|
52
|
-
return await releaseLock(nodeishFs, lockDirPath, "save", lock);
|
|
53
|
-
}
|
|
54
|
-
async function save() {
|
|
55
|
-
await writeJSON({
|
|
56
|
-
filePath,
|
|
57
|
-
nodeishFs: nodeishFs,
|
|
58
|
-
messages: [...index.values()],
|
|
59
|
-
locales: args.locales,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
export async function readJSON(args) {
|
|
64
|
-
let result = [];
|
|
65
|
-
debug("loadAll", args.filePath);
|
|
66
|
-
try {
|
|
67
|
-
const file = await args.nodeishFs.readFile(args.filePath, { encoding: "utf-8" });
|
|
68
|
-
result = JSON.parse(file);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (error?.code !== "ENOENT") {
|
|
72
|
-
debug("loadMessages", error);
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return result.map(removeSlots);
|
|
77
|
-
}
|
|
78
|
-
export async function writeJSON(args) {
|
|
79
|
-
debug("saveall", args.filePath);
|
|
80
|
-
try {
|
|
81
|
-
await createDirectoryIfNotExits(getDirname(args.filePath), args.nodeishFs);
|
|
82
|
-
const output = injectJSONNewlines(JSON.stringify(args.messages.map((bundle) => addSlots(bundle, args.locales))));
|
|
83
|
-
await args.nodeishFs.writeFile(args.filePath, output);
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
debug("saveMessages", error);
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async function createDirectoryIfNotExits(path, nodeishFs) {
|
|
91
|
-
try {
|
|
92
|
-
await nodeishFs.mkdir(path, { recursive: true });
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
if (error.code !== "EEXIST") {
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.test.d.ts","sourceRoot":"","sources":["../../src/persistence/store.test.ts"],"names":[],"mappings":""}
|