@tolinax/ayoune-cli 2024.2.16 → 2024.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ const aYOUneModules = [
2
+ { label: "Artificial Intelligence", module: "ai" },
3
+ { label: "Asset store", module: "assetstore" },
4
+ { label: "Customer Relationship Management", module: "crm" },
5
+ { label: "Project management", module: "pm" },
6
+ { label: "Content management system", module: "cms" },
7
+ { label: "Marketing", module: "marketing" },
8
+ { label: "Automation", module: "automation" },
9
+ { label: "Sale", module: "sale" },
10
+ { label: "Product information management", module: "pim" },
11
+ { label: "Hub", module: "hub" },
12
+ { label: "Human Resources", module: "hr" },
13
+ { label: "Service Desk", module: "service" },
14
+ { label: "Purchase", module: "purchase" },
15
+ { label: "Accounting", module: "accounting" },
16
+ { label: "E Commerce", module: "ecommerce" },
17
+ { label: "Monitoring", module: "monitoring" },
18
+ { label: "Production", module: "production" },
19
+ { label: "Affiliate", module: "affiliate" },
20
+ { label: "Reporting", module: "reporting" },
21
+ { label: "Export", module: "export" },
22
+ { label: "Configuration", module: "config" },
23
+ { label: "Terminal", module: "terminal" },
24
+ ];
25
+ export default aYOUneModules;
26
+ export { aYOUneModules };
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
- #! /usr/bin/env node
2
- import { Command } from "commander";
3
- import { createSpinner } from "nanospinner";
4
- import { initializeSettings } from "./lib/helpers/initializeSettings.js";
5
- import { createProgram } from "./lib/commands/createProgram.js";
6
- //Create new command instance
7
- const program = new Command();
8
- initializeSettings();
9
- //Setup spinner
10
- export const spinner = createSpinner("Getting data...");
11
- createProgram(program);
1
+ #! /usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { createSpinner } from "nanospinner";
4
+ import { initializeSettings } from "./lib/helpers/initializeSettings.js";
5
+ import { createProgram } from "./lib/commands/createProgram.js";
6
+ //Create new command instance
7
+ const program = new Command();
8
+ initializeSettings();
9
+ //Setup spinner
10
+ export const spinner = createSpinner("Getting data...");
11
+ createProgram(program);
package/lib/api/login.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { socket } from "../socket/socketClient.js";
2
- import { randomAsciiString } from "@tolinax/ayoune-models/utils/makeRandomToken.js";
2
+ import { randomAsciiString } from "../helpers/makeRandomToken.js";
3
3
  import { spinner } from "../../index.js";
4
4
  import { localStorage } from "../helpers/localStorage.js";
5
5
  export const login = async () => {
@@ -1,30 +1,30 @@
1
- import { Argument } from "commander";
2
- import { localStorage } from "../helpers/localStorage.js";
3
- import { handleAuditOperation } from "../operations/handleAuditOperation.js";
4
- import { promptAudits } from "../prompts/promptAudits.js";
5
- import { handleSingleAuditOperation } from "../operations/handleSingleAuditOperation.js";
6
- import yaml from "js-yaml";
7
- export function createAuditCommand(program) {
8
- program
9
- .command("audit")
10
- .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
11
- .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
12
- .alias("history")
13
- .description("Get the history of <id> in <collection>")
14
- .action(async (collection, id, options) => {
15
- try {
16
- const opts = { ...program.opts(), ...options };
17
- const { data, content, result, meta } = await handleAuditOperation(collection, id, {
18
- ...opts,
19
- });
20
- const selectedAudit = await promptAudits(result);
21
- const { singleData, singleContent, singleResult, singleMeta } = await handleSingleAuditOperation(collection, id, selectedAudit, {
22
- ...opts,
23
- });
24
- console.log(yaml.dump(singleContent));
25
- }
26
- catch (e) {
27
- console.error(e);
28
- }
29
- });
30
- }
1
+ import { Argument } from "commander";
2
+ import { localStorage } from "../helpers/localStorage.js";
3
+ import { handleAuditOperation } from "../operations/handleAuditOperation.js";
4
+ import { promptAudits } from "../prompts/promptAudits.js";
5
+ import { handleSingleAuditOperation } from "../operations/handleSingleAuditOperation.js";
6
+ import yaml from "js-yaml";
7
+ export function createAuditCommand(program) {
8
+ program
9
+ .command("audit")
10
+ .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
11
+ .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
12
+ .alias("history")
13
+ .description("Get the history of <id> in <collection>")
14
+ .action(async (collection, id, options) => {
15
+ try {
16
+ const opts = { ...program.opts(), ...options };
17
+ const { data, content, result, meta } = await handleAuditOperation(collection, id, {
18
+ ...opts,
19
+ });
20
+ const selectedAudit = await promptAudits(result);
21
+ const { singleData, singleContent, singleResult, singleMeta } = await handleSingleAuditOperation(collection, id, selectedAudit, {
22
+ ...opts,
23
+ });
24
+ console.log(yaml.dump(singleContent));
25
+ }
26
+ catch (e) {
27
+ console.error(e);
28
+ }
29
+ });
30
+ }
@@ -1,24 +1,24 @@
1
- import { Argument } from "commander";
2
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
- import { handleCopySingleOperation } from "../operations/handleCopySingleOperation.js";
4
- import { localStorage } from "../helpers/localStorage.js";
5
- export function createCopyCommand(program) {
6
- program
7
- .command("copy")
8
- .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
9
- .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
10
- .alias("cp")
11
- .description("Copy entry with <id> in <collection>")
12
- .action(async (collection, id, options) => {
13
- try {
14
- const opts = { ...program.opts(), ...options };
15
- const module = getModuleFromCollection(collection);
16
- await handleCopySingleOperation(module.module, collection, id, {
17
- ...opts,
18
- });
19
- }
20
- catch (e) {
21
- console.error(e);
22
- }
23
- });
24
- }
1
+ import { Argument } from "commander";
2
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
+ import { handleCopySingleOperation } from "../operations/handleCopySingleOperation.js";
4
+ import { localStorage } from "../helpers/localStorage.js";
5
+ export function createCopyCommand(program) {
6
+ program
7
+ .command("copy")
8
+ .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
9
+ .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
10
+ .alias("cp")
11
+ .description("Copy entry with <id> in <collection>")
12
+ .action(async (collection, id, options) => {
13
+ try {
14
+ const opts = { ...program.opts(), ...options };
15
+ const module = getModuleFromCollection(collection);
16
+ await handleCopySingleOperation(module.module, collection, id, {
17
+ ...opts,
18
+ });
19
+ }
20
+ catch (e) {
21
+ console.error(e);
22
+ }
23
+ });
24
+ }
@@ -1,31 +1,31 @@
1
- import { Argument } from "commander";
2
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
- import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
4
- import { handleCreateSingleOperation } from "../operations/handleCreateSingleOperation.js";
5
- import { promptName } from "../prompts/promptName.js";
6
- import { localStorage } from "../helpers/localStorage.js";
7
- export function createCreateCommand(program) {
8
- program
9
- .command("create")
10
- .alias("c")
11
- .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
12
- .description("Create entry in <collection>")
13
- .action(async (collection, options) => {
14
- try {
15
- const opts = { ...program.opts(), ...options };
16
- if (!collection) {
17
- collection = await promptCollectionWithModule();
18
- }
19
- const module = getModuleFromCollection(collection);
20
- const name = await promptName();
21
- await handleCreateSingleOperation(module.module, collection, name, {
22
- ...opts,
23
- });
24
- localStorage.setItem("lastModule", module.module);
25
- localStorage.setItem("lastCollection", collection);
26
- }
27
- catch (e) {
28
- console.error(e);
29
- }
30
- });
31
- }
1
+ import { Argument } from "commander";
2
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
+ import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
4
+ import { handleCreateSingleOperation } from "../operations/handleCreateSingleOperation.js";
5
+ import { promptName } from "../prompts/promptName.js";
6
+ import { localStorage } from "../helpers/localStorage.js";
7
+ export function createCreateCommand(program) {
8
+ program
9
+ .command("create")
10
+ .alias("c")
11
+ .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
12
+ .description("Create entry in <collection>")
13
+ .action(async (collection, options) => {
14
+ try {
15
+ const opts = { ...program.opts(), ...options };
16
+ if (!collection) {
17
+ collection = await promptCollectionWithModule();
18
+ }
19
+ const module = getModuleFromCollection(collection);
20
+ const name = await promptName();
21
+ await handleCreateSingleOperation(module.module, collection, name, {
22
+ ...opts,
23
+ });
24
+ localStorage.setItem("lastModule", module.module);
25
+ localStorage.setItem("lastCollection", collection);
26
+ }
27
+ catch (e) {
28
+ console.error(e);
29
+ }
30
+ });
31
+ }
@@ -1,27 +1,27 @@
1
- import { Argument } from "commander";
2
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
- import { handleDescribeSingleOperation } from "../operations/handleDescribeSingleOperation.js";
4
- import { localStorage } from "../helpers/localStorage.js";
5
- export function createDescribeCommand(program) {
6
- program
7
- .command("describe")
8
- .alias("d")
9
- .description("Describe entry with <id> in <collection>")
10
- .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
11
- .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
12
- .action(async (collection, id, options) => {
13
- try {
14
- const opts = { ...program.opts(), ...options };
15
- const module = getModuleFromCollection(collection);
16
- localStorage.setItem("lastModule", module.module);
17
- localStorage.setItem("lastCollection", collection);
18
- localStorage.setItem("lastId", id);
19
- await handleDescribeSingleOperation(module.module, collection, id, {
20
- ...opts,
21
- });
22
- }
23
- catch (e) {
24
- console.error(e);
25
- }
26
- });
27
- }
1
+ import { Argument } from "commander";
2
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
+ import { handleDescribeSingleOperation } from "../operations/handleDescribeSingleOperation.js";
4
+ import { localStorage } from "../helpers/localStorage.js";
5
+ export function createDescribeCommand(program) {
6
+ program
7
+ .command("describe")
8
+ .alias("d")
9
+ .description("Describe entry with <id> in <collection>")
10
+ .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
11
+ .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
12
+ .action(async (collection, id, options) => {
13
+ try {
14
+ const opts = { ...program.opts(), ...options };
15
+ const module = getModuleFromCollection(collection);
16
+ localStorage.setItem("lastModule", module.module);
17
+ localStorage.setItem("lastCollection", collection);
18
+ localStorage.setItem("lastId", id);
19
+ await handleDescribeSingleOperation(module.module, collection, id, {
20
+ ...opts,
21
+ });
22
+ }
23
+ catch (e) {
24
+ console.error(e);
25
+ }
26
+ });
27
+ }
@@ -1,28 +1,28 @@
1
- import { Argument } from "commander";
2
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
- import { handleGetSingleOperation } from "../operations/handleGetSingleOperation.js";
4
- import { handleEditOperation } from "../operations/handleEditOperation.js";
5
- import { localStorage } from "../helpers/localStorage.js";
6
- export function createEditCommand(program) {
7
- program
8
- .command("edit")
9
- .alias("e")
10
- .description("Edit entry with [id] in [collection]")
11
- .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
12
- .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
13
- .action(async (collection, id, options) => {
14
- try {
15
- const opts = { ...program.opts(), ...options };
16
- const module = getModuleFromCollection(collection);
17
- localStorage.setItem("lastModule", module.module);
18
- localStorage.setItem("lastCollection", collection);
19
- localStorage.setItem("lastId", id);
20
- let result = {};
21
- result = await handleGetSingleOperation(module.module, collection, id, opts);
22
- await handleEditOperation(module.module, collection, result.content);
23
- }
24
- catch (e) {
25
- console.error(e);
26
- }
27
- });
28
- }
1
+ import { Argument } from "commander";
2
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
3
+ import { handleGetSingleOperation } from "../operations/handleGetSingleOperation.js";
4
+ import { handleEditOperation } from "../operations/handleEditOperation.js";
5
+ import { localStorage } from "../helpers/localStorage.js";
6
+ export function createEditCommand(program) {
7
+ program
8
+ .command("edit")
9
+ .alias("e")
10
+ .description("Edit entry with [id] in [collection]")
11
+ .addArgument(new Argument("[collection]", "The collection to use").default(localStorage.getItem("lastCollection"), `The last used collection (${localStorage.getItem("lastCollection")})`))
12
+ .addArgument(new Argument("[id]", "The id to get the audit from").default(localStorage.getItem("lastId"), `The last used id (${localStorage.getItem("lastId")})`))
13
+ .action(async (collection, id, options) => {
14
+ try {
15
+ const opts = { ...program.opts(), ...options };
16
+ const module = getModuleFromCollection(collection);
17
+ localStorage.setItem("lastModule", module.module);
18
+ localStorage.setItem("lastCollection", collection);
19
+ localStorage.setItem("lastId", id);
20
+ let result = {};
21
+ result = await handleGetSingleOperation(module.module, collection, id, opts);
22
+ await handleEditOperation(module.module, collection, result.content);
23
+ }
24
+ catch (e) {
25
+ console.error(e);
26
+ }
27
+ });
28
+ }
@@ -1,36 +1,36 @@
1
- import { parseInteger } from "../helpers/parseInt.js";
2
- import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
3
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
4
- import { saveFile } from "../helpers/saveFile.js";
5
- import { handleGetOperation } from "../operations/handleGetOperation.js";
6
- import { localStorage } from "../helpers/localStorage.js";
7
- export function createGetCommand(program) {
8
- program
9
- .command("get [collection]")
10
- .alias("g")
11
- .description("Get Data in collection")
12
- .option("-p, --page <number>", "Page", parseInteger, 1)
13
- .option("-l, --limit <number>", "Limit", parseInteger, 20)
14
- .option("-f, --from <date>", "From date")
15
- .option("-i, --fields <fields...>", "Fields to get")
16
- .action(async (collection, options) => {
17
- try {
18
- const opts = { ...program.opts(), ...options };
19
- if (!collection) {
20
- collection = await promptCollectionWithModule();
21
- }
22
- const module = getModuleFromCollection(collection);
23
- localStorage.setItem("lastModule", module.module);
24
- localStorage.setItem("lastCollection", collection);
25
- let result = {};
26
- let entry = "";
27
- result = await handleGetOperation(module.module, collection, opts);
28
- if (opts.save) {
29
- await saveFile("get", opts, result);
30
- }
31
- }
32
- catch (e) {
33
- console.error(e);
34
- }
35
- });
36
- }
1
+ import { parseInteger } from "../helpers/parseInt.js";
2
+ import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
3
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
4
+ import { saveFile } from "../helpers/saveFile.js";
5
+ import { handleGetOperation } from "../operations/handleGetOperation.js";
6
+ import { localStorage } from "../helpers/localStorage.js";
7
+ export function createGetCommand(program) {
8
+ program
9
+ .command("get [collection]")
10
+ .alias("g")
11
+ .description("Get Data in collection")
12
+ .option("-p, --page <number>", "Page", parseInteger, 1)
13
+ .option("-l, --limit <number>", "Limit", parseInteger, 20)
14
+ .option("-f, --from <date>", "From date")
15
+ .option("-i, --fields <fields...>", "Fields to get")
16
+ .action(async (collection, options) => {
17
+ try {
18
+ const opts = { ...program.opts(), ...options };
19
+ if (!collection) {
20
+ collection = await promptCollectionWithModule();
21
+ }
22
+ const module = getModuleFromCollection(collection);
23
+ localStorage.setItem("lastModule", module.module);
24
+ localStorage.setItem("lastCollection", collection);
25
+ let result = {};
26
+ let entry = "";
27
+ result = await handleGetOperation(module.module, collection, opts);
28
+ if (opts.save) {
29
+ await saveFile("get", opts, result);
30
+ }
31
+ }
32
+ catch (e) {
33
+ console.error(e);
34
+ }
35
+ });
36
+ }
@@ -1,35 +1,35 @@
1
- import { parseInteger } from "../helpers/parseInt.js";
2
- import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
3
- import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
4
- import { handleListOperation } from "../operations/handleListOperation.js";
5
- import { saveFile } from "../helpers/saveFile.js";
6
- import { localStorage } from "../helpers/localStorage.js";
7
- export function createListCommand(program) {
8
- program
9
- .command("list [collection]")
10
- .alias("l")
11
- .description("List entries in collection")
12
- .option("-p, --page <number>", "Page", parseInteger, 1)
13
- .option("-l, --limit <number>", "Limit", parseInteger, 20)
14
- .option("-f, --from <date>", "From date")
15
- .action(async (collection, options) => {
16
- try {
17
- const opts = { ...program.opts(), ...options };
18
- if (!collection) {
19
- collection = await promptCollectionWithModule();
20
- }
21
- const module = getModuleFromCollection(collection);
22
- localStorage.setItem("lastModule", module.module);
23
- localStorage.setItem("lastCollection", collection);
24
- let result = {};
25
- let entry = "";
26
- result = await handleListOperation(module.module, collection, opts);
27
- if (opts.save) {
28
- await saveFile("list", opts, result);
29
- }
30
- }
31
- catch (e) {
32
- console.error(e);
33
- }
34
- });
35
- }
1
+ import { parseInteger } from "../helpers/parseInt.js";
2
+ import { promptCollectionWithModule } from "../prompts/promptCollectionWithModule.js";
3
+ import { getModuleFromCollection } from "../models/getModuleFromCollection.js";
4
+ import { handleListOperation } from "../operations/handleListOperation.js";
5
+ import { saveFile } from "../helpers/saveFile.js";
6
+ import { localStorage } from "../helpers/localStorage.js";
7
+ export function createListCommand(program) {
8
+ program
9
+ .command("list [collection]")
10
+ .alias("l")
11
+ .description("List entries in collection")
12
+ .option("-p, --page <number>", "Page", parseInteger, 1)
13
+ .option("-l, --limit <number>", "Limit", parseInteger, 20)
14
+ .option("-f, --from <date>", "From date")
15
+ .action(async (collection, options) => {
16
+ try {
17
+ const opts = { ...program.opts(), ...options };
18
+ if (!collection) {
19
+ collection = await promptCollectionWithModule();
20
+ }
21
+ const module = getModuleFromCollection(collection);
22
+ localStorage.setItem("lastModule", module.module);
23
+ localStorage.setItem("lastCollection", collection);
24
+ let result = {};
25
+ let entry = "";
26
+ result = await handleListOperation(module.module, collection, opts);
27
+ if (opts.save) {
28
+ await saveFile("list", opts, result);
29
+ }
30
+ }
31
+ catch (e) {
32
+ console.error(e);
33
+ }
34
+ });
35
+ }
@@ -1,41 +1,41 @@
1
- import { promptModule } from "../prompts/promptModule.js";
2
- import { promptCollectionInModule } from "../prompts/promptCollectionInModule.js";
3
- import { promptOperation } from "../prompts/promptOperation.js";
4
- import { handleListOperation } from "../operations/handleListOperation.js";
5
- import { promptEntry } from "../prompts/promptEntry.js";
6
- import { handleCollectionOperation } from "../operations/handleCollectionOperation.js";
7
- import { localStorage } from "../helpers/localStorage.js";
8
- import { parseInteger } from "../helpers/parseInt.js";
9
- import { handleGetOperation } from "../operations/handleGetOperation.js";
10
- export function createModulesCommand(program) {
11
- program
12
- .command("modules")
13
- .alias("m")
14
- .description("List modules")
15
- .option("-p, --page <number>", "Page", parseInteger, 1)
16
- .option("-l, --limit <number>", "Limit", parseInteger, 20)
17
- .option("-f, --from <date>", "From date")
18
- .action(async (options) => {
19
- try {
20
- const opts = { ...program.opts(), ...options };
21
- const module = await promptModule();
22
- const collection = await promptCollectionInModule(module);
23
- const operation = await promptOperation();
24
- localStorage.setItem("lastModule", module);
25
- localStorage.setItem("lastCollection", collection);
26
- let entry = "";
27
- if (operation === "list") {
28
- const { result } = await handleListOperation(module, collection, opts);
29
- entry = await promptEntry(result);
30
- }
31
- if (operation === "get") {
32
- const { result } = await handleGetOperation(module, collection, opts);
33
- entry = await promptEntry(result);
34
- }
35
- await handleCollectionOperation(module, collection, entry, opts);
36
- }
37
- catch (e) {
38
- console.error(e);
39
- }
40
- });
41
- }
1
+ import { promptModule } from "../prompts/promptModule.js";
2
+ import { promptCollectionInModule } from "../prompts/promptCollectionInModule.js";
3
+ import { promptOperation } from "../prompts/promptOperation.js";
4
+ import { handleListOperation } from "../operations/handleListOperation.js";
5
+ import { promptEntry } from "../prompts/promptEntry.js";
6
+ import { handleCollectionOperation } from "../operations/handleCollectionOperation.js";
7
+ import { localStorage } from "../helpers/localStorage.js";
8
+ import { parseInteger } from "../helpers/parseInt.js";
9
+ import { handleGetOperation } from "../operations/handleGetOperation.js";
10
+ export function createModulesCommand(program) {
11
+ program
12
+ .command("modules")
13
+ .alias("m")
14
+ .description("List modules")
15
+ .option("-p, --page <number>", "Page", parseInteger, 1)
16
+ .option("-l, --limit <number>", "Limit", parseInteger, 20)
17
+ .option("-f, --from <date>", "From date")
18
+ .action(async (options) => {
19
+ try {
20
+ const opts = { ...program.opts(), ...options };
21
+ const module = await promptModule();
22
+ const collection = await promptCollectionInModule(module);
23
+ const operation = await promptOperation();
24
+ localStorage.setItem("lastModule", module);
25
+ localStorage.setItem("lastCollection", collection);
26
+ let entry = "";
27
+ if (operation === "list") {
28
+ const { result } = await handleListOperation(module, collection, opts);
29
+ entry = await promptEntry(result);
30
+ }
31
+ if (operation === "get") {
32
+ const { result } = await handleGetOperation(module, collection, opts);
33
+ entry = await promptEntry(result);
34
+ }
35
+ await handleCollectionOperation(module, collection, entry, opts);
36
+ }
37
+ catch (e) {
38
+ console.error(e);
39
+ }
40
+ });
41
+ }
@@ -1,16 +1,16 @@
1
- import { localStorage } from "../helpers/localStorage.js";
2
- export function createStorageCommand(program) {
3
- program
4
- .command("storage")
5
- .alias("s")
6
- .description("Show current local storage")
7
- .action(async () => {
8
- try {
9
- const storage = { ...localStorage };
10
- console.table(storage);
11
- }
12
- catch (e) {
13
- console.error(e);
14
- }
15
- });
16
- }
1
+ import { localStorage } from "../helpers/localStorage.js";
2
+ export function createStorageCommand(program) {
3
+ program
4
+ .command("storage")
5
+ .alias("s")
6
+ .description("Show current local storage")
7
+ .action(async () => {
8
+ try {
9
+ const storage = { ...localStorage };
10
+ console.table(storage);
11
+ }
12
+ catch (e) {
13
+ console.error(e);
14
+ }
15
+ });
16
+ }