@salesforce/packaging 5.0.9-spi.1 → 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.
@@ -179,6 +179,20 @@ export type PackageTrustLinkStatusResult = {
179
179
  EstablishedDate?: string;
180
180
  RevokedDate?: string;
181
181
  };
182
+ /** CLI --status values for `sf package trust link list` (PBO-admin). */
183
+ export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
184
+ /** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
185
+ export type PackageTrustLinkStatus = 'Pending' | 'Accepted' | 'Declined' | 'Revoked' | 'Failed';
186
+ export type PackageTrustLinkRecord = {
187
+ Id: string;
188
+ AuthoringOrg: string;
189
+ VerifiedOrg: string;
190
+ Status: PackageTrustLinkStatus;
191
+ RequestedBy: string | null;
192
+ CreatedDate: string;
193
+ EstablishedDate: string | null;
194
+ RevokedDate: string | null;
195
+ };
182
196
  export type PackageTrustLinkUnlinkResult = {
183
197
  removed: boolean;
184
198
  LinkRequestId?: string;
@@ -1,5 +1,5 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
2
+ import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
3
3
  export declare class PackageTrustLink {
4
4
  constructor();
5
5
  /**
@@ -26,6 +26,14 @@ export declare class PackageTrustLink {
26
26
  * @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
27
27
  */
28
28
  static status(connection: Connection): Promise<PackageTrustLinkStatusResult>;
29
+ /**
30
+ * List inbound Public Secure trust-link requests for the connected Verified PBO.
31
+ *
32
+ * Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
33
+ * self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
34
+ * Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
35
+ */
36
+ static list(connection: Connection, status?: PackageTrustLinkListStatusFilter): Promise<PackageTrustLinkRecord[]>;
29
37
  /**
30
38
  * Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
31
39
  * `Not Linked` state.
@@ -8,6 +8,21 @@ 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
+ const MINIMUM_API_VERSION = '68.0';
12
+ const ORGANIZATION_TYPE_VERIFIED = 'Verified';
13
+ const STATUS_FILTER_TO_API = {
14
+ pending: 'Pending',
15
+ approved: 'Accepted',
16
+ declined: 'Declined',
17
+ revoked: 'Revoked',
18
+ };
19
+ const isStatusFilter = (status) => Object.prototype.hasOwnProperty.call(STATUS_FILTER_TO_API, status);
20
+ const toApiStatus = (status) => {
21
+ if (!isStatusFilter(status)) {
22
+ throw messages.createError('invalidStatus', [status]);
23
+ }
24
+ return STATUS_FILTER_TO_API[status];
25
+ };
11
26
  // The absence of a trust link record is a valid state the CLI reports; the SObject Status
12
27
  // picklist itself only covers the states an existing link can be in.
13
28
  const NOT_LINKED = 'Not Linked';
@@ -84,6 +99,39 @@ class PackageTrustLink {
84
99
  ...(existing.RevokedDate ? { RevokedDate: existing.RevokedDate } : {}),
85
100
  };
86
101
  }
102
+ /**
103
+ * List inbound Public Secure trust-link requests for the connected Verified PBO.
104
+ *
105
+ * Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
106
+ * self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
107
+ * Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
108
+ */
109
+ static async list(connection, status) {
110
+ if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
111
+ throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
112
+ }
113
+ const orgId = connection.getAuthInfoFields()?.orgId;
114
+ if (!orgId) {
115
+ throw messages.createError('missingOrgId');
116
+ }
117
+ const verifiedOrgId = (0, core_1.trimTo15)(orgId);
118
+ const statusFilter = status ? toApiStatus(status) : undefined;
119
+ const statusClause = statusFilter ? ` AND Status = '${statusFilter}'` : '';
120
+ const query = 'SELECT Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate FROM ' +
121
+ `${TRUST_LINK_SOBJECT} WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
122
+ `AND AuthoringOrg != '${verifiedOrgId}'${statusClause} ORDER BY CreatedDate DESC`;
123
+ const result = await connection.autoFetchQuery(query, { tooling: true });
124
+ return (result.records ?? []).map(({ Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate }) => ({
125
+ Id,
126
+ AuthoringOrg,
127
+ VerifiedOrg,
128
+ Status,
129
+ RequestedBy: RequestedBy ?? null,
130
+ CreatedDate,
131
+ EstablishedDate: EstablishedDate ?? null,
132
+ RevokedDate: RevokedDate ?? null,
133
+ }));
134
+ }
87
135
  /**
88
136
  * Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
89
137
  * `Not Linked` state.
@@ -6,6 +6,18 @@ The Verified Org ID %s isn't valid. Specify a valid organization ID (starts with
6
6
 
7
7
  This org already has a trust link to Verified Org %s with status '%s'. An org can have only one trust link at a time; delete the existing trust link before requesting a new one.
8
8
 
9
+ # apiVersionTooLow
10
+
11
+ Package link requires API version %s or later.
12
+
13
+ # missingOrgId
14
+
15
+ Unable to determine the target org ID from the current connection.
16
+
17
+ # invalidStatus
18
+
19
+ The status %s is invalid. Valid values are: pending, approved, declined, revoked.
20
+
9
21
  # trustLinkNotFound
10
22
 
11
23
  This org has no trust link to remove; it's already in the Not Linked state.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "5.0.9-spi.1",
3
+ "version": "5.0.9-spi.3",
4
4
  "description": "Packaging library for the Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",