@scalar/agent-chat 0.3.1 → 0.3.3
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/App.vue.d.ts +4 -5
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js +16 -14
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Chat.vue.js +43 -16
- package/dist/api.d.ts +53 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +67 -37
- package/dist/components/ApprovalSection.vue.d.ts.map +1 -1
- package/dist/components/ApprovalSection.vue.js +1 -1
- package/dist/components/ApprovalSection.vue2.js +19 -28
- package/dist/components/AuthenticationProvided.vue.js +8 -8
- package/dist/components/PaymentSection.vue.d.ts +1 -7
- package/dist/components/PaymentSection.vue.d.ts.map +1 -1
- package/dist/components/PaymentSection.vue.js +2 -2
- package/dist/components/PaymentSection.vue2.js +21 -21
- package/dist/components/ResponseBody/helpers/media-types.d.ts +0 -4
- package/dist/components/ResponseBody/helpers/media-types.d.ts.map +1 -1
- package/dist/components/ResponseBody/helpers/media-types.js +0 -1
- package/dist/entities/index.d.ts +1 -0
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +17 -15
- package/dist/entities/registry/document.d.ts +3 -1
- package/dist/entities/registry/document.d.ts.map +1 -1
- package/dist/helpers.d.ts +8 -67
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +67 -57
- package/dist/hooks/use-agent-key-documents.d.ts +2 -0
- package/dist/hooks/use-agent-key-documents.d.ts.map +1 -0
- package/dist/hooks/use-agent-key-documents.js +16 -0
- package/dist/hooks/use-curated-documents.d.ts +2 -0
- package/dist/hooks/use-curated-documents.d.ts.map +1 -0
- package/dist/hooks/use-curated-documents.js +12 -0
- package/dist/hooks/use-search.d.ts +4 -8
- package/dist/hooks/use-search.d.ts.map +1 -1
- package/dist/hooks/use-search.js +14 -18
- package/dist/hooks/use-term-and-conditions.d.ts +0 -1
- package/dist/hooks/use-term-and-conditions.d.ts.map +1 -1
- package/dist/hooks/use-term-and-conditions.js +0 -1
- package/dist/hooks/use-upload-tmp-document.d.ts +6 -2
- package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +45 -23
- package/dist/package.json +1 -1
- package/dist/registry/add-documents-to-store.d.ts +6 -5
- package/dist/registry/add-documents-to-store.d.ts.map +1 -1
- package/dist/registry/add-documents-to-store.js +16 -20
- package/dist/state/state.d.ts +16 -7
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +92 -78
- package/dist/style.css +1 -1
- package/dist/views/Chat/Chat.vue.js +2 -2
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +2 -2
- package/dist/views/PromptForm.vue2.js +118 -104
- package/dist/views/Settings/DocSettings.vue.d.ts.map +1 -1
- package/dist/views/Settings/DocSettings.vue.js +2 -2
- package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
- package/dist/views/Settings/Settings.vue.js +2 -2
- package/dist/views/Settings/Settings.vue2.js +33 -31
- package/package.json +8 -8
- package/dist/components/Suggestion.vue.d.ts +0 -10
- package/dist/components/Suggestion.vue.d.ts.map +0 -1
- package/dist/components/TestRequestButton.vue.d.ts +0 -8
- package/dist/components/TestRequestButton.vue.d.ts.map +0 -1
package/dist/entities/index.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { AgentErrorCodes as e } from "./error/constants.js";
|
|
2
2
|
import { createError as E } from "./error/helpers.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { MAX_PROMPT_SIZE as A } from "./prompt/constants.js";
|
|
4
|
+
import { registryApiMetadata as T } from "./registry/document.js";
|
|
5
|
+
import { ASK_FOR_AUTHENTICATION_TOOL_NAME as I, askForAuthenticationInputSchema as M } from "./tools/ask-for-authentication.js";
|
|
6
|
+
import { TOOL_NAMESPACE_SLUG_DELIMITER as S } from "./tools/constants.js";
|
|
7
|
+
import { EXECUTE_REQUEST_TOOL_NAME as N, executeRequestToolInputSchema as P } from "./tools/execute-request.js";
|
|
8
|
+
import { GET_MINI_OPENAPI_SPEC_TOOL_NAME as f, getMiniOpenAPIDocToolInputSchema as n } from "./tools/get-mini-openapi-spec.js";
|
|
9
|
+
import { GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME as L } from "./tools/get-openapi-spec-summary.js";
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
I as ASK_FOR_AUTHENTICATION_TOOL_NAME,
|
|
11
12
|
e as AgentErrorCodes,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
N as EXECUTE_REQUEST_TOOL_NAME,
|
|
14
|
+
f as GET_MINI_OPENAPI_SPEC_TOOL_NAME,
|
|
15
|
+
L as GET_OPENAPI_SPECS_SUMMARY_TOOL_NAME,
|
|
16
|
+
A as MAX_PROMPT_SIZE,
|
|
17
|
+
S as TOOL_NAMESPACE_SLUG_DELIMITER,
|
|
18
|
+
M as askForAuthenticationInputSchema,
|
|
17
19
|
E as createError,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
P as executeRequestToolInputSchema,
|
|
21
|
+
n as getMiniOpenAPIDocToolInputSchema,
|
|
22
|
+
T as registryApiMetadata
|
|
21
23
|
};
|
|
@@ -9,7 +9,9 @@ export declare const registryApiMetadata: z.ZodObject<{
|
|
|
9
9
|
logoUrl: z.ZodNullable<z.ZodURL>;
|
|
10
10
|
slug: z.ZodString;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
|
-
export type ApiMetadata = z.infer<typeof registryApiMetadata
|
|
12
|
+
export type ApiMetadata = z.infer<typeof registryApiMetadata> & {
|
|
13
|
+
removable?: boolean;
|
|
14
|
+
};
|
|
13
15
|
export type RegistryDocument = {
|
|
14
16
|
namespace: string;
|
|
15
17
|
slug: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/entities/registry/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/entities/registry/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AAEvF,MAAM,MAAM,gBAAgB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IACE,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,YAAY,EAAE,WAAW,CAAC,YAAY,GAAG,SAAS,CAAA;CACnD,CACF,CAAA"}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,69 +1,16 @@
|
|
|
1
|
-
import type { MergedSecuritySchemes } from '@scalar/api-client/v2/blocks/scalar-auth-selector-block';
|
|
2
1
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
3
|
-
import type { AuthenticationConfiguration } from '@scalar/types/api-reference';
|
|
4
2
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
5
|
-
import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
|
|
6
3
|
import type { XScalarSelectedSecurity } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-selected-security';
|
|
7
|
-
import type {
|
|
4
|
+
import type { OperationObject, SecuritySchemeObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
8
5
|
import { type SecuritySchemes } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
|
|
9
|
-
import type { ToolUIPart, UIDataTypes, UIMessagePart } from 'ai';
|
|
10
|
-
import type { Tools } from './state/state.js';
|
|
11
|
-
/** Combine pathItem and operation parameters into a single, dereferenced parameter array */
|
|
12
|
-
export declare const combineParams: (pathParams?: PathItemObject["parameters"], operationParams?: OperationObject["parameters"]) => ParameterObject[];
|
|
13
|
-
/**
|
|
14
|
-
* Iterate through all available servers and pick the first one
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* getFirstServer([operation.servers, pathItem.servers, server])
|
|
18
|
-
*/
|
|
19
|
-
export declare function getFirstServer(...availableServers: (ServerObject[] | ServerObject | undefined | null)[]): ServerObject | undefined;
|
|
20
|
-
/** Determine if a message part is a tool */
|
|
21
|
-
export declare function isToolPart(part: UIMessagePart<UIDataTypes, Tools>): part is ToolUIPart<Tools>;
|
|
22
|
-
/**
|
|
23
|
-
* Extracts the default scopes for a security scheme.
|
|
24
|
-
* Only OAuth2 schemes can have default scopes via the x-default-scopes extension.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getDefaultScopes: (scheme: SecuritySchemeObject | undefined) => string[];
|
|
27
|
-
/**
|
|
28
|
-
* Determines the default security scheme to use for an operation.
|
|
29
|
-
*
|
|
30
|
-
* Priority order:
|
|
31
|
-
* 1. User-configured preferred security scheme (if provided)
|
|
32
|
-
* 2. First security requirement from the OpenAPI spec
|
|
33
|
-
* 3. null (no security required)
|
|
34
|
-
*/
|
|
35
|
-
export declare const getDefaultSecurity: (securityRequirements: SecurityRequirementObject[], preferredSecurityScheme: AuthenticationConfiguration["preferredSecurityScheme"], securitySchemes: MergedSecuritySchemes) => SecurityRequirementObject | null;
|
|
36
|
-
/**
|
|
37
|
-
* Find the intersection between which security is selected on the document and what this operation requires
|
|
38
|
-
*
|
|
39
|
-
* If there is no overlap, we return the first requirement
|
|
40
|
-
*/
|
|
41
|
-
export declare const filterSelectedSecurity: (document: OpenApiDocument, operation: OperationObject | null, securitySchemes?: MergedSecuritySchemes) => SecuritySchemeObject[];
|
|
42
6
|
export declare function getOperations(doc: Partial<OpenAPIV3_1.Document>): OperationObject[];
|
|
43
|
-
/** Flattens all security requirements from a document */
|
|
44
|
-
export declare function getSecurityFromDocument(document: WorkspaceDocument): SecuritySchemeObject[];
|
|
45
7
|
/** Generate document settings from workspace store */
|
|
46
8
|
export declare function createDocumentSettings(workspaceStore: WorkspaceStore): {
|
|
47
9
|
[k: string]: {
|
|
48
|
-
activeServer: ServerObject | null;
|
|
10
|
+
activeServer: import("@scalar/workspace-store/schemas/v3.1/strict/server").ServerObject | null;
|
|
49
11
|
securitySchemes: SecuritySchemeObject[];
|
|
50
12
|
};
|
|
51
13
|
};
|
|
52
|
-
/**
|
|
53
|
-
* Provides an interface to store and retrieve the selected client value
|
|
54
|
-
* in local storage.
|
|
55
|
-
*/
|
|
56
|
-
export declare const clientStorage: () => {
|
|
57
|
-
/**
|
|
58
|
-
* Gets the stored selected client from local storage.
|
|
59
|
-
*/
|
|
60
|
-
get: () => string | null;
|
|
61
|
-
/**
|
|
62
|
-
* Stores the selected client value in local storage.
|
|
63
|
-
* @param value The value to store
|
|
64
|
-
*/
|
|
65
|
-
set: (value: string) => void;
|
|
66
|
-
};
|
|
67
14
|
/**
|
|
68
15
|
* Provides an interface to store and retrieve authentication scheme
|
|
69
16
|
* information in local storage, including both the available schemes and
|
|
@@ -389,18 +336,6 @@ export declare const authStorage: () => {
|
|
|
389
336
|
*/
|
|
390
337
|
setSelectedSchemes: (slug: string, value: XScalarSelectedSecurity) => void;
|
|
391
338
|
};
|
|
392
|
-
/**
|
|
393
|
-
* Recursively merges secret values from stored data into the current schema.
|
|
394
|
-
* Only merges secrets if the corresponding structure exists in the current schema.
|
|
395
|
-
*
|
|
396
|
-
* This function walks through both objects in parallel, copying any keys that
|
|
397
|
-
* start with 'x-scalar-secret-' from the stored object to the current object,
|
|
398
|
-
* but only if the path exists in the current schema.
|
|
399
|
-
*
|
|
400
|
-
* @param current - The current schema object (source of truth for structure)
|
|
401
|
-
* @param stored - The stored object containing secret values to restore
|
|
402
|
-
*/
|
|
403
|
-
export declare const mergeSecrets: (current: unknown, stored: unknown) => void;
|
|
404
339
|
/**
|
|
405
340
|
* Restores authentication secrets from local storage to the workspace store.
|
|
406
341
|
*
|
|
@@ -415,4 +350,10 @@ export declare const restoreAuthSecretsFromStorage: ({ documentName, workspaceSt
|
|
|
415
350
|
workspaceStore: WorkspaceStore;
|
|
416
351
|
}) => void;
|
|
417
352
|
export declare function safeParseJson(value: string): any;
|
|
353
|
+
/**
|
|
354
|
+
* Wrap url with Scalar Proxy
|
|
355
|
+
*
|
|
356
|
+
* Skips wrapping if the url is localhost
|
|
357
|
+
*/
|
|
358
|
+
export declare function makeScalarProxyUrl(url: string): string;
|
|
418
359
|
//# sourceMappingURL=helpers.d.ts.map
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAGpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gFAAgF,CAAA;AAE7H,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,8DAA8D,CAAA;AACrE,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,8DAA8D,CAAA;AAErE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,GACwB,eAAe,EAAE,CACxG;AAyBD,sDAAsD;AACtD,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,cAAc;;;;;EAgBpE;AAKD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAYpB;;OAEG;uBACgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIzB;;;OAGG;uBACgB,MAAM,SAAS,eAAe;IAGjD;;OAEG;+BACwB,MAAM;;;;;;IAIjC;;;OAGG;+BACwB,MAAM,SAAS,uBAAuB;CAIpE,CAAA;AAgDD;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,GAAI,mCAG3C;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;CAC/B,KAAG,IAuCH,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAM1C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAqB7C"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,111 +1,121 @@
|
|
|
1
1
|
import { getSelectedServer as O } from "@scalar/api-client/v2/features/operation";
|
|
2
|
-
import { getServers as
|
|
2
|
+
import { getServers as x } from "@scalar/api-client/v2/helpers";
|
|
3
3
|
import { isObject as l } from "@scalar/helpers/object/is-object";
|
|
4
|
-
import { REFERENCE_LS_KEYS as d, safeLocalStorage as
|
|
5
|
-
import { getResolvedRef as
|
|
6
|
-
import { coerceValue as
|
|
7
|
-
import { XScalarSelectedSecuritySchema as
|
|
8
|
-
function
|
|
9
|
-
return Object.values(
|
|
4
|
+
import { REFERENCE_LS_KEYS as d, safeLocalStorage as v } from "@scalar/helpers/object/local-storage";
|
|
5
|
+
import { getResolvedRef as h } from "@scalar/workspace-store/helpers/get-resolved-ref";
|
|
6
|
+
import { coerceValue as y } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
7
|
+
import { XScalarSelectedSecuritySchema as b, SecuritySchemesSchema as E } from "@scalar/workspace-store/schemas/v3.1/strict/openapi-document";
|
|
8
|
+
function P(e) {
|
|
9
|
+
return Object.values(e.paths ?? {}).flatMap((c) => Object.values(c ?? {}));
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
const s = (
|
|
13
|
-
return
|
|
14
|
-
const o =
|
|
15
|
-
return o && r.push(
|
|
11
|
+
function j(e) {
|
|
12
|
+
const s = (e["x-scalar-selected-security"]?.selectedSchemes ?? []).flatMap((r) => Object.keys(r)), t = e.components?.securitySchemes;
|
|
13
|
+
return t ? s.reduce((r, n) => {
|
|
14
|
+
const o = t[n];
|
|
15
|
+
return o && r.push(h(o)), r;
|
|
16
16
|
}, []) : [];
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function C(e) {
|
|
19
19
|
return Object.fromEntries(
|
|
20
|
-
Object.entries(
|
|
21
|
-
const
|
|
20
|
+
Object.entries(e.workspace.documents).map(([c, s]) => {
|
|
21
|
+
const t = x(s.servers, {
|
|
22
22
|
documentUrl: s?.["x-scalar-original-source-url"]
|
|
23
23
|
});
|
|
24
24
|
return [
|
|
25
25
|
c,
|
|
26
26
|
{
|
|
27
|
-
activeServer: O(s,
|
|
28
|
-
securitySchemes:
|
|
27
|
+
activeServer: O(s, t),
|
|
28
|
+
securitySchemes: j(s)
|
|
29
29
|
}
|
|
30
30
|
];
|
|
31
31
|
})
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
const
|
|
34
|
+
const m = v(), f = () => {
|
|
35
|
+
const e = d.AUTH_SCHEMES, c = d.SELECTED_AUTH_SCHEMES, s = (t, r) => `${r}-${((o) => o === "schemas" ? e : c)(t)}`;
|
|
36
36
|
return {
|
|
37
37
|
/**
|
|
38
38
|
* Retrieves and coerces the authentication schemes stored in local storage.
|
|
39
39
|
*/
|
|
40
|
-
getSchemas: (
|
|
41
|
-
const r = JSON.parse(
|
|
42
|
-
return
|
|
40
|
+
getSchemas: (t) => {
|
|
41
|
+
const r = JSON.parse(m.getItem(s("schemas", t)) ?? "{}");
|
|
42
|
+
return y(E, r);
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* Stores the authentication schemes in local storage.
|
|
46
46
|
* @param value The SecuritySchemes object to stringify and store.
|
|
47
47
|
*/
|
|
48
|
-
setSchemas: (
|
|
49
|
-
|
|
48
|
+
setSchemas: (t, r) => {
|
|
49
|
+
m.setItem(s("schemas", t), JSON.stringify(r));
|
|
50
50
|
},
|
|
51
51
|
/**
|
|
52
52
|
* Retrieves and coerces the selected authentication schemes stored in local storage.
|
|
53
53
|
*/
|
|
54
|
-
getSelectedSchemes: (
|
|
55
|
-
const r = JSON.parse(
|
|
56
|
-
return
|
|
54
|
+
getSelectedSchemes: (t) => {
|
|
55
|
+
const r = JSON.parse(m.getItem(s("selectedSchemes", t)) ?? "{}");
|
|
56
|
+
return y(b, r);
|
|
57
57
|
},
|
|
58
58
|
/**
|
|
59
59
|
* Stores the user's selected authentication schemes in local storage.
|
|
60
60
|
* @param value The XScalarSelectedSecurity object to stringify and store.
|
|
61
61
|
*/
|
|
62
|
-
setSelectedSchemes: (
|
|
63
|
-
|
|
62
|
+
setSelectedSchemes: (t, r) => {
|
|
63
|
+
m.setItem(s("selectedSchemes", t), JSON.stringify(r));
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
}, p = (
|
|
67
|
-
if (!(!l(
|
|
68
|
-
for (const [s,
|
|
69
|
-
if (typeof
|
|
70
|
-
|
|
66
|
+
}, p = (e, c) => {
|
|
67
|
+
if (!(!l(e) || !l(c)))
|
|
68
|
+
for (const [s, t] of Object.entries(c)) {
|
|
69
|
+
if (typeof t != "object") {
|
|
70
|
+
e[s] = t;
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
|
-
p(
|
|
73
|
+
p(h(e[s]), t);
|
|
74
74
|
}
|
|
75
|
-
},
|
|
76
|
-
documentName:
|
|
75
|
+
}, U = (e, c) => Object.keys(e).every((s) => c.has(s)), I = (e, c) => e >= c ? c - 1 : e, H = ({
|
|
76
|
+
documentName: e,
|
|
77
77
|
workspaceStore: c
|
|
78
78
|
}) => {
|
|
79
|
-
const s =
|
|
80
|
-
if (!
|
|
79
|
+
const s = f().getSchemas(e), t = c.workspace.documents[e];
|
|
80
|
+
if (!t)
|
|
81
81
|
return;
|
|
82
|
-
const n =
|
|
83
|
-
if (!
|
|
84
|
-
const
|
|
85
|
-
|
|
82
|
+
const n = f().getSelectedSchemes(e), o = new Set(Object.keys(t.components?.securitySchemes ?? {})), S = n["x-scalar-selected-security"]?.selectedSchemes?.filter((a) => U(a, o));
|
|
83
|
+
if (!t["x-scalar-selected-security"] && S && S.length > 0) {
|
|
84
|
+
const a = n["x-scalar-selected-security"]?.selectedIndex, i = I(a ?? 0, S.length);
|
|
85
|
+
t["x-scalar-selected-security"] = {
|
|
86
86
|
selectedIndex: i,
|
|
87
|
-
selectedSchemes:
|
|
87
|
+
selectedSchemes: S
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
|
-
const g =
|
|
91
|
-
for (const [
|
|
92
|
-
const
|
|
93
|
-
l(
|
|
90
|
+
const g = t.components?.securitySchemes ?? {};
|
|
91
|
+
for (const [a, i] of Object.entries(s)) {
|
|
92
|
+
const u = h(g[a]);
|
|
93
|
+
l(u) && p(u, i);
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
function
|
|
96
|
+
function M(e) {
|
|
97
97
|
try {
|
|
98
|
-
return JSON.parse(
|
|
98
|
+
return JSON.parse(e);
|
|
99
99
|
} catch {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
+
function N(e) {
|
|
104
|
+
try {
|
|
105
|
+
const c = new URL(e);
|
|
106
|
+
if (c.host === "localhost")
|
|
107
|
+
return e;
|
|
108
|
+
const s = new URLSearchParams({ scalar_url: c.toString() });
|
|
109
|
+
return new URL(`https://proxy.scalar.com/?${s}`).toString();
|
|
110
|
+
} catch {
|
|
111
|
+
return console.error(`Invalid URL provided: ${e}`), e;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
103
114
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
F as safeParseJson
|
|
115
|
+
f as authStorage,
|
|
116
|
+
C as createDocumentSettings,
|
|
117
|
+
P as getOperations,
|
|
118
|
+
N as makeScalarProxyUrl,
|
|
119
|
+
H as restoreAuthSecretsFromStorage,
|
|
120
|
+
M as safeParseJson
|
|
111
121
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-agent-key-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-agent-key-documents.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,SAkBnC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { onMounted as a } from "vue";
|
|
2
|
+
import { useState as m } from "../state/state.js";
|
|
3
|
+
function i() {
|
|
4
|
+
const { api: t, addDocument: o, mode: n, getAgentKey: s } = m();
|
|
5
|
+
a(async () => {
|
|
6
|
+
if (n !== "full" || !s)
|
|
7
|
+
return;
|
|
8
|
+
const e = await t.getKeyDocuments();
|
|
9
|
+
e.success && e.data.documents.forEach(
|
|
10
|
+
({ namespace: u, slug: c }) => o({ namespace: u, slug: c, removable: !1 })
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
i as useAgentKeyDocuments
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-curated-documents.d.ts","sourceRoot":"","sources":["../../src/hooks/use-curated-documents.ts"],"names":[],"mappings":"AAIA,wBAAgB,mBAAmB,SAYlC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { onMounted as s } from "vue";
|
|
2
|
+
import { useState as o } from "../state/state.js";
|
|
3
|
+
function r() {
|
|
4
|
+
const { api: e, curatedDocuments: u } = o();
|
|
5
|
+
s(async () => {
|
|
6
|
+
const t = await e.getCuratedDocuments();
|
|
7
|
+
t.success && (u.value = t.data.results);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
r as useCuratedDocuments
|
|
12
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ApiMetadata } from '../entities/registry/document.js';
|
|
1
2
|
export declare function useSearch(): {
|
|
2
3
|
query: import("vue").WritableComputedRef<string, string>;
|
|
3
4
|
results: import("vue").Ref<{
|
|
@@ -7,20 +8,15 @@ export declare function useSearch(): {
|
|
|
7
8
|
currentVersion: string;
|
|
8
9
|
logoUrl: string | null;
|
|
9
10
|
slug: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
title: string;
|
|
13
|
-
namespace: string;
|
|
14
|
-
currentVersion: string;
|
|
15
|
-
logoUrl: string | null;
|
|
16
|
-
slug: string;
|
|
17
|
-
}[] | {
|
|
11
|
+
removable?: boolean | undefined;
|
|
12
|
+
}[], ApiMetadata[] | {
|
|
18
13
|
id: string;
|
|
19
14
|
title: string;
|
|
20
15
|
namespace: string;
|
|
21
16
|
currentVersion: string;
|
|
22
17
|
logoUrl: string | null;
|
|
23
18
|
slug: string;
|
|
19
|
+
removable?: boolean | undefined;
|
|
24
20
|
}[]>;
|
|
25
21
|
};
|
|
26
22
|
//# sourceMappingURL=use-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../src/hooks/use-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,wBAAgB,SAAS;;;;;;;;;;;;;;;;;;;EAiCxB"}
|
package/dist/hooks/use-search.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { useDebounceFn as
|
|
2
|
-
import { ref as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getAccessToken: n
|
|
10
|
-
}).search(e);
|
|
11
|
-
o.success && (t.value = o.data.results);
|
|
12
|
-
}, 200), a = f({
|
|
1
|
+
import { useDebounceFn as a } from "@vueuse/core";
|
|
2
|
+
import { ref as u, computed as f } from "vue";
|
|
3
|
+
import { useState as i } from "../state/state.js";
|
|
4
|
+
function h() {
|
|
5
|
+
const { api: c } = i(), s = u(""), t = a(async (e) => {
|
|
6
|
+
const o = await c.search(e);
|
|
7
|
+
o.success && (r.value = o.data.results);
|
|
8
|
+
}, 200), n = f({
|
|
13
9
|
get: () => s.value,
|
|
14
10
|
set: (e) => {
|
|
15
|
-
|
|
11
|
+
t(e), s.value = e;
|
|
16
12
|
}
|
|
17
|
-
}),
|
|
18
|
-
return
|
|
19
|
-
query:
|
|
20
|
-
results:
|
|
13
|
+
}), r = u([]);
|
|
14
|
+
return t(""), {
|
|
15
|
+
query: n,
|
|
16
|
+
results: r
|
|
21
17
|
};
|
|
22
18
|
}
|
|
23
19
|
export {
|
|
24
|
-
|
|
20
|
+
h as useSearch
|
|
25
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-term-and-conditions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-term-and-conditions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-term-and-conditions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-term-and-conditions.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB;;;EAapC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WorkspaceDocument } from '@scalar/workspace-store/schemas';
|
|
2
1
|
export type UploadTmpDocumentState = {
|
|
3
2
|
type: 'error';
|
|
4
3
|
error: unknown;
|
|
@@ -9,8 +8,13 @@ export type UploadTmpDocumentState = {
|
|
|
9
8
|
} | {
|
|
10
9
|
type: 'done';
|
|
11
10
|
};
|
|
11
|
+
export declare function getTmpDocFromLocalStorage(): {
|
|
12
|
+
namespace: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
} | undefined;
|
|
12
15
|
export declare function useUploadTmpDocument(): {
|
|
13
|
-
uploadTempDocument: (document:
|
|
16
|
+
uploadTempDocument: (document: string) => Promise<{
|
|
17
|
+
url: string;
|
|
14
18
|
namespace: string;
|
|
15
19
|
slug: string;
|
|
16
20
|
} | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAQpB,wBAAgB,yBAAyB;;;cAYxC;AAED,wBAAgB,oBAAoB;mCAeU,MAAM;;;;;;EA4EnD"}
|
|
@@ -1,64 +1,86 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { z as
|
|
1
|
+
import { ref as m } from "vue";
|
|
2
|
+
import { z as o } from "zod/mini";
|
|
3
3
|
import { useState as d } from "../state/state.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const u = "scalar-tmp-doc";
|
|
5
|
+
function g({ namespace: t, slug: e }) {
|
|
6
|
+
localStorage.setItem(u, JSON.stringify({ namespace: t, slug: e }));
|
|
7
|
+
}
|
|
8
|
+
function v() {
|
|
9
|
+
const t = localStorage.getItem(u);
|
|
10
|
+
if (t)
|
|
11
|
+
return o.object({
|
|
12
|
+
namespace: o.string(),
|
|
13
|
+
slug: o.string()
|
|
14
|
+
}).parse(JSON.parse(t));
|
|
15
|
+
}
|
|
16
|
+
function h() {
|
|
17
|
+
const t = d(), e = m();
|
|
18
|
+
function c(s) {
|
|
19
|
+
const a = `${t.baseUrl}${s}`;
|
|
20
|
+
if (a.startsWith("/")) return a;
|
|
21
|
+
const n = new URLSearchParams({ scalar_url: a.toString() });
|
|
22
|
+
return new URL(`https://proxy.scalar.com/?${n}`);
|
|
11
23
|
}
|
|
12
|
-
async function
|
|
24
|
+
async function l(s) {
|
|
13
25
|
try {
|
|
14
26
|
e.value = { type: "uploading" };
|
|
15
|
-
const
|
|
27
|
+
const a = await fetch(c("/core/share/upload/apis"), {
|
|
16
28
|
method: "POST",
|
|
17
29
|
headers: { "Content-Type": "application/json" },
|
|
18
|
-
body: JSON.stringify({ document:
|
|
30
|
+
body: JSON.stringify({ document: s })
|
|
19
31
|
});
|
|
20
|
-
if (!
|
|
32
|
+
if (!a.ok) {
|
|
21
33
|
e.value = {
|
|
22
34
|
type: "error",
|
|
23
35
|
error: "Failed to upload document."
|
|
24
36
|
};
|
|
25
37
|
return;
|
|
26
38
|
}
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
39
|
+
const n = await a.json(), { success: p, data: r } = o.object({ url: o.string(), namespace: o.string(), slug: o.string() }).safeParse(n);
|
|
40
|
+
if (!p) {
|
|
29
41
|
e.value = {
|
|
30
42
|
type: "error",
|
|
31
43
|
error: "Failed to process document."
|
|
32
44
|
};
|
|
33
45
|
return;
|
|
34
46
|
}
|
|
35
|
-
|
|
47
|
+
e.value = {
|
|
36
48
|
type: "processing"
|
|
37
|
-
}
|
|
38
|
-
|
|
49
|
+
};
|
|
50
|
+
const i = await fetch(
|
|
51
|
+
c(`/vector/registry/embeddings/${r.namespace}/${r.slug}`),
|
|
39
52
|
{
|
|
40
53
|
method: "GET"
|
|
41
54
|
}
|
|
42
|
-
)
|
|
55
|
+
);
|
|
56
|
+
if (g({
|
|
57
|
+
namespace: r.namespace,
|
|
58
|
+
slug: r.slug
|
|
59
|
+
}), await t.addDocument({
|
|
60
|
+
namespace: r.namespace,
|
|
61
|
+
slug: r.slug,
|
|
62
|
+
removable: !1
|
|
63
|
+
}), !i.ok) {
|
|
43
64
|
e.value = {
|
|
44
65
|
type: "error",
|
|
45
66
|
error: "Failed to embed document."
|
|
46
67
|
};
|
|
47
68
|
return;
|
|
48
69
|
}
|
|
49
|
-
return e.value = { type: "done" }, setTimeout(() => {
|
|
70
|
+
return e.value = { type: "done" }, t.uploadedTmpDocumentUrl.value = r.url, setTimeout(() => {
|
|
50
71
|
e.value = void 0;
|
|
51
|
-
}, 2e3),
|
|
72
|
+
}, 2e3), r;
|
|
52
73
|
} catch {
|
|
53
74
|
e.value = { type: "error", error: "Failed to upload document." };
|
|
54
75
|
return;
|
|
55
76
|
}
|
|
56
77
|
}
|
|
57
78
|
return {
|
|
58
|
-
uploadTempDocument:
|
|
79
|
+
uploadTempDocument: l,
|
|
59
80
|
uploadState: e
|
|
60
81
|
};
|
|
61
82
|
}
|
|
62
83
|
export {
|
|
63
|
-
|
|
84
|
+
v as getTmpDocFromLocalStorage,
|
|
85
|
+
h as useUploadTmpDocument
|
|
64
86
|
};
|