@nxtedition/deepstream.io-client-js 28.0.2 → 28.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "28.0.2",
3
+ "version": "28.1.1",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -81,6 +81,7 @@ ACTIONS.CHALLENGE = 'CH'
81
81
  ACTIONS.CHALLENGE_RESPONSE = 'CHR'
82
82
  ACTIONS.READ = 'R'
83
83
  ACTIONS.UPDATE = 'U'
84
+ ACTIONS.PUT = 'P'
84
85
  ACTIONS.SUBSCRIBE = 'S'
85
86
  ACTIONS.SYNC = 'SY'
86
87
  ACTIONS.UNSUBSCRIBE = 'US'
@@ -398,6 +398,15 @@ class RecordHandler {
398
398
  }
399
399
  }
400
400
 
401
+ put(name, ...args) {
402
+ const record = this.getRecord(name)
403
+ try {
404
+ return record.put(...args)
405
+ } finally {
406
+ record.unref()
407
+ }
408
+ }
409
+
401
410
  /**
402
411
  *
403
412
  * @param {*} name
@@ -183,6 +183,26 @@ class Record {
183
183
  }
184
184
  }
185
185
 
186
+ put(version, data) {
187
+ const connection = this._handler._connection
188
+
189
+ if (typeof version !== 'string' || !/^\d+-.+/.test(version)) {
190
+ throw new Error('invalid argument: version')
191
+ }
192
+
193
+ if (!utils.isPlainObject(data)) {
194
+ throw new Error('invalid argument: data')
195
+ }
196
+
197
+ connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, [
198
+ this._name,
199
+ version,
200
+ jsonPath.stringify(data),
201
+ ])
202
+
203
+ this._onUpdate([this._name, version, jsonPath.stringify(data), 'F'])
204
+ }
205
+
186
206
  when(stateOrNil, optionsOrNil) {
187
207
  invariant(this._refs > 0, 'missing refs')
188
208