@extrahorizon/exh-cli 1.12.0-dev-135-55b05fe → 1.12.0-dev-137-56e1ad4

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.
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
- const exh_1 = require("../../../exh");
5
4
  const util_1 = require("../../../helpers/util");
5
+ const schemaRepository = require("../../../repositories/schemas");
6
6
  exports.command = 'list';
7
7
  exports.desc = 'List all schemas';
8
8
  const builder = (yargs) => (0, util_1.epilogue)(yargs);
9
9
  exports.builder = builder;
10
10
  const handler = async function list({ isTTY }) {
11
- const schemaListResponse = await (0, exh_1.getSdk)().raw.get('/data/v1/');
12
- if (schemaListResponse.data.data.length !== 0) {
13
- if (isTTY) {
14
- console.table(schemaListResponse.data.data.map((c) => ({ Id: c.id, Name: c.name, Description: c.description || '<none>' })));
15
- }
16
- else {
17
- schemaListResponse.data.data.forEach((f) => (console.log([f.id, f.name].join(','))));
18
- }
11
+ const schemas = await schemaRepository.fetchAll();
12
+ if (schemas.length < 1) {
13
+ return;
14
+ }
15
+ if (isTTY) {
16
+ console.table(schemas.map(schema => ({
17
+ Id: schema.id,
18
+ Name: schema.name,
19
+ Description: schema.description || '<none>',
20
+ })));
21
+ }
22
+ else {
23
+ schemas.forEach(schema => console.log([schema.id, schema.name].join(',')));
19
24
  }
20
25
  };
21
26
  exports.handler = handler;
@@ -1,28 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
- const exh_1 = require("../../exh");
5
4
  const util_1 = require("../../helpers/util");
5
+ const functionRepository = require("../../repositories/functions");
6
6
  exports.command = 'list';
7
7
  exports.desc = 'List all tasks';
8
8
  const builder = (yargs) => (0, util_1.epilogue)(yargs);
9
9
  exports.builder = builder;
10
10
  const handler = async function list({ isTTY }) {
11
- let functionResponse;
11
+ let functions;
12
12
  try {
13
- functionResponse = await (0, exh_1.getSdk)().raw.get('/tasks/v1/functions');
13
+ functions = await functionRepository.find();
14
14
  }
15
15
  catch (err) {
16
16
  console.log(err);
17
17
  return;
18
18
  }
19
- if (functionResponse.data.data.length !== 0) {
20
- if (isTTY) {
21
- console.table(functionResponse.data.data.map((c) => ({ Name: c.name, Description: c.Description || '<none>', 'Last updated': c.updateTimestamp.toISOString() })));
22
- }
23
- else {
24
- functionResponse.data.data.forEach((f) => (console.log(f.name)));
25
- }
19
+ if (functions.length < 1) {
20
+ return;
21
+ }
22
+ if (isTTY) {
23
+ console.table(functions.map((c) => ({
24
+ Name: c.name,
25
+ Description: c.description || '<none>',
26
+ 'Last updated': c.updateTimestamp.toISOString(),
27
+ })));
28
+ }
29
+ else {
30
+ functions.forEach((f) => (console.log(f.name)));
26
31
  }
27
32
  };
28
33
  exports.handler = handler;
@@ -2,25 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
4
  const chalk = require("chalk");
5
- const exh_1 = require("../../exh");
6
5
  const util_1 = require("../../helpers/util");
6
+ const templateRepository = require("../../repositories/templates");
7
7
  exports.command = 'list';
8
8
  exports.desc = 'List all templates';
9
9
  const builder = (yargs) => (0, util_1.epilogue)(yargs);
10
10
  exports.builder = builder;
11
11
  const handler = async function list({ isTTY }) {
12
- const templates = await (0, exh_1.getSdk)().templates.findAll();
13
- if (templates) {
14
- if (!templates.length) {
15
- console.log(chalk.red('No templates found'));
16
- return;
17
- }
18
- if (isTTY) {
19
- console.table(templates.map((c) => ({ Id: c.id, Name: c.name, Description: c.description || '<none>', 'Last updated': c.updateTimestamp.toISOString() })));
20
- }
21
- else {
22
- templates.forEach((f) => (console.log(f)));
23
- }
12
+ const templates = await templateRepository.findAll();
13
+ if (templates.length < 1) {
14
+ console.log(chalk.red('No templates found'));
15
+ return;
16
+ }
17
+ if (isTTY) {
18
+ console.table(templates.map(template => ({
19
+ Id: template.id,
20
+ Name: template.name,
21
+ Description: template.description || '<none>',
22
+ 'Last updated': template.updateTimestamp.toISOString(),
23
+ })));
24
+ }
25
+ else {
26
+ templates.forEach(template => console.log(template));
24
27
  }
25
28
  };
26
29
  exports.handler = handler;
@@ -17,6 +17,7 @@ export interface Transition {
17
17
  export declare function remove(schemaId: ObjectId): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
18
18
  export declare function disable(schemaId: ObjectId): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
19
19
  export declare function fetchSchemaByName(name: string): Promise<import("@extrahorizon/javascript-sdk").Schema>;
20
+ export declare function fetchAll(): Promise<import("@extrahorizon/javascript-sdk").Schema[]>;
20
21
  export declare function createSchema(name: string, description: string): Promise<import("@extrahorizon/javascript-sdk").Schema>;
21
22
  export declare function updateSchema(id: string, data: any): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
22
23
  export declare function createProperty(id: string, data: {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteIndex = exports.createIndex = exports.deleteTransition = exports.updateTransition = exports.createTransition = exports.updateCreationTransition = exports.deleteStatus = exports.updateStatus = exports.createStatus = exports.deleteProperty = exports.updateProperty = exports.createProperty = exports.updateSchema = exports.createSchema = exports.fetchSchemaByName = exports.disable = exports.remove = void 0;
3
+ exports.deleteIndex = exports.createIndex = exports.deleteTransition = exports.updateTransition = exports.createTransition = exports.updateCreationTransition = exports.deleteStatus = exports.updateStatus = exports.createStatus = exports.deleteProperty = exports.updateProperty = exports.createProperty = exports.updateSchema = exports.createSchema = exports.fetchAll = exports.fetchSchemaByName = exports.disable = exports.remove = void 0;
4
+ const javascript_sdk_1 = require("@extrahorizon/javascript-sdk");
4
5
  const exh_1 = require("../exh");
5
6
  async function remove(schemaId) {
6
7
  return await (0, exh_1.getSdk)().data.schemas.remove(schemaId);
@@ -14,6 +15,11 @@ async function fetchSchemaByName(name) {
14
15
  return await (0, exh_1.getSdk)().data.schemas.findByName(name);
15
16
  }
16
17
  exports.fetchSchemaByName = fetchSchemaByName;
18
+ async function fetchAll() {
19
+ const rql = (0, javascript_sdk_1.rqlBuilder)().select(['id', 'name', 'description']).build();
20
+ return await (0, exh_1.getSdk)().data.schemas.findAll({ rql });
21
+ }
22
+ exports.fetchAll = fetchAll;
17
23
  async function createSchema(name, description) {
18
24
  return await (0, exh_1.getSdk)().data.schemas.create({
19
25
  name,
@@ -1,3 +1,4 @@
1
1
  export declare function findByName(name: string): Promise<import("@extrahorizon/javascript-sdk").TemplateOut>;
2
2
  export declare function findById(id: string): Promise<import("@extrahorizon/javascript-sdk").TemplateOut>;
3
+ export declare function findAll(): Promise<import("@extrahorizon/javascript-sdk").TemplateOut[]>;
3
4
  export declare function remove(id: string): Promise<import("@extrahorizon/javascript-sdk").AffectedRecords>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.remove = exports.findById = exports.findByName = void 0;
3
+ exports.remove = exports.findAll = exports.findById = exports.findByName = void 0;
4
4
  const exh_1 = require("../exh");
5
5
  async function findByName(name) {
6
6
  return await (0, exh_1.getSdk)().templates.findByName(name);
@@ -10,6 +10,10 @@ async function findById(id) {
10
10
  return await (0, exh_1.getSdk)().templates.findById(id);
11
11
  }
12
12
  exports.findById = findById;
13
+ async function findAll() {
14
+ return await (0, exh_1.getSdk)().templates.findAll();
15
+ }
16
+ exports.findAll = findAll;
13
17
  async function remove(id) {
14
18
  return await (0, exh_1.getSdk)().templates.remove(id);
15
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.12.0-dev-135-55b05fe",
3
+ "version": "1.12.0-dev-137-56e1ad4",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",