@inlang/sdk 0.36.3 → 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,77 @@
|
|
|
1
|
+
import { loadProjectInMemory } from "./loadProjectInMemory.js";
|
|
2
|
+
import { type Lix } from "@lix-js/sdk";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import type { InlangPlugin, NodeFsPromisesSubsetLegacy } from "../plugin/schema.js";
|
|
5
|
+
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
6
|
+
/**
|
|
7
|
+
* Loads a project from a directory.
|
|
8
|
+
*
|
|
9
|
+
* Main use case are dev tools that want to load a project from a directory
|
|
10
|
+
* that is stored in git.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadProjectFromDirectory(args: {
|
|
13
|
+
path: string;
|
|
14
|
+
fs: typeof fs;
|
|
15
|
+
syncInterval?: number;
|
|
16
|
+
} & Omit<Parameters<typeof loadProjectInMemory>[0], "blob">): Promise<{
|
|
17
|
+
errors: {
|
|
18
|
+
get: () => Promise<Error[]>;
|
|
19
|
+
};
|
|
20
|
+
db: import("kysely").Kysely<import("../index.js").InlangDatabaseSchema>;
|
|
21
|
+
_sqlite: import("sqlite-wasm-kysely").SqliteDatabase;
|
|
22
|
+
id: {
|
|
23
|
+
get: () => Promise<string>;
|
|
24
|
+
};
|
|
25
|
+
plugins: {
|
|
26
|
+
get: () => Promise<readonly InlangPlugin[]>;
|
|
27
|
+
};
|
|
28
|
+
settings: {
|
|
29
|
+
get: () => Promise<ProjectSettings>;
|
|
30
|
+
set: (settings: ProjectSettings) => Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
lix: Lix;
|
|
33
|
+
importFiles: (args: {
|
|
34
|
+
pluginKey: InlangPlugin["key"];
|
|
35
|
+
files: import("./api.js").ImportFile[];
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
exportFiles: (args: {
|
|
38
|
+
pluginKey: InlangPlugin["key"];
|
|
39
|
+
}) => Promise<import("./api.js").ExportFile[]>;
|
|
40
|
+
close: () => Promise<void>;
|
|
41
|
+
toBlob: () => Promise<Blob>;
|
|
42
|
+
}>;
|
|
43
|
+
export declare class WarningDeprecatedLintRule extends Error {
|
|
44
|
+
constructor(module: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolving absolute paths for fs functions.
|
|
48
|
+
*
|
|
49
|
+
* This mapping is required for backwards compatibility.
|
|
50
|
+
* Relative paths in the project.inlang/settings.json
|
|
51
|
+
* file are resolved to absolute paths with `*.inlang`
|
|
52
|
+
* being pruned.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* "/website/project.inlang"
|
|
56
|
+
* "./local-plugins/mock-plugin.js"
|
|
57
|
+
* -> "/website/local-plugins/mock-plugin.js"
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
60
|
+
export declare function withAbsolutePaths(fs: NodeFsPromisesSubsetLegacy, projectPath: string): NodeFsPromisesSubsetLegacy;
|
|
61
|
+
/**
|
|
62
|
+
* Joins a path from a project path.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* joinPathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js"
|
|
66
|
+
*
|
|
67
|
+
* joinPathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js"
|
|
68
|
+
*/
|
|
69
|
+
export declare function absolutePathFromProject(projectPath: string, path: string): string;
|
|
70
|
+
export declare class ResourceFileImportError extends Error {
|
|
71
|
+
path: string;
|
|
72
|
+
constructor(args: {
|
|
73
|
+
cause: Error;
|
|
74
|
+
path: string;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=loadProjectFromDirectory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadProjectFromDirectory.d.ts","sourceRoot":"/","sources":["project/loadProjectFromDirectory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,SAAS,CAAC;AAGzB,OAAO,KAAK,EACX,YAAY,EACZ,0BAA0B,EAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAClE,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,EACzC,MAAM,CACN;;;;;;;;;;;;;;;;;;;;;;;;;;GAuJD;AAmfD,qBAAa,yBAA0B,SAAQ,KAAK;gBACvC,MAAM,EAAE,MAAM;CAM1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,0BAA0B,EAC9B,WAAW,EAAE,MAAM,GACjB,0BAA0B,CAgB5B;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAWxE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;CAMhD"}
|
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a707cbbf-d9cd-5dca-9279-55823fc96f37")}catch(e){}}();
|
|
3
|
+
import { newProject } from "./newProject.js";
|
|
4
|
+
import { loadProjectInMemory } from "./loadProjectInMemory.js";
|
|
5
|
+
import {} from "@lix-js/sdk";
|
|
6
|
+
import fs from "node:fs";
|
|
7
|
+
import nodePath from "node:path";
|
|
8
|
+
import { fromMessageV1 } from "../json-schema/old-v1-message/fromMessageV1.js";
|
|
9
|
+
import { PluginImportError } from "../plugin/errors.js";
|
|
10
|
+
import { upsertBundleNestedMatchByProperties } from "../import-export/upsertBundleNestedMatchByProperties.js";
|
|
11
|
+
/**
|
|
12
|
+
* Loads a project from a directory.
|
|
13
|
+
*
|
|
14
|
+
* Main use case are dev tools that want to load a project from a directory
|
|
15
|
+
* that is stored in git.
|
|
16
|
+
*/
|
|
17
|
+
export async function loadProjectFromDirectory(args) {
|
|
18
|
+
const settingsPath = nodePath.join(args.path, "settings.json");
|
|
19
|
+
const settings = JSON.parse(await args.fs.promises.readFile(settingsPath, "utf8"));
|
|
20
|
+
const localImport = await importLocalPlugins({
|
|
21
|
+
fs: args.fs,
|
|
22
|
+
settings,
|
|
23
|
+
path: args.path,
|
|
24
|
+
});
|
|
25
|
+
const providePluginsWithLocalPlugins = [
|
|
26
|
+
...(args.providePlugins ?? []),
|
|
27
|
+
...localImport.locallyImportedPlugins,
|
|
28
|
+
];
|
|
29
|
+
// TODO call tempProject.lix.settled() to wait for the new settings file, and remove reload of the proejct as soon as reactive settings has landed
|
|
30
|
+
// NOTE: we need to ensure two things:
|
|
31
|
+
// 1. settled needs to include the changes from the copyFiles call
|
|
32
|
+
// 2. the changes created from the copyFiles call need to be realized and lead to a signal on the settings
|
|
33
|
+
const project = await loadProjectInMemory({
|
|
34
|
+
...args,
|
|
35
|
+
providePlugins: providePluginsWithLocalPlugins,
|
|
36
|
+
blob: await newProject({
|
|
37
|
+
settings,
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
await syncLixFsFiles({
|
|
41
|
+
fs: args.fs,
|
|
42
|
+
path: args.path,
|
|
43
|
+
lix: project.lix,
|
|
44
|
+
syncInterval: args.syncInterval,
|
|
45
|
+
});
|
|
46
|
+
const { loadMessagesPlugins, saveMessagesPlugins, importPlugins, exportPlugins, } = categorizePlugins(await project.plugins.get());
|
|
47
|
+
// TODO i guess we should move this validation logic into sdk2/src/project/loadProject.ts
|
|
48
|
+
// Two scenarios could arise:
|
|
49
|
+
// 1. set settings is called from an app - it should detect and reject the setting of settings -> app need to be able to validate before calling set
|
|
50
|
+
// 2. the settings file loaded from disc here is corrupted -> user has to fix the file on disc
|
|
51
|
+
if (loadMessagesPlugins.length > 1 || saveMessagesPlugins.length > 1) {
|
|
52
|
+
throw new Error("Max one loadMessages (found: " +
|
|
53
|
+
loadMessagesPlugins.length +
|
|
54
|
+
") and one saveMessages plugins (found: " +
|
|
55
|
+
saveMessagesPlugins.length +
|
|
56
|
+
") are allowed ");
|
|
57
|
+
}
|
|
58
|
+
const importedResourceFileErrors = [];
|
|
59
|
+
if ((loadMessagesPlugins.length > 0 || saveMessagesPlugins.length > 0) &&
|
|
60
|
+
(exportPlugins.length > 0 || importPlugins.length > 0)) {
|
|
61
|
+
throw new Error("Plugins for loadMessages (found: " +
|
|
62
|
+
loadMessagesPlugins.length +
|
|
63
|
+
") and saveMessages plugins (found: " +
|
|
64
|
+
saveMessagesPlugins.length +
|
|
65
|
+
") must not coexist with import (found: " +
|
|
66
|
+
importPlugins.length +
|
|
67
|
+
") or export (found: " +
|
|
68
|
+
exportPlugins.length +
|
|
69
|
+
") ");
|
|
70
|
+
}
|
|
71
|
+
else if (loadMessagesPlugins.length > 1 || saveMessagesPlugins.length > 1) {
|
|
72
|
+
throw new Error("Max one loadMessages (found: " +
|
|
73
|
+
loadMessagesPlugins.length +
|
|
74
|
+
") and one saveMessages plugins (found: " +
|
|
75
|
+
saveMessagesPlugins.length +
|
|
76
|
+
") are allowed ");
|
|
77
|
+
}
|
|
78
|
+
else if (importPlugins[0]) {
|
|
79
|
+
const importer = importPlugins[0];
|
|
80
|
+
const files = [];
|
|
81
|
+
if (importer.toBeImportedFiles) {
|
|
82
|
+
const toBeImportedFiles = await importer.toBeImportedFiles({
|
|
83
|
+
settings: await project.settings.get(),
|
|
84
|
+
});
|
|
85
|
+
for (const toBeImported of toBeImportedFiles) {
|
|
86
|
+
const absolute = absolutePathFromProject(args.path, toBeImported.path);
|
|
87
|
+
try {
|
|
88
|
+
const data = await args.fs.promises.readFile(absolute);
|
|
89
|
+
const name = nodePath.basename(toBeImported.path);
|
|
90
|
+
files.push({
|
|
91
|
+
name,
|
|
92
|
+
locale: toBeImported.locale,
|
|
93
|
+
content: data,
|
|
94
|
+
pluginKey: importer.key,
|
|
95
|
+
toBeImportedFilesMetadata: toBeImported.metadata,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
// https://github.com/opral/inlang-sdk/issues/202
|
|
100
|
+
if (e?.code === "ENOENT") {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
importedResourceFileErrors.push(new ResourceFileImportError({
|
|
104
|
+
cause: e,
|
|
105
|
+
path: toBeImported.path,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
await project.importFiles({
|
|
111
|
+
pluginKey: importer.key,
|
|
112
|
+
files: files,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else if (loadMessagesPlugins[0] !== undefined) {
|
|
116
|
+
// TODO create resource files from loadMessageFn call - to poll?
|
|
117
|
+
await loadLegacyMessages({
|
|
118
|
+
project,
|
|
119
|
+
projectPath: args.path,
|
|
120
|
+
fs: args.fs,
|
|
121
|
+
pluginKey: loadMessagesPlugins[0].key ?? loadMessagesPlugins[0].id,
|
|
122
|
+
loadMessagesFn: loadMessagesPlugins[0].loadMessages,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
...project,
|
|
127
|
+
errors: {
|
|
128
|
+
get: async () => {
|
|
129
|
+
return [...localImport.errors, ...importedResourceFileErrors];
|
|
130
|
+
},
|
|
131
|
+
// subscribe: (
|
|
132
|
+
// callback: Parameters<InlangProject["errors"]["subscribe"]>[0]
|
|
133
|
+
// ) => {
|
|
134
|
+
// return project.errors.subscribe((value) => {
|
|
135
|
+
// callback([
|
|
136
|
+
// ...withLocallyImportedPluginWarning(value),
|
|
137
|
+
// ...localImport.errors,
|
|
138
|
+
// ...importedResourceFileErrors,
|
|
139
|
+
// ]);
|
|
140
|
+
// });
|
|
141
|
+
// },
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function loadLegacyMessages(args) {
|
|
146
|
+
const loadedLegacyMessages = await args.loadMessagesFn({
|
|
147
|
+
settings: await args.project.settings.get(),
|
|
148
|
+
// @ts-expect-error - type mismatch
|
|
149
|
+
nodeishFs: withAbsolutePaths(args.fs.promises, args.projectPath),
|
|
150
|
+
});
|
|
151
|
+
const upsertQueries = [];
|
|
152
|
+
for (const legacyMessage of loadedLegacyMessages) {
|
|
153
|
+
const messageBundle = fromMessageV1(legacyMessage);
|
|
154
|
+
upsertQueries.push(upsertBundleNestedMatchByProperties(args.project.db, messageBundle));
|
|
155
|
+
}
|
|
156
|
+
return await Promise.all(upsertQueries);
|
|
157
|
+
}
|
|
158
|
+
function arrayBuffersEqual(a, b) {
|
|
159
|
+
if (a.byteLength !== b.byteLength)
|
|
160
|
+
return false;
|
|
161
|
+
// Create views for byte-by-byte comparison
|
|
162
|
+
const view1 = new Uint8Array(a);
|
|
163
|
+
const view2 = new Uint8Array(b);
|
|
164
|
+
// Compare each byte
|
|
165
|
+
for (const [i, element] of view1.entries()) {
|
|
166
|
+
if (element !== view2[i]) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Watches a directory and copies files into lix, keeping them in sync.
|
|
174
|
+
*/
|
|
175
|
+
async function syncLixFsFiles(args) {
|
|
176
|
+
// NOTE this function is async - while it runs 100% sync in the naiv implementation - we may want to change to an async version to optimize
|
|
177
|
+
async function checkFsStateRecursive(dirPath, currentState) {
|
|
178
|
+
const entries = args.fs.readdirSync(dirPath, { withFileTypes: true });
|
|
179
|
+
for (const entry of entries) {
|
|
180
|
+
const fullPath = nodePath.join(dirPath, entry.name);
|
|
181
|
+
if (entry.isDirectory()) {
|
|
182
|
+
checkFsStateRecursive(fullPath, currentState);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// NOTE we could start with comparing the mdate and skip file read completely...
|
|
186
|
+
const data = args.fs.readFileSync(fullPath);
|
|
187
|
+
const relativePath = "/" + nodePath.relative(args.path, fullPath);
|
|
188
|
+
if (!currentState[relativePath]) {
|
|
189
|
+
currentState[relativePath] = {
|
|
190
|
+
content: data,
|
|
191
|
+
state: "unknown",
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (arrayBuffersEqual(currentState[relativePath].content, data)) {
|
|
196
|
+
currentState[relativePath].state = "known";
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
currentState[relativePath].state = "updated";
|
|
200
|
+
currentState[relativePath].content = data;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function checkLixState(currentLixState) {
|
|
207
|
+
// go through all files in lix and check there state
|
|
208
|
+
const filesInLix = await args.lix.db
|
|
209
|
+
.selectFrom("file")
|
|
210
|
+
.where("path", "not like", "%db.sqlite")
|
|
211
|
+
.selectAll()
|
|
212
|
+
.execute();
|
|
213
|
+
for (const fileInLix of filesInLix) {
|
|
214
|
+
const currentStateOfFileInLix = currentLixState[fileInLix.path];
|
|
215
|
+
// NOTE we could start with comparing the mdate and skip file read completely...
|
|
216
|
+
if (!currentStateOfFileInLix) {
|
|
217
|
+
currentLixState[fileInLix.path] = {
|
|
218
|
+
content: new Uint8Array(fileInLix.data).buffer,
|
|
219
|
+
state: "unknown",
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (arrayBuffersEqual(currentStateOfFileInLix.content, fileInLix.data.buffer)) {
|
|
224
|
+
currentStateOfFileInLix.state = "known";
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
currentStateOfFileInLix.state = "updated";
|
|
228
|
+
currentStateOfFileInLix.content = fileInLix.data
|
|
229
|
+
.buffer;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async function syncUpFsAndLixFiles(statesToSync) {
|
|
235
|
+
// for (const file of Object.keys(statesToSync.fsFileStates)) {
|
|
236
|
+
// if (file.includes("gitignore"))
|
|
237
|
+
// console.log(
|
|
238
|
+
// "fsFileStates : " +
|
|
239
|
+
// file +
|
|
240
|
+
// " fs " +
|
|
241
|
+
// statesToSync.fsFileStates[file]?.state +
|
|
242
|
+
// " lix " +
|
|
243
|
+
// statesToSync.lixFileStates[file]?.state
|
|
244
|
+
// );
|
|
245
|
+
// }
|
|
246
|
+
// Sync cases:
|
|
247
|
+
// fs - no state for file | fs - unkonwn | fs - known | fs - updated | fs - gone
|
|
248
|
+
// lix - no state for file NOTHING (1) | ADD TO LIX(2) | ERROR (3) | ERROR (4) | ERROR (5)
|
|
249
|
+
// lix - unknown ADD TO FS (6) | USE FS VER.(7) | ERROR (8) | CASE (9) | CASE (10)
|
|
250
|
+
// lix - known ERROR (11) | ERROR (12) | NOTHING(13) | ERROR (14) | ERROR (15)
|
|
251
|
+
// lix - updated ERROR (16) | ERROR (17) | USE LIX (18) | CASE (19) | CASE (20)
|
|
252
|
+
// lix - gone ERROR (21) | ERROR (22) | DELETE FS (23)| CASE (24) | CASE (25)
|
|
253
|
+
// TODO check export import from saveFileToDirectory
|
|
254
|
+
for (const [path, fsState] of Object.entries(statesToSync.fsFileStates)) {
|
|
255
|
+
// no state for file in LIX
|
|
256
|
+
if (!statesToSync.lixFileStates[path]) {
|
|
257
|
+
if (fsState.state === "unknown") {
|
|
258
|
+
// ADD TO LIX(2)
|
|
259
|
+
await upsertFileInLix(args, path, fsState.content);
|
|
260
|
+
statesToSync.lixFileStates[path] = {
|
|
261
|
+
state: "known",
|
|
262
|
+
content: fsState.content,
|
|
263
|
+
};
|
|
264
|
+
fsState.state = "known";
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
// ERROR (3), ERROR (4), ERROR (5)
|
|
268
|
+
// The file does not exist in lix but its state differs from unknown?
|
|
269
|
+
throw new Error("Illeagal lix<->fs sync state. The file [" +
|
|
270
|
+
path +
|
|
271
|
+
"] that was " +
|
|
272
|
+
fsState.state +
|
|
273
|
+
" on disc did not exit in lix");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
const lixState = statesToSync.lixFileStates[path];
|
|
278
|
+
if (fsState.state === "unknown") {
|
|
279
|
+
if (lixState.state === "unknown") {
|
|
280
|
+
if (arrayBuffersEqual(lixState.content, fsState.content)) {
|
|
281
|
+
lixState.state = "known";
|
|
282
|
+
fsState.state = "known";
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
await upsertFileInLix(args, path, fsState.content);
|
|
286
|
+
lixState.content = fsState.content;
|
|
287
|
+
lixState.state = "known";
|
|
288
|
+
fsState.state = "known";
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
// ERROR 12, 17, 22
|
|
293
|
+
throw new Error("Illeagal lix<->fs sync state. The file [" +
|
|
294
|
+
path +
|
|
295
|
+
"] that was " +
|
|
296
|
+
fsState.state +
|
|
297
|
+
" but did exist in lix already");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (fsState.state === "known") {
|
|
301
|
+
if (lixState.state === "known") {
|
|
302
|
+
// NO OP - NOTHING(13)
|
|
303
|
+
}
|
|
304
|
+
else if (lixState.state === "updated") {
|
|
305
|
+
// USE LIX (18)
|
|
306
|
+
args.fs.writeFileSync(
|
|
307
|
+
// TODO check platform dependent folder separator
|
|
308
|
+
args.path + path, Buffer.from(lixState.content));
|
|
309
|
+
fsState.content = lixState.content;
|
|
310
|
+
fsState.state = "known";
|
|
311
|
+
lixState.state = "known";
|
|
312
|
+
}
|
|
313
|
+
else if (lixState.state === "gone") {
|
|
314
|
+
// DELETE FS (23)
|
|
315
|
+
args.fs.unlinkSync(args.path + path);
|
|
316
|
+
fsState.state = "gone";
|
|
317
|
+
lixState.state = "gone";
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
else if (fsState.state === "updated") {
|
|
321
|
+
if (lixState.state === "unknown") {
|
|
322
|
+
// TODO A file was added to lix while a known file from fs was updated?
|
|
323
|
+
throw new Error("Illeagal lix<->fs sync state. The file [" +
|
|
324
|
+
path +
|
|
325
|
+
"] that was " +
|
|
326
|
+
fsState.state +
|
|
327
|
+
" but it was not known by lix yet?");
|
|
328
|
+
}
|
|
329
|
+
else if (lixState.state === "known") {
|
|
330
|
+
await upsertFileInLix(args, path, fsState.content);
|
|
331
|
+
lixState.content = fsState.content;
|
|
332
|
+
fsState.state = "known";
|
|
333
|
+
}
|
|
334
|
+
else if (lixState.state === "updated") {
|
|
335
|
+
// seems like we saw an update on the file in fs while some changes on lix have not been reached fs? FS -> Winns?
|
|
336
|
+
console.warn("seems like we saw an update on the file " +
|
|
337
|
+
path +
|
|
338
|
+
" in fs while some changes on lix have not been reached fs? FS -> Winns?");
|
|
339
|
+
await upsertFileInLix(args, path, fsState.content);
|
|
340
|
+
lixState.content = fsState.content;
|
|
341
|
+
lixState.state = "known";
|
|
342
|
+
fsState.state = "known";
|
|
343
|
+
}
|
|
344
|
+
else if (lixState.state === "gone") {
|
|
345
|
+
console.warn("seems like we saw an delete in lix while some changes on fs have not been reached fs? FS -> Winns?");
|
|
346
|
+
// TODO update the lix state
|
|
347
|
+
lixState.content = fsState.content;
|
|
348
|
+
lixState.state = "known";
|
|
349
|
+
fsState.state = "known";
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (fsState.state === "gone") {
|
|
353
|
+
if (lixState.state === "unknown") {
|
|
354
|
+
// TODO A file was added to lix while a known file from fs was removed?
|
|
355
|
+
throw new Error("Illeagal lix<->fs sync state. The file [" +
|
|
356
|
+
path +
|
|
357
|
+
"] that was " +
|
|
358
|
+
fsState.state +
|
|
359
|
+
" but it was not known by lix yet?");
|
|
360
|
+
}
|
|
361
|
+
else if (lixState.state === "known") {
|
|
362
|
+
// file is in known state with lix - means we have only changes on the fs - easy
|
|
363
|
+
await args.lix.db
|
|
364
|
+
.deleteFrom("file")
|
|
365
|
+
.where("path", "=", path)
|
|
366
|
+
.execute();
|
|
367
|
+
// NOTE: states where both are gone will get removed in the lix state loop
|
|
368
|
+
lixState.state = "gone";
|
|
369
|
+
}
|
|
370
|
+
else if (lixState.state === "updated") {
|
|
371
|
+
// seems like we saw an update on the file in fs while some changes on lix have not been reached fs? FS -> Winns?
|
|
372
|
+
console.warn("seems like we saw an update on the file in fs while some changes on lix have not been reached fs? FS -> Winns?");
|
|
373
|
+
await args.lix.db
|
|
374
|
+
.deleteFrom("file")
|
|
375
|
+
.where("path", "=", path)
|
|
376
|
+
.execute();
|
|
377
|
+
// NOTE: states where both are gone will get removed in the lix state loop
|
|
378
|
+
lixState.state = "gone";
|
|
379
|
+
fsState.state = "gone";
|
|
380
|
+
}
|
|
381
|
+
else if (lixState.state === "gone") {
|
|
382
|
+
console.warn("seems like we saw an delete in lix while we have a delete in lix simultaniously?");
|
|
383
|
+
lixState.state = "gone";
|
|
384
|
+
fsState.state = "gone";
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
for (const [path, lixState] of Object.entries(statesToSync.lixFileStates)) {
|
|
390
|
+
// no state for file in fs
|
|
391
|
+
if (!statesToSync.fsFileStates[path]) {
|
|
392
|
+
if (lixState.state == "unknown") {
|
|
393
|
+
// ADD TO FS (6)
|
|
394
|
+
// create directory if not exists
|
|
395
|
+
args.fs.mkdirSync(nodePath.dirname(nodePath.join(args.path, path)), {
|
|
396
|
+
recursive: true,
|
|
397
|
+
});
|
|
398
|
+
// write file
|
|
399
|
+
args.fs.writeFileSync(nodePath.join(args.path, path), Buffer.from(lixState.content));
|
|
400
|
+
statesToSync.fsFileStates[path] = {
|
|
401
|
+
state: "known",
|
|
402
|
+
content: lixState.content,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
// ERROR (11) 16 21
|
|
407
|
+
// The file does not exist on fs but its state differs from unknown?
|
|
408
|
+
throw new Error("Illeagal lix<->fs sync state. The file [" +
|
|
409
|
+
path +
|
|
410
|
+
"] that was in the state" +
|
|
411
|
+
lixState.state +
|
|
412
|
+
" for lix did not exist on disk");
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
if (lixState.state === "gone" &&
|
|
417
|
+
statesToSync.fsFileStates[path].state === "gone") {
|
|
418
|
+
delete statesToSync.lixFileStates[path];
|
|
419
|
+
delete statesToSync.fsFileStates[path];
|
|
420
|
+
}
|
|
421
|
+
else if (lixState.state !== statesToSync.fsFileStates[path].state) {
|
|
422
|
+
throw new Error("At this stage both states should be in sync lix state " +
|
|
423
|
+
lixState.state +
|
|
424
|
+
" fs state " +
|
|
425
|
+
statesToSync.fsFileStates[path].state);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
async function syncFiles(dirPath, fileStates, interval) {
|
|
431
|
+
// mark all states as removed - checkFsStateRecursive will update those that exist on the disc correspondingly
|
|
432
|
+
for (const fsState of Object.values(fileStates.fsFileStates)) {
|
|
433
|
+
fsState.state = "gone";
|
|
434
|
+
}
|
|
435
|
+
// mark all states as removed - checkFsStateRecursive will update those that exist on the disc correspondingly
|
|
436
|
+
for (const lixState of Object.values(fileStates.lixFileStates)) {
|
|
437
|
+
lixState.state = "gone";
|
|
438
|
+
}
|
|
439
|
+
// read states from disc - detect changes
|
|
440
|
+
await checkFsStateRecursive(dirPath, fileStates.fsFileStates);
|
|
441
|
+
// read states form lix - detect changes
|
|
442
|
+
await checkLixState(fileStates.lixFileStates);
|
|
443
|
+
// sync fs<->lix
|
|
444
|
+
await syncUpFsAndLixFiles(fileStates);
|
|
445
|
+
if (interval) {
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
syncFiles(dirPath, fileStates, interval);
|
|
448
|
+
}, interval);
|
|
449
|
+
}
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
// Initial copy of all files
|
|
453
|
+
await syncFiles(args.path, { fsFileStates: {}, lixFileStates: {} }, args.syncInterval);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
async function upsertFileInLix(args, path, data) {
|
|
457
|
+
// file is in known state with lix - means we have only changes on the fs - easy
|
|
458
|
+
// NOTE we use file_internal for now see: https://linear.app/opral/issue/LIXDK-102/re-visit-simplifying-the-change-queue-implementation#comment-65eb3485
|
|
459
|
+
// This means we don't see changes for the file we update via this method!
|
|
460
|
+
await args.lix.db
|
|
461
|
+
.insertInto("file") // change queue
|
|
462
|
+
.values({
|
|
463
|
+
path: path,
|
|
464
|
+
data: new Uint8Array(data),
|
|
465
|
+
})
|
|
466
|
+
.onConflict((oc) => oc.column("path").doUpdateSet({ data: new Uint8Array(data) }))
|
|
467
|
+
.execute();
|
|
468
|
+
}
|
|
469
|
+
// TODO i guess we should move this validation logic into sdk2/src/project/loadProject.ts
|
|
470
|
+
function categorizePlugins(plugins) {
|
|
471
|
+
const loadMessagesPlugins = plugins.filter((plugin) => plugin.loadMessages !== undefined);
|
|
472
|
+
const saveMessagesPlugins = plugins.filter((plugin) => plugin.saveMessages !== undefined);
|
|
473
|
+
const importPlugins = plugins.filter((plugin) => plugin.importFiles !== undefined && plugin.toBeImportedFiles !== undefined);
|
|
474
|
+
const exportPlugins = plugins.filter((plugin) => plugin.exportFiles !== undefined);
|
|
475
|
+
return {
|
|
476
|
+
loadMessagesPlugins,
|
|
477
|
+
saveMessagesPlugins,
|
|
478
|
+
importPlugins,
|
|
479
|
+
exportPlugins,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Imports local plugins for backwards compatibility.
|
|
484
|
+
*
|
|
485
|
+
* https://github.com/opral/inlang-sdk/issues/171
|
|
486
|
+
*/
|
|
487
|
+
async function importLocalPlugins(args) {
|
|
488
|
+
const errors = [];
|
|
489
|
+
const locallyImportedPlugins = [];
|
|
490
|
+
for (const module of args.settings.modules ?? []) {
|
|
491
|
+
if (module.startsWith("http")) {
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
const modulePath = absolutePathFromProject(args.path, module);
|
|
495
|
+
try {
|
|
496
|
+
let moduleAsText = await args.fs.promises.readFile(modulePath, "utf8");
|
|
497
|
+
if (moduleAsText.includes("messageLintRule")) {
|
|
498
|
+
errors.push(new WarningDeprecatedLintRule(module));
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
if (args.preprocessPluginBeforeImport) {
|
|
502
|
+
moduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);
|
|
503
|
+
}
|
|
504
|
+
const moduleWithMimeType = "data:application/javascript," + encodeURIComponent(moduleAsText);
|
|
505
|
+
const { default: plugin } = await import(
|
|
506
|
+
/* @vite-ignore */ moduleWithMimeType);
|
|
507
|
+
locallyImportedPlugins.push(plugin);
|
|
508
|
+
}
|
|
509
|
+
catch (e) {
|
|
510
|
+
errors.push(new PluginImportError({ plugin: module, cause: e }));
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
errors,
|
|
516
|
+
locallyImportedPlugins,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
export class WarningDeprecatedLintRule extends Error {
|
|
520
|
+
constructor(module) {
|
|
521
|
+
super(`The lint rule ${module} is deprecated. Please remove the lint rule from the settings. Lint rules are interim built into apps and will be succeeded by more generilizable lix validation rules.`);
|
|
522
|
+
this.name = "WarningDeprecatedLintRule";
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Resolving absolute paths for fs functions.
|
|
527
|
+
*
|
|
528
|
+
* This mapping is required for backwards compatibility.
|
|
529
|
+
* Relative paths in the project.inlang/settings.json
|
|
530
|
+
* file are resolved to absolute paths with `*.inlang`
|
|
531
|
+
* being pruned.
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* "/website/project.inlang"
|
|
535
|
+
* "./local-plugins/mock-plugin.js"
|
|
536
|
+
* -> "/website/local-plugins/mock-plugin.js"
|
|
537
|
+
*
|
|
538
|
+
*/
|
|
539
|
+
export function withAbsolutePaths(fs, projectPath) {
|
|
540
|
+
return {
|
|
541
|
+
// @ts-expect-error - node type mismatch
|
|
542
|
+
readFile: (path, options) => {
|
|
543
|
+
return fs.readFile(absolutePathFromProject(projectPath, path), options);
|
|
544
|
+
},
|
|
545
|
+
writeFile: (path, data) => {
|
|
546
|
+
return fs.writeFile(absolutePathFromProject(projectPath, path), data);
|
|
547
|
+
},
|
|
548
|
+
mkdir: (path) => {
|
|
549
|
+
return fs.mkdir(absolutePathFromProject(projectPath, path));
|
|
550
|
+
},
|
|
551
|
+
readdir: (path) => {
|
|
552
|
+
return fs.readdir(absolutePathFromProject(projectPath, path));
|
|
553
|
+
},
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Joins a path from a project path.
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* joinPathFromProject("/project.inlang", "./local-plugins/mock-plugin.js") -> "/local-plugins/mock-plugin.js"
|
|
561
|
+
*
|
|
562
|
+
* joinPathFromProject("/website/project.inlang", "./mock-plugin.js") -> "/website/mock-plugin.js"
|
|
563
|
+
*/
|
|
564
|
+
export function absolutePathFromProject(projectPath, path) {
|
|
565
|
+
// need to remove the project path from the module path for legacy reasons
|
|
566
|
+
// "/project.inlang/local-plugins/mock-plugin.js" -> "/local-plugins/mock-plugin.js"
|
|
567
|
+
const pathWithoutProject = projectPath
|
|
568
|
+
.split(nodePath.sep)
|
|
569
|
+
.slice(0, -1)
|
|
570
|
+
.join(nodePath.sep);
|
|
571
|
+
const resolvedPath = nodePath.resolve(pathWithoutProject, path);
|
|
572
|
+
return resolvedPath;
|
|
573
|
+
}
|
|
574
|
+
export class ResourceFileImportError extends Error {
|
|
575
|
+
path;
|
|
576
|
+
constructor(args) {
|
|
577
|
+
super("Could not import a resource file");
|
|
578
|
+
this.name = "ResourceFileImportError";
|
|
579
|
+
this.cause = args.cause;
|
|
580
|
+
this.path = args.path;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
//# sourceMappingURL=loadProjectFromDirectory.js.map
|
|
584
|
+
//# debugId=a707cbbf-d9cd-5dca-9279-55823fc96f37
|