New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kar-sdk

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kar-sdk - npm Package Compare versions

Comparing version 1.2.3 to 1.3.0

19

index.d.ts

@@ -161,3 +161,3 @@ // Type definitions for [KAR] [0.1.0]

*/
export function call (callee: Actor, path: string, ...args: any[]): Promise<any>;
export function rootCall (callee: Actor, path: string, ...args: any[]): Promise<any>;

@@ -172,3 +172,7 @@ /**

/**
* Construct a result object that encodes a tail call to another actor method
* Construct a result object that encodes a tail call to another actor method.
* If the calling and callee Actors are the same, the actor lock is retained
* between the two calls. This ensures that the Actor's state is not changed between
* the end of the calling method and the start of the callee method.
*
* @param callee The target Actor.

@@ -180,2 +184,13 @@ * @param path The actor method to invoke.

/**
* Construct a result object that encodes a tail call to another actor method.
* The lock on the current actor instance will be released even if the invoked
* method is on the same actor (it will be reacquired on invocation).
*
* @param callee The target Actor.
* @param path The actor method to invoke.
* @param args The arguments with which to invoke the actor method.
*/
export function tailCallReleasingLock(callee: Actor, path: string, ...args: any[]): any;
namespace reminders {

@@ -182,0 +197,0 @@ /**

@@ -149,2 +149,3 @@ /*

// call (callee:Actor, path:string, ...args:any[]):Promise<any>;
// TODO: Once we release an SDK with rootCall, then remove this option
const ta = args.shift()

@@ -162,2 +163,9 @@ const path = args.shift()

function actorRootCall (...args) {
// call (callee:Actor, path:string, ...args:any[]):Promise<any>;
const ta = args.shift()
const path = args.shift()
return postActor(`actor/${ta.kar.type}/${ta.kar.id}/call/${path}`, args, { 'Content-Type': 'application/kar+json' })
}
function actorAsyncCall (...args) {

@@ -185,2 +193,9 @@ if (typeof args[1] === 'string') {

function actorEncodeTailCallReleasingLock (...args) {
const ta = args.shift()
const path = args.shift()
const payload = JSON.stringify(args)
return { tailCall: true, value: { actorType: ta.kar.type, actorId: ta.kar.id, releaseLock: 'true', path: '/' + path, payload } }
}
const actorDelete = (actor) => del(`actor/${actor.kar.type}/${actor.kar.id}`)

@@ -297,3 +312,3 @@

table[req.params.type][req.params.id] = actor
table[req.params.type][req.params.id].kar = { type: req.params.type, id: req.params.id }
table[req.params.type][req.params.id].kar = { type: req.params.type, id: req.params.id, session: req.query.session }
}) // instantiate actor and add to index

@@ -303,3 +318,6 @@ .then(_ => { // run optional activate callback

})
.then(_ => res.sendStatus(201)) // Created
.then(_ => {
table[req.params.type][req.params.id].kar.session = undefined
return res.sendStatus(201) // Created
})
.catch(next)

@@ -325,3 +343,3 @@ })

// method invocation route
router.post('/kar/impl/v1/actor/:type/:id/:session/:method', (req, res, next) => {
router.post('/kar/impl/v1/actor/:type/:id/:method', (req, res, next) => {
const Actor = actors[req.params.type]

@@ -332,6 +350,6 @@ if (Actor == null) return res.status(404).type('text/plain').send(`no actor type ${req.params.type}`)

if (!(req.params.method in actor)) return res.status(404).type('text/plain').send(`no ${req.params.method} in actor with type ${req.params.type} and id ${req.params.id}`)
const priorSession = actor.kar.session
return Promise.resolve()
.then(_ => {
// NOTE: session intentionally not cleared before return (could be nested call in same session)
actor.kar.session = req.params.session
actor.kar.session = req.query.session
if (typeof actor[req.params.method] === 'function') return actor[req.params.method](...req.body)

@@ -341,2 +359,3 @@ return actor[req.params.method]

.then(value => {
actor.kar.session = priorSession
if (value === undefined) {

@@ -352,3 +371,6 @@ return res.status(204).send()

})
.catch(next)
.catch(_ => {
actor.kar.session = priorSession
next()
})
})

@@ -387,5 +409,7 @@

call: actorCall,
rootCall: actorRootCall,
asyncCall: actorAsyncCall,
remove: actorDelete,
tailCall: actorEncodeTailCall,
tailCallReleaasingLock: actorEncodeTailCallReleasingLock,
reminders: {

@@ -392,0 +416,0 @@ cancel: actorCancelReminder,

2

package.json

@@ -5,3 +5,3 @@ {

"types": "index.d.ts",
"version": "1.2.3",
"version": "1.3.0",
"description": "KAR SDK for JavaScript and TypeScript",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/IBM/kar",

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