@curvenote/cli
Version:
CLI Client library for Curvenote
142 lines • 6.52 kB
TypeScript
import type { ISession } from '../session/types.js';
import type { CollectionDTO, CollectionListingDTO, SubmissionKindDTO, SubmissionsListItemDTO } from '@curvenote/common';
import type { SubmitLog, SubmitOpts } from './types.js';
export declare function kindQuestions(kinds: Omit<SubmissionKindDTO, 'date_created' | 'date_modified' | 'checks'>[]): {
name: string;
type: string;
message: string;
choices: {
name: string;
value: string;
}[];
};
export declare function collectionMoniker(collection: CollectionDTO): string;
export declare function collectionQuestions(venue: string, collections: CollectionListingDTO['items'], opts?: {
allowClosedCollection?: boolean;
}): {
name: string;
type: string;
message: string;
choices: {
name: string;
value: CollectionDTO;
}[];
};
export declare function venueQuestion(session: ISession, action?: string): {
name: string;
type: string;
message: string;
filter: (venue: string) => string;
validate: (venue: string) => Promise<string | true>;
};
/**
* Choose and return a collection and kind based on venue
*
* By default, this function only looks at open collections; however, if
* `opts.allowClosedCollection` is `true`, the "open" requirement is removed.
*
* First `collection` must be determined; successful cases include:
* - `collection` is provided, valid, and "open"
* - `venue` has a single, "open" `collection`
* - `opts.yes` is `true` and the `venue` has a default, "open" `collection`
* - user interactively selects one of the available `collections` on the `venue`
*
* On failure, this function will `process.exit(1)`. Failure cases include:
* - No "open" collections
* - Provided `collection` is invalid or not "open"
* - `opts.yes` is `true` but there is no default, "open" `collection`
*
* After determining `collection`, `kind` is chosen using `determineKindFromCollection`.
*/
export declare function determineCollectionAndKind(session: ISession, venue: string, collections: CollectionListingDTO, opts?: {
kind?: string;
collection?: string;
yes?: boolean;
allowClosedCollection?: boolean;
}): Promise<{
collection: CollectionDTO;
kind: SubmissionKindDTO;
prompted?: boolean;
}>;
/**
* Fetch a list of kinds from `venue` API
*/
export declare function listSubmissionKinds(session: ISession, venue: string): Promise<{
items: SubmissionKindDTO[];
}>;
/**
* Fetch a single `venue` kind from API
*/
export declare function getSubmissionKind(session: ISession, venue: string, kindIdOrName: string): Promise<SubmissionKindDTO>;
/**
* Choose and return one kind based on venue and collection
*
* Successful cases include:
* - `kind` is provided and available on the `collection`
* - `collection` with a single `kind`, which is returned
* - `opts.yes` is `true` and the `collection` has a default `kind`, which is returned
* - user interactively selects one of the available `kinds` on the `collection`
*
* On failure, this function will `process.exit(1)`. Failure cases include:
* - Invalid `kind` is provided
* - `opts.yes` is `true` but there is no default `kind`
* - API fetch for selected kind fails (user is not authorized, venue does not exist, etc)
*/
export declare function determineKindFromCollection(session: ISession, venue: string, collection: CollectionDTO, opts?: {
kind?: string;
yes?: boolean;
}): Promise<{
kind: SubmissionKindDTO;
prompted?: boolean;
}>;
export declare function getSiteConfig(session: ISession): import("myst-config").SiteConfig;
export declare function ensureVenue(session: ISession, venue: string | undefined, opts?: {
yes?: boolean;
action?: string;
}): Promise<any>;
/**
* Prompt user for a new work key
*
* First, gives a simple Y/n with a default UUID. If the user is unhappy with that,
* they are prompted to write their own key.
*
* This key cannot already exist as a work key; if you want to link to an existing
* work, you must put the key directly in your project config file.
*/
export declare function promptForNewKey(session: ISession, opts?: {
yes?: boolean;
}): Promise<string>;
/**
* Ensure that a `venue` exists by performing a basic request to the venue
*
* If venue does not exist, fails with `process.exit(1)`.
*/
export declare function checkVenueExists(session: ISession, venue: string): Promise<void>;
export declare function checkVenueSubmitAccess(session: ISession, venue: string): Promise<boolean>;
/**
* Fetch `venue` collections from API
*/
export declare function listCollections(session: ISession, venue: string): Promise<CollectionListingDTO>;
/**
* Get collections from `venue` and log information about open collections
*
* This will fail with `process.exit(1)` if the fetch for venue collections fails.
* By default, it also fails if there are no open collections.
*
* If `requireOpenCollections` is false, this function will not fail if there are
* only closed collections or no collections at all.
*/
export declare function getVenueCollections(session: ISession, venue: string, requireOpenCollections?: boolean): Promise<CollectionListingDTO>;
export declare function checkForSubmissionKeyInUse(session: ISession, venue: string, key: string): Promise<boolean | null>;
export declare function chooseSubmission(session: ISession, submissions: SubmissionsListItemDTO[], opts?: {
yes?: boolean;
}): Promise<SubmissionsListItemDTO>;
export declare function getAllSubmissionsUsingKey(session: ISession, venue: string, key: string): Promise<SubmissionsListItemDTO[] | undefined>;
export declare function getSubmissionToUpdate(session: ISession, submissions: SubmissionsListItemDTO[]): Promise<SubmissionsListItemDTO | undefined>;
export declare function confirmUpdateToExistingSubmission(session: ISession, venue: string, collections: CollectionListingDTO, submission: SubmissionsListItemDTO, key: string, opts?: SubmitOpts): Promise<{
kind: SubmissionKindDTO;
collection: CollectionDTO;
}>;
export declare function createNewSubmission(session: ISession, submitLog: SubmitLog, venue: string, collection: CollectionDTO, kind: SubmissionKindDTO, cdn: string, cdnKey: string, jobId: string, key: string, opts?: SubmitOpts): Promise<void>;
export declare function updateExistingSubmission(session: ISession, submitLog: SubmitLog, venue: string, cdnKey: string, existingSubmission: SubmissionsListItemDTO, jobId: string): Promise<void>;
//# sourceMappingURL=submit.utils.d.ts.map