@scalar/workspace-store 0.61.0 → 0.63.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 +32 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +12 -1
- package/dist/entities/auth/schema.d.ts +200 -200
- package/dist/helpers/detect-changes-proxy.d.ts +7 -6
- package/dist/helpers/detect-changes-proxy.d.ts.map +1 -1
- package/dist/helpers/detect-changes-proxy.js +83 -38
- package/dist/helpers/document-revision.d.ts +26 -0
- package/dist/helpers/document-revision.d.ts.map +1 -0
- package/dist/helpers/document-revision.js +47 -0
- package/dist/helpers/get-resolved-ref-deep.d.ts +1 -1
- package/dist/helpers/get-resolved-ref-deep.d.ts.map +1 -1
- package/dist/helpers/get-resolved-ref-deep.js +25 -13
- package/dist/helpers/get-resolved-ref.d.ts.map +1 -1
- package/dist/helpers/get-resolved-ref.js +61 -3
- package/dist/helpers/unpack-proxy.d.ts +10 -0
- package/dist/helpers/unpack-proxy.d.ts.map +1 -1
- package/dist/helpers/unpack-proxy.js +15 -0
- package/dist/request-example/builder/build-request.d.ts.map +1 -1
- package/dist/request-example/builder/build-request.js +2 -1
- package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
- package/dist/request-example/builder/helpers/get-example-from-schema.js +21 -1
- package/dist/resolve.d.ts +10 -2
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +9 -1
- package/dist/schemas/reference-config/index.d.ts +40 -40
- package/dist/schemas/reference-config/settings.d.ts +40 -40
- package/dist/schemas/v3.1/strict/callback.d.ts +1 -1
- package/dist/schemas/v3.1/strict/components.d.ts +11 -11
- package/dist/schemas/v3.1/strict/encoding.d.ts +1 -1
- package/dist/schemas/v3.1/strict/header.d.ts +2 -2
- package/dist/schemas/v3.1/strict/media-type.d.ts +2 -2
- package/dist/schemas/v3.1/strict/openapi-document.d.ts +1260 -1260
- package/dist/schemas/v3.1/strict/operation.d.ts +3 -3
- package/dist/schemas/v3.1/strict/parameter.d.ts +2 -2
- package/dist/schemas/v3.1/strict/path-item.d.ts +10 -10
- package/dist/schemas/v3.1/strict/paths.d.ts +1 -1
- package/dist/schemas/v3.1/strict/reference.d.ts +14 -2
- package/dist/schemas/v3.1/strict/reference.d.ts.map +1 -1
- package/dist/schemas/v3.1/strict/reference.js +13 -1
- package/dist/schemas/v3.1/strict/response.d.ts +2 -2
- package/dist/schemas/v3.1/strict/responses.d.ts +1 -1
- package/dist/schemas/v3.2/openapi/index.d.ts.map +1 -1
- package/dist/schemas/v3.2/openapi/index.js +3 -0
- package/dist/schemas/v3.2/strict/callback.d.ts +1 -1
- package/dist/schemas/v3.2/strict/components.d.ts +12 -12
- package/dist/schemas/v3.2/strict/encoding.d.ts +1 -1
- package/dist/schemas/v3.2/strict/header.d.ts +2 -2
- package/dist/schemas/v3.2/strict/media-type.d.ts +3 -3
- package/dist/schemas/v3.2/strict/openapi-document.d.ts +1400 -1400
- package/dist/schemas/v3.2/strict/operation.d.ts +3 -3
- package/dist/schemas/v3.2/strict/parameter.d.ts +2 -2
- package/dist/schemas/v3.2/strict/path-item.d.ts +12 -12
- package/dist/schemas/v3.2/strict/paths.d.ts +1 -1
- package/dist/schemas/v3.2/strict/reference.d.ts +14 -2
- package/dist/schemas/v3.2/strict/reference.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/reference.js +13 -1
- package/dist/schemas/v3.2/strict/response.d.ts +2 -2
- package/dist/schemas/v3.2/strict/responses.d.ts +1 -1
- package/dist/schemas/v3.2/strict/security-scheme.d.ts +2 -2
- package/dist/schemas/v3.2/strict/security-scheme.d.ts.map +1 -1
- package/dist/schemas/v3.2/strict/security-scheme.js +1 -1
- package/dist/server.d.ts +27 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +18 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @scalar/workspace-store
|
|
2
2
|
|
|
3
|
+
## 0.63.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#10261](https://github.com/scalar/scalar/pull/10261): Add `getDocumentRevision(document)`, a counter the store bumps on every write to a document. A consumer caching a derivation of a schema node can validate the entry against it in constant time, instead of walking the subtree to see whether anything moved. It reads the same from any view of the document, including one with the reactive and detect-changes proxies stripped for reads, and returns 0 for a document no store tracks.
|
|
8
|
+
- [#10261](https://github.com/scalar/scalar/pull/10261): Type the result of `resolve.schema` as read-only. A resolved schema is the document's own node or a shallow merge over it, so writing to it writes into the document behind the store's back; every change belongs in a store mutation, and a caller that needs a modified shape copies what it needs first. No in-repo consumer had to change.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [#10261](https://github.com/scalar/scalar/pull/10261): Make rendering from the store cheaper: the detect-changes proxy no longer allocates a path on every property read, `getResolvedRefDeep` stops deep-unpacking every node it visits, `resolve.schema` builds its composed typebox schema once, and `getExampleFromSchema` builds its options cache key once per call instead of once per node.
|
|
13
|
+
- [#10261](https://github.com/scalar/scalar/pull/10261): Follow chains of references when resolving. A reference can point at a second reference — `resolve()` on a static or SSR workspace leaves the component behind as a `{ $ref: '#/x-ext/<hash>', $global: true }` stub with the content under `x-ext` — so `getResolvedRef` and `getResolvedRefDeep` now hop through references that carry nothing but a `$ref` until they reach the node itself, instead of handing back the stub. A reference that carries keywords of its own stays its own hop, since it is a schema in its own right.
|
|
14
|
+
|
|
15
|
+
## 0.62.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#10257](https://github.com/scalar/scalar/pull/10257): Expose each document whole from the server workspace store through `getResolvedDocument`, for rendering on the server from one reference while the browser keeps loading chunks. Resolve relative chunk references from a static workspace against the URL the document was loaded from; they failed before a request was made.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#10231](https://github.com/scalar/scalar/pull/10231): Trim surrounding whitespace from bearer tokens after resolving environment variables.
|
|
24
|
+
- [#9638](https://github.com/scalar/scalar/pull/9638): Keep `$ref-value` optional in the shared `reference()` schema helper. An unresolved `{ $ref }` (for example a sparse chunk from the server store) now passes through coercion untouched instead of being coerced into a synthesized default that dropped the reference. This aligns the helper with the schema position that already made this choice.
|
|
25
|
+
|
|
26
|
+
Apply the same behavior to both OpenAPI 3.1 and 3.2 reference helpers, including the current workspace ingestion schema.
|
|
27
|
+
|
|
28
|
+
- [#10179](https://github.com/scalar/scalar/pull/10179): Warn when OAuth2 metadata routes collide with declared API paths. Keep the OAuth2 metadata field in OpenAPI 3.2 schemas and document the HTTP exception for local development.
|
|
29
|
+
- [#10179](https://github.com/scalar/scalar/pull/10179): Support OpenAPI 3.2 OAuth2 metadata URLs in workspace schemas and the shared authentication UI. Fetch HTTPS authorization server metadata or HTTP metadata from local development URLs to discover flows or fill missing endpoints while preserving explicit configuration.
|
|
30
|
+
|
|
31
|
+
For local development, Scalar deliberately relaxes the OpenAPI 3.2 TLS requirement: metadata URLs and discovered endpoints may use HTTP for local development URLs recognized by the shared `isLocalUrl` helper, including loopback hosts, `0.0.0.0`, and reserved development domains such as `*.test` and `*.example`. Other hosts require HTTPS.
|
|
32
|
+
|
|
33
|
+
Discovery leaves `refreshUrl` unchanged. Token refresh already falls back to the flow's token URL when no refresh URL is configured, so a discovered token endpoint also supports refresh without overriding an explicit refresh URL.
|
|
34
|
+
|
|
3
35
|
## 0.61.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,2BAA2B,CAAA;AAErE,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAQ7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM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C,SAAS,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;QAChD,YAAY,EAAE,CACZ,iBAAiB,EACb;YACE,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;SACzC,GACD;YACE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAC1C,KACF,OAAO,CAAC,IAAI,CAAC,CAAA;KACnB,CACJ,CAAA;CACF,CAAA;AAuDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,cAAc,KAAG,cA+hCtE,CAAA;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/client.js
CHANGED
|
@@ -18,6 +18,7 @@ import { createAuthStore } from './entities/auth/index.js';
|
|
|
18
18
|
import { createHistoryStore } from './entities/history/index.js';
|
|
19
19
|
import { deepClone } from './helpers/deep-clone.js';
|
|
20
20
|
import { createDetectChangesProxy } from './helpers/detect-changes-proxy.js';
|
|
21
|
+
import { bumpDocumentRevision } from './helpers/document-revision.js';
|
|
21
22
|
import { safeAssign } from './helpers/general.js';
|
|
22
23
|
import { getFetch } from './helpers/get-fetch.js';
|
|
23
24
|
import { mergeObjects } from './helpers/merge-object.js';
|
|
@@ -219,6 +220,9 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
219
220
|
info: { title: '', version: '' },
|
|
220
221
|
'x-scalar-original-document-hash': '',
|
|
221
222
|
};
|
|
223
|
+
// Every write through the store passes here, which is what makes the revision a
|
|
224
|
+
// complete record of the document changing.
|
|
225
|
+
bumpDocumentRevision(document);
|
|
222
226
|
const event = {
|
|
223
227
|
type: 'documents',
|
|
224
228
|
documentName,
|
|
@@ -244,6 +248,7 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
244
248
|
info: { title: '', version: '' },
|
|
245
249
|
'x-scalar-original-document-hash': '',
|
|
246
250
|
};
|
|
251
|
+
bumpDocumentRevision(document);
|
|
247
252
|
// Active document changed
|
|
248
253
|
const event = {
|
|
249
254
|
type: 'documents',
|
|
@@ -746,9 +751,15 @@ export const createWorkspaceStore = (workspaceProps) => {
|
|
|
746
751
|
return Promise.resolve();
|
|
747
752
|
}
|
|
748
753
|
// Bundle the target document with the active document as root, resolving any external references
|
|
749
|
-
// and tracking resolution status through hooks
|
|
754
|
+
// and tracking resolution status through hooks.
|
|
755
|
+
//
|
|
756
|
+
// The origin is the URL the document was loaded from. A static server workspace writes its chunk
|
|
757
|
+
// references relative to the document (`./chunks/…`), and without the origin the loader has
|
|
758
|
+
// nothing to resolve them against, so every chunk fails before a request is made. SSR
|
|
759
|
+
// workspaces write absolute URLs and never needed it.
|
|
750
760
|
return bundle(target, {
|
|
751
761
|
root: activeDocument,
|
|
762
|
+
origin: activeDocument?.['x-scalar-original-source-url'],
|
|
752
763
|
treeShake: false,
|
|
753
764
|
plugins: [fetchUrls(), loadingStatus(), externalValueResolver()],
|
|
754
765
|
urlMap: true,
|