import type { Contract, ContractSummary, JsonSchema, QueryOptions } from 'autumndb'; import { Operation } from 'fast-json-patch'; import type { JellyfishSDK } from '.'; import type { Message } from './types'; export declare const isMentionedInMessage: (card: Message, userSlug: string, userGroups?: string[]) => boolean; /** * @namespace JellyfishSDK.card * @memberof JellyfishSDK */ export declare class CardSdk { private sdk; constructor(sdk: JellyfishSDK); /** * @summary Get a card * @name get * @public * @function * @memberof JellyfishSDK.card * * @description Get a card using an id or a slug * * @param {String} idOrSlug - The id or slug of the card to retrieve * @param {Object} options - Extra query options to use * @param {Object} [options.schema] - Additional schema that will be merged * into the query * * @fulfil {Object|null} - A single card, or null if one wasn't found * @returns {Promise} * * @example * sdk.card.get('user-johndoe') * .then((card) => { * console.log(card) * }) * * sdk.card.get('8b465c9a-b4cb-44c1-9df9-632649d7c4c3') * .then((card) => { * console.log(card) * }) */ get(idOrSlug: string): Promise; /** * @summary Get a card and its attached timeline * @name get * @public * @function * @memberof JellyfishSDK.card * * @description Get a card and its timeline using an id or a slug * * @param {String} idOrSlug - The id or slug of the card to retrieve * @param {Object} options - Additional options * * @fulfil {Object|null} - A single card, or null if one wasn't found * @returns {Promise} * * @example * sdk.card.getWithTimeline('user-johndoe') * .then((card) => { * console.log(card) * }) * * sdk.card.getWithTimeline('8b465c9a-b4cb-44c1-9df9-632649d7c4c3') * .then((card) => { * console.log(card) * }) */ getWithTimeline(idOrSlug: string, options?: { schema?: JsonSchema; queryOptions?: Omit; }): Promise; /** * @summary Get a card and cards linked to it using a verb * @public * @function * @memberof JellyfishSDK.card * * @description Get a card and its timeline using an id or a slug * * @param {String} idOrSlug - The id or slug of the card to retrieve * @param {String[]} verbs - Verbs to load * @param {Object} options - Additional options * * @fulfil {Object|null} - A single card, or null if one wasn't found * @returns {Promise} * * @example * sdk.card.getWithLinks('user-johndoe', [ 'has attached element' ]) * .then((card) => { * console.log(card) * }) * * sdk.card.getWithTimeline('8b465c9a-b4cb-44c1-9df9-632649d7c4c3', [ 'has attached element' ]) * .then((card) => { * console.log(card) * }) */ getWithLinks(idOrSlug: string, verbs: string[], options?: { type?: string; }): Promise; /** * @summary Get all cards of a given type * @name getAllByType * @public * @function * @memberof JellyfishSDK.card * * @description Get all cards that have the provided 'type' attribute * * @param {String} cardType - The type of card to retrieve * * @fulfil {Object[]} - All cards of the given type * @returns {Promise} * * @example * sdk.card.getAllByType('view') * .then((cards) => { * console.log(cards) * }) */ getAllByType(cardType: string): Promise; getByCreator(actorId: Contract['id'], type: string): Promise; /** * @summary Create a new card * @name create * @public * @function * @memberof JellyfishSDK.card * * @description Send an action request to create a new card * * @param {Object} card - The card that should be created, must include * a 'type' attribute. * * @fulfil {Card} - The newly created card * @returns {Promise} * * @example * sdk.card.create({ * type: 'thread', * data: { * description: 'lorem ipsum dolor sit amet' * } * }) * .then((id) => { * console.log(id) * }) */ create(card: Partial): Promise; /** * @summary Update a card * @name update * @public * @function * @memberof JellyfishSDK.card * * @description Send an action request to update a card * * @param {String} id - The id of the card that should be updated * @param {String} type - The card type * @param {Object[]} patch - A JSON Patch set of operationss * * @fulfil {Object} - An action response object * @returns {Promise} * * @example * sdk.card.update('8b465c9a-b4cb-44c1-9df9-632649d7c4c3', 'support-thread', [ * { * op: 'add', * path: '/data/description', * value: 'foo bar baz' * } * ]).then((response) => { * console.log(response) * }) */ update(id: Contract['id'], type: string, patch: Operation[]): Promise; /** * @summary Remove a card * @name remove * @public * @function * @memberof JellyfishSDK.card * * @description Send an action request to remove a card * * @param {String} id - The id of the card that should be removed * @param {String} type - The type of the card that should be removed * * @returns {Promise} * * @example * sdk.card.remove('8b465c9a-b4cb-44c1-9df9-632649d7c4c3', 'card') */ remove(id: Contract['id'], type: string): Promise; /** * @summary Create a link card * @name link * @public * @function * @memberof JellyfishSDK.card * * @description Link two cards together * * @param {Object} fromCard - The card that should be linked from * @param {Object} toCard - The card that should be linked to * @param {String} verb - The name of the relationship * * @returns {Promise} */ link(fromCard: Pick, toCard: Pick, verb: string): Promise; /** * @summary Remove a link card * @name unlink * @public * @function * @memberof JellyfishSDK.card * * @description Un-link two cards * * @param {String} fromCard - The id of the card that the link is from * @param {String} toCard - The id of the card that the link is to * @param {String} verb - The name of the relationship * * @returns {Promise} */ unlink(fromCard: Pick, toCard: Pick, verb: string): Promise>; /** * @summary Mark a card as read * @name markAsRead * @public * @function * @memberof JellyfishSDK.card * * @description Adds the user slug to the data.readBy field of the card. * * @param {String} userSlug - The slug of the user who has read the card * @param {String} card - The card that should be marked as read * @param {Array} userGroups - An array of groups that the user is a member of * * @returns {Promise} */ markAsRead(userSlug: string, card: Message, userGroups?: string[]): Promise; /** * @summary Mark a card as unread * @name markAsUnread * @public * @function * @memberof JellyfishSDK.card * * @description Removes the user slug from the data.readBy field of the card. * * @param {String} userSlug - The slug of the user who has read the card * @param {String} card - The card that should be marked as unread * @param {Array} userGroups - An array of groups that the user is a member of * * @returns {Promise} */ markAsUnread(userSlug: string, card: Message, userGroups?: string[]): Promise; }