Use new API
This commit is contained in:
parent
65a42a18bf
commit
570b5f9bfc
5 changed files with 31 additions and 19 deletions
|
|
@ -5,10 +5,7 @@ import type { components, paths } from "./types"; // generated by openapi-typesc
|
|||
import { Logger } from "src/logger";
|
||||
import { Database } from "src/database/database";
|
||||
import { SyncSettings } from "src/database/sync-settings";
|
||||
import {
|
||||
DocumentVersionId,
|
||||
RelativePath,
|
||||
} from "src/database/document-metadata.js";
|
||||
import { VaultUpdateId, RelativePath } from "src/database/document-metadata.js";
|
||||
|
||||
export class SyncServer {
|
||||
private static VAULT_ID = "default";
|
||||
|
|
@ -53,7 +50,7 @@ export class SyncServer {
|
|||
createdDate,
|
||||
}: {
|
||||
relativePath: RelativePath;
|
||||
parentVersionId: DocumentVersionId | undefined;
|
||||
parentVersionId: VaultUpdateId | undefined;
|
||||
contentBytes: Uint8Array;
|
||||
createdDate: Date;
|
||||
}): Promise<components["schemas"]["DocumentVersion"]> {
|
||||
|
|
@ -160,9 +157,9 @@ export class SyncServer {
|
|||
return response.data;
|
||||
}
|
||||
|
||||
public async getAll(): Promise<
|
||||
components["schemas"]["DocumentVersionWithoutContent"][]
|
||||
> {
|
||||
public async getAll(
|
||||
since?: VaultUpdateId
|
||||
): Promise<components["schemas"]["FetchLatestDocumentsResponse"]> {
|
||||
const response = await this.client.GET("/vaults/{vault_id}/documents", {
|
||||
params: {
|
||||
path: {
|
||||
|
|
@ -172,6 +169,9 @@ export class SyncServer {
|
|||
authorization:
|
||||
"Bearer " + this.database.getSettings().token,
|
||||
},
|
||||
query: {
|
||||
since_update_id: since,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,9 @@ export interface paths {
|
|||
};
|
||||
get: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
query?: {
|
||||
since_update_id?: number | null;
|
||||
};
|
||||
header: {
|
||||
authorization: string;
|
||||
};
|
||||
|
|
@ -65,7 +67,7 @@ export interface paths {
|
|||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["DocumentVersionWithoutContent"][];
|
||||
"application/json": components["schemas"]["FetchLatestDocumentsResponse"];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -225,7 +227,7 @@ export interface components {
|
|||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
versionId: number;
|
||||
vaultUpdateId: number;
|
||||
};
|
||||
DocumentVersionWithoutContent: {
|
||||
/** Format: date-time */
|
||||
|
|
@ -236,7 +238,12 @@ export interface components {
|
|||
updatedDate: string;
|
||||
vaultId: string;
|
||||
/** Format: int64 */
|
||||
versionId: number;
|
||||
vaultUpdateId: number;
|
||||
};
|
||||
FetchLatestDocumentsResponse: {
|
||||
/** Format: int64 */
|
||||
lastUpdateId: number;
|
||||
latestDocuments: components["schemas"]["DocumentVersionWithoutContent"][];
|
||||
};
|
||||
PathParams: {
|
||||
vault_id: string;
|
||||
|
|
@ -257,6 +264,10 @@ export interface components {
|
|||
isAuthenticated: boolean;
|
||||
serverVersion: string;
|
||||
};
|
||||
QueryParams: {
|
||||
/** Format: int64 */
|
||||
since_update_id?: number | null;
|
||||
};
|
||||
UpdateDocumentVersion: {
|
||||
contentBase64: string;
|
||||
/** Format: date-time */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue