Skip to content

Commit

Permalink
Improve AMLv2 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
loicknuchel committed Jun 17, 2024
1 parent f7a3c88 commit 7141de9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cli/src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ export async function launchAnalyze(url: string, opts: Opts, logger: Logger): Pr
if (!connector) return Promise.reject(`Invalid connector for ${dbUrl.kind ? `${dbUrl.kind} db` : `unknown db (${dbUrl.full})`}`)
if (opts.email && !isValidEmail(dbUrl, opts.email, logger)) return Promise.reject(`Invalid email (${opts.email})`)
if (opts.key && !isValidKey(dbUrl, opts.email, opts.key, logger)) return Promise.reject(`Invalid key (${opts.key})`)
if (opts.ignoreViolationsFrom && !opts.key) return Promise.reject(`You need a 'key' to ignore violations from a report`)

// TODO: extend config for user, database, queries, data... ({user: {}, database: {}, queries: {}, data: {}, rules: {}})
const app = 'azimutt-analyze'
const folder = opts.folder || `~/.azimutt/analyze${dbUrl.db ? '/' + dbUrl.db : ''}`
const now = Date.now()
const conf: RulesConf = await loadConf(folder, logger)
const history = opts.key ? await loadHistory(folder, logger) : []
const referenceReport: AnalyzeReport | undefined = opts.key && opts.ignoreViolationsFrom ? await loadReferenceReport(folder, opts.ignoreViolationsFrom, logger) : undefined
const referenceReport: AnalyzeReport | undefined = opts.ignoreViolationsFrom ? await loadReferenceReport(folder, opts.ignoreViolationsFrom, logger) : undefined
const connectorLogger = conf.database?.logQueries ? logger : loggerNoOp
const db: Database = await connector.getSchema(app, dbUrl, {...conf.database, logger: connectorLogger})
const queries: DatabaseQuery[] = await connector.getQueryHistory(app, dbUrl, {database: dbUrl.db, logger: connectorLogger}).catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ program.command('analyze')
.option('--size <number>', 'change shown violations limit per rule, default is 3', strictParseInt)
.option('--only <rules>', 'limit analyze to specified rules')
.option('--key <key>', `reach out to ${azimuttEmail} to buy a key for incremental rules: degrading queries, unused tables/indexes, fast growing tables/indexes and more...`)
.option('--ignore-violations-from <known-violations-path>', 'ignore violations present in existing report, path is relative to report folder, needs --key argument')
.option('--ignore-violations-from <folder-relative-path>', 'ignore violations present in existing report, path is relative to report folder, needs --key argument')
.action((url, args) => exec(launchAnalyze(url, args, logger), args))

program.command('export')
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/PagesComponents/New/Views.elm
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ viewProjectSourceTab htmlId zone projects model =
div []
[ viewHeading "Import an existing project" [ text "If you have an Azimutt project, you can load it here." ]
, div [ class "mt-6" ] [ ProjectSource.viewLocalInput ProjectSourceMsg Noop (htmlId ++ "-remote-file") ]
, p [ css [ "mt-1 text-sm text-gray-500" ] ] [ text "Download your project with the button on the bottom of the settings (top right cog)." ]
, p [ css [ "mt-1 text-sm text-gray-500" ] ] [ text "Export your project: ⚡️ > Export your schema > Full project (top right)." ]
, ProjectSource.viewParsing ProjectSourceMsg zone Nothing model
, model.parsedProject
|> Maybe.andThen Result.toMaybe
Expand Down
6 changes: 6 additions & 0 deletions libs/serde-aml/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,9 @@ order_lines
```

Hope you enjoyed AML, happy hacking on [Azimutt](https://azimutt.app)!

## Similar DSLs

https://dbml.dbdiagram.io
https://docs.eraser.io/docs/syntax-1
https://www.quickdatabasediagrams.com
3 changes: 2 additions & 1 deletion libs/serde-aml/docs/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Some specific keys are standardized for certain objects and can be interpreted b

Here are the standardized properties for [entities](./entity.md):

- `color`, to define the default Azimutt color, the value should be one of: red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, gray
- `color`, to define the default Azimutt color, values: red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, gray
- `icon`, show a nice icon in the entity header, values: email, folder, home, user, users...
- `position`, to define the default position when added to a layout, the value should be an array with two numbers
- `notes`, to define default notes for the entity
- `tags`, to define default tags for the entity
Expand Down

0 comments on commit 7141de9

Please sign in to comment.