Mass Implement of basic features
This commit is contained in:
@@ -4,12 +4,15 @@ import { getApiClient } from "../../api.js";
|
||||
export const functionsCountDefinition = {
|
||||
name: "functions",
|
||||
description: "Counts the amount of functions the current user has.",
|
||||
action: async () => {
|
||||
await countFunctions();
|
||||
options: [
|
||||
{ name: "--full", description: "List all functions instead of just the count", type: "boolean" },
|
||||
],
|
||||
action: async (options: any) => {
|
||||
await countFunctions(options?.full);
|
||||
},
|
||||
};
|
||||
|
||||
async function countFunctions() {
|
||||
async function countFunctions(full: boolean = false) {
|
||||
const client = await getApiClient();
|
||||
|
||||
try {
|
||||
@@ -19,7 +22,7 @@ async function countFunctions() {
|
||||
const functions = response.data.data;
|
||||
const count = functions.length;
|
||||
|
||||
if (count > 0) {
|
||||
if (full && count > 0) {
|
||||
console.log(chalk.blue("Functions List:"));
|
||||
functions.forEach((f: any) => {
|
||||
const namespaceInfo = f.namespace ? chalk.gray(` [NS: ${f.namespace.id}]`) : "";
|
||||
|
||||
@@ -4,12 +4,15 @@ import { getApiClient } from "../../api.js";
|
||||
export const namespacesCountDefinition = {
|
||||
name: "namespaces",
|
||||
description: "Counts the amount of namespaces the current user has.",
|
||||
action: async () => {
|
||||
await countNamespaces();
|
||||
options: [
|
||||
{ name: "--full", description: "List all namespaces instead of just the count", type: "boolean" },
|
||||
],
|
||||
action: async (options: any) => {
|
||||
await countNamespaces(options?.full);
|
||||
},
|
||||
};
|
||||
|
||||
async function countNamespaces() {
|
||||
async function countNamespaces(full: boolean = false) {
|
||||
const client = await getApiClient();
|
||||
|
||||
try {
|
||||
@@ -19,7 +22,7 @@ async function countNamespaces() {
|
||||
const namespaces = response.data.data;
|
||||
const count = namespaces.length;
|
||||
|
||||
if (count > 0) {
|
||||
if (full && count > 0) {
|
||||
console.log(chalk.blue("Namespaces List:"));
|
||||
namespaces.forEach((ns: any) => {
|
||||
console.log(`- ${chalk.cyan(ns.name)} ${chalk.gray(`(${ns.id})`)}`);
|
||||
|
||||
@@ -4,12 +4,15 @@ import { getApiClient } from "../../api.js";
|
||||
export const storagesCountDefinition = {
|
||||
name: "storages",
|
||||
description: "Counts the amount of storages the current user has.",
|
||||
action: async () => {
|
||||
await countStorages();
|
||||
options: [
|
||||
{ name: "--full", description: "List all storages instead of just the count", type: "boolean" },
|
||||
],
|
||||
action: async (options: any) => {
|
||||
await countStorages(options?.full);
|
||||
},
|
||||
};
|
||||
|
||||
async function countStorages() {
|
||||
async function countStorages(full: boolean = false) {
|
||||
const client = await getApiClient();
|
||||
|
||||
try {
|
||||
@@ -19,7 +22,7 @@ async function countStorages() {
|
||||
const storages = response.data.data;
|
||||
const count = storages.length;
|
||||
|
||||
if (count > 0) {
|
||||
if (full && count > 0) {
|
||||
console.log(chalk.blue("Storages List:"));
|
||||
storages.forEach((s: any) => {
|
||||
const purposeInfo = s.purpose ? chalk.gray(` - ${s.purpose}`) : "";
|
||||
|
||||
@@ -4,12 +4,15 @@ import { getApiClient } from "../../api.js";
|
||||
export const triggersCountDefinition = {
|
||||
name: "triggers",
|
||||
description: "Counts the amount of triggers the current user has.",
|
||||
action: async () => {
|
||||
await countTriggers();
|
||||
options: [
|
||||
{ name: "--full", description: "List all triggers instead of just the count", type: "boolean" },
|
||||
],
|
||||
action: async (options: any) => {
|
||||
await countTriggers(options?.full);
|
||||
},
|
||||
};
|
||||
|
||||
async function countTriggers() {
|
||||
async function countTriggers(full: boolean = false) {
|
||||
const client = await getApiClient();
|
||||
|
||||
try {
|
||||
@@ -19,7 +22,7 @@ async function countTriggers() {
|
||||
const triggers = response.data.data;
|
||||
const count = triggers.length;
|
||||
|
||||
if (count > 0) {
|
||||
if (full && count > 0) {
|
||||
console.log(chalk.blue("Triggers List:"));
|
||||
triggers.forEach((t: any) => {
|
||||
const functionInfo = t.function ? chalk.gray(` [Func: ${t.function.name}]`) : "";
|
||||
|
||||
Reference in New Issue
Block a user