@acedatacloud/piece-acemusic 0.1.1 → 0.2.0

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
@@ -24,3 +24,5 @@ Get an [application API key](https://platform.acedata.cloud/console/applications
24
24
  | List task history | Optional page and items per page. |
25
25
 
26
26
  Audio creation, reference import and writing lyrics are separately priced. Use the creation tool once, save its `task_id`, then retrieve the same task. If the connection breaks before a task ID arrives, inspect task history before resubmitting. The task state and `response` carry completion and partial failures. A partial result can contain one usable track. Play delivered tracks from `response.data[].audio_url`. Read [ACE Music API documentation](https://github.com/AceDataCloud/ACEMusicAPI) and [current pricing](https://platform.acedata.cloud/services/024e09b4-52cf-5e98-a91a-efedf43104c4?utm_source=opensource&utm_medium=referral&utm_campaign=evergreen).
27
+
28
+ Use Import Reference Asset with an enabled MIDI, image or video type. Keep its original task ID, then supply the finished asset ID and matching type to Create Song from Idea with v1.1. Get Reference Asset and List Reference Assets are free authenticated reads.
@@ -20,6 +20,16 @@ const operations = {
20
20
  "key": "model",
21
21
  "kind": "model",
22
22
  "required": false
23
+ },
24
+ "asset_id": {
25
+ "key": "asset_id",
26
+ "kind": "text",
27
+ "required": false
28
+ },
29
+ "asset_type": {
30
+ "key": "asset_type",
31
+ "kind": "asset_type",
32
+ "required": false
23
33
  }
24
34
  }
25
35
  },
@@ -211,6 +221,66 @@ const operations = {
211
221
  "required": false
212
222
  }
213
223
  }
224
+ },
225
+ "upload_asset": {
226
+ "endpoint": "assets",
227
+ "body": {
228
+ "action": "upload",
229
+ "async": true
230
+ },
231
+ "fields": {
232
+ "type": {
233
+ "key": "type",
234
+ "kind": "asset_type",
235
+ "required": true
236
+ },
237
+ "url": {
238
+ "key": "url",
239
+ "kind": "url",
240
+ "required": true
241
+ },
242
+ "name": {
243
+ "key": "name",
244
+ "kind": "text",
245
+ "required": false
246
+ }
247
+ }
248
+ },
249
+ "get_asset": {
250
+ "endpoint": "assets",
251
+ "body": {
252
+ "action": "retrieve"
253
+ },
254
+ "fields": {
255
+ "id": {
256
+ "key": "id",
257
+ "kind": "text",
258
+ "required": true
259
+ }
260
+ }
261
+ },
262
+ "list_assets": {
263
+ "endpoint": "assets",
264
+ "body": {
265
+ "action": "retrieve"
266
+ },
267
+ "fields": {
268
+ "type": {
269
+ "key": "type",
270
+ "kind": "asset_type",
271
+ "required": false
272
+ },
273
+ "page": {
274
+ "key": "page",
275
+ "kind": "page",
276
+ "required": false
277
+ },
278
+ "page_size": {
279
+ "key": "page_size",
280
+ "kind": "size",
281
+ "required": false
282
+ }
283
+ }
214
284
  }
215
285
  };
216
286
  function buildRequest(operation, values) {
@@ -247,14 +317,20 @@ function buildRequest(operation, values) {
247
317
  throw new Error("Invalid " + field);
248
318
  if (kind === "model" && !["acemusic-v1.1", "acemusic-v1"].includes(value))
249
319
  throw new Error("Unknown ACE Music model");
320
+ if (kind === "asset_type" && !["midi", "image", "video"].includes(value))
321
+ throw new Error("Choose midi, image or video");
250
322
  if (kind === "url") {
251
323
  const parsed = new URL(value);
252
324
  if (parsed.protocol !== "https:" || !parsed.hostname || parsed.username || parsed.password)
253
- throw new Error("Use a public HTTPS MP3 URL");
325
+ throw new Error("Use a public HTTPS URL");
254
326
  }
255
327
  }
256
328
  body[entry.key] = value;
257
329
  }
330
+ if (operation === "generate" && (body.asset_id || body.asset_type)) {
331
+ if (!body.asset_id || !body.asset_type || (body.model && body.model !== "acemusic-v1.1"))
332
+ throw new Error("Reference generation requires an asset ID and type with ACE Music v1.1");
333
+ }
258
334
  if (operation === "mashup") {
259
335
  if (body.first_audio_id === body.second_audio_id)
260
336
  throw new Error("The two reference track IDs must be distinct");
package/dist/src/index.js CHANGED
@@ -8,12 +8,35 @@ const auth = pieces_framework_1.PieceAuth.SecretText({
8
8
  description: 'Enter the raw [application key](https://platform.acedata.cloud/console/applications?utm_source=activepieces&utm_medium=referral&utm_campaign=evergreen) with ACE Music access.',
9
9
  required: true,
10
10
  });
11
+ const assetType = (required) => pieces_framework_1.Property.StaticDropdown({
12
+ displayName: 'Asset type', required,
13
+ options: { options: ['midi', 'image', 'video'].map(value => ({ label: value, value })) },
14
+ });
15
+ const uploadAsset = (0, pieces_framework_1.createAction)({
16
+ name: 'upload_asset', displayName: 'Import reference asset', description: 'Submit one separately priced import for an enabled type.', auth,
17
+ props: { type: assetType(true), url: pieces_framework_1.Property.ShortText({ displayName: 'Public HTTPS file URL', required: true }),
18
+ name: pieces_framework_1.Property.ShortText({ displayName: 'Display name', required: false }) },
19
+ async run(context) { return (0, client_1.invoke)(context.auth.secret_text, 'upload_asset', context.propsValue); },
20
+ });
21
+ const getAsset = (0, pieces_framework_1.createAction)({
22
+ name: 'get_asset', displayName: 'Get reference asset', description: 'Read one owned asset for free.', auth,
23
+ props: { id: pieces_framework_1.Property.ShortText({ displayName: 'Asset ID', required: true }) },
24
+ async run(context) { return (0, client_1.invoke)(context.auth.secret_text, 'get_asset', context.propsValue); },
25
+ });
26
+ const listAssets = (0, pieces_framework_1.createAction)({
27
+ name: 'list_assets', displayName: 'List reference assets', description: 'Read a page of owned assets for free.', auth,
28
+ props: { type: assetType(false), page: pieces_framework_1.Property.Number({ displayName: 'Page', required: false }),
29
+ page_size: pieces_framework_1.Property.Number({ displayName: 'Page size', required: false }) },
30
+ async run(context) { return (0, client_1.invoke)(context.auth.secret_text, 'list_assets', context.propsValue); },
31
+ });
11
32
  const generate = (0, pieces_framework_1.createAction)({
12
33
  name: 'generate',
13
34
  displayName: 'Create song from idea',
14
35
  description: 'Submit one paid song generation. Save its task ID.',
15
36
  auth,
16
37
  props: {
38
+ asset_id: pieces_framework_1.Property.ShortText({ displayName: 'Reference asset ID', required: false }),
39
+ asset_type: assetType(false),
17
40
  prompt: pieces_framework_1.Property.LongText({ displayName: 'Music or lyrics idea', required: true }),
18
41
  model: pieces_framework_1.Property.StaticDropdown({ displayName: 'Model', required: false, options: { options: ['acemusic-v1.1', 'acemusic-v1'].map(value => ({ label: value, value })) } }),
19
42
  },
@@ -140,6 +163,6 @@ exports.acemusic = (0, pieces_framework_1.createPiece)({
140
163
  authors: ['Ace Data Cloud'],
141
164
  minimumSupportedRelease: '0.92.2',
142
165
  auth,
143
- actions: [generate, custom, upload, cover, mashup, lyrics, retrieve, batch, history],
166
+ actions: [uploadAsset, getAsset, listAssets, generate, custom, upload, cover, mashup, lyrics, retrieve, batch, history],
144
167
  triggers: [],
145
168
  });
@@ -34,7 +34,7 @@
34
34
  "pieceName": "@acedatacloud/piece-acemusic",
35
35
  "actionName": "generate",
36
36
  "sampleData": {},
37
- "pieceVersion": "0.1.1",
37
+ "pieceVersion": "0.2.0",
38
38
  "propertySettings": {
39
39
  "prompt": {
40
40
  "type": "MANUAL"
@@ -62,7 +62,7 @@
62
62
  "pieceName": "@acedatacloud/piece-acemusic",
63
63
  "actionName": "retrieve",
64
64
  "sampleData": {},
65
- "pieceVersion": "0.1.1",
65
+ "pieceVersion": "0.2.0",
66
66
  "propertySettings": {
67
67
  "task_id": {
68
68
  "type": "MANUAL"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acedatacloud/piece-acemusic",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "ACE Music songs, lyrics, reference tracks and tasks for Activepieces.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/src/index.js",