From 94503d28a2430f4d37ea521b72d05eb95eaaea15 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Fri, 22 Apr 2022 19:38:26 +0800 Subject: [PATCH] update ci + check in ts bindings --- .github/workflows/ci.yaml | 34 ++++++++++++++++---------- core/.gitignore | 4 +-- core/bindings/Client.ts | 3 +++ core/bindings/ClientCommand.ts | 2 ++ core/bindings/ClientQuery.ts | 2 ++ core/bindings/ClientState.ts | 3 +++ core/bindings/CoreEvent.ts | 4 +++ core/bindings/CoreResource.ts | 5 ++++ core/bindings/CoreResponse.ts | 7 ++++++ core/bindings/DirectoryWithContents.ts | 3 +++ core/bindings/EncryptionAlgorithm.ts | 2 ++ core/bindings/File.ts | 5 ++++ core/bindings/FileKind.ts | 2 ++ core/bindings/FilePath.ts | 2 ++ core/bindings/JobReport.ts | 3 +++ core/bindings/JobStatus.ts | 2 ++ core/bindings/LibraryState.ts | 2 ++ core/bindings/LocationResource.ts | 2 ++ core/bindings/Platform.ts | 2 ++ core/bindings/Volume.ts | 2 ++ core/index.ts | 18 ++++++++++++++ 21 files changed, 93 insertions(+), 16 deletions(-) create mode 100644 core/bindings/Client.ts create mode 100644 core/bindings/ClientCommand.ts create mode 100644 core/bindings/ClientQuery.ts create mode 100644 core/bindings/ClientState.ts create mode 100644 core/bindings/CoreEvent.ts create mode 100644 core/bindings/CoreResource.ts create mode 100644 core/bindings/CoreResponse.ts create mode 100644 core/bindings/DirectoryWithContents.ts create mode 100644 core/bindings/EncryptionAlgorithm.ts create mode 100644 core/bindings/File.ts create mode 100644 core/bindings/FileKind.ts create mode 100644 core/bindings/FilePath.ts create mode 100644 core/bindings/JobReport.ts create mode 100644 core/bindings/JobStatus.ts create mode 100644 core/bindings/LibraryState.ts create mode 100644 core/bindings/LocationResource.ts create mode 100644 core/bindings/Platform.ts create mode 100644 core/bindings/Volume.ts create mode 100644 core/index.ts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7e6a2dbe1..1eb25943f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,12 +42,8 @@ jobs: run: pnpm -r exec tsc build-js: - name: Build apps/${{ matrix.app }} JS + name: Build JS runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - app: [desktop, web] steps: - name: Checkout repository uses: actions/checkout@v2 @@ -73,16 +69,18 @@ jobs: - name: Install dependencies run: pnpm i --frozen-lockfile - - name: Build - run: pnpm --filter @sd/${{ matrix.app }} build + - name: Build Desktop + run: pnpm desktop build + + - name: Build Web + run: pnpm web build - build-core-pkgs: - name: Build core/${{ matrix.package }} + build-core: + name: Build core (${{ matrix.platform }}) strategy: fail-fast: false matrix: platform: [macos-latest, ubuntu-latest, windows-latest] - package: [derive, prisma] runs-on: ${{ matrix.platform }} steps: - name: Checkout repository @@ -98,7 +96,17 @@ jobs: - name: Cache Rust Dependencies uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c + + - name: Build prisma-cli + run: cargo build + + - name: Build core-derive + run: cargo build -p core-derive --release - - name: Build core/${{ matrix.package }} - working-directory: core/${{matrix.package}} - run: cargo build --release \ No newline at end of file + - name: Generate Primsa client + working-directory: core + run: cargo prisma generate + + - name: Build core + run: cargo build -p core --release + \ No newline at end of file diff --git a/core/.gitignore b/core/.gitignore index ba84721a2..7a75bd931 100644 --- a/core/.gitignore +++ b/core/.gitignore @@ -1,6 +1,4 @@ /target /types *.db* -/bindings -/src/prisma.rs -index.ts \ No newline at end of file +/src/prisma.rs \ No newline at end of file diff --git a/core/bindings/Client.ts b/core/bindings/Client.ts new file mode 100644 index 000000000..2c0d9f32f --- /dev/null +++ b/core/bindings/Client.ts @@ -0,0 +1,3 @@ +import type { Platform } from "./Platform"; + +export interface Client { uuid: string, name: string, platform: Platform, tcp_address: string, last_seen: string, last_synchronized: string, } \ No newline at end of file diff --git a/core/bindings/ClientCommand.ts b/core/bindings/ClientCommand.ts new file mode 100644 index 000000000..06c115721 --- /dev/null +++ b/core/bindings/ClientCommand.ts @@ -0,0 +1,2 @@ + +export type ClientCommand = { key: "FileRead", params: { id: number, } } | { key: "FileDelete", params: { id: number, } } | { key: "LibDelete", params: { id: number, } } | { key: "TagCreate", params: { name: string, color: string, } } | { key: "TagUpdate", params: { name: string, color: string, } } | { key: "TagAssign", params: { file_id: number, tag_id: number, } } | { key: "TagDelete", params: { id: number, } } | { key: "LocCreate", params: { path: string, } } | { key: "LocUpdate", params: { id: number, name: string | null, } } | { key: "LocDelete", params: { id: number, } } | { key: "SysVolumeUnmount", params: { id: number, } } | { key: "GenerateThumbsForLocation", params: { id: number, path: string, } } | { key: "PurgeDatabase" }; \ No newline at end of file diff --git a/core/bindings/ClientQuery.ts b/core/bindings/ClientQuery.ts new file mode 100644 index 000000000..e8cd74cf3 --- /dev/null +++ b/core/bindings/ClientQuery.ts @@ -0,0 +1,2 @@ + +export type ClientQuery = { key: "ClientGetState" } | { key: "SysGetVolumes" } | { key: "LibGetTags" } | { key: "JobGetRunning" } | { key: "JobGetHistory" } | { key: "SysGetLocations" } | { key: "SysGetLocation", params: { id: number, } } | { key: "LibGetExplorerDir", params: { location_id: number, path: string, limit: number, } }; \ No newline at end of file diff --git a/core/bindings/ClientState.ts b/core/bindings/ClientState.ts new file mode 100644 index 000000000..34d84b404 --- /dev/null +++ b/core/bindings/ClientState.ts @@ -0,0 +1,3 @@ +import type { LibraryState } from "./LibraryState"; + +export interface ClientState { client_uuid: string, client_id: number, client_name: string, data_path: string, tcp_port: number, libraries: Array, current_library_uuid: string, } \ No newline at end of file diff --git a/core/bindings/CoreEvent.ts b/core/bindings/CoreEvent.ts new file mode 100644 index 000000000..043bfa562 --- /dev/null +++ b/core/bindings/CoreEvent.ts @@ -0,0 +1,4 @@ +import type { ClientQuery } from "./ClientQuery"; +import type { CoreResource } from "./CoreResource"; + +export type CoreEvent = { key: "InvalidateQuery", data: ClientQuery } | { key: "InvalidateQueryDebounced", data: ClientQuery } | { key: "InvalidateResource", data: CoreResource } | { key: "NewThumbnail", data: { cas_id: string, } } | { key: "Log", data: { message: string, } } | { key: "DatabaseDisconnected", data: { reason: string | null, } }; \ No newline at end of file diff --git a/core/bindings/CoreResource.ts b/core/bindings/CoreResource.ts new file mode 100644 index 000000000..3c2f70c91 --- /dev/null +++ b/core/bindings/CoreResource.ts @@ -0,0 +1,5 @@ +import type { File } from "./File"; +import type { JobReport } from "./JobReport"; +import type { LocationResource } from "./LocationResource"; + +export type CoreResource = "Client" | "Library" | { Location: LocationResource } | { File: File } | { Job: JobReport } | "Tag"; \ No newline at end of file diff --git a/core/bindings/CoreResponse.ts b/core/bindings/CoreResponse.ts new file mode 100644 index 000000000..60caf34db --- /dev/null +++ b/core/bindings/CoreResponse.ts @@ -0,0 +1,7 @@ +import type { ClientState } from "./ClientState"; +import type { DirectoryWithContents } from "./DirectoryWithContents"; +import type { JobReport } from "./JobReport"; +import type { LocationResource } from "./LocationResource"; +import type { Volume } from "./Volume"; + +export type CoreResponse = { key: "Success", data: null } | { key: "SysGetVolumes", data: Array } | { key: "SysGetLocation", data: LocationResource } | { key: "SysGetLocations", data: Array } | { key: "LibGetExplorerDir", data: DirectoryWithContents } | { key: "ClientGetState", data: ClientState } | { key: "LocCreate", data: LocationResource } | { key: "JobGetRunning", data: Array } | { key: "JobGetHistory", data: Array }; \ No newline at end of file diff --git a/core/bindings/DirectoryWithContents.ts b/core/bindings/DirectoryWithContents.ts new file mode 100644 index 000000000..89c0fb64f --- /dev/null +++ b/core/bindings/DirectoryWithContents.ts @@ -0,0 +1,3 @@ +import type { FilePath } from "./FilePath"; + +export interface DirectoryWithContents { directory: FilePath, contents: Array, } \ No newline at end of file diff --git a/core/bindings/EncryptionAlgorithm.ts b/core/bindings/EncryptionAlgorithm.ts new file mode 100644 index 000000000..d5b7d9889 --- /dev/null +++ b/core/bindings/EncryptionAlgorithm.ts @@ -0,0 +1,2 @@ + +export type EncryptionAlgorithm = "None" | "AES128" | "AES192" | "AES256"; \ No newline at end of file diff --git a/core/bindings/File.ts b/core/bindings/File.ts new file mode 100644 index 000000000..81017797f --- /dev/null +++ b/core/bindings/File.ts @@ -0,0 +1,5 @@ +import type { EncryptionAlgorithm } from "./EncryptionAlgorithm"; +import type { FileKind } from "./FileKind"; +import type { FilePath } from "./FilePath"; + +export interface File { id: number, cas_id: string, integrity_checksum: string | null, size_in_bytes: string, kind: FileKind, hidden: boolean, favorite: boolean, important: boolean, has_thumbnail: boolean, has_thumbstrip: boolean, has_video_preview: boolean, encryption: EncryptionAlgorithm, ipfs_id: string | null, comment: string | null, date_created: string, date_modified: string, date_indexed: string, paths: Array, } \ No newline at end of file diff --git a/core/bindings/FileKind.ts b/core/bindings/FileKind.ts new file mode 100644 index 000000000..1e0ec7b6c --- /dev/null +++ b/core/bindings/FileKind.ts @@ -0,0 +1,2 @@ + +export type FileKind = "Unknown" | "Directory" | "Package" | "Archive" | "Image" | "Video" | "Audio" | "Plaintext" | "Alias"; \ No newline at end of file diff --git a/core/bindings/FilePath.ts b/core/bindings/FilePath.ts new file mode 100644 index 000000000..33626e50a --- /dev/null +++ b/core/bindings/FilePath.ts @@ -0,0 +1,2 @@ + +export interface FilePath { id: number, is_dir: boolean, location_id: number, materialized_path: string, name: string, extension: string | null, file_id: number | null, parent_id: number | null, temp_cas_id: string | null, has_local_thumbnail: boolean, date_created: string, date_modified: string, date_indexed: string, permissions: string | null, } \ No newline at end of file diff --git a/core/bindings/JobReport.ts b/core/bindings/JobReport.ts new file mode 100644 index 000000000..a2adc7462 --- /dev/null +++ b/core/bindings/JobReport.ts @@ -0,0 +1,3 @@ +import type { JobStatus } from "./JobStatus"; + +export interface JobReport { id: string, date_created: string, date_modified: string, status: JobStatus, task_count: number, completed_task_count: number, message: string, seconds_elapsed: string, } \ No newline at end of file diff --git a/core/bindings/JobStatus.ts b/core/bindings/JobStatus.ts new file mode 100644 index 000000000..8fc11c5dc --- /dev/null +++ b/core/bindings/JobStatus.ts @@ -0,0 +1,2 @@ + +export type JobStatus = "Queued" | "Running" | "Completed" | "Canceled" | "Failed"; \ No newline at end of file diff --git a/core/bindings/LibraryState.ts b/core/bindings/LibraryState.ts new file mode 100644 index 000000000..3ec210308 --- /dev/null +++ b/core/bindings/LibraryState.ts @@ -0,0 +1,2 @@ + +export interface LibraryState { library_uuid: string, library_path: string, offline: boolean, } \ No newline at end of file diff --git a/core/bindings/LocationResource.ts b/core/bindings/LocationResource.ts new file mode 100644 index 000000000..70bd1e15a --- /dev/null +++ b/core/bindings/LocationResource.ts @@ -0,0 +1,2 @@ + +export interface LocationResource { id: number, name: string | null, path: string | null, total_capacity: number | null, available_capacity: number | null, is_removable: boolean | null, is_online: boolean, date_created: string, } \ No newline at end of file diff --git a/core/bindings/Platform.ts b/core/bindings/Platform.ts new file mode 100644 index 000000000..a25022b64 --- /dev/null +++ b/core/bindings/Platform.ts @@ -0,0 +1,2 @@ + +export type Platform = "Unknown" | "Windows" | "MacOS" | "Linux" | "IOS" | "Android"; \ No newline at end of file diff --git a/core/bindings/Volume.ts b/core/bindings/Volume.ts new file mode 100644 index 000000000..4b59fefd3 --- /dev/null +++ b/core/bindings/Volume.ts @@ -0,0 +1,2 @@ + +export interface Volume { name: string, mount_point: string, total_capacity: bigint, available_capacity: bigint, is_removable: boolean, disk_type: string | null, file_system: string | null, is_root_filesystem: boolean, } \ No newline at end of file diff --git a/core/index.ts b/core/index.ts new file mode 100644 index 000000000..4e5c3047d --- /dev/null +++ b/core/index.ts @@ -0,0 +1,18 @@ +export * from './bindings/Client'; +export * from './bindings/ClientCommand'; +export * from './bindings/ClientQuery'; +export * from './bindings/ClientState'; +export * from './bindings/CoreEvent'; +export * from './bindings/CoreResource'; +export * from './bindings/CoreResponse'; +export * from './bindings/DirectoryWithContents'; +export * from './bindings/EncryptionAlgorithm'; +export * from './bindings/File'; +export * from './bindings/FileKind'; +export * from './bindings/FilePath'; +export * from './bindings/JobReport'; +export * from './bindings/JobStatus'; +export * from './bindings/LibraryState'; +export * from './bindings/LocationResource'; +export * from './bindings/Platform'; +export * from './bindings/Volume';