@aderis-erp/cli 1.0.12 → 1.0.14
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/dist/commands/access-groups.js +4 -4
- package/dist/commands/account-transaction-allocations.js +4 -4
- package/dist/commands/account-transactions.js +4 -4
- package/dist/commands/accounts.js +4 -4
- package/dist/commands/{agent-runs.d.ts → agent-platform.d.ts} +2 -2
- package/dist/commands/agent-platform.js +1175 -0
- package/dist/commands/audit-log.js +7 -7
- package/dist/commands/auth/login.js +2 -3
- package/dist/commands/bank-accounts.js +4 -4
- package/dist/commands/bank-integrations.js +4 -4
- package/dist/commands/business-partners.js +6 -6
- package/dist/commands/chat.js +12 -8
- package/dist/commands/config/add.js +2 -3
- package/dist/commands/config/rename.d.ts +10 -0
- package/dist/commands/config/rename.js +68 -0
- package/dist/commands/credit-card-accounts.js +4 -4
- package/dist/commands/delivery-notes.d.ts +43 -0
- package/dist/commands/delivery-notes.js +1206 -0
- package/dist/commands/documents.js +5 -5
- package/dist/commands/dunning-configs.js +4 -4
- package/dist/commands/dunning-reminders.js +4 -4
- package/dist/commands/dunning-runs.js +4 -4
- package/dist/commands/email-transactions.js +4 -4
- package/dist/commands/employees.js +4 -4
- package/dist/commands/entity-configurations.js +4 -4
- package/dist/commands/event-processor-mappings.js +4 -4
- package/dist/commands/files-internal.js +4 -4
- package/dist/commands/health.js +4 -4
- package/dist/commands/inbox.d.ts +1 -0
- package/dist/commands/inbox.js +10 -8
- package/dist/commands/integrations.js +4 -4
- package/dist/commands/item-categories.js +4 -4
- package/dist/commands/items.js +4 -4
- package/dist/commands/journal-lines.js +4 -4
- package/dist/commands/journals.js +7 -5
- package/dist/commands/ledgers.js +4 -4
- package/dist/commands/office-locations.js +4 -4
- package/dist/commands/payment-methods.js +4 -4
- package/dist/commands/payment-runs.js +5 -7
- package/dist/commands/payment-terms.js +4 -4
- package/dist/commands/payments.d.ts +40 -0
- package/dist/commands/payments.js +1180 -0
- package/dist/commands/price-lists.js +4 -4
- package/dist/commands/processor-mappings.js +4 -4
- package/dist/commands/processors.js +4 -4
- package/dist/commands/purchase-order-types.js +4 -4
- package/dist/commands/purchase-orders.js +4 -4
- package/dist/commands/reports.js +4 -4
- package/dist/commands/salary-types.js +4 -4
- package/dist/commands/sales-invoices.js +13 -12
- package/dist/commands/sales-orders.js +7 -5
- package/dist/commands/saved-views.js +4 -4
- package/dist/commands/scheduled-processor-mappings.d.ts +40 -0
- package/dist/commands/{agent-runs.js → scheduled-processor-mappings.js} +22 -23
- package/dist/commands/schedules.d.ts +40 -0
- package/dist/commands/schedules.js +1182 -0
- package/dist/commands/tags.js +4 -4
- package/dist/commands/tax-codes.js +4 -4
- package/dist/commands/tax-matrix.js +4 -4
- package/dist/commands/tenants.js +9 -7
- package/dist/commands/text-templates.js +4 -4
- package/dist/commands/tools.js +4 -4
- package/dist/commands/vat-declarations.js +4 -4
- package/dist/commands/vendor-invoices.js +8 -8
- package/dist/commands/webhooks.js +4 -4
- package/dist/commands/workflows.js +4 -4
- package/dist/lib/api-client.d.ts +8 -0
- package/dist/lib/api-client.js +20 -0
- package/dist/lib/auth.js +2 -2
- package/dist/lib/config.d.ts +2 -1
- package/dist/lib/config.js +20 -5
- package/oclif.manifest.json +956 -231
- package/package.json +2 -2
package/dist/commands/tags.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -40,7 +40,7 @@ export default class Tags extends Command {
|
|
|
40
40
|
limit: Flags.string({ description: 'Items per page' }),
|
|
41
41
|
include: Flags.string({ description: 'Relations to include' }),
|
|
42
42
|
search: Flags.string({ description: 'Search term' }),
|
|
43
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
43
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
44
44
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
45
45
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
46
46
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -114,7 +114,7 @@ export default class Tags extends Command {
|
|
|
114
114
|
if (flags.search)
|
|
115
115
|
queryParams.search = flags.search;
|
|
116
116
|
if (flags['sort-by'])
|
|
117
|
-
queryParams.sortBy = flags['sort-by'];
|
|
117
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
118
118
|
if (flags.query) {
|
|
119
119
|
try {
|
|
120
120
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -573,7 +573,7 @@ export default class Tags extends Command {
|
|
|
573
573
|
if (flags.search)
|
|
574
574
|
baseParams.search = flags.search;
|
|
575
575
|
if (flags['sort-by'])
|
|
576
|
-
baseParams.sortBy = flags['sort-by'];
|
|
576
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
577
577
|
if (flags.include)
|
|
578
578
|
baseParams.include = flags.include;
|
|
579
579
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -43,7 +43,7 @@ export default class TaxCodes extends Command {
|
|
|
43
43
|
limit: Flags.string({ description: 'Items per page' }),
|
|
44
44
|
include: Flags.string({ description: 'Relations to include' }),
|
|
45
45
|
search: Flags.string({ description: 'Search term' }),
|
|
46
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
46
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
47
47
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
48
48
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
49
49
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -117,7 +117,7 @@ export default class TaxCodes extends Command {
|
|
|
117
117
|
if (flags.search)
|
|
118
118
|
queryParams.search = flags.search;
|
|
119
119
|
if (flags['sort-by'])
|
|
120
|
-
queryParams.sortBy = flags['sort-by'];
|
|
120
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
121
121
|
if (flags.query) {
|
|
122
122
|
try {
|
|
123
123
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -576,7 +576,7 @@ export default class TaxCodes extends Command {
|
|
|
576
576
|
if (flags.search)
|
|
577
577
|
baseParams.search = flags.search;
|
|
578
578
|
if (flags['sort-by'])
|
|
579
|
-
baseParams.sortBy = flags['sort-by'];
|
|
579
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
580
580
|
if (flags.include)
|
|
581
581
|
baseParams.include = flags.include;
|
|
582
582
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -40,7 +40,7 @@ export default class TaxMatrix extends Command {
|
|
|
40
40
|
limit: Flags.string({ description: 'Items per page' }),
|
|
41
41
|
include: Flags.string({ description: 'Relations to include' }),
|
|
42
42
|
search: Flags.string({ description: 'Search term' }),
|
|
43
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
43
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
44
44
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
45
45
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
46
46
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -114,7 +114,7 @@ export default class TaxMatrix extends Command {
|
|
|
114
114
|
if (flags.search)
|
|
115
115
|
queryParams.search = flags.search;
|
|
116
116
|
if (flags['sort-by'])
|
|
117
|
-
queryParams.sortBy = flags['sort-by'];
|
|
117
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
118
118
|
if (flags.query) {
|
|
119
119
|
try {
|
|
120
120
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -573,7 +573,7 @@ export default class TaxMatrix extends Command {
|
|
|
573
573
|
if (flags.search)
|
|
574
574
|
baseParams.search = flags.search;
|
|
575
575
|
if (flags['sort-by'])
|
|
576
|
-
baseParams.sortBy = flags['sort-by'];
|
|
576
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
577
577
|
if (flags.include)
|
|
578
578
|
baseParams.include = flags.include;
|
|
579
579
|
if (flags.query) {
|
package/dist/commands/tenants.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
6
6
|
const HAS_EXPORT = true;
|
|
7
7
|
const HAS_CAMT053 = false;
|
|
8
8
|
const NESTED_IMPORTS = [];
|
|
9
|
-
const SUBCOMMANDS = [...["list", "create", "get", "update", "delete"], ...(HAS_IMPORT ? ['import'] : []), ...(HAS_EXPORT ? ['export'] : []), ...NESTED_IMPORTS.map(n => `import-${n}`)];
|
|
9
|
+
const SUBCOMMANDS = [...["list", "create", "get", "update", "delete", "logo", "icon"], ...(HAS_IMPORT ? ['import'] : []), ...(HAS_EXPORT ? ['export'] : []), ...NESTED_IMPORTS.map(n => `import-${n}`)];
|
|
10
10
|
const ENDPOINTS = {
|
|
11
11
|
'list': { method: 'GET', path: '/v1/tenants', summary: 'Get all tenants with pagination (admin only)', pathParams: [], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
12
|
-
'create': { method: 'POST', path: '/v1/tenants', summary: 'Create a new tenant (admin only)', pathParams: [], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['supportedLocales', 'allowedSenders', 'salesInvoiceRecipientCc', 'salesInvoiceRecipientBcc', 'salesOrderRecipientCc', 'salesOrderRecipientBcc'] },
|
|
12
|
+
'create': { method: 'POST', path: '/v1/tenants', summary: 'Create a new tenant (admin only)', pathParams: [], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['supportedLocales', 'allowedSenders', 'salesInvoiceRecipientCc', 'salesInvoiceRecipientBcc', 'salesOrderRecipientCc', 'salesOrderRecipientBcc', 'deliveryNoteRecipientCc', 'deliveryNoteRecipientBcc'] },
|
|
13
13
|
'get': { method: 'GET', path: '/v1/tenants/{id}', summary: 'Get a tenant by ID (own tenant or admin)', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
14
|
-
'update': { method: 'PATCH', path: '/v1/tenants/{id}', summary: 'Update a tenant (own tenant or admin)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['supportedLocales', 'allowedSenders', 'salesInvoiceRecipientCc', 'salesInvoiceRecipientBcc', 'salesOrderRecipientCc', 'salesOrderRecipientBcc'] },
|
|
14
|
+
'update': { method: 'PATCH', path: '/v1/tenants/{id}', summary: 'Update a tenant (own tenant or admin)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['supportedLocales', 'allowedSenders', 'salesInvoiceRecipientCc', 'salesInvoiceRecipientBcc', 'salesOrderRecipientCc', 'salesOrderRecipientBcc', 'deliveryNoteRecipientCc', 'deliveryNoteRecipientBcc'] },
|
|
15
15
|
'delete': { method: 'DELETE', path: '/v1/tenants/{id}', summary: 'Delete a tenant (admin only)', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
16
|
+
'logo': { method: 'POST', path: '/v1/tenants/{id}/logo', summary: 'Upload the tenant logo to the public bucket and set logoUrl (own tenant or admin)', pathParams: ['id'], hasBody: false, isMultipart: true, isBinaryResponse: false, bodyArrayFields: [] },
|
|
17
|
+
'icon': { method: 'POST', path: '/v1/tenants/{id}/icon', summary: 'Upload the tenant icon to the public bucket and set iconUrl (own tenant or admin)', pathParams: ['id'], hasBody: false, isMultipart: true, isBinaryResponse: false, bodyArrayFields: [] },
|
|
16
18
|
};
|
|
17
19
|
export default class Tenants extends Command {
|
|
18
20
|
static description = 'Manage tenants';
|
|
@@ -40,7 +42,7 @@ export default class Tenants extends Command {
|
|
|
40
42
|
limit: Flags.string({ description: 'Items per page' }),
|
|
41
43
|
include: Flags.string({ description: 'Relations to include' }),
|
|
42
44
|
search: Flags.string({ description: 'Search term' }),
|
|
43
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
45
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
44
46
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
45
47
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
46
48
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -114,7 +116,7 @@ export default class Tenants extends Command {
|
|
|
114
116
|
if (flags.search)
|
|
115
117
|
queryParams.search = flags.search;
|
|
116
118
|
if (flags['sort-by'])
|
|
117
|
-
queryParams.sortBy = flags['sort-by'];
|
|
119
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
118
120
|
if (flags.query) {
|
|
119
121
|
try {
|
|
120
122
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -573,7 +575,7 @@ export default class Tenants extends Command {
|
|
|
573
575
|
if (flags.search)
|
|
574
576
|
baseParams.search = flags.search;
|
|
575
577
|
if (flags['sort-by'])
|
|
576
|
-
baseParams.sortBy = flags['sort-by'];
|
|
578
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
577
579
|
if (flags.include)
|
|
578
580
|
baseParams.include = flags.include;
|
|
579
581
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -40,7 +40,7 @@ export default class TextTemplates extends Command {
|
|
|
40
40
|
limit: Flags.string({ description: 'Items per page' }),
|
|
41
41
|
include: Flags.string({ description: 'Relations to include' }),
|
|
42
42
|
search: Flags.string({ description: 'Search term' }),
|
|
43
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
43
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
44
44
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
45
45
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
46
46
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -114,7 +114,7 @@ export default class TextTemplates extends Command {
|
|
|
114
114
|
if (flags.search)
|
|
115
115
|
queryParams.search = flags.search;
|
|
116
116
|
if (flags['sort-by'])
|
|
117
|
-
queryParams.sortBy = flags['sort-by'];
|
|
117
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
118
118
|
if (flags.query) {
|
|
119
119
|
try {
|
|
120
120
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -573,7 +573,7 @@ export default class TextTemplates extends Command {
|
|
|
573
573
|
if (flags.search)
|
|
574
574
|
baseParams.search = flags.search;
|
|
575
575
|
if (flags['sort-by'])
|
|
576
|
-
baseParams.sortBy = flags['sort-by'];
|
|
576
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
577
577
|
if (flags.include)
|
|
578
578
|
baseParams.include = flags.include;
|
|
579
579
|
if (flags.query) {
|
package/dist/commands/tools.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = false;
|
|
@@ -33,7 +33,7 @@ export default class Tools extends Command {
|
|
|
33
33
|
limit: Flags.string({ description: 'Items per page' }),
|
|
34
34
|
include: Flags.string({ description: 'Relations to include' }),
|
|
35
35
|
search: Flags.string({ description: 'Search term' }),
|
|
36
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
36
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
37
37
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
38
38
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
39
39
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -107,7 +107,7 @@ export default class Tools extends Command {
|
|
|
107
107
|
if (flags.search)
|
|
108
108
|
queryParams.search = flags.search;
|
|
109
109
|
if (flags['sort-by'])
|
|
110
|
-
queryParams.sortBy = flags['sort-by'];
|
|
110
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
111
111
|
if (flags.query) {
|
|
112
112
|
try {
|
|
113
113
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -566,7 +566,7 @@ export default class Tools extends Command {
|
|
|
566
566
|
if (flags.search)
|
|
567
567
|
baseParams.search = flags.search;
|
|
568
568
|
if (flags['sort-by'])
|
|
569
|
-
baseParams.sortBy = flags['sort-by'];
|
|
569
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
570
570
|
if (flags.include)
|
|
571
571
|
baseParams.include = flags.include;
|
|
572
572
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -56,7 +56,7 @@ export default class VatDeclarations extends Command {
|
|
|
56
56
|
limit: Flags.string({ description: 'Items per page' }),
|
|
57
57
|
include: Flags.string({ description: 'Relations to include' }),
|
|
58
58
|
search: Flags.string({ description: 'Search term' }),
|
|
59
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
59
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
60
60
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
61
61
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
62
62
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -130,7 +130,7 @@ export default class VatDeclarations extends Command {
|
|
|
130
130
|
if (flags.search)
|
|
131
131
|
queryParams.search = flags.search;
|
|
132
132
|
if (flags['sort-by'])
|
|
133
|
-
queryParams.sortBy = flags['sort-by'];
|
|
133
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
134
134
|
if (flags.query) {
|
|
135
135
|
try {
|
|
136
136
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -589,7 +589,7 @@ export default class VatDeclarations extends Command {
|
|
|
589
589
|
if (flags.search)
|
|
590
590
|
baseParams.search = flags.search;
|
|
591
591
|
if (flags['sort-by'])
|
|
592
|
-
baseParams.sortBy = flags['sort-by'];
|
|
592
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
593
593
|
if (flags.include)
|
|
594
594
|
baseParams.include = flags.include;
|
|
595
595
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -9,12 +9,12 @@ const NESTED_IMPORTS = ["line-items", "notes", "files", "payments"];
|
|
|
9
9
|
const SUBCOMMANDS = [...["list", "create", "get", "update", "delete", "submit", "approve", "decline", "book", "rebuild-journal", "cancel", "confirm-cancellation", "change-vendor", "recalculate-payment-status", "validate", "create-line-items", "update-line-items", "delete-line-items", "list-notes", "create-notes", "get-notes", "update-notes", "delete-notes", "list-files", "create-files", "get-files", "update-files", "delete-files", "files-download", "list-payments", "create-payments", "get-payments", "update-payments", "delete-payments", "payments-approve", "payments-cancel"], ...(HAS_IMPORT ? ['import'] : []), ...(HAS_EXPORT ? ['export'] : []), ...NESTED_IMPORTS.map(n => `import-${n}`)];
|
|
10
10
|
const ENDPOINTS = {
|
|
11
11
|
'list': { method: 'GET', path: '/v1/vendor-invoices', summary: 'Get all vendor invoices with pagination', pathParams: [], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
12
|
-
'create': { method: 'POST', path: '/v1/vendor-invoices', summary: 'Create a new vendor invoice', pathParams: [], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'payments'] },
|
|
12
|
+
'create': { method: 'POST', path: '/v1/vendor-invoices', summary: 'Create a new vendor invoice', pathParams: [], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['earlyPaymentDiscounts', 'totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'payments'] },
|
|
13
13
|
'get': { method: 'GET', path: '/v1/vendor-invoices/{id}', summary: 'Get a vendor invoice by ID', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
14
|
-
'update': { method: 'PATCH', path: '/v1/vendor-invoices/{id}', summary: 'Update a vendor invoice', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
14
|
+
'update': { method: 'PATCH', path: '/v1/vendor-invoices/{id}', summary: 'Update a vendor invoice', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['earlyPaymentDiscounts', 'totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
15
15
|
'delete': { method: 'DELETE', path: '/v1/vendor-invoices/{id}', summary: 'Delete a vendor invoice', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
16
16
|
'submit': { method: 'POST', path: '/v1/vendor-invoices/{id}/submit', summary: 'Submit a vendor invoice for approval (transitions DRAFT to PENDING_APPROVAL)', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
17
|
-
'approve': { method: 'POST', path: '/v1/vendor-invoices/{id}/approve', summary: 'Approve a vendor invoice (transitions DRAFT/PENDING_APPROVAL to APPROVED)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
17
|
+
'approve': { method: 'POST', path: '/v1/vendor-invoices/{id}/approve', summary: 'Approve a vendor invoice (transitions DRAFT/PENDING_APPROVAL to APPROVED)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['earlyPaymentDiscounts', 'totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
18
18
|
'decline': { method: 'POST', path: '/v1/vendor-invoices/{id}/decline', summary: 'Decline a vendor invoice (transitions PENDING_APPROVAL to DECLINED)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
19
19
|
'book': { method: 'POST', path: '/v1/vendor-invoices/{id}/book', summary: 'Manually book a vendor invoice (dispatch to ledger-booking-agent)', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
20
20
|
'rebuild-journal': { method: 'POST', path: '/v1/vendor-invoices/{id}/rebuild-journal', summary: 'Rebuild a vendor invoice booking journal (dispatch to ledger-booking-agent)', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
@@ -22,7 +22,7 @@ const ENDPOINTS = {
|
|
|
22
22
|
'confirm-cancellation': { method: 'POST', path: '/v1/vendor-invoices/{id}/confirm-cancellation', summary: 'Confirm bank cancellation for a vendor invoice (PENDING_CANCELLATION to CANCELLED)', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
23
23
|
'change-vendor': { method: 'POST', path: '/v1/vendor-invoices/{id}/change-vendor', summary: 'Change the vendor on a vendor invoice', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
24
24
|
'recalculate-payment-status': { method: 'POST', path: '/v1/vendor-invoices/{id}/recalculate-payment-status', summary: 'Recalculate a vendor invoice\'s open amount and payment status', pathParams: ['id'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
25
|
-
'validate': { method: 'POST', path: '/v1/vendor-invoices/{id}/validate', summary: 'Validate a vendor invoice update without persisting changes', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
25
|
+
'validate': { method: 'POST', path: '/v1/vendor-invoices/{id}/validate', summary: 'Validate a vendor invoice update without persisting changes', pathParams: ['id'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: ['earlyPaymentDiscounts', 'totalAmountByTaxRate', 'files', 'notes', 'lineItems', 'tagIds', 'removeFileIds'] },
|
|
26
26
|
'create-line-items': { method: 'POST', path: '/v1/vendor-invoices/{invoiceId}/line-items', summary: 'Add a line item to a vendor invoice', pathParams: ['invoiceId'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
27
27
|
'update-line-items': { method: 'PATCH', path: '/v1/vendor-invoices/{invoiceId}/line-items/{lineItemId}', summary: 'Update a line item on a vendor invoice', pathParams: ['invoiceId', 'lineItemId'], hasBody: true, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
28
28
|
'delete-line-items': { method: 'DELETE', path: '/v1/vendor-invoices/{invoiceId}/line-items/{lineItemId}', summary: 'Remove a line item from a vendor invoice', pathParams: ['invoiceId', 'lineItemId'], hasBody: false, isMultipart: false, isBinaryResponse: false, bodyArrayFields: [] },
|
|
@@ -75,7 +75,7 @@ export default class VendorInvoices extends Command {
|
|
|
75
75
|
limit: Flags.string({ description: 'Items per page' }),
|
|
76
76
|
include: Flags.string({ description: 'Relations to include' }),
|
|
77
77
|
search: Flags.string({ description: 'Search term' }),
|
|
78
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
78
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
79
79
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
80
80
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
81
81
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -149,7 +149,7 @@ export default class VendorInvoices extends Command {
|
|
|
149
149
|
if (flags.search)
|
|
150
150
|
queryParams.search = flags.search;
|
|
151
151
|
if (flags['sort-by'])
|
|
152
|
-
queryParams.sortBy = flags['sort-by'];
|
|
152
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
153
153
|
if (flags.query) {
|
|
154
154
|
try {
|
|
155
155
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -608,7 +608,7 @@ export default class VendorInvoices extends Command {
|
|
|
608
608
|
if (flags.search)
|
|
609
609
|
baseParams.search = flags.search;
|
|
610
610
|
if (flags['sort-by'])
|
|
611
|
-
baseParams.sortBy = flags['sort-by'];
|
|
611
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
612
612
|
if (flags.include)
|
|
613
613
|
baseParams.include = flags.include;
|
|
614
614
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = true;
|
|
@@ -42,7 +42,7 @@ export default class Webhooks extends Command {
|
|
|
42
42
|
limit: Flags.string({ description: 'Items per page' }),
|
|
43
43
|
include: Flags.string({ description: 'Relations to include' }),
|
|
44
44
|
search: Flags.string({ description: 'Search term' }),
|
|
45
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
45
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
46
46
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
47
47
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
48
48
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -116,7 +116,7 @@ export default class Webhooks extends Command {
|
|
|
116
116
|
if (flags.search)
|
|
117
117
|
queryParams.search = flags.search;
|
|
118
118
|
if (flags['sort-by'])
|
|
119
|
-
queryParams.sortBy = flags['sort-by'];
|
|
119
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
120
120
|
if (flags.query) {
|
|
121
121
|
try {
|
|
122
122
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -575,7 +575,7 @@ export default class Webhooks extends Command {
|
|
|
575
575
|
if (flags.search)
|
|
576
576
|
baseParams.search = flags.search;
|
|
577
577
|
if (flags['sort-by'])
|
|
578
|
-
baseParams.sortBy = flags['sort-by'];
|
|
578
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
579
579
|
if (flags.include)
|
|
580
580
|
baseParams.include = flags.include;
|
|
581
581
|
if (flags.query) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command, Args, Flags } from '@oclif/core';
|
|
2
|
-
import { apiRequest, ApiError } from '../lib/api-client.js';
|
|
2
|
+
import { apiRequest, ApiError, normalizeSortBy } from '../lib/api-client.js';
|
|
3
3
|
import { getCurrentContext, getContext, getBaseUrls } from '../lib/config.js';
|
|
4
4
|
// Add 'import' action if both create and update exist
|
|
5
5
|
const HAS_IMPORT = false;
|
|
@@ -34,7 +34,7 @@ export default class Workflows extends Command {
|
|
|
34
34
|
limit: Flags.string({ description: 'Items per page' }),
|
|
35
35
|
include: Flags.string({ description: 'Relations to include' }),
|
|
36
36
|
search: Flags.string({ description: 'Search term' }),
|
|
37
|
-
'sort-by': Flags.string({ description: 'Sort field' }),
|
|
37
|
+
'sort-by': Flags.string({ description: 'Sort field(s), comma-separated. Direction (:ASC/:DESC) is optional; date-like fields default to DESC, others to ASC.' }),
|
|
38
38
|
filter: Flags.string({ description: 'Filter (e.g. --filter status=ACTIVE). Operators: in:A,B, like:%, gt:, lt:, null:', multiple: true }),
|
|
39
39
|
query: Flags.string({ description: 'Additional query params as JSON' }),
|
|
40
40
|
fields: Flags.string({ description: 'Comma-separated list of fields to show (e.g. --fields=id,name,status)' }),
|
|
@@ -108,7 +108,7 @@ export default class Workflows extends Command {
|
|
|
108
108
|
if (flags.search)
|
|
109
109
|
queryParams.search = flags.search;
|
|
110
110
|
if (flags['sort-by'])
|
|
111
|
-
queryParams.sortBy = flags['sort-by'];
|
|
111
|
+
queryParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
112
112
|
if (flags.query) {
|
|
113
113
|
try {
|
|
114
114
|
Object.assign(queryParams, JSON.parse(flags.query));
|
|
@@ -567,7 +567,7 @@ export default class Workflows extends Command {
|
|
|
567
567
|
if (flags.search)
|
|
568
568
|
baseParams.search = flags.search;
|
|
569
569
|
if (flags['sort-by'])
|
|
570
|
-
baseParams.sortBy = flags['sort-by'];
|
|
570
|
+
baseParams.sortBy = normalizeSortBy(flags['sort-by']);
|
|
571
571
|
if (flags.include)
|
|
572
572
|
baseParams.include = flags.include;
|
|
573
573
|
if (flags.query) {
|
package/dist/lib/api-client.d.ts
CHANGED
|
@@ -20,6 +20,14 @@ export interface PaginatedResponse<T> {
|
|
|
20
20
|
totalPages: number;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a --sort-by value: comma-separated fields, each optionally suffixed
|
|
25
|
+
* with `:ASC` or `:DESC`. Fields without an explicit direction default to DESC
|
|
26
|
+
* when the leaf name ends in `At`, `Date`, or `Time` (dates read newest-first);
|
|
27
|
+
* everything else defaults to ASC. Returned as an array so axios expands it
|
|
28
|
+
* into repeated `sortBy=a:ASC&sortBy=b:DESC` params.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeSortBy(input: string): string[];
|
|
23
31
|
export declare class ApiError extends Error {
|
|
24
32
|
status: number;
|
|
25
33
|
data?: unknown | undefined;
|
package/dist/lib/api-client.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { getValidToken } from './auth.js';
|
|
3
3
|
import { getBaseUrls, getCurrentContext } from './config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Normalize a --sort-by value: comma-separated fields, each optionally suffixed
|
|
6
|
+
* with `:ASC` or `:DESC`. Fields without an explicit direction default to DESC
|
|
7
|
+
* when the leaf name ends in `At`, `Date`, or `Time` (dates read newest-first);
|
|
8
|
+
* everything else defaults to ASC. Returned as an array so axios expands it
|
|
9
|
+
* into repeated `sortBy=a:ASC&sortBy=b:DESC` params.
|
|
10
|
+
*/
|
|
11
|
+
export function normalizeSortBy(input) {
|
|
12
|
+
return input
|
|
13
|
+
.split(',')
|
|
14
|
+
.map((part) => part.trim())
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.map((part) => {
|
|
17
|
+
if (part.includes(':'))
|
|
18
|
+
return part;
|
|
19
|
+
const leaf = part.split('.').pop() ?? part;
|
|
20
|
+
const dateLike = /(?:At|Date|Time)$/.test(leaf);
|
|
21
|
+
return `${part}:${dateLike ? 'DESC' : 'ASC'}`;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
4
24
|
export class ApiError extends Error {
|
|
5
25
|
status;
|
|
6
26
|
data;
|
package/dist/lib/auth.js
CHANGED
|
@@ -14,8 +14,8 @@ function buildValidatedUrl(baseUrl, path) {
|
|
|
14
14
|
const url = new URL(baseUrl);
|
|
15
15
|
// Protocol + host checks
|
|
16
16
|
const allowedDomains = [
|
|
17
|
-
'api.aderis.com', 'api-
|
|
18
|
-
'auth.aderis.com', 'auth-
|
|
17
|
+
'api.aderis.com', 'api-staging.aderis.com', 'api-dev.aderis.com',
|
|
18
|
+
'auth.aderis.com', 'auth-staging.aderis.com', 'auth-dev.aderis.com',
|
|
19
19
|
'localhost',
|
|
20
20
|
];
|
|
21
21
|
if (!allowedDomains.includes(url.hostname)) {
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Conf from 'conf';
|
|
2
|
-
export type Environment = 'dev' | 'live' | 'staging'
|
|
2
|
+
export type Environment = 'dev' | 'live' | 'staging';
|
|
3
3
|
export interface BaseUrls {
|
|
4
4
|
api: string;
|
|
5
5
|
auth: string;
|
|
@@ -37,6 +37,7 @@ export declare function listContexts(): Context[];
|
|
|
37
37
|
export declare function getContext(name: string): Context | null;
|
|
38
38
|
export declare function addContext(context: Context): void;
|
|
39
39
|
export declare function updateContext(name: string, updates: Partial<Context>): void;
|
|
40
|
+
export declare function renameContext(oldName: string, newName: string): void;
|
|
40
41
|
export declare function deleteContext(name: string): void;
|
|
41
42
|
export declare function saveTokens(contextName: string, tokens: TokenData): void;
|
|
42
43
|
export declare function saveCachedTenants(contextName: string, tenants: CachedTenant[]): void;
|
package/dist/lib/config.js
CHANGED
|
@@ -15,17 +15,12 @@ export const BASE_URLS = {
|
|
|
15
15
|
api: 'https://api-staging.aderis.com',
|
|
16
16
|
auth: 'https://auth-staging.aderis.com',
|
|
17
17
|
},
|
|
18
|
-
test: {
|
|
19
|
-
api: 'https://api-test.aderis.com',
|
|
20
|
-
auth: 'https://auth-test.aderis.com',
|
|
21
|
-
},
|
|
22
18
|
};
|
|
23
19
|
// Default OAuth client IDs per environment (public clients, no secret required)
|
|
24
20
|
export const DEFAULT_CLIENT_IDS = {
|
|
25
21
|
dev: '74fd96f8-cf4b-49d8-b713-2a121ea22910',
|
|
26
22
|
live: '970d9568-84c9-4613-b966-30d7e1d93828',
|
|
27
23
|
staging: 'bf0e5dd6-419f-4d64-8951-2c385533651f',
|
|
28
|
-
test: 'bf0e5dd6-419f-4d64-8951-2c385533651f',
|
|
29
24
|
};
|
|
30
25
|
const CONFIG_DIR = path.join(os.homedir(), '.aderis');
|
|
31
26
|
// Ensure config directory exists
|
|
@@ -86,6 +81,26 @@ export function updateContext(name, updates) {
|
|
|
86
81
|
contexts[name] = { ...contexts[name], ...updates };
|
|
87
82
|
config.set('contexts', contexts);
|
|
88
83
|
}
|
|
84
|
+
export function renameContext(oldName, newName) {
|
|
85
|
+
if (oldName === newName) {
|
|
86
|
+
throw new Error('New name must be different from the current name');
|
|
87
|
+
}
|
|
88
|
+
const contexts = config.get('contexts');
|
|
89
|
+
if (!contexts[oldName]) {
|
|
90
|
+
throw new Error(`Context "${oldName}" does not exist`);
|
|
91
|
+
}
|
|
92
|
+
if (contexts[newName]) {
|
|
93
|
+
throw new Error(`Context "${newName}" already exists`);
|
|
94
|
+
}
|
|
95
|
+
const renamed = { ...contexts[oldName], name: newName };
|
|
96
|
+
delete contexts[oldName];
|
|
97
|
+
contexts[newName] = renamed;
|
|
98
|
+
config.set('contexts', contexts);
|
|
99
|
+
// Keep the active context pointer in sync if we renamed the current one
|
|
100
|
+
if (config.get('current_context') === oldName) {
|
|
101
|
+
config.set('current_context', newName);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
89
104
|
export function deleteContext(name) {
|
|
90
105
|
const contexts = config.get('contexts');
|
|
91
106
|
if (!contexts[name]) {
|