@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
410 lines (408 loc) • 13.3 kB
TypeScript
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Observable } from 'rxjs';
import { ContentType } from '../models/ContentType';
import { LookupTable } from '../models/LookupTable';
import ContentInstance, { InstanceRecord } from '../models/ContentInstance';
import { ComponentsContentTypeParams, ContentInstancePage } from '../models/Search';
import { DetailedItem, LegacyItem, SandboxItem } from '../models/Item';
import { ItemHistoryEntry } from '../models/Version';
import { GetChildrenOptions } from '../models/GetChildrenOptions';
import QuickCreateItem from '../models/content/QuickCreateItem';
import { Clipboard } from '../models/GlobalState';
import { StandardAction } from '../models/StandardAction';
import { GetChildrenResponse } from '../models/GetChildrenResponse';
import { GetItemWithChildrenResponse } from '../models/GetItemWithChildrenResponse';
import { FetchItemsByPathOptions } from '../models/FetchItemsByPath';
import FetchItemsByPathArray from '../models/FetchItemsByPathArray';
export declare function fetchComponentInstanceHTML(path: string): Observable<string>;
interface GetContentOptions {
lock: boolean;
}
export declare function fetchContentXML(
site: string,
path: string,
options?: Partial<GetContentOptions>
): Observable<string>;
export declare function fetchContentDOM(site: string, path: string): Observable<XMLDocument>;
interface GetDescriptorOptions {
flatten: boolean;
}
export declare function fetchDescriptorXML(
site: string,
path: string,
options?: Partial<GetDescriptorOptions>
): Observable<string>;
export declare function fetchDescriptorDOM(
site: string,
path: string,
options?: Partial<GetDescriptorOptions>
): Observable<XMLDocument>;
export declare function fetchSandboxItem(site: string, path: string): Observable<SandboxItem>;
export declare function fetchSandboxItem(
site: string,
path: string,
options: FetchItemsByPathOptions & {
castAsDetailedItem?: false;
}
): Observable<SandboxItem>;
export declare function fetchSandboxItem(
site: string,
path: string,
options: FetchItemsByPathOptions & {
castAsDetailedItem: true;
}
): Observable<DetailedItem>;
export declare function fetchDetailedItem(
siteId: string,
path: string,
options?: {
preferContent: boolean;
}
): Observable<DetailedItem>;
export declare function fetchDetailedItems(site: string, paths: string[]): Observable<DetailedItem[]>;
export declare function fetchContentInstanceLookup(
site: string,
path: string,
contentTypesLookup: LookupTable<ContentType>
): Observable<LookupTable<ContentInstance>>;
export declare function fetchContentInstance(
site: string,
path: string,
contentTypesLookup: LookupTable<ContentType>
): Observable<ContentInstance>;
export declare function writeContent(
site: string,
path: string,
content: string,
options?: {
unlock: boolean;
}
): Observable<boolean>;
export declare function fetchContentInstanceDescriptor(
site: string,
path: string,
options?: Partial<GetDescriptorOptions>,
contentTypeLookup?: LookupTable<ContentType>
): Observable<{
model: ContentInstance;
modelLookup: LookupTable<ContentInstance>;
/**
* A lookup table directly completed/mutated by this function indexed by path of those objects
* that are incomplete/unflattened.
*/
unflattenedPaths: LookupTable<ContentInstance>;
}>;
/**
* Creates a new content item xml document and writes it to the repo.
*/
export declare function writeInstance(
site: string,
instance: ContentInstance,
contentType: ContentType,
shouldSerializeValueFn?: (fieldId: any) => boolean
): Observable<any>;
export declare function updateField(
site: string,
modelId: string,
fieldId: string,
indexToUpdate: number,
path: string,
value: any,
serializeValue?: boolean | ((value: any) => string)
): Observable<any>;
/**
* Inserts a *new* component item on the specified component collection field. In case of shared components, only
* updates the target content item field to include the reference, does not create/write the shared component document.
* */
export declare function insertComponent(
siteId: string,
parentDocPath: string,
parentModelId: string,
parentFieldId: string,
targetIndex: string | number,
parentContentType: ContentType,
insertedContentInstance: ContentInstance,
insertedItemContentType: ContentType,
isSharedInstance?: boolean,
shouldSerializeValueFn?: (fieldId: string) => boolean
): Observable<any>;
/**
* Insert an *existing* (i.e. shared) component on to the document
* */
export declare function insertInstance(
siteId: string,
parentDocPath: string,
parentModelId: string,
parentFieldId: string,
targetIndex: string | number,
parentContentType: ContentType,
insertedInstance: ContentInstance,
datasource?: string
): Observable<any>;
export declare function insertItem(
site: string,
modelId: string,
fieldId: string,
index: string | number,
instance: InstanceRecord,
path: string,
shouldSerializeValueFn?: (fieldId: string) => boolean
): Observable<any>;
export declare function duplicateItem(
site: string,
modelId: string,
fieldId: string,
targetIndex: string | number,
path: string
): Observable<{
updatedDocument: XMLDocument;
newItem: {
modelId: string;
path: string;
};
}>;
export declare function sortItem(
site: string,
modelId: string,
fieldId: string,
currentIndex: number,
targetIndex: number,
path: string
): Observable<any>;
export declare function moveItem(
site: string,
originalModelId: string,
originalFieldId: string,
originalIndex: number,
targetModelId: string,
targetFieldId: string,
targetIndex: number,
originalParentPath: string,
targetParentPath: string
): Observable<any>;
export declare function deleteItem(
site: string,
modelId: string,
fieldId: string,
indexToDelete: number | string,
path: string
): Observable<any>;
export declare function fetchItemsByContentType(
site: string,
contentType: string,
contentTypesLookup: LookupTable<ContentType>,
options?: ComponentsContentTypeParams
): Observable<ContentInstancePage>;
export declare function fetchItemsByContentType(
site: string,
contentTypes: string[],
contentTypesLookup: LookupTable<ContentType>,
options?: ComponentsContentTypeParams
): Observable<ContentInstancePage>;
export declare function formatXML(site: string, path: string): Observable<boolean>;
export declare function createFileUpload(
uploadUrl: string,
file: any,
path: string,
uploadMeta:
| (Record<string, unknown> & {
site: string;
})
| (Record<string, unknown> & {
siteId: string;
}),
xsrfArgumentName?: string
): Observable<StandardAction>;
export declare function uploadBlob(
site: string,
path: string,
fileData: {
name: string;
type: string;
blob: Blob;
}
): Observable<StandardAction>;
export declare function uploadBlob(
site: string,
path: string,
fileData: {
name: string;
type: string;
blob: Blob;
},
uploadMeta: Record<string, unknown>
): Observable<StandardAction>;
export declare function uploadBlob(
site: string,
path: string,
fileData: {
name: string;
type: string;
blob: Blob;
},
uploadMeta: Record<string, unknown>,
uploadUrl: string
): Observable<StandardAction>;
export declare function uploadBlob(
site: string,
path: string,
fileData: {
name: string;
type: string;
blob: Blob;
},
uploadMeta: Record<string, unknown>,
uploadUrl: string,
xsrfArgumentName: string
): Observable<StandardAction>;
export declare function uploadDataUrl(
site: string,
file: any,
path: string,
xsrfArgumentName: string
): Observable<StandardAction>;
export declare function uploadToS3(
site: string,
file: any,
path: string,
profileId: string,
xsrfArgumentName: string
): Observable<StandardAction>;
export declare function uploadToWebDAV(
site: string,
file: any,
path: string,
profileId: string,
xsrfArgumentName: string
): Observable<StandardAction>;
export declare function uploadToCMIS(
site: string,
file: any,
path: string,
repositoryId: string,
xsrfArgumentName: string
): Observable<StandardAction>;
export declare function getBulkUploadUrl(site: string, path: string): string;
export declare function fetchQuickCreateList(site: string): Observable<QuickCreateItem[]>;
export declare function fetchItemHistory(site: string, path: string): Observable<ItemHistoryEntry[]>;
export declare function revertTo(site: string, path: string, versionNumber: string): Observable<Boolean>;
interface VersionDescriptor {
site: string;
path: string;
versionNumber: string;
content: ContentInstance;
}
export declare function fetchItemVersion(
site: string,
path: string,
versionNumber: string
): Observable<VersionDescriptor>;
export declare function fetchVersions(
site: string,
versions: ItemHistoryEntry[]
): Observable<[VersionDescriptor, VersionDescriptor]>;
export declare function fetchChildrenByPath(
siteId: string,
path: string,
options?: Partial<GetChildrenOptions>
): Observable<GetChildrenResponse>;
/**
* siteId {string} The site id.
* fetchOptionsByPath {LookupTable<Partial<GetChildrenOptions>>} A lookup table of paths and their respective options.
* options {GetChildrenOptions} Options that will be applied to all the path requests.
* */
export declare function fetchChildrenByPaths(
siteId: string,
fetchOptionsByPath: LookupTable<Partial<GetChildrenOptions>>,
options?: Partial<GetChildrenOptions>
): Observable<LookupTable<GetChildrenResponse>>;
export declare function fetchItemsByPath(
siteId: string,
paths: string[]
): Observable<FetchItemsByPathArray<SandboxItem>>;
export declare function fetchItemsByPath(
siteId: string,
paths: string[],
options: FetchItemsByPathOptions & {
castAsDetailedItem: false;
}
): Observable<FetchItemsByPathArray<SandboxItem>>;
export declare function fetchItemsByPath(
siteId: string,
paths: string[],
options: FetchItemsByPathOptions & {
castAsDetailedItem: true;
}
): Observable<FetchItemsByPathArray<DetailedItem>>;
export declare function fetchItemsByPath(
siteId: string,
paths: string[],
options: FetchItemsByPathOptions
): Observable<FetchItemsByPathArray<SandboxItem>>;
export declare function fetchItemByPath(siteId: string, path: string): Observable<SandboxItem>;
export declare function fetchItemByPath(
siteId: string,
path: string,
options: FetchItemsByPathOptions & {
castAsDetailedItem: false;
}
): Observable<SandboxItem>;
export declare function fetchItemByPath(
siteId: string,
path: string,
options: FetchItemsByPathOptions & {
castAsDetailedItem: true;
}
): Observable<DetailedItem>;
export declare function fetchItemByPath(
siteId: string,
path: string,
options: FetchItemsByPathOptions
): Observable<SandboxItem>;
export declare function fetchItemWithChildrenByPath(
siteId: string,
path: string,
options?: Partial<GetChildrenOptions>
): Observable<GetItemWithChildrenResponse>;
export declare function paste(siteId: string, targetPath: string, clipboard: Clipboard): Observable<any>;
export declare function duplicate(siteId: string, path: string): Observable<any>;
export declare function deleteItems(
siteId: string,
items: string[],
comment: string,
optionalDependencies?: string[]
): Observable<boolean>;
export declare function lock(siteId: string, path: string): Observable<boolean>;
export declare function unlock(siteId: string, path: string): Observable<boolean>;
export declare function fetchWorkflowAffectedItems(site: string, path: string): Observable<SandboxItem[]>;
export declare function createFolder(site: string, path: string, name: string): Observable<unknown>;
export declare function createFile(site: string, path: string, fileName: string): Observable<unknown>;
export declare function renameFolder(site: string, path: string, name: string): Observable<any>;
export declare function renameContent(siteId: string, path: string, name: string): Observable<any>;
export declare function changeContentType(site: string, path: string, contentType: string): Observable<boolean>;
export declare function checkPathExistence(site: string, path: string): Observable<boolean>;
export declare function fetchLegacyItem(site: string, path: string): Observable<LegacyItem>;
export declare function fetchLegacyItemsTree(
site: string,
path: string,
options?: Partial<{
depth: number;
order: string;
}>
): Observable<LegacyItem>;
export declare function fetchContentByCommitId(site: string, path: string, commitId: string): Observable<string | Blob>;
export {};