-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.ts
36 lines (32 loc) · 919 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import inquirer from "inquirer";
import {getRecord} from "./getRecord";
const allowedRecordTypes = ["salesorder", "transaction", "purchaseorder", "employee", "savedsearch"];
/**
* Prompts the user to select a record type and enter a record ID, and then fetches the record from Netsuite.
* @returns {Promise<void>}
*/
const main = async () => {
const answers = await inquirer.prompt([
{
type: "list",
name: "recordType",
message: "Select a record type:",
choices: allowedRecordTypes,
},
{
type: "input",
name: "recordId",
message: "Enter the record ID:",
validate: (input: string) => {
return input.trim() !== "" || "Record ID cannot be empty";
},
},
]);
try {
const recordData = await getRecord(answers.recordType, answers.recordId);
console.log(recordData);
} catch (error) {
console.error(error);
}
};
main();