@inlang/sdk 0.36.3 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/database/initDb.d.ts +7 -0
- package/dist/database/initDb.d.ts.map +1 -0
- package/dist/database/initDb.js +36 -0
- package/dist/database/initDb.js.map +1 -0
- package/dist/database/initDbAndSchema.test.d.ts +2 -0
- package/dist/database/initDbAndSchema.test.d.ts.map +1 -0
- package/dist/database/initDbAndSchema.test.js +110 -0
- package/dist/database/initDbAndSchema.test.js.map +1 -0
- package/dist/database/jsonbPlugin.d.ts +20 -0
- package/dist/database/jsonbPlugin.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.js +183 -0
- package/dist/database/jsonbPlugin.js.map +1 -0
- package/dist/database/jsonbPlugin.test.d.ts +2 -0
- package/dist/database/jsonbPlugin.test.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.test.js +119 -0
- package/dist/database/jsonbPlugin.test.js.map +1 -0
- package/dist/database/schema.d.ts +74 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +45 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/helper.d.ts +71 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +91 -0
- package/dist/helper.js.map +1 -0
- package/dist/human-id/human-id.d.ts +3 -0
- package/dist/human-id/human-id.d.ts.map +1 -0
- package/dist/human-id/human-id.js +12 -0
- package/dist/human-id/human-id.js.map +1 -0
- package/dist/human-id/words.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.js +4 -0
- package/dist/human-id/words.js.map +1 -0
- package/dist/human-id/words.test.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.test.js +4 -0
- package/dist/human-id/words.test.js.map +1 -0
- package/dist/import-export/exportFiles.d.ts +11 -0
- package/dist/import-export/exportFiles.d.ts.map +1 -0
- package/dist/import-export/exportFiles.js +26 -0
- package/dist/import-export/exportFiles.js.map +1 -0
- package/dist/import-export/importFiles.d.ts +13 -0
- package/dist/import-export/importFiles.d.ts.map +1 -0
- package/dist/import-export/importFiles.js +124 -0
- package/dist/import-export/importFiles.js.map +1 -0
- package/dist/import-export/importFiles.test.d.ts +2 -0
- package/dist/import-export/importFiles.test.d.ts.map +1 -0
- package/dist/import-export/importFiles.test.js +179 -0
- package/dist/import-export/importFiles.test.js.map +1 -0
- package/dist/import-export/roundtrip.test.d.ts +2 -0
- package/dist/import-export/roundtrip.test.d.ts.map +1 -0
- package/dist/import-export/roundtrip.test.js +273 -0
- package/dist/import-export/roundtrip.test.js.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts +4 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js +58 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -0
- package/dist/index.d.ts +21 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js +84 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts +86 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.js +35 -0
- package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js +67 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -0
- package/dist/json-schema/pattern.d.ts +190 -0
- package/dist/json-schema/pattern.d.ts.map +1 -0
- package/dist/json-schema/pattern.js +43 -0
- package/dist/json-schema/pattern.js.map +1 -0
- package/dist/json-schema/settings.d.ts +31 -0
- package/dist/json-schema/settings.d.ts.map +1 -0
- package/dist/json-schema/settings.js +96 -0
- package/dist/json-schema/settings.js.map +1 -0
- package/dist/json-schema/settings.test-d.d.ts +2 -0
- package/dist/json-schema/settings.test-d.d.ts.map +1 -0
- package/dist/json-schema/settings.test-d.js +20 -0
- package/dist/json-schema/settings.test-d.js.map +1 -0
- package/dist/lix-plugin/applyChanges.d.ts +3 -0
- package/dist/lix-plugin/applyChanges.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.js +127 -0
- package/dist/lix-plugin/applyChanges.js.map +1 -0
- package/dist/lix-plugin/applyChanges.test.d.ts +2 -0
- package/dist/lix-plugin/applyChanges.test.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.test.js +135 -0
- package/dist/lix-plugin/applyChanges.test.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.d.ts +3 -0
- package/dist/lix-plugin/detectConflicts.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.js +47 -0
- package/dist/lix-plugin/detectConflicts.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts +2 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.js +251 -0
- package/dist/lix-plugin/detectConflicts.test.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts +8 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.js +109 -0
- package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts +2 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js +418 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -0
- package/dist/lix-plugin/merge.test.d.ts +2 -0
- package/dist/lix-plugin/merge.test.d.ts.map +1 -0
- package/dist/lix-plugin/merge.test.js +120 -0
- package/dist/lix-plugin/merge.test.js.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts +2 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js +176 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -0
- package/dist/migrations/v2/createMessageV1.d.ts +28 -0
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -0
- package/dist/migrations/v2/createMessageV1.js +31 -0
- package/dist/migrations/v2/createMessageV1.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts +9 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +31 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts +2 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +45 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -0
- package/dist/plugin/cache.d.ts +6 -0
- package/dist/plugin/cache.d.ts.map +1 -0
- package/dist/plugin/cache.js +59 -0
- package/dist/plugin/cache.js.map +1 -0
- package/dist/plugin/cache.test.d.ts +2 -0
- package/dist/plugin/cache.test.d.ts.map +1 -0
- package/dist/plugin/cache.test.js +61 -0
- package/dist/plugin/cache.test.js.map +1 -0
- package/dist/plugin/errors.d.ts +41 -0
- package/dist/plugin/errors.d.ts.map +1 -0
- package/dist/plugin/errors.js +48 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/importPlugins.d.ts +19 -0
- package/dist/plugin/importPlugins.d.ts.map +1 -0
- package/dist/plugin/importPlugins.js +43 -0
- package/dist/plugin/importPlugins.js.map +1 -0
- package/dist/plugin/importPlugins.test.d.ts +2 -0
- package/dist/plugin/importPlugins.test.d.ts.map +1 -0
- package/dist/plugin/importPlugins.test.js +95 -0
- package/dist/plugin/importPlugins.test.js.map +1 -0
- package/dist/plugin/meta/ideExtension.d.ts +54 -0
- package/dist/plugin/meta/ideExtension.d.ts.map +1 -0
- package/dist/plugin/meta/ideExtension.js +5 -0
- package/dist/plugin/meta/ideExtension.js.map +1 -0
- package/dist/plugin/schema.d.ts +152 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/schema.js +5 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/project/api.d.ts +74 -0
- package/dist/project/api.d.ts.map +1 -0
- package/dist/project/api.js +5 -0
- package/dist/project/api.js.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts +14 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.js +87 -0
- package/dist/project/initHandleSaveToLixOnChange.js.map +1 -0
- package/dist/project/loadProject.d.ts +53 -0
- package/dist/project/loadProject.d.ts.map +1 -0
- package/dist/project/loadProject.js +167 -0
- package/dist/project/loadProject.js.map +1 -0
- package/dist/project/loadProject.test.d.ts.map +1 -0
- package/dist/project/loadProject.test.js +146 -0
- package/dist/project/loadProject.test.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.d.ts +77 -0
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.js +584 -0
- package/dist/project/loadProjectFromDirectory.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts +2 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.js +663 -0
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -0
- package/dist/project/loadProjectInMemory.d.ts +8 -0
- package/dist/project/loadProjectInMemory.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.js +32 -0
- package/dist/project/loadProjectInMemory.js.map +1 -0
- package/dist/project/loadProjectInMemory.test.d.ts +2 -0
- package/dist/project/loadProjectInMemory.test.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.test.js +27 -0
- package/dist/project/loadProjectInMemory.test.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.d.ts +13 -0
- package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.js +53 -0
- package/dist/project/maybeCaptureTelemetry.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts +2 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.js +65 -0
- package/dist/project/maybeCaptureTelemetry.test.js.map +1 -0
- package/dist/project/newProject.d.ts +17 -0
- package/dist/project/newProject.d.ts.map +1 -0
- package/dist/project/newProject.js +71 -0
- package/dist/project/newProject.js.map +1 -0
- package/dist/project/newProject.test.d.ts +2 -0
- package/dist/project/newProject.test.d.ts.map +1 -0
- package/dist/project/newProject.test.js +37 -0
- package/dist/project/newProject.test.js.map +1 -0
- package/dist/project/saveProjectToDirectory.d.ts +8 -0
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.js +86 -0
- package/dist/project/saveProjectToDirectory.js.map +1 -0
- package/dist/project/saveProjectToDirectory.test.d.ts +2 -0
- package/dist/project/saveProjectToDirectory.test.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.test.js +245 -0
- package/dist/project/saveProjectToDirectory.test.js.map +1 -0
- package/dist/project/state/id$.d.ts +6 -0
- package/dist/project/state/id$.d.ts.map +1 -0
- package/dist/project/state/id$.js +19 -0
- package/dist/project/state/id$.js.map +1 -0
- package/dist/project/state/id$.test.d.ts +2 -0
- package/dist/project/state/id$.test.d.ts.map +1 -0
- package/dist/project/state/id$.test.js +36 -0
- package/dist/project/state/id$.test.js.map +1 -0
- package/dist/project/state/setSettings.d.ts +7 -0
- package/dist/project/state/setSettings.d.ts.map +1 -0
- package/dist/project/state/setSettings.js +16 -0
- package/dist/project/state/setSettings.js.map +1 -0
- package/dist/project/state/setSettings.test.d.ts +2 -0
- package/dist/project/state/setSettings.test.d.ts.map +1 -0
- package/dist/project/state/setSettings.test.js +58 -0
- package/dist/project/state/setSettings.test.js.map +1 -0
- package/dist/project/state/settings$.d.ts +7 -0
- package/dist/project/state/settings$.d.ts.map +1 -0
- package/dist/project/state/settings$.js +21 -0
- package/dist/project/state/settings$.js.map +1 -0
- package/dist/project/state/settings$.test.d.ts +2 -0
- package/dist/project/state/settings$.test.d.ts.map +1 -0
- package/dist/project/state/settings$.test.js +51 -0
- package/dist/project/state/settings$.test.js.map +1 -0
- package/dist/project/state/state.d.ts +58 -0
- package/dist/project/state/state.d.ts.map +1 -0
- package/dist/project/state/state.js +67 -0
- package/dist/project/state/state.js.map +1 -0
- package/dist/project/state/state.test.d.ts +2 -0
- package/dist/project/state/state.test.d.ts.map +1 -0
- package/dist/project/state/state.test.js +103 -0
- package/dist/project/state/state.test.js.map +1 -0
- package/dist/query-utilities/index.d.ts +5 -0
- package/dist/query-utilities/index.d.ts.map +1 -0
- package/dist/query-utilities/index.js +8 -0
- package/dist/query-utilities/index.js.map +1 -0
- package/dist/query-utilities/insertBundleNested.d.ts +4 -0
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/insertBundleNested.js +39 -0
- package/dist/query-utilities/insertBundleNested.js.map +1 -0
- package/dist/query-utilities/pollQuery.d.ts +14 -0
- package/dist/query-utilities/pollQuery.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.js +22 -0
- package/dist/query-utilities/pollQuery.js.map +1 -0
- package/dist/query-utilities/pollQuery.test.d.ts +2 -0
- package/dist/query-utilities/pollQuery.test.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.test.js +67 -0
- package/dist/query-utilities/pollQuery.test.js.map +1 -0
- package/dist/query-utilities/selectBundleNested.d.ts +107 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/selectBundleNested.js +43 -0
- package/dist/query-utilities/selectBundleNested.js.map +1 -0
- package/dist/query-utilities/updateBundleNested.d.ts +12 -0
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/updateBundleNested.js +25 -0
- package/dist/query-utilities/updateBundleNested.js.map +1 -0
- package/dist/query-utilities/upsertBundleNested.d.ts +4 -0
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/upsertBundleNested.js +50 -0
- package/dist/query-utilities/upsertBundleNested.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +6 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +9 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/error-reporting/index.d.ts +15 -0
- package/dist/services/error-reporting/index.d.ts.map +1 -0
- package/dist/services/error-reporting/index.js +30 -0
- package/dist/services/error-reporting/index.js.map +1 -0
- package/dist/{telemetry → services/telemetry}/capture.d.ts +4 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +77 -0
- package/dist/services/telemetry/capture.js.map +1 -0
- package/dist/services/telemetry/capture.test.d.ts +2 -0
- package/dist/services/telemetry/capture.test.d.ts.map +1 -0
- package/dist/services/telemetry/capture.test.js +44 -0
- package/dist/services/telemetry/capture.test.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.d.ts +11 -0
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.js +83 -0
- package/dist/utilities/detectJsonFormatting.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts +2 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.js +33 -0
- package/dist/utilities/detectJsonFormatting.test.js.map +1 -0
- package/package.json +32 -40
- package/src/database/initDb.ts +34 -0
- package/src/database/initDbAndSchema.test.ts +125 -0
- package/src/database/jsonbPlugin.test.ts +154 -0
- package/src/database/jsonbPlugin.ts +215 -0
- package/src/database/schema.ts +127 -0
- package/src/helper.ts +113 -0
- package/src/human-id/human-id.ts +14 -0
- package/src/{storage/human-id → human-id}/words.test.ts +14 -14
- package/src/{storage/human-id → human-id}/words.ts +4 -4
- package/src/import-export/exportFiles.ts +36 -0
- package/src/import-export/importFiles.test.ts +211 -0
- package/src/import-export/importFiles.ts +142 -0
- package/src/import-export/roundtrip.test.ts +313 -0
- package/src/import-export/upsertBundleNestedMatchByProperties.ts +74 -0
- package/src/index.ts +29 -37
- package/src/json-schema/old-v1-message/README.md +1 -0
- package/src/json-schema/old-v1-message/fromMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/fromMessageV1.ts +99 -0
- package/src/json-schema/old-v1-message/schemaV1.ts +66 -0
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +79 -0
- package/src/json-schema/pattern.ts +59 -0
- package/src/json-schema/settings.test-d.ts +21 -0
- package/src/json-schema/settings.ts +138 -0
- package/src/lix-plugin/applyChanges.test.ts +150 -0
- package/src/lix-plugin/applyChanges.ts +171 -0
- package/src/lix-plugin/detectConflicts.test.ts +286 -0
- package/src/lix-plugin/detectConflicts.ts +62 -0
- package/src/lix-plugin/inlangLixPluginV1.test.ts +439 -0
- package/src/lix-plugin/inlangLixPluginV1.ts +132 -0
- package/src/lix-plugin/merge.test.ts +133 -0
- package/src/lix-plugin/resolveConflictBySelecting.test.ts +188 -0
- package/src/migrations/v2/createMessageV1.ts +37 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.test.ts +51 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.ts +31 -0
- package/src/plugin/cache.test.ts +83 -0
- package/src/plugin/cache.ts +79 -0
- package/src/plugin/errors.ts +67 -0
- package/src/plugin/importPlugins.test.ts +107 -0
- package/src/plugin/importPlugins.ts +60 -0
- package/src/plugin/meta/ideExtension.ts +56 -0
- package/src/plugin/schema.ts +165 -0
- package/src/project/api.ts +77 -0
- package/src/project/initHandleSaveToLixOnChange.ts +93 -0
- package/src/project/loadProject.test.ts +177 -0
- package/src/project/loadProject.ts +245 -0
- package/src/project/loadProjectFromDirectory.test.ts +854 -0
- package/src/project/loadProjectFromDirectory.ts +752 -0
- package/src/project/loadProjectInMemory.test.ts +29 -0
- package/src/project/loadProjectInMemory.ts +36 -0
- package/src/project/maybeCaptureTelemetry.test.ts +72 -0
- package/src/project/maybeCaptureTelemetry.ts +61 -0
- package/src/project/newProject.test.ts +36 -0
- package/src/project/newProject.ts +78 -0
- package/src/project/saveProjectToDirectory.test.ts +310 -0
- package/src/project/saveProjectToDirectory.ts +100 -0
- package/src/query-utilities/index.ts +4 -0
- package/src/query-utilities/insertBundleNested.ts +46 -0
- package/src/query-utilities/selectBundleNested.ts +46 -0
- package/src/query-utilities/updateBundleNested.ts +35 -0
- package/src/query-utilities/upsertBundleNested.ts +61 -0
- package/src/services/env-variables/createIndexFile.js +40 -0
- package/src/{env-variables → services/env-variables}/index.d.ts +8 -5
- package/src/services/error-reporting/index.ts +28 -0
- package/src/services/telemetry/capture.test.ts +48 -0
- package/src/services/telemetry/capture.ts +98 -0
- package/src/utilities/detectJsonFormatting.test.ts +38 -0
- package/src/utilities/detectJsonFormatting.ts +109 -0
- package/dist/adapter/solidAdapter.d.ts +0 -33
- package/dist/adapter/solidAdapter.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.js +0 -40
- package/dist/adapter/solidAdapter.test.d.ts +0 -2
- package/dist/adapter/solidAdapter.test.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.test.js +0 -356
- package/dist/api.d.ts +0 -113
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -1
- package/dist/api.test-d.d.ts +0 -2
- package/dist/api.test-d.d.ts.map +0 -1
- package/dist/api.test-d.js +0 -4
- package/dist/createMessageLintReportsQuery.d.ts +0 -12
- package/dist/createMessageLintReportsQuery.d.ts.map +0 -1
- package/dist/createMessageLintReportsQuery.js +0 -176
- package/dist/createMessagesQuery.d.ts +0 -19
- package/dist/createMessagesQuery.d.ts.map +0 -1
- package/dist/createMessagesQuery.js +0 -451
- package/dist/createMessagesQuery.test.d.ts +0 -2
- package/dist/createMessagesQuery.test.d.ts.map +0 -1
- package/dist/createMessagesQuery.test.js +0 -402
- package/dist/createNewProject.d.ts +0 -12
- package/dist/createNewProject.d.ts.map +0 -1
- package/dist/createNewProject.js +0 -38
- package/dist/createNewProject.test.d.ts +0 -2
- package/dist/createNewProject.test.d.ts.map +0 -1
- package/dist/createNewProject.test.js +0 -91
- package/dist/createNodeishFsWithAbsolutePaths.d.ts +0 -12
- package/dist/createNodeishFsWithAbsolutePaths.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.js +0 -38
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts +0 -2
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.test.js +0 -44
- package/dist/createNodeishFsWithWatcher.d.ts +0 -14
- package/dist/createNodeishFsWithWatcher.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.js +0 -75
- package/dist/createNodeishFsWithWatcher.test.d.ts +0 -2
- package/dist/createNodeishFsWithWatcher.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.test.js +0 -38
- package/dist/defaultProjectSettings.d.ts +0 -14
- package/dist/defaultProjectSettings.d.ts.map +0 -1
- package/dist/defaultProjectSettings.js +0 -22
- package/dist/env-variables/index.d.ts +0 -4
- package/dist/env-variables/index.d.ts.map +0 -1
- package/dist/env-variables/index.js +0 -3
- package/dist/errors.d.ts +0 -48
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -62
- package/dist/lint/index.d.ts +0 -3
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -2
- package/dist/lint/message/errors.d.ts +0 -7
- package/dist/lint/message/errors.d.ts.map +0 -1
- package/dist/lint/message/errors.js +0 -9
- package/dist/lint/message/lintMessages.d.ts +0 -13
- package/dist/lint/message/lintMessages.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.js +0 -12
- package/dist/lint/message/lintMessages.test.d.ts +0 -2
- package/dist/lint/message/lintMessages.test.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.test.js +0 -107
- package/dist/lint/message/lintSingleMessage.d.ts +0 -19
- package/dist/lint/message/lintSingleMessage.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.js +0 -38
- package/dist/lint/message/lintSingleMessage.test.d.ts +0 -2
- package/dist/lint/message/lintSingleMessage.test.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.test.js +0 -161
- package/dist/listProjects.d.ts +0 -5
- package/dist/listProjects.d.ts.map +0 -1
- package/dist/listProjects.js +0 -38
- package/dist/listProjects.test.d.ts +0 -2
- package/dist/listProjects.test.d.ts.map +0 -1
- package/dist/listProjects.test.js +0 -72
- package/dist/loadProject.d.ts +0 -19
- package/dist/loadProject.d.ts.map +0 -1
- package/dist/loadProject.js +0 -343
- package/dist/loadProject.test.d.ts.map +0 -1
- package/dist/loadProject.test.js +0 -975
- package/dist/messages/errors.d.ts +0 -13
- package/dist/messages/errors.d.ts.map +0 -1
- package/dist/messages/errors.js +0 -18
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -2
- package/dist/messages/variant.d.ts +0 -46
- package/dist/messages/variant.d.ts.map +0 -1
- package/dist/messages/variant.js +0 -176
- package/dist/messages/variant.test.d.ts +0 -2
- package/dist/messages/variant.test.d.ts.map +0 -1
- package/dist/messages/variant.test.js +0 -439
- package/dist/migrations/maybeAddModuleCache.d.ts +0 -6
- package/dist/migrations/maybeAddModuleCache.d.ts.map +0 -1
- package/dist/migrations/maybeAddModuleCache.js +0 -62
- package/dist/migrations/maybeCreateFirstProjectId.d.ts +0 -16
- package/dist/migrations/maybeCreateFirstProjectId.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.js +0 -46
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts +0 -2
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.test.js +0 -24
- package/dist/migrations/migrateToDirectory.d.ts +0 -10
- package/dist/migrations/migrateToDirectory.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.js +0 -48
- package/dist/migrations/migrateToDirectory.test.d.ts +0 -2
- package/dist/migrations/migrateToDirectory.test.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.test.js +0 -48
- package/dist/parseConfig.d.ts +0 -8
- package/dist/parseConfig.d.ts.map +0 -1
- package/dist/parseConfig.js +0 -26
- package/dist/persistence/batchedIO.d.ts +0 -11
- package/dist/persistence/batchedIO.d.ts.map +0 -1
- package/dist/persistence/batchedIO.js +0 -49
- package/dist/persistence/batchedIO.test.d.ts +0 -2
- package/dist/persistence/batchedIO.test.d.ts.map +0 -1
- package/dist/persistence/batchedIO.test.js +0 -56
- package/dist/persistence/filelock/acquireFileLock.d.ts +0 -3
- package/dist/persistence/filelock/acquireFileLock.d.ts.map +0 -1
- package/dist/persistence/filelock/acquireFileLock.js +0 -111
- package/dist/persistence/filelock/releaseLock.d.ts +0 -3
- package/dist/persistence/filelock/releaseLock.d.ts.map +0 -1
- package/dist/persistence/filelock/releaseLock.js +0 -24
- package/dist/persistence/store.d.ts +0 -107
- package/dist/persistence/store.d.ts.map +0 -1
- package/dist/persistence/store.js +0 -99
- package/dist/persistence/store.test.d.ts +0 -2
- package/dist/persistence/store.test.d.ts.map +0 -1
- package/dist/persistence/store.test.js +0 -79
- package/dist/persistence/storeApi.d.ts +0 -22
- package/dist/persistence/storeApi.d.ts.map +0 -1
- package/dist/persistence/storeApi.js +0 -1
- package/dist/reactivity/map.d.ts +0 -67
- package/dist/reactivity/map.d.ts.map +0 -1
- package/dist/reactivity/map.js +0 -143
- package/dist/reactivity/solid.d.ts +0 -14
- package/dist/reactivity/solid.d.ts.map +0 -1
- package/dist/reactivity/solid.js +0 -15
- package/dist/reactivity/solid.test.d.ts +0 -2
- package/dist/reactivity/solid.test.d.ts.map +0 -1
- package/dist/reactivity/solid.test.js +0 -189
- package/dist/reactivity/trigger.d.ts +0 -11
- package/dist/reactivity/trigger.d.ts.map +0 -1
- package/dist/reactivity/trigger.js +0 -46
- package/dist/resolve-modules/cache.d.ts +0 -6
- package/dist/resolve-modules/cache.d.ts.map +0 -1
- package/dist/resolve-modules/cache.js +0 -58
- package/dist/resolve-modules/errors.d.ts +0 -41
- package/dist/resolve-modules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/errors.js +0 -45
- package/dist/resolve-modules/import.d.ts +0 -19
- package/dist/resolve-modules/import.d.ts.map +0 -1
- package/dist/resolve-modules/import.js +0 -102
- package/dist/resolve-modules/import.test.d.ts +0 -2
- package/dist/resolve-modules/import.test.d.ts.map +0 -1
- package/dist/resolve-modules/import.test.js +0 -47
- package/dist/resolve-modules/index.d.ts +0 -3
- package/dist/resolve-modules/index.d.ts.map +0 -1
- package/dist/resolve-modules/index.js +0 -2
- package/dist/resolve-modules/message-lint-rules/errors.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/errors.js +0 -6
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +0 -24
- package/dist/resolve-modules/plugins/errors.d.ts +0 -33
- package/dist/resolve-modules/plugins/errors.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/errors.js +0 -38
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts +0 -3
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.js +0 -92
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.test.js +0 -252
- package/dist/resolve-modules/plugins/types.d.ts +0 -57
- package/dist/resolve-modules/plugins/types.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.js +0 -1
- package/dist/resolve-modules/plugins/types.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/types.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.test.js +0 -45
- package/dist/resolve-modules/resolveModules.d.ts +0 -3
- package/dist/resolve-modules/resolveModules.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.js +0 -80
- package/dist/resolve-modules/resolveModules.test.d.ts +0 -2
- package/dist/resolve-modules/resolveModules.test.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.test.js +0 -185
- package/dist/resolve-modules/types.d.ts +0 -63
- package/dist/resolve-modules/types.d.ts.map +0 -1
- package/dist/resolve-modules/types.js +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.d.ts +0 -2
- package/dist/resolve-modules/validateModuleSettings.test.d.ts.map +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.js +0 -71
- package/dist/resolve-modules/validatedModuleSettings.d.ts +0 -7
- package/dist/resolve-modules/validatedModuleSettings.d.ts.map +0 -1
- package/dist/resolve-modules/validatedModuleSettings.js +0 -11
- package/dist/storage/helper.d.ts +0 -11
- package/dist/storage/helper.d.ts.map +0 -1
- package/dist/storage/helper.js +0 -63
- package/dist/storage/helpers.test.d.ts +0 -2
- package/dist/storage/helpers.test.d.ts.map +0 -1
- package/dist/storage/helpers.test.js +0 -84
- package/dist/storage/human-id/human-readable-id.d.ts +0 -3
- package/dist/storage/human-id/human-readable-id.d.ts.map +0 -1
- package/dist/storage/human-id/human-readable-id.js +0 -20
- package/dist/storage/human-id/words.d.ts.map +0 -1
- package/dist/storage/human-id/words.test.d.ts.map +0 -1
- package/dist/telemetry/capture.d.ts.map +0 -1
- package/dist/telemetry/capture.js +0 -39
- package/dist/telemetry/groupIdentify.d.ts +0 -13
- package/dist/telemetry/groupIdentify.d.ts.map +0 -1
- package/dist/telemetry/groupIdentify.js +0 -35
- package/dist/test-utilities/createMessage.d.ts +0 -18
- package/dist/test-utilities/createMessage.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.js +0 -17
- package/dist/test-utilities/createMessage.test.d.ts +0 -2
- package/dist/test-utilities/createMessage.test.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.test.js +0 -106
- package/dist/test-utilities/index.d.ts +0 -3
- package/dist/test-utilities/index.d.ts.map +0 -1
- package/dist/test-utilities/index.js +0 -2
- package/dist/test-utilities/sleep.d.ts +0 -4
- package/dist/test-utilities/sleep.d.ts.map +0 -1
- package/dist/test-utilities/sleep.js +0 -9
- package/dist/v2/helper.d.ts +0 -43
- package/dist/v2/helper.d.ts.map +0 -1
- package/dist/v2/helper.js +0 -75
- package/dist/v2/helper.test.d.ts +0 -2
- package/dist/v2/helper.test.d.ts.map +0 -1
- package/dist/v2/helper.test.js +0 -92
- package/dist/v2/index.d.ts +0 -4
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -2
- package/dist/v2/mocks/index.d.ts +0 -3
- package/dist/v2/mocks/index.d.ts.map +0 -1
- package/dist/v2/mocks/index.js +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts +0 -3
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.js +0 -194
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.test.js +0 -10
- package/dist/v2/mocks/plural/bundle.d.ts +0 -3
- package/dist/v2/mocks/plural/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.js +0 -162
- package/dist/v2/mocks/plural/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/plural/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.test.js +0 -15
- package/dist/v2/shim.d.ts +0 -12
- package/dist/v2/shim.d.ts.map +0 -1
- package/dist/v2/shim.js +0 -151
- package/dist/v2/shim.test.d.ts +0 -2
- package/dist/v2/shim.test.d.ts.map +0 -1
- package/dist/v2/shim.test.js +0 -49
- package/dist/v2/stubQueryApi.d.ts +0 -9
- package/dist/v2/stubQueryApi.d.ts.map +0 -1
- package/dist/v2/stubQueryApi.js +0 -38
- package/dist/v2/types.d.ts +0 -521
- package/dist/v2/types.d.ts.map +0 -1
- package/dist/v2/types.js +0 -78
- package/dist/validateProjectPath.d.ts +0 -17
- package/dist/validateProjectPath.d.ts.map +0 -1
- package/dist/validateProjectPath.js +0 -31
- package/dist/validateProjectPath.test.d.ts +0 -2
- package/dist/validateProjectPath.test.d.ts.map +0 -1
- package/dist/validateProjectPath.test.js +0 -40
- package/dist/versionedInterfaces.d.ts +0 -8
- package/dist/versionedInterfaces.d.ts.map +0 -1
- package/dist/versionedInterfaces.js +0 -8
- package/src/adapter/solidAdapter.test.ts +0 -472
- package/src/adapter/solidAdapter.ts +0 -79
- package/src/api.test-d.ts +0 -8
- package/src/api.ts +0 -116
- package/src/createMessageLintReportsQuery.ts +0 -225
- package/src/createMessagesQuery.test.ts +0 -538
- package/src/createMessagesQuery.ts +0 -635
- package/src/createNewProject.test.ts +0 -105
- package/src/createNewProject.ts +0 -46
- package/src/createNodeishFsWithAbsolutePaths.test.ts +0 -55
- package/src/createNodeishFsWithAbsolutePaths.ts +0 -52
- package/src/createNodeishFsWithWatcher.test.ts +0 -50
- package/src/createNodeishFsWithWatcher.ts +0 -85
- package/src/defaultProjectSettings.ts +0 -26
- package/src/env-variables/.prettierignore +0 -1
- package/src/env-variables/createIndexFile.js +0 -28
- package/src/errors.ts +0 -84
- package/src/lint/index.ts +0 -2
- package/src/lint/message/errors.ts +0 -9
- package/src/lint/message/lintMessages.test.ts +0 -126
- package/src/lint/message/lintMessages.ts +0 -25
- package/src/lint/message/lintSingleMessage.test.ts +0 -191
- package/src/lint/message/lintSingleMessage.ts +0 -57
- package/src/listProjects.test.ts +0 -91
- package/src/listProjects.ts +0 -48
- package/src/loadProject.test.ts +0 -1173
- package/src/loadProject.ts +0 -460
- package/src/messages/errors.ts +0 -25
- package/src/messages/index.ts +0 -2
- package/src/messages/variant.test.ts +0 -511
- package/src/messages/variant.ts +0 -247
- package/src/migrations/maybeAddModuleCache.ts +0 -68
- package/src/migrations/maybeCreateFirstProjectId.test.ts +0 -31
- package/src/migrations/maybeCreateFirstProjectId.ts +0 -51
- package/src/migrations/migrateToDirectory.test.ts +0 -54
- package/src/migrations/migrateToDirectory.ts +0 -62
- package/src/parseConfig.ts +0 -35
- package/src/persistence/batchedIO.test.ts +0 -63
- package/src/persistence/batchedIO.ts +0 -64
- package/src/persistence/filelock/acquireFileLock.ts +0 -129
- package/src/persistence/filelock/releaseLock.ts +0 -29
- package/src/persistence/store.test.ts +0 -102
- package/src/persistence/store.ts +0 -119
- package/src/persistence/storeApi.ts +0 -19
- package/src/reactivity/map.ts +0 -135
- package/src/reactivity/solid.test.ts +0 -222
- package/src/reactivity/solid.ts +0 -42
- package/src/reactivity/trigger.ts +0 -46
- package/src/resolve-modules/cache.ts +0 -89
- package/src/resolve-modules/errors.ts +0 -69
- package/src/resolve-modules/import.test.ts +0 -62
- package/src/resolve-modules/import.ts +0 -133
- package/src/resolve-modules/index.ts +0 -2
- package/src/resolve-modules/message-lint-rules/errors.ts +0 -9
- package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +0 -27
- package/src/resolve-modules/plugins/errors.ts +0 -56
- package/src/resolve-modules/plugins/resolvePlugins.test.ts +0 -301
- package/src/resolve-modules/plugins/resolvePlugins.ts +0 -129
- package/src/resolve-modules/plugins/types.test.ts +0 -53
- package/src/resolve-modules/plugins/types.ts +0 -76
- package/src/resolve-modules/resolveModules.test.ts +0 -224
- package/src/resolve-modules/resolveModules.ts +0 -113
- package/src/resolve-modules/types.ts +0 -72
- package/src/resolve-modules/validateModuleSettings.test.ts +0 -85
- package/src/resolve-modules/validatedModuleSettings.ts +0 -19
- package/src/storage/helper.ts +0 -74
- package/src/storage/helpers.test.ts +0 -95
- package/src/storage/human-id/human-readable-id.ts +0 -27
- package/src/telemetry/capture.ts +0 -49
- package/src/telemetry/groupIdentify.ts +0 -41
- package/src/test-utilities/createMessage.test.ts +0 -118
- package/src/test-utilities/createMessage.ts +0 -21
- package/src/test-utilities/index.ts +0 -2
- package/src/test-utilities/sleep.ts +0 -11
- package/src/v2/helper.test.ts +0 -95
- package/src/v2/helper.ts +0 -98
- package/src/v2/index.ts +0 -3
- package/src/v2/mocks/index.ts +0 -2
- package/src/v2/mocks/multipleMatcher/bundle.test.ts +0 -11
- package/src/v2/mocks/multipleMatcher/bundle.ts +0 -196
- package/src/v2/mocks/plural/bundle.test.ts +0 -18
- package/src/v2/mocks/plural/bundle.ts +0 -164
- package/src/v2/shim.test.ts +0 -56
- package/src/v2/shim.ts +0 -173
- package/src/v2/stubQueryApi.ts +0 -43
- package/src/v2/types.ts +0 -159
- package/src/validateProjectPath.test.ts +0 -50
- package/src/validateProjectPath.ts +0 -38
- package/src/versionedInterfaces.ts +0 -9
- /package/dist/{storage/human-id → human-id}/words.d.ts +0 -0
- /package/dist/{storage/human-id → human-id}/words.test.d.ts +0 -0
- /package/dist/{loadProject.test.d.ts → project/loadProject.test.d.ts} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2528caec-29b9-569d-a353-9888c7c50eac")}catch(e){}}();
|
|
3
|
+
import { test, expect, vi } from "vitest";
|
|
4
|
+
import { withCache } from "./cache.js";
|
|
5
|
+
import { newLixFile, openLixInMemory } from "@lix-js/sdk";
|
|
6
|
+
import { sql } from "kysely";
|
|
7
|
+
test("it should be network-first", async () => {
|
|
8
|
+
const mockLoader = vi
|
|
9
|
+
.fn()
|
|
10
|
+
.mockResolvedValueOnce("module content 1")
|
|
11
|
+
.mockResolvedValueOnce("module content 2");
|
|
12
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
13
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
14
|
+
const result1 = await withCache(mockLoader, lix)(mockModulePath);
|
|
15
|
+
expect(mockLoader).toHaveBeenCalledTimes(1);
|
|
16
|
+
expect(result1).toBe("module content 1");
|
|
17
|
+
const cachedPlugins = await lix.db
|
|
18
|
+
.selectFrom("file")
|
|
19
|
+
.selectAll()
|
|
20
|
+
// @ts-expect-error - kysely doesn't know about GLOB
|
|
21
|
+
.where(sql `path GLOB '/cache/plugins/*'`)
|
|
22
|
+
.execute();
|
|
23
|
+
expect(cachedPlugins.length).toBe(1);
|
|
24
|
+
const parsed = new TextDecoder().decode(cachedPlugins[0].data);
|
|
25
|
+
expect(parsed).toBe("module content 1");
|
|
26
|
+
const result2 = await withCache(mockLoader, lix)(mockModulePath);
|
|
27
|
+
expect(mockLoader).toHaveBeenCalledTimes(2);
|
|
28
|
+
expect(result2).toBe("module content 2");
|
|
29
|
+
const cachedPlugins2 = await lix.db
|
|
30
|
+
.selectFrom("file")
|
|
31
|
+
.selectAll()
|
|
32
|
+
// @ts-expect-error - kysely doesn't know about GLOB
|
|
33
|
+
.where(sql `path GLOB '/cache/plugins/*'`)
|
|
34
|
+
.execute();
|
|
35
|
+
expect(cachedPlugins2.length).toBe(1);
|
|
36
|
+
const parsed2 = new TextDecoder().decode(cachedPlugins2[0].data);
|
|
37
|
+
expect(parsed2).toBe("module content 2");
|
|
38
|
+
});
|
|
39
|
+
test("it should throw the error from the loader if the cache does not exist", async () => {
|
|
40
|
+
const mockLoader = vi.fn().mockRejectedValueOnce(new Error("Network error"));
|
|
41
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
42
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
43
|
+
expect(async () => await withCache(mockLoader, lix)(mockModulePath)).rejects.toThrowError("Network error");
|
|
44
|
+
});
|
|
45
|
+
test("it should fallback to the cache if the loader fails", async () => {
|
|
46
|
+
const mockLoader = vi.fn().mockRejectedValueOnce(new Error("Network error"));
|
|
47
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
48
|
+
const mockModuleCachePath = "/cache/plugins/31i1etp0l413h";
|
|
49
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
50
|
+
await lix.db
|
|
51
|
+
.insertInto("file")
|
|
52
|
+
.values({
|
|
53
|
+
path: mockModuleCachePath,
|
|
54
|
+
data: new TextEncoder().encode("cached module content"),
|
|
55
|
+
})
|
|
56
|
+
.execute();
|
|
57
|
+
const result = await withCache(mockLoader, lix)(mockModulePath);
|
|
58
|
+
expect(result).toBe("cached module content");
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=cache.test.js.map
|
|
61
|
+
//# debugId=2528caec-29b9-569d-a353-9888c7c50eac
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.test.js","sources":["plugin/cache.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { withCache } from \"./cache.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\nimport { sql } from \"kysely\";\n\ntest(\"it should be network-first\", async () => {\n\tconst mockLoader = vi\n\t\t.fn()\n\t\t.mockResolvedValueOnce(\"module content 1\")\n\t\t.mockResolvedValueOnce(\"module content 2\");\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result1 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(1);\n\texpect(result1).toBe(\"module content 1\");\n\n\tconst cachedPlugins = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins.length).toBe(1);\n\n\tconst parsed = new TextDecoder().decode(cachedPlugins[0]!.data);\n\n\texpect(parsed).toBe(\"module content 1\");\n\n\tconst result2 = await withCache(mockLoader, lix)(mockModulePath);\n\n\texpect(mockLoader).toHaveBeenCalledTimes(2);\n\texpect(result2).toBe(\"module content 2\");\n\n\tconst cachedPlugins2 = await lix.db\n\t\t.selectFrom(\"file\")\n\t\t.selectAll()\n\t\t// @ts-expect-error - kysely doesn't know about GLOB\n\t\t.where(sql`path GLOB '/cache/plugins/*'`)\n\t\t.execute();\n\n\texpect(cachedPlugins2.length).toBe(1);\n\n\tconst parsed2 = new TextDecoder().decode(cachedPlugins2[0]!.data);\n\n\texpect(parsed2).toBe(\"module content 2\");\n});\n\ntest(\"it should throw the error from the loader if the cache does not exist\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\texpect(\n\t\tasync () => await withCache(mockLoader, lix)(mockModulePath)\n\t).rejects.toThrowError(\"Network error\");\n});\n\ntest(\"it should fallback to the cache if the loader fails\", async () => {\n\tconst mockLoader = vi.fn().mockRejectedValueOnce(new Error(\"Network error\"));\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"cached module content\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await withCache(mockLoader, lix)(mockModulePath);\n\texpect(result).toBe(\"cached module content\");\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC7C,MAAM,UAAU,GAAG,EAAE;SACnB,EAAE,EAAE;SACJ,qBAAqB,CAAC,kBAAkB,CAAC;SACzC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAE5C,MAAM,cAAc,GAAG,4BAA4B,CAAC;IAEpD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAEhE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;IAEjE,MAAM,CAAC,UAAU,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAEzC,MAAM,aAAa,GAAG,MAAM,GAAG,CAAC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CAAC,CAAC,CAAC;IAE7E,MAAM,cAAc,GAAG,4BAA4B,CAAC;IAEpD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAEhE,MAAM,CACL,KAAK,IAAI,EAAE,CAAC,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,cAAc,CAAC,CAC5D,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;AACzC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,qDAAqD,EAAE,KAAK,IAAI,EAAE;IACtE,MAAM,UAAU,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC;IAE7E,MAAM,cAAc,GAAG,4BAA4B,CAAC;IACpD,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;IAE3D,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAEhE,MAAM,GAAG,CAAC,EAAE;SACV,UAAU,CAAC,MAAM,CAAC;SAClB,MAAM,CAAC;QACP,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC;KACvD,CAAC;SACD,OAAO,EAAE,CAAC;IAEZ,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC;IAChE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC","debug_id":"2528caec-29b9-569d-a353-9888c7c50eac"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ValueError } from "@sinclair/typebox/errors";
|
|
2
|
+
export declare class PluginError extends Error {
|
|
3
|
+
readonly plugin: string;
|
|
4
|
+
constructor(message: string, options: {
|
|
5
|
+
plugin: string;
|
|
6
|
+
cause?: Error;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Error when a plugin cannot be imported.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PluginImportError extends PluginError {
|
|
13
|
+
constructor(options: {
|
|
14
|
+
plugin: string;
|
|
15
|
+
cause: Error;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare class PluginSettingsAreInvalidError extends PluginError {
|
|
19
|
+
constructor(options: {
|
|
20
|
+
plugin: string;
|
|
21
|
+
errors: ValueError[];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Error when a plugin does not implement a required function
|
|
26
|
+
*/
|
|
27
|
+
export declare class PluginDoesNotImplementFunctionError extends PluginError {
|
|
28
|
+
constructor(options: {
|
|
29
|
+
plugin: string;
|
|
30
|
+
function: string;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error when a plugin was expected to exist, but doesn't
|
|
35
|
+
*/
|
|
36
|
+
export declare class PluginMissingError extends PluginError {
|
|
37
|
+
constructor(options: {
|
|
38
|
+
plugin: string;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"/","sources":["plugin/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D,qBAAa,WAAY,SAAQ,KAAK;IACrC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAMvE;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;gBACrC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE;CAOrD;AAED,qBAAa,6BAA8B,SAAQ,WAAW;gBACjD,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,EAAE,CAAA;KAAE;CAgB7D;AAED;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,WAAW;gBACvD,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;CAOzD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;gBACtC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;CAIvC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="80038c16-cc9c-5214-8c46-54bb2f3bc458")}catch(e){}}();
|
|
3
|
+
export class PluginError extends Error {
|
|
4
|
+
plugin;
|
|
5
|
+
constructor(message, options) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "PluginError";
|
|
8
|
+
this.plugin = options.plugin;
|
|
9
|
+
this.cause = options.cause;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error when a plugin cannot be imported.
|
|
14
|
+
*/
|
|
15
|
+
export class PluginImportError extends PluginError {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super(`Couldn't import the plugin "${options.plugin}":\n\n${options.cause}`, options);
|
|
18
|
+
this.name = "PluginImportError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class PluginSettingsAreInvalidError extends PluginError {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
super(`The settings of "${options.plugin}" are invalid:\n\n${options.errors
|
|
24
|
+
.map((error) => `Path "${error.path}" with value "${JSON.stringify(error.value, undefined, 2)}": "${error.message}"`)
|
|
25
|
+
.join("\n")}`, options);
|
|
26
|
+
this.name = "PluginSettingsAreInvalidError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Error when a plugin does not implement a required function
|
|
31
|
+
*/
|
|
32
|
+
export class PluginDoesNotImplementFunctionError extends PluginError {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
super(`The plugin "${options.plugin}" does not implement the "${options.function}" function.`, options);
|
|
35
|
+
this.name = "PluginDoesNotImplementFunction";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Error when a plugin was expected to exist, but doesn't
|
|
40
|
+
*/
|
|
41
|
+
export class PluginMissingError extends PluginError {
|
|
42
|
+
constructor(options) {
|
|
43
|
+
super(`The plugin "${options.plugin}" does not exist`, options);
|
|
44
|
+
this.name = "PluginMissingError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=errors.js.map
|
|
48
|
+
//# debugId=80038c16-cc9c-5214-8c46-54bb2f3bc458
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["plugin/errors.ts"],"sourceRoot":"/","sourcesContent":["import type { ValueError } from \"@sinclair/typebox/errors\";\n\nexport class PluginError extends Error {\n\tpublic readonly plugin: string;\n\n\tconstructor(message: string, options: { plugin: string; cause?: Error }) {\n\t\tsuper(message);\n\t\tthis.name = \"PluginError\";\n\t\tthis.plugin = options.plugin;\n\t\tthis.cause = options.cause;\n\t}\n}\n\n/**\n * Error when a plugin cannot be imported.\n */\nexport class PluginImportError extends PluginError {\n\tconstructor(options: { plugin: string; cause: Error }) {\n\t\tsuper(\n\t\t\t`Couldn't import the plugin \"${options.plugin}\":\\n\\n${options.cause}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginImportError\";\n\t}\n}\n\nexport class PluginSettingsAreInvalidError extends PluginError {\n\tconstructor(options: { plugin: string; errors: ValueError[] }) {\n\t\tsuper(\n\t\t\t`The settings of \"${options.plugin}\" are invalid:\\n\\n${options.errors\n\t\t\t\t.map(\n\t\t\t\t\t(error) =>\n\t\t\t\t\t\t`Path \"${error.path}\" with value \"${JSON.stringify(\n\t\t\t\t\t\t\terror.value,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t2\n\t\t\t\t\t\t)}\": \"${error.message}\"`\n\t\t\t\t)\n\t\t\t\t.join(\"\\n\")}`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginSettingsAreInvalidError\";\n\t}\n}\n\n/**\n * Error when a plugin does not implement a required function\n */\nexport class PluginDoesNotImplementFunctionError extends PluginError {\n\tconstructor(options: { plugin: string; function: string }) {\n\t\tsuper(\n\t\t\t`The plugin \"${options.plugin}\" does not implement the \"${options.function}\" function.`,\n\t\t\toptions\n\t\t);\n\t\tthis.name = \"PluginDoesNotImplementFunction\";\n\t}\n}\n\n/**\n * Error when a plugin was expected to exist, but doesn't\n */\nexport class PluginMissingError extends PluginError {\n\tconstructor(options: { plugin: string }) {\n\t\tsuper(`The plugin \"${options.plugin}\" does not exist`, options);\n\t\tthis.name = \"PluginMissingError\";\n\t}\n}\n"],"names":[],"mappings":";;AAEA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACrB,MAAM,CAAS;IAE/B,YAAY,OAAe,EAAE,OAA0C;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IACjD,YAAY,OAAyC;QACpD,KAAK,CACJ,+BAA+B,OAAO,CAAC,MAAM,SAAS,OAAO,CAAC,KAAK,EAAE,EACrE,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD;AAED,MAAM,OAAO,6BAA8B,SAAQ,WAAW;IAC7D,YAAY,OAAiD;QAC5D,KAAK,CACJ,oBAAoB,OAAO,CAAC,MAAM,qBAAqB,OAAO,CAAC,MAAM;aACnE,GAAG,CACH,CAAC,KAAK,EAAE,EAAE,CACT,SAAS,KAAK,CAAC,IAAI,iBAAiB,IAAI,CAAC,SAAS,CACjD,KAAK,CAAC,KAAK,EACX,SAAS,EACT,CAAC,CACD,OAAO,KAAK,CAAC,OAAO,GAAG,CACzB;aACA,IAAI,CAAC,IAAI,CAAC,EAAE,EACd,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC7C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,mCAAoC,SAAQ,WAAW;IACnE,YAAY,OAA6C;QACxD,KAAK,CACJ,eAAe,OAAO,CAAC,MAAM,6BAA6B,OAAO,CAAC,QAAQ,aAAa,EACvF,OAAO,CACP,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC9C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,WAAW;IAClD,YAAY,OAA2B;QACtC,KAAK,CAAC,eAAe,OAAO,CAAC,MAAM,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD","debug_id":"80038c16-cc9c-5214-8c46-54bb2f3bc458"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Lix } from "@lix-js/sdk";
|
|
2
|
+
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
3
|
+
import { PluginError } from "./errors.js";
|
|
4
|
+
import type { InlangPlugin } from "./schema.js";
|
|
5
|
+
/**
|
|
6
|
+
* Function that preprocesses the plugin before importing it.
|
|
7
|
+
*
|
|
8
|
+
* - used by sherlock to convert ESM to CJS
|
|
9
|
+
*/
|
|
10
|
+
export type PreprocessPluginBeforeImportFunction = (moduleText: string) => Promise<string> | string;
|
|
11
|
+
export declare function importPlugins(args: {
|
|
12
|
+
lix: Lix;
|
|
13
|
+
settings: ProjectSettings;
|
|
14
|
+
preprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
plugins: InlangPlugin[];
|
|
17
|
+
errors: PluginError[];
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=importPlugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importPlugins.d.ts","sourceRoot":"/","sources":["plugin/importPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD;;;;GAIG;AACH,MAAM,MAAM,oCAAoC,GAAG,CAClD,UAAU,EAAE,MAAM,KACd,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAE9B,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACzC,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,eAAe,CAAC;IAC1B,4BAA4B,CAAC,EAAE,oCAAoC,CAAC;CACpE,GAAG,OAAO,CAAC;IACX,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,WAAW,EAAE,CAAC;CACtB,CAAC,CAyBD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="922b0ccf-6503-5077-b1ae-ef03acdecbf1")}catch(e){}}();
|
|
3
|
+
import { PluginError, PluginImportError } from "./errors.js";
|
|
4
|
+
import { withCache } from "./cache.js";
|
|
5
|
+
export async function importPlugins(args) {
|
|
6
|
+
const plugins = [];
|
|
7
|
+
const errors = [];
|
|
8
|
+
for (const uri of args.settings.modules ?? []) {
|
|
9
|
+
try {
|
|
10
|
+
let moduleAsText = await withCache(fetchPlugin, args.lix)(uri);
|
|
11
|
+
if (args.preprocessPluginBeforeImport) {
|
|
12
|
+
moduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);
|
|
13
|
+
}
|
|
14
|
+
const moduleWithMimeType = "data:application/javascript," + encodeURIComponent(moduleAsText);
|
|
15
|
+
const { default: module } = await import(
|
|
16
|
+
/* @vite-ignore */ moduleWithMimeType);
|
|
17
|
+
// old legacy message lint rules are not supported
|
|
18
|
+
// and ingored for backwards compatibility
|
|
19
|
+
if (module.id?.includes("messageLintRule")) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
plugins.push(module);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
errors.push(new PluginImportError({ plugin: uri, cause: e }));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { plugins, errors };
|
|
29
|
+
}
|
|
30
|
+
async function fetchPlugin(uri) {
|
|
31
|
+
try {
|
|
32
|
+
const response = await fetch(uri);
|
|
33
|
+
return await response.text();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new PluginImportError({
|
|
37
|
+
plugin: uri,
|
|
38
|
+
cause: error,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=importPlugins.js.map
|
|
43
|
+
//# debugId=922b0ccf-6503-5077-b1ae-ef03acdecbf1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importPlugins.js","sources":["plugin/importPlugins.ts"],"sourceRoot":"/","sourcesContent":["import type { Lix } from \"@lix-js/sdk\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport { PluginError, PluginImportError } from \"./errors.js\";\nimport type { InlangPlugin } from \"./schema.js\";\nimport { withCache } from \"./cache.js\";\n\n/**\n * Function that preprocesses the plugin before importing it.\n *\n * - used by sherlock to convert ESM to CJS\n */\nexport type PreprocessPluginBeforeImportFunction = (\n\tmoduleText: string\n) => Promise<string> | string;\n\nexport async function importPlugins(args: {\n\tlix: Lix;\n\tsettings: ProjectSettings;\n\tpreprocessPluginBeforeImport?: PreprocessPluginBeforeImportFunction;\n}): Promise<{\n\tplugins: InlangPlugin[];\n\terrors: PluginError[];\n}> {\n\tconst plugins: InlangPlugin[] = [];\n\tconst errors: PluginError[] = [];\n\tfor (const uri of args.settings.modules ?? []) {\n\t\ttry {\n\t\t\tlet moduleAsText = await withCache(fetchPlugin, args.lix)(uri);\n\t\t\tif (args.preprocessPluginBeforeImport) {\n\t\t\t\tmoduleAsText = await args.preprocessPluginBeforeImport(moduleAsText);\n\t\t\t}\n\t\t\tconst moduleWithMimeType =\n\t\t\t\t\"data:application/javascript,\" + encodeURIComponent(moduleAsText);\n\t\t\tconst { default: module } = await import(\n\t\t\t\t/* @vite-ignore */ moduleWithMimeType\n\t\t\t);\n\t\t\t// old legacy message lint rules are not supported\n\t\t\t// and ingored for backwards compatibility\n\t\t\tif (module.id?.includes(\"messageLintRule\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tplugins.push(module);\n\t\t} catch (e) {\n\t\t\terrors.push(new PluginImportError({ plugin: uri, cause: e as Error }));\n\t\t}\n\t}\n\treturn { plugins, errors };\n}\n\nasync function fetchPlugin(uri: string): Promise<string> {\n\ttry {\n\t\tconst response = await fetch(uri);\n\t\treturn await response.text();\n\t} catch (error) {\n\t\tthrow new PluginImportError({\n\t\t\tplugin: uri,\n\t\t\tcause: error as Error,\n\t\t});\n\t}\n}\n"],"names":[],"mapp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MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,iBAAiB,CAAC;YAC3B,MAAM,EAAE,GAAG;YACX,KAAK,EAAE,KAAc;SACrB,CAAC,CAAC;IACJ,CAAC;AACF,CAAC","debug_id":"922b0ccf-6503-5077-b1ae-ef03acdecbf1"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importPlugins.test.d.ts","sourceRoot":"/","sources":["plugin/importPlugins.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="df00fa76-3eb4-5842-9f9d-4f593257ee7e")}catch(e){}}();
|
|
3
|
+
import { test, expect, vi } from "vitest";
|
|
4
|
+
import { importPlugins } from "./importPlugins.js";
|
|
5
|
+
import { PluginImportError } from "./errors.js";
|
|
6
|
+
import { newLixFile, openLixInMemory } from "@lix-js/sdk";
|
|
7
|
+
test("it should preprocess a plugin", async () => {
|
|
8
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
9
|
+
ok: true,
|
|
10
|
+
text: vi.fn().mockResolvedValue("export default { key: 'mock' }"),
|
|
11
|
+
});
|
|
12
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
13
|
+
const result = await importPlugins({
|
|
14
|
+
lix,
|
|
15
|
+
settings: {
|
|
16
|
+
baseLocale: "en",
|
|
17
|
+
locales: ["en"],
|
|
18
|
+
modules: ["https://mock.com/module.js"],
|
|
19
|
+
},
|
|
20
|
+
preprocessPluginBeforeImport: async (moduleText) => {
|
|
21
|
+
return moduleText.replace("mock", "preprocessed");
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
25
|
+
expect(result.plugins.length).toBe(1);
|
|
26
|
+
expect(result.errors.length).toBe(0);
|
|
27
|
+
expect(result.plugins[0]?.key).toBe("preprocessed");
|
|
28
|
+
});
|
|
29
|
+
test("if a fetch fails, a plugin import error is expected", async () => {
|
|
30
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
31
|
+
ok: false,
|
|
32
|
+
statusText: "HTTP 404",
|
|
33
|
+
});
|
|
34
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
35
|
+
const result = await importPlugins({
|
|
36
|
+
lix,
|
|
37
|
+
settings: {
|
|
38
|
+
baseLocale: "en",
|
|
39
|
+
locales: ["en"],
|
|
40
|
+
modules: ["https://mock.com/module.js"],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
expect(global.fetch).toHaveBeenCalledTimes(1);
|
|
44
|
+
expect(result.plugins.length).toBe(0);
|
|
45
|
+
expect(result.errors.length).toBe(1);
|
|
46
|
+
expect(result.errors[0]).toBeInstanceOf(PluginImportError);
|
|
47
|
+
});
|
|
48
|
+
test("it should filter message lint rules for legacy reasons", async () => {
|
|
49
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
50
|
+
ok: true,
|
|
51
|
+
text: vi
|
|
52
|
+
.fn()
|
|
53
|
+
.mockResolvedValue("export default { id: 'messageLintRule.something' }"),
|
|
54
|
+
});
|
|
55
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
56
|
+
const result = await importPlugins({
|
|
57
|
+
lix,
|
|
58
|
+
settings: {
|
|
59
|
+
baseLocale: "en",
|
|
60
|
+
locales: ["en"],
|
|
61
|
+
modules: ["https://mock.com/module.js"],
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
expect(result.plugins.length).toBe(0);
|
|
65
|
+
expect(result.errors.length).toBe(0);
|
|
66
|
+
});
|
|
67
|
+
// more tests are found in cache.test.ts
|
|
68
|
+
test("cache should work", async () => {
|
|
69
|
+
global.fetch = vi.fn().mockResolvedValue({
|
|
70
|
+
ok: false,
|
|
71
|
+
});
|
|
72
|
+
const mockModulePath = "https://mock.com/module.js";
|
|
73
|
+
const mockModuleCachePath = "/cache/plugins/31i1etp0l413h";
|
|
74
|
+
const lix = await openLixInMemory({ blob: await newLixFile() });
|
|
75
|
+
await lix.db
|
|
76
|
+
.insertInto("file")
|
|
77
|
+
.values({
|
|
78
|
+
path: mockModuleCachePath,
|
|
79
|
+
data: new TextEncoder().encode("export default { key: 'mock' }"),
|
|
80
|
+
})
|
|
81
|
+
.execute();
|
|
82
|
+
const result = await importPlugins({
|
|
83
|
+
lix,
|
|
84
|
+
settings: {
|
|
85
|
+
baseLocale: "en",
|
|
86
|
+
locales: ["en"],
|
|
87
|
+
modules: [mockModulePath],
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
expect(result.errors).lengthOf(0);
|
|
91
|
+
expect(result.plugins).lengthOf(1);
|
|
92
|
+
expect(result.plugins[0]?.key).toBe("mock");
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=importPlugins.test.js.map
|
|
95
|
+
//# debugId=df00fa76-3eb4-5842-9f9d-4f593257ee7e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importPlugins.test.js","sources":["plugin/importPlugins.test.ts"],"sourceRoot":"/","sourcesContent":["import { test, expect, vi } from \"vitest\";\nimport { importPlugins } from \"./importPlugins.js\";\nimport { PluginImportError } from \"./errors.js\";\nimport { newLixFile, openLixInMemory } from \"@lix-js/sdk\";\n\ntest(\"it should preprocess a plugin\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi.fn().mockResolvedValue(\"export default { key: 'mock' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t\tpreprocessPluginBeforeImport: async (moduleText) => {\n\t\t\treturn moduleText.replace(\"mock\", \"preprocessed\");\n\t\t},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalledTimes(1);\n\texpect(result.plugins.length).toBe(1);\n\texpect(result.errors.length).toBe(0);\n\texpect(result.plugins[0]?.key).toBe(\"preprocessed\");\n});\n\ntest(\"if a fetch fails, a plugin import error is expected\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t\tstatusText: \"HTTP 404\",\n\t});\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(global.fetch).toHaveBeenCalledTimes(1);\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(1);\n\texpect(result.errors[0]).toBeInstanceOf(PluginImportError);\n});\n\ntest(\"it should filter message lint rules for legacy reasons\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: true,\n\t\ttext: vi\n\t\t\t.fn()\n\t\t\t.mockResolvedValue(\"export default { id: 'messageLintRule.something' }\"),\n\t});\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [\"https://mock.com/module.js\"],\n\t\t},\n\t});\n\n\texpect(result.plugins.length).toBe(0);\n\texpect(result.errors.length).toBe(0);\n});\n\n// more tests are found in cache.test.ts\ntest(\"cache should work\", async () => {\n\tglobal.fetch = vi.fn().mockResolvedValue({\n\t\tok: false,\n\t});\n\n\tconst mockModulePath = \"https://mock.com/module.js\";\n\tconst mockModuleCachePath = \"/cache/plugins/31i1etp0l413h\";\n\n\tconst lix = await openLixInMemory({ blob: await newLixFile() });\n\n\tawait lix.db\n\t\t.insertInto(\"file\")\n\t\t.values({\n\t\t\tpath: mockModuleCachePath,\n\t\t\tdata: new TextEncoder().encode(\"export default { key: 'mock' }\"),\n\t\t})\n\t\t.execute();\n\n\tconst result = await importPlugins({\n\t\tlix,\n\t\tsettings: {\n\t\t\tbaseLocale: \"en\",\n\t\t\tlocales: [\"en\"],\n\t\t\tmodules: [mockModulePath],\n\t\t},\n\t});\n\n\texpect(result.errors).lengthOf(0);\n\texpect(result.plugins).lengthOf(1);\n\texpect(result.plugins[0]?.key).toBe(\"mock\");\n});\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE1D,IAAI,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;IAChD,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QACxC,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,gCAAgC,CAAC;KACjE,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,UAAU,EAAE,EAAE,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QAClC,GAAG;QACH,QAAQ,EAAE;YACT,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC,IAAI,CAAC;YACf,OAAO,EAAE,CAAC,4BAA4B,CAAC;SACvC;QACD,4BAA4B,EAAE,KAA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C,CAAC;IAEhE,MAAM,GAAG,CAAC,EAAE;SACV,UAAU,CAAC,MAAM,CAAC;SAClB,MAAM,CAAC;QACP,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gCAAgC,CAAC;KAChE,CAAC;SACD,OAAO,EAAE,CAAC;IAEZ,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QAClC,GAAG;QACH,QAAQ,EAAE;YACT,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC,IAAI,CAAC;YACf,OAAO,EAAE,CAAC,cAAc,CAAC;SACzB;KACD,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC","debug_id":"df00fa76-3eb4-5842-9f9d-4f593257ee7e"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
interface Position {
|
|
2
|
+
line: number;
|
|
3
|
+
character: number;
|
|
4
|
+
}
|
|
5
|
+
interface MessageReferenceMatch {
|
|
6
|
+
bundleId: string;
|
|
7
|
+
position: {
|
|
8
|
+
start: Position;
|
|
9
|
+
end: Position;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface IdeExtensionConfigSchema {
|
|
13
|
+
/**
|
|
14
|
+
* Defines matchers for message references inside the code.
|
|
15
|
+
*
|
|
16
|
+
* @param args - Represents the data to conduct the search on.
|
|
17
|
+
* @returns A promise with matched message references.
|
|
18
|
+
*/
|
|
19
|
+
messageReferenceMatchers: Array<(args: {
|
|
20
|
+
documentText: string;
|
|
21
|
+
}) => Promise<MessageReferenceMatch[]>>;
|
|
22
|
+
/**
|
|
23
|
+
* Defines options to extract messages.
|
|
24
|
+
*/
|
|
25
|
+
extractMessageOptions: Array<{
|
|
26
|
+
/**
|
|
27
|
+
* Function which is called when the user finishes the message extraction command.
|
|
28
|
+
*
|
|
29
|
+
* @param args - Contains messageId and selection.
|
|
30
|
+
* @returns The code which is inserted into the document.
|
|
31
|
+
*/
|
|
32
|
+
callback: (args: {
|
|
33
|
+
bundleId: string;
|
|
34
|
+
selection: string;
|
|
35
|
+
}) => {
|
|
36
|
+
bundleId: string;
|
|
37
|
+
messageReplacement: string;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* An array of Visual Studio Code DocumentSelectors.
|
|
42
|
+
*
|
|
43
|
+
* The document selectors specify for which files/programming languages
|
|
44
|
+
* (typescript, svelte, etc.) the extension should be activated.
|
|
45
|
+
*
|
|
46
|
+
* See https://code.visualstudio.com/api/references/document-selector
|
|
47
|
+
*/
|
|
48
|
+
documentSelectors?: Array<{
|
|
49
|
+
language?: string;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
export type IdeExtensionConfig = IdeExtensionConfigSchema;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=ideExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ideExtension.d.ts","sourceRoot":"/","sources":["plugin/meta/ideExtension.ts"],"names":[],"mappings":"AACA,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAGD,UAAU,qBAAqB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACT,KAAK,EAAE,QAAQ,CAAC;QAChB,GAAG,EAAE,QAAQ,CAAC;KACd,CAAC;CACF;AAGD,UAAU,wBAAwB;IACjC;;;;;OAKG;IACH,wBAAwB,EAAE,KAAK,CAC9B,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,qBAAqB,EAAE,CAAC,CACpE,CAAC;IAEF;;OAEG;IACH,qBAAqB,EAAE,KAAK,CAAC;QAC5B;;;;;WAKG;QACH,QAAQ,EAAE,CAAC,IAAI,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,KAAK;YAC5D,QAAQ,EAAE,MAAM,CAAC;YACjB,kBAAkB,EAAE,MAAM,CAAC;SAC3B,CAAC;KACF,CAAC,CAAC;IAEH;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD;AAGD,MAAM,MAAM,kBAAkB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6b094482-1e1c-5a82-b9ff-edb0247348e7")}catch(e){}}();
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=ideExtension.js.map
|
|
5
|
+
//# debugId=6b094482-1e1c-5a82-b9ff-edb0247348e7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ideExtension.js","sources":["plugin/meta/ideExtension.ts"],"sourceRoot":"/","sourcesContent":["// Basic structure for a position in the document\ninterface Position {\n\tline: number;\n\tcharacter: number;\n}\n\n// Basic structure for a message reference match\ninterface MessageReferenceMatch {\n\tbundleId: string;\n\tposition: {\n\t\tstart: Position;\n\t\tend: Position;\n\t};\n}\n\n// Main IDE extension configuration schema\ninterface IdeExtensionConfigSchema {\n\t/**\n\t * Defines matchers for message references inside the code.\n\t *\n\t * @param args - Represents the data to conduct the search on.\n\t * @returns A promise with matched message references.\n\t */\n\tmessageReferenceMatchers: Array<\n\t\t(args: { documentText: string }) => Promise<MessageReferenceMatch[]>\n\t>;\n\n\t/**\n\t * Defines options to extract messages.\n\t */\n\textractMessageOptions: Array<{\n\t\t/**\n\t\t * Function which is called when the user finishes the message extraction command.\n\t\t *\n\t\t * @param args - Contains messageId and selection.\n\t\t * @returns The code which is inserted into the document.\n\t\t */\n\t\tcallback: (args: { bundleId: string; selection: string }) => {\n\t\t\tbundleId: string;\n\t\t\tmessageReplacement: string;\n\t\t};\n\t}>;\n\n\t/**\n\t * An array of Visual Studio Code DocumentSelectors.\n\t *\n\t * The document selectors specify for which files/programming languages\n\t * (typescript, svelte, etc.) the extension should be activated.\n\t *\n\t * See https://code.visualstudio.com/api/references/document-selector\n\t */\n\tdocumentSelectors?: Array<{ language?: string }>;\n}\n\n// Export the type for external use\nexport type IdeExtensionConfig = IdeExtensionConfigSchema;\n"],"names":[],"mappings":"","debug_id":"6b094482-1e1c-5a82-b9ff-edb0247348e7"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { TObject } from "@sinclair/typebox";
|
|
2
|
+
import type { MessageV1 } from "../json-schema/old-v1-message/schemaV1.js";
|
|
3
|
+
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
4
|
+
import type { Bundle, Message, NewBundle, NewMessage, NewVariant, Variant } from "../database/schema.js";
|
|
5
|
+
import type { ExportFile, ImportFile } from "../project/api.js";
|
|
6
|
+
export type InlangPlugin<ExternalSettings extends Record<string, any> | unknown = unknown> = {
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `key` instead.
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The key of the plugin.
|
|
13
|
+
*/
|
|
14
|
+
key: string;
|
|
15
|
+
settingsSchema?: TObject;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `importFiles` instead.
|
|
18
|
+
*/
|
|
19
|
+
loadMessages?: (args: {
|
|
20
|
+
settings: ProjectSettings;
|
|
21
|
+
nodeishFs: NodeFsPromisesSubsetLegacy;
|
|
22
|
+
}) => Promise<MessageV1[]> | MessageV1[];
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `exportFiles` instead.
|
|
25
|
+
*/
|
|
26
|
+
saveMessages?: (args: {
|
|
27
|
+
messages: MessageV1[];
|
|
28
|
+
settings: ProjectSettings;
|
|
29
|
+
nodeishFs: NodeFsPromisesSubsetLegacy;
|
|
30
|
+
}) => Promise<void> | void;
|
|
31
|
+
/**
|
|
32
|
+
* Files that should be imported by the inlang SDK.
|
|
33
|
+
*
|
|
34
|
+
* - `metadata` is optional and can be used to store additional information
|
|
35
|
+
* that is accessible in `importFiles` via `toBeImportedMetadata`. See
|
|
36
|
+
* https://github.com/opral/inlang-sdk/issues/218 for more info.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
toBeImportedFiles?: (args: {
|
|
40
|
+
settings: ProjectSettings & ExternalSettings;
|
|
41
|
+
}) => MaybePromise<Array<{
|
|
42
|
+
path: string;
|
|
43
|
+
locale: string;
|
|
44
|
+
metadata?: Record<string, any>;
|
|
45
|
+
}>>;
|
|
46
|
+
importFiles?: (args: {
|
|
47
|
+
files: ImportFile[];
|
|
48
|
+
settings: ProjectSettings & ExternalSettings;
|
|
49
|
+
}) => MaybePromise<{
|
|
50
|
+
bundles: BundleImport[];
|
|
51
|
+
messages: MessageImport[];
|
|
52
|
+
variants: VariantImport[];
|
|
53
|
+
}>;
|
|
54
|
+
exportFiles?: (args: {
|
|
55
|
+
bundles: Bundle[];
|
|
56
|
+
messages: Message[];
|
|
57
|
+
variants: Variant[];
|
|
58
|
+
settings: ProjectSettings & ExternalSettings;
|
|
59
|
+
}) => MaybePromise<Array<ExportFile>>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use the `meta` field instead.
|
|
62
|
+
*/
|
|
63
|
+
addCustomApi?: (args: {
|
|
64
|
+
settings: ProjectSettings & ExternalSettings;
|
|
65
|
+
}) => Record<string, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Define app-specific APIs under a `meta` field.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* meta: {
|
|
71
|
+
* "app.inlang.ide-extension": {
|
|
72
|
+
* documentPaths: ["*.json"]
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
*/
|
|
76
|
+
meta?: Record<string, Record<string, unknown>>;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Exposing only a subset to ease mapping of fs functions.
|
|
80
|
+
*
|
|
81
|
+
* https://github.com/opral/inlang-sdk/issues/136
|
|
82
|
+
*/
|
|
83
|
+
export type NodeFsPromisesSubsetLegacy = {
|
|
84
|
+
readFile: ((path: string) => Promise<ArrayBuffer>) | ((path: string, options?: {
|
|
85
|
+
encoding: "utf-8";
|
|
86
|
+
}) => Promise<string>);
|
|
87
|
+
readdir: (path: string) => Promise<string[]>;
|
|
88
|
+
writeFile: (path: string, data: ArrayBuffer | string) => Promise<void>;
|
|
89
|
+
mkdir: (path: string) => Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* A to be imported bundle.
|
|
93
|
+
*/
|
|
94
|
+
export type BundleImport = NewBundle;
|
|
95
|
+
/**
|
|
96
|
+
* A to be imported message.
|
|
97
|
+
*
|
|
98
|
+
* The `id` property is omitted because it is generated by the SDK.
|
|
99
|
+
*/
|
|
100
|
+
export type MessageImport = Omit<NewMessage, "id"> & {
|
|
101
|
+
/**
|
|
102
|
+
* If the id is not provided, the SDK will generate one.
|
|
103
|
+
*/
|
|
104
|
+
id?: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* A to be imported variant.
|
|
108
|
+
*
|
|
109
|
+
* - The `id` and `messageId` properties are omitted because they are generated by the SDK.
|
|
110
|
+
* - The `bundleId` and `locale` properties are added to the import variant to match the variant
|
|
111
|
+
* with a message.
|
|
112
|
+
*/
|
|
113
|
+
export type VariantImport = (NewVariant & {
|
|
114
|
+
/**
|
|
115
|
+
* If the id is not provided, the SDK will generate one.
|
|
116
|
+
*/
|
|
117
|
+
id: string;
|
|
118
|
+
/**
|
|
119
|
+
* If the messageId is not provided, the SDK will match the variant
|
|
120
|
+
* with a message based on the `messageBundleId` and `messageLocale` properties.
|
|
121
|
+
*/
|
|
122
|
+
messageId: string;
|
|
123
|
+
/**
|
|
124
|
+
* Required to match the variant with a message in case the `id` and `messageId` are undefined.
|
|
125
|
+
*/
|
|
126
|
+
messageBundleId?: undefined;
|
|
127
|
+
/**
|
|
128
|
+
* Required to match the variant with a message in case the `id` and `messageId` are undefined.
|
|
129
|
+
*/
|
|
130
|
+
messageLocale?: undefined;
|
|
131
|
+
}) | (Omit<NewVariant, "id" | "messageId"> & {
|
|
132
|
+
/**
|
|
133
|
+
* If the id is not provided, the SDK will generate one.
|
|
134
|
+
*/
|
|
135
|
+
id?: undefined;
|
|
136
|
+
/**
|
|
137
|
+
* If the messageId is not provided, the SDK will match the variant
|
|
138
|
+
* with a message based on the `messageBundleId` and `messageLocale` properties.
|
|
139
|
+
*/
|
|
140
|
+
messageId?: undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Required to match the variant with a message in case the `id` and `messageId` are undefined.
|
|
143
|
+
*/
|
|
144
|
+
messageBundleId: string;
|
|
145
|
+
/**
|
|
146
|
+
* Required to match the variant with a message in case the `id` and `messageId` are undefined.
|
|
147
|
+
*/
|
|
148
|
+
messageLocale: string;
|
|
149
|
+
});
|
|
150
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"/","sources":["plugin/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,KAAK,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AC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC;AAErC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG;IACpD;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACtB,CAAC,UAAU,GAAG;IACd;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;CACzB,CAAC,GACF,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG;IACxC;;OAEG;IACH,EAAE,CAAC,EAAE,SAAS,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEN,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4dbbc1bc-ac41-5301-b32c-65db7bd6cf85")}catch(e){}}();
|
|
3
|
+
export {};
|
|
4
|
+
//# sourceMappingURL=schema.js.map
|
|
5
|
+
//# debugId=4dbbc1bc-ac41-5301-b32c-65db7bd6cf85
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["plugin/schema.ts"],"sourceRoot":"/","sourcesContent":["import type { TObject } from \"@sinclair/typebox\";\nimport type { MessageV1 } from \"../json-schema/old-v1-message/schemaV1.js\";\nimport type { ProjectSettings } from \"../json-schema/settings.js\";\nimport type {\n\tBundle,\n\tMessage,\n\tNewBundle,\n\tNewMessage,\n\tNewVariant,\n\tVariant,\n} from \"../database/schema.js\";\nimport type { ExportFile, ImportFile } from \"../project/api.js\";\n\nexport type InlangPlugin<\n\tExternalSettings extends Record<string, any> | unknown = unknown,\n> = {\n\t/**\n\t * @deprecated Use `key` instead.\n\t */\n\tid?: string;\n\t/**\n\t * The key of the plugin.\n\t */\n\tkey: string;\n\tsettingsSchema?: TObject;\n\t/**\n\t * @deprecated Use `importFiles` instead.\n\t */\n\tloadMessages?: (args: {\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<MessageV1[]> | MessageV1[];\n\t/**\n\t * @deprecated Use `exportFiles` instead.\n\t */\n\tsaveMessages?: (args: {\n\t\tmessages: MessageV1[];\n\t\tsettings: ProjectSettings;\n\t\tnodeishFs: NodeFsPromisesSubsetLegacy;\n\t}) => Promise<void> | void;\n\t/**\n\t * Files that should be imported by the inlang SDK.\n\t *\n\t * - `metadata` is optional and can be used to store additional information\n\t * that is accessible in `importFiles` via `toBeImportedMetadata`. See\n\t * https://github.com/opral/inlang-sdk/issues/218 for more info.\n\t *\n\t */\n\ttoBeImportedFiles?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<\n\t\tArray<{ path: string; locale: string; metadata?: Record<string, any> }>\n\t>;\n\timportFiles?: (args: {\n\t\tfiles: ImportFile[];\n\t\tsettings: ProjectSettings & ExternalSettings; // we expose the settings in case the importFunction needs to access the plugin config\n\t}) => MaybePromise<{\n\t\tbundles: BundleImport[];\n\t\tmessages: MessageImport[];\n\t\tvariants: VariantImport[];\n\t}>;\n\texportFiles?: (args: {\n\t\tbundles: Bundle[];\n\t\tmessages: Message[];\n\t\tvariants: Variant[];\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => MaybePromise<Array<ExportFile>>;\n\t/**\n\t * @deprecated Use the `meta` field instead.\n\t */\n\taddCustomApi?: (args: {\n\t\tsettings: ProjectSettings & ExternalSettings;\n\t}) => Record<string, unknown>;\n\t/**\n\t * Define app-specific APIs under a `meta` field.\n\t *\n\t * @example\n\t * meta: {\n\t * \"app.inlang.ide-extension\": {\n\t * documentPaths: [\"*.json\"]\n\t * }\n\t * }\n\t */\n\tmeta?: Record<string, Record<string, unknown>>;\n};\n\n/**\n * Exposing only a subset to ease mapping of fs functions.\n *\n * https://github.com/opral/inlang-sdk/issues/136\n */\nexport type NodeFsPromisesSubsetLegacy = {\n\treadFile:\n\t\t| ((path: string) => Promise<ArrayBuffer>)\n\t\t| ((path: string, options?: { encoding: \"utf-8\" }) => Promise<string>);\n\treaddir: (path: string) => Promise<string[]>;\n\twriteFile: (path: string, data: ArrayBuffer | string) => Promise<void>;\n\tmkdir: (path: string) => Promise<void>;\n};\n\n/**\n * A to be imported bundle.\n */\nexport type BundleImport = NewBundle;\n\n/**\n * A to be imported message.\n *\n * The `id` property is omitted because it is generated by the SDK.\n */\nexport type MessageImport = Omit<NewMessage, \"id\"> & {\n\t/**\n\t * If the id is not provided, the SDK will generate one.\n\t */\n\tid?: string;\n};\n\n/**\n * A to be imported variant.\n *\n * - The `id` and `messageId` properties are omitted because they are generated by the SDK.\n * - The `bundleId` and `locale` properties are added to the import variant to match the variant\n * with a message.\n */\nexport type VariantImport =\n\t| (NewVariant & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid: string;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale?: undefined;\n\t })\n\t| (Omit<NewVariant, \"id\" | \"messageId\"> & {\n\t\t\t/**\n\t\t\t * If the id is not provided, the SDK will generate one.\n\t\t\t */\n\t\t\tid?: undefined;\n\t\t\t/**\n\t\t\t * If the messageId is not provided, the SDK will match the variant\n\t\t\t * with a message based on the `messageBundleId` and `messageLocale` properties.\n\t\t\t */\n\t\t\tmessageId?: undefined;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageBundleId: string;\n\t\t\t/**\n\t\t\t * Required to match the variant with a message in case the `id` and `messageId` are undefined.\n\t\t\t */\n\t\t\tmessageLocale: string;\n\t });\n\ntype MaybePromise<T> = T | Promise<T>;\n"],"names":[],"mappings":"","debug_id":"4dbbc1bc-ac41-5301-b32c-65db7bd6cf85"}
|