@eddye68/studio-client
Version:
The AWS service Studio client
1,440 lines (1,399 loc) • 42.6 kB
JavaScript
// src/common/argument-error.ts
var ArgumentError = class _ArgumentError extends Error {
constructor(message, paramName, error) {
super(_ArgumentError.buildMessage(message, paramName, error));
this.paramName = paramName;
this.name = "ArgumentError";
}
static buildMessage(message, paramName, error) {
return `${message} (Parameter '${paramName}')`;
}
};
// src/model/wfl/basic-metadata.ts
var BasicMetaData = class {
constructor(params) {
this.__classname__ = "BasicMetaData";
this.ID = null;
this.DocumentID = null;
this.Name = null;
this.Type = null;
this.Publication = null;
this.Category = null;
this.ContentSource = null;
this.MasterId = null;
this.StoryId = null;
this.ID = params.ID ?? null;
this.DocumentID = params.DocumentID ?? null;
this.Name = params.Name ?? null;
this.Type = params.Type ?? null;
this.Publication = params.Publication ?? null;
this.Category = params.Category ?? null;
this.ContentSource = params.ContentSource ?? null;
this.MasterId = params.MasterId ?? null;
this.StoryId = params.StoryId ?? null;
}
};
// src/model/wfl/category.ts
var Category = class {
constructor(params) {
this.__classname__ = "Category";
this.Id = null;
this.Name = null;
this.Id = params.Id ?? null;
this.Name = params.Name ?? null;
}
};
// src/model/wfl/metadata.ts
var MetaData = class {
constructor(params) {
this.__classname__ = "MetaData";
this.BasicMetaData = null;
this.RightsMetaData = null;
this.SourceMetaData = null;
this.ContentMetaData = null;
this.WorkflowMetaData = null;
this.ExtraMetaData = null;
this.BasicMetaData = params.BasicMetaData ?? null;
this.RightsMetaData = params.RightsMetaData ?? null;
this.SourceMetaData = params.SourceMetaData ?? null;
this.ContentMetaData = params.ContentMetaData ?? null;
this.WorkflowMetaData = params.WorkflowMetaData ?? null;
this.ExtraMetaData = params.ExtraMetaData ?? null;
}
};
// src/model/wfl/publication.ts
var Publication = class {
constructor(params) {
this.__classname__ = "Publication";
this.Id = null;
this.Name = null;
this.Id = params.Id ?? null;
this.Name = params.Name ?? null;
}
};
// src/model/wfl/state.ts
var State = class {
constructor(Id = null, Name = null, Type = null, Produce = null, Color = null, DefaultRouteTo = null) {
this.__classname__ = "State";
this.Id = null;
this.Name = null;
this.Type = null;
this.Produce = null;
this.Color = null;
this.DefaultRouteTo = null;
this.Id = Id;
this.Name = Name;
this.Type = Type;
this.Produce = Produce;
this.Color = Color;
this.DefaultRouteTo = DefaultRouteTo;
}
};
// src/model/wfl/wflobject.ts
var WflObject = class {
constructor(params) {
this.__classname__ = "Object";
this.MetaData = null;
this.Relations = null;
this.Pages = null;
this.Files = null;
this.Messages = null;
this.Elements = null;
this.Targets = null;
this.Renditions = null;
this.MessageList = null;
this.ObjectLabels = null;
this.InDesignArticles = null;
this.Placements = null;
this.Operations = null;
this.MetaData = params.Metadata ?? null;
this.Relations = params.Relations ?? null;
;
this.Pages = params.Pages ?? null;
;
this.Files = params.Files ?? null;
;
this.Messages = params.Messages ?? null;
;
this.Elements = params.Elements ?? null;
;
this.Targets = params.Targets ?? null;
;
this.Renditions = params.Renditions ?? null;
;
this.MessageList = params.MessageList ?? null;
;
this.ObjectLabels = params.ObjectLabels ?? null;
;
this.InDesignArticles = params.InDesignArticles ?? null;
;
this.Placements = params.Placements ?? null;
;
this.Operations = params.Operations ?? null;
;
}
};
// src/model/wfl/workflow-metadata.ts
var WorkflowMetaData = class {
constructor(params) {
this.__classname__ = "WorkflowMetaData";
this.Deadline = null;
this.Urgency = null;
this.Modifier = null;
this.Modified = null;
this.Creator = null;
this.Created = null;
this.Comment = null;
this.State = null;
this.RouteTo = null;
this.LockedBy = null;
this.Version = null;
this.DeadlineSoft = null;
this.Rating = null;
this.Deletor = null;
this.Deleted = null;
this.Deadline = params.Deadline ?? null;
this.Urgency = params.Urgency ?? null;
this.Modifier = params.Modifier ?? null;
this.Modified = params.Modified ?? null;
this.Creator = params.Creator ?? null;
this.Created = params.Created ?? null;
this.Comment = params.Comment ?? null;
this.State = params.State ?? null;
this.RouteTo = params.RouteTo ?? null;
this.LockedBy = params.LockedBy ?? null;
this.Version = params.Version ?? null;
this.DeadlineSoft = params.DeadlineSoft ?? null;
this.Rating = params.Rating ?? null;
this.Deletor = params.Deletor ?? null;
this.Deleted = params.Deleted ?? null;
}
};
// src/client/helpers/wfl-helpers.ts
var WflHelpers = class {
/**
*
* @param name
* @param type The object type like 'Article'
* @param categoryId
* @param publicationId
* @param stateId
*
* @returns The Workflow object
*/
static createWflObject(name, type, categoryId, publicationId, stateId) {
return new WflObject({
Metadata: new MetaData({
BasicMetaData: new BasicMetaData({
Name: name,
Type: type,
Publication: new Publication({
Id: publicationId
}),
Category: new Category({
Id: categoryId
})
}),
WorkflowMetaData: new WorkflowMetaData({
State: new State(stateId)
})
}),
Files: [],
Relations: []
});
}
};
// src/client/client-error.ts
var ClientError = class extends Error {
constructor(msg) {
super(msg);
this.name = "ClientError";
}
};
// src/client/client.ts
import { v4 as uuidv42 } from "uuid";
// src/http-client/http-error.ts
var HttpError = class extends Error {
/**
*
* @param {string} message
*/
constructor(message) {
super(message);
this.name = "HttpError";
}
};
// src/http-client/http-response-error.ts
var HttpResponseError = class _HttpResponseError extends HttpError {
/**
*
* @param {Response} response
*/
constructor(message, response) {
super(_HttpResponseError.buildMessage(message, response));
this.code = response.status;
this.name = "HttpResponseError";
}
static buildMessage(message, response) {
if (message) {
return `HTTP Error: ${message}: ${response.status} ${response.statusText}`;
} else {
return `HTTP Error: ${response.status} ${response.statusText}`;
}
}
};
// src/http-client/http-client.ts
import { v4 as uuidv4 } from "uuid";
var HttpClient = class {
constructor(logger) {
this.headers = {};
this.baseUrl = ".";
this.logger = logger;
}
/**
*
* @returns The configuration service base URL
*/
getBaseUrl() {
return this.baseUrl;
}
setBaseUrl(baseUrl) {
this.baseUrl = baseUrl;
}
setCommonHeaders(headers) {
this.headers = headers;
}
async request(httpMethod, path, query, body) {
httpMethod = httpMethod.toUpperCase();
if (query === void 0) {
query = new URLSearchParams();
}
const url = this.getBaseUrl() + "/" + path + (query.size > 0 ? "?" + query.toString() : "");
const request = {
method: httpMethod.toUpperCase(),
headers: { ...this.headers }
// Clone headers
};
console.log(`HttpClient::_request: httpMethod=[${httpMethod}], url=[${url}]`);
if (httpMethod === "POST") {
this.logger.debug(`HttpClient::_request: body=[${JSON.stringify(body)}]`);
console.log("HttpClient::_request: body:", body);
request.body = JSON.stringify(body);
request.headers["Content-Type"] = "application/json";
}
const response = await fetch(url, request);
let data = null;
const contentType = response.headers.get("Content-Type");
switch (contentType) {
case "application/json":
data = await response.json();
break;
default:
throw new HttpResponseError(`Unsupported content type: ${contentType}`, response);
}
data = this._checkResponse(data);
return data.Result;
}
/**
*
* @param url
* @returns
*/
async downloadFile(url, query) {
if (query === void 0) {
query = new URLSearchParams();
}
const parsedUrl = new URL(url);
query.forEach((value, key) => {
parsedUrl.searchParams.set(key, value);
});
url = parsedUrl.toString();
const response = await fetch(url);
if (!response.ok) {
throw new HttpResponseError("Object cannot be downloaded from Studio.", response);
}
const buffer = await response.arrayBuffer();
console.log(`Downloaded ${buffer.byteLength} bytes`);
return buffer;
}
/**
* Upload a file to the Studio transfer server.
*
*
* @param body
* @param size
* @param contentType
* @param ticket
* @param studiobaseUrl The Studio base url
*
* @returns The url to the uploaded file
*/
async uploadFile(body, size, contentType, ticket, studiobaseUrl) {
this.logger.debug(`HttpClient::uploadFile: ticket=[${ticket}], studiobaseUrl=[${studiobaseUrl}]`);
const url = `${studiobaseUrl}/transferindex.php?ticket=${ticket}&fileguid=${uuidv4()}`;
const headers = {
"Content-Type": contentType
};
if (size !== null) {
headers["Content-Length"] = String(size);
}
const response = await fetch(url, {
method: "PUT",
// To prevent the error: RequestInit: duplex option is required when sending a body
// Note: The order is important!!!! The 'duplex' setting must be set before the body otherwise it will be ignored.
duplex: "half",
body,
headers
});
if (!response.ok) {
throw new HttpResponseError("Unable to upload file.", response);
}
return url;
}
/**
* @param {object} data
* @private
*/
_checkResponse(data) {
console.log("HttpClient::_checkResponse: ", data);
if (data === null) {
throw new HttpError("No JSON data received");
}
if (data.hasOwnProperty("Status")) {
if (data.Status !== "ok") {
if (data.StatusMessage !== void 0) {
throw new ClientError(`The status is not 'ok': ${data.Status}: ${data.StatusMessage}`);
} else {
throw new ClientError(`The status is not 'ok': ${data.Status}`);
}
}
} else {
throw new HttpError("No 'Status' property found in response");
}
if (!data.hasOwnProperty("Result")) {
throw new HttpError("No 'Result' property found in response");
}
return data;
}
_sanitizeUrl(url) {
return url.replace(/\/$/, "");
}
};
// src/model/wfl/relation.ts
var RelationType = /* @__PURE__ */ ((RelationType2) => {
RelationType2["Contained"] = "Contained";
RelationType2["Placed"] = "Placed";
RelationType2["DeletedContained"] = "DeletedContained";
return RelationType2;
})(RelationType || {});
var Relation = class {
constructor(params) {
this.__classname__ = "Relation";
this.Parent = null;
this.Child = null;
this.Type = null;
this.Placements = null;
this.ParentVersion = null;
this.ChildVersion = null;
this.Rating = null;
this.Targets = null;
this.ParentInfo = null;
this.ChildInfo = null;
this.ObjectLabels = null;
this.Parent = params.Parent ?? null;
this.Child = params.Child ?? null;
this.Type = params.Type ?? null;
this.Placements = params.Placements ?? null;
this.ParentVersion = params.ParentVersion ?? null;
this.ChildVersion = params.ChildVersion ?? null;
this.Rating = params.Rating ?? null;
this.Targets = params.Targets ?? null;
this.ParentInfo = params.ParentInfo ?? null;
this.ChildInfo = params.ChildInfo ?? null;
this.ObjectLabels = params.ObjectLabels ?? null;
}
};
// src/client/client.ts
var Client = class {
/**
*
* @param logger The logger instance
* @param options The Client options
* @param httpClient The Http client. When not defined an instance will be created automatically.
*/
constructor(logger, options, httpClient) {
this._studioBaseUrl = "";
this._publicationsCache = {};
/**
* The configurationId
*/
this._configurationId = null;
console.log("Client::constructor", options);
if (httpClient === void 0) {
httpClient = new HttpClient(logger);
}
this._logger = logger;
this._options = options;
this._httpClient = httpClient;
this._httpClient.setCommonHeaders({
"User-Agent": "StudioClient Client",
"x-api-key": this.options.apiKey
});
this._httpClient.setBaseUrl(options.baseUrl);
}
get options() {
return this._options;
}
/**
* @returns The configurationid
* @throws QqAwsServiceStudioClientClientError when not logged on
*/
get configurationId() {
if (this._configurationId === null) {
throw new ClientError("Not logged on");
}
;
return this._configurationId;
}
validateOptions(options) {
if (options.baseUrl == "") {
throw new ClientError("baseUrl is required");
}
}
/**
*
* @returns true when logged in
*/
isLoggedOn() {
return this._configurationId !== null;
}
setStudioBaseUrl(url) {
this._studioBaseUrl = this._sanitizeUrl(url);
}
/**
*
* @param configurationId
* @returns true when logged in
*/
async logon(configurationId) {
console.log(`QqAwsServiceStudioClientClient::logon: configurationId=[${configurationId}]`);
this._configurationId = configurationId;
return this.isLoggedOn();
}
/**
*
* @returns The Woodwing Studio base URL
*/
getBaseUrl() {
return this._options.baseUrl;
}
/**
* @param studioUrl The
* @param appname The application name
* @param username The WoodWing Studio username
* @param password The WoodWing Studio password
* @param requestId Optional: The requestID
* @param configurationId Optional: The configurationID
* @returns The new or given ConfigurationId
* @throws QqAwsServiceStudioClientClientError when the registration fails.
*/
async register(studioUrl, appname, username, password, requestId, configurationId) {
if (requestId === void 0) {
requestId = this._generateRequestId();
}
console.log(`QqAwsServiceStudioClientClient::register: studioUrl=[${studioUrl}], appname=[${appname}], username=[${username}], requestId=[${requestId}]`);
const request = {
"Appname": appname,
"Url": this._sanitizeUrl(studioUrl),
"Username": username,
"Password": password,
"RequestId": requestId
};
if (configurationId !== void 0) {
if (this._configurationId !== null) {
request.ConfigurationId = this._configurationId;
}
request.ConfigurationId = configurationId;
}
const result = await this._httpClient.request("POST", "studioapplication", void 0, request);
if ("ConfigurationId" in result) {
this._configurationId = result.ConfigurationId;
return result.ConfigurationId;
}
throw new ClientError("No 'ConfigurationId' in response");
}
async unRegister(configurationId) {
if (configurationId === void 0) {
configurationId = this.configurationId;
}
}
/**
*
* @param ids The publication ids to resolve
* @param requestInfo What elements to retrieve. "PubChannels","States", "Categories"
* @param forceNew When true, ignore local cache.
* @returns All resolved publications
*/
async getPublications(ids, requestInfo, forceNew, requestId, configurationId) {
if (forceNew === void 0) {
forceNew = false;
}
console.log(`SqCreatePdf2Client::getPublications: ids=[${ids.join(", ")}], forceNew=[${forceNew}]`);
let idsToRequest = [];
for (const id of ids) {
if (forceNew === true || !(id in this._publicationsCache)) {
idsToRequest.push(id);
} else {
this._logger.debug(`Brand ${id} already loaded. Check the request info`);
if (requestInfo !== void 0) {
for (const requestInfoElement of requestInfo) {
if (!(requestInfoElement in this._publicationsCache[id])) {
this._logger.debug(`Brand ${id} already loaded. But ${requestInfoElement} was not requested before.`);
idsToRequest.push(id);
break;
}
}
}
}
}
if (idsToRequest.length > 0) {
const publications = await this.getPublicationsInt(
idsToRequest,
requestInfo
);
for (const publication of publications) {
const brandId = publication.Id;
this._publicationsCache[brandId] = publication;
}
}
let result = [];
for (const id of ids) {
if (id in this._publicationsCache) {
result.push(this._publicationsCache[id]);
}
}
return result;
}
/**
*
* @param {string} publicationId
* @returns {Promise<null|object>}
*/
async getPublication(publicationId, requestInfo) {
const publications = await this.getPublications([publicationId], requestInfo);
for (let pubIdx in publications) {
const publication = publications[pubIdx];
console.log("processing publication: ", publication);
if (publication.Id === publicationId.toString()) {
return publication;
}
}
return null;
}
/**
*
* @param forceNew When true create a new ticket instead of the cached ticket
* @param requestId
* @param configurationId
* @returns
*/
async getTicket(forceNew, requestId, configurationId) {
if (forceNew === void 0) {
forceNew = false;
}
if (requestId === void 0) {
requestId = this._generateRequestId();
}
if (configurationId === void 0) {
configurationId = this.configurationId;
}
console.log(`QqAwsServiceStudioClientClient::getTicket: forceNew=[${forceNew}], requestId=[${requestId}], configurationId=[${configurationId}]`);
const path = "ticket";
const query = new URLSearchParams({
ConfigurationId: configurationId,
RequestId: requestId,
Forcenew: forceNew ? "true" : "false"
});
const result = await this._httpClient.request("GET", path, query);
return result;
}
/**
* @inheritdoc
*/
async getStateByName(publicationId, type, name) {
const publication = await this.getPublication(publicationId, ["States"]);
if (publication === null) {
return null;
}
for (const state of publication.States) {
if (state.Type.toLowerCase() === type.toLowerCase() && state.Name.toLowerCase() === name.toLowerCase()) {
return state;
}
}
return null;
}
/**
*
* @param wflObject
* @param childId
* @param type
* @param parentType
* @returns
*/
async getWflRelations(wflObject, childId, type = "Contained", parentType = "Dossier") {
let result = [];
for (let relIdx in wflObject.Relations) {
const relation = wflObject.Relations[relIdx];
if (relation.Child === childId && relation.Type.toLowerCase() === type.toLowerCase() && relation.ParentInfo.Type.toLowerCase() === parentType.toLowerCase()) {
result.push(relation);
}
}
return result;
}
// /**
// *
// * @param {string} bucket
// * @param {string} key
// *
// * @returns {Promise<object>}
// */
// async getDigitalArticle = async(bucket : string, key : string) : Promise<object> => {
// const s3client = new S3Client({});
// const response = await s3client.send(new GetObjectCommand(
// {
// Bucket: bucket,
// Key: key
// }
// ));
// if (!response.ETag) {
// throw new Error('Error getting digital article from bucket.');
// }
// return response;
// }
/**
*
* @param url
* @returns
*/
async downloadFile(url, query) {
if (query === void 0) {
query = new URLSearchParams();
}
query.append("ticket", await this.getTicket());
const buffer = await this._httpClient.downloadFile(url, query);
return buffer;
}
/**
* @inheritdoc
*/
async uploadFile(body, contentType, size) {
if (this._studioBaseUrl === "") {
throw new ClientError("No studio base url set");
}
const url = await this._httpClient.uploadFile(body, size, contentType, await this.getTicket(), this._studioBaseUrl);
return url;
}
/**
*
* @param objectIds
* @param rendition
* @param requestInfo
* @param lock
* @param areas
* @returns
*/
async getObjects(objectIds, rendition = "native", requestInfo = ["MetaData"], lock = false, areas = ["Workflow"]) {
const query = this._getCommonQueryParameters();
query.append("ObjectIds", objectIds.join(","));
query.append("RequestInfo", requestInfo.join(","));
query.append("Rendition", rendition);
const response = await this._httpClient.request("get", "objects", query);
return response;
}
async createObjects(wflObjects, lock = false) {
const body = {
WflObjects: wflObjects,
RequestId: this._generateRequestId(),
ConfigurationId: this.configurationId,
Lock: lock
};
const response = await this._httpClient.request("post", "objects", void 0, body);
return response;
}
/**
*
* @param parentIdOrInstance
* @param childIdsOrInstances
* @param type
* @returns
*/
async createObjectRelations(parentIdOrInstance, childIdsOrInstances, type = "Contained" /* Contained */) {
const parentId = this._getObjectId(parentIdOrInstance);
const childIds = [];
for (const childIdOrInstance of childIdsOrInstances) {
const childId = this._getObjectId(childIdOrInstance);
childIds.push(childId);
}
let relations = [];
for (const childId of childIds) {
relations.push(new Relation({
Parent: parentId,
Child: childId,
Type: type
}));
}
const body = {
RequestId: this._generateRequestId(),
Relations: relations,
ConfigurationId: this.configurationId
};
const response = await this._httpClient.request("post", "objectrelations", void 0, body);
return response;
}
/**
*
* @param childIdsOrInstances
* @param permanent
* @param areas
* @returns
*/
async deleteObjects(childIdsOrInstances, permanent = false, areas = "Workflow") {
const ids = [];
for (const childIdOrInstance of childIdsOrInstances) {
const childId = this._getObjectId(childIdOrInstance);
ids.push(childId);
}
const query = this._getCommonQueryParameters();
query.append("ObjectIds", ids.join(","));
query.append("Permanent", "");
query.append("Areas", areas);
query.append("RequestId", this._generateRequestId());
query.append("ConfigurationId", this.configurationId);
const response = await this._httpClient.request("delete", "objects", query);
return response;
}
/**
*
* @param action Workflow Action type.
* @param context v10.40 Can be used to provide relevant information based on the dialog circumstances.
* @param metaData v8.0: MetaData value allows client app to round trip the data.
* @param targets v8.0: Object's targets. Data contained in Targets allow client app to round trip the data.
* @param defaultDossier v7.0: Dossier ID: Request to populate the Dossier property.
* The given Publication and Issue are used to get dossiers (to choose from). If no Issue specified,
* first one is taken. The dossier ID will be used to set the default value at Dossier property.
* If DefaultDossier is nil (or left out) no dossier property nor dossiers will be returned.
* @param parent v7.0: Parent ID: When creating objects that are placed (such as creating articles form layout) the client
* knows that the object will be placed, but the server does not know yet. For placed objects,
* the dialog has some fields disabled (greyed) like Publication/Brand, Issue and Category. Nil (or left out)
* means object is not placed.
* @param template v7.0: Template ID : When creating objects, some properties should be taken from a template.
* Those should be pre-filled in for the new object at the Create workflow dialog. Provide the object ID of
* the template (that was picked by user) to let server pre-fill properties. Nil (or left out) means object
* is not created from template.
* @param areas v8.0: Area to search for the object. Nil means 'workflow' area only (for backwards compatibility reasons).
* @param multipleObjects v9.2: Indicate if the dialog is for multiple objects or single object.
* Nil means 'false' (for backwards compatibility reasons).
* @returns
*/
async getDialog2(action, context, metaData, targets, defaultDossier, parent, template, areas, multipleObjects) {
const body = {
RequestId: this._generateRequestId(),
ConfigurationId: this.configurationId,
Action: action
};
if (context) {
body["Context"] = context;
}
if (metaData) {
body["Metadata"] = metaData;
}
if (targets) {
body["Targets"] = targets;
}
if (defaultDossier) {
body["DefaultDossier"] = defaultDossier;
}
if (parent) {
body["Parent"] = parent;
}
if (template) {
body["Template"] = template;
}
if (areas) {
body["Areas"] = areas;
}
if (multipleObjects) {
body["MultipleObjects"] = multipleObjects;
}
const response = await this._httpClient.request("post", "dialog", void 0, body);
return response;
}
/**
*
* @param ids The brand id(s)
* @param requestInfo What elements to retrieve. "PubChannels","States", "Categories"
* @param requestId
* @param configurationId
* @returns
*/
async getPublicationsInt(ids, requestInfo, requestId, configurationId) {
if (requestInfo === void 0) {
requestInfo = [];
}
if (requestId === void 0) {
requestId = this._generateRequestId();
}
console.log(`QqAwsServiceStudioClientClient::getPublications: ids=[${ids.join(",")}], requestInfo=[${requestInfo.join(", ")}], requestId=[${requestId}]`);
if (configurationId === void 0) {
configurationId = this.configurationId;
}
const query = this._getCommonQueryParameters(configurationId);
query.append("Ids", ids.join(","));
query.append("RequestInfo", requestInfo.join(", "));
const result = await this._httpClient.request("GET", "publications", query);
return result;
}
/**
* Add the ConfigurationId and RequestId to the query
*
*
* @param configurationId Overrule the configurationId when required.
* @returns
*/
_getCommonQueryParameters(configurationId) {
if (configurationId === void 0) {
configurationId = this.configurationId;
}
const query = new URLSearchParams({
ConfigurationId: configurationId,
RequestId: this._generateRequestId()
});
return query;
}
/**
* Get the parentId from the iddOrInstance
*
* @param iddOrInstance
* @returns The object id
* @throws ClientError when the id cannot be determined
*/
_getObjectId(idOrInstance) {
if (idOrInstance instanceof WflObject || typeof idOrInstance === "object" && "__classname__" in idOrInstance && idOrInstance["__classname__"] === "Object") {
const id = idOrInstance.MetaData?.BasicMetaData?.ID;
if (id === void 0 || id === null) {
throw new ClientError(`childId is undefined`);
}
return id;
} else {
return idOrInstance;
}
}
_sanitizeUrl(url) {
return url.replace(/\/$/, "");
}
_generateRequestId() {
return uuidv42();
}
};
// src/client/client-option-error.ts
var ClientOptionError = class _ClientOptionError extends Error {
constructor(message, optionName, error) {
super(_ClientOptionError.buildMessage(message, optionName, error));
this.optionName = optionName;
this.name = "ClientOptionError";
}
static buildMessage(message, optionName, error) {
return `${message} (Option '${optionName}')`;
}
};
// src/client/client-options.ts
var ClientOptions = class {
constructor() {
// -------------------- baseUrl --------------------
this._baseUrl = null;
// -------------------- apiKey --------------------
this._apiKey = null;
}
/**
*
* @throws QqAwsServiceStudioClientClientError When the baseurl is not set
*/
get baseUrl() {
if (this._baseUrl === null) {
throw new ClientOptionError("Option not set", "baseUrl");
}
;
return this._baseUrl;
}
setBaseUrl(value) {
this._baseUrl = value.replace(/\/$/, "");
return this;
}
/**
* @returns The apiKey
* @throws QqAwsServiceStudioClientClientError When the apiKey is not set
*/
get apiKey() {
if (this._apiKey === null) {
throw new ClientOptionError("Option not set", "apiKey");
}
;
return this._apiKey;
}
/**
*
* @param value The API key
* @returns
*/
setApiKey(value) {
this._apiKey = value;
return this;
}
};
// src/model/wfl/attachment.ts
var Attachment = class {
constructor(params) {
this.__classname__ = "Attachment";
this.Rendition = null;
this.Type = null;
this.Content = null;
this.FilePath = null;
this.FileUrl = null;
this.EditionId = null;
this.ContentSourceFileLink = null;
this.ContentSourceProxyLink = null;
this.Rendition = params.Rendition ?? null;
this.Type = params.Type ?? null;
this.Content = params.Content ?? null;
this.FilePath = params.FilePath ?? null;
this.FileUrl = params.FileUrl ?? null;
this.EditionId = params.EditionId ?? null;
this.ContentSourceFileLink = params.ContentSourceFileLink ?? null;
this.ContentSourceProxyLink = params.ContentSourceProxyLink ?? null;
}
};
// src/model/wfl/content-metadata.ts
var ContentMetaData = class {
constructor(params) {
this.__classname__ = "ContentMetaData";
this.Description = null;
this.DescriptionAuthor = null;
this.Keywords = null;
this.Slugline = null;
this.Format = null;
this.Columns = null;
this.Width = null;
this.Height = null;
this.Dpi = null;
this.LengthWords = null;
this.LengthChars = null;
this.LengthParas = null;
this.LengthLines = null;
this.PlainContent = null;
this.FileSize = null;
this.ColorSpace = null;
this.HighResFile = null;
this.Encoding = null;
this.Compression = null;
this.KeyFrameEveryFrames = null;
this.Channels = null;
this.AspectRatio = null;
this.Orientation = null;
this.Dimensions = null;
this.Description = params.Description ?? null;
this.DescriptionAuthor = params.DescriptionAuthor ?? null;
this.Keywords = params.Keywords ?? null;
this.Slugline = params.Slugline ?? null;
this.Format = params.Format ?? null;
this.Columns = params.Columns ?? null;
this.Width = params.Width ?? null;
this.Height = params.Height ?? null;
this.Dpi = params.Dpi ?? null;
this.LengthWords = params.LengthWords ?? null;
this.LengthChars = params.LengthChars ?? null;
this.LengthParas = params.LengthParas ?? null;
this.LengthLines = params.LengthLines ?? null;
this.PlainContent = params.PlainContent ?? null;
this.FileSize = params.FileSize ?? null;
this.ColorSpace = params.ColorSpace ?? null;
this.HighResFile = params.HighResFile ?? null;
this.Encoding = params.Encoding ?? null;
this.Compression = params.Compression ?? null;
this.KeyFrameEveryFrames = params.KeyFrameEveryFrames ?? null;
this.Channels = params.Channels ?? null;
this.AspectRatio = params.AspectRatio ?? null;
this.Orientation = params.Orientation ?? null;
this.Dimensions = params.Dimensions ?? null;
}
};
// src/model/wfl/edition-renditions-info.ts
var EditionRenditionsInfo = class {
constructor($Edition = null, $Renditions = null) {
this.__classname__ = "EditionRenditionsInfo";
this.$Edition = null;
this.$Renditions = null;
this.$Edition = $Edition;
this.$Renditions = $Renditions;
}
};
// src/model/wfl/edition.ts
var Edition = class {
constructor(Id = null, Name = null) {
this.__classname__ = "Edition";
this.Id = null;
this.Name = null;
this.Id = Id;
this.Name = Name;
}
};
// src/model/wfl/element.ts
var Element = class {
constructor(ID = null, Name = null, LengthWords = null, LengthChars = null, LengthParas = null, LengthLines = null, Snippet = null, Version = null, Content = null) {
this.__classname__ = "Element";
this.ID = null;
this.Name = null;
this.LengthWords = null;
this.LengthChars = null;
this.LengthParas = null;
this.LengthLines = null;
this.Snippet = null;
this.Version = null;
this.Content = null;
this.ID = ID;
this.Name = Name;
this.LengthWords = LengthWords;
this.LengthChars = LengthChars;
this.LengthParas = LengthParas;
this.LengthLines = LengthLines;
this.Snippet = Snippet;
this.Version = Version;
this.Content = Content;
}
};
// src/model/wfl/extra-metadata.ts
var ExtraMetaData = class {
constructor(params) {
this.__classname__ = "ExtraMetaData";
this.Property = null;
this.Values = null;
this.Property = params.Property ?? null;
this.Values = params.Values ?? null;
}
};
// src/model/wfl/indesign-article.ts
var InDesignArticle = class {
constructor(Id = null, Name = null, SplineIDs = null) {
this.__classname__ = "InDesignArticle";
this.Id = null;
this.Name = null;
this.SplineIDs = null;
this.Id = Id;
this.Name = Name;
this.SplineIDs = SplineIDs;
}
};
// src/model/wfl/issue.ts
var Issue = class {
constructor(Id = null, NameId = null, OverrulePublicationId = null) {
this.__classname__ = "Issue";
this.Id = null;
this.NameId = null;
this.OverrulePublicationId = null;
this.Id = Id;
this.NameId = NameId;
this.OverrulePublicationId = OverrulePublicationId;
}
};
// src/model/wfl/message-list.ts
var MessageList = class {
constructor(Messages = null, ReadMessageIDs = null, DeleteMessageIDs = null) {
this.__classname__ = "MessageList";
this.Messages = null;
this.ReadMessageIDs = null;
this.DeleteMessageIDs = null;
this.Messages = Messages;
this.ReadMessageIDs = ReadMessageIDs;
this.DeleteMessageIDs = DeleteMessageIDs;
}
};
// src/model/wfl/message.ts
var Message = class {
constructor(ObjectID = null, UserID = null, MessageID = null, MessageType = null, MessageTypeDetail = null, Message2 = null, TimeStamp = null, Expiration = null, MessageLevel = null, FromUser = null, StickyInfo2 = null, ThreadMessageID = null, ReplyToMessageID = null, MessageStatus = null, ObjectVersion = null) {
this.__classname__ = "Message";
this.ObjectID = null;
this.UserID = null;
this.MessageID = null;
this.MessageType = null;
this.MessageTypeDetail = null;
this.Message = null;
this.TimeStamp = null;
this.Expiration = null;
this.MessageLevel = null;
this.FromUser = null;
this.StickyInfo = null;
this.ThreadMessageID = null;
this.ReplyToMessageID = null;
this.MessageStatus = null;
this.ObjectVersion = null;
this.ObjectID = ObjectID;
this.UserID = UserID;
this.MessageID = MessageID;
this.MessageType = MessageType;
this.MessageTypeDetail = MessageTypeDetail;
this.Message = Message2;
this.TimeStamp = TimeStamp;
this.Expiration = Expiration;
this.MessageLevel = MessageLevel;
this.FromUser = FromUser;
this.StickyInfo = StickyInfo2;
this.ThreadMessageID = ThreadMessageID;
this.ReplyToMessageID = ReplyToMessageID;
this.MessageStatus = MessageStatus;
this.ObjectVersion = ObjectVersion;
}
};
// src/model/wfl/metadata-value.ts
var MetaDataValue = class {
constructor(params) {
this.__classname__ = "MetaDataValue";
this.Property = params.Property;
this.Values = params.Values ?? null;
this.PropertyValues = params.PropertyValues ?? null;
}
};
// src/model/wfl/object-info.ts
var ObjectInfo = class {
constructor(ID = null, Name = null, Type = null, Format = null) {
this.__classname__ = "ObjectInfo";
this.ID = null;
this.Name = null;
this.Type = null;
this.Format = null;
this.ID = ID;
this.Name = Name;
this.Type = Type;
this.Format = Format;
}
};
// src/model/wfl/object-label.ts
var ObjectLabel = class {
constructor(Id = null, Name = null) {
this.__classname__ = "ObjectLabel";
this.Id = null;
this.Name = null;
this.Id = Id;
this.Name = Name;
}
};
// src/model/wfl/object-operations.ts
var ObjectOperation = class {
constructor(Id = null, Name = null, Type = null, Params = null) {
this.__classname__ = "ObjectOperation";
this.Id = null;
this.Name = null;
this.Type = null;
this.Params = null;
this.Id = Id;
this.Name = Name;
this.Type = Type;
this.Params = Params;
}
};
// src/model/wfl/page.ts
var Page = class {
constructor(Width = null, Height = null, PageNumber = null, PageOrder = null, Files = null, Edition2 = null, Master = null, Instance = null, PageSequence = null, Renditions = null, Orientation = null) {
this.__classname__ = "Page";
this.Width = null;
this.Height = null;
this.PageNumber = null;
this.PageOrder = null;
this.Files = null;
this.Edition = null;
this.Master = null;
this.Instance = null;
this.PageSequence = null;
this.Renditions = null;
this.Orientation = null;
this.Width = Width;
this.Height = Height;
this.PageNumber = PageNumber;
this.PageOrder = PageOrder;
this.Files = Files;
this.Edition = Edition2;
this.Master = Master;
this.Instance = Instance;
this.PageSequence = PageSequence;
this.Renditions = Renditions;
this.Orientation = Orientation;
}
};
// src/model/wfl/param.ts
var Param = class {
constructor(Name = null, Value = null) {
this.__classname__ = "Param";
this.Name = null;
this.Value = null;
this.Name = Name;
this.Value = Value;
}
};
// src/model/wfl/placement.ts
var Placement = class {
constructor(Id = null, Left = null, Top = null, Width = null, Height = null) {
this.__classname__ = "Placement";
this.Id = null;
this.Left = null;
this.Top = null;
this.Width = null;
this.Height = null;
this.Id = Id;
this.Left = Left;
this.Top = Top;
this.Width = Width;
this.Height = Height;
}
};
// src/model/wfl/property-value.ts
var PropertyValue = class {
constructor(params) {
this.__classname__ = "PropertyValue";
this.Value = params.Value;
this.Display = params.Display ?? null;
this.Entity = params.Entity ?? null;
}
};
// src/model/wfl/pub-channel.ts
var PubChannel = class {
constructor(Id = null, Name = null) {
this.__classname__ = "PubChannel";
this.Id = null;
this.Name = null;
this.Id = Id;
this.Name = Name;
}
};
// src/model/wfl/rendition-type-info.ts
var RenditionTypeInfo = class {
constructor(Rendition = null, Type = null) {
this.__classname__ = "RenditionTypeInfo";
this.Rendition = null;
this.Type = null;
this.Rendition = Rendition;
this.Type = Type;
}
};
// src/model/wfl/rights-metadata.ts
var RightsMetaData = class {
constructor(params) {
this.__classname__ = "RightsMetaData";
this.CopyrightMarked = null;
this.Copyright = null;
this.CopyrightURL = null;
this.CopyrightMarked = params.CopyrightMarked ?? null;
this.Copyright = params.Copyright ?? null;
this.CopyrightURL = params.CopyrightURL ?? null;
}
};
// src/model/wfl/source-metadata.ts
var SourceMetaData = class {
constructor(params) {
this.__classname__ = "SourceMetaData";
this.Credit = null;
this.Source = null;
this.Author = null;
this.Credit = params.Credit ?? null;
this.Source = params.Source ?? null;
this.Author = params.Author ?? null;
}
};
// src/model/wfl/sticky-info.ts
var StickyInfo = class {
constructor(AnchorX = null, AnchorY = null, Left = null, Top = null, Width = null, Height = null, Page2 = null, Version = null, Color = null, PageSequence = null) {
this.__classname__ = "StickyInfo";
this.AnchorX = null;
this.AnchorY = null;
this.Left = null;
this.Top = null;
this.Width = null;
this.Height = null;
this.Page = null;
this.Version = null;
this.Color = null;
this.PageSequence = null;
this.AnchorX = AnchorX;
this.AnchorY = AnchorY;
this.Left = Left;
this.Top = Top;
this.Width = Width;
this.Height = Height;
this.Page = Page2;
this.Version = Version;
this.Color = Color;
this.PageSequence = PageSequence;
}
};
// src/model/wfl/target.ts
var Target = class {
constructor(params) {
this.__classname__ = "Target";
this.PubChannel = null;
this.Issue = null;
this.Editions = null;
/**
* @deprecated DISCONTINUED since 10.12
*/
this.PublishedDate = null;
/**
* @deprecated DISCONTINUED since 10.12
*/
this.PublishedVersion = null;
this.PubChannel = params.PubChannel;
this.Issue = params.Issue ?? null;
this.Editions = params.Editions ?? null;
}
};
export {
ArgumentError,
Attachment,
BasicMetaData,
Category,
Client,
ClientError,
ClientOptionError,
ClientOptions,
ContentMetaData,
Edition,
EditionRenditionsInfo,
Element,
ExtraMetaData,
HttpClient,
HttpError,
HttpResponseError,
InDesignArticle,
Issue,
Message,
MessageList,
MetaData,
MetaDataValue,
ObjectInfo,
ObjectLabel,
ObjectOperation,
Page,
Param,
Placement,
PropertyValue,
PubChannel,
Publication,
Relation,
RelationType,
RenditionTypeInfo,
RightsMetaData,
SourceMetaData,
State,
StickyInfo,
Target,
WflHelpers,
WflObject,
WorkflowMetaData
};
//# sourceMappingURL=index.mjs.map