@graffy/core 0.16.0-alpha.7 → 0.16.0-alpha.8

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.
Files changed (3) hide show
  1. package/index.cjs +22 -6
  2. package/index.mjs +22 -6
  3. package/package.json +3 -3
package/index.cjs CHANGED
@@ -165,9 +165,14 @@ class Graffy {
165
165
  this.core.on(
166
166
  "read",
167
167
  path,
168
- shiftFn(async function porcelainRead(query, options) {
169
- const decoded = common.decodeQuery(query);
170
- const encoded = common.encodeGraph(await handle(decoded, options));
168
+ shiftFn(async function porcelainRead(query, options, next) {
169
+ const porcelainQuery = common.decodeQuery(query);
170
+ const encoded = common.encodeGraph(
171
+ await handle(porcelainQuery, options, async (nextQuery, nextOpts) => {
172
+ const nextResult = await next(common.encodeQuery(nextQuery), nextOpts);
173
+ return common.decodeGraph(nextResult);
174
+ })
175
+ );
171
176
  const finalized = common.finalize(encoded, query);
172
177
  return finalized;
173
178
  }, path)
@@ -181,7 +186,9 @@ class Graffy {
181
186
  path,
182
187
  shiftGen(function porcelainWatch(query, options) {
183
188
  return stream.makeStream((push, end) => {
184
- const subscription = handle(common.decodeQuery(query), options);
189
+ const subscription = handle(common.decodeQuery(query), options, () => {
190
+ throw Error("porcelain.watch_next_unsupported: " + path);
191
+ });
185
192
  (async function() {
186
193
  try {
187
194
  let firstValue = (await subscription.next()).value;
@@ -204,8 +211,17 @@ class Graffy {
204
211
  this.core.on(
205
212
  "write",
206
213
  path,
207
- shiftFn(async function porcelainWrite(change, options) {
208
- return common.encodeGraph(await handle(common.decodeGraph(change), options));
214
+ shiftFn(async function porcelainWrite(change, options, next) {
215
+ return common.encodeGraph(
216
+ await handle(
217
+ common.decodeGraph(change),
218
+ options,
219
+ async (nextChange, nextOpts) => {
220
+ const nextResult = await next(common.encodeGraph(nextChange), nextOpts);
221
+ return common.decodeGraph(nextResult);
222
+ }
223
+ )
224
+ );
209
225
  }, path)
210
226
  );
211
227
  }
package/index.mjs CHANGED
@@ -162,9 +162,14 @@ class Graffy {
162
162
  this.core.on(
163
163
  "read",
164
164
  path,
165
- shiftFn(async function porcelainRead(query, options) {
166
- const decoded = decodeQuery(query);
167
- const encoded = encodeGraph(await handle(decoded, options));
165
+ shiftFn(async function porcelainRead(query, options, next) {
166
+ const porcelainQuery = decodeQuery(query);
167
+ const encoded = encodeGraph(
168
+ await handle(porcelainQuery, options, async (nextQuery, nextOpts) => {
169
+ const nextResult = await next(encodeQuery(nextQuery), nextOpts);
170
+ return decodeGraph(nextResult);
171
+ })
172
+ );
168
173
  const finalized = finalize(encoded, query);
169
174
  return finalized;
170
175
  }, path)
@@ -178,7 +183,9 @@ class Graffy {
178
183
  path,
179
184
  shiftGen(function porcelainWatch(query, options) {
180
185
  return makeStream((push, end) => {
181
- const subscription = handle(decodeQuery(query), options);
186
+ const subscription = handle(decodeQuery(query), options, () => {
187
+ throw Error("porcelain.watch_next_unsupported: " + path);
188
+ });
182
189
  (async function() {
183
190
  try {
184
191
  let firstValue = (await subscription.next()).value;
@@ -201,8 +208,17 @@ class Graffy {
201
208
  this.core.on(
202
209
  "write",
203
210
  path,
204
- shiftFn(async function porcelainWrite(change, options) {
205
- return encodeGraph(await handle(decodeGraph(change), options));
211
+ shiftFn(async function porcelainWrite(change, options, next) {
212
+ return encodeGraph(
213
+ await handle(
214
+ decodeGraph(change),
215
+ options,
216
+ async (nextChange, nextOpts) => {
217
+ const nextResult = await next(encodeGraph(nextChange), nextOpts);
218
+ return decodeGraph(nextResult);
219
+ }
220
+ )
221
+ );
206
222
  }, path)
207
223
  );
208
224
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/core",
3
3
  "description": "The main module for Graffy, a library for intuitive real-time data APIs.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.16.0-alpha.7",
5
+ "version": "0.16.0-alpha.8",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.16.0-alpha.7",
20
- "@graffy/stream": "0.16.0-alpha.7",
19
+ "@graffy/common": "0.16.0-alpha.8",
20
+ "@graffy/stream": "0.16.0-alpha.8",
21
21
  "debug": "^4.3.3"
22
22
  }
23
23
  }