@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,161 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test, vi } from "vitest";
|
|
2
|
-
import { lintSingleMessage } from "./lintSingleMessage.js";
|
|
3
|
-
import { tryCatch } from "@inlang/result";
|
|
4
|
-
const lintRule1 = {
|
|
5
|
-
id: "messageLintRule.r.1",
|
|
6
|
-
displayName: "",
|
|
7
|
-
description: "",
|
|
8
|
-
run: vi.fn(),
|
|
9
|
-
};
|
|
10
|
-
const lintRule2 = {
|
|
11
|
-
id: "messageLintRule.r.2",
|
|
12
|
-
displayName: "",
|
|
13
|
-
description: "",
|
|
14
|
-
run: vi.fn(),
|
|
15
|
-
};
|
|
16
|
-
const message1 = {};
|
|
17
|
-
const messages = [message1];
|
|
18
|
-
describe("lintSingleMessage", async () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
vi.resetAllMocks();
|
|
21
|
-
});
|
|
22
|
-
describe("resolve rules and settings", async () => {
|
|
23
|
-
// the lint function is un-opinionated and does not set a default level.
|
|
24
|
-
// opinionated users like the inlang instance can very well set a default level (separation of concerns)
|
|
25
|
-
test("it should throw if a lint level is not provided for a given lint rule", async () => {
|
|
26
|
-
lintRule1.run.mockImplementation(({ report }) => report({}));
|
|
27
|
-
const result = await tryCatch(() => lintSingleMessage({
|
|
28
|
-
settings: {
|
|
29
|
-
sourceLanguageTag: "en",
|
|
30
|
-
languageTags: ["en"],
|
|
31
|
-
messageLintRuleLevels: {},
|
|
32
|
-
modules: [],
|
|
33
|
-
},
|
|
34
|
-
messages,
|
|
35
|
-
message: message1,
|
|
36
|
-
rules: [lintRule1],
|
|
37
|
-
}));
|
|
38
|
-
expect(result.error).toBeDefined();
|
|
39
|
-
expect(result.data).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
test("it should override the default lint level", async () => {
|
|
42
|
-
lintRule1.run.mockImplementation(({ report }) => report({}));
|
|
43
|
-
const reports = await lintSingleMessage({
|
|
44
|
-
settings: {
|
|
45
|
-
sourceLanguageTag: "en",
|
|
46
|
-
languageTags: ["en"],
|
|
47
|
-
modules: [],
|
|
48
|
-
messageLintRuleLevels: {
|
|
49
|
-
[lintRule1.id]: "error",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
messages,
|
|
53
|
-
message: message1,
|
|
54
|
-
rules: [lintRule1],
|
|
55
|
-
});
|
|
56
|
-
expect(reports.data[0]?.level).toBe("error");
|
|
57
|
-
});
|
|
58
|
-
test("it should pass the correct settings", async () => {
|
|
59
|
-
const settings = {
|
|
60
|
-
sourceLanguageTag: "en",
|
|
61
|
-
languageTags: ["en"],
|
|
62
|
-
modules: [],
|
|
63
|
-
messageLintRuleLevels: {
|
|
64
|
-
[lintRule1.id]: "warning",
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
const fn = vi.fn();
|
|
68
|
-
lintRule1.run.mockImplementation(({ settings }) => fn(settings));
|
|
69
|
-
await lintSingleMessage({
|
|
70
|
-
settings,
|
|
71
|
-
messages,
|
|
72
|
-
message: message1,
|
|
73
|
-
rules: [lintRule1],
|
|
74
|
-
});
|
|
75
|
-
expect(fn).toHaveBeenCalledWith(settings);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
test("it should await all rules", async () => {
|
|
79
|
-
let m1Called = false;
|
|
80
|
-
let m2Called = false;
|
|
81
|
-
lintRule1.run.mockImplementation(() => {
|
|
82
|
-
m1Called = true;
|
|
83
|
-
});
|
|
84
|
-
lintRule2.run.mockImplementation(async () => {
|
|
85
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
86
|
-
m2Called = true;
|
|
87
|
-
});
|
|
88
|
-
await lintSingleMessage({
|
|
89
|
-
settings: {
|
|
90
|
-
sourceLanguageTag: "en",
|
|
91
|
-
languageTags: ["en"],
|
|
92
|
-
modules: [],
|
|
93
|
-
messageLintRuleLevels: {
|
|
94
|
-
[lintRule1.id]: "warning",
|
|
95
|
-
[lintRule2.id]: "warning",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
messages,
|
|
99
|
-
message: message1,
|
|
100
|
-
rules: [lintRule1, lintRule2],
|
|
101
|
-
});
|
|
102
|
-
expect(m1Called).toBe(true);
|
|
103
|
-
expect(m2Called).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
test("it should process all rules in parallel", async () => {
|
|
106
|
-
const fn = vi.fn();
|
|
107
|
-
lintRule1.run.mockImplementation(async () => {
|
|
108
|
-
fn(lintRule1.id, "before");
|
|
109
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
110
|
-
fn(lintRule1.id, "after");
|
|
111
|
-
});
|
|
112
|
-
lintRule2.run.mockImplementation(async () => {
|
|
113
|
-
fn(lintRule2.id, "before");
|
|
114
|
-
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
115
|
-
fn(lintRule2.id, "after");
|
|
116
|
-
});
|
|
117
|
-
await lintSingleMessage({
|
|
118
|
-
settings: {
|
|
119
|
-
sourceLanguageTag: "en",
|
|
120
|
-
languageTags: ["en"],
|
|
121
|
-
modules: [],
|
|
122
|
-
messageLintRuleLevels: {
|
|
123
|
-
[lintRule1.id]: "warning",
|
|
124
|
-
[lintRule2.id]: "warning",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
messages,
|
|
128
|
-
message: message1,
|
|
129
|
-
rules: [lintRule1, lintRule2],
|
|
130
|
-
});
|
|
131
|
-
expect(fn).toHaveBeenCalledTimes(4);
|
|
132
|
-
expect(fn).toHaveBeenNthCalledWith(1, lintRule1.id, "before");
|
|
133
|
-
expect(fn).toHaveBeenNthCalledWith(2, lintRule2.id, "before");
|
|
134
|
-
expect(fn).toHaveBeenNthCalledWith(3, lintRule1.id, "after");
|
|
135
|
-
expect(fn).toHaveBeenNthCalledWith(4, lintRule2.id, "after");
|
|
136
|
-
});
|
|
137
|
-
test("it should not abort the linting process when errors occur", async () => {
|
|
138
|
-
lintRule1.run.mockImplementation(() => {
|
|
139
|
-
throw new Error("error");
|
|
140
|
-
});
|
|
141
|
-
lintRule2.run.mockImplementation(({ report }) => {
|
|
142
|
-
report({});
|
|
143
|
-
});
|
|
144
|
-
const result = await lintSingleMessage({
|
|
145
|
-
settings: {
|
|
146
|
-
sourceLanguageTag: "en",
|
|
147
|
-
languageTags: ["en"],
|
|
148
|
-
modules: [],
|
|
149
|
-
messageLintRuleLevels: {
|
|
150
|
-
[lintRule1.id]: "warning",
|
|
151
|
-
[lintRule2.id]: "warning",
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
messages,
|
|
155
|
-
message: message1,
|
|
156
|
-
rules: [lintRule1, lintRule2],
|
|
157
|
-
});
|
|
158
|
-
expect(result.data).length(1);
|
|
159
|
-
expect(result.errors).length(1);
|
|
160
|
-
});
|
|
161
|
-
});
|
package/dist/listProjects.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listProjects.d.ts","sourceRoot":"","sources":["../src/listProjects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAInD,eAAO,MAAM,YAAY,cACb,iBAAiB,QACtB,MAAM,KACV,OAAO,CAAC,KAAK,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAwCxC,CAAA"}
|
package/dist/listProjects.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const ignores = ["node_modules", ".git"];
|
|
2
|
-
export const listProjects = async (nodeishFs, from) => {
|
|
3
|
-
// !TODO: Remove this limit once we introduce caching
|
|
4
|
-
const recursionLimit = 5;
|
|
5
|
-
const projects = [];
|
|
6
|
-
async function searchDir(path, depth) {
|
|
7
|
-
if (depth > recursionLimit) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const files = await nodeishFs.readdir(path);
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
const filePath = `${path}/${file}`;
|
|
13
|
-
try {
|
|
14
|
-
const stats = await nodeishFs.stat(filePath);
|
|
15
|
-
if (stats.isDirectory()) {
|
|
16
|
-
if (ignores.includes(file)) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
if (file.endsWith(".inlang")) {
|
|
20
|
-
projects.push({ projectPath: filePath });
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
await searchDir(filePath, depth + 1);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
await searchDir(from, 0);
|
|
33
|
-
// remove double slashes
|
|
34
|
-
for (const project of projects) {
|
|
35
|
-
project.projectPath = project.projectPath.replace(/\/\//g, "/");
|
|
36
|
-
}
|
|
37
|
-
return projects;
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listProjects.test.d.ts","sourceRoot":"","sources":["../src/listProjects.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { assert, describe, it, expect } from "vitest";
|
|
2
|
-
import { listProjects } from "./listProjects.js";
|
|
3
|
-
import { createNodeishMemoryFs } from "@lix-js/fs";
|
|
4
|
-
import { mockRepo } from "@lix-js/client";
|
|
5
|
-
// eslint-disable-next-line no-restricted-imports -- test
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
const settings = {
|
|
8
|
-
sourceLanguageTag: "en",
|
|
9
|
-
languageTags: ["en"],
|
|
10
|
-
modules: ["plugin.js", "lintRule.js"],
|
|
11
|
-
messageLintRuleLevels: {
|
|
12
|
-
"messageLintRule.project.missingTranslation": "error",
|
|
13
|
-
},
|
|
14
|
-
"plugin.project.i18next": {
|
|
15
|
-
pathPattern: "./examples/example01/{languageTag}.json",
|
|
16
|
-
variableReferencePattern: ["{", "}"],
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
describe("listProjects", () => {
|
|
20
|
-
it("should find all projects a given path", async () => {
|
|
21
|
-
const fs = createNodeishMemoryFs();
|
|
22
|
-
await fs.mkdir("/user/dir1/project.inlang", { recursive: true });
|
|
23
|
-
await fs.writeFile("/user/dir1/project.inlang/settings.json", JSON.stringify(settings));
|
|
24
|
-
await fs.mkdir("/user/dir2/project.inlang", { recursive: true });
|
|
25
|
-
await fs.writeFile("/user/dir2/project.inlang/settings.json", JSON.stringify(settings));
|
|
26
|
-
await listProjects(fs, "/user").then((projects) => {
|
|
27
|
-
assert(projects.length === 2);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it("should return objects inside of an array with the projectPath", async () => {
|
|
31
|
-
const fs = createNodeishMemoryFs();
|
|
32
|
-
await fs.mkdir("/user/dir1/project.inlang", { recursive: true });
|
|
33
|
-
await fs.writeFile("/user/dir1/project.inlang/settings.json", JSON.stringify(settings));
|
|
34
|
-
await fs.mkdir("/user/dir2/project.inlang", { recursive: true });
|
|
35
|
-
await fs.writeFile("/user/dir2/project.inlang/settings.json", JSON.stringify(settings));
|
|
36
|
-
await listProjects(fs, "/user").then((projects) => {
|
|
37
|
-
assert.isTrue(typeof projects[0] === "object");
|
|
38
|
-
assert.isTrue(typeof projects[0]?.projectPath === "string");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
it("should limit the recursion depth to 5", async () => {
|
|
42
|
-
const fs = createNodeishMemoryFs();
|
|
43
|
-
await fs.mkdir("/user/dir1/dir2/dir3/dir4/dir5/dir6/project.inlang", { recursive: true });
|
|
44
|
-
await fs.writeFile("/user/dir1/dir2/dir3/dir4/dir5/dir6/project.inlang/settings.json", JSON.stringify(settings));
|
|
45
|
-
await listProjects(fs, "/user").then((projects) => {
|
|
46
|
-
assert(projects.length === 0);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
it("should not crash on broken symlinks as cal.com has", async () => {
|
|
50
|
-
const ciTestRepo = JSON.parse(readFileSync("./mocks/ci-test-repo-no-shallow.json", { encoding: "utf-8" }));
|
|
51
|
-
const repo = await mockRepo({
|
|
52
|
-
fromSnapshot: ciTestRepo,
|
|
53
|
-
repoOptions: { experimentalFeatures: { lixCommit: true, lazyClone: false } },
|
|
54
|
-
});
|
|
55
|
-
repo.checkout({ branch: "test-symlink" });
|
|
56
|
-
const link = await repo.nodeishFs.readlink("test-symlink-not-existing-target");
|
|
57
|
-
expect(link).toBe("/test-symlink-not-existing-target//.././no-exist");
|
|
58
|
-
await listProjects(repo.nodeishFs, "/").then((projects) => {
|
|
59
|
-
assert(projects.length === 1);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
it("should also find files inside of a dir that ends with *.inlang", async () => {
|
|
63
|
-
const fs = createNodeishMemoryFs();
|
|
64
|
-
await fs.mkdir("/user/dir1/go.inlang", { recursive: true });
|
|
65
|
-
await fs.writeFile("/user/dir1/go.inlang/settings.json", JSON.stringify(settings));
|
|
66
|
-
await fs.mkdir("/user/dir2/flutter.inlang", { recursive: true });
|
|
67
|
-
await fs.writeFile("/user/dir2/flutter.inlang/settings.json", JSON.stringify(settings));
|
|
68
|
-
await listProjects(fs, "/user").then((projects) => {
|
|
69
|
-
assert(projects.length === 2);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
package/dist/loadProject.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { InlangProject, Subscribable } from "./api.js";
|
|
2
|
-
import { type ImportFunction } from "./resolve-modules/index.js";
|
|
3
|
-
import type { Repository } from "@lix-js/client";
|
|
4
|
-
/**
|
|
5
|
-
* @param projectPath - Absolute path to the inlang settings file.
|
|
6
|
-
* @param repo - An instance of a lix repo as returned by `openRepository`.
|
|
7
|
-
* @param _import - Use `_import` to pass a custom import function for testing,
|
|
8
|
-
* and supporting legacy resolvedModules such as CJS.
|
|
9
|
-
* @param appId - The app id to use for telemetry e.g "app.inlang.badge"
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export declare function loadProject(args: {
|
|
13
|
-
projectPath: string;
|
|
14
|
-
repo: Repository;
|
|
15
|
-
appId?: string;
|
|
16
|
-
_import?: ImportFunction;
|
|
17
|
-
}): Promise<InlangProject>;
|
|
18
|
-
export declare function createSubscribable<T>(signal: () => T): Subscribable<T>;
|
|
19
|
-
//# sourceMappingURL=loadProject.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadProject.d.ts","sourceRoot":"","sources":["../src/loadProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,aAAa,EAGb,YAAY,EAGZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,4BAA4B,CAAA;AAuBhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAchD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;CACxB,GAAG,OAAO,CAAC,aAAa,CAAC,CAoSzB;AAoGD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAQtE"}
|
package/dist/loadProject.js
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { resolveModules } from "./resolve-modules/index.js";
|
|
2
|
-
import { TypeCompiler, ValueErrorType } from "@sinclair/typebox/compiler";
|
|
3
|
-
import { ProjectSettingsFileJSONSyntaxError, ProjectSettingsFileNotFoundError, ProjectSettingsInvalidError, } from "./errors.js";
|
|
4
|
-
import { createRoot, createSignal, createEffect, batch } from "./reactivity/solid.js";
|
|
5
|
-
import { createMessagesQuery } from "./createMessagesQuery.js";
|
|
6
|
-
import { createMessageLintReportsQuery } from "./createMessageLintReportsQuery.js";
|
|
7
|
-
import { ProjectSettings } from "./versionedInterfaces.js";
|
|
8
|
-
import { tryCatch } from "@inlang/result";
|
|
9
|
-
import { migrateIfOutdated } from "@inlang/project-settings/migration";
|
|
10
|
-
import { createNodeishFsWithAbsolutePaths } from "./createNodeishFsWithAbsolutePaths.js";
|
|
11
|
-
import { createNodeishFsWithWatcher } from "./createNodeishFsWithWatcher.js";
|
|
12
|
-
import { normalizePath } from "@lix-js/fs";
|
|
13
|
-
import { assertValidProjectPath } from "./validateProjectPath.js";
|
|
14
|
-
// Migrations
|
|
15
|
-
import { maybeMigrateToDirectory } from "./migrations/migrateToDirectory.js";
|
|
16
|
-
import { maybeCreateFirstProjectId } from "./migrations/maybeCreateFirstProjectId.js";
|
|
17
|
-
import { maybeAddModuleCache } from "./migrations/maybeAddModuleCache.js";
|
|
18
|
-
import { capture } from "./telemetry/capture.js";
|
|
19
|
-
import { identifyProject } from "./telemetry/groupIdentify.js";
|
|
20
|
-
import { stubMessagesQuery, stubMessageLintReportsQuery } from "./v2/stubQueryApi.js";
|
|
21
|
-
import { openStore } from "./persistence/store.js";
|
|
22
|
-
import _debug from "debug";
|
|
23
|
-
const debug = _debug("sdk:loadProject");
|
|
24
|
-
const settingsCompiler = TypeCompiler.Compile(ProjectSettings);
|
|
25
|
-
/**
|
|
26
|
-
* @param projectPath - Absolute path to the inlang settings file.
|
|
27
|
-
* @param repo - An instance of a lix repo as returned by `openRepository`.
|
|
28
|
-
* @param _import - Use `_import` to pass a custom import function for testing,
|
|
29
|
-
* and supporting legacy resolvedModules such as CJS.
|
|
30
|
-
* @param appId - The app id to use for telemetry e.g "app.inlang.badge"
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
export async function loadProject(args) {
|
|
34
|
-
const projectPath = normalizePath(args.projectPath);
|
|
35
|
-
// -- validation --------------------------------------------------------
|
|
36
|
-
// the only place where throwing is acceptable because the project
|
|
37
|
-
// won't even be loaded. do not throw anywhere else. otherwise, apps
|
|
38
|
-
// can't handle errors gracefully.
|
|
39
|
-
assertValidProjectPath(projectPath);
|
|
40
|
-
debug(projectPath);
|
|
41
|
-
const nodeishFs = createNodeishFsWithAbsolutePaths({
|
|
42
|
-
projectPath,
|
|
43
|
-
nodeishFs: args.repo.nodeishFs,
|
|
44
|
-
});
|
|
45
|
-
// -- migratations ------------------------------------------------
|
|
46
|
-
await maybeMigrateToDirectory({ nodeishFs, projectPath });
|
|
47
|
-
await maybeCreateFirstProjectId({ projectPath, repo: args.repo });
|
|
48
|
-
await maybeAddModuleCache({ projectPath, repo: args.repo });
|
|
49
|
-
// -- load project ------------------------------------------------------
|
|
50
|
-
return await createRoot(async () => {
|
|
51
|
-
// TODO remove tryCatch after https://github.com/opral/monorepo/issues/2013
|
|
52
|
-
// - a repo will always be present
|
|
53
|
-
// - if a repo is present, the project id will always be present
|
|
54
|
-
const { data: projectId } = await tryCatch(() => nodeishFs.readFile(args.projectPath + "/project_id", { encoding: "utf-8" }));
|
|
55
|
-
const [initialized, markInitAsComplete, markInitAsFailed] = createAwaitable();
|
|
56
|
-
const [loadedSettings, markSettingsAsLoaded, markSettingsAsFailed] = createAwaitable();
|
|
57
|
-
const [resolvedModules, setResolvedModules] = createSignal();
|
|
58
|
-
// -- settings ------------------------------------------------------------
|
|
59
|
-
const [settings, _setSettings] = createSignal();
|
|
60
|
-
let v2Persistence = false;
|
|
61
|
-
let locales = [];
|
|
62
|
-
// TODO:
|
|
63
|
-
// if (projectId) {
|
|
64
|
-
// telemetryBrowser.group("project", projectId, {
|
|
65
|
-
// name: projectId,
|
|
66
|
-
// })
|
|
67
|
-
// }
|
|
68
|
-
const setSettings = (newSettings) => {
|
|
69
|
-
try {
|
|
70
|
-
const validatedSettings = parseSettings(newSettings);
|
|
71
|
-
v2Persistence = !!validatedSettings.experimental?.persistence;
|
|
72
|
-
locales = validatedSettings.languageTags;
|
|
73
|
-
batch(() => {
|
|
74
|
-
// reset the resolved modules first - since they are no longer valid at that point
|
|
75
|
-
setResolvedModules(undefined);
|
|
76
|
-
_setSettings(validatedSettings);
|
|
77
|
-
});
|
|
78
|
-
return { data: validatedSettings };
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
if (error instanceof ProjectSettingsInvalidError) {
|
|
82
|
-
return { error };
|
|
83
|
-
}
|
|
84
|
-
throw new Error("Unhandled error in setSettings. This is an internal bug. Please file an issue.", { cause: error });
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const nodeishFsWithWatchersForSettings = createNodeishFsWithWatcher({
|
|
88
|
-
nodeishFs: nodeishFs,
|
|
89
|
-
onChange: async () => {
|
|
90
|
-
const readSettingsResult = await tryCatch(async () => await loadSettings({
|
|
91
|
-
settingsFilePath: projectPath + "/settings.json",
|
|
92
|
-
nodeishFs: nodeishFs,
|
|
93
|
-
}));
|
|
94
|
-
if (readSettingsResult.error)
|
|
95
|
-
return;
|
|
96
|
-
const newSettings = readSettingsResult.data;
|
|
97
|
-
if (JSON.stringify(newSettings) !== JSON.stringify(settings())) {
|
|
98
|
-
setSettings(newSettings);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
const settingsResult = await tryCatch(async () => await loadSettings({
|
|
103
|
-
settingsFilePath: projectPath + "/settings.json",
|
|
104
|
-
nodeishFs: nodeishFsWithWatchersForSettings,
|
|
105
|
-
}));
|
|
106
|
-
if (settingsResult.error) {
|
|
107
|
-
markInitAsFailed(settingsResult.error);
|
|
108
|
-
markSettingsAsFailed(settingsResult.error);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
setSettings(settingsResult.data);
|
|
112
|
-
markSettingsAsLoaded();
|
|
113
|
-
}
|
|
114
|
-
// -- resolvedModules -----------------------------------------------------------
|
|
115
|
-
createEffect(() => {
|
|
116
|
-
const _settings = settings();
|
|
117
|
-
if (!_settings)
|
|
118
|
-
return;
|
|
119
|
-
resolveModules({
|
|
120
|
-
settings: _settings,
|
|
121
|
-
nodeishFs,
|
|
122
|
-
_import: args._import,
|
|
123
|
-
projectPath,
|
|
124
|
-
})
|
|
125
|
-
.then((resolvedModules) => {
|
|
126
|
-
setResolvedModules(resolvedModules);
|
|
127
|
-
})
|
|
128
|
-
.catch((err) => markInitAsFailed(err));
|
|
129
|
-
});
|
|
130
|
-
// -- installed items ----------------------------------------------------
|
|
131
|
-
let settingsValue;
|
|
132
|
-
// workaround to not run effects twice (e.g. settings change + modules change) (I'm sure there exists a solid way of doing this, but I haven't found it yet)
|
|
133
|
-
createEffect(() => (settingsValue = settings()));
|
|
134
|
-
const installedMessageLintRules = () => {
|
|
135
|
-
if (!resolvedModules())
|
|
136
|
-
return [];
|
|
137
|
-
return resolvedModules().messageLintRules.map((rule) => ({
|
|
138
|
-
id: rule.id,
|
|
139
|
-
displayName: rule.displayName,
|
|
140
|
-
description: rule.description,
|
|
141
|
-
module: resolvedModules()?.meta.find((m) => m.id.includes(rule.id))?.module ??
|
|
142
|
-
"Unknown module. You stumbled on a bug in inlang's source code. Please open an issue.",
|
|
143
|
-
// default to warning, see https://github.com/opral/monorepo/issues/1254
|
|
144
|
-
level: settingsValue["messageLintRuleLevels"]?.[rule.id] ?? "warning",
|
|
145
|
-
settingsSchema: rule.settingsSchema,
|
|
146
|
-
}));
|
|
147
|
-
};
|
|
148
|
-
const installedPlugins = () => {
|
|
149
|
-
if (!resolvedModules())
|
|
150
|
-
return [];
|
|
151
|
-
return resolvedModules().plugins.map((plugin) => ({
|
|
152
|
-
id: plugin.id,
|
|
153
|
-
displayName: plugin.displayName,
|
|
154
|
-
description: plugin.description,
|
|
155
|
-
module: resolvedModules()?.meta.find((m) => m.id.includes(plugin.id))?.module ??
|
|
156
|
-
"Unknown module. You stumbled on a bug in inlang's source code. Please open an issue.",
|
|
157
|
-
settingsSchema: plugin.settingsSchema,
|
|
158
|
-
}));
|
|
159
|
-
};
|
|
160
|
-
// -- messages ----------------------------------------------------------
|
|
161
|
-
const [loadMessagesViaPluginError, setLoadMessagesViaPluginError] = createSignal();
|
|
162
|
-
const [saveMessagesViaPluginError, setSaveMessagesViaPluginError] = createSignal();
|
|
163
|
-
let messagesQuery;
|
|
164
|
-
let lintReportsQuery;
|
|
165
|
-
let store;
|
|
166
|
-
// wait for seetings to load v2Persistence flag
|
|
167
|
-
// .catch avoids throwing here if the awaitable is rejected
|
|
168
|
-
// error is recorded via markInitAsFailed so no need to capture it again
|
|
169
|
-
await loadedSettings.catch(() => { });
|
|
170
|
-
if (v2Persistence) {
|
|
171
|
-
messagesQuery = stubMessagesQuery;
|
|
172
|
-
lintReportsQuery = stubMessageLintReportsQuery;
|
|
173
|
-
try {
|
|
174
|
-
store = await openStore({ projectPath, nodeishFs, locales });
|
|
175
|
-
markInitAsComplete();
|
|
176
|
-
}
|
|
177
|
-
catch (e) {
|
|
178
|
-
markInitAsFailed(e);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
messagesQuery = createMessagesQuery({
|
|
183
|
-
projectPath,
|
|
184
|
-
nodeishFs,
|
|
185
|
-
settings,
|
|
186
|
-
resolvedModules,
|
|
187
|
-
onInitialMessageLoadResult: (e) => {
|
|
188
|
-
if (e) {
|
|
189
|
-
markInitAsFailed(e);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
markInitAsComplete();
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
onLoadMessageResult: (e) => {
|
|
196
|
-
setLoadMessagesViaPluginError(e);
|
|
197
|
-
},
|
|
198
|
-
onSaveMessageResult: (e) => {
|
|
199
|
-
setSaveMessagesViaPluginError(e);
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
lintReportsQuery = createMessageLintReportsQuery(messagesQuery, settings, installedMessageLintRules, resolvedModules);
|
|
203
|
-
store = undefined;
|
|
204
|
-
}
|
|
205
|
-
// -- app ---------------------------------------------------------------
|
|
206
|
-
const initializeError = await initialized.catch((error) => error);
|
|
207
|
-
/**
|
|
208
|
-
* Utility to escape reactive tracking and avoid multiple calls to
|
|
209
|
-
* the capture event.
|
|
210
|
-
*
|
|
211
|
-
* Should be addressed with https://github.com/opral/monorepo/issues/1772
|
|
212
|
-
*/
|
|
213
|
-
let projectLoadedCapturedAlready = false;
|
|
214
|
-
if (projectId && projectLoadedCapturedAlready === false) {
|
|
215
|
-
projectLoadedCapturedAlready = true;
|
|
216
|
-
// TODO ensure that capture is "awaited" without blocking the the app from starting
|
|
217
|
-
await identifyProject({
|
|
218
|
-
projectId,
|
|
219
|
-
properties: {
|
|
220
|
-
// using the id for now as a name but can be changed in the future
|
|
221
|
-
// we need at least one property to make a project visible in the dashboard
|
|
222
|
-
name: projectId,
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
await capture("SDK loaded project", {
|
|
226
|
-
projectId,
|
|
227
|
-
properties: {
|
|
228
|
-
appId: args.appId,
|
|
229
|
-
settings: settings(),
|
|
230
|
-
installedPluginIds: installedPlugins().map((p) => p.id),
|
|
231
|
-
installedMessageLintRuleIds: installedMessageLintRules().map((r) => r.id),
|
|
232
|
-
// TODO: fix for v2Persistence
|
|
233
|
-
// https://github.com/opral/inlang-message-sdk/issues/78
|
|
234
|
-
numberOfMessages: messagesQuery.includedMessageIds().length,
|
|
235
|
-
},
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
id: projectId,
|
|
240
|
-
installed: {
|
|
241
|
-
plugins: createSubscribable(() => installedPlugins()),
|
|
242
|
-
messageLintRules: createSubscribable(() => installedMessageLintRules()),
|
|
243
|
-
},
|
|
244
|
-
errors: createSubscribable(() => [
|
|
245
|
-
...(initializeError ? [initializeError] : []),
|
|
246
|
-
...(resolvedModules() ? resolvedModules().errors : []),
|
|
247
|
-
...(loadMessagesViaPluginError() ? [loadMessagesViaPluginError()] : []),
|
|
248
|
-
...(saveMessagesViaPluginError() ? [saveMessagesViaPluginError()] : []),
|
|
249
|
-
// have a query error exposed
|
|
250
|
-
//...(lintErrors() ?? []),
|
|
251
|
-
]),
|
|
252
|
-
settings: createSubscribable(() => settings()),
|
|
253
|
-
setSettings: (newSettings) => {
|
|
254
|
-
const result = setSettings(newSettings);
|
|
255
|
-
if (!result.error)
|
|
256
|
-
writeSettingsToDisk({ nodeishFs, settings: result.data, projectPath });
|
|
257
|
-
return result.error ? result : { data: undefined };
|
|
258
|
-
},
|
|
259
|
-
customApi: createSubscribable(() => resolvedModules()?.resolvedPluginApi.customApi || {}),
|
|
260
|
-
query: {
|
|
261
|
-
messages: messagesQuery,
|
|
262
|
-
messageLintReports: lintReportsQuery,
|
|
263
|
-
},
|
|
264
|
-
store,
|
|
265
|
-
};
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
// ------------------------------------------------------------------------------------------------
|
|
269
|
-
const loadSettings = async (args) => {
|
|
270
|
-
const { data: settingsFile, error: settingsFileError } = await tryCatch(async () => await args.nodeishFs.readFile(args.settingsFilePath, { encoding: "utf-8" }));
|
|
271
|
-
if (settingsFileError)
|
|
272
|
-
throw new ProjectSettingsFileNotFoundError({
|
|
273
|
-
cause: settingsFileError,
|
|
274
|
-
path: args.settingsFilePath,
|
|
275
|
-
});
|
|
276
|
-
const json = tryCatch(() => JSON.parse(settingsFile));
|
|
277
|
-
if (json.error) {
|
|
278
|
-
throw new ProjectSettingsFileJSONSyntaxError({
|
|
279
|
-
cause: json.error,
|
|
280
|
-
path: args.settingsFilePath,
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
return parseSettings(json.data);
|
|
284
|
-
};
|
|
285
|
-
/**
|
|
286
|
-
* @throws If the settings are not valid
|
|
287
|
-
*/
|
|
288
|
-
const parseSettings = (settings) => {
|
|
289
|
-
const withMigration = migrateIfOutdated(settings);
|
|
290
|
-
if (settingsCompiler.Check(withMigration) === false) {
|
|
291
|
-
const typeErrors = [...settingsCompiler.Errors(settings)];
|
|
292
|
-
if (typeErrors.length > 0) {
|
|
293
|
-
throw new ProjectSettingsInvalidError({
|
|
294
|
-
errors: typeErrors,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
const { sourceLanguageTag, languageTags } = settings;
|
|
299
|
-
if (!languageTags.includes(sourceLanguageTag)) {
|
|
300
|
-
throw new ProjectSettingsInvalidError({
|
|
301
|
-
errors: [
|
|
302
|
-
{
|
|
303
|
-
message: `The sourceLanguageTag "${sourceLanguageTag}" is not included in the languageTags "${languageTags.join('", "')}". Please add it to the languageTags.`,
|
|
304
|
-
type: ValueErrorType.String,
|
|
305
|
-
schema: ProjectSettings,
|
|
306
|
-
value: sourceLanguageTag,
|
|
307
|
-
path: "sourceLanguageTag",
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
return withMigration;
|
|
313
|
-
};
|
|
314
|
-
const writeSettingsToDisk = async (args) => {
|
|
315
|
-
const serializeResult = tryCatch(() =>
|
|
316
|
-
// TODO: this will probably not match the original formatting
|
|
317
|
-
JSON.stringify(args.settings, undefined, 2));
|
|
318
|
-
if (serializeResult.error)
|
|
319
|
-
throw serializeResult.error;
|
|
320
|
-
const serializedSettings = serializeResult.data;
|
|
321
|
-
const writeResult = await tryCatch(async () => await args.nodeishFs.writeFile(args.projectPath + "/settings.json", serializedSettings));
|
|
322
|
-
if (writeResult.error)
|
|
323
|
-
throw writeResult.error;
|
|
324
|
-
};
|
|
325
|
-
// ------------------------------------------------------------------------------------------------
|
|
326
|
-
const createAwaitable = () => {
|
|
327
|
-
let resolve;
|
|
328
|
-
let reject;
|
|
329
|
-
const promise = new Promise((res, rej) => {
|
|
330
|
-
resolve = res;
|
|
331
|
-
reject = rej;
|
|
332
|
-
});
|
|
333
|
-
return [promise, resolve, reject];
|
|
334
|
-
};
|
|
335
|
-
export function createSubscribable(signal) {
|
|
336
|
-
return Object.assign(signal, {
|
|
337
|
-
subscribe: (callback) => {
|
|
338
|
-
createEffect(() => {
|
|
339
|
-
callback(signal());
|
|
340
|
-
});
|
|
341
|
-
},
|
|
342
|
-
});
|
|
343
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadProject.test.d.ts","sourceRoot":"","sources":["../src/loadProject.test.ts"],"names":[],"mappings":""}
|