Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as helpers from './utils/helpers.js';
import * as netsuite from './utils/netsuite.js';
import * as sftp from './utils/sftp.js';
export { helpers, netsuite, sftp };
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
"version": "0.3.0",
"description": "Utilities to be used in Pipedream as NPM dependencies",
"main": "index.js",
"types": "index.d.ts",
"files": [
"utils",
"!utils/*.test.js"
],
"scripts": {
"test": "node --test",
"lint": "npx eslint .",
"type-check": "tsc",
"type-check": "tsc --noEmit",
"format": "prettier --write \"**/*.js\"",
"format-check": "prettier --check \"**/*.js\""
"format-check": "prettier --check \"**/*.js\"",
"generate-types": "tsc --allowJs --declaration --emitDeclarationOnly --outDir ."
},
"repository": {
"type": "git",
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"baseUrl": ".",
"allowJs": true,
"checkJs": true,
"noEmit": true,
"strict": false,

"lib": ["ES2021", "DOM"],
Expand All @@ -14,4 +13,3 @@
"include": ["**/*.js"],
"exclude": ["node_modules"]
}

19 changes: 19 additions & 0 deletions utils/helpers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Returns a Date object with the end_of_month.beginning_of_day from a Date Time
* @param {Date | string} date
* @return {Date}
*/
export function lastDay(date: Date | string): Date;
/**
* Normalize strings
* @param {string | undefined} v
* @returns {string}
*/
export function normalizeString(v: string | undefined): string;
/**
* Check if string starts with a prefix
* @param {string} val
* @param {string} prefix
* @returns {boolean}
*/
export function startsWith(val: string, prefix: string): boolean;
1 change: 1 addition & 0 deletions utils/helpers.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
46 changes: 46 additions & 0 deletions utils/netsuite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Represents the NetSuite OAuth configuration.
* @typedef {import('netsuite-api-client').NetsuiteOptions} Config
*/
/**
* Options for a NetSuite request. See https://github.com/julbrs/netsuite-api-client/blob/main/src/types.ts
* @typedef {import('netsuite-api-client').NetsuiteRequestOptions} Options - Request options
*/
/**
* Gets the portion of the URL starting with '/record'. Used to obtain a GET query path from the "location" response
* header on a NetSuite POST request.
* @param {string | string[]} url
* @returns {string}
*/
export function getRecordPath(url: string | string[]): string;
/**
* Send a request to NetSuite
* @param {Options} options - Request options
* @param {Config} config - NetSuite configuration
* @returns {Promise<import('netsuite-api-client').NetsuiteResponse>}
*/
export function request(options: Options, config: Config): Promise<import("netsuite-api-client").NetsuiteResponse>;
/**
* Run a SuiteQL query to get a specific (single) NetSuite record.
* @param {string} query - SuiteQL Query
* @param {Config} config - NetSuite configuration
* @returns {Promise<any>}
*/
export function queryRecord(query: string, config: Config): Promise<any>;
/**
* Run a SuiteQL query against NetSuite records.
* @param {string} query - SuiteQL Query
* @param {Config} config - NetSuite configuration
* @param {?Number} timeout - The timeout in seconds
* @param {Number} timeoutRecords - The maximum number of records to return before timing out
* @returns {Promise<Array>}
*/
export function queryRecords(query: string, config: Config, timeout?: number | null, timeoutRecords?: number): Promise<any[]>;
/**
* Represents the NetSuite OAuth configuration.
*/
export type Config = import("netsuite-api-client").NetsuiteOptions;
/**
* - Request options
*/
export type Options = import("netsuite-api-client").NetsuiteRequestOptions;
1 change: 1 addition & 0 deletions utils/netsuite.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
30 changes: 30 additions & 0 deletions utils/sftp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @typedef {Object} SftpConfig
* @property {string} host
* @property {string} username
* @property {string} privateKey
*/
/**
* @typedef {Object} SftpResponse
* @property {string} message
* @property {string} error
* @property {boolean} successful
*/
/**
* Moves a file by its path to a new destination on an SFTP host. Returns an error or success message.
* @param {string} filePath - The path to the local file to upload
* @param {string} dest - The path to the destination file on the remote server including the new name
* @param {SftpConfig} sftpConfig - SFTP authentication details
* @returns {Promise<SftpResponse>} - { message: string, error: string, successful: boolean }
*/
export function renameSftpFile(filePath: string, dest: string, sftpConfig: SftpConfig): Promise<SftpResponse>;
export type SftpConfig = {
host: string;
username: string;
privateKey: string;
};
export type SftpResponse = {
message: string;
error: string;
successful: boolean;
};