mirror of
https://github.com/outline/outline.git
synced 2026-11-28 00:09:58 +03:00
* feat: Add document owners Documents can now have owners, stored as an array of user IDs. Owners must be active members or admins, and changing them requires the existing manage users permission on the document, gated behind a new DocumentOwners plan entitlement that is included in every plan. - ownerIds accepted by documents.create and documents.update and returned by the document presenter - ownerIds filter field (eq/in) for documents.list and documents.search - ownerIds on the MCP create_document and update_document tools, and an ownerId filter on list_documents - Owners section in the document Insights dialog to add and remove owners - Owner filter on the search page - In-app and email notification when a user is made an owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFdSZ39ZGPf31jyGcYz * feat: Give document owners responsibility for their documents - Access requests are routed to owners that can manage the document before falling back to document, collection and workspace admins - Owners are subscribed to a document when they are added, respecting a previous unsubscribe - Owners that can edit a document can also manage its access, owners and archive it; ownership never grants access on its own - Owners are shown in the document byline, list items and search results, and document hover previews Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016MJXFdSZ39ZGPf31jyGcYz * feat: Manage document owners from the share panel - Owner is a role in the share panel permission menu and invite picker for individual users, adding an owner gives them the manage permission - Lowering an owner's permission or removing their access removes the ownership - Owners are sorted to the top of the member list - Owners added through the API or MCP are given the manage permission - Owners do not also receive the "added to document" notification - Only added owners are validated, so suspended owners can still be removed - Deleted users are removed from document owners - Removes the owners section from Insights * fix: Address review feedback on document owners - Authorize owner changes before assigning owners on create - Lock the document when adding an owner so concurrent invitations are kept - Enforce the owner limit on every path - Run MCP document updates in a transaction - Broadcast owner removals to connected clients * feat: Add collection owners - Collections can have owners, who also own every document in the collection, shown first in document bylines - Owner is a role in the collection share panel and invite picker for individual users, adding an owner gives them the manage permission - Lowering an owner's permission or removing their access removes the ownership - ownerIds on collections.create, collections.update and the MCP collection tools - The document owner filter includes documents in owned collections - Access requests go to document and collection owners together - Collection owners are subscribed to the collection and notified when they are added - Deleted users are removed from collection owners - Renames the personal collection policy helper to isPersonalCollectionOwner * feat: Show profile cards on owner names, hide inherited owners in collection lists * fix: Allow adding yourself as a collection owner, include collection owners in MCP exact match * fix: Correct singular owner translations * feat: Allow users to make themselves a document owner - The share panel suggests the current user when they can manage owners, and only offers the Owner permission for them - documents.add_user accepts the actor's own ID when changing ownership, without changing their own access - An owner's own row offers "Remove as owner", which keeps their access - Hides the duplicate "You have full access" row when the current user is listed as a member * fix: Restore singular owner translations * fix: Limit owners to 5, use no key update locks when adding owners * refactor: Move owner logic into Document and Collection model methods - addOwner, removeOwner, grantOwnerAccess and setOwnerIds on both models, locking the row so concurrent owner changes are kept - Owner events are created by an update hook from the change in ownerIds - The manageOwners check runs at the route level when ownerIds is sent - Removes the documentOwners and collectionOwners command modules - Removes duplicate owner tests * fix: Owner selection and membership edge cases - Remove document owners from the legacy plan - Selecting yourself in the share picker only suggests other users that can be owners, and you are not suggested next to groups or guests - Users that make themselves an owner through the API get the manage permission, so they are listed in the share panel * perf: Scope the collection owner filter subquery to the team * chore: Drop redundant teamId UUID check --------- Co-authored-by: Claude <noreply@anthropic.com>
707 lines
17 KiB
TypeScript
707 lines
17 KiB
TypeScript
import type { ParameterizedContext } from "koa";
|
|
import type { RouterContext } from "@koa/router";
|
|
import type { InferAttributes, Model, Transaction } from "sequelize";
|
|
import type { z } from "zod";
|
|
import type { Details as UserAgentDetails } from "express-useragent";
|
|
import type {
|
|
AuthenticationType,
|
|
CollectionSort,
|
|
NavigationNode,
|
|
Client,
|
|
CollectionPermission,
|
|
JSONValue,
|
|
MentionType,
|
|
UnfurlResourceType,
|
|
ProsemirrorData,
|
|
UnfurlResponse,
|
|
} from "@shared/types";
|
|
import type { BaseSchema } from "@server/routes/api/schema";
|
|
import type { AccountProvisionerResult } from "./commands/accountProvisioner";
|
|
import type { OAuthIntent, OAuthState } from "./utils/oauthState";
|
|
import type {
|
|
AccessRequest,
|
|
ApiKey,
|
|
Attachment,
|
|
AuthenticationProvider,
|
|
FileOperation,
|
|
Revision,
|
|
Team,
|
|
User,
|
|
UserMembership,
|
|
UserPasskey,
|
|
WebhookSubscription,
|
|
Pin,
|
|
Star,
|
|
Document,
|
|
Collection,
|
|
Group,
|
|
Integration,
|
|
Comment,
|
|
Subscription,
|
|
View,
|
|
Notification,
|
|
Share,
|
|
GroupMembership,
|
|
Import,
|
|
OAuthClient,
|
|
} from "./models";
|
|
|
|
export { AuthenticationType } from "@shared/types";
|
|
|
|
export type AuthenticationResult = AccountProvisionerResult & {
|
|
client: Client;
|
|
};
|
|
|
|
export type Authentication = {
|
|
/** The user associated with this session. */
|
|
user: User;
|
|
/** The token used for authenticating API requests, WebSocket connections, etc. */
|
|
token: string;
|
|
/** The type of authentication used to create this session (e.g., "api", "app", "oauth"). */
|
|
type?: AuthenticationType;
|
|
/** The authentication service used to create this session (e.g., "email", "passkeys", "google"). */
|
|
service?: string;
|
|
/** The OAuth scopes granted for this session, if applicable. */
|
|
scope?: string[];
|
|
};
|
|
|
|
export type Pagination = {
|
|
limit: number;
|
|
offset: number;
|
|
nextPath: string;
|
|
};
|
|
|
|
export type AppState = {
|
|
pagination: Pagination;
|
|
/** The teams authorized to receive an inbound webhook. */
|
|
webhookTeamIds?: string[];
|
|
oauthClient?: OAuthClient;
|
|
oauthIntent?: OAuthIntent;
|
|
oauthState?: OAuthState;
|
|
/** The identifiers this request is rate limited against. */
|
|
rateLimiterIdentifiers?: string[];
|
|
/** The share that the request's custom domain points to. */
|
|
rootShare?: Share | null;
|
|
/** The nonce allowed by the content security policy for inline scripts. */
|
|
cspNonce?: string;
|
|
/** Additional script sources allowed by the content security policy. */
|
|
cspScriptSrc?: string[];
|
|
/** Additional style sources allowed by the content security policy. */
|
|
cspStyleSrc?: string[];
|
|
/** Whether the response may be framed by other origins. */
|
|
cspAllowFraming?: boolean;
|
|
};
|
|
|
|
/** Fields that middleware sets on the Koa context. */
|
|
export interface AppContextFields {
|
|
/** The authentication for the request, empty when the request is anonymous. */
|
|
auth?: Authentication | Record<string, never>;
|
|
/** The transaction for the request, when the route runs in one. */
|
|
transaction?: Transaction;
|
|
/** The parsed User-Agent header. */
|
|
userAgent?: UserAgentDetails;
|
|
/** The path prefix when the app is mounted under another path. */
|
|
mountPath?: string;
|
|
/** Redirects in the browser so that auth cookies are sent with the request. */
|
|
redirectOnClient: RedirectOnClient;
|
|
}
|
|
|
|
type RedirectOnClient = (redirectTo: string, method?: "GET" | "POST") => void;
|
|
|
|
// Set on app.context, so every Koa context has it.
|
|
declare module "koa" {
|
|
interface DefaultContext {
|
|
redirectOnClient: RedirectOnClient;
|
|
}
|
|
}
|
|
|
|
export type AppContext = ParameterizedContext<AppState, AppContextFields>;
|
|
|
|
/** The Koa context within a router route, including matched params. */
|
|
export type AppRouterContext = RouterContext<AppState, AppContextFields>;
|
|
|
|
export type BaseReq = z.infer<typeof BaseSchema>;
|
|
|
|
export type BaseRes = unknown;
|
|
|
|
/** The context passed to route handlers, commands and model mutations. */
|
|
export interface Context<
|
|
ReqT = Partial<BaseReq>,
|
|
ResT = BaseRes,
|
|
> extends RouterContext<AppState, AppContextFields, ResT> {
|
|
// Router internals are left untyped so that handlers with a narrower context
|
|
// remain assignable to route middleware.
|
|
router: never;
|
|
matched?: never;
|
|
|
|
/** Typed and validated version of request, consisting of validated body, query, etc. */
|
|
input: ReqT;
|
|
|
|
/** The authentication for the actor performing the request. */
|
|
auth: Authentication;
|
|
|
|
/** The transaction that database mutations should run in. */
|
|
transaction: Transaction;
|
|
}
|
|
|
|
type BaseEvent<T extends Model> = {
|
|
teamId: string;
|
|
actorId: string;
|
|
ip: string | null;
|
|
authType?: AuthenticationType | null;
|
|
changes?: {
|
|
attributes: Partial<InferAttributes<T>>;
|
|
previous: Partial<InferAttributes<T>>;
|
|
} | null;
|
|
};
|
|
|
|
export type ApiKeyEvent = BaseEvent<ApiKey> & {
|
|
name: "api_keys.create" | "api_keys.delete";
|
|
modelId: string;
|
|
data: {
|
|
name: string;
|
|
};
|
|
};
|
|
|
|
export type AttachmentEvent = BaseEvent<Attachment> &
|
|
(
|
|
| {
|
|
name: "attachments.create";
|
|
modelId: string;
|
|
data: {
|
|
name: string;
|
|
source?: "import";
|
|
};
|
|
}
|
|
| {
|
|
name: "attachments.update";
|
|
modelId: string;
|
|
}
|
|
| {
|
|
name: "attachments.delete";
|
|
modelId: string;
|
|
data: {
|
|
name: string;
|
|
};
|
|
}
|
|
);
|
|
|
|
export type AuthenticationProviderEvent = BaseEvent<AuthenticationProvider> & {
|
|
name: "authenticationProviders.update";
|
|
modelId: string;
|
|
data: {
|
|
enabled: boolean;
|
|
};
|
|
};
|
|
|
|
export type UserEvent = BaseEvent<User> &
|
|
(
|
|
| {
|
|
name:
|
|
| "users.signin"
|
|
| "users.update"
|
|
| "users.suspend"
|
|
| "users.activate"
|
|
| "users.delete"
|
|
| "users.invite_accepted";
|
|
userId: string;
|
|
}
|
|
| {
|
|
name: "users.signout";
|
|
userId: string;
|
|
data?: {
|
|
name: string;
|
|
/** What caused the sign out, absent on events from older versions. */
|
|
reason?: "manual" | "sso_revoked";
|
|
};
|
|
}
|
|
| {
|
|
name: "users.create" | "users.promote" | "users.demote";
|
|
userId: string;
|
|
data: {
|
|
name: string;
|
|
};
|
|
}
|
|
| {
|
|
name: "users.invite";
|
|
userId: string;
|
|
data: {
|
|
email: string;
|
|
name: string;
|
|
};
|
|
}
|
|
);
|
|
|
|
export type UserMembershipEvent = BaseEvent<UserMembership> & {
|
|
name: "userMemberships.update";
|
|
modelId: string;
|
|
userId: string;
|
|
documentId: string;
|
|
data: {
|
|
index: string | null;
|
|
};
|
|
};
|
|
|
|
export type DocumentMovedEvent = BaseEvent<Document> & {
|
|
name: "documents.move";
|
|
documentId: string;
|
|
collectionId: string;
|
|
data: {
|
|
collectionIds: string[];
|
|
documentIds: string[];
|
|
};
|
|
};
|
|
|
|
export type DocumentEvent = BaseEvent<Document> &
|
|
(
|
|
| {
|
|
name:
|
|
| "documents.create"
|
|
| "documents.publish"
|
|
| "documents.delete"
|
|
| "documents.permanent_delete"
|
|
| "documents.archive"
|
|
| "documents.restore";
|
|
documentId: string;
|
|
collectionId: string;
|
|
data?: {
|
|
source?: "import";
|
|
};
|
|
}
|
|
| {
|
|
name: "documents.unpublish";
|
|
documentId: string;
|
|
collectionId?: string;
|
|
}
|
|
| {
|
|
name: "documents.unarchive";
|
|
documentId: string;
|
|
collectionId: string;
|
|
}
|
|
| {
|
|
name:
|
|
| "documents.update"
|
|
| "documents.update.delayed"
|
|
| "documents.update.debounced";
|
|
documentId: string;
|
|
collectionId: string;
|
|
createdAt: string;
|
|
data?: {
|
|
done: boolean;
|
|
/** The latest collaborator sequence included in the persisted snapshot. */
|
|
collaborators?: number;
|
|
};
|
|
}
|
|
| {
|
|
name: "documents.title_change";
|
|
documentId: string;
|
|
collectionId: string;
|
|
createdAt: string;
|
|
}
|
|
| DocumentMovedEvent
|
|
| AccessRequestEvent
|
|
);
|
|
|
|
export type TemplateEvent = BaseEvent<Document> & {
|
|
name:
|
|
| "templates.create"
|
|
| "templates.update"
|
|
| "templates.delete"
|
|
| "templates.restore";
|
|
modelId: string;
|
|
collectionId?: string;
|
|
};
|
|
|
|
export type EmptyTrashEvent = {
|
|
name: "documents.empty_trash";
|
|
teamId: string;
|
|
actorId: string;
|
|
};
|
|
|
|
export type RevisionEvent = BaseEvent<Revision> & {
|
|
name: "revisions.create";
|
|
documentId: string;
|
|
modelId: string;
|
|
};
|
|
|
|
export type FileOperationEvent = BaseEvent<FileOperation> & {
|
|
name:
|
|
| "fileOperations.create"
|
|
| "fileOperations.update"
|
|
| "fileOperations.delete";
|
|
modelId: string;
|
|
data: Partial<FileOperation>;
|
|
};
|
|
|
|
export type CollectionUserEvent = BaseEvent<UserMembership> & {
|
|
name: "collections.add_user" | "collections.remove_user";
|
|
userId: string;
|
|
modelId: string;
|
|
collectionId: string;
|
|
/** Only present when the membership was created or updated. */
|
|
data?: {
|
|
isNew?: boolean;
|
|
};
|
|
};
|
|
|
|
export type CollectionGroupEvent = BaseEvent<GroupMembership> & {
|
|
name: "collections.add_group" | "collections.remove_group";
|
|
collectionId: string;
|
|
modelId: string;
|
|
data: { membershipId: string };
|
|
};
|
|
|
|
export type DocumentUserEvent = BaseEvent<UserMembership> & {
|
|
name: "documents.add_user" | "documents.remove_user";
|
|
userId: string;
|
|
modelId: string;
|
|
documentId: string;
|
|
/** Only present when the membership was created or updated. */
|
|
data?: {
|
|
isNew?: boolean;
|
|
};
|
|
};
|
|
|
|
export type DocumentOwnerEvent = BaseEvent<Document> & {
|
|
name: "documents.add_owner" | "documents.remove_owner";
|
|
userId: string;
|
|
modelId: string;
|
|
documentId: string;
|
|
};
|
|
|
|
export type CollectionOwnerEvent = BaseEvent<Collection> & {
|
|
name: "collections.add_owner" | "collections.remove_owner";
|
|
userId: string;
|
|
modelId: string;
|
|
collectionId: string;
|
|
};
|
|
|
|
export type AccessRequestEvent = BaseEvent<AccessRequest> & {
|
|
name: "access_requests.create";
|
|
modelId: string;
|
|
documentId: string;
|
|
};
|
|
|
|
export type DocumentGroupEvent = BaseEvent<GroupMembership> & {
|
|
name: "documents.add_group" | "documents.remove_group";
|
|
documentId: string;
|
|
modelId: string;
|
|
data: {
|
|
isNew?: boolean;
|
|
membershipId: string;
|
|
};
|
|
};
|
|
|
|
export type CollectionEvent = BaseEvent<Collection> & {
|
|
name:
|
|
| "collections.create"
|
|
| "collections.update"
|
|
| "collections.delete"
|
|
| "collections.archive"
|
|
| "collections.restore"
|
|
| "collections.move"
|
|
| "collections.permission_changed";
|
|
collectionId: string;
|
|
};
|
|
|
|
export type GroupUserEvent = BaseEvent<UserMembership> & {
|
|
name: "groups.add_user" | "groups.remove_user";
|
|
userId: string;
|
|
modelId: string;
|
|
};
|
|
|
|
export type GroupEvent = BaseEvent<Group> &
|
|
(
|
|
| GroupUserEvent
|
|
| {
|
|
name: "groups.create" | "groups.delete" | "groups.update";
|
|
modelId: string;
|
|
}
|
|
);
|
|
|
|
export type IntegrationEvent = BaseEvent<Integration> & {
|
|
name: "integrations.create" | "integrations.update" | "integrations.delete";
|
|
modelId: string;
|
|
};
|
|
|
|
export type TeamEvent = BaseEvent<Team> & {
|
|
name: "teams.create" | "teams.update" | "teams.delete" | "teams.destroy";
|
|
};
|
|
|
|
export type PinEvent = BaseEvent<Pin> & {
|
|
name: "pins.create" | "pins.update" | "pins.delete";
|
|
modelId: string;
|
|
documentId: string;
|
|
collectionId?: string;
|
|
};
|
|
|
|
export type CommentUpdateEvent = BaseEvent<Comment> & {
|
|
name: "comments.update";
|
|
modelId: string;
|
|
documentId: string;
|
|
actorId: string;
|
|
data?: {
|
|
newMentionIds: string[];
|
|
};
|
|
};
|
|
|
|
export type CommentReactionEvent = BaseEvent<Comment> & {
|
|
name: "comments.add_reaction" | "comments.remove_reaction";
|
|
modelId: string;
|
|
documentId: string;
|
|
data: {
|
|
emoji: string;
|
|
};
|
|
};
|
|
|
|
export type CommentEvent =
|
|
| (BaseEvent<Comment> & {
|
|
name: "comments.create";
|
|
modelId: string;
|
|
documentId: string;
|
|
actorId: string;
|
|
})
|
|
| CommentUpdateEvent
|
|
| (BaseEvent<Comment> & {
|
|
name: "comments.delete";
|
|
modelId: string;
|
|
documentId: string;
|
|
actorId: string;
|
|
collectionId: string;
|
|
})
|
|
| CommentReactionEvent;
|
|
|
|
export type StarEvent = BaseEvent<Star> & {
|
|
name: "stars.create" | "stars.update" | "stars.delete";
|
|
modelId: string;
|
|
documentId: string;
|
|
userId: string;
|
|
};
|
|
|
|
export type ShareEvent = BaseEvent<Share> & {
|
|
name: "shares.create" | "shares.update" | "shares.revoke";
|
|
modelId: string;
|
|
documentId: string;
|
|
collectionId?: string;
|
|
};
|
|
|
|
export type SubscriptionEvent = BaseEvent<Subscription> & {
|
|
name: "subscriptions.create" | "subscriptions.delete";
|
|
modelId: string;
|
|
userId: string;
|
|
documentId: string | null;
|
|
collectionId: string | null;
|
|
};
|
|
|
|
export type ViewEvent = BaseEvent<View> & {
|
|
name: "views.create";
|
|
documentId: string;
|
|
collectionId: string;
|
|
modelId: string;
|
|
data: {
|
|
title: string;
|
|
};
|
|
};
|
|
|
|
export type WebhookDeliveryStatus = "pending" | "success" | "failed";
|
|
|
|
export type WebhookSubscriptionEvent = BaseEvent<WebhookSubscription> & {
|
|
name:
|
|
| "webhookSubscriptions.create"
|
|
| "webhookSubscriptions.delete"
|
|
| "webhookSubscriptions.update";
|
|
modelId: string;
|
|
data: {
|
|
name: string;
|
|
url: string;
|
|
events: string[];
|
|
};
|
|
};
|
|
|
|
export type NotificationEvent = BaseEvent<Notification> & {
|
|
name:
|
|
| "notifications.create"
|
|
| "notifications.update"
|
|
| "notifications.delete";
|
|
modelId: string;
|
|
teamId: string;
|
|
userId: string;
|
|
actorId: string;
|
|
commentId?: string;
|
|
documentId?: string;
|
|
collectionId?: string;
|
|
membershipId?: string;
|
|
};
|
|
|
|
export type OAuthClientEvent = BaseEvent<OAuthClient> & {
|
|
name: "oauthClients.create" | "oauthClients.update" | "oauthClients.delete";
|
|
modelId: string;
|
|
};
|
|
|
|
export type UserPasskeyEvent = BaseEvent<UserPasskey> & {
|
|
name: "passkeys.create" | "passkeys.update" | "passkeys.delete";
|
|
modelId: string;
|
|
userId: string;
|
|
};
|
|
|
|
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
export type ImportEvent = BaseEvent<Import<any>> & {
|
|
name:
|
|
| "imports.create"
|
|
| "imports.update"
|
|
| "imports.processed"
|
|
| "imports.delete";
|
|
modelId: string;
|
|
};
|
|
|
|
export type Event =
|
|
| ApiKeyEvent
|
|
| AttachmentEvent
|
|
| AuthenticationProviderEvent
|
|
| DocumentEvent
|
|
| DocumentUserEvent
|
|
| DocumentOwnerEvent
|
|
| AccessRequestEvent
|
|
| DocumentMovedEvent
|
|
| DocumentGroupEvent
|
|
| PinEvent
|
|
| CommentEvent
|
|
| StarEvent
|
|
| CollectionEvent
|
|
| CollectionUserEvent
|
|
| CollectionOwnerEvent
|
|
| CollectionGroupEvent
|
|
| FileOperationEvent
|
|
| IntegrationEvent
|
|
| GroupEvent
|
|
| RevisionEvent
|
|
| ShareEvent
|
|
| SubscriptionEvent
|
|
| TeamEvent
|
|
| TemplateEvent
|
|
| UserEvent
|
|
| UserMembershipEvent
|
|
| ViewEvent
|
|
| WebhookSubscriptionEvent
|
|
| NotificationEvent
|
|
| OAuthClientEvent
|
|
| UserPasskeyEvent
|
|
| EmptyTrashEvent
|
|
| ImportEvent;
|
|
|
|
export type NotificationMetadata = {
|
|
notificationId?: string;
|
|
};
|
|
|
|
export type JSONExportMetadata = {
|
|
/** The version of the export, allows updated structure in the future. */
|
|
exportVersion: number;
|
|
/** The version of the application that created the export. */
|
|
version: string;
|
|
/** The date the export was created. */
|
|
createdAt: string;
|
|
/** The ID of the user that created the export. */
|
|
createdById: string;
|
|
/** The email of the user that created the export. */
|
|
createdByEmail: string | null;
|
|
};
|
|
|
|
export type DocumentJSONExport = {
|
|
id: string;
|
|
urlId: string;
|
|
title: string;
|
|
/**
|
|
* For backward compatibility, maintain the `emoji` field.
|
|
* Future exports will use the `icon` field.
|
|
* */
|
|
emoji?: string | null;
|
|
icon: string | null;
|
|
color: string | null;
|
|
data: ProsemirrorData;
|
|
createdById: string;
|
|
createdByName: string;
|
|
createdByEmail: string | null;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
publishedAt: string | null;
|
|
fullWidth: boolean;
|
|
parentDocumentId: string | null;
|
|
};
|
|
|
|
export type AttachmentJSONExport = {
|
|
id: string;
|
|
documentId: string | null;
|
|
contentType: string;
|
|
name: string;
|
|
size: number;
|
|
key: string;
|
|
};
|
|
|
|
export type CollectionJSONExport = {
|
|
collection: {
|
|
id: string;
|
|
urlId: string;
|
|
name: string;
|
|
data?: ProsemirrorData | null;
|
|
description?: string | null;
|
|
permission?: CollectionPermission | null;
|
|
color?: string | null;
|
|
icon?: string | null;
|
|
sort: CollectionSort;
|
|
documentStructure: NavigationNode[] | null;
|
|
};
|
|
documents: {
|
|
[id: string]: DocumentJSONExport;
|
|
};
|
|
attachments: {
|
|
[id: string]: AttachmentJSONExport;
|
|
};
|
|
};
|
|
|
|
export type UnfurlIssueOrPR =
|
|
| UnfurlResponse[UnfurlResourceType.Issue]
|
|
| UnfurlResponse[UnfurlResourceType.PR];
|
|
|
|
export type UnfurlProject = UnfurlResponse[UnfurlResourceType.Project];
|
|
|
|
export type UnfurlURL = UnfurlResponse[UnfurlResourceType.URL];
|
|
|
|
export type Unfurl =
|
|
| UnfurlIssueOrPR
|
|
| UnfurlProject
|
|
| UnfurlURL
|
|
| {
|
|
type: Exclude<
|
|
UnfurlResourceType,
|
|
| UnfurlResourceType.Issue
|
|
| UnfurlResourceType.PR
|
|
| UnfurlResourceType.Project
|
|
| UnfurlResourceType.URL
|
|
>;
|
|
[x: string]: JSONValue;
|
|
};
|
|
|
|
export type UnfurlError = {
|
|
error: string;
|
|
/** How long to cache the error for in seconds, defaults to one minute. */
|
|
cacheExpiry?: number;
|
|
};
|
|
|
|
export type UnfurlSignature = (
|
|
url: string,
|
|
actor?: User
|
|
) => Promise<Unfurl | UnfurlError | undefined>;
|
|
|
|
/**
|
|
* Recognizes the URL of a resource belonging to the service and returns the
|
|
* type of mention that represents it, or undefined when the URL is not one the
|
|
* service can mention.
|
|
*/
|
|
export type MentionSignature = (url: URL) => MentionType | undefined;
|
|
|
|
export type UninstallSignature = (integration: Integration) => Promise<void>;
|
|
|
|
export type Replace<T, K extends keyof T, N extends string> = {
|
|
[P in keyof T as P extends K ? N : P]: T[P extends K ? K : P];
|
|
};
|