@acedatacloud/piece-seedance 0.1.4 → 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,22 +2,22 @@
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@0.1.1` 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 version `0.1.4`. 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
- 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). If you have no General application, choose **Initialize General Application**.
12
- 2. Open a General application or an application with **Seedance** access. A General key can access the services your account is entitled to use; a service-specific key is limited to that service.
13
- 3. Use the application's copy button, or choose **Manage Keys → Create** to create a separate key named `Activepieces Seedance`. Set expiry and usage limits as needed. If you restrict **Allowed APIs**, include both `/seedance/videos` and `/seedance/tasks`, then copy the key.
14
- 4. Create an Activepieces connection and enter only the API key, without `Bearer `. A `platform-...` management token is not a generation API key. Keep the key in the connection, never in a flow export. Check current [pricing](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) and balance before generating.
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
+ 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.
13
+ 3. Click the copy button beside **API KEY** on the application card, or choose **Manage Keys → Create** to create a separate key named `Activepieces Seedance`. Set expiry and usage limits as needed. If you restrict **Allowed APIs**, include both `/seedance/videos` and `/seedance/tasks`, then copy the key.
14
+ 4. Create an Activepieces connection and enter only the API key, without `Bearer `. A `platform-...` management token is not a generation API key. Keep the key in the connection, never in a flow export. Check current [pricing](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) before generating. If the General Application balance is low, click **Top Up** on that card.
15
15
 
16
16
  ## First flow
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,16 +2,16 @@
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.1` 作为自定义 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.4`。在流程中搜索 **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
- 1. 在 [Ace Data Cloud Applications](https://platform.acedata.cloud/console/applications?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen) 注册或登录。若没有通用应用,点击 **Initialize General Application**。
12
- 2. 打开通用应用或具备 **Seedance** 权限的应用。通用 Key 可访问账号已获授权的服务;专用 Key 仅限对应服务。
13
- 3. 使用应用卡片的复制按钮,或通过 **Manage Keys → Create** 创建名为 `Activepieces Seedance` 的独立 Key,按需设置有效期与用量限制。若启用 **Allowed APIs**,应同时包含 `/seedance/videos` 与 `/seedance/tasks`,创建后复制 Key。
14
- 4. 创建 Activepieces 连接,只填写 API Key 本身,不加 `Bearer `。`platform-...` 管理 Token 不是生成 API Key。Key 留在连接中,不写入流程导出。生成前查看当前[价格](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen)与余额。
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
+ 2. 使用**通用应用**卡片,并确认账号具备 **Seedance** 权限。通用 Key 可访问账号已获授权的服务;专用 Key 仅限对应服务。
13
+ 3. 点击应用卡片上 **API KEY** 旁的复制按钮,或通过 **Manage Keys → Create** 创建名为 `Activepieces Seedance` 的独立 Key,按需设置有效期与用量限制。若启用 **Allowed APIs**,应同时包含 `/seedance/videos` 与 `/seedance/tasks`,创建后复制 Key。
14
+ 4. 创建 Activepieces 连接,只填写 API Key 本身,不加 `Bearer `。`platform-...` 管理 Token 不是生成 API Key。Key 留在连接中,不写入流程导出。生成前查看当前[价格](https://platform.acedata.cloud/models?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen)。通用应用余额不足时,点击该卡片上的**充值**。
15
15
 
16
16
  ## 首次流程
17
17
 
@@ -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
  },
@@ -4,6 +4,6 @@ exports.seedanceAuth = void 0;
4
4
  const pieces_framework_1 = require("@activepieces/pieces-framework");
5
5
  exports.seedanceAuth = pieces_framework_1.PieceAuth.SecretText({
6
6
  displayName: 'Ace Data Cloud API key',
7
- description: 'Register or sign in at [Applications](https://platform.acedata.cloud/console/applications?utm_source=activepieces&utm_medium=referral&utm_campaign=evergreen). If needed choose Initialize General Application, then copy the key or use Manage Keys → Create for a dedicated Activepieces key. Check service permissions, balance, current pricing and Allowed APIs in the guide. Paste only the API key without Bearer; a platform management token is not a generation key.',
7
+ description: 'Register or sign in at [Applications](https://platform.acedata.cloud/console/applications?utm_source=activepieces&utm_medium=referral&utm_campaign=evergreen). On the General Application card, select Create API Key first if no key appears. Then click the copy button beside API KEY. For a separate key, use Manage Keys → Create. Check service permissions, current pricing and Allowed APIs. If the General Application balance is low, click Top Up on that card. Paste only the API key without Bearer; a platform management token is not a generation key.',
8
8
  required: true,
9
9
  });
@@ -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.4",
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.4",
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.4",
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": {