From 3b842d1d79ce2c604a2b206bca0033ee7e7612f0 Mon Sep 17 00:00:00 2001 From: Felix Haeberle Date: Mon, 29 Jul 2024 16:50:29 +0200 Subject: [PATCH] start update import & loadProject & remove concept of `InlangModule` which is now `InlangPlugin` remove lint rules as inlang module type while migrating them to lix validation rules. cc @samuelstroschein @janfjohannes --- inlang/source-code/sdk-v2/src/import-utils.ts | 6 ++-- .../source-code/sdk-v2/src/loadProjectOpfs.ts | 30 +++++++++---------- .../sdk-v2/src/validatedModuleSettings.ts | 4 +-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/inlang/source-code/sdk-v2/src/import-utils.ts b/inlang/source-code/sdk-v2/src/import-utils.ts index 5aef0ac8b9..dc158db5ea 100644 --- a/inlang/source-code/sdk-v2/src/import-utils.ts +++ b/inlang/source-code/sdk-v2/src/import-utils.ts @@ -1,12 +1,12 @@ import { ModuleImportError } from "./resolve-modules/errors.js" -import type { InlangModule } from "./types/module.js" +import type { InlangPlugin } from "./types/module.js" /** * @throws {ModuleImportError} */ -type Importer = (uri: string) => Promise +type Importer = (uri: string) => Promise -export function createDebugImport(importMap: Record): Importer { +export function createDebugImport(importMap: Record): Importer { return async (uri) => { const resolved = importMap[uri] if (resolved) return { default: resolved } diff --git a/inlang/source-code/sdk-v2/src/loadProjectOpfs.ts b/inlang/source-code/sdk-v2/src/loadProjectOpfs.ts index 513754d2da..2f6b8e6c3a 100644 --- a/inlang/source-code/sdk-v2/src/loadProjectOpfs.ts +++ b/inlang/source-code/sdk-v2/src/loadProjectOpfs.ts @@ -22,14 +22,14 @@ import { BehaviorSubject, combineLatest, from, switchMap, tap } from "rxjs" import { createDebugImport, importSequence } from "./import-utils.js" // development only -import lintRule from "./dev-modules/lint-rule.js" -import makeOpralUppercase from "./dev-modules/opral-uppercase-lint-rule.js" -import missingSelectorLintRule from "./dev-modules/missing-selector-lint-rule.js" -import missingCatchallLintRule from "./dev-modules/missingCatchall.js" +// import lintRule from "./dev-modules/lint-rule.js" +// import makeOpralUppercase from "./dev-modules/opral-uppercase-lint-rule.js" +// import missingSelectorLintRule from "./dev-modules/missing-selector-lint-rule.js" +// import missingCatchallLintRule from "./dev-modules/missingCatchall.js" import { resolveModules } from "./resolveModules2.js" import type { InstalledLintRule, ProjectSettings2 } from "./types/project-settings.js" import type { InlangProject } from "./types/project.js" -import type { LanguageTag } from "@inlang/plugin" +// import type { LanguageTag } from "@inlang/plugin" // extend the SQLocalKysely class to expose a rawSql function // needed for non parametrized queries @@ -65,15 +65,15 @@ export async function loadProjectOpfs(args: { inlangFolderPath: string }): Promi const projectSettings$ = new BehaviorSubject(projectSettings) // TODO SDK-v2 LIX how to deal with plugins we want to load? - const _import = importSequence( - createDebugImport({ - "sdk-dev:lint-rule.js": lintRule, - "sdk-dev:opral-uppercase-lint.js": makeOpralUppercase, - "sdk-dev:missing-selector-lint-rule.js": missingSelectorLintRule, - "sdk-dev:missing-catchall-variant": missingCatchallLintRule, - }) /*, - createImport(projectPath, nodeishFs)*/ - ) + const _import = importSequence() + // Lint rules are now Lix validation rules, therefore this needs to be reimplemented + // createDebugImport({ + // "sdk-dev:lint-rule.js": lintRule, + // "sdk-dev:opral-uppercase-lint.js": makeOpralUppercase, + // "sdk-dev:missing-selector-lint-rule.js": missingSelectorLintRule, + // "sdk-dev:missing-catchall-variant": missingCatchallLintRule, + // }), + // createImport(projectPath, nodeishFs) const lifecycle$ = new BehaviorSubject("initializing") const settings$ = projectSettings$.asObservable() @@ -144,7 +144,7 @@ export async function loadProjectOpfs(args: { inlangFolderPath: string }): Promi }, subscribe: () => projectSettings$.subscribe(), }, - + bundle: { /* search: (args: { lintRulesIds: string[], locales: LanguageTag[], bundleIds: string[], text: string }): string[] { diff --git a/inlang/source-code/sdk-v2/src/validatedModuleSettings.ts b/inlang/source-code/sdk-v2/src/validatedModuleSettings.ts index 5400a43edc..77142d4e95 100644 --- a/inlang/source-code/sdk-v2/src/validatedModuleSettings.ts +++ b/inlang/source-code/sdk-v2/src/validatedModuleSettings.ts @@ -1,9 +1,9 @@ import type { TSchema } from "@sinclair/typebox" import { Value, type ValueError } from "@sinclair/typebox/value" -import type { InlangModule } from "./types/module.js" +import type { InlangPlugin } from "./types/module.js" export const validatedModuleSettings = (args: { - settingsSchema: InlangModule["default"]["settingsSchema"] + settingsSchema: InlangPlugin["default"]["settingsSchema"] moduleSettings: unknown }): "isValid" | ValueError[] => { if (args.settingsSchema && args.moduleSettings) {