@contrail/cli 3.6.0-alpha.f45f126 → 3.7.0-alpha.0d7ff29
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/README.md +405 -71
- package/dist/api/types.d.ts +35 -0
- package/dist/api/types.js +49 -1
- package/dist/auth/login.d.ts +1 -1
- package/dist/auth/login.js +47 -29
- package/dist/auth/login.spec.js +48 -15
- package/dist/auth/sign-in-error.d.ts +7 -0
- package/dist/auth/sign-in-error.js +24 -0
- package/dist/auth/sign-in-error.spec.d.ts +1 -0
- package/dist/auth/sign-in-error.spec.js +22 -0
- package/dist/auth/sso.d.ts +5 -3
- package/dist/auth/sso.js +34 -18
- package/dist/auth/sso.spec.js +63 -10
- package/dist/baseFlags.d.ts +4 -0
- package/dist/baseFlags.js +9 -1
- package/dist/basecommand.d.ts +5 -0
- package/dist/basecommand.js +17 -4
- package/dist/basecommand.spec.d.ts +1 -0
- package/dist/basecommand.spec.js +69 -0
- package/dist/commands/app/create.d.ts +1 -0
- package/dist/commands/app/delete.d.ts +1 -0
- package/dist/commands/app/extension/deploy.d.ts +1 -0
- package/dist/commands/app/extension/deployment/list.d.ts +1 -0
- package/dist/commands/app/getApiKey.d.ts +1 -0
- package/dist/commands/app/getApiKey.js +2 -2
- package/dist/commands/app/init.d.ts +1 -0
- package/dist/commands/app/install.d.ts +1 -0
- package/dist/commands/app/publish.d.ts +1 -0
- package/dist/commands/app/uninstall.d.ts +1 -0
- package/dist/commands/app/upgrade.d.ts +1 -0
- package/dist/commands/app/version/major.d.ts +1 -0
- package/dist/commands/app/version/minor.d.ts +1 -0
- package/dist/commands/app/version/patch.d.ts +1 -0
- package/dist/commands/config/create.d.ts +2 -0
- package/dist/commands/config/create.js +1 -0
- package/dist/commands/config/describe.d.ts +2 -0
- package/dist/commands/config/describe.js +7 -4
- package/dist/commands/config/list.d.ts +2 -0
- package/dist/commands/config/list.js +2 -3
- package/dist/commands/config/set.d.ts +1 -0
- package/dist/commands/config/set.js +11 -6
- package/dist/commands/config/use.d.ts +2 -0
- package/dist/commands/config/use.js +4 -0
- package/dist/commands/entities/create.d.ts +50 -0
- package/dist/commands/entities/create.js +618 -0
- package/dist/commands/entities/create.spec.d.ts +1 -0
- package/dist/commands/entities/create.spec.js +581 -0
- package/dist/commands/entities/delete.d.ts +21 -0
- package/dist/commands/entities/delete.js +146 -0
- package/dist/commands/entities/get.d.ts +26 -0
- package/dist/commands/entities/get.js +298 -0
- package/dist/commands/entities/grammar.spec.d.ts +1 -0
- package/dist/commands/entities/grammar.spec.js +79 -0
- package/dist/commands/entities/output.spec.d.ts +1 -0
- package/dist/commands/entities/output.spec.js +72 -0
- package/dist/commands/entities/update.d.ts +33 -0
- package/dist/commands/entities/update.js +212 -0
- package/dist/commands/feature-flags/export.d.ts +1 -0
- package/dist/commands/feature-flags/import.d.ts +1 -0
- package/dist/commands/file/upload.d.ts +1 -0
- package/dist/commands/groups/export.d.ts +1 -0
- package/dist/commands/groups/import.d.ts +1 -0
- package/dist/commands/instance/export.d.ts +1 -0
- package/dist/commands/instance/import.d.ts +1 -0
- package/dist/commands/load/colors.d.ts +1 -0
- package/dist/commands/load/custom-entity.d.ts +1 -0
- package/dist/commands/load/line-sheet.d.ts +1 -0
- package/dist/commands/load/upload-and-load.d.ts +1 -0
- package/dist/commands/load-local/index.d.ts +1 -0
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.js +1 -1
- package/dist/commands/org-config/export.d.ts +1 -0
- package/dist/commands/org-config/import.d.ts +1 -0
- package/dist/commands/projects/export.d.ts +1 -0
- package/dist/commands/projects/list.d.ts +1 -0
- package/dist/commands/projects/load.d.ts +1 -0
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/getAll.d.ts +1 -0
- package/dist/commands/types/getOptionSets.d.ts +1 -0
- package/dist/commands/types/loadAll.d.ts +1 -0
- package/dist/commands/types/mergeOptionSets.d.ts +1 -0
- package/dist/commands/types/mergeTypeProperties.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +1 -0
- package/dist/commands/types/parseTypesFromFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +1 -0
- package/dist/commands/types/uploadOptionSets.d.ts +1 -0
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +1 -0
- package/dist/commands/types/uploadRuleSets.d.ts +1 -0
- package/dist/commands/types/uploadTypeOverrides.d.ts +1 -0
- package/dist/commands/types/uploadTypePolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +1 -0
- package/dist/commands/types/uploadTypes.d.ts +1 -0
- package/dist/commands/users/export.d.ts +1 -0
- package/dist/commands/users/import.d.ts +1 -0
- package/dist/commands/webhooks/create.d.ts +1 -0
- package/dist/commands/webhooks/delete.d.ts +1 -0
- package/dist/commands/webhooks/delete.js +2 -3
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +1 -0
- package/dist/commands/webhooks/list.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/install.d.ts +1 -0
- package/dist/commands/workflow-template-definitions/list.d.ts +1 -0
- package/dist/commands/workflow-templates/delete.d.ts +1 -0
- package/dist/commands/workflow-templates/export.d.ts +1 -0
- package/dist/commands/workflow-templates/list.d.ts +1 -0
- package/dist/commands/workflow-templates/load.d.ts +1 -0
- package/dist/common.d.ts +10 -1
- package/dist/common.js +37 -1
- package/dist/common.spec.d.ts +1 -0
- package/dist/common.spec.js +40 -0
- package/dist/helpers/config/config.d.ts +4 -3
- package/dist/helpers/config/config.js +52 -45
- package/dist/helpers/config/config.spec.d.ts +1 -0
- package/dist/helpers/config/config.spec.js +79 -0
- package/dist/helpers/config/redact-tokens.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.js +14 -0
- package/dist/helpers/config/redact-tokens.spec.d.ts +1 -0
- package/dist/helpers/config/redact-tokens.spec.js +24 -0
- package/dist/helpers/entities/assortment-items.d.ts +11 -0
- package/dist/helpers/entities/assortment-items.js +76 -0
- package/dist/helpers/entities/batchFetch.d.ts +11 -0
- package/dist/helpers/entities/batchFetch.js +50 -0
- package/dist/helpers/entities/index.d.ts +3 -0
- package/dist/helpers/entities/index.js +6 -0
- package/dist/helpers/entities/items.d.ts +6 -0
- package/dist/helpers/entities/items.js +60 -0
- package/dist/helpers/entities/items.spec.d.ts +1 -0
- package/dist/helpers/entities/items.spec.js +19 -0
- package/dist/helpers/entities/project-items.d.ts +2 -0
- package/dist/helpers/entities/project-items.js +44 -0
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +20 -3
- package/dist/helpers/propertySpecifications/dateRanges.d.ts +34 -0
- package/dist/helpers/propertySpecifications/dateRanges.js +91 -0
- package/dist/helpers/propertySpecifications/dateRanges.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/dateRanges.spec.js +97 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.d.ts +39 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.js +102 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/propertySpecifications.spec.js +387 -0
- package/dist/helpers/propertySpecifications/propertyValues.d.ts +31 -0
- package/dist/helpers/propertySpecifications/propertyValues.js +132 -0
- package/dist/helpers/propertySpecifications/propertyValues.spec.d.ts +1 -0
- package/dist/helpers/propertySpecifications/propertyValues.spec.js +156 -0
- package/dist/logger.js +4 -1
- package/dist/logger.spec.d.ts +1 -0
- package/dist/logger.spec.js +12 -0
- package/node_modules/@contrail/entity-compare/package.json +6 -3
- package/node_modules/@contrail/loader/lib/common/conditional-columns.js +1 -1
- package/node_modules/@contrail/loader/lib/constants.d.ts +0 -8
- package/node_modules/@contrail/loader/lib/constants.js +1 -9
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.d.ts +0 -4
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.js +0 -57
- package/node_modules/@contrail/loader/lib/entities-v2/linesheet-v2/item-processor.spec.js +34 -492
- package/node_modules/@contrail/loader/lib/pipeline/validate.js +52 -2
- package/node_modules/@contrail/loader/lib/pipeline/validate.spec.js +85 -0
- package/node_modules/@contrail/loader/package.json +2 -2
- package/node_modules/@contrail/sdk/.github/workflows/publish-to-npm.yml +1 -4
- package/node_modules/@contrail/sdk/lib/auth/login.js +1 -1
- package/node_modules/@contrail/sdk/lib/config/config.d.ts +3 -0
- package/node_modules/@contrail/sdk/lib/config/config.js +13 -7
- package/node_modules/@contrail/sdk/lib/core/request.js +6 -2
- package/node_modules/@contrail/sdk/lib/entities/entities.client.d.ts +2 -0
- package/node_modules/@contrail/sdk/lib/entities/entities.client.js +3 -1
- package/node_modules/@contrail/sdk/lib/entities/entity.resource.registry.js +1 -0
- package/node_modules/@contrail/sdk/lib/image-search/image-search.d.ts +34 -0
- package/node_modules/@contrail/sdk/lib/image-search/image-search.js +42 -0
- package/node_modules/@contrail/sdk/lib/image-search/index.d.ts +1 -0
- package/node_modules/@contrail/sdk/lib/image-search/index.js +17 -0
- package/node_modules/@contrail/sdk/lib/index.d.ts +1 -0
- package/node_modules/@contrail/sdk/lib/index.js +1 -0
- package/node_modules/@contrail/sdk/package.json +1 -1
- package/node_modules/@contrail/sdk/scripts/replicate-bug.js +69 -0
- package/oclif.manifest.json +969 -9
- package/package.json +6 -12
|
@@ -6,6 +6,7 @@ export default class ExportUsers extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
outFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
};
|
|
@@ -3,6 +3,7 @@ export default class ImportUsers extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -4,6 +4,7 @@ export default class CreateWebhooks extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -4,6 +4,7 @@ export default class DeleteWebhooks extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -6,7 +6,6 @@ const login_1 = require("../../auth/login");
|
|
|
6
6
|
const webhooks_1 = require("../../api/webhooks");
|
|
7
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
8
|
const basecommand_1 = require("../../basecommand");
|
|
9
|
-
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
10
9
|
class DeleteWebhooks extends basecommand_1.BaseCommand {
|
|
11
10
|
static description = 'Delete an existing webhook. To delete a single webhook, pass its ID. To delete multiple webhooks, do not pass a value for the ID, and select multiple using the interactive selector';
|
|
12
11
|
static examples = [
|
|
@@ -43,10 +42,10 @@ class DeleteWebhooks extends basecommand_1.BaseCommand {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
if (this.flags.json) {
|
|
46
|
-
|
|
45
|
+
this.log(JSON.stringify(deletedWebhooks, null, 2));
|
|
47
46
|
}
|
|
48
47
|
else {
|
|
49
|
-
|
|
48
|
+
this.log(deletedWebhooks.map((x) => x.id).join('\n'));
|
|
50
49
|
}
|
|
51
50
|
}
|
|
52
51
|
}
|
|
@@ -3,6 +3,7 @@ export default class GetWebhookTrigger extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -4,6 +4,7 @@ export default class ListWebhooks extends BaseCommand {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
7
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -3,6 +3,7 @@ export default class InstallWorkflowTemplateDefinitions extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -3,6 +3,7 @@ export default class ListWorkflowTemplateDefinitions extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -3,6 +3,7 @@ export default class DeleteWorkflowTemplates extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -6,6 +6,7 @@ export default class ExportWorkflows extends BaseCommand {
|
|
|
6
6
|
static flags: {
|
|
7
7
|
outFile: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
8
|
overwrite: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
9
10
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
10
11
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
12
|
};
|
|
@@ -3,6 +3,7 @@ export default class ListWorkflowTemplates extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
|
@@ -3,6 +3,7 @@ export default class LoadWorkflowTemplates extends BaseCommand {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
+
config: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
6
7
|
alwaysConfirmEnv: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
7
8
|
logLevel: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
8
9
|
};
|
package/dist/common.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
export declare function getSeparatorByPlatform(): string;
|
|
3
3
|
export declare function delay(ms: number): Promise<NodeJS.Timeout>;
|
|
4
|
-
export declare function removeSlash(string:
|
|
4
|
+
export declare function removeSlash(string: string): string;
|
|
5
|
+
export declare function routeConsoleLogToStderr(): void;
|
|
6
|
+
export declare function sdkErrorMessage(reason: any): string;
|
|
7
|
+
export declare const promptOnStderr: any;
|
|
8
|
+
/**
|
|
9
|
+
* An id beginning with a hyphen is consumed as flags before a command sees it,
|
|
10
|
+
* which can silently switch on a boolean flag and shift the remaining arguments.
|
|
11
|
+
* Platform ids are long enough to tell apart from a cluster of short flags.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findIdParsedAsFlag(argv: string[], shortFlagsTakingValues?: string): string | undefined;
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
3
|
+
exports.findIdParsedAsFlag = exports.promptOnStderr = exports.sdkErrorMessage = exports.routeConsoleLogToStderr = exports.removeSlash = exports.delay = exports.getSeparatorByPlatform = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
4
6
|
function getSeparatorByPlatform() {
|
|
5
7
|
const isWin = process.platform === 'win32';
|
|
6
8
|
const separator = isWin ? '\\' : '/';
|
|
@@ -16,3 +18,37 @@ function removeSlash(string) {
|
|
|
16
18
|
return string.replace(re, '-');
|
|
17
19
|
}
|
|
18
20
|
exports.removeSlash = removeSlash;
|
|
21
|
+
// The SDK and auth flow print request logs and token messages via bare
|
|
22
|
+
// console.log. A command whose stdout is a data contract must route those to
|
|
23
|
+
// stderr before any of that code runs.
|
|
24
|
+
function routeConsoleLogToStderr() {
|
|
25
|
+
console.log = (...args) => console.error(...args);
|
|
26
|
+
}
|
|
27
|
+
exports.routeConsoleLogToStderr = routeConsoleLogToStderr;
|
|
28
|
+
// SDK errors can carry an empty message with the response body in details
|
|
29
|
+
function sdkErrorMessage(reason) {
|
|
30
|
+
return reason?.message || reason?.details || String(reason);
|
|
31
|
+
}
|
|
32
|
+
exports.sdkErrorMessage = sdkErrorMessage;
|
|
33
|
+
// inquirer renders prompt UI to its output stream directly, bypassing the
|
|
34
|
+
// console.log redirect; stdout must stay data-only
|
|
35
|
+
exports.promptOnStderr = inquirer_1.default.createPromptModule({ output: process.stderr });
|
|
36
|
+
/**
|
|
37
|
+
* An id beginning with a hyphen is consumed as flags before a command sees it,
|
|
38
|
+
* which can silently switch on a boolean flag and shift the remaining arguments.
|
|
39
|
+
* Platform ids are long enough to tell apart from a cluster of short flags.
|
|
40
|
+
*/
|
|
41
|
+
function findIdParsedAsFlag(argv, shortFlagsTakingValues = '') {
|
|
42
|
+
const separator = argv.indexOf('--');
|
|
43
|
+
const beforeSeparator = separator === -1 ? argv : argv.slice(0, separator);
|
|
44
|
+
return beforeSeparator.find((token) => {
|
|
45
|
+
// a long flag could never have been a short-flag cluster, and oclif rejects
|
|
46
|
+
// an unknown one itself
|
|
47
|
+
if (token.startsWith('--') || !/^-[A-Za-z0-9_-]{8,}$/.test(token)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
// oclif reads -rvalue as a flag with an attached value
|
|
51
|
+
return !shortFlagsTakingValues.includes(token[1]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.findIdParsedAsFlag = findIdParsedAsFlag;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("./common");
|
|
4
|
+
describe('findIdParsedAsFlag', () => {
|
|
5
|
+
const GET_SHORT_FLAGS_WITH_VALUES = 'loprst';
|
|
6
|
+
it('should find an id that a short flag cluster would swallow', () => {
|
|
7
|
+
expect((0, common_1.findIdParsedAsFlag)(['delete', 'item', '-d3YBdV-d8PXI88U'])).toBe('-d3YBdV-d8PXI88U');
|
|
8
|
+
});
|
|
9
|
+
it('should ignore long flags, whatever their length', () => {
|
|
10
|
+
const longFlags = [
|
|
11
|
+
'--paginated',
|
|
12
|
+
'--inputFile',
|
|
13
|
+
'--outputFile',
|
|
14
|
+
'--relations',
|
|
15
|
+
'--propertySlugs',
|
|
16
|
+
'--skipHydrateRelationships',
|
|
17
|
+
'--alwaysConfirmEnv',
|
|
18
|
+
'--apiVersion',
|
|
19
|
+
'--logLevel',
|
|
20
|
+
'--dryRun',
|
|
21
|
+
'--suffix',
|
|
22
|
+
];
|
|
23
|
+
longFlags.forEach((flag) => {
|
|
24
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', flag])).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
it('should ignore a short flag carrying an attached value', () => {
|
|
28
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-rprojectItems'], GET_SHORT_FLAGS_WITH_VALUES)).toBeUndefined();
|
|
29
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-ooutput12345'], GET_SHORT_FLAGS_WITH_VALUES)).toBeUndefined();
|
|
30
|
+
});
|
|
31
|
+
it('should still flag an id whose first character is not a value-taking flag', () => {
|
|
32
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-d3YBdV-d8PX'], GET_SHORT_FLAGS_WITH_VALUES)).toBe('-d3YBdV-d8PX');
|
|
33
|
+
});
|
|
34
|
+
it('should ignore everything after the -- separator', () => {
|
|
35
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '--', '-nJkS_UQjgRHrENJ'])).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
it('should ignore short flag clusters and ordinary arguments', () => {
|
|
38
|
+
expect((0, common_1.findIdParsedAsFlag)(['get', 'color', '-dS', '-t', '5', 'someId'])).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -9,10 +9,11 @@ export declare function readVibeIQConfig(): Promise<any>;
|
|
|
9
9
|
export declare function writeVibeIQConfig(config: any): Promise<void>;
|
|
10
10
|
export declare function storeVibeIQConfig(incomingConfig: any): Promise<void>;
|
|
11
11
|
export declare function createConfig(fileName: any): Promise<void>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function selectConfigForRun(configName: string | undefined): void;
|
|
13
|
+
export declare function fetchConfigNameForRun(): Promise<string>;
|
|
13
14
|
export declare function getConfig(): Promise<any>;
|
|
14
|
-
export declare function storeConfig(incomingConfig: any
|
|
15
|
+
export declare function storeConfig(incomingConfig: any): Promise<void>;
|
|
15
16
|
export declare function getConfigFiles(): Promise<any>;
|
|
16
17
|
export declare function getConfigContent(fileName: string): Promise<any>;
|
|
17
|
-
export declare function validateEnvironments(envName?:
|
|
18
|
+
export declare function validateEnvironments(envName?: string | null): Promise<any>;
|
|
18
19
|
export declare function checkTelemetry(cliVersion: string): Promise<void>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkTelemetry = exports.validateEnvironments = exports.getConfigContent = exports.getConfigFiles = exports.storeConfig = exports.getConfig = exports.
|
|
3
|
+
exports.checkTelemetry = exports.validateEnvironments = exports.getConfigContent = exports.getConfigFiles = exports.storeConfig = exports.getConfig = exports.fetchConfigNameForRun = exports.selectConfigForRun = exports.createConfig = exports.storeVibeIQConfig = exports.writeVibeIQConfig = exports.readVibeIQConfig = exports.initializeVibeIQConfig = exports.findEnvironmentName = exports.ENVIRONMENTS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
7
|
const node_os_1 = require("node:os");
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
9
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
9
10
|
const configFileName = 'config.json';
|
|
10
11
|
const defaultConfigFileName = 'default.json';
|
|
@@ -12,6 +13,8 @@ const userHomeDir = (0, node_os_1.homedir)();
|
|
|
12
13
|
const configDirectoryLocation = (0, node_path_1.join)(userHomeDir, '.vibeiq', 'configs');
|
|
13
14
|
const configFileLocation = (0, node_path_1.join)(configDirectoryLocation, configFileName);
|
|
14
15
|
const defaultConfigFileLocation = (0, node_path_1.join)(configDirectoryLocation, defaultConfigFileName);
|
|
16
|
+
let requestedConfigName;
|
|
17
|
+
let configNameForRun;
|
|
15
18
|
exports.ENVIRONMENTS = {
|
|
16
19
|
dev: 'https://api.dev.vibeiq.com/dev/api',
|
|
17
20
|
prod: 'https://api.vibeiq.com/prod/api',
|
|
@@ -34,8 +37,8 @@ async function initializeVibeIQConfig() {
|
|
|
34
37
|
configInUse: (0, node_path_1.parse)(defaultConfigFileName).name,
|
|
35
38
|
logLevel: 'debug',
|
|
36
39
|
};
|
|
37
|
-
await
|
|
38
|
-
await
|
|
40
|
+
await writeFileAtomically(configFileLocation, JSON.stringify(config, null, 2));
|
|
41
|
+
await writeFileAtomically(defaultConfigFileLocation, '{}');
|
|
39
42
|
}
|
|
40
43
|
catch (error) {
|
|
41
44
|
logger_1.default.error(`could not initialize config file (${configFileLocation}).`);
|
|
@@ -46,13 +49,13 @@ exports.initializeVibeIQConfig = initializeVibeIQConfig;
|
|
|
46
49
|
async function readVibeIQConfig() {
|
|
47
50
|
let fileContent;
|
|
48
51
|
try {
|
|
49
|
-
fileContent =
|
|
52
|
+
fileContent = (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
50
53
|
}
|
|
51
54
|
catch {
|
|
52
55
|
logger_1.default.debug(`failed to open config file (${configFileLocation}) for reading.`);
|
|
53
56
|
logger_1.default.debug('trying to initialize config file');
|
|
54
57
|
await initializeVibeIQConfig();
|
|
55
|
-
fileContent =
|
|
58
|
+
fileContent = (await node_fs_1.promises.readFile(configFileLocation)).toString();
|
|
56
59
|
}
|
|
57
60
|
try {
|
|
58
61
|
return JSON.parse(fileContent);
|
|
@@ -64,7 +67,7 @@ async function readVibeIQConfig() {
|
|
|
64
67
|
exports.readVibeIQConfig = readVibeIQConfig;
|
|
65
68
|
async function writeVibeIQConfig(config) {
|
|
66
69
|
try {
|
|
67
|
-
await
|
|
70
|
+
await writeFileAtomically(configFileLocation, JSON.stringify(config, null, 2));
|
|
68
71
|
}
|
|
69
72
|
catch (error) {
|
|
70
73
|
logger_1.default.error(`Could not open config file (${configFileLocation}) for writing.`);
|
|
@@ -82,7 +85,7 @@ async function storeVibeIQConfig(incomingConfig) {
|
|
|
82
85
|
exports.storeVibeIQConfig = storeVibeIQConfig;
|
|
83
86
|
async function createConfig(fileName) {
|
|
84
87
|
try {
|
|
85
|
-
await
|
|
88
|
+
await writeFileAtomically((0, node_path_1.join)(configDirectoryLocation, `${fileName}.json`), '{}');
|
|
86
89
|
}
|
|
87
90
|
catch (error) {
|
|
88
91
|
logger_1.default.error('Could not create config file.');
|
|
@@ -90,59 +93,63 @@ async function createConfig(fileName) {
|
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
exports.createConfig = createConfig;
|
|
93
|
-
async function writeConfig(config, configName
|
|
96
|
+
async function writeConfig(config, configName) {
|
|
94
97
|
try {
|
|
95
|
-
|
|
96
|
-
if (!configName) {
|
|
97
|
-
const fileContent = await readVibeIQConfig();
|
|
98
|
-
configFileName = fileContent.configInUse;
|
|
99
|
-
}
|
|
100
|
-
await node_fs_1.promises.writeFile((0, node_path_1.join)(configDirectoryLocation, `${configFileName}.json`), JSON.stringify(config, null, 2));
|
|
98
|
+
await writeFileAtomically((0, node_path_1.join)(configDirectoryLocation, `${configName}.json`), JSON.stringify(config, null, 2));
|
|
101
99
|
}
|
|
102
100
|
catch (error) {
|
|
103
101
|
logger_1.default.error('Could not open config file for writing.');
|
|
104
102
|
throw error;
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
function selectConfigForRun(configName) {
|
|
106
|
+
requestedConfigName = configName;
|
|
107
|
+
configNameForRun = undefined;
|
|
108
|
+
}
|
|
109
|
+
exports.selectConfigForRun = selectConfigForRun;
|
|
110
|
+
function fetchConfigNameForRun() {
|
|
111
|
+
configNameForRun ??= fetchConfigNameFromFlagOrPointer();
|
|
112
|
+
return configNameForRun;
|
|
113
|
+
}
|
|
114
|
+
exports.fetchConfigNameForRun = fetchConfigNameForRun;
|
|
115
|
+
async function fetchConfigNameFromFlagOrPointer() {
|
|
116
|
+
if (!requestedConfigName) {
|
|
117
|
+
const configInUse = (await readVibeIQConfig())?.configInUse;
|
|
118
|
+
if (!configInUse) {
|
|
119
|
+
throw new Error('No config selected. Pass --config, set CONTRAIL_CLI_CONFIG, or run `contrail config use`.');
|
|
120
|
+
}
|
|
121
|
+
return configInUse;
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const configNames = await getConfigFiles();
|
|
124
|
+
if (!configNames?.includes(requestedConfigName)) {
|
|
125
|
+
throw new Error(`No config named "${requestedConfigName}". Pass --config or set CONTRAIL_CLI_CONFIG to one of: ${configNames?.join(', ')}`);
|
|
125
126
|
}
|
|
127
|
+
return requestedConfigName;
|
|
128
|
+
}
|
|
129
|
+
async function getConfig() {
|
|
130
|
+
return getConfigContent(await fetchConfigNameForRun());
|
|
126
131
|
}
|
|
127
132
|
exports.getConfig = getConfig;
|
|
128
|
-
async function storeConfig(incomingConfig
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
configContent = await getConfigContent(configName);
|
|
135
|
-
}
|
|
136
|
-
let config = {
|
|
137
|
-
...configContent,
|
|
133
|
+
async function storeConfig(incomingConfig) {
|
|
134
|
+
const configName = await fetchConfigNameForRun();
|
|
135
|
+
const config = {
|
|
136
|
+
...(await getConfigContent(configName)),
|
|
138
137
|
...incomingConfig,
|
|
139
138
|
};
|
|
140
|
-
if (!merge) {
|
|
141
|
-
config = incomingConfig;
|
|
142
|
-
}
|
|
143
139
|
await writeConfig(config, configName);
|
|
144
140
|
}
|
|
145
141
|
exports.storeConfig = storeConfig;
|
|
142
|
+
async function writeFileAtomically(path, content) {
|
|
143
|
+
const tempPath = `${path}.${(0, node_crypto_1.randomUUID)()}.tmp`;
|
|
144
|
+
try {
|
|
145
|
+
await node_fs_1.promises.writeFile(tempPath, content, { mode: 0o600 });
|
|
146
|
+
await node_fs_1.promises.rename(tempPath, path);
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
await node_fs_1.promises.rm(tempPath, { force: true });
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
146
153
|
async function getConfigFiles() {
|
|
147
154
|
try {
|
|
148
155
|
const dirContent = (await node_fs_1.promises.readdir(configDirectoryLocation, { withFileTypes: true }))
|
|
@@ -165,7 +172,7 @@ async function getConfigContent(fileName) {
|
|
|
165
172
|
return JSON.parse(fileContent);
|
|
166
173
|
}
|
|
167
174
|
catch (error) {
|
|
168
|
-
logger_1.default.error(`Failed to open/parse config file (${fileName}) might be malformed or not found
|
|
175
|
+
logger_1.default.error(`Failed to open/parse config file (${fileName}) might be malformed or not found. Path: ${configFilePath}, error: ${error}`);
|
|
169
176
|
}
|
|
170
177
|
}
|
|
171
178
|
exports.getConfigContent = getConfigContent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
const os_1 = require("os");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
let mockHome;
|
|
7
|
+
jest.mock('node:os', () => ({
|
|
8
|
+
...jest.requireActual('node:os'),
|
|
9
|
+
homedir: () => mockHome,
|
|
10
|
+
}));
|
|
11
|
+
jest.mock('../../logger', () => ({
|
|
12
|
+
__esModule: true,
|
|
13
|
+
default: { debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() },
|
|
14
|
+
}));
|
|
15
|
+
const DEV = { apiGateway: 'https://api.dev.vibeiq.com/dev/api', orgSlug: 'adam-zone-1' };
|
|
16
|
+
const PROD = { apiGateway: 'https://api.vibeiq.com/prod/api', orgSlug: 'adam-prod-1' };
|
|
17
|
+
describe('config selection', () => {
|
|
18
|
+
let configDir;
|
|
19
|
+
let config;
|
|
20
|
+
const writeJson = (name, content) => (0, fs_1.writeFileSync)((0, path_1.join)(configDir, `${name}.json`), JSON.stringify(content));
|
|
21
|
+
const readJson = (name) => JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(configDir, `${name}.json`)).toString());
|
|
22
|
+
const switchPointerTo = (name) => writeJson('config', { configInUse: name });
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
mockHome = (0, fs_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), 'contrail-cli-config-'));
|
|
25
|
+
configDir = (0, path_1.join)(mockHome, '.vibeiq', 'configs');
|
|
26
|
+
(0, fs_1.mkdirSync)(configDir, { recursive: true });
|
|
27
|
+
writeJson('dev', DEV);
|
|
28
|
+
writeJson('prod', PROD);
|
|
29
|
+
switchPointerTo('dev');
|
|
30
|
+
jest.isolateModules(() => {
|
|
31
|
+
config = require('./config');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
jest.restoreAllMocks();
|
|
36
|
+
(0, fs_1.rmSync)(mockHome, { recursive: true, force: true });
|
|
37
|
+
});
|
|
38
|
+
it('should use the config chosen with config use when none is named', async () => {
|
|
39
|
+
config.selectConfigForRun(undefined);
|
|
40
|
+
expect(await config.getConfig()).toEqual(DEV);
|
|
41
|
+
});
|
|
42
|
+
it('should use the named config over the one chosen with config use', async () => {
|
|
43
|
+
config.selectConfigForRun('prod');
|
|
44
|
+
expect(await config.getConfig()).toEqual(PROD);
|
|
45
|
+
});
|
|
46
|
+
it('should keep reading and saving the config it started with after another terminal switches', async () => {
|
|
47
|
+
config.selectConfigForRun(undefined);
|
|
48
|
+
await config.getConfig();
|
|
49
|
+
switchPointerTo('prod');
|
|
50
|
+
await config.storeConfig({ apiUserToken: 'refreshed-dev-token' });
|
|
51
|
+
expect(await config.getConfig()).toEqual({ ...DEV, apiUserToken: 'refreshed-dev-token' });
|
|
52
|
+
expect(readJson('prod')).toEqual(PROD);
|
|
53
|
+
});
|
|
54
|
+
it('should fail when no config is named and none is chosen with config use', async () => {
|
|
55
|
+
writeJson('config', {});
|
|
56
|
+
config.selectConfigForRun(undefined);
|
|
57
|
+
await expect(config.getConfig()).rejects.toThrow('No config selected.');
|
|
58
|
+
});
|
|
59
|
+
it('should fail and list the configs when the named config does not exist', async () => {
|
|
60
|
+
config.selectConfigForRun('staging');
|
|
61
|
+
await expect(config.getConfig()).rejects.toThrow('No config named "staging". Pass --config or set CONTRAIL_CLI_CONFIG to one of: dev, prod');
|
|
62
|
+
});
|
|
63
|
+
it('should leave the previous config intact when a save dies partway', async () => {
|
|
64
|
+
config.selectConfigForRun('dev');
|
|
65
|
+
const realWriteFile = fs_1.promises.writeFile;
|
|
66
|
+
jest.spyOn(fs_1.promises, 'writeFile').mockImplementationOnce(async (path) => {
|
|
67
|
+
await realWriteFile(path, '{"apiGatew');
|
|
68
|
+
throw new Error('ENOSPC: no space left on device');
|
|
69
|
+
});
|
|
70
|
+
await expect(config.storeConfig({ apiUserToken: 'new-token' })).rejects.toThrow('ENOSPC');
|
|
71
|
+
expect(readJson('dev')).toEqual(DEV);
|
|
72
|
+
expect((0, fs_1.readdirSync)(configDir).filter((file) => file.endsWith('.tmp'))).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
it('should keep a saved config readable only by its owner', async () => {
|
|
75
|
+
config.selectConfigForRun('dev');
|
|
76
|
+
await config.storeConfig({ apiUserToken: 'new-token' });
|
|
77
|
+
expect((0, fs_1.statSync)((0, path_1.join)(configDir, 'dev.json')).mode & 0o777).toBe(0o600);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redactTokens(config: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redactTokens = void 0;
|
|
4
|
+
const TOKEN_FIELDS = ['apiUserToken', 'apiRefreshToken'];
|
|
5
|
+
function redactTokens(config) {
|
|
6
|
+
const redacted = { ...config };
|
|
7
|
+
for (const field of TOKEN_FIELDS) {
|
|
8
|
+
if (redacted[field]) {
|
|
9
|
+
redacted[field] = '[redacted]';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return redacted;
|
|
13
|
+
}
|
|
14
|
+
exports.redactTokens = redactTokens;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const redact_tokens_1 = require("./redact-tokens");
|
|
4
|
+
describe('redactTokens', () => {
|
|
5
|
+
it('should hide the access and refresh tokens and keep the org and environment', () => {
|
|
6
|
+
expect((0, redact_tokens_1.redactTokens)({
|
|
7
|
+
apiGateway: 'https://api.dev.vibeiq.com/dev/api',
|
|
8
|
+
orgSlug: 'adam-zone-1',
|
|
9
|
+
apiUserToken: 'secret-access',
|
|
10
|
+
apiRefreshToken: 'secret-refresh',
|
|
11
|
+
})).toEqual({
|
|
12
|
+
apiGateway: 'https://api.dev.vibeiq.com/dev/api',
|
|
13
|
+
orgSlug: 'adam-zone-1',
|
|
14
|
+
apiUserToken: '[redacted]',
|
|
15
|
+
apiRefreshToken: '[redacted]',
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it('should leave a config without tokens unchanged', () => {
|
|
19
|
+
expect((0, redact_tokens_1.redactTokens)({ orgSlug: 'adam-zone-1', apiRefreshToken: null })).toEqual({
|
|
20
|
+
orgSlug: 'adam-zone-1',
|
|
21
|
+
apiRefreshToken: null,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Item } from '@contrail/entity-types';
|
|
2
|
+
import { API_VERSION } from '@contrail/sdk';
|
|
3
|
+
export declare function createAssortmentItem(assortmentItem: {
|
|
4
|
+
assortmentId: string;
|
|
5
|
+
itemId: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}, options?: {
|
|
8
|
+
skipHydrateRelationships?: boolean;
|
|
9
|
+
apiVersion?: API_VERSION;
|
|
10
|
+
}): Promise<any>;
|
|
11
|
+
export declare function findItemsNotInAssortment(assortmentId: string, count?: number): Promise<Item[]>;
|