diff --git a/components/qr_api/actions/common/base.mjs b/components/qr_api/actions/common/base.mjs new file mode 100644 index 0000000000000..3e1917426b3ec --- /dev/null +++ b/components/qr_api/actions/common/base.mjs @@ -0,0 +1,219 @@ +import fs from "fs"; +import constants from "../../common/constants.mjs"; +import { cleanObj } from "../../common/utils.mjs"; +import app from "../../qr_api.app.mjs"; + +export default { + props: { + app, + filename: { + type: "string", + label: "Filename", + description: "The filename that will be used to save in `/tmp` directory without extension", + }, + size: { + type: "string", + label: "Size", + description: "Parameter valid only if poster.url is not specified. Use this parameter to specify the size preset of the QR Code image (including Quiet Zone which is free area around QR Code to ensure scannability).", + options: constants.SIZE_OPTIONS, + optional: true, + }, + quiteZone: { + type: "string", + label: "Quiet Zone", + description: "Parameter valid only if poster.url is not specified. Use this parameter to specify the size of the Quiet Zone (which is free area around QR Code to ensure scannability). Set the Quiet Zone within a range of 0 to 12 (where 0 indicates no Quiet Zone and 12 the maximum). Tip: To achieve high scannability, it is recommended to set the Quiet Zone value to at least 4 or higher.", + options: constants.QUITE_ZONE_OPTIONS, + optional: true, + }, + customSize: { + type: "integer", + label: "Custom Size", + description: "Parameter valid only if parameter size is set to custom. Use this parameter to specify the custom size of the QR Code image in pixels (including Quiet Zone, which is free area around QR Code to ensure scannability).", + min: 300, + max: 6000, + optional: true, + }, + errorCorrection: { + type: "string", + label: "Error Correction", + description: "Use this parameter to set error correction level of the QR Code. Error Correction helps maintain scannability of the QR Code even if there is some damage to data modules. Error correction is measured in damage in percentage (%) that it can sustain. Values are L (~7%), M (~15%), Q (~25%), and H (~30%).", + options: constants.ERROR_CORRECTION_OPTIONS, + optional: true, + }, + dataPattern: { + type: "string", + label: "Data Pattern", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to edit the pattern of data modules of the QR Code. Choose pattern value from drop-down. View all the data patterns [here](https://qrapi.io/patterns-design#dataPatterns).", + options: constants.DATA_PATTERN_OPTIONS, + optional: true, + }, + eyePattern: { + type: "string", + label: "Eye Pattern", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to edit the pattern of the eyes (position markers in the three corners) of the QR Code. Choose pattern value from drop-down. View all the eye patterns [here](https://qrapi.io/patterns-design#eyePatterns).", + options: constants.EYE_PATTERN_OPTIONS, + optional: true, + }, + dataGradientStyle: { + type: "string", + label: "Data Gradient Style", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to add a color gradient style to the group of data modules. Choose style value from drop-down. View all the gradient patterns [here](https://qrapi.io/patterns-design#gradientPatterns).", + options: constants.DATA_GRADIENT_STYLE_OPTIONS, + optional: true, + }, + dataGradientStartColor: { + type: "string", + label: "Data Gradient Start Color", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to EITHER add a color (in hex format #000000) to all data modules (if data_gradient_style is set to None) OR to add the start color to data modules (if data_gradient_style is not set to None).", + optional: true, + }, + dataGradientEndColor: { + type: "string", + label: "Data Gradient End Color", + description: "Parameter valid only if poster.url is not specified and data_gradient_style is not set to None. Use this parameter to set the end color (in hex format #000000) to data modules.", + optional: true, + }, + eyeColorInner: { + type: "string", + label: "Eye Color Inner", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to specify color (in hex format #000000) to the inner component of the QR Code (all three) eyes (position markers in the three corners).", + optional: true, + }, + eyeColorOuter: { + type: "string", + label: "Eye Color Outer", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to specify color (in hex format #000000) to the outer component of the QR Code (all three) eyes (position markers in the three corners).", + optional: true, + }, + backgroundColor: { + type: "string", + label: "Background Color", + description: "Parameter valid and required only if poster.url is not specified. Use this parameter to specify color (in hex format #000000) of the QR Codes' background including non-dark data modules. To remove background (i.e. make transparent), use value false. Tip: For highest scannability keep the background color as white i.e. #FFFFFF.", + optional: true, + }, + logoUrl: { + type: "string", + label: "Logo URL", + description: "Parameter valid only if poster.url is not specified. Use this field if you want to design the QR Code with the 'Custom with Logo' feature. Otherwise, skip. Enter the URL of the image you want as a logo. Tip: Ensure the image source allows cross-domain access. Or simply use the Media feature to upload image and get URL or choose from our list of ready-made logos and icons. See the full list [here](https://qrapi.io/templates).", + optional: true, + }, + logoSize: { + type: "integer", + label: "Logo Size", + description: "Parameter valid only if data in logo.url is specified. Enter the size of the logo image as a percentage (%) of size of logo. Tip: High logo size may make the QR Code unscannable. Test thoroughly before finalizing.", + optional: true, + }, + logoExcavated: { + type: "boolean", + label: "Logo Excavated", + description: "Parameter valid only if data in logo.url is specified. Use this paramater to specify if the blocks around the logo should be remove (true) or should not be removed (false) Tip: If selecting true, set error correction to a higher-level to ensure loss of blocks doesn't affect scannability.", + optional: true, + }, + logoAngle: { + type: "integer", + label: "Logo Angle", + description: "Parameter valid only if data in logo.url is specified. Use this parameter if you wish to rotate the image at an angle. Use values 1-359 (degrees) for clockwise rotation and -1 to -359 (degrees) for anti-clockwise rotation.", + optional: true, + }, + logoCache: { + type: "boolean", + label: "Logo Cache", + description: "Parameter valid and required only if logo.url is specified. By default, it will be set to True. When set to True, the logo image provided will be cached for 10 minutes to improve performance. Set to False only if the image uploaded in the URL provided in logo.url field will change frequently, else skip.", + optional: true, + }, + posterUrl: { + type: "string", + label: "Poster URL", + description: "Use this field if you want to design the QR Code with the 'Custom with Background' feature. Otherwise, skip. Enter the URL of the image you want as a background image. Tip: Ensure the image source allows cross-domain access. Or simply use the Media feature to upload image and get URL.", + optional: true, + }, + posterLeft: { + type: "integer", + label: "Poster Left", + description: "Parameter valid only if poster.url is specified. This parameter will help you position the QR Code from the left edge of the uploaded background image. Specify value in percentage (%) where value is the distance between the left-edge of the image and the centre of the QR Code.Tip: Value 50 is placing the QR Code in the centre of the background image in terms of image width.", + optional: true, + }, + posterTop: { + type: "integer", + label: "Poster Top", + description: "Parameter valid only if poster.url is specified. This parameter will help you position the QR Code from the top edge of the uploaded background image. Specify value in percentage (%) where value is the distance between the top-edge of the image and the centre of the QR Code.Tip: Value 50 is placing the QR Code in the centre of the background image in terms of image height.", + optional: true, + }, + posterSize: { + type: "integer", + label: "Poster Size", + description: "Parameter valid only if poster.url is specified. This parameter will help you specify the size of the QR Code relative to the size of the uploaded background image. Specify value in percentage (%) where value is the ratio of QR Code size and Uploaded Image size.", + optional: true, + }, + posterEyeshape: { + type: "string", + label: "Poster Eye Shape", + description: "Parameter valid only if poster.url is specified. Use this parameter to edit the pattern of the eyes (position markers in the three corners) of the QR Code. Choose pattern value from drop-down. View all the poster eye patterns [here](https://qrapi.io/patterns-design#eyePatterns).", + options: constants.POSTER_EYE_SHAPE_OPTIONS, + optional: true, + }, + posterDataPattern: { + type: "string", + label: "Poster Data Pattern", + description: "Parameter valid only if poster.url is specified. Use this parameter to edit the pattern of data modules of the QR Code. Choose pattern value from drop-down. View all the poster data patterns [here](https://qrapi.io/patterns-design#posterDataPatterns).", + options: constants.POSTER_DATA_PATTERN_OPTIONS, + optional: true, + }, + format: { + type: "string", + label: "Format", + description: "Format of QR Code", + options: constants.FORMAT_OPTIONS, + }, + syncDir: { + type: "dir", + accessMode: "write", + sync: true, + }, + }, + async run({ $ }) { + const response = await this.app.createQrcode({ + type: this.getType(), + $, + maxBodyLength: Infinity, + responseType: "arraybuffer", + params: cleanObj({ + ...this.getParams(), + format: this.format, + size: this.size, + quite_zone: this.quiteZone && parseInt(this.quiteZone), + custom_size: this.customSize, + error_correction: this.errorCorrection, + data_pattern: this.dataPattern, + eye_pattern: this.eyePattern, + data_gradient_style: this.dataGradientStyle, + data_gradient_start_color: this.dataGradientStartColor, + data_gradient_end_color: this.dataGradientEndColor, + eye_color_inner: this.eyeColorInner, + eye_color_outer: this.eyeColorOuter, + background_color: this.backgroundColor, + ["logo.url"]: this.logoUrl, + ["logo.size"]: this.logoSize, + ["logo.excavated"]: this.logoExcavated, + ["logo.angle"]: this.logoAngle, + ["logo.cache"]: this.logoCache, + ["poster.url"]: this.posterUrl, + ["poster.left"]: this.posterLeft, + ["poster.top"]: this.posterTop, + ["poster.size"]: this.posterSize, + ["poster.eyeshape"]: this.posterEyeshape, + ["poster.dataPattern"]: this.posterDataPattern, + }), + }); + + const buffer = new Buffer.from(response); + const filePath = `/tmp/${this.filename}.${this.format}`; + fs.writeFileSync(filePath, buffer); + + $.export("$summary", "Successfully created QR Code and saved to `/tmp` directory"); + return { + filename: this.filename, + filePath, + }; + }, +}; diff --git a/components/qr_api/actions/create-email-qrcode/create-email-qrcode.mjs b/components/qr_api/actions/create-email-qrcode/create-email-qrcode.mjs new file mode 100644 index 0000000000000..c8e4f5643773f --- /dev/null +++ b/components/qr_api/actions/create-email-qrcode/create-email-qrcode.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-email-qrcode", + name: "Create Email QR Code", + description: "Create an Email QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_email_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + address: { + type: "string", + label: "Email Address", + description: "The email address you want to encode in the QR Code.", + }, + }, + methods: { + ...common.methods, + getType() { + return "email"; + }, + getParams() { + return { + address: this.address, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-googlemaps-qrcode/create-googlemaps-qrcode.mjs b/components/qr_api/actions/create-googlemaps-qrcode/create-googlemaps-qrcode.mjs new file mode 100644 index 0000000000000..69cd6294dba96 --- /dev/null +++ b/components/qr_api/actions/create-googlemaps-qrcode/create-googlemaps-qrcode.mjs @@ -0,0 +1,35 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-googlemaps-qrcode", + name: "Create Google Maps QR Code", + description: "Create a Google Maps QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_googlemaps_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + latitude: { + type: "string", + label: "Latitude", + description: "Enter the map location latitude (in degrees) you want encoded in the QR Code e.g. the latitude of Washington DC, US is 38.8951", + }, + longitude: { + type: "string", + label: "Longitude", + description: "Enter the map location longitude (in degrees) you want encoded in the QR Code e.g. the longitude of Washington DC, US is -77.0364", + }, + }, + methods: { + ...common.methods, + getType() { + return "googlemaps"; + }, + getParams() { + return { + latitude: parseFloat(this.latitude), + longitude: parseFloat(this.longitude), + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-phonecall-qrcode/create-phonecall-qrcode.mjs b/components/qr_api/actions/create-phonecall-qrcode/create-phonecall-qrcode.mjs new file mode 100644 index 0000000000000..dded3836bd9b8 --- /dev/null +++ b/components/qr_api/actions/create-phonecall-qrcode/create-phonecall-qrcode.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-phonecall-qrcode", + name: "Create Phone Call QR Code", + description: "Create a Phone Call QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_phonecall_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + number: { + type: "string", + label: "Number", + description: "The phone number you want to encode in the QR Code.", + }, + }, + methods: { + ...common.methods, + getType() { + return "phonecall"; + }, + getParams() { + return { + number: this.number, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-sms-qrcode/create-sms-qrcode.mjs b/components/qr_api/actions/create-sms-qrcode/create-sms-qrcode.mjs new file mode 100644 index 0000000000000..af741118cab80 --- /dev/null +++ b/components/qr_api/actions/create-sms-qrcode/create-sms-qrcode.mjs @@ -0,0 +1,35 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-sms-qrcode", + name: "Create SMS QR Code", + description: "Create a SMS QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_sms_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + phoneNo: { + type: "string", + label: "Phone Number", + description: "The phone number of the recipient of the SMS.", + }, + message: { + type: "string", + label: "Message", + description: "The message of the SMS.", + }, + }, + methods: { + ...common.methods, + getType() { + return "SMS"; + }, + getParams() { + return { + phone_no: this.phoneNo, + message: this.message, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-text-qrcode/create-text-qrcode.mjs b/components/qr_api/actions/create-text-qrcode/create-text-qrcode.mjs new file mode 100644 index 0000000000000..3b264d59a5b06 --- /dev/null +++ b/components/qr_api/actions/create-text-qrcode/create-text-qrcode.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-text-qrcode", + name: "Create Text QR Code", + description: "Create a Text QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_text_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + data: { + type: "string", + label: "Text", + description: "The text to be encoded in the QR Code.", + }, + }, + methods: { + ...common.methods, + getType() { + return "text"; + }, + getParams() { + return { + data: this.data, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-url-qrcode/create-url-qrcode.mjs b/components/qr_api/actions/create-url-qrcode/create-url-qrcode.mjs new file mode 100644 index 0000000000000..35d5bf869b3cc --- /dev/null +++ b/components/qr_api/actions/create-url-qrcode/create-url-qrcode.mjs @@ -0,0 +1,29 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-url-qrcode", + name: "Create URL QR Code", + description: "Create a URL QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_url_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + url: { + type: "string", + label: "URL", + description: "The URL to encode in the QR Code.", + }, + }, + methods: { + ...common.methods, + getType() { + return "url"; + }, + getParams() { + return { + url: this.url, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-vcard-qrcode/create-vcard-qrcode.mjs b/components/qr_api/actions/create-vcard-qrcode/create-vcard-qrcode.mjs new file mode 100644 index 0000000000000..9dfd6d08bfde0 --- /dev/null +++ b/components/qr_api/actions/create-vcard-qrcode/create-vcard-qrcode.mjs @@ -0,0 +1,120 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-vcard-qrcode", + name: "Create VCard QR Code", + description: "Create a VCard QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_vcard_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + uname: { + type: "string", + label: "Uname", + description: "Enter full name of contact you want encoded in the Vcard.", + }, + title: { + type: "string", + label: "Title", + description: "Enter title/designation of contact you want encoded in the Vcard.", + optional: true, + }, + company: { + type: "string", + label: "Company", + description: "Enter company name of contact you want encoded in the Vcard.", + optional: true, + }, + department: { + type: "string", + label: "Department", + description: "Enter department name you want encoded in the Vcard.", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "Enter email address of contact you want encoded in the Vcard.", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "Enter phone number of contact you want encoded in the Vcard.", + optional: true, + }, + homePhone: { + type: "string", + label: "Home Phone", + description: "Enter cell number of contact you want encoded in the Vcard.", + optional: true, + }, + fax: { + type: "string", + label: "Fax", + description: "Enter fax number of contact you want encoded in the Vcard.", + optional: true, + }, + website: { + type: "string", + label: "Website", + description: "Enter website URL of contact you want encoded in the Vcard.", + optional: true, + }, + street: { + type: "string", + label: "Street", + description: "Enter street address of contact you want encoded in the Vcard.", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "Enter city name of contact you want encoded in the Vcard.", + optional: true, + }, + state: { + type: "string", + label: "State", + description: "Enter state name of contact you want encoded in the Vcard.", + optional: true, + }, + postal_code: { + type: "string", + label: "Postal Code", + description: "Enter zip/postal code of contact you want encoded in the Vcard.", + optional: true, + }, + country: { + type: "string", + label: "Country", + description: "Enter country name of contact you want encoded in the Vcard.", + optional: true, + }, + }, + methods: { + ...common.methods, + getType() { + return "vcard"; + }, + getParams() { + return { + uname: this.uname, + title: this.title, + company: this.company, + department: this.department, + email: this.email, + phone: this.phone, + homePhone: this.homePhone, + fax: this.fax, + website: this.website, + street: this.street, + city: this.city, + state: this.state, + postal_code: this.postal_code, + country: this.country, + }; + }, + }, +}; diff --git a/components/qr_api/actions/create-wifi-qrcode/create-wifi-qrcode.mjs b/components/qr_api/actions/create-wifi-qrcode/create-wifi-qrcode.mjs new file mode 100644 index 0000000000000..fed1e3466de3b --- /dev/null +++ b/components/qr_api/actions/create-wifi-qrcode/create-wifi-qrcode.mjs @@ -0,0 +1,45 @@ +import constants from "../../common/constants.mjs"; +import common from "../common/base.mjs"; + +export default { + ...common, + key: "qr_api-create-wifi-qrcode", + name: "Create WiFi QR Code", + description: "Create a WiFi QR Code. [See the documentation](https://qrapi.io/api-documentation/#/qrcode/create_wifi_qr_code)", + version: "0.0.1", + type: "action", + props: { + ...common.props, + ssid: { + type: "string", + label: "SSID", + description: "The SSID of the WiFi network.", + }, + authentication: { + type: "string", + label: "Authentication", + description: "The security protocol of the WiFi network. If you're not sure, check security setting in network properties.", + options: constants.AUTHENTICATION_OPTIONS, + optional: true, + }, + psk: { + type: "string", + label: "PSK", + description: "The password of the WiFi network.", + optional: true, + }, + }, + methods: { + ...common.methods, + getType() { + return "wifi"; + }, + getParams() { + return { + ssid: this.ssid, + authentication: this.authentication, + psk: this.psk, + }; + }, + }, +}; diff --git a/components/qr_api/common/constants.mjs b/components/qr_api/common/constants.mjs new file mode 100644 index 0000000000000..03c067773efef --- /dev/null +++ b/components/qr_api/common/constants.mjs @@ -0,0 +1,183 @@ +const SIZE_OPTIONS = [ + "s", + "m", + "l", + "xl", + "xxl", + "xxxl", + "custom", +]; + +const QUITE_ZONE_OPTIONS = [ + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", +]; + +const ERROR_CORRECTION_OPTIONS = [ + "L", + "M", + "Q", + "H", +]; + +const DATA_PATTERN_OPTIONS = [ + "RECT", + "ROUND", + "MINI_LEAF", + "CHIPS", + "FIREFLY", + "ROUNDED_CORNERS", + "VERTICAL_PIPES", + "HORIZONTAL_PIPES", + "VERTICAL_NIGHT_LIFE", + "HORIZONTAL_NIGHT_LIFE", + "PANCARDS", + "CURVED_RECTS", + "NAWABI_DARWAZA", + "ROTATED_SQUARES", + "ROTATED_RECTS", + "HAND_IN_HANDS", + "RANDOM_ROTATE", + "ALTERNATE_DIAGONAL", + "CIRCLE_ON_CORNERS", + "CONNECTED_HAMMERS", + "CONNECTED_CIRCLES", + "POINTED_BEAKS", + "MAZE", + "CURVED_MAZE", + "TRIANGLES", + "VERTICAL_TRIANGLES", + "HORIZONTAL_TRIANGLES", + "HUT", + "CIRCULAR_DIAGONAL", + "LIGHT_CIRCLE", + "LIGHT_SQUARE", + "LIGHT_ROUNDED_CORNERS", + "LIGHT_CIRCLE_SQUARE", + "NOOVERLAP_ROUND_CORNER", +]; + +const EYE_PATTERN_OPTIONS = [ + "RECT_RECT", + "ROUND_RECT", + "RECT_CIRC", + "ROUNDRECT_CIRC", + "CIRC_CIRC", + "BR_LEAF", + "TR_LEAF", + "BL_LEAF", + "TL_LEAF", + "TLBR_LEAF", + "TRBL_LEAF", + "TRBL_LEAF_CIRC", + "TLBR_LEAF_CIRC", + "TRBL_LEAF_DIAD", + "RECT_DIAD", + "UNI_LEAF", + "BLOAT_RECT", + "WARP_RECT0", + "CURVE_RECT", + "DIST_RECT", + "ZIGZAG", + "WARP_RECT1", + "BLACK_HOLE", + "STAR", + "GRID", + "SCION", + "OCTAGON", + "FLOWER", + "HUT", + "DARK_HUT", +]; + +const DATA_GRADIENT_STYLE_OPTIONS = [ + "Horizontal", + "Vertical", + "Diagonal", + "ReverseDiagonal", + "Radial", + "Eye_Horizontal", + "Eye_Vertical", + "Eye_Diagonal", + "Eye_ReverseDiagonal", + "Eye_Radial", + "None", +]; + +const POSTER_EYE_SHAPE_OPTIONS = [ + "RECT_RECT", + "ROUND_RECT", + "RECT_CIRC", + "ROUNDRECT_CIRC", + "CIRC_CIRC", + "BR_LEAF", + "TR_LEAF", + "BL_LEAF", + "TL_LEAF", + "TLBR_LEAF", + "TRBL_LEAF", + "TRBL_LEAF_CIRC", + "TLBR_LEAF_CIRC", + "TRBL_LEAF_DIAD", + "RECT_DIAD", + "UNI_LEAF", + "BLOAT_RECT", + "WARP_RECT0", + "CURVE_RECT", + "DIST_RECT", + "ZIGZAG", + "WARP_RECT1", + "BLACK_HOLE", + "STAR", + "GRID", + "SCION", + "OCTAGON", + "FLOWER", + "HUT", + "DARK_HUT", +]; + +const POSTER_DATA_PATTERN_OPTIONS = [ + "ROUND", + "SQUARE", + "DIAMONDS", + "OVAL", +]; + +const FORMAT_OPTIONS = [ + "png", + "jpg", + "svg", + "pdf", + "eps", +]; + +const AUTHENTICATION_OPTIONS = [ + "WPA", + "WEP", + "unencrypted", +]; + +export default { + SIZE_OPTIONS, + QUITE_ZONE_OPTIONS, + ERROR_CORRECTION_OPTIONS, + DATA_PATTERN_OPTIONS, + EYE_PATTERN_OPTIONS, + DATA_GRADIENT_STYLE_OPTIONS, + POSTER_EYE_SHAPE_OPTIONS, + POSTER_DATA_PATTERN_OPTIONS, + FORMAT_OPTIONS, + AUTHENTICATION_OPTIONS, +}; diff --git a/components/qr_api/common/utils.mjs b/components/qr_api/common/utils.mjs new file mode 100644 index 0000000000000..84d95389e3876 --- /dev/null +++ b/components/qr_api/common/utils.mjs @@ -0,0 +1,16 @@ +export const cleanObj = (obj) => { + return Object.entries(obj) + .filter(([ + , + v, + ]) => (v != null && v != "" && JSON.stringify(v) != "{}")) + .reduce((acc, [ + k, + v, + ]) => ({ + ...acc, + [k]: (!Array.isArray(v) && v === Object(v)) + ? cleanObj(v) + : v, + }), {}); +}; diff --git a/components/qr_api/package.json b/components/qr_api/package.json index ed2504025a6fd..de5f166600b90 100644 --- a/components/qr_api/package.json +++ b/components/qr_api/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/qr_api", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream QR API Components", "main": "qr_api.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/components/qr_api/qr_api.app.mjs b/components/qr_api/qr_api.app.mjs index 2f6438e079a8b..2cdf626efec30 100644 --- a/components/qr_api/qr_api.app.mjs +++ b/components/qr_api/qr_api.app.mjs @@ -1,11 +1,34 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "qr_api", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://qrapi.io/v2"; + }, + _params(params = {}) { + return { + api_key: this.$auth.api_key, + ...params, + }; + }, + _makeRequest({ + $ = this, path, params = {}, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + params: this._params(params), + ...opts, + }); + }, + createQrcode({ + type, ...opts + }) { + return this._makeRequest({ + path: `/qrcode/${type}`, + ...opts, + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2566e58986c87..aa67533617443 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6797,8 +6797,7 @@ importers: components/humanloop: {} - components/humantic_ai: - specifiers: {} + components/humantic_ai: {} components/humor_api: dependencies: @@ -11480,7 +11479,11 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/qr_api: {} + components/qr_api: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/qryptal: {} @@ -12646,8 +12649,7 @@ importers: specifier: ^4.0.0 version: 4.0.1 - components/securityscorecard: - specifiers: {} + components/securityscorecard: {} components/securitytrails: dependencies: @@ -30986,22 +30988,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@10.0.0: resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==}