@graffiti-garden/api 1.0.5 → 1.0.7
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/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/cjs/1-api.js.map +1 -1
- package/dist/cjs/3-errors.js +8 -0
- package/dist/cjs/3-errors.js.map +2 -2
- package/dist/cjs/4-utilities.js +2 -2
- package/dist/cjs/4-utilities.js.map +2 -2
- package/dist/cjs/5-runtime-types.js.map +1 -1
- package/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/1-api.js.map +1 -1
- package/dist/esm/3-errors.js +8 -0
- package/dist/esm/3-errors.js.map +2 -2
- package/dist/esm/4-utilities.js +2 -2
- package/dist/esm/4-utilities.js.map +2 -2
- package/dist/esm/5-runtime-types.js.map +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/src/1-api.d.ts +1 -1
- package/dist/src/1-api.d.ts.map +1 -1
- package/dist/src/3-errors.d.ts +3 -0
- package/dist/src/3-errors.d.ts.map +1 -1
- package/dist/src/4-utilities.d.ts +1 -1
- package/dist/src/4-utilities.d.ts.map +1 -1
- package/dist/src/5-runtime-types.d.ts +2 -2
- package/dist/src/5-runtime-types.d.ts.map +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/tests/index.d.ts +4 -4
- package/dist/tests/index.d.ts.map +1 -1
- package/dist/tests.mjs +8 -8
- package/dist/tests.mjs.map +3 -3
- package/package.json +1 -1
- package/src/1-api.ts +1 -1
- package/src/3-errors.ts +8 -0
- package/src/4-utilities.ts +3 -3
- package/src/5-runtime-types.ts +2 -2
- package/src/index.ts +5 -5
- package/tests/crud.ts +1 -1
- package/tests/discover.ts +3 -3
- package/tests/index.ts +4 -4
- package/tests/media.ts +1 -1
package/dist/cjs/1-api.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/1-api.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiSession,\n GraffitiPostObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiMedia,\n GraffitiPostMedia,\n GraffitiMediaAccept,\n} from \"./2-types\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\n/**\n * This API describes a small but powerful set of methods that\n * can be used to create many different kinds of social applications,\n * from applications like Twitter, to Messenger, to Wikipedia, to many more new designs.\n * See the [Graffiti project website](https://graffiti.garden)\n * for links to example applications. Additionally, apps built on top\n * of the API interoperate with each other so you can seamlessly switch\n * between apps without losing your friends or data.\n *\n * These API methods should satisfy all of an application's needs for\n * the communication, storage, and access management of social data.\n * The rest of the application can be built with standard client-side\n * user interface tools to present and interact with that data\u2014no server code necessary!\n *\n * The Typescript code for this API is [open source on Github](https://github.com/graffiti-garden/api).\n *\n * There are several different implementations of this Graffiti API available,\n * including a [federated implementation](https://github.com/graffiti-garden/implementation-remote),\n * that lets people choose where their data is stored (you do not need to host your own server)\n * and a [local implementation](https://github.com/graffiti-garden/implementation-local)\n * that can be used for testing and development. Different implementations can\n * be swapped-in in the future without changing the API or any of the apps built on\n * top of it. In fact, we're working on an end-to-end encrypted version now!\n * [Follow Theia on BlueSky for updates](https://bsky.app/profile/theias.place).\n *\n * On the other side of the stack, there is [Vue plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * that wraps around this API to provide reactivity. Other plugin frameworks\n * and high-level libraries will be available in the future.\n *\n * ## API Overview\n *\n * The Graffiti API provides applications with methods for {@link login} and {@link logout},\n * methods to interact with data objects using standard database operations ({@link post}, {@link get}, and {@link delete}),\n * and a method to {@link discover} data objects created by others.\n * These data objects have a couple structured properties:\n * - {@link GraffitiObjectBase.url | `url`} (string): A globally unique identifier and locator for the object.\n * - {@link GraffitiObjectBase.actor | `actor`} (string): An unforgeable identifier for the creator of the object.\n * - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the actors who are allowed to access the object (undefined for public objects).\n * - {@link GraffitiObjectBase.channels | `channels`} (string[]): An array of the *contexts* in which the object should appear.\n *\n * All other data is stored in the object's unstructured {@link GraffitiObjectBase.value | `value`} property.\n * This data can be used to represent social artifacts (e.g. posts, profiles) and activities (e.g. likes, follows).\n * For example, a post might have the value:\n\n * ```js\n * {\n * title: \"My First Post\",\n * content: \"Hello, world!\",\n * published: 1630483200000\n * }\n * ```\n *\n * a profile might have the value:\n *\n * ```js\n * {\n * name: \"Theia Henderson\",\n * pronouns: \"she/her\",\n * describes: \"did:web:theias.place\" // Theia's actor ID\n * }\n * ```\n *\n * and a \"Like\" might have the value:\n *\n * ```js\n * {\n * activity: \"Like\",\n * target: \"graffiti:remote:pod.graffiti.garden/12345\" // The URL of the graffiti object being liked\n * }\n * ```\n *\n * New social artifacts and activities can be easily created, simply\n * by creating new objects with appropriate properties. Despite the lack of\n * structure, we expect Graffiti object properties to adhere to a \"[folksonomy](https://en.wikipedia.org/wiki/Folksonomy)\",\n * similar to hashtags. Any string can be used as a hashtag on Twitter,\n * but there is social value in using the same hashtags at other people and\n * so a structure naturally emerges. Similarly, Graffiti objects\n * can have arbitrary properties but if people use the same properties as each other,\n * their apps will interoperate, which has social value.\n *\n * For a more complete and detailed overview of Graffiti's design, please\n * refer to [this section of the Graffiti paper](https://dl.acm.org/doi/10.1145/3746059.3747627#sec-3),\n * published in ACM UIST 2025. The paper also overviews {@link GraffitiObjectBase.channels | `channels`},\n * which are Graffiti's means of organizing data contextually, and a concept called \"total reification\",\n * which handles explains how moderation, collaboration, and other interactions are managed.\n *\n * @groupDescription 1 - Single-Object Methods\n * Methods for {@link post | creating}, {@link get | reading},\n * and {@link delete | deleting} {@link GraffitiObjectBase | Graffiti objects}.\n * @groupDescription 2 - Multi-Object Methods\n * Methods that retrieve or accumulate information about multiple {@link GraffitiObjectBase | Graffiti objects} at a time.\n * @groupDescription 3 - Media Methods\n * Methods for {@link postMedia | creating}, {@link getMedia | reading},\n * and {@link deleteMedia | deleting} media data.\n * @groupDescription 4 - Identity Methods\n * Methods and properties for logging in and out.\n */\nexport abstract class Graffiti {\n /**\n * Creates a new {@link GraffitiObjectBase | object}.\n *\n * @returns Returns the object that has been posted, complete with its\n * assigned {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}.\n *\n * @group 1 - Single-Object Methods\n */\n abstract post<Schema extends JSONSchema>(\n /**\n * An object to post, minus its {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}, which will be assigned once posted.\n * This object is statically type-checked against the [JSON schema](https://json-schema.org/) that can be optionally provided\n * as the generic type parameter. It is recommended to use a schema to\n * ensure that the posted object matches subsequent {@link get} or {@link discover}\n * methods.\n */\n partialObject: GraffitiPostObject<Schema>,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Retrieves an object from a given {@link GraffitiObjectBase.url | `url`} matching\n * the provided `schema`.\n *\n * If the retreiving {@link GraffitiObjectBase.actor | `actor`} is not\n * the object's `actor`,\n * the object's {@link GraffitiObjectBase.allowed | `allowed`} and\n * {@link GraffitiObjectBase.channels | `channels`} properties are\n * not revealed, similar to a BCC email.\n *\n * @returns Returns the retrieved object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has been deleted, or the actor is not\n * {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorSchemaMismatch} if the retrieved object does not match the provided schema.\n *\n * @throws {@link GraffitiErrorInvalidSchema} If an invalid schema is provided.\n *\n * @group 1 - Single-Object Methods\n */\n abstract get<Schema extends JSONSchema>(\n /**\n * The location of the object to get.\n */\n url: string | GraffitiObjectUrl,\n /**\n * The JSON schema to validate the retrieved object against.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * the retrieved object's {@link GraffitiObjectBase.allowed | `allowed`}\n * property must be `undefined`.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Deletes an object from a given {@link GraffitiObjectBase.url | `url`}\n * that had previously been {@link post | `post`ed}.\n * The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the\n * `actor` that created the object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,\n * or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * is not the same `actor` as the one who created the object.\n *\n * @group 1 - Single-Object Methods\n */\n abstract delete(\n /**\n * The location of the object to delete.\n */\n url: string | GraffitiObjectUrl,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObjectBase>;\n\n /**\n * Discovers objects created by any actor that are contained\n * in at least one of the given {@link GraffitiObjectBase.channels | `channels`}\n * and match the given [JSON Schema](https://json-schema.org).\n *\n * Objects are returned asynchronously as they are discovered but the stream\n * will end once all leads have been exhausted.\n * The {@link GraffitiObjectStream} ends by returning a\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method and a\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string,\n * each of which can be be used to poll for new objects.\n * The `continue` method preserves the type safety of the stream and the `cursor`\n * string can be serialized to continue the stream after an application is closed\n * and reopened.\n *\n * `discover` will not return objects that the querying {@link GraffitiObjectBase.actor | `actor`}\n * is not {@link GraffitiObjectBase.allowed | `allowed`} to access.\n * If the `actor` is not the creator of a discovered object,\n * the allowed list will be masked to only contain the querying actor if the\n * allowed list is not `undefined` (public). Additionally, if the actor is not the\n * creator of a discovered object, any {@link GraffitiObjectBase.channels | `channels`}\n * not specified by the `discover` method will not be revealed. This masking happens\n * before the object is validated against the supplied `schema`.\n *\n * Since different implementations may fetch data from multiple sources there is\n * no guarentee on the order that objects are returned in.\n *\n * @throws {@link GraffitiErrorInvalidSchema} if an invalid schema is provided.\n * Discovery is lazy and will not throw until the iterator is consumed.\n *\n * @returns Returns a stream of objects that match the given {@link GraffitiObjectBase.channels | `channels`}\n * and [JSON Schema](https://json-schema.org).\n *\n * @group 2 - Multi-Object Methods\n */\n abstract discover<Schema extends JSONSchema>(\n /**\n * The {@link GraffitiObjectBase.channels | `channels`} that objects must be associated with.\n */\n channels: string[],\n /**\n * A [JSON Schema](https://json-schema.org) that objects must satisfy.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * only objects that have no {@link GraffitiObjectBase.allowed | `allowed`}\n * property will be returned.\n */\n session?: GraffitiSession | null,\n ): GraffitiObjectStream<Schema>;\n\n /**\n * Continues a {@link GraffitiObjectStream} from a given\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.\n * The continuation will return new objects that have been {@link post | `post`ed}\n * that match the original stream, and also returns the\n * {@link GraffitiObjectBase.url | `url`}s of objects that\n * have been {@link delete | `delete`d}, as marked by a `tombstone`.\n *\n * The `cursor` allows the client to\n * serialize the state of the stream and continue it later.\n * However this method loses any typing information that was\n * present in the original stream. For better type safety\n * and when serializing is not necessary, use the\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method\n * instead, which is returned along with the `cursor` at the\n * end of the original stream.\n *\n * @throws {@link GraffitiErrorNotFound} upon iteration\n * if the cursor is invalid or expired.\n *\n * @throws {@link GraffitiErrorForbidden} upon iteration\n * if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor`\n * that initiated the original stream.\n *\n * @group 2 - Multi-Object Methods\n */\n abstract continueDiscover(\n cursor: string,\n session?: GraffitiSession | null,\n ): GraffitiObjectStreamContinue<{}>;\n\n /**\n * Uploads media data, such as an image or video.\n *\n * Unlike structured {@link GraffitiObjectBase | objects},\n * media is not indexed for {@link discover | `discover`y} and\n * must be retrieved by its exact URL using {@link getMedia}\n *\n * @returns The URL that the media was posted to.\n *\n * @group 3 - Media Methods\n */\n abstract postMedia(\n /**\n * The media data to upload, and optionally\n * an {@link GraffitiObjectBase.allowed | `allowed`}\n * list of actors that can view it.\n */\n media: GraffitiPostMedia,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<string>;\n\n /**\n * Deletes media previously {@link postMedia | `post`ed} to a given URL.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor` that {@link postMedia | `post`ed}\n * the media.\n *\n * @group 3 - Media Methods\n */\n abstract deleteMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n url: string,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * Retrieves media from the given media URL, adhering to the given requirements.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorTooLarge} if the media exceeds the given `maxBytes`.\n *\n * @throws {@link GraffitiErrorNotAcceptable} if the media does not match the given\n * `accept` specification.\n *\n * @returns The URL of the retrieved media, as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n * and the {@link GraffitiObjectBase.actor | `actor`} that posted it.\n *\n * @group 3 - Media Methods\n */\n abstract getMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n mediaUrl: string,\n /**\n * A specification for what types and sizes of media are acceptable.\n */\n accept: GraffitiMediaAccept,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiMedia>;\n\n /**\n * Begins the login process. Depending on the implementation, this may\n * involve redirecting to a login page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * The {@link GraffitiSession | session} object is returned\n * asynchronously via {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLoginEvent} with event type `login`.\n *\n * @group 4 - Identity Methods\n */\n abstract login(\n /**\n * A suggested actor to login as. For example, if a user tries to\n * edit a post but are not logged in, the interface can infer that\n * they might want to log in as the actor who created the post\n * they are attempting to edit.\n *\n * Even if provided, the implementation should allow the user\n * to log in as a different actor if they choose.\n */\n actor?: string | null,\n ): Promise<void>;\n\n /**\n * Begins the logout process for a particular {@link GraffitiSession | session}. Depending on the implementation, this may\n * involve redirecting the user to a logout page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * A confirmation will be returned asynchronously via\n * {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLogoutEvent} as event type `logout`.\n *\n * @group 4 - Identity Methods\n */\n abstract logout(\n /**\n * The {@link GraffitiSession | session} object to logout.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * An event target that can be used to listen for the following\n * events and their corresponding event types:\n * - `login` - {@link GraffitiLoginEvent}\n * - `logout` - {@link GraffitiLogoutEvent}\n * - `initialized` - {@link GraffitiSessionInitializedEvent}\n *\n * @group 4 - Identity Methods\n */\n abstract readonly sessionEvents: EventTarget;\n\n /**\n * Retrieves the human-readable handle associated\n * with the given actor. The handle may change over time\n * and so it should be used for display purposes only.\n *\n * The inverse of {@link handleToActor}.\n *\n * @throws {@link GraffitiErrorNotFound} if a handle cannot be\n * found for the given actor.\n *\n * @returns A human-readable handle for the given actor.\n *\n * @group 4 - Identity Methods\n */\n abstract actorToHandle(actor: string): Promise<string>;\n\n /**\n * Retrieves the actor ID associated with the given handle.\n *\n * The inverse of {@link actorToHandle}.\n *\n * @throws {@link GraffitiErrorNotFound} if there is no actor\n * with the given handle.\n *\n * @returns The actor ID for the given handle.\n *\n * @group 4 - Identity Methods\n */\n abstract handleToActor(handle: string): Promise<string>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiSession,\n GraffitiPostObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiMedia,\n GraffitiPostMedia,\n GraffitiMediaAccept,\n} from \"./2-types.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\n/**\n * This API describes a small but powerful set of methods that\n * can be used to create many different kinds of social applications,\n * from applications like Twitter, to Messenger, to Wikipedia, to many more new designs.\n * See the [Graffiti project website](https://graffiti.garden)\n * for links to example applications. Additionally, apps built on top\n * of the API interoperate with each other so you can seamlessly switch\n * between apps without losing your friends or data.\n *\n * These API methods should satisfy all of an application's needs for\n * the communication, storage, and access management of social data.\n * The rest of the application can be built with standard client-side\n * user interface tools to present and interact with that data\u2014no server code necessary!\n *\n * The Typescript code for this API is [open source on Github](https://github.com/graffiti-garden/api).\n *\n * There are several different implementations of this Graffiti API available,\n * including a [federated implementation](https://github.com/graffiti-garden/implementation-remote),\n * that lets people choose where their data is stored (you do not need to host your own server)\n * and a [local implementation](https://github.com/graffiti-garden/implementation-local)\n * that can be used for testing and development. Different implementations can\n * be swapped-in in the future without changing the API or any of the apps built on\n * top of it. In fact, we're working on an end-to-end encrypted version now!\n * [Follow Theia on BlueSky for updates](https://bsky.app/profile/theias.place).\n *\n * On the other side of the stack, there is [Vue plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * that wraps around this API to provide reactivity. Other plugin frameworks\n * and high-level libraries will be available in the future.\n *\n * ## API Overview\n *\n * The Graffiti API provides applications with methods for {@link login} and {@link logout},\n * methods to interact with data objects using standard database operations ({@link post}, {@link get}, and {@link delete}),\n * and a method to {@link discover} data objects created by others.\n * These data objects have a couple structured properties:\n * - {@link GraffitiObjectBase.url | `url`} (string): A globally unique identifier and locator for the object.\n * - {@link GraffitiObjectBase.actor | `actor`} (string): An unforgeable identifier for the creator of the object.\n * - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the actors who are allowed to access the object (undefined for public objects).\n * - {@link GraffitiObjectBase.channels | `channels`} (string[]): An array of the *contexts* in which the object should appear.\n *\n * All other data is stored in the object's unstructured {@link GraffitiObjectBase.value | `value`} property.\n * This data can be used to represent social artifacts (e.g. posts, profiles) and activities (e.g. likes, follows).\n * For example, a post might have the value:\n\n * ```js\n * {\n * title: \"My First Post\",\n * content: \"Hello, world!\",\n * published: 1630483200000\n * }\n * ```\n *\n * a profile might have the value:\n *\n * ```js\n * {\n * name: \"Theia Henderson\",\n * pronouns: \"she/her\",\n * describes: \"did:web:theias.place\" // Theia's actor ID\n * }\n * ```\n *\n * and a \"Like\" might have the value:\n *\n * ```js\n * {\n * activity: \"Like\",\n * target: \"graffiti:remote:pod.graffiti.garden/12345\" // The URL of the graffiti object being liked\n * }\n * ```\n *\n * New social artifacts and activities can be easily created, simply\n * by creating new objects with appropriate properties. Despite the lack of\n * structure, we expect Graffiti object properties to adhere to a \"[folksonomy](https://en.wikipedia.org/wiki/Folksonomy)\",\n * similar to hashtags. Any string can be used as a hashtag on Twitter,\n * but there is social value in using the same hashtags at other people and\n * so a structure naturally emerges. Similarly, Graffiti objects\n * can have arbitrary properties but if people use the same properties as each other,\n * their apps will interoperate, which has social value.\n *\n * For a more complete and detailed overview of Graffiti's design, please\n * refer to [this section of the Graffiti paper](https://dl.acm.org/doi/10.1145/3746059.3747627#sec-3),\n * published in ACM UIST 2025. The paper also overviews {@link GraffitiObjectBase.channels | `channels`},\n * which are Graffiti's means of organizing data contextually, and a concept called \"total reification\",\n * which handles explains how moderation, collaboration, and other interactions are managed.\n *\n * @groupDescription 1 - Single-Object Methods\n * Methods for {@link post | creating}, {@link get | reading},\n * and {@link delete | deleting} {@link GraffitiObjectBase | Graffiti objects}.\n * @groupDescription 2 - Multi-Object Methods\n * Methods that retrieve or accumulate information about multiple {@link GraffitiObjectBase | Graffiti objects} at a time.\n * @groupDescription 3 - Media Methods\n * Methods for {@link postMedia | creating}, {@link getMedia | reading},\n * and {@link deleteMedia | deleting} media data.\n * @groupDescription 4 - Identity Methods\n * Methods and properties for logging in and out.\n */\nexport abstract class Graffiti {\n /**\n * Creates a new {@link GraffitiObjectBase | object}.\n *\n * @returns Returns the object that has been posted, complete with its\n * assigned {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}.\n *\n * @group 1 - Single-Object Methods\n */\n abstract post<Schema extends JSONSchema>(\n /**\n * An object to post, minus its {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}, which will be assigned once posted.\n * This object is statically type-checked against the [JSON schema](https://json-schema.org/) that can be optionally provided\n * as the generic type parameter. It is recommended to use a schema to\n * ensure that the posted object matches subsequent {@link get} or {@link discover}\n * methods.\n */\n partialObject: GraffitiPostObject<Schema>,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Retrieves an object from a given {@link GraffitiObjectBase.url | `url`} matching\n * the provided `schema`.\n *\n * If the retreiving {@link GraffitiObjectBase.actor | `actor`} is not\n * the object's `actor`,\n * the object's {@link GraffitiObjectBase.allowed | `allowed`} and\n * {@link GraffitiObjectBase.channels | `channels`} properties are\n * not revealed, similar to a BCC email.\n *\n * @returns Returns the retrieved object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has been deleted, or the actor is not\n * {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorSchemaMismatch} if the retrieved object does not match the provided schema.\n *\n * @throws {@link GraffitiErrorInvalidSchema} If an invalid schema is provided.\n *\n * @group 1 - Single-Object Methods\n */\n abstract get<Schema extends JSONSchema>(\n /**\n * The location of the object to get.\n */\n url: string | GraffitiObjectUrl,\n /**\n * The JSON schema to validate the retrieved object against.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * the retrieved object's {@link GraffitiObjectBase.allowed | `allowed`}\n * property must be `undefined`.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Deletes an object from a given {@link GraffitiObjectBase.url | `url`}\n * that had previously been {@link post | `post`ed}.\n * The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the\n * `actor` that created the object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,\n * or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * is not the same `actor` as the one who created the object.\n *\n * @group 1 - Single-Object Methods\n */\n abstract delete(\n /**\n * The location of the object to delete.\n */\n url: string | GraffitiObjectUrl,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObjectBase>;\n\n /**\n * Discovers objects created by any actor that are contained\n * in at least one of the given {@link GraffitiObjectBase.channels | `channels`}\n * and match the given [JSON Schema](https://json-schema.org).\n *\n * Objects are returned asynchronously as they are discovered but the stream\n * will end once all leads have been exhausted.\n * The {@link GraffitiObjectStream} ends by returning a\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method and a\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string,\n * each of which can be be used to poll for new objects.\n * The `continue` method preserves the type safety of the stream and the `cursor`\n * string can be serialized to continue the stream after an application is closed\n * and reopened.\n *\n * `discover` will not return objects that the querying {@link GraffitiObjectBase.actor | `actor`}\n * is not {@link GraffitiObjectBase.allowed | `allowed`} to access.\n * If the `actor` is not the creator of a discovered object,\n * the allowed list will be masked to only contain the querying actor if the\n * allowed list is not `undefined` (public). Additionally, if the actor is not the\n * creator of a discovered object, any {@link GraffitiObjectBase.channels | `channels`}\n * not specified by the `discover` method will not be revealed. This masking happens\n * before the object is validated against the supplied `schema`.\n *\n * Since different implementations may fetch data from multiple sources there is\n * no guarentee on the order that objects are returned in.\n *\n * @throws {@link GraffitiErrorInvalidSchema} if an invalid schema is provided.\n * Discovery is lazy and will not throw until the iterator is consumed.\n *\n * @returns Returns a stream of objects that match the given {@link GraffitiObjectBase.channels | `channels`}\n * and [JSON Schema](https://json-schema.org).\n *\n * @group 2 - Multi-Object Methods\n */\n abstract discover<Schema extends JSONSchema>(\n /**\n * The {@link GraffitiObjectBase.channels | `channels`} that objects must be associated with.\n */\n channels: string[],\n /**\n * A [JSON Schema](https://json-schema.org) that objects must satisfy.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * only objects that have no {@link GraffitiObjectBase.allowed | `allowed`}\n * property will be returned.\n */\n session?: GraffitiSession | null,\n ): GraffitiObjectStream<Schema>;\n\n /**\n * Continues a {@link GraffitiObjectStream} from a given\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.\n * The continuation will return new objects that have been {@link post | `post`ed}\n * that match the original stream, and also returns the\n * {@link GraffitiObjectBase.url | `url`}s of objects that\n * have been {@link delete | `delete`d}, as marked by a `tombstone`.\n *\n * The `cursor` allows the client to\n * serialize the state of the stream and continue it later.\n * However this method loses any typing information that was\n * present in the original stream. For better type safety\n * and when serializing is not necessary, use the\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method\n * instead, which is returned along with the `cursor` at the\n * end of the original stream.\n *\n * @throws {@link GraffitiErrorNotFound} upon iteration\n * if the cursor is invalid or expired.\n *\n * @throws {@link GraffitiErrorForbidden} upon iteration\n * if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor`\n * that initiated the original stream.\n *\n * @group 2 - Multi-Object Methods\n */\n abstract continueDiscover(\n cursor: string,\n session?: GraffitiSession | null,\n ): GraffitiObjectStreamContinue<{}>;\n\n /**\n * Uploads media data, such as an image or video.\n *\n * Unlike structured {@link GraffitiObjectBase | objects},\n * media is not indexed for {@link discover | `discover`y} and\n * must be retrieved by its exact URL using {@link getMedia}\n *\n * @returns The URL that the media was posted to.\n *\n * @group 3 - Media Methods\n */\n abstract postMedia(\n /**\n * The media data to upload, and optionally\n * an {@link GraffitiObjectBase.allowed | `allowed`}\n * list of actors that can view it.\n */\n media: GraffitiPostMedia,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<string>;\n\n /**\n * Deletes media previously {@link postMedia | `post`ed} to a given URL.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor` that {@link postMedia | `post`ed}\n * the media.\n *\n * @group 3 - Media Methods\n */\n abstract deleteMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n url: string,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * Retrieves media from the given media URL, adhering to the given requirements.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorTooLarge} if the media exceeds the given `maxBytes`.\n *\n * @throws {@link GraffitiErrorNotAcceptable} if the media does not match the given\n * `accept` specification.\n *\n * @returns The URL of the retrieved media, as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n * and the {@link GraffitiObjectBase.actor | `actor`} that posted it.\n *\n * @group 3 - Media Methods\n */\n abstract getMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n mediaUrl: string,\n /**\n * A specification for what types and sizes of media are acceptable.\n */\n accept: GraffitiMediaAccept,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiMedia>;\n\n /**\n * Begins the login process. Depending on the implementation, this may\n * involve redirecting to a login page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * The {@link GraffitiSession | session} object is returned\n * asynchronously via {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLoginEvent} with event type `login`.\n *\n * @group 4 - Identity Methods\n */\n abstract login(\n /**\n * A suggested actor to login as. For example, if a user tries to\n * edit a post but are not logged in, the interface can infer that\n * they might want to log in as the actor who created the post\n * they are attempting to edit.\n *\n * Even if provided, the implementation should allow the user\n * to log in as a different actor if they choose.\n */\n actor?: string | null,\n ): Promise<void>;\n\n /**\n * Begins the logout process for a particular {@link GraffitiSession | session}. Depending on the implementation, this may\n * involve redirecting the user to a logout page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * A confirmation will be returned asynchronously via\n * {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLogoutEvent} as event type `logout`.\n *\n * @group 4 - Identity Methods\n */\n abstract logout(\n /**\n * The {@link GraffitiSession | session} object to logout.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * An event target that can be used to listen for the following\n * events and their corresponding event types:\n * - `login` - {@link GraffitiLoginEvent}\n * - `logout` - {@link GraffitiLogoutEvent}\n * - `initialized` - {@link GraffitiSessionInitializedEvent}\n *\n * @group 4 - Identity Methods\n */\n abstract readonly sessionEvents: EventTarget;\n\n /**\n * Retrieves the human-readable handle associated\n * with the given actor. The handle may change over time\n * and so it should be used for display purposes only.\n *\n * The inverse of {@link handleToActor}.\n *\n * @throws {@link GraffitiErrorNotFound} if a handle cannot be\n * found for the given actor.\n *\n * @returns A human-readable handle for the given actor.\n *\n * @group 4 - Identity Methods\n */\n abstract actorToHandle(actor: string): Promise<string>;\n\n /**\n * Retrieves the actor ID associated with the given handle.\n *\n * The inverse of {@link actorToHandle}.\n *\n * @throws {@link GraffitiErrorNotFound} if there is no actor\n * with the given handle.\n *\n * @returns The actor ID for the given handle.\n *\n * @group 4 - Identity Methods\n */\n abstract handleToActor(handle: string): Promise<string>;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+GO,MAAe,SAAS;AAoV/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/3-errors.js
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var errors_exports = {};
|
|
20
20
|
__export(errors_exports, {
|
|
21
|
+
GraffitiErrorCursorExpired: () => GraffitiErrorCursorExpired,
|
|
21
22
|
GraffitiErrorForbidden: () => GraffitiErrorForbidden,
|
|
22
23
|
GraffitiErrorInvalidSchema: () => GraffitiErrorInvalidSchema,
|
|
23
24
|
GraffitiErrorNotAcceptable: () => GraffitiErrorNotAcceptable,
|
|
@@ -68,4 +69,11 @@ class GraffitiErrorNotAcceptable extends Error {
|
|
|
68
69
|
Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
72
|
+
class GraffitiErrorCursorExpired extends Error {
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message);
|
|
75
|
+
this.name = "GraffitiErrorCursorExpired";
|
|
76
|
+
Object.setPrototypeOf(this, GraffitiErrorCursorExpired.prototype);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
71
79
|
//# sourceMappingURL=3-errors.js.map
|
package/dist/cjs/3-errors.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/3-errors.ts"],
|
|
4
|
-
"sourcesContent": ["export class GraffitiErrorForbidden extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorForbidden\";\n Object.setPrototypeOf(this, GraffitiErrorForbidden.prototype);\n }\n}\n\nexport class GraffitiErrorNotFound extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotFound\";\n Object.setPrototypeOf(this, GraffitiErrorNotFound.prototype);\n }\n}\n\nexport class GraffitiErrorInvalidSchema extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorInvalidSchema\";\n Object.setPrototypeOf(this, GraffitiErrorInvalidSchema.prototype);\n }\n}\n\nexport class GraffitiErrorSchemaMismatch extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorSchemaMismatch\";\n Object.setPrototypeOf(this, GraffitiErrorSchemaMismatch.prototype);\n }\n}\n\nexport class GraffitiErrorTooLarge extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorTooLarge\";\n Object.setPrototypeOf(this, GraffitiErrorTooLarge.prototype);\n }\n}\n\nexport class GraffitiErrorNotAcceptable extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotAcceptable\";\n Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,+BAA+B,MAAM;AAAA,EAChD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,SAAS;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,4BAA4B,SAAS;AAAA,EACnE;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;",
|
|
4
|
+
"sourcesContent": ["export class GraffitiErrorForbidden extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorForbidden\";\n Object.setPrototypeOf(this, GraffitiErrorForbidden.prototype);\n }\n}\n\nexport class GraffitiErrorNotFound extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotFound\";\n Object.setPrototypeOf(this, GraffitiErrorNotFound.prototype);\n }\n}\n\nexport class GraffitiErrorInvalidSchema extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorInvalidSchema\";\n Object.setPrototypeOf(this, GraffitiErrorInvalidSchema.prototype);\n }\n}\n\nexport class GraffitiErrorSchemaMismatch extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorSchemaMismatch\";\n Object.setPrototypeOf(this, GraffitiErrorSchemaMismatch.prototype);\n }\n}\n\nexport class GraffitiErrorTooLarge extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorTooLarge\";\n Object.setPrototypeOf(this, GraffitiErrorTooLarge.prototype);\n }\n}\n\nexport class GraffitiErrorNotAcceptable extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotAcceptable\";\n Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);\n }\n}\n\nexport class GraffitiErrorCursorExpired extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorCursorExpired\";\n Object.setPrototypeOf(this, GraffitiErrorCursorExpired.prototype);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,+BAA+B,MAAM;AAAA,EAChD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,SAAS;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,4BAA4B,SAAS;AAAA,EACnE;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/4-utilities.js
CHANGED
|
@@ -35,7 +35,7 @@ __export(utilities_exports, {
|
|
|
35
35
|
unpackObjectUrl: () => unpackObjectUrl
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(utilities_exports);
|
|
38
|
-
var import_errors = require("./3-errors");
|
|
38
|
+
var import_errors = require("./3-errors.js");
|
|
39
39
|
function unpackObjectUrl(url) {
|
|
40
40
|
return typeof url === "string" ? url : url.url;
|
|
41
41
|
}
|
|
@@ -70,7 +70,7 @@ function isMediaAcceptable(mediaType, acceptableMediaTypes) {
|
|
|
70
70
|
let ajv = void 0;
|
|
71
71
|
async function compileGraffitiObjectSchema(schema) {
|
|
72
72
|
if (!ajv) {
|
|
73
|
-
const {
|
|
73
|
+
const { Ajv } = await import("ajv");
|
|
74
74
|
ajv = new Ajv({ strict: false });
|
|
75
75
|
}
|
|
76
76
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/4-utilities.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiObjectUrl,\n GraffitiSession,\n} from \"./2-types\";\nimport { GraffitiErrorInvalidSchema } from \"./3-errors\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\nimport type Ajv from \"ajv\";\n\nexport function unpackObjectUrl(url: string | GraffitiObjectUrl) {\n return typeof url === \"string\" ? url : url.url;\n}\n\nexport function isActorAllowedGraffitiObject(\n object: GraffitiObjectBase,\n session?: GraffitiSession | null,\n) {\n return (\n // If there is no allowed list, the actor is allowed.\n !Array.isArray(object.allowed) ||\n // Otherwise...\n (typeof session?.actor === \"string\" &&\n // The actor must be the creator of the object\n (object.actor === session.actor ||\n // Or be on the allowed list\n object.allowed.includes(session.actor)))\n );\n}\n\nexport function maskGraffitiObject(\n object: GraffitiObjectBase,\n channels: string[],\n actor?: string | null,\n): GraffitiObjectBase {\n // If the actor is the creator, return the object as is\n if (actor === object.actor) return object;\n\n // If there is an allowed list, mask it to only include the actor\n // (This assumes the actor is already allowed to access the object)\n const allowedMasked = object.allowed && actor ? [actor] : undefined;\n // Mask the channels to only include the channels that are being queried\n const channelsMasked = object.channels.filter((c) => channels.includes(c));\n\n return {\n ...object,\n allowed: allowedMasked,\n channels: channelsMasked,\n };\n}\n\nexport function isMediaAcceptable(\n mediaType: string,\n acceptableMediaTypes: string[],\n): boolean {\n const [type, subtype] = mediaType.toLowerCase().split(\";\")[0].split(\"/\");\n\n if (!type || !subtype) return false;\n\n return acceptableMediaTypes.some((acceptable) => {\n const [accType, accSubtype] = acceptable\n .toLowerCase()\n .split(\";\")[0]\n .split(\"/\");\n\n if (!accType || !accSubtype) return false;\n\n return (\n (accType === type || accType === \"*\") &&\n (accSubtype === subtype || accSubtype === \"*\")\n );\n });\n}\n\nlet ajv: Ajv | undefined = undefined;\nexport async function compileGraffitiObjectSchema<Schema extends JSONSchema>(\n schema: Schema,\n) {\n if (!ajv) {\n const {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAA2C;AAIpC,SAAS,gBAAgB,KAAiC;AAC/D,SAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AAC7C;AAEO,SAAS,6BACd,QACA,SACA;AACA;AAAA;AAAA,IAEE,CAAC,MAAM,QAAQ,OAAO,OAAO;AAAA,IAE5B,OAAO,SAAS,UAAU;AAAA,KAExB,OAAO,UAAU,QAAQ;AAAA,IAExB,OAAO,QAAQ,SAAS,QAAQ,KAAK;AAAA;AAE7C;AAEO,SAAS,mBACd,QACA,UACA,OACoB;AAEpB,MAAI,UAAU,OAAO,MAAO,QAAO;AAInC,QAAM,gBAAgB,OAAO,WAAW,QAAQ,CAAC,KAAK,IAAI;AAE1D,QAAM,iBAAiB,OAAO,SAAS,OAAO,CAAC,MAAM,SAAS,SAAS,CAAC,CAAC;AAEzE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;AAEO,SAAS,kBACd,WACA,sBACS;AACT,QAAM,CAAC,MAAM,OAAO,IAAI,UAAU,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG;AAEvE,MAAI,CAAC,QAAQ,CAAC,QAAS,QAAO;AAE9B,SAAO,qBAAqB,KAAK,CAAC,eAAe;AAC/C,UAAM,CAAC,SAAS,UAAU,IAAI,WAC3B,YAAY,EACZ,MAAM,GAAG,EAAE,CAAC,EACZ,MAAM,GAAG;AAEZ,QAAI,CAAC,WAAW,CAAC,WAAY,QAAO;AAEpC,YACG,YAAY,QAAQ,YAAY,SAChC,eAAe,WAAW,eAAe;AAAA,EAE9C,CAAC;AACH;AAEA,IAAI,MAAuB;AAC3B,eAAsB,4BACpB,QACA;AACA,MAAI,CAAC,KAAK;AACR,UAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["import type {\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiObjectUrl,\n GraffitiSession,\n} from \"./2-types.js\";\nimport { GraffitiErrorInvalidSchema } from \"./3-errors.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\nimport type Ajv from \"ajv\";\n\nexport function unpackObjectUrl(url: string | GraffitiObjectUrl) {\n return typeof url === \"string\" ? url : url.url;\n}\n\nexport function isActorAllowedGraffitiObject(\n object: GraffitiObjectBase,\n session?: GraffitiSession | null,\n) {\n return (\n // If there is no allowed list, the actor is allowed.\n !Array.isArray(object.allowed) ||\n // Otherwise...\n (typeof session?.actor === \"string\" &&\n // The actor must be the creator of the object\n (object.actor === session.actor ||\n // Or be on the allowed list\n object.allowed.includes(session.actor)))\n );\n}\n\nexport function maskGraffitiObject(\n object: GraffitiObjectBase,\n channels: string[],\n actor?: string | null,\n): GraffitiObjectBase {\n // If the actor is the creator, return the object as is\n if (actor === object.actor) return object;\n\n // If there is an allowed list, mask it to only include the actor\n // (This assumes the actor is already allowed to access the object)\n const allowedMasked = object.allowed && actor ? [actor] : undefined;\n // Mask the channels to only include the channels that are being queried\n const channelsMasked = object.channels.filter((c) => channels.includes(c));\n\n return {\n ...object,\n allowed: allowedMasked,\n channels: channelsMasked,\n };\n}\n\nexport function isMediaAcceptable(\n mediaType: string,\n acceptableMediaTypes: string[],\n): boolean {\n const [type, subtype] = mediaType.toLowerCase().split(\";\")[0].split(\"/\");\n\n if (!type || !subtype) return false;\n\n return acceptableMediaTypes.some((acceptable) => {\n const [accType, accSubtype] = acceptable\n .toLowerCase()\n .split(\";\")[0]\n .split(\"/\");\n\n if (!accType || !accSubtype) return false;\n\n return (\n (accType === type || accType === \"*\") &&\n (accSubtype === subtype || accSubtype === \"*\")\n );\n });\n}\n\nlet ajv: Ajv | undefined = undefined;\nexport async function compileGraffitiObjectSchema<Schema extends JSONSchema>(\n schema: Schema,\n) {\n if (!ajv) {\n const { Ajv } = await import(\"ajv\");\n ajv = new Ajv({ strict: false });\n }\n\n try {\n // Force the validation guard because\n // it is too big for the type checker.\n // Fortunately json-schema-to-ts is\n // well tested against ajv.\n return ajv.compile(schema) as (\n data: GraffitiObjectBase,\n ) => data is GraffitiObject<Schema>;\n } catch (error) {\n throw new GraffitiErrorInvalidSchema(\n error instanceof Error ? error.message : String(error),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAA2C;AAIpC,SAAS,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d,UAAM,IAAI;AAAA,MACR,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IACvD;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/5-runtime-types.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n looseObject,\n array,\n string,\n url,\n union,\n instanceof as instanceof_,\n int,\n tuple,\n nullable,\n optional,\n nonnegative,\n extend,\n} from \"zod/mini\";\nimport type { Graffiti } from \"./1-api\";\nimport type {\n GraffitiObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiPostObject,\n GraffitiSession,\n} from \"./2-types\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\nexport const GraffitiPostObjectSchema = looseObject({\n value: looseObject({}),\n channels: array(string()),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiObjectSchema = extend(GraffitiPostObjectSchema, {\n url: url(),\n actor: url(),\n});\n\nexport const GraffitiObjectUrlSchema = union([\n looseObject({\n url: url(),\n }),\n url(),\n]);\n\nexport const GraffitiSessionSchema = looseObject({\n actor: url(),\n});\nexport const GraffitiOptionalSessionSchema = optional(\n nullable(GraffitiSessionSchema),\n);\n\nexport const GraffitiPostMediaSchema = looseObject({\n data: instanceof_(Blob),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiMediaSchema = extend(GraffitiPostMediaSchema, {\n actor: url(),\n});\nexport const GraffitiMediaAcceptSchema = looseObject({\n types: optional(array(string())),\n maxBytes: optional(int().check(nonnegative())),\n});\n\nasync function* wrapGraffitiStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStream<Schema>,\n): GraffitiObjectStream<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\nasync function* wrapGraffitiContinueStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStreamContinue<Schema>,\n): GraffitiObjectStreamContinue<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\n\n// @ts-ignore - infinite nesting issue\nexport class GraffitiRuntimeTypes implements Graffiti {\n sessionEvents: Graffiti[\"sessionEvents\"];\n constructor(protected readonly graffiti: Graffiti) {\n this.sessionEvents = this.graffiti.sessionEvents;\n }\n\n login: Graffiti[\"login\"] = (...args) => {\n const typedArgs = tuple([optional(url())]).parse(args);\n return this.graffiti.login(...typedArgs);\n };\n\n logout: Graffiti[\"logout\"] = (...args) => {\n const typedArgs = tuple([GraffitiSessionSchema]).parse(args);\n return this.graffiti.logout(...typedArgs);\n };\n\n handleToActor: Graffiti[\"handleToActor\"] = (...args) => {\n const typedArgs = tuple([string()]).parse(args);\n return this.graffiti.handleToActor(...typedArgs);\n };\n\n actorToHandle: Graffiti[\"actorToHandle\"] = (...args) => {\n const typedArgs = tuple([url()]).parse(args);\n return this.graffiti.actorToHandle(...typedArgs);\n };\n\n async post<Schema extends JSONSchema>(\n partialObject: GraffitiPostObject<Schema>,\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>> {\n const typedArgs = tuple([\n GraffitiPostObjectSchema,\n GraffitiSessionSchema,\n ]).parse([partialObject, session]);\n\n return (await this.graffiti.post<{}>(\n ...typedArgs,\n )) as GraffitiObject<Schema>;\n }\n\n get: Graffiti[\"get\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.get(...typedArgs) as Promise<\n GraffitiObject<(typeof args)[1]>\n >;\n };\n\n delete: Graffiti[\"delete\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.delete(...typedArgs);\n };\n\n postMedia: Graffiti[\"postMedia\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiPostMediaSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.postMedia(...typedArgs);\n };\n\n getMedia: Graffiti[\"getMedia\"] = (...args) => {\n const typedArgs = tuple([\n url(),\n GraffitiMediaAcceptSchema,\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.getMedia(...typedArgs);\n };\n\n deleteMedia: Graffiti[\"deleteMedia\"] = (...args) => {\n const typedArgs = tuple([url(), GraffitiSessionSchema]).parse(args);\n\n return this.graffiti.deleteMedia(...typedArgs);\n };\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const typedArgs = tuple([\n array(string()),\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n const stream = this.graffiti.discover(...typedArgs) as GraffitiObjectStream<\n (typeof args)[1]\n >;\n return wrapGraffitiStream(stream);\n };\n\n continueDiscover: Graffiti[\"continueDiscover\"] = (...args) => {\n const typedArgs = tuple([string(), GraffitiOptionalSessionSchema]).parse(\n args,\n );\n\n const stream = this.graffiti.continueDiscover(...typedArgs);\n return wrapGraffitiContinueStream(stream);\n };\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {\n looseObject,\n array,\n string,\n url,\n union,\n instanceof as instanceof_,\n int,\n tuple,\n nullable,\n optional,\n nonnegative,\n extend,\n} from \"zod/mini\";\nimport type { Graffiti } from \"./1-api.js\";\nimport type {\n GraffitiObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiPostObject,\n GraffitiSession,\n} from \"./2-types.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\nexport const GraffitiPostObjectSchema = looseObject({\n value: looseObject({}),\n channels: array(string()),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiObjectSchema = extend(GraffitiPostObjectSchema, {\n url: url(),\n actor: url(),\n});\n\nexport const GraffitiObjectUrlSchema = union([\n looseObject({\n url: url(),\n }),\n url(),\n]);\n\nexport const GraffitiSessionSchema = looseObject({\n actor: url(),\n});\nexport const GraffitiOptionalSessionSchema = optional(\n nullable(GraffitiSessionSchema),\n);\n\nexport const GraffitiPostMediaSchema = looseObject({\n data: instanceof_(Blob),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiMediaSchema = extend(GraffitiPostMediaSchema, {\n actor: url(),\n});\nexport const GraffitiMediaAcceptSchema = looseObject({\n types: optional(array(string())),\n maxBytes: optional(int().check(nonnegative())),\n});\n\nasync function* wrapGraffitiStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStream<Schema>,\n): GraffitiObjectStream<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\nasync function* wrapGraffitiContinueStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStreamContinue<Schema>,\n): GraffitiObjectStreamContinue<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\n\n// @ts-ignore - infinite nesting issue\nexport class GraffitiRuntimeTypes implements Graffiti {\n sessionEvents: Graffiti[\"sessionEvents\"];\n constructor(protected readonly graffiti: Graffiti) {\n this.sessionEvents = this.graffiti.sessionEvents;\n }\n\n login: Graffiti[\"login\"] = (...args) => {\n const typedArgs = tuple([optional(url())]).parse(args);\n return this.graffiti.login(...typedArgs);\n };\n\n logout: Graffiti[\"logout\"] = (...args) => {\n const typedArgs = tuple([GraffitiSessionSchema]).parse(args);\n return this.graffiti.logout(...typedArgs);\n };\n\n handleToActor: Graffiti[\"handleToActor\"] = (...args) => {\n const typedArgs = tuple([string()]).parse(args);\n return this.graffiti.handleToActor(...typedArgs);\n };\n\n actorToHandle: Graffiti[\"actorToHandle\"] = (...args) => {\n const typedArgs = tuple([url()]).parse(args);\n return this.graffiti.actorToHandle(...typedArgs);\n };\n\n async post<Schema extends JSONSchema>(\n partialObject: GraffitiPostObject<Schema>,\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>> {\n const typedArgs = tuple([\n GraffitiPostObjectSchema,\n GraffitiSessionSchema,\n ]).parse([partialObject, session]);\n\n return (await this.graffiti.post<{}>(\n ...typedArgs,\n )) as GraffitiObject<Schema>;\n }\n\n get: Graffiti[\"get\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.get(...typedArgs) as Promise<\n GraffitiObject<(typeof args)[1]>\n >;\n };\n\n delete: Graffiti[\"delete\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.delete(...typedArgs);\n };\n\n postMedia: Graffiti[\"postMedia\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiPostMediaSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.postMedia(...typedArgs);\n };\n\n getMedia: Graffiti[\"getMedia\"] = (...args) => {\n const typedArgs = tuple([\n url(),\n GraffitiMediaAcceptSchema,\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.getMedia(...typedArgs);\n };\n\n deleteMedia: Graffiti[\"deleteMedia\"] = (...args) => {\n const typedArgs = tuple([url(), GraffitiSessionSchema]).parse(args);\n\n return this.graffiti.deleteMedia(...typedArgs);\n };\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const typedArgs = tuple([\n array(string()),\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n const stream = this.graffiti.discover(...typedArgs) as GraffitiObjectStream<\n (typeof args)[1]\n >;\n return wrapGraffitiStream(stream);\n };\n\n continueDiscover: Graffiti[\"continueDiscover\"] = (...args) => {\n const typedArgs = tuple([string(), GraffitiOptionalSessionSchema]).parse(\n args,\n );\n\n const stream = this.graffiti.continueDiscover(...typedArgs);\n return wrapGraffitiContinueStream(stream);\n };\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAaO;AAWA,MAAM,+BAA2B,yBAAY;AAAA,EAClD,WAAO,yBAAY,CAAC,CAAC;AAAA,EACrB,cAAU,uBAAM,oBAAO,CAAC;AAAA,EACxB,aAAS,0BAAS,0BAAS,uBAAM,iBAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AACM,MAAM,2BAAuB,oBAAO,0BAA0B;AAAA,EACnE,SAAK,iBAAI;AAAA,EACT,WAAO,iBAAI;AACb,CAAC;AAEM,MAAM,8BAA0B,mBAAM;AAAA,MAC3C,yBAAY;AAAA,IACV,SAAK,iBAAI;AAAA,EACX,CAAC;AAAA,MACD,iBAAI;AACN,CAAC;AAEM,MAAM,4BAAwB,yBAAY;AAAA,EAC/C,WAAO,iBAAI;AACb,CAAC;AACM,MAAM,oCAAgC;AAAA,MAC3C,sBAAS,qBAAqB;AAChC;AAEO,MAAM,8BAA0B,yBAAY;AAAA,EACjD,UAAM,YAAAA,YAAY,IAAI;AAAA,EACtB,aAAS,0BAAS,0BAAS,uBAAM,iBAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AACM,MAAM,0BAAsB,oBAAO,yBAAyB;AAAA,EACjE,WAAO,iBAAI;AACb,CAAC;AACM,MAAM,gCAA4B,yBAAY;AAAA,EACnD,WAA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AI;AAAA,MACJ;AAAA,MACA;AAAA,IACF,CAAC,EAAE,MAAM,IAAI;AAEb,WAAO,KAAK,SAAS,SAAS,GAAG,SAAS;AAAA,EAC5C;AAAA,EAEA,cAAuC,IAAI,SAAS;AAClD,UAAM,gBAAY,mBAAM,KAAC,iBAAI,GAAG,qBAAqB,CAAC,EAAE,MAAM,IAAI;AAElE,WAAO,KAAK,SAAS,YAAY,GAAG,SAAS;AAAA,EAC/C;AAAA,EAEA,WAAiC,IAAI,SAAS;AAC5C,UAAM,gBAAY,mBAAM;AAAA,UACtB,uBAAM,oBAAO,CAAC;AAAA,UACd,yBAAY,CAAC,CAAC;AAAA,MACd;AAAA,IACF,CAAC,EAAE,MAAM,IAAI;AACb,UAAM,SAAS,KAAK,SAAS,SAAS,GAAG,SAAS;AAGlD,WAAO,mBAAmB,MAAM;AAAA,EAClC;AAAA,EAEA,mBAAiD,IAAI,SAAS;AAC5D,UAAM,gBAAY,mBAAM,KAAC,oBAAO,GAAG,6BAA6B,CAAC,EAAE;AAAA,MACjE;AAAA,IACF;AAEA,UAAM,SAAS,KAAK,SAAS,iBAAiB,GAAG,SAAS;AAC1D,WAAO,2BAA2B,MAAM;AAAA,EAC1C;AACF;",
|
|
6
6
|
"names": ["instanceof_"]
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,9 +15,9 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
15
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
16
|
var index_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./1-api"), module.exports);
|
|
19
|
-
__reExport(index_exports, require("./2-types"), module.exports);
|
|
20
|
-
__reExport(index_exports, require("./3-errors"), module.exports);
|
|
21
|
-
__reExport(index_exports, require("./4-utilities"), module.exports);
|
|
22
|
-
__reExport(index_exports, require("./5-runtime-types"), module.exports);
|
|
18
|
+
__reExport(index_exports, require("./1-api.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./2-types.js"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./3-errors.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./4-utilities.js"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./5-runtime-types.js"), module.exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
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": ["export * from \"./1-api\";\nexport * from \"./2-types\";\nexport * from \"./3-errors\";\nexport * from \"./4-utilities\";\nexport * from \"./5-runtime-types\";\nexport type { JSONSchema } from \"json-schema-to-ts\";\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"./1-api.js\";\nexport * from \"./2-types.js\";\nexport * from \"./3-errors.js\";\nexport * from \"./4-utilities.js\";\nexport * from \"./5-runtime-types.js\";\nexport type { JSONSchema } from \"json-schema-to-ts\";\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,uBAAd;AACA,0BAAc,yBADd;AAEA,0BAAc,0BAFd;AAGA,0BAAc,6BAHd;AAIA,0BAAc,iCAJd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/1-api.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/1-api.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiSession,\n GraffitiPostObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiMedia,\n GraffitiPostMedia,\n GraffitiMediaAccept,\n} from \"./2-types\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\n/**\n * This API describes a small but powerful set of methods that\n * can be used to create many different kinds of social applications,\n * from applications like Twitter, to Messenger, to Wikipedia, to many more new designs.\n * See the [Graffiti project website](https://graffiti.garden)\n * for links to example applications. Additionally, apps built on top\n * of the API interoperate with each other so you can seamlessly switch\n * between apps without losing your friends or data.\n *\n * These API methods should satisfy all of an application's needs for\n * the communication, storage, and access management of social data.\n * The rest of the application can be built with standard client-side\n * user interface tools to present and interact with that data\u2014no server code necessary!\n *\n * The Typescript code for this API is [open source on Github](https://github.com/graffiti-garden/api).\n *\n * There are several different implementations of this Graffiti API available,\n * including a [federated implementation](https://github.com/graffiti-garden/implementation-remote),\n * that lets people choose where their data is stored (you do not need to host your own server)\n * and a [local implementation](https://github.com/graffiti-garden/implementation-local)\n * that can be used for testing and development. Different implementations can\n * be swapped-in in the future without changing the API or any of the apps built on\n * top of it. In fact, we're working on an end-to-end encrypted version now!\n * [Follow Theia on BlueSky for updates](https://bsky.app/profile/theias.place).\n *\n * On the other side of the stack, there is [Vue plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * that wraps around this API to provide reactivity. Other plugin frameworks\n * and high-level libraries will be available in the future.\n *\n * ## API Overview\n *\n * The Graffiti API provides applications with methods for {@link login} and {@link logout},\n * methods to interact with data objects using standard database operations ({@link post}, {@link get}, and {@link delete}),\n * and a method to {@link discover} data objects created by others.\n * These data objects have a couple structured properties:\n * - {@link GraffitiObjectBase.url | `url`} (string): A globally unique identifier and locator for the object.\n * - {@link GraffitiObjectBase.actor | `actor`} (string): An unforgeable identifier for the creator of the object.\n * - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the actors who are allowed to access the object (undefined for public objects).\n * - {@link GraffitiObjectBase.channels | `channels`} (string[]): An array of the *contexts* in which the object should appear.\n *\n * All other data is stored in the object's unstructured {@link GraffitiObjectBase.value | `value`} property.\n * This data can be used to represent social artifacts (e.g. posts, profiles) and activities (e.g. likes, follows).\n * For example, a post might have the value:\n\n * ```js\n * {\n * title: \"My First Post\",\n * content: \"Hello, world!\",\n * published: 1630483200000\n * }\n * ```\n *\n * a profile might have the value:\n *\n * ```js\n * {\n * name: \"Theia Henderson\",\n * pronouns: \"she/her\",\n * describes: \"did:web:theias.place\" // Theia's actor ID\n * }\n * ```\n *\n * and a \"Like\" might have the value:\n *\n * ```js\n * {\n * activity: \"Like\",\n * target: \"graffiti:remote:pod.graffiti.garden/12345\" // The URL of the graffiti object being liked\n * }\n * ```\n *\n * New social artifacts and activities can be easily created, simply\n * by creating new objects with appropriate properties. Despite the lack of\n * structure, we expect Graffiti object properties to adhere to a \"[folksonomy](https://en.wikipedia.org/wiki/Folksonomy)\",\n * similar to hashtags. Any string can be used as a hashtag on Twitter,\n * but there is social value in using the same hashtags at other people and\n * so a structure naturally emerges. Similarly, Graffiti objects\n * can have arbitrary properties but if people use the same properties as each other,\n * their apps will interoperate, which has social value.\n *\n * For a more complete and detailed overview of Graffiti's design, please\n * refer to [this section of the Graffiti paper](https://dl.acm.org/doi/10.1145/3746059.3747627#sec-3),\n * published in ACM UIST 2025. The paper also overviews {@link GraffitiObjectBase.channels | `channels`},\n * which are Graffiti's means of organizing data contextually, and a concept called \"total reification\",\n * which handles explains how moderation, collaboration, and other interactions are managed.\n *\n * @groupDescription 1 - Single-Object Methods\n * Methods for {@link post | creating}, {@link get | reading},\n * and {@link delete | deleting} {@link GraffitiObjectBase | Graffiti objects}.\n * @groupDescription 2 - Multi-Object Methods\n * Methods that retrieve or accumulate information about multiple {@link GraffitiObjectBase | Graffiti objects} at a time.\n * @groupDescription 3 - Media Methods\n * Methods for {@link postMedia | creating}, {@link getMedia | reading},\n * and {@link deleteMedia | deleting} media data.\n * @groupDescription 4 - Identity Methods\n * Methods and properties for logging in and out.\n */\nexport abstract class Graffiti {\n /**\n * Creates a new {@link GraffitiObjectBase | object}.\n *\n * @returns Returns the object that has been posted, complete with its\n * assigned {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}.\n *\n * @group 1 - Single-Object Methods\n */\n abstract post<Schema extends JSONSchema>(\n /**\n * An object to post, minus its {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}, which will be assigned once posted.\n * This object is statically type-checked against the [JSON schema](https://json-schema.org/) that can be optionally provided\n * as the generic type parameter. It is recommended to use a schema to\n * ensure that the posted object matches subsequent {@link get} or {@link discover}\n * methods.\n */\n partialObject: GraffitiPostObject<Schema>,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Retrieves an object from a given {@link GraffitiObjectBase.url | `url`} matching\n * the provided `schema`.\n *\n * If the retreiving {@link GraffitiObjectBase.actor | `actor`} is not\n * the object's `actor`,\n * the object's {@link GraffitiObjectBase.allowed | `allowed`} and\n * {@link GraffitiObjectBase.channels | `channels`} properties are\n * not revealed, similar to a BCC email.\n *\n * @returns Returns the retrieved object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has been deleted, or the actor is not\n * {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorSchemaMismatch} if the retrieved object does not match the provided schema.\n *\n * @throws {@link GraffitiErrorInvalidSchema} If an invalid schema is provided.\n *\n * @group 1 - Single-Object Methods\n */\n abstract get<Schema extends JSONSchema>(\n /**\n * The location of the object to get.\n */\n url: string | GraffitiObjectUrl,\n /**\n * The JSON schema to validate the retrieved object against.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * the retrieved object's {@link GraffitiObjectBase.allowed | `allowed`}\n * property must be `undefined`.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Deletes an object from a given {@link GraffitiObjectBase.url | `url`}\n * that had previously been {@link post | `post`ed}.\n * The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the\n * `actor` that created the object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,\n * or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * is not the same `actor` as the one who created the object.\n *\n * @group 1 - Single-Object Methods\n */\n abstract delete(\n /**\n * The location of the object to delete.\n */\n url: string | GraffitiObjectUrl,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObjectBase>;\n\n /**\n * Discovers objects created by any actor that are contained\n * in at least one of the given {@link GraffitiObjectBase.channels | `channels`}\n * and match the given [JSON Schema](https://json-schema.org).\n *\n * Objects are returned asynchronously as they are discovered but the stream\n * will end once all leads have been exhausted.\n * The {@link GraffitiObjectStream} ends by returning a\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method and a\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string,\n * each of which can be be used to poll for new objects.\n * The `continue` method preserves the type safety of the stream and the `cursor`\n * string can be serialized to continue the stream after an application is closed\n * and reopened.\n *\n * `discover` will not return objects that the querying {@link GraffitiObjectBase.actor | `actor`}\n * is not {@link GraffitiObjectBase.allowed | `allowed`} to access.\n * If the `actor` is not the creator of a discovered object,\n * the allowed list will be masked to only contain the querying actor if the\n * allowed list is not `undefined` (public). Additionally, if the actor is not the\n * creator of a discovered object, any {@link GraffitiObjectBase.channels | `channels`}\n * not specified by the `discover` method will not be revealed. This masking happens\n * before the object is validated against the supplied `schema`.\n *\n * Since different implementations may fetch data from multiple sources there is\n * no guarentee on the order that objects are returned in.\n *\n * @throws {@link GraffitiErrorInvalidSchema} if an invalid schema is provided.\n * Discovery is lazy and will not throw until the iterator is consumed.\n *\n * @returns Returns a stream of objects that match the given {@link GraffitiObjectBase.channels | `channels`}\n * and [JSON Schema](https://json-schema.org).\n *\n * @group 2 - Multi-Object Methods\n */\n abstract discover<Schema extends JSONSchema>(\n /**\n * The {@link GraffitiObjectBase.channels | `channels`} that objects must be associated with.\n */\n channels: string[],\n /**\n * A [JSON Schema](https://json-schema.org) that objects must satisfy.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * only objects that have no {@link GraffitiObjectBase.allowed | `allowed`}\n * property will be returned.\n */\n session?: GraffitiSession | null,\n ): GraffitiObjectStream<Schema>;\n\n /**\n * Continues a {@link GraffitiObjectStream} from a given\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.\n * The continuation will return new objects that have been {@link post | `post`ed}\n * that match the original stream, and also returns the\n * {@link GraffitiObjectBase.url | `url`}s of objects that\n * have been {@link delete | `delete`d}, as marked by a `tombstone`.\n *\n * The `cursor` allows the client to\n * serialize the state of the stream and continue it later.\n * However this method loses any typing information that was\n * present in the original stream. For better type safety\n * and when serializing is not necessary, use the\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method\n * instead, which is returned along with the `cursor` at the\n * end of the original stream.\n *\n * @throws {@link GraffitiErrorNotFound} upon iteration\n * if the cursor is invalid or expired.\n *\n * @throws {@link GraffitiErrorForbidden} upon iteration\n * if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor`\n * that initiated the original stream.\n *\n * @group 2 - Multi-Object Methods\n */\n abstract continueDiscover(\n cursor: string,\n session?: GraffitiSession | null,\n ): GraffitiObjectStreamContinue<{}>;\n\n /**\n * Uploads media data, such as an image or video.\n *\n * Unlike structured {@link GraffitiObjectBase | objects},\n * media is not indexed for {@link discover | `discover`y} and\n * must be retrieved by its exact URL using {@link getMedia}\n *\n * @returns The URL that the media was posted to.\n *\n * @group 3 - Media Methods\n */\n abstract postMedia(\n /**\n * The media data to upload, and optionally\n * an {@link GraffitiObjectBase.allowed | `allowed`}\n * list of actors that can view it.\n */\n media: GraffitiPostMedia,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<string>;\n\n /**\n * Deletes media previously {@link postMedia | `post`ed} to a given URL.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor` that {@link postMedia | `post`ed}\n * the media.\n *\n * @group 3 - Media Methods\n */\n abstract deleteMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n url: string,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * Retrieves media from the given media URL, adhering to the given requirements.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorTooLarge} if the media exceeds the given `maxBytes`.\n *\n * @throws {@link GraffitiErrorNotAcceptable} if the media does not match the given\n * `accept` specification.\n *\n * @returns The URL of the retrieved media, as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n * and the {@link GraffitiObjectBase.actor | `actor`} that posted it.\n *\n * @group 3 - Media Methods\n */\n abstract getMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n mediaUrl: string,\n /**\n * A specification for what types and sizes of media are acceptable.\n */\n accept: GraffitiMediaAccept,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiMedia>;\n\n /**\n * Begins the login process. Depending on the implementation, this may\n * involve redirecting to a login page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * The {@link GraffitiSession | session} object is returned\n * asynchronously via {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLoginEvent} with event type `login`.\n *\n * @group 4 - Identity Methods\n */\n abstract login(\n /**\n * A suggested actor to login as. For example, if a user tries to\n * edit a post but are not logged in, the interface can infer that\n * they might want to log in as the actor who created the post\n * they are attempting to edit.\n *\n * Even if provided, the implementation should allow the user\n * to log in as a different actor if they choose.\n */\n actor?: string | null,\n ): Promise<void>;\n\n /**\n * Begins the logout process for a particular {@link GraffitiSession | session}. Depending on the implementation, this may\n * involve redirecting the user to a logout page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * A confirmation will be returned asynchronously via\n * {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLogoutEvent} as event type `logout`.\n *\n * @group 4 - Identity Methods\n */\n abstract logout(\n /**\n * The {@link GraffitiSession | session} object to logout.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * An event target that can be used to listen for the following\n * events and their corresponding event types:\n * - `login` - {@link GraffitiLoginEvent}\n * - `logout` - {@link GraffitiLogoutEvent}\n * - `initialized` - {@link GraffitiSessionInitializedEvent}\n *\n * @group 4 - Identity Methods\n */\n abstract readonly sessionEvents: EventTarget;\n\n /**\n * Retrieves the human-readable handle associated\n * with the given actor. The handle may change over time\n * and so it should be used for display purposes only.\n *\n * The inverse of {@link handleToActor}.\n *\n * @throws {@link GraffitiErrorNotFound} if a handle cannot be\n * found for the given actor.\n *\n * @returns A human-readable handle for the given actor.\n *\n * @group 4 - Identity Methods\n */\n abstract actorToHandle(actor: string): Promise<string>;\n\n /**\n * Retrieves the actor ID associated with the given handle.\n *\n * The inverse of {@link actorToHandle}.\n *\n * @throws {@link GraffitiErrorNotFound} if there is no actor\n * with the given handle.\n *\n * @returns The actor ID for the given handle.\n *\n * @group 4 - Identity Methods\n */\n abstract handleToActor(handle: string): Promise<string>;\n}\n"],
|
|
4
|
+
"sourcesContent": ["import type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiSession,\n GraffitiPostObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiMedia,\n GraffitiPostMedia,\n GraffitiMediaAccept,\n} from \"./2-types.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\n/**\n * This API describes a small but powerful set of methods that\n * can be used to create many different kinds of social applications,\n * from applications like Twitter, to Messenger, to Wikipedia, to many more new designs.\n * See the [Graffiti project website](https://graffiti.garden)\n * for links to example applications. Additionally, apps built on top\n * of the API interoperate with each other so you can seamlessly switch\n * between apps without losing your friends or data.\n *\n * These API methods should satisfy all of an application's needs for\n * the communication, storage, and access management of social data.\n * The rest of the application can be built with standard client-side\n * user interface tools to present and interact with that data\u2014no server code necessary!\n *\n * The Typescript code for this API is [open source on Github](https://github.com/graffiti-garden/api).\n *\n * There are several different implementations of this Graffiti API available,\n * including a [federated implementation](https://github.com/graffiti-garden/implementation-remote),\n * that lets people choose where their data is stored (you do not need to host your own server)\n * and a [local implementation](https://github.com/graffiti-garden/implementation-local)\n * that can be used for testing and development. Different implementations can\n * be swapped-in in the future without changing the API or any of the apps built on\n * top of it. In fact, we're working on an end-to-end encrypted version now!\n * [Follow Theia on BlueSky for updates](https://bsky.app/profile/theias.place).\n *\n * On the other side of the stack, there is [Vue plugin](https://vue.graffiti.garden/variables/GraffitiPlugin.html)\n * that wraps around this API to provide reactivity. Other plugin frameworks\n * and high-level libraries will be available in the future.\n *\n * ## API Overview\n *\n * The Graffiti API provides applications with methods for {@link login} and {@link logout},\n * methods to interact with data objects using standard database operations ({@link post}, {@link get}, and {@link delete}),\n * and a method to {@link discover} data objects created by others.\n * These data objects have a couple structured properties:\n * - {@link GraffitiObjectBase.url | `url`} (string): A globally unique identifier and locator for the object.\n * - {@link GraffitiObjectBase.actor | `actor`} (string): An unforgeable identifier for the creator of the object.\n * - {@link GraffitiObjectBase.allowed | `allowed`} (string[] | undefined): An array of the actors who are allowed to access the object (undefined for public objects).\n * - {@link GraffitiObjectBase.channels | `channels`} (string[]): An array of the *contexts* in which the object should appear.\n *\n * All other data is stored in the object's unstructured {@link GraffitiObjectBase.value | `value`} property.\n * This data can be used to represent social artifacts (e.g. posts, profiles) and activities (e.g. likes, follows).\n * For example, a post might have the value:\n\n * ```js\n * {\n * title: \"My First Post\",\n * content: \"Hello, world!\",\n * published: 1630483200000\n * }\n * ```\n *\n * a profile might have the value:\n *\n * ```js\n * {\n * name: \"Theia Henderson\",\n * pronouns: \"she/her\",\n * describes: \"did:web:theias.place\" // Theia's actor ID\n * }\n * ```\n *\n * and a \"Like\" might have the value:\n *\n * ```js\n * {\n * activity: \"Like\",\n * target: \"graffiti:remote:pod.graffiti.garden/12345\" // The URL of the graffiti object being liked\n * }\n * ```\n *\n * New social artifacts and activities can be easily created, simply\n * by creating new objects with appropriate properties. Despite the lack of\n * structure, we expect Graffiti object properties to adhere to a \"[folksonomy](https://en.wikipedia.org/wiki/Folksonomy)\",\n * similar to hashtags. Any string can be used as a hashtag on Twitter,\n * but there is social value in using the same hashtags at other people and\n * so a structure naturally emerges. Similarly, Graffiti objects\n * can have arbitrary properties but if people use the same properties as each other,\n * their apps will interoperate, which has social value.\n *\n * For a more complete and detailed overview of Graffiti's design, please\n * refer to [this section of the Graffiti paper](https://dl.acm.org/doi/10.1145/3746059.3747627#sec-3),\n * published in ACM UIST 2025. The paper also overviews {@link GraffitiObjectBase.channels | `channels`},\n * which are Graffiti's means of organizing data contextually, and a concept called \"total reification\",\n * which handles explains how moderation, collaboration, and other interactions are managed.\n *\n * @groupDescription 1 - Single-Object Methods\n * Methods for {@link post | creating}, {@link get | reading},\n * and {@link delete | deleting} {@link GraffitiObjectBase | Graffiti objects}.\n * @groupDescription 2 - Multi-Object Methods\n * Methods that retrieve or accumulate information about multiple {@link GraffitiObjectBase | Graffiti objects} at a time.\n * @groupDescription 3 - Media Methods\n * Methods for {@link postMedia | creating}, {@link getMedia | reading},\n * and {@link deleteMedia | deleting} media data.\n * @groupDescription 4 - Identity Methods\n * Methods and properties for logging in and out.\n */\nexport abstract class Graffiti {\n /**\n * Creates a new {@link GraffitiObjectBase | object}.\n *\n * @returns Returns the object that has been posted, complete with its\n * assigned {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}.\n *\n * @group 1 - Single-Object Methods\n */\n abstract post<Schema extends JSONSchema>(\n /**\n * An object to post, minus its {@link GraffitiObjectBase.url | `url`} and\n * {@link GraffitiObjectBase.actor | `actor`}, which will be assigned once posted.\n * This object is statically type-checked against the [JSON schema](https://json-schema.org/) that can be optionally provided\n * as the generic type parameter. It is recommended to use a schema to\n * ensure that the posted object matches subsequent {@link get} or {@link discover}\n * methods.\n */\n partialObject: GraffitiPostObject<Schema>,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Retrieves an object from a given {@link GraffitiObjectBase.url | `url`} matching\n * the provided `schema`.\n *\n * If the retreiving {@link GraffitiObjectBase.actor | `actor`} is not\n * the object's `actor`,\n * the object's {@link GraffitiObjectBase.allowed | `allowed`} and\n * {@link GraffitiObjectBase.channels | `channels`} properties are\n * not revealed, similar to a BCC email.\n *\n * @returns Returns the retrieved object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has been deleted, or the actor is not\n * {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorSchemaMismatch} if the retrieved object does not match the provided schema.\n *\n * @throws {@link GraffitiErrorInvalidSchema} If an invalid schema is provided.\n *\n * @group 1 - Single-Object Methods\n */\n abstract get<Schema extends JSONSchema>(\n /**\n * The location of the object to get.\n */\n url: string | GraffitiObjectUrl,\n /**\n * The JSON schema to validate the retrieved object against.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * the retrieved object's {@link GraffitiObjectBase.allowed | `allowed`}\n * property must be `undefined`.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiObject<Schema>>;\n\n /**\n * Deletes an object from a given {@link GraffitiObjectBase.url | `url`}\n * that had previously been {@link post | `post`ed}.\n * The deleting {@link GraffitiObjectBase.actor | `actor`} must be the same as the\n * `actor` that created the object.\n *\n * @throws {@link GraffitiErrorNotFound} if the object does not exist, has already been deleted,\n * or the actor is not {@link GraffitiObjectBase.allowed | `allowed`} to access it.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * is not the same `actor` as the one who created the object.\n *\n * @group 1 - Single-Object Methods\n */\n abstract delete(\n /**\n * The location of the object to delete.\n */\n url: string | GraffitiObjectUrl,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<GraffitiObjectBase>;\n\n /**\n * Discovers objects created by any actor that are contained\n * in at least one of the given {@link GraffitiObjectBase.channels | `channels`}\n * and match the given [JSON Schema](https://json-schema.org).\n *\n * Objects are returned asynchronously as they are discovered but the stream\n * will end once all leads have been exhausted.\n * The {@link GraffitiObjectStream} ends by returning a\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method and a\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string,\n * each of which can be be used to poll for new objects.\n * The `continue` method preserves the type safety of the stream and the `cursor`\n * string can be serialized to continue the stream after an application is closed\n * and reopened.\n *\n * `discover` will not return objects that the querying {@link GraffitiObjectBase.actor | `actor`}\n * is not {@link GraffitiObjectBase.allowed | `allowed`} to access.\n * If the `actor` is not the creator of a discovered object,\n * the allowed list will be masked to only contain the querying actor if the\n * allowed list is not `undefined` (public). Additionally, if the actor is not the\n * creator of a discovered object, any {@link GraffitiObjectBase.channels | `channels`}\n * not specified by the `discover` method will not be revealed. This masking happens\n * before the object is validated against the supplied `schema`.\n *\n * Since different implementations may fetch data from multiple sources there is\n * no guarentee on the order that objects are returned in.\n *\n * @throws {@link GraffitiErrorInvalidSchema} if an invalid schema is provided.\n * Discovery is lazy and will not throw until the iterator is consumed.\n *\n * @returns Returns a stream of objects that match the given {@link GraffitiObjectBase.channels | `channels`}\n * and [JSON Schema](https://json-schema.org).\n *\n * @group 2 - Multi-Object Methods\n */\n abstract discover<Schema extends JSONSchema>(\n /**\n * The {@link GraffitiObjectBase.channels | `channels`} that objects must be associated with.\n */\n channels: string[],\n /**\n * A [JSON Schema](https://json-schema.org) that objects must satisfy.\n */\n schema: Schema,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}. If no `session` is provided,\n * only objects that have no {@link GraffitiObjectBase.allowed | `allowed`}\n * property will be returned.\n */\n session?: GraffitiSession | null,\n ): GraffitiObjectStream<Schema>;\n\n /**\n * Continues a {@link GraffitiObjectStream} from a given\n * {@link GraffitiObjectStreamReturn.cursor | `cursor`} string.\n * The continuation will return new objects that have been {@link post | `post`ed}\n * that match the original stream, and also returns the\n * {@link GraffitiObjectBase.url | `url`}s of objects that\n * have been {@link delete | `delete`d}, as marked by a `tombstone`.\n *\n * The `cursor` allows the client to\n * serialize the state of the stream and continue it later.\n * However this method loses any typing information that was\n * present in the original stream. For better type safety\n * and when serializing is not necessary, use the\n * {@link GraffitiObjectStreamReturn.continue | `continue`} method\n * instead, which is returned along with the `cursor` at the\n * end of the original stream.\n *\n * @throws {@link GraffitiErrorNotFound} upon iteration\n * if the cursor is invalid or expired.\n *\n * @throws {@link GraffitiErrorForbidden} upon iteration\n * if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor`\n * that initiated the original stream.\n *\n * @group 2 - Multi-Object Methods\n */\n abstract continueDiscover(\n cursor: string,\n session?: GraffitiSession | null,\n ): GraffitiObjectStreamContinue<{}>;\n\n /**\n * Uploads media data, such as an image or video.\n *\n * Unlike structured {@link GraffitiObjectBase | objects},\n * media is not indexed for {@link discover | `discover`y} and\n * must be retrieved by its exact URL using {@link getMedia}\n *\n * @returns The URL that the media was posted to.\n *\n * @group 3 - Media Methods\n */\n abstract postMedia(\n /**\n * The media data to upload, and optionally\n * an {@link GraffitiObjectBase.allowed | `allowed`}\n * list of actors that can view it.\n */\n media: GraffitiPostMedia,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<string>;\n\n /**\n * Deletes media previously {@link postMedia | `post`ed} to a given URL.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorForbidden} if the {@link GraffitiObjectBase.actor | `actor`}\n * provided in the `session` is not the same as the `actor` that {@link postMedia | `post`ed}\n * the media.\n *\n * @group 3 - Media Methods\n */\n abstract deleteMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n url: string,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * Retrieves media from the given media URL, adhering to the given requirements.\n *\n * @throws {@link GraffitiErrorNotFound} if no media at that URL exists.\n *\n * @throws {@link GraffitiErrorTooLarge} if the media exceeds the given `maxBytes`.\n *\n * @throws {@link GraffitiErrorNotAcceptable} if the media does not match the given\n * `accept` specification.\n *\n * @returns The URL of the retrieved media, as a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\n * and the {@link GraffitiObjectBase.actor | `actor`} that posted it.\n *\n * @group 3 - Media Methods\n */\n abstract getMedia(\n /**\n * A globally unique identifier and locator for the media.\n */\n mediaUrl: string,\n /**\n * A specification for what types and sizes of media are acceptable.\n */\n accept: GraffitiMediaAccept,\n /**\n * An implementation-specific object with information to authenticate the\n * {@link GraffitiObjectBase.actor | `actor`}.\n */\n session?: GraffitiSession | null,\n ): Promise<GraffitiMedia>;\n\n /**\n * Begins the login process. Depending on the implementation, this may\n * involve redirecting to a login page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * The {@link GraffitiSession | session} object is returned\n * asynchronously via {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLoginEvent} with event type `login`.\n *\n * @group 4 - Identity Methods\n */\n abstract login(\n /**\n * A suggested actor to login as. For example, if a user tries to\n * edit a post but are not logged in, the interface can infer that\n * they might want to log in as the actor who created the post\n * they are attempting to edit.\n *\n * Even if provided, the implementation should allow the user\n * to log in as a different actor if they choose.\n */\n actor?: string | null,\n ): Promise<void>;\n\n /**\n * Begins the logout process for a particular {@link GraffitiSession | session}. Depending on the implementation, this may\n * involve redirecting the user to a logout page or opening a popup,\n * so it should always be called in response to a gesture, such as clicking\n * a button, due to the [feature-gating browser security feature](https://developer.mozilla.org/en-US/docs/Web/Security/User_activation).\n *\n * A confirmation will be returned asynchronously via\n * {@link Graffiti.sessionEvents | sessionEvents}\n * as a {@link GraffitiLogoutEvent} as event type `logout`.\n *\n * @group 4 - Identity Methods\n */\n abstract logout(\n /**\n * The {@link GraffitiSession | session} object to logout.\n */\n session: GraffitiSession,\n ): Promise<void>;\n\n /**\n * An event target that can be used to listen for the following\n * events and their corresponding event types:\n * - `login` - {@link GraffitiLoginEvent}\n * - `logout` - {@link GraffitiLogoutEvent}\n * - `initialized` - {@link GraffitiSessionInitializedEvent}\n *\n * @group 4 - Identity Methods\n */\n abstract readonly sessionEvents: EventTarget;\n\n /**\n * Retrieves the human-readable handle associated\n * with the given actor. The handle may change over time\n * and so it should be used for display purposes only.\n *\n * The inverse of {@link handleToActor}.\n *\n * @throws {@link GraffitiErrorNotFound} if a handle cannot be\n * found for the given actor.\n *\n * @returns A human-readable handle for the given actor.\n *\n * @group 4 - Identity Methods\n */\n abstract actorToHandle(actor: string): Promise<string>;\n\n /**\n * Retrieves the actor ID associated with the given handle.\n *\n * The inverse of {@link actorToHandle}.\n *\n * @throws {@link GraffitiErrorNotFound} if there is no actor\n * with the given handle.\n *\n * @returns The actor ID for the given handle.\n *\n * @group 4 - Identity Methods\n */\n abstract handleToActor(handle: string): Promise<string>;\n}\n"],
|
|
5
5
|
"mappings": "AA+GO,MAAe,SAAS;AAoV/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/3-errors.js
CHANGED
|
@@ -40,7 +40,15 @@ class GraffitiErrorNotAcceptable extends Error {
|
|
|
40
40
|
Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
class GraffitiErrorCursorExpired extends Error {
|
|
44
|
+
constructor(message) {
|
|
45
|
+
super(message);
|
|
46
|
+
this.name = "GraffitiErrorCursorExpired";
|
|
47
|
+
Object.setPrototypeOf(this, GraffitiErrorCursorExpired.prototype);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
43
50
|
export {
|
|
51
|
+
GraffitiErrorCursorExpired,
|
|
44
52
|
GraffitiErrorForbidden,
|
|
45
53
|
GraffitiErrorInvalidSchema,
|
|
46
54
|
GraffitiErrorNotAcceptable,
|
package/dist/esm/3-errors.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/3-errors.ts"],
|
|
4
|
-
"sourcesContent": ["export class GraffitiErrorForbidden extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorForbidden\";\n Object.setPrototypeOf(this, GraffitiErrorForbidden.prototype);\n }\n}\n\nexport class GraffitiErrorNotFound extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotFound\";\n Object.setPrototypeOf(this, GraffitiErrorNotFound.prototype);\n }\n}\n\nexport class GraffitiErrorInvalidSchema extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorInvalidSchema\";\n Object.setPrototypeOf(this, GraffitiErrorInvalidSchema.prototype);\n }\n}\n\nexport class GraffitiErrorSchemaMismatch extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorSchemaMismatch\";\n Object.setPrototypeOf(this, GraffitiErrorSchemaMismatch.prototype);\n }\n}\n\nexport class GraffitiErrorTooLarge extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorTooLarge\";\n Object.setPrototypeOf(this, GraffitiErrorTooLarge.prototype);\n }\n}\n\nexport class GraffitiErrorNotAcceptable extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotAcceptable\";\n Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAO,MAAM,+BAA+B,MAAM;AAAA,EAChD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,SAAS;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,4BAA4B,SAAS;AAAA,EACnE;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;",
|
|
4
|
+
"sourcesContent": ["export class GraffitiErrorForbidden extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorForbidden\";\n Object.setPrototypeOf(this, GraffitiErrorForbidden.prototype);\n }\n}\n\nexport class GraffitiErrorNotFound extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotFound\";\n Object.setPrototypeOf(this, GraffitiErrorNotFound.prototype);\n }\n}\n\nexport class GraffitiErrorInvalidSchema extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorInvalidSchema\";\n Object.setPrototypeOf(this, GraffitiErrorInvalidSchema.prototype);\n }\n}\n\nexport class GraffitiErrorSchemaMismatch extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorSchemaMismatch\";\n Object.setPrototypeOf(this, GraffitiErrorSchemaMismatch.prototype);\n }\n}\n\nexport class GraffitiErrorTooLarge extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorTooLarge\";\n Object.setPrototypeOf(this, GraffitiErrorTooLarge.prototype);\n }\n}\n\nexport class GraffitiErrorNotAcceptable extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorNotAcceptable\";\n Object.setPrototypeOf(this, GraffitiErrorNotAcceptable.prototype);\n }\n}\n\nexport class GraffitiErrorCursorExpired extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"GraffitiErrorCursorExpired\";\n Object.setPrototypeOf(this, GraffitiErrorCursorExpired.prototype);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,+BAA+B,MAAM;AAAA,EAChD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,uBAAuB,SAAS;AAAA,EAC9D;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,4BAA4B,SAAS;AAAA,EACnE;AACF;AAEO,MAAM,8BAA8B,MAAM;AAAA,EAC/C,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,sBAAsB,SAAS;AAAA,EAC7D;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,mCAAmC,MAAM;AAAA,EACpD,YAAY,SAAkB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,WAAO,eAAe,MAAM,2BAA2B,SAAS;AAAA,EAClE;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/4-utilities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraffitiErrorInvalidSchema } from "./3-errors";
|
|
1
|
+
import { GraffitiErrorInvalidSchema } from "./3-errors.js";
|
|
2
2
|
function unpackObjectUrl(url) {
|
|
3
3
|
return typeof url === "string" ? url : url.url;
|
|
4
4
|
}
|
|
@@ -33,7 +33,7 @@ function isMediaAcceptable(mediaType, acceptableMediaTypes) {
|
|
|
33
33
|
let ajv = void 0;
|
|
34
34
|
async function compileGraffitiObjectSchema(schema) {
|
|
35
35
|
if (!ajv) {
|
|
36
|
-
const {
|
|
36
|
+
const { Ajv } = await import("ajv");
|
|
37
37
|
ajv = new Ajv({ strict: false });
|
|
38
38
|
}
|
|
39
39
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/4-utilities.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiObjectUrl,\n GraffitiSession,\n} from \"./2-types\";\nimport { GraffitiErrorInvalidSchema } from \"./3-errors\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\nimport type Ajv from \"ajv\";\n\nexport function unpackObjectUrl(url: string | GraffitiObjectUrl) {\n return typeof url === \"string\" ? url : url.url;\n}\n\nexport function isActorAllowedGraffitiObject(\n object: GraffitiObjectBase,\n session?: GraffitiSession | null,\n) {\n return (\n // If there is no allowed list, the actor is allowed.\n !Array.isArray(object.allowed) ||\n // Otherwise...\n (typeof session?.actor === \"string\" &&\n // The actor must be the creator of the object\n (object.actor === session.actor ||\n // Or be on the allowed list\n object.allowed.includes(session.actor)))\n );\n}\n\nexport function maskGraffitiObject(\n object: GraffitiObjectBase,\n channels: string[],\n actor?: string | null,\n): GraffitiObjectBase {\n // If the actor is the creator, return the object as is\n if (actor === object.actor) return object;\n\n // If there is an allowed list, mask it to only include the actor\n // (This assumes the actor is already allowed to access the object)\n const allowedMasked = object.allowed && actor ? [actor] : undefined;\n // Mask the channels to only include the channels that are being queried\n const channelsMasked = object.channels.filter((c) => channels.includes(c));\n\n return {\n ...object,\n allowed: allowedMasked,\n channels: channelsMasked,\n };\n}\n\nexport function isMediaAcceptable(\n mediaType: string,\n acceptableMediaTypes: string[],\n): boolean {\n const [type, subtype] = mediaType.toLowerCase().split(\";\")[0].split(\"/\");\n\n if (!type || !subtype) return false;\n\n return acceptableMediaTypes.some((acceptable) => {\n const [accType, accSubtype] = acceptable\n .toLowerCase()\n .split(\";\")[0]\n .split(\"/\");\n\n if (!accType || !accSubtype) return false;\n\n return (\n (accType === type || accType === \"*\") &&\n (accSubtype === subtype || accSubtype === \"*\")\n );\n });\n}\n\nlet ajv: Ajv | undefined = undefined;\nexport async function compileGraffitiObjectSchema<Schema extends JSONSchema>(\n schema: Schema,\n) {\n if (!ajv) {\n const {
|
|
5
|
-
"mappings": "AAMA,SAAS,kCAAkC;AAIpC,SAAS,gBAAgB,KAAiC;AAC/D,SAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AAC7C;AAEO,SAAS,6BACd,QACA,SACA;AACA;AAAA;AAAA,IAEE,CAAC,MAAM,QAAQ,OAAO,OAAO;AAAA,IAE5B,OAAO,SAAS,UAAU;AAAA,KAExB,OAAO,UAAU,QAAQ;AAAA,IAExB,OAAO,QAAQ,SAAS,QAAQ,KAAK;AAAA;AAE7C;AAEO,SAAS,mBACd,QACA,UACA,OACoB;AAEpB,MAAI,UAAU,OAAO,MAAO,QAAO;AAInC,QAAM,gBAAgB,OAAO,WAAW,QAAQ,CAAC,KAAK,IAAI;AAE1D,QAAM,iBAAiB,OAAO,SAAS,OAAO,CAAC,MAAM,SAAS,SAAS,CAAC,CAAC;AAEzE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;AAEO,SAAS,kBACd,WACA,sBACS;AACT,QAAM,CAAC,MAAM,OAAO,IAAI,UAAU,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG;AAEvE,MAAI,CAAC,QAAQ,CAAC,QAAS,QAAO;AAE9B,SAAO,qBAAqB,KAAK,CAAC,eAAe;AAC/C,UAAM,CAAC,SAAS,UAAU,IAAI,WAC3B,YAAY,EACZ,MAAM,GAAG,EAAE,CAAC,EACZ,MAAM,GAAG;AAEZ,QAAI,CAAC,WAAW,CAAC,WAAY,QAAO;AAEpC,YACG,YAAY,QAAQ,YAAY,SAChC,eAAe,WAAW,eAAe;AAAA,EAE9C,CAAC;AACH;AAEA,IAAI,MAAuB;AAC3B,eAAsB,4BACpB,QACA;AACA,MAAI,CAAC,KAAK;AACR,UAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["import type {\n GraffitiObject,\n GraffitiObjectBase,\n GraffitiObjectUrl,\n GraffitiSession,\n} from \"./2-types.js\";\nimport { GraffitiErrorInvalidSchema } from \"./3-errors.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\nimport type Ajv from \"ajv\";\n\nexport function unpackObjectUrl(url: string | GraffitiObjectUrl) {\n return typeof url === \"string\" ? url : url.url;\n}\n\nexport function isActorAllowedGraffitiObject(\n object: GraffitiObjectBase,\n session?: GraffitiSession | null,\n) {\n return (\n // If there is no allowed list, the actor is allowed.\n !Array.isArray(object.allowed) ||\n // Otherwise...\n (typeof session?.actor === \"string\" &&\n // The actor must be the creator of the object\n (object.actor === session.actor ||\n // Or be on the allowed list\n object.allowed.includes(session.actor)))\n );\n}\n\nexport function maskGraffitiObject(\n object: GraffitiObjectBase,\n channels: string[],\n actor?: string | null,\n): GraffitiObjectBase {\n // If the actor is the creator, return the object as is\n if (actor === object.actor) return object;\n\n // If there is an allowed list, mask it to only include the actor\n // (This assumes the actor is already allowed to access the object)\n const allowedMasked = object.allowed && actor ? [actor] : undefined;\n // Mask the channels to only include the channels that are being queried\n const channelsMasked = object.channels.filter((c) => channels.includes(c));\n\n return {\n ...object,\n allowed: allowedMasked,\n channels: channelsMasked,\n };\n}\n\nexport function isMediaAcceptable(\n mediaType: string,\n acceptableMediaTypes: string[],\n): boolean {\n const [type, subtype] = mediaType.toLowerCase().split(\";\")[0].split(\"/\");\n\n if (!type || !subtype) return false;\n\n return acceptableMediaTypes.some((acceptable) => {\n const [accType, accSubtype] = acceptable\n .toLowerCase()\n .split(\";\")[0]\n .split(\"/\");\n\n if (!accType || !accSubtype) return false;\n\n return (\n (accType === type || accType === \"*\") &&\n (accSubtype === subtype || accSubtype === \"*\")\n );\n });\n}\n\nlet ajv: Ajv | undefined = undefined;\nexport async function compileGraffitiObjectSchema<Schema extends JSONSchema>(\n schema: Schema,\n) {\n if (!ajv) {\n const { Ajv } = await import(\"ajv\");\n ajv = new Ajv({ strict: false });\n }\n\n try {\n // Force the validation guard because\n // it is too big for the type checker.\n // Fortunately json-schema-to-ts is\n // well tested against ajv.\n return ajv.compile(schema) as (\n data: GraffitiObjectBase,\n ) => data is GraffitiObject<Schema>;\n } catch (error) {\n throw new GraffitiErrorInvalidSchema(\n error instanceof Error ? error.message : String(error),\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAMA,SAAS,kCAAkC;AAIpC,SAAS,gBAAgB,KAAiC;AAC/D,SAAO,OAAO,QAAQ,WAAW,MAAM,IAAI;AAC7C;AAEO,SAAS,6BACd,QACA,SACA;AACA;AAAA;AAAA,IAEE,CAAC,MAAM,QAAQ,OAAO,OAAO;AAAA,IAE5B,OAAO,SAAS,UAAU;AAAA,KAExB,OAAO,UAAU,QAAQ;AAAA,IAExB,OAAO,QAAQ,SAAS,QAAQ,KAAK;AAAA;AAE7C;AAEO,SAAS,mBACd,QACA,UACA,OACoB;AAEpB,MAAI,UAAU,OAAO,MAAO,QAAO;AAInC,QAAM,gBAAgB,OAAO,WAAW,QAAQ,CAAC,KAAK,IAAI;AAE1D,QAAM,iBAAiB,OAAO,SAAS,OAAO,CAAC,MAAM,SAAS,SAAS,CAAC,CAAC;AAEzE,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,EACZ;AACF;AAEO,SAAS,kBACd,WACA,sBACS;AACT,QAAM,CAAC,MAAM,OAAO,IAAI,UAAU,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG;AAEvE,MAAI,CAAC,QAAQ,CAAC,QAAS,QAAO;AAE9B,SAAO,qBAAqB,KAAK,CAAC,eAAe;AAC/C,UAAM,CAAC,SAAS,UAAU,IAAI,WAC3B,YAAY,EACZ,MAAM,GAAG,EAAE,CAAC,EACZ,MAAM,GAAG;AAEZ,QAAI,CAAC,WAAW,CAAC,WAAY,QAAO;AAEpC,YACG,YAAY,QAAQ,YAAY,SAChC,eAAe,WAAW,eAAe;AAAA,EAE9C,CAAC;AACH;AAEA,IAAI,MAAuB;AAC3B,eAAsB,4BACpB,QACA;AACA,MAAI,CAAC,KAAK;AACR,UAAM,EAAE,IAAI,IAAI,MAAM,OAAO,KAAK;AAClC,UAAM,IAAI,IAAI,EAAE,QAAQ,MAAM,CAAC;AAAA,EACjC;AAEA,MAAI;AAKF,WAAO,IAAI,QAAQ,MAAM;AAAA,EAG3B,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,IACvD;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/5-runtime-types.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n looseObject,\n array,\n string,\n url,\n union,\n instanceof as instanceof_,\n int,\n tuple,\n nullable,\n optional,\n nonnegative,\n extend,\n} from \"zod/mini\";\nimport type { Graffiti } from \"./1-api\";\nimport type {\n GraffitiObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiPostObject,\n GraffitiSession,\n} from \"./2-types\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\nexport const GraffitiPostObjectSchema = looseObject({\n value: looseObject({}),\n channels: array(string()),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiObjectSchema = extend(GraffitiPostObjectSchema, {\n url: url(),\n actor: url(),\n});\n\nexport const GraffitiObjectUrlSchema = union([\n looseObject({\n url: url(),\n }),\n url(),\n]);\n\nexport const GraffitiSessionSchema = looseObject({\n actor: url(),\n});\nexport const GraffitiOptionalSessionSchema = optional(\n nullable(GraffitiSessionSchema),\n);\n\nexport const GraffitiPostMediaSchema = looseObject({\n data: instanceof_(Blob),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiMediaSchema = extend(GraffitiPostMediaSchema, {\n actor: url(),\n});\nexport const GraffitiMediaAcceptSchema = looseObject({\n types: optional(array(string())),\n maxBytes: optional(int().check(nonnegative())),\n});\n\nasync function* wrapGraffitiStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStream<Schema>,\n): GraffitiObjectStream<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\nasync function* wrapGraffitiContinueStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStreamContinue<Schema>,\n): GraffitiObjectStreamContinue<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\n\n// @ts-ignore - infinite nesting issue\nexport class GraffitiRuntimeTypes implements Graffiti {\n sessionEvents: Graffiti[\"sessionEvents\"];\n constructor(protected readonly graffiti: Graffiti) {\n this.sessionEvents = this.graffiti.sessionEvents;\n }\n\n login: Graffiti[\"login\"] = (...args) => {\n const typedArgs = tuple([optional(url())]).parse(args);\n return this.graffiti.login(...typedArgs);\n };\n\n logout: Graffiti[\"logout\"] = (...args) => {\n const typedArgs = tuple([GraffitiSessionSchema]).parse(args);\n return this.graffiti.logout(...typedArgs);\n };\n\n handleToActor: Graffiti[\"handleToActor\"] = (...args) => {\n const typedArgs = tuple([string()]).parse(args);\n return this.graffiti.handleToActor(...typedArgs);\n };\n\n actorToHandle: Graffiti[\"actorToHandle\"] = (...args) => {\n const typedArgs = tuple([url()]).parse(args);\n return this.graffiti.actorToHandle(...typedArgs);\n };\n\n async post<Schema extends JSONSchema>(\n partialObject: GraffitiPostObject<Schema>,\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>> {\n const typedArgs = tuple([\n GraffitiPostObjectSchema,\n GraffitiSessionSchema,\n ]).parse([partialObject, session]);\n\n return (await this.graffiti.post<{}>(\n ...typedArgs,\n )) as GraffitiObject<Schema>;\n }\n\n get: Graffiti[\"get\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.get(...typedArgs) as Promise<\n GraffitiObject<(typeof args)[1]>\n >;\n };\n\n delete: Graffiti[\"delete\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.delete(...typedArgs);\n };\n\n postMedia: Graffiti[\"postMedia\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiPostMediaSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.postMedia(...typedArgs);\n };\n\n getMedia: Graffiti[\"getMedia\"] = (...args) => {\n const typedArgs = tuple([\n url(),\n GraffitiMediaAcceptSchema,\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.getMedia(...typedArgs);\n };\n\n deleteMedia: Graffiti[\"deleteMedia\"] = (...args) => {\n const typedArgs = tuple([url(), GraffitiSessionSchema]).parse(args);\n\n return this.graffiti.deleteMedia(...typedArgs);\n };\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const typedArgs = tuple([\n array(string()),\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n const stream = this.graffiti.discover(...typedArgs) as GraffitiObjectStream<\n (typeof args)[1]\n >;\n return wrapGraffitiStream(stream);\n };\n\n continueDiscover: Graffiti[\"continueDiscover\"] = (...args) => {\n const typedArgs = tuple([string(), GraffitiOptionalSessionSchema]).parse(\n args,\n );\n\n const stream = this.graffiti.continueDiscover(...typedArgs);\n return wrapGraffitiContinueStream(stream);\n };\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {\n looseObject,\n array,\n string,\n url,\n union,\n instanceof as instanceof_,\n int,\n tuple,\n nullable,\n optional,\n nonnegative,\n extend,\n} from \"zod/mini\";\nimport type { Graffiti } from \"./1-api.js\";\nimport type {\n GraffitiObject,\n GraffitiObjectStream,\n GraffitiObjectStreamContinue,\n GraffitiPostObject,\n GraffitiSession,\n} from \"./2-types.js\";\nimport type { JSONSchema } from \"json-schema-to-ts\";\n\nexport const GraffitiPostObjectSchema = looseObject({\n value: looseObject({}),\n channels: array(string()),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiObjectSchema = extend(GraffitiPostObjectSchema, {\n url: url(),\n actor: url(),\n});\n\nexport const GraffitiObjectUrlSchema = union([\n looseObject({\n url: url(),\n }),\n url(),\n]);\n\nexport const GraffitiSessionSchema = looseObject({\n actor: url(),\n});\nexport const GraffitiOptionalSessionSchema = optional(\n nullable(GraffitiSessionSchema),\n);\n\nexport const GraffitiPostMediaSchema = looseObject({\n data: instanceof_(Blob),\n allowed: optional(nullable(array(url()))),\n});\nexport const GraffitiMediaSchema = extend(GraffitiPostMediaSchema, {\n actor: url(),\n});\nexport const GraffitiMediaAcceptSchema = looseObject({\n types: optional(array(string())),\n maxBytes: optional(int().check(nonnegative())),\n});\n\nasync function* wrapGraffitiStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStream<Schema>,\n): GraffitiObjectStream<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\nasync function* wrapGraffitiContinueStream<Schema extends JSONSchema>(\n stream: GraffitiObjectStreamContinue<Schema>,\n): GraffitiObjectStreamContinue<Schema> {\n while (true) {\n const next = await stream.next();\n if (next.done) {\n const { cursor, continue: continue_ } = next.value;\n return {\n cursor,\n continue: (...args) => {\n const typedArgs = tuple([GraffitiOptionalSessionSchema]).parse(args);\n return continue_(...typedArgs);\n },\n };\n } else {\n yield next.value;\n }\n }\n}\n\n// @ts-ignore - infinite nesting issue\nexport class GraffitiRuntimeTypes implements Graffiti {\n sessionEvents: Graffiti[\"sessionEvents\"];\n constructor(protected readonly graffiti: Graffiti) {\n this.sessionEvents = this.graffiti.sessionEvents;\n }\n\n login: Graffiti[\"login\"] = (...args) => {\n const typedArgs = tuple([optional(url())]).parse(args);\n return this.graffiti.login(...typedArgs);\n };\n\n logout: Graffiti[\"logout\"] = (...args) => {\n const typedArgs = tuple([GraffitiSessionSchema]).parse(args);\n return this.graffiti.logout(...typedArgs);\n };\n\n handleToActor: Graffiti[\"handleToActor\"] = (...args) => {\n const typedArgs = tuple([string()]).parse(args);\n return this.graffiti.handleToActor(...typedArgs);\n };\n\n actorToHandle: Graffiti[\"actorToHandle\"] = (...args) => {\n const typedArgs = tuple([url()]).parse(args);\n return this.graffiti.actorToHandle(...typedArgs);\n };\n\n async post<Schema extends JSONSchema>(\n partialObject: GraffitiPostObject<Schema>,\n session: GraffitiSession,\n ): Promise<GraffitiObject<Schema>> {\n const typedArgs = tuple([\n GraffitiPostObjectSchema,\n GraffitiSessionSchema,\n ]).parse([partialObject, session]);\n\n return (await this.graffiti.post<{}>(\n ...typedArgs,\n )) as GraffitiObject<Schema>;\n }\n\n get: Graffiti[\"get\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.get(...typedArgs) as Promise<\n GraffitiObject<(typeof args)[1]>\n >;\n };\n\n delete: Graffiti[\"delete\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiObjectUrlSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.delete(...typedArgs);\n };\n\n postMedia: Graffiti[\"postMedia\"] = (...args) => {\n const typedArgs = tuple([\n GraffitiPostMediaSchema,\n GraffitiSessionSchema,\n ]).parse(args);\n return this.graffiti.postMedia(...typedArgs);\n };\n\n getMedia: Graffiti[\"getMedia\"] = (...args) => {\n const typedArgs = tuple([\n url(),\n GraffitiMediaAcceptSchema,\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n\n return this.graffiti.getMedia(...typedArgs);\n };\n\n deleteMedia: Graffiti[\"deleteMedia\"] = (...args) => {\n const typedArgs = tuple([url(), GraffitiSessionSchema]).parse(args);\n\n return this.graffiti.deleteMedia(...typedArgs);\n };\n\n discover: Graffiti[\"discover\"] = (...args) => {\n const typedArgs = tuple([\n array(string()),\n looseObject({}),\n GraffitiOptionalSessionSchema,\n ]).parse(args);\n const stream = this.graffiti.discover(...typedArgs) as GraffitiObjectStream<\n (typeof args)[1]\n >;\n return wrapGraffitiStream(stream);\n };\n\n continueDiscover: Graffiti[\"continueDiscover\"] = (...args) => {\n const typedArgs = tuple([string(), GraffitiOptionalSessionSchema]).parse(\n args,\n );\n\n const stream = this.graffiti.continueDiscover(...typedArgs);\n return wrapGraffitiContinueStream(stream);\n };\n}\n"],
|
|
5
5
|
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAWA,MAAM,2BAA2B,YAAY;AAAA,EAClD,OAAO,YAAY,CAAC,CAAC;AAAA,EACrB,UAAU,MAAM,OAAO,CAAC;AAAA,EACxB,SAAS,SAAS,SAAS,MAAM,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC;AACM,MAAM,uBAAuB,OAAO,0BAA0B;AAAA,EACnE,KAAK,IAAI;AAAA,EACT,OAAO,IAAI;AACb,CAAC;AAEM,MAAM,0BAA0B,MAAM;AAAA,EAC3C,YAAY;AAAA,IACV,KAAK,IAAI;AAAA,EACX,CAAC;AAAA,EACD,IAAI;AACN,CAAC;AAEM,MAAM,wBAAwB,YAAY;AAAA,EAC/C,OAAO,IAAI;AACb,CAAC;AACM,MAAM,gCAAgC;AAAA,EAC3C,SAAS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SAAS;AAC9C,UAAM,YAAY,MAAM;AAAA,MACtB;AAAA,MACA;AAAA,IACF,CAAC,EAAE,MAAM,IAAI;AACb,WAAO,KAAK,SAAS,UAAU,GAAG,SAAS;AAAA,EAC7C;AAAA,EAEA,WAAiC,IAAI,SAAS;AAC5C,UAAM,YAAY,MAAM;AAAA,MACtB,IAAI;AAAA,MACJ;AAAA,MACA;AAAA,IACF,CAAC,EAAE,MAAM,IAAI;AAEb,WAAO,KAAK,SAAS,SAAS,GAAG,SAAS;AAAA,EAC5C;AAAA,EAEA,cAAuC,IAAI,SAAS;AAClD,UAAM,YAAY,MAAM,CAAC,IAAI,GAAG,qBAAqB,CAAC,EAAE,MAAM,IAAI;AAElE,WAAO,KAAK,SAAS,YAAY,GAAG,SAAS;AAAA,EAC/C;AAAA,EAEA,WAAiC,IAAI,SAAS;AAC5C,UAAM,YAAY,MAAM;AAAA,MACtB,MAAM,OAAO,CAAC;AAAA,MACd,YAAY,CAAC,CAAC;AAAA,MACd;AAAA,IACF,CAAC,EAAE,MAAM,IAAI;AACb,UAAM,SAAS,KAAK,SAAS,SAAS,GAAG,SAAS;AAGlD,WAAO,mBAAmB,MAAM;AAAA,EAClC;AAAA,EAEA,mBAAiD,IAAI,SAAS;AAC5D,UAAM,YAAY,MAAM,CAAC,OAAO,GAAG,6BAA6B,CAAC,EAAE;AAAA,MACjE;AAAA,IACF;AAEA,UAAM,SAAS,KAAK,SAAS,iBAAiB,GAAG,SAAS;AAC1D,WAAO,2BAA2B,MAAM;AAAA,EAC1C;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./1-api";
|
|
2
|
-
export * from "./2-types";
|
|
3
|
-
export * from "./3-errors";
|
|
4
|
-
export * from "./4-utilities";
|
|
5
|
-
export * from "./5-runtime-types";
|
|
1
|
+
export * from "./1-api.js";
|
|
2
|
+
export * from "./2-types.js";
|
|
3
|
+
export * from "./3-errors.js";
|
|
4
|
+
export * from "./4-utilities.js";
|
|
5
|
+
export * from "./5-runtime-types.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"./1-api\";\nexport * from \"./2-types\";\nexport * from \"./3-errors\";\nexport * from \"./4-utilities\";\nexport * from \"./5-runtime-types\";\nexport type { JSONSchema } from \"json-schema-to-ts\";\n"],
|
|
4
|
+
"sourcesContent": ["export * from \"./1-api.js\";\nexport * from \"./2-types.js\";\nexport * from \"./3-errors.js\";\nexport * from \"./4-utilities.js\";\nexport * from \"./5-runtime-types.js\";\nexport type { JSONSchema } from \"json-schema-to-ts\";\n"],
|
|
5
5
|
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/src/1-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraffitiObjectUrl, GraffitiObject, GraffitiObjectBase, GraffitiSession, GraffitiPostObject, GraffitiObjectStream, GraffitiObjectStreamContinue, GraffitiMedia, GraffitiPostMedia, GraffitiMediaAccept } from "./2-types";
|
|
1
|
+
import type { GraffitiObjectUrl, GraffitiObject, GraffitiObjectBase, GraffitiSession, GraffitiPostObject, GraffitiObjectStream, GraffitiObjectStreamContinue, GraffitiMedia, GraffitiPostMedia, GraffitiMediaAccept } from "./2-types.js";
|
|
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
|
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":"A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AO,EAAE,eAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAEhB;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC;IAE7C;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEtD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CACxD"}
|
package/dist/src/3-errors.d.ts
CHANGED
|
@@ -16,4 +16,7 @@ export declare class GraffitiErrorTooLarge extends Error {
|
|
|
16
16
|
export declare class GraffitiErrorNotAcceptable extends Error {
|
|
17
17
|
constructor(message?: string);
|
|
18
18
|
}
|
|
19
|
+
export declare class GraffitiErrorCursorExpired extends Error {
|
|
20
|
+
constructor(message?: string);
|
|
21
|
+
}
|
|
19
22
|
//# sourceMappingURL=3-errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3-errors.d.ts","sourceRoot":"","sources":["../../src/3-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM;CAK7B"}
|
|
1
|
+
{"version":3,"file":"3-errors.d.ts","sourceRoot":"","sources":["../../src/3-errors.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM;CAK7B;AAED,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,CAAC,EAAE,MAAM;CAK7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraffitiObject, GraffitiObjectBase, GraffitiObjectUrl, GraffitiSession } from "./2-types";
|
|
1
|
+
import type { GraffitiObject, GraffitiObjectBase, GraffitiObjectUrl, GraffitiSession } from "./2-types.js";
|
|
2
2
|
import type { JSONSchema } from "json-schema-to-ts";
|
|
3
3
|
export declare function unpackObjectUrl(url: string | GraffitiObjectUrl): string;
|
|
4
4
|
export declare function isActorAllowedGraffitiObject(object: GraffitiObjectBase, session?: GraffitiSession | null): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"4-utilities.d.ts","sourceRoot":"","sources":["../../src/4-utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAChB,MAAM,
|
|
1
|
+
{"version":3,"file":"4-utilities.d.ts","sourceRoot":"","sources":["../../src/4-utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,UAE9D;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,WAYjC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,kBAAkB,CAepB;AAED,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAkBT;AAGD,wBAAsB,2BAA2B,CAAC,MAAM,SAAS,UAAU,EACzE,MAAM,EAAE,MAAM,kBAaJ,kBAAkB,KACrB,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,EAMtC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Graffiti } from "./1-api";
|
|
2
|
-
import type { GraffitiObject, GraffitiPostObject, GraffitiSession } from "./2-types";
|
|
1
|
+
import type { Graffiti } from "./1-api.js";
|
|
2
|
+
import type { GraffitiObject, GraffitiPostObject, GraffitiSession } from "./2-types.js";
|
|
3
3
|
import type { JSONSchema } from "json-schema-to-ts";
|
|
4
4
|
export declare const GraffitiPostObjectSchema: import("zod/mini").ZodMiniObject<{
|
|
5
5
|
value: import("zod/mini").ZodMiniObject<{}, import("zod/v4/core").$loose>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5-runtime-types.d.ts","sourceRoot":"","sources":["../../src/5-runtime-types.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"5-runtime-types.d.ts","sourceRoot":"","sources":["../../src/5-runtime-types.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EA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