@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
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { resolvePlugins } from "./resolvePlugins.js";
|
|
4
|
-
import { PluginLoadMessagesFunctionAlreadyDefinedError, PluginSaveMessagesFunctionAlreadyDefinedError, PluginHasInvalidIdError, PluginReturnedInvalidCustomApiError, PluginsDoNotProvideLoadOrSaveMessagesError, } from "./errors.js";
|
|
5
|
-
it("should return an error if a plugin uses an invalid id", async () => {
|
|
6
|
-
const mockPlugin = {
|
|
7
|
-
// @ts-expect-error - invalid id
|
|
8
|
-
id: "no-namespace",
|
|
9
|
-
description: { en: "My plugin description" },
|
|
10
|
-
displayName: { en: "My plugin" },
|
|
11
|
-
loadMessages: () => undefined,
|
|
12
|
-
saveMessages: () => undefined,
|
|
13
|
-
};
|
|
14
|
-
const resolved = await resolvePlugins({
|
|
15
|
-
plugins: [mockPlugin],
|
|
16
|
-
settings: {},
|
|
17
|
-
nodeishFs: {},
|
|
18
|
-
});
|
|
19
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginHasInvalidIdError);
|
|
20
|
-
});
|
|
21
|
-
it("should expose the project settings including the plugin settings", async () => {
|
|
22
|
-
const settings = {
|
|
23
|
-
sourceLanguageTag: "en",
|
|
24
|
-
languageTags: ["en", "de"],
|
|
25
|
-
modules: [],
|
|
26
|
-
"plugin.namespace.placeholder": {
|
|
27
|
-
myPluginSetting: "value",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
const mockPlugin = {
|
|
31
|
-
id: "plugin.namespace.placeholder",
|
|
32
|
-
description: { en: "My plugin description" },
|
|
33
|
-
displayName: { en: "My plugin" },
|
|
34
|
-
saveMessages: async ({ settings }) => {
|
|
35
|
-
expect(settings).toStrictEqual(settings);
|
|
36
|
-
},
|
|
37
|
-
addCustomApi: ({ settings }) => {
|
|
38
|
-
expect(settings).toStrictEqual(settings);
|
|
39
|
-
return {};
|
|
40
|
-
},
|
|
41
|
-
loadMessages: async ({ settings }) => {
|
|
42
|
-
expect(settings).toStrictEqual(settings);
|
|
43
|
-
return [];
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
const resolved = await resolvePlugins({
|
|
47
|
-
plugins: [mockPlugin],
|
|
48
|
-
settings: settings,
|
|
49
|
-
nodeishFs: {},
|
|
50
|
-
});
|
|
51
|
-
await resolved.data.loadMessages({ settings, nodeishFs: {} });
|
|
52
|
-
await resolved.data.saveMessages({ settings, messages: [], nodeishFs: {} });
|
|
53
|
-
});
|
|
54
|
-
describe("loadMessages", () => {
|
|
55
|
-
it("should load messages from a local source", async () => {
|
|
56
|
-
const mockPlugin = {
|
|
57
|
-
id: "plugin.namespace.placeholder",
|
|
58
|
-
description: { en: "My plugin description" },
|
|
59
|
-
displayName: { en: "My plugin" },
|
|
60
|
-
loadMessages: async () => [
|
|
61
|
-
{ id: "test", alias: {}, expressions: [], selectors: [], variants: [] },
|
|
62
|
-
],
|
|
63
|
-
};
|
|
64
|
-
const resolved = await resolvePlugins({
|
|
65
|
-
plugins: [mockPlugin],
|
|
66
|
-
settings: {},
|
|
67
|
-
nodeishFs: {},
|
|
68
|
-
});
|
|
69
|
-
expect(await resolved.data.loadMessages({
|
|
70
|
-
settings: {},
|
|
71
|
-
nodeishFs: {},
|
|
72
|
-
})).toEqual([{ id: "test", alias: {}, expressions: [], selectors: [], variants: [] }]);
|
|
73
|
-
});
|
|
74
|
-
it("should collect an error if function is defined twice in multiple plugins", async () => {
|
|
75
|
-
const mockPlugin = {
|
|
76
|
-
id: "plugin.namepsace.loadMessagesFirst",
|
|
77
|
-
description: { en: "My plugin description" },
|
|
78
|
-
displayName: { en: "My plugin" },
|
|
79
|
-
loadMessages: async () => undefined,
|
|
80
|
-
};
|
|
81
|
-
const mockPlugin2 = {
|
|
82
|
-
id: "plugin.namepsace.loadMessagesSecond",
|
|
83
|
-
description: { en: "My plugin description" },
|
|
84
|
-
displayName: { en: "My plugin" },
|
|
85
|
-
loadMessages: async () => undefined,
|
|
86
|
-
};
|
|
87
|
-
const resolved = await resolvePlugins({
|
|
88
|
-
plugins: [mockPlugin, mockPlugin2],
|
|
89
|
-
nodeishFs: {},
|
|
90
|
-
settings: {},
|
|
91
|
-
});
|
|
92
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginLoadMessagesFunctionAlreadyDefinedError);
|
|
93
|
-
});
|
|
94
|
-
it("should return an error if no plugin defines loadMessages", async () => {
|
|
95
|
-
const mockPlugin = {
|
|
96
|
-
id: "plugin.namepsace.loadMessagesFirst",
|
|
97
|
-
description: { en: "My plugin description" },
|
|
98
|
-
displayName: { en: "My plugin" },
|
|
99
|
-
saveMessages: async () => undefined,
|
|
100
|
-
};
|
|
101
|
-
const resolved = await resolvePlugins({
|
|
102
|
-
plugins: [mockPlugin],
|
|
103
|
-
nodeishFs: {},
|
|
104
|
-
settings: {},
|
|
105
|
-
});
|
|
106
|
-
expect(resolved.errors).toHaveLength(1);
|
|
107
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginsDoNotProvideLoadOrSaveMessagesError);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe("saveMessages", () => {
|
|
111
|
-
it("should save messages to a local source", async () => {
|
|
112
|
-
const mockPlugin = {
|
|
113
|
-
id: "plugin.namespace.placeholder",
|
|
114
|
-
description: { en: "My plugin description" },
|
|
115
|
-
displayName: { en: "My plugin" },
|
|
116
|
-
loadMessages: async () => undefined,
|
|
117
|
-
saveMessages: async () => undefined,
|
|
118
|
-
};
|
|
119
|
-
const resolved = await resolvePlugins({
|
|
120
|
-
plugins: [mockPlugin],
|
|
121
|
-
nodeishFs: {},
|
|
122
|
-
settings: {},
|
|
123
|
-
});
|
|
124
|
-
expect(resolved.errors).toHaveLength(0);
|
|
125
|
-
});
|
|
126
|
-
it("should collect an error if function is defined twice in multiple plugins", async () => {
|
|
127
|
-
const mockPlugin = {
|
|
128
|
-
id: "plugin.namepsace.saveMessages",
|
|
129
|
-
description: { en: "My plugin description" },
|
|
130
|
-
displayName: { en: "My plugin" },
|
|
131
|
-
saveMessages: async () => undefined,
|
|
132
|
-
};
|
|
133
|
-
const mockPlugin2 = {
|
|
134
|
-
id: "plugin.namepsace.saveMessages2",
|
|
135
|
-
description: { en: "My plugin description" },
|
|
136
|
-
displayName: { en: "My plugin" },
|
|
137
|
-
saveMessages: async () => undefined,
|
|
138
|
-
};
|
|
139
|
-
const resolved = await resolvePlugins({
|
|
140
|
-
plugins: [mockPlugin, mockPlugin2],
|
|
141
|
-
settings: {},
|
|
142
|
-
nodeishFs: {},
|
|
143
|
-
});
|
|
144
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginSaveMessagesFunctionAlreadyDefinedError);
|
|
145
|
-
});
|
|
146
|
-
it("should return an error if no plugin defines saveMessages", async () => {
|
|
147
|
-
const mockPlugin = {
|
|
148
|
-
id: "plugin.namepsace.loadMessagesFirst",
|
|
149
|
-
description: { en: "My plugin description" },
|
|
150
|
-
displayName: { en: "My plugin" },
|
|
151
|
-
loadMessages: async () => undefined,
|
|
152
|
-
};
|
|
153
|
-
const resolved = await resolvePlugins({
|
|
154
|
-
plugins: [mockPlugin],
|
|
155
|
-
nodeishFs: {},
|
|
156
|
-
settings: {},
|
|
157
|
-
});
|
|
158
|
-
expect(resolved.errors).toHaveLength(1);
|
|
159
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginsDoNotProvideLoadOrSaveMessagesError);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
describe("addCustomApi", () => {
|
|
163
|
-
it("it should resolve app specific api", async () => {
|
|
164
|
-
const mockPlugin = {
|
|
165
|
-
id: "plugin.namespace.placeholder",
|
|
166
|
-
description: { en: "My plugin description" },
|
|
167
|
-
displayName: { en: "My plugin" },
|
|
168
|
-
addCustomApi: () => ({
|
|
169
|
-
"my-app": {
|
|
170
|
-
messageReferenceMatcher: () => undefined,
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
};
|
|
174
|
-
const resolved = await resolvePlugins({
|
|
175
|
-
plugins: [mockPlugin],
|
|
176
|
-
settings: {},
|
|
177
|
-
nodeishFs: {},
|
|
178
|
-
});
|
|
179
|
-
expect(resolved.data.customApi).toHaveProperty("my-app");
|
|
180
|
-
});
|
|
181
|
-
it("it should resolve multiple app specific apis", async () => {
|
|
182
|
-
const mockPlugin = {
|
|
183
|
-
id: "plugin.namespace.placeholder",
|
|
184
|
-
description: { en: "My plugin description" },
|
|
185
|
-
displayName: { en: "My plugin" },
|
|
186
|
-
addCustomApi: () => ({
|
|
187
|
-
"my-app-1": {
|
|
188
|
-
functionOfMyApp1: () => undefined,
|
|
189
|
-
},
|
|
190
|
-
"my-app-2": {
|
|
191
|
-
functionOfMyApp2: () => undefined,
|
|
192
|
-
},
|
|
193
|
-
}),
|
|
194
|
-
};
|
|
195
|
-
const mockPlugin2 = {
|
|
196
|
-
id: "plugin.namespace.placeholder2",
|
|
197
|
-
description: { en: "My plugin description" },
|
|
198
|
-
displayName: { en: "My plugin" },
|
|
199
|
-
addCustomApi: () => ({
|
|
200
|
-
"my-app-3": {
|
|
201
|
-
functionOfMyApp3: () => undefined,
|
|
202
|
-
},
|
|
203
|
-
}),
|
|
204
|
-
};
|
|
205
|
-
const resolved = await resolvePlugins({
|
|
206
|
-
plugins: [mockPlugin, mockPlugin2],
|
|
207
|
-
settings: {},
|
|
208
|
-
nodeishFs: {},
|
|
209
|
-
});
|
|
210
|
-
expect(resolved.data.customApi).toHaveProperty("my-app-1");
|
|
211
|
-
expect(resolved.data.customApi).toHaveProperty("my-app-2");
|
|
212
|
-
expect(resolved.data.customApi).toHaveProperty("my-app-3");
|
|
213
|
-
});
|
|
214
|
-
it("it should throw an error if return value is not an object", async () => {
|
|
215
|
-
const mockPlugin = {
|
|
216
|
-
id: "plugin.namespace.placeholder",
|
|
217
|
-
description: { en: "My plugin description" },
|
|
218
|
-
displayName: { en: "My plugin" },
|
|
219
|
-
// @ts-expect-error - invalid return type
|
|
220
|
-
addCustomApi: () => undefined,
|
|
221
|
-
};
|
|
222
|
-
const resolved = await resolvePlugins({
|
|
223
|
-
plugins: [mockPlugin],
|
|
224
|
-
settings: {},
|
|
225
|
-
nodeishFs: {},
|
|
226
|
-
});
|
|
227
|
-
expect(resolved.errors[0]).toBeInstanceOf(PluginReturnedInvalidCustomApiError);
|
|
228
|
-
});
|
|
229
|
-
it("it should throw an error if the passed options are not defined inside customApi", async () => {
|
|
230
|
-
const mockPlugin = {
|
|
231
|
-
id: "plugin.namepsace.placeholder",
|
|
232
|
-
description: { en: "My plugin description" },
|
|
233
|
-
displayName: { en: "My plugin" },
|
|
234
|
-
addCustomApi: () => ({
|
|
235
|
-
"app.inlang.placeholder": {
|
|
236
|
-
messageReferenceMatcher: () => {
|
|
237
|
-
return { hello: "world" };
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
}),
|
|
241
|
-
};
|
|
242
|
-
const resolved = await resolvePlugins({
|
|
243
|
-
plugins: [mockPlugin],
|
|
244
|
-
settings: {},
|
|
245
|
-
nodeishFs: {},
|
|
246
|
-
});
|
|
247
|
-
expect(resolved.data.customApi).toHaveProperty("app.inlang.placeholder");
|
|
248
|
-
expect((resolved.data.customApi?.["app.inlang.placeholder"]).messageReferenceMatcher()).toEqual({
|
|
249
|
-
hello: "world",
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { NodeishFilesystem } from "@lix-js/fs";
|
|
2
|
-
import type { PluginReturnedInvalidCustomApiError, PluginLoadMessagesFunctionAlreadyDefinedError, PluginSaveMessagesFunctionAlreadyDefinedError, PluginHasInvalidIdError, PluginHasInvalidSchemaError, PluginsDoNotProvideLoadOrSaveMessagesError } from "./errors.js";
|
|
3
|
-
import type { Message } from "@inlang/message";
|
|
4
|
-
import type { CustomApiInlangIdeExtension, Plugin } from "@inlang/plugin";
|
|
5
|
-
import type { ProjectSettings } from "@inlang/project-settings";
|
|
6
|
-
/**
|
|
7
|
-
* The filesystem is a subset of project lisa's nodeish filesystem.
|
|
8
|
-
*
|
|
9
|
-
* - only uses minimally required functions to decrease the API footprint on the ecosystem.
|
|
10
|
-
*/
|
|
11
|
-
export type NodeishFilesystemSubset = Pick<NodeishFilesystem, "readFile" | "readdir" | "mkdir" | "writeFile" | "watch">;
|
|
12
|
-
/**
|
|
13
|
-
* Function that resolves (imports and initializes) the plugins.
|
|
14
|
-
*/
|
|
15
|
-
export type ResolvePluginsFunction = (args: {
|
|
16
|
-
plugins: Array<Plugin>;
|
|
17
|
-
settings: ProjectSettings;
|
|
18
|
-
nodeishFs: NodeishFilesystemSubset;
|
|
19
|
-
}) => Promise<{
|
|
20
|
-
data: ResolvedPluginApi;
|
|
21
|
-
errors: Array<PluginReturnedInvalidCustomApiError | PluginLoadMessagesFunctionAlreadyDefinedError | PluginSaveMessagesFunctionAlreadyDefinedError | PluginHasInvalidIdError | PluginHasInvalidSchemaError | PluginsDoNotProvideLoadOrSaveMessagesError>;
|
|
22
|
-
}>;
|
|
23
|
-
/**
|
|
24
|
-
* The API after resolving the plugins.
|
|
25
|
-
*/
|
|
26
|
-
export type ResolvedPluginApi = {
|
|
27
|
-
loadMessages: (args: {
|
|
28
|
-
settings: ProjectSettings;
|
|
29
|
-
nodeishFs: NodeishFilesystemSubset;
|
|
30
|
-
}) => Promise<Message[]> | Message[];
|
|
31
|
-
saveMessages: (args: {
|
|
32
|
-
settings: ProjectSettings;
|
|
33
|
-
messages: Message[];
|
|
34
|
-
nodeishFs: NodeishFilesystemSubset;
|
|
35
|
-
}) => Promise<void> | void;
|
|
36
|
-
/**
|
|
37
|
-
* App specific APIs.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* // define
|
|
41
|
-
* customApi: ({ settings }) => ({
|
|
42
|
-
* "app.inlang.ide-extension": {
|
|
43
|
-
* messageReferenceMatcher: () => {
|
|
44
|
-
* // use settings
|
|
45
|
-
* settings.pathPattern
|
|
46
|
-
* return
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* })
|
|
50
|
-
* // use
|
|
51
|
-
* customApi['app.inlang.ide-extension'].messageReferenceMatcher()
|
|
52
|
-
*/
|
|
53
|
-
customApi: Record<`app.${string}.${string}` | `library.${string}.${string}`, unknown> & {
|
|
54
|
-
"app.inlang.ideExtension"?: CustomApiInlangIdeExtension;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/resolve-modules/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EACX,mCAAmC,EACnC,6CAA6C,EAC7C,6CAA6C,EAC7C,uBAAuB,EACvB,2BAA2B,EAC3B,0CAA0C,EAC1C,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE/D;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACzC,iBAAiB,EACjB,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,CACxD,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE;IAC3C,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACtB,QAAQ,EAAE,eAAe,CAAA;IACzB,SAAS,EAAE,uBAAuB,CAAA;CAClC,KAAK,OAAO,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAA;IACvB,MAAM,EAAE,KAAK,CACV,mCAAmC,GACnC,6CAA6C,GAC7C,6CAA6C,GAC7C,uBAAuB,GACvB,2BAA2B,GAC3B,0CAA0C,CAC5C,CAAA;CACD,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,eAAe,CAAA;QACzB,SAAS,EAAE,uBAAuB,CAAA;KAClC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAA;IACpC,YAAY,EAAE,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,eAAe,CAAA;QACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;QACnB,SAAS,EAAE,uBAAuB,CAAA;KAClC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAC1B;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,EAAE,MAAM,CAAC,OAAO,MAAM,IAAI,MAAM,EAAE,GAAG,WAAW,MAAM,IAAI,MAAM,EAAE,EAAE,OAAO,CAAC,GAAG;QACvF,yBAAyB,CAAC,EAAE,2BAA2B,CAAA;KACvD,CAAA;CACD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../../src/resolve-modules/plugins/types.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ProjectSettings } from "@inlang/project-settings";
|
|
2
|
-
import { Value } from "@sinclair/typebox/value";
|
|
3
|
-
import { describe, test, expect } from "vitest";
|
|
4
|
-
import { expectType } from "tsd";
|
|
5
|
-
import { Plugin } from "@inlang/plugin";
|
|
6
|
-
describe("Plugin", () => {
|
|
7
|
-
test("meta.id should enforce plugin.namespace.* patterns", () => {
|
|
8
|
-
expectType("");
|
|
9
|
-
const mockPlugin = {
|
|
10
|
-
id: "plugin.namespace.placeholder",
|
|
11
|
-
displayName: { en: "" },
|
|
12
|
-
description: { en: "" },
|
|
13
|
-
};
|
|
14
|
-
const passCases = ["plugin.namespace.helloWorld", "plugin.namespace.i18n"];
|
|
15
|
-
const failCases = [
|
|
16
|
-
"namespace.hello_World",
|
|
17
|
-
"plugin.namespace-HelloWorld",
|
|
18
|
-
"lintRule.namespace.coolPlugin",
|
|
19
|
-
];
|
|
20
|
-
for (const pass of passCases) {
|
|
21
|
-
mockPlugin.id = pass;
|
|
22
|
-
// @ts-ignore - type mismatch error. fix after refactor
|
|
23
|
-
expect(Value.Check(Plugin, mockPlugin)).toBe(true);
|
|
24
|
-
}
|
|
25
|
-
for (const fail of failCases) {
|
|
26
|
-
mockPlugin.id = fail;
|
|
27
|
-
// @ts-ignore - type mismatch error. fix after refactor
|
|
28
|
-
expect(Value.Check(Plugin, mockPlugin)).toBe(false);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
test("meta.id should be a valid inlang.config.setting key", () => {
|
|
32
|
-
const settings = {
|
|
33
|
-
sourceLanguageTag: "en",
|
|
34
|
-
languageTags: ["en", "de"],
|
|
35
|
-
modules: [],
|
|
36
|
-
};
|
|
37
|
-
const cases = ["plugin.namespace.helloWorld", "plugin.namespace.i18n"];
|
|
38
|
-
for (const _case of cases) {
|
|
39
|
-
const mergedSettings = { ...settings, [_case]: {} };
|
|
40
|
-
expect(Value.Check(ProjectSettings, mergedSettings)).toBe(true);
|
|
41
|
-
// @ts-ignore - type mismatch error. fix after refactor
|
|
42
|
-
expect(Value.Check(Plugin["properties"]["id"], _case)).toBe(true);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModules.d.ts","sourceRoot":"","sources":["../../src/resolve-modules/resolveModules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAoBvD,eAAO,MAAM,cAAc,EAAE,qBA4F5B,CAAA"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { InlangModule } from "@inlang/module";
|
|
2
|
-
import { ModuleError, ModuleImportError, ModuleHasNoExportsError, ModuleExportIsInvalidError, ModuleSettingsAreInvalidError, } from "./errors.js";
|
|
3
|
-
import { tryCatch } from "@inlang/result";
|
|
4
|
-
import { resolveMessageLintRules } from "./message-lint-rules/resolveMessageLintRules.js";
|
|
5
|
-
import { createImport } from "./import.js";
|
|
6
|
-
import { resolvePlugins } from "./plugins/resolvePlugins.js";
|
|
7
|
-
import { TypeCompiler } from "@sinclair/typebox/compiler";
|
|
8
|
-
import { validatedModuleSettings } from "./validatedModuleSettings.js";
|
|
9
|
-
const ModuleCompiler = TypeCompiler.Compile(InlangModule);
|
|
10
|
-
export const resolveModules = async (args) => {
|
|
11
|
-
const _import = args._import ?? createImport(args.projectPath, args.nodeishFs);
|
|
12
|
-
const allPlugins = [];
|
|
13
|
-
const allMessageLintRules = [];
|
|
14
|
-
const meta = [];
|
|
15
|
-
const moduleErrors = [];
|
|
16
|
-
async function resolveModule(module) {
|
|
17
|
-
const importedModule = await tryCatch(() => _import(module));
|
|
18
|
-
// -- FAILED TO IMPORT --
|
|
19
|
-
if (importedModule.error) {
|
|
20
|
-
moduleErrors.push(new ModuleImportError({
|
|
21
|
-
module: module,
|
|
22
|
-
cause: importedModule.error,
|
|
23
|
-
}));
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// -- MODULE DOES NOT EXPORT ANYTHING --
|
|
27
|
-
if (importedModule.data?.default === undefined) {
|
|
28
|
-
moduleErrors.push(new ModuleHasNoExportsError({
|
|
29
|
-
module: module,
|
|
30
|
-
}));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
// -- CHECK IF MODULE IS SYNTACTIALLY VALID
|
|
34
|
-
const isValidModule = ModuleCompiler.Check(importedModule.data);
|
|
35
|
-
if (isValidModule === false) {
|
|
36
|
-
const errors = [...ModuleCompiler.Errors(importedModule.data)];
|
|
37
|
-
moduleErrors.push(new ModuleExportIsInvalidError({
|
|
38
|
-
module: module,
|
|
39
|
-
errors,
|
|
40
|
-
}));
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// -- VALIDATE MODULE SETTINGS
|
|
44
|
-
const result = validatedModuleSettings({
|
|
45
|
-
settingsSchema: importedModule.data.default.settingsSchema,
|
|
46
|
-
moduleSettings: args.settings[importedModule.data.default.id],
|
|
47
|
-
});
|
|
48
|
-
if (result !== "isValid") {
|
|
49
|
-
moduleErrors.push(new ModuleSettingsAreInvalidError({ module: module, errors: result }));
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
meta.push({
|
|
53
|
-
module: module,
|
|
54
|
-
id: importedModule.data.default.id,
|
|
55
|
-
});
|
|
56
|
-
if (importedModule.data.default.id.startsWith("plugin.")) {
|
|
57
|
-
allPlugins.push(importedModule.data.default);
|
|
58
|
-
}
|
|
59
|
-
else if (importedModule.data.default.id.startsWith("messageLintRule.")) {
|
|
60
|
-
allMessageLintRules.push(importedModule.data.default);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
moduleErrors.push(new ModuleError(`Unimplemented module type ${importedModule.data.default.id}.The module has not been installed.`, { module: module }));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
await Promise.all(args.settings.modules.map(resolveModule));
|
|
67
|
-
const resolvedPlugins = await resolvePlugins({
|
|
68
|
-
plugins: allPlugins,
|
|
69
|
-
settings: args.settings,
|
|
70
|
-
nodeishFs: args.nodeishFs,
|
|
71
|
-
});
|
|
72
|
-
const resolvedLintRules = resolveMessageLintRules({ messageLintRules: allMessageLintRules });
|
|
73
|
-
return {
|
|
74
|
-
meta,
|
|
75
|
-
messageLintRules: allMessageLintRules,
|
|
76
|
-
plugins: allPlugins,
|
|
77
|
-
resolvedPluginApi: resolvedPlugins.data,
|
|
78
|
-
errors: [...moduleErrors, ...resolvedLintRules.errors, ...resolvedPlugins.errors],
|
|
79
|
-
};
|
|
80
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModules.test.d.ts","sourceRoot":"","sources":["../../src/resolve-modules/resolveModules.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { expect, it } from "vitest";
|
|
2
|
-
import { ModuleError, ModuleExportIsInvalidError, ModuleHasNoExportsError, ModuleImportError, ModuleSettingsAreInvalidError, } from "./errors.js";
|
|
3
|
-
import { resolveModules } from "./resolveModules.js";
|
|
4
|
-
import { Type } from "@sinclair/typebox";
|
|
5
|
-
it("should return an error if a plugin cannot be imported", async () => {
|
|
6
|
-
const settings = {
|
|
7
|
-
sourceLanguageTag: "en",
|
|
8
|
-
languageTags: ["de", "en"],
|
|
9
|
-
modules: ["https://myplugin.com/index.js"],
|
|
10
|
-
};
|
|
11
|
-
const resolved = await resolveModules({
|
|
12
|
-
projectPath: "/project.inlang",
|
|
13
|
-
settings,
|
|
14
|
-
nodeishFs: {},
|
|
15
|
-
_import: () => {
|
|
16
|
-
throw new ModuleImportError({
|
|
17
|
-
module: settings.modules[0],
|
|
18
|
-
cause: new Error("Could not import"),
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleImportError);
|
|
23
|
-
});
|
|
24
|
-
it("should resolve plugins and message lint rules successfully", async () => {
|
|
25
|
-
// Define mock data
|
|
26
|
-
const mockPlugin = {
|
|
27
|
-
id: "plugin.namespace.mock",
|
|
28
|
-
description: { en: "Mock plugin description" },
|
|
29
|
-
displayName: { en: "Mock Plugin" },
|
|
30
|
-
loadMessages: () => undefined,
|
|
31
|
-
saveMessages: () => undefined,
|
|
32
|
-
addCustomApi: () => ({
|
|
33
|
-
"app.inlang.ideExtension": {
|
|
34
|
-
messageReferenceMatcher: () => undefined,
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
};
|
|
38
|
-
const mockMessageLintRule = {
|
|
39
|
-
id: "messageLintRule.namespace.mock",
|
|
40
|
-
description: { en: "Mock lint rule description" },
|
|
41
|
-
displayName: { en: "Mock Lint Rule" },
|
|
42
|
-
run: () => undefined,
|
|
43
|
-
};
|
|
44
|
-
const settings = {
|
|
45
|
-
sourceLanguageTag: "en",
|
|
46
|
-
languageTags: ["de", "en"],
|
|
47
|
-
modules: ["lint-rule.js", "plugin.js"],
|
|
48
|
-
};
|
|
49
|
-
const _import = async (name) => {
|
|
50
|
-
if (name === "lint-rule.js") {
|
|
51
|
-
return {
|
|
52
|
-
default: mockMessageLintRule,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
return {
|
|
57
|
-
default: mockPlugin,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
// Call the function
|
|
62
|
-
const resolved = await resolveModules({
|
|
63
|
-
projectPath: "/project.inlang",
|
|
64
|
-
settings,
|
|
65
|
-
_import,
|
|
66
|
-
nodeishFs: {},
|
|
67
|
-
});
|
|
68
|
-
// Assert results
|
|
69
|
-
expect(resolved.errors).toHaveLength(0);
|
|
70
|
-
// Check for the meta data of the plugin
|
|
71
|
-
expect(resolved.plugins.some((module) => module.id === mockPlugin.id)).toBeDefined();
|
|
72
|
-
// Check for the app specific api
|
|
73
|
-
expect(resolved.resolvedPluginApi["customApi"]?.["app.inlang.ideExtension"]).toBeDefined();
|
|
74
|
-
// Check for the lint rule
|
|
75
|
-
expect(resolved.messageLintRules[0]?.id).toBe(mockMessageLintRule.id);
|
|
76
|
-
});
|
|
77
|
-
it("should return an error if a module cannot be imported", async () => {
|
|
78
|
-
const settings = {
|
|
79
|
-
sourceLanguageTag: "en",
|
|
80
|
-
languageTags: ["de", "en"],
|
|
81
|
-
modules: ["https://myplugin.com/index.js"],
|
|
82
|
-
};
|
|
83
|
-
const _import = async () => {
|
|
84
|
-
throw new ModuleImportError({
|
|
85
|
-
module: settings.modules[0],
|
|
86
|
-
cause: new Error(),
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
// Call the function
|
|
90
|
-
const resolved = await resolveModules({
|
|
91
|
-
projectPath: "/project.inlang",
|
|
92
|
-
settings,
|
|
93
|
-
_import,
|
|
94
|
-
nodeishFs: {},
|
|
95
|
-
});
|
|
96
|
-
// Assert results
|
|
97
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleImportError);
|
|
98
|
-
});
|
|
99
|
-
it("should return an error if a module does not export anything", async () => {
|
|
100
|
-
const settings = {
|
|
101
|
-
sourceLanguageTag: "en",
|
|
102
|
-
languageTags: ["de", "en"],
|
|
103
|
-
modules: ["https://myplugin.com/index.js"],
|
|
104
|
-
};
|
|
105
|
-
const _import = async () => ({});
|
|
106
|
-
// Call the function
|
|
107
|
-
const resolved = await resolveModules({
|
|
108
|
-
projectPath: "/project.inlang",
|
|
109
|
-
settings,
|
|
110
|
-
_import,
|
|
111
|
-
nodeishFs: {},
|
|
112
|
-
});
|
|
113
|
-
// Assert results
|
|
114
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleHasNoExportsError);
|
|
115
|
-
});
|
|
116
|
-
it("should return an error if a module exports an invalid plugin or lint rule", async () => {
|
|
117
|
-
const settings = {
|
|
118
|
-
sourceLanguageTag: "en",
|
|
119
|
-
languageTags: ["de", "en"],
|
|
120
|
-
modules: ["https://myplugin.com/index.js"],
|
|
121
|
-
};
|
|
122
|
-
const _import = async () => ({
|
|
123
|
-
// @ts-expect-error - invalid meta of a plugin
|
|
124
|
-
default: {
|
|
125
|
-
id: "plugin.namespace.mock",
|
|
126
|
-
description: { en: "Mock plugin description" },
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
const resolved = await resolveModules({
|
|
130
|
-
projectPath: "/project.inlang",
|
|
131
|
-
settings,
|
|
132
|
-
_import,
|
|
133
|
-
nodeishFs: {},
|
|
134
|
-
});
|
|
135
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleExportIsInvalidError);
|
|
136
|
-
});
|
|
137
|
-
it("should handle other unhandled errors during plugin resolution", async () => {
|
|
138
|
-
const errorMessage = "Unhandled error during plugin resolution";
|
|
139
|
-
const settings = {
|
|
140
|
-
sourceLanguageTag: "en",
|
|
141
|
-
languageTags: ["de", "en"],
|
|
142
|
-
modules: ["https://myplugin.com/index.js"],
|
|
143
|
-
};
|
|
144
|
-
const _import = async () => {
|
|
145
|
-
throw new Error(errorMessage);
|
|
146
|
-
};
|
|
147
|
-
// Call the function
|
|
148
|
-
const resolved = await resolveModules({
|
|
149
|
-
projectPath: "/project.inlang",
|
|
150
|
-
settings,
|
|
151
|
-
_import,
|
|
152
|
-
nodeishFs: {},
|
|
153
|
-
});
|
|
154
|
-
// Assert results
|
|
155
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleError);
|
|
156
|
-
});
|
|
157
|
-
it("should return an error if a moduleSettings are invalid", async () => {
|
|
158
|
-
const settings = {
|
|
159
|
-
sourceLanguageTag: "en",
|
|
160
|
-
languageTags: ["de", "en"],
|
|
161
|
-
modules: ["plugin.js"],
|
|
162
|
-
"plugin.namespace.mock": {
|
|
163
|
-
ignore: ["invalid"],
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
const _import = async () => ({
|
|
167
|
-
default: {
|
|
168
|
-
id: "plugin.namespace.mock",
|
|
169
|
-
description: { en: "Mock plugin description" },
|
|
170
|
-
displayName: { en: "Mock Plugin" },
|
|
171
|
-
settingsSchema: Type.Object({
|
|
172
|
-
ignore: Type.String(),
|
|
173
|
-
}),
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
// Call the function
|
|
177
|
-
const resolved = await resolveModules({
|
|
178
|
-
projectPath: "/project.inlang",
|
|
179
|
-
settings,
|
|
180
|
-
_import,
|
|
181
|
-
nodeishFs: {},
|
|
182
|
-
});
|
|
183
|
-
// Assert results
|
|
184
|
-
expect(resolved.errors[0]).toBeInstanceOf(ModuleSettingsAreInvalidError);
|
|
185
|
-
});
|