From 03f7f1dfa82a881f9629c6cda0f01f9a14197c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Knuchel?= Date: Mon, 25 Nov 2024 18:25:37 +0100 Subject: [PATCH] Code review --- .../website/docs/create-your-project.html.heex | 2 +- extensions/vscode-aml/package.json | 7 ++++++- extensions/vscode-aml/resources/schema.json | 10 +++++----- extensions/vscode-aml/resources/schema.sql | 10 +++++----- extensions/vscode-aml/src/web/extension.ts | 6 +++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex b/backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex index 5adbe161a..41ede1ff3 100644 --- a/backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex +++ b/backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex @@ -3,7 +3,7 @@ <%= doc_prose do %>

Azimutt explorer has several ways to import your database schema. The suggested one is the database connection - as it's more reliable and offer more features (see below) but you have many other options if you prefer. + as it's more reliable and offers more features (see below) but you have many other options if you prefer. New Azimutt project

diff --git a/extensions/vscode-aml/package.json b/extensions/vscode-aml/package.json index 3f3dbfa8f..f0685877a 100644 --- a/extensions/vscode-aml/package.json +++ b/extensions/vscode-aml/package.json @@ -28,7 +28,12 @@ "directory": "extensions/vscode-aml" }, "browser": "./dist/web/extension.js", - "activationEvents": [], + "activationEvents": [ + "onLanguage:aml", + "onCommand:aml.new", + "onCommand:aml.fromJson", + "onCommand:aml.fromSQL" + ], "contributes": { "languages": [ { diff --git a/extensions/vscode-aml/resources/schema.json b/extensions/vscode-aml/resources/schema.json index e19813f89..16f1da78d 100644 --- a/extensions/vscode-aml/resources/schema.json +++ b/extensions/vscode-aml/resources/schema.json @@ -29,13 +29,13 @@ {"name": "id", "type": "int", "extra": {"autoIncrement": null}}, {"name": "title", "type": "varchar"}, {"name": "content", "type": "text", "doc": "allow markdown"}, - {"name": "status", "type": "post_status", "default": "draft"}, + {"name": "status", "type": "cms.post_status", "default": "draft"}, {"name": "author", "type": "int"}, {"name": "tags", "type": "varchar[]"}, {"name": "created_at", "type": "timestamp", "default": "`now()`"}, - {"name": "created_by", "type": "unknown"}, + {"name": "created_by", "type": "int"}, {"name": "updated_at", "type": "timestamp", "default": "`now()`"}, - {"name": "updated_by", "type": "unknown"} + {"name": "updated_by", "type": "int"} ], "pk": {"attrs": [["id"]]}, "checks": [ @@ -50,9 +50,9 @@ {"name": "post_id", "type": "int"}, {"name": "content", "type": "text"}, {"name": "created_at", "type": "timestamp", "default": "`now()`"}, - {"name": "created_by", "type": "unknown"}, + {"name": "created_by", "type": "int"}, {"name": "updated_at", "type": "timestamp", "default": "`now()`"}, - {"name": "updated_by", "type": "unknown"} + {"name": "updated_by", "type": "int"} ], "pk": {"attrs": [["id"]]} }, diff --git a/extensions/vscode-aml/resources/schema.sql b/extensions/vscode-aml/resources/schema.sql index eb4a7709c..09242fa14 100644 --- a/extensions/vscode-aml/resources/schema.sql +++ b/extensions/vscode-aml/resources/schema.sql @@ -21,13 +21,13 @@ CREATE TABLE cms.posts ( id int PRIMARY KEY, title varchar NOT NULL CHECK (length(title) > 10), content text NOT NULL, - status post_status NOT NULL DEFAULT 'draft', + status cms.post_status NOT NULL DEFAULT 'draft', author int NOT NULL REFERENCES users(id), tags varchar[] NOT NULL, created_at timestamp NOT NULL DEFAULT now(), - created_by unknown NOT NULL REFERENCES users(id), + created_by int NOT NULL REFERENCES users(id), updated_at timestamp NOT NULL DEFAULT now(), - updated_by unknown NOT NULL REFERENCES users(id) + updated_by int NOT NULL REFERENCES users(id) ); COMMENT ON COLUMN cms.posts.content IS 'allow markdown'; @@ -36,9 +36,9 @@ CREATE TABLE cms.comments ( post_id int NOT NULL REFERENCES cms.posts(id), content text NOT NULL, created_at timestamp NOT NULL DEFAULT now(), - created_by unknown NOT NULL REFERENCES users(id), + created_by int NOT NULL REFERENCES users(id), updated_at timestamp NOT NULL DEFAULT now(), - updated_by unknown NOT NULL REFERENCES users(id) + updated_by int NOT NULL REFERENCES users(id) ); -- Tracking tables diff --git a/extensions/vscode-aml/src/web/extension.ts b/extensions/vscode-aml/src/web/extension.ts index 8a0f9a05c..5f9e18d87 100644 --- a/extensions/vscode-aml/src/web/extension.ts +++ b/extensions/vscode-aml/src/web/extension.ts @@ -192,13 +192,13 @@ function openInAzimuttUrl(aml: string): string { class AmlDocumentSymbolProvider implements DocumentSymbolProvider { provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult { const symbols: DocumentSymbol[] = [] - const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g + const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g // TODO: use `.split('\n')` for "better" parsing let match: RegExpExecArray | null = null while (match = regex.exec(document.getText())) { - const [all, lr, keyword, name] = match || [] + const [all = '', lr = '', keyword = '', name = ''] = match || [] if (name === 'rel') { continue } const range = new Range( - document.positionAt(match.index + lr.length + (keyword || '').length), + document.positionAt(match.index + lr.length + keyword.length), document.positionAt(match.index + all.length) ) // see https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.DocumentSymbol.html