import * as request from 'request'; import { InkstoneConfig } from './config'; import { MaybeAuthToken } from './services'; export declare namespace inkstone { interface Pagination { Page: number; PerPage: number; } interface PaginatedResponse { Page: number; TotalPages: number; Collection: T[]; } const setConfig: (newVals: InkstoneConfig) => void; const isOnline: () => Promise; type Callback = (err: Error | null, data: T, response: request.RequestResponse) => void; namespace support { function getPresignedUrl(authToken: MaybeAuthToken, uuid: string, cb: inkstone.Callback): void; } namespace user { interface Authentication { Expiration: string; Token: string; } interface ChangePasswordParams { OldPassword: string; NewPassword: string; } interface User { Username: string; IsAdmin: boolean; } function authenticate(username: string, password: string, cb: inkstone.Callback): void; function unauthenticate(authToken: MaybeAuthToken, cb: inkstone.Callback): void; const get: (cb: Callback) => void; interface UserUpdateParams { Username: string; } const update: (params: UserUpdateParams, cb: Callback) => void; function changePassword(authToken: MaybeAuthToken, params: ChangePasswordParams, cb: inkstone.Callback): void; function confirm(token: string, cb: inkstone.Callback): void; interface PasswordResetCreateParams { Email: string; ContinueUrl?: string; } function requestResetPassword(params: string | PasswordResetCreateParams, cb: inkstone.Callback): void; interface RequestConfirmEmailParams { Email: string; ContinueUrl?: string; } function requestConfirmEmail(params: string | RequestConfirmEmailParams, cb: inkstone.Callback): void; function claimResetPassword(resetPasswordUUID: string, password: string, cb: inkstone.Callback): void; interface UserCreateParams { Email: string; Password: string; OrganizationName: string; NewsletterOptIn?: boolean; ContinueUrl?: string; } function create(params: UserCreateParams, cb: inkstone.Callback): void; } namespace organization { interface Organization { Name: string; PlanExpirationDate?: number; Role: Role; TrialStartDate?: number; TrialDurationDays?: number; } enum Role { FREE = 0, PRO = 1, TEAM_ADMIN = 2, SUBSIDIARY_PRO = 3 } const list: (cb: Callback) => void; } namespace snapshot { interface Snapshot { UniqueId: string; GitTag?: string; GitSha?: string; Published: boolean; Syndicated: boolean; } interface SnapshotAndProjectAndOrganization { Snapshot: Snapshot; Project: project.Project; Organization: organization.Organization; } function getSnapshotAndProject(id: string, cb: inkstone.Callback): void; function registerSyndication(id: string, secretToken: string, cb: inkstone.Callback): void; function feature(authToken: MaybeAuthToken, uniqueId: string, cb: inkstone.Callback): void; function unfeature(authToken: MaybeAuthToken, uniqueId: string, cb: inkstone.Callback): void; } namespace integrations { interface OAuthAccessTokenResponse { AccessToken: string; RefreshToken: string; ExpiresIn: number; } interface JSONWebTokenResponse { AccessToken: string; } /** * Get a Figma access token using a Figma authorization code. * @param {string} code * @param {inkstone.Callback} cb */ function getFigmaAccessToken(code: string, cb: inkstone.Callback): void; /** * Get a Canny access token as a logged-in user. * @param {string} code * @param {inkstone.Callback} cb */ function getCannyAccessToken(authToken: MaybeAuthToken, cb: inkstone.Callback): void; } namespace community { interface HaiKudos { TotalFromCurrentUser?: number; Total: number; } interface SimpleNamedEntity { Name: string; } interface CommunityProject { Project: SimpleNamedEntity; Organization: SimpleNamedEntity; IsSyndicated?: boolean; IsPublic?: boolean; BytecodeUrl?: string; StandaloneUrl?: string; EmbedUrl?: string; LottieUrl?: string; GifUrl?: string; StillUrl?: string; VideoUrl?: string; HaiKudos?: HaiKudos; SnapshotUuid?: string; } interface OrganizationAndCommunityProjects { IsCurrentUser: boolean; Organization: organization.Organization; CommunityProjects: CommunityProject[]; } interface CommunityProjectsFilters { IsFeatured: boolean; } interface CommunityProjectsQuery { Pagination: inkstone.Pagination; Filters: CommunityProjectsFilters; } /** * Get the community project list. * * Pass undefined as the first parameter if making the request on behalf of an anonymous user. If making the * request on behalf of a logged-in user, pass in their auth token to populate the `TotalFromCurrentUser` * hai-kudos field. * @param {string | undefined} authToken * @param {CommunityProjectsQuery} query * @param {inkstone.Callback[]>} cb */ function projectList(authToken: MaybeAuthToken, query: CommunityProjectsQuery, cb: inkstone.Callback>): void; /** * Fork a community project. * * This endpoint requires auth. */ const forkCommunityProject: (params: CommunityProject, cb: Callback) => void; interface SetHaiKudosParams { OrganizationName: string; ProjectName: string; Total: number; } /** * Give hai-kudos as an authenticated user. * * Here, hai-kudos are treated as a single entity with the expectation that the caller will debounce multiple * snaps into one request with a defined `Total`. * * Hai-kudos cannot be persisted as an unauthenticated user; it's expected that making users *feel like* * they're giving hai-kudos as an unauthenticated user is handled on the client side. * @param {string} authToken * @param {inkstone.community.SetHaiKudosParams} params * @param {inkstone.Callback} cb */ function setHaiKudos(authToken: MaybeAuthToken, params: SetHaiKudosParams, cb: inkstone.Callback): void; /** * Get the community profile of an organization by name. * * Pass undefined as the first parameter if making the request on behalf of an anonymous user. If making the * request on behalf of a logged-in user, pass in their auth token to populate the `TotalFromCurrentUser` * hai-kudos field. Additionally, if the requesting user is a member of the organization, the response payload * will indicate `IsCurrentUser: true`. * @param {string | undefined} authToken * @param {string} organizationName * @param {inkstone.Callback} cb */ function getProfile(authToken: MaybeAuthToken, organizationName: string, cb: inkstone.Callback): void; /** * Get a community project by organization and project name. * * @param {string | undefined} authToken * @param {string} organizationName * @param {string} projectName * @param {inkstone.Callback} cb */ function getProject(authToken: MaybeAuthToken, organizationName: string, projectName: string, cb: inkstone.Callback): void; } namespace project { interface Project { Name: string; IsPublic: boolean; IsFork: boolean; ForkComplete: boolean; RepositoryUrl: string; UniqueId: string; } interface ProjectAndCredentials { Project: Project; Credentials: {}; } interface ProjectCreateParams { Name: string; IsPublic: boolean; DeferCaudexBacking?: boolean; } interface ProjectSnapshot { PrivateURL: string; AssetsSyndicated: boolean; StandaloneURL: string; EmbedURL: string; GifURL: string; VideoURL: string; StillURL: string; LottieURL: string; } const create: (params: ProjectCreateParams, cb: Callback) => void; interface ProjectUpdateParams { Name: string; EnsureCaudexBacking?: boolean; IsPublic: boolean; } const update: (params: ProjectUpdateParams, cb: Callback) => void; const list: (cb: Callback) => void; interface ProjectGetParams { Name: string; } const get: (params: ProjectGetParams, cb: Callback) => void; interface ProjectDeleteParams { Name: string; } const deleteByName: (params: ProjectDeleteParams, cb: Callback) => void; interface CreateSnapshotParams { Name: string; Sha: string; } const createSnapshot: (params: CreateSnapshotParams, cb: Callback) => void; interface GetSnapshotParams { Name: string; Sha: string; } const getSnapshot: (params: GetSnapshotParams, cb: Callback) => void; interface MarkSnapshotSyndicatedParams { Name: string; Sha: string; } const markSnapshotSyndicated: (params: MarkSnapshotSyndicatedParams, cb: Callback) => void; interface CreateSnapshotAssetParams { Name: string; Sha: string; Filename: string; } interface SnapshotPresignedURL { URL: string; } const createSnapshotAsset: (params: CreateSnapshotAssetParams, cb: Callback) => void; } namespace updates { function check(authToken: MaybeAuthToken, query: string, cb: inkstone.Callback): void; } namespace billing { interface Customer { BillingName: string; BillingEmail: string; BillingCountry: string; BillingCity: string; BillingAddressLine: string; BillingZipCode: string; BillingVatNumber: string; } interface Card { ID: string; LastFourDigits: string; ExpirationMonth: number; ExpirationYear: number; IsDefault: boolean; } interface Tier { Price: number; UpTo: number; } interface Plan { ID: string; Currency: 'usd'; Interval: 'year' | 'quarter' | 'month'; Price: number; IsCurrentPlan: boolean; BillingScheme: string; Tiers: Tier[]; } interface Subscription { ID: string; CurrentPeriodStart: number; CurrentPeriodEnd: number; DaysUntilDue: number; CancelAtPeriodEnd: boolean; Quantity: number; } interface Invoice { ID: string; Amount: number; Number: string; Created: number; DownloadLink: string; } interface Profile { Customer: Customer; Cards: Card[]; Plan: Plan; Subscription: Subscription; Invoices: Invoice[]; } interface Product { Name: string; Plans: Plan[]; } interface Coupon { AmountOff: number | null; PercentOff: number | null; Valid: boolean; Name?: string; } /** * @authentication-optional * Describes the available products. This endpoint is the source of valid values of PlanID which can be used to * call setPlan() below. * * If the call is authenticated, then the IsCurrentPlan property will be populated in the list of available plans. */ const listProducts: (cb: Callback) => void; /** * @authentication-required * Describes the customer billing profile. * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND - when we are unable to locate customer data. */ const describe: (cb: Callback) => void; /** * @authentication-required * Sets up the customer profile. A customer profile must be provided before calling any of the methods below. * * Error codes: * E_BILLING_INFO_REQUIRED - when parameters are missing. * E_BILLING_UNABLE_TO_UPDATE_CUSTOMER_RECORD - when the Stripe call fails. */ const setCustomer: (customer: Customer, cb: Callback) => void; interface AddCardRequestParams { Token: string; } interface CreateTaxIDRequestParams { Email: string; VatNumber: string; CompanyName: string; AddressLine: string; Country: string; City: string; ZipCode: string; } /** * @authentication-required * Adds a card using a Stripe token, which must be generated on the client side. A customer profile is required * (see setCustomer() for details). The first card added will automatically be set as the default. The default can * be changed using setCardAsDefaultById() below. * @see {@link https://stripe.com/docs/stripe-js/reference#stripe-create-token} * * Error codes: * E_BILLING_TOKEN_REQUIRED - when a billing token is not provided in the payload. * E_BILLING_CUSTOMER_NOT_FOUND - if you have failed to call setCustomer() first. * E_BILLING_CREATE_CARD_FAILED - when the Stripe call fails. */ const addCard: (card: AddCardRequestParams, cb: Callback) => void; /** * @authentication-required * Sets a card as default. The card ID here is available from the Profile object, obtained by calling describe() * above. A customer profile is required (see setCustomer() for details). * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND - if you have failed to call setCustomer() first. * E_BILLING_SET_DEFAULT_CARD_FAILED - when the Stripe call fails. */ const setCardAsDefaultById: (cardId: string, cb: Callback) => void; /** * @authentication-required * Deletes a card. This request will fail if the user attempts to delete the default card without first specifying * a new default card. Same as setCardAsDefaultById(), the card ID here is available from the Profile object, * obtained by calling describe() above. A customer profile is required (see setCustomer() for details). * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND - if you have failed to call setCustomer() first. * E_BILLING_DELETE_CARD_FAILED - when the Stripe call fails. */ const deleteCardById: (cardId: string, cb: Callback) => void; interface SetPlanRequestParams { PlanID: string; Quantity?: number; Coupon?: string; } /** * @authentication-required * Sets a billing plan for the user. Prior to calling this method, both a customer profile (see setCustomer()) and * a default payment source (see addCard()/setCardAsDefaultById() must be specified). As noted above, the PlanID * string is available via the listProducts() endpoint above…or via hardcoding, since for now we only sell one * plan! * * Error codes: * E_BILLING_UNKNOWN_PLAN_ID - when an unknown plan ID is provided to the endpoint. * E_BILLING_CUSTOMER_NOT_FOUND - if you have failed to call setCustomer() first. * E_BILLING_CHARGE_FAILED - when we are unable to charge the user's card. */ const setPlan: (plan: SetPlanRequestParams, cb: Callback) => void; /** * @authentication-required * Cancels the user's active plan at the end of the billing period. And active plan is required (see setPlan() * above). * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND - if you have failed to call setCustomer() first. * E_BILLING_UNABLE_TO_CANCEL_SUBSCRIPTION - when the Stripe call fails. */ const cancelPlan: (cb: Callback) => void; /** * @authentication-required * Gives information about a coupon via a provided ID * * Error codes: * E_BILLING_COUPON_NOT_FOUND when an unknown coupon ID is provided to the endpoint. */ const getCoupon: (couponID: string, cb: Callback) => void; /** * @authentication-required * Creates a Tax ID associated to a customer. * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND - when the customer don't exist. * E_BILLING_VAT_NUMBER_REQUIRED - if the vat number is not passed. * E_BILLING_CREATE_TAX_ID_INVALID_VALUE - if the vat number is invalid. * E_BILLING_CREATE_TAX_ID_FAILED - when the Stripe call fails. */ const createTaxID: (taxID: CreateTaxIDRequestParams, cb: Callback) => void; interface AddSeatsParams { NumberOfSeatsToAdd: number; } /** * @authentication-required * A Team admin assign seats to subsdiary users * * Error codes: * E_BILLING_CUSTOMER_NOT_FOUND when the Stripe customer does not exist. * E_INVALID_NUMBER_OF_SEATS when the number of seats is not valid. */ const addSeats: (addSeatsParams: AddSeatsParams, cb: Callback) => void; } namespace team { interface CreateTeamParams { NumberOfSeats: number; } /** * @authentication-required * Creates a Team. * * Error codes: * E_TEAM_INVALID_NUMBER_OF_SEATS - when the number of seats is not valid. * E_TEAM_CREATE_FAILED - when something went wrong while creating the team in the DB. */ const createTeam: (team: CreateTeamParams, cb: Callback) => void; interface SeatAssignment { Username: string; } /** * @authentication-required * Return the already assigned seats for a user. * */ const listAssignedSeats: (cb: Callback) => void; interface ConfirmSeatParams { VerificationUniqueID: string; Password: string; } /** * A invited user confirms the account by reseting the password. * */ const confirmSeat: (confirmSeatParams: ConfirmSeatParams, cb: Callback) => void; interface ResendConfirmSeatEmailParams { Email: string; ContinueUrl: string; } /** * Resend the invite to join a team. * */ const resendConfirmSeatEmail: (resendConfirmSeatEmailParams: ResendConfirmSeatEmailParams, cb: Callback) => void; interface AssignSeatsParams { Email: string; } /** * @authentication-required * The team admin assing a collection of seats. * * Error codes: * ErrorCodeTeamNotEnoughSeats - when the team does not have enough seats to all users */ const assignSeats: (assignSeatsParams: AssignSeatsParams[], cb: Callback) => void; } }