Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create VSCode extension for AML #333

Merged
merged 20 commits into from
Nov 25, 2024
Merged

Create VSCode extension for AML #333

merged 20 commits into from
Nov 25, 2024

Conversation

loicknuchel
Copy link
Contributor

@loicknuchel loicknuchel commented Nov 22, 2024

Blocked (need help)

When running tsc --noEmit, I get many error that likely comes from CommonJS / ESM incompatibilities but maybe also something else.
They are generated when I import anything from @azimutt/aml (cf npm) into vscode-aml.
Not sure what to change in vscode-aml or in @azimutt/aml (cf ./libs/aml), main files:

Any idea?

node_modules/@azimutt/aml/out/index.d.ts:2:29 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './dotGenerator.js'?

2 import { generateDot } from "./dotGenerator";
                              ~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:3:33 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './mermaidGenerator.js'?

3 import { generateMermaid } from "./mermaidGenerator";
                                  ~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:4:34 - error TS2835: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './markdownGenerator.js'?

4 import { generateMarkdown } from "./markdownGenerator";
                                   ~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:11:37 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

11     language: (opts?: {}) => import("./extensions/monaco.types").IMonarchLanguage;
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:12:39 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

12     completion: (opts?: {}) => import("./extensions/monaco.types").CompletionItemProvider;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:13:39 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

13     codeAction: (opts?: {}) => import("./extensions/monaco.types").CodeActionProvider;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:14:37 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

14     codeLens: (opts?: {}) => import("./extensions/monaco.types").CodeLensProvider;
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:15:50 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

15     createMarker: (e: ParserError, model: import("./extensions/monaco.types").ITextModel, editor: import("./extensions/monaco.types").IStandaloneCodeEditor) => import("./extensions/monaco.types").IMarkerData;
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:15:106 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

15     createMarker: (e: ParserError, model: import("./extensions/monaco.types").ITextModel, editor: import("./extensions/monaco.types").IStandaloneCodeEditor) => import("./extensions/monaco.types").IMarkerData;
                                                                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/aml/out/index.d.ts:15:168 - error TS2307: Cannot find module './extensions/monaco.types' or its corresponding type declarations.

15     createMarker: (e: ParserError, model: import("./extensions/monaco.types").ITextModel, editor: import("./extensions/monaco.types").IStandaloneCodeEditor) => import("./extensions/monaco.types").IMarkerData;
                                                                                                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@azimutt/models/out/databaseDiff.d.ts:22:50 - error TS2536: Type 'k' cannot be used to index type 'addQuestionMarks<baseObjectOutputType<{ before: ZodType<T, ZodTypeDef, T>; after: ZodType<T, ZodTypeDef, T>; }>, any>'.

22 }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23     before: z.ZodType<T, z.ZodTypeDef, T>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24     after: z.ZodType<T, z.ZodTypeDef, T>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 }>, any>[k]; } : never, z.baseObjectInputType<{
   ~~~~~~~~~~~

node_modules/@azimutt/models/out/databaseDiff.d.ts:28:46 - error TS2536: Type 'k_1' cannot be used to index type 'baseObjectInputType<{ before: ZodType<T, ZodTypeDef, T>; after: ZodType<T, ZodTypeDef, T>; }>'.

28 }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
                                                ~~~~~~~~~~~~~~~~~~~~~~~
29     before: z.ZodType<T, z.ZodTypeDef, T>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30     after: z.ZodType<T, z.ZodTypeDef, T>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31 }>[k_1]; } : never>;
   ~~~~~~~

node_modules/@azimutt/models/out/databaseDiff.d.ts:42:50 - error TS2536: Type 'k' cannot be used to index type 'addQuestionMarks<baseObjectOutputType<{ before: ZodOptional<ZodType<T, ZodTypeDef, T>>; after: ZodOptional<ZodType<T, ZodTypeDef, T>>; }>, any>'.

42 }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43     before: z.ZodOptional<z.ZodType<T, z.ZodTypeDef, T>>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44     after: z.ZodOptional<z.ZodType<T, z.ZodTypeDef, T>>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 }>, any>[k]; } : never, z.baseObjectInputType<{
   ~~~~~~~~~~~

node_modules/@azimutt/models/out/databaseDiff.d.ts:48:46 - error TS2536: Type 'k_1' cannot be used to index type 'baseObjectInputType<{ before: ZodOptional<ZodType<T, ZodTypeDef, T>>; after: ZodOptional<ZodType<T, ZodTypeDef, T>>; }>'.

48 }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
                                                ~~~~~~~~~~~~~~~~~~~~~~~
49     before: z.ZodOptional<z.ZodType<T, z.ZodTypeDef, T>>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50     after: z.ZodOptional<z.ZodType<T, z.ZodTypeDef, T>>;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51 }>[k_1]; } : never>;
   ~~~~~~~

src/web/extension.ts:16:24 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@azimutt/aml")' call instead.
  To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to '/home/loic/workspace/azimutt/azimutt/extensions/vscode-aml/package.json'.

16 import {parseAml} from "@azimutt/aml";
                          ~~~~~~~~~~~~~~

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new Visual Studio Code extension for Azimutt Markup Language (AML) with features like syntax highlighting, snippets, and command support for creating and converting AML files.
  • Documentation Updates

    • Improved clarity and navigation in various documentation files related to project setup and usage.
    • Updated links in README files for connectors and the gateway to reflect the new directory structure.
  • Configuration Changes

    • Updated .gitignore and .dockerignore files to refine ignored files and directories.
    • Modified package.json and pnpm-workspace.yaml to reflect the new directory structure for the desktop and browser extension.
  • Bug Fixes

    • Enhanced regex patterns for better attribute type matching in AML syntax.

Copy link

coderabbitai bot commented Nov 22, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve updates to various configuration and documentation files across the project. Key modifications include enhancements to .dockerignore and .gitignore files for better exclusion of unnecessary files, adjustments to the .pre-commit-config.yaml to reflect a new directory structure, and the introduction of new configuration files for the Visual Studio Code extension. Additionally, several README files were updated to correct paths, and new schema definitions were added to support the AML language. The overall structure and organization of the project have been refined.

Changes

File Path Change Summary
.dockerignore Added entries to ignore files related to Elixir, Node.js, and Elm; updated path for browser extension files.
.gitignore Changed entry for .vscode from relative to absolute path.
.pre-commit-config.yaml Updated hooks for TypeScript, Elixir, and Elm; modified comments for directory structure changes.
backend/.gitignore Added entry to ignore .vscode directory.
backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex Textual modifications for clarity and grammatical accuracy.
backend/lib/azimutt_web/templates/website/docs/getting-started.html.heex Added a new section to enhance content.
backend/lib/azimutt_web/templates/website/docs/what-is-azimutt.html.heex Textual modifications and added links for improved navigation.
extensions/browser-extension/package.json Updated directory field in the repository object.
extensions/desktop/package.json Updated directory field in the repository object.
extensions/vscode-aml/.gitignore Added entries to ignore build artifacts and dependencies.
extensions/vscode-aml/.npmrc Added configuration option to enable pre and post scripts.
extensions/vscode-aml/.vscode/extensions.json New file created with recommended VS Code extensions.
extensions/vscode-aml/.vscode/launch.json New launch configuration file with setups for running and testing the extension.
extensions/vscode-aml/.vscode/settings.json New settings file to customize editor behavior.
extensions/vscode-aml/.vscode/tasks.json New tasks defined for managing web development workflows.
extensions/vscode-aml/.vscodeignore New file created to specify files ignored when packaging the extension.
extensions/vscode-aml/CHANGELOG.md New changelog file documenting notable changes.
extensions/vscode-aml/README.md New README file outlining features and roadmap for the extension.
extensions/vscode-aml/esbuild.js New file introducing build configuration using esbuild.
extensions/vscode-aml/eslint.config.mjs New ESLint configuration file for TypeScript files.
extensions/vscode-aml/language-configuration.json New file defining language support configurations.
extensions/vscode-aml/package.json New file providing metadata and configuration for the vscode-aml extension.
extensions/vscode-aml/resources/schema.aml New file defining a structured schema for user authentication and content management.
extensions/vscode-aml/resources/schema.json New JSON schema file defining entities and relations for CMS and tracking.
extensions/vscode-aml/resources/schema.sql New SQL schema defining types and tables for user management and content management.
extensions/vscode-aml/snippets.json New file containing code snippets for AML.
extensions/vscode-aml/src/web/extension.ts New file introducing the main extension logic and command registrations.
extensions/vscode-aml/src/web/test/suite/extension.test.ts New test suite for the extension.
extensions/vscode-aml/src/web/test/suite/mochaTestRunner.ts New file for running Mocha tests in a browser environment.
extensions/vscode-aml/syntaxes/aml.tmLanguage.json New file defining syntax highlighting rules for AML.
extensions/vscode-aml/tsconfig.json New TypeScript configuration file specifying compiler options.
gateway/README.md Updated link reference for the desktop application.
integration/README.md File deleted.
integration/compose.yaml File deleted.
integration/mysql.sql File deleted.
integration/postgres.sql File deleted.
libs/aml/src/extensions/monaco.ts Modified regex pattern for better attribute type matching.
libs/connector-bigquery/README.md Updated link for the Desktop app.
libs/connector-couchbase/README.md Updated link for the Desktop app.
libs/connector-mariadb/README.md Updated link for the Desktop app.
libs/connector-mongodb/README.md Updated link for the Desktop app.
libs/connector-mysql/README.md Updated link for the Desktop app.
libs/connector-oracle/README.md Updated link for the Desktop app.
libs/connector-postgres/README.md Updated link for the Desktop app.
libs/connector-snowflake/README.md Updated link for the Desktop app.
libs/connector-sqlserver/README.md Updated link for the Desktop app.
package.json Updated build script to exclude the ./extensions/desktop directory.
pnpm-workspace.yaml Updated package paths to reflect new directory structure.

Poem

In the garden of code, we hop and play,
With paths and scripts, we clear the way.
New links and files, like carrots in rows,
Enhancing our project, as each change grows.
So let’s celebrate, with a joyful cheer,
For every new feature brings us all near! 🐇✨

Warning

Rate limit exceeded

@loicknuchel has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 12 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 03f7f1d and 8922494.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@loicknuchel loicknuchel marked this pull request as ready for review November 25, 2024 12:36
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 27

🧹 Outside diff range and nitpick comments (38)
extensions/vscode-aml/resources/schema.aml (2)

8-10: Clarify the structure of the settings JSON field.

The nested fields theme and last_page within settings json nullable may not be correctly defined. In AML, to define the structure of a JSON field, you might need to use comments or annotations since JSON fields don't enforce a schema by default.

Consider documenting the expected structure of the settings field for clarity:

 settings json nullable
+  # Expected JSON structure:
+  # {
+  #   "theme": "light" | "dark",
+  #   "last_page": "string"
+  # }

22-22: Specify foreign key relationships explicitly for author field.

The author field references users(id) but doesn't specify the relationship type. For clarity, you might want to use -> to indicate the foreign key relationship, similar to how it's done with created_by and updated_by.

Apply this diff to clarify the relationship:

-author int -> users(id)
+author int -> users(id)

(If the arrow -> is already present and this is a formatting issue, please disregard.)

extensions/vscode-aml/esbuild.js (2)

76-78: Review the necessity of redefining 'global'

Defining global as globalThis may not be necessary and could lead to unexpected behaviors. Since the code is targeting the browser environment, and globalThis is already available, overriding global might introduce conflicts.

Consider removing the define option for global:

 define: {
-    global: 'globalThis',
 },

Ensure that any dependencies relying on global are appropriately handled or polyfilled.


80-86: Adjust the order of plugins for proper polyfilling

The NodeGlobalsPolyfillPlugin should be placed before other plugins that might rely on the polyfills it provides. Ensuring it runs early can prevent issues where subsequent plugins or code expect Node.js globals to be available.

Apply this diff to reorder the plugins:

 plugins: [
+    polyfill.NodeGlobalsPolyfillPlugin({
+        process: true,
+        buffer: true,
+    }),
     testBundlePlugin,
     esbuildProblemMatcherPlugin,
-    polyfill.NodeGlobalsPolyfillPlugin({
-        process: true,
-        buffer: true,
-    }),
 ],
backend/lib/azimutt_web/templates/website/docs/getting-started.html.heex (1)

3-7: LGTM! Consider adding ARIA attributes for better accessibility.

The added section provides a good transition to the main topics and uses semantic HTML with proper class naming.

Consider enhancing accessibility by adding an ARIA role:

-    <p class="lead">
+    <p class="lead" role="doc-introduction">
extensions/vscode-aml/src/web/test/suite/extension.test.ts (2)

8-9: Consider structuring tests by feature

The current test suite is too broad. Consider organizing tests into feature-specific suites for better maintainability.

Example structure:

suite('AML Extension Tests', () => {
    suite('Syntax Validation', () => {
        // Syntax related tests
    });
    
    suite('Command Execution', () => {
        // Command related tests
    });
    
    suite('Integration Tests', () => {
        // Integration with VSCode API tests
    });
});

1-5: Add type checking for VSCode API usage

While the imports are correct, consider adding type assertions or checks when using the VSCode API to ensure type safety.

Example:

import * as assert from 'assert';
import * as vscode from 'vscode';

// Add type guard
function isTextEditor(editor: unknown): editor is vscode.TextEditor {
    return editor instanceof vscode.TextEditor;
}
extensions/vscode-aml/src/web/test/suite/mochaTestRunner.ts (1)

1-7: Consider enhancing type safety and test reporting.

A few suggestions to improve the setup:

  1. Add type information to the import
  2. Consider using a more informative reporter for better debugging
-// Imports mocha for the browser, defining the `mocha` global.
-import 'mocha/mocha';
+import type * as Mocha from 'mocha';
+// Imports mocha for the browser, defining the `mocha` global.
+import 'mocha/mocha.js';

 mocha.setup({
   ui: 'tdd',
-  reporter: undefined
+  reporter: 'spec', // or 'html' for browser-friendly output
   timeout: 60000 // Optional: Add timeout for long-running tests
 });
extensions/vscode-aml/snippets.json (5)

2-6: Consider adding serial/autoincrement option for primary keys

The primary key snippet covers common types (uuid, int, bigint) but could be enhanced by adding serial/autoincrement as an option, which is frequently used in database schemas.

 "Primary key": {
     "prefix": "id",
-    "body": ["id ${1|uuid,int,bigint|} pk\n"],
+    "body": ["id ${1|uuid,int,bigint,serial|} pk\n"],
     "description": "A Primary Key column"
 }

7-18: Enhance relationship snippets with descriptions and nullable option

The relationship snippets could be improved by:

  1. Adding descriptions to help users understand each relationship type
  2. Including an optional nullable modifier
 "Many to one": {
     "prefix": ["fk", "->"],
-    "body": ["-> ${1:entity}(${2:attribute})$0"]
+    "body": ["-> ${1:entity}(${2:attribute})${3| ,nullable |}$0"],
+    "description": "Creates a many-to-one relationship (foreign key) to another table"
 },
 "One to one": {
     "prefix": ["fk", "--"],
-    "body": ["-- ${1:entity}(${2:attribute})$0"]
+    "body": ["-- ${1:entity}(${2:attribute})${3| ,nullable |}$0"],
+    "description": "Creates a one-to-one relationship (unique foreign key) to another table"
 },
 "Many to many": {
     "prefix": ["fk", "<>", "><"],
-    "body": ["<> ${1:entity}(${2:attribute})$0"]
+    "body": ["<> ${1:entity}(${2:attribute})${3| ,nullable |}$0"],
+    "description": "Creates a many-to-many relationship requiring a junction table"
 }

19-30: Add descriptions and type options for timestamp snippets

The timestamp snippets could be enhanced with:

  1. Descriptions explaining their purpose
  2. Predefined type options (timestamp, timestamptz)
 "Created At": {
     "prefix": "created_at",
-    "body": ["created_at ${1:timestamp}=`${2:now()}`\n"],
+    "body": ["created_at ${1|timestamp,timestamptz|}=`${2:now()}`\n"],
+    "description": "Adds a creation timestamp column with default value"
 },
 "Updated At": {
     "prefix": "updated_at",
-    "body": ["updated_at ${1:timestamp}=`${2:now()}`\n"],
+    "body": ["updated_at ${1|timestamp,timestamptz|}=`${2:now()}`\n"],
+    "description": "Adds an update timestamp column with default value"
 },
 "Timestamps": {
     "prefix": "timestamps",
-    "body": ["created_at ${1:timestamp}=`${2:now()}`", "updated_at ${1:timestamp}=`${2:now()}`\n"],
+    "body": ["created_at ${1|timestamp,timestamptz|}=`${2:now()}`", "updated_at ${1|timestamp,timestamptz|}=`${2:now()}`\n"],
+    "description": "Adds both creation and update timestamp columns"
 }

31-34: Add description and type options for soft delete snippet

The soft delete snippet could be enhanced with:

  1. Description explaining the soft delete pattern
  2. Predefined type options
 "Deleted At": {
     "prefix": "deleted_at",
-    "body": ["deleted_at ${1:timestamp} nullable\n"],
+    "body": ["deleted_at ${1|timestamp,timestamptz|} nullable\n"],
+    "description": "Adds a nullable timestamp column for soft deletes"
 }

35-46: Enhance user tracking snippets with descriptions and configurable table name

The user tracking snippets could be improved by:

  1. Adding descriptions to explain the auditing pattern
  2. Making the users table name configurable through a shared variable
 "Created By": {
     "prefix": "created_by",
-    "body": ["created_by -> ${1:users}(id)\n"],
+    "body": ["created_by -> \${1:${TM_SELECTED_TEXT:users}}(id)\n"],
+    "description": "Adds a foreign key column to track the creating user"
 },
 "Updated By": {
     "prefix": "updated_by",
-    "body": ["updated_by -> ${1:users}(id)\n"],
+    "body": ["updated_by -> \${1:${TM_SELECTED_TEXT:users}}(id)\n"],
+    "description": "Adds a foreign key column to track the updating user"
 },
 "Deleted By": {
     "prefix": "deleted_by",
-    "body": ["deleted_by nullable -> ${1:users}(id)\n"],
+    "body": ["deleted_by nullable -> \${1:${TM_SELECTED_TEXT:users}}(id)\n"],
+    "description": "Adds a nullable foreign key column to track the deleting user"
 }
extensions/vscode-aml/resources/schema.sql (2)

6-16: Consider these improvements to the users table

  1. Consider using UUID instead of integer for the primary key to support distributed systems and prevent ID enumeration.
  2. Add email format validation using CHECK constraint.
  3. Consider using JSONB instead of JSON for better performance and indexing capabilities.

Here's the suggested implementation:

 CREATE TABLE users (
-  id int PRIMARY KEY,
+  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
   name varchar(64) NOT NULL,
-  email varchar(256) NOT NULL UNIQUE,
+  email varchar(256) NOT NULL UNIQUE CHECK (email ~* '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$'),
   auth auth_kind NOT NULL,
-  settings json,
+  settings jsonb,
   created_at timestamp NOT NULL DEFAULT now(),
   updated_at timestamp NOT NULL DEFAULT now(),
   deleted_at timestamp
 );

46-53: Consider alternatives to polymorphic associations

The current design using item_kind and item_id as a polymorphic reference can't enforce referential integrity and might lead to invalid data.

Consider these alternatives:

  1. Separate junction tables approach (recommended for data integrity):
CREATE TABLE tracking.user_events (
    event_id uuid REFERENCES tracking.events(id),
    user_id int REFERENCES users(id),
    PRIMARY KEY (event_id)
);

CREATE TABLE tracking.post_events (
    event_id uuid REFERENCES tracking.events(id),
    post_id int REFERENCES cms.posts(id),
    PRIMARY KEY (event_id)
);

CREATE TABLE tracking.comment_events (
    event_id uuid REFERENCES tracking.events(id),
    comment_id int REFERENCES cms.comments(id),
    PRIMARY KEY (event_id)
);
  1. Check constraint approach (if junction tables are not preferred):
ALTER TABLE tracking.events
ADD CONSTRAINT valid_item_reference
CHECK (
    (item_kind = 'users' AND EXISTS (SELECT 1 FROM users WHERE id = item_id)) OR
    (item_kind = 'posts' AND EXISTS (SELECT 1 FROM cms.posts WHERE id = item_id)) OR
    (item_kind = 'comments' AND EXISTS (SELECT 1 FROM cms.comments WHERE id = item_id)) OR
    item_kind IS NULL
);
extensions/vscode-aml/README.md (6)

3-3: Add alt text to the marketplace badge for accessibility.

The marketplace badge image should include alt text to improve accessibility.

-[![](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
+[![VSCode Marketplace Version](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
🧰 Tools
🪛 Markdownlint (0.35.0)

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


7-7: Add descriptive alt text to the screenshot for accessibility.

The screenshot image should include descriptive alt text to improve accessibility and provide context.

-![AML in VS Code](assets/screenshot.png)
+![Screenshot showing AML syntax highlighting and features in Visual Studio Code](assets/screenshot.png)

23-28: Update API documentation links to VS Code API.

The roadmap items reference Monaco Editor API documentation, but since this is a VS Code extension, they should link to the VS Code Extension API documentation instead.

-auto-complete (cf [registerCompletionItemProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCompletionItemProvider.html))
+auto-complete (cf [registerCompletionItemProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCompletionItemProvider))
-rename (cf [registerRenameProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerRenameProvider.html))
+rename (cf [registerRenameProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerRenameProvider))
-hover infos (cf [registerHoverProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerHoverProvider.html))
+hover infos (cf [registerHoverProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerHoverProvider))
-go-to-definition (cf [registerDefinitionProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerDefinitionProvider.html))
+go-to-definition (cf [registerDefinitionProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerDefinitionProvider))
-quick-fixes (cf [registerCodeActionProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCodeActionProvider.html))
+quick-fixes (cf [registerCodeActionProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeActionProvider))
-hints with actions (cf [registerCodeLensProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCodeLensProvider.html))
+hints with actions (cf [registerCodeLensProvider](https://code.visualstudio.com/api/references/vscode-api#languages.registerCodeLensProvider))

42-42: Fix grammatical error.

There's a grammatical error in this sentence.

-VS Code language extensions are made of several and quite independent part.
+VS Code language extensions are made of several and quite independent parts.

47-53: Consider adding relative links to referenced files.

The development section references several files. Consider adding relative links to make it easier for contributors to navigate to these files directly from the README.

-[language-configuration.json](language-configuration.json)
+[language-configuration.json](./language-configuration.json)
-[syntaxes/aml.tmLanguage.json](syntaxes/aml.tmLanguage.json)
+[syntaxes/aml.tmLanguage.json](./syntaxes/aml.tmLanguage.json)
-[src/web/extension.ts](src/web/extension.ts)
+[src/web/extension.ts](./src/web/extension.ts)
-[snippets.json](snippets.json)
+[snippets.json](./snippets.json)
-[package.json](package.json)
+[package.json](./package.json)

64-65: Enhance publication instructions with security considerations.

The publication section could benefit from:

  1. A note about securely handling the Personal Access Token
  2. More detailed steps for the publication process
  3. Version management guidelines

Consider expanding this section with more detailed instructions and security best practices for handling the PAT.

extensions/vscode-aml/package.json (1)

60-87: Improve command title consistency and clarity.

There are several inconsistencies in the command definitions:

  1. Inconsistent capitalization: "New database schema" vs "convert JSON to AML"
  2. The "convert AML to" command title seems incomplete
  3. Only the preview command has an icon

Consider applying these changes:

       {
         "command": "aml.new",
         "category": "AML",
-        "title": "New database schema"
+        "title": "New Database Schema",
+        "icon": "$(new-file)"
       },
       {
         "command": "aml.fromJson",
         "category": "AML",
-        "title": "convert JSON to AML"
+        "title": "Convert JSON to AML",
+        "icon": "$(json)"
       },
       {
         "command": "aml.fromSQL",
         "category": "AML",
-        "title": "convert SQL to AML"
+        "title": "Convert SQL to AML",
+        "icon": "$(database)"
       },
       {
         "command": "aml.convert",
         "category": "AML",
-        "title": "convert AML to"
+        "title": "Convert AML to Other Format",
+        "icon": "$(export)"
       },
.dockerignore (1)

Line range hint 1-109: Consider cleaning up redundant patterns.

The file contains many duplicated patterns from different versions, particularly in the Elm-related sections. Consider consolidating them to improve maintainability:

  1. The multiple version-specific Elm patterns under backend/_build could be simplified to a single pattern
  2. Some nested patterns are already covered by parent directory ignores

Example consolidation:

- backend/_build/dev/rel/azimutt/lib/azimutt-2.0.1670333486/priv/static/elm/**/dist
- backend/_build/dev/rel/azimutt/lib/azimutt-2.0.1670334969/priv/static/elm/**/dist
- # ... more version-specific patterns
+ backend/_build/**/priv/static/elm/**/dist
+ backend/_build/**/priv/static/elm/**/script.js
+ backend/_build/**/priv/static/elm/**/script.js.map
extensions/vscode-aml/resources/schema.json (2)

3-24: Consider additional constraints and indexing for the users entity

The users entity is well-structured but could benefit from some additional safeguards:

  1. Add an email format check constraint
  2. Consider adding a size limit for the settings JSON
  3. Add an index on deleted_at to optimize soft delete queries
  4. Consider a default value for the auth field
 {
   "name": "users",
   "attrs": [
     {"name": "id", "type": "int", "extra": {"autoIncrement": null}},
     {"name": "name", "type": "varchar(64)"},
-    {"name": "email", "type": "varchar(256)"},
+    {"name": "email", "type": "varchar(256)", "extra": {"check": "email ~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$'"}},
-    {"name": "auth", "type": "auth_kind"},
+    {"name": "auth", "type": "auth_kind", "default": "password"},
     {"name": "settings", "type": "json", "null": true, "attrs": [
       {"name": "theme", "type": "theme"},
       {"name": "last_page", "type": "string", "doc": "url of the last visited page"}
-    ]},
+    ], "extra": {"check": "jsonb_typeof(settings) = 'object' AND jsonb_array_length(settings) <= 1000"}},
     {"name": "created_at", "type": "timestamp", "default": "`now()`"},
     {"name": "updated_at", "type": "timestamp", "default": "`now()`"},
     {"name": "deleted_at", "type": "timestamp", "null": true}
   ],
   "pk": {"attrs": [["id"]]},
   "indexes": [
     {"attrs": [["email"]], "unique": true},
-    {"name": "user_name_idx", "attrs": [["name"]]}
+    {"name": "user_name_idx", "attrs": [["name"]]},
+    {"name": "user_deleted_at_idx", "attrs": [["deleted_at"]]}
   ],
   "extra": {"color": "blue", "tags": ["pii"], "alias": "u"}
 }

90-95: Consider using schema names instead of line numbers in comments

The line numbers in comments might become incorrect when the schema changes. Consider using schema names directly:

   "extra": {
     "comments": [
-      {"line": 15, "comment": "CMS tables"},
-      {"line": 39, "comment": "Tracking tables"}
+      {"schema": "cms", "comment": "CMS tables"},
+      {"schema": "tracking", "comment": "Tracking tables"}
     ]
   }
.pre-commit-config.yaml (2)

Line range hint 1-191: Add pre-commit hook for the VSCode extension

Given the TypeScript module resolution issues mentioned in the PR, consider adding a pre-commit hook for the VSCode extension to ensure it builds successfully before commits. This would help catch packaging issues early in the development cycle.

Add this hook configuration:

    - id: vscode-aml
      name: 'extensions/vscode-aml'
      language: system
      entry: bash -c 'cd extensions/vscode-aml && exec npm run build && exec npm run package'
      pass_filenames: false
      files: extensions/vscode-aml/.*\.ts*$

192-193: Document testing strategy for extensions

The comments indicate that extensions lack tests and builds. Given the current PR's focus on VSCode extension packaging issues, consider:

  1. Documenting why these extensions don't have tests/builds in pre-commit
  2. Adding a testing strategy for the VSCode extension to prevent packaging issues

Would you like help creating a testing strategy document for the extensions directory?

backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex (3)

Line range hint 24-28: Consider using relative URLs for GitHub links.

Using absolute GitHub URLs makes the documentation more fragile to repository changes. Consider using environment variables or relative paths for repository links.

Example approach:

-<a href="https://github.com/azimuttapp/azimutt/blob/main/libs/connector-postgres/src/postgres.ts" target="_blank">
+<a href="<%= @github_repo %>/blob/main/libs/connector-postgres/src/postgres.ts" target="_blank">

39-39: Consider enhancing data privacy clarity.

While the statement is accurate, it could be more explicit about the client-side processing to build trust.

Suggested enhancement:

-the parsing is made on the frontend and your schema is shown with no business data sent to Azimutt.
+the parsing is performed entirely in your browser (client-side) and your schema is shown with no business data ever sent to Azimutt servers.

56-59: Consider adding JSON schema example.

While the documentation now better explains the JSON import process, adding a small example of the expected JSON schema format would make it more user-friendly.

Example addition:

You just have to format it according to the JSON Schema below the import section.
+For example:
+```json
+{
+  "tables": [{
+    "name": "users",
+    "columns": [
+      {"name": "id", "type": "uuid"},
+      {"name": "email", "type": "varchar(255)"}
+    ]
+  }]
+}
+```
extensions/vscode-aml/src/web/extension.ts (3)

30-30: Consider managing preview panel state locally

Using a global variable for the preview panel state could lead to issues in larger extensions. Consider encapsulating this within a class or manager.

-let previewPanel: WebviewPanel | undefined = undefined
+class PreviewManager {
+    private panel: WebviewPanel | undefined;
+    
+    getPanel(): WebviewPanel | undefined {
+        return this.panel;
+    }
+    
+    setPanel(panel: WebviewPanel | undefined): void {
+        this.panel = panel;
+    }
+}
+const previewManager = new PreviewManager();

126-157: Enhance preview functionality

The preview implementation could be improved:

  1. Add error handling for preview generation failures
  2. Consider adding syntax highlighting for the preview
  3. Add loading state while preview is being generated

Would you like help implementing these enhancements to the preview functionality?


197-197: Make the assignment more explicit

The assignment in the while condition was flagged by static analysis. While this is a common pattern, it can be made more explicit:

-		while (match = regex.exec(document.getText())) {
+		while (true) {
+			match = regex.exec(document.getText());
+			if (!match) break;
🧰 Tools
🪛 Biome (1.9.4)

[error] 197-197: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

libs/aml/src/extensions/monaco.ts (5)

Line range hint 73-76: Consider extracting regex patterns to a configuration file.

The regex patterns are complex and scattered throughout the code. Consider extracting them to a separate configuration file for better maintainability and reusability.

Create a new file monaco.patterns.ts:

export const patterns = {
  entity: /^[a-zA-Z_][a-zA-Z0-9_#]*/,
  attributeName: /^ +[a-zA-Z_][a-zA-Z0-9_#]*/,
  // ... other patterns
}

Line range hint 73-74: Add documentation for regex patterns.

The regex patterns are crucial for the language support but lack documentation explaining their purpose and expected matches.

Add JSDoc comments:

+/**
+ * Matches valid entity names in AML.
+ * Examples: User, Product_Category, Order#1
+ */
 export const entityRegex = /^[a-zA-Z_][a-zA-Z0-9_#]*/
+/**
+ * Matches valid attribute names with leading spaces.
+ * Examples: " name", " created_at", " user_id"
+ */
 export const attributeNameRegex = /^ +[a-zA-Z_][a-zA-Z0-9_#]*/

Also applies to: 86-87


Line range hint 4-4: Address TODO comments.

There are unimplemented features mentioned in TODO comments that could enhance the editor experience.

Would you like me to help implement:

  1. Hover provider to show entity/type definition or AML doc
  2. Refactoring support for renaming entities/attributes

Also applies to: 73-74


Line range hint 301-315: Enhance code actions provider with more quick fixes.

The code actions provider currently only handles legacy replacements. Consider adding more quick fixes for common issues:

  1. Adding missing properties
  2. Fixing type mismatches
  3. Adding missing relations
export const codeAction = (opts: {} = {}): CodeActionProvider => ({
  provideCodeActions(model: ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeActionList> {
    const actions: CodeAction[] = [];
    
    if (context.markers.length > 0) {
      // Handle different marker types
      context.markers.forEach(marker => {
        if (marker.message.includes('missing property')) {
          actions.push(createAddPropertyAction(marker, model, range));
        }
        // Add more handlers
      });
    }
    
    return {actions, dispose() {}};
  }
});

Line range hint 401-421: Add error handling to helper functions.

The helper functions like suggestText and suggestSnippet should validate their inputs to prevent runtime errors.

function suggestText(text: string, kind: CompletionItemKind, position: Position, opts: {insert?: string, documentation?: string} = {}): CompletionItem {
    if (!text || !position) {
        throw new Error('Invalid arguments: text and position are required');
    }
    
    return {
        label: text.trim(),
        kind,
        insertText: opts.insert || text,
        range: {
            startLineNumber: position.lineNumber,
            startColumn: position.column,
            endLineNumber: position.lineNumber,
            endColumn: position.column,
        },
        documentation: opts.documentation,
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e0806e0 and d0b8290.

⛔ Files ignored due to path filters (13)
  • extensions/browser-extension/public/assets/azimutt_128.png is excluded by !**/*.png
  • extensions/browser-extension/public/assets/azimutt_16.png is excluded by !**/*.png
  • extensions/browser-extension/public/assets/azimutt_32.png is excluded by !**/*.png
  • extensions/browser-extension/public/assets/azimutt_48.png is excluded by !**/*.png
  • extensions/desktop/images/icon.ico is excluded by !**/*.ico
  • extensions/desktop/images/icon.png is excluded by !**/*.png
  • extensions/vscode-aml/assets/icon-white.png is excluded by !**/*.png
  • extensions/vscode-aml/assets/icon-white.svg is excluded by !**/*.svg
  • extensions/vscode-aml/assets/icon.png is excluded by !**/*.png
  • extensions/vscode-aml/assets/icon.svg is excluded by !**/*.svg
  • extensions/vscode-aml/assets/screenshot.png is excluded by !**/*.png
  • extensions/vscode-aml/package-lock.json is excluded by !**/package-lock.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (48)
  • .dockerignore (1 hunks)
  • .gitignore (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • backend/.gitignore (1 hunks)
  • backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex (4 hunks)
  • backend/lib/azimutt_web/templates/website/docs/getting-started.html.heex (1 hunks)
  • backend/lib/azimutt_web/templates/website/docs/what-is-azimutt.html.heex (3 hunks)
  • extensions/browser-extension/package.json (1 hunks)
  • extensions/desktop/package.json (1 hunks)
  • extensions/vscode-aml/.gitignore (1 hunks)
  • extensions/vscode-aml/.npmrc (1 hunks)
  • extensions/vscode-aml/.vscode/extensions.json (1 hunks)
  • extensions/vscode-aml/.vscode/launch.json (1 hunks)
  • extensions/vscode-aml/.vscode/settings.json (1 hunks)
  • extensions/vscode-aml/.vscode/tasks.json (1 hunks)
  • extensions/vscode-aml/.vscodeignore (1 hunks)
  • extensions/vscode-aml/CHANGELOG.md (1 hunks)
  • extensions/vscode-aml/README.md (1 hunks)
  • extensions/vscode-aml/esbuild.js (1 hunks)
  • extensions/vscode-aml/eslint.config.mjs (1 hunks)
  • extensions/vscode-aml/language-configuration.json (1 hunks)
  • extensions/vscode-aml/package.json (1 hunks)
  • extensions/vscode-aml/resources/schema.aml (1 hunks)
  • extensions/vscode-aml/resources/schema.json (1 hunks)
  • extensions/vscode-aml/resources/schema.sql (1 hunks)
  • extensions/vscode-aml/snippets.json (1 hunks)
  • extensions/vscode-aml/src/web/extension.ts (1 hunks)
  • extensions/vscode-aml/src/web/test/suite/extension.test.ts (1 hunks)
  • extensions/vscode-aml/src/web/test/suite/mochaTestRunner.ts (1 hunks)
  • extensions/vscode-aml/syntaxes/aml.tmLanguage.json (1 hunks)
  • extensions/vscode-aml/tsconfig.json (1 hunks)
  • gateway/README.md (1 hunks)
  • integration/README.md (0 hunks)
  • integration/compose.yaml (0 hunks)
  • integration/mysql.sql (0 hunks)
  • integration/postgres.sql (0 hunks)
  • libs/aml/src/extensions/monaco.ts (1 hunks)
  • libs/connector-bigquery/README.md (1 hunks)
  • libs/connector-couchbase/README.md (1 hunks)
  • libs/connector-mariadb/README.md (1 hunks)
  • libs/connector-mongodb/README.md (1 hunks)
  • libs/connector-mysql/README.md (1 hunks)
  • libs/connector-oracle/README.md (1 hunks)
  • libs/connector-postgres/README.md (1 hunks)
  • libs/connector-snowflake/README.md (1 hunks)
  • libs/connector-sqlserver/README.md (1 hunks)
  • package.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
💤 Files with no reviewable changes (4)
  • integration/README.md
  • integration/compose.yaml
  • integration/mysql.sql
  • integration/postgres.sql
✅ Files skipped from review due to trivial changes (24)
  • .gitignore
  • backend/.gitignore
  • extensions/browser-extension/package.json
  • extensions/vscode-aml/.gitignore
  • extensions/vscode-aml/.npmrc
  • extensions/vscode-aml/.vscode/extensions.json
  • extensions/vscode-aml/.vscode/launch.json
  • extensions/vscode-aml/.vscode/settings.json
  • extensions/vscode-aml/.vscode/tasks.json
  • extensions/vscode-aml/.vscodeignore
  • extensions/vscode-aml/CHANGELOG.md
  • extensions/vscode-aml/language-configuration.json
  • extensions/vscode-aml/syntaxes/aml.tmLanguage.json
  • extensions/vscode-aml/tsconfig.json
  • gateway/README.md
  • libs/connector-bigquery/README.md
  • libs/connector-couchbase/README.md
  • libs/connector-mariadb/README.md
  • libs/connector-mongodb/README.md
  • libs/connector-mysql/README.md
  • libs/connector-oracle/README.md
  • libs/connector-postgres/README.md
  • libs/connector-snowflake/README.md
  • libs/connector-sqlserver/README.md
🧰 Additional context used
🪛 Markdownlint (0.35.0)
extensions/vscode-aml/README.md

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)

🪛 Biome (1.9.4)
extensions/vscode-aml/src/web/extension.ts

[error] 197-197: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (22)
extensions/vscode-aml/resources/schema.aml (1)

31-31: Ensure consistency in foreign key declarations.

In post_id int -> cms.posts(id), make sure that the foreign key relationship is correctly defined and consistent with other relationships in the schema.

Run the following script to verify foreign key declarations:

✅ Verification successful

Foreign key declaration is consistent with schema design

The foreign key post_id int -> cms.posts(id) is correctly defined and follows the same pattern as other foreign key relationships in the schema:

  • It references an existing table cms.posts
  • It references the primary key id of that table
  • The data type int matches the referenced column's type
  • The syntax is consistent with other foreign keys in the schema (e.g., author int -> users(id), created_by -> users(id))
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Ensure all foreign key fields correctly reference existing tables and fields.

# Check for foreign key references
rg -A 0 $'->' *.aml

Length of output: 427


Script:

#!/bin/bash
# Search for foreign key references in the schema file
rg "\->" "extensions/vscode-aml/resources/schema.aml"

# Also check for table definitions to verify they exist
rg "table" "extensions/vscode-aml/resources/schema.aml"

Length of output: 299


Script:

#!/bin/bash
# Let's get more context around these foreign keys and table definitions
rg -B 2 -A 2 "table|schema" "extensions/vscode-aml/resources/schema.aml"

# Also get the full content of the schema file to understand the complete structure
cat "extensions/vscode-aml/resources/schema.aml"

Length of output: 1597

extensions/vscode-aml/esbuild.js (2)

88-94: Handle cleanup in watch mode to prevent resource leaks

When running in watch mode, the esbuild context is not disposed of upon process termination, which could lead to resource leaks. It's good practice to handle termination signals to gracefully dispose of resources.

Consider adding listeners for termination signals to dispose of the esbuild context:

 if (watch) {
     await ctx.watch();
+    // Handle process termination signals
+    process.on('SIGINT', async () => {
+        await ctx.dispose();
+        process.exit();
+    });
 } else {
     await ctx.rebuild();
     await ctx.dispose();
 }

Would you like assistance in implementing this cleanup?


48-49: ⚠️ Potential issue

Ensure glob pattern correctly matches test files

The glob pattern used may not match test files with extensions .test.ts and .test.tsx as intended. The {} braces in the pattern are for brace expansion, but in some glob implementations, this requires enabling the braceExpansion option.

Apply this diff to adjust the glob pattern:

- const files = await glob.glob('*.test.{ts,tsx}', { cwd: testsRoot, posix: true });
+ const files = await glob.glob('*.test.@(ts|tsx)', { cwd: testsRoot, posix: true, braceExpansion: true });

Alternatively, ensure that glob is configured to support brace expansion or use a different pattern such as:

+ const files = await glob.glob('*.test.*(ts|tsx)', { cwd: testsRoot, posix: true });

Please verify that the glob library version supports the used pattern and options.

pnpm-workspace.yaml (1)

5-6: LGTM! Good structural organization.

Moving extension packages under a dedicated "extensions" directory improves the project's organization and maintainability.

Let's verify that all related configurations have been updated to reflect this structural change:

✅ Verification successful

✅ Directory structure change is properly implemented

The verification confirms that:

  • Both directories exist in their new locations: extensions/browser-extension/ and extensions/desktop/
  • Each extension has its own package.json file in place
  • Root package.json has been updated to handle the new structure (e.g., --filter=!\"./extensions/desktop\")
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all configurations are consistent with the new directory structure
# Expected: All references should use the new paths under "extensions/"

# Check package.json files for old paths
echo "Checking package.json files for old paths..."
rg -l "\"(directory|path)\": *\"(browser-extension|desktop)\"" 

# Check for any remaining references to old paths in various config files
echo "Checking config files for old paths..."
rg -l "browser-extension/|desktop/" \
  --type yaml \
  --type json \
  --type toml \
  --glob '!pnpm-workspace.yaml' \
  --glob '!**/node_modules/**'

Length of output: 379


Script:

#!/bin/bash
# Let's try a different approach to verify the structural changes

# 1. First, check if the directories exist in the new location
echo "Checking if directories exist in the new structure..."
fd -t d "^(browser-extension|desktop)$" extensions/

# 2. Look for any package.json files in these directories
echo -e "\nChecking package.json files in extension directories..."
fd -t f "package.json" extensions/

# 3. Check for references to these paths in any file (excluding binary and generated files)
echo -e "\nChecking for any remaining references to old paths..."
rg -l "(browser-extension|desktop)" \
  --type-not binary \
  --type-not lock \
  --glob '!**/node_modules/**' \
  --glob '!**/.git/**' \
  --glob '!pnpm-workspace.yaml'

# 4. Check the root package.json specifically
echo -e "\nChecking root package.json content..."
cat package.json

Length of output: 2374

extensions/vscode-aml/src/web/test/suite/mochaTestRunner.ts (1)

1-26: Consider browser-specific test infrastructure improvements.

As this is a browser-based test runner for a VSCode extension, consider these architectural improvements:

  1. Add browser compatibility checks
  2. Implement proper test timeouts and memory management
  3. Add integration with VSCode's test API

Let's verify the VSCode extension test setup:

extensions/vscode-aml/eslint.config.mjs (1)

1-28: Verify ESLint configuration with TypeScript files.

Let's verify that the ESLint configuration properly handles TypeScript files and module resolution.

✅ Verification successful

ESLint configuration is properly set up for TypeScript

The ESLint configuration is correctly set up with proper TypeScript support:

  • TypeScript files are present and follow standard import patterns
  • tsconfig.json has appropriate module resolution (Node16) and strict type checking
  • ESLint config properly integrates TypeScript parser and plugin with necessary rules
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify ESLint configuration with TypeScript files

# Check for TypeScript files in the extension
echo "Checking for TypeScript files..."
fd -e ts -d 2 . extensions/vscode-aml

# Check for existing import statements
echo "Checking import statements..."
rg "import .* from" --type ts extensions/vscode-aml

# Check for tsconfig.json
echo "Checking TypeScript configuration..."
cat extensions/vscode-aml/tsconfig.json

Length of output: 1531

package.json (2)

33-33: LGTM! Path updated to reflect new directory structure.

The build script filter has been correctly updated to maintain the same behavior while reflecting the new directory structure where components are organized under the 'extensions' directory.


33-33: Verify workspace configuration consistency and build requirements.

Since this PR introduces a new VSCode extension, please verify:

  1. If the VSCode extension should also be excluded from the main build
  2. If the path patterns are consistent across all workspace configuration files
✅ Verification successful

Let me gather more information about the build configurations and exclusions to make a proper assessment.


Build configuration is correctly set up for extensions

The current workspace configuration is consistent and appropriate:

  1. The VSCode extension (vscode-aml) doesn't need to be excluded from the main build because:

    • It has its own independent build process using vscode:prepublish and package-web scripts
    • It's not included in the workspace packages list in pnpm-workspace.yaml
  2. The desktop extension exclusion is correct because:

    • It uses Electron-specific build tools (electron-forge make)
    • It's explicitly listed in the workspace but excluded from the main build command
    • This separation prevents conflicts between desktop and web-based builds
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for workspace configuration consistency and build patterns

# Check workspace configuration files for path patterns
echo "Checking pnpm-workspace.yaml for extension paths:"
cat pnpm-workspace.yaml

# Look for other build-related configuration files
echo -e "\nChecking for other build configuration files:"
fd -t f "^(package|tsconfig|vite.config|rollup.config|webpack.config).*\.(json|js|ts)$" -x echo "Found config: {}"

# Check if vscode extension is referenced in any build configs
echo -e "\nChecking for vscode extension references:"
rg -l "vscode|vsce|extension" -g "package.json" -g "*.config.*"

Length of output: 3586


Script:

#!/bin/bash
# Check the build scripts and dependencies in package.json files
echo "Checking root package.json build script:"
cat package.json | jq -r '.scripts.build'

echo -e "\nChecking VSCode extension package.json:"
cat extensions/vscode-aml/package.json | jq -r '{scripts,engines,devDependencies}'

echo -e "\nChecking desktop extension package.json:"
cat extensions/desktop/package.json | jq -r '{scripts,build}'

echo -e "\nChecking if other packages have special build configurations:"
for f in $(fd -t f "package.json" -E "node_modules"); do
    echo "=== $f ==="
    cat "$f" | jq -r 'select(.scripts.build != null) | .scripts.build'
done

Length of output: 8698

extensions/vscode-aml/snippets.json (1)

1-47: Well-structured snippets covering essential database patterns

The snippets provide a comprehensive set of templates for common database patterns including:

  • Primary keys
  • Various relationship types
  • Timestamp tracking
  • Soft deletes
  • User auditing

The structure is clean and follows VSCode snippet conventions.

extensions/desktop/package.json (2)

20-20: LGTM! Directory path update is consistent with repository restructuring.

The change from "desktop" to "extensions/desktop" aligns with the new project structure.

Let's verify the consistency of this change across the workspace:

✅ Verification successful

Directory path update is consistent with monorepo workspace configuration

The verification confirms that:

  • The new path "extensions/desktop" is correctly listed in the workspace packages
  • No references to the old "desktop" directory path remain in package.json files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the directory structure changes are consistent across workspace configuration

# Check if the new path exists and is referenced in workspace config
fd -t f "pnpm-workspace.yaml" -x cat {} \; | grep -A 5 "packages:"

# Check if there are any remaining references to the old path
rg "\"directory\":\s*\"desktop\"" -g "package.json"

Length of output: 231


Line range hint 1-67: Consider updating TypeScript configuration to address module resolution issues.

Given the PR objectives mentioning TypeScript module resolution issues, particularly with @azimutt/* workspace dependencies, consider the following recommendations:

  1. Ensure tsconfig.json is configured with "moduleResolution": "bundler" for better ESM compatibility
  2. Add .ts, .js, .mts, .mjs extensions to the compilerOptions.moduleResolution settings

Let's check the current TypeScript configuration:

backend/lib/azimutt_web/templates/website/docs/what-is-azimutt.html.heex (4)

5-6: LGTM! Content improvements enhance clarity.

The rephrasing in the lead paragraph improves readability while maintaining a professional tone.


20-20: Verify the Gateway documentation path exists.

The added link improves navigation, but we should ensure the referenced documentation page exists.

✅ Verification successful

Link to Gateway documentation is valid

The gateway documentation file exists at backend/lib/azimutt_web/templates/website/docs/gateway.html.heex, confirming that the added link is correctly pointing to an existing documentation page.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the Gateway documentation page exists
# Expected: Find the gateway documentation file

fd --type f "gateway" backend/lib/azimutt_web/templates/website/docs/

Length of output: 134


34-34: Verify the CLI documentation path exists.

The added link follows the consistent documentation pattern, but we should verify the referenced page exists.

✅ Verification successful

CLI documentation path exists and is correctly referenced

The link to the CLI documentation is valid as the file cli.html.heex exists at the expected location in the documentation directory.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the CLI documentation page exists
# Expected: Find the CLI documentation file

fd --type f "cli" backend/lib/azimutt_web/templates/website/docs/

Length of output: 126


40-40: Verify the converters documentation path exists.

The added link maintains documentation consistency, but we should verify the referenced page exists.

✅ Verification successful

Link to converters documentation is valid

The converters documentation page exists at backend/lib/azimutt_web/templates/website/docs/converters.html.heex, confirming that the added link is correctly pointing to an existing resource.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the converters documentation page exists
# Expected: Find the converters documentation file

fd --type f "converters" backend/lib/azimutt_web/templates/website/docs/

Length of output: 140

extensions/vscode-aml/package.json (1)

9-11: Consider lowering the minimum VSCode version requirement.

The extension requires VSCode ^1.95.0 which is quite recent. Consider if you really need features from this version, as lowering it would increase the potential user base.

.dockerignore (1)

107-109: LGTM! Verify the extension path restructuring.

The new ignore patterns for the browser extension look correct and follow standard practices.

Let's verify the extension path restructuring:

✅ Verification successful

Path restructuring verified and correctly implemented

The extension path restructuring has been successfully verified:

  • The extensions/ directory exists and contains the browser extension in the correct location
  • The browser extension package is properly configured with the new path in package.json
  • All references to the browser extension in the workspace configuration (pnpm-workspace.yaml) use the correct path
  • No references to old/incorrect paths were found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the extension directory structure and package locations

# Check if the extensions directory exists and contains expected subdirectories
fd --type d --max-depth 2 '^extensions$'

# Check for any remaining references to old paths
rg -g '!.dockerignore' 'browser-extension/(?!.*extensions/)'

Length of output: 374


Script:

#!/bin/bash
# Let's try a different approach to verify the extension path restructuring

# Check if extensions directory exists and list its contents
ls -la extensions/

# Find all package.json files under extensions directory
fd package.json extensions/

# Search for any browser-extension related paths in the codebase
rg -g '!.dockerignore' 'browser-extension'

# Look for any extension-related configuration files
fd -e config.js -e manifest.json extensions/

Length of output: 1167

extensions/vscode-aml/resources/schema.json (2)

73-83: LGTM! Relations are well-defined

The relations section properly defines all foreign key relationships, including the polymorphic associations for the events table. The inline attribute is appropriately used.


84-89: LGTM! Types are well-defined

The type definitions are clear and properly namespaced. The values are appropriate for each enum type.

backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex (1)

48-50: LGTM! Documentation improvements for Prisma section.

The changes enhance clarity by properly describing Prisma and providing relevant documentation links.

extensions/vscode-aml/src/web/extension.ts (1)

43-43: 🛠️ Refactor suggestion

Consider implementing cleanup in deactivate

The empty deactivate function might miss opportunities for proper cleanup. Consider disposing of any remaining resources, especially the preview panel.

-export function deactivate() {}
+export function deactivate() {
+    if (previewPanel) {
+        previewPanel.dispose();
+        previewPanel = undefined;
+    }
+}

Likely invalid or redundant comment.

libs/aml/src/extensions/monaco.ts (1)

58-58: Verify the regex pattern change for attribute types.

The regex pattern has been updated to allow one or more spaces around keywords. While this change improves flexibility, we should ensure it doesn't introduce any unintended matches.

✅ Verification successful

Let me gather more specific information about the attribute type usage in the codebase.

This will help us verify if the regex pattern matches the actual usage patterns in the codebase and test files.


Based on the search results, I can now verify the regex pattern change. The codebase shows extensive usage of SQL data types in various formats, including:

  1. Simple types: varchar, text, int, numeric, etc.
  2. Types with parameters: varchar(10), varchar(140), etc.
  3. Types with spaces: double precision
  4. Types with modifiers: timestamp with time zone, character varying

The updated regex pattern in the review accommodates these variations by:

  • Using + for spaces to handle types like double precision and timestamp with time zone
  • Supporting optional parameters with \d+
  • Including all common SQL data types
  • Maintaining word boundaries with \b

The regex pattern change is correct and matches the actual usage in the codebase.

The pattern matches all attribute type declarations found in the codebase while maintaining proper word boundaries and flexibility for spaces. No issues were found with the updated pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the regex pattern against sample AML files to ensure it matches correctly

# Search for attribute type declarations in AML files
rg -l '\.aml$' | while read -r file; do
  echo "=== $file ==="
  rg -A 1 '^\s+[a-zA-Z_][a-zA-Z0-9_#]*\s+\w+' "$file"
done

Length of output: 7135


Script:

#!/bin/bash
# Search for actual attribute type declarations in the codebase
rg -A 1 'type\s+(varchar|text|int|numeric|float|double|boolean|timestamp|date|time|interval|json|string|number)' --type ts

# Also check for any test files that might contain attribute type examples
fd -e test.ts -e spec.ts | xargs rg 'type.*:.*\b(varchar|text|int|numeric|float|double|boolean|timestamp|date|time|interval|json|string|number)\b'

Length of output: 69233

extensions/vscode-aml/resources/schema.aml Show resolved Hide resolved
extensions/vscode-aml/resources/schema.aml Show resolved Hide resolved
extensions/vscode-aml/resources/schema.aml Show resolved Hide resolved
extensions/vscode-aml/resources/schema.aml Show resolved Hide resolved
Comment on lines +67 to +68
format: 'cjs',
minify: production,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use ECMAScript module format for browser target

The build configuration specifies format: 'cjs', which outputs CommonJS modules. Since the target platform is the browser, using ECMAScript modules ('esm') is more appropriate and ensures better compatibility with modern browsers.

Apply this diff to change the module format:

 format: 'cjs',
+// Use 'esm' format for browser compatibility
-format: 'cjs',
+format: 'esm',

Committable suggestion skipped: line range outside the PR's diff.

extensions/vscode-aml/src/web/extension.ts Show resolved Hide resolved
extensions/vscode-aml/src/web/extension.ts Show resolved Hide resolved
Comment on lines 192 to 215
class AmlDocumentSymbolProvider implements DocumentSymbolProvider {
provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]> {
const symbols: DocumentSymbol[] = []
const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g
let match: RegExpExecArray | null = null
while (match = regex.exec(document.getText())) {
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 + all.length)
)
// see https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.DocumentSymbol.html
symbols.push(new DocumentSymbol(
name,
``, // TODO: set entity doc if available
keyword?.trim() === 'type' ? SymbolKind.Enum : SymbolKind.Class,
range,
range
))
}
return symbols
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using proper parsing instead of regex

The current regex-based symbol extraction might be fragile for complex AML syntax. Consider:

  1. Using a proper parser for more reliable symbol extraction
  2. Adding support for nested symbols
  3. Including more symbol information (fields, relationships)

Example enhancement:

 class AmlDocumentSymbolProvider implements DocumentSymbolProvider {
     provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]> {
-        const regex = /(^|\n)(type\s+)?((?:[a-zA-Z_][a-zA-Z0-9_]*\.)?[a-zA-Z_][a-zA-Z0-9_]*)/g;
+        // TODO: Use proper AML parser when @azimutt/aml is available
+        const symbols: DocumentSymbol[] = [];
+        const lines = document.getText().split('\n');
+        let currentTable: DocumentSymbol | undefined;
+        
+        for (let i = 0; i < lines.length; i++) {
+            const line = lines[i].trim();
+            if (line && !line.startsWith('#')) {
+                if (!line.startsWith(' ')) {
+                    // Table definition
+                    const range = new Range(i, 0, i, line.length);
+                    currentTable = new DocumentSymbol(
+                        line,
+                        '',
+                        SymbolKind.Class,
+                        range,
+                        range
+                    );
+                    symbols.push(currentTable);
+                } else if (currentTable) {
+                    // Field definition
+                    const range = new Range(i, 0, i, line.length);
+                    currentTable.children.push(new DocumentSymbol(
+                        line.trim(),
+                        '',
+                        SymbolKind.Field,
+                        range,
+                        range
+                    ));
+                }
+            }
+        }
         return symbols;
     }
 }

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Biome (1.9.4)

[error] 197-197: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

extensions/vscode-aml/src/web/extension.ts Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (8)
extensions/vscode-aml/README.md (5)

3-3: Add alt text to the marketplace badge for accessibility.

The marketplace badge image should include descriptive alt text.

-[![](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
+[![VSCode Marketplace Version](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
🧰 Tools
🪛 Markdownlint (0.35.0)

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


7-7: Use relative path for screenshot image.

The absolute path starting with / might not work correctly in all contexts. Consider using a relative path instead.

-![AML in VS Code](/extensions/vscode-aml/assets/screenshot.png)
+![AML in VS Code](./assets/screenshot.png)

19-30: Consider creating GitHub issues for roadmap items.

The roadmap contains several valuable features. To better track progress and allow community participation, consider creating GitHub issues for each planned feature. This will help with:

  • Progress tracking
  • Community discussions
  • Feature prioritization

Would you like me to help create GitHub issues for these roadmap items?


42-42: Fix grammatical error in sentence.

There's a grammatical error in the sentence.

-VS Code language extensions are made of several and quite independent part.
+VS Code language extensions are made of several and quite independent parts.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~42-~42: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)


54-59: Consider structuring development tips as a list.

The tips section would be more readable as a structured list.

-Tips:
-
-Debug extension via F5 (Run Web Extension)
-Relaunch the extension from the debug toolbar after changing code in `src/web/extension.ts`
-Reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes

+Tips:
+
+1. Debug extension via F5 (Run Web Extension)
+2. Relaunch the extension from the debug toolbar after changing code in `src/web/extension.ts`
+3. Reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes
extensions/vscode-aml/src/web/extension.ts (3)

43-43: Consider implementing cleanup in deactivate()

The deactivate function should clean up any resources that were created during the extension's lifetime, such as disposing of the previewPanel if it exists.

-export function deactivate() {}
+export function deactivate() {
+    if (previewPanel) {
+        previewPanel.dispose();
+        previewPanel = undefined;
+    }
+}

30-30: Consider using a Map for managing multiple preview panels

The current singleton pattern with previewPanel limits the extension to a single preview. Consider using a Map to support multiple preview panels, keyed by document URI.

-let previewPanel: WebviewPanel | undefined = undefined
+const previewPanels = new Map<string, WebviewPanel>();

 function previewAml(editor: TextEditor, context: ExtensionContext) {
     if (editor.document.languageId !== 'aml') {
         vscode.window.showErrorMessage('Needs AML file to preview it.')
         return
     }
-    if (!previewPanel) {
-        previewPanel = vscode.window.createWebviewPanel(...)
+    const uri = editor.document.uri.toString();
+    let panel = previewPanels.get(uri);
+    if (!panel) {
+        panel = vscode.window.createWebviewPanel(...)
+        previewPanels.set(uri, panel);

Also applies to: 131-156


168-184: Enhance preview HTML with proper styling and error handling

The current preview HTML is very basic. Consider:

  1. Adding CSS for better styling
  2. Implementing proper error handling for invalid AML
  3. Adding loading states for large files
 function buildAmlPreview(aml: string): string | undefined {
     const content = aml.trim()
     return `<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>AML preview</title>
+    <style>
+        body { font-family: system-ui; padding: 1rem; }
+        .error { color: red; }
+        .preview { margin-top: 1rem; }
+        pre { background: #f5f5f5; padding: 1rem; border-radius: 4px; }
+    </style>
 </head>
 <body>
     <a href="${openInAzimuttUrl(aml)}" target="_blank">Open in Azimutt</a>
-    <pre>${content}</pre>
+    <div class="preview">
+        ${content ? `<pre>${content}</pre>` : '<div class="error">Invalid AML content</div>'}
+    </div>
 </body>
 </html>`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d0b8290 and dc36eae.

📒 Files selected for processing (3)
  • extensions/vscode-aml/README.md (1 hunks)
  • extensions/vscode-aml/src/web/extension.ts (1 hunks)
  • extensions/vscode-aml/syntaxes/aml.tmLanguage.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • extensions/vscode-aml/syntaxes/aml.tmLanguage.json
🧰 Additional context used
🪛 LanguageTool
extensions/vscode-aml/README.md

[uncategorized] ~42-~42: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

🪛 Markdownlint (0.35.0)
extensions/vscode-aml/README.md

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)

🪛 Biome (1.9.4)
extensions/vscode-aml/src/web/extension.ts

[error] 196-196: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (1)
extensions/vscode-aml/src/web/extension.ts (1)

229-266: LGTM! Well-implemented utility functions

The utility functions are well-implemented with proper TypeScript types and error handling.

extensions/vscode-aml/README.md Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
extensions/vscode-aml/README.md (3)

3-3: Add alt text to the marketplace badge for accessibility.

Add descriptive alt text to the marketplace badge image.

-[![](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
+[![VSCode Marketplace Version](https://vsmarketplacebadges.dev/version/azimutt.vscode-aml.png)](https://marketplace.visualstudio.com/items?itemName=azimutt.vscode-aml)
🧰 Tools
🪛 Markdownlint (0.35.0)

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


19-30: Consider structuring the roadmap items.

The roadmap items could be better organized by grouping them into categories or phases. Consider:

  1. Core functionality (diagram preview, conversions)
  2. Editor features (auto-complete, hover, etc.)
  3. Advanced features (database connection)

This would help users and contributors understand the development priorities better.


42-42: Fix grammatical error.

There's a grammatical error in this sentence.

-VS Code language extensions are made of several and quite independent part.
+VS Code language extensions are made of several and quite independent parts.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~42-~42: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dc36eae and 90c926e.

📒 Files selected for processing (3)
  • extensions/vscode-aml/.vscodeignore (1 hunks)
  • extensions/vscode-aml/README.md (1 hunks)
  • extensions/vscode-aml/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • extensions/vscode-aml/.vscodeignore
  • extensions/vscode-aml/package.json
🧰 Additional context used
🪛 LanguageTool
extensions/vscode-aml/README.md

[uncategorized] ~42-~42: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

🪛 Markdownlint (0.35.0)
extensions/vscode-aml/README.md

3-3: null
Images should have alternate text (alt text)

(MD045, no-alt-text)

🔇 Additional comments (3)
extensions/vscode-aml/README.md (3)

12-14: LGTM!

The features section is clear and well-documented.


64-64: Reusing existing review comment about access token security.


7-7: Verify the screenshot path.

The screenshot path starts with a forward slash which might not work correctly on GitHub. Consider using a relative path instead.

✅ Verification successful

The screenshot path is valid and accessible

The screenshot exists at the specified path extensions/vscode-aml/assets/screenshot.png. While the path starts with a forward slash, this is actually a common and valid syntax for referencing images in markdown files on GitHub, as GitHub automatically resolves repository-relative paths starting with /. The current path will work correctly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the screenshot file exists at the specified path
if [ -f "extensions/vscode-aml/assets/screenshot.png" ]; then
    echo "Screenshot exists at the correct path"
else
    echo "Screenshot not found at the expected path"
fi

Length of output: 141

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (10)
extensions/vscode-aml/README.md (6)

9-9: Use a stable reference for the screenshot URL

The current URL uses refs/heads/main which might break if the branch structure changes. Consider using a specific commit hash or release tag instead of the branch reference.

-![AML in VS Code](https://raw.githubusercontent.com/azimuttapp/azimutt/refs/heads/main/extensions/vscode-aml/assets/screenshot.png)
+![AML in VS Code](https://raw.githubusercontent.com/azimuttapp/azimutt/<commit-hash>/extensions/vscode-aml/assets/screenshot.png)

20-20: Fix grammar in usage instructions

Add "the" before "documentation".

-Write your schema using AML, check [documentation](https://azimutt.app/docs/aml) is needed.
+Write your schema using AML, check the [documentation](https://azimutt.app/docs/aml) if needed.

24-38: Enhance the AML code example with more explanatory comments

Consider adding more inline comments to explain the AML syntax features being demonstrated, such as default values, enums, and timestamps.

 ```aml
 users
   id uuid pk
-  name varchar index
-  email varchar unique
-  role user_role(admin, guest)=guest
+  name varchar index        # demonstrates indexing
+  email varchar unique      # demonstrates unique constraint
+  role user_role(admin, guest)=guest  # demonstrates enum with default value

 posts | store all posts
   id uuid pk
   title varchar
   content text | allow markdown formatting
   author uuid -> users(id) # inline relation
-  created_at timestamp=`now()`
+  created_at timestamp=`now()`  # demonstrates default value with function

---

`44-50`: **Separate feature descriptions from implementation details**

Consider restructuring the roadmap to separate user-facing feature descriptions from technical implementation details. This makes the roadmap more accessible to users while preserving the technical notes.

```diff
-Add parsing errors ([createDiagnosticCollection](https://code.visualstudio.com/api/references/vscode-api#languages.createDiagnosticCollection)?)
-auto-complete (cf [registerCompletionItemProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCompletionItemProvider.html))
+### Planned Features
+- Syntax error detection and reporting
+- Intelligent code completion
+
+### Technical Implementation Notes
+- Use `createDiagnosticCollection` for error reporting
+- Implement `registerCompletionItemProvider` for auto-complete

64-64: Fix plural form in development section

Correct the noun number for better grammar.

-VS Code language extensions are made of several and quite independent part.
+VS Code language extensions are made of several and quite independent parts.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~64-~64: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)


1-90: Improve document structure with consistent heading hierarchy

Consider using consistent heading levels throughout the document and adding a table of contents for better navigation.

+# AML Support for VS Code
+
+## Table of Contents
+
+- [Features](#features)
+- [Usage](#usage)
+- [Roadmap](#roadmap)
+- [Issues & Contributing](#issues--contributing)
+- [Development](#development)
+  - [Components](#components)
+  - [Tips](#tips)
+- [Publication](#publication)
+
-# AML Support for VS Code
🧰 Tools
🪛 LanguageTool

[uncategorized] ~19-~19: You might be missing the article “the” here.
Context: ...age Create an empty .aml file or use AML: New database schema (ERD) command....

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[uncategorized] ~64-~64: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

extensions/vscode-aml/src/web/extension.ts (4)

30-30: Consider scoping the previewPanel variable

The previewPanel variable is declared in the global scope. Consider moving it inside the activate function and managing its lifecycle there for better encapsulation.

-let previewPanel: WebviewPanel | undefined = undefined
+export function activate(context: ExtensionContext) {
+    let previewPanel: WebviewPanel | undefined = undefined

43-43: Add documentation for the deactivate function

Even though the function is empty, it's part of the VSCode extension lifecycle. Add a JSDoc comment explaining why no cleanup is needed.

+/**
+ * This method is called when the extension is deactivated.
+ * No cleanup needed as all disposables are managed by VSCode's ExtensionContext.
+ */
 export function deactivate() {}

47-66: Consider making the sample content configurable

The sample content is hardcoded. Consider:

  1. Loading it from a template file
  2. Making it configurable through extension settings
  3. Adding multiple templates for different use cases

Would you like help implementing template configuration support?


257-267: Enhance debounce with cleanup handling

The current debounce implementation doesn't handle cleanup of pending timeouts.

 function debounce<F extends (...args: Parameters<F>) => ReturnType<F>>(
     func: F,
     delay: number
 ): (...args: Parameters<F>) => void {
     let timeout: Timeout
-    return (...args: Parameters<F>): void => {
+    const debouncedFn = (...args: Parameters<F>): void => {
         clearTimeout(timeout)
         timeout = setTimeout(() => func(...args), delay)
     }
+    // Add cleanup method
+    debouncedFn.cancel = () => {
+        clearTimeout(timeout)
+    }
+    return debouncedFn
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 90c926e and b32660b.

⛔ Files ignored due to path filters (3)
  • extensions/vscode-aml/assets/icon-white.png is excluded by !**/*.png
  • extensions/vscode-aml/assets/icon.png is excluded by !**/*.png
  • extensions/vscode-aml/assets/screenshot.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • extensions/vscode-aml/README.md (1 hunks)
  • extensions/vscode-aml/package.json (1 hunks)
  • extensions/vscode-aml/src/web/extension.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • extensions/vscode-aml/package.json
🧰 Additional context used
🪛 LanguageTool
extensions/vscode-aml/README.md

[uncategorized] ~19-~19: You might be missing the article “the” here.
Context: ...age Create an empty .aml file or use AML: New database schema (ERD) command....

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[uncategorized] ~64-~64: The grammatical number of this noun doesn’t look right. Consider replacing it.
Context: ...e made of several and quite independent part. For general knowledge, look at the [ex...

(AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)

🪛 Biome (1.9.4)
extensions/vscode-aml/src/web/extension.ts

[error] 197-197: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

extensions/vscode-aml/src/web/extension.ts Show resolved Hide resolved
extensions/vscode-aml/src/web/extension.ts Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (5)
extensions/vscode-aml/package.json (2)

9-11: Consider lowering the VSCode engine version requirement.

The current requirement of ^1.95.0 might unnecessarily limit your user base. Many of the features used in this extension might work with older versions of VSCode. Consider testing with lower versions (e.g., ^1.74.0) to support a broader user base.


86-89: Improve clarity of the convert command title.

The title "Convert AML to ..." is vague and doesn't indicate the available conversion options. Consider either:

  1. Listing the supported formats: "Convert AML to (JSON/SQL/...)"
  2. Or splitting into separate commands for each target format
extensions/vscode-aml/resources/schema.json (1)

90-95: Consider using schema-level comments instead of line numbers

Line numbers in comments can become stale when the schema changes. Consider moving these organizational comments to schema-level documentation.

 {
   "extra": {
     "comments": [
-      {"line": 15, "comment": "CMS tables"},
-      {"line": 39, "comment": "Tracking tables"}
+      {"schema": "cms", "comment": "CMS tables"},
+      {"schema": "tracking", "comment": "Tracking tables"}
     ]
   }
 }
extensions/vscode-aml/src/web/extension.ts (2)

74-75: Enhance user feedback for work-in-progress features

While the conversion features are being implemented, consider providing more informative feedback:

  1. Indicate the expected completion timeline
  2. Show a progress indicator for long-running operations
  3. Provide alternative workarounds if available
-vscode.window.showInformationMessage('JSON to AML conversion not implemented yet, work in progress...')
+await vscode.window.withProgress(
+  {
+    location: vscode.ProgressLocation.Notification,
+    title: "JSON to AML conversion",
+    cancellable: false
+  },
+  async () => {
+    await vscode.window.showInformationMessage(
+      'JSON to AML conversion is coming soon! In the meantime, you can use the Azimutt web app at https://azimutt.app',
+      'Open Azimutt'
+    ).then(selection => {
+      if (selection === 'Open Azimutt') {
+        vscode.env.openExternal(vscode.Uri.parse('https://azimutt.app'));
+      }
+    });
+  }
+);

Also applies to: 87-88, 102-124


169-185: Enhance preview functionality with syntax highlighting

The current preview shows plain text content. Consider enhancing it with:

  1. Syntax highlighting using Prism.js or highlight.js
  2. Dark theme support based on VSCode's current theme
  3. Custom CSS for better readability
 return `<!DOCTYPE html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>AML preview</title>
+    <link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism.min.css" rel="stylesheet" />
+    <style>
+      body { padding: 16px; }
+      pre { margin: 0; }
+      .vscode-dark pre { background: #1e1e1e; }
+    </style>
 </head>
 <body class="${panel.webview.options.localResourceRoots ? 'vscode-dark' : 'vscode-light'}">
 	<a href="${openInAzimuttUrl(aml)}" target="_blank">Open in Azimutt</a>
-    <pre>${content}</pre>
+    <pre><code class="language-aml">${content}</code></pre>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
 </body>
 </html>`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b32660b and 03f7f1d.

📒 Files selected for processing (5)
  • backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex (4 hunks)
  • extensions/vscode-aml/package.json (1 hunks)
  • extensions/vscode-aml/resources/schema.json (1 hunks)
  • extensions/vscode-aml/resources/schema.sql (1 hunks)
  • extensions/vscode-aml/src/web/extension.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/lib/azimutt_web/templates/website/docs/create-your-project.html.heex
  • extensions/vscode-aml/resources/schema.sql
🧰 Additional context used
🪛 Biome (1.9.4)
extensions/vscode-aml/src/web/extension.ts

[error] 197-197: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (8)
extensions/vscode-aml/package.json (1)

6-6: Verify presence of referenced files.

The package.json references several files that are crucial for the extension. Let's verify they exist:

Also applies to: 50-51, 53-53, 60-60, 66-66

✅ Verification successful

All referenced files are present and correctly located

All files referenced in package.json exist in their expected locations within the extensions/vscode-aml directory:

  • ✓ assets/icon.png
  • ✓ assets/icon.svg
  • ✓ language-configuration.json
  • ✓ syntaxes/aml.tmLanguage.json
  • ✓ snippets.json
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all referenced files exist

echo "Checking referenced files..."
files=(
  "assets/icon.png"
  "assets/icon.svg"
  "language-configuration.json"
  "syntaxes/aml.tmLanguage.json"
  "snippets.json"
)

for file in "${files[@]}"; do
  if [ -f "$file" ]; then
    echo "✓ Found: $file"
  else
    echo "✗ Missing: $file"
  fi
done

Length of output: 858


Script:

#!/bin/bash
# Let's check if these files exist in different locations within the extensions/vscode-aml directory
cd extensions/vscode-aml 2>/dev/null
echo "Checking in extensions/vscode-aml directory..."
files=(
  "assets/icon.png"
  "assets/icon.svg"
  "language-configuration.json"
  "syntaxes/aml.tmLanguage.json"
  "snippets.json"
)

for file in "${files[@]}"; do
  if [ -f "$file" ]; then
    echo "✓ Found: $file"
  else
    echo "✗ Missing: $file"
  fi
done

# Let's also use fd to find these files anywhere in the repository
echo -e "\nSearching for files in the repository..."
fd -t f "icon\.(png|svg)$|language-configuration\.json$|aml\.tmLanguage\.json$|snippets\.json$"

Length of output: 1199

extensions/vscode-aml/resources/schema.json (4)

26-44: Past review comment is still applicable

The previous review comment about adding indexes for author and status fields remains valid.


46-58: Past review comment is still applicable

The previous review comment about adding indexes for post_id and created_at remains valid.


59-71: Past review comment is still applicable

The previous review comment about adding indexes and constraints for the events entity remains valid.


84-89: LGTM! Types are well-defined

The custom types are properly scoped and have appropriate values defined.

extensions/vscode-aml/src/web/extension.ts (3)

32-41: LGTM! Well-structured command registration

The command registration follows VSCode extension best practices:

  • Proper use of context subscriptions for cleanup
  • Clear command naming convention
  • Appropriate command handlers

257-267: LGTM! Well-implemented debounce utility

The debounce implementation is:

  • Type-safe with proper generic constraints
  • Correctly handles cleanup of previous timeouts
  • Uses appropriate TypeScript types

16-28: ⚠️ Potential issue

Address module compatibility issues with @azimutt packages

The commented imports are required for implementing the core functionality, but they're causing TypeScript compiler errors due to CommonJS and ECMAScript module incompatibilities. Consider:

  1. Update the imports to use the .js extension explicitly:
-// import {ParserError, ParserErrorLevel} from "@azimutt/models";
-/*import {generateSql, parseSql} from "@azimutt/parser-sql";
+import {ParserError, ParserErrorLevel} from "@azimutt/models/dist/types.js";
+import {generateSql, parseSql} from "@azimutt/parser-sql/dist/index.js";
  1. Update tsconfig.json to use "moduleResolution": "node16" or "nodenext".

extensions/vscode-aml/resources/schema.json Show resolved Hide resolved
extensions/vscode-aml/resources/schema.json Show resolved Hide resolved
extensions/vscode-aml/src/web/extension.ts Show resolved Hide resolved
@loicknuchel loicknuchel merged commit afec779 into main Nov 25, 2024
3 of 4 checks passed
@loicknuchel loicknuchel deleted the vscode-extension branch November 25, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant