@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 @@
1
+ {"version":3,"file":"create-workspace-store.d.ts","sourceRoot":"","sources":["../src/create-workspace-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAa,MAAM,4BAA4B,CAAA;AAKjG,KAAK,0BA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pers/proxy.js";
3
+ import { fetchUrl, isObject, readLocalFile, resolveContents } from "./helpers/general.js";
4
+ import { getValueByPath, parseJsonPointer } from "./helpers/json-path-utils.js";
5
+ async function loadDocument(workspaceDocument) {
6
+ if ("url" in workspaceDocument) {
7
+ return fetchUrl(workspaceDocument.url);
8
+ }
9
+ if ("path" in workspaceDocument) {
10
+ return readLocalFile(workspaceDocument.path);
11
+ }
12
+ return {
13
+ ok: true,
14
+ data: workspaceDocument.document
15
+ };
16
+ }
17
+ async function createWorkspaceStore(workspaceProps) {
18
+ const workspace = reactive({
19
+ ...workspaceProps?.meta,
20
+ documents: (await Promise.all(
21
+ (workspaceProps?.documents ?? []).map(async (data) => {
22
+ const resolved = await loadDocument(data);
23
+ if (!resolved.ok) {
24
+ console.error(`Can not load the document '${data.name}'`);
25
+ return {
26
+ name: data.name,
27
+ meta: data.meta,
28
+ document: {}
29
+ };
30
+ }
31
+ return {
32
+ name: data.name,
33
+ meta: data.meta,
34
+ document: isObject(resolved.data) ? resolved.data : {}
35
+ };
36
+ })
37
+ )).reduce((acc, { name, meta, document }) => {
38
+ acc[name] = createMagicProxy({ ...document, ...meta });
39
+ return acc;
40
+ }, {}),
41
+ /**
42
+ * Returns the currently active document from the workspace.
43
+ * The active document is determined by the 'x-scalar-active-document' metadata field,
44
+ * falling back to the first document in the workspace if no active document is specified.
45
+ *
46
+ * @returns The active document or undefined if no document is found
47
+ */
48
+ get activeDocument() {
49
+ const activeDocumentKey = workspace["x-scalar-active-document"] ?? Object.keys(workspace.documents)[0] ?? "";
50
+ return workspace.documents[activeDocumentKey];
51
+ }
52
+ });
53
+ return {
54
+ /**
55
+ * Returns the raw (non-reactive) workspace object
56
+ */
57
+ get rawWorkspace() {
58
+ return toRaw(workspace);
59
+ },
60
+ /**
61
+ * Returns the reactive workspace object with an additional activeDocument getter
62
+ */
63
+ get workspace() {
64
+ return workspace;
65
+ },
66
+ /**
67
+ * Updates a specific metadata field in the workspace
68
+ * @param key - The metadata field to update
69
+ * @param value - The new value for the field
70
+ * @example
71
+ * // Update the workspace title
72
+ * update('x-scalar-active-document', 'document-name')
73
+ */
74
+ update(key, value) {
75
+ if (key === "__proto__" || key === "constructor" || key === "prototype") {
76
+ throw new Error("Invalid key: cannot modify prototype");
77
+ }
78
+ Object.assign(workspace, { [key]: value });
79
+ },
80
+ /**
81
+ * Updates a specific metadata field in a document
82
+ * @param name - The name of the document to update ('active' or a specific document name)
83
+ * @param key - The metadata field to update
84
+ * @param value - The new value for the field
85
+ * @throws Error if the specified document doesn't exist
86
+ * @example
87
+ * // Update the auth of the active document
88
+ * updateDocument('active', 'x-scalar-active-auth', 'Bearer')
89
+ * // Update the auth of a specific document
90
+ * updateDocument('document-name', 'x-scalar-active-auth', 'Bearer')
91
+ */
92
+ updateDocument(name, key, value) {
93
+ const currentDocument = workspace.documents[name === "active" ? workspace["x-scalar-active-document"] ?? workspaceProps?.documents?.[0].name ?? "" : name];
94
+ if (!currentDocument) {
95
+ throw "Please select a valid document";
96
+ }
97
+ Object.assign(currentDocument, { [key]: value });
98
+ },
99
+ /**
100
+ * Resolves a reference in the active document by following the provided path and resolving any external $ref references.
101
+ * This method traverses the document structure following the given path and resolves any $ref references it encounters.
102
+ * During resolution, it sets a loading status and updates the reference with the resolved content.
103
+ *
104
+ * @param path - Array of strings representing the path to the reference (e.g. ['paths', '/users', 'get', 'responses', '200'])
105
+ * @throws Error if the path is invalid or empty
106
+ * @example
107
+ * // Resolve a reference in the active document
108
+ * resolve(['paths', '/users', 'get', 'responses', '200'])
109
+ */
110
+ resolve: async (path) => {
111
+ if (path.length <= 1) {
112
+ throw "Please provide a valid path";
113
+ }
114
+ const lastPathSegment = path.pop();
115
+ const activeDocument = workspace.documents[workspace["x-scalar-active-document"] ?? Object.keys(workspace.documents)[0] ?? ""];
116
+ let parent = activeDocument;
117
+ for (const p of path) {
118
+ parent = parent[p];
119
+ }
120
+ const processedObjects = /* @__PURE__ */ new WeakSet();
121
+ const resolveRecursive = async (root, targetKey) => {
122
+ if (!root && !isObject(root)) {
123
+ return;
124
+ }
125
+ const target = root[targetKey];
126
+ if (!target || !isObject(target)) {
127
+ return;
128
+ }
129
+ const rawTarget = getRaw(target);
130
+ if (processedObjects.has(rawTarget)) {
131
+ return;
132
+ }
133
+ processedObjects.add(rawTarget);
134
+ if (typeof target === "object" && "$ref" in target && typeof target["$ref"] === "string") {
135
+ const ref = target["$ref"];
136
+ Object.assign(target, { "$status": "loading" });
137
+ const [path2, pointer] = ref.split("#");
138
+ const result = await resolveContents(path2);
139
+ if (result.ok) {
140
+ if (targetKey === "__proto__" || targetKey === "constructor" || targetKey === "prototype") {
141
+ throw new Error("Invalid key: cannot modify prototype");
142
+ }
143
+ Object.assign(root, { [targetKey]: getValueByPath(result.data, parseJsonPointer(pointer)) });
144
+ await resolveRecursive(root, targetKey);
145
+ } else {
146
+ Object.assign(target, { "$status": "error" });
147
+ }
148
+ return;
149
+ }
150
+ await Promise.all(Object.keys(target).map((key) => resolveRecursive(target, key)));
151
+ };
152
+ return resolveRecursive(parent, lastPathSegment);
153
+ },
154
+ /**
155
+ * Adds a new document to the workspace
156
+ * @param document - The document content to add. This should be a valid OpenAPI/Swagger document or other supported format
157
+ * @param meta - Metadata for the document, including its name and other properties defined in WorkspaceDocumentMeta
158
+ * @example
159
+ * // Add a new OpenAPI document to the workspace
160
+ * store.addDocument({
161
+ * name: 'name',
162
+ * document: {
163
+ * openapi: '3.0.0',
164
+ * info: { title: 'title' },
165
+ * },
166
+ * meta: {
167
+ * 'x-scalar-active-auth': 'Bearer',
168
+ * 'x-scalar-active-server': 'production'
169
+ * }
170
+ * })
171
+ */
172
+ addDocument: async (input) => {
173
+ const { name, meta } = input;
174
+ const resolve = await loadDocument(input);
175
+ if (!resolve.ok || !isObject(resolve.data)) {
176
+ console.error(`Can not load the document '${name}'`);
177
+ return;
178
+ }
179
+ workspace.documents[name] = createMagicProxy({ ...resolve.data, ...meta });
180
+ }
181
+ };
182
+ }
183
+ export {
184
+ createWorkspaceStore
185
+ };
186
+ //# sourceMappingURL=create-workspace-store.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/create-workspace-store.ts"],
4
+ "sourcesContent": ["import { reactive, toRaw } from 'vue'\nimport type { WorkspaceMeta, WorkspaceDocumentMeta, Workspace } from './schemas/server-workspace'\nimport { createMagicProxy, getRaw } from './helpers/proxy'\nimport { fetchUrl, isObject, readLocalFile, resolveContents } from '@/helpers/general'\nimport { getValueByPath, parseJsonPointer } from '@/helpers/json-path-utils'\n\ntype WorkspaceDocumentMetaInput = { meta?: WorkspaceDocumentMeta; name: string }\ntype WorkspaceDocumentInput =\n | ({ document: Record<string, unknown> } & WorkspaceDocumentMetaInput)\n | ({ url: string } & WorkspaceDocumentMetaInput)\n | ({ path: string } & WorkspaceDocumentMetaInput)\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 from local file\n * const fileDoc = await loadDocument({ name: 'local', path: './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 fetchUrl(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readLocalFile(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Creates a reactive workspace store that manages documents and their metadata.\n * The store provides functionality for accessing, updating, and resolving document references.\n *\n * @param workspaceProps - Configuration object for the workspace\n * @param workspaceProps.meta - Optional metadata for the workspace\n * @param workspaceProps.documents - Optional record of documents to initialize the workspace with\n * @returns An object containing methods and getters for managing the workspace\n */\nexport async function createWorkspaceStore(workspaceProps?: {\n meta?: WorkspaceMeta\n documents?: WorkspaceDocumentInput[]\n}) {\n // Create a reactive workspace object with proxied documents\n // Each document is wrapped in a proxy to enable reactive updates and reference resolution\n const workspace = reactive({\n ...workspaceProps?.meta,\n documents: (\n await Promise.all(\n (workspaceProps?.documents ?? []).map<\n Promise<{ name: string; meta?: WorkspaceDocumentMeta; document: Record<string, unknown> }>\n >(async (data) => {\n const resolved = await loadDocument(data)\n\n if (!resolved.ok) {\n console.error(`Can not load the document '${data.name}'`)\n return {\n name: data.name,\n meta: data.meta,\n document: {},\n }\n }\n\n return {\n name: data.name,\n meta: data.meta,\n document: isObject(resolved.data) ? (resolved.data as Record<string, unknown>) : {},\n }\n }),\n )\n ).reduce<Record<string, Record<string, unknown>>>((acc, { name, meta, document }) => {\n /**\n * We wrap each document in the magic proxy to enable auto-resolving of references\n */\n acc[name] = createMagicProxy({ ...document, ...meta })\n return acc\n }, {}),\n /**\n * Returns the currently active document from the workspace.\n * The active document is determined by the 'x-scalar-active-document' metadata field,\n * falling back to the first document in the workspace if no active document is specified.\n *\n * @returns The active document or undefined if no document is found\n */\n get activeDocument(): (typeof workspace.documents)[number] | undefined {\n const activeDocumentKey = workspace['x-scalar-active-document'] ?? Object.keys(workspace.documents)[0] ?? ''\n return workspace.documents[activeDocumentKey]\n },\n }) as Workspace\n\n return {\n /**\n * Returns the raw (non-reactive) workspace object\n */\n get rawWorkspace() {\n return toRaw(workspace)\n },\n /**\n * Returns the reactive workspace object with an additional activeDocument getter\n */\n get workspace() {\n return workspace\n },\n /**\n * Updates a specific metadata field in the workspace\n * @param key - The metadata field to update\n * @param value - The new value for the field\n * @example\n * // Update the workspace title\n * update('x-scalar-active-document', 'document-name')\n */\n update<K extends keyof WorkspaceMeta>(key: K, value: WorkspaceMeta[K]) {\n // @ts-ignore\n if (key === '__proto__' || key === 'constructor' || key === 'prototype') {\n throw new Error('Invalid key: cannot modify prototype')\n }\n Object.assign(workspace, { [key]: value })\n },\n /**\n * Updates a specific metadata field in a document\n * @param name - The name of the document to update ('active' or a specific document name)\n * @param key - The metadata field to update\n * @param value - The new value for the field\n * @throws Error if the specified document doesn't exist\n * @example\n * // Update the auth of the active document\n * updateDocument('active', 'x-scalar-active-auth', 'Bearer')\n * // Update the auth of a specific document\n * updateDocument('document-name', 'x-scalar-active-auth', 'Bearer')\n */\n updateDocument<K extends keyof WorkspaceDocumentMeta>(\n name: 'active' | (string & {}),\n key: K,\n value: WorkspaceDocumentMeta[K],\n ) {\n const currentDocument =\n workspace.documents[\n name === 'active'\n ? (workspace['x-scalar-active-document'] ?? workspaceProps?.documents?.[0].name ?? '')\n : name\n ]\n\n if (!currentDocument) {\n throw 'Please select a valid document'\n }\n\n Object.assign(currentDocument, { [key]: value })\n },\n /**\n * Resolves a reference in the active document by following the provided path and resolving any external $ref references.\n * This method traverses the document structure following the given path and resolves any $ref references it encounters.\n * During resolution, it sets a loading status and updates the reference with the resolved content.\n *\n * @param path - Array of strings representing the path to the reference (e.g. ['paths', '/users', 'get', 'responses', '200'])\n * @throws Error if the path is invalid or empty\n * @example\n * // Resolve a reference in the active document\n * resolve(['paths', '/users', 'get', 'responses', '200'])\n */\n resolve: async (path: string[]) => {\n if (path.length <= 1) {\n throw 'Please provide a valid path'\n }\n\n const lastPathSegment = path.pop()! // We are sure there is at least an element on the array\n\n const activeDocument =\n workspace.documents[workspace['x-scalar-active-document'] ?? Object.keys(workspace.documents)[0] ?? '']\n\n let parent = activeDocument as Record<string, any>\n\n for (const p of path) {\n parent = parent[p]\n }\n\n // Keep track of objects we've already processed to prevent infinite loops\n const processedObjects = new WeakSet()\n\n const resolveRecursive = async (root: unknown, targetKey: string) => {\n if (!root && !isObject(root)) {\n return\n }\n\n const target = (root as Record<string, unknown>)[targetKey]\n\n if (!target || !isObject(target)) {\n return\n }\n\n // Unwrap the target from the proxy\n const rawTarget = getRaw(target)\n\n // Skip if we've already processed this object\n if (processedObjects.has(rawTarget)) {\n return\n }\n\n // Mark this object as processed\n processedObjects.add(rawTarget)\n\n if (typeof target === 'object' && '$ref' in target && typeof target['$ref'] === 'string') {\n const ref = target['$ref']\n\n // Set the status to loading while we resolve the ref\n Object.assign(target, { '$status': 'loading' })\n\n const [path, pointer] = ref.split('#')\n const result = await resolveContents(path)\n\n if (result.ok) {\n if (targetKey === '__proto__' || targetKey === 'constructor' || targetKey === 'prototype') {\n throw new Error('Invalid key: cannot modify prototype')\n }\n\n Object.assign(root as object, { [targetKey]: getValueByPath(result.data, parseJsonPointer(pointer)) })\n\n await resolveRecursive(root, targetKey)\n } else {\n Object.assign(target, { '$status': 'error' })\n }\n\n return\n }\n\n await Promise.all(Object.keys(target).map((key) => resolveRecursive(target, key)))\n }\n\n return resolveRecursive(parent, lastPathSegment)\n },\n /**\n * Adds a new document to the workspace\n * @param document - The document content to add. This should be a valid OpenAPI/Swagger document or other supported format\n * @param meta - Metadata for the document, including its name and other properties defined in WorkspaceDocumentMeta\n * @example\n * // Add a new OpenAPI document to the workspace\n * store.addDocument({\n * name: 'name',\n * document: {\n * openapi: '3.0.0',\n * info: { title: 'title' },\n * },\n * meta: {\n * 'x-scalar-active-auth': 'Bearer',\n * 'x-scalar-active-server': 'production'\n * }\n * })\n */\n addDocument: async (input: WorkspaceDocumentInput) => {\n const { name, meta } = input\n\n const resolve = await loadDocument(input)\n\n if (!resolve.ok || !isObject(resolve.data)) {\n console.error(`Can not load the document '${name}'`)\n return\n }\n\n workspace.documents[name] = createMagicProxy({ ...(resolve.data as Record<string, unknown>), ...meta })\n },\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,UAAU,aAAa;AAEhC,SAAS,kBAAkB,cAAc;AACzC,SAAS,UAAU,UAAU,eAAe,uBAAuB;AACnE,SAAS,gBAAgB,wBAAwB;AAgCjD,eAAe,aAAa,mBAA2C;AACrE,MAAI,SAAS,mBAAmB;AAC9B,WAA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AiB,EAAE,GAAI,QAAQ,MAAkC,GAAG,KAAK,CAAC;AAAA,IACxG;AAAA,EACF;AACF;",
6
+ "names": ["path"]
7
+ }
@@ -0,0 +1,88 @@
1
+ export type UnknownObject = Record<string, unknown>;
2
+ /**
3
+ * Returns true if the value is a non-null object (but not an array).
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * isObject({}) // true
8
+ * isObject([]) // false
9
+ * isObject(null) // false
10
+ * ```
11
+ */
12
+ export declare function isObject(value: unknown): value is UnknownObject;
13
+ /**
14
+ * Checks if a string is a remote URL (starts with http:// or https://)
15
+ * @param value - The URL string to check
16
+ * @returns true if the string is a remote URL, false otherwise
17
+ * @example
18
+ * ```ts
19
+ * isRemoteUrl('https://example.com/schema.json') // true
20
+ * isRemoteUrl('http://api.example.com/schemas/user.json') // true
21
+ * isRemoteUrl('#/components/schemas/User') // false
22
+ * isRemoteUrl('./local-schema.json') // false
23
+ * ```
24
+ */
25
+ export declare function isRemoteUrl(value: string): boolean;
26
+ /**
27
+ * Checks if a string is a local reference (starts with #)
28
+ * @param value - The reference string to check
29
+ * @returns true if the string is a local reference, false otherwise
30
+ * @example
31
+ * ```ts
32
+ * isLocalRef('#/components/schemas/User') // true
33
+ * isLocalRef('https://example.com/schema.json') // false
34
+ * isLocalRef('./local-schema.json') // false
35
+ * ```
36
+ */
37
+ export declare function isLocalRef(value: string): boolean;
38
+ type ResolveResult = {
39
+ ok: false;
40
+ } | {
41
+ ok: true;
42
+ data: unknown;
43
+ };
44
+ /**
45
+ * Fetches and parses JSON data from a remote URL.
46
+ *
47
+ * @param value - The URL to fetch data from
48
+ * @returns A result object containing either the parsed JSON data or an error indicator
49
+ * @example
50
+ * ```ts
51
+ * const result = await fetchUrl('https://api.example.com/data')
52
+ * if (result.ok) {
53
+ * console.log(result.data) // The parsed JSON data
54
+ * }
55
+ * ```
56
+ */
57
+ export declare function fetchUrl(value: string): Promise<ResolveResult>;
58
+ /**
59
+ * Reads and parses a local JSON file from the filesystem.
60
+ *
61
+ * @param value - The file path to read from
62
+ * @returns A result object containing either the parsed JSON data or an error indicator
63
+ * @example
64
+ * ```ts
65
+ * const result = await readLocalFile('./data.json')
66
+ * if (result.ok) {
67
+ * console.log(result.data) // The parsed JSON data
68
+ * }
69
+ * ```
70
+ */
71
+ export declare function readLocalFile(value: string): Promise<ResolveResult>;
72
+ /**
73
+ * Resolves a reference by attempting to fetch data from either a remote URL or local filesystem.
74
+ * The function automatically determines whether to use fetchUrl() for remote URLs or readLocalFile() for local paths.
75
+ *
76
+ * @param value - The reference string to resolve (URL or file path)
77
+ * @returns A result object containing either the resolved data or an error indicator
78
+ * @example
79
+ * ```ts
80
+ * const result = await resolveContents('https://api.example.com/data')
81
+ * if (result.ok) {
82
+ * console.log(result.data) // The resolved data
83
+ * }
84
+ * ```
85
+ */
86
+ export declare function resolveContents(value: string): Promise<ResolveResult>;
87
+ export {};
88
+ //# sourceMappingURL=general.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../src/helpers/general.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEnD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAE/D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,KAAK,aAAa,GAAG;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAA;AAEhE;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CASpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAQzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAE3E"}
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs/promises";
2
+ function isObject(value) {
3
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4
+ }
5
+ function isRemoteUrl(value) {
6
+ return value.startsWith("http://") || value.startsWith("https://");
7
+ }
8
+ function isLocalRef(value) {
9
+ return value.startsWith("#");
10
+ }
11
+ async function fetchUrl(value) {
12
+ const response = await fetch(value);
13
+ if (response.ok) {
14
+ const body = await response.json();
15
+ return { ok: true, data: body };
16
+ }
17
+ return { ok: false };
18
+ }
19
+ async function readLocalFile(value) {
20
+ try {
21
+ const contents = await fs.readFile(value, "utf-8");
22
+ return { ok: true, data: JSON.parse(contents) };
23
+ } catch {
24
+ return { ok: false };
25
+ }
26
+ }
27
+ async function resolveContents(value) {
28
+ return isRemoteUrl(value) ? await fetchUrl(value) : await readLocalFile(value);
29
+ }
30
+ export {
31
+ fetchUrl,
32
+ isLocalRef,
33
+ isObject,
34
+ isRemoteUrl,
35
+ readLocalFile,
36
+ resolveContents
37
+ };
38
+ //# sourceMappingURL=general.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/general.ts"],
4
+ "sourcesContent": ["import fs from 'node:fs/promises'\n\nexport type UnknownObject = Record<string, unknown>\n\n/**\n * Returns true if the value is a non-null object (but not an array).\n *\n * @example\n * ```ts\n * isObject({}) // true\n * isObject([]) // false\n * isObject(null) // false\n * ```\n */\nexport function isObject(value: unknown): value is UnknownObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/**\n * Checks if a string is a remote URL (starts with http:// or https://)\n * @param value - The URL string to check\n * @returns true if the string is a remote URL, false otherwise\n * @example\n * ```ts\n * isRemoteUrl('https://example.com/schema.json') // true\n * isRemoteUrl('http://api.example.com/schemas/user.json') // true\n * isRemoteUrl('#/components/schemas/User') // false\n * isRemoteUrl('./local-schema.json') // false\n * ```\n */\nexport function isRemoteUrl(value: string): boolean {\n return value.startsWith('http://') || value.startsWith('https://')\n}\n\n/**\n * Checks if a string is a local reference (starts with #)\n * @param value - The reference string to check\n * @returns true if the string is a local reference, false otherwise\n * @example\n * ```ts\n * isLocalRef('#/components/schemas/User') // true\n * isLocalRef('https://example.com/schema.json') // false\n * isLocalRef('./local-schema.json') // false\n * ```\n */\nexport function isLocalRef(value: string): boolean {\n return value.startsWith('#')\n}\n\ntype ResolveResult = { ok: false } | { ok: true; data: unknown }\n\n/**\n * Fetches and parses JSON data from a remote URL.\n *\n * @param value - The URL to fetch data from\n * @returns A result object containing either the parsed JSON data or an error indicator\n * @example\n * ```ts\n * const result = await fetchUrl('https://api.example.com/data')\n * if (result.ok) {\n * console.log(result.data) // The parsed JSON data\n * }\n * ```\n */\nexport async function fetchUrl(value: string): Promise<ResolveResult> {\n const response = await fetch(value)\n\n if (response.ok) {\n const body = await response.json()\n return { ok: true, data: body }\n }\n\n return { ok: false }\n}\n\n/**\n * Reads and parses a local JSON file from the filesystem.\n *\n * @param value - The file path to read from\n * @returns A result object containing either the parsed JSON data or an error indicator\n * @example\n * ```ts\n * const result = await readLocalFile('./data.json')\n * if (result.ok) {\n * console.log(result.data) // The parsed JSON data\n * }\n * ```\n */\nexport async function readLocalFile(value: string): Promise<ResolveResult> {\n try {\n const contents = await fs.readFile(value, 'utf-8')\n\n return { ok: true, data: JSON.parse(contents) }\n } catch {\n return { ok: false }\n }\n}\n\n/**\n * Resolves a reference by attempting to fetch data from either a remote URL or local filesystem.\n * The function automatically determines whether to use fetchUrl() for remote URLs or readLocalFile() for local paths.\n *\n * @param value - The reference string to resolve (URL or file path)\n * @returns A result object containing either the resolved data or an error indicator\n * @example\n * ```ts\n * const result = await resolveContents('https://api.example.com/data')\n * if (result.ok) {\n * console.log(result.data) // The resolved data\n * }\n * ```\n */\nexport async function resolveContents(value: string): Promise<ResolveResult> {\n return isRemoteUrl(value) ? await fetchUrl(value) : await readLocalFile(value)\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AAcR,SAAS,SAAS,OAAwC;AAC/D,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAcO,SAAS,YAAY,OAAwB;AAClD,SAAO,MAAM,WAAW,SAAS,KAAK,MAAM,WAAW,UAAU;AACnE;AAaO,SAAS,WAAW,OAAwB;AACjD,SAAO,MAAM,WAAW,GAAG;AAC7B;AAiBA,eAAsB,SAAS,OAAuC;AACpE,QAAM,WAAW,MAAM,MAAM,KAAK;AAElC,MAAI,SAAS,IAAI;AACf,UAAM,OAAO,MAAM,SAAS,KAAK;AACjC,WAAO,EAAE,IAAI,MAAM,MAAM,KAAK;AAAA,EAChC;AAEA,SAAO,EAAE,IAAI,MAAM;AACrB;AAeA,eAAsB,cAAc,OAAuC;AACzE,MAAI;AACF,UAAM,WAAW,MAAM,GAAG,SAAS,OAAO,OAAO;AAEjD,WAAO,EAAE,IAAI,MAAM,MAAM,KAAK,MAAM,QAAQ,EAAE;AAAA,EAChD,QAAQ;AACN,WAAO,EAAE,IAAI,MAAM;AAAA,EACrB;AACF;AAgBA,eAAsB,gBAAgB,OAAuC;AAC3E,SAAO,YAAY,KAAK,IAAI,MAAM,SAAS,KAAK,IAAI,MAAM,cAAc,KAAK;AAC/E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Parses a JSON Pointer string into an array of path segments
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * parseJsonPointer('#/components/schemas/User')
7
+ *
8
+ * ['components', 'schemas', 'User']
9
+ * ```
10
+ */
11
+ export declare function parseJsonPointer(pointer: string): string[];
12
+ /**
13
+ * Retrieves a nested value from the source document using a path array
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * getValueByPath(document, ['components', 'schemas', 'User'])
18
+ *
19
+ * { id: '123', name: 'John Doe' }
20
+ * ```
21
+ */
22
+ export declare function getValueByPath(obj: any, pointer: string[]): unknown;
23
+ //# sourceMappingURL=json-path-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-path-utils.d.ts","sourceRoot":"","sources":["../../src/helpers/json-path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAOnE"}
@@ -0,0 +1,16 @@
1
+ function parseJsonPointer(pointer) {
2
+ return pointer.split("/").filter((segment, index) => (index !== 0 || segment !== "#") && segment);
3
+ }
4
+ function getValueByPath(obj, pointer) {
5
+ return pointer.reduce((acc, part) => {
6
+ if (acc === void 0 || acc === null) {
7
+ return void 0;
8
+ }
9
+ return acc[part];
10
+ }, obj);
11
+ }
12
+ export {
13
+ getValueByPath,
14
+ parseJsonPointer
15
+ };
16
+ //# sourceMappingURL=json-path-utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/json-path-utils.ts"],
4
+ "sourcesContent": ["/**\n * Parses a JSON Pointer string into an array of path segments\n *\n * @example\n * ```ts\n * parseJsonPointer('#/components/schemas/User')\n *\n * ['components', 'schemas', 'User']\n * ```\n */\nexport function parseJsonPointer(pointer: string): string[] {\n return (\n pointer\n // Split on '/'\n .split('/')\n // Remove the leading '#' if present\n .filter((segment, index) => (index !== 0 || segment !== '#') && segment)\n )\n}\n\n/**\n * Retrieves a nested value from the source document using a path array\n *\n * @example\n * ```ts\n * getValueByPath(document, ['components', 'schemas', 'User'])\n *\n * { id: '123', name: 'John Doe' }\n * ```\n */\nexport function getValueByPath(obj: any, pointer: string[]): unknown {\n return pointer.reduce((acc, part) => {\n if (acc === undefined || acc === null) {\n return undefined\n }\n return acc[part]\n }, obj)\n}\n"],
5
+ "mappings": "AAUO,SAAS,iBAAiB,SAA2B;AAC1D,SACE,QAEG,MAAM,GAAG,EAET,OAAO,CAAC,SAAS,WAAW,UAAU,KAAK,YAAY,QAAQ,OAAO;AAE7E;AAYO,SAAS,eAAe,KAAU,SAA4B;AACnE,SAAO,QAAQ,OAAO,CAAC,KAAK,SAAS;AACnC,QAAI,QAAQ,UAAa,QAAQ,MAAM;AACrC,aAAO;AAAA,IACT;AACA,WAAO,IAAI,IAAI;AAAA,EACjB,GAAG,GAAG;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,63 @@
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>(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(obj: UnknownObject): UnknownObject;
63
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
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;AAoH7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EACtD,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,GAAG,EAAE,aAAa,iBAExC"}
@@ -0,0 +1,100 @@
1
+ import { isReactive, toRaw } from "vue";
2
+ import { getValueByPath, parseJsonPointer } from "./json-path-utils.js";
3
+ import { isLocalRef, isObject } from "./general.js";
4
+ const TARGET_SYMBOL = Symbol("target");
5
+ function createProxyHandler(sourceDocument, resolvedProxyCache) {
6
+ return {
7
+ get(target, property, receiver) {
8
+ if (property === TARGET_SYMBOL) {
9
+ return target;
10
+ }
11
+ if (property === "__isProxy") {
12
+ return true;
13
+ }
14
+ const value = Reflect.get(target, property, receiver);
15
+ const deepResolveNestedRefs = (value2) => {
16
+ if (!isObject(value2)) {
17
+ return value2;
18
+ }
19
+ if ("$ref" in value2) {
20
+ const ref = value2.$ref;
21
+ if (isLocalRef(ref)) {
22
+ const referencePath = parseJsonPointer(ref);
23
+ const resolvedValue = getValueByPath(sourceDocument, referencePath);
24
+ return deepResolveNestedRefs(resolvedValue);
25
+ }
26
+ }
27
+ return createMagicProxy(value2, sourceDocument, resolvedProxyCache);
28
+ };
29
+ return deepResolveNestedRefs(value);
30
+ },
31
+ set(target, property, newValue, receiver) {
32
+ const rawTarget = isReactive(target) ? toRaw(target) : target;
33
+ const currentValue = rawTarget[property];
34
+ if (isObject(currentValue) && "$ref" in currentValue && typeof currentValue.$ref === "string" && isLocalRef(currentValue.$ref)) {
35
+ const referencePath = parseJsonPointer(currentValue.$ref);
36
+ const targetObject = getValueByPath(sourceDocument, referencePath.slice(0, -1));
37
+ const lastPathSegment = referencePath[referencePath.length - 1];
38
+ if (targetObject && lastPathSegment) {
39
+ targetObject[lastPathSegment] = newValue;
40
+ }
41
+ } else {
42
+ Reflect.set(rawTarget, property, newValue, receiver);
43
+ }
44
+ return true;
45
+ },
46
+ has(target, key) {
47
+ if (typeof key === "string" && key !== "$ref" && typeof target.$ref === "string" && isLocalRef(target.$ref)) {
48
+ const referencePath = parseJsonPointer(target["$ref"]);
49
+ const resolvedValue = getValueByPath(sourceDocument, referencePath);
50
+ return resolvedValue ? key in resolvedValue : false;
51
+ }
52
+ return key in target;
53
+ },
54
+ ownKeys(target) {
55
+ if ("$ref" in target && typeof target.$ref === "string" && isLocalRef(target.$ref)) {
56
+ const referencePath = parseJsonPointer(target["$ref"]);
57
+ const resolvedValue = getValueByPath(sourceDocument, referencePath);
58
+ return resolvedValue ? Reflect.ownKeys(resolvedValue) : [];
59
+ }
60
+ return Reflect.ownKeys(target);
61
+ },
62
+ getOwnPropertyDescriptor(target, key) {
63
+ if ("$ref" in target && key !== "$ref" && typeof target.$ref === "string" && isLocalRef(target.$ref)) {
64
+ const referencePath = parseJsonPointer(target["$ref"]);
65
+ const resolvedValue = getValueByPath(sourceDocument, referencePath);
66
+ if (resolvedValue) {
67
+ return Object.getOwnPropertyDescriptor(resolvedValue, key);
68
+ }
69
+ }
70
+ return Object.getOwnPropertyDescriptor(target, key);
71
+ }
72
+ };
73
+ }
74
+ function createMagicProxy(targetObject, sourceDocument = targetObject, resolvedProxyCache) {
75
+ if (!isObject(targetObject)) {
76
+ return targetObject;
77
+ }
78
+ const rawTarget = isReactive(targetObject) ? toRaw(targetObject) : targetObject;
79
+ if (resolvedProxyCache?.has(rawTarget)) {
80
+ const cachedValue = resolvedProxyCache.get(rawTarget);
81
+ if (cachedValue) {
82
+ return cachedValue;
83
+ }
84
+ }
85
+ const handler = createProxyHandler(sourceDocument, resolvedProxyCache);
86
+ const proxy = new Proxy(rawTarget, handler);
87
+ if (resolvedProxyCache) {
88
+ resolvedProxyCache.set(rawTarget, proxy);
89
+ }
90
+ return proxy;
91
+ }
92
+ function getRaw(obj) {
93
+ return obj[TARGET_SYMBOL];
94
+ }
95
+ export {
96
+ TARGET_SYMBOL,
97
+ createMagicProxy,
98
+ getRaw
99
+ };
100
+ //# sourceMappingURL=proxy.js.map