Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@serverless/platform-client

Package Overview
Dependencies
Maintainers
7
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@serverless/platform-client - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9-beta

src/webhooks.js

2

package.json
{
"name": "@serverless/platform-client",
"version": "1.1.8",
"version": "1.1.9-beta",
"main": "./src/index.js",

@@ -5,0 +5,0 @@ "jsdelivr": "dist-web/serverless-platform-client.min.js",

@@ -12,3 +12,4 @@ {

"dashboard": "https://app.serverless-dev.com",
"providers": "https://sp-providers-v1.serverless-platform-dev.com"
"providers": "https://sp-providers-v1.serverless-platform-dev.com",
"event-webhooks": "https://event-webhooks-v1.serverless-platform-dev.com"
},

@@ -22,4 +23,5 @@ "prod": {

"dashboard": "https://app.serverless.com",
"providers": "https://sp-providers-v1.serverless-platform.com"
"providers": "https://sp-providers-v1.serverless-platform.com",
"event-webhooks": "https://event-webhooks-v1.serverless-platform.com"
}
}

@@ -13,2 +13,3 @@ 'use strict';

const Eventer = require('./Eventer');
const webhooks = require('./webhooks');
const utils = require('./utils');

@@ -420,10 +421,6 @@

*/
async getProvidersByOrgServiceInstance(orgUid, serviceUid, instanceUid) {
return resources.getProvidersByOrgServiceInstance(this, orgUid, serviceUid, instanceUid);
async getProviderByOrgServiceInstance(orgUid, serviceUid, instanceUid) {
return resources.getProviderByOrgServiceInstance(this, orgUid, serviceUid, instanceUid);
}
async getProvidersByLink(orgUid, linkType, linkUid) {
return resources.getProvidersByLink(this, orgUid, linkType, linkUid);
}
/**

@@ -492,3 +489,3 @@ *

/**
* Retrieve a Serverless Platform Event synchronously via HTTP API.
* Retrieve a Serverless Platform Event.
* @param {string} uid UID of event to be fetched

@@ -511,3 +508,3 @@ * @returns {object} An event object if a valid id was provided. All events share a common structure, detailed below. The only property that will differ is the `data` payload.

*/
async getEvent(uid) {
getEvent(uid) {
return this.eventer.getEvent(uid);

@@ -517,3 +514,3 @@ }

/**
* List all events synchronously via HTTP API.
* List all Serverless Platform events.
* @param {Object} options List options

@@ -800,2 +797,163 @@ * @param {string} options.org_name The name of the Serverless Platform Organization. Optional. By default, fetches events under the connecting organization.

}
/**
* Registers a webhook endpoint to receive Serverless Platform events. Endpoint should be able to receieve JSON formatted event as a HTTP POST payload.
* @param {string} url HTTP webhook endpoint URL.
* @param {string} options.description An optional description of what the webhook is used for.
* @param {object} options.filter Optionally, filter which events this endpoint should receive.
* @param {object} options.filter.enabled_events The list of events to enable for this endpoint. `["*"]` indicates that all events are enabled.
* @param {string} options.filter.stage_name Only receive events on a specific stage. If not set, will receive events from all app stages.
* @param {string} options.filter.app_name Only receive events on a specific app. If not set, will receive events from all apps.
* @param {string} options.filter.instance_name Only receive events on a specific service. If not set, will receive events from all services.
* @returns {Promise<object>} Registered webhook endpoint.
* ```json
* {
* "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
* "object": "webhook_endpoint",
* "url": "https://postb.in/1598300732037-0682672155089",
* "description": "This is my webhook, I like it a lot",
* "filter": {
* "enabled_events": ["*"],
* "stage_name": "dev",
* "app_name": "test-app",
* "instance_name": "test-instance"
* },
* "status": {
* "disabled": false,
* "most_recent_delivery": null
* },
* "created": 1593710260258
* }
* ```
*/
registerWebhook(url, options = {}) {
return webhooks.register(this, url, options.description, options.filter || {});
}
/**
* Lists all regsitered webhook endpoints.
* @param {string} options.starting_after A cursor for use in pagination. `starting_after` is a webhook endpoint object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with `whe_foo`, your subsequent call can include `starting_after=whe_foo` in order to fetch the next page of the list.
* @param {number} options.limit A limit on the number of webhook endpoints to be returned. Limit can range between 1 and 100, and the default is 10.
* @returns {Promise<object>} A dictionary with a `data` property that contains an array, with each entry being a `webhook` object.
* ```json
* {
* "object": "list",
* "data": [
* {
* "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
* "object": "webhook_endpoint",
* "url": "https://postb.in/1598300732037-0682672155089",
* "description": "This is my webhook, I like it a lot",
* "filter": {
* "enabled_events": ["*"],
* "stage_name": "dev",
* "app_name": "test-app",
* "instance_name": "test-instance"
* },
* "status": {
* "disabled": false,
* "most_recent_delivery": {
* "event_uid": "evt_5cmXN7kqdu5YY69HFKegmiGR",
* "response_status_code": 200,
* "response_text": "{\"ok\": true}"
* }
* },
* "created": 1593710260258
* },
* {...},
* {...}
* ]
* }
* ```
*/
listWebhooks(options = {}) {
const { starting_after: startingAfter, limit = 10 } = options;
return webhooks.list(this, startingAfter, limit);
}
/**
* Retrieves the webhook endpoint with the given ID.
* @param {string} uid Webhook endpoint ID.
* @returns {Promise<object>} A webhook endpoint if a valid webhook endpoint ID was provided.
* ```json
* {
* "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
* "object": "webhook_endpoint",
* "url": "https://postb.in/1598300732037-0682672155089",
* "description": "This is my webhook, I like it a lot",
* "filter": {
* "enabled_events": ["*"],
* "stage_name": "dev",
* "app_name": "test-app",
* "instance_name": "test-instance"
* },
* "status": {
* "disabled": false,
* "most_recent_delivery": {
* "event_uid": "evt_5cmXN7kqdu5YY69HFKegmiGR",
* "response_status_code": 200,
* "response_text": "{\"ok\": true}"
* }
* },
* "created": 1593710260258
* }
*/
getWebhook(uid) {
return webhooks.get(this, uid);
}
/**
* Updates the registered webhook endpoint. You may edit the url, description, the list of filters, and the status of your endpoint.
* @param {string} uid Webhook endpoint ID.
* @param {string} updates.url HTTP webhook endpoint url, if updating.
* @param {string} updates.description An optional updated description of what the webhook is used for.
* @param {object} updates.filter Optionally, update filter which events this endpoint should receive. An existing filter can reset by setting it to `null`.
* @param {object} updates.filter.enabled_events The list of events to enable for this endpoint. `["*"]` indicates that all events are enabled.
* @param {string} updates.filter.stage_name Only receive events on a specific stage. If not set, will receive events from all app stages.
* @param {string} updates.filter.app_name Only receive events on a specific app. If not set, will receive events from all apps.
* @param {string} updates.filter.instance_name Only receive events on a specific service. If not set, will receive events from all services.
* @param {boolean} updates.status.disabled Enable/disable the webhook endpoint.
* @returns {Promise<object>} Updated webhook endpoint.
* ```json
* {
* "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
* "object": "webhook_endpoint",
* "url": "https://postb.in/1598300732037-0682672155089",
* "description": "This is my webhook, I like it a lot",
* "filter": {
* "enabled_events": ["*"],
* "stage_name": "dev",
* "app_name": "test-app",
* "instance_name": "test-instance"
* },
* "status": {
* "disabled": false,
* "most_recent_delivery": {
* "event_uid": "evt_5cmXN7kqdu5YY69HFKegmiGR",
* "response_status_code": 200,
* "response_text": "{\"ok\": true}"
* }
* },
* "created": 1593710260258
* }
* ```
*/
updateWebhook(uid, updates) {
return webhooks.update(this, uid, updates || {});
}
/**
* Deletes the webhook endpoint with the given ID.
* @param {string} uid Webhook endpoint ID.
* @returns {Promise<object>} An object with the deleted webhook endpoints’s ID if a valid webhook endpoint ID was provided. Otherwise, this call throws an error, such as if the webhook endpoint has already been deleted.
* ```json
* {
* "uid": "whk_2y9fUcnZroc8BhMjC26tQdg8",
* "object": "webhook_endpoint",
* "deleted": true
* }
*/
deleteWebhook(uid) {
return webhooks.remove(this, uid);
}
}

@@ -802,0 +960,0 @@

@@ -195,6 +195,2 @@ 'use strict';

* Create initToken for a tenant/user pair
*
* @param {*} sdk
* @param {*} orgName
* @param {*} data
*/

@@ -217,5 +213,2 @@ const createInitToken = async (sdk, orgName = null, data) => {

* Fetch initToken by ID
*
* @param {*} sdk
* @param {*} tokenUid
*/

@@ -234,5 +227,2 @@ const getInitToken = async (sdk, tokenUid) => {

* Get providers by Org
*
* @param {*} sdk
* @param {*} orgUid
*/

@@ -251,6 +241,2 @@ const getProviders = async (sdk, orgUid) => {

* Create a Provider
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} data
*/

@@ -270,6 +256,2 @@ const createProvider = async (sdk, orgUid, data) => {

* Get a Provider
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} providerUid
*/

@@ -288,7 +270,2 @@ const getProvider = async (sdk, orgUid, providerUid) => {

* Update a Provider
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} providerUid
* @param {*} data
*/

@@ -308,6 +285,2 @@ const updateProvider = async (sdk, orgUid, providerUid, data) => {

* Delete a Provider
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} providerUid
*/

@@ -326,8 +299,2 @@ const deleteProvider = async (sdk, orgUid, providerUid) => {

* Create a providerLink
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} linkType
* @param {*} linkUid
* @param {*} providerUid
*/

@@ -349,7 +316,2 @@ const createProviderLink = async (sdk, orgUid, linkType, linkUid, providerUid) => {

* Destroy a providerLink
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} linkType
* @param {*} linkUid
*/

@@ -367,27 +329,5 @@ const deleteProviderLink = async (sdk, orgUid, linkType, linkUid) => {

/**
* Get providers by Link
* @param {*} sdk
* @param {*} orgUid
* @param {*} linkType
* @param {*} linkUid
*/
const getProvidersByLink = async (sdk, orgUid, linkType, linkUid) => {
const endpoint = `${sdk.getDomain('providers')}/orgs/${orgUid}/${linkType}s/${linkUid}`;
return await utils.request({
accessKey: sdk.accessKey,
endpoint,
method: 'GET',
});
};
/**
* Get providers by Org, Service, and Instance
*
* @param {*} sdk
* @param {*} orgUid
* @param {*} serviceUid
* @param {*} instanceUid
*/
const getProvidersByOrgServiceInstance = async (sdk, orgUid, serviceUid, instanceUid) => {
const getProviderByOrgServiceInstance = async (sdk, orgUid, serviceUid, instanceUid) => {
const endpoint = `${sdk.getDomain(

@@ -421,3 +361,3 @@ 'providers'

getProvider,
getProvidersByOrgServiceInstance,
getProviderByOrgServiceInstance,
createProvider,

@@ -428,3 +368,2 @@ updateProvider,

deleteProviderLink,
getProvidersByLink,
};

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc