@graffiti-garden/api 0.6.4 → 1.0.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/README.md +0 -7
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +4 -4
- package/dist/src/1-api.d.ts +172 -178
- package/dist/src/1-api.d.ts.map +1 -1
- package/dist/src/2-types.d.ts +39 -152
- package/dist/src/2-types.d.ts.map +1 -1
- package/dist/src/3-errors.d.ts +2 -8
- package/dist/src/3-errors.d.ts.map +1 -1
- package/dist/src/4-utilities.d.ts +8 -0
- package/dist/src/4-utilities.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/tests/crud.d.ts +1 -1
- package/dist/tests/crud.d.ts.map +1 -1
- package/dist/tests/discover.d.ts +1 -1
- package/dist/tests/discover.d.ts.map +1 -1
- package/dist/tests/index.d.ts +1 -2
- package/dist/tests/index.d.ts.map +1 -1
- package/dist/tests/media.d.ts +3 -0
- package/dist/tests/media.d.ts.map +1 -0
- package/dist/tests/utils.d.ts +3 -3
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/tests.mjs +207 -790
- package/dist/tests.mjs.map +4 -4
- package/package.json +6 -6
- package/src/1-api.ts +182 -186
- package/src/2-types.ts +42 -157
- package/src/3-errors.ts +6 -22
- package/src/4-utilities.ts +65 -0
- package/src/index.ts +1 -0
- package/tests/crud.ts +39 -332
- package/tests/discover.ts +51 -349
- package/tests/index.ts +1 -2
- package/tests/media.ts +158 -0
- package/tests/utils.ts +4 -4
- package/dist/tests/channel-stats.d.ts +0 -3
- package/dist/tests/channel-stats.d.ts.map +0 -1
- package/dist/tests/orphans.d.ts +0 -3
- package/dist/tests/orphans.d.ts.map +0 -1
- package/tests/channel-stats.ts +0 -129
- package/tests/orphans.ts +0 -128
package/dist/src/1-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraffitiObjectUrl, GraffitiObject,
|
|
1
|
+
import type { GraffitiObjectUrl, GraffitiObject, GraffitiSession, GraffitiPostObject, GraffitiObjectStream, 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
|
|
@@ -32,14 +32,13 @@ import type { JSONSchema } from "json-schema-to-ts";
|
|
|
32
32
|
* ## API Overview
|
|
33
33
|
*
|
|
34
34
|
* The Graffiti API provides applications with methods for {@link login} and {@link logout},
|
|
35
|
-
* methods to
|
|
36
|
-
* and a method to {@link discover} data objects
|
|
35
|
+
* methods to interact with data objects using standard database operations ({@link post}, {@link get}, and {@link delete}),
|
|
36
|
+
* and a method to {@link discover} data objects created by others.
|
|
37
37
|
* These data objects have a couple structured properties:
|
|
38
38
|
* - {@link GraffitiObjectBase.url | `url`} (string): A globally unique identifier and locator for the object.
|
|
39
39
|
* - {@link GraffitiObjectBase.actor | `actor`} (string): An unforgeable identifier for the creator of the object.
|
|
40
|
-
* - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the
|
|
40
|
+
* - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the actors who are allowed to access the object (undefined for public objects).
|
|
41
41
|
* - {@link GraffitiObjectBase.channels | `channels`} (string[]): An array of the *contexts* in which the object should appear.
|
|
42
|
-
* - {@link GraffitiObjectBase.lastModified | `revision`} (number): A number to compare different versions of an object.
|
|
43
42
|
*
|
|
44
43
|
* All other data is stored in the object's unstructured {@link GraffitiObjectBase.value | `value`} property.
|
|
45
44
|
* This data can be used to represent social artifacts (e.g. posts, profiles) and activities (e.g. likes, follows).
|
|
@@ -87,57 +86,48 @@ import type { JSONSchema } from "json-schema-to-ts";
|
|
|
87
86
|
* which are Graffiti's means of organizing data contextually, and a concept called "total reification",
|
|
88
87
|
* which handles explains how moderation, collaboration, and other interactions are managed.
|
|
89
88
|
*
|
|
90
|
-
* @groupDescription
|
|
91
|
-
* Methods for {@link
|
|
89
|
+
* @groupDescription 1 - Single-Object Methods
|
|
90
|
+
* Methods for {@link post | creating}, {@link get | reading},
|
|
92
91
|
* and {@link delete | deleting} {@link GraffitiObjectBase | Graffiti objects}.
|
|
93
|
-
* @groupDescription
|
|
92
|
+
* @groupDescription 2 - Multi-Object Methods
|
|
94
93
|
* Methods that retrieve or accumulate information about multiple {@link GraffitiObjectBase | Graffiti objects} at a time.
|
|
95
|
-
* @groupDescription
|
|
94
|
+
* @groupDescription 3 - Media Methods
|
|
95
|
+
* Methods for {@link postMedia | creating}, {@link getMedia | reading},
|
|
96
|
+
* and {@link deleteMedia | deleting} media data.
|
|
97
|
+
* @groupDescription 4 - Identity Methods
|
|
96
98
|
* Methods and properties for logging in and out.
|
|
97
99
|
*/
|
|
98
100
|
export declare abstract class Graffiti {
|
|
99
101
|
/**
|
|
100
|
-
* Creates a new {@link GraffitiObjectBase | object}
|
|
101
|
-
* An object can only be replaced by the same {@link GraffitiObjectBase.actor | `actor`}
|
|
102
|
-
* that created it.
|
|
102
|
+
* Creates a new {@link GraffitiObjectBase | object}.
|
|
103
103
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* @throws {@link GraffitiErrorNotFound} if a {@link GraffitiObjectBase.url | `url`}
|
|
108
|
-
* is provided that has not been created yet or the {@link GraffitiObjectBase.actor | `actor`}
|
|
109
|
-
* is not {@link GraffitiObjectBase.allowed | `allowed`} to see it.
|
|
110
|
-
*
|
|
111
|
-
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
112
|
-
* is not the same `actor` as the one who created the object.
|
|
113
|
-
*
|
|
114
|
-
* @returns Returns the object that was replaced if one one exists, otherwise returns an object with
|
|
115
|
-
* with an empty {@link GraffitiObjectBase.value | `value`},
|
|
116
|
-
* {@link GraffitiObjectBase.channels | `channels`}, and {@link GraffitiObjectBase.allowed | `allowed`}
|
|
117
|
-
* list.
|
|
118
|
-
* The {@link GraffitiObjectBase.lastModified | `lastModified`} property of the returned object
|
|
119
|
-
* will be updated to the time of replacement/creation.
|
|
104
|
+
* @returns Returns the object that has been posted, complete with its
|
|
105
|
+
* assigned {@link GraffitiObjectBase.url | `url`} and
|
|
106
|
+
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
120
107
|
*
|
|
121
|
-
* @group
|
|
108
|
+
* @group 1 - Single-Object Methods
|
|
122
109
|
*/
|
|
123
|
-
abstract
|
|
110
|
+
abstract post<Schema extends JSONSchema>(
|
|
124
111
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
112
|
+
* An object to post, minus its {@link GraffitiObjectBase.url | `url`} and
|
|
113
|
+
* {@link GraffitiObjectBase.actor | `actor`}, which will be assigned once posted.
|
|
114
|
+
* This object is statically type-checked against the [JSON schema](https://json-schema.org/) that can be optionally provided
|
|
115
|
+
* as the generic type parameter. It is recommended to a schema to
|
|
116
|
+
* ensure that the posted object matches subsequent {@link get} or {@link discover}
|
|
128
117
|
* methods.
|
|
129
118
|
*/
|
|
130
|
-
|
|
119
|
+
partialObject: GraffitiPostObject<Schema>,
|
|
131
120
|
/**
|
|
132
121
|
* An implementation-specific object with information to authenticate the
|
|
133
122
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
134
123
|
*/
|
|
135
|
-
session: GraffitiSession): Promise<
|
|
124
|
+
session: GraffitiSession): Promise<GraffitiPostObject<Schema> & {
|
|
125
|
+
url: string;
|
|
126
|
+
actor: string;
|
|
127
|
+
}>;
|
|
136
128
|
/**
|
|
137
|
-
* Retrieves an object from a given {@link GraffitiObjectBase.url | `url`}
|
|
138
|
-
*
|
|
139
|
-
* The retrieved object is type-checked against the provided [JSON schema](https://json-schema.org/)
|
|
140
|
-
* otherwise a {@link GraffitiErrorSchemaMismatch} is thrown.
|
|
129
|
+
* Retrieves an object from a given {@link GraffitiObjectBase.url | `url`} matching
|
|
130
|
+
* the provided `schema`.
|
|
141
131
|
*
|
|
142
132
|
* If the retreiving {@link GraffitiObjectBase.actor | `actor`} is not
|
|
143
133
|
* the object's `actor`,
|
|
@@ -152,7 +142,7 @@ export declare abstract class Graffiti {
|
|
|
152
142
|
*
|
|
153
143
|
* @throws {@link GraffitiErrorSchemaMismatch} if the retrieved object does not match the provided schema.
|
|
154
144
|
*
|
|
155
|
-
* @group
|
|
145
|
+
* @group 1 - Single-Object Methods
|
|
156
146
|
*/
|
|
157
147
|
abstract get<Schema extends JSONSchema>(
|
|
158
148
|
/**
|
|
@@ -171,59 +161,18 @@ export declare abstract class Graffiti {
|
|
|
171
161
|
*/
|
|
172
162
|
session?: GraffitiSession | null): Promise<GraffitiObject<Schema>>;
|
|
173
163
|
/**
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* `actor` that created the object.
|
|
177
|
-
*
|
|
178
|
-
* @returns Returns the original object prior to the patch with its
|
|
179
|
-
* {@link GraffitiObjectBase.lastModified | `lastModified`}
|
|
180
|
-
* property updated to the time of patching.
|
|
181
|
-
*
|
|
182
|
-
* @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,
|
|
183
|
-
* or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.
|
|
184
|
-
*
|
|
185
|
-
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
186
|
-
* is not the same `actor` as the one who created the object.
|
|
187
|
-
*
|
|
188
|
-
* @group CRUD Methods
|
|
189
|
-
*/
|
|
190
|
-
abstract patch(
|
|
191
|
-
/**
|
|
192
|
-
* A collection of [JSON Patch](https://jsonpatch.com) operations
|
|
193
|
-
* to apply to the object. See {@link GraffitiPatch} for more information.
|
|
194
|
-
*/
|
|
195
|
-
patch: GraffitiPatch,
|
|
196
|
-
/**
|
|
197
|
-
* The location of the object to patch.
|
|
198
|
-
*/
|
|
199
|
-
url: string | GraffitiObjectUrl,
|
|
200
|
-
/**
|
|
201
|
-
* An implementation-specific object with information to authenticate the
|
|
202
|
-
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
203
|
-
*/
|
|
204
|
-
session: GraffitiSession): Promise<GraffitiObjectBase>;
|
|
205
|
-
/**
|
|
206
|
-
* Deletes an object from a given {@link GraffitiObjectBase.url | `url`}.
|
|
164
|
+
* Deletes an object from a given {@link GraffitiObjectBase.url | `url`}
|
|
165
|
+
* that had previously been {@link post | `post`ed}.
|
|
207
166
|
* The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the
|
|
208
167
|
* `actor` that created the object.
|
|
209
168
|
*
|
|
210
|
-
*
|
|
211
|
-
* to ensure a person's [right to be forgotten](https://en.wikipedia.org/wiki/Right_to_be_forgotten).
|
|
212
|
-
* In cases where deleting and restoring an object is useful, an object's
|
|
213
|
-
* {@link GraffitiObjectBase.allowed | `allowed`} property can be set to
|
|
214
|
-
* an empty list to hide it from all actors except the creator.
|
|
215
|
-
*
|
|
216
|
-
* @returns Returns the object that was deleted with its
|
|
217
|
-
* {@link GraffitiObjectBase.lastModified | `lastModified`}
|
|
218
|
-
* property updated to the time of deletion.
|
|
219
|
-
*
|
|
220
|
-
* @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,
|
|
169
|
+
* @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,
|
|
221
170
|
* or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.
|
|
222
171
|
*
|
|
223
172
|
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
224
173
|
* is not the same `actor` as the one who created the object.
|
|
225
174
|
*
|
|
226
|
-
* @group
|
|
175
|
+
* @group 1 - Single-Object Methods
|
|
227
176
|
*/
|
|
228
177
|
abstract delete(
|
|
229
178
|
/**
|
|
@@ -234,7 +183,7 @@ export declare abstract class Graffiti {
|
|
|
234
183
|
* An implementation-specific object with information to authenticate the
|
|
235
184
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
236
185
|
*/
|
|
237
|
-
session: GraffitiSession): Promise<
|
|
186
|
+
session: GraffitiSession): Promise<void>;
|
|
238
187
|
/**
|
|
239
188
|
* Discovers objects created by any actor that are contained
|
|
240
189
|
* in at least one of the given {@link GraffitiObjectBase.channels | `channels`}
|
|
@@ -250,7 +199,7 @@ export declare abstract class Graffiti {
|
|
|
250
199
|
* string can be serialized to continue the stream after an application is closed
|
|
251
200
|
* and reopened.
|
|
252
201
|
*
|
|
253
|
-
* `discover` will not return objects that the {@link GraffitiObjectBase.actor | `actor`}
|
|
202
|
+
* `discover` will not return objects that the querying {@link GraffitiObjectBase.actor | `actor`}
|
|
254
203
|
* is not {@link GraffitiObjectBase.allowed | `allowed`} to access.
|
|
255
204
|
* If the `actor` is not the creator of a discovered object,
|
|
256
205
|
* the allowed list will be masked to only contain the querying actor if the
|
|
@@ -261,14 +210,11 @@ export declare abstract class Graffiti {
|
|
|
261
210
|
*
|
|
262
211
|
* Since different implementations may fetch data from multiple sources there is
|
|
263
212
|
* no guarentee on the order that objects are returned in.
|
|
264
|
-
* It is also possible that duplicate objects are returned and their
|
|
265
|
-
* {@link GraffitiObjectBase.lastModified | `lastModified`} fields must be used
|
|
266
|
-
* to determine which object is the most recent.
|
|
267
213
|
*
|
|
268
214
|
* @returns Returns a stream of objects that match the given {@link GraffitiObjectBase.channels | `channels`}
|
|
269
215
|
* and [JSON Schema](https://json-schema.org).
|
|
270
216
|
*
|
|
271
|
-
* @group
|
|
217
|
+
* @group 2 - Multi-Object Methods
|
|
272
218
|
*/
|
|
273
219
|
abstract discover<Schema extends JSONSchema>(
|
|
274
220
|
/**
|
|
@@ -287,88 +233,127 @@ export declare abstract class Graffiti {
|
|
|
287
233
|
*/
|
|
288
234
|
session?: GraffitiSession | null): GraffitiObjectStream<Schema>;
|
|
289
235
|
/**
|
|
290
|
-
*
|
|
291
|
-
* {@link
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* Like {@link channelStats}, this method is not useful for most applications,
|
|
297
|
-
* but necessary for getting a global view of all an actor's Graffiti data
|
|
298
|
-
* to implement something like Facebook's Activity Log or a debugging interface.
|
|
236
|
+
* Continues a {@link GraffitiObjectStream} from a given
|
|
237
|
+
* {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.
|
|
238
|
+
* The continuation will return new objects that have been {@link post | `post`ed}
|
|
239
|
+
* that match the original stream, and also returns the
|
|
240
|
+
* {@link GraffitiObjectBase.url | `url`}s of objects that
|
|
241
|
+
* have been {@link delete | `delete`d}, as marked by a `tombstone`.
|
|
299
242
|
*
|
|
300
|
-
*
|
|
301
|
-
* the
|
|
302
|
-
*
|
|
303
|
-
*
|
|
243
|
+
* The `cursor` allows the client to
|
|
244
|
+
* serialize the state of the stream and continue it later.
|
|
245
|
+
* However this method loses any typing information that was
|
|
246
|
+
* present in the original stream. For better type safety
|
|
247
|
+
* and when serializing is not necessary, use the
|
|
248
|
+
* {@link GraffitiObjectStreamReturn.continue | `continue`} method
|
|
249
|
+
* instead, which is returned along with the `cursor` at the
|
|
250
|
+
* end of the original stream.
|
|
304
251
|
*
|
|
305
|
-
* @
|
|
306
|
-
*
|
|
307
|
-
*
|
|
252
|
+
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
253
|
+
* provided in the `session` is not the same as the `actor`
|
|
254
|
+
* that initiated the original stream.
|
|
308
255
|
*
|
|
309
|
-
* @group
|
|
256
|
+
* @group 2 - Multi-Object Methods
|
|
310
257
|
*/
|
|
311
|
-
abstract
|
|
258
|
+
abstract continueDiscover(cursor: string, session?: GraffitiSession | null): GraffitiObjectStreamContinue<{}>;
|
|
312
259
|
/**
|
|
313
|
-
*
|
|
260
|
+
* Uploads media data, such as an image or video.
|
|
261
|
+
*
|
|
262
|
+
* Unlike structured {@link GraffitiObjectBase | objects},
|
|
263
|
+
* media is not indexed for {@link discover | `discover`y} and
|
|
264
|
+
* must be retrieved by its exact URL using {@link getMedia}
|
|
265
|
+
*
|
|
266
|
+
* @returns The URL that the media was posted to.
|
|
267
|
+
*
|
|
268
|
+
* @group 3 - Media Methods
|
|
314
269
|
*/
|
|
315
|
-
|
|
270
|
+
abstract postMedia(media: {
|
|
271
|
+
/**
|
|
272
|
+
* The binary data of the media to be uploaded,
|
|
273
|
+
* along with its [media type](https://www.iana.org/assignments/media-types/media-types.xhtml),
|
|
274
|
+
* formatted as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob).
|
|
275
|
+
*/
|
|
276
|
+
data: Blob;
|
|
277
|
+
/**
|
|
278
|
+
* An optional list, identical in function to an object's
|
|
279
|
+
* {@link GraffitiObjectBase.allowed | `allowed`} property,
|
|
280
|
+
* that specifies the {@link GraffitiObjectBase.actor | `actor`}s
|
|
281
|
+
* who are allowed to access the media. If the list is `undefined`
|
|
282
|
+
* or `null`, anyone with the URL can access the media. If the list
|
|
283
|
+
* is empty, only the {@link GraffitiObjectBase.actor | `actor`}
|
|
284
|
+
* who {@link postMedia | `post`ed} the media can access it.
|
|
285
|
+
*/
|
|
286
|
+
allowed?: string[] | null;
|
|
287
|
+
},
|
|
316
288
|
/**
|
|
317
289
|
* An implementation-specific object with information to authenticate the
|
|
318
290
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
319
291
|
*/
|
|
320
|
-
session: GraffitiSession):
|
|
292
|
+
session: GraffitiSession): Promise<string>;
|
|
321
293
|
/**
|
|
322
|
-
*
|
|
323
|
-
* that an {@link GraffitiObjectBase.actor | `actor`} has posted to.
|
|
324
|
-
* This method will not return statistics related to any other actor's channel usage.
|
|
325
|
-
*
|
|
326
|
-
* Like {@link recoverOrphans}, this method is not useful for most applications,
|
|
327
|
-
* but necessary for getting a global view of all an actor's Graffiti data
|
|
328
|
-
* to implement something like Facebook's Activity Log or a debugging interface.
|
|
294
|
+
* Deletes media previously {@link postMedia | `post`ed} to a given URL.
|
|
329
295
|
*
|
|
330
|
-
*
|
|
331
|
-
* the stream will end once all leads have been exhausted.
|
|
296
|
+
* @throws {@link GraffitiErrorNotFound} if no media at that URL exists.
|
|
332
297
|
*
|
|
333
|
-
* @
|
|
298
|
+
* @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}
|
|
299
|
+
* provided in the `session` is not the same as the `actor` that {@link postMedia | `post`ed}
|
|
300
|
+
* the media.
|
|
334
301
|
*
|
|
335
|
-
* @
|
|
336
|
-
|
|
302
|
+
* @group 3 - Media Methods
|
|
303
|
+
*/
|
|
304
|
+
abstract deleteMedia(
|
|
305
|
+
/**
|
|
306
|
+
* A globally unique identifier and locator for the media.
|
|
337
307
|
*/
|
|
338
|
-
|
|
308
|
+
mediaUrl: string,
|
|
339
309
|
/**
|
|
340
310
|
* An implementation-specific object with information to authenticate the
|
|
341
311
|
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
342
312
|
*/
|
|
343
|
-
session: GraffitiSession):
|
|
313
|
+
session: GraffitiSession): Promise<void>;
|
|
344
314
|
/**
|
|
345
|
-
*
|
|
346
|
-
* {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.
|
|
347
|
-
* The continuation will return new objects that have been created
|
|
348
|
-
* that match the original stream, and also returns the
|
|
349
|
-
* {@link GraffitiObjectBase.url | `url`}s of objects that
|
|
350
|
-
* have been deleted, as marked by a `tombstone`.
|
|
315
|
+
* Retrieves media from the given media URL, adhering to the given requirements.
|
|
351
316
|
*
|
|
352
|
-
*
|
|
353
|
-
* were already returned by the original stream. This is dependent
|
|
354
|
-
* on how much state the underlying implementation maintains.
|
|
317
|
+
* @throws {@link GraffitiErrorNotFound} if no media at that URL exists.
|
|
355
318
|
*
|
|
356
|
-
*
|
|
357
|
-
* serialize the state of the stream and continue it later.
|
|
358
|
-
* However this method loses any typing information that was
|
|
359
|
-
* present in the original stream. For better type safety
|
|
360
|
-
* and when serializing is not necessary, use the
|
|
361
|
-
* {@link GraffitiObjectStreamReturn.continue | `continue`} method
|
|
362
|
-
* instead, which is returned along with the `cursor` at the
|
|
363
|
-
* end of the original stream.
|
|
319
|
+
* @throws {@link GraffitiErrorTooLarge} if the media exceeds the given `maxBytes`.
|
|
364
320
|
*
|
|
365
|
-
* @throws {@link
|
|
366
|
-
*
|
|
367
|
-
*
|
|
321
|
+
* @throws {@link GraffitiErrorNotAcceptable} if the media does not match the given
|
|
322
|
+
* `accept` specification.
|
|
323
|
+
*
|
|
324
|
+
* @returns The URL of the retrieved media, as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
|
|
325
|
+
* and the {@link GraffitiObjectBase.actor | `actor`} that posted it.
|
|
368
326
|
*
|
|
369
|
-
* @group
|
|
327
|
+
* @group 3 - Media Methods
|
|
370
328
|
*/
|
|
371
|
-
abstract
|
|
329
|
+
abstract getMedia(
|
|
330
|
+
/**
|
|
331
|
+
* A globally unique identifier and locator for the media.
|
|
332
|
+
*/
|
|
333
|
+
mediaUrl: string,
|
|
334
|
+
/**
|
|
335
|
+
* A set of requirements the retrieved media must meet.
|
|
336
|
+
*/
|
|
337
|
+
requirements: {
|
|
338
|
+
/**
|
|
339
|
+
* A list of acceptable media types for the retrieved media,
|
|
340
|
+
* formatted as like an [HTTP Accept header](https://httpwg.org/specs/rfc9110.html#field.accept)
|
|
341
|
+
*/
|
|
342
|
+
accept?: string;
|
|
343
|
+
/**
|
|
344
|
+
* The maximum acceptable size, in bytes, of the media.
|
|
345
|
+
*/
|
|
346
|
+
maxBytes?: number;
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* An implementation-specific object with information to authenticate the
|
|
350
|
+
* {@link GraffitiObjectBase.actor | `actor`}.
|
|
351
|
+
*/
|
|
352
|
+
session?: GraffitiSession | null): Promise<{
|
|
353
|
+
data: Blob;
|
|
354
|
+
actor: string;
|
|
355
|
+
allowed?: string[] | null;
|
|
356
|
+
}>;
|
|
372
357
|
/**
|
|
373
358
|
* Begins the login process. Depending on the implementation, this may
|
|
374
359
|
* involve redirecting to a login page or opening a popup,
|
|
@@ -379,38 +364,19 @@ export declare abstract class Graffiti {
|
|
|
379
364
|
* asynchronously via {@link Graffiti.sessionEvents | sessionEvents}
|
|
380
365
|
* as a {@link GraffitiLoginEvent} with event type `login`.
|
|
381
366
|
*
|
|
382
|
-
* @group
|
|
367
|
+
* @group 4 - Identity Methods
|
|
383
368
|
*/
|
|
384
369
|
abstract login(
|
|
385
370
|
/**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
371
|
+
* A suggested actor to login as. For example, if a user tries to
|
|
372
|
+
* edit a post but are not logged in, the interface can infer that
|
|
373
|
+
* they might want to log in as the actor who created the post
|
|
374
|
+
* they are attempting to edit.
|
|
375
|
+
*
|
|
376
|
+
* Even if provided, the implementation should allow the user
|
|
377
|
+
* to log in as a different actor if they choose.
|
|
389
378
|
*/
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* A suggested actor to login as. For example, if a user tries to
|
|
393
|
-
* edit a post but are not logged in, the interface can infer that
|
|
394
|
-
* they might want to log in as the actor who created the post
|
|
395
|
-
* they are attempting to edit.
|
|
396
|
-
*
|
|
397
|
-
* Even if provided, the implementation should allow the user
|
|
398
|
-
* to log in as a different actor if they choose.
|
|
399
|
-
*/
|
|
400
|
-
actor?: string;
|
|
401
|
-
/**
|
|
402
|
-
* A yet to be defined permissions scope. An application may use
|
|
403
|
-
* this to indicate the minimum necessary scope needed to
|
|
404
|
-
* operate. For example, it may need to be able read private
|
|
405
|
-
* messages from a certain set of channels, or write messages that
|
|
406
|
-
* follow a particular schema.
|
|
407
|
-
*
|
|
408
|
-
* The login process should make it clear what scope an application
|
|
409
|
-
* is requesting and allow the user to enhance or reduce that
|
|
410
|
-
* scope as necessary.
|
|
411
|
-
*/
|
|
412
|
-
scope?: {};
|
|
413
|
-
}): Promise<void>;
|
|
379
|
+
actor?: string): Promise<void>;
|
|
414
380
|
/**
|
|
415
381
|
* Begins the logout process for a particular {@link GraffitiSession | session}. Depending on the implementation, this may
|
|
416
382
|
* involve redirecting the user to a logout page or opening a popup,
|
|
@@ -421,7 +387,7 @@ export declare abstract class Graffiti {
|
|
|
421
387
|
* {@link Graffiti.sessionEvents | sessionEvents}
|
|
422
388
|
* as a {@link GraffitiLogoutEvent} as event type `logout`.
|
|
423
389
|
*
|
|
424
|
-
* @group
|
|
390
|
+
* @group 4 - Identity Methods
|
|
425
391
|
*/
|
|
426
392
|
abstract logout(
|
|
427
393
|
/**
|
|
@@ -435,8 +401,36 @@ export declare abstract class Graffiti {
|
|
|
435
401
|
* - `logout` - {@link GraffitiLogoutEvent}
|
|
436
402
|
* - `initialized` - {@link GraffitiSessionInitializedEvent}
|
|
437
403
|
*
|
|
438
|
-
* @group
|
|
404
|
+
* @group 4 - Identity Methods
|
|
439
405
|
*/
|
|
440
406
|
abstract readonly sessionEvents: EventTarget;
|
|
407
|
+
/**
|
|
408
|
+
* Retrieves the human-readable handle associated
|
|
409
|
+
* with the given actor. The handle may change over time
|
|
410
|
+
* and so it should be used for display purposes only.
|
|
411
|
+
*
|
|
412
|
+
* The inverse of {@link handleToActor}.
|
|
413
|
+
*
|
|
414
|
+
* @throws {@link GraffitiErrorNotFound} if a handle cannot be
|
|
415
|
+
* found for the given actor.
|
|
416
|
+
*
|
|
417
|
+
* @returns A human-readable handle for the given actor.
|
|
418
|
+
*
|
|
419
|
+
* @group 4 - Identity Methods
|
|
420
|
+
*/
|
|
421
|
+
abstract actorToHandle(actor: string): Promise<string>;
|
|
422
|
+
/**
|
|
423
|
+
* Retrieves the actor ID associated with the given handle.
|
|
424
|
+
*
|
|
425
|
+
* The inverse of {@link actorToHandle}.
|
|
426
|
+
*
|
|
427
|
+
* @throws {@link GraffitiErrorNotFound} if there is no actor
|
|
428
|
+
* with the given handle.
|
|
429
|
+
*
|
|
430
|
+
* @returns The actor ID for the given handle.
|
|
431
|
+
*
|
|
432
|
+
* @group 4 - Identity Methods
|
|
433
|
+
*/
|
|
434
|
+
abstract handleToActor(handle: string): Promise<string>;
|
|
441
435
|
}
|
|
442
436
|
//# sourceMappingURL=1-api.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"1-api.d.ts","sourceRoot":"","sources":["../../src/1-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EAEd,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AACH,8BAAsB,QAAQ;IAC5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,CAAC,MAAM,SAAS,UAAU;IACrC;;;;;;;OAOG;IACH,aAAa,EAAE,kBAAkB,CAAC,MAAM,CAAC;IACzC;;;OAGG;IACH,OAAO,EAAE,eAAe,GACvB,OAAO,CACR,kBAAkB,CAAC,MAAM,CAAC,GAAG;QAC3B,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,CACF;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,GAAG,CAAC,MAAM,SAAS,UAAU;IACpC;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,iBAAiB;IAC/B;;OAEG;IACH,MAAM,EAAE,MAAM;IACd;;;;;OAKG;IACH,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,GAC/B,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAElC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM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