@salesforce/packaging 5.0.9-spi.2 → 5.0.9-spi.3
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
|
/** CLI --status values for `sf package trust link list` (PBO-admin). */
|
|
174
183
|
export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
|
|
175
184
|
/** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
2
|
+
import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, 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
|
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
19
31
|
*
|
|
@@ -23,6 +23,9 @@ const toApiStatus = (status) => {
|
|
|
23
23
|
}
|
|
24
24
|
return STATUS_FILTER_TO_API[status];
|
|
25
25
|
};
|
|
26
|
+
// The absence of a trust link record is a valid state the CLI reports; the SObject Status
|
|
27
|
+
// picklist itself only covers the states an existing link can be in.
|
|
28
|
+
const NOT_LINKED = 'Not Linked';
|
|
26
29
|
class PackageTrustLink {
|
|
27
30
|
constructor() { }
|
|
28
31
|
/**
|
|
@@ -66,6 +69,36 @@ class PackageTrustLink {
|
|
|
66
69
|
Status: 'Pending',
|
|
67
70
|
};
|
|
68
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Report the connected authoring org's Public Secure (VerifiedDev) trust link state.
|
|
74
|
+
*
|
|
75
|
+
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
76
|
+
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
77
|
+
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
78
|
+
* state when the org has no link at all. It never mutates anything.
|
|
79
|
+
*
|
|
80
|
+
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
81
|
+
* @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
|
|
82
|
+
*/
|
|
83
|
+
static async status(connection) {
|
|
84
|
+
// The Tooling API query runs against the connected authoring org (AuthoringOrg is server-set),
|
|
85
|
+
// so this returns that org's own link if any. No record means the org was never linked.
|
|
86
|
+
const existing = await queryExistingTrustLink(connection);
|
|
87
|
+
if (!existing) {
|
|
88
|
+
return { Status: NOT_LINKED, linked: false };
|
|
89
|
+
}
|
|
90
|
+
// Only surface timestamps that are actually set — a Pending link has no EstablishedDate, and
|
|
91
|
+
// only a Revoked link has a RevokedDate. Emitting undefined keys would leak nulls into --json.
|
|
92
|
+
return {
|
|
93
|
+
Status: existing.Status,
|
|
94
|
+
linked: true,
|
|
95
|
+
LinkRequestId: existing.Id,
|
|
96
|
+
VerifiedOrgId: existing.VerifiedOrg,
|
|
97
|
+
...(existing.CreatedDate ? { RequestedDate: existing.CreatedDate } : {}),
|
|
98
|
+
...(existing.EstablishedDate ? { EstablishedDate: existing.EstablishedDate } : {}),
|
|
99
|
+
...(existing.RevokedDate ? { RevokedDate: existing.RevokedDate } : {}),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
69
102
|
/**
|
|
70
103
|
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
71
104
|
*
|
|
@@ -132,7 +165,7 @@ class PackageTrustLink {
|
|
|
132
165
|
}
|
|
133
166
|
exports.PackageTrustLink = PackageTrustLink;
|
|
134
167
|
async function queryExistingTrustLink(connection) {
|
|
135
|
-
const query = `SELECT Id, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
168
|
+
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
136
169
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
137
170
|
return result.records?.[0];
|
|
138
171
|
}
|