@knowlearning/agents 0.9.187 → 0.9.188

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.
@@ -1,6 +1,7 @@
1
1
  import { validate as isUUID, v1 as uuid } from 'uuid'
2
2
  import PatchProxy from '@knowlearning/patch-proxy'
3
3
  import watchImplementation from './watch.js'
4
+ import sync from './sync.js'
4
5
 
5
6
  export default function EmbeddedAgent(postMessage) {
6
7
  let messageIndex = 0
@@ -227,6 +228,7 @@ export default function EmbeddedAgent(postMessage) {
227
228
  synced,
228
229
  close,
229
230
  response,
231
+ sync,
230
232
  query
231
233
  }
232
234
  }
@@ -4,6 +4,7 @@ import messageQueue from './message-queue.js'
4
4
  import stateImplementation from './state.js'
5
5
  import watchImplementation from '../watch.js'
6
6
  import downloadImplementation from '../download.js'
7
+ import sync from '../sync.js'
7
8
 
8
9
  // TODO: consider using something better than name as mechanism
9
10
  // for resoling default scope in context
@@ -229,6 +230,7 @@ export default function Agent({ Connection, domain, token, sid, uuid, fetch, app
229
230
  debug,
230
231
  guarantee,
231
232
  response,
233
+ sync,
232
234
  on
233
235
  }
234
236
  }
package/agents/sync.js ADDED
@@ -0,0 +1,7 @@
1
+ import { compare, applyPatch } from 'fast-json-patch'
2
+
3
+ export default function sync(state, target) {
4
+ const patch = compare(state, target)
5
+ applyPatch(state, patch, true, true)
6
+ return { patch }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowlearning/agents",
3
- "version": "0.9.187",
3
+ "version": "0.9.188",
4
4
  "description": "API for embedding applications in KnowLearning systems.",
5
5
  "main": "node.js",
6
6
  "browser": "browser.js",