@inlang/sdk 0.36.4 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/database/initDb.d.ts +7 -0
- package/dist/database/initDb.d.ts.map +1 -0
- package/dist/database/initDb.js +36 -0
- package/dist/database/initDb.js.map +1 -0
- package/dist/database/initDbAndSchema.test.d.ts +2 -0
- package/dist/database/initDbAndSchema.test.d.ts.map +1 -0
- package/dist/database/initDbAndSchema.test.js +110 -0
- package/dist/database/initDbAndSchema.test.js.map +1 -0
- package/dist/database/jsonbPlugin.d.ts +20 -0
- package/dist/database/jsonbPlugin.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.js +183 -0
- package/dist/database/jsonbPlugin.js.map +1 -0
- package/dist/database/jsonbPlugin.test.d.ts +2 -0
- package/dist/database/jsonbPlugin.test.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.test.js +119 -0
- package/dist/database/jsonbPlugin.test.js.map +1 -0
- package/dist/database/schema.d.ts +74 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +45 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/helper.d.ts +71 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +91 -0
- package/dist/helper.js.map +1 -0
- package/dist/human-id/human-id.d.ts +3 -0
- package/dist/human-id/human-id.d.ts.map +1 -0
- package/dist/human-id/human-id.js +12 -0
- package/dist/human-id/human-id.js.map +1 -0
- package/dist/human-id/words.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.js +4 -0
- package/dist/human-id/words.js.map +1 -0
- package/dist/human-id/words.test.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.test.js +4 -0
- package/dist/human-id/words.test.js.map +1 -0
- package/dist/import-export/exportFiles.d.ts +11 -0
- package/dist/import-export/exportFiles.d.ts.map +1 -0
- package/dist/import-export/exportFiles.js +26 -0
- package/dist/import-export/exportFiles.js.map +1 -0
- package/dist/import-export/importFiles.d.ts +13 -0
- package/dist/import-export/importFiles.d.ts.map +1 -0
- package/dist/import-export/importFiles.js +124 -0
- package/dist/import-export/importFiles.js.map +1 -0
- package/dist/import-export/importFiles.test.d.ts +2 -0
- package/dist/import-export/importFiles.test.d.ts.map +1 -0
- package/dist/import-export/importFiles.test.js +179 -0
- package/dist/import-export/importFiles.test.js.map +1 -0
- package/dist/import-export/roundtrip.test.d.ts +2 -0
- package/dist/import-export/roundtrip.test.d.ts.map +1 -0
- package/dist/import-export/roundtrip.test.js +273 -0
- package/dist/import-export/roundtrip.test.js.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts +4 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js +58 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -0
- package/dist/index.d.ts +21 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js +84 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts +86 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.js +35 -0
- package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js +67 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -0
- package/dist/json-schema/pattern.d.ts +190 -0
- package/dist/json-schema/pattern.d.ts.map +1 -0
- package/dist/json-schema/pattern.js +43 -0
- package/dist/json-schema/pattern.js.map +1 -0
- package/dist/json-schema/settings.d.ts +31 -0
- package/dist/json-schema/settings.d.ts.map +1 -0
- package/dist/json-schema/settings.js +96 -0
- package/dist/json-schema/settings.js.map +1 -0
- package/dist/json-schema/settings.test-d.d.ts +2 -0
- package/dist/json-schema/settings.test-d.d.ts.map +1 -0
- package/dist/json-schema/settings.test-d.js +20 -0
- package/dist/json-schema/settings.test-d.js.map +1 -0
- package/dist/lix-plugin/applyChanges.d.ts +3 -0
- package/dist/lix-plugin/applyChanges.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.js +127 -0
- package/dist/lix-plugin/applyChanges.js.map +1 -0
- package/dist/lix-plugin/applyChanges.test.d.ts +2 -0
- package/dist/lix-plugin/applyChanges.test.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.test.js +135 -0
- package/dist/lix-plugin/applyChanges.test.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.d.ts +3 -0
- package/dist/lix-plugin/detectConflicts.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.js +47 -0
- package/dist/lix-plugin/detectConflicts.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts +2 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.js +251 -0
- package/dist/lix-plugin/detectConflicts.test.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts +8 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.js +109 -0
- package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts +2 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js +418 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -0
- package/dist/lix-plugin/merge.test.d.ts +2 -0
- package/dist/lix-plugin/merge.test.d.ts.map +1 -0
- package/dist/lix-plugin/merge.test.js +120 -0
- package/dist/lix-plugin/merge.test.js.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts +2 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js +176 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -0
- package/dist/migrations/v2/createMessageV1.d.ts +28 -0
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -0
- package/dist/migrations/v2/createMessageV1.js +31 -0
- package/dist/migrations/v2/createMessageV1.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts +9 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +31 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts +2 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +45 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -0
- package/dist/plugin/cache.d.ts +6 -0
- package/dist/plugin/cache.d.ts.map +1 -0
- package/dist/plugin/cache.js +59 -0
- package/dist/plugin/cache.js.map +1 -0
- package/dist/plugin/cache.test.d.ts +2 -0
- package/dist/plugin/cache.test.d.ts.map +1 -0
- package/dist/plugin/cache.test.js +61 -0
- package/dist/plugin/cache.test.js.map +1 -0
- package/dist/plugin/errors.d.ts +41 -0
- package/dist/plugin/errors.d.ts.map +1 -0
- package/dist/plugin/errors.js +48 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/importPlugins.d.ts +19 -0
- package/dist/plugin/importPlugins.d.ts.map +1 -0
- package/dist/plugin/importPlugins.js +43 -0
- package/dist/plugin/importPlugins.js.map +1 -0
- package/dist/plugin/importPlugins.test.d.ts +2 -0
- package/dist/plugin/importPlugins.test.d.ts.map +1 -0
- package/dist/plugin/importPlugins.test.js +95 -0
- package/dist/plugin/importPlugins.test.js.map +1 -0
- package/dist/plugin/meta/ideExtension.d.ts +54 -0
- package/dist/plugin/meta/ideExtension.d.ts.map +1 -0
- package/dist/plugin/meta/ideExtension.js +5 -0
- package/dist/plugin/meta/ideExtension.js.map +1 -0
- package/dist/plugin/schema.d.ts +152 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/schema.js +5 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/project/api.d.ts +74 -0
- package/dist/project/api.d.ts.map +1 -0
- package/dist/project/api.js +5 -0
- package/dist/project/api.js.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts +14 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.js +87 -0
- package/dist/project/initHandleSaveToLixOnChange.js.map +1 -0
- package/dist/project/loadProject.d.ts +53 -0
- package/dist/project/loadProject.d.ts.map +1 -0
- package/dist/project/loadProject.js +168 -0
- package/dist/project/loadProject.js.map +1 -0
- package/dist/project/loadProject.test.d.ts.map +1 -0
- package/dist/project/loadProject.test.js +146 -0
- package/dist/project/loadProject.test.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.d.ts +77 -0
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.js +584 -0
- package/dist/project/loadProjectFromDirectory.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts +2 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.js +663 -0
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -0
- package/dist/project/loadProjectInMemory.d.ts +8 -0
- package/dist/project/loadProjectInMemory.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.js +32 -0
- package/dist/project/loadProjectInMemory.js.map +1 -0
- package/dist/project/loadProjectInMemory.test.d.ts +2 -0
- package/dist/project/loadProjectInMemory.test.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.test.js +27 -0
- package/dist/project/loadProjectInMemory.test.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.d.ts +15 -0
- package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.js +58 -0
- package/dist/project/maybeCaptureTelemetry.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts +2 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.js +71 -0
- package/dist/project/maybeCaptureTelemetry.test.js.map +1 -0
- package/dist/project/newProject.d.ts +17 -0
- package/dist/project/newProject.d.ts.map +1 -0
- package/dist/project/newProject.js +71 -0
- package/dist/project/newProject.js.map +1 -0
- package/dist/project/newProject.test.d.ts +2 -0
- package/dist/project/newProject.test.d.ts.map +1 -0
- package/dist/project/newProject.test.js +37 -0
- package/dist/project/newProject.test.js.map +1 -0
- package/dist/project/saveProjectToDirectory.d.ts +8 -0
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.js +86 -0
- package/dist/project/saveProjectToDirectory.js.map +1 -0
- package/dist/project/saveProjectToDirectory.test.d.ts +2 -0
- package/dist/project/saveProjectToDirectory.test.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.test.js +245 -0
- package/dist/project/saveProjectToDirectory.test.js.map +1 -0
- package/dist/project/state/id$.d.ts +6 -0
- package/dist/project/state/id$.d.ts.map +1 -0
- package/dist/project/state/id$.js +19 -0
- package/dist/project/state/id$.js.map +1 -0
- package/dist/project/state/id$.test.d.ts +2 -0
- package/dist/project/state/id$.test.d.ts.map +1 -0
- package/dist/project/state/id$.test.js +36 -0
- package/dist/project/state/id$.test.js.map +1 -0
- package/dist/project/state/setSettings.d.ts +7 -0
- package/dist/project/state/setSettings.d.ts.map +1 -0
- package/dist/project/state/setSettings.js +16 -0
- package/dist/project/state/setSettings.js.map +1 -0
- package/dist/project/state/setSettings.test.d.ts +2 -0
- package/dist/project/state/setSettings.test.d.ts.map +1 -0
- package/dist/project/state/setSettings.test.js +58 -0
- package/dist/project/state/setSettings.test.js.map +1 -0
- package/dist/project/state/settings$.d.ts +7 -0
- package/dist/project/state/settings$.d.ts.map +1 -0
- package/dist/project/state/settings$.js +21 -0
- package/dist/project/state/settings$.js.map +1 -0
- package/dist/project/state/settings$.test.d.ts +2 -0
- package/dist/project/state/settings$.test.d.ts.map +1 -0
- package/dist/project/state/settings$.test.js +51 -0
- package/dist/project/state/settings$.test.js.map +1 -0
- package/dist/project/state/state.d.ts +58 -0
- package/dist/project/state/state.d.ts.map +1 -0
- package/dist/project/state/state.js +67 -0
- package/dist/project/state/state.js.map +1 -0
- package/dist/project/state/state.test.d.ts +2 -0
- package/dist/project/state/state.test.d.ts.map +1 -0
- package/dist/project/state/state.test.js +103 -0
- package/dist/project/state/state.test.js.map +1 -0
- package/dist/query-utilities/index.d.ts +5 -0
- package/dist/query-utilities/index.d.ts.map +1 -0
- package/dist/query-utilities/index.js +8 -0
- package/dist/query-utilities/index.js.map +1 -0
- package/dist/query-utilities/insertBundleNested.d.ts +4 -0
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/insertBundleNested.js +39 -0
- package/dist/query-utilities/insertBundleNested.js.map +1 -0
- package/dist/query-utilities/pollQuery.d.ts +14 -0
- package/dist/query-utilities/pollQuery.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.js +22 -0
- package/dist/query-utilities/pollQuery.js.map +1 -0
- package/dist/query-utilities/pollQuery.test.d.ts +2 -0
- package/dist/query-utilities/pollQuery.test.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.test.js +67 -0
- package/dist/query-utilities/pollQuery.test.js.map +1 -0
- package/dist/query-utilities/selectBundleNested.d.ts +107 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/selectBundleNested.js +43 -0
- package/dist/query-utilities/selectBundleNested.js.map +1 -0
- package/dist/query-utilities/updateBundleNested.d.ts +12 -0
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/updateBundleNested.js +25 -0
- package/dist/query-utilities/updateBundleNested.js.map +1 -0
- package/dist/query-utilities/upsertBundleNested.d.ts +4 -0
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/upsertBundleNested.js +50 -0
- package/dist/query-utilities/upsertBundleNested.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +6 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +9 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/error-reporting/index.d.ts +15 -0
- package/dist/services/error-reporting/index.d.ts.map +1 -0
- package/dist/services/error-reporting/index.js +30 -0
- package/dist/services/error-reporting/index.js.map +1 -0
- package/dist/{telemetry → services/telemetry}/capture.d.ts +5 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +76 -0
- package/dist/services/telemetry/capture.js.map +1 -0
- package/dist/services/telemetry/capture.test.d.ts +2 -0
- package/dist/services/telemetry/capture.test.d.ts.map +1 -0
- package/dist/services/telemetry/capture.test.js +46 -0
- package/dist/services/telemetry/capture.test.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.d.ts +11 -0
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.js +83 -0
- package/dist/utilities/detectJsonFormatting.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts +2 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.js +33 -0
- package/dist/utilities/detectJsonFormatting.test.js.map +1 -0
- package/package.json +32 -40
- package/src/database/initDb.ts +34 -0
- package/src/database/initDbAndSchema.test.ts +125 -0
- package/src/database/jsonbPlugin.test.ts +154 -0
- package/src/database/jsonbPlugin.ts +215 -0
- package/src/database/schema.ts +127 -0
- package/src/helper.ts +113 -0
- package/src/human-id/human-id.ts +14 -0
- package/src/{storage/human-id → human-id}/words.test.ts +14 -14
- package/src/{storage/human-id → human-id}/words.ts +4 -4
- package/src/import-export/exportFiles.ts +36 -0
- package/src/import-export/importFiles.test.ts +211 -0
- package/src/import-export/importFiles.ts +142 -0
- package/src/import-export/roundtrip.test.ts +313 -0
- package/src/import-export/upsertBundleNestedMatchByProperties.ts +74 -0
- package/src/index.ts +29 -37
- package/src/json-schema/old-v1-message/README.md +1 -0
- package/src/json-schema/old-v1-message/fromMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/fromMessageV1.ts +99 -0
- package/src/json-schema/old-v1-message/schemaV1.ts +66 -0
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +79 -0
- package/src/json-schema/pattern.ts +59 -0
- package/src/json-schema/settings.test-d.ts +21 -0
- package/src/json-schema/settings.ts +138 -0
- package/src/lix-plugin/applyChanges.test.ts +150 -0
- package/src/lix-plugin/applyChanges.ts +171 -0
- package/src/lix-plugin/detectConflicts.test.ts +286 -0
- package/src/lix-plugin/detectConflicts.ts +62 -0
- package/src/lix-plugin/inlangLixPluginV1.test.ts +439 -0
- package/src/lix-plugin/inlangLixPluginV1.ts +132 -0
- package/src/lix-plugin/merge.test.ts +133 -0
- package/src/lix-plugin/resolveConflictBySelecting.test.ts +188 -0
- package/src/migrations/v2/createMessageV1.ts +37 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.test.ts +51 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.ts +31 -0
- package/src/plugin/cache.test.ts +83 -0
- package/src/plugin/cache.ts +79 -0
- package/src/plugin/errors.ts +67 -0
- package/src/plugin/importPlugins.test.ts +107 -0
- package/src/plugin/importPlugins.ts +60 -0
- package/src/plugin/meta/ideExtension.ts +56 -0
- package/src/plugin/schema.ts +165 -0
- package/src/project/api.ts +77 -0
- package/src/project/initHandleSaveToLixOnChange.ts +93 -0
- package/src/project/loadProject.test.ts +176 -0
- package/src/project/loadProject.ts +246 -0
- package/src/project/loadProjectFromDirectory.test.ts +854 -0
- package/src/project/loadProjectFromDirectory.ts +752 -0
- package/src/project/loadProjectInMemory.test.ts +29 -0
- package/src/project/loadProjectInMemory.ts +36 -0
- package/src/project/maybeCaptureTelemetry.test.ts +79 -0
- package/src/project/maybeCaptureTelemetry.ts +69 -0
- package/src/project/newProject.test.ts +36 -0
- package/src/project/newProject.ts +78 -0
- package/src/project/saveProjectToDirectory.test.ts +310 -0
- package/src/project/saveProjectToDirectory.ts +100 -0
- package/src/query-utilities/index.ts +4 -0
- package/src/query-utilities/insertBundleNested.ts +46 -0
- package/src/query-utilities/selectBundleNested.ts +46 -0
- package/src/query-utilities/updateBundleNested.ts +35 -0
- package/src/query-utilities/upsertBundleNested.ts +61 -0
- package/src/services/env-variables/createIndexFile.js +40 -0
- package/src/{env-variables → services/env-variables}/index.d.ts +8 -5
- package/src/services/error-reporting/index.ts +28 -0
- package/src/services/telemetry/capture.test.ts +50 -0
- package/src/services/telemetry/capture.ts +99 -0
- package/src/utilities/detectJsonFormatting.test.ts +38 -0
- package/src/utilities/detectJsonFormatting.ts +109 -0
- package/dist/adapter/solidAdapter.d.ts +0 -33
- package/dist/adapter/solidAdapter.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.js +0 -40
- package/dist/adapter/solidAdapter.test.d.ts +0 -2
- package/dist/adapter/solidAdapter.test.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.test.js +0 -356
- package/dist/api.d.ts +0 -113
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -1
- package/dist/api.test-d.d.ts +0 -2
- package/dist/api.test-d.d.ts.map +0 -1
- package/dist/api.test-d.js +0 -4
- package/dist/createMessageLintReportsQuery.d.ts +0 -12
- package/dist/createMessageLintReportsQuery.d.ts.map +0 -1
- package/dist/createMessageLintReportsQuery.js +0 -176
- package/dist/createMessagesQuery.d.ts +0 -19
- package/dist/createMessagesQuery.d.ts.map +0 -1
- package/dist/createMessagesQuery.js +0 -451
- package/dist/createMessagesQuery.test.d.ts +0 -2
- package/dist/createMessagesQuery.test.d.ts.map +0 -1
- package/dist/createMessagesQuery.test.js +0 -402
- package/dist/createNewProject.d.ts +0 -12
- package/dist/createNewProject.d.ts.map +0 -1
- package/dist/createNewProject.js +0 -38
- package/dist/createNewProject.test.d.ts +0 -2
- package/dist/createNewProject.test.d.ts.map +0 -1
- package/dist/createNewProject.test.js +0 -91
- package/dist/createNodeishFsWithAbsolutePaths.d.ts +0 -12
- package/dist/createNodeishFsWithAbsolutePaths.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.js +0 -38
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts +0 -2
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.test.js +0 -44
- package/dist/createNodeishFsWithWatcher.d.ts +0 -14
- package/dist/createNodeishFsWithWatcher.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.js +0 -75
- package/dist/createNodeishFsWithWatcher.test.d.ts +0 -2
- package/dist/createNodeishFsWithWatcher.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.test.js +0 -38
- package/dist/defaultProjectSettings.d.ts +0 -14
- package/dist/defaultProjectSettings.d.ts.map +0 -1
- package/dist/defaultProjectSettings.js +0 -22
- package/dist/env-variables/index.d.ts +0 -4
- package/dist/env-variables/index.d.ts.map +0 -1
- package/dist/env-variables/index.js +0 -3
- package/dist/errors.d.ts +0 -48
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -62
- package/dist/lint/index.d.ts +0 -3
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -2
- package/dist/lint/message/errors.d.ts +0 -7
- package/dist/lint/message/errors.d.ts.map +0 -1
- package/dist/lint/message/errors.js +0 -9
- package/dist/lint/message/lintMessages.d.ts +0 -13
- package/dist/lint/message/lintMessages.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.js +0 -12
- package/dist/lint/message/lintMessages.test.d.ts +0 -2
- package/dist/lint/message/lintMessages.test.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.test.js +0 -107
- package/dist/lint/message/lintSingleMessage.d.ts +0 -19
- package/dist/lint/message/lintSingleMessage.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.js +0 -38
- package/dist/lint/message/lintSingleMessage.test.d.ts +0 -2
- package/dist/lint/message/lintSingleMessage.test.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.test.js +0 -161
- package/dist/listProjects.d.ts +0 -5
- package/dist/listProjects.d.ts.map +0 -1
- package/dist/listProjects.js +0 -38
- package/dist/listProjects.test.d.ts +0 -2
- package/dist/listProjects.test.d.ts.map +0 -1
- package/dist/listProjects.test.js +0 -72
- package/dist/loadProject.d.ts +0 -19
- package/dist/loadProject.d.ts.map +0 -1
- package/dist/loadProject.js +0 -343
- package/dist/loadProject.test.d.ts.map +0 -1
- package/dist/loadProject.test.js +0 -975
- package/dist/messages/errors.d.ts +0 -13
- package/dist/messages/errors.d.ts.map +0 -1
- package/dist/messages/errors.js +0 -18
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -2
- package/dist/messages/variant.d.ts +0 -46
- package/dist/messages/variant.d.ts.map +0 -1
- package/dist/messages/variant.js +0 -176
- package/dist/messages/variant.test.d.ts +0 -2
- package/dist/messages/variant.test.d.ts.map +0 -1
- package/dist/messages/variant.test.js +0 -439
- package/dist/migrations/maybeAddModuleCache.d.ts +0 -6
- package/dist/migrations/maybeAddModuleCache.d.ts.map +0 -1
- package/dist/migrations/maybeAddModuleCache.js +0 -62
- package/dist/migrations/maybeCreateFirstProjectId.d.ts +0 -16
- package/dist/migrations/maybeCreateFirstProjectId.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.js +0 -46
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts +0 -2
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.test.js +0 -24
- package/dist/migrations/migrateToDirectory.d.ts +0 -10
- package/dist/migrations/migrateToDirectory.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.js +0 -48
- package/dist/migrations/migrateToDirectory.test.d.ts +0 -2
- package/dist/migrations/migrateToDirectory.test.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.test.js +0 -48
- package/dist/parseConfig.d.ts +0 -8
- package/dist/parseConfig.d.ts.map +0 -1
- package/dist/parseConfig.js +0 -26
- package/dist/persistence/batchedIO.d.ts +0 -11
- package/dist/persistence/batchedIO.d.ts.map +0 -1
- package/dist/persistence/batchedIO.js +0 -49
- package/dist/persistence/batchedIO.test.d.ts +0 -2
- package/dist/persistence/batchedIO.test.d.ts.map +0 -1
- package/dist/persistence/batchedIO.test.js +0 -56
- package/dist/persistence/filelock/acquireFileLock.d.ts +0 -3
- package/dist/persistence/filelock/acquireFileLock.d.ts.map +0 -1
- package/dist/persistence/filelock/acquireFileLock.js +0 -111
- package/dist/persistence/filelock/releaseLock.d.ts +0 -3
- package/dist/persistence/filelock/releaseLock.d.ts.map +0 -1
- package/dist/persistence/filelock/releaseLock.js +0 -24
- package/dist/persistence/store.d.ts +0 -107
- package/dist/persistence/store.d.ts.map +0 -1
- package/dist/persistence/store.js +0 -99
- package/dist/persistence/store.test.d.ts +0 -2
- package/dist/persistence/store.test.d.ts.map +0 -1
- package/dist/persistence/store.test.js +0 -79
- package/dist/persistence/storeApi.d.ts +0 -22
- package/dist/persistence/storeApi.d.ts.map +0 -1
- package/dist/persistence/storeApi.js +0 -1
- package/dist/reactivity/map.d.ts +0 -67
- package/dist/reactivity/map.d.ts.map +0 -1
- package/dist/reactivity/map.js +0 -143
- package/dist/reactivity/solid.d.ts +0 -14
- package/dist/reactivity/solid.d.ts.map +0 -1
- package/dist/reactivity/solid.js +0 -15
- package/dist/reactivity/solid.test.d.ts +0 -2
- package/dist/reactivity/solid.test.d.ts.map +0 -1
- package/dist/reactivity/solid.test.js +0 -189
- package/dist/reactivity/trigger.d.ts +0 -11
- package/dist/reactivity/trigger.d.ts.map +0 -1
- package/dist/reactivity/trigger.js +0 -46
- package/dist/resolve-modules/cache.d.ts +0 -6
- package/dist/resolve-modules/cache.d.ts.map +0 -1
- package/dist/resolve-modules/cache.js +0 -58
- package/dist/resolve-modules/errors.d.ts +0 -41
- package/dist/resolve-modules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/errors.js +0 -45
- package/dist/resolve-modules/import.d.ts +0 -19
- package/dist/resolve-modules/import.d.ts.map +0 -1
- package/dist/resolve-modules/import.js +0 -102
- package/dist/resolve-modules/import.test.d.ts +0 -2
- package/dist/resolve-modules/import.test.d.ts.map +0 -1
- package/dist/resolve-modules/import.test.js +0 -47
- package/dist/resolve-modules/index.d.ts +0 -3
- package/dist/resolve-modules/index.d.ts.map +0 -1
- package/dist/resolve-modules/index.js +0 -2
- package/dist/resolve-modules/message-lint-rules/errors.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/errors.js +0 -6
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +0 -24
- package/dist/resolve-modules/plugins/errors.d.ts +0 -33
- package/dist/resolve-modules/plugins/errors.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/errors.js +0 -38
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts +0 -3
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.js +0 -92
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.test.js +0 -252
- package/dist/resolve-modules/plugins/types.d.ts +0 -57
- package/dist/resolve-modules/plugins/types.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.js +0 -1
- package/dist/resolve-modules/plugins/types.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/types.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.test.js +0 -45
- package/dist/resolve-modules/resolveModules.d.ts +0 -3
- package/dist/resolve-modules/resolveModules.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.js +0 -80
- package/dist/resolve-modules/resolveModules.test.d.ts +0 -2
- package/dist/resolve-modules/resolveModules.test.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.test.js +0 -185
- package/dist/resolve-modules/types.d.ts +0 -63
- package/dist/resolve-modules/types.d.ts.map +0 -1
- package/dist/resolve-modules/types.js +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.d.ts +0 -2
- package/dist/resolve-modules/validateModuleSettings.test.d.ts.map +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.js +0 -71
- package/dist/resolve-modules/validatedModuleSettings.d.ts +0 -7
- package/dist/resolve-modules/validatedModuleSettings.d.ts.map +0 -1
- package/dist/resolve-modules/validatedModuleSettings.js +0 -11
- package/dist/storage/helper.d.ts +0 -11
- package/dist/storage/helper.d.ts.map +0 -1
- package/dist/storage/helper.js +0 -63
- package/dist/storage/helpers.test.d.ts +0 -2
- package/dist/storage/helpers.test.d.ts.map +0 -1
- package/dist/storage/helpers.test.js +0 -84
- package/dist/storage/human-id/human-readable-id.d.ts +0 -3
- package/dist/storage/human-id/human-readable-id.d.ts.map +0 -1
- package/dist/storage/human-id/human-readable-id.js +0 -20
- package/dist/storage/human-id/words.d.ts.map +0 -1
- package/dist/storage/human-id/words.test.d.ts.map +0 -1
- package/dist/telemetry/capture.d.ts.map +0 -1
- package/dist/telemetry/capture.js +0 -39
- package/dist/telemetry/groupIdentify.d.ts +0 -13
- package/dist/telemetry/groupIdentify.d.ts.map +0 -1
- package/dist/telemetry/groupIdentify.js +0 -35
- package/dist/test-utilities/createMessage.d.ts +0 -18
- package/dist/test-utilities/createMessage.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.js +0 -17
- package/dist/test-utilities/createMessage.test.d.ts +0 -2
- package/dist/test-utilities/createMessage.test.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.test.js +0 -106
- package/dist/test-utilities/index.d.ts +0 -3
- package/dist/test-utilities/index.d.ts.map +0 -1
- package/dist/test-utilities/index.js +0 -2
- package/dist/test-utilities/sleep.d.ts +0 -4
- package/dist/test-utilities/sleep.d.ts.map +0 -1
- package/dist/test-utilities/sleep.js +0 -9
- package/dist/v2/helper.d.ts +0 -43
- package/dist/v2/helper.d.ts.map +0 -1
- package/dist/v2/helper.js +0 -75
- package/dist/v2/helper.test.d.ts +0 -2
- package/dist/v2/helper.test.d.ts.map +0 -1
- package/dist/v2/helper.test.js +0 -92
- package/dist/v2/index.d.ts +0 -4
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -2
- package/dist/v2/mocks/index.d.ts +0 -3
- package/dist/v2/mocks/index.d.ts.map +0 -1
- package/dist/v2/mocks/index.js +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts +0 -3
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.js +0 -194
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.test.js +0 -10
- package/dist/v2/mocks/plural/bundle.d.ts +0 -3
- package/dist/v2/mocks/plural/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.js +0 -162
- package/dist/v2/mocks/plural/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/plural/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.test.js +0 -15
- package/dist/v2/shim.d.ts +0 -12
- package/dist/v2/shim.d.ts.map +0 -1
- package/dist/v2/shim.js +0 -151
- package/dist/v2/shim.test.d.ts +0 -2
- package/dist/v2/shim.test.d.ts.map +0 -1
- package/dist/v2/shim.test.js +0 -49
- package/dist/v2/stubQueryApi.d.ts +0 -9
- package/dist/v2/stubQueryApi.d.ts.map +0 -1
- package/dist/v2/stubQueryApi.js +0 -38
- package/dist/v2/types.d.ts +0 -521
- package/dist/v2/types.d.ts.map +0 -1
- package/dist/v2/types.js +0 -78
- package/dist/validateProjectPath.d.ts +0 -17
- package/dist/validateProjectPath.d.ts.map +0 -1
- package/dist/validateProjectPath.js +0 -31
- package/dist/validateProjectPath.test.d.ts +0 -2
- package/dist/validateProjectPath.test.d.ts.map +0 -1
- package/dist/validateProjectPath.test.js +0 -40
- package/dist/versionedInterfaces.d.ts +0 -8
- package/dist/versionedInterfaces.d.ts.map +0 -1
- package/dist/versionedInterfaces.js +0 -8
- package/src/adapter/solidAdapter.test.ts +0 -472
- package/src/adapter/solidAdapter.ts +0 -79
- package/src/api.test-d.ts +0 -8
- package/src/api.ts +0 -116
- package/src/createMessageLintReportsQuery.ts +0 -225
- package/src/createMessagesQuery.test.ts +0 -538
- package/src/createMessagesQuery.ts +0 -635
- package/src/createNewProject.test.ts +0 -105
- package/src/createNewProject.ts +0 -46
- package/src/createNodeishFsWithAbsolutePaths.test.ts +0 -55
- package/src/createNodeishFsWithAbsolutePaths.ts +0 -52
- package/src/createNodeishFsWithWatcher.test.ts +0 -50
- package/src/createNodeishFsWithWatcher.ts +0 -85
- package/src/defaultProjectSettings.ts +0 -26
- package/src/env-variables/.prettierignore +0 -1
- package/src/env-variables/createIndexFile.js +0 -28
- package/src/errors.ts +0 -84
- package/src/lint/index.ts +0 -2
- package/src/lint/message/errors.ts +0 -9
- package/src/lint/message/lintMessages.test.ts +0 -126
- package/src/lint/message/lintMessages.ts +0 -25
- package/src/lint/message/lintSingleMessage.test.ts +0 -191
- package/src/lint/message/lintSingleMessage.ts +0 -57
- package/src/listProjects.test.ts +0 -91
- package/src/listProjects.ts +0 -48
- package/src/loadProject.test.ts +0 -1173
- package/src/loadProject.ts +0 -460
- package/src/messages/errors.ts +0 -25
- package/src/messages/index.ts +0 -2
- package/src/messages/variant.test.ts +0 -511
- package/src/messages/variant.ts +0 -247
- package/src/migrations/maybeAddModuleCache.ts +0 -68
- package/src/migrations/maybeCreateFirstProjectId.test.ts +0 -31
- package/src/migrations/maybeCreateFirstProjectId.ts +0 -51
- package/src/migrations/migrateToDirectory.test.ts +0 -54
- package/src/migrations/migrateToDirectory.ts +0 -62
- package/src/parseConfig.ts +0 -35
- package/src/persistence/batchedIO.test.ts +0 -63
- package/src/persistence/batchedIO.ts +0 -64
- package/src/persistence/filelock/acquireFileLock.ts +0 -129
- package/src/persistence/filelock/releaseLock.ts +0 -29
- package/src/persistence/store.test.ts +0 -102
- package/src/persistence/store.ts +0 -119
- package/src/persistence/storeApi.ts +0 -19
- package/src/reactivity/map.ts +0 -135
- package/src/reactivity/solid.test.ts +0 -222
- package/src/reactivity/solid.ts +0 -42
- package/src/reactivity/trigger.ts +0 -46
- package/src/resolve-modules/cache.ts +0 -89
- package/src/resolve-modules/errors.ts +0 -69
- package/src/resolve-modules/import.test.ts +0 -62
- package/src/resolve-modules/import.ts +0 -133
- package/src/resolve-modules/index.ts +0 -2
- package/src/resolve-modules/message-lint-rules/errors.ts +0 -9
- package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +0 -27
- package/src/resolve-modules/plugins/errors.ts +0 -56
- package/src/resolve-modules/plugins/resolvePlugins.test.ts +0 -301
- package/src/resolve-modules/plugins/resolvePlugins.ts +0 -129
- package/src/resolve-modules/plugins/types.test.ts +0 -53
- package/src/resolve-modules/plugins/types.ts +0 -76
- package/src/resolve-modules/resolveModules.test.ts +0 -224
- package/src/resolve-modules/resolveModules.ts +0 -113
- package/src/resolve-modules/types.ts +0 -72
- package/src/resolve-modules/validateModuleSettings.test.ts +0 -85
- package/src/resolve-modules/validatedModuleSettings.ts +0 -19
- package/src/storage/helper.ts +0 -74
- package/src/storage/helpers.test.ts +0 -95
- package/src/storage/human-id/human-readable-id.ts +0 -27
- package/src/telemetry/capture.ts +0 -49
- package/src/telemetry/groupIdentify.ts +0 -41
- package/src/test-utilities/createMessage.test.ts +0 -118
- package/src/test-utilities/createMessage.ts +0 -21
- package/src/test-utilities/index.ts +0 -2
- package/src/test-utilities/sleep.ts +0 -11
- package/src/v2/helper.test.ts +0 -95
- package/src/v2/helper.ts +0 -98
- package/src/v2/index.ts +0 -3
- package/src/v2/mocks/index.ts +0 -2
- package/src/v2/mocks/multipleMatcher/bundle.test.ts +0 -11
- package/src/v2/mocks/multipleMatcher/bundle.ts +0 -196
- package/src/v2/mocks/plural/bundle.test.ts +0 -18
- package/src/v2/mocks/plural/bundle.ts +0 -164
- package/src/v2/shim.test.ts +0 -56
- package/src/v2/shim.ts +0 -173
- package/src/v2/stubQueryApi.ts +0 -43
- package/src/v2/types.ts +0 -159
- package/src/validateProjectPath.test.ts +0 -50
- package/src/validateProjectPath.ts +0 -38
- package/src/versionedInterfaces.ts +0 -9
- /package/dist/{storage/human-id → human-id}/words.d.ts +0 -0
- /package/dist/{storage/human-id → human-id}/words.test.d.ts +0 -0
- /package/dist/{loadProject.test.d.ts → project/loadProject.test.d.ts} +0 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OperationNodeTransformer,
|
|
3
|
+
sql,
|
|
4
|
+
ValueListNode,
|
|
5
|
+
ValueNode,
|
|
6
|
+
ValuesNode,
|
|
7
|
+
ParseJSONResultsPlugin,
|
|
8
|
+
type KyselyPlugin,
|
|
9
|
+
type PluginTransformQueryArgs,
|
|
10
|
+
type PluginTransformResultArgs,
|
|
11
|
+
type QueryResult,
|
|
12
|
+
type RootOperationNode,
|
|
13
|
+
type UnknownRow,
|
|
14
|
+
OnConflictNode,
|
|
15
|
+
} from "kysely";
|
|
16
|
+
import type { SqliteDatabase } from "sqlite-wasm-kysely";
|
|
17
|
+
|
|
18
|
+
export class JsonbPlugin implements KyselyPlugin {
|
|
19
|
+
#serializeJsonTransformer = new SerializeJsonbTransformer();
|
|
20
|
+
#parseJsonPlugin = new ParseJSONResultsPlugin();
|
|
21
|
+
#database: SqliteDatabase;
|
|
22
|
+
|
|
23
|
+
constructor(args: { database: SqliteDatabase }) {
|
|
24
|
+
this.#database = args.database;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* For an outgoing query like insert or update, the JSON
|
|
29
|
+
* values are transformed into `jsonb` function calls when
|
|
30
|
+
* executed against the database.
|
|
31
|
+
*/
|
|
32
|
+
transformQuery(args: PluginTransformQueryArgs): RootOperationNode {
|
|
33
|
+
if (
|
|
34
|
+
args.node.kind === "InsertQueryNode" ||
|
|
35
|
+
args.node.kind === "UpdateQueryNode"
|
|
36
|
+
) {
|
|
37
|
+
const result = this.#serializeJsonTransformer.transformNode(args.node);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
return args.node;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* For incoming query results, the JSON binaries are parsed
|
|
45
|
+
* into JSON objects.
|
|
46
|
+
*/
|
|
47
|
+
async transformResult(
|
|
48
|
+
args: PluginTransformResultArgs
|
|
49
|
+
): Promise<QueryResult<UnknownRow>> {
|
|
50
|
+
for (const row of args.result.rows) {
|
|
51
|
+
for (const key in row) {
|
|
52
|
+
if (
|
|
53
|
+
row[key] instanceof ArrayBuffer ||
|
|
54
|
+
// uint8array, etc
|
|
55
|
+
ArrayBuffer.isView(row[key])
|
|
56
|
+
) {
|
|
57
|
+
try {
|
|
58
|
+
const res = this.#database.exec(`SELECT json(?)`, {
|
|
59
|
+
returnValue: "resultRows",
|
|
60
|
+
bind: [row[key] as any],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
row[key] = JSON.parse(res[0] as any);
|
|
64
|
+
} catch {
|
|
65
|
+
// it's not a json binary
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// in case it's a regular (text) json, run it through kyseley's json parser
|
|
71
|
+
return this.#parseJsonPlugin.transformResult(args);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class SerializeJsonbTransformer extends OperationNodeTransformer {
|
|
76
|
+
protected override transformOnConflict(node: OnConflictNode): OnConflictNode {
|
|
77
|
+
return super.transformOnConflict({
|
|
78
|
+
...node,
|
|
79
|
+
updates: node.updates?.map((updateItem) => {
|
|
80
|
+
if (updateItem.kind !== "ColumnUpdateNode") {
|
|
81
|
+
return updateItem;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
kind: "ColumnUpdateNode",
|
|
85
|
+
column: updateItem.column,
|
|
86
|
+
// @ts-expect-error - we know that the value is a ValueNode
|
|
87
|
+
value: this.transformValue(updateItem.value),
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected override transformValue(node: ValueNode): ValueNode {
|
|
94
|
+
const { value } = node;
|
|
95
|
+
const serializedValue = maybeSerializeJson(value);
|
|
96
|
+
if (value === serializedValue) {
|
|
97
|
+
return node;
|
|
98
|
+
}
|
|
99
|
+
// @ts-expect-error - we know that the node is a ValueNode
|
|
100
|
+
return sql`jsonb(${serializedValue})`.toOperationNode();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Transforms the value list node by replacing all JSON objects with `jsonb` function calls.
|
|
104
|
+
*/
|
|
105
|
+
protected override transformValueList(node: ValueListNode): ValueListNode {
|
|
106
|
+
return super.transformValueList({
|
|
107
|
+
...node,
|
|
108
|
+
values: node.values.map((listNodeItem) => {
|
|
109
|
+
if (listNodeItem.kind !== "ValueNode") {
|
|
110
|
+
return listNodeItem;
|
|
111
|
+
}
|
|
112
|
+
// @ts-expect-error - we know that the node is a ValueNode
|
|
113
|
+
const { value } = listNodeItem;
|
|
114
|
+
const serializedValue = maybeSerializeJson(value);
|
|
115
|
+
|
|
116
|
+
if (value === serializedValue) {
|
|
117
|
+
return listNodeItem;
|
|
118
|
+
}
|
|
119
|
+
return sql`jsonb(${serializedValue})`.toOperationNode();
|
|
120
|
+
}),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Why this function is needed or why this works remains a mystery.
|
|
126
|
+
*/
|
|
127
|
+
override transformValues(node: ValuesNode): ValuesNode {
|
|
128
|
+
return super.transformValues({
|
|
129
|
+
...node,
|
|
130
|
+
values: node.values.map((valueItemNode) => {
|
|
131
|
+
if (valueItemNode.kind !== "PrimitiveValueListNode") {
|
|
132
|
+
return valueItemNode;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// change valueItem to ValueListNode
|
|
136
|
+
return {
|
|
137
|
+
kind: "ValueListNode",
|
|
138
|
+
values: valueItemNode.values.map(
|
|
139
|
+
(value) =>
|
|
140
|
+
({
|
|
141
|
+
kind: "ValueNode",
|
|
142
|
+
value,
|
|
143
|
+
}) as ValueNode
|
|
144
|
+
),
|
|
145
|
+
} as ValueListNode;
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function maybeSerializeJson(value: any): any {
|
|
152
|
+
if (
|
|
153
|
+
// binary data
|
|
154
|
+
value instanceof ArrayBuffer ||
|
|
155
|
+
// uint8array, etc
|
|
156
|
+
ArrayBuffer.isView(value) ||
|
|
157
|
+
value === null ||
|
|
158
|
+
value === undefined
|
|
159
|
+
) {
|
|
160
|
+
return value;
|
|
161
|
+
} else if (typeof value === "object" || Array.isArray(value)) {
|
|
162
|
+
return JSON.stringify(value);
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// The code here didn't work https://github.com/opral/inlang-sdk/issues/132#issuecomment-2339321910
|
|
168
|
+
// but would be the "right" solution to avoid heuristics which column might or might not be a json column
|
|
169
|
+
// // modifies the query in place for readability and performance
|
|
170
|
+
// function mapQuery(
|
|
171
|
+
// node: InsertQueryNode,
|
|
172
|
+
// jsonColumns: TableSchema
|
|
173
|
+
// ): InsertQueryNode {
|
|
174
|
+
// // if the query is not an insert query, we don't need to do anything
|
|
175
|
+
// if (node.into === undefined) {
|
|
176
|
+
// return node;
|
|
177
|
+
// }
|
|
178
|
+
// // if the table is not in the schema that has json columns, we don't need to do anything
|
|
179
|
+
// const columnsWithJson = jsonColumns[node.into.table.identifier.name];
|
|
180
|
+
// if (columnsWithJson === undefined) {
|
|
181
|
+
// return node;
|
|
182
|
+
// }
|
|
183
|
+
// // find the indexes of the values that need to be transformed
|
|
184
|
+
// // SQL query: INSERT INTO table (col1, col2) VALUES (val1, val2)
|
|
185
|
+
// const indexesThatNeedToBeTransformed: [number, string][] = [];
|
|
186
|
+
// for (const [i, col] of node.columns?.entries() ?? []) {
|
|
187
|
+
// const jsonType = columnsWithJson[col.column.name];
|
|
188
|
+
// if (jsonType !== undefined) {
|
|
189
|
+
// indexesThatNeedToBeTransformed.push([i, jsonType]);
|
|
190
|
+
// }
|
|
191
|
+
// }
|
|
192
|
+
// const values = structuredClone(node.values);
|
|
193
|
+
// for (const [i, jsonType] of indexesThatNeedToBeTransformed) {
|
|
194
|
+
// if (
|
|
195
|
+
// // top level values node that should contain a list of values
|
|
196
|
+
// node.values?.kind !== "ValuesNode" &&
|
|
197
|
+
// // the node we are interested in must be a value node
|
|
198
|
+
// // @ts-expect-error - we know that the node is a ValuesNode with values
|
|
199
|
+
// (node.values as ValuesNode).values?.[i].kind !== "ValueNode"
|
|
200
|
+
// ) {
|
|
201
|
+
// throw new Error("Unexpected node structure");
|
|
202
|
+
// }
|
|
203
|
+
// const serializedJson = JSON.stringify(node.values.values[0].values[i]);
|
|
204
|
+
// // @ts-expect-error - we know that the node is a ValuesNode with values
|
|
205
|
+
// values.values[0].values[i] =
|
|
206
|
+
// jsonType === "jsonb"
|
|
207
|
+
// ? sql`jsonb(${serializedJson})`.toOperationNode()
|
|
208
|
+
// : sql`json(${serializedJson})`.toOperationNode();
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
// return {
|
|
212
|
+
// ...node,
|
|
213
|
+
// values,
|
|
214
|
+
// };
|
|
215
|
+
// }
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Generated, Insertable, Selectable, Updateable } from "kysely";
|
|
2
|
+
import type { SqliteDatabase } from "sqlite-wasm-kysely";
|
|
3
|
+
import {
|
|
4
|
+
Declaration,
|
|
5
|
+
Pattern,
|
|
6
|
+
VariableReference,
|
|
7
|
+
} from "../json-schema/pattern.js";
|
|
8
|
+
|
|
9
|
+
export function applySchema(args: { sqlite: SqliteDatabase }) {
|
|
10
|
+
const foreignKeyActivated: any = args.sqlite.exec("PRAGMA foreign_keys", {
|
|
11
|
+
returnValue: "resultRows",
|
|
12
|
+
});
|
|
13
|
+
if (
|
|
14
|
+
// first row that is returned
|
|
15
|
+
// first column of the first row
|
|
16
|
+
// is equal to 0, then foreign keys are disabled
|
|
17
|
+
foreignKeyActivated[0][0] === 0
|
|
18
|
+
) {
|
|
19
|
+
args.sqlite.exec("PRAGMA foreign_keys = ON", {
|
|
20
|
+
returnValue: "resultRows",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
args.sqlite.exec(`
|
|
25
|
+
CREATE TABLE IF NOT EXISTS bundle (
|
|
26
|
+
id TEXT PRIMARY KEY DEFAULT (human_id()),
|
|
27
|
+
declarations BLOB NOT NULL DEFAULT (jsonb('[]'))
|
|
28
|
+
) strict;
|
|
29
|
+
|
|
30
|
+
CREATE TABLE IF NOT EXISTS message (
|
|
31
|
+
id TEXT PRIMARY KEY DEFAULT (uuid_v7()),
|
|
32
|
+
bundle_id TEXT NOT NULL,
|
|
33
|
+
locale TEXT NOT NULL,
|
|
34
|
+
selectors BLOB NOT NULL DEFAULT (jsonb('[]')),
|
|
35
|
+
FOREIGN KEY (bundle_id) REFERENCES bundle(id) ON DELETE CASCADE
|
|
36
|
+
) strict;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
CREATE TABLE IF NOT EXISTS variant (
|
|
40
|
+
id TEXT PRIMARY KEY DEFAULT (uuid_v7()),
|
|
41
|
+
message_id TEXT NOT NULL,
|
|
42
|
+
matches BLOB NOT NULL DEFAULT (jsonb('[]')),
|
|
43
|
+
pattern BLOB NOT NULL DEFAULT (jsonb('[]')),
|
|
44
|
+
FOREIGN KEY (message_id) REFERENCES message(id) ON DELETE CASCADE
|
|
45
|
+
) strict;
|
|
46
|
+
|
|
47
|
+
CREATE INDEX IF NOT EXISTS idx_message_bundle_id ON message (bundle_id);
|
|
48
|
+
CREATE INDEX IF NOT EXISTS idx_variant_message_id ON variant (message_id);
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type InlangDatabaseSchema = {
|
|
53
|
+
bundle: BundleTable;
|
|
54
|
+
message: MessageTable;
|
|
55
|
+
variant: VariantTable;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type BundleTable = {
|
|
59
|
+
id: Generated<string>;
|
|
60
|
+
declarations: Generated<Array<Declaration>>;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type MessageTable = {
|
|
64
|
+
id: Generated<string>;
|
|
65
|
+
bundleId: string;
|
|
66
|
+
locale: string;
|
|
67
|
+
selectors: Generated<Array<VariableReference>>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type VariantTable = {
|
|
71
|
+
id: Generated<string>;
|
|
72
|
+
messageId: string;
|
|
73
|
+
matches: Generated<Array<Match>>;
|
|
74
|
+
pattern: Generated<Pattern>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A match is a variable reference that is either a literal or a catch-all.
|
|
79
|
+
*
|
|
80
|
+
* https://github.com/opral/inlang-sdk/issues/205
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* match = { type: "match", name: "gender", value: { type: "literal", value: "male" }}
|
|
84
|
+
*/
|
|
85
|
+
export type Match = LiteralMatch | CatchAllMatch;
|
|
86
|
+
|
|
87
|
+
export type LiteralMatch = {
|
|
88
|
+
type: "literal-match";
|
|
89
|
+
key: VariableReference["name"];
|
|
90
|
+
value: string;
|
|
91
|
+
};
|
|
92
|
+
export type CatchAllMatch = {
|
|
93
|
+
type: "catchall-match";
|
|
94
|
+
key: VariableReference["name"];
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type Bundle = Selectable<BundleTable>;
|
|
98
|
+
export type NewBundle = Insertable<BundleTable>;
|
|
99
|
+
export type BundleUpdate = Updateable<BundleTable>;
|
|
100
|
+
|
|
101
|
+
export type Message = Selectable<MessageTable>;
|
|
102
|
+
export type NewMessage = Insertable<MessageTable>;
|
|
103
|
+
export type MessageUpdate = Updateable<MessageTable>;
|
|
104
|
+
|
|
105
|
+
export type Variant = Selectable<VariantTable>;
|
|
106
|
+
export type NewVariant = Insertable<VariantTable>;
|
|
107
|
+
export type VariantUpdate = Updateable<VariantTable>;
|
|
108
|
+
|
|
109
|
+
export type MessageNested = Message & {
|
|
110
|
+
variants: Variant[];
|
|
111
|
+
};
|
|
112
|
+
export type NewMessageNested = NewMessage & {
|
|
113
|
+
variants: NewVariant[];
|
|
114
|
+
};
|
|
115
|
+
export type MessageNestedUpdate = Updateable<MessageTable> & {
|
|
116
|
+
variants: VariantUpdate[];
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type BundleNested = Bundle & {
|
|
120
|
+
messages: MessageNested[];
|
|
121
|
+
};
|
|
122
|
+
export type NewBundleNested = NewBundle & {
|
|
123
|
+
messages: NewMessageNested[];
|
|
124
|
+
};
|
|
125
|
+
export type BundleNestedUpdate = BundleUpdate & {
|
|
126
|
+
messages: MessageNestedUpdate[];
|
|
127
|
+
};
|
package/src/helper.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
2
|
+
import type { ProjectSettings } from "./json-schema/settings.js";
|
|
3
|
+
import { humanId } from "./human-id/human-id.js";
|
|
4
|
+
import type {
|
|
5
|
+
Match,
|
|
6
|
+
NewBundleNested,
|
|
7
|
+
NewMessageNested,
|
|
8
|
+
Variant,
|
|
9
|
+
} from "./database/schema.js";
|
|
10
|
+
import type { Text } from "./json-schema/pattern.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* create v2 Bundle with a random human ID
|
|
14
|
+
*
|
|
15
|
+
* @deprecated
|
|
16
|
+
*
|
|
17
|
+
* use the database directly
|
|
18
|
+
*
|
|
19
|
+
* - less code because the database has default values
|
|
20
|
+
* - `createMessage` is misleading because it does not treat expressions in the text
|
|
21
|
+
*
|
|
22
|
+
* @example createBundle({
|
|
23
|
+
* messages: [
|
|
24
|
+
* createMessage({locale: "en", text: "Hello world!"})
|
|
25
|
+
* createMessage({locale: "de", text: "Hallo Welt!"})
|
|
26
|
+
* ]
|
|
27
|
+
* })
|
|
28
|
+
*/
|
|
29
|
+
export function createBundle(args: {
|
|
30
|
+
id?: string;
|
|
31
|
+
messages: NewMessageNested[];
|
|
32
|
+
}): NewBundleNested {
|
|
33
|
+
return {
|
|
34
|
+
id: args.id ?? humanId(),
|
|
35
|
+
messages: args.messages,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @deprecated
|
|
42
|
+
* use the database directly
|
|
43
|
+
*
|
|
44
|
+
* - text will always be a string, no matter
|
|
45
|
+
* if an expression is provided like hello "{username}"
|
|
46
|
+
* - the database has default values
|
|
47
|
+
*
|
|
48
|
+
* ```
|
|
49
|
+
* await project.db.insertInto("message").values({
|
|
50
|
+
* bundleId: "bundleId",
|
|
51
|
+
* pattern: []
|
|
52
|
+
* ...
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* create v2 Messsage AST with a randomId, and text-only pattern
|
|
57
|
+
* @example createMessage({locale: "en", text: "Hello world"})
|
|
58
|
+
*/
|
|
59
|
+
export function createMessage(args: {
|
|
60
|
+
bundleId: string;
|
|
61
|
+
locale: ProjectSettings["locales"][number];
|
|
62
|
+
text: string;
|
|
63
|
+
matches?: Match[];
|
|
64
|
+
}): NewMessageNested {
|
|
65
|
+
const messageId = uuid();
|
|
66
|
+
return {
|
|
67
|
+
bundleId: args.bundleId,
|
|
68
|
+
id: messageId,
|
|
69
|
+
locale: args.locale,
|
|
70
|
+
selectors: [],
|
|
71
|
+
variants: [
|
|
72
|
+
createVariant({
|
|
73
|
+
messageId: messageId,
|
|
74
|
+
text: args.text,
|
|
75
|
+
matches: args.matches,
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @deprecated
|
|
84
|
+
*
|
|
85
|
+
* use the database directly
|
|
86
|
+
*
|
|
87
|
+
* - less code because the database has default values
|
|
88
|
+
* - `text` is misleading because it does not treat expressions in the text
|
|
89
|
+
*
|
|
90
|
+
* create v2 Variant AST with text-only pattern
|
|
91
|
+
* @example createVariant({match: ["*"], text: "Hello world"})
|
|
92
|
+
*/
|
|
93
|
+
export function createVariant(args: {
|
|
94
|
+
messageId: string;
|
|
95
|
+
id?: string;
|
|
96
|
+
text?: string;
|
|
97
|
+
matches?: Match[];
|
|
98
|
+
pattern?: Variant["pattern"];
|
|
99
|
+
}): Variant {
|
|
100
|
+
return {
|
|
101
|
+
messageId: args.messageId,
|
|
102
|
+
id: args.id ? args.id : uuid(),
|
|
103
|
+
matches: args.matches ? args.matches : [],
|
|
104
|
+
pattern: args.pattern ? args.pattern : [toTextElement(args.text ?? "")],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function toTextElement(text: string): Text {
|
|
109
|
+
return {
|
|
110
|
+
type: "text",
|
|
111
|
+
value: text,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { adjectives, animals, verbs } from "./words.js";
|
|
2
|
+
|
|
3
|
+
export function humanId() {
|
|
4
|
+
return `${adjectives[Math.floor(Math.random() * 256)]}_${
|
|
5
|
+
adjectives[Math.floor(Math.random() * 256)]
|
|
6
|
+
}_${animals[Math.floor(Math.random() * 256)]}_${
|
|
7
|
+
verbs[Math.floor(Math.random() * 256)]
|
|
8
|
+
}`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isHumanId(id: string): boolean {
|
|
12
|
+
// naive implementation (good enough for now)
|
|
13
|
+
return id.split("_").length === 4;
|
|
14
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest"
|
|
2
|
-
import { adjectives, animals, adverbs, verbs } from "./words.js"
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { adjectives, animals, adverbs, verbs } from "./words.js";
|
|
3
3
|
|
|
4
|
-
const wordlists = [adjectives, animals, adverbs, verbs]
|
|
5
|
-
const allwords = [...adjectives, ...animals, ...adverbs, ...verbs]
|
|
4
|
+
const wordlists = [adjectives, animals, adverbs, verbs];
|
|
5
|
+
const allwords = [...adjectives, ...animals, ...adverbs, ...verbs];
|
|
6
6
|
|
|
7
7
|
describe("wordlists", () => {
|
|
8
8
|
it("should have 256 words", () => {
|
|
9
9
|
for (const wordlist of wordlists) {
|
|
10
|
-
expect(wordlist.length).toBe(256)
|
|
10
|
+
expect(wordlist.length).toBe(256);
|
|
11
11
|
}
|
|
12
|
-
})
|
|
12
|
+
});
|
|
13
13
|
it("words should be unique across lists", () => {
|
|
14
|
-
const unique = new Set(allwords)
|
|
15
|
-
expect(unique.size).toBe(256 * 4)
|
|
16
|
-
})
|
|
14
|
+
const unique = new Set(allwords);
|
|
15
|
+
expect(unique.size).toBe(256 * 4);
|
|
16
|
+
});
|
|
17
17
|
it("words should have < 10 characters", () => {
|
|
18
18
|
for (const word of allwords) {
|
|
19
|
-
expect(word.length).toBeLessThan(10)
|
|
19
|
+
expect(word.length).toBeLessThan(10);
|
|
20
20
|
}
|
|
21
|
-
})
|
|
21
|
+
});
|
|
22
22
|
it("words should match /^[a-z]+$/", () => {
|
|
23
23
|
for (const word of allwords) {
|
|
24
|
-
expect(word.match(/^[a-z]+$/) !== null).toBe(true)
|
|
24
|
+
expect(word.match(/^[a-z]+$/) !== null).toBe(true);
|
|
25
25
|
}
|
|
26
|
-
})
|
|
27
|
-
})
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -255,7 +255,7 @@ export const animals = [
|
|
|
255
255
|
"wren",
|
|
256
256
|
"yak",
|
|
257
257
|
"zebra",
|
|
258
|
-
]
|
|
258
|
+
];
|
|
259
259
|
|
|
260
260
|
export const adjectives = [
|
|
261
261
|
"acidic",
|
|
@@ -514,7 +514,7 @@ export const adjectives = [
|
|
|
514
514
|
"zany",
|
|
515
515
|
"zesty",
|
|
516
516
|
"zippy",
|
|
517
|
-
]
|
|
517
|
+
];
|
|
518
518
|
|
|
519
519
|
export const adverbs = [
|
|
520
520
|
"ablaze",
|
|
@@ -773,7 +773,7 @@ export const adverbs = [
|
|
|
773
773
|
"within",
|
|
774
774
|
"wrongly",
|
|
775
775
|
"yonder",
|
|
776
|
-
]
|
|
776
|
+
];
|
|
777
777
|
|
|
778
778
|
export const verbs = [
|
|
779
779
|
"absorb",
|
|
@@ -1032,4 +1032,4 @@ export const verbs = [
|
|
|
1032
1032
|
"zap",
|
|
1033
1033
|
"zip",
|
|
1034
1034
|
"zoom",
|
|
1035
|
-
]
|
|
1035
|
+
];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import {
|
|
3
|
+
PluginDoesNotImplementFunctionError,
|
|
4
|
+
PluginMissingError,
|
|
5
|
+
} from "../plugin/errors.js";
|
|
6
|
+
import type { ProjectSettings } from "../json-schema/settings.js";
|
|
7
|
+
import type { InlangDatabaseSchema } from "../database/schema.js";
|
|
8
|
+
import type { InlangPlugin } from "../plugin/schema.js";
|
|
9
|
+
|
|
10
|
+
export async function exportFiles(opts: {
|
|
11
|
+
readonly pluginKey: string;
|
|
12
|
+
readonly settings: ProjectSettings;
|
|
13
|
+
readonly plugins: readonly InlangPlugin[];
|
|
14
|
+
readonly db: Kysely<InlangDatabaseSchema>;
|
|
15
|
+
}) {
|
|
16
|
+
const plugin = opts.plugins.find((p) => p.key === opts.pluginKey);
|
|
17
|
+
if (!plugin) throw new PluginMissingError({ plugin: opts.pluginKey });
|
|
18
|
+
if (!plugin.exportFiles) {
|
|
19
|
+
throw new PluginDoesNotImplementFunctionError({
|
|
20
|
+
plugin: opts.pluginKey,
|
|
21
|
+
function: "exportFiles",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const bundles = await opts.db.selectFrom("bundle").selectAll().execute();
|
|
26
|
+
const messages = await opts.db.selectFrom("message").selectAll().execute();
|
|
27
|
+
const variants = await opts.db.selectFrom("variant").selectAll().execute();
|
|
28
|
+
|
|
29
|
+
const files = await plugin.exportFiles({
|
|
30
|
+
settings: structuredClone(opts.settings),
|
|
31
|
+
bundles,
|
|
32
|
+
messages,
|
|
33
|
+
variants,
|
|
34
|
+
});
|
|
35
|
+
return files;
|
|
36
|
+
}
|