From 8b058350fcee09e40734a18f3a30782a592bc8d4 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah Date: Wed, 13 Aug 2025 11:10:53 +0800 Subject: [PATCH] fix: update types file --- types.d.ts | 316 +++++++++++++++++++++++++++-------------------------- 1 file changed, 161 insertions(+), 155 deletions(-) diff --git a/types.d.ts b/types.d.ts index 704cb8cf..7972ef06 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,6 +1,93 @@ +/** + * Log Forwarding management API + */ +declare class LogForwarding { + /** + * Get current Log Forwarding settings + * @returns response from get API + */ + get(): Promise; + /** + * Set Log Forwarding to Adobe I/O Runtime (default behavior) + * @returns response from set API + */ + setAdobeIoRuntime(): Promise; + /** + * Set Log Forwarding to Azure Log Analytics + * @param customerId - customer ID + * @param sharedKey - shared key + * @param logType - log type + * @returns response from set API + */ + setAzureLogAnalytics(customerId: string, sharedKey: string, logType: string): Promise; + /** + * Set Log Forwarding to Splunk HEC + * @param host - host + * @param port - port + * @param index - index + * @param hecToken - hec token + * @returns response from set API + */ + setSplunkHec(host: string, port: string, index: string, hecToken: string): Promise; + /** + * Get supported destinations + * @returns in format: { value: , name: } + */ + getSupportedDestinations(): object[]; + /** + * Get destination settings + * @param destination - Destination name + * @returns in format: { name: , message: [, type: ] } + */ + getDestinationSettings(destination: string): object[]; + /** + * Configure destination + * @param destination - Destination name + * @param config - value-pairs of settings, specific to the destination + * @returns response from set API + */ + setDestination(destination: string, config: any): Promise; + /** + * Get log forwarding errors + * @returns Errors in format { destination: '', errors: [] } + */ + getErrors(): any; +} + +/** + * Log Forwarding destination provider + */ +declare class LogForwardingLocalDestinationsProvider { + /** + * Get supported destinations + * @returns in format: { value: , name: } + */ + getSupportedDestinations(): object[]; + /** + * Get destination settings + * @param destination - Destination name + * @returns in format: { name: , message: [, type: ] } + */ + getDestinationSettings(destination: string): object[]; +} + +/** + * This class provides methods to call your RuntimeAPI APIs. + * Before calling any method initialize the instance by calling the `init` method on it + * with valid options argument + */ +declare class RuntimeAPI { + /** + * Initializes a RuntimeAPI object and returns it. + * @param options - options for initialization + * @returns a RuntimeAPI object + */ + init(options: OpenwhiskOptions): Promise; +} + /** * Searches for a webpack config file, starting at the action path and working - towards the root of the project. Will return the first one it finds. + * towards the root of the project. Will return the first one it finds. * @param actionPath - Path of the action * @param root - Root of the project * @returns Webpack config file path, will be 'null' if not found @@ -9,7 +96,7 @@ declare function getWebpackConfigPath(actionPath: string, root: string): Promise /** * Loads a Webpack config file from the config path provided. Sets fields required - for Runtime actions. Returns an object that can be passed to the Webpack library. + * for Runtime actions. Returns an object that can be passed to the Webpack library. * @param configPath - Path of the Webpack config file * @param actionPath - Path of the action * @param tempBuildDir - Path of the output directory for the bundle @@ -46,8 +133,8 @@ declare function prepareToBuildAction(action: any, root: string, dist: string): /** * Will zip actions. - By default only actions which were not built before will be zipped. - Last built actions data will be used to validate which action needs zipping. + * By default only actions which were not built before will be zipped. + * Last built actions data will be used to validate which action needs zipping. * @param buildsList - Array of data about actions available to be zipped. * @param lastBuildsPath - Path to the last built actions data. * @param distFolder - Path to the output root. @@ -56,35 +143,41 @@ declare function prepareToBuildAction(action: any, root: string, dist: string): declare function zipActions(buildsList: ActionBuild[], lastBuildsPath: string, distFolder: string): string[]; /** - * runs the command + * @property [actions] - filter list of actions to deploy by provided array, e.g. ['name1', ..] + * @property [byBuiltActions] - if true, trim actions from the manifest based on the already built actions + * @property [sequences] - filter list of sequences to deploy, e.g. ['name1', ..] + * @property [triggers] - filter list of triggers to deploy, e.g. ['name1', ..] + * @property [rules] - filter list of rules to deploy, e.g. ['name1', ..] + * @property [apis] - filter list of apis to deploy, e.g. ['name1', ..] + * @property [dependencies] - filter list of package dependencies to deploy, e.g. ['name1', ..] + */ +declare type FilterEntities = { + actions?: any[]; + byBuiltActions?: boolean; + sequences?: any[]; + triggers?: any[]; + rules?: any[]; + apis?: any[]; + dependencies?: any[]; +}; + +/** + * @property [filterEntities] - add filters to deploy only specified OpenWhisk entities + * @property [useForce] - force deploy of actions + */ +declare type DeployConfig = { + filterEntities?: FilterEntities; + useForce?: boolean; +}; + +/** + * Runs the command * @param config - app config * @param [deployConfig] - deployment config - * @param [deployConfig.isLocalDev] - local dev flag // todo: remove - * @param [deployConfig.filterEntities] - add filters to deploy only specified OpenWhisk entities - * @param [deployConfig.filterEntities.actions] - filter list of actions to deploy by provided array, e.g. ['name1', ..] - * @param [deployConfig.filterEntities.byBuiltActions] - if true, trim actions from the manifest based on the already built actions - * @param [deployConfig.filterEntities.sequences] - filter list of sequences to deploy, e.g. ['name1', ..] - * @param [deployConfig.filterEntities.triggers] - filter list of triggers to deploy, e.g. ['name1', ..] - * @param [deployConfig.filterEntities.rules] - filter list of rules to deploy, e.g. ['name1', ..] - * @param [deployConfig.filterEntities.apis] - filter list of apis to deploy, e.g. ['name1', ..] - * @param [deployConfig.filterEntities.dependencies] - filter list of package dependencies to deploy, e.g. ['name1', ..] - * @param [deployConfig.useForce] - force deploy of actions * @param [logFunc] - custom logger function * @returns deployedEntities */ -declare function deployActions(config: any, deployConfig?: { - isLocalDev?: boolean; - filterEntities?: { - actions?: any[]; - byBuiltActions?: boolean; - sequences?: any[]; - triggers?: any[]; - rules?: any[]; - apis?: any[]; - dependencies?: any[]; - }; - useForce?: boolean; -}, logFunc?: any): Promise; +declare function deployActions(config: any, deployConfig?: DeployConfig, logFunc?: any): Promise; /** * @param scriptConfig - config @@ -103,89 +196,16 @@ declare function deployWsk(scriptConfig: any, manifestContent: any, logFunc: any */ declare function init(options: OpenwhiskOptions): Promise; -/** - * Log Forwarding management API - */ -declare class LogForwarding { - /** - * Get current Log Forwarding settings - * @returns response from get API - */ - get(): Promise; - /** - * Set Log Forwarding to Adobe I/O Runtime (default behavior) - * @returns response from set API - */ - setAdobeIoRuntime(): Promise; - /** - * Set Log Forwarding to Azure Log Analytics - * @param customerId - customer ID - * @param sharedKey - shared key - * @param logType - log type - * @returns response from set API - */ - setAzureLogAnalytics(customerId: string, sharedKey: string, logType: string): Promise; - /** - * Set Log Forwarding to Splunk HEC - * @param host - host - * @param port - port - * @param index - index - * @param hecToken - hec token - * @returns response from set API - */ - setSplunkHec(host: string, port: string, index: string, hecToken: string): Promise; - /** - * Get supported destinations - * @returns in format: { value: , name: } - */ - getSupportedDestinations(): object[]; - /** - * Get destination settings - * @param destination - Destination name - * @returns in format: { name: , message: [, type: ] } - */ - getDestinationSettings(destination: string): object[]; - /** - * Configure destination - * @param destination - Destination name - * @param config - value-pairs of settings, specific to the destination - * @returns response from set API - */ - setDestination(destination: string, config: any): Promise; - /** - * Get log forwarding errors - * @returns Errors in format { destination: '', errors: [] } - */ - getErrors(): any; -} - -/** - * Log Forwarding destination provider - */ -declare class LogForwardingLocalDestinationsProvider { - /** - * Get supported destinations - * @returns in format: { value: , name: } - */ - getSupportedDestinations(): object[]; - /** - * Get destination settings - * @param destination - Destination name - * @returns in format: { name: , message: [, type: ] } - */ - getDestinationSettings(destination: string): object[]; -} - /** * Prints action logs. * @param config - openwhisk config * @param logger - an instance of a logger to emit messages to * @param limit - maximum number of activations to fetch logs from * @param filterActions - array of actions to fetch logs from - examples:- - ['pkg1/'] = logs of all deployed actions under package pkg1 - ['pkg1/action'] = logs of action 'action' under package 'pkg1' - [] = logs of all actions in the namespace + * examples:- + * ['pkg1/'] = logs of all deployed actions under package pkg1 + * ['pkg1/action'] = logs of action 'action' under package 'pkg1' + * [] = logs of all actions in the namespace * @param strip - if true, strips the timestamp which prefixes every log line * @param tail - if true, logs are fetched continuously * @param fetchLogsInterval - number of seconds to wait before fetching logs again when tail is set to true @@ -194,20 +214,6 @@ declare class LogForwardingLocalDestinationsProvider { */ declare function printActionLogs(config: any, logger: any, limit: number, filterActions: any[], strip: boolean, tail: boolean, fetchLogsInterval?: number, startTime: number): any; -/** - * This class provides methods to call your RuntimeAPI APIs. -Before calling any method initialize the instance by calling the `init` method on it -with valid options argument - */ -declare class RuntimeAPI { - /** - * Initializes a RuntimeAPI object and returns it. - * @param options - options for initialization - * @returns a RuntimeAPI object - */ - init(options: OpenwhiskOptions): Promise; -} - /** * A class to manage triggers */ @@ -294,7 +300,7 @@ declare function undeployWsk(packageName: string, manifestContent: any, owOption /** * The entry point to the information read from the manifest, this can be extracted using -[setPaths](#setpaths). + * [setPaths](#setpaths). */ declare type ManifestPackages = ManifestPackage[]; @@ -325,14 +331,14 @@ declare type ManifestPackage = { * @property [version] - the manifest action version * @property function - the path to the action code * @property runtime - the runtime environment or kind in which the action - executes, e.g. 'nodejs:18' + * executes, e.g. 'nodejs:18' * @property [main] - the entry point to the function * @property [inputs] - the list of action default parameters * @property [limits] - limits for the action * @property [web] - indicate if an action should be exported as web, can take the - value of: true | false | yes | no | raw + * value of: true | false | yes | no | raw * @property [raw-http] - indicate if an action should be exported as raw web action, this - option is only valid if `web` or `web-export` is set to true + * option is only valid if `web` or `web-export` is set to true * @property [docker] - the docker container to run the action into * @property [annotations] - the manifest action annotations */ @@ -367,7 +373,7 @@ declare function getIncludesForAction(action: ManifestAction): Promise