mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
new enum library, re-codegen, GetTaskQueue()
This commit is contained in:
1 parent
2c56624e45
commit
0c623b58ff
27 files changed
+689
-169
No files matched your search
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "\n SELECT\n id,\n task_status,\n task_type,\n model_type,\n provider,\n provider_job_id,\n frontend_caller,\n frontend_subscriber_id,\n frontend_subscriber_payload,\n created_at as \"created_at: DateTime<Utc>\",\n updated_at as \"updated_at: DateTime<Utc>\",\n completed_at as \"completed_at: DateTime<Utc>\"\n FROM tasks\n WHERE is_dismissed_by_user != 0\n ",
|
||||
"query": "\n SELECT\n id,\n task_status,\n task_type,\n model_type,\n provider,\n provider_job_id,\n frontend_caller,\n frontend_subscriber_id,\n frontend_subscriber_payload,\n created_at as \"created_at: DateTime<Utc>\",\n updated_at as \"updated_at: DateTime<Utc>\",\n completed_at as \"completed_at: DateTime<Utc>\"\n FROM tasks\n WHERE is_dismissed_by_user == 0\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -82,5 +82,5 @@
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "c43d7cf8ccc65ea193ff927265a185df46342cdeba2670d6cb0afedf342881d0"
|
||||
"hash": "a142dc3fdf5b6e741c268d8f2e9996a28c214f5835681297d58a9431da8de939"
|
||||
}
|
||||
@@ -47,7 +47,7 @@ pub async fn list_tasks_for_frontend(
|
||||
updated_at as "updated_at: DateTime<Utc>",
|
||||
completed_at as "completed_at: DateTime<Utc>"
|
||||
FROM tasks
|
||||
WHERE is_dismissed_by_user != 0
|
||||
WHERE is_dismissed_by_user == 0
|
||||
"#);
|
||||
|
||||
let result = query.fetch_all(db.get_pool())
|
||||
|
||||
@@ -156,6 +156,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../../libs/api"
|
||||
},
|
||||
{
|
||||
"path": "../../libs/api-enums"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"extends": [
|
||||
"../../.eslintrc.json"
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!**/*"
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx",
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.ts",
|
||||
"*.tsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.js",
|
||||
"*.jsx"
|
||||
],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*.json"
|
||||
],
|
||||
"parser": "jsonc-eslint-parser",
|
||||
"rules": {
|
||||
"@nx/dependency-checks": [
|
||||
"error",
|
||||
{
|
||||
"ignoredFiles": [
|
||||
"{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}",
|
||||
"{projectRoot}/vite.config.{js,ts,mjs,mts}"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# api-enums
|
||||
|
||||
This library was generated with [Nx](https://nx.dev).
|
||||
|
||||
## Building
|
||||
|
||||
Run `nx build api-enums` to build the library.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `nx test api-enums` to execute the unit tests via [Vitest](https://vitest.dev/).
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@storyteller/api-enums",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"development": "./src/index.ts",
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"default": "./dist/index.js"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from './lib/index.js';
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
// NOTE: These are defined in Rust (as the source of truth) and duplicated in the frontend.
|
||||
// In the future, we should use code gen (protobufs or similar) to keep the two sides in sync.
|
||||
|
||||
export enum GenerationProvider {
|
||||
Artcraft = "artcraft",
|
||||
Fal = "fal",
|
||||
Midjourney = "midjourney",
|
||||
Sora = "sora",
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./generation_provider.js";
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from "./common/index.js";
|
||||
export * from "./tauri/index.js";
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./tasks/index.js";
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from "./task_model_type.js";
|
||||
export * from "./task_status.js";
|
||||
export * from "./task_type.js";
|
||||
@@ -0,0 +1,33 @@
|
||||
// NOTE: These are defined in Rust (as the source of truth) and duplicated in the frontend.
|
||||
// In the future, we should use code gen (protobufs or similar) to keep the two sides in sync.
|
||||
|
||||
export enum TaskModelType {
|
||||
// Image models
|
||||
Flux1Dev = "flux_1_dev",
|
||||
Flux1Schnell = "flux_1_schnell",
|
||||
FluxDevJuggernaut = "flux_dev_juggernaut",
|
||||
FluxPro1 = "flux_pro_1",
|
||||
FluxPro11 = "flux_pro_1.1",
|
||||
FluxPro11Ultra = "flux_pro_1.1_ultra",
|
||||
FluxProKontextMax = "flux_pro_kontext_max",
|
||||
Gemini25Flash = "gemini_25_flash",
|
||||
GptImage1 = "gpt_image_1",
|
||||
Recraft3 = "recraft_3",
|
||||
|
||||
// Generic Midjourney model, version unknown.
|
||||
Midjourney = "midjourney",
|
||||
|
||||
// Video models
|
||||
Kling16Pro = "kling_1.6_pro",
|
||||
Kling21Pro = "kling_2.1_pro",
|
||||
Kling21Master = "kling_2.1_master",
|
||||
Seedance10Lite = "seedance_1.0_lite",
|
||||
Sora2 = "sora_2",
|
||||
Veo2 = "veo_2",
|
||||
Veo3 = "veo_3",
|
||||
Veo3Fast = "veo_3_fast",
|
||||
|
||||
// 3D Object generation models
|
||||
Hunyuan3d2_0 = "hunyuan_3d_2.0",
|
||||
Hunyuan3d2_1 = "hunyuan_3d_2.1",
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// NOTE: These are defined in Rust (as the source of truth) and duplicated in the frontend.
|
||||
// In the future, we should use code gen (protobufs or similar) to keep the two sides in sync.
|
||||
|
||||
export enum TaskStatus {
|
||||
Pending = "pending",
|
||||
Started = "started",
|
||||
CompleteSuccess = "complete_success",
|
||||
CompleteFailure = "complete_failure",
|
||||
AttemptFailed = "attempt_failed",
|
||||
Dead = "dead",
|
||||
CancelledByUser = "cancelled_by_user",
|
||||
CancelledByProvider = "cancelled_by_provider",
|
||||
CancelledByUs = "cancelled_by_us",
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// NOTE: These are defined in Rust (as the source of truth) and duplicated in the frontend.
|
||||
// In the future, we should use code gen (protobufs or similar) to keep the two sides in sync.
|
||||
|
||||
export enum TaskType {
|
||||
ImageGeneration = "image_generation",
|
||||
ImageInpaintEdit = "image_inpaint_edit",
|
||||
VideoGeneration = "video_generation",
|
||||
ObjectGeneration = "object_generation",
|
||||
BackgroundRemoval = "background_removal",
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
||||
"emitDeclarationOnly": true,
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"types": [
|
||||
"node",
|
||||
"vite/client"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"references": [],
|
||||
"exclude": [
|
||||
"vite.config.ts",
|
||||
"vite.config.mts",
|
||||
"vitest.config.ts",
|
||||
"vitest.config.mts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.test.tsx",
|
||||
"src/**/*.spec.tsx",
|
||||
"src/**/*.test.js",
|
||||
"src/**/*.spec.js",
|
||||
"src/**/*.test.jsx",
|
||||
"src/**/*.spec.jsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/vitest",
|
||||
"types": [
|
||||
"vitest/globals",
|
||||
"vitest/importMeta",
|
||||
"vite/client",
|
||||
"node",
|
||||
"vitest"
|
||||
],
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": [
|
||||
"vite.config.ts",
|
||||
"vite.config.mts",
|
||||
"vitest.config.ts",
|
||||
"vitest.config.mts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.test.tsx",
|
||||
"src/**/*.spec.tsx",
|
||||
"src/**/*.test.js",
|
||||
"src/**/*.spec.js",
|
||||
"src/**/*.test.jsx",
|
||||
"src/**/*.spec.jsx",
|
||||
"src/**/*.d.ts"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/// <reference types='vitest' />
|
||||
import { defineConfig } from 'vite';
|
||||
import dts from 'vite-plugin-dts';
|
||||
import * as path from 'path';
|
||||
|
||||
export default defineConfig(() => ({
|
||||
root: __dirname,
|
||||
cacheDir: '../../node_modules/.vite/libs/api-enums',
|
||||
plugins: [dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json') })],
|
||||
// Uncomment this if you are using workers.
|
||||
// worker: {
|
||||
// plugins: [ nxViteTsPaths() ],
|
||||
// },
|
||||
// Configuration for building your library.
|
||||
// See: https://vitejs.dev/guide/build.html#library-mode
|
||||
build: {
|
||||
outDir: './dist',
|
||||
emptyOutDir: true,
|
||||
reportCompressedSize: true,
|
||||
commonjsOptions: {
|
||||
transformMixedEsModules: true,
|
||||
},
|
||||
lib: {
|
||||
// Could also be a dictionary or array of multiple entry points.
|
||||
entry: 'src/index.ts',
|
||||
name: '@storyteller/api-enums',
|
||||
fileName: 'index',
|
||||
// Change this to the formats you want to support.
|
||||
// Don't forget to update your package.json as well.
|
||||
formats: ['es' as const]
|
||||
},
|
||||
rollupOptions: {
|
||||
// External packages that should not be bundled into your library.
|
||||
external: []
|
||||
},
|
||||
},
|
||||
test: {
|
||||
watch: false,
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
|
||||
reporters: ['default'],
|
||||
coverage: {
|
||||
reportsDirectory: './test-output/vitest/coverage',
|
||||
provider: 'v8' as const,
|
||||
}
|
||||
},
|
||||
}));
|
||||
@@ -6,6 +6,9 @@
|
||||
{
|
||||
"path": "../tauri-utils"
|
||||
},
|
||||
{
|
||||
"path": "../api-enums"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
"references": [
|
||||
{
|
||||
"path": "../tauri-utils/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../api-enums/tsconfig.lib.json"
|
||||
}
|
||||
],
|
||||
"exclude": [
|
||||
|
||||
@@ -20,6 +20,7 @@ export * from "./lib/openai/GetOpenAIApiKey.js";
|
||||
export * from "./lib/openai/SetOpenAIApiKey.js";
|
||||
export * from "./lib/providers/GetProviderOrder.js";
|
||||
export * from "./lib/providers/Provider.js";
|
||||
export * from "./lib/artcraft/task_queue/GetTaskQueue.js";
|
||||
export * from "./lib/providers/SetProviderOrder.js";
|
||||
export * from "./lib/settings/GetAppPreferences.js";
|
||||
export * from "./lib/settings/UpdateAppPreference.js";
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { CommandResult } from "../../common/CommandStatus";
|
||||
import { TaskStatus, TaskType, TaskModelType, GenerationProvider } from "@storyteller/api-enums";
|
||||
|
||||
interface GetTaskQueueResponse {
|
||||
tasks: TaskQueueItem[],
|
||||
}
|
||||
|
||||
export interface TaskQueueItem {
|
||||
id: string,
|
||||
task_status: TaskStatus,
|
||||
task_type: TaskType,
|
||||
model_type?: TaskModelType,
|
||||
provider?: GenerationProvider,
|
||||
provider_job_id?: string,
|
||||
created_at: Date,
|
||||
updated_at: Date,
|
||||
completed_at?: Date,
|
||||
}
|
||||
|
||||
interface GetTaskQueueSuccess extends CommandResult {
|
||||
payload: GetTaskQueueResponse;
|
||||
}
|
||||
|
||||
export const GetTaskQueue = async () : Promise<GetTaskQueueResponse> => {
|
||||
try {
|
||||
let result = await invoke("get_task_queue_command") as GetTaskQueueSuccess;
|
||||
return result.payload;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
(window as any).test_get_task_queue = GetTaskQueue;
|
||||
@@ -10,6 +10,9 @@
|
||||
},
|
||||
{
|
||||
"path": "../model-list"
|
||||
},
|
||||
{
|
||||
"path": "../api-enums"
|
||||
}
|
||||
],
|
||||
"extends": "../../tsconfig.base.json"
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
"references": [
|
||||
{
|
||||
"path": "../model-list/tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "../api-enums/tsconfig.lib.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+345
-166
File diff suppressed because it is too large.
Load diff
@@ -170,6 +170,9 @@
|
||||
},
|
||||
{
|
||||
"path": "./libs/components/tutorial-modal"
|
||||
},
|
||||
{
|
||||
"path": "./libs/api-enums"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user