@acedatacloud/piece-seedance 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Create a Seedance text-to-video task and retrieve the **same task ID** through Ace Data Cloud. The Piece has two actions: **Create Seedance video task** and **Get Seedance task**. A task ID means the request was accepted, not that the video is ready. [中文指南](README.zh-CN.md)
4
4
 
5
- **Distribution:** Install `@acedatacloud/piece-seedance` (this source targets `0.1.5`; check npm for the published version) as a custom Piece in your Activepieces instance. A public npm package does not automatically enter the shared Activepieces catalog.
5
+ **Distribution:** Install `@acedatacloud/piece-seedance` (this source targets `0.1.6`; check npm for the published version) as a custom Piece in your Activepieces instance. A public npm package does not automatically enter the shared Activepieces catalog.
6
6
 
7
7
  ## Install and connect
8
8
 
9
- In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**. Enter `@acedatacloud/piece-seedance` and the published version (this release targets `0.1.5`). Search for **Seedance** when adding a flow action, then check the logo and both actions.
9
+ In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**. Enter `@acedatacloud/piece-seedance` and the published version (this release targets `0.1.6`). Search for **Seedance** when adding a flow action, then check the logo and both actions.
10
10
 
11
11
  1. Register or sign in at [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen). The page prepares your **General Application** card automatically. If the card has no key, select **Create API Key** first.
12
12
  2. Use the **General Application** card and confirm your account has **Seedance** access. A General key can access the services your account is entitled to use; a service-specific key is limited to that service.
@@ -17,7 +17,7 @@ In Activepieces 0.92.2+, open **Platform Admin → Catalogue → Pieces → Inst
17
17
 
18
18
  1. Add **Create Seedance video task**. Enter a text description. For a small first run, choose `doubao-seedance-2-0-mini-260615`, `480p`, 4 seconds, `16:9`, and leave **Generate audio** off.
19
19
  2. Run creation **once** and save `task_id`. The action uses `callback_url` for asynchronous submission and has no HTTP retry. If a timeout or 5xx occurs, inspect [request history](https://platform.acedata.cloud/console/usages?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) before trying again: a task may already exist.
20
- 3. Add **Get Seedance task** and map **Task ID** from the creation output. Query that same ID until `status=succeeded` or `failed`. Pending media is not returned as final video.
20
+ 3. Add **Get Seedance task** and map **Task ID** from the creation output. Query that same ID until `status=succeeded` or `failed`. Pending previews are withheld from both `media_urls` and `result`; a completed response without a final video is reported as failed.
21
21
  4. Open a URL in `media_urls` only when `success=true`. A task lookup does not create or bill another video.
22
22
 
23
23
  The [credential-free quickstart flow](https://raw.githubusercontent.com/AceDataCloud/SeedanceActivepieces/main/examples/seedance-quickstart.json) imports with both connections empty and the same task-ID mapping intact. Add your own connection before running. Creation retries are disabled in the sample.
package/README.zh-CN.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  通过 Ace Data Cloud 创建 Seedance 文生视频任务,并按**同一个任务 ID**查询结果。Piece 提供 **Create Seedance video task** 与 **Get Seedance task** 两个动作。拿到任务 ID 不代表视频已经完成。[English](README.md)
4
4
 
5
- **分发方式:**在 Activepieces 实例中将 `@acedatacloud/piece-seedance`(本源码目标为 `0.1.5`,已发布版本请查看 npm) 作为自定义 Piece 安装。公开 npm 包不会自动进入 Activepieces 共享目录。
5
+ **分发方式:**在 Activepieces 实例中将 `@acedatacloud/piece-seedance`(本源码目标为 `0.1.6`,已发布版本请查看 npm) 作为自定义 Piece 安装。公开 npm 包不会自动进入 Activepieces 共享目录。
6
6
 
7
7
  ## 安装与连接
8
8
 
9
- Activepieces 0.92.2+ 中进入 **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**,填写 `@acedatacloud/piece-seedance` 和已发布版本(本次目标为 `0.1.5`)。在流程中搜索 **Seedance**,核对 Logo 和两个动作。
9
+ Activepieces 0.92.2+ 中进入 **Platform Admin → Catalogue → Pieces → Install Piece → NPM Registry**,填写 `@acedatacloud/piece-seedance` 和已发布版本(本次目标为 `0.1.6`)。在流程中搜索 **Seedance**,核对 Logo 和两个动作。
10
10
 
11
11
  1. 在 [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) 注册或登录。页面会自动准备好**通用应用**卡片。若卡片尚无 Key,请先选择**创建 API Key**。
12
12
  2. 使用**通用应用**卡片,并确认账号具备 **Seedance** 权限。通用 Key 可访问账号已获授权的服务;专用 Key 仅限对应服务。
@@ -24,7 +24,7 @@ exports.getTask = (0, pieces_framework_1.createAction)({
24
24
  const response = await client_1.seedanceClient.post({
25
25
  token: context.auth.secret_text,
26
26
  path: '/seedance/tasks',
27
- body: { id: taskId },
27
+ body: { action: 'retrieve', id: taskId },
28
28
  });
29
29
  return client_1.seedanceClient.normalizeTask({ body: response, taskId });
30
30
  },
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.seedanceClient = void 0;
4
- const pieces_common_1 = require("@activepieces/pieces-common");
5
4
  const secure_http_1 = require("../secure-http");
6
5
  async function post({ token, path, body, }) {
7
6
  const response = await secure_http_1.httpClient.sendRequest({
8
- method: pieces_common_1.HttpMethod.POST,
7
+ method: 'POST',
9
8
  url: `https://api.acedata.cloud${path}`,
10
9
  headers: {
11
10
  Authorization: `Bearer ${token}`,
@@ -18,23 +17,40 @@ async function post({ token, path, body, }) {
18
17
  }
19
18
  function normalizeTask({ body, taskId }) {
20
19
  const envelope = record(body);
20
+ const returnedTaskId = stringValue(envelope.id);
21
+ if (!returnedTaskId || !sameTaskId(returnedTaskId, taskId)) {
22
+ throw new Error('No matching task was returned. Check the original task ID.');
23
+ }
21
24
  const payload = parsePayload('response' in envelope ? envelope.response : body);
22
25
  const values = record(payload);
26
+ const resultTaskId = stringValue(values.task_id);
27
+ if (resultTaskId && !sameTaskId(resultTaskId, taskId)) {
28
+ throw new Error('The response did not match the requested original task.');
29
+ }
30
+ const envelopeTrace = stringValue(envelope.trace_id);
31
+ const resultTrace = stringValue(values.trace_id);
32
+ if (envelopeTrace && resultTrace && envelopeTrace !== resultTrace) {
33
+ throw new Error('The response did not match the original task trace.');
34
+ }
23
35
  const states = collectStates(payload);
24
- const failed = states.some((state) => FAILED_STATES.has(state)) || hasFailure(payload);
25
- const unfinished = 'finished_at' in envelope && envelope.finished_at === null;
26
- const finished = !unfinished &&
27
- !failed &&
28
- ((states.length > 0 && states.every((state) => COMPLETE_STATES.has(state))) ||
29
- Boolean(envelope.finished_at && hasContent(payload)));
30
- const traceId = stringValue(values.trace_id) || stringValue(envelope.trace_id);
36
+ const envelopeState = stringValue(envelope.status) || stringValue(envelope.state);
37
+ if (envelopeState)
38
+ states.push(envelopeState.toLowerCase());
39
+ const failed = states.some((state) => FAILED_STATES.has(state)) || hasFailure(payload) ||
40
+ envelope.success === false || Boolean(envelope.error);
41
+ const hasFinish = envelope.finished_at !== undefined && envelope.finished_at !== null && envelope.finished_at !== '';
42
+ const completeStates = states.length === 0 || states.every((state) => COMPLETE_STATES.has(state));
43
+ const media = collectMediaUrls(payload);
44
+ const finished = hasFinish && !failed && completeStates && media.length > 0;
45
+ const noFinalMedia = hasFinish && !failed && completeStates && media.length === 0;
46
+ const traceId = resultTrace || envelopeTrace;
31
47
  return {
32
48
  task_id: taskId,
33
- status: failed && !unfinished ? 'failed' : finished ? 'succeeded' : 'pending',
49
+ status: failed || noFinalMedia ? 'failed' : finished ? 'succeeded' : 'pending',
34
50
  success: finished,
35
51
  trace_id: traceId,
36
- media_urls: finished ? collectMediaUrls(payload) : [],
37
- result: sanitize(payload),
52
+ media_urls: finished ? media : [],
53
+ result: finished ? sanitize(payload) : failed ? sanitizeFailure(payload) : {},
38
54
  };
39
55
  }
40
56
  function taskIdFromSubmission(body) {
@@ -61,6 +77,10 @@ function record(value) {
61
77
  function stringValue(value) {
62
78
  return typeof value === 'string' ? value : '';
63
79
  }
80
+ function sameTaskId(a, b) {
81
+ const uuid = /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i;
82
+ return uuid.test(a) && uuid.test(b) ? a.toLowerCase() === b.toLowerCase() : a === b;
83
+ }
64
84
  function collectStates(value) {
65
85
  if (Array.isArray(value)) {
66
86
  return value.flatMap(collectStates);
@@ -105,9 +125,6 @@ function collectMediaUrls(value) {
105
125
  });
106
126
  return [...new Set(urls)];
107
127
  }
108
- function hasContent(value) {
109
- return Array.isArray(value) ? value.length > 0 : Object.keys(record(value)).length > 0;
110
- }
111
128
  function sanitize(value) {
112
129
  if (Array.isArray(value)) {
113
130
  return value.map(sanitize);
@@ -119,6 +136,14 @@ function sanitize(value) {
119
136
  .filter(([key]) => !SENSITIVE_KEYS.has(key.toLowerCase()) && !SENSITIVE_KEY_PATTERN.test(key))
120
137
  .map(([key, child]) => [key, key === 'error' ? 'Task failed; inspect its task or trace ID.' : sanitize(child)]));
121
138
  }
139
+ function sanitizeFailure(value) {
140
+ const item = record(value);
141
+ return {
142
+ ...(item.success === false ? { success: false } : {}),
143
+ ...(stringValue(item.task_id) ? { task_id: stringValue(item.task_id) } : {}),
144
+ ...(item.error ? { error: 'Task failed; inspect its task or trace ID.' } : {}),
145
+ };
146
+ }
122
147
  exports.seedanceClient = { post, normalizeTask, taskIdFromSubmission };
123
148
  const COMPLETE_STATES = new Set(['complete', 'completed', 'succeeded', 'succeed', 'success', 'finished']);
124
149
  const FAILED_STATES = new Set(['failed', 'error', 'cancelled', 'canceled', 'rejected']);
@@ -39,7 +39,7 @@
39
39
  "pieceName": "@acedatacloud/piece-seedance",
40
40
  "actionName": "generate_video",
41
41
  "sampleData": {},
42
- "pieceVersion": "0.1.5",
42
+ "pieceVersion": "0.1.6",
43
43
  "propertySettings": {
44
44
  "prompt": {
45
45
  "type": "MANUAL"
@@ -82,7 +82,7 @@
82
82
  "pieceName": "@acedatacloud/piece-seedance",
83
83
  "actionName": "get_task",
84
84
  "sampleData": {},
85
- "pieceVersion": "0.1.5",
85
+ "pieceVersion": "0.1.6",
86
86
  "propertySettings": {
87
87
  "taskId": {
88
88
  "type": "MANUAL"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acedatacloud/piece-seedance",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Seedance video generation and task lookup through Ace Data Cloud for Activepieces",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/src/index.js",
@@ -24,7 +24,6 @@
24
24
  "bugs": "https://github.com/AceDataCloud/SeedanceActivepieces/issues",
25
25
  "license": "MIT",
26
26
  "dependencies": {
27
- "@activepieces/pieces-common": "0.12.5",
28
27
  "@activepieces/pieces-framework": "0.32.0"
29
28
  },
30
29
  "devDependencies": {