@scalar/workspace-store 0.5.2 → 0.7.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.
- package/CHANGELOG.md +31 -0
- package/README.md +94 -7
- package/dist/client.d.ts +11713 -11143
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -2
- package/dist/client.js.map +2 -2
- package/dist/helpers/json-path-utils.d.ts +1 -1
- package/dist/helpers/json-path-utils.d.ts.map +1 -1
- package/dist/helpers/json-path-utils.js.map +2 -2
- package/dist/helpers/merge-object.d.ts +23 -0
- package/dist/helpers/merge-object.d.ts.map +1 -0
- package/dist/helpers/merge-object.js +20 -0
- package/dist/helpers/merge-object.js.map +7 -0
- package/dist/helpers/proxy.d.ts.map +1 -1
- package/dist/helpers/proxy.js +5 -2
- package/dist/helpers/proxy.js.map +2 -2
- package/dist/schemas/reference-config/appearance.d.ts +13 -0
- package/dist/schemas/reference-config/appearance.d.ts.map +1 -0
- package/dist/schemas/reference-config/appearance.js +26 -0
- package/dist/schemas/reference-config/appearance.js.map +7 -0
- package/dist/schemas/reference-config/features.d.ts +15 -0
- package/dist/schemas/reference-config/features.d.ts.map +1 -0
- package/dist/schemas/reference-config/features.js +30 -0
- package/dist/schemas/reference-config/features.js.map +7 -0
- package/dist/schemas/reference-config/index.d.ts +53 -0
- package/dist/schemas/reference-config/index.d.ts.map +1 -0
- package/dist/schemas/reference-config/index.js +66 -0
- package/dist/schemas/reference-config/index.js.map +7 -0
- package/dist/schemas/reference-config/meta.d.ts +12 -0
- package/dist/schemas/reference-config/meta.d.ts.map +1 -0
- package/dist/schemas/reference-config/meta.js +24 -0
- package/dist/schemas/reference-config/meta.js.map +7 -0
- package/dist/schemas/reference-config/routing.d.ts +8 -0
- package/dist/schemas/reference-config/routing.d.ts.map +1 -0
- package/dist/schemas/reference-config/routing.js +16 -0
- package/dist/schemas/reference-config/routing.js.map +7 -0
- package/dist/schemas/reference-config/settings.d.ts +8 -0
- package/dist/schemas/reference-config/settings.d.ts.map +1 -0
- package/dist/schemas/reference-config/settings.js +16 -0
- package/dist/schemas/reference-config/settings.js.map +7 -0
- package/dist/schemas/v3.1/strict/components.d.ts +167 -40
- package/dist/schemas/v3.1/strict/components.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/header.d.ts +2 -0
- package/dist/schemas/v3.1/strict/header.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts +6 -0
- package/dist/schemas/v3.1/strict/media-header-encoding.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/media-type.d.ts +1 -0
- package/dist/schemas/v3.1/strict/media-type.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts +73 -2
- package/dist/schemas/v3.1/strict/oauth-flow.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauth-flow.js +44 -7
- package/dist/schemas/v3.1/strict/oauth-flow.js.map +2 -2
- package/dist/schemas/v3.1/strict/oauthflows.d.ts +11 -10
- package/dist/schemas/v3.1/strict/oauthflows.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/oauthflows.js +11 -8
- package/dist/schemas/v3.1/strict/oauthflows.js.map +2 -2
- package/dist/schemas/v3.1/strict/operation.d.ts +11 -2
- package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.d.ts +11 -5
- package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/parameter.js +1 -1
- package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
- package/dist/schemas/v3.1/strict/path-item.d.ts +5 -2
- package/dist/schemas/v3.1/strict/path-item.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/path-operations.d.ts +158 -32
- package/dist/schemas/v3.1/strict/path-operations.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/paths.d.ts +71 -14
- package/dist/schemas/v3.1/strict/paths.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/request-body.d.ts +2 -0
- package/dist/schemas/v3.1/strict/request-body.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/response.d.ts +4 -0
- package/dist/schemas/v3.1/strict/response.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/responses.d.ts +4 -0
- package/dist/schemas/v3.1/strict/responses.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.d.ts +6 -1
- package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/schema.js +7 -2
- package/dist/schemas/v3.1/strict/schema.js.map +2 -2
- package/dist/schemas/v3.1/strict/security-scheme.d.ts +22 -20
- package/dist/schemas/v3.1/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.1/type-guard.d.ts +5 -0
- package/dist/schemas/v3.1/type-guard.d.ts.map +1 -1
- package/dist/schemas/v3.1/type-guard.js +1 -3
- package/dist/schemas/v3.1/type-guard.js.map +2 -2
- package/dist/server.d.ts +687 -651
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +52 -49
- package/dist/server.js.map +2 -2
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +7 -0
- package/package.json +19 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a05d638: feat(workspace-store): create types and validator for reference config schema
|
|
8
|
+
- 8d8e427: feat(api-reference): load documents on the new store
|
|
9
|
+
- dbbdd70: feat(workspace-store) add configuration mapping to the workspace store
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 23b150b: fix: export and fix up some types from workspace store
|
|
14
|
+
- Updated dependencies [533469b]
|
|
15
|
+
- Updated dependencies [23b150b]
|
|
16
|
+
- @scalar/openapi-types@0.3.4
|
|
17
|
+
- @scalar/helpers@0.0.5
|
|
18
|
+
- @scalar/openapi-parser@0.18.0
|
|
19
|
+
- @scalar/types@0.2.5
|
|
20
|
+
- @scalar/code-highlight@0.1.4
|
|
21
|
+
|
|
22
|
+
## 0.6.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- b97c82a: feat(workspace-store): server store input document from different sources
|
|
27
|
+
- 9f786d5: feat(workspace-store): preserve the original ref information
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- @scalar/code-highlight@0.1.4
|
|
32
|
+
- @scalar/openapi-parser@0.18.0
|
|
33
|
+
|
|
3
34
|
## 0.5.2
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Create a new store in SSR mode
|
|
|
11
11
|
|
|
12
12
|
```ts
|
|
13
13
|
// Create the store
|
|
14
|
-
const store = createServerWorkspaceStore({
|
|
14
|
+
const store = await createServerWorkspaceStore({
|
|
15
15
|
baseUrl: 'example.com',
|
|
16
16
|
mode: 'ssr',
|
|
17
17
|
meta: { 'x-scalar-active-document': 'document-name' },
|
|
@@ -44,7 +44,7 @@ const store = createServerWorkspaceStore({
|
|
|
44
44
|
})
|
|
45
45
|
|
|
46
46
|
// Add a new document to the store
|
|
47
|
-
store.addDocument({
|
|
47
|
+
await store.addDocument({
|
|
48
48
|
openapi: '3.1.1',
|
|
49
49
|
info: {
|
|
50
50
|
title: 'Hello World',
|
|
@@ -82,7 +82,7 @@ Create a new store in static mode
|
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
84
|
// Create the store
|
|
85
|
-
const store = createServerWorkspaceStore({
|
|
85
|
+
const store = await createServerWorkspaceStore({
|
|
86
86
|
directory: 'assets',
|
|
87
87
|
mode: 'static',
|
|
88
88
|
meta: { 'x-scalar-active-document': 'document-name' },
|
|
@@ -115,7 +115,7 @@ const store = createServerWorkspaceStore({
|
|
|
115
115
|
})
|
|
116
116
|
|
|
117
117
|
// Add a new document to the store
|
|
118
|
-
store.addDocument({
|
|
118
|
+
await store.addDocument({
|
|
119
119
|
openapi: '3.1.1',
|
|
120
120
|
info: {
|
|
121
121
|
title: 'Hello World',
|
|
@@ -145,6 +145,30 @@ store.addDocument({
|
|
|
145
145
|
const workspace = await store.generateWorkspaceChunks()
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
+
### Load documents from external sources
|
|
149
|
+
```ts
|
|
150
|
+
// Initialize the store with documents from external sources
|
|
151
|
+
const store = await createServerWorkspaceStore({
|
|
152
|
+
mode: 'static',
|
|
153
|
+
documents: [
|
|
154
|
+
{
|
|
155
|
+
name: 'remoteFile',
|
|
156
|
+
url: 'http://localhost/document.json'
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'fsFile',
|
|
160
|
+
path: './document.json'
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
// Output: { openapi: 'x.x.x', ... }
|
|
166
|
+
console.log(store.getWorkspace().documents.remoteFile)
|
|
167
|
+
|
|
168
|
+
// Output: { openapi: 'x.x.x', ... }
|
|
169
|
+
console.log(store.getWorkspace().documents.fsFile)
|
|
170
|
+
```
|
|
171
|
+
|
|
148
172
|
## Client-Side Workspace Store
|
|
149
173
|
|
|
150
174
|
A reactive workspace store for managing OpenAPI documents with automatic reference resolution and chunked loading capabilities. Works seamlessly with server-side stores to handle large documents efficiently.
|
|
@@ -154,7 +178,7 @@ A reactive workspace store for managing OpenAPI documents with automatic referen
|
|
|
154
178
|
```ts
|
|
155
179
|
|
|
156
180
|
// Initialize a new workspace store with default document
|
|
157
|
-
const store =
|
|
181
|
+
const store = createWorkspaceStore({
|
|
158
182
|
documents: [
|
|
159
183
|
{
|
|
160
184
|
name: 'default',
|
|
@@ -172,7 +196,7 @@ const store = await createWorkspaceStore({
|
|
|
172
196
|
})
|
|
173
197
|
|
|
174
198
|
// Add another OpenAPI document to the workspace
|
|
175
|
-
store.
|
|
199
|
+
store.addDocumentSync({
|
|
176
200
|
document: {
|
|
177
201
|
info: {
|
|
178
202
|
title: 'OpenApi document',
|
|
@@ -196,4 +220,67 @@ store.updateDocument('active', "x-scalar-active-auth", '<value>')
|
|
|
196
220
|
|
|
197
221
|
// Resolve and load document chunks including any $ref references
|
|
198
222
|
await store.resolve(['paths', '/users', 'get'])
|
|
199
|
-
```
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Load documents from external sources
|
|
226
|
+
|
|
227
|
+
You can only initialize the store with object literals but if you want to add documents from external sources you can use the addDocument function
|
|
228
|
+
|
|
229
|
+
```ts
|
|
230
|
+
const store = createWorkspaceStore()
|
|
231
|
+
|
|
232
|
+
// Load a document into the store from a remote url
|
|
233
|
+
await store.addDocument({
|
|
234
|
+
name: 'default',
|
|
235
|
+
url: 'http://localhost/document.json'
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
// Output: { openapi: 'x.x.x', ... }
|
|
239
|
+
console.log(store.workspace.documents.default)
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### Configuration
|
|
243
|
+
|
|
244
|
+
You can pass configuration object to the workspace store which is going to be applied to all the documents
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
const store = createWorkspaceStore({
|
|
248
|
+
config: {
|
|
249
|
+
"x-scalar-reference-config": {
|
|
250
|
+
features: {
|
|
251
|
+
showModels: true,
|
|
252
|
+
},
|
|
253
|
+
appearance: {
|
|
254
|
+
layout: 'modern'
|
|
255
|
+
},
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
})
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
You can override specific document configuration when you add the document to the store
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
store.addDocumentSync({
|
|
265
|
+
name: 'example',
|
|
266
|
+
document: {
|
|
267
|
+
openapi: '3.0.0',
|
|
268
|
+
info: { title: 'Example API', version: '1.0.0' },
|
|
269
|
+
paths: {},
|
|
270
|
+
},
|
|
271
|
+
config: {
|
|
272
|
+
features: {
|
|
273
|
+
showModels: false,
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
To get the active document configuration you can use config getter\
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
// Get the configuration for the active document
|
|
283
|
+
console.log(store.config['x-scalar-reference-config'].features.showModels)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
When no configuration is provided it will return the default configuration
|