1.0.2 • Published 15 days ago

@opentext/otts-module-api v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
15 days ago

OTTS Module API

The purpose of this package is to provide application and component developers with convenient JavaScript-based APIs to integrate with OpenText LiveSite Content Services (LSCS) APIs and OpenText TeamSite Module datums (properties). Note: This module is only compatible with OpenText TeamSite 23.2 and later.

Prerequisites

  • Create or clone a JavaScript application/component project workspace (e.g., React, Angular, Vue, Vanilla JS, etc.)
  • OpenText TeamSite 23.2 or later

Installation

To install this package, run the following command in the root of your project:

> npm install otts-api

Setup

After installation, add the otts_module_api.js file to the root folder of your project. Copy this file to the appropriate third-party source folder. For example, for React projects, this is likely the /public folder. For Angular projects, it is likely the /src folder.

Usage

LCSC API values and Module Datum values are retrieved based on the environment in which your application/component is running. While testing in your local development environment, the package will retrieve LSCS content and Component Datum values from iw_module_stubs.js.

Note: iw_module_config.json must be present in the same directory as otts_module_api.js. Data spec and default values are loaded during bootstrap and before the main app launches.

Note: To ensure that local testing functions correctly, You must load this API script into the DOM AFTER iw_module_stubs.js.

API

All functions are static and accessible using the global iw variable.

iw.init() For applications/components that need control over when to initialize themselves.

iw.getPropertyValue(moduleId, datumId) Retrieves the datum/property value for the provided component and datum.

  • moduleId : string - The generated TeamSite module ID
  • datumId : string - The developer-defined datum/property ID

iw.queryLscs(api, params, callback, useStagingInAuthoring) Retrieves content from LSCS.

  • api : string - The LSCS API to use ("documents" or "documents-meta")
  • params : object - The developer-defined datum/property ID. For additional help, refer to the LSCS documentation.
  • callback : function - The callback function
  • useStagingInAuthoring : boolean - Whether or not to use Staging content in the Authoring environment (default is false)

iw.getProjects(callback) Retrieves the projects, to be used as an input for LSCS queries.

  • callback : function - The callback function

Sample usage (TypeScript)

const iw : any = window['iw'];

/*
 * to get datum/property values
 */

// a potential way of retrieving the module/app ID
const root = document.getElementById('root');
const id = root.dataset['appId'];
   
const myBooleanValue = iw.getPropertyValue(id, 'D001');
const mySelectedCheckBox = iw.getPropertyValue(id, 'D002').value;

/* 
 * to query LSCS
 */

// basic example wildcard query
let params = { 
	q: '*',
	includeDCRContent: true,
	format: 'json'
};
iw.queryLscs(api, params, (data) => {
	// callback function
});

// query with additional filters
let params = {
	q: 'ast_relative_path:*/' + searchQuery,
	project: selectedProject,
	includeDCRContent: true,
	format: 'json'
}
iw.queryLscs('documents', params, (data) => {
	// callback function
});
1.0.2

15 days ago

1.0.1

10 months ago

1.0.0

1 year ago