feat: add responses package
This commit is contained in:
7
packages/responses/src/Domain/Item/ApiEndpointParam.ts
Normal file
7
packages/responses/src/Domain/Item/ApiEndpointParam.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export enum ApiEndpointParam {
|
||||
LastSyncToken = 'sync_token',
|
||||
PaginationToken = 'cursor_token',
|
||||
SyncDlLimit = 'limit',
|
||||
SyncPayloads = 'items',
|
||||
ApiVersion = 'api',
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { MinimalHttpResponse } from '../Http/MinimalHttpResponses'
|
||||
import { IntegrityPayload } from './IntegrityPayload'
|
||||
|
||||
export type CheckIntegrityResponse = MinimalHttpResponse & {
|
||||
data: {
|
||||
mismatches: IntegrityPayload[]
|
||||
}
|
||||
}
|
||||
11
packages/responses/src/Domain/Item/ConflictParams.ts
Normal file
11
packages/responses/src/Domain/Item/ConflictParams.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ConflictType } from './ConflictType'
|
||||
import { ServerItemResponse } from './ServerItemResponse'
|
||||
|
||||
export type ConflictParams = {
|
||||
type: ConflictType
|
||||
server_item?: ServerItemResponse
|
||||
unsaved_item?: ServerItemResponse
|
||||
|
||||
/** @legacay */
|
||||
item?: ServerItemResponse
|
||||
}
|
||||
9
packages/responses/src/Domain/Item/ConflictType.ts
Normal file
9
packages/responses/src/Domain/Item/ConflictType.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export enum ConflictType {
|
||||
ConflictingData = 'sync_conflict',
|
||||
UuidConflict = 'uuid_conflict',
|
||||
ContentTypeError = 'content_type_error',
|
||||
ContentError = 'content_error',
|
||||
ReadOnlyError = 'readonly_error',
|
||||
UuidError = 'uuid_error',
|
||||
SyncError = 'sync_error',
|
||||
}
|
||||
14
packages/responses/src/Domain/Item/GetSingleItemResponse.ts
Normal file
14
packages/responses/src/Domain/Item/GetSingleItemResponse.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { MinimalHttpResponse } from '../Http/MinimalHttpResponses'
|
||||
import { ServerItemResponse } from './ServerItemResponse'
|
||||
|
||||
export type GetSingleItemResponse = MinimalHttpResponse & {
|
||||
data:
|
||||
| {
|
||||
success: true
|
||||
item: ServerItemResponse
|
||||
}
|
||||
| {
|
||||
success: false
|
||||
message: string
|
||||
}
|
||||
}
|
||||
6
packages/responses/src/Domain/Item/IntegrityPayload.ts
Normal file
6
packages/responses/src/Domain/Item/IntegrityPayload.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { MicrosecondsTimestamp, Uuid } from '@standardnotes/common'
|
||||
|
||||
export type IntegrityPayload = {
|
||||
uuid: Uuid
|
||||
updated_at_timestamp: MicrosecondsTimestamp
|
||||
}
|
||||
14
packages/responses/src/Domain/Item/RawSyncData.ts
Normal file
14
packages/responses/src/Domain/Item/RawSyncData.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ApiEndpointParam } from './ApiEndpointParam'
|
||||
import { ConflictParams } from './ConflictParams'
|
||||
import { ServerItemResponse } from './ServerItemResponse'
|
||||
|
||||
export type RawSyncData = {
|
||||
error?: unknown
|
||||
[ApiEndpointParam.LastSyncToken]?: string
|
||||
[ApiEndpointParam.PaginationToken]?: string
|
||||
retrieved_items?: ServerItemResponse[]
|
||||
saved_items?: ServerItemResponse[]
|
||||
conflicts?: ConflictParams[]
|
||||
unsaved?: ConflictParams[]
|
||||
status?: number
|
||||
}
|
||||
4
packages/responses/src/Domain/Item/RawSyncResponse.ts
Normal file
4
packages/responses/src/Domain/Item/RawSyncResponse.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { HttpResponse } from '../Http/HttpResponse'
|
||||
import { RawSyncData } from './RawSyncData'
|
||||
|
||||
export type RawSyncResponse = HttpResponse & { data: RawSyncData }
|
||||
10
packages/responses/src/Domain/Item/RevisionListEntry.ts
Normal file
10
packages/responses/src/Domain/Item/RevisionListEntry.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { RoleName } from '@standardnotes/common'
|
||||
|
||||
export type RevisionListEntry = {
|
||||
content_type: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
/** The uuid of the revision */
|
||||
uuid: string
|
||||
required_role: RoleName
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { HttpResponse } from '../Http/HttpResponse'
|
||||
import { RevisionListEntry } from './RevisionListEntry'
|
||||
|
||||
export type RevisionListResponse = HttpResponse & { data: RevisionListEntry[] }
|
||||
15
packages/responses/src/Domain/Item/ServerItemResponse.ts
Normal file
15
packages/responses/src/Domain/Item/ServerItemResponse.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface ServerItemResponse {
|
||||
content_type: ContentType
|
||||
content: string | undefined
|
||||
created_at_timestamp: number
|
||||
created_at: Date
|
||||
deleted: boolean
|
||||
duplicate_of?: Uuid
|
||||
enc_item_key: string
|
||||
items_key_id?: string
|
||||
updated_at_timestamp: number
|
||||
updated_at: Date
|
||||
uuid: string
|
||||
}
|
||||
15
packages/responses/src/Domain/Item/SingleRevision.ts
Normal file
15
packages/responses/src/Domain/Item/SingleRevision.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
|
||||
export type SingleRevision = {
|
||||
auth_hash?: string
|
||||
content_type: ContentType
|
||||
content: string
|
||||
created_at: string
|
||||
enc_item_key: string
|
||||
/** The uuid of the item this revision was created with */
|
||||
item_uuid: string
|
||||
items_key_id: string
|
||||
updated_at: string
|
||||
/** The uuid of the revision */
|
||||
uuid: Uuid
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { HttpResponse } from '../Http/HttpResponse'
|
||||
import { SingleRevision } from './SingleRevision'
|
||||
|
||||
export type SingleRevisionResponse = HttpResponse & {
|
||||
data: SingleRevision
|
||||
}
|
||||
Reference in New Issue
Block a user