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

rxws

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxws - npm Package Compare versions

Comparing version 3.1.1 to 3.2.1

47

lib/post.spec.js

@@ -131,2 +131,49 @@ 'use strict';

fit('should make a request with extra resources', function () {
(0, _post2.default)('users.posts.comments', {
name: 'test'
}, {
parameters: {
users: 1234,
posts: 1236
},
extraResources: {
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
}).subscribe(function () {});
expect(backend.write).toHaveBeenCalled();
var request = JSON.parse(backend.write.calls.argsFor(0));
expect((0, _testUtils.messagesAreEqual)(request, {
"header": {
"resource": "post.users.posts.comments",
"parameters": {
users: 1234,
posts: 1236
}
},
"body": {
"comments": {
name: 'test'
},
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
})).toBe(true);
});
it('should throw when no resource is passed', function () {

@@ -133,0 +180,0 @@ expect(function () {

2

lib/request.js

@@ -99,3 +99,3 @@ 'use strict';

var observerObj = requestMap[JSON.parse(message).header.correlationId];
if (!observerObj) throw new Error('No associated request to retry', rawMessage);
if (!observerObj) throw new Error('No associated request to retry', message);

@@ -102,0 +102,0 @@ var request = observerObj.request;

'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _request = require('./request');

@@ -15,4 +17,2 @@

function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
/* istanbul ignore next */

@@ -19,0 +19,0 @@ describe('request', function () {

@@ -52,2 +52,5 @@ 'use strict';

var extraResources = config.extraResources || {};
delete config.extraResources;
var correlationId = (0, _nodeUuid2.default)();

@@ -64,5 +67,5 @@ var resourceList = config.resource.split('.');

}),
body: _defineProperty({}, resourceList[resourceList.length - 1], body)
body: _extends({}, extraResources, _defineProperty({}, resourceList[resourceList.length - 1], body))
};
};
}

@@ -77,3 +77,35 @@ 'use strict';

});
it('should generate request object with extra resource bodies', function () {
var request = (0, _utils.generateRequestObject)({})({
resource: 'groups.forms.sections.subSections.blocks.questions',
method: 'get',
parameters: {
groups: 1,
forms: 2,
sections: 3,
subSections: 4,
blocks: 5,
questions: 4
},
data: {
stuff: 1
},
extraResources: {
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
});
expect(request.body.notifications.template).toBe('client-invite');
expect(request.body.invoices.id).toBe(123);
expect(request.extraResources).not.toBeDefined();
});
});
});
{
"name": "rxws",
"version": "3.1.1",
"version": "3.2.1",
"description": "A RESTful reactive JavaScript implmentation on top of web sockets",

@@ -5,0 +5,0 @@ "main": "lib/rxws.js",

@@ -186,1 +186,13 @@ # RxWS

`rxws.onMessage(type: string): observable`
`config obbject:`
```javascript
{
resource: string,
method: string,
parameters: object,
data: object,
extraResources: object,
queryParameters: object
}
```

@@ -123,2 +123,49 @@ import post from './post';

fit('should make a request with extra resources', () => {
post('users.posts.comments', {
name: 'test'
}, {
parameters: {
users: 1234,
posts: 1236
},
extraResources: {
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
}).subscribe(() => {});
expect(backend.write).toHaveBeenCalled();
let request = JSON.parse(backend.write.calls.argsFor(0));
expect(messagesAreEqual(request, {
"header": {
"resource": "post.users.posts.comments",
"parameters": {
users: 1234,
posts: 1236
}
},
"body": {
"comments": {
name: 'test'
},
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
})).toBe(true);
});
it('should throw when no resource is passed', () => {

@@ -125,0 +172,0 @@ expect(function() { post('').subscribe(function() {}) }).toThrow();

@@ -85,3 +85,3 @@ import { Observable } from 'rx';

let observerObj = requestMap[JSON.parse(message).header.correlationId];
if (!observerObj) throw new Error('No associated request to retry', rawMessage);
if (!observerObj) throw new Error('No associated request to retry', message);

@@ -88,0 +88,0 @@ let request = observerObj.request;

@@ -33,8 +33,11 @@ import uuid from 'node-uuid';

let body = config.data;
const body = config.data;
delete config.data;
let correlationId = uuid();
let resourceList = config.resource.split('.');
const extraResources = config.extraResources || {};
delete config.extraResources;
const correlationId = uuid();
const resourceList = config.resource.split('.');
if (config.method === 'remove') config.method = 'delete';

@@ -51,2 +54,3 @@ config.resource = config.method + '.' + config.resource;

body: {
...extraResources,
[resourceList[resourceList.length - 1]]: body

@@ -53,0 +57,0 @@ }

@@ -75,3 +75,35 @@ import { generateRequestObject } from './utils';

});
it('should generate request object with extra resource bodies', () => {
const request = generateRequestObject({})({
resource: 'groups.forms.sections.subSections.blocks.questions',
method: 'get',
parameters: {
groups: 1,
forms: 2,
sections: 3,
subSections: 4,
blocks: 5,
questions: 4
},
data: {
stuff: 1
},
extraResources: {
notifications: {
template: 'client-invite',
url: 'https:/./app.canopytax.com'
},
invoices: {
id: 123,
name: 'your mom'
}
}
})
expect(request.body.notifications.template).toBe('client-invite');
expect(request.body.invoices.id).toBe(123);
expect(request.extraResources).not.toBeDefined();
});
});
});
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