@scalar/agent-chat 0.12.44 → 0.12.45
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.test.d.ts +2 -0
- package/dist/App.test.d.ts.map +1 -0
- package/dist/App.vue.d.ts +4 -0
- package/dist/App.vue.d.ts.map +1 -1
- package/dist/App.vue.js.map +1 -1
- package/dist/App.vue.script.js +2 -0
- package/dist/App.vue.script.js.map +1 -1
- package/dist/Chat.vue.d.ts.map +1 -1
- package/dist/Chat.vue.js.map +1 -1
- package/dist/Chat.vue.script.js +13 -5
- package/dist/Chat.vue.script.js.map +1 -1
- package/dist/components/UploadSection.vue.js +1 -1
- package/dist/components/UploadSection.vue.js.map +1 -1
- package/dist/components/UploadSection.vue.script.js +2 -2
- package/dist/components/UploadSection.vue.script.js.map +1 -1
- package/dist/entities/tools/get-openapi-specs-summary.d.ts +3 -2
- package/dist/entities/tools/get-openapi-specs-summary.d.ts.map +1 -1
- package/dist/entities/tools/get-openapi-specs-summary.js.map +1 -1
- package/dist/entities/tools/search-openapi-operations.d.ts +2 -1
- package/dist/entities/tools/search-openapi-operations.d.ts.map +1 -1
- package/dist/entities/tools/search-openapi-operations.js.map +1 -1
- package/dist/helpers/get-search-result-labels.d.ts +3 -0
- package/dist/helpers/get-search-result-labels.d.ts.map +1 -0
- package/dist/helpers/get-search-result-labels.js +38 -0
- package/dist/helpers/get-search-result-labels.js.map +1 -0
- package/dist/helpers/get-search-result-labels.test.d.ts +2 -0
- package/dist/helpers/get-search-result-labels.test.d.ts.map +1 -0
- package/dist/helpers.d.ts +0 -3
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +2 -5
- package/dist/helpers.js.map +1 -1
- package/dist/hooks/use-agent-key-documents.js +1 -1
- package/dist/hooks/use-agent-key-documents.js.map +1 -1
- package/dist/hooks/use-upload-tmp-document.d.ts +1 -1
- package/dist/hooks/use-upload-tmp-document.d.ts.map +1 -1
- package/dist/hooks/use-upload-tmp-document.js +24 -17
- package/dist/hooks/use-upload-tmp-document.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/registry/add-documents-to-store.d.ts.map +1 -1
- package/dist/registry/add-documents-to-store.js.map +1 -1
- package/dist/state/state.d.ts +5 -1
- package/dist/state/state.d.ts.map +1 -1
- package/dist/state/state.js +15 -6
- package/dist/state/state.js.map +1 -1
- package/dist/state/state.test.d.ts +2 -0
- package/dist/state/state.test.d.ts.map +1 -0
- package/dist/style.css +79 -71
- package/dist/views/Chat/Messages/AskForAuthentication.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.js.map +1 -1
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js +44 -35
- package/dist/views/Chat/Messages/AskForAuthentication.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.js.map +1 -1
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js +8 -3
- package/dist/views/Chat/Messages/ExecuteRequestTool.vue.script.js.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.d.ts.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.js +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.js.map +1 -1
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js +6 -9
- package/dist/views/Chat/Messages/SearchOpenAPIOperationsTool.vue.script.js.map +1 -1
- package/dist/views/PromptForm.vue.d.ts.map +1 -1
- package/dist/views/PromptForm.vue.js +1 -1
- package/dist/views/PromptForm.vue.js.map +1 -1
- package/dist/views/PromptForm.vue.script.js +0 -1
- package/dist/views/PromptForm.vue.script.js.map +1 -1
- package/dist/views/Settings/Settings.vue.d.ts.map +1 -1
- package/dist/views/Settings/Settings.vue.js +1 -1
- package/dist/views/Settings/Settings.vue.js.map +1 -1
- package/dist/views/Settings/Settings.vue.script.js +10 -6
- package/dist/views/Settings/Settings.vue.script.js.map +1 -1
- package/dist/views/Start.vue.js +1 -1
- package/dist/views/Start.vue.js.map +1 -1
- package/dist/views/Start.vue.script.js +1 -1
- package/dist/views/Start.vue.script.js.map +1 -1
- package/dist/vue-styles.css +71 -71
- package/package.json +7 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.test.d.ts","sourceRoot":"","sources":["../src/App.test.ts"],"names":[],"mappings":""}
|
package/dist/App.vue.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ type __VLS_Props = {
|
|
|
11
11
|
getAccessToken?: () => string;
|
|
12
12
|
getAgentKey?: () => string;
|
|
13
13
|
getActiveDocumentJson?: () => string;
|
|
14
|
+
/** Identifies the selected reference source in outgoing questions. */
|
|
15
|
+
getActiveDocumentContext?: () => string | undefined;
|
|
14
16
|
isLoggedIn?: Ref<boolean>;
|
|
15
17
|
prefilledMessage?: Ref<string>;
|
|
16
18
|
hideAddApi?: boolean;
|
|
@@ -55,9 +57,11 @@ declare const state: {
|
|
|
55
57
|
getAccessToken?: () => string;
|
|
56
58
|
getAgentKey?: () => string;
|
|
57
59
|
api: import("./api.js").Api;
|
|
60
|
+
uploadState: Ref<import("./hooks/use-upload-tmp-document.js").UploadTmpDocumentState | undefined>;
|
|
58
61
|
uploadedTmpDocumentUrl: Ref<string | undefined>;
|
|
59
62
|
curatedDocuments: Ref<import("./entities/index.js").ApiMetadata[]>;
|
|
60
63
|
getActiveDocumentJson?: () => string;
|
|
64
|
+
getActiveDocumentContext?: () => string | undefined;
|
|
61
65
|
hideAddApi?: boolean;
|
|
62
66
|
};
|
|
63
67
|
export type ChatExposed = {
|
package/dist/App.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.vue.d.ts","sourceRoot":"","sources":["../src/App.vue"],"names":[],"mappings":"AA6EA,OAAO,EAAW,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAGvC,OAAO,EAA6B,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChF,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,KAAK,WAAW,GAAG;IACjB,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,MAAM,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,MAAM,CAAA;IAC1B,qBAAqB,CAAC,EAAE,MAAM,MAAM,CAAA;IACpC,sEAAsE;IACtE,wBAAwB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IACnD,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACzB,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC;AAuBF,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BK,CAAC;WAAc,CAAC;;;;;iBAEC,CAAC;;;;;;;;;;;;;;;CAjBhC,CAAA;AAIF,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,EAAE,OAAO,KAAK,CAAC,gBAAgB,CAAA;CAChD,CAAA;AA+CD,QAAA,MAAM,YAAY;;;;kFAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/App.vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.js","names":[],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n isLoggedIn,\n prefilledMessage,\n hideAddApi,\n} = defineProps<{\n registryDocuments: RegistryDocument[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode?: ChatMode\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n isLoggedIn?: Ref<boolean>\n prefilledMessage?: Ref<string>\n hideAddApi?: boolean\n}>()\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst state = createState({\n getActiveDocumentJson,\n initialRegistryDocuments: registryDocuments,\n prefilledMessageRef: prefilledMessage,\n platformProxyUrl,\n registryUrl,\n baseUrl,\n mode,\n getAccessToken,\n getAgentKey,\n isLoggedIn,\n dashboardUrl,\n hideAddApi,\n})\n\nprovide(STATE_SYMBOL, state)\n\nexport type ChatExposed = {\n addDocumentAsync: typeof state.addDocumentAsync\n}\n\ndefineExpose<ChatExposed>({\n addDocumentAsync: state.addDocumentAsync,\n})\n</script>\n\n<template>\n <Chat @uploadApi=\"$emit('uploadApi')\" />\n</template>\n\n<style scoped></style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"App.vue.js","names":[],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n getActiveDocumentContext,\n isLoggedIn,\n prefilledMessage,\n hideAddApi,\n} = defineProps<{\n registryDocuments: RegistryDocument[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode?: ChatMode\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n /** Identifies the selected reference source in outgoing questions. */\n getActiveDocumentContext?: () => string | undefined\n isLoggedIn?: Ref<boolean>\n prefilledMessage?: Ref<string>\n hideAddApi?: boolean\n}>()\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst state = createState({\n getActiveDocumentJson,\n getActiveDocumentContext,\n initialRegistryDocuments: registryDocuments,\n prefilledMessageRef: prefilledMessage,\n platformProxyUrl,\n registryUrl,\n baseUrl,\n mode,\n getAccessToken,\n getAgentKey,\n isLoggedIn,\n dashboardUrl,\n hideAddApi,\n})\n\nprovide(STATE_SYMBOL, state)\n\nexport type ChatExposed = {\n addDocumentAsync: typeof state.addDocumentAsync\n}\n\ndefineExpose<ChatExposed>({\n addDocumentAsync: state.addDocumentAsync,\n})\n</script>\n\n<template>\n <Chat @uploadApi=\"$emit('uploadApi')\" />\n</template>\n\n<style scoped></style>\n"],"mappings":""}
|
package/dist/App.vue.script.js
CHANGED
|
@@ -14,6 +14,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompon
|
|
|
14
14
|
getAccessToken: { type: Function },
|
|
15
15
|
getAgentKey: { type: Function },
|
|
16
16
|
getActiveDocumentJson: { type: Function },
|
|
17
|
+
getActiveDocumentContext: { type: Function },
|
|
17
18
|
isLoggedIn: {},
|
|
18
19
|
prefilledMessage: {},
|
|
19
20
|
hideAddApi: { type: Boolean }
|
|
@@ -22,6 +23,7 @@ var App_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompon
|
|
|
22
23
|
setup(__props, { expose: __expose }) {
|
|
23
24
|
const state = createState({
|
|
24
25
|
getActiveDocumentJson: __props.getActiveDocumentJson,
|
|
26
|
+
getActiveDocumentContext: __props.getActiveDocumentContext,
|
|
25
27
|
initialRegistryDocuments: __props.registryDocuments,
|
|
26
28
|
prefilledMessageRef: __props.prefilledMessage,
|
|
27
29
|
platformProxyUrl: __props.platformProxyUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.vue.script.js","names":["$emit"],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n isLoggedIn,\n prefilledMessage,\n hideAddApi,\n} = defineProps<{\n registryDocuments: RegistryDocument[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode?: ChatMode\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n isLoggedIn?: Ref<boolean>\n prefilledMessage?: Ref<string>\n hideAddApi?: boolean\n}>()\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst state = createState({\n getActiveDocumentJson,\n initialRegistryDocuments: registryDocuments,\n prefilledMessageRef: prefilledMessage,\n platformProxyUrl,\n registryUrl,\n baseUrl,\n mode,\n getAccessToken,\n getAgentKey,\n isLoggedIn,\n dashboardUrl,\n hideAddApi,\n})\n\nprovide(STATE_SYMBOL, state)\n\nexport type ChatExposed = {\n addDocumentAsync: typeof state.addDocumentAsync\n}\n\ndefineExpose<ChatExposed>({\n addDocumentAsync: state.addDocumentAsync,\n})\n</script>\n\n<template>\n <Chat @uploadApi=\"$emit('uploadApi')\" />\n</template>\n\n<style scoped></style>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"App.vue.script.js","names":["$emit"],"sources":["../src/App.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { provide, type Ref } from 'vue'\n\nimport Chat from '@/Chat.vue'\nimport { createState, STATE_SYMBOL, type RegistryDocument } from '@/state/state'\nimport { type ChatMode } from '@/types'\n\nconst {\n dashboardUrl,\n platformProxyUrl,\n registryDocuments,\n registryUrl,\n baseUrl,\n mode = 'full',\n getAccessToken,\n getAgentKey,\n getActiveDocumentJson,\n getActiveDocumentContext,\n isLoggedIn,\n prefilledMessage,\n hideAddApi,\n} = defineProps<{\n registryDocuments: RegistryDocument[]\n registryUrl: string\n dashboardUrl: string\n platformProxyUrl: string\n baseUrl: string\n mode?: ChatMode\n getAccessToken?: () => string\n getAgentKey?: () => string\n getActiveDocumentJson?: () => string\n /** Identifies the selected reference source in outgoing questions. */\n getActiveDocumentContext?: () => string | undefined\n isLoggedIn?: Ref<boolean>\n prefilledMessage?: Ref<string>\n hideAddApi?: boolean\n}>()\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst state = createState({\n getActiveDocumentJson,\n getActiveDocumentContext,\n initialRegistryDocuments: registryDocuments,\n prefilledMessageRef: prefilledMessage,\n platformProxyUrl,\n registryUrl,\n baseUrl,\n mode,\n getAccessToken,\n getAgentKey,\n isLoggedIn,\n dashboardUrl,\n hideAddApi,\n})\n\nprovide(STATE_SYMBOL, state)\n\nexport type ChatExposed = {\n addDocumentAsync: typeof state.addDocumentAsync\n}\n\ndefineExpose<ChatExposed>({\n addDocumentAsync: state.addDocumentAsync,\n})\n</script>\n\n<template>\n <Chat @uploadApi=\"$emit('uploadApi')\" />\n</template>\n\n<style scoped></style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,QAAQ,YAAY;GACxB,uBAAoB,QAAA;GACpB,0BAAuB,QAAA;GACvB,0BAA0B,QAAA;GAC1B,qBAAqB,QAAA;GACrB,kBAAe,QAAA;GACf,aAAU,QAAA;GACV,SAAM,QAAA;GACN,MAAG,QAAA;GACH,gBAAa,QAAA;GACb,aAAU,QAAA;GACV,YAAS,QAAA;GACT,cAAW,QAAA;GACX,YAAS,QAAA;EACX,CAAC;EAED,QAAQ,cAAc,KAAK;EAM3B,SAA0B,EACxB,kBAAkB,MAAM,iBAC1B,CAAC;;uBAIC,YAAwC,cAAA,EAAjC,aAAS,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,WAAA,GAAA,CAAA"}
|
package/dist/Chat.vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.vue.d.ts","sourceRoot":"","sources":["../src/Chat.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Chat.vue.d.ts","sourceRoot":"","sources":["../src/Chat.vue"],"names":[],"mappings":"AAsTA,QAAA,MAAM,YAAY;;;;iFAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
package/dist/Chat.vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.vue.js","names":[],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {
|
|
1
|
+
{"version":3,"file":"Chat.vue.js","names":[],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {\n getTmpDocFromLocalStorage,\n useUploadTmpDocument,\n} from '@/hooks/use-upload-tmp-document'\nimport { useState } from '@/state/state'\nimport Layout from '@/views/Layout.vue'\nimport Settings from '@/views/Settings/Settings.vue'\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst {\n chat,\n prompt,\n settingsModal,\n eventBus,\n workspaceStore,\n config,\n mode,\n addDocument,\n getActiveDocumentJson,\n getActiveDocumentContext,\n terms,\n} = useState()\n\nconst clientModalRef = useTemplateRef<HTMLElement>('clientModal')\n// Authentication and server controls also work before the request editor opens.\nconst stopClientEvents = initializeWorkspaceEventHandlers({\n eventBus,\n store: ref(workspaceStore),\n hooks: {},\n})\nconst clientLoadingStatus = ref<'idle' | 'loading' | 'error'>('idle')\nuseLazyApiClient({\n eventBus,\n status: clientLoadingStatus,\n load: async () => {\n const { createApiClientModal } = await import('@scalar/api-client/modal')\n return () => {\n if (!clientModalRef.value) {\n return null\n }\n stopClientEvents()\n return createApiClientModal({\n el: clientModalRef.value,\n options: config,\n eventBus,\n workspaceStore,\n })\n }\n },\n})\nonBeforeUnmount(stopClientEvents)\n\nonMounted(async () => {\n const tmpDoc = getTmpDocFromLocalStorage()\n\n if (mode === 'preview' && tmpDoc && !getActiveDocumentJson) {\n await addDocument({\n namespace: tmpDoc.namespace,\n slug: tmpDoc.slug,\n removable: false,\n tmp: true,\n })\n }\n})\n\nconst { uploadTempDocument } = useUploadTmpDocument()\nwatch(\n terms.accepted,\n (accepted) => {\n if (accepted && mode === 'preview' && getActiveDocumentJson) {\n void uploadTempDocument(getActiveDocumentJson(), true)\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => {\n void chat.stop()\n})\n\nuseChatScroll()\nuseAgentKeyDocuments()\nuseCuratedDocuments()\n\nasync function handleSubmit() {\n const context = getActiveDocumentContext?.()\n await chat.sendMessage({\n text: context\n ? `${prompt.value}\\n\\nSelected API description: ${context}`\n : prompt.value,\n })\n}\n</script>\n\n<template>\n <div ref=\"clientModal\" />\n <div\n v-if=\"clientLoadingStatus !== 'idle'\"\n class=\"bg-b-1 text-c-1 fixed right-4 bottom-4 z-[10001] rounded-lg border px-4 py-3 text-sm shadow-lg\"\n :role=\"clientLoadingStatus === 'error' ? 'alert' : 'status'\">\n {{\n clientLoadingStatus === 'loading'\n ? 'Loading request editor…'\n : 'Could not load the request editor. Refresh the page and try again.'\n }}\n </div>\n <Layout\n @submit=\"handleSubmit\"\n @uploadApi=\"$emit('uploadApi')\" />\n <Settings :modalState=\"settingsModal\" />\n</template>\n"],"mappings":""}
|
package/dist/Chat.vue.script.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getTmpDocFromLocalStorage } from "./hooks/use-upload-tmp-document.js";
|
|
1
|
+
import { getTmpDocFromLocalStorage, useUploadTmpDocument } from "./hooks/use-upload-tmp-document.js";
|
|
2
2
|
import { useState } from "./state/state.js";
|
|
3
3
|
import { useAgentKeyDocuments } from "./hooks/use-agent-key-documents.js";
|
|
4
4
|
import { useChatScroll } from "./hooks/use-chat-scroll.js";
|
|
5
5
|
import { useCuratedDocuments } from "./hooks/use-curated-documents.js";
|
|
6
6
|
import Layout_default from "./views/Layout.vue.js";
|
|
7
7
|
import Settings_default from "./views/Settings/Settings.vue.js";
|
|
8
|
-
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, onBeforeUnmount, onMounted, openBlock, ref, toDisplayString, unref, useTemplateRef } from "vue";
|
|
8
|
+
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, onBeforeUnmount, onMounted, openBlock, ref, toDisplayString, unref, useTemplateRef, watch } from "vue";
|
|
9
9
|
import { useLazyApiClient } from "@scalar/api-client/modal/use-lazy-api-client";
|
|
10
10
|
import { initializeWorkspaceEventHandlers } from "@scalar/api-client/v2/workspace-events";
|
|
11
11
|
//#region src/Chat.vue?vue&type=script&setup=true&lang.ts
|
|
@@ -15,7 +15,7 @@ var Chat_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
15
15
|
__name: "Chat",
|
|
16
16
|
emits: ["uploadApi"],
|
|
17
17
|
setup(__props) {
|
|
18
|
-
const { chat, prompt, settingsModal, eventBus, workspaceStore, config, mode, addDocument } = useState();
|
|
18
|
+
const { chat, prompt, settingsModal, eventBus, workspaceStore, config, mode, addDocument, getActiveDocumentJson, getActiveDocumentContext, terms } = useState();
|
|
19
19
|
const clientModalRef = useTemplateRef("clientModal");
|
|
20
20
|
const stopClientEvents = initializeWorkspaceEventHandlers({
|
|
21
21
|
eventBus,
|
|
@@ -43,18 +43,26 @@ var Chat_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCompo
|
|
|
43
43
|
onBeforeUnmount(stopClientEvents);
|
|
44
44
|
onMounted(async () => {
|
|
45
45
|
const tmpDoc = getTmpDocFromLocalStorage();
|
|
46
|
-
if (mode === "preview" && tmpDoc) await addDocument({
|
|
46
|
+
if (mode === "preview" && tmpDoc && !getActiveDocumentJson) await addDocument({
|
|
47
47
|
namespace: tmpDoc.namespace,
|
|
48
48
|
slug: tmpDoc.slug,
|
|
49
49
|
removable: false,
|
|
50
50
|
tmp: true
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
+
const { uploadTempDocument } = useUploadTmpDocument();
|
|
54
|
+
watch(terms.accepted, (accepted) => {
|
|
55
|
+
if (accepted && mode === "preview" && getActiveDocumentJson) uploadTempDocument(getActiveDocumentJson(), true);
|
|
56
|
+
}, { immediate: true });
|
|
57
|
+
onBeforeUnmount(() => {
|
|
58
|
+
chat.stop();
|
|
59
|
+
});
|
|
53
60
|
useChatScroll();
|
|
54
61
|
useAgentKeyDocuments();
|
|
55
62
|
useCuratedDocuments();
|
|
56
63
|
async function handleSubmit() {
|
|
57
|
-
|
|
64
|
+
const context = getActiveDocumentContext?.();
|
|
65
|
+
await chat.sendMessage({ text: context ? `${prompt.value}\n\nSelected API description: ${context}` : prompt.value });
|
|
58
66
|
}
|
|
59
67
|
return (_ctx, _cache) => {
|
|
60
68
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.vue.script.js","names":["$emit"],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {
|
|
1
|
+
{"version":3,"file":"Chat.vue.script.js","names":["$emit"],"sources":["../src/Chat.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useLazyApiClient } from '@scalar/api-client/modal/use-lazy-api-client'\nimport { initializeWorkspaceEventHandlers } from '@scalar/api-client/v2/workspace-events'\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { useAgentKeyDocuments } from '@/hooks/use-agent-key-documents'\nimport { useChatScroll } from '@/hooks/use-chat-scroll'\nimport { useCuratedDocuments } from '@/hooks/use-curated-documents'\nimport {\n getTmpDocFromLocalStorage,\n useUploadTmpDocument,\n} from '@/hooks/use-upload-tmp-document'\nimport { useState } from '@/state/state'\nimport Layout from '@/views/Layout.vue'\nimport Settings from '@/views/Settings/Settings.vue'\n\ndefineEmits<{\n (e: 'uploadApi'): void\n}>()\n\nconst {\n chat,\n prompt,\n settingsModal,\n eventBus,\n workspaceStore,\n config,\n mode,\n addDocument,\n getActiveDocumentJson,\n getActiveDocumentContext,\n terms,\n} = useState()\n\nconst clientModalRef = useTemplateRef<HTMLElement>('clientModal')\n// Authentication and server controls also work before the request editor opens.\nconst stopClientEvents = initializeWorkspaceEventHandlers({\n eventBus,\n store: ref(workspaceStore),\n hooks: {},\n})\nconst clientLoadingStatus = ref<'idle' | 'loading' | 'error'>('idle')\nuseLazyApiClient({\n eventBus,\n status: clientLoadingStatus,\n load: async () => {\n const { createApiClientModal } = await import('@scalar/api-client/modal')\n return () => {\n if (!clientModalRef.value) {\n return null\n }\n stopClientEvents()\n return createApiClientModal({\n el: clientModalRef.value,\n options: config,\n eventBus,\n workspaceStore,\n })\n }\n },\n})\nonBeforeUnmount(stopClientEvents)\n\nonMounted(async () => {\n const tmpDoc = getTmpDocFromLocalStorage()\n\n if (mode === 'preview' && tmpDoc && !getActiveDocumentJson) {\n await addDocument({\n namespace: tmpDoc.namespace,\n slug: tmpDoc.slug,\n removable: false,\n tmp: true,\n })\n }\n})\n\nconst { uploadTempDocument } = useUploadTmpDocument()\nwatch(\n terms.accepted,\n (accepted) => {\n if (accepted && mode === 'preview' && getActiveDocumentJson) {\n void uploadTempDocument(getActiveDocumentJson(), true)\n }\n },\n { immediate: true },\n)\nonBeforeUnmount(() => {\n void chat.stop()\n})\n\nuseChatScroll()\nuseAgentKeyDocuments()\nuseCuratedDocuments()\n\nasync function handleSubmit() {\n const context = getActiveDocumentContext?.()\n await chat.sendMessage({\n text: context\n ? `${prompt.value}\\n\\nSelected API description: ${context}`\n : prompt.value,\n })\n}\n</script>\n\n<template>\n <div ref=\"clientModal\" />\n <div\n v-if=\"clientLoadingStatus !== 'idle'\"\n class=\"bg-b-1 text-c-1 fixed right-4 bottom-4 z-[10001] rounded-lg border px-4 py-3 text-sm shadow-lg\"\n :role=\"clientLoadingStatus === 'error' ? 'alert' : 'status'\">\n {{\n clientLoadingStatus === 'loading'\n ? 'Loading request editor…'\n : 'Could not load the request editor. Refresh the page and try again.'\n }}\n </div>\n <Layout\n @submit=\"handleSubmit\"\n @uploadApi=\"$emit('uploadApi')\" />\n <Settings :modalState=\"settingsModal\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAoBA,MAAM,EACJ,MACA,QACA,eACA,UACA,gBACA,QACA,MACA,aACA,uBACA,0BACA,UACE,SAAS;EAEb,MAAM,iBAAiB,eAA4B,aAAa;EAEhE,MAAM,mBAAmB,iCAAiC;GACxD;GACA,OAAO,IAAI,cAAc;GACzB,OAAO,CAAC;EACV,CAAC;EACD,MAAM,sBAAsB,IAAkC,MAAM;EACpE,iBAAiB;GACf;GACA,QAAQ;GACR,MAAM,YAAY;IAChB,MAAM,EAAE,yBAAyB,MAAM,OAAO;IAC9C,aAAa;KACX,IAAI,CAAC,eAAe,OAClB,OAAO;KAET,iBAAiB;KACjB,OAAO,qBAAqB;MAC1B,IAAI,eAAe;MACnB,SAAS;MACT;MACA;KACF,CAAC;IACH;GACF;EACF,CAAC;EACD,gBAAgB,gBAAgB;EAEhC,UAAU,YAAY;GACpB,MAAM,SAAS,0BAA0B;GAEzC,IAAI,SAAS,aAAa,UAAU,CAAC,uBACnC,MAAM,YAAY;IAChB,WAAW,OAAO;IAClB,MAAM,OAAO;IACb,WAAW;IACX,KAAK;GACP,CAAC;EAEL,CAAC;EAED,MAAM,EAAE,uBAAuB,qBAAqB;EACpD,MACE,MAAM,WACL,aAAa;GACZ,IAAI,YAAY,SAAS,aAAa,uBACpC,mBAAwB,sBAAsB,GAAG,IAAI;EAEzD,GACA,EAAE,WAAW,KAAK,CACpB;EACA,sBAAsB;GACpB,KAAU,KAAK;EACjB,CAAC;EAED,cAAc;EACd,qBAAqB;EACrB,oBAAoB;EAEpB,eAAe,eAAe;GAC5B,MAAM,UAAU,2BAA2B;GAC3C,MAAM,KAAK,YAAY,EACrB,MAAM,UACF,GAAG,OAAO,MAAM,gCAAgC,YAChD,OAAO,MACb,CAAC;EACH;;;IAIE,mBAAyB,OAAzB,YAAyB,MAAA,GAAA;IAEjB,oBAAA,UAAmB,UAAA,UAAA,GAD3B,mBASM,OAAA;;KAPJ,OAAM;KACL,MAAM,oBAAA,UAAmB,UAAA,UAAA;uBAExB,oBAAA,UAAmB,YAAA,4BAAA,oEAAA,GAAA,GAAA,UAAA,KAAA,mBAAA,IAAA,IAAA;IAKvB,YAEoC,gBAAA;KADjC,UAAQ;KACR,aAAS,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,WAAA;;IACnB,YAAwC,kBAAA,EAA7B,YAAY,MAAA,aAAA,EAAa,GAAA,MAAA,GAAA,CAAA,YAAA,CAAA"}
|
|
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../_virtual/_plugin-vue_export-he
|
|
|
2
2
|
import UploadSection_vue_vue_type_script_setup_true_lang_default from "./UploadSection.vue.script.js";
|
|
3
3
|
/* empty css */
|
|
4
4
|
//#region src/components/UploadSection.vue
|
|
5
|
-
var UploadSection_default = /*#__PURE__*/ _plugin_vue_export_helper_default(UploadSection_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var UploadSection_default = /*#__PURE__*/ _plugin_vue_export_helper_default(UploadSection_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b82d2f3a"]]);
|
|
6
6
|
//#endregion
|
|
7
7
|
export { UploadSection_default as default };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadSection.vue.js","names":[],"sources":["../../src/components/UploadSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarLoading, useLoadingState } from '@scalar/components/loading'\nimport { ScalarIconCheck, ScalarIconXCircle } from '@scalar/icons'\nimport { computed } from 'vue'\n\nimport { type UploadTmpDocumentState } from '@/hooks/use-upload-tmp-document'\n\nconst { uploadState } = defineProps<{\n uploadState: UploadTmpDocumentState\n}>()\n\nconst loadingState = useLoadingState()\n\nconst isLoading = computed(() =>\n ['uploading', 'processing', 'loading'].includes(uploadState.type),\n)\n</script>\n\n<template>\n <div\n class=\"uploadSection\"\n :class=\"{\n error: uploadState.type === 'error',\n done: uploadState.type === 'done',\n }\">\n <div\n v-if=\"isLoading\"\n class=\"flex items-center gap-1.5\">\n <ScalarLoading\n class=\"text-blue\"\n :loader=\"{\n ...loadingState,\n isLoading: true,\n }\"\n size=\"lg\" />\n <strong\n v-if=\"uploadState.type === 'loading'\"\n class=\"uploadText\">\n Loading
|
|
1
|
+
{"version":3,"file":"UploadSection.vue.js","names":[],"sources":["../../src/components/UploadSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarLoading, useLoadingState } from '@scalar/components/loading'\nimport { ScalarIconCheck, ScalarIconXCircle } from '@scalar/icons'\nimport { computed } from 'vue'\n\nimport { type UploadTmpDocumentState } from '@/hooks/use-upload-tmp-document'\n\nconst { uploadState } = defineProps<{\n uploadState: UploadTmpDocumentState\n}>()\n\nconst loadingState = useLoadingState()\n\nconst isLoading = computed(() =>\n ['uploading', 'processing', 'loading'].includes(uploadState.type),\n)\n</script>\n\n<template>\n <div\n class=\"uploadSection\"\n :class=\"{\n error: uploadState.type === 'error',\n done: uploadState.type === 'done',\n }\">\n <div\n v-if=\"isLoading\"\n class=\"flex items-center gap-1.5\">\n <ScalarLoading\n class=\"text-blue\"\n :loader=\"{\n ...loadingState,\n isLoading: true,\n }\"\n size=\"lg\" />\n <strong\n v-if=\"uploadState.type === 'loading'\"\n class=\"uploadText\">\n Loading API description…\n </strong>\n <strong\n v-else-if=\"uploadState.type === 'processing'\"\n class=\"uploadText\">\n Processing API description…\n </strong>\n <strong\n v-else\n class=\"uploadText\">\n Uploading API description…\n </strong>\n </div>\n <strong\n v-if=\"uploadState.type === 'done'\"\n class=\"uploadText flex items-center gap-1.5\">\n <ScalarIconCheck class=\"icon text-green\" />\n Your API description has been processed successfully.\n </strong>\n <strong\n v-if=\"uploadState.type === 'error'\"\n class=\"uploadText flex items-center gap-1.5\">\n <ScalarIconXCircle class=\"icon text-red\" />\n {{ uploadState.error }}\n </strong>\n </div>\n</template>\n\n<style scoped>\n.uploadSection {\n width: 100%;\n margin-bottom: -16px;\n padding: 8px 8px 24px 12px;\n position: relative;\n background: color-mix(\n in srgb,\n var(--scalar-color-blue),\n var(--scalar-background-1) 95%\n );\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-3xl) var(--scalar-radius-3xl) 0 0;\n display: flex;\n align-items: center;\n justify-content: space-between;\n position: absolute;\n top: 0;\n transform: translate3d(0, calc(-100% + 16px), 0);\n}\n\n.uploadSection.error {\n background: color-mix(\n in srgb,\n var(--scalar-color-red),\n var(--scalar-background-1) 95%\n );\n}\n\n.uploadSection.done {\n background: color-mix(\n in srgb,\n var(--scalar-color-green),\n var(--scalar-background-1) 95%\n );\n}\n\n.uploadText {\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-font-size-3);\n}\n\n.icon {\n height: 20px;\n width: 20px;\n}\n</style>\n"],"mappings":""}
|
|
@@ -48,8 +48,8 @@ var UploadSection_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ de
|
|
|
48
48
|
isLoading: true
|
|
49
49
|
},
|
|
50
50
|
size: "lg"
|
|
51
|
-
}, null, 8, ["loader"]), __props.uploadState.type === "loading" ? (openBlock(), createElementBlock("strong", _hoisted_2, " Loading
|
|
52
|
-
__props.uploadState.type === "done" ? (openBlock(), createElementBlock("strong", _hoisted_5, [createVNode(unref(ScalarIconCheck), { class: "icon text-green" }), _cache[0] || (_cache[0] = createTextVNode(" Your
|
|
51
|
+
}, null, 8, ["loader"]), __props.uploadState.type === "loading" ? (openBlock(), createElementBlock("strong", _hoisted_2, " Loading API description… ")) : __props.uploadState.type === "processing" ? (openBlock(), createElementBlock("strong", _hoisted_3, " Processing API description… ")) : (openBlock(), createElementBlock("strong", _hoisted_4, " Uploading API description… "))])) : createCommentVNode("", true),
|
|
52
|
+
__props.uploadState.type === "done" ? (openBlock(), createElementBlock("strong", _hoisted_5, [createVNode(unref(ScalarIconCheck), { class: "icon text-green" }), _cache[0] || (_cache[0] = createTextVNode(" Your API description has been processed successfully. ", -1))])) : createCommentVNode("", true),
|
|
53
53
|
__props.uploadState.type === "error" ? (openBlock(), createElementBlock("strong", _hoisted_6, [createVNode(unref(ScalarIconXCircle), { class: "icon text-red" }), createTextVNode(" " + toDisplayString(__props.uploadState.error), 1)])) : createCommentVNode("", true)
|
|
54
54
|
], 2);
|
|
55
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UploadSection.vue.script.js","names":[],"sources":["../../src/components/UploadSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarLoading, useLoadingState } from '@scalar/components/loading'\nimport { ScalarIconCheck, ScalarIconXCircle } from '@scalar/icons'\nimport { computed } from 'vue'\n\nimport { type UploadTmpDocumentState } from '@/hooks/use-upload-tmp-document'\n\nconst { uploadState } = defineProps<{\n uploadState: UploadTmpDocumentState\n}>()\n\nconst loadingState = useLoadingState()\n\nconst isLoading = computed(() =>\n ['uploading', 'processing', 'loading'].includes(uploadState.type),\n)\n</script>\n\n<template>\n <div\n class=\"uploadSection\"\n :class=\"{\n error: uploadState.type === 'error',\n done: uploadState.type === 'done',\n }\">\n <div\n v-if=\"isLoading\"\n class=\"flex items-center gap-1.5\">\n <ScalarLoading\n class=\"text-blue\"\n :loader=\"{\n ...loadingState,\n isLoading: true,\n }\"\n size=\"lg\" />\n <strong\n v-if=\"uploadState.type === 'loading'\"\n class=\"uploadText\">\n Loading
|
|
1
|
+
{"version":3,"file":"UploadSection.vue.script.js","names":[],"sources":["../../src/components/UploadSection.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarLoading, useLoadingState } from '@scalar/components/loading'\nimport { ScalarIconCheck, ScalarIconXCircle } from '@scalar/icons'\nimport { computed } from 'vue'\n\nimport { type UploadTmpDocumentState } from '@/hooks/use-upload-tmp-document'\n\nconst { uploadState } = defineProps<{\n uploadState: UploadTmpDocumentState\n}>()\n\nconst loadingState = useLoadingState()\n\nconst isLoading = computed(() =>\n ['uploading', 'processing', 'loading'].includes(uploadState.type),\n)\n</script>\n\n<template>\n <div\n class=\"uploadSection\"\n :class=\"{\n error: uploadState.type === 'error',\n done: uploadState.type === 'done',\n }\">\n <div\n v-if=\"isLoading\"\n class=\"flex items-center gap-1.5\">\n <ScalarLoading\n class=\"text-blue\"\n :loader=\"{\n ...loadingState,\n isLoading: true,\n }\"\n size=\"lg\" />\n <strong\n v-if=\"uploadState.type === 'loading'\"\n class=\"uploadText\">\n Loading API description…\n </strong>\n <strong\n v-else-if=\"uploadState.type === 'processing'\"\n class=\"uploadText\">\n Processing API description…\n </strong>\n <strong\n v-else\n class=\"uploadText\">\n Uploading API description…\n </strong>\n </div>\n <strong\n v-if=\"uploadState.type === 'done'\"\n class=\"uploadText flex items-center gap-1.5\">\n <ScalarIconCheck class=\"icon text-green\" />\n Your API description has been processed successfully.\n </strong>\n <strong\n v-if=\"uploadState.type === 'error'\"\n class=\"uploadText flex items-center gap-1.5\">\n <ScalarIconXCircle class=\"icon text-red\" />\n {{ uploadState.error }}\n </strong>\n </div>\n</template>\n\n<style scoped>\n.uploadSection {\n width: 100%;\n margin-bottom: -16px;\n padding: 8px 8px 24px 12px;\n position: relative;\n background: color-mix(\n in srgb,\n var(--scalar-color-blue),\n var(--scalar-background-1) 95%\n );\n border: var(--scalar-border-width) solid var(--scalar-border-color);\n border-radius: var(--scalar-radius-3xl) var(--scalar-radius-3xl) 0 0;\n display: flex;\n align-items: center;\n justify-content: space-between;\n position: absolute;\n top: 0;\n transform: translate3d(0, calc(-100% + 16px), 0);\n}\n\n.uploadSection.error {\n background: color-mix(\n in srgb,\n var(--scalar-color-red),\n var(--scalar-background-1) 95%\n );\n}\n\n.uploadSection.done {\n background: color-mix(\n in srgb,\n var(--scalar-color-green),\n var(--scalar-background-1) 95%\n );\n}\n\n.uploadText {\n font-weight: var(--scalar-semibold);\n font-size: var(--scalar-font-size-3);\n}\n\n.icon {\n height: 20px;\n width: 20px;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWA,MAAM,eAAe,gBAAgB;EAErC,MAAM,YAAY,eAChB;GAAC;GAAa;GAAc;EAAS,CAAC,CAAC,SAAS,QAAA,YAAY,IAAI,CAClE;;uBAIE,mBA4CM,OAAA,EA3CJ,OAAK,eAAA,CAAC,iBAAe;WACE,QAAA,YAAY,SAAI;UAA0B,QAAA,YAAY,SAAI;;IAKzE,UAAA,SAAA,UAAA,GADR,mBAyBM,OAzBN,YAyBM,CAtBJ,YAMc,MAAA,aAAA,GAAA;KALZ,OAAM;KACL,QAAM;SAAiB,MAAA,YAAA;;;KAIxB,MAAK;6BAEC,QAAA,YAAY,SAAI,aAAA,UAAA,GADxB,mBAIS,UAJT,YAEqB,4BAErB,KAEa,QAAA,YAAY,SAAI,gBAAA,UAAA,GAD7B,mBAIS,UAJT,YAEqB,+BAErB,MAAA,UAAA,GACA,mBAIS,UAJT,YAEqB,8BAErB,EAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;IAGM,QAAA,YAAY,SAAI,UAAA,UAAA,GADxB,mBAKS,UALT,YAKS,CAFP,YAA2C,MAAA,eAAA,GAAA,EAA1B,OAAM,kBAAiB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,gBAAG,2DAE7C,EAAA,EAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;IAEQ,QAAA,YAAY,SAAI,WAAA,UAAA,GADxB,mBAKS,UALT,YAKS,CAFP,YAA2C,MAAA,iBAAA,GAAA,EAAxB,OAAM,gBAAe,CAAA,GAAA,gBAAG,MAC3C,gBAAG,QAAA,YAAY,KAAK,GAAA,CAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
|
+
import type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1';
|
|
2
3
|
export declare const SUMMARIZE_OPENAPI_SPECS_TOOL_NAME: "summarize-openapi-specs";
|
|
3
|
-
export type GetOpenAPISpecsSummaryToolOutput = {
|
|
4
|
+
export type GetOpenAPISpecsSummaryToolOutput = ({
|
|
4
5
|
paths: string[];
|
|
5
6
|
components?: {
|
|
6
7
|
securitySchemes: Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SecuritySchemeObject>;
|
|
@@ -8,5 +9,5 @@ export type GetOpenAPISpecsSummaryToolOutput = {
|
|
|
8
9
|
info?: OpenAPIV3_1.InfoObject;
|
|
9
10
|
externalDocs: any;
|
|
10
11
|
servers?: OpenAPIV3_1.ServerObject[];
|
|
11
|
-
}[];
|
|
12
|
+
} | Partial<AsyncApiDocument>)[];
|
|
12
13
|
//# sourceMappingURL=get-openapi-specs-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-openapi-specs-summary.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/get-openapi-specs-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"get-openapi-specs-summary.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/get-openapi-specs-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE,eAAO,MAAM,iCAAiC,EAAG,yBAAkC,CAAA;AAEnF,MAAM,MAAM,gCAAgC,GAAG,CAC3C;IACE,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,UAAU,CAAC,EAAE;QACX,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,eAAe,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAA;KAChG,CAAA;IACD,IAAI,CAAC,EAAE,WAAW,CAAC,UAAU,CAAA;IAC7B,YAAY,EAAE,GAAG,CAAA;IACjB,OAAO,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,CAAA;CACrC,GACD,OAAO,CAAC,gBAAgB,CAAC,CAC5B,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-openapi-specs-summary.js","names":[],"sources":["../../../src/entities/tools/get-openapi-specs-summary.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\n\nexport const SUMMARIZE_OPENAPI_SPECS_TOOL_NAME = 'summarize-openapi-specs' as const\n\nexport type GetOpenAPISpecsSummaryToolOutput = {\n
|
|
1
|
+
{"version":3,"file":"get-openapi-specs-summary.js","names":[],"sources":["../../../src/entities/tools/get-openapi-specs-summary.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\n\nexport const SUMMARIZE_OPENAPI_SPECS_TOOL_NAME = 'summarize-openapi-specs' as const\n\nexport type GetOpenAPISpecsSummaryToolOutput = (\n | {\n paths: string[]\n components?: {\n securitySchemes: Record<string, OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SecuritySchemeObject>\n }\n info?: OpenAPIV3_1.InfoObject\n externalDocs: any\n servers?: OpenAPIV3_1.ServerObject[]\n }\n | Partial<AsyncApiDocument>\n)[]\n"],"mappings":";AAGA,IAAa,oCAAoC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
|
+
import type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1';
|
|
2
3
|
import { type Static } from '@scalar/validation';
|
|
3
4
|
export declare const SEARCH_OPENAPI_OPERATIONS_TOOL_NAME: "search-openapi-operations";
|
|
4
5
|
export declare const searchOpenAPIOperationsInputSchema: import("@scalar/validation").ObjectSchema<{
|
|
5
6
|
question: import("@scalar/validation").StringSchema;
|
|
6
7
|
}>;
|
|
7
8
|
export type SearchOpenAPIOperationsToolInput = Static<typeof searchOpenAPIOperationsInputSchema>;
|
|
8
|
-
export type SearchOpenAPIOperationsToolOutput = Partial<OpenAPIV3_1.Document>[];
|
|
9
|
+
export type SearchOpenAPIOperationsToolOutput = (Partial<OpenAPIV3_1.Document> | Partial<AsyncApiDocument>)[];
|
|
9
10
|
//# sourceMappingURL=search-openapi-operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-openapi-operations.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/search-openapi-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,oBAAoB,CAAA;AAEhE,eAAO,MAAM,mCAAmC,EAAG,2BAAoC,CAAA;AAEvF,eAAO,MAAM,kCAAkC;;EAE7C,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,MAAM,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAEhG,MAAM,MAAM,iCAAiC,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"search-openapi-operations.d.ts","sourceRoot":"","sources":["../../../src/entities/tools/search-openapi-operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,oBAAoB,CAAA;AAEhE,eAAO,MAAM,mCAAmC,EAAG,2BAAoC,CAAA;AAEvF,eAAO,MAAM,kCAAkC;;EAE7C,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,MAAM,CAAC,OAAO,kCAAkC,CAAC,CAAA;AAEhG,MAAM,MAAM,iCAAiC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-openapi-operations.js","names":[],"sources":["../../../src/entities/tools/search-openapi-operations.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport { type Static, object, string } from '@scalar/validation'\n\nexport const SEARCH_OPENAPI_OPERATIONS_TOOL_NAME = 'search-openapi-operations' as const\n\nexport const searchOpenAPIOperationsInputSchema = object({\n question: string(),\n})\n\nexport type SearchOpenAPIOperationsToolInput = Static<typeof searchOpenAPIOperationsInputSchema>\n\nexport type SearchOpenAPIOperationsToolOutput = Partial<OpenAPIV3_1.Document>[]\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"search-openapi-operations.js","names":[],"sources":["../../../src/entities/tools/search-openapi-operations.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from '@scalar/openapi-types'\nimport type { AsyncApiDocument } from '@scalar/types/asyncapi/3.1'\nimport { type Static, object, string } from '@scalar/validation'\n\nexport const SEARCH_OPENAPI_OPERATIONS_TOOL_NAME = 'search-openapi-operations' as const\n\nexport const searchOpenAPIOperationsInputSchema = object({\n question: string(),\n})\n\nexport type SearchOpenAPIOperationsToolInput = Static<typeof searchOpenAPIOperationsInputSchema>\n\nexport type SearchOpenAPIOperationsToolOutput = (Partial<OpenAPIV3_1.Document> | Partial<AsyncApiDocument>)[]\n"],"mappings":";;AAIA,IAAa,sCAAsC;AAEnD,IAAa,qCAAqC,OAAO,EACvD,UAAU,OAAO,EACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-search-result-labels.d.ts","sourceRoot":"","sources":["../../src/helpers/get-search-result-labels.ts"],"names":[],"mappings":"AAQA,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,GAAI,OAAO,OAAO,KAAG,MAAM,EA0C5D,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
|
|
2
|
+
import { isObject } from "@scalar/helpers/object/is-object";
|
|
3
|
+
import { createMagicProxy } from "@scalar/json-magic/magic-proxy";
|
|
4
|
+
import { getResolvedAsyncApiRef } from "@scalar/workspace-store/helpers/get-resolved-async-api-ref";
|
|
5
|
+
//#region src/helpers/get-search-result-labels.ts
|
|
6
|
+
var entries = (value) => isObject(value) ? Object.entries(value) : [];
|
|
7
|
+
var label = (value, fallback) => typeof value === "string" && value ? value : fallback;
|
|
8
|
+
/** Display native API identities without treating path metadata as operations. */
|
|
9
|
+
var getSearchResultLabels = (input) => {
|
|
10
|
+
if (!isObject(input)) return [];
|
|
11
|
+
const document = createMagicProxy(input);
|
|
12
|
+
const title = isObject(document.info) ? label(document.info.title, "") : "";
|
|
13
|
+
const prefix = title ? `${title} - ` : "";
|
|
14
|
+
if (typeof document.asyncapi === "string") {
|
|
15
|
+
const operations = entries(document.operations).flatMap(([name, node]) => {
|
|
16
|
+
const operation = getResolvedAsyncApiRef(node);
|
|
17
|
+
if (!isObject(operation)) return [];
|
|
18
|
+
const channel = getResolvedAsyncApiRef(operation.channel);
|
|
19
|
+
const address = isObject(channel) ? label(channel.address, "Unknown address") : "Unknown address";
|
|
20
|
+
return [`${prefix}${label(operation.action, "Operation")} ${address}: ${label(operation.title, label(operation.summary, name))}`];
|
|
21
|
+
});
|
|
22
|
+
const channels = entries(document.channels).flatMap(([name, node]) => {
|
|
23
|
+
const channel = getResolvedAsyncApiRef(node);
|
|
24
|
+
if (!isObject(channel)) return [];
|
|
25
|
+
const address = label(channel.address, "Unknown address");
|
|
26
|
+
return [`${prefix}Channel ${address}: ${label(channel.title, name)}`, ...entries(channel.messages).map(([messageName, node]) => {
|
|
27
|
+
const message = getResolvedAsyncApiRef(node);
|
|
28
|
+
return `${prefix}Message ${isObject(message) ? label(message.title, label(message.name, messageName)) : messageName} (${address})`;
|
|
29
|
+
})];
|
|
30
|
+
});
|
|
31
|
+
return [...operations, ...channels];
|
|
32
|
+
}
|
|
33
|
+
return entries(document.paths).flatMap(([path, node]) => entries(node).flatMap(([method, operation]) => isHttpMethod(method) && isObject(operation) ? [`${prefix}${label(operation.summary, `${method.toUpperCase()} ${path}`)}`] : []));
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getSearchResultLabels };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=get-search-result-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-search-result-labels.js","names":[],"sources":["../../src/helpers/get-search-result-labels.ts"],"sourcesContent":["import { isHttpMethod } from '@scalar/helpers/http/is-http-method'\nimport { isObject } from '@scalar/helpers/object/is-object'\nimport { createMagicProxy } from '@scalar/json-magic/magic-proxy'\nimport { getResolvedAsyncApiRef } from '@scalar/workspace-store/helpers/get-resolved-async-api-ref'\n\nconst entries = (value: unknown): [string, unknown][] => (isObject(value) ? Object.entries(value) : [])\nconst label = (value: unknown, fallback: string): string => (typeof value === 'string' && value ? value : fallback)\n\n/** Display native API identities without treating path metadata as operations. */\nexport const getSearchResultLabels = (input: unknown): string[] => {\n if (!isObject(input)) {\n return []\n }\n const document = createMagicProxy(input)\n const title = isObject(document.info) ? label(document.info.title, '') : ''\n const prefix = title ? `${title} - ` : ''\n if (typeof document.asyncapi === 'string') {\n const operations = entries(document.operations).flatMap(([name, node]) => {\n const operation = getResolvedAsyncApiRef(node)\n if (!isObject(operation)) {\n return []\n }\n const channel = getResolvedAsyncApiRef(operation.channel)\n const address = isObject(channel) ? label(channel.address, 'Unknown address') : 'Unknown address'\n return [\n `${prefix}${label(operation.action, 'Operation')} ${address}: ${label(operation.title, label(operation.summary, name))}`,\n ]\n })\n const channels = entries(document.channels).flatMap(([name, node]) => {\n const channel = getResolvedAsyncApiRef(node)\n if (!isObject(channel)) {\n return []\n }\n const address = label(channel.address, 'Unknown address')\n return [\n `${prefix}Channel ${address}: ${label(channel.title, name)}`,\n ...entries(channel.messages).map(([messageName, node]) => {\n const message = getResolvedAsyncApiRef(node)\n return `${prefix}Message ${isObject(message) ? label(message.title, label(message.name, messageName)) : messageName} (${address})`\n }),\n ]\n })\n return [...operations, ...channels]\n }\n return entries(document.paths).flatMap(([path, node]) =>\n entries(node).flatMap(([method, operation]) =>\n isHttpMethod(method) && isObject(operation)\n ? [`${prefix}${label(operation.summary, `${method.toUpperCase()} ${path}`)}`]\n : [],\n ),\n )\n}\n"],"mappings":";;;;;AAKA,IAAM,WAAW,UAAyC,SAAS,KAAK,IAAI,OAAO,QAAQ,KAAK,IAAI,CAAC;AACrG,IAAM,SAAS,OAAgB,aAA8B,OAAO,UAAU,YAAY,QAAQ,QAAQ;;AAG1G,IAAa,yBAAyB,UAA6B;CACjE,IAAI,CAAC,SAAS,KAAK,GACjB,OAAO,CAAC;CAEV,MAAM,WAAW,iBAAiB,KAAK;CACvC,MAAM,QAAQ,SAAS,SAAS,IAAI,IAAI,MAAM,SAAS,KAAK,OAAO,EAAE,IAAI;CACzE,MAAM,SAAS,QAAQ,GAAG,MAAM,OAAO;CACvC,IAAI,OAAO,SAAS,aAAa,UAAU;EACzC,MAAM,aAAa,QAAQ,SAAS,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,UAAU;GACxE,MAAM,YAAY,uBAAuB,IAAI;GAC7C,IAAI,CAAC,SAAS,SAAS,GACrB,OAAO,CAAC;GAEV,MAAM,UAAU,uBAAuB,UAAU,OAAO;GACxD,MAAM,UAAU,SAAS,OAAO,IAAI,MAAM,QAAQ,SAAS,iBAAiB,IAAI;GAChF,OAAO,CACL,GAAG,SAAS,MAAM,UAAU,QAAQ,WAAW,EAAE,GAAG,QAAQ,IAAI,MAAM,UAAU,OAAO,MAAM,UAAU,SAAS,IAAI,CAAC,GACvH;EACF,CAAC;EACD,MAAM,WAAW,QAAQ,SAAS,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,UAAU;GACpE,MAAM,UAAU,uBAAuB,IAAI;GAC3C,IAAI,CAAC,SAAS,OAAO,GACnB,OAAO,CAAC;GAEV,MAAM,UAAU,MAAM,QAAQ,SAAS,iBAAiB;GACxD,OAAO,CACL,GAAG,OAAO,UAAU,QAAQ,IAAI,MAAM,QAAQ,OAAO,IAAI,KACzD,GAAG,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,CAAC,aAAa,UAAU;IACxD,MAAM,UAAU,uBAAuB,IAAI;IAC3C,OAAO,GAAG,OAAO,UAAU,SAAS,OAAO,IAAI,MAAM,QAAQ,OAAO,MAAM,QAAQ,MAAM,WAAW,CAAC,IAAI,YAAY,IAAI,QAAQ;GAClI,CAAC,CACH;EACF,CAAC;EACD,OAAO,CAAC,GAAG,YAAY,GAAG,QAAQ;CACpC;CACA,OAAO,QAAQ,SAAS,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,UAC7C,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,QAAQ,eAC9B,aAAa,MAAM,KAAK,SAAS,SAAS,IACtC,CAAC,GAAG,SAAS,MAAM,UAAU,SAAS,GAAG,OAAO,YAAY,EAAE,GAAG,MAAM,GAAG,IAC1E,CAAC,CACP,CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-search-result-labels.test.d.ts","sourceRoot":"","sources":["../../src/helpers/get-search-result-labels.test.ts"],"names":[],"mappings":""}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import type { OpenAPIV3_1 } from '@scalar/openapi-types';
|
|
2
1
|
import type { WorkspaceStore } from '@scalar/workspace-store/client';
|
|
3
2
|
import { type Auth } from '@scalar/workspace-store/entities/auth';
|
|
4
3
|
import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example';
|
|
5
|
-
import type { OperationObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
6
|
-
export declare function getOperations(doc: Partial<OpenAPIV3_1.Document>): OperationObject[];
|
|
7
4
|
/** Generate document settings from workspace store. AsyncAPI docs are skipped — this feature is OpenAPI-native. */
|
|
8
5
|
export declare function createDocumentSettings(workspaceStore: WorkspaceStore): {
|
|
9
6
|
[k: string]: {
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,EAAE,KAAK,IAAI,EAAc,MAAM,uCAAuC,CAAA;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AAmCzF,mHAAmH;AACnH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,cAAc;;;;;EAuBpE;AAKD;;;;GAIG;AACH,eAAO,MAAM,WAAW;IAMpB;;OAEG;oBACa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAItB;;;OAGG;oBACa,MAAM,SAAS,IAAI;CAItC,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,GAAI,mCAG3C;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;CAC/B,KAAG,IAIH,CAAA;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,OAM1C"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
import { isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
1
2
|
import { getSecurityRequirements, getSecuritySchemes, getSelectedSecurity, getSelectedServer, getServers, mergeSecurity } from "@scalar/workspace-store/request-example";
|
|
2
3
|
import { REFERENCE_LS_KEYS, safeLocalStorage } from "@scalar/helpers/object/local-storage";
|
|
3
4
|
import { AuthSchema } from "@scalar/workspace-store/entities/auth";
|
|
4
|
-
import { isOpenApiDocument } from "@scalar/workspace-store/schemas/type-guards";
|
|
5
5
|
import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
|
|
6
6
|
//#region src/helpers.ts
|
|
7
|
-
function getOperations(doc) {
|
|
8
|
-
return Object.values(doc.paths ?? {}).flatMap((path) => Object.values(path ?? {}));
|
|
9
|
-
}
|
|
10
7
|
/** Flattens all security requirements from a document */
|
|
11
8
|
function getSecurityFromDocument(documentName, document, authStore) {
|
|
12
9
|
const mergedSecurity = mergeSecurity(document?.components?.securitySchemes, {}, authStore, documentName);
|
|
@@ -75,6 +72,6 @@ function safeParseJson(value) {
|
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
//#endregion
|
|
78
|
-
export { authStorage, createDocumentSettings,
|
|
75
|
+
export { authStorage, createDocumentSettings, restoreAuthSecretsFromStorage, safeParseJson };
|
|
79
76
|
|
|
80
77
|
//# sourceMappingURL=helpers.js.map
|
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 {
|
|
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 { 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 { isOpenApiDocument } from '@scalar/workspace-store/schemas/type-guards'\nimport { coerceValue } from '@scalar/workspace-store/schemas/typebox-coerce'\nimport type { OpenApiDocument } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\n\n/** Flattens all security requirements from a document */\nfunction getSecurityFromDocument(\n documentName: string,\n document: OpenApiDocument,\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. AsyncAPI docs are skipped — this feature is OpenAPI-native. */\nexport function createDocumentSettings(workspaceStore: WorkspaceStore) {\n const openApiEntries: [string, OpenApiDocument][] = []\n for (const [key, document] of Object.entries(workspaceStore.workspace.documents)) {\n if (isOpenApiDocument(document)) {\n openApiEntries.push([key, document])\n }\n }\n\n return Object.fromEntries(\n openApiEntries.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,SAAS,wBACP,cACA,UACA,WAC8B;CAC9B,MAAM,iBAAiB,cAAc,UAAU,YAAY,iBAAiB,CAAC,GAAG,WAAW,YAAY;CAEvG,MAAM,uBAAuB,wBAAwB,SAAS,QAAQ;CAEtE,MAAM,mBAAmB,oBACvB,UAAU,uBAAuB;EAC/B,MAAM;EACN;CACF,CAAC,GACD,KAAA,GACA,oBACF;CAEA,OAAO,mBAAmB,gBAAgB,iBAAiB,gBAAgB,iBAAiB,kBAAkB,CAAC,CAAC;AAClH;;AAGA,SAAgB,uBAAuB,gBAAgC;CACrE,MAAM,iBAA8C,CAAC;CACrD,KAAK,MAAM,CAAC,KAAK,aAAa,OAAO,QAAQ,eAAe,UAAU,SAAS,GAC7E,IAAI,kBAAkB,QAAQ,GAC5B,eAAe,KAAK,CAAC,KAAK,QAAQ,CAAC;CAIvC,OAAO,OAAO,YACZ,eAAe,KAAK,CAAC,KAAK,cAAc;EAKtC,OAAO,CACL,KACA;GACE,cAAc,kBAAkB,UAAU,MAAM,MAPpC,WAAW,SAAS,SAAS,EAC3C,aAAa,SAAS,gCACxB,CAK0D,CAAO;GAC7D,iBAAiB,wBAAwB,KAAK,UAAU,eAAe,IAAI;EAC7E,CACF;CACF,CAAC,CACH;AACF;AAGA,IAAM,UAAU,iBAAiB;;;;;;AAOjC,IAAa,oBAAoB;CAC/B,MAAM,UAAU,SAAiB;EAC/B,OAAO,GAAG,kBAAkB,KAAK,GAAG;CACtC;CAEA,OAAO;;;;EAIL,UAAU,SAAiB;GAEzB,OAAO,YAAY,YADJ,KAAK,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,KAAK,IAC5B,CAAM;EACvC;;;;;EAKA,UAAU,MAAc,UAAgB;GACtC,QAAQ,QAAQ,OAAO,IAAI,GAAG,KAAK,UAAU,KAAK,CAAC;EACrD;CACF;AACF;;;;;;;;;;AAWA,IAAa,iCAAiC,EAC5C,cACA,qBAIU;CAEV,MAAM,OADkB,YACX,CAAA,CAAgB,QAAQ,YAAY;CACjD,eAAe,KAAK,KAAK,GAAG,eAAe,KAAK,CAAC;AACnD;AAEA,SAAgB,cAAc,OAAe;CAC3C,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN;CACF;AACF"}
|
|
@@ -9,7 +9,7 @@ function useAgentKeyDocuments() {
|
|
|
9
9
|
if (mode !== "full" || !getAgentKey) return;
|
|
10
10
|
const keyDocumentsResult = await api.getKeyDocuments();
|
|
11
11
|
if (!keyDocumentsResult.success) {
|
|
12
|
-
toast("Failed to fetch your
|
|
12
|
+
toast("Failed to fetch your API description. The Agent key may be invalid.", "error");
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
keyDocumentsResult.data.documents.forEach(({ namespace, slug }) => addDocument({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-key-documents.js","names":[],"sources":["../../src/hooks/use-agent-key-documents.ts"],"sourcesContent":["import { useToasts } from '@scalar/use-toasts'\nimport { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useAgentKeyDocuments() {\n const { api, addDocument, mode, getAgentKey } = useState()\n const { toast } = useToasts()\n\n onMounted(async () => {\n if (mode !== 'full' || !getAgentKey) {\n return\n }\n\n const keyDocumentsResult = await api.getKeyDocuments()\n\n if (!keyDocumentsResult.success) {\n toast('Failed to fetch your
|
|
1
|
+
{"version":3,"file":"use-agent-key-documents.js","names":[],"sources":["../../src/hooks/use-agent-key-documents.ts"],"sourcesContent":["import { useToasts } from '@scalar/use-toasts'\nimport { onMounted } from 'vue'\n\nimport { useState } from '@/state/state'\n\nexport function useAgentKeyDocuments() {\n const { api, addDocument, mode, getAgentKey } = useState()\n const { toast } = useToasts()\n\n onMounted(async () => {\n if (mode !== 'full' || !getAgentKey) {\n return\n }\n\n const keyDocumentsResult = await api.getKeyDocuments()\n\n if (!keyDocumentsResult.success) {\n toast('Failed to fetch your API description. The Agent key may be invalid.', 'error')\n return\n }\n\n keyDocumentsResult.data.documents.forEach(({ namespace, slug }) =>\n addDocument({ namespace, slug, removable: false }),\n )\n })\n}\n"],"mappings":";;;;AAKA,SAAgB,uBAAuB;CACrC,MAAM,EAAE,KAAK,aAAa,MAAM,gBAAgB,SAAS;CACzD,MAAM,EAAE,UAAU,UAAU;CAE5B,UAAU,YAAY;EACpB,IAAI,SAAS,UAAU,CAAC,aACtB;EAGF,MAAM,qBAAqB,MAAM,IAAI,gBAAgB;EAErD,IAAI,CAAC,mBAAmB,SAAS;GAC/B,MAAM,uEAAuE,OAAO;GACpF;EACF;EAEA,mBAAmB,KAAK,UAAU,SAAS,EAAE,WAAW,WACtD,YAAY;GAAE;GAAW;GAAM,WAAW;EAAM,CAAC,CACnD;CACF,CAAC;AACH"}
|
|
@@ -16,7 +16,7 @@ export declare function getTmpDocFromLocalStorage(): {
|
|
|
16
16
|
} | undefined;
|
|
17
17
|
export declare function removeTmpDocFromLocalStorage(): void;
|
|
18
18
|
/**
|
|
19
|
-
* Handle uploading a temporary
|
|
19
|
+
* Handle uploading a temporary API description.
|
|
20
20
|
*/
|
|
21
21
|
export declare function useUploadTmpDocument(): {
|
|
22
22
|
uploadTempDocument: (document: string, isAgent?: boolean) => Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAQA,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,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAapB,wBAAgB,yBAAyB;;;cAOxC;AAED,wBAAgB,4BAA4B,SAO3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB;
|
|
1
|
+
{"version":3,"file":"use-upload-tmp-document.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload-tmp-document.ts"],"names":[],"mappings":"AAQA,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,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAapB,wBAAgB,yBAAyB;;;cAOxC;AAED,wBAAgB,4BAA4B,SAO3C;AAED;;GAEG;AACH,wBAAgB,oBAAoB;mCAWU,MAAM;;;;;;EAyFnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "../state/state.js";
|
|
2
|
-
import {
|
|
2
|
+
import { onScopeDispose } from "vue";
|
|
3
3
|
import { coerce, object, string, validate } from "@scalar/validation";
|
|
4
4
|
import { redirectToProxy } from "@scalar/helpers/url/redirect-to-proxy";
|
|
5
5
|
//#region src/hooks/use-upload-tmp-document.ts
|
|
@@ -25,11 +25,13 @@ function removeTmpDocFromLocalStorage() {
|
|
|
25
25
|
localStorage.removeItem(TMP_DOC_LS_KEY);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Handle uploading a temporary
|
|
28
|
+
* Handle uploading a temporary API description.
|
|
29
29
|
*/
|
|
30
30
|
function useUploadTmpDocument() {
|
|
31
31
|
const state = useState();
|
|
32
|
-
const uploadState =
|
|
32
|
+
const { uploadState } = state;
|
|
33
|
+
const controller = new AbortController();
|
|
34
|
+
onScopeDispose(() => controller.abort());
|
|
33
35
|
function createUrl(path) {
|
|
34
36
|
const fullUrl = `${state.baseUrl}${path}`;
|
|
35
37
|
return redirectToProxy(state.platformProxyUrl, fullUrl);
|
|
@@ -39,13 +41,14 @@ function useUploadTmpDocument() {
|
|
|
39
41
|
uploadState.value = { type: "uploading" };
|
|
40
42
|
const response = await fetch(createUrl(`/core/share/upload/apis${isAgent ? "?source=agent" : ""}`), {
|
|
41
43
|
method: "POST",
|
|
44
|
+
signal: controller.signal,
|
|
42
45
|
headers: { "Content-Type": "application/json" },
|
|
43
46
|
body: JSON.stringify({ document })
|
|
44
47
|
});
|
|
45
48
|
if (!response.ok) {
|
|
46
49
|
uploadState.value = {
|
|
47
50
|
type: "error",
|
|
48
|
-
error: "Failed to upload your
|
|
51
|
+
error: "Failed to upload your API description."
|
|
49
52
|
};
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
@@ -64,24 +67,27 @@ function useUploadTmpDocument() {
|
|
|
64
67
|
}
|
|
65
68
|
const uploadData = coerce(uploadResponseSchema, json);
|
|
66
69
|
uploadState.value = { type: "processing" };
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
await state.addDocument({
|
|
73
|
-
namespace: uploadData.namespace,
|
|
74
|
-
slug: uploadData.slug,
|
|
75
|
-
removable: false,
|
|
76
|
-
tmp: true
|
|
77
|
-
});
|
|
78
|
-
if (!embeddingStatusResponse.ok) {
|
|
70
|
+
if (!(await fetch(createUrl(`/vector/registry/embeddings/${uploadData.namespace}/${uploadData.slug}`), {
|
|
71
|
+
method: "GET",
|
|
72
|
+
signal: controller.signal
|
|
73
|
+
})).ok) {
|
|
79
74
|
uploadState.value = {
|
|
80
75
|
type: "error",
|
|
81
76
|
error: "Failed to embed document."
|
|
82
77
|
};
|
|
83
78
|
return;
|
|
84
79
|
}
|
|
80
|
+
await state.addDocument({
|
|
81
|
+
namespace: uploadData.namespace,
|
|
82
|
+
slug: uploadData.slug,
|
|
83
|
+
removable: false,
|
|
84
|
+
tmp: true
|
|
85
|
+
});
|
|
86
|
+
if (controller.signal.aborted) return;
|
|
87
|
+
saveTmpDocumentInLocalStorage({
|
|
88
|
+
namespace: uploadData.namespace,
|
|
89
|
+
slug: uploadData.slug
|
|
90
|
+
});
|
|
85
91
|
uploadState.value = { type: "done" };
|
|
86
92
|
state.uploadedTmpDocumentUrl.value = uploadData.url;
|
|
87
93
|
setTimeout(() => {
|
|
@@ -89,9 +95,10 @@ function useUploadTmpDocument() {
|
|
|
89
95
|
}, SHOW_UPLOAD_SUCCESS_DELAY);
|
|
90
96
|
return uploadData;
|
|
91
97
|
} catch {
|
|
98
|
+
if (controller.signal.aborted) return;
|
|
92
99
|
uploadState.value = {
|
|
93
100
|
type: "error",
|
|
94
|
-
error: "Failed to upload your
|
|
101
|
+
error: "Failed to upload your API description."
|
|
95
102
|
};
|
|
96
103
|
return;
|
|
97
104
|
}
|