@pipeline-builder/pipeline-data 4.1.15 → 4.1.16
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.
- package/lib/api/access-control-builder.d.ts +18 -1
- package/lib/api/access-control-builder.js +19 -6
- package/lib/api/crud-service.d.ts +94 -36
- package/lib/api/crud-service.js +188 -166
- package/lib/api/plugin-resolution.d.ts +253 -0
- package/lib/api/plugin-resolution.js +649 -0
- package/lib/api/public-directory.d.ts +281 -0
- package/lib/api/public-directory.js +457 -0
- package/lib/api/query-builders.d.ts +13 -0
- package/lib/api/query-builders.js +74 -9
- package/lib/api/reporting/caches.js +4 -4
- package/lib/api/reporting/dora-scoring.d.ts +3 -3
- package/lib/api/reporting/dora-scoring.js +4 -4
- package/lib/api/reporting/dora.d.ts +6 -6
- package/lib/api/reporting/dora.js +97 -73
- package/lib/api/reporting/plugin-runtime.d.ts +25 -0
- package/lib/api/reporting/plugin-runtime.js +106 -0
- package/lib/api/reporting/query-scope.d.ts +8 -2
- package/lib/api/reporting/query-scope.js +16 -7
- package/lib/api/reporting/retention.d.ts +4 -10
- package/lib/api/reporting/retention.js +8 -11
- package/lib/api/reporting/sql-helpers.d.ts +4 -7
- package/lib/api/reporting/sql-helpers.js +8 -9
- package/lib/api/reporting/types.d.ts +55 -17
- package/lib/api/reporting/types.js +1 -1
- package/lib/api/reporting-service.d.ts +35 -26
- package/lib/api/reporting-service.js +245 -161
- package/lib/api/semver-range.d.ts +73 -0
- package/lib/api/semver-range.js +227 -0
- package/lib/api/soft-delete-sweep.js +8 -20
- package/lib/core/query-filters.d.ts +18 -3
- package/lib/core/query-filters.js +1 -1
- package/lib/database/drizzle-schema.d.ts +7790 -2461
- package/lib/database/drizzle-schema.js +29 -1
- package/lib/database/index.d.ts +4 -2
- package/lib/database/index.js +5 -3
- package/lib/database/pg-result.d.ts +19 -0
- package/lib/database/pg-result.js +32 -0
- package/lib/database/postgres-connection.js +14 -24
- package/lib/database/public-reader.d.ts +14 -0
- package/lib/database/public-reader.js +68 -0
- package/lib/database/retry-strategy.d.ts +3 -5
- package/lib/database/retry-strategy.js +4 -6
- package/lib/database/schema/compliance.d.ts +16 -34
- package/lib/database/schema/compliance.js +4 -4
- package/lib/database/schema/dashboard.js +4 -2
- package/lib/database/schema/ecosystem.d.ts +6586 -0
- package/lib/database/schema/ecosystem.js +709 -0
- package/lib/database/schema/message.d.ts +6 -12
- package/lib/database/schema/message.js +3 -1
- package/lib/database/schema/pipeline.d.ts +79 -5
- package/lib/database/schema/pipeline.js +46 -25
- package/lib/database/schema/plugin.d.ts +587 -3
- package/lib/database/schema/plugin.js +86 -14
- package/lib/database/tenancy.d.ts +6 -7
- package/lib/database/tenancy.js +13 -14
- package/lib/index.d.ts +7 -4
- package/lib/index.js +7 -4
- package/lib/testing/exports.json +146 -0
- package/package.json +44 -7
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import type { CrudTx } from './crud-service.js';
|
|
2
|
+
import { type AdvisorySeverity, type BlockedListingRef, type BlockOnAdvisory, type OfficialInstalls, type PluginAdvisory, type PluginInstall, type PluginInstallPolicy, type PluginListing, type PluginListingVersion, type Publisher, type PublisherTier } from '../database/drizzle-schema.js';
|
|
3
|
+
/** An org's consumption policy, as the resolver applies it. */
|
|
4
|
+
export interface ConsumptionPolicy {
|
|
5
|
+
allowedTiers: PublisherTier[];
|
|
6
|
+
requireApprovalTiers: PublisherTier[];
|
|
7
|
+
secretsAllowedTiers: PublisherTier[];
|
|
8
|
+
blockOnAdvisory: BlockOnAdvisory;
|
|
9
|
+
officialInstalls: OfficialInstalls;
|
|
10
|
+
blockedListings: BlockedListingRef[];
|
|
11
|
+
}
|
|
12
|
+
/** The defaults (and the column defaults of `plugin_install_policies`). */
|
|
13
|
+
export declare const DEFAULT_CONSUMPTION_POLICY: Readonly<ConsumptionPolicy>;
|
|
14
|
+
/** At most this many blocked listings per policy. */
|
|
15
|
+
export declare const MAX_BLOCKED_LISTINGS = 500;
|
|
16
|
+
/** A stored policy row (or none) as a {@link ConsumptionPolicy}. */
|
|
17
|
+
export declare function policyOf(row: Partial<PluginInstallPolicy> | null | undefined): ConsumptionPolicy;
|
|
18
|
+
/**
|
|
19
|
+
* A team's policy under its root org's: each field takes the STRICTER of
|
|
20
|
+
* the two, so a team can narrow what its root allows but never widen it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeConsumptionPolicies(root: ConsumptionPolicy, team: ConsumptionPolicy): ConsumptionPolicy;
|
|
23
|
+
/**
|
|
24
|
+
* The policy an org's resolution runs under. A root org: its own row (or the
|
|
25
|
+
* defaults). A team (`rootOrgId` set): its root's policy, merged with the
|
|
26
|
+
* team's own row when it has one.
|
|
27
|
+
*/
|
|
28
|
+
export declare function effectiveConsumptionPolicy(rows: ReadonlyArray<Partial<PluginInstallPolicy> & {
|
|
29
|
+
orgId?: string;
|
|
30
|
+
}>, orgId: string, rootOrgId?: string): ConsumptionPolicy;
|
|
31
|
+
/**
|
|
32
|
+
* Validate a (partial) policy update over `base`. Returns the full new policy,
|
|
33
|
+
* or an error message. `blockedListings` entries are `{ publisher, name }` or
|
|
34
|
+
* `"publisher/name"`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyPolicyUpdate(base: ConsumptionPolicy, input: unknown): ConsumptionPolicy | string;
|
|
37
|
+
/** Why a reference can't resolve; `code` is an api-core `ErrorCode` name. */
|
|
38
|
+
export interface ResolutionRefusal {
|
|
39
|
+
code: 'NOT_FOUND' | 'PLUGIN_NOT_INSTALLED' | 'PLUGIN_BLOCKED_BY_POLICY' | 'PLUGIN_UNAVAILABLE';
|
|
40
|
+
reason: string;
|
|
41
|
+
message: string;
|
|
42
|
+
details?: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
/** A non-fatal note a resolution carries (synth prints it). */
|
|
45
|
+
export interface ResolutionWarning {
|
|
46
|
+
code: 'PLUGIN_ADVISORY' | 'PLUGIN_DEPRECATED' | 'PLUGIN_SECRETS_WITHHELD' | 'LISTING_UNMAINTAINED';
|
|
47
|
+
message: string;
|
|
48
|
+
}
|
|
49
|
+
/** Why the org's policy (or the listing's state) keeps a listing out, or null. */
|
|
50
|
+
export interface ListingBlock {
|
|
51
|
+
reason: 'tier' | 'blocked_listing' | 'suspended';
|
|
52
|
+
message: string;
|
|
53
|
+
}
|
|
54
|
+
/** Whether `policy` (or the listing's own state) refuses the listing outright. */
|
|
55
|
+
export declare function listingBlock(policy: ConsumptionPolicy, publisher: Pick<Publisher, 'handle' | 'tier' | 'suspendedAt'>, listing: Pick<PluginListing, 'name' | 'state'>): ListingBlock | null;
|
|
56
|
+
/** The refusal a {@link ListingBlock} becomes. */
|
|
57
|
+
export declare function blockRefusal(block: ListingBlock): ResolutionRefusal;
|
|
58
|
+
/** Severities each `blockOnAdvisory` setting blocks. */
|
|
59
|
+
export declare const ADVISORY_BLOCK_SEVERITIES: Readonly<Record<BlockOnAdvisory, readonly AdvisorySeverity[]>>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether an advisory's `affectedRange` covers `version`: `||`-separated
|
|
62
|
+
* comparator sets, each either the lookup spec forms (`^`, `~`, partial,
|
|
63
|
+
* exact) or space-separated comparators (`>=1.0.0 <1.2.3`) or a hyphen range.
|
|
64
|
+
* `*` covers everything; an unparseable range covers nothing.
|
|
65
|
+
*/
|
|
66
|
+
export declare function advisoryRangeCovers(range: string, version: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Why `range` isn't a usable advisory range (the forms {@link advisoryRangeCovers}
|
|
69
|
+
* understands), or null when it is. An advisory whose range parses as nothing
|
|
70
|
+
* would silently cover nothing, so drafts are refused instead.
|
|
71
|
+
*/
|
|
72
|
+
export declare function advisoryRangeProblem(range: string): string | null;
|
|
73
|
+
/** The PUBLISHED advisories whose range covers `version` (any severity), most severe first. */
|
|
74
|
+
export declare function advisoriesCovering<A extends Pick<PluginAdvisory, 'severity' | 'state' | 'affectedRange'>>(advisories: readonly A[], version: string): A[];
|
|
75
|
+
/** The PUBLISHED advisories the policy blocks `version` for. */
|
|
76
|
+
export declare function blockingAdvisories(advisories: readonly Pick<PluginAdvisory, 'id' | 'severity' | 'state' | 'affectedRange' | 'fixedVersion' | 'summary'>[], version: string, policy: Pick<ConsumptionPolicy, 'blockOnAdvisory'>): Array<Pick<PluginAdvisory, 'id' | 'severity' | 'state' | 'affectedRange' | 'fixedVersion' | 'summary'>>;
|
|
77
|
+
/** How the org reaches a listing: an explicit install row, or the implicit Official one. */
|
|
78
|
+
export type InstallMode = {
|
|
79
|
+
kind: 'explicit';
|
|
80
|
+
install: PluginInstall;
|
|
81
|
+
inherited: boolean;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'implicit';
|
|
84
|
+
};
|
|
85
|
+
type VersionRow = Pick<PluginListingVersion, 'version' | 'yankedAt' | 'pausedAt' | 'breaking'>;
|
|
86
|
+
/**
|
|
87
|
+
* The implicit Official install's range: every version of the LOWEST live
|
|
88
|
+
* major (`<major>.x`) — patch and minor versions flow, a new major never does
|
|
89
|
+
* (the org moves to it with an explicit install). Null when nothing is live.
|
|
90
|
+
*/
|
|
91
|
+
export declare function implicitInstallRange(versions: readonly VersionRow[]): string | null;
|
|
92
|
+
/** Whether an install's version policy admits `version` (the baseline is `pinnedVersion`). */
|
|
93
|
+
export declare function installAdmits(install: Pick<PluginInstall, 'versionPolicy' | 'pinnedVersion'>, version: string, versions: readonly VersionRow[]): boolean;
|
|
94
|
+
/** Whether `mode` admits `version` (the implicit range for an implicit install). */
|
|
95
|
+
export declare function modeAdmits(mode: InstallMode, version: string, versions: readonly VersionRow[]): boolean;
|
|
96
|
+
/** Input to {@link selectListingVersion}. */
|
|
97
|
+
export interface VersionChoiceInput<V extends PluginListingVersion = PluginListingVersion> {
|
|
98
|
+
ref: string;
|
|
99
|
+
versions: readonly V[];
|
|
100
|
+
mode: InstallMode;
|
|
101
|
+
/** The reference's own version spec (`filter.version`). */
|
|
102
|
+
requested?: string;
|
|
103
|
+
advisories: readonly PluginAdvisory[];
|
|
104
|
+
policy: ConsumptionPolicy;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Pick the listed version a reference resolves to (see the module doc), or
|
|
108
|
+
* the refusal that explains why none can.
|
|
109
|
+
*/
|
|
110
|
+
export declare function selectListingVersion<V extends PluginListingVersion>(input: VersionChoiceInput<V>): {
|
|
111
|
+
version: V;
|
|
112
|
+
} | {
|
|
113
|
+
refusal: ResolutionRefusal;
|
|
114
|
+
};
|
|
115
|
+
/** The org (and, for a team, its root org) a resolution runs for. */
|
|
116
|
+
export interface ResolutionScope {
|
|
117
|
+
orgId: string;
|
|
118
|
+
/** The root org when the caller is a team. */
|
|
119
|
+
rootOrgId?: string;
|
|
120
|
+
}
|
|
121
|
+
/** The org ids whose installs and policies apply, own first. */
|
|
122
|
+
export declare function scopeOrgIds(scope: ResolutionScope): string[];
|
|
123
|
+
/**
|
|
124
|
+
* How the org reaches `listing` — or the refusal. An ACTIVE own-org row wins,
|
|
125
|
+
* then the root org's (a team inherits it); failing both, the implicit
|
|
126
|
+
* Official install (unless the policy is `explicit`); otherwise the org's own
|
|
127
|
+
* pending / denied row explains the refusal.
|
|
128
|
+
*/
|
|
129
|
+
export declare function installModeFor(publisher: Pick<Publisher, 'handle'>, listing: Pick<PluginListing, 'id' | 'name'>, installs: readonly PluginInstall[], policy: ConsumptionPolicy, scope: ResolutionScope): InstallMode | ResolutionRefusal;
|
|
130
|
+
/** The rows the resolver reads. Implementations must run with a scope that can
|
|
131
|
+
* read the ecosystem tables and the org's (and root org's) install rows. */
|
|
132
|
+
export interface ListingDataSource {
|
|
133
|
+
publisherByHandle(handle: string): Promise<Publisher | null>;
|
|
134
|
+
publishersByIds(ids: string[]): Promise<Publisher[]>;
|
|
135
|
+
listingByName(publisherId: string, name: string): Promise<PluginListing | null>;
|
|
136
|
+
/** Listed / unmaintained listings (optionally only these ids or names). */
|
|
137
|
+
liveListings(filter?: {
|
|
138
|
+
ids?: string[];
|
|
139
|
+
names?: string[];
|
|
140
|
+
}): Promise<PluginListing[]>;
|
|
141
|
+
versionsForListings(listingIds: string[]): Promise<PluginListingVersion[]>;
|
|
142
|
+
/** PUBLISHED advisories. */
|
|
143
|
+
advisoriesForListings(listingIds: string[]): Promise<PluginAdvisory[]>;
|
|
144
|
+
installsForOrgs(orgIds: string[]): Promise<PluginInstall[]>;
|
|
145
|
+
policiesForOrgs(orgIds: string[]): Promise<PluginInstallPolicy[]>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* A {@link ListingDataSource} over a drizzle transaction. The caller owns the
|
|
149
|
+
* transaction's scope: it must be able to read the ecosystem tables (app-role
|
|
150
|
+
* RLS) and the install rows of the org AND its root org (a team's reads of its
|
|
151
|
+
* root's rows need an elevated scope, like parent-org plugin reads).
|
|
152
|
+
*/
|
|
153
|
+
export declare function drizzleListingSource(tx: CrudTx): ListingDataSource;
|
|
154
|
+
/** A plugin reference as the resolver reads it. */
|
|
155
|
+
export interface ListingReference {
|
|
156
|
+
/** Publisher handle; absent = the Official listing (the unqualified fallback). */
|
|
157
|
+
publisher?: string;
|
|
158
|
+
name: string;
|
|
159
|
+
/** The reference's `filter.version`. */
|
|
160
|
+
version?: string;
|
|
161
|
+
}
|
|
162
|
+
/** A reference that resolved to a listed version. */
|
|
163
|
+
export interface ListingResolved {
|
|
164
|
+
ok: true;
|
|
165
|
+
publisher: Publisher;
|
|
166
|
+
listing: PluginListing;
|
|
167
|
+
version: PluginListingVersion;
|
|
168
|
+
mode: InstallMode;
|
|
169
|
+
policy: ConsumptionPolicy;
|
|
170
|
+
/** The spec declares secrets the policy withholds from this tier. */
|
|
171
|
+
secretsWithheld: boolean;
|
|
172
|
+
warnings: ResolutionWarning[];
|
|
173
|
+
}
|
|
174
|
+
/** A reference that named a listing but can't resolve. */
|
|
175
|
+
export interface ListingRefused {
|
|
176
|
+
ok: false;
|
|
177
|
+
refusal: ResolutionRefusal;
|
|
178
|
+
publisher?: Publisher;
|
|
179
|
+
listing?: PluginListing;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Resolve `ref` to a listed version for `scope`, or refuse. Null when the
|
|
183
|
+
* listing doesn't exist at all (an unqualified reference then simply has no
|
|
184
|
+
* Official fallback).
|
|
185
|
+
*/
|
|
186
|
+
export declare function resolveListingReference(source: ListingDataSource, ref: ListingReference, scope: ResolutionScope): Promise<ListingResolved | ListingRefused | null>;
|
|
187
|
+
/**
|
|
188
|
+
* The non-fatal notes a resolved listed version carries (lookup answers,
|
|
189
|
+
* synth prints them, the installs view shows them): an unmaintained listing, a
|
|
190
|
+
* deprecated version, a PUBLISHED advisory covering the version that the org's
|
|
191
|
+
* `blockOnAdvisory` doesn't block (a blocking one refuses resolution instead),
|
|
192
|
+
* and withheld secrets.
|
|
193
|
+
*/
|
|
194
|
+
export declare function listedVersionWarnings(input: {
|
|
195
|
+
publisher: Pick<Publisher, 'handle' | 'tier'>;
|
|
196
|
+
listing: Pick<PluginListing, 'name' | 'state'>;
|
|
197
|
+
version: Pick<PluginListingVersion, 'version' | 'deprecatedAt' | 'deprecationMessage' | 'specSnapshot'>;
|
|
198
|
+
advisories: readonly Pick<PluginAdvisory, 'severity' | 'state' | 'affectedRange' | 'fixedVersion' | 'summary'>[];
|
|
199
|
+
policy: Pick<ConsumptionPolicy, 'secretsAllowedTiers'>;
|
|
200
|
+
}): {
|
|
201
|
+
warnings: ResolutionWarning[];
|
|
202
|
+
secretsWithheld: boolean;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* The plugin record a resolved listing version runs as — the shape synth and
|
|
206
|
+
* the contract check read (a `plugins` row's run fields), built from the
|
|
207
|
+
* version's frozen spec snapshot. `id` is the LISTING VERSION's id (the step
|
|
208
|
+
* manifest resolves it back), `imageRepository` its `public/*` copy.
|
|
209
|
+
*/
|
|
210
|
+
export declare function listedPluginRecord(res: ListingResolved): Record<string, unknown>;
|
|
211
|
+
/** One listing with the org's standing on it. */
|
|
212
|
+
export interface OrgListingState {
|
|
213
|
+
publisher: Publisher;
|
|
214
|
+
listing: PluginListing;
|
|
215
|
+
versions: PluginListingVersion[];
|
|
216
|
+
/** How the org reaches it, or why it can't (not installed, pending, …). */
|
|
217
|
+
mode: InstallMode | ResolutionRefusal;
|
|
218
|
+
/** A policy / state block (tier, blocked listing, suspended), or null. */
|
|
219
|
+
block: ListingBlock | null;
|
|
220
|
+
/** What an UNVERSIONED reference resolves to right now, or null. */
|
|
221
|
+
resolved: PluginListingVersion | null;
|
|
222
|
+
/** Why nothing resolves, when the org does reach the listing (e.g. an advisory block). */
|
|
223
|
+
refusal: ResolutionRefusal | null;
|
|
224
|
+
/** The listing's PUBLISHED advisories. */
|
|
225
|
+
advisories: PluginAdvisory[];
|
|
226
|
+
/** The org's own install row for it (explicit, possibly pending/denied). */
|
|
227
|
+
ownInstall: PluginInstall | null;
|
|
228
|
+
/** The org's effective consumption policy (the same for every listing). */
|
|
229
|
+
policy: ConsumptionPolicy;
|
|
230
|
+
}
|
|
231
|
+
/** The org's policy + install rows (own and root). */
|
|
232
|
+
export interface OrgInstallContext {
|
|
233
|
+
policy: ConsumptionPolicy;
|
|
234
|
+
installs: PluginInstall[];
|
|
235
|
+
scope: ResolutionScope;
|
|
236
|
+
}
|
|
237
|
+
/** Load the org's policy and install rows. */
|
|
238
|
+
export declare function loadOrgInstallContext(source: ListingDataSource, scope: ResolutionScope): Promise<OrgInstallContext>;
|
|
239
|
+
/**
|
|
240
|
+
* The org's standing on every live listing (or only `filter`'s). Used by the
|
|
241
|
+
* in-app catalog; {@link resolvableListings} narrows it to what resolves.
|
|
242
|
+
*/
|
|
243
|
+
export declare function orgListingStates(source: ListingDataSource, scope: ResolutionScope, filter?: {
|
|
244
|
+
ids?: string[];
|
|
245
|
+
names?: string[];
|
|
246
|
+
}, ctx?: OrgInstallContext): Promise<OrgListingState[]>;
|
|
247
|
+
/** The listings an org's references resolve to now (installed or implicit, not blocked). */
|
|
248
|
+
export declare function resolvableListings(source: ListingDataSource, scope: ResolutionScope, filter?: {
|
|
249
|
+
names?: string[];
|
|
250
|
+
}): Promise<Array<OrgListingState & {
|
|
251
|
+
resolved: PluginListingVersion;
|
|
252
|
+
}>>;
|
|
253
|
+
export {};
|