jbilcke-hf HF staff commited on
Commit
fa2b025
1 Parent(s): b0b352d

add parameter for the completion mode

Browse files
packages/aitube-client/package.json CHANGED
@@ -4,7 +4,7 @@
4
  "main": "dist/index.js",
5
  "types": "dist/index.d.ts",
6
  "type": "module",
7
- "version": "0.0.11",
8
  "description": "Official API client for AiTube.at",
9
  "scripts": {
10
  "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
 
4
  "main": "dist/index.js",
5
  "types": "dist/index.d.ts",
6
  "type": "module",
7
+ "version": "0.0.12",
8
  "description": "Official API client for AiTube.at",
9
  "scripts": {
10
  "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js && bun run build:declaration",
packages/aitube-client/src/api/editClapDialogues.ts CHANGED
@@ -1,12 +1,26 @@
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
 
4
 
5
  export async function editClapDialogues({
6
  clap,
 
7
  token,
8
  }: {
9
  clap: ClapProject
 
 
 
 
 
 
 
 
 
 
 
 
10
  token?: string
11
  }): Promise<ClapProject> {
12
 
@@ -14,7 +28,16 @@ export async function editClapDialogues({
14
 
15
  const hasToken = typeof token === "string" && token.length > 0
16
 
17
- const newClap = await fetchClap(`${aitubeApiUrl}edit/dialogues`, {
 
 
 
 
 
 
 
 
 
18
  method: "POST",
19
  headers: {
20
  "Content-Type": "application/x-gzip",
 
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
4
+ import { ClapCompletionMode } from "./types"
5
 
6
  export async function editClapDialogues({
7
  clap,
8
+ completionMode = ClapCompletionMode.MERGE,
9
  token,
10
  }: {
11
  clap: ClapProject
12
+
13
+ /**
14
+ * Completion mode (optional, defaults to "merge")
15
+ *
16
+ * Possible values are:
17
+ * - full: the API and the client will return a full clap file. This is a very convenient and simple mode, but it is also very ineficient, so it should not be used for intensive applications.
18
+ * - partial: the API and the client will return a partial clap file, containing only the new values and changes. This is useful for real-time applications and streaming.
19
+ * - merge: the API will return a partial clap file, and the client will return a merge of the original with the new values. This is safe to run, there are no side-effects.
20
+ * - replace: the API will return a partial clap file, and the client will replace the original. This is the most efficient mode, but it relies on side-effects and inline object updates.
21
+ */
22
+ completionMode?: ClapCompletionMode
23
+
24
  token?: string
25
  }): Promise<ClapProject> {
26
 
 
28
 
29
  const hasToken = typeof token === "string" && token.length > 0
30
 
31
+ const newClap = await fetchClap(
32
+ `${aitubeApiUrl}edit/dialogues${
33
+ typeof completionMode === "string"
34
+ ? `?c=${
35
+ completionMode === ClapCompletionMode.FULL
36
+ ? "full"
37
+ : "partial"
38
+ }`
39
+ : ""
40
+ }`, {
41
  method: "POST",
42
  headers: {
43
  "Content-Type": "application/x-gzip",
packages/aitube-client/src/api/editClapEntities.ts CHANGED
@@ -1,12 +1,27 @@
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
 
4
 
5
  export async function editClapEntities({
6
  clap,
 
7
  token,
8
  }: {
 
9
  clap: ClapProject
 
 
 
 
 
 
 
 
 
 
 
 
10
  token?: string
11
  }): Promise<ClapProject> {
12
 
@@ -14,7 +29,16 @@ export async function editClapEntities({
14
 
15
  const hasToken = typeof token === "string" && token.length > 0
16
 
17
- const newClap = await fetchClap(`${aitubeApiUrl}edit/entities`, {
 
 
 
 
 
 
 
 
 
18
  method: "POST",
19
  headers: {
20
  "Content-Type": "application/x-gzip",
 
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
4
+ import { ClapCompletionMode } from "./types"
5
 
6
  export async function editClapEntities({
7
  clap,
8
+ completionMode = ClapCompletionMode.MERGE,
9
  token,
10
  }: {
11
+ // A ClapProject instance
12
  clap: ClapProject
13
+
14
+ /**
15
+ * Completion mode (optional, defaults to "merge")
16
+ *
17
+ * Possible values are:
18
+ * - full: the API and the client will return a full clap file. This is a very convenient and simple mode, but it is also very ineficient, so it should not be used for intensive applications.
19
+ * - partial: the API and the client will return a partial clap file, containing only the new values and changes. This is useful for real-time applications and streaming.
20
+ * - merge: the API will return a partial clap file, and the client will return a merge of the original with the new values. This is safe to run, there are no side-effects.
21
+ * - replace: the API will return a partial clap file, and the client will replace the original. This is the most efficient mode, but it relies on side-effects and inline object updates.
22
+ */
23
+ completionMode?: ClapCompletionMode
24
+
25
  token?: string
26
  }): Promise<ClapProject> {
27
 
 
29
 
30
  const hasToken = typeof token === "string" && token.length > 0
31
 
32
+ const newClap = await fetchClap(
33
+ `${aitubeApiUrl}edit/entities${
34
+ typeof completionMode === "string"
35
+ ? `?c=${
36
+ completionMode === ClapCompletionMode.FULL
37
+ ? "full"
38
+ : "partial"
39
+ }`
40
+ : ""
41
+ }`, {
42
  method: "POST",
43
  headers: {
44
  "Content-Type": "application/x-gzip",
packages/aitube-client/src/api/editClapStoryboards.ts CHANGED
@@ -1,12 +1,26 @@
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
 
4
 
5
  export async function editClapStoryboards({
6
  clap,
 
7
  token,
8
  }: {
9
  clap: ClapProject
 
 
 
 
 
 
 
 
 
 
 
 
10
  token?: string
11
  }): Promise<ClapProject> {
12
 
@@ -14,7 +28,15 @@ export async function editClapStoryboards({
14
 
15
  const hasToken = typeof token === "string" && token.length > 0
16
 
17
- const newClap = await fetchClap(`${aitubeApiUrl}edit/storyboards`, {
 
 
 
 
 
 
 
 
18
  method: "POST",
19
  headers: {
20
  "Content-Type": "application/x-gzip",
 
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
4
+ import { ClapCompletionMode } from "./types"
5
 
6
  export async function editClapStoryboards({
7
  clap,
8
+ completionMode = ClapCompletionMode.MERGE,
9
  token,
10
  }: {
11
  clap: ClapProject
12
+
13
+ /**
14
+ * Completion mode (optional, defaults to "merge")
15
+ *
16
+ * Possible values are:
17
+ * - full: the API and the client will return a full clap file. This is a very convenient and simple mode, but it is also very ineficient, so it should not be used for intensive applications.
18
+ * - partial: the API and the client will return a partial clap file, containing only the new values and changes. This is useful for real-time applications and streaming.
19
+ * - merge: the API will return a partial clap file, and the client will return a merge of the original with the new values. This is safe to run, there are no side-effects.
20
+ * - replace: the API will return a partial clap file, and the client will replace the original. This is the most efficient mode, but it relies on side-effects and inline object updates.
21
+ */
22
+ completionMode?: ClapCompletionMode
23
+
24
  token?: string
25
  }): Promise<ClapProject> {
26
 
 
28
 
29
  const hasToken = typeof token === "string" && token.length > 0
30
 
31
+ const newClap = await fetchClap(`${aitubeApiUrl}edit/storyboards${
32
+ typeof completionMode === "string"
33
+ ? `?c=${
34
+ completionMode === ClapCompletionMode.FULL
35
+ ? "full"
36
+ : "partial"
37
+ }`
38
+ : ""
39
+ }`, {
40
  method: "POST",
41
  headers: {
42
  "Content-Type": "application/x-gzip",
packages/aitube-client/src/api/editClapVideos.ts CHANGED
@@ -1,12 +1,26 @@
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
 
4
 
5
  export async function editClapVideos({
6
  clap,
 
7
  token,
8
  }: {
9
  clap: ClapProject
 
 
 
 
 
 
 
 
 
 
 
 
10
  token?: string
11
  }): Promise<ClapProject> {
12
 
@@ -14,7 +28,15 @@ export async function editClapVideos({
14
 
15
  const hasToken = typeof token === "string" && token.length > 0
16
 
17
- const newClap = await fetchClap(`${aitubeApiUrl}edit/videos`, {
 
 
 
 
 
 
 
 
18
  method: "POST",
19
  headers: {
20
  "Content-Type": "application/x-gzip",
 
1
  import { ClapProject, fetchClap, serializeClap } from "@aitube/clap"
2
 
3
  import { aitubeApiUrl } from "@/config"
4
+ import { ClapCompletionMode } from "./types"
5
 
6
  export async function editClapVideos({
7
  clap,
8
+ completionMode = ClapCompletionMode.MERGE,
9
  token,
10
  }: {
11
  clap: ClapProject
12
+
13
+ /**
14
+ * Completion mode (optional, defaults to "merge")
15
+ *
16
+ * Possible values are:
17
+ * - full: the API and the client will return a full clap file. This is a very convenient and simple mode, but it is also very ineficient, so it should not be used for intensive applications.
18
+ * - partial: the API and the client will return a partial clap file, containing only the new values and changes. This is useful for real-time applications and streaming.
19
+ * - merge: the API will return a partial clap file, and the client will return a merge of the original with the new values. This is safe to run, there are no side-effects.
20
+ * - replace: the API will return a partial clap file, and the client will replace the original. This is the most efficient mode, but it relies on side-effects and inline object updates.
21
+ */
22
+ completionMode?: ClapCompletionMode
23
+
24
  token?: string
25
  }): Promise<ClapProject> {
26
 
 
28
 
29
  const hasToken = typeof token === "string" && token.length > 0
30
 
31
+ const newClap = await fetchClap(`${aitubeApiUrl}edit/videos${
32
+ typeof completionMode === "string"
33
+ ? `?c=${
34
+ completionMode === ClapCompletionMode.FULL
35
+ ? "full"
36
+ : "partial"
37
+ }`
38
+ : ""
39
+ }`, {
40
  method: "POST",
41
  headers: {
42
  "Content-Type": "application/x-gzip",
packages/aitube-client/src/api/exportClapToVideo.ts CHANGED
@@ -11,7 +11,14 @@ export async function exportClapToVideo({
11
  token,
12
  }: {
13
  clap: ClapProject
 
 
 
 
 
 
14
  format?: SupportedExportFormat
 
15
  token?: string
16
  }): Promise<string> {
17
 
 
11
  token,
12
  }: {
13
  clap: ClapProject
14
+
15
+ /**
16
+ * Desired output video format (defaults to "mp4")
17
+ *
18
+ * Can be either "mp4" or "webm"
19
+ */
20
  format?: SupportedExportFormat
21
+
22
  token?: string
23
  }): Promise<string> {
24
 
packages/aitube-client/src/api/index.ts CHANGED
@@ -3,4 +3,5 @@ export { editClapStoryboards } from "./editClapStoryboards"
3
  export { editClapVideos } from "./editClapVideos"
4
  export { editClapDialogues } from "./editClapDialogues"
5
  export { editClapEntities } from "./editClapEntities"
6
- export { createClap } from "./createClap"
 
 
3
  export { editClapVideos } from "./editClapVideos"
4
  export { editClapDialogues } from "./editClapDialogues"
5
  export { editClapEntities } from "./editClapEntities"
6
+ export { createClap } from "./createClap"
7
+ export { ClapCompletionMode } from "./types"
packages/aitube-client/src/api/types.ts ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export enum ClapCompletionMode {
2
+ /**
3
+ * the API and the client will return a full clap file.
4
+ * This is a very convenient and simple mode, but it is also very ineficient,
5
+ * so it should not be used for intensive applications.
6
+ */
7
+ FULL = "full",
8
+
9
+ /**
10
+ * the API and the client will return a partial clap file containing only the changes,
11
+ * containing only the new values and changes.
12
+ * This is useful for real-time applications and streaming.
13
+ */
14
+ PARTIAL = "partial",
15
+
16
+ /**
17
+ * the API will return a partial clap file containing only the changes,
18
+ * and the client will return a merge of the original with the new values.
19
+ * This is safe to run, there are no side-effects.
20
+ */
21
+ MERGE = "merge",
22
+
23
+ /**
24
+ * the API will return a partial clap file, and the client will replace the original.
25
+ * This is the most efficient mode, but it relies on side-effects and inline object updates.
26
+ */
27
+ REPLACE = "replace"
28
+ }
packages/aitube-client/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export {
6
  editClapStoryboards,
7
  editClapVideos,
8
  exportClapToVideo,
 
9
  } from './api'
10
 
11
  export {
 
6
  editClapStoryboards,
7
  editClapVideos,
8
  exportClapToVideo,
9
+ ClapCompletionMode,
10
  } from './api'
11
 
12
  export {