UNPKG

@hijiriishi/piece-myjvn

Version:

This package is an Activepieces piece for integrating with MyJVM. Information on vulnerabilities and countermeasures for software used in Japan, provided through the MyJVN API.

82 lines 3.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAlertList = void 0; const tslib_1 = require("tslib"); const pieces_framework_1 = require("@activepieces/pieces-framework"); const pieces_common_1 = require("@activepieces/pieces-common"); const pieces_common_2 = require("@activepieces/pieces-common"); const common_1 = require("../common"); const zod_1 = require("zod"); exports.getAlertList = (0, pieces_framework_1.createAction)({ name: 'get-alertlist', displayName: 'Get Alert List', description: 'fetch the list of security warnings and advisories.', props: { startItem: pieces_framework_1.Property.Number({ displayName: 'startItem', description: 'Start entry index (1 or greater))', required: false, defaultValue: 1 }), maxCountItem: pieces_framework_1.Property.Number({ displayName: 'maxCountItem', description: 'Number of Entries to Retrieve (1 to 50)', required: false, defaultValue: 50 }), datePublished: pieces_framework_1.Property.ShortText({ displayName: 'datePublished', description: 'Last Updated Year (YYYY)', required: false, }), dateFirstPublished: pieces_framework_1.Property.ShortText({ displayName: 'dateFirstPublished', description: 'First Published Year (YYYY)', required: false, }), cpeName: pieces_framework_1.Property.Array({ displayName: 'cpeNames', description: 'CPE Product Name (Format: cpe:/{part}:{vendor}:{product})', required: false, defaultValue: [], }), ft: common_1.myjvnCommon.ft, }, run(context) { return tslib_1.__awaiter(this, void 0, void 0, function* () { yield pieces_common_2.propsValidation.validateZod(context.propsValue, { startItem: zod_1.z.number().min(1, 'startItem (1 or greater)').optional(), maxCountItem: zod_1.z.number().min(1).max(50, 'maxCountItem (1 to 50)').optional(), datePublished: zod_1.z.string().regex(/^\d{4}$/, 'datePublished (YYYY)').optional(), dateFirstPublished: zod_1.z.string().regex(/^\d{4}$/, 'dateFirstPublished (YYYY)').optional(), }); const { startItem, maxCountItem, datePublished, dateFirstPublished, cpeName, ft } = context.propsValue; const payload = new URLSearchParams({ method: 'getAlertList', feed: 'hnd', }); if (startItem) payload.append('startItem', startItem.toString()); if (maxCountItem) payload.append('maxCountItem', maxCountItem.toString()); if (datePublished) payload.append('datePublished', datePublished); if (dateFirstPublished) payload.append('dateFirstPublished', dateFirstPublished); if (cpeName && cpeName.length > 0) payload.append('cpeName', cpeName.join('+')); if (ft) payload.append('ft', ft); const res = yield pieces_common_1.httpClient.sendRequest({ method: pieces_common_1.HttpMethod.POST, url: common_1.myjvnCommon.baseUrl, headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: payload.toString(), }); return res.body; }); }, }); //# sourceMappingURL=get-alertlist.js.map