@salesforce/packaging 5.0.9-spi.0 → 5.0.9-spi.1
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.
|
@@ -170,6 +170,15 @@ export type PackageTrustLinkRequestResult = {
|
|
|
170
170
|
VerifiedOrgId: string;
|
|
171
171
|
Status: string;
|
|
172
172
|
};
|
|
173
|
+
export type PackageTrustLinkStatusResult = {
|
|
174
|
+
Status: string;
|
|
175
|
+
linked: boolean;
|
|
176
|
+
LinkRequestId?: string;
|
|
177
|
+
VerifiedOrgId?: string;
|
|
178
|
+
RequestedDate?: string;
|
|
179
|
+
EstablishedDate?: string;
|
|
180
|
+
RevokedDate?: string;
|
|
181
|
+
};
|
|
173
182
|
export type PackageTrustLinkUnlinkResult = {
|
|
174
183
|
removed: boolean;
|
|
175
184
|
LinkRequestId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
2
|
+
import { PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
3
3
|
export declare class PackageTrustLink {
|
|
4
4
|
constructor();
|
|
5
5
|
/**
|
|
@@ -14,6 +14,18 @@ export declare class PackageTrustLink {
|
|
|
14
14
|
* @returns the created trust relationship Id, verified org ID, and status.
|
|
15
15
|
*/
|
|
16
16
|
static request(connection: Connection, options: PackageTrustLinkRequestOptions): Promise<PackageTrustLinkRequestResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Report the connected authoring org's Public Secure (VerifiedDev) trust link state.
|
|
19
|
+
*
|
|
20
|
+
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
21
|
+
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
22
|
+
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
23
|
+
* state when the org has no link at all. It never mutates anything.
|
|
24
|
+
*
|
|
25
|
+
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
26
|
+
* @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
|
|
27
|
+
*/
|
|
28
|
+
static status(connection: Connection): Promise<PackageTrustLinkStatusResult>;
|
|
17
29
|
/**
|
|
18
30
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
19
31
|
* `Not Linked` state.
|
|
@@ -8,6 +8,9 @@ const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_
|
|
|
8
8
|
// Tooling API SObject backing the VerifiedDev (Public Secure) org-level trust relationship
|
|
9
9
|
// between the connected authoring org and a Verified PBO. See W-23970567 / SPI CLI design doc.
|
|
10
10
|
const TRUST_LINK_SOBJECT = 'PkgVrfyAuthOrgTrustRela';
|
|
11
|
+
// The absence of a trust link record is a valid state the CLI reports; the SObject Status
|
|
12
|
+
// picklist itself only covers the states an existing link can be in.
|
|
13
|
+
const NOT_LINKED = 'Not Linked';
|
|
11
14
|
class PackageTrustLink {
|
|
12
15
|
constructor() { }
|
|
13
16
|
/**
|
|
@@ -51,6 +54,36 @@ class PackageTrustLink {
|
|
|
51
54
|
Status: 'Pending',
|
|
52
55
|
};
|
|
53
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Report the connected authoring org's Public Secure (VerifiedDev) trust link state.
|
|
59
|
+
*
|
|
60
|
+
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
61
|
+
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
62
|
+
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
63
|
+
* state when the org has no link at all. It never mutates anything.
|
|
64
|
+
*
|
|
65
|
+
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
66
|
+
* @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
|
|
67
|
+
*/
|
|
68
|
+
static async status(connection) {
|
|
69
|
+
// The Tooling API query runs against the connected authoring org (AuthoringOrg is server-set),
|
|
70
|
+
// so this returns that org's own link if any. No record means the org was never linked.
|
|
71
|
+
const existing = await queryExistingTrustLink(connection);
|
|
72
|
+
if (!existing) {
|
|
73
|
+
return { Status: NOT_LINKED, linked: false };
|
|
74
|
+
}
|
|
75
|
+
// Only surface timestamps that are actually set — a Pending link has no EstablishedDate, and
|
|
76
|
+
// only a Revoked link has a RevokedDate. Emitting undefined keys would leak nulls into --json.
|
|
77
|
+
return {
|
|
78
|
+
Status: existing.Status,
|
|
79
|
+
linked: true,
|
|
80
|
+
LinkRequestId: existing.Id,
|
|
81
|
+
VerifiedOrgId: existing.VerifiedOrg,
|
|
82
|
+
...(existing.CreatedDate ? { RequestedDate: existing.CreatedDate } : {}),
|
|
83
|
+
...(existing.EstablishedDate ? { EstablishedDate: existing.EstablishedDate } : {}),
|
|
84
|
+
...(existing.RevokedDate ? { RevokedDate: existing.RevokedDate } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
54
87
|
/**
|
|
55
88
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
56
89
|
* `Not Linked` state.
|
|
@@ -84,7 +117,7 @@ class PackageTrustLink {
|
|
|
84
117
|
}
|
|
85
118
|
exports.PackageTrustLink = PackageTrustLink;
|
|
86
119
|
async function queryExistingTrustLink(connection) {
|
|
87
|
-
const query = `SELECT Id, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
120
|
+
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
88
121
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
89
122
|
return result.records?.[0];
|
|
90
123
|
}
|