@salesforce/packaging 5.0.9-spi.0 → 5.0.9-spi.2

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,20 @@ export type PackageTrustLinkRequestResult = {
170
170
  VerifiedOrgId: string;
171
171
  Status: string;
172
172
  };
173
+ /** CLI --status values for `sf package trust link list` (PBO-admin). */
174
+ export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
175
+ /** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
176
+ export type PackageTrustLinkStatus = 'Pending' | 'Accepted' | 'Declined' | 'Revoked' | 'Failed';
177
+ export type PackageTrustLinkRecord = {
178
+ Id: string;
179
+ AuthoringOrg: string;
180
+ VerifiedOrg: string;
181
+ Status: PackageTrustLinkStatus;
182
+ RequestedBy: string | null;
183
+ CreatedDate: string;
184
+ EstablishedDate: string | null;
185
+ RevokedDate: string | null;
186
+ };
173
187
  export type PackageTrustLinkUnlinkResult = {
174
188
  removed: boolean;
175
189
  LinkRequestId?: string;
@@ -1,5 +1,5 @@
1
1
  import { Connection } from '@salesforce/core';
2
- import { PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
2
+ import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
3
3
  export declare class PackageTrustLink {
4
4
  constructor();
5
5
  /**
@@ -14,6 +14,14 @@ 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
+ * List inbound Public Secure trust-link requests for the connected Verified PBO.
19
+ *
20
+ * Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
21
+ * self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
22
+ * Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
23
+ */
24
+ static list(connection: Connection, status?: PackageTrustLinkListStatusFilter): Promise<PackageTrustLinkRecord[]>;
17
25
  /**
18
26
  * Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
19
27
  * `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
  class PackageTrustLink {
12
27
  constructor() { }
13
28
  /**
@@ -51,6 +66,39 @@ class PackageTrustLink {
51
66
  Status: 'Pending',
52
67
  };
53
68
  }
69
+ /**
70
+ * List inbound Public Secure trust-link requests for the connected Verified PBO.
71
+ *
72
+ * Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
73
+ * self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
74
+ * Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
75
+ */
76
+ static async list(connection, status) {
77
+ if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
78
+ throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
79
+ }
80
+ const orgId = connection.getAuthInfoFields()?.orgId;
81
+ if (!orgId) {
82
+ throw messages.createError('missingOrgId');
83
+ }
84
+ const verifiedOrgId = (0, core_1.trimTo15)(orgId);
85
+ const statusFilter = status ? toApiStatus(status) : undefined;
86
+ const statusClause = statusFilter ? ` AND Status = '${statusFilter}'` : '';
87
+ const query = 'SELECT Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate FROM ' +
88
+ `${TRUST_LINK_SOBJECT} WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
89
+ `AND AuthoringOrg != '${verifiedOrgId}'${statusClause} ORDER BY CreatedDate DESC`;
90
+ const result = await connection.autoFetchQuery(query, { tooling: true });
91
+ return (result.records ?? []).map(({ Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate }) => ({
92
+ Id,
93
+ AuthoringOrg,
94
+ VerifiedOrg,
95
+ Status,
96
+ RequestedBy: RequestedBy ?? null,
97
+ CreatedDate,
98
+ EstablishedDate: EstablishedDate ?? null,
99
+ RevokedDate: RevokedDate ?? null,
100
+ }));
101
+ }
54
102
  /**
55
103
  * Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
56
104
  * `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.0",
3
+ "version": "5.0.9-spi.2",
4
4
  "description": "Packaging library for the Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",