@salesforce/plugin-signups 1.5.6 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +66 -66
- package/lib/commands/org/create/shape.d.ts +3 -3
- package/lib/commands/org/create/shape.js +20 -22
- package/lib/commands/org/create/shape.js.map +1 -1
- package/lib/commands/org/create/snapshot.d.ts +7 -7
- package/lib/commands/org/create/snapshot.js +46 -50
- package/lib/commands/org/create/snapshot.js.map +1 -1
- package/lib/commands/org/delete/shape.d.ts +5 -20
- package/lib/commands/org/delete/shape.js +28 -73
- package/lib/commands/org/delete/shape.js.map +1 -1
- package/lib/commands/org/delete/snapshot.d.ts +4 -4
- package/lib/commands/org/delete/snapshot.js +28 -30
- package/lib/commands/org/delete/snapshot.js.map +1 -1
- package/lib/commands/org/get/snapshot.d.ts +5 -5
- package/lib/commands/org/get/snapshot.js +27 -29
- package/lib/commands/org/get/snapshot.js.map +1 -1
- package/lib/commands/org/list/shape.d.ts +3 -7
- package/lib/commands/org/list/shape.js +22 -34
- package/lib/commands/org/list/shape.js.map +1 -1
- package/lib/commands/org/list/snapshot.d.ts +4 -4
- package/lib/commands/org/list/snapshot.js +21 -23
- package/lib/commands/org/list/snapshot.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/shared/deleteUtils.d.ts +19 -0
- package/lib/shared/deleteUtils.js +58 -0
- package/lib/shared/deleteUtils.js.map +1 -0
- package/lib/shared/orgShapeListUtils.d.ts +13 -0
- package/lib/shared/orgShapeListUtils.js +26 -13
- package/lib/shared/orgShapeListUtils.js.map +1 -1
- package/lib/shared/snapshot.d.ts +0 -2
- package/lib/shared/snapshot.js +20 -32
- package/lib/shared/snapshot.js.map +1 -1
- package/messages/messages.md +4 -0
- package/oclif.lock +611 -718
- package/oclif.manifest.json +573 -245
- package/package.json +35 -55
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../../../src/commands/org/list/snapshot.ts"],"names":[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AAC;QACjD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YACvB,gBAAgB,CAAC,OAAO,CAAC,CAAC;SAC3B;QACD,OAAO,OAAO,CAAC;IACjB,CAAC"}
|
package/lib/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
declare const _default: {};
|
2
|
-
export
|
2
|
+
export default _default;
|
package/lib/index.js
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
"use strict";
|
2
1
|
/*
|
3
2
|
* Copyright (c) 2021, salesforce.com, inc.
|
4
3
|
* All rights reserved.
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
7
6
|
*/
|
8
|
-
|
7
|
+
export default {};
|
9
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,EAAE,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
2
|
+
export type FailureMsg = {
|
3
|
+
shapeId: string;
|
4
|
+
message: string;
|
5
|
+
};
|
6
|
+
export type DeleteAllResult = {
|
7
|
+
shapeIds: string[];
|
8
|
+
failures: FailureMsg[];
|
9
|
+
};
|
10
|
+
/**
|
11
|
+
* Delete all ShapeRepresentation records for the shapeOrg.
|
12
|
+
*
|
13
|
+
* @return List of SR IDs that were deleted
|
14
|
+
*/
|
15
|
+
export declare const deleteAll: (conn: Connection, username: string) => Promise<DeleteAllResult>;
|
16
|
+
declare const _default: {
|
17
|
+
deleteAll: (conn: Connection<import("jsforce").Schema>, username: string) => Promise<DeleteAllResult>;
|
18
|
+
};
|
19
|
+
export default _default;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
3
|
+
* All rights reserved.
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
6
|
+
*/
|
7
|
+
import { dirname } from 'node:path';
|
8
|
+
import { fileURLToPath } from 'node:url';
|
9
|
+
import { Messages } from '@salesforce/core';
|
10
|
+
/**
|
11
|
+
* Delete all ShapeRepresentation records for the shapeOrg.
|
12
|
+
*
|
13
|
+
* @return List of SR IDs that were deleted
|
14
|
+
*/
|
15
|
+
export const deleteAll = async (conn, username) => {
|
16
|
+
let shapeIds = [];
|
17
|
+
const deleteAllResult = {
|
18
|
+
shapeIds: [],
|
19
|
+
failures: [],
|
20
|
+
};
|
21
|
+
try {
|
22
|
+
const result = await conn.query('SELECT Id FROM ShapeRepresentation');
|
23
|
+
if (result.totalSize === 0) {
|
24
|
+
return deleteAllResult;
|
25
|
+
}
|
26
|
+
shapeIds = result.records.map((shape) => shape.Id);
|
27
|
+
}
|
28
|
+
catch (err) {
|
29
|
+
const JsForceErr = err;
|
30
|
+
if (JsForceErr.errorCode && JsForceErr.errorCode === 'INVALID_TYPE') {
|
31
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
32
|
+
const messages = Messages.loadMessages('@salesforce/plugin-signups', 'shape.delete');
|
33
|
+
// ShapeExportPref is not enabled, or user does not have CRUD access
|
34
|
+
throw messages.createError('noAccess', [username]);
|
35
|
+
}
|
36
|
+
// non-access error
|
37
|
+
throw JsForceErr;
|
38
|
+
}
|
39
|
+
await Promise.all(shapeIds.map(async (id) => {
|
40
|
+
try {
|
41
|
+
const delResult = await conn.sobject('ShapeRepresentation').delete(id);
|
42
|
+
if (delResult.success) {
|
43
|
+
deleteAllResult.shapeIds.push(id);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
catch (err) {
|
47
|
+
deleteAllResult.failures.push({
|
48
|
+
shapeId: id,
|
49
|
+
message: err instanceof Error ? err.message : 'error contained no message',
|
50
|
+
});
|
51
|
+
}
|
52
|
+
}));
|
53
|
+
return deleteAllResult;
|
54
|
+
};
|
55
|
+
export default {
|
56
|
+
deleteAll,
|
57
|
+
};
|
58
|
+
//# sourceMappingURL=deleteUtils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"deleteUtils.js","sourceRoot":"","sources":["../../src/shared/deleteUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAc,MAAM,kBAAkB,CAAC;AAuBxD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,IAAgB,EAAE,QAAgB,EAA4B,EAAE;IAC9F,IAAI,QAAQ,GAAa,EAAE,CAAC;IAC5B,MAAM,eAAe,GAAoB;QACvC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACb,CAAC;IACF,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAsB,oCAAoC,CAAC,CAAC;QAC3F,IAAI,MAAM,CAAC,SAAS,KAAK,CAAC,EAAE;YAC1B,OAAO,eAAe,CAAC;SACxB;QACD,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACpD;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,UAAU,GAAG,GAAmB,CAAC;QACvC,IAAI,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,KAAK,cAAc,EAAE;YACnE,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,cAAc,CAAC,CAAC;YAErF,oEAAoE;YACpE,MAAM,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;SACpD;QACD,mBAAmB;QACnB,MAAM,UAAU,CAAC;KAClB;IAED,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QACxB,IAAI;YACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACvE,IAAI,SAAS,CAAC,OAAO,EAAE;gBACrB,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aACnC;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC5B,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,4BAA4B;aAC3E,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,eAAe;IACb,SAAS;CACV,CAAC"}
|
@@ -17,3 +17,16 @@ export declare function getAllShapesFromOrg(orgAuth: OrgAuthorization): Promise<
|
|
17
17
|
* Check if the ShapeExportPilot preference is enabled.
|
18
18
|
*/
|
19
19
|
export declare function isShapeEnabled(conn: Connection): Promise<boolean>;
|
20
|
+
export declare const getAllOrgShapesFromAuthenticatedOrgs: () => Promise<{
|
21
|
+
orgShapes: OrgShapeListResult[];
|
22
|
+
errors: Error[];
|
23
|
+
}>;
|
24
|
+
declare const _default: {
|
25
|
+
getAllOrgShapesFromAuthenticatedOrgs: () => Promise<{
|
26
|
+
orgShapes: OrgShapeListResult[];
|
27
|
+
errors: Error[];
|
28
|
+
}>;
|
29
|
+
isShapeEnabled: typeof isShapeEnabled;
|
30
|
+
getAllShapesFromOrg: typeof getAllShapesFromOrg;
|
31
|
+
};
|
32
|
+
export default _default;
|
@@ -1,19 +1,17 @@
|
|
1
|
-
"use strict";
|
2
1
|
/*
|
3
2
|
* Copyright (c) 2022, salesforce.com, inc.
|
4
3
|
* All rights reserved.
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
7
6
|
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const org = await core_1.Org.create({ aliasOrUsername: orgAuth.username });
|
7
|
+
import { dirname } from 'node:path';
|
8
|
+
import { fileURLToPath } from 'node:url';
|
9
|
+
import { AuthInfo, Logger, Messages, Org, SfError } from '@salesforce/core';
|
10
|
+
import { settleAll } from '@salesforce/kit';
|
11
|
+
export async function getAllShapesFromOrg(orgAuth) {
|
12
|
+
const org = await Org.create({ aliasOrUsername: orgAuth.username });
|
15
13
|
const conn = org.getConnection();
|
16
|
-
const logger = await
|
14
|
+
const logger = await Logger.child(`getAllShapesFromOrg, ${orgAuth.username}`);
|
17
15
|
logger.info(`Query org: ${orgAuth.username} for shapes`);
|
18
16
|
try {
|
19
17
|
const shapesFound = await conn.query("SELECT Id, Status, CreatedBy.Username, CreatedDate FROM ShapeRepresentation WHERE Status IN ( 'Active', 'InProgress' )");
|
@@ -36,20 +34,35 @@ async function getAllShapesFromOrg(orgAuth) {
|
|
36
34
|
}
|
37
35
|
else {
|
38
36
|
logger.error(false, 'Error finding org shapes', JsForceErr);
|
39
|
-
const error =
|
37
|
+
const error = SfError.wrap(JsForceErr);
|
38
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
39
|
+
const messages = Messages.loadMessages('@salesforce/plugin-signups', 'messages');
|
40
40
|
error.message = messages.getMessage('errorWithOrg', [orgAuth.username, JsForceErr.message]);
|
41
41
|
return Promise.reject(error);
|
42
42
|
}
|
43
43
|
}
|
44
44
|
}
|
45
|
-
exports.getAllShapesFromOrg = getAllShapesFromOrg;
|
46
45
|
/**
|
47
46
|
* Check if the ShapeExportPilot preference is enabled.
|
48
47
|
*/
|
49
|
-
async function isShapeEnabled(conn) {
|
48
|
+
export async function isShapeEnabled(conn) {
|
50
49
|
const prefValue = await conn.tooling.query(`SELECT IsShapeExportPrefEnabled FROM ${'DevHubSettings'}`);
|
51
50
|
// no records are returned if ShapeExportPilot perm is disabled
|
52
51
|
return prefValue.totalSize > 0 && prefValue.records?.[0]?.IsShapeExportPrefEnabled;
|
53
52
|
}
|
54
|
-
|
53
|
+
export const getAllOrgShapesFromAuthenticatedOrgs = async () => {
|
54
|
+
const orgs = await AuthInfo.listAllAuthorizations((orgAuth) => !orgAuth.error && !orgAuth.isScratchOrg);
|
55
|
+
if (orgs.length === 0) {
|
56
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
57
|
+
const messages = Messages.loadMessages('@salesforce/plugin-signups', 'messages');
|
58
|
+
throw messages.createError('noAuthFound');
|
59
|
+
}
|
60
|
+
const shapes = await settleAll(orgs.map((o) => getAllShapesFromOrg(o)));
|
61
|
+
return { orgShapes: shapes.fulfilled.flat(), errors: shapes.rejected };
|
62
|
+
};
|
63
|
+
export default {
|
64
|
+
getAllOrgShapesFromAuthenticatedOrgs,
|
65
|
+
isShapeEnabled,
|
66
|
+
getAllShapesFromOrg,
|
67
|
+
};
|
55
68
|
//# sourceMappingURL=orgShapeListUtils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"orgShapeListUtils.js","sourceRoot":"","sources":["../../src/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MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACxG,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,UAAU,CAAC,CAAC;QACjF,MAAM,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;KAC3C;IACD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAuB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9F,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;AACzE,CAAC,CAAC;AAEF,eAAe;IACb,oCAAoC;IACpC,cAAc;IACd,mBAAmB;CACpB,CAAC"}
|
package/lib/shared/snapshot.d.ts
CHANGED
package/lib/shared/snapshot.js
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
"use strict";
|
2
1
|
/*
|
3
2
|
* Copyright (c) 2020, salesforce.com, inc.
|
4
3
|
* All rights reserved.
|
5
4
|
* Licensed under the BSD 3-Clause license.
|
6
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
7
6
|
*/
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const messages =
|
15
|
-
|
7
|
+
import { dirname } from 'node:path';
|
8
|
+
import { fileURLToPath } from 'node:url';
|
9
|
+
import { ux } from '@oclif/core';
|
10
|
+
import { SfError, Messages } from '@salesforce/core';
|
11
|
+
import { capitalCase } from 'change-case';
|
12
|
+
Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
|
13
|
+
const messages = Messages.loadMessages('@salesforce/plugin-signups', 'snapshot');
|
14
|
+
export const ORG_SNAPSHOT_FIELDS = [
|
16
15
|
'Id',
|
17
16
|
'SnapshotName',
|
18
17
|
'Description',
|
@@ -21,8 +20,6 @@ exports.ORG_SNAPSHOT_FIELDS = [
|
|
21
20
|
'CreatedDate',
|
22
21
|
'LastModifiedDate',
|
23
22
|
'ExpirationDate',
|
24
|
-
'LastClonedDate',
|
25
|
-
'LastClonedById',
|
26
23
|
'Error',
|
27
24
|
];
|
28
25
|
const dateTimeFormatter = (dateString) => dateString
|
@@ -52,11 +49,6 @@ const ORG_SNAPSHOT_COLUMNS = {
|
|
52
49
|
header: 'Expiration Date',
|
53
50
|
get: (row) => (row.ExpirationDate ? new Date(row.ExpirationDate).toLocaleDateString() : ''),
|
54
51
|
},
|
55
|
-
LastClonedDate: {
|
56
|
-
header: 'Last Cloned Date',
|
57
|
-
get: (row) => rowDateTimeFormatter(row, 'LastClonedDate'),
|
58
|
-
},
|
59
|
-
LastClonedById: { header: 'Last Cloned By Id', get: (row) => row.LastClonedById ?? '' },
|
60
52
|
};
|
61
53
|
const invalidTypeErrorHandler = (e) => {
|
62
54
|
if (e instanceof Error && e.name === 'INVALID_TYPE') {
|
@@ -64,8 +56,8 @@ const invalidTypeErrorHandler = (e) => {
|
|
64
56
|
}
|
65
57
|
throw e;
|
66
58
|
};
|
67
|
-
const queryAll = async (conn) => {
|
68
|
-
const query = `SELECT ${
|
59
|
+
export const queryAll = async (conn) => {
|
60
|
+
const query = `SELECT ${ORG_SNAPSHOT_FIELDS.join(',')} FROM OrgSnapshot Order by CreatedDate`;
|
69
61
|
try {
|
70
62
|
const result = (await conn.query(query)).records;
|
71
63
|
return result;
|
@@ -74,44 +66,40 @@ const queryAll = async (conn) => {
|
|
74
66
|
return invalidTypeErrorHandler(e);
|
75
67
|
}
|
76
68
|
};
|
77
|
-
|
78
|
-
const
|
79
|
-
const query = `SELECT ${exports.ORG_SNAPSHOT_FIELDS.join(',')} FROM OrgSnapshot WHERE ${nameOrId.startsWith('0Oo') ? 'Id' : 'SnapshotName'} = '${nameOrId}'`;
|
69
|
+
export const queryByNameOrId = async (conn, nameOrId) => {
|
70
|
+
const query = `SELECT ${ORG_SNAPSHOT_FIELDS.join(',')} FROM OrgSnapshot WHERE ${nameOrId.startsWith('0Oo') ? 'Id' : 'SnapshotName'} = '${nameOrId}'`;
|
80
71
|
try {
|
81
72
|
const result = await conn.singleRecordQuery(query);
|
82
73
|
return result;
|
83
74
|
}
|
84
75
|
catch (e) {
|
85
|
-
if (e instanceof
|
76
|
+
if (e instanceof SfError && e.name === 'SingleRecordQuery_NoRecords') {
|
86
77
|
e.message = messages.getMessage('noSnapshots', [nameOrId]);
|
87
78
|
}
|
88
79
|
return invalidTypeErrorHandler(e);
|
89
80
|
}
|
90
81
|
};
|
91
|
-
|
92
|
-
|
93
|
-
core_1.ux.table(Object.entries(snapshotRecord)
|
82
|
+
export const printSingleRecordTable = (snapshotRecord) => {
|
83
|
+
ux.table(Object.entries(snapshotRecord)
|
94
84
|
.filter(([key]) => key !== 'attributes')
|
95
85
|
// remove empty error field
|
96
86
|
.filter(([key, value]) => key !== 'Error' || typeof value === 'string')
|
97
87
|
// every field on the type is a string
|
98
88
|
.map(([key, value]) => ({
|
99
|
-
Name:
|
89
|
+
Name: capitalCase(key),
|
100
90
|
// format the datetime values
|
101
|
-
Value: ['LastModifiedDate', '
|
91
|
+
Value: ['LastModifiedDate', 'CreatedDate'].includes(key) ? dateTimeFormatter(value) : value,
|
102
92
|
}))
|
103
93
|
// null/undefined becomes empty string
|
104
94
|
.map((row) => (row.Value ? row : { ...row, Value: '' })), { Name: {}, Value: {} });
|
105
95
|
};
|
106
|
-
|
107
|
-
const printRecordTable = (snapshotRecords) => {
|
96
|
+
export const printRecordTable = (snapshotRecords) => {
|
108
97
|
if (snapshotRecords.length === 0) {
|
109
|
-
|
98
|
+
ux.log('No snapshots found');
|
110
99
|
return;
|
111
100
|
}
|
112
|
-
|
101
|
+
ux.table(
|
113
102
|
// we know what columns we want, so filter out the other fields
|
114
103
|
snapshotRecords.map((s) => Object.fromEntries(Object.entries(s).filter(([key]) => Object.keys(ORG_SNAPSHOT_COLUMNS).includes(key)))), ORG_SNAPSHOT_COLUMNS, { title: `Org Snapshots [${snapshotRecords.length}]`, 'no-truncate': true });
|
115
104
|
};
|
116
|
-
exports.printRecordTable = printRecordTable;
|
117
105
|
//# sourceMappingURL=snapshot.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/shared/snapshot.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/shared/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAc,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC1E,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,UAAU,CAAC,CAAC;AAkBjF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI;IACJ,cAAc;IACd,aAAa;IACb,QAAQ;IACR,WAAW;IACX,aAAa;IACb,kBAAkB;IAClB,gBAAgB;IAChB,OAAO;CACR,CAAC;AACF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