From 1177ce101197a6e1aa32cad89ca6fba3163e1650 Mon Sep 17 00:00:00 2001 From: Deepak Prabhakara Date: Wed, 11 Oct 2023 09:18:03 +0100 Subject: [PATCH] Format using prettier and add check-format step to GH actions (#1759) * prettier format * added check-format step to github actions --- .eslintignore | 3 + .github/ISSUE_TEMPLATE/bug_report.md | 4 +- .github/ISSUE_TEMPLATE/feature_request.md | 6 +- .github/workflows/main.yml | 3 +- .prettierignore | 5 + .prettierrc.js | 6 +- .release-it.json | 6 +- README.md | 5 +- .../CreateSSOConnection.tsx | 16 +- lib/utils.ts | 15 +- npm/.eslintignore | 3 +- npm/src/controller/analytics.ts | 18 +- npm/src/controller/oauth/allowed.ts | 11 +- npm/src/controller/oauth/code-verifier.ts | 4 +- npm/src/directory-sync/request.ts | 5 +- npm/src/directory-sync/types.ts | 9 +- npm/src/saml/claims.ts | 4 +- package.json | 7 +- styles/globals.css | 14 +- swagger/swagger.json | 250 +++++------------- 20 files changed, 136 insertions(+), 258 deletions(-) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..a08d5e9c3 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules +dist +npm/dist \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 50ea97083..bf5c1459d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,9 @@ --- name: Bug report about: Report any issues with the platform -title: "" +title: '' labels: bug -assignees: "" +assignees: '' --- Found a bug? Please fill out the sections below. 👍 diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 3e53a7e54..ebd239907 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,9 +1,9 @@ --- name: Feature request about: Suggest a feature or idea -title: "" +title: '' labels: enhancement -assignees: "" +assignees: '' --- > Please check if your Feature Request has not been already raised in the [Discussions Tab](https://github.com/boxyhq/jackson/discussions), as we would like to reduce duplicates. If it has been already raised, simply upvote it 🔼. @@ -40,4 +40,4 @@ assignees: "" You might want to link to related issues here, if you haven't already. --> -(Write your answer here.) \ No newline at end of file +(Write your answer here.) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea117c926..d08c5dc7e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -139,7 +139,8 @@ jobs: restore-keys: | ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- - run: npm run custom-install - - run: npm run lint + - run: npm run check-lint + - run: npm run check-format - run: npm run build - run: npm run test working-directory: ./npm diff --git a/.prettierignore b/.prettierignore index bddbcd8a7..72dc9a12f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,6 +5,11 @@ public **/**/.next **/**/public npm/migration/** +npm/dist/** +npm/.nyc_output/** +.vscode/** + +npm/package-lock.json *.lock *.log diff --git a/.prettierrc.js b/.prettierrc.js index b28ecb7ae..19e37507f 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -3,9 +3,9 @@ module.exports = { bracketSameLine: true, singleQuote: true, jsxSingleQuote: true, - trailingComma: "es5", + trailingComma: 'es5', semi: true, printWidth: 110, - arrowParens: "always", - importOrderSeparation: true, + arrowParens: 'always', + // importOrderSeparation: true, }; diff --git a/.release-it.json b/.release-it.json index c4242d488..ab02f3e9c 100644 --- a/.release-it.json +++ b/.release-it.json @@ -20,9 +20,7 @@ "tagAnnotation": "Release ${version}", "tagArgs": [], "push": true, - "pushArgs": [ - "--follow-tags" - ], + "pushArgs": ["--follow-tags"], "pushRepo": "" }, "npm": { @@ -48,4 +46,4 @@ "pr": ":rocket: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._" } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 38351f0aa..542926b90 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,10 @@

[⬆️ Take a look at our Issues ⬆️](https://github.com/boxyhq/jackson/issues) +

-___ +---

· Explore the docs » @@ -27,8 +28,6 @@ ___ · SaaS Early Access »

- - # ⭐️ SAML Jackson: Enterprise SSO made simple

diff --git a/components/setup-link-instructions/CreateSSOConnection.tsx b/components/setup-link-instructions/CreateSSOConnection.tsx index 4a8ba9171..36a00c637 100644 --- a/components/setup-link-instructions/CreateSSOConnection.tsx +++ b/components/setup-link-instructions/CreateSSOConnection.tsx @@ -26,22 +26,10 @@ const CreateSSOConnection = ({ setupLinkToken, idpType }: CreateSSOConnectionPro save: `/api/setup/${setupLinkToken}/sso-connection`, }; - - return idpType === 'saml' ? ( - + ) : ( - + ); }; diff --git a/lib/utils.ts b/lib/utils.ts index a923988af..394e2bd69 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -61,14 +61,13 @@ export const strategyChecker = (req: NextApiRequest): { isSAML: boolean; isOIDC: // The oidcMetadata JSON will be parsed here export const oidcMetadataParse = ( - body: - | ( - | OIDCSSOConnectionWithDiscoveryUrl - | (Omit & { oidcMetadata: string }) - ) & { - clientID: string; - clientSecret: string; - } + body: ( + | OIDCSSOConnectionWithDiscoveryUrl + | (Omit & { oidcMetadata: string }) + ) & { + clientID: string; + clientSecret: string; + } ) => { if (!body.oidcDiscoveryUrl && typeof body.oidcMetadata === 'string') { try { diff --git a/npm/.eslintignore b/npm/.eslintignore index 76add878f..a08d5e9c3 100644 --- a/npm/.eslintignore +++ b/npm/.eslintignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +npm/dist \ No newline at end of file diff --git a/npm/src/controller/analytics.ts b/npm/src/controller/analytics.ts index 6c4363082..1dd6fbb92 100644 --- a/npm/src/controller/analytics.ts +++ b/npm/src/controller/analytics.ts @@ -31,9 +31,12 @@ export class AnalyticsController { await this.send(); } - setInterval(async () => { - await this.send(); - }, 60 * 60 * 24 * 1000); + setInterval( + async () => { + await this.send(); + }, + 60 * 60 * 24 * 1000 + ); } async send() { @@ -45,9 +48,12 @@ export class AnalyticsController { }, (err: Error | undefined) => { if (err) { - setTimeout(() => { - this.send(); - }, 1000 * 60 * 60); + setTimeout( + () => { + this.send(); + }, + 1000 * 60 * 60 + ); return; } diff --git a/npm/src/controller/oauth/allowed.ts b/npm/src/controller/oauth/allowed.ts index 6abd26975..902c5dd7f 100644 --- a/npm/src/controller/oauth/allowed.ts +++ b/npm/src/controller/oauth/allowed.ts @@ -1,7 +1,4 @@ -export const redirect = ( - redirectUrl: string, - redirectUrls: string[] -): boolean => { +export const redirect = (redirectUrl: string, redirectUrls: string[]): boolean => { const url: URL = new URL(redirectUrl); for (const idx in redirectUrls) { @@ -9,11 +6,7 @@ export const redirect = ( // TODO: Check pathname, for now pathname is ignored - if ( - rUrl.protocol === url.protocol && - rUrl.hostname === url.hostname && - rUrl.port === url.port - ) { + if (rUrl.protocol === url.protocol && rUrl.hostname === url.hostname && rUrl.port === url.port) { return true; } } diff --git a/npm/src/controller/oauth/code-verifier.ts b/npm/src/controller/oauth/code-verifier.ts index 03adfcbb7..90dfaef2a 100644 --- a/npm/src/controller/oauth/code-verifier.ts +++ b/npm/src/controller/oauth/code-verifier.ts @@ -5,7 +5,5 @@ export const transformBase64 = (input: string): string => { }; export const encode = (code_challenge: string): string => { - return transformBase64( - crypto.createHash('sha256').update(code_challenge).digest('base64') - ); + return transformBase64(crypto.createHash('sha256').update(code_challenge).digest('base64')); }; diff --git a/npm/src/directory-sync/request.ts b/npm/src/directory-sync/request.ts index 365f3bf4a..ecca1aa8d 100644 --- a/npm/src/directory-sync/request.ts +++ b/npm/src/directory-sync/request.ts @@ -7,7 +7,10 @@ import type { } from '../typings'; export class RequestHandler { - constructor(private directoryUsers: IDirectoryUsers, private directoryGroups: IDirectoryGroups) {} + constructor( + private directoryUsers: IDirectoryUsers, + private directoryGroups: IDirectoryGroups + ) {} async handle(request: DirectorySyncRequest, callback?: EventCallback): Promise { const resourceType = request.resourceType.toLowerCase(); diff --git a/npm/src/directory-sync/types.ts b/npm/src/directory-sync/types.ts index e7819b5b9..a55550f21 100644 --- a/npm/src/directory-sync/types.ts +++ b/npm/src/directory-sync/types.ts @@ -157,11 +157,10 @@ export type UserPatchOperation = { export type GroupPatchOperation = { op: 'add' | 'remove' | 'replace'; path?: 'members' | 'displayName'; - value: - | { - value: string; - display?: string; - }[]; + value: { + value: string; + display?: string; + }[]; }; export type GroupMembership = { diff --git a/npm/src/saml/claims.ts b/npm/src/saml/claims.ts index bb6a7f6e5..9268293ca 100644 --- a/npm/src/saml/claims.ts +++ b/npm/src/saml/claims.ts @@ -35,8 +35,8 @@ const mapping = [ ...arrayMapping, ]; -type attributes = typeof mapping[number]['attribute']; -type schemas = typeof mapping[number]['schema']; +type attributes = (typeof mapping)[number]['attribute']; +type schemas = (typeof mapping)[number]['schema']; const map = (claims: Record) => { arrayMapping.forEach((m) => { diff --git a/package.json b/package.json index 97bd3ab5a..ecc72d228 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "dev": "cross-env JACKSON_API_KEYS=secret IDP_ENABLED=true next dev -p 5225", "dev-dbs": "docker-compose -f ./_dev/docker-compose.yml up -d", "dev-dbs-destroy": "docker-compose -f ./_dev/docker-compose.yml down --volumes --remove-orphans", - "lint": "next lint && eslint -c .eslintrc.js --ext .ts ./", "mongo": "cross-env JACKSON_API_KEYS=secret DB_ENGINE=mongo DB_URL=mongodb://localhost:27017/jackson npm run dev", "pre-loaded": "cross-env JACKSON_API_KEYS=secret DB_ENGINE=mem PRE_LOADED_CONNECTION='./_dev/saml_config' npm run dev", "pre-loaded-db": "cross-env JACKSON_API_KEYS=secret PRE_LOADED_CONNECTION='./_dev/saml_config' npm run dev", @@ -50,7 +49,11 @@ "prebuild": "ts-node --logError prebuild.ts", "build": "next build", "postbuild": "ts-node --logError postbuild.ts", - "release": "git checkout release && git merge origin/main && release-it" + "release": "git checkout release && git merge origin/main && release-it", + "check-types": "tsc --pretty --noEmit", + "check-format": "prettier --check .", + "check-lint": "next lint && eslint -c .eslintrc.js --ext ts --ext tsx --ext js ./", + "format": "prettier --write ." }, "dependencies": { "@boxyhq/metrics": "0.2.5", diff --git a/styles/globals.css b/styles/globals.css index 036cd31b1..ce2e60259 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -10,8 +10,18 @@ html, body { padding: 0; margin: 0; - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, - Droid Sans, Helvetica Neue, sans-serif; + font-family: + -apple-system, + BlinkMacSystemFont, + Segoe UI, + Roboto, + Oxygen, + Ubuntu, + Cantarell, + Fira Sans, + Droid Sans, + Helvetica Neue, + sans-serif; } a { diff --git a/swagger/swagger.json b/swagger/swagger.json index 80fe01739..28d20cc74 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -16,10 +16,7 @@ }, "host": "localhost:5225", "basePath": "/", - "schemes": [ - "http", - "https" - ], + "schemes": ["http", "https"], "securityDefinitions": { "apiKey": { "type": "apiKey", @@ -38,16 +35,9 @@ "post": { "summary": "Create SSO connection", "operationId": "create-sso-connection", - "tags": [ - "Single Sign On" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["Single Sign On"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "parameters": [ { "$ref": "#/parameters/nameParamPost" @@ -107,13 +97,8 @@ "patch": { "summary": "Update SSO Connection", "operationId": "update-sso-connection", - "tags": [ - "Single Sign On" - ], - "consumes": [ - "application/json", - "application/x-www-form-urlencoded" - ], + "tags": ["Single Sign On"], + "consumes": ["application/json", "application/x-www-form-urlencoded"], "parameters": [ { "$ref": "#/parameters/clientIDParamPatch" @@ -196,9 +181,7 @@ } ], "operationId": "get-connections", - "tags": [ - "Single Sign On" - ], + "tags": ["Single Sign On"], "responses": { "200": { "$ref": "#/responses/200Get" @@ -231,9 +214,7 @@ ], "summary": "Delete SSO Connections", "operationId": "delete-sso-connection", - "tags": [ - "Single Sign On" - ], + "tags": ["Single Sign On"], "responses": { "200": { "description": "Success" @@ -256,9 +237,7 @@ } ], "operationId": "get-connections-by-product", - "tags": [ - "Single Sign On" - ], + "tags": ["Single Sign On"], "responses": { "200": { "$ref": "#/responses/200Get" @@ -276,12 +255,8 @@ "post": { "summary": "Code exchange", "operationId": "oauth-code-exchange", - "tags": [ - "OAuth" - ], - "consumes": [ - "application/x-www-form-urlencoded" - ], + "tags": ["OAuth"], + "consumes": ["application/x-www-form-urlencoded"], "parameters": [ { "name": "grant_type", @@ -356,9 +331,7 @@ "get": { "summary": "Get profile", "operationId": "oauth-get-profile", - "tags": [ - "OAuth" - ], + "tags": ["OAuth"], "responses": { "200": { "description": "Success", @@ -413,16 +386,9 @@ "post": { "summary": "Create a Setup Link", "operationId": "create-sso-setup-link", - "tags": [ - "Setup Links | Single Sign On" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["Setup Links | Single Sign On"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "parameters": [ { "$ref": "#/parameters/tenantParamPost" @@ -460,9 +426,7 @@ } ], "operationId": "delete-sso-setup-link", - "tags": [ - "Setup Links | Single Sign On" - ], + "tags": ["Setup Links | Single Sign On"], "responses": { "200": { "description": "Success", @@ -489,9 +453,7 @@ } ], "operationId": "get-sso-setup-link", - "tags": [ - "Setup Links | Single Sign On" - ], + "tags": ["Setup Links | Single Sign On"], "responses": { "200": { "description": "Success", @@ -506,16 +468,9 @@ "post": { "summary": "Create a Setup Link", "operationId": "create-dsync-setup-link", - "tags": [ - "Setup Links | Directory Sync" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["Setup Links | Directory Sync"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "parameters": [ { "$ref": "#/parameters/tenantParamPost" @@ -547,9 +502,7 @@ } ], "operationId": "delete-dsync-setup-link", - "tags": [ - "Setup Links | Directory Sync" - ], + "tags": ["Setup Links | Directory Sync"], "responses": { "200": { "description": "Success", @@ -576,9 +529,7 @@ } ], "operationId": "get-dsync-setup-link", - "tags": [ - "Setup Links | Directory Sync" - ], + "tags": ["Setup Links | Directory Sync"], "responses": { "200": { "description": "Success", @@ -598,9 +549,7 @@ } ], "operationId": "get-sso-setup-link-by-product", - "tags": [ - "Setup Links | Single Sign On" - ], + "tags": ["Setup Links | Single Sign On"], "responses": { "200": { "description": "Success", @@ -623,9 +572,7 @@ } ], "operationId": "get-dsync-setup-link-by-product", - "tags": [ - "Setup Links | Directory Sync" - ], + "tags": ["Setup Links | Directory Sync"], "responses": { "200": { "description": "Success", @@ -651,12 +598,8 @@ "type": "string" } ], - "tags": [ - "SAML Traces" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Traces"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -675,12 +618,8 @@ "$ref": "#/parameters/product" } ], - "tags": [ - "SAML Traces" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Traces"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -741,16 +680,9 @@ "type": "string" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "responses": { "200": { "description": "Success", @@ -773,16 +705,9 @@ "$ref": "#/parameters/product" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "responses": { "200": { "description": "Success", @@ -808,12 +733,8 @@ "type": "string" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -834,12 +755,8 @@ "type": "string" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success" @@ -855,12 +772,8 @@ "$ref": "#/parameters/product" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -892,12 +805,8 @@ "type": "string" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -922,12 +831,8 @@ "$ref": "#/parameters/directoryId" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -959,12 +864,8 @@ "type": "string" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -989,12 +890,8 @@ "$ref": "#/parameters/directoryId" } ], - "tags": [ - "Directory Sync" - ], - "produces": [ - "application/json" - ], + "tags": ["Directory Sync"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -1069,16 +966,9 @@ "type": "string" } ], - "tags": [ - "SAML Federation" - ], - "produces": [ - "application/json" - ], - "consumes": [ - "application/x-www-form-urlencoded", - "application/json" - ], + "tags": ["SAML Federation"], + "produces": ["application/json"], + "consumes": ["application/x-www-form-urlencoded", "application/json"], "responses": { "200": { "description": "Success", @@ -1116,12 +1006,8 @@ "type": "string" } ], - "tags": [ - "SAML Federation" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Federation"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -1198,12 +1084,8 @@ "type": "string" } ], - "tags": [ - "SAML Federation" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Federation"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -1238,12 +1120,8 @@ "type": "string" } ], - "tags": [ - "SAML Federation" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Federation"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -1266,12 +1144,8 @@ "type": "string" } ], - "tags": [ - "SAML Federation" - ], - "produces": [ - "application/json" - ], + "tags": ["SAML Federation"], + "produces": ["application/json"], "responses": { "200": { "description": "Success", @@ -1301,9 +1175,7 @@ "provider": "okta.com" }, "defaultRedirectUrl": "https://hoppscotch.io/", - "redirectUrl": [ - "https://hoppscotch.io/" - ], + "redirectUrl": ["https://hoppscotch.io/"], "tenant": "hoppscotch.io", "product": "API Engine", "name": "Hoppscotch-SP", @@ -1899,4 +1771,4 @@ } }, "tags": [] -} \ No newline at end of file +}