@graffiti-garden/wrapper-synchronize 0.2.4 → 1.0.2
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/browser/{ajv-L3T2Y2ZC.js → ajv-UZKI6BMI.js} +2 -2
- package/dist/browser/chunk-YB7WCAZH.js +7 -0
- package/dist/browser/{chunk-ZOOM6B5R.js.map → chunk-YB7WCAZH.js.map} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +81 -131
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +82 -132
- package/dist/esm/index.js.map +2 -2
- package/dist/index.d.ts +31 -45
- package/dist/index.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/index.spec.ts +110 -277
- package/src/index.ts +109 -161
- package/dist/browser/chunk-ZOOM6B5R.js +0 -7
- package/dist/browser/fast-json-patch-5UD2BOZL.js +0 -19
- package/dist/browser/fast-json-patch-5UD2BOZL.js.map +0 -7
- /package/dist/browser/{ajv-L3T2Y2ZC.js.map → ajv-UZKI6BMI.js.map} +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -33,17 +33,19 @@ __export(index_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(index_exports);
|
|
34
34
|
var import_api = require("@graffiti-garden/api");
|
|
35
35
|
var import_repeater = require("@repeaterjs/repeater");
|
|
36
|
-
|
|
37
|
-
class GraffitiSynchronize extends import_api.Graffiti {
|
|
36
|
+
class GraffitiSynchronize {
|
|
38
37
|
ajv_;
|
|
39
|
-
applyPatch_;
|
|
40
38
|
graffiti;
|
|
41
39
|
callbacks = /* @__PURE__ */ new Set();
|
|
42
40
|
options;
|
|
43
|
-
channelStats;
|
|
44
41
|
login;
|
|
45
42
|
logout;
|
|
46
43
|
sessionEvents;
|
|
44
|
+
postMedia;
|
|
45
|
+
getMedia;
|
|
46
|
+
deleteMedia;
|
|
47
|
+
actorToHandle;
|
|
48
|
+
handleToActor;
|
|
47
49
|
get ajv() {
|
|
48
50
|
if (!this.ajv_) {
|
|
49
51
|
this.ajv_ = (async () => {
|
|
@@ -53,52 +55,42 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
53
55
|
}
|
|
54
56
|
return this.ajv_;
|
|
55
57
|
}
|
|
56
|
-
get applyPatch() {
|
|
57
|
-
if (!this.applyPatch_) {
|
|
58
|
-
this.applyPatch_ = (async () => {
|
|
59
|
-
const { applyPatch } = await import("fast-json-patch");
|
|
60
|
-
return applyPatch;
|
|
61
|
-
})();
|
|
62
|
-
}
|
|
63
|
-
return this.applyPatch_;
|
|
64
|
-
}
|
|
65
58
|
/**
|
|
66
59
|
* Wraps a Graffiti API instance to provide the synchronize methods.
|
|
67
60
|
* The GraffitiSyncrhonize class rather than the Graffiti class
|
|
68
61
|
* must be used for all functions for the synchronize methods to work.
|
|
69
62
|
*/
|
|
70
63
|
constructor(graffiti, options) {
|
|
71
|
-
super();
|
|
72
64
|
this.options = options ?? {};
|
|
73
65
|
this.graffiti = graffiti;
|
|
74
|
-
this.channelStats = graffiti.channelStats.bind(graffiti);
|
|
75
66
|
this.login = graffiti.login.bind(graffiti);
|
|
76
67
|
this.logout = graffiti.logout.bind(graffiti);
|
|
77
68
|
this.sessionEvents = graffiti.sessionEvents;
|
|
69
|
+
this.postMedia = graffiti.postMedia.bind(graffiti);
|
|
70
|
+
this.getMedia = graffiti.getMedia.bind(graffiti);
|
|
71
|
+
this.deleteMedia = graffiti.deleteMedia.bind(graffiti);
|
|
72
|
+
this.actorToHandle = graffiti.actorToHandle.bind(graffiti);
|
|
73
|
+
this.handleToActor = graffiti.handleToActor.bind(graffiti);
|
|
78
74
|
}
|
|
79
|
-
synchronize(matchObject, channels, schema, session) {
|
|
80
|
-
const seenUrls = /* @__PURE__ */ new Set();
|
|
75
|
+
synchronize(matchObject, channels, schema, session, seenUrls = /* @__PURE__ */ new Set()) {
|
|
81
76
|
const repeater = new import_repeater.Repeater(
|
|
82
77
|
async (push, stop) => {
|
|
83
|
-
const validate = (0,
|
|
84
|
-
const callback = (
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
seenUrls.add(object.url);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
78
|
+
const validate = (0, import_api.compileGraffitiObjectSchema)(await this.ajv, schema);
|
|
79
|
+
const callback = (objectUpdate) => {
|
|
80
|
+
if (objectUpdate?.tombstone) {
|
|
81
|
+
if (seenUrls.has(objectUpdate.object.url)) {
|
|
82
|
+
push(objectUpdate);
|
|
83
|
+
}
|
|
84
|
+
} else if (objectUpdate && matchObject(objectUpdate.object) && (this.options.omniscient || (0, import_api.isActorAllowedGraffitiObject)(objectUpdate.object, session))) {
|
|
85
|
+
const object = JSON.parse(
|
|
86
|
+
JSON.stringify(objectUpdate.object)
|
|
87
|
+
);
|
|
88
|
+
if (!this.options.omniscient) {
|
|
89
|
+
(0, import_api.maskGraffitiObject)(object, channels, session);
|
|
90
|
+
}
|
|
91
|
+
if (validate(object)) {
|
|
92
|
+
push({ object });
|
|
93
|
+
seenUrls.add(object.url);
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
96
|
};
|
|
@@ -113,8 +105,8 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
113
105
|
}
|
|
114
106
|
/**
|
|
115
107
|
* This method has the same signature as {@link discover} but listens for
|
|
116
|
-
* changes made via {@link
|
|
117
|
-
* fetched from {@link get}, {@link discover}, and {@link
|
|
108
|
+
* changes made via {@link post} and {@link delete} or
|
|
109
|
+
* fetched from {@link get}, {@link discover}, and {@link continueDiscover}
|
|
118
110
|
* and then streams appropriate changes to provide a responsive and
|
|
119
111
|
* consistent user experience.
|
|
120
112
|
*
|
|
@@ -122,10 +114,9 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
122
114
|
* and will not terminate unless the user calls the `return` method on the iterator
|
|
123
115
|
* or `break`s out of the loop.
|
|
124
116
|
*
|
|
125
|
-
* @group Synchronize Methods
|
|
117
|
+
* @group 0 - Synchronize Methods
|
|
126
118
|
*/
|
|
127
|
-
synchronizeDiscover(
|
|
128
|
-
const [channels, schema, session] = args;
|
|
119
|
+
synchronizeDiscover(channels, schema, session) {
|
|
129
120
|
function matchObject(object) {
|
|
130
121
|
return object.channels.some((channel) => channels.includes(channel));
|
|
131
122
|
}
|
|
@@ -133,43 +124,28 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
133
124
|
}
|
|
134
125
|
/**
|
|
135
126
|
* This method has the same signature as {@link get} but
|
|
136
|
-
* listens for changes made via {@link
|
|
137
|
-
* fetched from {@link get}, {@link discover}, and {@link
|
|
127
|
+
* listens for changes made via {@link post}, and {@link delete} or
|
|
128
|
+
* fetched from {@link get}, {@link discover}, and {@link continueDiscover} and then
|
|
138
129
|
* streams appropriate changes to provide a responsive and consistent user experience.
|
|
139
130
|
*
|
|
140
131
|
* Unlike {@link get}, which returns a single result, this method continuously
|
|
141
132
|
* listens for changes which are output as an asynchronous stream, similar
|
|
142
133
|
* to {@link discover}.
|
|
143
134
|
*
|
|
144
|
-
* @group Synchronize Methods
|
|
135
|
+
* @group 0 - Synchronize Methods
|
|
145
136
|
*/
|
|
146
|
-
synchronizeGet(
|
|
147
|
-
const
|
|
148
|
-
const url = (0, import_utilities.unpackObjectUrl)(objectUrl);
|
|
137
|
+
synchronizeGet(objectUrl, schema, session) {
|
|
138
|
+
const url = (0, import_api.unpackObjectUrl)(objectUrl);
|
|
149
139
|
function matchObject(object) {
|
|
150
140
|
return object.url === url;
|
|
151
141
|
}
|
|
152
|
-
return this.synchronize(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
* streams appropriate changes to provide a responsive and consistent user experience.
|
|
160
|
-
*
|
|
161
|
-
* Unlike {@link recoverOrphans}, this method continuously listens for changes
|
|
162
|
-
* and will not terminate unless the user calls the `return` method on the iterator
|
|
163
|
-
* or `break`s out of the loop.
|
|
164
|
-
*
|
|
165
|
-
* @group Synchronize Methods
|
|
166
|
-
*/
|
|
167
|
-
synchronizeRecoverOrphans(...args) {
|
|
168
|
-
const [schema, session] = args;
|
|
169
|
-
function matchObject(object) {
|
|
170
|
-
return object.actor === session.actor && object.channels.length === 0;
|
|
171
|
-
}
|
|
172
|
-
return this.synchronize(matchObject, [], schema, session);
|
|
142
|
+
return this.synchronize(
|
|
143
|
+
matchObject,
|
|
144
|
+
[],
|
|
145
|
+
schema,
|
|
146
|
+
session,
|
|
147
|
+
/* @__PURE__ */ new Set([url])
|
|
148
|
+
);
|
|
173
149
|
}
|
|
174
150
|
/**
|
|
175
151
|
* Streams changes made to *any* object in *any* channel
|
|
@@ -181,74 +157,54 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
181
157
|
* Be careful using this method. Without additional filters it can
|
|
182
158
|
* expose the user to content out of context.
|
|
183
159
|
*
|
|
184
|
-
* @group Synchronize Methods
|
|
160
|
+
* @group 0 - Synchronize Methods
|
|
185
161
|
*/
|
|
186
162
|
synchronizeAll(schema, session) {
|
|
187
163
|
return this.synchronize(() => true, [], schema, session);
|
|
188
164
|
}
|
|
189
|
-
async synchronizeDispatch(
|
|
165
|
+
async synchronizeDispatch(objectUpdate, waitForListeners = false) {
|
|
190
166
|
for (const callback of this.callbacks) {
|
|
191
|
-
callback(
|
|
167
|
+
callback(objectUpdate);
|
|
192
168
|
}
|
|
193
169
|
if (waitForListeners) {
|
|
194
170
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
195
171
|
}
|
|
196
172
|
}
|
|
197
173
|
get = async (...args) => {
|
|
198
|
-
|
|
199
|
-
|
|
174
|
+
try {
|
|
175
|
+
const object = await this.graffiti.get(...args);
|
|
176
|
+
this.synchronizeDispatch({ object });
|
|
177
|
+
return object;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error instanceof import_api.GraffitiErrorNotFound) {
|
|
180
|
+
this.synchronizeDispatch({
|
|
181
|
+
tombstone: true,
|
|
182
|
+
object: { url: (0, import_api.unpackObjectUrl)(args[0]) }
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
post = async (...args) => {
|
|
189
|
+
const object = await this.graffiti.post(...args);
|
|
190
|
+
await this.synchronizeDispatch({ object }, true);
|
|
200
191
|
return object;
|
|
201
192
|
};
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
...oldObject,
|
|
207
|
-
value: partialObject.value,
|
|
208
|
-
channels: partialObject.channels,
|
|
209
|
-
allowed: partialObject.allowed
|
|
193
|
+
delete = async (...args) => {
|
|
194
|
+
const update = {
|
|
195
|
+
tombstone: true,
|
|
196
|
+
object: { url: (0, import_api.unpackObjectUrl)(args[0]) }
|
|
210
197
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
);
|
|
221
|
-
return oldObject;
|
|
222
|
-
};
|
|
223
|
-
patch = async (...args) => {
|
|
224
|
-
const oldObject = await this.graffiti.patch(...args);
|
|
225
|
-
const newObject = { ...oldObject };
|
|
226
|
-
for (const prop of ["value", "channels", "allowed"]) {
|
|
227
|
-
(0, import_utilities.applyGraffitiPatch)(await this.applyPatch, prop, args[0], newObject);
|
|
198
|
+
try {
|
|
199
|
+
const oldObject = await this.graffiti.delete(...args);
|
|
200
|
+
await this.synchronizeDispatch(update, true);
|
|
201
|
+
return oldObject;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
if (error instanceof import_api.GraffitiErrorNotFound) {
|
|
204
|
+
await this.synchronizeDispatch(update, true);
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
228
207
|
}
|
|
229
|
-
await this.synchronizeDispatch(
|
|
230
|
-
{
|
|
231
|
-
tombstone: true,
|
|
232
|
-
object: oldObject
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
object: newObject
|
|
236
|
-
},
|
|
237
|
-
true
|
|
238
|
-
);
|
|
239
|
-
return oldObject;
|
|
240
|
-
};
|
|
241
|
-
delete = async (...args) => {
|
|
242
|
-
const oldObject = await this.graffiti.delete(...args);
|
|
243
|
-
await this.synchronizeDispatch(
|
|
244
|
-
{
|
|
245
|
-
tombstone: true,
|
|
246
|
-
object: oldObject
|
|
247
|
-
},
|
|
248
|
-
void 0,
|
|
249
|
-
true
|
|
250
|
-
);
|
|
251
|
-
return oldObject;
|
|
252
208
|
};
|
|
253
209
|
objectStreamContinue(iterator) {
|
|
254
210
|
const this_ = this;
|
|
@@ -258,14 +214,12 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
258
214
|
if (result.done) {
|
|
259
215
|
const { continue: continue_, cursor } = result.value;
|
|
260
216
|
return {
|
|
261
|
-
continue: () => this_.objectStreamContinue(continue_()),
|
|
217
|
+
continue: (session) => this_.objectStreamContinue(continue_(session)),
|
|
262
218
|
cursor
|
|
263
219
|
};
|
|
264
220
|
}
|
|
265
221
|
if (!result.value.error) {
|
|
266
|
-
this_.synchronizeDispatch(
|
|
267
|
-
result.value
|
|
268
|
-
);
|
|
222
|
+
this_.synchronizeDispatch(result.value);
|
|
269
223
|
}
|
|
270
224
|
yield result.value;
|
|
271
225
|
}
|
|
@@ -285,12 +239,8 @@ class GraffitiSynchronize extends import_api.Graffiti {
|
|
|
285
239
|
const iterator = this.graffiti.discover(...args);
|
|
286
240
|
return this.objectStream(iterator);
|
|
287
241
|
};
|
|
288
|
-
|
|
289
|
-
const iterator = this.graffiti.
|
|
290
|
-
return this.objectStream(iterator);
|
|
291
|
-
};
|
|
292
|
-
continueObjectStream = (...args) => {
|
|
293
|
-
const iterator = this.graffiti.continueObjectStream(...args);
|
|
242
|
+
continueDiscover = (...args) => {
|
|
243
|
+
const iterator = this.graffiti.continueDiscover(...args);
|
|
294
244
|
return this.objectStreamContinue(iterator);
|
|
295
245
|
};
|
|
296
246
|
}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type Ajv from \"ajv\";\nimport { Graffiti } from \"@graffiti-garden/api\";\nimport type {\n GraffitiSession,\n JSONSchema,\n GraffitiObjectStream,\n GraffitiObjectStreamContinueEntry,\n GraffitiObjectStreamContinue,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\nimport type { GraffitiObjectBase } from \"@graffiti-garden/api\";\nimport { Repeater } from \"@repeaterjs/repeater\";\nimport type { applyPatch } from \"fast-json-patch\";\nimport {\n applyGraffitiPatch,\n compileGraffitiObjectSchema,\n isActorAllowedGraffitiObject,\n maskGraffitiObject,\n unpackObjectUrl,\n} from \"@graffiti-garden/implementation-local/utilities\";\nexport type * from \"@graffiti-garden/api\";\n\nexport type GraffitiSynchronizeCallback = (\n oldObject: GraffitiObjectStreamContinueEntry<{}>,\n newObject?: GraffitiObjectStreamContinueEntry<{}>,\n) => void;\n\nexport interface GraffitiSynchronizeOptions {\n /**\n * Allows synchronize to listen to all objects, not just those\n * that the session is allowed to see. This is useful to get a\n * global view of all Graffiti objects passsing through the system,\n * for example to build a client-side cache. Additional mechanisms\n * should be in place to ensure that users do not see objects or\n * properties they are not allowed to see.\n *\n * Default: `false`\n */\n omniscient?: boolean;\n}\n\n/**\n * Wraps the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * so that changes made or received in one part of an application\n * are automatically routed to other parts of the application.\n * This is an important tool for building responsive\n * and consistent user interfaces, and is built upon to make\n * the [Graffiti Vue Plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * and possibly other front-end libraries in the future.\n *\n * [See a live example](/example).\n *\n * Specifically, this library provides the following *synchronize*\n * methods to correspond with each of the following Graffiti API methods:\n *\n * | API Method | Synchronize Method |\n * |------------|--------------------|\n * | {@link get} | {@link synchronizeGet} |\n * | {@link discover} | {@link synchronizeDiscover} |\n * | {@link recoverOrphans} | {@link synchronizeRecoverOrphans} |\n *\n * Whenever a change is made via {@link put}, {@link patch}, and {@link delete} or\n * received from {@link get}, {@link discover}, and {@link recoverOrphans},\n * those changes are forwarded to the appropriate synchronize method.\n * Each synchronize method returns an iterator that streams these changes\n * continually until the user calls `return` on the iterator or `break`s out of the loop,\n * allowing for live updates without additional polling.\n *\n * Example 1: Suppose a user publishes a post using {@link put}. If the feed\n * displaying that user's posts is using {@link synchronizeDiscover} to listen for changes,\n * then the user's new post will instantly appear in their feed, giving the UI a\n * responsive feel.\n *\n * Example 2: Suppose one of a user's friends changes their name. As soon as the\n * user's application receives one notice of that change (using {@link get}\n * or {@link discover}), then {@link synchronizeDiscover} listeners can be used to update\n * all instance's of that friend's name in the user's application instantly,\n * providing a consistent user experience.\n *\n * The source code for this library is [available on GitHub](https://github.com/graffiti-garden/wrapper-synchronize/).\n *\n * @groupDescription Synchronize Methods\n * This group contains methods that listen for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n */\nexport class GraffitiSynchronize extends Graffiti {\n protected ajv_: Promise<Ajv> | undefined;\n protected applyPatch_: Promise<typeof applyPatch> | undefined;\n protected readonly graffiti: Graffiti;\n protected readonly callbacks = new Set<GraffitiSynchronizeCallback>();\n protected readonly options: GraffitiSynchronizeOptions;\n\n channelStats: Graffiti[\"channelStats\"];\n login: Graffiti[\"login\"];\n logout: Graffiti[\"logout\"];\n sessionEvents: Graffiti[\"sessionEvents\"];\n\n protected get ajv() {\n if (!this.ajv_) {\n this.ajv_ = (async () => {\n const { default: Ajv } = await import(\"ajv\");\n return new Ajv({ strict: false });\n })();\n }\n return this.ajv_;\n }\n\n protected get applyPatch() {\n if (!this.applyPatch_) {\n this.applyPatch_ = (async () => {\n const { applyPatch } = await import(\"fast-json-patch\");\n return applyPatch;\n })();\n }\n return this.applyPatch_;\n }\n\n /**\n * Wraps a Graffiti API instance to provide the synchronize methods.\n * The GraffitiSyncrhonize class rather than the Graffiti class\n * must be used for all functions for the synchronize methods to work.\n */\n constructor(\n /**\n * The [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * instance to wrap.\n */\n graffiti: Graffiti,\n options?: GraffitiSynchronizeOptions,\n ) {\n super();\n this.options = options ?? {};\n this.graffiti = graffiti;\n this.channelStats = graffiti.channelStats.bind(graffiti);\n this.login = graffiti.login.bind(graffiti);\n this.logout = graffiti.logout.bind(graffiti);\n this.sessionEvents = graffiti.sessionEvents;\n }\n\n protected synchronize<Schema extends JSONSchema>(\n matchObject: (object: GraffitiObjectBase) => boolean,\n channels: string[],\n schema: Schema,\n session?: GraffitiSession | null,\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const seenUrls = new Set<string>();\n\n const repeater = new Repeater<GraffitiObjectStreamContinueEntry<Schema>>(\n async (push, stop) => {\n const validate = compileGraffitiObjectSchema(await this.ajv, schema);\n const callback: GraffitiSynchronizeCallback = (\n oldObjectRaw,\n newObjectRaw,\n ) => {\n for (const objectRaw of [newObjectRaw, oldObjectRaw]) {\n if (objectRaw?.tombstone) {\n if (seenUrls.has(objectRaw.object.url)) {\n push(objectRaw);\n }\n } else if (\n objectRaw &&\n matchObject(objectRaw.object) &&\n (this.options.omniscient ||\n isActorAllowedGraffitiObject(objectRaw.object, session))\n ) {\n // Deep clone the object to prevent mutation\n const object = JSON.parse(\n JSON.stringify(objectRaw.object),\n ) as GraffitiObject<{}>;\n if (!this.options.omniscient) {\n maskGraffitiObject(object, channels, session);\n }\n if (validate(object)) {\n push({ object });\n seenUrls.add(object.url);\n break;\n }\n }\n }\n };\n\n this.callbacks.add(callback);\n await stop;\n this.callbacks.delete(callback);\n },\n );\n\n return (async function* () {\n for await (const i of repeater) yield i;\n })();\n }\n\n /**\n * This method has the same signature as {@link discover} but listens for\n * changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans}\n * and then streams appropriate changes to provide a responsive and\n * consistent user experience.\n *\n * Unlike {@link discover}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeDiscover<Schema extends JSONSchema>(\n ...args: Parameters<typeof Graffiti.prototype.discover<Schema>>\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const [channels, schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.channels.some((channel) => channels.includes(channel));\n }\n return this.synchronize<Schema>(matchObject, channels, schema, session);\n }\n\n /**\n * This method has the same signature as {@link get} but\n * listens for changes made via {@link put}, {@link patch}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link get}, which returns a single result, this method continuously\n * listens for changes which are output as an asynchronous stream, similar\n * to {@link discover}.\n *\n * @group Synchronize Methods\n */\n synchronizeGet<Schema extends JSONSchema>(\n ...args: Parameters<typeof Graffiti.prototype.get<Schema>>\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const [objectUrl, schema, session] = args;\n const url = unpackObjectUrl(objectUrl);\n function matchObject(object: GraffitiObjectBase) {\n return object.url === url;\n }\n return this.synchronize<Schema>(matchObject, [], schema, session);\n }\n\n /**\n * This method has the same signature as {@link recoverOrphans} but\n * listens for changes made via\n * {@link put}, {@link patch}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, and {@link recoverOrphans} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link recoverOrphans}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group Synchronize Methods\n */\n synchronizeRecoverOrphans<Schema extends JSONSchema>(\n ...args: Parameters<typeof Graffiti.prototype.recoverOrphans<Schema>>\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const [schema, session] = args;\n function matchObject(object: GraffitiObjectBase) {\n return object.actor === session.actor && object.channels.length === 0;\n }\n return this.synchronize<Schema>(matchObject, [], schema, session);\n }\n\n /**\n * Streams changes made to *any* object in *any* channel\n * and made by *any* user. You may want to use it in conjuction with\n * {@link GraffitiSynchronizeOptions.omniscient} to get a global view\n * of all Graffiti objects passing through the system. This is useful\n * for building a client-side cache, for example.\n *\n * Be careful using this method. Without additional filters it can\n * expose the user to content out of context.\n *\n * @group Synchronize Methods\n */\n synchronizeAll<Schema extends JSONSchema>(\n schema: Schema,\n session?: GraffitiSession | null,\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n return this.synchronize<Schema>(() => true, [], schema, session);\n }\n\n protected async synchronizeDispatch(\n oldObject: GraffitiObjectStreamContinueEntry<{}>,\n newObject?: GraffitiObjectStreamContinueEntry<{}>,\n waitForListeners = false,\n ) {\n for (const callback of this.callbacks) {\n callback(oldObject, newObject);\n }\n if (waitForListeners) {\n // Wait for the listeners to receive\n // their objects, before returning the operation\n // that triggered them.\n //\n // This is important for mutators (put, patch, delete)\n // to ensure the application state has been updated\n // everywhere before returning, giving consistent\n // feedback to the user that the operation has completed.\n //\n // The opposite is true for accessors (get, discover, recoverOrphans),\n // where it is a weird user experience to call `get`\n // in one place and have the application update\n // somewhere else first. It is also less efficient.\n //\n // The hack is simply to await one \"macro task cycle\".\n // We need to wait for this cycle rather than using\n // `await push` in the callback, because it turns out\n // that `await push` won't resolve until the following\n // .next() call of the iterator, so if only\n // one .next() is called, this dispatch will hang.\n await new Promise((resolve) => setTimeout(resolve, 0));\n }\n }\n\n get: Graffiti[\"get\"] = async (...args) => {\n const object = await this.graffiti.get(...args);\n this.synchronizeDispatch({ object });\n return object;\n };\n\n put: Graffiti[\"put\"] = async (...args) => {\n const oldObject = await this.graffiti.put<{}>(...args);\n const partialObject = args[0];\n const newObject: GraffitiObjectBase = {\n ...oldObject,\n value: partialObject.value,\n channels: partialObject.channels,\n allowed: partialObject.allowed,\n };\n await this.synchronizeDispatch(\n {\n tombstone: true,\n object: oldObject,\n },\n {\n object: newObject,\n },\n true,\n );\n return oldObject;\n };\n\n patch: Graffiti[\"patch\"] = async (...args) => {\n const oldObject = await this.graffiti.patch(...args);\n const newObject: GraffitiObjectBase = { ...oldObject };\n for (const prop of [\"value\", \"channels\", \"allowed\"] as const) {\n applyGraffitiPatch(await this.applyPatch, prop, args[0], newObject);\n }\n await this.synchronizeDispatch(\n {\n tombstone: true,\n object: oldObject,\n },\n {\n object: newObject,\n },\n true,\n );\n return oldObject;\n };\n\n delete: Graffiti[\"delete\"] = async (...args) => {\n const oldObject = await this.graffiti.delete(...args);\n await this.synchronizeDispatch(\n {\n tombstone: true,\n object: oldObject,\n },\n undefined,\n true,\n );\n return oldObject;\n };\n\n protected objectStreamContinue<Schema extends JSONSchema>(\n iterator: GraffitiObjectStreamContinue<Schema>,\n ): GraffitiObjectStreamContinue<Schema> {\n const this_ = this;\n return (async function* () {\n while (true) {\n const result = await iterator.next();\n if (result.done) {\n const { continue: continue_, cursor } = result.value;\n return {\n continue: () => this_.objectStreamContinue<Schema>(continue_()),\n cursor,\n };\n }\n if (!result.value.error) {\n this_.synchronizeDispatch(\n result.value as GraffitiObjectStreamContinueEntry<{}>,\n );\n }\n yield result.value;\n }\n })();\n }\n\n protected objectStream<Schema extends JSONSchema>(\n iterator: GraffitiObjectStream<Schema>,\n ): GraffitiObjectStream<Schema> {\n const wrapped = this.objectStreamContinue<Schema>(iterator);\n return (async function* () {\n // Filter out the tombstones for type safety\n while (true) {\n const result = await wrapped.next();\n if (result.done) return result.value;\n if (result.value.error || !result.value.tombstone) yield result.value;\n }\n })();\n }\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const iterator = this.graffiti.discover(...args);\n return this.objectStream<(typeof args)[1]>(iterator);\n };\n\n recoverOrphans: Graffiti[\"recoverOrphans\"] = (...args) => {\n const iterator = this.graffiti.recoverOrphans(...args);\n return this.objectStream<(typeof args)[0]>(iterator);\n };\n\n continueObjectStream: Graffiti[\"continueObjectStream\"] = (...args) => {\n const iterator = this.graffiti.continueObjectStream(...args);\n return this.objectStreamContinue<{}>(iterator);\n };\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import type Ajv from \"ajv\";\nimport type {\n Graffiti,\n GraffitiSession,\n JSONSchema,\n GraffitiObjectBase,\n GraffitiObjectStream,\n GraffitiObjectStreamContinueEntry,\n GraffitiObjectStreamContinue,\n GraffitiObjectUrl,\n} from \"@graffiti-garden/api\";\nimport {\n GraffitiErrorNotFound,\n compileGraffitiObjectSchema,\n isActorAllowedGraffitiObject,\n maskGraffitiObject,\n unpackObjectUrl,\n} from \"@graffiti-garden/api\";\nimport { Repeater } from \"@repeaterjs/repeater\";\nexport type * from \"@graffiti-garden/api\";\n\nexport type GraffitiSynchronizeCallback = (\n object: GraffitiObjectStreamContinueEntry<{}>,\n) => void;\n\nexport interface GraffitiSynchronizeOptions {\n /**\n * Allows synchronize to listen to all objects, not just those\n * that the session is allowed to see. This is useful to get a\n * global view of all Graffiti objects passsing through the system,\n * for example to build a client-side cache. Additional mechanisms\n * should be in place to ensure that users do not see objects or\n * properties they are not allowed to see.\n *\n * Default: `false`\n */\n omniscient?: boolean;\n}\n\n/**\n * Wraps the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * so that changes made or received in one part of an application\n * are automatically routed to other parts of the application.\n * This is an important tool for building responsive\n * and consistent user interfaces, and is built upon to make\n * the [Graffiti Vue Plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * and possibly other front-end libraries in the future.\n *\n * [See a live example](/example).\n *\n * Specifically, this library provides the following *synchronize*\n * methods to correspond with each of the following Graffiti API methods:\n *\n * | API Method | Synchronize Method |\n * |------------|--------------------|\n * | {@link get} | {@link synchronizeGet} |\n * | {@link discover} | {@link synchronizeDiscover} |\n *\n * Whenever a change is made via {@link post} and {@link delete} or\n * received from {@link get}, {@link discover}, and {@link continueDiscover},\n * those changes are forwarded to the appropriate synchronize method.\n * Each synchronize method returns an iterator that streams these changes\n * continually until the user calls `return` on the iterator or `break`s out of the loop,\n * allowing for live updates without additional polling.\n *\n * Example 1: Suppose a user publishes a post using {@link post}. If the feed\n * displaying that user's posts is using {@link synchronizeDiscover} to listen for changes,\n * then the user's new post will instantly appear in their feed, giving the UI a\n * responsive feel.\n *\n * Example 2: Suppose one of a user's friends changes their name. As soon as the\n * user's application receives one notice of that change (using {@link get}\n * or {@link discover}), then {@link synchronizeDiscover} listeners can be used to update\n * all instance's of that friend's name in the user's application instantly,\n * providing a consistent user experience.\n *\n * Additionally, the library supplies a {@link synchronizeAll} method that can be used\n * to stream all the Graffiti changes that an application is aware of, which can be used\n * for caching or history building.\n *\n * The source code for this library is [available on GitHub](https://github.com/graffiti-garden/wrapper-synchronize/).\n *\n * @groupDescription 0 - Synchronize Methods\n * This group contains methods that listen for changes made via\n * {@link post}, and {@link delete} or fetched from\n * {@link get}, {@link discover}, or {@link continueDiscover} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n */\nexport class GraffitiSynchronize implements Graffiti {\n protected ajv_: Promise<Ajv> | undefined;\n protected readonly graffiti: Graffiti;\n protected readonly callbacks = new Set<GraffitiSynchronizeCallback>();\n protected readonly options: GraffitiSynchronizeOptions;\n\n login: Graffiti[\"login\"];\n logout: Graffiti[\"logout\"];\n sessionEvents: Graffiti[\"sessionEvents\"];\n postMedia: Graffiti[\"postMedia\"];\n getMedia: Graffiti[\"getMedia\"];\n deleteMedia: Graffiti[\"deleteMedia\"];\n actorToHandle: Graffiti[\"actorToHandle\"];\n handleToActor: Graffiti[\"handleToActor\"];\n\n protected get ajv() {\n if (!this.ajv_) {\n this.ajv_ = (async () => {\n const { default: Ajv } = await import(\"ajv\");\n return new Ajv({ strict: false });\n })();\n }\n return this.ajv_;\n }\n\n /**\n * Wraps a Graffiti API instance to provide the synchronize methods.\n * The GraffitiSyncrhonize class rather than the Graffiti class\n * must be used for all functions for the synchronize methods to work.\n */\n constructor(\n /**\n * The [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * instance to wrap.\n */\n graffiti: Graffiti,\n options?: GraffitiSynchronizeOptions,\n ) {\n this.options = options ?? {};\n this.graffiti = graffiti;\n this.login = graffiti.login.bind(graffiti);\n this.logout = graffiti.logout.bind(graffiti);\n this.sessionEvents = graffiti.sessionEvents;\n this.postMedia = graffiti.postMedia.bind(graffiti);\n this.getMedia = graffiti.getMedia.bind(graffiti);\n this.deleteMedia = graffiti.deleteMedia.bind(graffiti);\n this.actorToHandle = graffiti.actorToHandle.bind(graffiti);\n this.handleToActor = graffiti.handleToActor.bind(graffiti);\n }\n\n protected synchronize<Schema extends JSONSchema>(\n matchObject: (object: GraffitiObjectBase) => boolean,\n channels: string[],\n schema: Schema,\n session?: GraffitiSession | null,\n seenUrls: Set<string> = new Set<string>(),\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const repeater = new Repeater<GraffitiObjectStreamContinueEntry<Schema>>(\n async (push, stop) => {\n const validate = compileGraffitiObjectSchema(await this.ajv, schema);\n const callback: GraffitiSynchronizeCallback = (objectUpdate) => {\n if (objectUpdate?.tombstone) {\n if (seenUrls.has(objectUpdate.object.url)) {\n push(objectUpdate);\n }\n } else if (\n objectUpdate &&\n matchObject(objectUpdate.object) &&\n (this.options.omniscient ||\n isActorAllowedGraffitiObject(objectUpdate.object, session))\n ) {\n // Deep clone the object to prevent mutation\n const object = JSON.parse(\n JSON.stringify(objectUpdate.object),\n ) as GraffitiObjectBase;\n if (!this.options.omniscient) {\n maskGraffitiObject(object, channels, session);\n }\n if (validate(object)) {\n push({ object });\n seenUrls.add(object.url);\n }\n }\n };\n\n this.callbacks.add(callback);\n await stop;\n this.callbacks.delete(callback);\n },\n );\n\n return (async function* () {\n for await (const i of repeater) yield i;\n })();\n }\n\n /**\n * This method has the same signature as {@link discover} but listens for\n * changes made via {@link post} and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link continueDiscover}\n * and then streams appropriate changes to provide a responsive and\n * consistent user experience.\n *\n * Unlike {@link discover}, this method continuously listens for changes\n * and will not terminate unless the user calls the `return` method on the iterator\n * or `break`s out of the loop.\n *\n * @group 0 - Synchronize Methods\n */\n synchronizeDiscover<Schema extends JSONSchema>(\n channels: string[],\n schema: Schema,\n session?: GraffitiSession | null,\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n function matchObject(object: GraffitiObjectBase) {\n return object.channels.some((channel) => channels.includes(channel));\n }\n return this.synchronize<Schema>(matchObject, channels, schema, session);\n }\n\n /**\n * This method has the same signature as {@link get} but\n * listens for changes made via {@link post}, and {@link delete} or\n * fetched from {@link get}, {@link discover}, and {@link continueDiscover} and then\n * streams appropriate changes to provide a responsive and consistent user experience.\n *\n * Unlike {@link get}, which returns a single result, this method continuously\n * listens for changes which are output as an asynchronous stream, similar\n * to {@link discover}.\n *\n * @group 0 - Synchronize Methods\n */\n synchronizeGet<Schema extends JSONSchema>(\n objectUrl: string | GraffitiObjectUrl,\n schema: Schema,\n session?: GraffitiSession | null | undefined,\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n const url = unpackObjectUrl(objectUrl);\n function matchObject(object: GraffitiObjectBase) {\n return object.url === url;\n }\n return this.synchronize<Schema>(\n matchObject,\n [],\n schema,\n session,\n new Set<string>([url]),\n );\n }\n\n /**\n * Streams changes made to *any* object in *any* channel\n * and made by *any* user. You may want to use it in conjuction with\n * {@link GraffitiSynchronizeOptions.omniscient} to get a global view\n * of all Graffiti objects passing through the system. This is useful\n * for building a client-side cache, for example.\n *\n * Be careful using this method. Without additional filters it can\n * expose the user to content out of context.\n *\n * @group 0 - Synchronize Methods\n */\n synchronizeAll<Schema extends JSONSchema>(\n schema: Schema,\n session?: GraffitiSession | null,\n ): AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>> {\n return this.synchronize<Schema>(() => true, [], schema, session);\n }\n\n protected async synchronizeDispatch(\n objectUpdate: GraffitiObjectStreamContinueEntry<{}>,\n waitForListeners = false,\n ) {\n for (const callback of this.callbacks) {\n callback(objectUpdate);\n }\n if (waitForListeners) {\n // Wait for the listeners to receive\n // their objects, before returning the operation\n // that triggered them.\n //\n // This is important for mutators (put, patch, delete)\n // to ensure the application state has been updated\n // everywhere before returning, giving consistent\n // feedback to the user that the operation has completed.\n //\n // The opposite is true for accessors (get, discover, recoverOrphans),\n // where it is a weird user experience to call `get`\n // in one place and have the application update\n // somewhere else first. It is also less efficient.\n //\n // The hack is simply to await one \"macro task cycle\".\n // We need to wait for this cycle rather than using\n // `await push` in the callback, because it turns out\n // that `await push` won't resolve until the following\n // .next() call of the iterator, so if only\n // one .next() is called, this dispatch will hang.\n await new Promise((resolve) => setTimeout(resolve, 0));\n }\n }\n\n get: Graffiti[\"get\"] = async (...args) => {\n try {\n const object = await this.graffiti.get(...args);\n this.synchronizeDispatch({ object });\n return object;\n } catch (error) {\n if (error instanceof GraffitiErrorNotFound) {\n this.synchronizeDispatch({\n tombstone: true,\n object: { url: unpackObjectUrl(args[0]) },\n });\n }\n throw error;\n }\n };\n\n post: Graffiti[\"post\"] = async (...args) => {\n // @ts-ignore\n const object = await this.graffiti.post(...args);\n await this.synchronizeDispatch({ object }, true);\n return object;\n };\n\n delete: Graffiti[\"delete\"] = async (...args) => {\n const update = {\n tombstone: true,\n object: { url: unpackObjectUrl(args[0]) },\n } as const;\n try {\n const oldObject = await this.graffiti.delete(...args);\n await this.synchronizeDispatch(update, true);\n return oldObject;\n } catch (error) {\n if (error instanceof GraffitiErrorNotFound) {\n await this.synchronizeDispatch(update, true);\n }\n throw error;\n }\n };\n\n protected objectStreamContinue<Schema extends JSONSchema>(\n iterator: GraffitiObjectStreamContinue<Schema>,\n ): GraffitiObjectStreamContinue<Schema> {\n const this_ = this;\n return (async function* () {\n while (true) {\n const result = await iterator.next();\n if (result.done) {\n const { continue: continue_, cursor } = result.value;\n return {\n continue: (session?: GraffitiSession | null) =>\n this_.objectStreamContinue<Schema>(continue_(session)),\n cursor,\n };\n }\n if (!result.value.error) {\n this_.synchronizeDispatch(result.value);\n }\n yield result.value;\n }\n })();\n }\n\n protected objectStream<Schema extends JSONSchema>(\n iterator: GraffitiObjectStream<Schema>,\n ): GraffitiObjectStream<Schema> {\n const wrapped = this.objectStreamContinue<Schema>(iterator);\n return (async function* () {\n // Filter out the tombstones for type safety\n while (true) {\n const result = await wrapped.next();\n if (result.done) return result.value;\n if (result.value.error || !result.value.tombstone) yield result.value;\n }\n })();\n }\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const iterator = this.graffiti.discover(...args);\n return this.objectStream<(typeof args)[1]>(iterator);\n };\n\n continueDiscover: Graffiti[\"continueDiscover\"] = (...args) => {\n const iterator = this.graffiti.continueDiscover(...args);\n return this.objectStreamContinue<{}>(iterator);\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,iBAMO;AACP,sBAAyB;AAsElB,MAAM,oBAAwC;AAAA,EACzC;AAAA,EACS;AAAA,EACA,YAAY,oBAAI,IAAiC;AAAA,EACjD;AAAA,EAEnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,IAAc,MAAM;AAClB,QAAI,CAAC,KAAK,MAAM;AACd,WAAK,QAAQ,YAAY;AACvB,cAAM,EAAE,SAAS,IAAI,IAAI,MAAM,OAAO,KAAK;AAC3C,eAAO,IAAI,IAAI,EAAE,QAAQ,MAAM,CAAC;AAAA,MAClC,GAAG;A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