@scalar/agent-chat 0.10.4 → 0.10.5
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/dist/helpers.js +3 -3
- package/dist/helpers.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +9 -9
package/dist/helpers.js
CHANGED
|
@@ -7,11 +7,11 @@ function u(e) {
|
|
|
7
7
|
return Object.values(e.paths ?? {}).flatMap((e) => Object.values(e ?? {}));
|
|
8
8
|
}
|
|
9
9
|
function d(r, i, o) {
|
|
10
|
-
let s = a(i?.components?.securitySchemes, {}, o, r), c = e(i.security)
|
|
11
|
-
return t(s, n(o.getAuthSelectedSchemas({
|
|
10
|
+
let s = a(i?.components?.securitySchemes, {}, o, r), c = e(i.security), l = n(o.getAuthSelectedSchemas({
|
|
12
11
|
type: "document",
|
|
13
12
|
documentName: r
|
|
14
|
-
}), void 0, c)
|
|
13
|
+
}), void 0, c);
|
|
14
|
+
return t(s, l.selectedSchemes[l.selectedIndex] ?? {});
|
|
15
15
|
}
|
|
16
16
|
function f(e) {
|
|
17
17
|
return Object.fromEntries(Object.entries(e.workspace.documents).map(([t, n]) => [t, {
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {})) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: WorkspaceDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName)\n\n const securityRequirements = getSecurityRequirements(document.security)\n\n const selectedSecurity = getSelectedSecurity(\n authStore.getAuthSelectedSchemas({\n type: 'document',\n documentName,\n }),\n undefined,\n securityRequirements,\n )\n\n return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes)\n}\n\n/** Generate document settings from workspace store */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n return Object.fromEntries(\n Object.entries(workspaceStore.workspace.documents).map(([key, document]) => {\n const servers = getServers(document.servers, {\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n\n return [\n key,\n {\n activeServer: getSelectedServer(document, null, null, servers),\n securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth),\n },\n ]\n }),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const getKey = (slug: string) => {\n return `${REFERENCE_LS_KEYS.AUTH}-${slug}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getAuth: (slug: string) => {\n const parsed = JSON.parse(storage.getItem(getKey(slug)) ?? '{}')\n return coerceValue(AuthSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The Auth object to stringify and store.\n */\n setAuth: (slug: string, value: Auth) => {\n storage.setItem(getKey(slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(documentName)\n workspaceStore.auth.load({ [documentName]: auth })\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,EAAc,GAAoC;AAChE,QAAO,OAAO,OAAO,EAAI,SAAS,EAAE,CAAC,CAAC,SAAS,MAAS,OAAO,OAAO,KAAQ,EAAE,CAAC,CAAC;;AAIpF,SAAS,EACP,GACA,GACA,GAC8B;CAC9B,IAAM,IAAiB,EAAc,GAAU,YAAY,iBAAiB,EAAE,EAAE,GAAW,EAAa,EAElG,IAAuB,EAAwB,EAAS,SAAS
|
|
1
|
+
{"version":3,"file":"helpers.js","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["import { REFERENCE_LS_KEYS, safeLocalStorage } from '@scalar/helpers/object/local-storage'\nimport type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { WorkspaceStore } from '@scalar/workspace-store/client'\nimport type { AuthStore } from '@scalar/workspace-store/entities/auth'\nimport { type Auth, AuthSchema } from '@scalar/workspace-store/entities/auth'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport {\n getSecurityRequirements,\n getSecuritySchemes,\n getSelectedSecurity,\n getSelectedServer,\n getServers,\n mergeSecurity,\n} from '@scalar/workspace-store/request-example'\nimport type { WorkspaceDocument } from '@scalar/workspace-store/schemas'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OperationObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\n\nexport function getOperations(doc: Partial<OpenAPIV3_1.Document>) {\n return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {})) as OperationObject[]\n}\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: WorkspaceDocument,\n authStore: AuthStore,\n): SecuritySchemeObjectSecret[] {\n const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName)\n\n const securityRequirements = getSecurityRequirements(document.security)\n\n const selectedSecurity = getSelectedSecurity(\n authStore.getAuthSelectedSchemas({\n type: 'document',\n documentName,\n }),\n undefined,\n securityRequirements,\n )\n\n return getSecuritySchemes(mergedSecurity, selectedSecurity.selectedSchemes[selectedSecurity.selectedIndex] ?? {})\n}\n\n/** Generate document settings from workspace store */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n return Object.fromEntries(\n Object.entries(workspaceStore.workspace.documents).map(([key, document]) => {\n const servers = getServers(document.servers, {\n documentUrl: document?.['x-scalar-original-source-url'],\n })\n\n return [\n key,\n {\n activeServer: getSelectedServer(document, null, null, servers),\n securitySchemes: getSecurityFromDocument(key, document, workspaceStore.auth),\n },\n ]\n }),\n )\n}\n\n// Local storage helper instance, safely wrapped.\nconst storage = safeLocalStorage()\n\n/**\n * Provides an interface to store and retrieve authentication scheme\n * information in local storage, including both the available schemes and\n * the user's selected schemes.\n */\nexport const authStorage = () => {\n const getKey = (slug: string) => {\n return `${REFERENCE_LS_KEYS.AUTH}-${slug}`\n }\n\n return {\n /**\n * Retrieves and coerces the authentication schemes stored in local storage.\n */\n getAuth: (slug: string) => {\n const parsed = JSON.parse(storage.getItem(getKey(slug)) ?? '{}')\n return coerceValue(AuthSchema, parsed)\n },\n /**\n * Stores the authentication schemes in local storage.\n * @param value The Auth object to stringify and store.\n */\n setAuth: (slug: string, value: Auth) => {\n storage.setItem(getKey(slug), JSON.stringify(value))\n },\n }\n}\n\n/**\n * Restores authentication secrets from local storage to the workspace store.\n *\n * This function iterates through stored authentication schemes and restores\n * any secret values (keys starting with x-scalar-secret-) to the active\n * document's security schemes. It uses the current security schemes as the\n * source of truth, only restoring secrets for structures that exist in the\n * current document.\n */\nexport const restoreAuthSecretsFromStorage = ({\n documentName,\n workspaceStore,\n}: {\n documentName: string\n workspaceStore: WorkspaceStore\n}): void => {\n const authPersistence = authStorage()\n const auth = authPersistence.getAuth(documentName)\n workspaceStore.auth.load({ [documentName]: auth })\n}\n\nexport function safeParseJson(value: string) {\n try {\n return JSON.parse(value)\n } catch {\n return\n }\n}\n"],"mappings":";;;;;AAkBA,SAAgB,EAAc,GAAoC;AAChE,QAAO,OAAO,OAAO,EAAI,SAAS,EAAE,CAAC,CAAC,SAAS,MAAS,OAAO,OAAO,KAAQ,EAAE,CAAC,CAAC;;AAIpF,SAAS,EACP,GACA,GACA,GAC8B;CAC9B,IAAM,IAAiB,EAAc,GAAU,YAAY,iBAAiB,EAAE,EAAE,GAAW,EAAa,EAElG,IAAuB,EAAwB,EAAS,SAAS,EAEjE,IAAmB,EACvB,EAAU,uBAAuB;EAC/B,MAAM;EACN;EACD,CAAC,EACF,KAAA,GACA,EACD;AAED,QAAO,EAAmB,GAAgB,EAAiB,gBAAgB,EAAiB,kBAAkB,EAAE,CAAC;;AAInH,SAAgB,EAAuB,GAAgC;AACrE,QAAO,OAAO,YACZ,OAAO,QAAQ,EAAe,UAAU,UAAU,CAAC,KAAK,CAAC,GAAK,OAKrD,CACL,GACA;EACE,cAAc,EAAkB,GAAU,MAAM,MAPpC,EAAW,EAAS,SAAS,EAC3C,aAAa,IAAW,iCACzB,CAAC,CAKgE;EAC9D,iBAAiB,EAAwB,GAAK,GAAU,EAAe,KAAK;EAC7E,CACF,CACD,CACH;;AAIH,IAAM,IAAU,GAAkB,EAOrB,UAAoB;CAC/B,IAAM,KAAU,MACP,GAAG,EAAkB,KAAK,GAAG;AAGtC,QAAO;EAIL,UAAU,MAED,EAAY,GADJ,KAAK,MAAM,EAAQ,QAAQ,EAAO,EAAK,CAAC,IAAI,KAAK,CAC1B;EAMxC,UAAU,GAAc,MAAgB;AACtC,KAAQ,QAAQ,EAAO,EAAK,EAAE,KAAK,UAAU,EAAM,CAAC;;EAEvD;GAYU,KAAiC,EAC5C,iBACA,wBAIU;CAEV,IAAM,IADkB,GAAa,CACR,QAAQ,EAAa;AAClD,GAAe,KAAK,KAAK,GAAG,IAAe,GAAM,CAAC;;AAGpD,SAAgB,EAAc,GAAe;AAC3C,KAAI;AACF,SAAO,KAAK,MAAM,EAAM;SAClB;AACN"}
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/agent-chat"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.10.
|
|
13
|
+
"version": "0.10.5",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
"truncate-json": "3.0.1",
|
|
51
51
|
"vue": "^3.5.30",
|
|
52
52
|
"zod": "^4.3.5",
|
|
53
|
-
"@scalar/api-client": "3.
|
|
54
|
-
"@scalar/components": "0.22.
|
|
55
|
-
"@scalar/helpers": "0.5.
|
|
56
|
-
"@scalar/
|
|
53
|
+
"@scalar/api-client": "3.1.0",
|
|
54
|
+
"@scalar/components": "0.22.1",
|
|
55
|
+
"@scalar/helpers": "0.5.1",
|
|
56
|
+
"@scalar/json-magic": "0.12.7",
|
|
57
57
|
"@scalar/icons": "0.7.2",
|
|
58
|
-
"@scalar/
|
|
58
|
+
"@scalar/openapi-types": "0.7.0",
|
|
59
|
+
"@scalar/types": "0.9.1",
|
|
59
60
|
"@scalar/themes": "0.15.3",
|
|
60
|
-
"@scalar/
|
|
61
|
-
"@scalar/
|
|
62
|
-
"@scalar/workspace-store": "0.46.0"
|
|
61
|
+
"@scalar/workspace-store": "0.46.1",
|
|
62
|
+
"@scalar/use-toasts": "0.10.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@tailwindcss/vite": "^4.2.0",
|