UNPKG

5.33 kBTypeScriptView Raw
1import type { BaseCollection, CursorPaginatedCollection, CursorPaginatedCollectionProp, DefaultElements, ISO8601Timestamp, Link, MakeRequest, MakeRequestPayload } from '../common-types';
2import { ScheduledActionReferenceFilters } from '../common-types';
3import type { AsyncActionProcessingOptions } from '../methods/action';
4import type { ReleaseAction } from './release-action';
5/** Entity types supported by the Release API */
6type Entity = 'Entry' | 'Asset';
7type ReleaseStatus = 'active' | 'archived';
8export interface ReleaseQueryOptions {
9 /** Find releases filtered by the Entity type (Asset, Entry) */
10 'entities.sys.linkType'?: string;
11 /** Find releases containing the specified, comma-separated entities. Requires `entities.sys.linkType` */
12 'entities.sys.id[in]'?: string;
13 /** Comma-separated list of ids to exclude from the query */
14 'sys.id[nin]'?: string;
15 /** Comma-separated list of Ids to find (inclusion) */
16 'sys.id[in]'?: string;
17 /** Comma-separated list of user Ids to find releases by creator */
18 'sys.createdBy.sys.id[in]'?: string;
19 /** Comma-separated filter (inclusion) by Release status (active, archived) */
20 'sys.status[in]'?: ReleaseStatus;
21 /** Comma-separated filter (exclusion) by Release status (active, archived) */
22 'sys.status[nin]'?: ReleaseStatus;
23 /** Find releases using full text phrase and term matching */
24 'title[match]'?: string;
25 /** Filter by empty Releases (exists=false) or Releases with items (exists=true) */
26 'entities[exists]'?: boolean;
27 /** If present, will return results based on a pagination cursor */
28 pageNext?: string;
29 /**
30 * Limit how many records are returned in the result
31 * @default 100
32 * */
33 limit?: number;
34 /**
35 * Order releases
36 * Supported values include
37 * - `title`, `-title`
38 * - `sys.updatedAt`, `-sys.updatedAt`
39 * - `sys.createdAt`, `-sys.createdAt`
40 * @default -sys.updatedAt
41 * */
42 order?: string;
43}
44export type ReleaseSysProps = {
45 id: string;
46 type: 'Release';
47 version: number;
48 status: ReleaseStatus;
49 space: Link<'Space'>;
50 environment: Link<'Environment'>;
51 archivedBy?: Link<'User'>;
52 archivedAt?: ISO8601Timestamp;
53 createdBy: Link<'User'> | Link<'AppDefinition'>;
54 updatedBy: Link<'User'> | Link<'AppDefinition'>;
55 createdAt: ISO8601Timestamp;
56 updatedAt: ISO8601Timestamp;
57 lastAction?: Link<'ReleaseAction'>;
58};
59export type ReleaseReferenceFilters = ScheduledActionReferenceFilters;
60export declare const ReleaseReferenceFilters: typeof ScheduledActionReferenceFilters;
61export type ReleaseMetadata = {
62 withReferences: {
63 entity: Link<'Entry'>;
64 filter: Record<ReleaseReferenceFilters, string[]>;
65 }[];
66};
67/** The object returned by the Releases API */
68export interface ReleaseProps {
69 title: string;
70 sys: ReleaseSysProps;
71 entities: BaseCollection<Link<Entity>>;
72 metadata?: ReleaseMetadata;
73}
74export interface ReleasePayload extends MakeRequestPayload {
75 title: string;
76 entities: BaseCollection<Link<Entity>>;
77}
78export interface ReleaseValidatePayload {
79 action?: 'publish';
80}
81export interface ReleaseValidateOptions {
82 payload?: ReleaseValidatePayload;
83 processingOptions?: AsyncActionProcessingOptions;
84}
85export interface ReleaseApiMethods {
86 /**
87 * Archives a release and locks any actions such as adding new entities or publishing/unpublishing.
88 * This operation increases the sys.version property
89 * @throws {BadRequest} if the release is already archived
90 * */
91 archive(): Promise<Release>;
92 /**
93 * Unarchives an `archived` release and unlocks operations on the Release. This operation increases the sys.version property
94 * @throws {BadRequest} if the release is not archived
95 * */
96 unarchive(): Promise<Release>;
97 /** Updates a Release and returns the updated Release object */
98 update(payload: ReleasePayload): Promise<Release>;
99 /** Deletes a Release and all ReleaseActions linked to it (non-reversible) */
100 delete(): Promise<void>;
101 /** Publishes a Release and waits until the asynchronous action is completed */
102 publish(options?: AsyncActionProcessingOptions): Promise<ReleaseAction<'publish'>>;
103 /** Unpublishes a Release and waits until the asynchronous action is completed */
104 unpublish(options?: AsyncActionProcessingOptions): Promise<ReleaseAction<'unpublish'>>;
105 /** Validates a Release and waits until the asynchronous action is completed */
106 validate({ payload, options, }?: {
107 payload?: ReleaseValidatePayload;
108 options?: AsyncActionProcessingOptions;
109 }): Promise<ReleaseAction<'validate'>>;
110}
111export interface Release extends ReleaseProps, ReleaseApiMethods, DefaultElements<ReleaseProps> {
112}
113/**
114 * Return a Release object enhanced with its own API helper functions.
115 * @private
116 * @param makeRequest - function to make requests via an adapter
117 * @param data - Raw Release data
118 * @return Wrapped Release data
119 */
120export declare function wrapRelease(makeRequest: MakeRequest, data: ReleaseProps): Release;
121/**
122 * @private
123 */
124export declare const wrapReleaseCollection: (makeRequest: MakeRequest, data: CursorPaginatedCollectionProp<ReleaseProps>) => CursorPaginatedCollection<Release, ReleaseProps>;
125export {};