@scalar/workspace-store 0.1.0

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.
Files changed (198) hide show
  1. package/.turbo/turbo-build.log +10 -0
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +199 -0
  4. package/dist/create-server-workspace-store.d.ts +151 -0
  5. package/dist/create-server-workspace-store.d.ts.map +1 -0
  6. package/dist/create-server-workspace-store.js +199 -0
  7. package/dist/create-server-workspace-store.js.map +7 -0
  8. package/dist/create-workspace-store.d.ts +19773 -0
  9. package/dist/create-workspace-store.d.ts.map +1 -0
  10. package/dist/create-workspace-store.js +186 -0
  11. package/dist/create-workspace-store.js.map +7 -0
  12. package/dist/helpers/general.d.ts +88 -0
  13. package/dist/helpers/general.d.ts.map +1 -0
  14. package/dist/helpers/general.js +38 -0
  15. package/dist/helpers/general.js.map +7 -0
  16. package/dist/helpers/json-path-utils.d.ts +23 -0
  17. package/dist/helpers/json-path-utils.d.ts.map +1 -0
  18. package/dist/helpers/json-path-utils.js +16 -0
  19. package/dist/helpers/json-path-utils.js.map +7 -0
  20. package/dist/helpers/proxy.d.ts +63 -0
  21. package/dist/helpers/proxy.d.ts.map +1 -0
  22. package/dist/helpers/proxy.js +100 -0
  23. package/dist/helpers/proxy.js.map +7 -0
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +13 -0
  27. package/dist/index.js.map +7 -0
  28. package/dist/schemas/callback.d.ts +1095 -0
  29. package/dist/schemas/callback.d.ts.map +1 -0
  30. package/dist/schemas/callback.js +11 -0
  31. package/dist/schemas/callback.js.map +7 -0
  32. package/dist/schemas/components.d.ts +2461 -0
  33. package/dist/schemas/components.d.ts.map +1 -0
  34. package/dist/schemas/components.js +38 -0
  35. package/dist/schemas/components.js.map +7 -0
  36. package/dist/schemas/contact.d.ts +10 -0
  37. package/dist/schemas/contact.d.ts.map +1 -0
  38. package/dist/schemas/contact.js +13 -0
  39. package/dist/schemas/contact.js.map +7 -0
  40. package/dist/schemas/discriminator.d.ts +12 -0
  41. package/dist/schemas/discriminator.d.ts.map +1 -0
  42. package/dist/schemas/discriminator.js +11 -0
  43. package/dist/schemas/discriminator.js.map +7 -0
  44. package/dist/schemas/encoding.d.ts +23 -0
  45. package/dist/schemas/encoding.d.ts.map +1 -0
  46. package/dist/schemas/encoding.js +13 -0
  47. package/dist/schemas/encoding.js.map +7 -0
  48. package/dist/schemas/example.d.ts +16 -0
  49. package/dist/schemas/example.d.ts.map +1 -0
  50. package/dist/schemas/example.js +15 -0
  51. package/dist/schemas/example.js.map +7 -0
  52. package/dist/schemas/external-documentation.d.ts +8 -0
  53. package/dist/schemas/external-documentation.d.ts.map +1 -0
  54. package/dist/schemas/external-documentation.js +11 -0
  55. package/dist/schemas/external-documentation.js.map +7 -0
  56. package/dist/schemas/header.d.ts +18 -0
  57. package/dist/schemas/header.d.ts.map +1 -0
  58. package/dist/schemas/header.js +13 -0
  59. package/dist/schemas/header.js.map +7 -0
  60. package/dist/schemas/info.d.ts +28 -0
  61. package/dist/schemas/info.d.ts.map +1 -0
  62. package/dist/schemas/info.js +23 -0
  63. package/dist/schemas/info.js.map +7 -0
  64. package/dist/schemas/license.d.ts +10 -0
  65. package/dist/schemas/license.d.ts.map +1 -0
  66. package/dist/schemas/license.js +13 -0
  67. package/dist/schemas/license.js.map +7 -0
  68. package/dist/schemas/link.d.ts +30 -0
  69. package/dist/schemas/link.d.ts.map +1 -0
  70. package/dist/schemas/link.js +20 -0
  71. package/dist/schemas/link.js.map +7 -0
  72. package/dist/schemas/media-type.d.ts +55 -0
  73. package/dist/schemas/media-type.d.ts.map +1 -0
  74. package/dist/schemas/media-type.js +19 -0
  75. package/dist/schemas/media-type.js.map +7 -0
  76. package/dist/schemas/oauth-flow.d.ts +12 -0
  77. package/dist/schemas/oauth-flow.d.ts.map +1 -0
  78. package/dist/schemas/oauth-flow.js +15 -0
  79. package/dist/schemas/oauth-flow.js.map +7 -0
  80. package/dist/schemas/oauthflows.d.ts +34 -0
  81. package/dist/schemas/oauthflows.d.ts.map +1 -0
  82. package/dist/schemas/oauthflows.js +16 -0
  83. package/dist/schemas/oauthflows.js.map +7 -0
  84. package/dist/schemas/openapi-document.d.ts +4683 -0
  85. package/dist/schemas/openapi-document.d.ts.map +1 -0
  86. package/dist/schemas/openapi-document.js +35 -0
  87. package/dist/schemas/openapi-document.js.map +7 -0
  88. package/dist/schemas/operation-without-callback.d.ts +190 -0
  89. package/dist/schemas/operation-without-callback.d.ts.map +1 -0
  90. package/dist/schemas/operation-without-callback.js +39 -0
  91. package/dist/schemas/operation-without-callback.js.map +7 -0
  92. package/dist/schemas/parameter.d.ts +25 -0
  93. package/dist/schemas/parameter.d.ts.map +1 -0
  94. package/dist/schemas/parameter.js +22 -0
  95. package/dist/schemas/parameter.js.map +7 -0
  96. package/dist/schemas/path-item.d.ts +1106 -0
  97. package/dist/schemas/path-item.d.ts.map +1 -0
  98. package/dist/schemas/path-item.js +37 -0
  99. package/dist/schemas/path-item.js.map +7 -0
  100. package/dist/schemas/paths.d.ts +1093 -0
  101. package/dist/schemas/paths.d.ts.map +1 -0
  102. package/dist/schemas/paths.js +11 -0
  103. package/dist/schemas/paths.js.map +7 -0
  104. package/dist/schemas/reference.d.ts +17 -0
  105. package/dist/schemas/reference.d.ts.map +1 -0
  106. package/dist/schemas/reference.js +15 -0
  107. package/dist/schemas/reference.js.map +7 -0
  108. package/dist/schemas/request-body.d.ts +54 -0
  109. package/dist/schemas/request-body.d.ts.map +1 -0
  110. package/dist/schemas/request-body.js +14 -0
  111. package/dist/schemas/request-body.js.map +7 -0
  112. package/dist/schemas/response.d.ts +84 -0
  113. package/dist/schemas/response.d.ts.map +1 -0
  114. package/dist/schemas/response.js +19 -0
  115. package/dist/schemas/response.js.map +7 -0
  116. package/dist/schemas/responses.d.ts +94 -0
  117. package/dist/schemas/responses.d.ts.map +1 -0
  118. package/dist/schemas/responses.js +8 -0
  119. package/dist/schemas/responses.js.map +7 -0
  120. package/dist/schemas/schema.d.ts +34 -0
  121. package/dist/schemas/schema.d.ts.map +1 -0
  122. package/dist/schemas/schema.js +22 -0
  123. package/dist/schemas/schema.js.map +7 -0
  124. package/dist/schemas/security-requirement.d.ts +11 -0
  125. package/dist/schemas/security-requirement.d.ts.map +1 -0
  126. package/dist/schemas/security-requirement.js +10 -0
  127. package/dist/schemas/security-requirement.js.map +7 -0
  128. package/dist/schemas/security-scheme.d.ts +137 -0
  129. package/dist/schemas/security-scheme.d.ts.map +1 -0
  130. package/dist/schemas/security-scheme.js +56 -0
  131. package/dist/schemas/security-scheme.js.map +7 -0
  132. package/dist/schemas/server-variable.d.ts +10 -0
  133. package/dist/schemas/server-variable.d.ts.map +1 -0
  134. package/dist/schemas/server-variable.js +13 -0
  135. package/dist/schemas/server-variable.js.map +7 -0
  136. package/dist/schemas/server-workspace.d.ts +14043 -0
  137. package/dist/schemas/server-workspace.d.ts.map +1 -0
  138. package/dist/schemas/server-workspace.js +29 -0
  139. package/dist/schemas/server-workspace.js.map +7 -0
  140. package/dist/schemas/server.d.ts +14 -0
  141. package/dist/schemas/server.d.ts.map +1 -0
  142. package/dist/schemas/server.js +14 -0
  143. package/dist/schemas/server.js.map +7 -0
  144. package/dist/schemas/tag.d.ts +13 -0
  145. package/dist/schemas/tag.d.ts.map +1 -0
  146. package/dist/schemas/tag.js +14 -0
  147. package/dist/schemas/tag.js.map +7 -0
  148. package/dist/schemas/xml.d.ts +18 -0
  149. package/dist/schemas/xml.d.ts.map +1 -0
  150. package/dist/schemas/xml.js +17 -0
  151. package/dist/schemas/xml.js.map +7 -0
  152. package/esbuild.ts +6 -0
  153. package/package.json +54 -0
  154. package/src/create-server-workspace-store.test.ts +429 -0
  155. package/src/create-server-workspace-store.ts +339 -0
  156. package/src/create-workspace-store.test.ts +488 -0
  157. package/src/create-workspace-store.ts +282 -0
  158. package/src/helpers/general.ts +115 -0
  159. package/src/helpers/json-path-utils.test.ts +13 -0
  160. package/src/helpers/json-path-utils.ts +38 -0
  161. package/src/helpers/proxy.test.ts +61 -0
  162. package/src/helpers/proxy.ts +213 -0
  163. package/src/index.ts +8 -0
  164. package/src/schemas/callback.ts +13 -0
  165. package/src/schemas/components.ts +36 -0
  166. package/src/schemas/contact.ts +11 -0
  167. package/src/schemas/discriminator.ts +13 -0
  168. package/src/schemas/encoding.ts +17 -0
  169. package/src/schemas/example.ts +17 -0
  170. package/src/schemas/external-documentation.ts +9 -0
  171. package/src/schemas/header.ts +19 -0
  172. package/src/schemas/info.ts +23 -0
  173. package/src/schemas/license.ts +11 -0
  174. package/src/schemas/link.ts +24 -0
  175. package/src/schemas/media-type.ts +21 -0
  176. package/src/schemas/oauth-flow.ts +13 -0
  177. package/src/schemas/oauthflows.ts +16 -0
  178. package/src/schemas/openapi-document.ts +34 -0
  179. package/src/schemas/operation-without-callback.ts +37 -0
  180. package/src/schemas/parameter.ts +26 -0
  181. package/src/schemas/path-item.ts +35 -0
  182. package/src/schemas/paths.ts +11 -0
  183. package/src/schemas/reference.ts +18 -0
  184. package/src/schemas/request-body.ts +12 -0
  185. package/src/schemas/response.ts +16 -0
  186. package/src/schemas/responses.ts +14 -0
  187. package/src/schemas/schema.ts +26 -0
  188. package/src/schemas/security-requirement.ts +16 -0
  189. package/src/schemas/security-scheme.ts +58 -0
  190. package/src/schemas/server-variable.ts +11 -0
  191. package/src/schemas/server-workspace.ts +36 -0
  192. package/src/schemas/server.ts +12 -0
  193. package/src/schemas/tag.ts +12 -0
  194. package/src/schemas/xml.ts +19 -0
  195. package/test/helpers.ts +16 -0
  196. package/tsconfig.build.json +12 -0
  197. package/tsconfig.json +8 -0
  198. package/vite.config.ts +9 -0
@@ -0,0 +1,18 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ /**
4
+ * A simple object to allow referencing other components in the OpenAPI Description, internally and externally.
5
+ *
6
+ * The $ref string value contains a URI RFC3986, which identifies the value being referenced.
7
+ *
8
+ * See the rules for resolving Relative References. */
9
+ export const ReferenceObject = Type.Object({
10
+ /** REQUIRED. The reference identifier. This MUST be in the form of a URI. */
11
+ '$ref': Type.String(),
12
+ /** Indicates the current status of the reference resolution. Can be either 'loading' while fetching the reference or 'error' if the resolution failed. */
13
+ '$status': Type.Optional(Type.Union([Type.Literal('loading'), Type.Literal('error')])),
14
+ /** A short summary which by default SHOULD override that of the referenced component. If the referenced object-type does not allow a summary field, then this field has no effect. */
15
+ summary: Type.Optional(Type.String()),
16
+ /** A description which by default SHOULD override that of the referenced component. CommonMark syntax MAY be used for rich text representation. If the referenced object-type does not allow a description field, then this field has no effect. */
17
+ description: Type.Optional(Type.String()),
18
+ })
@@ -0,0 +1,12 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { MediaTypeObject } from './media-type'
3
+
4
+ /** Describes a single request body. */
5
+ export const RequestBodyObject = Type.Object({
6
+ /** A brief description of the request body. This could contain examples of use. CommonMark syntax MAY be used for rich text representation. */
7
+ description: Type.Optional(Type.String()),
8
+ /** REQUIRED. The content of the request body. The key is a media type or media type range and the value describes it. For requests that match multiple keys, only the most specific key is applicable. e.g. "text/plain" overrides "text/* */
9
+ content: Type.Record(Type.String(), MediaTypeObject),
10
+ /** Determines if the request body is required in the request. Defaults to false. */
11
+ required: Type.Optional(Type.Boolean()),
12
+ })
@@ -0,0 +1,16 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { HeaderObject } from './header'
3
+ import { ReferenceObject } from './reference'
4
+ import { MediaTypeObject } from './media-type'
5
+ import { LinkObject } from './link'
6
+
7
+ export const ResponseObject = Type.Object({
8
+ /** REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text representation. */
9
+ description: Type.String(),
10
+ /** Maps a header name to its definition. RFC7230 states header names are case insensitive. If a response header is defined with the name "Content-Type", it SHALL be ignored. */
11
+ headers: Type.Optional(Type.Record(Type.String(), Type.Union([HeaderObject, ReferenceObject]))),
12
+ /** A map containing descriptions of potential response payloads. The key is a media type or media type range and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. "text/plain" overrides "text/*" */
13
+ content: Type.Optional(Type.Record(Type.String(), MediaTypeObject)),
14
+ /** A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. */
15
+ links: Type.Optional(Type.Record(Type.String(), Type.Union([LinkObject, ReferenceObject]))),
16
+ })
@@ -0,0 +1,14 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { ReferenceObject } from './reference'
3
+ import { ResponseObject } from './response'
4
+
5
+ /**
6
+ * A container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
7
+ *
8
+ * The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors.
9
+ *
10
+ * The default MAY be used as a default Response Object for all HTTP codes that are not covered individually by the Responses Object.
11
+ *
12
+ * The Responses Object MUST contain at least one response code, and if only one response code is provided it SHOULD be the response for a successful operation call.
13
+ */
14
+ export const ResponsesObject = Type.Record(Type.String(), Type.Union([ResponseObject, ReferenceObject]))
@@ -0,0 +1,26 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { DiscriminatorObject } from './discriminator'
3
+ import { XMLObject } from './xml'
4
+ import { ExternalDocumentationObject } from './external-documentation'
5
+
6
+ /**
7
+ * The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the JSON Schema Specification Draft 2020-12. The empty schema (which allows any instance to validate) MAY be represented by the boolean value true and a schema which allows no instance to validate MAY be represented by the boolean value false.
8
+ *
9
+ * For more information about the keywords, see JSON Schema Core and JSON Schema Validation.
10
+ *
11
+ * Unless stated otherwise, the keyword definitions follow those of JSON Schema and do not add any additional semantics; this includes keywords such as $schema, $id, $ref, and $dynamicRef being URIs rather than URLs. Where JSON Schema indicates that behavior is defined by the application (e.g. for annotations), OAS also defers the definition of semantics to the application consuming the OpenAPI document.
12
+ */
13
+ export const SchemaObject = Type.Object({
14
+ /** Adds support for polymorphism. The discriminator is used to determine which of a set of schemas a payload is expected to satisfy. See Composition and Inheritance for more details. */
15
+ discriminator: Type.Optional(DiscriminatorObject),
16
+ /** This MAY be used only on property schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property. */
17
+ xml: Type.Optional(XMLObject),
18
+ /** Additional external documentation for this schema. */
19
+ externalDocs: Type.Optional(ExternalDocumentationObject),
20
+ /**
21
+ * A free-form field to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
22
+ *
23
+ * Deprecated: The example field has been deprecated in favor of the JSON Schema examples keyword. Use of example is discouraged, and later versions of this specification may remove it.
24
+ */
25
+ example: Type.Optional(Type.Any()),
26
+ })
@@ -0,0 +1,16 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ /**
4
+ * Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.
5
+ *
6
+ * A Security Requirement Object MAY refer to multiple security schemes in which case all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.
7
+ *
8
+ * When the security field is defined on the OpenAPI Object or Operation Object and contains multiple Security Requirement Objects, only one of the entries in the list needs to be satisfied to authorize the request. This enables support for scenarios where the API allows multiple, independent security schemes.
9
+ *
10
+ * An empty Security Requirement Object ({}) indicates anonymous access is supported.
11
+ */
12
+ export const SecurityRequirementObject = Type.Record(
13
+ Type.String(),
14
+ /** Each name MUST correspond to a security scheme which is declared in the Security Schemes under the Components Object. If the security scheme is of type "oauth2" or "openIdConnect", then the value is a list of scope names required for the execution, and the list MAY be empty if authorization does not require a specified scope. For other security scheme types, the array MAY contain a list of role names which are required for the execution, but are not otherwise defined or exchanged in-band. */
15
+ Type.Array(Type.String()),
16
+ )
@@ -0,0 +1,58 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { OAuthFlowsObject } from './oauthflows'
3
+
4
+ export const DescriptionSchema = Type.Object({
5
+ /** A description for security scheme. CommonMark syntax MAY be used for rich text representation. */
6
+ description: Type.Optional(Type.String()),
7
+ })
8
+
9
+ export const ApiKeySchema = Type.Intersect([
10
+ DescriptionSchema,
11
+ Type.Object({
12
+ /** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect". */
13
+ type: Type.Literal('apiKey'),
14
+ /** REQUIRED. The name of the header, query or cookie parameter to be used. */
15
+ name: Type.String(),
16
+ /** REQUIRED. The location of the API key. Valid values are "query", "header", or "cookie". */
17
+ in: Type.String(),
18
+ }),
19
+ ])
20
+
21
+ export const HttpSchema = Type.Intersect([
22
+ DescriptionSchema,
23
+ Type.Object({
24
+ /** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect". */
25
+ type: Type.Literal('http'),
26
+ /** REQUIRED. The name of the HTTP Authentication scheme to be used in the Authorization header as defined in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry. The value is case-insensitive, as defined in RFC7235. */
27
+ scheme: Type.String(),
28
+ /** A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. */
29
+ bearerFormat: Type.Optional(Type.String()),
30
+ }),
31
+ ])
32
+
33
+ export const OAuth2 = Type.Intersect([
34
+ DescriptionSchema,
35
+ Type.Object({
36
+ /** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect". */
37
+ type: Type.Literal('oauth2'),
38
+ /** REQUIRED. An object containing configuration information for the flow types supported. */
39
+ flows: OAuthFlowsObject,
40
+ }),
41
+ ])
42
+
43
+ export const OpenIdConnect = Type.Intersect([
44
+ DescriptionSchema,
45
+ Type.Object({
46
+ /** REQUIRED. The type of the security scheme. Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect". */
47
+ type: Type.Literal('openIdConnect'),
48
+ /** REQUIRED. Well-known URL to discover the [[OpenID-Connect-Discovery]] provider metadata. */
49
+ openIdConnectUrl: Type.String(),
50
+ }),
51
+ ])
52
+
53
+ /**
54
+ * Defines a security scheme that can be used by the operations.
55
+ *
56
+ * Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in RFC6749, and [[OpenID-Connect-Core]]. Please note that as of 2020, the implicit flow is about to be deprecated by OAuth 2.0 Security Best Current Practice. Recommended for most use cases is Authorization Code Grant flow with PKCE.
57
+ */
58
+ export const SecuritySchemeObject = Type.Union([ApiKeySchema, HttpSchema, OAuth2, OpenIdConnect])
@@ -0,0 +1,11 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ /** An object representing a Server Variable for server URL template substitution. */
4
+ export const ServerVariableObject = Type.Object({
5
+ /** An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty. */
6
+ enum: Type.Optional(Type.Array(Type.String())),
7
+ /** REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. If the enum is defined, the value MUST exist in the enum's values. Note that this behavior is different from the Schema Object's default keyword, which documents the receiver's behavior rather than inserting the value into the data. */
8
+ default: Type.Optional(Type.String()),
9
+ /** An optional description for the server variable. CommonMark syntax MAY be used for rich text representation. */
10
+ description: Type.Optional(Type.String()),
11
+ })
@@ -0,0 +1,36 @@
1
+ import { type Static, Type } from '@sinclair/typebox'
2
+ import { OpenAPIDocumentSchema } from './openapi-document'
3
+
4
+ const WorkspaceDocumentMetaSchema = Type.Partial(
5
+ Type.Object({
6
+ 'x-scalar-active-auth': Type.String(),
7
+ 'x-scalar-active-server': Type.String(),
8
+ }),
9
+ )
10
+
11
+ export type WorkspaceDocumentMeta = Static<typeof WorkspaceDocumentMetaSchema>
12
+
13
+ export const WorkspaceDocumentSchema = Type.Intersect([WorkspaceDocumentMetaSchema, OpenAPIDocumentSchema])
14
+
15
+ export type WorkspaceDocument = Static<typeof WorkspaceDocumentSchema>
16
+
17
+ const WorkspaceMetaSchema = Type.Partial(
18
+ Type.Object({
19
+ 'x-scalar-dark-mode': Type.Boolean(),
20
+ 'x-scalar-default-client': Type.String(),
21
+ 'x-scalar-active-document': Type.String(),
22
+ 'x-scalar-theme': Type.String(),
23
+ }),
24
+ )
25
+
26
+ export type WorkspaceMeta = Static<typeof WorkspaceMetaSchema>
27
+
28
+ export const WorkspaceSchema = Type.Intersect([
29
+ WorkspaceMetaSchema,
30
+ Type.Object({
31
+ documents: Type.Record(Type.String(), Type.Partial(WorkspaceDocumentSchema)),
32
+ activeDocument: Type.Partial(WorkspaceDocumentSchema),
33
+ }),
34
+ ])
35
+
36
+ export type Workspace = Static<typeof WorkspaceSchema>
@@ -0,0 +1,12 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { ServerVariableObject } from './server-variable'
3
+
4
+ /** An object representing a Server. */
5
+ export const ServerObject = Type.Object({
6
+ /** REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the document containing the Server Object is being served. Variable substitutions will be made when a variable is named in {braces}. */
7
+ url: Type.String(),
8
+ /** An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation. */
9
+ description: Type.Optional(Type.String()),
10
+ /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
11
+ variables: Type.Optional(Type.Record(Type.String(), ServerVariableObject)),
12
+ })
@@ -0,0 +1,12 @@
1
+ import { Type } from '@sinclair/typebox'
2
+ import { ExternalDocumentationObject } from './external-documentation'
3
+
4
+ /** Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. */
5
+ export const TagObject = Type.Object({
6
+ /** REQUIRED. The name of the tag. */
7
+ name: Type.String(),
8
+ /** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
9
+ description: Type.Optional(Type.String()),
10
+ /** Additional external documentation for this tag. */
11
+ externalDocs: Type.Optional(ExternalDocumentationObject),
12
+ })
@@ -0,0 +1,19 @@
1
+ import { Type } from '@sinclair/typebox'
2
+
3
+ /**
4
+ * A metadata object that allows for more fine-tuned XML model definitions.
5
+ *
6
+ * When using arrays, XML element names are not inferred (for singular/plural forms) and the name field SHOULD be used to add that information. See examples for expected behavior.
7
+ */
8
+ export const XMLObject = Type.Object({
9
+ /** Replaces the name of the element/attribute used for the described schema property. When defined within items, it will affect the name of the individual XML elements within the list. When defined alongside type being "array" (outside the items), it will affect the wrapping element if and only if wrapped is true. If wrapped is false, it will be ignored. */
10
+ name: Type.Optional(Type.String()),
11
+ /** The URI of the namespace definition. Value MUST be in the form of a non-relative URI. */
12
+ namespace: Type.Optional(Type.String()),
13
+ /** The prefix to be used for the name. */
14
+ prefix: Type.Optional(Type.String()),
15
+ /** Declares whether the property definition translates to an attribute instead of an element. Default value is false. */
16
+ attribute: Type.Optional(Type.Boolean()),
17
+ /** MAY be used only for an array definition. Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>). Default value is false. The definition takes effect only when defined alongside type being "array" (outside the items). */
18
+ wrapped: Type.Optional(Type.Boolean()),
19
+ })
@@ -0,0 +1,16 @@
1
+ import fs from 'node:fs/promises'
2
+
3
+ export async function allFilesMatch(fileList: { path: string; content: string }[]): Promise<boolean> {
4
+ for (const { content, path } of fileList) {
5
+ try {
6
+ const actualContent = await fs.readFile(path, 'utf8')
7
+ if (actualContent !== content) {
8
+ return false
9
+ }
10
+ } catch {
11
+ // If file doesn't exist or any other read error
12
+ return false
13
+ }
14
+ }
15
+ return true
16
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src"],
4
+ "exclude": ["**/*.test.ts", "**/*.test-d.ts"],
5
+ "compilerOptions": {
6
+ "skipLibCheck": true,
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "emitDeclarationOnly": true,
10
+ "outDir": "dist/"
11
+ }
12
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@/*": ["./src/*"]
6
+ }
7
+ }
8
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { alias } from '@scalar/build-tooling'
2
+ import { defineConfig } from 'vite'
3
+
4
+ export default defineConfig({
5
+ plugins: [],
6
+ resolve: {
7
+ alias: alias(import.meta.url),
8
+ },
9
+ })