@scalar/mock-server 0.2.111 → 0.2.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @scalar/mock-server
2
2
 
3
+ ## 0.2.112
4
+
5
+ ### Patch Changes
6
+
7
+ - fa6afe8: chore: code formatting
8
+ - 1223c1f: chore: code style
9
+ - Updated dependencies [54fdfcb]
10
+ - Updated dependencies [1223c1f]
11
+ - @scalar/oas-utils@0.2.105
12
+ - @scalar/openapi-parser@0.10.7
13
+ - @scalar/openapi-types@0.1.7
14
+
3
15
  ## 0.2.111
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
- import type { MockServerOptions } from './types.js';
2
1
  import { Hono } from 'hono';
2
+ import type { MockServerOptions } from './types.js';
3
3
  /**
4
4
  * Create a mock server instance
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"createMockServer.d.ts","sourceRoot":"","sources":["../src/createMockServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAS5D,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAA;AAMzC;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,uFAoDhE"}
1
+ {"version":3,"file":"createMockServer.d.ts","sourceRoot":"","sources":["../src/createMockServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAgB,MAAM,MAAM,CAAA;AAGzC,OAAO,KAAK,EAAc,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAW5D;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,uFAoDhE"}
@@ -1,12 +1,12 @@
1
+ import { openapi } from '@scalar/openapi-parser';
2
+ import { Hono } from 'hono';
3
+ import { cors } from 'hono/cors';
1
4
  import { getOperations } from './utils/getOperations.js';
2
5
  import { handleAuthentication } from './utils/handleAuthentication.js';
3
6
  import { honoRouteFromPath } from './utils/honoRouteFromPath.js';
4
7
  import { isAuthenticationRequired } from './utils/isAuthenticationRequired.js';
5
8
  import { logAuthenticationInstructions } from './utils/logAuthenticationInstructions.js';
6
9
  import { setupAuthenticationRoutes } from './utils/setupAuthenticationRoutes.js';
7
- import { openapi } from '@scalar/openapi-parser';
8
- import { Hono } from 'hono';
9
- import { cors } from 'hono/cors';
10
10
  import { mockAnyResponse } from './routes/mockAnyResponse.js';
11
11
  import { respondWithOpenApiDocument } from './routes/respondWithOpenApiDocument.js';
12
12
 
@@ -1,6 +1,6 @@
1
- import type { MockServerOptions } from '../types.js';
2
1
  import type { OpenAPI } from '@scalar/openapi-types';
3
2
  import type { Context } from 'hono';
3
+ import type { MockServerOptions } from '../types.js';
4
4
  /**
5
5
  * Mock any response
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mockAnyResponse.d.ts","sourceRoot":"","sources":["../../src/routes/mockAnyResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAMnC;;GAEG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,OAAO,EACV,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,OAAO,EAAE,iBAAiB,YAkF3B"}
1
+ {"version":3,"file":"mockAnyResponse.d.ts","sourceRoot":"","sources":["../../src/routes/mockAnyResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAMnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAGhD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,OAAO,EACV,SAAS,EAAE,OAAO,CAAC,SAAS,EAC5B,OAAO,EAAE,iBAAiB,YAkF3B"}
@@ -1,7 +1,7 @@
1
- import { findPreferredResponseKey } from '../utils/findPreferredResponseKey.js';
2
1
  import { getExampleFromSchema } from '@scalar/oas-utils/spec-getters';
3
2
  import { accepts } from 'hono/accepts';
4
3
  import objectToXML from 'object-to-xml';
4
+ import { findPreferredResponseKey } from '../utils/findPreferredResponseKey.js';
5
5
 
6
6
  /**
7
7
  * Mock any response
@@ -56,7 +56,7 @@ function mockAnyResponse(c, operation, options) {
56
56
  })
57
57
  : null;
58
58
  // Status code
59
- const statusCode = parseInt(preferredResponseKey === 'default'
59
+ const statusCode = Number.parseInt(preferredResponseKey === 'default'
60
60
  ? '200'
61
61
  : (preferredResponseKey ?? '200'), 10);
62
62
  c.status(statusCode);
@@ -1 +1 @@
1
- {"version":3,"file":"respondWithAuthorizePage.d.ts","sourceRoot":"","sources":["../../src/routes/respondWithAuthorizePage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAKnC;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,GAAE,MAAW,YAoCtE"}
1
+ {"version":3,"file":"respondWithAuthorizePage.d.ts","sourceRoot":"","sources":["../../src/routes/respondWithAuthorizePage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAKnC;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,SAAK,YAoC9D"}
@@ -19,7 +19,7 @@ function respondWithAuthorizePage(c, title = '') {
19
19
  const htmlContent = generateAuthorizationHtml(redirectUrl.toString(), title);
20
20
  return c.html(htmlContent);
21
21
  }
22
- catch (error) {
22
+ catch {
23
23
  return c.html(generateErrorHtml('Invalid redirect_uri format', 'Please provide a valid URL. The redirect_uri parameter must be a properly formatted URL that includes the protocol (e.g., https://) and a valid domain. This is essential for the OAuth 2.0 flow to securely redirect after authorization.'), 400);
24
24
  }
25
25
  }
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { OpenAPI } from '@scalar/openapi-types';
2
- import { type Context } from 'hono';
2
+ import type { Context } from 'hono';
3
3
  /** Available HTTP methods for Hono routes */
4
4
  export declare const httpMethods: readonly ["get", "put", "post", "delete", "options", "patch"];
5
5
  /** Valid HTTP method */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,KAAK,OAAO,EAAQ,MAAM,MAAM,CAAA;AAEzC,6CAA6C;AAC7C,eAAO,MAAM,WAAW,+DAOd,CAAA;AAEV,wBAAwB;AACxB,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE3C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAA;KAAE,KAAK,IAAI,CAAA;CAC/E,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,6CAA6C;AAC7C,eAAO,MAAM,WAAW,+DAOd,CAAA;AAEV,wBAAwB;AACxB,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE3C;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAA;KAAE,KAAK,IAAI,CAAA;CAC/E,CAAA"}
@@ -11,7 +11,7 @@ function getPathFromUrl(url) {
11
11
  const path = urlObject.pathname;
12
12
  return path === '/' ? path : path.replace(/\/$/, '');
13
13
  }
14
- catch (error) {
14
+ catch {
15
15
  // If URL is invalid, return the original string
16
16
  return url;
17
17
  }
@@ -1,5 +1,5 @@
1
- import { type HttpMethod } from '../types.js';
2
1
  import type { OpenAPI, OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from '@scalar/openapi-types';
2
+ import { type HttpMethod } from '../types.js';
3
3
  /**
4
4
  * Takes a dereferenced OpenAPI document and returns all operations.
5
5
  * Ignores other attributes, like summary, parameters, etc.
@@ -1 +1 @@
1
- {"version":3,"file":"getOperations.d.ts","sourceRoot":"","sources":["../../src/utils/getOperations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,CAAC,EACD,SAAS,CAAC,cAAc,GACxB,SAAS,CAAC,cAAc,GACxB,WAAW,CAAC,cAAc,GAC7B,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAUvC"}
1
+ {"version":3,"file":"getOperations.d.ts","sourceRoot":"","sources":["../../src/utils/getOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAEtD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,CAAC,EACD,SAAS,CAAC,cAAc,GACxB,SAAS,CAAC,cAAc,GACxB,WAAW,CAAC,cAAc,GAC7B,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,CAUvC"}
@@ -20,14 +20,14 @@ function logAuthenticationInstructions(securitySchemes) {
20
20
  console.log();
21
21
  }
22
22
  else if (scheme.in === 'query') {
23
- console.log(`✅ API Key Authentication`);
23
+ console.log('✅ API Key Authentication');
24
24
  console.log(` Use any API key in the ${scheme.name} query parameter:`);
25
25
  console.log();
26
26
  console.log(` ?${scheme.name}=YOUR_API_KEY_HERE`);
27
27
  console.log();
28
28
  }
29
29
  else if (scheme.in === 'cookie') {
30
- console.log(`✅ API Key Authentication`);
30
+ console.log('✅ API Key Authentication');
31
31
  console.log(` Use any API key in the ${scheme.name} cookie:`);
32
32
  console.log();
33
33
  console.log(` Cookie: ${scheme.name}=YOUR_API_KEY_HERE`);
@@ -1 +1 @@
1
- {"version":3,"file":"setupAuthenticationRoutes.d.ts","sourceRoot":"","sources":["../../src/utils/setupAuthenticationRoutes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAIhC;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,QAuG1B"}
1
+ {"version":3,"file":"setupAuthenticationRoutes.d.ts","sourceRoot":"","sources":["../../src/utils/setupAuthenticationRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAOhC;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,IAAI,EACT,MAAM,CAAC,EAAE,OAAO,CAAC,QAAQ,QAuG1B"}
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "swagger",
17
17
  "cli"
18
18
  ],
19
- "version": "0.2.111",
19
+ "version": "0.2.112",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -38,22 +38,24 @@
38
38
  "dependencies": {
39
39
  "hono": "^4.6.5",
40
40
  "object-to-xml": "^2.0.0",
41
- "@scalar/oas-utils": "0.2.104",
42
- "@scalar/openapi-parser": "0.10.6",
43
- "@scalar/openapi-types": "0.1.7"
41
+ "@scalar/oas-utils": "0.2.105",
42
+ "@scalar/openapi-types": "0.1.7",
43
+ "@scalar/openapi-parser": "0.10.7"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@hono/node-server": "^1.11.0",
47
47
  "@types/node": "^20.17.10",
48
48
  "vite": "^5.4.10",
49
- "@scalar/build-tooling": "0.1.12",
50
- "@scalar/hono-api-reference": "0.5.173"
49
+ "@scalar/hono-api-reference": "0.5.174",
50
+ "@scalar/build-tooling": "0.1.13"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "scalar-build-rollup",
54
54
  "dev": "nodemon --exec \"vite-node playground/index.ts\" --ext ts --quiet",
55
- "lint:check": "eslint .",
56
- "lint:fix": "eslint . --fix",
55
+ "format": "scalar-format",
56
+ "format:check": "scalar-format-check",
57
+ "lint:check": "scalar-lint-check",
58
+ "lint:fix": "scalar-lint-fix",
57
59
  "test": "vitest",
58
60
  "types:build": "scalar-types-build",
59
61
  "types:check": "scalar-types-check"