@graffiti-garden/api 0.6.0 → 0.6.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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +2 -2
- package/dist/src/1-api.d.ts +26 -19
- package/dist/src/1-api.d.ts.map +1 -1
- package/dist/src/2-types.d.ts +135 -23
- package/dist/src/2-types.d.ts.map +1 -1
- package/dist/tests/crud.d.ts.map +1 -1
- package/dist/tests/discover.d.ts.map +1 -1
- package/dist/tests/orphans.d.ts.map +1 -1
- package/dist/tests/utils.d.ts +2 -2
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/tests.mjs +64 -27
- package/dist/tests.mjs.map +2 -2
- package/package.json +1 -1
- package/src/1-api.ts +29 -20
- package/src/2-types.ts +156 -29
- package/tests/crud.ts +8 -0
- package/tests/discover.ts +105 -49
- package/tests/orphans.ts +8 -9
- package/tests/utils.ts +10 -3
package/dist/src/1-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraffitiObjectUrl, GraffitiObject, GraffitiObjectBase, GraffitiPatch, GraffitiSession, GraffitiPutObject,
|
|
1
|
+
import type { GraffitiObjectUrl, GraffitiObject, GraffitiObjectBase, GraffitiPatch, GraffitiSession, GraffitiPutObject, GraffitiObjectStream, GraffitiChannelStatsStream, GraffitiObjectStreamContinue } from "./2-types";
|
|
2
2
|
import type { JSONSchema } from "json-schema-to-ts";
|
|
3
3
|
/**
|
|
4
4
|
* This API describes a small but powerful set of methods that
|
|
@@ -286,7 +286,13 @@ export declare abstract class Graffiti {
|
|
|
286
286
|
* The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the
|
|
287
287
|
* `actor` that created the object.
|
|
288
288
|
*
|
|
289
|
-
* @
|
|
289
|
+
* It is not possible to re-{@link put} an object that has been deleted
|
|
290
|
+
* to ensure a user's [right to be forgotten](https://en.wikipedia.org/wiki/Right_to_be_forgotten).
|
|
291
|
+
* In cases where deleting and restoring an object is useful, an object's
|
|
292
|
+
* {@link GraffitiObjectBase.allowed | `allowed`} property can be set to
|
|
293
|
+
* an empty list to hide it from all users except the creator.
|
|
294
|
+
*
|
|
295
|
+
* @returns The object that was deleted with its
|
|
290
296
|
* {@link GraffitiObjectBase.lastModified | `lastModified`}
|
|
291
297
|
* property updated to the time of deletion.
|
|
292
298
|
*
|
|
@@ -315,21 +321,21 @@ export declare abstract class Graffiti {
|
|
|
315
321
|
*
|
|
316
322
|
* Objects are returned asynchronously as they are discovered but the stream
|
|
317
323
|
* will end once all leads have been exhausted.
|
|
318
|
-
* The {@link
|
|
324
|
+
* The {@link GraffitiObjectStream} ends by returning a `continue`
|
|
319
325
|
* method and a `cursor` string, each of which can be be used to poll for new objects.
|
|
320
|
-
* The `continue` method preserves the
|
|
326
|
+
* The `continue` method preserves the type safety of the stream and the `cursor`
|
|
321
327
|
* string can be serialized to continue the stream after an application is closed
|
|
322
328
|
* and reopened.
|
|
323
|
-
* See the {@link
|
|
329
|
+
* See the {@link continueObjectStream} method for more information.
|
|
324
330
|
*
|
|
325
331
|
* `discover` will not return objects that the {@link GraffitiObjectBase.actor | `actor`}
|
|
326
332
|
* is not {@link GraffitiObjectBase.allowed | `allowed`} to access.
|
|
327
|
-
* If the actor is not the creator of a discovered object,
|
|
333
|
+
* If the `actor` is not the creator of a discovered object,
|
|
328
334
|
* the allowed list will be masked to only contain the querying actor if the
|
|
329
335
|
* allowed list is not `undefined` (public). Additionally, if the actor is not the
|
|
330
336
|
* creator of a discovered object, any {@link GraffitiObjectBase.channels | `channels`}
|
|
331
337
|
* not specified by the `discover` method will not be revealed. This masking happens
|
|
332
|
-
* before the supplied schema
|
|
338
|
+
* before the object is validated against the supplied `schema`.
|
|
333
339
|
*
|
|
334
340
|
* Since different implementations may fetch data from multiple sources there is
|
|
335
341
|
* no guarentee on the order that objects are returned in.
|
|
@@ -357,7 +363,7 @@ export declare abstract class Graffiti {
|
|
|
357
363
|
* only objects that have no {@link GraffitiObjectBase.allowed | `allowed`}
|
|
358
364
|
* property will be returned.
|
|
359
365
|
*/
|
|
360
|
-
session?: GraffitiSession | null):
|
|
366
|
+
session?: GraffitiSession | null): GraffitiObjectStream<Schema>;
|
|
361
367
|
/**
|
|
362
368
|
* Discovers objects **not** contained in any
|
|
363
369
|
* {@link GraffitiObjectBase.channels | `channels`}
|
|
@@ -388,7 +394,7 @@ export declare abstract class Graffiti {
|
|
|
388
394
|
* An implementation-specific object with information to authenticate the
|
|
389
395
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
390
396
|
*/
|
|
391
|
-
session: GraffitiSession):
|
|
397
|
+
session: GraffitiSession): GraffitiObjectStream<Schema>;
|
|
392
398
|
/**
|
|
393
399
|
* Returns statistics about all the {@link GraffitiObjectBase.channels | `channels`}
|
|
394
400
|
* that an {@link GraffitiObjectBase.actor | `actor`} has posted to.
|
|
@@ -396,10 +402,9 @@ export declare abstract class Graffiti {
|
|
|
396
402
|
* necessary for certain applications where a user wants a
|
|
397
403
|
* global view of all their Graffiti data or to debug
|
|
398
404
|
* channel usage.
|
|
399
|
-
|
|
405
|
+
*
|
|
400
406
|
* Like {@link discover}, objects are returned asynchronously as they are discovered,
|
|
401
|
-
|
|
402
|
-
* can be continued using the `continue` method or `cursor` string.
|
|
407
|
+
* the stream will end once all leads have been exhausted.
|
|
403
408
|
*
|
|
404
409
|
* @group Query Methods
|
|
405
410
|
*
|
|
@@ -411,12 +416,13 @@ export declare abstract class Graffiti {
|
|
|
411
416
|
* An implementation-specific object with information to authenticate the
|
|
412
417
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
413
418
|
*/
|
|
414
|
-
session: GraffitiSession):
|
|
419
|
+
session: GraffitiSession): GraffitiChannelStatsStream;
|
|
415
420
|
/**
|
|
416
|
-
* Continues a {@link
|
|
421
|
+
* Continues a {@link GraffitiObjectStream} from a given `cursor` string.
|
|
417
422
|
* The continuation will return new objects that have been created
|
|
418
|
-
* that match the original stream, and also
|
|
419
|
-
*
|
|
423
|
+
* that match the original stream, and also returns the
|
|
424
|
+
* {@link GraffitiObjectBase.url | `url`}s of objects that
|
|
425
|
+
* have been deleted, as marked by a `tombstone`.
|
|
420
426
|
*
|
|
421
427
|
* The continuation may also include duplicates of objects that
|
|
422
428
|
* were already returned by the original stream. This is dependent
|
|
@@ -425,8 +431,9 @@ export declare abstract class Graffiti {
|
|
|
425
431
|
* The `cursor` allows the client to
|
|
426
432
|
* serialize the state of the stream and continue it later.
|
|
427
433
|
* However this method loses any typing information that was
|
|
428
|
-
* present in the original stream.
|
|
429
|
-
*
|
|
434
|
+
* present in the original stream. For better type safety
|
|
435
|
+
* and when serializing is not necessary, use the `continue`
|
|
436
|
+
* method instead, returned along with the `cursor` at the
|
|
430
437
|
* end of the original stream.
|
|
431
438
|
*
|
|
432
439
|
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
@@ -435,7 +442,7 @@ export declare abstract class Graffiti {
|
|
|
435
442
|
*
|
|
436
443
|
* @group Query Methods
|
|
437
444
|
*/
|
|
438
|
-
abstract
|
|
445
|
+
abstract continueObjectStream(cursor: string, session?: GraffitiSession | null): GraffitiObjectStreamContinue<{}>;
|
|
439
446
|
/**
|
|
440
447
|
* Begins the login process. Depending on the implementation, this may
|
|
441
448
|
* involve redirecting the user to a login page or opening a popup,
|
package/dist/src/1-api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"1-api.d.ts","sourceRoot":"","sources":["../../src/1-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"1-api.d.ts","sourceRoot":"","sources":["../../src/1-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB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,EAAE,WAAW,CAAC;CAC9C"}
|
package/dist/src/2-types.d.ts
CHANGED
|
@@ -282,8 +282,7 @@ export interface GraffitiPatch {
|
|
|
282
282
|
allowed?: JSONPatchOperation[];
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
|
-
*
|
|
286
|
-
* returned by Graffiti's query-like operations such as
|
|
285
|
+
* A stream of data that are returned by Graffiti's query-like operations
|
|
287
286
|
* {@link Graffiti.discover} and {@link Graffiti.recoverOrphans}.
|
|
288
287
|
*
|
|
289
288
|
* Errors are returned within the stream rather than as
|
|
@@ -291,38 +290,143 @@ export interface GraffitiPatch {
|
|
|
291
290
|
* some implementations may pull data from multiple sources
|
|
292
291
|
* including some that may be unreliable. In many cases,
|
|
293
292
|
* these errors can be safely ignored.
|
|
294
|
-
*
|
|
295
|
-
* source of the error including its scheme and other
|
|
296
|
-
* implementation-specific details (e.g. domain name).
|
|
293
|
+
* See {@link GraffitiStreamError}.
|
|
297
294
|
*
|
|
298
295
|
* The stream is an [`AsyncGenerator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function)
|
|
299
296
|
* that can be iterated over using `for await` loops or calling `next` on the generator.
|
|
300
297
|
* The stream can be terminated by breaking out of a loop calling `return` on the generator.
|
|
301
298
|
*
|
|
302
|
-
* The stream ends by returning a
|
|
299
|
+
* The stream ends by returning a {@link GraffitiObjectStreamReturn.continue | `continue`}
|
|
300
|
+
* function and a {@link GraffitiObjectStreamReturn.cursor | `cursor`} string,
|
|
303
301
|
* each of which can be used to resume the stream from where it left off.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
*
|
|
302
|
+
*/
|
|
303
|
+
export type GraffitiObjectStream<Schema extends JSONSchema> = AsyncGenerator<GraffitiStreamError | GraffitiObjectStreamEntry<Schema>, GraffitiObjectStreamReturn<Schema>>;
|
|
304
|
+
/**
|
|
305
|
+
* An error that can occur in either the
|
|
306
|
+
* {@link GraffitiObjectStream} or {@link GraffitiChannelStatsStream}.
|
|
308
307
|
*
|
|
309
|
-
*
|
|
310
|
-
* boolean to indicate whether a stream element previously returned has been deleted.
|
|
311
|
-
* The continuation may also include duplicates of objects that
|
|
312
|
-
* were already returned by the original stream. This is dependent
|
|
313
|
-
* on how much state the underlying implementation maintains.
|
|
308
|
+
* @internal
|
|
314
309
|
*/
|
|
315
|
-
export
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
} | {
|
|
310
|
+
export interface GraffitiStreamError {
|
|
311
|
+
/**
|
|
312
|
+
* The error that occurred while streaming data.
|
|
313
|
+
*/
|
|
320
314
|
error: Error;
|
|
315
|
+
/**
|
|
316
|
+
* The origin that the error occurred. It will include
|
|
317
|
+
* the scheme of the Graffiti implementation used and other
|
|
318
|
+
* implementation-specific information like a hostname.
|
|
319
|
+
*/
|
|
321
320
|
origin: string;
|
|
322
|
-
}
|
|
323
|
-
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* A successful result from a {@link GraffitiObjectStream} or
|
|
324
|
+
* {@link GraffitiObjectStreamContinue} that includes an object.
|
|
325
|
+
*
|
|
326
|
+
* @internal
|
|
327
|
+
*/
|
|
328
|
+
export interface GraffitiObjectStreamEntry<Schema extends JSONSchema> {
|
|
329
|
+
/**
|
|
330
|
+
* Empty property for compatibility with {@link GraffitiStreamError}
|
|
331
|
+
*/
|
|
332
|
+
error?: undefined;
|
|
333
|
+
/**
|
|
334
|
+
* Empty property for compatibility with {@link GraffitiObjectStreamContinueTombstone}
|
|
335
|
+
*/
|
|
336
|
+
tombstone?: undefined;
|
|
337
|
+
/**
|
|
338
|
+
* The object returned by the stream.
|
|
339
|
+
*/
|
|
340
|
+
object: GraffitiObject<Schema>;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* A result from a {@link GraffitiObjectStreamContinue} that indicated
|
|
344
|
+
* an object has been deleted since the original stream was run.
|
|
345
|
+
* Only sparse metadata about the deleted object is returned to respect
|
|
346
|
+
* the deleting user's privacy.
|
|
347
|
+
*
|
|
348
|
+
* @internal
|
|
349
|
+
*/
|
|
350
|
+
export interface GraffitiObjectStreamContinueTombstone {
|
|
351
|
+
/**
|
|
352
|
+
* Empty property for compatibility with {@link GraffitiStreamError}
|
|
353
|
+
*/
|
|
354
|
+
error?: undefined;
|
|
355
|
+
/**
|
|
356
|
+
* Use this property to differentiate a tombstone from a
|
|
357
|
+
* {@link GraffitiObjectStreamEntry}.
|
|
358
|
+
*/
|
|
359
|
+
tombstone: true;
|
|
360
|
+
/**
|
|
361
|
+
* Sparse metadata about the deleted object. The full object is not returned
|
|
362
|
+
* to respect a user's privacy.
|
|
363
|
+
*/
|
|
364
|
+
object: {
|
|
365
|
+
/**
|
|
366
|
+
* The {@link GraffitiObjectBase.url | `url`} of the deleted object.
|
|
367
|
+
*/
|
|
368
|
+
url: string;
|
|
369
|
+
/**
|
|
370
|
+
* The time at which the object was deleted, comparable to
|
|
371
|
+
* {@link GraffitiObjectBase.lastModified | `lastModified`}.
|
|
372
|
+
*
|
|
373
|
+
* While it is not possible to re-{@link Graffiti.put | put} objects that have been
|
|
374
|
+
* {@link Graffiti.delete | deleted}, objects may appear deleted if
|
|
375
|
+
* an {@link GraffitiObjectBase.actor | `actor`} is no longer
|
|
376
|
+
* {@link GraffitiObjectBase.allowed | `allowed`} to access them.
|
|
377
|
+
* Therefore the {@link GraffitiObjectBase.lastModified | `lastModified`} property
|
|
378
|
+
* is necessary to compare object versions.
|
|
379
|
+
*/
|
|
380
|
+
lastModified: number;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* A continuation of the {@link GraffitiObjectStream} type can include
|
|
385
|
+
* both objects and tombstones of deleted objects.
|
|
386
|
+
*
|
|
387
|
+
* @internal
|
|
388
|
+
*/
|
|
389
|
+
export type GraffitiObjectStreamContinueEntry<Schema extends JSONSchema> = GraffitiObjectStreamEntry<Schema> | GraffitiObjectStreamContinueTombstone;
|
|
390
|
+
/**
|
|
391
|
+
* The output of a {@link GraffitiObjectStream} or a {@link GraffitiObjectStreamContinue}
|
|
392
|
+
* that allows the stream to be continued from where it left off.
|
|
393
|
+
*
|
|
394
|
+
* The {@link continue} function preserves the typing of the original stream,
|
|
395
|
+
* where as the {@link cursor} string can be serialized for use after a user
|
|
396
|
+
* has closed and reopened an application.
|
|
397
|
+
*
|
|
398
|
+
* The continued stream may include `tombstone`s of objects that have been
|
|
399
|
+
* deleted since the original stream was run. See {@link GraffitiObjectStreamContinueTombstone}.
|
|
400
|
+
* The continued stream may also return some objects that were already
|
|
401
|
+
* returned by the original stream, depending on how much state the
|
|
402
|
+
* underlying implementation is able to preserve.
|
|
403
|
+
*
|
|
404
|
+
* @internal
|
|
405
|
+
*/
|
|
406
|
+
export interface GraffitiObjectStreamReturn<Schema extends JSONSchema> {
|
|
407
|
+
/**
|
|
408
|
+
* @returns A function that creates new stream that continues from where the original stream left off.
|
|
409
|
+
* It preserves the typing of the original stream.
|
|
410
|
+
*/
|
|
411
|
+
continue: () => GraffitiObjectStreamContinue<Schema>;
|
|
412
|
+
/**
|
|
413
|
+
* A string that can be serialized and stored to resume the stream later.
|
|
414
|
+
* It must be passed to the {@link Graffiti.continueObjectStream} method
|
|
415
|
+
* to resume the stream.
|
|
416
|
+
*/
|
|
324
417
|
cursor: string;
|
|
325
|
-
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* A continutation of the {@link GraffitiObjectStream} type, as returned by
|
|
421
|
+
* the {@link GraffitiObjectStreamReturn.continue} or by using
|
|
422
|
+
* {@link GraffitiObjectStreamReturn.cursor} with {@link Graffiti.continueObjectStream}.
|
|
423
|
+
*
|
|
424
|
+
* The continued stream may include `tombstone`s of objects that have been
|
|
425
|
+
* deleted since the original stream was run. See {@link GraffitiObjectStreamContinueTombstone}.
|
|
426
|
+
*
|
|
427
|
+
* @internal
|
|
428
|
+
*/
|
|
429
|
+
export type GraffitiObjectStreamContinue<Schema extends JSONSchema> = AsyncGenerator<GraffitiStreamError | GraffitiObjectStreamContinueEntry<Schema>, GraffitiObjectStreamReturn<Schema>>;
|
|
326
430
|
/**
|
|
327
431
|
* Statistic about single channel returned by {@link Graffiti.channelStats}.
|
|
328
432
|
* These statistics only account for contributions made by the
|
|
@@ -345,6 +449,14 @@ export type ChannelStats = {
|
|
|
345
449
|
*/
|
|
346
450
|
lastModified: number;
|
|
347
451
|
};
|
|
452
|
+
/**
|
|
453
|
+
* A stream of data that are returned by Graffiti's {@link Graffiti.channelStats} method.
|
|
454
|
+
* See {@link GraffitiObjectStream} for more information on streams.
|
|
455
|
+
*/
|
|
456
|
+
export type GraffitiChannelStatsStream = AsyncGenerator<GraffitiStreamError | {
|
|
457
|
+
error?: undefined;
|
|
458
|
+
value: ChannelStats;
|
|
459
|
+
}>;
|
|
348
460
|
/**
|
|
349
461
|
* The event type produced in {@link Graffiti.sessionEvents}
|
|
350
462
|
* when a user logs in manually from {@link Graffiti.login}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2-types.d.ts","sourceRoot":"","sources":["../../src/2-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEvE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,KAAK,EAAE,EAAE,CAAC;IAEV;;;;;;;;;;;;OAYG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAE1B;;;;;;;;;;;;OAYG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;;;;;;;;;;;OAiBG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;;;;;;OAUG;IACH,YAAY,EAAE,MAAM,CAAC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EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GACD,IAAI,GACJ,SAAS,CACZ,CAAC"}
|
package/dist/tests/crud.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../tests/crud.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAGhB,MAAM,sBAAsB,CAAC;AAW9B,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,EACrE,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC7D,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"crud.d.ts","sourceRoot":"","sources":["../../tests/crud.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAGhB,MAAM,sBAAsB,CAAC;AAW9B,eAAO,MAAM,iBAAiB,GAC5B,aAAa,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,EACrE,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC7D,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,SAugB9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../tests/discover.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../tests/discover.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EAGR,eAAe,EAEhB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,qBAAqB,GAChC,aAAa,MAAM,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,EAC1E,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC7D,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,SA2oB9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orphans.d.ts","sourceRoot":"","sources":["../../tests/orphans.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGtE,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,IAAI,CACrB,QAAQ,EACR,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAC9C,EACD,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC7D,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"orphans.d.ts","sourceRoot":"","sources":["../../tests/orphans.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGtE,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,IAAI,CACrB,QAAQ,EACR,gBAAgB,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAC9C,EACD,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC7D,aAAa,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,SAqG9D,CAAC"}
|
package/dist/tests/utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { GraffitiPutObject,
|
|
1
|
+
import type { GraffitiPutObject, GraffitiObjectStream, JSONSchema, GraffitiObject } from "@graffiti-garden/api";
|
|
2
2
|
export declare function randomString(): string;
|
|
3
3
|
export declare function randomValue(): {
|
|
4
4
|
[x: string]: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function randomPutObject(): GraffitiPutObject<{}>;
|
|
7
|
-
export declare function nextStreamValue<
|
|
7
|
+
export declare function nextStreamValue<Schema extends JSONSchema>(iterator: GraffitiObjectStream<Schema>): Promise<GraffitiObject<Schema>>;
|
|
8
8
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../tests/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../tests/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,wBAAgB,YAAY,IAAI,MAAM,CASrC;AAED,wBAAgB,WAAW;;EAI1B;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAAC,EAAE,CAAC,CAKvD;AAED,wBAAsB,eAAe,CAAC,MAAM,SAAS,UAAU,EAC7D,QAAQ,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACrC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAKjC"}
|
package/dist/tests.mjs
CHANGED
|
@@ -32,7 +32,7 @@ async function nextStreamValue(iterator) {
|
|
|
32
32
|
const result = await iterator.next();
|
|
33
33
|
assert(!result.done && !result.value.error, "result has no value");
|
|
34
34
|
assert(!result.value.tombstone, "result has been deleted!");
|
|
35
|
-
return result.value.
|
|
35
|
+
return result.value.object;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// tests/crud.ts
|
|
@@ -101,6 +101,12 @@ var graffitiCRUDTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
101
101
|
await expect(graffiti.delete(beforeDeleted, session)).rejects.toThrow(
|
|
102
102
|
GraffitiErrorNotFound
|
|
103
103
|
);
|
|
104
|
+
await expect(
|
|
105
|
+
graffiti.put(
|
|
106
|
+
{ url: beforeDeleted.url, value: {}, channels: [] },
|
|
107
|
+
session
|
|
108
|
+
)
|
|
109
|
+
).rejects.toThrow(GraffitiErrorNotFound);
|
|
104
110
|
});
|
|
105
111
|
it("put, delete, patch with wrong actor", async () => {
|
|
106
112
|
await expect(
|
|
@@ -523,7 +529,11 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
523
529
|
const object = randomPutObject();
|
|
524
530
|
object.allowed = [randomString(), randomString()];
|
|
525
531
|
const putted = await graffiti.put(object, session1);
|
|
526
|
-
const iteratorSession1 = graffiti.discover(
|
|
532
|
+
const iteratorSession1 = graffiti.discover(
|
|
533
|
+
object.channels,
|
|
534
|
+
{},
|
|
535
|
+
session1
|
|
536
|
+
);
|
|
527
537
|
const value = await nextStreamValue(iteratorSession1);
|
|
528
538
|
expect2(value.value).toEqual(object.value);
|
|
529
539
|
expect2(value.channels).toEqual(object.channels);
|
|
@@ -539,7 +549,11 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
539
549
|
const object = randomPutObject();
|
|
540
550
|
object.allowed = [randomString(), session2.actor, randomString()];
|
|
541
551
|
const putted = await graffiti.put(object, session1);
|
|
542
|
-
const iteratorSession2 = graffiti.discover(
|
|
552
|
+
const iteratorSession2 = graffiti.discover(
|
|
553
|
+
object.channels,
|
|
554
|
+
{},
|
|
555
|
+
session2
|
|
556
|
+
);
|
|
543
557
|
const value = await nextStreamValue(iteratorSession2);
|
|
544
558
|
expect2(value.value).toEqual(object.value);
|
|
545
559
|
expect2(value.allowed).toEqual([session2.actor]);
|
|
@@ -733,7 +747,9 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
733
747
|
},
|
|
734
748
|
session2
|
|
735
749
|
);
|
|
736
|
-
const value2 = await nextStreamValue(
|
|
750
|
+
const value2 = await nextStreamValue(
|
|
751
|
+
iteratorSession2SmallAllowPeekSelf
|
|
752
|
+
);
|
|
737
753
|
expect2(value2.value).toEqual(object.value);
|
|
738
754
|
await expect2(
|
|
739
755
|
iteratorSession2SmallAllowPeekSelf.next()
|
|
@@ -822,7 +838,9 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
822
838
|
},
|
|
823
839
|
session2
|
|
824
840
|
);
|
|
825
|
-
const value2 = await nextStreamValue(
|
|
841
|
+
const value2 = await nextStreamValue(
|
|
842
|
+
iteratorSession2SmallAllowPeekSelf
|
|
843
|
+
);
|
|
826
844
|
expect2(value2.value).toEqual(object.value);
|
|
827
845
|
await expect2(
|
|
828
846
|
iteratorSession2SmallAllowPeekSelf.next()
|
|
@@ -878,7 +896,7 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
878
896
|
}
|
|
879
897
|
})) {
|
|
880
898
|
assert2(!result.error, "result has error");
|
|
881
|
-
if (property in result.
|
|
899
|
+
if (property in result.object.value) {
|
|
882
900
|
count++;
|
|
883
901
|
}
|
|
884
902
|
}
|
|
@@ -902,11 +920,8 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
902
920
|
const tombIterator = returnValue.value.continue();
|
|
903
921
|
const value = await tombIterator.next();
|
|
904
922
|
assert2(!value.done && !value.value.error, "value is done");
|
|
905
|
-
|
|
906
|
-
expect2(value.value.
|
|
907
|
-
expect2(value.value.value.channels).toEqual(object.channels);
|
|
908
|
-
expect2(value.value.value.actor).toEqual(session.actor);
|
|
909
|
-
expect2(value.value.value.lastModified).toEqual(deleted.lastModified);
|
|
923
|
+
assert2(value.value.tombstone, "value is not tombstone");
|
|
924
|
+
expect2(value.value.object.url).toEqual(putted.url);
|
|
910
925
|
await expect2(tombIterator.next()).resolves.toHaveProperty("done", true);
|
|
911
926
|
});
|
|
912
927
|
it2("discover for replaced channels", async () => {
|
|
@@ -940,18 +955,43 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
940
955
|
expect2(value32.value.tombstone && value22.done).toBe(false);
|
|
941
956
|
continue;
|
|
942
957
|
}
|
|
943
|
-
await
|
|
958
|
+
const value5 = await iterator1.next();
|
|
959
|
+
assert2(value5.done, "value5 is not done");
|
|
944
960
|
const value4 = await tombIterator.next();
|
|
945
961
|
assert2(!value4.done && !value4.value.error, "value is done");
|
|
946
|
-
|
|
947
|
-
expect2(value4.value.
|
|
948
|
-
expect2(value4.value.
|
|
949
|
-
expect2(value4.value.value.lastModified).toEqual(replaced.lastModified);
|
|
962
|
+
assert2(value4.value.tombstone, "value is not tombstone");
|
|
963
|
+
expect2(value4.value.object.url).toEqual(putted.url);
|
|
964
|
+
expect2(value4.value.object.lastModified).toEqual(replaced.lastModified);
|
|
950
965
|
const value2 = await nextStreamValue(iterator2);
|
|
951
966
|
await expect2(iterator2.next()).resolves.toHaveProperty("done", true);
|
|
952
967
|
expect2(value2.value).toEqual(object2.value);
|
|
953
968
|
expect2(value2.channels).toEqual(object2.channels);
|
|
954
969
|
expect2(value2.lastModified).toEqual(replaced.lastModified);
|
|
970
|
+
const patched = await graffiti.patch(
|
|
971
|
+
{
|
|
972
|
+
channels: [{ op: "replace", path: "", value: object1.channels }]
|
|
973
|
+
},
|
|
974
|
+
replaced,
|
|
975
|
+
session
|
|
976
|
+
);
|
|
977
|
+
const tombIterator2 = value5.value.continue();
|
|
978
|
+
let result;
|
|
979
|
+
for await (const value of tombIterator2) {
|
|
980
|
+
if (value.error) continue;
|
|
981
|
+
if (!result) {
|
|
982
|
+
result = value;
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
if (value.object.lastModified > result.object.lastModified || value.object.lastModified === result.object.lastModified && !value.tombstone && result.tombstone) {
|
|
986
|
+
result = value;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
assert2(result, "result is not defined");
|
|
990
|
+
assert2(!result.tombstone, "result is tombstone");
|
|
991
|
+
expect2(result.object.url).toEqual(replaced.url);
|
|
992
|
+
expect2(result.object.lastModified).toEqual(patched.lastModified);
|
|
993
|
+
expect2(result.object.channels).toEqual(object1.channels);
|
|
994
|
+
expect2(result.object.value).toEqual(object2.value);
|
|
955
995
|
}
|
|
956
996
|
});
|
|
957
997
|
it2("discover for patched allowed", async () => {
|
|
@@ -974,10 +1014,8 @@ var graffitiDiscoverTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
974
1014
|
const iterator = returnValue.value.continue();
|
|
975
1015
|
const value = await iterator.next();
|
|
976
1016
|
assert2(!value.done && !value.value.error, "value is done");
|
|
977
|
-
|
|
978
|
-
expect2(value.value.
|
|
979
|
-
expect2(value.value.value.channels).toEqual(object.channels);
|
|
980
|
-
expect2(value.value.value.allowed).toBeUndefined();
|
|
1017
|
+
assert2(value.value.tombstone, "value is not tombstone");
|
|
1018
|
+
expect2(value.value.object.url).toEqual(putted.url);
|
|
981
1019
|
await expect2(iterator.next()).resolves.toHaveProperty("done", true);
|
|
982
1020
|
});
|
|
983
1021
|
it2("put concurrently and discover one", async () => {
|
|
@@ -1029,7 +1067,7 @@ var graffitiOrphanTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
1029
1067
|
const orphanIterator1 = graffiti.recoverOrphans({}, session);
|
|
1030
1068
|
for await (const orphan of orphanIterator1) {
|
|
1031
1069
|
if (orphan.error) continue;
|
|
1032
|
-
existingOrphans.push(orphan.
|
|
1070
|
+
existingOrphans.push(orphan.object.url);
|
|
1033
1071
|
}
|
|
1034
1072
|
const object = randomPutObject();
|
|
1035
1073
|
object.channels = [];
|
|
@@ -1039,9 +1077,9 @@ var graffitiOrphanTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
1039
1077
|
for await (const orphan of orphanIterator2) {
|
|
1040
1078
|
if (orphan.error) continue;
|
|
1041
1079
|
assert3(!orphan.tombstone, "orphan is tombstone");
|
|
1042
|
-
if (orphan.
|
|
1080
|
+
if (orphan.object.url === putted.url) {
|
|
1043
1081
|
numResults++;
|
|
1044
|
-
expect3(orphan.
|
|
1082
|
+
expect3(orphan.object.lastModified).toBe(putted.lastModified);
|
|
1045
1083
|
}
|
|
1046
1084
|
}
|
|
1047
1085
|
expect3(numResults).toBe(1);
|
|
@@ -1086,7 +1124,7 @@ var graffitiOrphanTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
1086
1124
|
let numResults = 0;
|
|
1087
1125
|
for await (const orphan of orphanIterator) {
|
|
1088
1126
|
if (orphan.error) continue;
|
|
1089
|
-
if (orphan.
|
|
1127
|
+
if (orphan.object.url === putOrphan.url) {
|
|
1090
1128
|
numResults++;
|
|
1091
1129
|
}
|
|
1092
1130
|
}
|
|
@@ -1097,9 +1135,8 @@ var graffitiOrphanTests = (useGraffiti, useSession1, useSession2) => {
|
|
|
1097
1135
|
!value2.done && !value2.value.error,
|
|
1098
1136
|
"value2 is done or has error"
|
|
1099
1137
|
);
|
|
1100
|
-
|
|
1101
|
-
expect3(value2.value.
|
|
1102
|
-
expect3(value2.value.value.channels).toEqual([]);
|
|
1138
|
+
assert3(value2.value.tombstone, "value2 is not tombstone");
|
|
1139
|
+
expect3(value2.value.object.url).toBe(putOrphan.url);
|
|
1103
1140
|
await expect3(iterator2.next()).resolves.toHaveProperty("done", true);
|
|
1104
1141
|
});
|
|
1105
1142
|
});
|