@norbix.ai/cli 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +121 -0
- package/bin/run.js +4 -0
- package/dist/base.js +100 -0
- package/dist/commands/account/billing-portal.js +21 -0
- package/dist/commands/account/profile.js +12 -0
- package/dist/commands/account/projects.js +12 -0
- package/dist/commands/account/regions.js +12 -0
- package/dist/commands/account/status.js +12 -0
- package/dist/commands/account/team.js +12 -0
- package/dist/commands/account/usage.js +12 -0
- package/dist/commands/api.js +87 -0
- package/dist/commands/apikeys/list.js +12 -0
- package/dist/commands/apikeys/regenerate.js +25 -0
- package/dist/commands/config/get.js +20 -0
- package/dist/commands/config/list.js +18 -0
- package/dist/commands/config/set.js +25 -0
- package/dist/commands/config/unset.js +20 -0
- package/dist/commands/db/aggregate.js +42 -0
- package/dist/commands/db/aggregates.js +16 -0
- package/dist/commands/db/count.js +26 -0
- package/dist/commands/db/delete.js +45 -0
- package/dist/commands/db/distinct.js +25 -0
- package/dist/commands/db/find.js +33 -0
- package/dist/commands/db/get.js +20 -0
- package/dist/commands/db/insert-many.js +29 -0
- package/dist/commands/db/insert.js +26 -0
- package/dist/commands/db/replace.js +25 -0
- package/dist/commands/db/schema.js +16 -0
- package/dist/commands/db/schemas.js +20 -0
- package/dist/commands/db/taxonomies.js +20 -0
- package/dist/commands/db/taxonomy.js +16 -0
- package/dist/commands/db/update.js +44 -0
- package/dist/commands/email/archive.js +16 -0
- package/dist/commands/email/campaign.js +21 -0
- package/dist/commands/email/campaigns.js +20 -0
- package/dist/commands/email/clone.js +16 -0
- package/dist/commands/email/delete.js +25 -0
- package/dist/commands/email/stop.js +31 -0
- package/dist/commands/email/template.js +16 -0
- package/dist/commands/email/templates.js +18 -0
- package/dist/commands/email/unarchive.js +16 -0
- package/dist/commands/env/delete.js +28 -0
- package/dist/commands/env/list.js +12 -0
- package/dist/commands/env/use.js +17 -0
- package/dist/commands/files/delete.js +34 -0
- package/dist/commands/files/download.js +45 -0
- package/dist/commands/files/info.js +27 -0
- package/dist/commands/files/list.js +30 -0
- package/dist/commands/files/sign.js +29 -0
- package/dist/commands/files/upload.js +62 -0
- package/dist/commands/integrations.js +34 -0
- package/dist/commands/login.js +65 -0
- package/dist/commands/logout.js +27 -0
- package/dist/commands/logs/list.js +38 -0
- package/dist/commands/logs/settings.js +12 -0
- package/dist/commands/logs/trail.js +18 -0
- package/dist/commands/module.js +48 -0
- package/dist/commands/payments/disable.js +16 -0
- package/dist/commands/payments/enable.js +16 -0
- package/dist/commands/payments/integrations.js +12 -0
- package/dist/commands/payments/trigger.js +16 -0
- package/dist/commands/payments/triggers.js +12 -0
- package/dist/commands/push/archive.js +16 -0
- package/dist/commands/push/campaign.js +21 -0
- package/dist/commands/push/campaigns.js +20 -0
- package/dist/commands/push/clone.js +16 -0
- package/dist/commands/push/delete.js +25 -0
- package/dist/commands/push/stop.js +30 -0
- package/dist/commands/push/template.js +16 -0
- package/dist/commands/push/templates.js +18 -0
- package/dist/commands/push/unarchive.js +16 -0
- package/dist/commands/scheduler/delete.js +25 -0
- package/dist/commands/scheduler/disable.js +16 -0
- package/dist/commands/scheduler/enable.js +16 -0
- package/dist/commands/scheduler/get.js +16 -0
- package/dist/commands/scheduler/list.js +20 -0
- package/dist/commands/sms/archive.js +16 -0
- package/dist/commands/sms/campaign.js +21 -0
- package/dist/commands/sms/campaigns.js +20 -0
- package/dist/commands/sms/clone.js +16 -0
- package/dist/commands/sms/delete.js +25 -0
- package/dist/commands/sms/stop.js +30 -0
- package/dist/commands/sms/template.js +16 -0
- package/dist/commands/sms/templates.js +18 -0
- package/dist/commands/sms/unarchive.js +16 -0
- package/dist/commands/users/block.js +16 -0
- package/dist/commands/users/delete.js +25 -0
- package/dist/commands/users/get.js +16 -0
- package/dist/commands/users/invite.js +16 -0
- package/dist/commands/users/list.js +27 -0
- package/dist/commands/users/policies.js +12 -0
- package/dist/commands/users/roles.js +12 -0
- package/dist/commands/users/unblock.js +16 -0
- package/dist/commands/webhooks/disable.js +18 -0
- package/dist/commands/webhooks/enable.js +18 -0
- package/dist/commands/webhooks/remove.js +30 -0
- package/dist/commands/webhooks/secret.js +34 -0
- package/dist/commands/webhooks/show.js +12 -0
- package/dist/commands/whoami.js +43 -0
- package/dist/lib/files.js +35 -0
- package/dist/lib/json.js +21 -0
- package/dist/lib/store.js +39 -0
- package/oclif.manifest.json +8497 -0
- package/package.json +114 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
5
|
+
export default class DbDelete extends BaseCommand {
|
|
6
|
+
static description = 'Delete records: one by --id, or many by --filter with --many';
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%= config.bin %> db delete orders --id 66b2f0a1...',
|
|
9
|
+
`<%= config.bin %> db delete orders --filter '{"status":"cancelled"}' --many --yes`,
|
|
10
|
+
];
|
|
11
|
+
static args = {
|
|
12
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
13
|
+
};
|
|
14
|
+
static flags = {
|
|
15
|
+
id: Flags.string({ description: 'Record ID (single delete)', exclusive: ['many', 'filter'] }),
|
|
16
|
+
filter: Flags.string({ char: 'f', description: 'JSON filter (with --many)', dependsOn: ['many'] }),
|
|
17
|
+
many: Flags.boolean({ description: 'Delete every record matching --filter', default: false }),
|
|
18
|
+
yes: Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt', default: false }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { args, flags } = await this.parse(DbDelete);
|
|
22
|
+
const client = this.client(flags);
|
|
23
|
+
if (flags.many) {
|
|
24
|
+
if (!flags.filter)
|
|
25
|
+
this.error('--many requires --filter.');
|
|
26
|
+
const filter = await readJsonInput(flags.filter, 'filter');
|
|
27
|
+
if (!flags.yes && process.stdout.isTTY) {
|
|
28
|
+
const ok = await confirm({
|
|
29
|
+
message: `Delete ALL records in "${args.collection}" matching ${filter}?`,
|
|
30
|
+
default: false,
|
|
31
|
+
});
|
|
32
|
+
if (!ok)
|
|
33
|
+
return this.print('Cancelled.');
|
|
34
|
+
}
|
|
35
|
+
const res = await client.api.database.deleteMany({ collectionName: args.collection, filter });
|
|
36
|
+
this.print(res);
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
if (!flags.id)
|
|
40
|
+
this.error('Pass --id for a single delete, or --filter with --many.');
|
|
41
|
+
const res = await client.api.database.deleteOne({ collectionName: args.collection, id: flags.id });
|
|
42
|
+
this.print(res);
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbDistinct extends BaseCommand {
|
|
5
|
+
static description = 'List the distinct values of one field in a collection';
|
|
6
|
+
static examples = [`<%= config.bin %> db distinct orders status --filter '{"total":{"$gt":10}}'`];
|
|
7
|
+
static args = {
|
|
8
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
9
|
+
field: Args.string({ required: true, description: 'Field name' }),
|
|
10
|
+
};
|
|
11
|
+
static flags = {
|
|
12
|
+
filter: Flags.string({ char: 'f', description: 'JSON filter (or `-` for stdin)' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(DbDistinct);
|
|
16
|
+
const client = this.client(flags);
|
|
17
|
+
const res = await client.api.database.distinct({
|
|
18
|
+
collectionName: args.collection,
|
|
19
|
+
field: args.field,
|
|
20
|
+
filter: flags.filter ? await readJsonInput(flags.filter, 'filter') : undefined,
|
|
21
|
+
});
|
|
22
|
+
this.print(res);
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbFind extends BaseCommand {
|
|
5
|
+
static description = 'Find records in a collection (MongoDB-style filter)';
|
|
6
|
+
static examples = [
|
|
7
|
+
'<%= config.bin %> db find orders',
|
|
8
|
+
`<%= config.bin %> db find orders --filter '{"status":"paid"}' --page-size 20`,
|
|
9
|
+
`<%= config.bin %> db find orders --json | jq '.list.items'`,
|
|
10
|
+
];
|
|
11
|
+
static args = {
|
|
12
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
13
|
+
};
|
|
14
|
+
static flags = {
|
|
15
|
+
filter: Flags.string({ char: 'f', description: 'JSON filter (or `-` for stdin)' }),
|
|
16
|
+
'page-size': Flags.integer({ description: 'Records per page' }),
|
|
17
|
+
after: Flags.string({ description: 'Cursor: fetch the page after this item' }),
|
|
18
|
+
before: Flags.string({ description: 'Cursor: fetch the page before this item' }),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { args, flags } = await this.parse(DbFind);
|
|
22
|
+
const client = this.client(flags);
|
|
23
|
+
const res = await client.api.database.find({
|
|
24
|
+
collectionName: args.collection,
|
|
25
|
+
filter: flags.filter ? await readJsonInput(flags.filter, 'filter') : undefined,
|
|
26
|
+
pageSize: flags['page-size'],
|
|
27
|
+
startingAfter: flags.after,
|
|
28
|
+
endingBefore: flags.before,
|
|
29
|
+
});
|
|
30
|
+
this.print(res);
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class DbGet extends BaseCommand {
|
|
4
|
+
static description = 'Get one record by ID';
|
|
5
|
+
static examples = ['<%= config.bin %> db get orders 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
8
|
+
id: Args.string({ required: true, description: 'Record ID' }),
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { args, flags } = await this.parse(DbGet);
|
|
12
|
+
const client = this.client(flags);
|
|
13
|
+
const res = await client.api.database.findOne({
|
|
14
|
+
collectionName: args.collection,
|
|
15
|
+
id: args.id,
|
|
16
|
+
});
|
|
17
|
+
this.print(res);
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbInsertMany extends BaseCommand {
|
|
5
|
+
static description = 'Insert many records at once (JSON array)';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> db insert-many orders --docs '[{"a":1},{"a":2}]'`,
|
|
8
|
+
'cat orders.json | <%= config.bin %> db insert-many orders --docs -',
|
|
9
|
+
];
|
|
10
|
+
static args = {
|
|
11
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
12
|
+
};
|
|
13
|
+
static flags = {
|
|
14
|
+
docs: Flags.string({ char: 'd', required: true, description: 'JSON array of documents (or `-` for stdin)' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { args, flags } = await this.parse(DbInsertMany);
|
|
18
|
+
const client = this.client(flags);
|
|
19
|
+
const documents = await readJsonInput(flags.docs, 'docs');
|
|
20
|
+
if (!documents.trimStart().startsWith('['))
|
|
21
|
+
this.error('--docs must be a JSON array.');
|
|
22
|
+
const res = await client.api.database.insertMany({
|
|
23
|
+
collectionName: args.collection,
|
|
24
|
+
documents,
|
|
25
|
+
});
|
|
26
|
+
this.print(res);
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbInsert extends BaseCommand {
|
|
5
|
+
static description = 'Insert one record into a collection';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> db insert orders --doc '{"status":"new","total":9.99}'`,
|
|
8
|
+
'cat order.json | <%= config.bin %> db insert orders --doc -',
|
|
9
|
+
];
|
|
10
|
+
static args = {
|
|
11
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
12
|
+
};
|
|
13
|
+
static flags = {
|
|
14
|
+
doc: Flags.string({ char: 'd', required: true, description: 'JSON document (or `-` for stdin)' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { args, flags } = await this.parse(DbInsert);
|
|
18
|
+
const client = this.client(flags);
|
|
19
|
+
const res = await client.api.database.insertOne({
|
|
20
|
+
collectionName: args.collection,
|
|
21
|
+
document: await readJsonInput(flags.doc, 'doc'),
|
|
22
|
+
});
|
|
23
|
+
this.print(res);
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbReplace extends BaseCommand {
|
|
5
|
+
static description = 'Replace one record fully (unlike update, the whole document is swapped)';
|
|
6
|
+
static examples = [`<%= config.bin %> db replace orders --id 66b2f0a1... --doc '{"status":"new"}'`];
|
|
7
|
+
static args = {
|
|
8
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
id: Flags.string({ required: true, description: 'Record ID' }),
|
|
12
|
+
doc: Flags.string({ char: 'd', required: true, description: 'JSON replacement document (or `-` for stdin)' }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(DbReplace);
|
|
16
|
+
const client = this.client(flags);
|
|
17
|
+
const res = await client.api.database.replaceOne({
|
|
18
|
+
collectionName: args.collection,
|
|
19
|
+
id: flags.id,
|
|
20
|
+
replacement: await readJsonInput(flags.doc, 'doc'),
|
|
21
|
+
});
|
|
22
|
+
this.print(res);
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class DbSchema extends BaseCommand {
|
|
4
|
+
static description = 'Show one database schema';
|
|
5
|
+
static examples = ['<%= config.bin %> db schema 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Schema ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(DbSchema);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.database.getDatabaseSchema({ id: args.id });
|
|
13
|
+
this.print(res);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class DbSchemas extends BaseCommand {
|
|
4
|
+
static description = 'List database schemas (collections definitions)';
|
|
5
|
+
static examples = ['<%= config.bin %> db schemas'];
|
|
6
|
+
static flags = {
|
|
7
|
+
'page-size': Flags.integer({ description: 'Records per page' }),
|
|
8
|
+
after: Flags.string({ description: 'Cursor: fetch the page after this item' }),
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(DbSchemas);
|
|
12
|
+
const client = this.client(flags);
|
|
13
|
+
const res = await client.hub.database.getDatabaseSchemas({
|
|
14
|
+
pageSize: flags['page-size'],
|
|
15
|
+
startingAfter: flags.after,
|
|
16
|
+
});
|
|
17
|
+
this.print(res);
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class DbTaxonomies extends BaseCommand {
|
|
4
|
+
static description = 'List database taxonomies';
|
|
5
|
+
static examples = ['<%= config.bin %> db taxonomies'];
|
|
6
|
+
static flags = {
|
|
7
|
+
'page-size': Flags.integer({ description: 'Records per page' }),
|
|
8
|
+
after: Flags.string({ description: 'Cursor: fetch the page after this item' }),
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(DbTaxonomies);
|
|
12
|
+
const client = this.client(flags);
|
|
13
|
+
const res = await client.hub.database.getDatabaseTaxonomies({
|
|
14
|
+
pageSize: flags['page-size'],
|
|
15
|
+
startingAfter: flags.after,
|
|
16
|
+
});
|
|
17
|
+
this.print(res);
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class DbTaxonomy extends BaseCommand {
|
|
4
|
+
static description = 'Show one database taxonomy';
|
|
5
|
+
static examples = ['<%= config.bin %> db taxonomy 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Taxonomy ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(DbTaxonomy);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.database.getDatabaseTaxonomy({ id: args.id });
|
|
13
|
+
this.print(res);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { readJsonInput } from '../../lib/json.js';
|
|
4
|
+
export default class DbUpdate extends BaseCommand {
|
|
5
|
+
static description = 'Update records: one by --id, or many by --filter with --many';
|
|
6
|
+
static examples = [
|
|
7
|
+
`<%= config.bin %> db update orders --id 66b2f0a1... --update '{"$set":{"status":"shipped"}}'`,
|
|
8
|
+
`<%= config.bin %> db update orders --filter '{"status":"new"}' --update '{"$set":{"status":"queued"}}' --many`,
|
|
9
|
+
];
|
|
10
|
+
static args = {
|
|
11
|
+
collection: Args.string({ required: true, description: 'Collection name' }),
|
|
12
|
+
};
|
|
13
|
+
static flags = {
|
|
14
|
+
id: Flags.string({ description: 'Record ID (single update)', exclusive: ['many', 'filter'] }),
|
|
15
|
+
filter: Flags.string({ char: 'f', description: 'JSON filter (with --many)', dependsOn: ['many'] }),
|
|
16
|
+
update: Flags.string({ char: 'u', required: true, description: 'JSON update (e.g. {"$set":{...}}) or `-` for stdin' }),
|
|
17
|
+
many: Flags.boolean({ description: 'Update every record matching --filter', default: false }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(DbUpdate);
|
|
21
|
+
const client = this.client(flags);
|
|
22
|
+
const update = await readJsonInput(flags.update, 'update');
|
|
23
|
+
if (flags.many) {
|
|
24
|
+
if (!flags.filter)
|
|
25
|
+
this.error('--many requires --filter.');
|
|
26
|
+
const res = await client.api.database.updateMany({
|
|
27
|
+
collectionName: args.collection,
|
|
28
|
+
filter: await readJsonInput(flags.filter, 'filter'),
|
|
29
|
+
update,
|
|
30
|
+
});
|
|
31
|
+
this.print(res);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
if (!flags.id)
|
|
35
|
+
this.error('Pass --id for a single update, or --filter with --many.');
|
|
36
|
+
const res = await client.api.database.updateOne({
|
|
37
|
+
collectionName: args.collection,
|
|
38
|
+
id: flags.id,
|
|
39
|
+
update,
|
|
40
|
+
});
|
|
41
|
+
this.print(res);
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailArchive extends BaseCommand {
|
|
4
|
+
static description = 'Archive an email template';
|
|
5
|
+
static examples = ['<%= config.bin %> email archive 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Template ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(EmailArchive);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.notifications.archiveEmailTemplate({ id: args.id });
|
|
13
|
+
this.print(`Template ${args.id} archived.`);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailCampaign extends BaseCommand {
|
|
4
|
+
static description = 'Show one email campaign (or its statistics with --stats)';
|
|
5
|
+
static examples = ['<%= config.bin %> email campaign 66b2f0a1... --stats'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Campaign ID' }),
|
|
8
|
+
};
|
|
9
|
+
static flags = {
|
|
10
|
+
stats: Flags.boolean({ description: 'Show delivery statistics instead of the campaign itself', default: false }),
|
|
11
|
+
};
|
|
12
|
+
async run() {
|
|
13
|
+
const { args, flags } = await this.parse(EmailCampaign);
|
|
14
|
+
const client = this.client(flags);
|
|
15
|
+
const res = flags.stats
|
|
16
|
+
? await client.hub.notifications.getEmailCampaignStatistics({ id: args.id })
|
|
17
|
+
: await client.hub.notifications.getEmailCampaign({ id: args.id });
|
|
18
|
+
this.print(res);
|
|
19
|
+
return res;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailCampaigns extends BaseCommand {
|
|
4
|
+
static description = 'List email campaigns';
|
|
5
|
+
static examples = ['<%= config.bin %> email campaigns'];
|
|
6
|
+
static flags = {
|
|
7
|
+
'page-size': Flags.integer({ description: 'Records per page' }),
|
|
8
|
+
after: Flags.string({ description: 'Cursor: fetch the page after this item' }),
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(EmailCampaigns);
|
|
12
|
+
const client = this.client(flags);
|
|
13
|
+
const res = await client.hub.notifications.getEmailCampaigns({
|
|
14
|
+
pageSize: flags['page-size'],
|
|
15
|
+
startingAfter: flags.after,
|
|
16
|
+
});
|
|
17
|
+
this.print(res);
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailClone extends BaseCommand {
|
|
4
|
+
static description = 'Clone an email template';
|
|
5
|
+
static examples = ['<%= config.bin %> email clone 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Template ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(EmailClone);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.notifications.cloneEmailTemplate({ id: args.id });
|
|
13
|
+
this.print(`Template ${args.id} cloned.`);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
export default class EmailDelete extends BaseCommand {
|
|
5
|
+
static description = 'Delete an email template';
|
|
6
|
+
static examples = ['<%= config.bin %> email delete 66b2f0a1... --yes'];
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.string({ required: true, description: 'Template ID' }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
yes: Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt', default: false }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(EmailDelete);
|
|
15
|
+
const client = this.client(flags);
|
|
16
|
+
if (!flags.yes && process.stdout.isTTY) {
|
|
17
|
+
const ok = await confirm({ message: `Delete email template ${args.id}?`, default: false });
|
|
18
|
+
if (!ok)
|
|
19
|
+
return this.print('Cancelled.');
|
|
20
|
+
}
|
|
21
|
+
const res = await client.hub.notifications.deleteEmailTemplate({ id: args.id });
|
|
22
|
+
this.print(`Template ${args.id} deleted.`);
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
export default class EmailStop extends BaseCommand {
|
|
5
|
+
static description = 'Stop a running email campaign';
|
|
6
|
+
static examples = ['<%= config.bin %> email stop 66b2f0a1... --yes'];
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.string({ required: true, description: 'Campaign ID' }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
yes: Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt', default: false }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(EmailStop);
|
|
15
|
+
const client = this.client(flags);
|
|
16
|
+
if (!flags.yes && process.stdout.isTTY) {
|
|
17
|
+
const ok = await confirm({ message: `Stop email campaign ${args.id}?`, default: false });
|
|
18
|
+
if (!ok)
|
|
19
|
+
return this.print('Cancelled.');
|
|
20
|
+
}
|
|
21
|
+
// stop* methods are newer than SDK 1.2.0 — guard so older SDKs fail nicely.
|
|
22
|
+
const n = client.hub.notifications;
|
|
23
|
+
if (!n.stopEmailCampaign) {
|
|
24
|
+
this.error('Your installed @norbix.ai/ts does not support stopping campaigns yet.\n' +
|
|
25
|
+
`Update the SDK, or run: norbix api "/{version}/notifications/email/campaigns/${args.id}/stop" --hub --method POST`);
|
|
26
|
+
}
|
|
27
|
+
const res = await n.stopEmailCampaign({ id: args.id });
|
|
28
|
+
this.print(`Campaign ${args.id} stopped.`);
|
|
29
|
+
return res;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailTemplate extends BaseCommand {
|
|
4
|
+
static description = 'Show one email template';
|
|
5
|
+
static examples = ['<%= config.bin %> email template 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Template ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(EmailTemplate);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.notifications.getEmailTemplate({ id: args.id });
|
|
13
|
+
this.print(res);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailTemplates extends BaseCommand {
|
|
4
|
+
static description = 'List email templates';
|
|
5
|
+
static examples = ['<%= config.bin %> email templates --archived'];
|
|
6
|
+
static flags = {
|
|
7
|
+
archived: Flags.boolean({ description: 'Include archived templates', default: false }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { flags } = await this.parse(EmailTemplates);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.notifications.getEmailTemplates({
|
|
13
|
+
showArchived: flags.archived,
|
|
14
|
+
});
|
|
15
|
+
this.print(res);
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
export default class EmailUnarchive extends BaseCommand {
|
|
4
|
+
static description = 'Restore an archived email template';
|
|
5
|
+
static examples = ['<%= config.bin %> email unarchive 66b2f0a1...'];
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.string({ required: true, description: 'Template ID' }),
|
|
8
|
+
};
|
|
9
|
+
async run() {
|
|
10
|
+
const { args, flags } = await this.parse(EmailUnarchive);
|
|
11
|
+
const client = this.client(flags);
|
|
12
|
+
const res = await client.hub.notifications.unArchiveEmailTemplate({ id: args.id });
|
|
13
|
+
this.print(`Template ${args.id} restored.`);
|
|
14
|
+
return res;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
export default class EnvDelete extends BaseCommand {
|
|
5
|
+
static description = 'Delete a non-PROD environment (cascades its integrations)';
|
|
6
|
+
static examples = ['<%= config.bin %> env delete STAGING --yes'];
|
|
7
|
+
static args = {
|
|
8
|
+
name: Args.string({ required: true, description: 'Environment name (PROD cannot be deleted)' }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
yes: Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt', default: false }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(EnvDelete);
|
|
15
|
+
const client = this.client(flags);
|
|
16
|
+
if (!flags.yes && process.stdout.isTTY) {
|
|
17
|
+
const ok = await confirm({
|
|
18
|
+
message: `Delete environment "${args.name}" and everything inside it?`,
|
|
19
|
+
default: false,
|
|
20
|
+
});
|
|
21
|
+
if (!ok)
|
|
22
|
+
return this.print('Cancelled.');
|
|
23
|
+
}
|
|
24
|
+
const res = await client.hub.environments.delete({ environmentName: args.name });
|
|
25
|
+
this.print(`Environment ${args.name} deleted.`);
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class EnvList extends BaseCommand {
|
|
3
|
+
static description = "List the project's environments (PROD is always first)";
|
|
4
|
+
static examples = ['<%= config.bin %> env list'];
|
|
5
|
+
async run() {
|
|
6
|
+
const { flags } = await this.parse(EnvList);
|
|
7
|
+
const client = this.client(flags);
|
|
8
|
+
const res = await client.hub.environments.list();
|
|
9
|
+
this.print(res);
|
|
10
|
+
return res;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { writeStore } from '../../lib/store.js';
|
|
4
|
+
export default class EnvUse extends BaseCommand {
|
|
5
|
+
static description = 'Set the default environment for all future commands (stored locally)';
|
|
6
|
+
static examples = ['<%= config.bin %> env use TEST', '<%= config.bin %> env use PROD'];
|
|
7
|
+
static args = {
|
|
8
|
+
name: Args.string({ required: true, description: 'Environment name (e.g. PROD, TEST)' }),
|
|
9
|
+
};
|
|
10
|
+
async run() {
|
|
11
|
+
const { args } = await this.parse(EnvUse);
|
|
12
|
+
const stored = this.readStore();
|
|
13
|
+
writeStore(this.config.configDir, { ...stored, env: args.name });
|
|
14
|
+
this.print(`Default environment set to ${args.name}. Override per command with --env.`);
|
|
15
|
+
return { env: args.name };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { BaseCommand } from '../../base.js';
|
|
4
|
+
import { integrationFlag, resolveIntegration } from '../../lib/files.js';
|
|
5
|
+
export default class FilesDelete extends BaseCommand {
|
|
6
|
+
static description = 'Delete one file';
|
|
7
|
+
static examples = ['<%= config.bin %> files delete invoices/2026/invoice.pdf --yes'];
|
|
8
|
+
static args = {
|
|
9
|
+
remote: Args.string({ required: true, description: 'Remote file path' }),
|
|
10
|
+
};
|
|
11
|
+
static flags = {
|
|
12
|
+
integration: integrationFlag,
|
|
13
|
+
yes: Flags.boolean({ char: 'y', description: 'Skip the confirmation prompt', default: false }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(FilesDelete);
|
|
17
|
+
const client = this.client(flags);
|
|
18
|
+
const integration = resolveIntegration(flags.integration, this.readStore().filesIntegrationId);
|
|
19
|
+
if (!integration) {
|
|
20
|
+
this.error('No files integration ID. Pass --integration or run `norbix config set filesIntegrationId <id>`.');
|
|
21
|
+
}
|
|
22
|
+
if (!flags.yes && process.stdout.isTTY) {
|
|
23
|
+
const ok = await confirm({ message: `Delete file "${args.remote}"?`, default: false });
|
|
24
|
+
if (!ok)
|
|
25
|
+
return this.print('Cancelled.');
|
|
26
|
+
}
|
|
27
|
+
const res = await client.api.files.deleteFileApi({
|
|
28
|
+
filesIntegrationId: integration,
|
|
29
|
+
path: args.remote,
|
|
30
|
+
});
|
|
31
|
+
this.print(`Deleted ${args.remote}.`);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
}
|