@scalar/workspace-store 0.10.2 → 0.12.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 +40 -0
- package/README.md +115 -3
- package/dist/client.d.ts +14 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +175 -69
- package/dist/client.js.map +3 -3
- package/dist/helpers/apply-selective-updates.d.ts +1 -1
- package/dist/helpers/apply-selective-updates.d.ts.map +1 -1
- package/dist/helpers/apply-selective-updates.js +1 -1
- package/dist/helpers/apply-selective-updates.js.map +1 -1
- package/dist/helpers/overrides-proxy.d.ts +5 -0
- package/dist/helpers/overrides-proxy.d.ts.map +1 -0
- package/dist/helpers/overrides-proxy.js +48 -0
- package/dist/helpers/overrides-proxy.js.map +7 -0
- package/dist/mutators/index.js +1 -1
- package/dist/mutators/index.js.map +2 -2
- package/dist/navigation/helpers/traverse-schemas.js +2 -2
- package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
- package/dist/navigation/helpers/traverse-tags.js +2 -2
- package/dist/navigation/helpers/traverse-tags.js.map +2 -2
- package/dist/schemas/inmemory-workspace.d.ts +5633 -0
- package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
- package/dist/schemas/inmemory-workspace.js +3 -1
- package/dist/schemas/inmemory-workspace.js.map +2 -2
- package/dist/schemas/reference-config/index.d.ts +2 -2
- package/dist/schemas/reference-config/index.d.ts.map +1 -1
- package/dist/schemas/reference-config/index.js.map +2 -2
- package/dist/schemas/typebox-types.d.ts +14 -0
- package/dist/schemas/typebox-types.d.ts.map +1 -0
- package/dist/schemas/typebox-types.js +19 -0
- package/dist/schemas/typebox-types.js.map +7 -0
- package/dist/schemas/v3.1/type-guard.d.ts +4 -2
- package/dist/schemas/v3.1/type-guard.d.ts.map +1 -1
- package/dist/schemas/v3.1/type-guard.js +3 -1
- package/dist/schemas/v3.1/type-guard.js.map +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -4
- package/dist/server.js.map +2 -2
- package/dist/types.d.ts +6 -39
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -9
- package/dist/helpers/proxy.d.ts +0 -63
- package/dist/helpers/proxy.d.ts.map +0 -1
- package/dist/helpers/proxy.js +0 -103
- package/dist/helpers/proxy.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inmemory-workspace.d.ts","sourceRoot":"","sources":["../../src/schemas/inmemory-workspace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inmemory-workspace.d.ts","sourceRoot":"","sources":["../../src/schemas/inmemory-workspace.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAErD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAM,CAAC,OAAO,uBAAuB,CAAC,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PartialDeep } from "../schemas/typebox-types.js";
|
|
1
2
|
import { WorkspaceDocumentSchema, WorkspaceMetaSchema } from "../schemas/workspace.js";
|
|
2
3
|
import { ConfigSchema } from "../schemas/workspace-specification/config.js";
|
|
3
4
|
import { Type } from "@sinclair/typebox";
|
|
@@ -6,7 +7,8 @@ const InMemoryWorkspaceSchema = Type.Object({
|
|
|
6
7
|
documentConfigs: Type.Record(Type.String(), ConfigSchema),
|
|
7
8
|
documents: Type.Record(Type.String(), WorkspaceDocumentSchema),
|
|
8
9
|
originalDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),
|
|
9
|
-
intermediateDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema)
|
|
10
|
+
intermediateDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),
|
|
11
|
+
overrides: Type.Record(Type.String(), PartialDeep(WorkspaceDocumentSchema))
|
|
10
12
|
});
|
|
11
13
|
export {
|
|
12
14
|
InMemoryWorkspaceSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/schemas/inmemory-workspace.ts"],
|
|
4
|
-
"sourcesContent": ["import { WorkspaceDocumentSchema, WorkspaceMetaSchema } from '@/schemas/workspace'\nimport { ConfigSchema } from '@/schemas/workspace-specification/config'\nimport { Type, type Static } from '@sinclair/typebox'\n\nexport const InMemoryWorkspaceSchema = Type.Object({\n meta: WorkspaceMetaSchema,\n documentConfigs: Type.Record(Type.String(), ConfigSchema),\n documents: Type.Record(Type.String(), WorkspaceDocumentSchema),\n originalDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),\n intermediateDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),\n})\n\nexport type InMemoryWorkspace = Static<typeof InMemoryWorkspaceSchema>\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB,2BAA2B;AAC7D,SAAS,oBAAoB;AAC7B,SAAS,YAAyB;AAE3B,MAAM,0BAA0B,KAAK,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,iBAAiB,KAAK,OAAO,KAAK,OAAO,GAAG,YAAY;AAAA,EACxD,WAAW,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA,EAC7D,mBAAmB,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA,EACrE,uBAAuB,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;
|
|
4
|
+
"sourcesContent": ["import { PartialDeep } from '@/schemas/typebox-types'\nimport { WorkspaceDocumentSchema, WorkspaceMetaSchema } from '@/schemas/workspace'\nimport { ConfigSchema } from '@/schemas/workspace-specification/config'\nimport { Type, type Static } from '@sinclair/typebox'\n\nexport const InMemoryWorkspaceSchema = Type.Object({\n meta: WorkspaceMetaSchema,\n documentConfigs: Type.Record(Type.String(), ConfigSchema),\n documents: Type.Record(Type.String(), WorkspaceDocumentSchema),\n originalDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),\n intermediateDocuments: Type.Record(Type.String(), WorkspaceDocumentSchema),\n overrides: Type.Record(Type.String(), PartialDeep(WorkspaceDocumentSchema)),\n})\n\nexport type InMemoryWorkspace = Static<typeof InMemoryWorkspaceSchema>\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB,2BAA2B;AAC7D,SAAS,oBAAoB;AAC7B,SAAS,YAAyB;AAE3B,MAAM,0BAA0B,KAAK,OAAO;AAAA,EACjD,MAAM;AAAA,EACN,iBAAiB,KAAK,OAAO,KAAK,OAAO,GAAG,YAAY;AAAA,EACxD,WAAW,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA,EAC7D,mBAAmB,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA,EACrE,uBAAuB,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA,EACzE,WAAW,KAAK,OAAO,KAAK,OAAO,GAAG,YAAY,uBAAuB,CAAC;AAC5E,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Static } from '@sinclair/typebox';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DeepRequired } from '../../types.js';
|
|
3
3
|
/**
|
|
4
4
|
* ReferenceConfigSchema defines the shape of the configuration object
|
|
5
5
|
* for the API Reference. All properties are optional due to Type.Partial.
|
|
@@ -49,5 +49,5 @@ export declare const ReferenceConfigSchema: import("@sinclair/typebox").TObject<
|
|
|
49
49
|
httpClients: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"c/libcurl" | "clojure/clj_http" | "csharp/httpclient" | "csharp/restsharp" | "dart/http" | "go/native" | "http/http1.1" | "java/asynchttp" | "java/nethttp" | "java/okhttp" | "java/unirest" | "js/axios" | "js/fetch" | "js/jquery" | "js/ofetch" | "js/xhr" | "kotlin/okhttp" | "node/axios" | "node/fetch" | "node/ofetch" | "node/undici" | "objc/nsurlsession" | "ocaml/cohttp" | "php/curl" | "php/guzzle" | "powershell/restmethod" | "powershell/webrequest" | "python/python3" | "python/requests" | "python/httpx_sync" | "python/httpx_async" | "r/httr" | "ruby/native" | "rust/reqwest" | "shell/curl" | "shell/httpie" | "shell/wget" | "swift/nsurlsession">[]>>>;
|
|
50
50
|
}>;
|
|
51
51
|
export type ReferenceConfig = Static<typeof ReferenceConfigSchema>;
|
|
52
|
-
export declare const defaultReferenceConfig:
|
|
52
|
+
export declare const defaultReferenceConfig: DeepRequired<ReferenceConfig>;
|
|
53
53
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/reference-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAOrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/schemas/reference-config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAElE,eAAO,MAAM,sBAAsB,EAAE,YAAY,CAAC,eAAe,CAkChE,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/schemas/reference-config/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Type, type Static } from '@sinclair/typebox'\nimport { AVAILABLE_CLIENTS } from '@scalar/types/snippetz'\nimport { defaultMeta, MetaSchema } from '@/schemas/reference-config/meta'\nimport { defaultFeatures, FeaturesSchema } from '@/schemas/reference-config/features'\nimport { AppearanceSchema, defaultAppearance } from '@/schemas/reference-config/appearance'\nimport { defaultRouting, RoutingSchema } from '@/schemas/reference-config/routing'\nimport { defaultSettings, SettingsSchema } from '@/schemas/reference-config/settings'\nimport type {
|
|
5
|
-
"mappings": "AAAA,SAAS,YAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,aAAa,kBAAkB;AACxC,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,iBAAiB,sBAAsB;AAQzC,MAAM,wBAAwB,KAAK;AAAA,EACxC,KAAK,OAAO;AAAA;AAAA,IAEV,OAAO,KAAK,OAAO;AAAA;AAAA,IAEnB,MAAM,KAAK,OAAO;AAAA;AAAA,IAElB,UAAU;AAAA;AAAA,IAEV,SAAS,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAE3C,eAAe,KAAK,MAAM,CAAC,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAEzE,SAAS;AAAA;AAAA,IAET,YAAY;AAAA;AAAA,IAEZ,UAAU;AAAA;AAAA,IAEV,MAAM;AAAA;AAAA,IAEN,aAAa,KAAK,MAAM,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,EAC7F,CAAC;AACH;AAIO,MAAM,
|
|
4
|
+
"sourcesContent": ["import { Type, type Static } from '@sinclair/typebox'\nimport { AVAILABLE_CLIENTS } from '@scalar/types/snippetz'\nimport { defaultMeta, MetaSchema } from '@/schemas/reference-config/meta'\nimport { defaultFeatures, FeaturesSchema } from '@/schemas/reference-config/features'\nimport { AppearanceSchema, defaultAppearance } from '@/schemas/reference-config/appearance'\nimport { defaultRouting, RoutingSchema } from '@/schemas/reference-config/routing'\nimport { defaultSettings, SettingsSchema } from '@/schemas/reference-config/settings'\nimport type { DeepRequired, MutableArray } from '@/types'\n\n/**\n * ReferenceConfigSchema defines the shape of the configuration object\n * for the API Reference. All properties are optional due to Type.Partial.\n * This schema is used for validating and typing the configuration.\n */\nexport const ReferenceConfigSchema = Type.Partial(\n Type.Object({\n /** Document level title */\n title: Type.String(),\n /** Unique slug to identify the document */\n slug: Type.String(),\n /** Settings for the API reference (controls behavior and options) */\n settings: SettingsSchema,\n /** Tag sorting method: currently only 'alpha' (alphabetical) is supported */\n tagSort: Type.Union([Type.Literal('alpha')]),\n /** Operation sorting method: by HTTP method or alphabetically */\n operationSort: Type.Union([Type.Literal('method'), Type.Literal('alpha')]),\n /** Routing configuration (controls navigation) */\n routing: RoutingSchema,\n /** Appearance configuration (controls theming and UI options) */\n appearance: AppearanceSchema,\n /** Features configuration (toggles for enabling/disabling features) */\n features: FeaturesSchema,\n /** Meta information */\n meta: MetaSchema,\n /** List of enabled HTTP clients for code samples */\n httpClients: Type.Array(Type.Union(AVAILABLE_CLIENTS.map((client) => Type.Literal(client)))),\n }),\n)\n\nexport type ReferenceConfig = Static<typeof ReferenceConfigSchema>\n\nexport const defaultReferenceConfig: DeepRequired<ReferenceConfig> = {\n title: 'Scalar API Reference',\n slug: 'scalar-api-reference',\n tagSort: 'alpha',\n operationSort: 'method',\n\n /**\n * Default settings for the API reference.\n */\n settings: defaultSettings,\n\n /**\n * Default routing configuration for the API reference.\n */\n routing: defaultRouting,\n /**\n * Default appearance configuration for the API reference.\n */\n appearance: defaultAppearance,\n\n /**\n * Default features configuration for the API reference.\n */\n features: defaultFeatures,\n\n /**\n * Default meta configuration for the API reference.\n */\n meta: defaultMeta,\n\n /**\n * Default HTTP clients for the API reference.\n */\n httpClients: AVAILABLE_CLIENTS as MutableArray<typeof AVAILABLE_CLIENTS>,\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,aAAa,kBAAkB;AACxC,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,yBAAyB;AACpD,SAAS,gBAAgB,qBAAqB;AAC9C,SAAS,iBAAiB,sBAAsB;AAQzC,MAAM,wBAAwB,KAAK;AAAA,EACxC,KAAK,OAAO;AAAA;AAAA,IAEV,OAAO,KAAK,OAAO;AAAA;AAAA,IAEnB,MAAM,KAAK,OAAO;AAAA;AAAA,IAElB,UAAU;AAAA;AAAA,IAEV,SAAS,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAE3C,eAAe,KAAK,MAAM,CAAC,KAAK,QAAQ,QAAQ,GAAG,KAAK,QAAQ,OAAO,CAAC,CAAC;AAAA;AAAA,IAEzE,SAAS;AAAA;AAAA,IAET,YAAY;AAAA;AAAA,IAEZ,UAAU;AAAA;AAAA,IAEV,MAAM;AAAA;AAAA,IAEN,aAAa,KAAK,MAAM,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,EAC7F,CAAC;AACH;AAIO,MAAM,yBAAwD;AAAA,EACnE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,SAAS;AAAA,EACT,eAAe;AAAA;AAAA;AAAA;AAAA,EAKf,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,SAAS;AAAA;AAAA;AAAA;AAAA,EAIT,YAAY;AAAA;AAAA;AAAA;AAAA,EAKZ,UAAU;AAAA;AAAA;AAAA;AAAA,EAKV,MAAM;AAAA;AAAA;AAAA;AAAA,EAKN,aAAa;AACf;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See: https://github.com/sinclairzx81/typebox/discussions/835
|
|
3
|
+
*/
|
|
4
|
+
import { type TSchema, type TIntersect, type TUnion, type TObject, type TPartial, type TProperties, type Evaluate } from '@sinclair/typebox';
|
|
5
|
+
export type TPartialDeepProperties<T extends TProperties> = {
|
|
6
|
+
[K in keyof T]: TPartialDeep<T[K]>;
|
|
7
|
+
};
|
|
8
|
+
export type TPartialDeepRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [
|
|
9
|
+
infer L extends TSchema,
|
|
10
|
+
...infer R extends TSchema[]
|
|
11
|
+
] ? TPartialDeepRest<R, [...Acc, TPartialDeep<L>]> : Acc;
|
|
12
|
+
export type TPartialDeep<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TPartialDeepRest<S>> : T extends TUnion<infer S> ? TUnion<TPartialDeepRest<S>> : T extends TObject<infer S> ? TPartial<TObject<Evaluate<TPartialDeepProperties<S>>>> : T;
|
|
13
|
+
export declare function PartialDeep<T extends TSchema>(schema: T): TPartialDeep<T>;
|
|
14
|
+
//# sourceMappingURL=typebox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AY,CAAC,CAAC,CAAC,CAUzE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TypeGuard,
|
|
3
|
+
Type
|
|
4
|
+
} from "@sinclair/typebox";
|
|
5
|
+
function PartialDeepProperties(properties) {
|
|
6
|
+
return Object.getOwnPropertyNames(properties).reduce((acc, key) => {
|
|
7
|
+
return { ...acc, [key]: PartialDeep(properties[key]) };
|
|
8
|
+
}, {});
|
|
9
|
+
}
|
|
10
|
+
function PartialDeepRest(rest) {
|
|
11
|
+
return rest.map((schema) => PartialDeep(schema));
|
|
12
|
+
}
|
|
13
|
+
function PartialDeep(schema) {
|
|
14
|
+
return TypeGuard.IsIntersect(schema) ? Type.Intersect(PartialDeepRest(schema.allOf)) : TypeGuard.IsUnion(schema) ? Type.Union(PartialDeepRest(schema.anyOf)) : TypeGuard.IsObject(schema) ? Type.Partial(Type.Object(PartialDeepProperties(schema.properties))) : schema;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
PartialDeep
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=typebox-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/schemas/typebox-types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * See: https://github.com/sinclairzx81/typebox/discussions/835\n */\n\nimport {\n TypeGuard,\n Type,\n type TSchema,\n type TIntersect,\n type TUnion,\n type TObject,\n type TPartial,\n type TProperties,\n type Evaluate,\n} from '@sinclair/typebox'\n\n// -------------------------------------------------------------------------------------\n// TPartialDeepProperties\n// -------------------------------------------------------------------------------------\nexport type TPartialDeepProperties<T extends TProperties> = {\n [K in keyof T]: TPartialDeep<T[K]>\n}\nfunction PartialDeepProperties<T extends TProperties>(properties: T): TPartialDeepProperties<T> {\n return Object.getOwnPropertyNames(properties).reduce((acc, key) => {\n return { ...acc, [key]: PartialDeep(properties[key] as any) }\n }, {}) as never\n}\n// -------------------------------------------------------------------------------------\n// TPartialDeepRest\n// -------------------------------------------------------------------------------------\nexport type TPartialDeepRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [\n infer L extends TSchema,\n ...infer R extends TSchema[],\n]\n ? TPartialDeepRest<R, [...Acc, TPartialDeep<L>]>\n : Acc\nfunction PartialDeepRest<T extends TSchema[]>(rest: [...T]): TPartialDeepRest<T> {\n return rest.map((schema) => PartialDeep(schema)) as never\n}\n// -------------------------------------------------------------------------------------\n// TPartialDeep\n// -------------------------------------------------------------------------------------\nexport type TPartialDeep<T extends TSchema> = T extends TIntersect<infer S>\n ? TIntersect<TPartialDeepRest<S>>\n : T extends TUnion<infer S>\n ? TUnion<TPartialDeepRest<S>>\n : T extends TObject<infer S>\n ? TPartial<TObject<Evaluate<TPartialDeepProperties<S>>>>\n : T\nexport function PartialDeep<T extends TSchema>(schema: T): TPartialDeep<T> {\n return (\n TypeGuard.IsIntersect(schema)\n ? Type.Intersect(PartialDeepRest(schema.allOf))\n : TypeGuard.IsUnion(schema)\n ? Type.Union(PartialDeepRest(schema.anyOf))\n : TypeGuard.IsObject(schema)\n ? Type.Partial(Type.Object(PartialDeepProperties(schema.properties)))\n : schema\n ) as never\n}\n"],
|
|
5
|
+
"mappings": "AAIA;AAAA,EACE;AAAA,EACA;AAAA,OAQK;AAQP,SAAS,sBAA6C,YAA0C;AAC9F,SAAO,OAAO,oBAAoB,UAAU,EAAE,OAAO,CAAC,KAAK,QAAQ;AACjE,WAAO,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,YAAY,WAAW,GAAG,CAAQ,EAAE;AAAA,EAC9D,GAAG,CAAC,CAAC;AACP;AAUA,SAAS,gBAAqC,MAAmC;AAC/E,SAAO,KAAK,IAAI,CAAC,WAAW,YAAY,MAAM,CAAC;AACjD;AAWO,SAAS,YAA+B,QAA4B;AACzE,SACE,UAAU,YAAY,MAAM,IACxB,KAAK,UAAU,gBAAgB,OAAO,KAAK,CAAC,IAC5C,UAAU,QAAQ,MAAM,IACtB,KAAK,MAAM,gBAAgB,OAAO,KAAK,CAAC,IACxC,UAAU,SAAS,MAAM,IACvB,KAAK,QAAQ,KAAK,OAAO,sBAAsB,OAAO,UAAU,CAAC,CAAC,IAClE;AAEZ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReferenceObject } from '../../schemas/v3.1/strict/reference.js';
|
|
2
|
-
/** Type guard to check if a value is a reference */
|
|
3
|
-
export declare const isReference: (value: unknown) => value is ReferenceObject;
|
|
4
2
|
/**
|
|
5
3
|
* Type helper we can use if we have performed the isReference check higher in the stack
|
|
6
4
|
*/
|
|
7
5
|
export type Dereference<T> = Exclude<T, ReferenceObject>;
|
|
6
|
+
/** Type guard to check if a value is a reference */
|
|
7
|
+
export declare const isReference: (value: unknown) => value is ReferenceObject;
|
|
8
|
+
/** Type guard to check if a reference has been resolved */
|
|
9
|
+
export declare const isResolvedRef: <T>(value: unknown) => value is Dereference<T>;
|
|
8
10
|
//# sourceMappingURL=type-guard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-guard.d.ts","sourceRoot":"","sources":["../../../src/schemas/v3.1/type-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,KAAK,IAAI,eACU,CAAA;AAEhE
|
|
1
|
+
{"version":3,"file":"type-guard.d.ts","sourceRoot":"","sources":["../../../src/schemas/v3.1/type-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,CAAA;AAExD,oDAAoD;AACpD,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,KAAK,IAAI,eACU,CAAA;AAEhE,2DAA2D;AAC3D,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,OAAO,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const isReference = (value) => typeof value === "object" && value !== null && "$ref" in value;
|
|
2
|
+
const isResolvedRef = (value) => typeof value === "object" && value !== null && !("$ref" in value);
|
|
2
3
|
export {
|
|
3
|
-
isReference
|
|
4
|
+
isReference,
|
|
5
|
+
isResolvedRef
|
|
4
6
|
};
|
|
5
7
|
//# sourceMappingURL=type-guard.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/schemas/v3.1/type-guard.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReferenceObject } from '@/schemas/v3.1/strict/reference'\n\n/** Type guard to check if a value is a reference */\nexport const isReference = (value: unknown): value is ReferenceObject =>\n typeof value === 'object' && value !== null && '$ref' in value\n\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { ReferenceObject } from '@/schemas/v3.1/strict/reference'\n\n/**\n * Type helper we can use if we have performed the isReference check higher in the stack\n */\nexport type Dereference<T> = Exclude<T, ReferenceObject>\n\n/** Type guard to check if a value is a reference */\nexport const isReference = (value: unknown): value is ReferenceObject =>\n typeof value === 'object' && value !== null && '$ref' in value\n\n/** Type guard to check if a reference has been resolved */\nexport const isResolvedRef = <T>(value: unknown): value is Dereference<T> =>\n typeof value === 'object' && value !== null && !('$ref' in value)\n"],
|
|
5
|
+
"mappings": "AAQO,MAAM,cAAc,CAAC,UAC1B,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AAGpD,MAAM,gBAAgB,CAAI,UAC/B,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/server.d.ts.map
CHANGED
|
@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gB,8BAA8B,CAC5C,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,uBAyB3G;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,uBAkC3G;AAsCD;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,cAAc,EAAE,0BAA0B;IAmGvF;;;;;;;;;;;OAWG;;IAwCH;;;;;;;;;;OAUG;;mBApJc,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG;YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;SAAE,CAAC;;;;;;IAwJzG;;;;;;;;;;;;;;;;;OAiBG;mBACY,MAAM;IAGrB;;;;;;;;;OASG;yBA9G6B,sBAAsB;GAiHzD"}
|
package/dist/server.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createNavigation } from "./navigation/index.js";
|
|
|
6
6
|
import { extensions } from "./schemas/extensions.js";
|
|
7
7
|
import { OpenAPIDocumentSchema } from "./schemas/v3.1/strict/openapi-document.js";
|
|
8
8
|
import { keyOf } from "./helpers/general.js";
|
|
9
|
-
import { fetchUrls, readFiles } from "@scalar/
|
|
9
|
+
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
10
10
|
import { coerceValue } from "./schemas/typebox-coerce.js";
|
|
11
11
|
const DEFAULT_ASSETS_FOLDER = "assets";
|
|
12
12
|
const WORKSPACE_FILE_NAME = "scalar-workspace.json";
|
|
@@ -32,7 +32,9 @@ function filterHttpMethodsOnly(paths) {
|
|
|
32
32
|
function escapePaths(paths) {
|
|
33
33
|
const result = {};
|
|
34
34
|
Object.keys(paths).forEach((path) => {
|
|
35
|
-
|
|
35
|
+
if (paths[path]) {
|
|
36
|
+
result[escapeJsonPointer(path)] = paths[path];
|
|
37
|
+
}
|
|
36
38
|
});
|
|
37
39
|
return result;
|
|
38
40
|
}
|
|
@@ -43,7 +45,7 @@ function externalizeComponentReferences(document, meta) {
|
|
|
43
45
|
}
|
|
44
46
|
Object.entries(document.components).forEach(([type, component]) => {
|
|
45
47
|
if (!component || typeof component !== "object") {
|
|
46
|
-
return
|
|
48
|
+
return;
|
|
47
49
|
}
|
|
48
50
|
result[type] = {};
|
|
49
51
|
Object.keys(component).forEach((name) => {
|
|
@@ -60,7 +62,7 @@ function externalizePathReferences(document, meta) {
|
|
|
60
62
|
}
|
|
61
63
|
Object.entries(document.paths).forEach(([path, pathItem]) => {
|
|
62
64
|
if (!pathItem || typeof pathItem !== "object") {
|
|
63
|
-
return
|
|
65
|
+
return;
|
|
64
66
|
}
|
|
65
67
|
const pathItemRecord = pathItem;
|
|
66
68
|
result[path] = {};
|
package/dist/server.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/server.ts"],
|
|
4
|
-
"sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport { OpenAPIDocumentSchema, type OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { PathsObject } from '@/schemas/v3.1/strict/paths'\nimport { keyOf } from '@/helpers/general'\nimport type { OperationObject } from '@/schemas/v3.1/strict/path-operations'\nimport { fetchUrls, readFiles } from '@scalar/openapi-parser/plugins'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport type { ComponentsObject } from '@/schemas/v3.1/strict/components'\nimport type { TraversedEntry } from '@/schemas/navigation'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: Record<string, Record<string, OperationObject>>) {\n const result: Record<string, Record<string, OperationObject>> = {}\n Object.keys(paths).forEach((path) => {\n result[escapeJsonPointer(path)] = paths[path]\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return result\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return result\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nasync function loadDocument(workspaceDocument: WorkspaceDocumentInput) {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedEntry[] }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification)\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,mBAAmB,eAAe;AAC3C,SAAS,gBAAgB,wBAAwB;AAEjD,OAAO,QAAQ;AACf,SAAS,WAAW;AACpB,SAAS,wBAAsD;AAC/D,SAAS,kBAAkB;AAC3B,SAAS,6BAAmD;AAE5D,SAAS,aAAa;AAEtB,SAAS,WAAW,iBAAiB;AACrC,SAAS,mBAAmB;AAI5B,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAoB;AACxD,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,UAAM,kBAAuC,CAAC;AAE9C,eAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,UAAI,YAAY,IAAI,OAAO,YAAY,CAAC,GAAG;AACzC,wBAAgB,MAAM,IAAI;AAAA,MAC5B;AAAA,IACF;AAEA,QAAI,OAAO,KAAK,eAAe,EAAE,SAAS,GAAG;AAC3C,aAAO,IAAI,IAAI;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAWO,SAAS,YAAY,OAAwD;AAClF,QAAM,SAA0D,CAAC;
|
|
4
|
+
"sourcesContent": ["import { escapeJsonPointer, upgrade } from '@scalar/openapi-parser'\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\nimport fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\nimport { createNavigation, type createNavigationOptions } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport { OpenAPIDocumentSchema, type OpenApiDocument } from '@/schemas/v3.1/strict/openapi-document'\nimport type { PathsObject } from '@/schemas/v3.1/strict/paths'\nimport { keyOf } from '@/helpers/general'\nimport type { OperationObject } from '@/schemas/v3.1/strict/path-operations'\nimport { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport type { ComponentsObject } from '@/schemas/v3.1/strict/components'\nimport type { TraversedEntry } from '@/schemas/navigation'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: createNavigationOptions\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(paths: Record<string, Record<string, OperationObject>>) {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n Object.keys(paths).forEach((path) => {\n if (paths[path]) {\n result[escapeJsonPointer(path)] = paths[path]\n }\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nasync function loadDocument(workspaceDocument: WorkspaceDocumentInput) {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedEntry[] }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document).specification)\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,mBAAmB,eAAe;AAC3C,SAAS,gBAAgB,wBAAwB;AAEjD,OAAO,QAAQ;AACf,SAAS,WAAW;AACpB,SAAS,wBAAsD;AAC/D,SAAS,kBAAkB;AAC3B,SAAS,6BAAmD;AAE5D,SAAS,aAAa;AAEtB,SAAS,WAAW,iBAAiB;AACrC,SAAS,mBAAmB;AAI5B,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAoB;AACxD,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - 'Required': Makes all properties required
|
|
8
|
-
* - 'Readonly': Makes all properties readonly
|
|
9
|
-
*
|
|
10
|
-
* If no valid transformation is provided, returns the original type unchanged.
|
|
11
|
-
*
|
|
12
|
-
* @template T - The type to transform
|
|
13
|
-
* @template Transform - The transformation to apply ('NonNullable' | 'Partial' | 'Required' | 'Readonly')
|
|
14
|
-
*/
|
|
15
|
-
type ApplyTransform<T, Transform> = Transform extends 'NonNullable' ? NonNullable<T> : Transform extends 'Partial' ? Partial<T> : Transform extends 'Required' ? Required<T> : Transform extends 'Readonly' ? Readonly<T> : T;
|
|
16
|
-
/**
|
|
17
|
-
* Recursively applies a type transformation to all levels of a nested type structure.
|
|
18
|
-
*
|
|
19
|
-
* This utility type traverses through complex nested types and applies the specified transformation
|
|
20
|
-
* at each level. It handles:
|
|
21
|
-
* - Functions: Returns the function type unchanged (no transformation applied)
|
|
22
|
-
* - Arrays: Recursively transforms each element in the array
|
|
23
|
-
* - Objects: Recursively transforms each property value in the object
|
|
24
|
-
* - Primitives: Applies the transformation directly using ApplyTransform
|
|
25
|
-
*
|
|
26
|
-
* The transformation is applied using the ApplyTransform utility, which supports:
|
|
27
|
-
* 'NonNullable', 'Partial', 'Required', and 'Readonly' transformations.
|
|
28
|
-
*
|
|
29
|
-
* @template T - The type to recursively transform
|
|
30
|
-
* @template Transform - The transformation to apply at each level
|
|
31
|
-
* @example
|
|
32
|
-
* // Make all properties in a nested object optional
|
|
33
|
-
* type OptionalNested = DeepTransform<{ a: { b: string } }, 'Partial'>
|
|
34
|
-
* // Result: { a?: { b?: string } }
|
|
35
|
-
*/
|
|
36
|
-
export type DeepTransform<T, Transform> = T extends (...args: any[]) => any ? T : T extends Array<infer U> ? Array<DeepTransform<U, Transform>> : T extends object ? {
|
|
37
|
-
[K in keyof T]-?: DeepTransform<ApplyTransform<NonNullable<T[K]>, Transform>, Transform>;
|
|
38
|
-
} : ApplyTransform<NonNullable<T>, Transform>;
|
|
1
|
+
export type DeepRequired<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepRequired<U>> : T extends object ? {
|
|
2
|
+
[K in keyof T]-?: DeepRequired<T[K]>;
|
|
3
|
+
} : T;
|
|
4
|
+
export type DeepPartial<T> = T extends Function ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
|
|
5
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
6
|
+
} : T;
|
|
39
7
|
/**
|
|
40
8
|
* Converts a readonly array type to a mutable array type.
|
|
41
9
|
*
|
|
@@ -53,5 +21,4 @@ export type DeepTransform<T, Transform> = T extends (...args: any[]) => any ? T
|
|
|
53
21
|
export type MutableArray<T extends readonly any[]> = {
|
|
54
22
|
-readonly [k in keyof T]: T[k];
|
|
55
23
|
};
|
|
56
|
-
export {};
|
|
57
24
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAC5C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GACtB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACxC,CAAC,CAAA;AAET,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAC3C,CAAC,GACD,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GACrB,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtC,CAAC,CAAA;AAET;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,EAAE,IAAI;IACnD,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAA"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"openapi",
|
|
17
17
|
"scalar"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.
|
|
19
|
+
"version": "0.12.0",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18"
|
|
22
22
|
},
|
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
"types": "./dist/schemas.d.ts",
|
|
33
33
|
"default": "./dist/schemas.js"
|
|
34
34
|
},
|
|
35
|
+
"./schemas/schemas/workspace": {
|
|
36
|
+
"import": "./dist/schemas/workspace.js",
|
|
37
|
+
"types": "./dist/schemas/workspace.d.ts",
|
|
38
|
+
"default": "./dist/schemas/workspace.js"
|
|
39
|
+
},
|
|
40
|
+
"./helpers/*": {
|
|
41
|
+
"import": "./dist/helpers/*.js",
|
|
42
|
+
"types": "./dist/helpers/*.d.ts",
|
|
43
|
+
"default": "./dist/helpers/*.js"
|
|
44
|
+
},
|
|
35
45
|
"./schemas/v3.1/*": {
|
|
36
46
|
"import": "./dist/schemas/v3.1/*.js",
|
|
37
47
|
"types": "./dist/schemas/v3.1/*.d.ts",
|
|
@@ -57,18 +67,17 @@
|
|
|
57
67
|
"github-slugger": "^2.0.0",
|
|
58
68
|
"vue": "^3.5.17",
|
|
59
69
|
"yaml": "2.8.0",
|
|
60
|
-
"@scalar/
|
|
61
|
-
"@scalar/
|
|
62
|
-
"@scalar/
|
|
63
|
-
"@scalar/
|
|
64
|
-
"@scalar/openapi-
|
|
65
|
-
"@scalar/types": "0.2.10"
|
|
70
|
+
"@scalar/helpers": "0.0.7",
|
|
71
|
+
"@scalar/json-magic": "0.1.0",
|
|
72
|
+
"@scalar/code-highlight": "0.1.9",
|
|
73
|
+
"@scalar/types": "0.2.11",
|
|
74
|
+
"@scalar/openapi-parser": "0.19.0"
|
|
66
75
|
},
|
|
67
76
|
"devDependencies": {
|
|
68
77
|
"@google-cloud/storage": "7.16.0",
|
|
69
78
|
"fastify": "^5.3.3",
|
|
70
|
-
"vite": "
|
|
71
|
-
"vitest": "^
|
|
79
|
+
"vite": "6.1.6",
|
|
80
|
+
"vitest": "^3.2.4",
|
|
72
81
|
"@scalar/build-tooling": "0.2.4"
|
|
73
82
|
},
|
|
74
83
|
"scripts": {
|
package/dist/helpers/proxy.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { UnknownObject } from './general.js';
|
|
2
|
-
export declare const TARGET_SYMBOL: unique symbol;
|
|
3
|
-
/**
|
|
4
|
-
* Creates a proxy that automatically resolves JSON references ($ref) in an object.
|
|
5
|
-
* The proxy intercepts property access and automatically resolves any $ref references
|
|
6
|
-
* to their target values in the source document.
|
|
7
|
-
*
|
|
8
|
-
* @param targetObject - The object to create a proxy for
|
|
9
|
-
* @param sourceDocument - The source document containing the reference targets (defaults to targetObject)
|
|
10
|
-
* @param resolvedProxyCache - Optional cache to store resolved proxies and prevent duplicate proxies
|
|
11
|
-
* @returns A proxy that automatically resolves $ref references
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Basic usage with local references
|
|
15
|
-
* const doc = {
|
|
16
|
-
* components: {
|
|
17
|
-
* schemas: {
|
|
18
|
-
* User: { type: 'object', properties: { name: { type: 'string' } } }
|
|
19
|
-
* }
|
|
20
|
-
* },
|
|
21
|
-
* paths: {
|
|
22
|
-
* '/users': {
|
|
23
|
-
* get: {
|
|
24
|
-
* responses: {
|
|
25
|
-
* 200: {
|
|
26
|
-
* content: {
|
|
27
|
-
* 'application/json': {
|
|
28
|
-
* schema: { $ref: '#/components/schemas/User' }
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* const proxy = createMagicProxy(doc)
|
|
39
|
-
* // Accessing the schema will automatically resolve the $ref
|
|
40
|
-
* console.log(proxy.paths['/users'].get.responses[200].content['application/json'].schema)
|
|
41
|
-
* // Output: { type: 'object', properties: { name: { type: 'string' } } }
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* // Using with a cache to prevent duplicate proxies
|
|
45
|
-
* const cache = new WeakMap()
|
|
46
|
-
* const proxy1 = createMagicProxy(doc, doc, cache)
|
|
47
|
-
* const proxy2 = createMagicProxy(doc, doc, cache)
|
|
48
|
-
* // proxy1 and proxy2 are the same instance due to caching
|
|
49
|
-
* console.log(proxy1 === proxy2) // true
|
|
50
|
-
*/
|
|
51
|
-
export declare function createMagicProxy<T extends UnknownObject | UnknownObject[]>(targetObject: T, sourceDocument?: T, resolvedProxyCache?: WeakMap<object, T>): T;
|
|
52
|
-
/**
|
|
53
|
-
* Gets the raw (non-proxied) version of an object created by createMagicProxy.
|
|
54
|
-
* This is useful when you need to access the original object without the magic proxy wrapper.
|
|
55
|
-
*
|
|
56
|
-
* @param obj - The magic proxy object to get the raw version of
|
|
57
|
-
* @returns The raw version of the object
|
|
58
|
-
* @example
|
|
59
|
-
* const proxy = createMagicProxy({ foo: { $ref: '#/bar' } })
|
|
60
|
-
* const raw = getRaw(proxy) // { foo: { $ref: '#/bar' } }
|
|
61
|
-
*/
|
|
62
|
-
export declare function getRaw<T extends UnknownObject>(obj: T): T;
|
|
63
|
-
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/proxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE9C,eAAO,MAAM,aAAa,eAAmB,CAAA;AAyH7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,EACxE,YAAY,EAAE,CAAC,EACf,cAAc,GAAE,CAAgB,EAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GACtC,CAAC,CAyBH;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,aAAa,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEzD"}
|