mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 10:21:15 +01:00
Model and DB refactor (#61)
- [x] Move from `sqlx` to `rusqlite` - [x] Generate TS types from Rust models
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
|
||||
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
|
||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
import { Input } from './core/Input';
|
||||
import { VStack } from './core/Stacks';
|
||||
|
||||
@@ -27,7 +27,7 @@ export function BasicAuth<T extends HttpRequest | GrpcRequest>({ request }: Prop
|
||||
if (request.model === 'http_request') {
|
||||
updateHttpRequest.mutate({
|
||||
id: request.id,
|
||||
update: (r) => ({
|
||||
update: (r: HttpRequest) => ({
|
||||
...r,
|
||||
authentication: { password: r.authentication.password, username },
|
||||
}),
|
||||
@@ -35,7 +35,7 @@ export function BasicAuth<T extends HttpRequest | GrpcRequest>({ request }: Prop
|
||||
} else {
|
||||
updateGrpcRequest.mutate({
|
||||
id: request.id,
|
||||
update: (r) => ({
|
||||
update: (r: GrpcRequest) => ({
|
||||
...r,
|
||||
authentication: { password: r.authentication.password, username },
|
||||
}),
|
||||
@@ -57,7 +57,7 @@ export function BasicAuth<T extends HttpRequest | GrpcRequest>({ request }: Prop
|
||||
if (request.model === 'http_request') {
|
||||
updateHttpRequest.mutate({
|
||||
id: request.id,
|
||||
update: (r) => ({
|
||||
update: (r: HttpRequest) => ({
|
||||
...r,
|
||||
authentication: { username: r.authentication.username, password },
|
||||
}),
|
||||
@@ -65,7 +65,7 @@ export function BasicAuth<T extends HttpRequest | GrpcRequest>({ request }: Prop
|
||||
} else {
|
||||
updateGrpcRequest.mutate({
|
||||
id: request.id,
|
||||
update: (r) => ({
|
||||
update: (r: GrpcRequest) => ({
|
||||
...r,
|
||||
authentication: { username: r.authentication.username, password },
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
|
||||
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
|
||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
import { Input } from './core/Input';
|
||||
import { VStack } from './core/Stacks';
|
||||
|
||||
@@ -27,7 +27,7 @@ export function BearerAuth<T extends HttpRequest | GrpcRequest>({ request }: Pro
|
||||
if (request.model === 'http_request') {
|
||||
updateHttpRequest.mutate({
|
||||
id: request.id ?? null,
|
||||
update: (r) => ({
|
||||
update: (r: HttpRequest) => ({
|
||||
...r,
|
||||
authentication: { token },
|
||||
}),
|
||||
@@ -35,7 +35,7 @@ export function BearerAuth<T extends HttpRequest | GrpcRequest>({ request }: Pro
|
||||
} else {
|
||||
updateGrpcRequest.mutate({
|
||||
id: request.id ?? null,
|
||||
update: (r) => ({
|
||||
update: (r: GrpcRequest) => ({
|
||||
...r,
|
||||
authentication: { token },
|
||||
}),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import mime from 'mime';
|
||||
import { useKeyValue } from '../hooks/useKeyValue';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { Banner } from './core/Banner';
|
||||
import { Button } from './core/Button';
|
||||
import { InlineCode } from './core/InlineCode';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useCookieJars } from '../hooks/useCookieJars';
|
||||
import { useUpdateCookieJar } from '../hooks/useUpdateCookieJar';
|
||||
import type { Cookie } from '../lib/gen/Cookie';
|
||||
import { cookieDomain } from '../lib/models';
|
||||
import { Banner } from './core/Banner';
|
||||
import { IconButton } from './core/IconButton';
|
||||
@@ -37,7 +38,7 @@ export const CookieDialog = function ({ cookieJarId }: Props) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-background-highlight-secondary">
|
||||
{cookieJar?.cookies.map((c) => (
|
||||
{cookieJar?.cookies.map((c: Cookie) => (
|
||||
<tr key={c.domain + c.raw_cookie}>
|
||||
<td className="py-2 select-text cursor-text font-mono font-semibold max-w-0">
|
||||
{cookieDomain(c)}
|
||||
@@ -55,7 +56,7 @@ export const CookieDialog = function ({ cookieJarId }: Props) {
|
||||
onClick={async () => {
|
||||
await updateCookieJar.mutateAsync({
|
||||
...cookieJar,
|
||||
cookies: cookieJar.cookies.filter((c2) => c2 !== c),
|
||||
cookies: cookieJar.cookies.filter((c2: Cookie) => c2 !== c),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useKeyValue } from '../hooks/useKeyValue';
|
||||
import { usePrompt } from '../hooks/usePrompt';
|
||||
import { useUpdateEnvironment } from '../hooks/useUpdateEnvironment';
|
||||
import { useUpdateWorkspace } from '../hooks/useUpdateWorkspace';
|
||||
import type { Environment, Workspace } from '../lib/models';
|
||||
import type { Environment, Workspace } from '@yaakapp/api';
|
||||
import { Button } from './core/Button';
|
||||
import { ContextMenu } from './core/Dropdown';
|
||||
import type {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { save } from '@tauri-apps/plugin-dialog';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import slugify from 'slugify';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { count } from '../lib/pluralize';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { Button } from './core/Button';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import type { Pair, PairEditorProps } from './core/PairEditor';
|
||||
import { PairEditor } from './core/PairEditor';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import type { Pair, PairEditorProps } from './core/PairEditor';
|
||||
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { EditorView } from 'codemirror';
|
||||
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
import { useIntrospectGraphQL } from '../hooks/useIntrospectGraphQL';
|
||||
import { tryFormatJson } from '../lib/formatters';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { Button } from './core/Button';
|
||||
import type { EditorProps } from './core/Editor';
|
||||
import { Editor, formatGraphQL } from './core/Editor';
|
||||
|
||||
@@ -5,7 +5,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { useGrpcEvents } from '../hooks/useGrpcEvents';
|
||||
import { usePinnedGrpcConnection } from '../hooks/usePinnedGrpcConnection';
|
||||
import { useStateWithDeps } from '../hooks/useStateWithDeps';
|
||||
import type { GrpcEvent, GrpcRequest } from '../lib/models';
|
||||
import type { GrpcEvent, GrpcRequest } from '@yaakapp/api';
|
||||
import { isResponseLoading } from '../lib/models';
|
||||
import { Banner } from './core/Banner';
|
||||
import { Button } from './core/Button';
|
||||
|
||||
@@ -6,7 +6,7 @@ import { createGlobalState } from 'react-use';
|
||||
import type { ReflectResponseService } from '../hooks/useGrpc';
|
||||
import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey';
|
||||
import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
|
||||
import type { GrpcMetadataEntry, GrpcRequest } from '../lib/models';
|
||||
import type { GrpcMetadataEntry, GrpcRequest } from '@yaakapp/api';
|
||||
import { AUTH_TYPE_BASIC, AUTH_TYPE_BEARER, AUTH_TYPE_NONE } from '../lib/models';
|
||||
import { BasicAuth } from './BasicAuth';
|
||||
import { BearerAuth } from './BearerAuth';
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useEffect, useMemo, useRef } from 'react';
|
||||
import { useAlert } from '../hooks/useAlert';
|
||||
import type { ReflectResponseService } from '../hooks/useGrpc';
|
||||
import { tryFormatJson } from '../lib/formatters';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { count } from '../lib/pluralize';
|
||||
import { Button } from './core/Button';
|
||||
import type { EditorProps } from './core/Editor';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { connections } from '../lib/data/connections';
|
||||
import { encodings } from '../lib/data/encodings';
|
||||
import { headerNames } from '../lib/data/headerNames';
|
||||
import { mimeTypes } from '../lib/data/mimetypes';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import type { GenericCompletionConfig } from './core/Editor/genericCompletion';
|
||||
import type { PairEditorProps } from './core/PairEditor';
|
||||
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CSSProperties } from 'react';
|
||||
import React from 'react';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { SplitLayout } from './core/SplitLayout';
|
||||
import { RequestPane } from './RequestPane';
|
||||
import { ResponsePane } from './ResponsePane';
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
|
||||
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
|
||||
import { useWorkspaces } from '../hooks/useWorkspaces';
|
||||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
import { Button } from './core/Button';
|
||||
import { InlineCode } from './core/InlineCode';
|
||||
import { Select } from './core/Select';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState } from 'react';
|
||||
import { useOpenWorkspace } from '../hooks/useOpenWorkspace';
|
||||
import { useSettings } from '../hooks/useSettings';
|
||||
import { useUpdateSettings } from '../hooks/useUpdateSettings';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { Button } from './core/Button';
|
||||
import { Checkbox } from './core/Checkbox';
|
||||
import { Icon } from './core/Icon';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { formatDistanceToNowStrict } from 'date-fns';
|
||||
import { useDeleteGrpcConnection } from '../hooks/useDeleteGrpcConnection';
|
||||
import { useDeleteGrpcConnections } from '../hooks/useDeleteGrpcConnections';
|
||||
import type { GrpcConnection } from '../lib/models';
|
||||
import type { GrpcConnection } from '@yaakapp/api';
|
||||
import { count } from '../lib/pluralize';
|
||||
import { Dropdown } from './core/Dropdown';
|
||||
import { Icon } from './core/Icon';
|
||||
|
||||
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
||||
import { useDeleteHttpResponse } from '../hooks/useDeleteHttpResponse';
|
||||
import { useDeleteHttpResponses } from '../hooks/useDeleteHttpResponses';
|
||||
import { useSaveResponse } from '../hooks/useSaveResponse';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { pluralize } from '../lib/pluralize';
|
||||
import { Dropdown } from './core/Dropdown';
|
||||
import { Icon } from './core/Icon';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useRequestUpdateKey } from '../hooks/useRequestUpdateKey';
|
||||
import { useSendAnyHttpRequest } from '../hooks/useSendAnyHttpRequest';
|
||||
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
|
||||
import { tryFormatJson } from '../lib/formatters';
|
||||
import type { HttpHeader, HttpRequest, HttpUrlParameter } from '../lib/models';
|
||||
import type { HttpRequest, HttpRequestHeader, HttpUrlParameter } from '@yaakapp/api';
|
||||
import {
|
||||
AUTH_TYPE_BASIC,
|
||||
AUTH_TYPE_BEARER,
|
||||
@@ -211,7 +211,8 @@ export const RequestPane = memo(function RequestPane({
|
||||
[activeRequestId, updateRequest],
|
||||
);
|
||||
const handleHeadersChange = useCallback(
|
||||
(headers: HttpHeader[]) => updateRequest.mutate({ id: activeRequestId, update: { headers } }),
|
||||
(headers: HttpRequestHeader[]) =>
|
||||
updateRequest.mutate({ id: activeRequestId, update: { headers } }),
|
||||
[activeRequestId, updateRequest],
|
||||
);
|
||||
const handleUrlParametersChange = useCallback(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { KeyValueRow, KeyValueRows } from './core/KeyValueRow';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { open } from '@tauri-apps/plugin-shell';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { IconButton } from './core/IconButton';
|
||||
import { KeyValueRow, KeyValueRows } from './core/KeyValueRow';
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createGlobalState } from 'react-use';
|
||||
import { useContentTypeFromHeaders } from '../hooks/useContentTypeFromHeaders';
|
||||
import { usePinnedHttpResponse } from '../hooks/usePinnedHttpResponse';
|
||||
import { useResponseViewMode } from '../hooks/useResponseViewMode';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { isResponseLoading } from '../lib/models';
|
||||
import { Banner } from './core/Banner';
|
||||
import { CountBadge } from './core/CountBadge';
|
||||
|
||||
@@ -32,7 +32,7 @@ import { useUpdateAnyGrpcRequest } from '../hooks/useUpdateAnyGrpcRequest';
|
||||
import { useUpdateAnyHttpRequest } from '../hooks/useUpdateAnyHttpRequest';
|
||||
import { useWorkspaces } from '../hooks/useWorkspaces';
|
||||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||
import type { Folder, GrpcRequest, HttpRequest, Workspace } from '../lib/models';
|
||||
import type { Folder, GrpcRequest, HttpRequest, Workspace } from '@yaakapp/api';
|
||||
import { isResponseLoading } from '../lib/models';
|
||||
import type { DropdownItem } from './core/Dropdown';
|
||||
import { ContextMenu } from './core/Dropdown';
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { EditorView } from 'codemirror';
|
||||
import type { FormEvent, ReactNode } from 'react';
|
||||
import { memo, useRef, useState } from 'react';
|
||||
import { useHotKey } from '../hooks/useHotKey';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import type { IconProps } from './core/Icon';
|
||||
import { IconButton } from './core/IconButton';
|
||||
import type { InputProps } from './core/Input';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { PairOrBulkEditor } from './core/PairOrBulkEditor';
|
||||
|
||||
type Props = {
|
||||
|
||||
@@ -33,7 +33,7 @@ import {
|
||||
import { tags as t } from '@lezer/highlight';
|
||||
import { graphql, graphqlLanguageSupport } from 'cm6-graphql';
|
||||
import { EditorView } from 'codemirror';
|
||||
import type { Environment, Workspace } from '../../../lib/models';
|
||||
import type { Environment, Workspace } from '@yaakapp/api';
|
||||
import type { EditorProps } from './index';
|
||||
import { pairs } from './pairs/extension';
|
||||
import { text } from './text/extension';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { LanguageSupport } from '@codemirror/language';
|
||||
import { LRLanguage } from '@codemirror/language';
|
||||
import { parseMixed } from '@lezer/common';
|
||||
import type { Environment, Workspace } from '../../../../lib/models';
|
||||
import type { Environment, Workspace } from '@yaakapp/api';
|
||||
import type { GenericCompletionConfig } from '../genericCompletion';
|
||||
import { genericCompletion } from '../genericCompletion';
|
||||
import { textLanguageName } from '../text/extension';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import classNames from 'classnames';
|
||||
import type { GrpcRequest, HttpRequest } from '../../lib/models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
request: HttpRequest | GrpcRequest;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import classNames from 'classnames';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: Pick<HttpResponse, 'status' | 'statusReason' | 'error'>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
import React from 'react';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: HttpResponse;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useSaveResponse } from '../../hooks/useSaveResponse';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { getContentTypeHeader } from '../../lib/models';
|
||||
import { Banner } from '../core/Banner';
|
||||
import { Button } from '../core/Button';
|
||||
|
||||
@@ -2,7 +2,7 @@ import classNames from 'classnames';
|
||||
import Papa from 'papaparse';
|
||||
import { useMemo } from 'react';
|
||||
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: HttpResponse;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
import classNames from 'classnames';
|
||||
import { useState } from 'react';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: HttpResponse;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import classNames from 'classnames';
|
||||
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { JsonAttributeTree } from '../core/JsonAttributeTree';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PDFDocumentProxy } from 'pdfjs-dist';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { Document, Page } from 'react-pdf';
|
||||
import { useDebouncedState } from '../../hooks/useDebouncedState';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import './PdfViewer.css';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useResponseBodyText } from '../../hooks/useResponseBodyText';
|
||||
import { useSaveResponse } from '../../hooks/useSaveResponse';
|
||||
import { useToggle } from '../../hooks/useToggle';
|
||||
import { tryFormatJson, tryFormatXml } from '../../lib/formatters';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { CopyButton } from '../CopyButton';
|
||||
import { Banner } from '../core/Banner';
|
||||
import { Button } from '../core/Button';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { convertFileSrc } from '@tauri-apps/api/core';
|
||||
import React from 'react';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: HttpResponse;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useResponseBodyText } from '../../hooks/useResponseBodyText';
|
||||
import type { HttpResponse } from '../../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
interface Props {
|
||||
response: HttpResponse;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { Environment } from '../lib/models';
|
||||
import type { Environment } from '@yaakapp/api';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useEnvironments } from './useEnvironments';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GrpcRequest, HttpRequest } from '../lib/models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
import { useActiveRequestId } from './useActiveRequestId';
|
||||
import { useRequests } from './useRequests';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import { useWorkspaces } from './useWorkspaces';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { Environment } from '../lib/models';
|
||||
import type { Environment } from '@yaakapp/api';
|
||||
import { QUERY_ENVIRONMENT_ID } from './useActiveEnvironmentId';
|
||||
import { useActiveRequestId } from './useActiveRequestId';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMemo } from 'react';
|
||||
import type { HttpHeader } from '../lib/models';
|
||||
import type { HttpResponseHeader } from '@yaakapp/api';
|
||||
|
||||
export function useContentTypeFromHeaders(headers: HttpHeader[] | null): string | null {
|
||||
export function useContentTypeFromHeaders(headers: HttpResponseHeader[] | null): string | null {
|
||||
return useMemo(
|
||||
() => headers?.find((h) => h.name.toLowerCase() === 'content-type')?.value ?? null,
|
||||
[headers],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Environment } from '../lib/models';
|
||||
import type { Environment } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Folder } from '../lib/models';
|
||||
import type { Folder } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveRequest } from './useActiveRequest';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useActiveRequest } from './useActiveRequest';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useActiveRequest } from './useActiveRequest';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
import { usePrompt } from './usePrompt';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { getGrpcRequest } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useConfirm } from './useConfirm';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import { fallbackRequestName } from '../lib/fallbackRequestName';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { getHttpRequest } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useConfirm } from './useConfirm';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Environment, Workspace } from '../lib/models';
|
||||
import type { Environment, Workspace } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useConfirm } from './useConfirm';
|
||||
import { environmentsQueryKey } from './useEnvironments';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Folder } from '../lib/models';
|
||||
import type { Folder } from '@yaakapp/api';
|
||||
import { getFolder } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useConfirm } from './useConfirm';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { GrpcConnection } from '../lib/models';
|
||||
import type { GrpcConnection } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { grpcConnectionsQueryKey } from './useGrpcConnections';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { httpResponsesQueryKey } from './useHttpResponses';
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import { useAppRoutes } from './useAppRoutes';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import { setKeyValue } from '../lib/keyValueStore';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { Environment } from '../lib/models';
|
||||
import type { Environment } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { Folder } from '../lib/models';
|
||||
import type { Folder } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation, useQuery } from '@tanstack/react-query';
|
||||
import { emit } from '@tauri-apps/api/event';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
||||
import type { GrpcConnection, GrpcRequest } from '../lib/models';
|
||||
import type { GrpcConnection, GrpcRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
import { useDebouncedValue } from './useDebouncedValue';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { GrpcConnection } from '../lib/models';
|
||||
import type { GrpcConnection } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
export function grpcConnectionsQueryKey({ requestId }: { requestId: string }) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { GrpcEvent } from '../lib/models';
|
||||
import type { GrpcEvent } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
export function grpcEventsQueryKey({ connectionId }: { connectionId: string }) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { useGrpcRequests } from './useGrpcRequests';
|
||||
|
||||
export function useGrpcRequest(id: string | null): GrpcRequest | null {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { useHttpRequests } from './useHttpRequests';
|
||||
|
||||
export function useHttpRequest(id: string | null): HttpRequest | null {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
export function httpResponsesQueryKey({ requestId }: { requestId: string }) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FormattedError } from '../components/core/FormattedError';
|
||||
import { VStack } from '../components/core/Stacks';
|
||||
import { useDialog } from '../components/DialogContext';
|
||||
import { ImportDataDialog } from '../components/ImportDataDialog';
|
||||
import type { Environment, Folder, GrpcRequest, HttpRequest, Workspace } from '../lib/models';
|
||||
import type { Environment, Folder, GrpcRequest, HttpRequest, Workspace } from '@yaakapp/api';
|
||||
import { count } from '../lib/pluralize';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { IntrospectionQuery } from 'graphql';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { buildClientSchema, getIntrospectionQuery } from '../components/core/Editor';
|
||||
import { minPromiseMillis } from '../lib/minPromiseMillis';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { getResponseBodyText } from '../lib/responseBody';
|
||||
import { sendEphemeralRequest } from '../lib/sendEphemeralRequest';
|
||||
import { useActiveEnvironmentId } from './useActiveEnvironmentId';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GrpcConnection } from '../lib/models';
|
||||
import type { GrpcConnection } from '@yaakapp/api';
|
||||
import { useGrpcConnections } from './useGrpcConnections';
|
||||
|
||||
export function useLatestGrpcConnection(requestId: string | null): GrpcConnection | null {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { useHttpResponses } from './useHttpResponses';
|
||||
|
||||
export function useLatestHttpResponse(requestId: string | null): HttpResponse | null {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GrpcConnection, GrpcRequest } from '../lib/models';
|
||||
import type { GrpcConnection, GrpcRequest } from '@yaakapp/api';
|
||||
import { useGrpcConnections } from './useGrpcConnections';
|
||||
import { useKeyValue } from './useKeyValue';
|
||||
import { useLatestGrpcConnection } from './useLatestGrpcConnection';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpRequest, HttpResponse } from '../lib/models';
|
||||
import type { HttpRequest, HttpResponse } from '@yaakapp/api';
|
||||
import { useHttpResponses } from './useHttpResponses';
|
||||
import { useKeyValue } from './useKeyValue';
|
||||
import { useLatestHttpResponse } from './useLatestHttpResponse';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { usePrompt } from './usePrompt';
|
||||
import { useRequests } from './useRequests';
|
||||
@@ -33,9 +34,9 @@ export function useRenameRequest(requestId: string | null) {
|
||||
defaultValue: request.name,
|
||||
});
|
||||
if (request.model === 'http_request') {
|
||||
updateHttpRequest.mutate({ id: request.id, update: (r) => ({ ...r, name }) });
|
||||
updateHttpRequest.mutate({ id: request.id, update: (r: HttpRequest) => ({ ...r, name }) });
|
||||
} else {
|
||||
updateGrpcRequest.mutate({ id: request.id, update: (r) => ({ ...r, name }) });
|
||||
updateGrpcRequest.mutate({ id: request.id, update: (r: GrpcRequest) => ({ ...r, name }) });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { getResponseBodyBlob } from '../lib/responseBody';
|
||||
|
||||
export function useResponseBodyBlob(response: HttpResponse) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { getResponseBodyText } from '../lib/responseBody';
|
||||
|
||||
export function useResponseBodyText(response: HttpResponse) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import mime from 'mime';
|
||||
import slugify from 'slugify';
|
||||
import { InlineCode } from '../components/core/InlineCode';
|
||||
import { useToast } from '../components/ToastContext';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { getContentTypeHeader } from '../lib/models';
|
||||
import { getHttpRequest } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMutation } from '@tanstack/react-query';
|
||||
import { save } from '@tauri-apps/plugin-dialog';
|
||||
import slugify from 'slugify';
|
||||
import { trackEvent } from '../lib/analytics';
|
||||
import type { HttpResponse } from '../lib/models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveCookieJar } from './useActiveCookieJar';
|
||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { Settings } from '../lib/models';
|
||||
import type { Settings } from '../lib/gen/Settings';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
export function settingsQueryKey() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { Folder } from '../lib/models';
|
||||
import type { Folder } from '@yaakapp/api';
|
||||
import { getFolder } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { foldersQueryKey } from './useFolders';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { GrpcRequest } from '../lib/models';
|
||||
import type { GrpcRequest } from '@yaakapp/api';
|
||||
import { getGrpcRequest } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { grpcRequestsQueryKey } from './useGrpcRequests';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { HttpRequest } from '../lib/models';
|
||||
import type { HttpRequest } from '@yaakapp/api';
|
||||
import { getHttpRequest } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { httpRequestsQueryKey } from './useHttpRequests';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { Environment } from '../lib/models';
|
||||
import type { Environment } from '@yaakapp/api';
|
||||
import { getEnvironment } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { environmentsQueryKey } from './useEnvironments';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { getWorkspace } from '../lib/store';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
import { workspacesQueryKey } from './useWorkspaces';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { Workspace } from '../lib/models';
|
||||
import type { Workspace } from '@yaakapp/api';
|
||||
import { invokeCmd } from '../lib/tauri';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/ban-types
|
||||
@@ -12,7 +12,9 @@ export function useWorkspaces() {
|
||||
useQuery({
|
||||
queryKey: workspacesQueryKey(),
|
||||
queryFn: async () => {
|
||||
console.log('GETTING WORKSPACES');
|
||||
const workspaces = await invokeCmd('cmd_list_workspaces');
|
||||
console.log('GOT WORKSPACES');
|
||||
return workspaces as Workspace[];
|
||||
},
|
||||
}).data ?? []
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GrpcRequest, HttpRequest } from './models';
|
||||
import type { GrpcRequest, HttpRequest } from '@yaakapp/api';
|
||||
|
||||
export function fallbackRequestName(r: HttpRequest | GrpcRequest | null): string {
|
||||
if (r == null) return '';
|
||||
|
||||
5
src-web/lib/gen/Cookie.ts
Normal file
5
src-web/lib/gen/Cookie.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { CookieDomain } from "./CookieDomain";
|
||||
import type { CookieExpires } from "./CookieExpires";
|
||||
|
||||
export type Cookie = { raw_cookie: string, domain: CookieDomain, expires: CookieExpires, path: [string, boolean], };
|
||||
3
src-web/lib/gen/CookieDomain.ts
Normal file
3
src-web/lib/gen/CookieDomain.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type CookieDomain = { "HostOnly": string } | { "Suffix": string } | "NotPresent" | "Empty";
|
||||
3
src-web/lib/gen/CookieExpires.ts
Normal file
3
src-web/lib/gen/CookieExpires.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type CookieExpires = { "AtUtc": string } | "SessionEnd";
|
||||
4
src-web/lib/gen/CookieJar.ts
Normal file
4
src-web/lib/gen/CookieJar.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { Cookie } from "./Cookie";
|
||||
|
||||
export type CookieJar = { id: string, model: "cookie_jar", createdAt: string, updatedAt: string, workspaceId: string, name: string, cookies: Array<Cookie>, };
|
||||
3
src-web/lib/gen/Settings.ts
Normal file
3
src-web/lib/gen/Settings.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type Settings = { id: string, model: "settings", createdAt: string, updatedAt: string, theme: string, appearance: string, themeDark: string, themeLight: string, updateChannel: string, interfaceFontSize: number, interfaceScale: number, editorFontSize: number, editorSoftWrap: boolean, openWorkspaceNewWindow: boolean | null, };
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { KeyValue } from './models';
|
||||
import type { KeyValue } from '@yaakapp/api';
|
||||
import { invokeCmd } from './tauri';
|
||||
|
||||
export async function setKeyValue<T>({
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import type {
|
||||
BaseModel,
|
||||
Workspace,
|
||||
HttpResponse,
|
||||
HttpRequest,
|
||||
HttpHeader,
|
||||
Folder,
|
||||
GrpcRequest,
|
||||
GrpcEvent,
|
||||
GrpcConnection,
|
||||
Environment,
|
||||
Folder,
|
||||
GrpcConnection,
|
||||
GrpcEvent,
|
||||
GrpcRequest,
|
||||
HttpRequest,
|
||||
HttpResponse,
|
||||
KeyValue,
|
||||
Workspace,
|
||||
HttpResponseHeader,
|
||||
} from '@yaakapp/api';
|
||||
import type { Cookie } from './gen/Cookie';
|
||||
import type { CookieJar } from './gen/CookieJar';
|
||||
import type { Settings } from './gen/Settings';
|
||||
|
||||
export * from '@yaakapp/api';
|
||||
export type { CookieJar, Cookie, Settings };
|
||||
|
||||
export const BODY_TYPE_NONE = null;
|
||||
export const BODY_TYPE_GRAPHQL = 'graphql';
|
||||
@@ -39,34 +42,6 @@ export type Model =
|
||||
| Environment
|
||||
| CookieJar;
|
||||
|
||||
export interface Settings extends BaseModel {
|
||||
readonly model: 'settings';
|
||||
theme: string;
|
||||
appearance: string;
|
||||
themeLight: string;
|
||||
themeDark: string;
|
||||
updateChannel: string;
|
||||
interfaceFontSize: number;
|
||||
interfaceScale: number;
|
||||
editorFontSize: number;
|
||||
editorSoftWrap: boolean;
|
||||
openWorkspaceNewWindow: boolean | null;
|
||||
}
|
||||
|
||||
export interface CookieJar extends BaseModel {
|
||||
readonly model: 'cookie_jar';
|
||||
workspaceId: string;
|
||||
name: string;
|
||||
cookies: Cookie[];
|
||||
}
|
||||
|
||||
export interface Cookie {
|
||||
raw_cookie: string;
|
||||
domain: { HostOnly: string } | { Suffix: string } | 'NotPresent' | 'Empty';
|
||||
expires: { AtUtc: string } | 'SessionEnd';
|
||||
path: [string, boolean];
|
||||
}
|
||||
|
||||
export function cookieDomain(cookie: Cookie): string {
|
||||
if (cookie.domain === 'NotPresent' || cookie.domain === 'Empty') {
|
||||
return 'n/a';
|
||||
@@ -80,13 +55,6 @@ export function cookieDomain(cookie: Cookie): string {
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
export interface KeyValue extends Omit<BaseModel, 'id'> {
|
||||
readonly model: 'key_value';
|
||||
readonly key: string;
|
||||
readonly namespace: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export function isResponseLoading(response: HttpResponse | GrpcConnection): boolean {
|
||||
return response.elapsed === 0;
|
||||
}
|
||||
@@ -101,6 +69,6 @@ export function modelsEq(a: Model, b: Model) {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function getContentTypeHeader(headers: HttpHeader[]): string | null {
|
||||
export function getContentTypeHeader(headers: HttpResponseHeader[]): string | null {
|
||||
return headers.find((h) => h.name.toLowerCase() === 'content-type')?.value ?? null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { readFile, readTextFile } from '@tauri-apps/plugin-fs';
|
||||
import type { HttpResponse } from './models';
|
||||
import type { HttpResponse } from '@yaakapp/api';
|
||||
|
||||
export async function getResponseBodyText(response: HttpResponse): Promise<string | null> {
|
||||
if (response.bodyPath) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { HttpRequest, HttpResponse } from './models';
|
||||
import type { HttpRequest, HttpResponse } from '@yaakapp/api';
|
||||
import { invokeCmd } from './tauri';
|
||||
|
||||
export async function sendEphemeralRequest(
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import type {
|
||||
CookieJar,
|
||||
Environment,
|
||||
Folder,
|
||||
GrpcRequest,
|
||||
HttpRequest,
|
||||
Settings,
|
||||
Workspace,
|
||||
} from './models';
|
||||
import type { Environment, Folder, GrpcRequest, HttpRequest, Workspace } from '@yaakapp/api';
|
||||
import type { CookieJar } from './gen/CookieJar';
|
||||
import type { Settings } from './gen/Settings';
|
||||
import { invokeCmd } from './tauri';
|
||||
|
||||
export async function getSettings(): Promise<Settings> {
|
||||
|
||||
1
src-web/modules.d.ts
vendored
Normal file
1
src-web/modules.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module 'format-graphql';
|
||||
Reference in New Issue
Block a user