Skip to content

Feature: Support Catalog User Interface#160

Merged
andreashimin merged 25 commits intodevelopfrom
feature/catalog-ui
May 18, 2023
Merged

Feature: Support Catalog User Interface#160
andreashimin merged 25 commits intodevelopfrom
feature/catalog-ui

Conversation

@andreashimin
Copy link
Contributor

@andreashimin andreashimin commented Apr 13, 2023

Description

Support the VulcanSQL Catalog user interface for retrieving data in a more efficient and user-friendly manner.

Sample vulcan.yaml

Please notice auth options should be either basic or password-file is setting up or disabled the auth

name: playground1
description: A starter Vulcan project
version: 0.1.0-alpha.1
template:
  provider: LocalFile
  # Path to .sql files
  folderPath: sqls
  codeLoader: InMemory
artifact:
  provider: LocalFile
  serializer: JSON
  # Path to build result
  filePath: result.json
schema-parser:
  reader: LocalFile
  # Path to .yaml files
  folderPath: sqls
document-generator:
  specs:
    - oas3
types:
  - RESTFUL
extensions:
  duckdb: '@vulcan-sql/extension-driver-duckdb'
profiles:
  - profile.yaml
rate-limit:
  options:
    interval:
      min: 1
    max: 10000
enforce-https:
  enabled: false
auth-source:
  options:
    key: token
auth:
  enabled: true
  options:
    basic:
      htpasswd-file:
        path: ./passwd.txt
        users:
          - name: jax
            attr:
              department: engineer
          - name: shimin
            attr:
              department: engineer
    password-file:
      path: ./bcrypt-passwd.txt
      users:
        - name: jax
          attr:
            department: engineer
        - name: shimin
          attr:
            department: engineer
response-format:
  enabled: true
  options:
    default: json
    formats:
      - json
      - csv

Catalog Server

Run Develop Command

yarn nx serve catalog-server

open http://localhost:4200

Default catalog option in yaml

catalog:
   hostname: localhost
   port: 4200

UI

  • Catalog list

image

image

VulcanSQL Serve

Run Develop Command

In labs/playground1, run

make start
// or
vulcan start // if already build

open http://localhost:3000

  1. Add /auth/available-types for retrieving auth type by API
  2. Add catalog-routers for providing APIs to Catalog Server.
    • /catalog/schemas
    • /catalog/schemas/:sourceName
      The schema APIs above will additionally provide url: string, apiDocUrl: string, shareKey: string
    • url: host + urlPath in VulcanSQL
    • apiDocUrl: the API document url in VulcanSQL
    • shareKey: the query string to pass the auth middleware
  3. exclude API docs path in auth middleware

VulcanSQL CLI

After discussion, the package.json will need to be updated after catalog publishing
You will need to do the actions below if you want to test in local

In labs/playground1

  1. Please add the line in package.json
{
   "dependencies": {
       ...
       "@vulcan-sql/catalog-server": "../../dist/packages/catalog-server"
   }
}
  1. Do yarn to install the dependencies

  2. Do make to replace the packages to your local developed packages

  3. You can use vulcan catalog command line in another terminal after running the VulcanSQL server with vulcan start.

VulcanSQL Package

  1. add -t --target for specific which target need to build and the default is vulcan-server

For Catalog Server, you can add the command below

vulcan package --output node --target catalog-server
  1. if user want to adjust the package folder path, can setting it like below
node-packager:
   vulcan-server:
       folderPath: dist
   catalog-server:
       folderPath: dist
docker-packager:
   vulcan-server:
       folderPath: dist
   catalog-server:
       folderPath: dist

Additional Context

@vercel
Copy link

vercel bot commented Apr 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vulcan-sql-document ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 17, 2023 7:23am

@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2023

Codecov Report

Patch coverage: 55.60% and project coverage change: -1.56 ⚠️

Comparison is base (f286a28) 93.01% compared to head (eccb2fe) 91.46%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #160      +/-   ##
===========================================
- Coverage    93.01%   91.46%   -1.56%     
===========================================
  Files          302      313      +11     
  Lines         4755     4943     +188     
  Branches       636      656      +20     
===========================================
+ Hits          4423     4521      +98     
- Misses         214      302      +88     
- Partials       118      120       +2     
Flag Coverage Δ
build 90.40% <48.48%> (-4.24%) ⬇️
catalog-server 100.00% <100.00%> (?)
cli 84.92% <50.00%> (-4.47%) ⬇️
core 94.36% <ø> (ø)
extension-dbt 97.43% <ø> (ø)
extension-debug-tools 98.11% <ø> (ø)
extension-driver-bq 85.21% <ø> (ø)
extension-driver-duckdb 96.46% <ø> (ø)
extension-driver-pg 96.11% <ø> (ø)
extension-driver-snowflake 96.22% <ø> (ø)
integration-testing 90.27% <ø> (ø)
serve 86.94% <60.39%> (-2.64%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...generator/spec-generator/oas3/oas3SpecGenerator.ts 97.46% <ø> (ø)
packages/serve/src/containers/types.ts 100.00% <ø> (ø)
...kages/serve/src/lib/auth/httpBasicAuthenticator.ts 87.23% <ø> (ø)
...es/serve/src/lib/auth/passwordFileAuthenticator.ts 81.81% <ø> (ø)
...ges/serve/src/lib/auth/simpleTokenAuthenticator.ts 100.00% <ø> (ø)
...ages/serve/src/models/extensions/documentRouter.ts 88.88% <ø> (ø)
...ges/serve/src/lib/catalog-router/catalogRouters.ts 26.19% <26.19%> (ø)
...b/packager/dockerPackager/dockerCatalogPackager.ts 29.41% <29.41%> (ø)
...c/lib/packager/nodePackager/nodeCatalogPackager.ts 31.25% <31.25%> (ø)
...ve/src/lib/middleware/auth/authRouterMiddleware.ts 91.48% <33.33%> (-8.52%) ⬇️
... and 24 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@kokokuo kokokuo left a comment

Choose a reason for hiding this comment

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

Besides some suggestions and question, serve,cli and labs package is LGTM 👍

The catalog-server and catalog-server-e2e need @fredalai, @JSYOU to assist, thanks!


private getAPIDocUrl(schema: APISchema) {
const splitUrl = schema.urlPath.split('/');
const restructureUrl = splitUrl
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest adding a comment with an example to explain the purpose.

.map((brick) =>
brick.startsWith(':') ? `{${brick.replace(':', '')}}` : brick
)
.join('~1');
Copy link
Contributor

Choose a reason for hiding this comment

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

Not know why need to join '~1', could you explain it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That actually the redoc generated url, it will convert the / to ~1
and looked like this one /doc#/paths/~1artist~1%7Bid%7D/get
but I had adjusted the redoc url in 1f05032
now it will more readable: doc#operation/get/artist/:id/works

const project = this.getProjectOptions();
const redoc = project?.['redoc'];
const docPath =
redoc?.url?.replace(/\/+$/, '').replace(/^\/+/, '') || 'doc';
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should need to add + in the first replace and send replace method? seems you would like to remove the first and last / ?

Btw, the same part also appeared in the AuthCredentialsMiddleware and AuthSourceNormalizerMiddleware, but you not add +

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for finding the difference, I just copied the original code from document router,
It will move to a function and provide the auth refactor function you mention below to use.

Comment on lines +43 to +55
// The endpoint not need contains auth credentials
const docPrefix =
this.projectOptions?.['redoc']?.url
.replace(/\/$/, '')
.replace(/^\//, '') || 'doc';
const pathsWithoutAuth = [
'/auth/token',
'/auth/available-types',
`/${docPrefix}`,
`/${docPrefix}/spec`,
`/${docPrefix}/redoc`,
];
if (pathsWithoutAuth.includes(context.path)) return next();
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems the AuthSourceNormalizerMiddleware also has the same code, maybe we could refactor the part to a function and put it in utils.ts under the auth folder, how do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, the code had been refactored in 1f05032

};

const serveCatalog = async (options: CatalogCommandOptions) => {
const next = await import(localModulePath('next'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question, where is next module from ? node modules ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will retrieve next module from the same local root with catalog-server.

Copy link
Contributor

@fredalai fredalai left a comment

Choose a reason for hiding this comment

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

For catalog-server-e2e part, we might be able to remove this part (https://nx.dev/packages/workspace/generators/remove#@nx/workspace:remove) first since we haven't added tests yet, what do you think?

@andreashimin
Copy link
Contributor Author

Hi @fredalai
I have fixed all the suggestions above :D
Please review again when you have free time, thanks~

Copy link
Contributor

@fredalai fredalai left a comment

Choose a reason for hiding this comment

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

LGTM, except for other comments.

Note: Update your branch based on the latest develop branch finally.

Copy link
Contributor

@kokokuo kokokuo left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the last comments!

Beside some suggestions that need to adjust, others LGTM 👍

Copy link
Contributor

@kokokuo kokokuo left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the suggestion, LGTM 👍

Let's please fix the CI test and it could prepare to merge :)

@andreashimin andreashimin merged commit f5ee500 into develop May 18, 2023
@andreashimin andreashimin deleted the feature/catalog-ui branch May 18, 2023 06:41
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.

6 participants