Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
export default {
key: "cloudinary-get-account-usage-details",
name: "Get Account Usage Details",
description: "Enables you to get a report on the status of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. [See the documentation](https://cloudinary.com/documentation/admin_api#usage)",
version: "0.1.2",
description: "Gets a report of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. [See the documentation](https://cloudinary.com/documentation/admin_api#usage)",
version: "0.2.0",
type: "action",
props: {
cloudinary,
dateInfo: {

Check warning on line 11 in components/cloudinary/actions/get-account-usage-details/get-account-usage-details.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop dateInfo must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 11 in components/cloudinary/actions/get-account-usage-details/get-account-usage-details.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop dateInfo must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "If `Date` is not specified, it defaults to the current date.",
},
date: {
type: "string",
label: "Date",
description: "The date for the usage report. Must be within the last 3 months and given in the format: `dd-mm-yyyy`. Default: the current date",
description: "The date for the usage report, in the `yyyy-mm-dd` format, e.g. `2019-07-21`. Must be between yesterday and the last 3 months.",
optional: true,
},
},
Expand All @@ -20,12 +25,17 @@
date: this.date,
};

const response = await this.cloudinary.getUsage(options);
try {
const response = await this.cloudinary.getUsage(options);

if (response) {
$.export("$summary", "Successfully retrieved usage details.");
}
if (response) {
$.export("$summary", "Successfully retrieved usage details");
}

return response;
return response;
}
catch (err) {
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
}
},
};
58 changes: 35 additions & 23 deletions components/cloudinary/actions/get-resources/get-resources.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "cloudinary-get-resources",
name: "Get Resources",
description: "Lists resources (assets) uploaded to your product environment. [See the documentation](https://cloudinary.com/documentation/admin_api#get_resources)",
version: "0.0.1",
version: "0.1.0",
type: "action",
props: {
cloudinary,
Expand All @@ -22,28 +22,35 @@ export default {
},
prefix: {
type: "string",
label: "Prefix",
description: "Find all assets with a public ID that starts with the specified prefix",
label: "Filter by Prefix",
description: "Find all assets with a public ID that starts with the specified prefix.",
optional: true,
},
tags: {
type: "boolean",
label: "Tags",
description: "Whether to include the list of tag names assigned to each asset",
label: "Include Tags",
description: "Whether to include the list of tag names assigned to each asset.",
default: false,
optional: true,
},
context: {
type: "boolean",
label: "Context",
description: "Whether to include key-value pairs of contextual metadata associated with each asset",
label: "Include Context",
description: "Whether to include key-value pairs of contextual metadata associated with each asset.",
default: false,
optional: true,
},
metadata: {
type: "boolean",
label: "Include Metadata",
description: "Whether to include the structured metadata fields and values assigned to each asset.",
default: false,
optional: true,
},
Comment on lines +43 to 49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

🛠️ Refactor suggestion

Add metadata property to options object

The review comment is correct. The metadata property is defined in the component's props but not included in the options object passed to the Cloudinary API call. Here are the specific locations that need attention:

  • In components/cloudinary/actions/get-resources/get-resources.mjs, add the metadata property to the options object in the run method:
const options = {
  resource_type: this.resourceType,
  type: this.type,
  prefix: this.prefix,
  tags: this.tags,
  context: this.context,
  moderation: this.moderation,
  metadata: this.metadata,
};
🔗 Analysis chain

Verify metadata property integration with Cloudinary API

The new metadata property is well-documented, but it needs to be included in the options object passed to the Cloudinary API.

Add the metadata property to the options object in the run method:

    const options = {
      resource_type: this.resourceType,
      type: this.type,
      prefix: this.prefix,
      tags: this.tags,
      context: this.context,
      moderation: this.moderation,
+     metadata: this.metadata,
    };

Let me verify if the metadata property is properly integrated with the Cloudinary API by checking the implementation.


Let me fix the regex and try again.

🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Check the implementation of the run method in the get-resources component
rg -A 20 "run\s*\(\s*\)\s*{" components/cloudinary/actions/get-resources/get-resources.mjs

Length of output: 190


Script:

#!/bin/bash
# Check the implementation of the run method in the get-resources component
rg "async run" -A 20 components/cloudinary/actions/get-resources/get-resources.mjs

Length of output: 674

moderation: {
type: "boolean",
label: "Moderation",
description: "Whether to include the image moderation status of each asset",
label: "Include Moderation",
description: "Whether to include the image moderation status of each asset.",
default: false,
optional: true,
},
Expand All @@ -66,22 +73,27 @@ export default {
};

const resources = [];
let next;
do {
const response = await this.cloudinary.getResources(options);
resources.push(...response.resources);
next = response.next_cursor;
options.next_cursor = next;
} while (next && resources.length < this.maxResults);
try {
let next;
do {
const response = await this.cloudinary.getResources(options);
resources.push(...response.resources);
next = response.next_cursor;
options.next_cursor = next;
} while (next && resources.length < this.maxResults);

if (resources.length > this.maxResults) {
resources.length = this.maxResults;
}
if (resources.length > this.maxResults) {
resources.length = this.maxResults;
}

$.export("$summary", `Found ${resources.length} resource${resources.length === 1
? ""
: "s"}.`);
$.export("$summary", `Retrieved ${resources.length} resource${resources.length === 1
? ""
: "s"}`);

return resources;
return resources;
}
catch (err) {
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
}
},
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { ConfigurationError } from "@pipedream/platform";
import cloudinary from "../../cloudinary.app.mjs";

export default {
key: "cloudinary-transform-resource",
name: "Transform Resource",
description: "Transform an image, video or audio asset on-the-fly with several options. [See the documentation](https://cloudinary.com/documentation/video_manipulation_and_delivery)",
version: "0.0.1",
type: "action",
props: {
cloudinary,
assetId: {
propDefinition: [
cloudinary,
"assetId",
],
},
info: {

Check warning on line 18 in components/cloudinary/actions/transform-resource/transform-resource.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 18 in components/cloudinary/actions/transform-resource/transform-resource.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: `You can either select a pre-configured transformation or pass a transformation string. Both can be managed in the [Cloudinary Transformation Builder](https://tx.cloudinary.com/).
\\
If both are specified, the transformation string will be ignored.`,
},
Comment on lines +18 to +24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure the info prop follows Pipedream guidelines.

Static analysis indicates that component props of type alert must have a label and a description. See docs.

Below is a suggested fix:

    info: {
      type: "alert",
      alertType: "info",
+     label: "Information",
+     description: "Guidance on selecting a named transformation or providing a transformation string.",
      content: `You can either select a pre-configured transformation...
If both are specified, the transformation string will be ignored.`,
    },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
info: {
type: "alert",
alertType: "info",
content: `You can either select a pre-configured transformation or pass a transformation string. Both can be managed in the [Cloudinary Transformation Builder](https://tx.cloudinary.com/).
\\
If both are specified, the transformation string will be ignored.`,
},
info: {
type: "alert",
alertType: "info",
label: "Information",
description: "Guidance on selecting a named transformation or providing a transformation string.",
content: `You can either select a pre-configured transformation or pass a transformation string. Both can be managed in the [Cloudinary Transformation Builder](https://tx.cloudinary.com/).
\\
If both are specified, the transformation string will be ignored.`,
},
🧰 Tools
🪛 GitHub Check: Lint Code Base

[warning] 18-18:
Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props


[warning] 18-18:
Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props

namedTransformation: {
propDefinition: [
cloudinary,
"namedTransformation",
],
},
transformationString: {
propDefinition: [
cloudinary,
"transformationString",
],
},
},
async run({ $ }) {
const {
cloudinary, assetId, namedTransformation, transformationString,
} = this;

if (!namedTransformation && !transformationString) {
throw new ConfigurationError("Either `Named Transformation` or `Transformation String` are required");
}

try {
const response = await cloudinary.transformAsset(assetId, namedTransformation
? {
transformation: namedTransformation,
}
: {
raw_transformation: transformationString,
});

if (response) {
$.export("$summary", "Successfully transformed resource");
}

return response;
} catch (err) {
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
}
},
};
Loading
Loading