@vltpkg/types 0.0.0-2 → 0.0.0-20
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/README.md +2 -1
- package/dist/esm/index.d.ts +241 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +502 -14
- package/dist/esm/index.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
# @vltpkg/types
|
|
4
4
|
|
|
5
|
-
A module for a handful of core types that are used throughout vlt
|
|
5
|
+
A module for a handful of core types that are used throughout vlt
|
|
6
|
+
extensively, and don't belong to any one particular implementation.
|
|
6
7
|
|
|
7
8
|
## Usage
|
|
8
9
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type that overrides specific properties of type T with new types
|
|
3
|
+
* from R. Constrains override values to exclude undefined, ensuring that
|
|
4
|
+
* normalization cannot introduce undefined to fields that shouldn't have it.
|
|
5
|
+
*/
|
|
6
|
+
export type Override<T, R extends {
|
|
7
|
+
[K in keyof R]: R[K] extends undefined ? never : R[K];
|
|
8
|
+
}> = {
|
|
9
|
+
[K in keyof T]: K extends keyof R ? R[K] : T[K];
|
|
10
|
+
};
|
|
1
11
|
/** anything that can be encoded in JSON */
|
|
2
12
|
export type JSONField = JSONField[] | boolean | number | string | {
|
|
3
13
|
[k: string]: JSONField;
|
|
@@ -33,8 +43,73 @@ export type Exports = Exclude<ConditionalValue, null> | ExportsSubpaths;
|
|
|
33
43
|
export type Imports = Record<`#${string}`, ConditionalValue>;
|
|
34
44
|
export type FundingEntry = string | {
|
|
35
45
|
url: string;
|
|
46
|
+
type?: string;
|
|
47
|
+
[key: string]: JSONField;
|
|
36
48
|
};
|
|
37
49
|
export type Funding = FundingEntry | FundingEntry[];
|
|
50
|
+
/**
|
|
51
|
+
* An object with url and optional additional properties
|
|
52
|
+
*/
|
|
53
|
+
export type NormalizedFundingEntry = {
|
|
54
|
+
url: string;
|
|
55
|
+
type?: string;
|
|
56
|
+
[key: string]: JSONField;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Normalized funding information, an array of {@link NormalizedFundingEntry}.
|
|
60
|
+
*/
|
|
61
|
+
export type NormalizedFunding = NormalizedFundingEntry[];
|
|
62
|
+
/**
|
|
63
|
+
* Normalize funding information to a consistent format.
|
|
64
|
+
*/
|
|
65
|
+
export declare const normalizeFunding: (funding: unknown) => NormalizedFunding | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if a value is a {@link NormalizedFundingEntry}.
|
|
68
|
+
*/
|
|
69
|
+
export declare const isNormalizedFundingEntry: (o: unknown) => o is NormalizedFundingEntry;
|
|
70
|
+
/**
|
|
71
|
+
* Type guard to check if a value is a {@link NormalizedFunding}.
|
|
72
|
+
*/
|
|
73
|
+
export declare const isNormalizedFunding: (o: unknown) => o is NormalizedFunding;
|
|
74
|
+
/**
|
|
75
|
+
* Given a version Normalize the version field in a manifest.
|
|
76
|
+
*/
|
|
77
|
+
export declare const fixManifestVersion: <T extends Manifest | ManifestRegistry>(manifest: T) => T;
|
|
78
|
+
declare const kWriteAccess: unique symbol;
|
|
79
|
+
declare const kIsPublisher: unique symbol;
|
|
80
|
+
/**
|
|
81
|
+
* Parse a string or object into a normalized contributor.
|
|
82
|
+
*/
|
|
83
|
+
export declare const parsePerson: (person: unknown, writeAccess?: boolean, isPublisher?: boolean) => NormalizedContributorEntry | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Normalized contributors - always an array of {@link NormalizedContributorEntry}.
|
|
86
|
+
*/
|
|
87
|
+
export type NormalizedContributors = NormalizedContributorEntry[];
|
|
88
|
+
/**
|
|
89
|
+
* Represents a normalized contributor object. This is the type that is
|
|
90
|
+
* used in the {@link NormalizedManifest} and {@link NormalizedManifestRegistry}
|
|
91
|
+
* objects.
|
|
92
|
+
*/
|
|
93
|
+
export type NormalizedContributorEntry = {
|
|
94
|
+
email?: string;
|
|
95
|
+
name?: string;
|
|
96
|
+
[kWriteAccess]?: boolean;
|
|
97
|
+
[kIsPublisher]?: boolean;
|
|
98
|
+
writeAccess?: boolean;
|
|
99
|
+
isPublisher?: boolean;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Type guard to check if a value is a normalized contributor entry.
|
|
103
|
+
*/
|
|
104
|
+
export declare const isNormalizedContributorEntry: (o: unknown) => o is NormalizedContributorEntry;
|
|
105
|
+
/**
|
|
106
|
+
* Type guard to check if a value is a {@link NormalizedContributors}.
|
|
107
|
+
*/
|
|
108
|
+
export declare const isNormalizedContributors: (o: unknown) => o is NormalizedContributors;
|
|
109
|
+
/**
|
|
110
|
+
* Normalize contributors and maintainers from various formats
|
|
111
|
+
*/
|
|
112
|
+
export declare const normalizeContributors: (contributors: unknown, maintainers?: unknown) => NormalizedContributorEntry[] | undefined;
|
|
38
113
|
export type Person = string | {
|
|
39
114
|
name: string;
|
|
40
115
|
url?: string;
|
|
@@ -48,6 +123,43 @@ export type Bugs = string | {
|
|
|
48
123
|
url?: string;
|
|
49
124
|
email?: string;
|
|
50
125
|
};
|
|
126
|
+
export type Keywords = string[] | string;
|
|
127
|
+
/**
|
|
128
|
+
* Normalized bugs entry - always an object with type and url/email
|
|
129
|
+
*/
|
|
130
|
+
export type NormalizedBugsEntry = {
|
|
131
|
+
type?: 'email' | 'link';
|
|
132
|
+
url?: string;
|
|
133
|
+
email?: string;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Normalized keywords - always an array of strings
|
|
137
|
+
*/
|
|
138
|
+
export type NormalizedKeywords = string[];
|
|
139
|
+
/**
|
|
140
|
+
* Normalized bugs - always an array of {@link NormalizedBugsEntry}
|
|
141
|
+
*/
|
|
142
|
+
export type NormalizedBugs = NormalizedBugsEntry[];
|
|
143
|
+
/**
|
|
144
|
+
* Normalize bugs information to a {@link NormalizedBugs} consistent format.
|
|
145
|
+
*/
|
|
146
|
+
export declare const normalizeBugs: (bugs: unknown) => NormalizedBugs | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Type guard to check if a value is a {@link NormalizedBugsEntry}.
|
|
149
|
+
*/
|
|
150
|
+
export declare const isNormalizedBugsEntry: (o: unknown) => o is NormalizedBugsEntry;
|
|
151
|
+
/**
|
|
152
|
+
* Type guard to check if a value is a {@link NormalizedBugs}.
|
|
153
|
+
*/
|
|
154
|
+
export declare const isNormalizedBugs: (o: unknown) => o is NormalizedBugs;
|
|
155
|
+
/**
|
|
156
|
+
* Normalize keywords information to a {@link NormalizedKeywords} consistent format.
|
|
157
|
+
*/
|
|
158
|
+
export declare const normalizeKeywords: (keywords: unknown) => NormalizedKeywords | undefined;
|
|
159
|
+
/**
|
|
160
|
+
* Type guard to check if a value is a {@link NormalizedKeywords}.
|
|
161
|
+
*/
|
|
162
|
+
export declare const isNormalizedKeywords: (o: unknown) => o is NormalizedKeywords;
|
|
51
163
|
export type Manifest = {
|
|
52
164
|
/** The name of the package. optional because {} is a valid package.json */
|
|
53
165
|
name?: string;
|
|
@@ -81,6 +193,8 @@ export type Manifest = {
|
|
|
81
193
|
cpu?: string[] | string;
|
|
82
194
|
/** URLs that can be visited to fund this project */
|
|
83
195
|
funding?: Funding;
|
|
196
|
+
/** The homepage of the repository */
|
|
197
|
+
homepage?: string;
|
|
84
198
|
/**
|
|
85
199
|
* Only present in Manifests served by a registry. Contains information
|
|
86
200
|
* about the artifact served for this package release.
|
|
@@ -89,7 +203,7 @@ export type Manifest = {
|
|
|
89
203
|
/** a short description of the package */
|
|
90
204
|
description?: string;
|
|
91
205
|
/** search keywords */
|
|
92
|
-
keywords?:
|
|
206
|
+
keywords?: Keywords;
|
|
93
207
|
/** where to go to file issues */
|
|
94
208
|
bugs?: Bugs;
|
|
95
209
|
/** where the development happens */
|
|
@@ -115,8 +229,43 @@ export type Manifest = {
|
|
|
115
229
|
author?: Person;
|
|
116
230
|
/** contributors to the package */
|
|
117
231
|
contributors?: Person[];
|
|
232
|
+
/** the license of the package */
|
|
233
|
+
license?: string;
|
|
234
|
+
};
|
|
235
|
+
export type NormalizedFields = {
|
|
236
|
+
bugs: NormalizedBugs | undefined;
|
|
237
|
+
author: NormalizedContributorEntry | undefined;
|
|
238
|
+
contributors: NormalizedContributors | undefined;
|
|
239
|
+
funding: NormalizedFunding | undefined;
|
|
240
|
+
keywords: NormalizedKeywords | undefined;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* A {@link Manifest} object that contains normalized fields.
|
|
244
|
+
*/
|
|
245
|
+
export type NormalizedManifest = Override<Manifest, NormalizedFields>;
|
|
246
|
+
/**
|
|
247
|
+
* A {@link ManifestRegistry} object that contains normalized fields.
|
|
248
|
+
*/
|
|
249
|
+
export type NormalizedManifestRegistry = Override<ManifestRegistry, NormalizedFields>;
|
|
250
|
+
/**
|
|
251
|
+
* A specific type of {@link Manifest} that represents manifests that were
|
|
252
|
+
* retrieved from a registry, these will always have `name`, `version`
|
|
253
|
+
* and `dist` information along with an optional `maintainers` field.
|
|
254
|
+
*/
|
|
255
|
+
export type ManifestRegistry = Manifest & Required<Pick<Manifest, 'name' | 'version' | 'dist'>> & {
|
|
256
|
+
maintainers?: unknown;
|
|
118
257
|
};
|
|
119
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Maps the manifest type to the equivalent normalized manifest type.
|
|
260
|
+
*/
|
|
261
|
+
export type SomeNormalizedManifest<T> = T extends ManifestRegistry ? NormalizedManifestRegistry : NormalizedManifest;
|
|
262
|
+
/**
|
|
263
|
+
* A document that represents available package versions in a given registry
|
|
264
|
+
* along with extra information, such as `dist-tags` and `maintainers` info.
|
|
265
|
+
* The `versions` field is key-value structure in which keys are the
|
|
266
|
+
* available versions of a given package and values are
|
|
267
|
+
* {@link ManifestRegistry} objects.
|
|
268
|
+
*/
|
|
120
269
|
export type Packument = {
|
|
121
270
|
name: string;
|
|
122
271
|
'dist-tags': Record<string, string>;
|
|
@@ -124,6 +273,8 @@ export type Packument = {
|
|
|
124
273
|
modified?: string;
|
|
125
274
|
time?: Record<string, string>;
|
|
126
275
|
readme?: string;
|
|
276
|
+
contributors?: Person[];
|
|
277
|
+
maintainers?: Person[];
|
|
127
278
|
};
|
|
128
279
|
export type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag';
|
|
129
280
|
/**
|
|
@@ -150,16 +301,93 @@ export type RevDoc = Omit<Packument, 'versions'> & {
|
|
|
150
301
|
/** all named shas referenced above */
|
|
151
302
|
shas: Record<string, string[]>;
|
|
152
303
|
};
|
|
304
|
+
/**
|
|
305
|
+
* A type guard to check if a value is a boolean.
|
|
306
|
+
*/
|
|
307
|
+
export declare const isBoolean: (value: unknown) => value is boolean;
|
|
308
|
+
export declare const integrityRE: RegExp;
|
|
153
309
|
export declare const isIntegrity: (i: unknown) => i is Integrity;
|
|
154
310
|
export declare const asIntegrity: (i: unknown) => Integrity;
|
|
155
311
|
export declare const assertIntegrity: (i: unknown) => asserts i is Integrity;
|
|
312
|
+
export declare const keyIDRE: RegExp;
|
|
156
313
|
export declare const isKeyID: (k: unknown) => k is KeyID;
|
|
157
314
|
export declare const asKeyID: (k: unknown) => KeyID;
|
|
158
315
|
export declare const assertKeyID: (k: unknown) => asserts k is KeyID;
|
|
316
|
+
/**
|
|
317
|
+
* Convert an unknown value to an error.
|
|
318
|
+
*/
|
|
319
|
+
export declare const asError: (er: unknown, fallbackMessage?: string) => Error;
|
|
320
|
+
/**
|
|
321
|
+
* Check if a value is an error.
|
|
322
|
+
*/
|
|
323
|
+
export declare const isError: (er: unknown) => er is Error;
|
|
324
|
+
/**
|
|
325
|
+
* Check if an error has a cause property.
|
|
326
|
+
*/
|
|
327
|
+
export declare const isErrorWithCause: (er: unknown) => er is Error & {
|
|
328
|
+
cause: unknown;
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Check if an unknown value is a plain object.
|
|
332
|
+
*/
|
|
333
|
+
export declare const isObject: (v: unknown) => v is Record<string, unknown>;
|
|
334
|
+
export declare const maybeRecordStringString: (o: unknown) => o is Record<string, string> | undefined;
|
|
335
|
+
export declare const isRecordStringString: (o: unknown) => o is Record<string, string>;
|
|
336
|
+
export declare const assertRecordStringString: (o: unknown) => void;
|
|
337
|
+
export declare const isRecordStringT: <T>(o: unknown, check: (o: unknown) => o is T) => o is Record<string, T>;
|
|
338
|
+
export declare const assertRecordStringT: <T>(o: unknown, check: (o: unknown) => o is T, wanted: string) => asserts o is Record<string, T>;
|
|
339
|
+
export declare const isRecordStringManifest: (o: unknown) => o is Record<string, Manifest>;
|
|
340
|
+
export declare const maybePeerDependenciesMetaSet: (o: unknown) => o is Record<string, PeerDependenciesMetaValue> | undefined;
|
|
341
|
+
export declare const maybeBoolean: (o: unknown) => o is boolean;
|
|
342
|
+
export declare const isPeerDependenciesMetaValue: (o: unknown) => o is PeerDependenciesMetaValue;
|
|
343
|
+
export declare const maybeString: (a: unknown) => a is string | undefined;
|
|
344
|
+
export declare const maybeDist: (a: unknown) => a is Manifest["dist"];
|
|
345
|
+
/**
|
|
346
|
+
* Is a given unknown value a valid {@link Manifest} object?
|
|
347
|
+
* Returns `true` if so.
|
|
348
|
+
*/
|
|
159
349
|
export declare const isManifest: (m: unknown) => m is Manifest;
|
|
350
|
+
/**
|
|
351
|
+
* A specific {@link Manifest} that is retrieved uniquely from reading
|
|
352
|
+
* registry packument and manifest endpoints, it has `dist`, `name` and
|
|
353
|
+
* `version` fields defined.
|
|
354
|
+
*/
|
|
160
355
|
export declare const isManifestRegistry: (m: unknown) => m is ManifestRegistry;
|
|
356
|
+
/**
|
|
357
|
+
* Given an unknown value, convert it to a {@link Manifest}.
|
|
358
|
+
*/
|
|
161
359
|
export declare const asManifest: (m: unknown, from?: (...a: unknown[]) => any) => Manifest;
|
|
360
|
+
/**
|
|
361
|
+
* Given a {@link Manifest} returns a {@link NormalizedManifest} that
|
|
362
|
+
* contains normalized author, bugs, funding, contributors, keywords and
|
|
363
|
+
* version fields.
|
|
364
|
+
*/
|
|
365
|
+
export declare const normalizeManifest: <T extends Manifest | ManifestRegistry>(manifest: T) => SomeNormalizedManifest<T>;
|
|
366
|
+
/**
|
|
367
|
+
* Type guard to check if a value is a {@link NormalizedManifest}.
|
|
368
|
+
*/
|
|
369
|
+
export declare const isNormalizedManifest: (o: unknown) => o is NormalizedManifest;
|
|
370
|
+
/**
|
|
371
|
+
* Given an unknown value, convert it to a {@link NormalizedManifest}.
|
|
372
|
+
*/
|
|
373
|
+
export declare const asNormalizedManifest: (m: unknown, from?: (...a: unknown[]) => any) => NormalizedManifest;
|
|
374
|
+
/**
|
|
375
|
+
* Given an unknown value, convert it to a {@link ManifestRegistry}.
|
|
376
|
+
*/
|
|
162
377
|
export declare const asManifestRegistry: (m: unknown, from?: (...a: unknown[]) => any) => ManifestRegistry;
|
|
378
|
+
/**
|
|
379
|
+
* Type guard to check if a value is a {@link NormalizedManifestRegistry}.
|
|
380
|
+
*/
|
|
381
|
+
export declare const isNormalizedManifestRegistry: (o: unknown) => o is NormalizedManifestRegistry;
|
|
382
|
+
/**
|
|
383
|
+
* Given an unknown value, convert it to a {@link NormalizedManifestRegistry}.
|
|
384
|
+
*/
|
|
385
|
+
export declare const asNormalizedManifestRegistry: (m: unknown, from?: (...a: unknown[]) => any) => NormalizedManifestRegistry;
|
|
386
|
+
/**
|
|
387
|
+
* Walks a normalized manifest and expands any symbols found
|
|
388
|
+
* in the `author` and `contributors` fields.
|
|
389
|
+
*/
|
|
390
|
+
export declare const expandNormalizedManifestSymbols: (m: NormalizedManifest) => NormalizedManifest;
|
|
163
391
|
export declare const assertManifest: (m: unknown) => asserts m is Manifest;
|
|
164
392
|
export declare const assertManifestRegistry: (m: unknown) => asserts m is ManifestRegistry;
|
|
165
393
|
export declare const isPackument: (p: unknown) => p is Packument;
|
|
@@ -173,6 +401,16 @@ export type DependencyTypeLong = 'dependencies' | 'devDependencies' | 'optionalD
|
|
|
173
401
|
* Unique keys that define different types of dependencies relationship.
|
|
174
402
|
*/
|
|
175
403
|
export type DependencyTypeShort = 'dev' | 'optional' | 'peer' | 'peerOptional' | 'prod';
|
|
404
|
+
/**
|
|
405
|
+
* Unique keys that indicate how a new or updated dependency should be saved
|
|
406
|
+
* back to a manifest.
|
|
407
|
+
*
|
|
408
|
+
* `'implicit'` is used to indicate that a dependency should be saved as
|
|
409
|
+
* whatever type it already exists as. If the dependency does not exist,
|
|
410
|
+
* then `'implicit'` is equivalent to `'prod'`, as that is the default
|
|
411
|
+
* save type.
|
|
412
|
+
*/
|
|
413
|
+
export type DependencySaveType = DependencyTypeShort | 'implicit';
|
|
176
414
|
/**
|
|
177
415
|
* A set of the possible long dependency type names,
|
|
178
416
|
* as used in `package.json` files.
|
|
@@ -187,4 +425,5 @@ export declare const shortDependencyTypes: Set<DependencyTypeShort>;
|
|
|
187
425
|
* to a corresponding short form name, used in lockfiles.
|
|
188
426
|
*/
|
|
189
427
|
export declare const dependencyTypes: Map<DependencyTypeLong, DependencyTypeShort>;
|
|
428
|
+
export {};
|
|
190
429
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GACjB,SAAS,EAAE,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC1B,IAAI,GACJ,SAAS,CAAA;AAEb,wBAAwB;AACxB,MAAM,MAAM,SAAS,GAAG,UAAU,MAAM,EAAE,CAAA;AAE1C,4BAA4B;AAC5B,MAAM,MAAM,KAAK,GAAG,UAAU,MAAM,EAAE,CAAA;AAEtC,+DAA+D;AAC/D,MAAM,MAAM,IAAI,GAAG;IACjB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,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;;GAEG;AACH,eAAO,MAAM,oBAAoB,0BAM/B,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,8CAQ1B,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,331 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
|
|
2
|
+
import { Version } from '@vltpkg/semver';
|
|
3
|
+
/**
|
|
4
|
+
* Normalize a single funding entry to a consistent format.
|
|
5
|
+
*/
|
|
6
|
+
const normalizeFundingEntry = (item) => {
|
|
7
|
+
const getTypeFromUrl = (url) => {
|
|
8
|
+
try {
|
|
9
|
+
const { hostname } = new URL(url);
|
|
10
|
+
const domain = hostname.startsWith('www.') ? hostname.slice(4) : hostname;
|
|
11
|
+
if (domain === 'github.com')
|
|
12
|
+
return 'github';
|
|
13
|
+
if (domain === 'patreon.com')
|
|
14
|
+
return 'patreon';
|
|
15
|
+
if (domain === 'opencollective.com')
|
|
16
|
+
return 'opencollective';
|
|
17
|
+
return 'individual';
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 'invalid';
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const validateType = (url, type) => {
|
|
24
|
+
const urlType = getTypeFromUrl(url);
|
|
25
|
+
if (!type ||
|
|
26
|
+
['github', 'patreon', 'opencollective'].includes(urlType))
|
|
27
|
+
return urlType;
|
|
28
|
+
if (urlType === 'invalid')
|
|
29
|
+
return undefined;
|
|
30
|
+
return type;
|
|
31
|
+
};
|
|
32
|
+
if (typeof item === 'string') {
|
|
33
|
+
return { url: item, type: getTypeFromUrl(item) };
|
|
34
|
+
}
|
|
35
|
+
if (isObject(item) &&
|
|
36
|
+
'url' in item &&
|
|
37
|
+
typeof item.url === 'string') {
|
|
38
|
+
// If the item is already normalized, return it directly
|
|
39
|
+
if (isNormalizedFundingEntry(item)) {
|
|
40
|
+
return item;
|
|
41
|
+
}
|
|
42
|
+
const obj = item;
|
|
43
|
+
const url = obj.url;
|
|
44
|
+
const validatedType = validateType(url, obj.type);
|
|
45
|
+
const result = { ...obj, url };
|
|
46
|
+
if (validatedType) {
|
|
47
|
+
result.type = validatedType;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
delete result.type;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
return { url: '', type: 'individual' };
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Normalize funding information to a consistent format.
|
|
58
|
+
*/
|
|
59
|
+
export const normalizeFunding = (funding) => {
|
|
60
|
+
if (!funding)
|
|
61
|
+
return;
|
|
62
|
+
const fundingArray = Array.isArray(funding) ? funding : [funding];
|
|
63
|
+
const sources = fundingArray.map(normalizeFundingEntry);
|
|
64
|
+
return sources.length > 0 ? sources : undefined;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Type guard to check if a value is a {@link NormalizedFundingEntry}.
|
|
68
|
+
*/
|
|
69
|
+
export const isNormalizedFundingEntry = (o) => {
|
|
70
|
+
return (isObject(o) &&
|
|
71
|
+
'url' in o &&
|
|
72
|
+
typeof o.url === 'string' &&
|
|
73
|
+
!!o.url &&
|
|
74
|
+
'type' in o &&
|
|
75
|
+
typeof o.type === 'string' &&
|
|
76
|
+
['github', 'patreon', 'opencollective', 'individual'].includes(o.type));
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Type guard to check if a value is a {@link NormalizedFunding}.
|
|
80
|
+
*/
|
|
81
|
+
export const isNormalizedFunding = (o) => {
|
|
82
|
+
return (Array.isArray(o) &&
|
|
83
|
+
o.length > 0 &&
|
|
84
|
+
o.every(isNormalizedFundingEntry));
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Given a version Normalize the version field in a manifest.
|
|
88
|
+
*/
|
|
89
|
+
export const fixManifestVersion = (manifest) => {
|
|
90
|
+
if (!Object.hasOwn(manifest, 'version')) {
|
|
91
|
+
return manifest;
|
|
92
|
+
}
|
|
93
|
+
if (!manifest.version) {
|
|
94
|
+
throw error('version is empty', {
|
|
95
|
+
manifest,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const version = Version.parse(manifest.version);
|
|
99
|
+
manifest.version = version.toString();
|
|
100
|
+
return manifest;
|
|
101
|
+
};
|
|
102
|
+
const kWriteAccess = Symbol.for('writeAccess');
|
|
103
|
+
const kIsPublisher = Symbol.for('isPublisher');
|
|
104
|
+
/**
|
|
105
|
+
* Parse a string or object into a normalized contributor.
|
|
106
|
+
*/
|
|
107
|
+
export const parsePerson = (person, writeAccess, isPublisher) => {
|
|
108
|
+
if (!person)
|
|
109
|
+
return;
|
|
110
|
+
if (isObject(person)) {
|
|
111
|
+
// this is an already parsed object person, just return its value
|
|
112
|
+
if (isNormalizedContributorEntry(person)) {
|
|
113
|
+
return person;
|
|
114
|
+
}
|
|
115
|
+
const name = typeof person.name === 'string' ? person.name : undefined;
|
|
116
|
+
const email = typeof person.email === 'string' ? person.email
|
|
117
|
+
: typeof person.mail === 'string' ? person.mail
|
|
118
|
+
: undefined;
|
|
119
|
+
if (!name && !email)
|
|
120
|
+
return undefined;
|
|
121
|
+
return {
|
|
122
|
+
name,
|
|
123
|
+
email,
|
|
124
|
+
[kWriteAccess]: writeAccess ?? false,
|
|
125
|
+
[kIsPublisher]: isPublisher ?? false,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
else if (typeof person === 'string') {
|
|
129
|
+
const NAME_PATTERN = /^([^(<]+)/;
|
|
130
|
+
const EMAIL_PATTERN = /<([^<>]+)>/;
|
|
131
|
+
const name = NAME_PATTERN.exec(person)?.[0].trim() || '';
|
|
132
|
+
const email = EMAIL_PATTERN.exec(person)?.[1] || '';
|
|
133
|
+
if (!name && !email)
|
|
134
|
+
return undefined;
|
|
135
|
+
return {
|
|
136
|
+
name: name || undefined,
|
|
137
|
+
email: email || undefined,
|
|
138
|
+
[kWriteAccess]: writeAccess ?? false,
|
|
139
|
+
[kIsPublisher]: isPublisher ?? false,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Type guard to check if a value is a normalized contributor entry.
|
|
146
|
+
*/
|
|
147
|
+
export const isNormalizedContributorEntry = (o) => {
|
|
148
|
+
return (isObject(o) &&
|
|
149
|
+
typeof o.name === 'string' &&
|
|
150
|
+
!!o.name &&
|
|
151
|
+
typeof o.email === 'string' &&
|
|
152
|
+
!!o.email &&
|
|
153
|
+
(isBoolean(o[kWriteAccess]) ||
|
|
154
|
+
isBoolean(o.writeAccess)) &&
|
|
155
|
+
(isBoolean(o[kIsPublisher]) ||
|
|
156
|
+
isBoolean(o.isPublisher)));
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Type guard to check if a value is a {@link NormalizedContributors}.
|
|
160
|
+
*/
|
|
161
|
+
export const isNormalizedContributors = (o) => {
|
|
162
|
+
return (Array.isArray(o) &&
|
|
163
|
+
o.length > 0 &&
|
|
164
|
+
o.every(isNormalizedContributorEntry));
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Normalize contributors and maintainers from various formats
|
|
168
|
+
*/
|
|
169
|
+
export const normalizeContributors = (contributors, maintainers) => {
|
|
170
|
+
if (!contributors && !maintainers)
|
|
171
|
+
return;
|
|
172
|
+
const result = [];
|
|
173
|
+
// Parse regular contributors (if any)
|
|
174
|
+
if (contributors) {
|
|
175
|
+
const contributorsArray = Array.isArray(contributors) ? contributors : [contributors];
|
|
176
|
+
const normalizedArray = contributorsArray.every(isNormalizedContributorEntry);
|
|
177
|
+
const noMaintainers = !maintainers ||
|
|
178
|
+
(Array.isArray(maintainers) && maintainers.length === 0);
|
|
179
|
+
// If all contributors are already normalized, and there are
|
|
180
|
+
// no maintainers, return the contributors directly
|
|
181
|
+
if (normalizedArray) {
|
|
182
|
+
if (noMaintainers) {
|
|
183
|
+
return contributorsArray.length > 0 ?
|
|
184
|
+
contributorsArray
|
|
185
|
+
: undefined;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
result.push(...contributorsArray);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// Parse each contributor and filter out undefined values
|
|
192
|
+
const parsedContributors = contributorsArray
|
|
193
|
+
.map(person => parsePerson(person))
|
|
194
|
+
.filter((c) => c !== undefined);
|
|
195
|
+
result.push(...parsedContributors);
|
|
196
|
+
}
|
|
197
|
+
// Parse maintainers with special flags
|
|
198
|
+
if (maintainers) {
|
|
199
|
+
const maintainersArray = Array.isArray(maintainers) ? maintainers : [maintainers];
|
|
200
|
+
const parsedMaintainers = maintainersArray
|
|
201
|
+
.map(person => parsePerson(person, true, true))
|
|
202
|
+
.filter((c) => c !== undefined);
|
|
203
|
+
result.push(...parsedMaintainers);
|
|
204
|
+
}
|
|
205
|
+
return result.length > 0 ? result : undefined;
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* Helper function to normalize a single {@link Bugs} entry.
|
|
209
|
+
*/
|
|
210
|
+
const normalizeSingleBug = (bug) => {
|
|
211
|
+
const res = [];
|
|
212
|
+
if (typeof bug === 'string') {
|
|
213
|
+
// Try to parse as URL first - if it succeeds, treat as link
|
|
214
|
+
try {
|
|
215
|
+
new URL(bug);
|
|
216
|
+
res.push({ type: 'link', url: bug });
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
// TODO: need a more robust email validation, likely
|
|
220
|
+
// to be replaced with valibot / zod
|
|
221
|
+
// If URL parsing fails, check if it's a valid email
|
|
222
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
223
|
+
if (emailRegex.test(bug)) {
|
|
224
|
+
res.push({ type: 'email', email: bug });
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Default to link for plain strings like 'example.com'
|
|
228
|
+
res.push({ type: 'link', url: bug });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (isObject(bug)) {
|
|
233
|
+
if (isNormalizedBugsEntry(bug)) {
|
|
234
|
+
res.push(bug);
|
|
235
|
+
}
|
|
236
|
+
const obj = bug;
|
|
237
|
+
if (obj.url) {
|
|
238
|
+
res.push({ type: 'link', url: obj.url });
|
|
239
|
+
}
|
|
240
|
+
if (obj.email) {
|
|
241
|
+
res.push({ type: 'email', email: obj.email });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return res.length > 0 ? res : [];
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Normalize bugs information to a {@link NormalizedBugs} consistent format.
|
|
248
|
+
*/
|
|
249
|
+
export const normalizeBugs = (bugs) => {
|
|
250
|
+
if (!bugs)
|
|
251
|
+
return;
|
|
252
|
+
const result = [];
|
|
253
|
+
// Handle array of bugs entries
|
|
254
|
+
if (Array.isArray(bugs)) {
|
|
255
|
+
for (const bug of bugs) {
|
|
256
|
+
result.push(...normalizeSingleBug(bug));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
// Handle single bugs entry
|
|
261
|
+
result.push(...normalizeSingleBug(bugs));
|
|
262
|
+
}
|
|
263
|
+
return result.length > 0 ? result : undefined;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Type guard to check if a value is a {@link NormalizedBugsEntry}.
|
|
267
|
+
*/
|
|
268
|
+
export const isNormalizedBugsEntry = (o) => {
|
|
269
|
+
return (isObject(o) &&
|
|
270
|
+
'type' in o &&
|
|
271
|
+
((o.type === 'email' &&
|
|
272
|
+
typeof o.email === 'string' &&
|
|
273
|
+
!!o.email) ||
|
|
274
|
+
(o.type === 'link' && typeof o.url === 'string' && !!o.url)));
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Type guard to check if a value is a {@link NormalizedBugs}.
|
|
278
|
+
*/
|
|
279
|
+
export const isNormalizedBugs = (o) => {
|
|
280
|
+
return (Array.isArray(o) && o.length > 0 && o.every(isNormalizedBugsEntry));
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Normalize keywords information to a {@link NormalizedKeywords} consistent format.
|
|
284
|
+
*/
|
|
285
|
+
export const normalizeKeywords = (keywords) => {
|
|
286
|
+
if (!keywords)
|
|
287
|
+
return;
|
|
288
|
+
let keywordArray = [];
|
|
289
|
+
if (typeof keywords === 'string') {
|
|
290
|
+
// Handle comma-separated string values
|
|
291
|
+
keywordArray = keywords
|
|
292
|
+
.split(',')
|
|
293
|
+
.map(keyword => keyword.trim())
|
|
294
|
+
.filter(keyword => keyword.length > 0);
|
|
295
|
+
}
|
|
296
|
+
else if (Array.isArray(keywords)) {
|
|
297
|
+
// If all keywords are already normalized, return them directly
|
|
298
|
+
if (isNormalizedKeywords(keywords)) {
|
|
299
|
+
return keywords;
|
|
300
|
+
}
|
|
301
|
+
// Handle array of strings, filter out empty/invalid entries
|
|
302
|
+
keywordArray = keywords
|
|
303
|
+
.filter((keyword) => typeof keyword === 'string')
|
|
304
|
+
.map(keyword => keyword.trim())
|
|
305
|
+
.filter(keyword => keyword.length > 0);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
// Invalid format
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
return keywordArray.length > 0 ? keywordArray : undefined;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Type guard to check if a value is a {@link NormalizedKeywords}.
|
|
315
|
+
*/
|
|
316
|
+
export const isNormalizedKeywords = (o) => {
|
|
317
|
+
return (Array.isArray(o) &&
|
|
318
|
+
o.length > 0 &&
|
|
319
|
+
o.every(keyword => typeof keyword === 'string' &&
|
|
320
|
+
!!keyword &&
|
|
321
|
+
!keyword.startsWith(' ') &&
|
|
322
|
+
!keyword.endsWith(' ')));
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* A type guard to check if a value is a boolean.
|
|
326
|
+
*/
|
|
327
|
+
export const isBoolean = (value) => typeof value === 'boolean';
|
|
328
|
+
export const integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/;
|
|
3
329
|
export const isIntegrity = (i) => typeof i === 'string' && integrityRE.test(i);
|
|
4
330
|
export const asIntegrity = (i) => {
|
|
5
331
|
if (!isIntegrity(i)) {
|
|
@@ -13,7 +339,7 @@ export const asIntegrity = (i) => {
|
|
|
13
339
|
export const assertIntegrity = i => {
|
|
14
340
|
asIntegrity(i);
|
|
15
341
|
};
|
|
16
|
-
const keyIDRE = /^SHA256:[a-zA-Z0-9/+]{43}$/;
|
|
342
|
+
export const keyIDRE = /^SHA256:[a-zA-Z0-9/+]{43}$/;
|
|
17
343
|
export const isKeyID = (k) => typeof k === 'string' && keyIDRE.test(k);
|
|
18
344
|
export const asKeyID = (k) => {
|
|
19
345
|
if (!isKeyID(k)) {
|
|
@@ -27,19 +353,52 @@ export const asKeyID = (k) => {
|
|
|
27
353
|
export const assertKeyID = k => {
|
|
28
354
|
asKeyID(k);
|
|
29
355
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
356
|
+
/**
|
|
357
|
+
* Convert an unknown value to an error.
|
|
358
|
+
*/
|
|
359
|
+
export const asError = (er, fallbackMessage = 'Unknown error') => er instanceof Error ? er : new Error(String(er) || fallbackMessage);
|
|
360
|
+
/**
|
|
361
|
+
* Check if a value is an error.
|
|
362
|
+
*/
|
|
363
|
+
export const isError = (er) => er instanceof Error;
|
|
364
|
+
/**
|
|
365
|
+
* Check if an error has a cause property.
|
|
366
|
+
*/
|
|
367
|
+
export const isErrorWithCause = (er) => isError(er) && 'cause' in er;
|
|
368
|
+
/**
|
|
369
|
+
* Check if an unknown value is a plain object.
|
|
370
|
+
*/
|
|
371
|
+
export const isObject = (v) => !!v &&
|
|
372
|
+
typeof v === 'object' &&
|
|
373
|
+
(v.constructor === Object ||
|
|
374
|
+
v.constructor === undefined);
|
|
375
|
+
export const maybeRecordStringString = (o) => o === undefined || isRecordStringString(o);
|
|
376
|
+
export const isRecordStringString = (o) => isRecordStringT(o, s => typeof s === 'string');
|
|
377
|
+
export const assertRecordStringString = (o) => assertRecordStringT(o, s => typeof s === 'string', 'Record<string, string>');
|
|
378
|
+
export const isRecordStringT = (o, check) => isObject(o) &&
|
|
34
379
|
Object.entries(o).every(([k, v]) => typeof k === 'string' && check(v));
|
|
35
|
-
const
|
|
36
|
-
|
|
380
|
+
export const assertRecordStringT = (o, check,
|
|
381
|
+
/** a type description, like 'Record<string, Record<string, string>>' */
|
|
382
|
+
wanted) => {
|
|
383
|
+
if (!isRecordStringT(o, check)) {
|
|
384
|
+
throw error('Invalid record', {
|
|
385
|
+
found: o,
|
|
386
|
+
wanted,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
export const isRecordStringManifest = (o) => isRecordStringT(o, v => isManifest(v));
|
|
391
|
+
export const maybePeerDependenciesMetaSet = (o) => o === undefined ||
|
|
37
392
|
isRecordStringT(o, v => isPeerDependenciesMetaValue(v));
|
|
38
|
-
const maybeBoolean = (o) => o === undefined || typeof o === 'boolean';
|
|
39
|
-
const isPeerDependenciesMetaValue = (o) =>
|
|
40
|
-
const maybeString = (a) => a === undefined || typeof a === 'string';
|
|
41
|
-
const maybeDist = (a) => a === undefined || (
|
|
42
|
-
|
|
393
|
+
export const maybeBoolean = (o) => o === undefined || typeof o === 'boolean';
|
|
394
|
+
export const isPeerDependenciesMetaValue = (o) => isObject(o) && maybeBoolean(o.optional);
|
|
395
|
+
export const maybeString = (a) => a === undefined || typeof a === 'string';
|
|
396
|
+
export const maybeDist = (a) => a === undefined || (isObject(a) && maybeString(a.tarball));
|
|
397
|
+
/**
|
|
398
|
+
* Is a given unknown value a valid {@link Manifest} object?
|
|
399
|
+
* Returns `true` if so.
|
|
400
|
+
*/
|
|
401
|
+
export const isManifest = (m) => isObject(m) &&
|
|
43
402
|
!Array.isArray(m) &&
|
|
44
403
|
maybeString(m.name) &&
|
|
45
404
|
maybeString(m.version) &&
|
|
@@ -50,19 +409,148 @@ export const isManifest = (m) => isObj(m) &&
|
|
|
50
409
|
maybeRecordStringString(m.acceptDependencies) &&
|
|
51
410
|
maybePeerDependenciesMetaSet(m.peerDependenciesMeta) &&
|
|
52
411
|
maybeDist(m.dist);
|
|
412
|
+
/**
|
|
413
|
+
* A specific {@link Manifest} that is retrieved uniquely from reading
|
|
414
|
+
* registry packument and manifest endpoints, it has `dist`, `name` and
|
|
415
|
+
* `version` fields defined.
|
|
416
|
+
*/
|
|
53
417
|
export const isManifestRegistry = (m) => isManifest(m) && !!m.dist && !!m.name && !!m.version;
|
|
418
|
+
/**
|
|
419
|
+
* Given an unknown value, convert it to a {@link Manifest}.
|
|
420
|
+
*/
|
|
54
421
|
export const asManifest = (m, from) => {
|
|
55
422
|
if (!isManifest(m)) {
|
|
56
423
|
throw error('invalid manifest', { found: m }, from ?? asManifest);
|
|
57
424
|
}
|
|
58
425
|
return m;
|
|
59
426
|
};
|
|
427
|
+
/**
|
|
428
|
+
* Given a {@link Manifest} returns a {@link NormalizedManifest} that
|
|
429
|
+
* contains normalized author, bugs, funding, contributors, keywords and
|
|
430
|
+
* version fields.
|
|
431
|
+
*/
|
|
432
|
+
export const normalizeManifest = (manifest) => {
|
|
433
|
+
manifest = fixManifestVersion(manifest);
|
|
434
|
+
const normalizedAuthor = parsePerson(manifest.author);
|
|
435
|
+
const normalizedFunding = normalizeFunding(manifest.funding);
|
|
436
|
+
const normalizedContributors = normalizeContributors(manifest.contributors, manifest.maintainers);
|
|
437
|
+
const normalizedBugs = normalizeBugs(manifest.bugs);
|
|
438
|
+
const normalizedKeywords = normalizeKeywords(manifest.keywords);
|
|
439
|
+
// holds the same object reference but renames the variable here
|
|
440
|
+
// so that it's simpler to cast it to the normalized type
|
|
441
|
+
const normalizedManifest = manifest;
|
|
442
|
+
if (normalizedAuthor) {
|
|
443
|
+
normalizedManifest.author = normalizedAuthor;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
delete normalizedManifest.author;
|
|
447
|
+
}
|
|
448
|
+
if (normalizedFunding) {
|
|
449
|
+
normalizedManifest.funding = normalizedFunding;
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
delete normalizedManifest.funding;
|
|
453
|
+
}
|
|
454
|
+
if (normalizedContributors) {
|
|
455
|
+
normalizedManifest.contributors = normalizedContributors;
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
delete normalizedManifest.contributors;
|
|
459
|
+
}
|
|
460
|
+
if (normalizedBugs) {
|
|
461
|
+
normalizedManifest.bugs = normalizedBugs;
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
delete normalizedManifest.bugs;
|
|
465
|
+
}
|
|
466
|
+
if (normalizedKeywords) {
|
|
467
|
+
normalizedManifest.keywords = normalizedKeywords;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
delete normalizedManifest.keywords;
|
|
471
|
+
}
|
|
472
|
+
// Remove maintainers field if it exists in the raw manifest
|
|
473
|
+
// this can only happen if the manifest is of ManifestRegistry type
|
|
474
|
+
if ('maintainers' in normalizedManifest &&
|
|
475
|
+
normalizedManifest.maintainers) {
|
|
476
|
+
delete normalizedManifest.maintainers;
|
|
477
|
+
return normalizedManifest;
|
|
478
|
+
}
|
|
479
|
+
return normalizedManifest;
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Type guard to check if a value is a {@link NormalizedManifest}.
|
|
483
|
+
*/
|
|
484
|
+
export const isNormalizedManifest = (o) => {
|
|
485
|
+
return (isManifest(o) &&
|
|
486
|
+
// given that all these values are optional and potentially undefined
|
|
487
|
+
// we only check their value content if they are present
|
|
488
|
+
('author' in o ? isNormalizedContributorEntry(o.author) : true) &&
|
|
489
|
+
('contributors' in o ?
|
|
490
|
+
isNormalizedContributors(o.contributors)
|
|
491
|
+
: true) &&
|
|
492
|
+
('funding' in o ? isNormalizedFunding(o.funding) : true) &&
|
|
493
|
+
('bugs' in o ? isNormalizedBugs(o.bugs) : true) &&
|
|
494
|
+
('keywords' in o ? isNormalizedKeywords(o.keywords) : true));
|
|
495
|
+
};
|
|
496
|
+
/**
|
|
497
|
+
* Given an unknown value, convert it to a {@link NormalizedManifest}.
|
|
498
|
+
*/
|
|
499
|
+
export const asNormalizedManifest = (m, from) => {
|
|
500
|
+
if (!isNormalizedManifest(m)) {
|
|
501
|
+
throw error('invalid normalized manifest', { found: m }, from ?? asNormalizedManifest);
|
|
502
|
+
}
|
|
503
|
+
return m;
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Given an unknown value, convert it to a {@link ManifestRegistry}.
|
|
507
|
+
*/
|
|
60
508
|
export const asManifestRegistry = (m, from) => {
|
|
61
509
|
if (!isManifestRegistry(m)) {
|
|
62
510
|
throw error('invalid registry manifest', { found: m }, from ?? asManifestRegistry);
|
|
63
511
|
}
|
|
64
512
|
return m;
|
|
65
513
|
};
|
|
514
|
+
/**
|
|
515
|
+
* Type guard to check if a value is a {@link NormalizedManifestRegistry}.
|
|
516
|
+
*/
|
|
517
|
+
export const isNormalizedManifestRegistry = (o) => {
|
|
518
|
+
return isNormalizedManifest(o) && isManifestRegistry(o);
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* Given an unknown value, convert it to a {@link NormalizedManifestRegistry}.
|
|
522
|
+
*/
|
|
523
|
+
export const asNormalizedManifestRegistry = (m, from) => {
|
|
524
|
+
if (!isNormalizedManifestRegistry(m)) {
|
|
525
|
+
throw error('invalid normalized manifest registry', { found: m }, from ?? asNormalizedManifestRegistry);
|
|
526
|
+
}
|
|
527
|
+
return m;
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Expands a normalized contributor entry by converting the
|
|
531
|
+
* in-memory symbols to their plain values.
|
|
532
|
+
*/
|
|
533
|
+
const expandNormalizedContributorEntrySymbols = (c) => {
|
|
534
|
+
return {
|
|
535
|
+
...c,
|
|
536
|
+
writeAccess: c[kWriteAccess],
|
|
537
|
+
isPublisher: c[kIsPublisher],
|
|
538
|
+
};
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* Walks a normalized manifest and expands any symbols found
|
|
542
|
+
* in the `author` and `contributors` fields.
|
|
543
|
+
*/
|
|
544
|
+
export const expandNormalizedManifestSymbols = (m) => {
|
|
545
|
+
const res = { ...m };
|
|
546
|
+
if (isNormalizedContributorEntry(m.author)) {
|
|
547
|
+
res.author = expandNormalizedContributorEntrySymbols(m.author);
|
|
548
|
+
}
|
|
549
|
+
if (isNormalizedContributors(m.contributors)) {
|
|
550
|
+
res.contributors = m.contributors.map(expandNormalizedContributorEntrySymbols);
|
|
551
|
+
}
|
|
552
|
+
return res;
|
|
553
|
+
};
|
|
66
554
|
export const assertManifest = m => {
|
|
67
555
|
asManifest(m, assertManifest);
|
|
68
556
|
};
|
|
@@ -70,7 +558,7 @@ export const assertManifestRegistry = m => {
|
|
|
70
558
|
asManifestRegistry(m, assertManifestRegistry);
|
|
71
559
|
};
|
|
72
560
|
export const isPackument = (p) => {
|
|
73
|
-
if (!
|
|
561
|
+
if (!isObject(p) || typeof p.name !== 'string')
|
|
74
562
|
return false;
|
|
75
563
|
const { versions, 'dist-tags': distTags, time } = p;
|
|
76
564
|
return (isRecordStringString(distTags) &&
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAiM3C,MAAM,WAAW,GAAG,8BAA8B,CAAA;AAClD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAkB,EAAE,CACxD,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAa,EAAE;IACnD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CACT,mBAAmB,EACnB;YACE,KAAK,EAAE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AEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAsB;IAC/D,MAAM;IACN,KAAK;IACL,MAAM;IACN,UAAU;IACV,cAAc;CACf,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAGpC;IACA,CAAC,cAAc,EAAE,MAAM,CAAC;IACxB,CAAC,iBAAiB,EAAE,KAAK,CAAC;IAC1B,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC5B,CAAC,sBAAsB,EAAE,UAAU,CAAC;CACrC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\n\n/** anything that can be encoded in JSON */\nexport type JSONField =\n | JSONField[]\n | boolean\n | number\n | string\n | { [k: string]: JSONField }\n | null\n | undefined\n\n/** sha512 SRI string */\nexport type Integrity = `sha512-${string}`\n\n/** SHA256 key identifier */\nexport type KeyID = `SHA256:${string}`\n\n/** The Manifest['dist'] field present in registry manifests */\nexport type Dist = {\n integrity?: Integrity\n shasum?: string\n tarball?: string\n fileCount?: number\n unpackedSize?: number\n signatures?: {\n keyid: KeyID\n sig: string\n }[]\n}\n\n/** An object used to mark some peerDeps as optional */\nexport type PeerDependenciesMetaValue = {\n optional?: boolean\n}\n\n// Don't use Record here since TS cant do circular references with that\n// https://github.com/microsoft/TypeScript/issues/41164#issuecomment-1427073368\nexport type ConditionalValueObject = {\n [k: string]: ConditionalValue\n}\n\nexport type ConditionalValue =\n | ConditionalValue[]\n | ConditionalValueObject\n | string\n | null\n\nexport type ExportsSubpaths = {\n [path in '.' | `./${string}`]?: ConditionalValue\n}\n\nexport type Exports =\n | Exclude<ConditionalValue, null>\n | ExportsSubpaths\n\nexport type Imports = Record<`#${string}`, ConditionalValue>\n\nexport type FundingEntry = string | { url: string }\nexport type Funding = FundingEntry | FundingEntry[]\n\nexport type Person =\n | string\n | {\n name: string\n url?: string\n email?: string\n }\n\nexport type Repository =\n | string\n | {\n type: string\n url: string\n }\n\nexport type Bugs =\n | string\n | {\n url?: string\n email?: string\n }\n\nexport type Manifest = {\n /** The name of the package. optional because {} is a valid package.json */\n name?: string\n /** The version of the package. optional because {} is a valid package.json */\n version?: string\n /** production dependencies, name:specifier */\n dependencies?: Record<string, string>\n /** development dependencies, name:specifier */\n devDependencies?: Record<string, string>\n /** optional dependencies, name:specifier */\n optionalDependencies?: Record<string, string>\n /** peer dependencies, name:specifier */\n peerDependencies?: Record<string, string>\n /** peer dependencies marked as optional */\n peerDependenciesMeta?: Record<string, PeerDependenciesMetaValue>\n /** dependency ranges that are acceptable, but not forced */\n acceptDependencies?: Record<string, string>\n /** names of dependencies included in the package tarball */\n bundleDependencies?: string[]\n /** a message indicating that this is not to be used */\n deprecated?: string\n /** executable built and linked by this package */\n bin?: Record<string, string> | string\n /** run-script actions for this package */\n scripts?: Record<string, string>\n /** supported run-time platforms this package can run on */\n engines?: Record<string, string>\n /** supported operating systems this package can run on */\n os?: string[] | string\n /** supported CPU architectures this package can run on */\n cpu?: string[] | string\n /** URLs that can be visited to fund this project */\n funding?: Funding\n /**\n * Only present in Manifests served by a registry. Contains information\n * about the artifact served for this package release.\n */\n dist?: Dist\n /** a short description of the package */\n description?: string\n /** search keywords */\n keywords?: string[]\n /** where to go to file issues */\n bugs?: Bugs\n /** where the development happens */\n repository?: Repository\n /** the main module, if exports['.'] is not set */\n main?: string\n /** named subpath exports */\n exports?: Exports\n /** named #identifier imports */\n imports?: Imports\n /**\n * the HEAD of the git repo this was published from\n * only present in published packages\n */\n gitHead?: string\n /** whether the package is private */\n private?: boolean\n /** whether this is ESM or CommonJS by default */\n type?: 'commonjs' | 'module'\n /** npm puts this on published manifests */\n gypfile?: boolean\n /** the author of a package */\n author?: Person\n /** contributors to the package */\n contributors?: Person[]\n}\n\nexport type ManifestRegistry = Manifest &\n Required<Pick<Manifest, 'name' | 'version' | 'dist'>>\n\nexport type Packument = {\n name: string\n 'dist-tags': Record<string, string>\n versions: Record<string, Manifest>\n modified?: string\n time?: Record<string, string>\n readme?: string\n}\n\nexport type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag'\n\n/**\n * A representation of a given remote ref in a {@link RevDoc} object.\n */\nexport type RevDocEntry = Omit<Manifest, 'type'> &\n Required<Pick<Manifest, 'version'>> & {\n /** sha this references */\n sha: string\n /** ref as passed git locally */\n ref: string\n /** canonical full ref, like `refs/tags/blahblah` */\n rawRef: string\n /** what type of ref this is: 'branch', 'tag', etc. */\n type: RefType\n }\n\n/**\n * An object kind of resembling a packument, but about a git repo.\n */\nexport type RevDoc = Omit<Packument, 'versions'> & {\n /** all semver-looking tags go in this record */\n versions: Record<string, RevDocEntry>\n /** all named things that can be cloned down remotely */\n refs: Record<string, RevDocEntry>\n /** all named shas referenced above */\n shas: Record<string, string[]>\n}\n\nconst integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/\nexport const isIntegrity = (i: unknown): i is Integrity =>\n typeof i === 'string' && integrityRE.test(i)\n\nexport const asIntegrity = (i: unknown): Integrity => {\n if (!isIntegrity(i)) {\n throw error(\n 'invalid integrity',\n {\n found: i,\n wanted: integrityRE,\n },\n asIntegrity,\n )\n }\n return i\n}\n\nexport const assertIntegrity: (\n i: unknown,\n) => asserts i is Integrity = i => {\n asIntegrity(i)\n}\n\nconst keyIDRE = /^SHA256:[a-zA-Z0-9/+]{43}$/\nexport const isKeyID = (k: unknown): k is KeyID =>\n typeof k === 'string' && keyIDRE.test(k)\n\nexport const asKeyID = (k: unknown): KeyID => {\n if (!isKeyID(k)) {\n throw error(\n 'invalid key ID',\n {\n found: k,\n wanted: keyIDRE,\n },\n asKeyID,\n )\n }\n return k\n}\n\nexport const assertKeyID: (k: unknown) => asserts k is KeyID = k => {\n asKeyID(k)\n}\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\nconst maybeRecordStringString = (\n o: unknown,\n): o is Record<string, string> | undefined =>\n o === undefined || isRecordStringString(o)\n\nconst isRecordStringString = (\n o: unknown,\n): o is Record<string, string> =>\n isRecordStringT<string>(o, s => typeof s === 'string')\n\nconst isRecordStringT = <T>(\n o: unknown,\n check: (o: unknown) => boolean,\n): o is Record<string, T> =>\n isObj(o) &&\n Object.entries(o).every(\n ([k, v]) => typeof k === 'string' && check(v),\n )\n\nconst isRecordStringManifest = (\n o: unknown,\n): o is Record<string, Manifest> =>\n isRecordStringT<Manifest>(o, v => isManifest(v))\n\nconst maybePeerDependenciesMetaSet = (\n o: unknown,\n): o is Record<string, PeerDependenciesMetaValue> | undefined =>\n o === undefined ||\n isRecordStringT<PeerDependenciesMetaValue>(o, v =>\n isPeerDependenciesMetaValue(v),\n )\n\nconst maybeBoolean = (o: unknown): o is boolean =>\n o === undefined || typeof o === 'boolean'\n\nconst isPeerDependenciesMetaValue = (\n o: unknown,\n): o is PeerDependenciesMetaValue =>\n isObj(o) && maybeBoolean(o.optional)\n\nconst maybeString = (a: unknown): a is string | undefined =>\n a === undefined || typeof a === 'string'\n\nconst maybeDist = (a: unknown): a is Manifest['dist'] =>\n a === undefined || (isObj(a) && maybeString(a.tarball))\n\nexport const isManifest = (m: unknown): m is Manifest =>\n isObj(m) &&\n !Array.isArray(m) &&\n maybeString(m.name) &&\n maybeString(m.version) &&\n maybeRecordStringString(m.dependencies) &&\n maybeRecordStringString(m.devDependencies) &&\n maybeRecordStringString(m.optionalDependencies) &&\n maybeRecordStringString(m.peerDependencies) &&\n maybeRecordStringString(m.acceptDependencies) &&\n maybePeerDependenciesMetaSet(m.peerDependenciesMeta) &&\n maybeDist(m.dist)\n\nexport const isManifestRegistry = (\n m: unknown,\n): m is ManifestRegistry =>\n isManifest(m) && !!m.dist && !!m.name && !!m.version\n\nexport const asManifest = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): Manifest => {\n if (!isManifest(m)) {\n throw error('invalid manifest', { found: m }, from ?? asManifest)\n }\n return m\n}\n\nexport const asManifestRegistry = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): ManifestRegistry => {\n if (!isManifestRegistry(m)) {\n throw error(\n 'invalid registry manifest',\n { found: m },\n from ?? asManifestRegistry,\n )\n }\n return m\n}\n\nexport const assertManifest: (\n m: unknown,\n) => asserts m is Manifest = m => {\n asManifest(m, assertManifest)\n}\nexport const assertManifestRegistry: (\n m: unknown,\n) => asserts m is ManifestRegistry = m => {\n asManifestRegistry(m, assertManifestRegistry)\n}\n\nexport const isPackument = (p: unknown): p is Packument => {\n if (!isObj(p) || typeof p.name !== 'string') return false\n const { versions, 'dist-tags': distTags, time } = p\n return (\n isRecordStringString(distTags) &&\n isRecordStringManifest(versions) &&\n maybeRecordStringString(time) &&\n Object.values(distTags).every(v => versions[v]?.name == p.name)\n )\n}\n\nexport const asPackument = (\n p: unknown,\n from?: (...a: unknown[]) => any,\n): Packument => {\n if (!isPackument(p)) {\n throw error(\n 'invalid packument',\n { found: p },\n from ?? asPackument,\n )\n }\n return p\n}\n\nexport const assertPackument: (\n m: unknown,\n) => asserts m is Packument = m => {\n asPackument(m)\n}\n\n/**\n * Name of the package.json keys used to define different types of dependencies.\n */\nexport type DependencyTypeLong =\n | 'dependencies'\n | 'devDependencies'\n | 'optionalDependencies'\n | 'peerDependencies'\n\n/**\n * Unique keys that define different types of dependencies relationship.\n */\nexport type DependencyTypeShort =\n | 'dev'\n | 'optional'\n | 'peer'\n | 'peerOptional'\n | 'prod'\n\n/**\n * A set of the possible long dependency type names,\n * as used in `package.json` files.\n */\nexport const longDependencyTypes = new Set<DependencyTypeLong>([\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n])\n\n/**\n * A set of the short type keys used to represent dependency relationships.\n */\nexport const shortDependencyTypes = new Set<DependencyTypeShort>([\n 'prod',\n 'dev',\n 'peer',\n 'optional',\n 'peerOptional',\n])\n\n/**\n * Maps between long form names usually used in `package.json` files\n * to a corresponding short form name, used in lockfiles.\n */\nexport const dependencyTypes = new Map<\n DependencyTypeLong,\n DependencyTypeShort\n>([\n ['dependencies', 'prod'],\n ['devDependencies', 'dev'],\n ['peerDependencies', 'peer'],\n ['optionalDependencies', 'optional'],\n])\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAyFxC;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAC5B,IAAa,EACW,EAAE;IAC1B,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;QAC7C,IAAI,CAAC;YACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;YACjC,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;YAC5D,IAAI,MAAM,KAAK,YAAY;gBAAE,OAAO,QAAQ,CAAA;YAC5C,IAAI,MAAM,KAAK,aAAa;gBAAE,OAAO,SAAS,CAAA;YAC9C,IAAI,MAAM,KAAK,oBAAoB;gBAAE,OAAO,gBAAgB,CAAA;YAC5D,OAAO,YAAY,CAAA;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAA;QAClB,CAAC;IACH,CAAC,CAAA;IAED,MAAM,YAAY,GAAG,CACnB,GAAW,EACX,IAAa,EACO,EAAE;QACtB,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAA;QACnC,IACE,CAAC,IAAI;YACL,CAAC,QAAQ,EAAE,SAAS,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;YAEzD,OAAO,OAAO,CAAA;QAChB,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAA;QAC3C,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,IAAI,OAAO,IAAI,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CAAqB;IAC7D,cAAc;IACd,iBAAiB;IACjB,kBAAkB;IAClB,sBAAsB;CACvB,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAsB;IAC/D,MAAM;IACN,KAAK;IACL,MAAM;IACN,UAAU;IACV,cAAc;CACf,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAGpC;IACA,CAAC,cAAc,EAAE,MAAM,CAAC;IACxB,CAAC,iBAAiB,EAAE,KAAK,CAAC;IAC1B,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAC5B,CAAC,sBAAsB,EAAE,UAAU,CAAC;CACrC,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { Version } from '@vltpkg/semver'\n\n/**\n * Utility type that overrides specific properties of type T with new types\n * from R. Constrains override values to exclude undefined, ensuring that\n * normalization cannot introduce undefined to fields that shouldn't have it.\n */\nexport type Override<\n T,\n R extends { [K in keyof R]: R[K] extends undefined ? never : R[K] },\n> = {\n [K in keyof T]: K extends keyof R ? R[K] : T[K]\n}\n\n/** anything that can be encoded in JSON */\nexport type JSONField =\n | JSONField[]\n | boolean\n | number\n | string\n | { [k: string]: JSONField }\n | null\n | undefined\n\n/** sha512 SRI string */\nexport type Integrity = `sha512-${string}`\n\n/** SHA256 key identifier */\nexport type KeyID = `SHA256:${string}`\n\n/** The Manifest['dist'] field present in registry manifests */\nexport type Dist = {\n integrity?: Integrity\n shasum?: string\n tarball?: string\n fileCount?: number\n unpackedSize?: number\n signatures?: {\n keyid: KeyID\n sig: string\n }[]\n}\n\n/** An object used to mark some peerDeps as optional */\nexport type PeerDependenciesMetaValue = {\n optional?: boolean\n}\n\n// Don't use Record here since TS cant do circular references with that\n// https://github.com/microsoft/TypeScript/issues/41164#issuecomment-1427073368\nexport type ConditionalValueObject = {\n [k: string]: ConditionalValue\n}\n\nexport type ConditionalValue =\n | ConditionalValue[]\n | ConditionalValueObject\n | string\n | null\n\nexport type ExportsSubpaths = {\n [path in '.' | `./${string}`]?: ConditionalValue\n}\n\nexport type Exports =\n | Exclude<ConditionalValue, null>\n | ExportsSubpaths\n\nexport type Imports = Record<`#${string}`, ConditionalValue>\n\nexport type FundingEntry =\n | string\n | { url: string; type?: string; [key: string]: JSONField }\nexport type Funding = FundingEntry | FundingEntry[]\n\n/**\n * An object with url and optional additional properties\n */\nexport type NormalizedFundingEntry = {\n url: string\n type?: string\n [key: string]: JSONField\n}\n\n/**\n * Normalized funding information, an array of {@link NormalizedFundingEntry}.\n */\nexport type NormalizedFunding = NormalizedFundingEntry[]\n\n/**\n * Normalize a single funding entry to a consistent format.\n */\nconst normalizeFundingEntry = (\n item: unknown,\n): NormalizedFundingEntry => {\n const getTypeFromUrl = (url: string): string => {\n try {\n const { hostname } = new URL(url)\n const domain =\n hostname.startsWith('www.') ? hostname.slice(4) : hostname\n if (domain === 'github.com') return 'github'\n if (domain === 'patreon.com') return 'patreon'\n if (domain === 'opencollective.com') return 'opencollective'\n return 'individual'\n } catch {\n return 'invalid'\n }\n }\n\n const validateType = (\n url: string,\n type?: string,\n ): string | undefined => {\n const urlType = getTypeFromUrl(url)\n if (\n !type ||\n ['github', 'patreon', 'opencollective'].includes(urlType)\n )\n return urlType\n if (urlType === 'invalid') return undefined\n return type\n }\n\n if (typeof item === 'string') {\n return { url: item, type: getTypeFromUrl(item) }\n }\n if (\n isObject(item) &&\n 'url' in item &&\n typeof item.url === 'string'\n ) {\n // If the item is already normalized, return it directly\n if (isNormalizedFundingEntry(item)) {\n return item\n }\n\n const obj = item\n const url = obj.url as string\n const validatedType = validateType(\n url,\n obj.type as string | undefined,\n )\n const result = { ...obj, url } as Record<string, unknown>\n if (validatedType) {\n result.type = validatedType\n } else {\n delete result.type\n }\n return result as NormalizedFundingEntry\n }\n return { url: '', type: 'individual' }\n}\n\n/**\n * Normalize funding information to a consistent format.\n */\nexport const normalizeFunding = (\n funding: unknown,\n): NormalizedFunding | undefined => {\n if (!funding) return\n\n const fundingArray = Array.isArray(funding) ? funding : [funding]\n const sources = fundingArray.map(normalizeFundingEntry)\n return sources.length > 0 ? sources : undefined\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedFundingEntry}.\n */\nexport const isNormalizedFundingEntry = (\n o: unknown,\n): o is NormalizedFundingEntry => {\n return (\n isObject(o) &&\n 'url' in o &&\n typeof o.url === 'string' &&\n !!o.url &&\n 'type' in o &&\n typeof o.type === 'string' &&\n ['github', 'patreon', 'opencollective', 'individual'].includes(\n o.type,\n )\n )\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedFunding}.\n */\nexport const isNormalizedFunding = (\n o: unknown,\n): o is NormalizedFunding => {\n return (\n Array.isArray(o) &&\n o.length > 0 &&\n o.every(isNormalizedFundingEntry)\n )\n}\n\n/**\n * Given a version Normalize the version field in a manifest.\n */\nexport const fixManifestVersion = <\n T extends Manifest | ManifestRegistry,\n>(\n manifest: T,\n): T => {\n if (!Object.hasOwn(manifest, 'version')) {\n return manifest\n }\n if (!manifest.version) {\n throw error('version is empty', {\n manifest,\n })\n }\n const version = Version.parse(manifest.version)\n manifest.version = version.toString()\n return manifest\n}\n\nconst kWriteAccess = Symbol.for('writeAccess')\nconst kIsPublisher = Symbol.for('isPublisher')\n\n/**\n * Parse a string or object into a normalized contributor.\n */\nexport const parsePerson = (\n person: unknown,\n writeAccess?: boolean,\n isPublisher?: boolean,\n): NormalizedContributorEntry | undefined => {\n if (!person) return\n\n if (isObject(person)) {\n // this is an already parsed object person, just return its value\n if (isNormalizedContributorEntry(person)) {\n return person\n }\n\n const name =\n typeof person.name === 'string' ? person.name : undefined\n const email =\n typeof person.email === 'string' ? person.email\n : typeof person.mail === 'string' ? person.mail\n : undefined\n\n if (!name && !email) return undefined\n\n return {\n name,\n email,\n [kWriteAccess]: writeAccess ?? false,\n [kIsPublisher]: isPublisher ?? false,\n }\n } else if (typeof person === 'string') {\n const NAME_PATTERN = /^([^(<]+)/\n const EMAIL_PATTERN = /<([^<>]+)>/\n const name = NAME_PATTERN.exec(person)?.[0].trim() || ''\n const email = EMAIL_PATTERN.exec(person)?.[1] || ''\n if (!name && !email) return undefined\n return {\n name: name || undefined,\n email: email || undefined,\n [kWriteAccess]: writeAccess ?? false,\n [kIsPublisher]: isPublisher ?? false,\n }\n }\n return\n}\n\n/**\n * Normalized contributors - always an array of {@link NormalizedContributorEntry}.\n */\nexport type NormalizedContributors = NormalizedContributorEntry[]\n\n/**\n * Represents a normalized contributor object. This is the type that is\n * used in the {@link NormalizedManifest} and {@link NormalizedManifestRegistry}\n * objects.\n */\nexport type NormalizedContributorEntry = {\n email?: string\n name?: string\n // in-memory we store those keys as symbols so that they\n // don't get written to user-managed package.json files\n [kWriteAccess]?: boolean\n [kIsPublisher]?: boolean\n // we also have a plain version that is used in the\n // transfer data format and lockfiles\n writeAccess?: boolean\n isPublisher?: boolean\n}\n\n/**\n * Type guard to check if a value is a normalized contributor entry.\n */\nexport const isNormalizedContributorEntry = (\n o: unknown,\n): o is NormalizedContributorEntry => {\n return (\n isObject(o) &&\n typeof o.name === 'string' &&\n !!o.name &&\n typeof o.email === 'string' &&\n !!o.email &&\n (isBoolean((o as NormalizedContributorEntry)[kWriteAccess]) ||\n isBoolean(o.writeAccess)) &&\n (isBoolean((o as NormalizedContributorEntry)[kIsPublisher]) ||\n isBoolean(o.isPublisher))\n )\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedContributors}.\n */\nexport const isNormalizedContributors = (\n o: unknown,\n): o is NormalizedContributors => {\n return (\n Array.isArray(o) &&\n o.length > 0 &&\n o.every(isNormalizedContributorEntry)\n )\n}\n\n/**\n * Normalize contributors and maintainers from various formats\n */\nexport const normalizeContributors = (\n contributors: unknown,\n maintainers?: unknown,\n): NormalizedContributorEntry[] | undefined => {\n if (!contributors && !maintainers) return\n\n const result: NormalizedContributorEntry[] = []\n\n // Parse regular contributors (if any)\n if (contributors) {\n const contributorsArray: unknown[] =\n Array.isArray(contributors) ? contributors : [contributors]\n\n const normalizedArray = contributorsArray.every(\n isNormalizedContributorEntry,\n )\n const noMaintainers =\n !maintainers ||\n (Array.isArray(maintainers) && maintainers.length === 0)\n\n // If all contributors are already normalized, and there are\n // no maintainers, return the contributors directly\n if (normalizedArray) {\n if (noMaintainers) {\n return contributorsArray.length > 0 ?\n contributorsArray\n : undefined\n } else {\n result.push(...contributorsArray)\n }\n }\n\n // Parse each contributor and filter out undefined values\n const parsedContributors = contributorsArray\n .map(person => parsePerson(person))\n .filter((c): c is NormalizedContributorEntry => c !== undefined)\n result.push(...parsedContributors)\n }\n\n // Parse maintainers with special flags\n if (maintainers) {\n const maintainersArray: unknown[] =\n Array.isArray(maintainers) ? maintainers : [maintainers]\n const parsedMaintainers = maintainersArray\n .map(person => parsePerson(person, true, true))\n .filter((c): c is NormalizedContributorEntry => c !== undefined)\n result.push(...parsedMaintainers)\n }\n\n return result.length > 0 ? result : undefined\n}\n\nexport type Person =\n | string\n | {\n name: string\n url?: string\n email?: string\n }\n\nexport type Repository =\n | string\n | {\n type: string\n url: string\n }\n\nexport type Bugs =\n | string\n | {\n url?: string\n email?: string\n }\n\nexport type Keywords = string[] | string\n\n/**\n * Normalized bugs entry - always an object with type and url/email\n */\nexport type NormalizedBugsEntry = {\n type?: 'email' | 'link'\n url?: string\n email?: string\n}\n\n/**\n * Normalized keywords - always an array of strings\n */\nexport type NormalizedKeywords = string[]\n\n/**\n * Normalized bugs - always an array of {@link NormalizedBugsEntry}\n */\nexport type NormalizedBugs = NormalizedBugsEntry[]\n\n/**\n * Helper function to normalize a single {@link Bugs} entry.\n */\nconst normalizeSingleBug = (bug: unknown): NormalizedBugsEntry[] => {\n const res: NormalizedBugsEntry[] = []\n\n if (typeof bug === 'string') {\n // Try to parse as URL first - if it succeeds, treat as link\n try {\n new URL(bug)\n res.push({ type: 'link', url: bug })\n } catch {\n // TODO: need a more robust email validation, likely\n // to be replaced with valibot / zod\n // If URL parsing fails, check if it's a valid email\n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/\n if (emailRegex.test(bug)) {\n res.push({ type: 'email', email: bug })\n } else {\n // Default to link for plain strings like 'example.com'\n res.push({ type: 'link', url: bug })\n }\n }\n } else if (isObject(bug)) {\n if (isNormalizedBugsEntry(bug)) {\n res.push(bug)\n }\n const obj = bug as { url?: string; email?: string }\n\n if (obj.url) {\n res.push({ type: 'link', url: obj.url })\n }\n if (obj.email) {\n res.push({ type: 'email', email: obj.email })\n }\n }\n\n return res.length > 0 ? res : []\n}\n\n/**\n * Normalize bugs information to a {@link NormalizedBugs} consistent format.\n */\nexport const normalizeBugs = (\n bugs: unknown,\n): NormalizedBugs | undefined => {\n if (!bugs) return\n\n const result: NormalizedBugsEntry[] = []\n\n // Handle array of bugs entries\n if (Array.isArray(bugs)) {\n for (const bug of bugs) {\n result.push(...normalizeSingleBug(bug))\n }\n } else {\n // Handle single bugs entry\n result.push(...normalizeSingleBug(bugs))\n }\n\n return result.length > 0 ? result : undefined\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedBugsEntry}.\n */\nexport const isNormalizedBugsEntry = (\n o: unknown,\n): o is NormalizedBugsEntry => {\n return (\n isObject(o) &&\n 'type' in o &&\n ((o.type === 'email' &&\n typeof o.email === 'string' &&\n !!o.email) ||\n (o.type === 'link' && typeof o.url === 'string' && !!o.url))\n )\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedBugs}.\n */\nexport const isNormalizedBugs = (o: unknown): o is NormalizedBugs => {\n return (\n Array.isArray(o) && o.length > 0 && o.every(isNormalizedBugsEntry)\n )\n}\n\n/**\n * Normalize keywords information to a {@link NormalizedKeywords} consistent format.\n */\nexport const normalizeKeywords = (\n keywords: unknown,\n): NormalizedKeywords | undefined => {\n if (!keywords) return\n\n let keywordArray: string[] = []\n\n if (typeof keywords === 'string') {\n // Handle comma-separated string values\n keywordArray = keywords\n .split(',')\n .map(keyword => keyword.trim())\n .filter(keyword => keyword.length > 0)\n } else if (Array.isArray(keywords)) {\n // If all keywords are already normalized, return them directly\n if (isNormalizedKeywords(keywords)) {\n return keywords as unknown as NormalizedKeywords\n }\n // Handle array of strings, filter out empty/invalid entries\n keywordArray = keywords\n .filter(\n (keyword): keyword is string => typeof keyword === 'string',\n )\n .map(keyword => keyword.trim())\n .filter(keyword => keyword.length > 0)\n } else {\n // Invalid format\n return\n }\n\n return keywordArray.length > 0 ? keywordArray : undefined\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedKeywords}.\n */\nexport const isNormalizedKeywords = (\n o: unknown,\n): o is NormalizedKeywords => {\n return (\n Array.isArray(o) &&\n o.length > 0 &&\n o.every(\n keyword =>\n typeof keyword === 'string' &&\n !!keyword &&\n !keyword.startsWith(' ') &&\n !keyword.endsWith(' '),\n )\n )\n}\n\nexport type Manifest = {\n /** The name of the package. optional because {} is a valid package.json */\n name?: string\n /** The version of the package. optional because {} is a valid package.json */\n version?: string\n /** production dependencies, name:specifier */\n dependencies?: Record<string, string>\n /** development dependencies, name:specifier */\n devDependencies?: Record<string, string>\n /** optional dependencies, name:specifier */\n optionalDependencies?: Record<string, string>\n /** peer dependencies, name:specifier */\n peerDependencies?: Record<string, string>\n /** peer dependencies marked as optional */\n peerDependenciesMeta?: Record<string, PeerDependenciesMetaValue>\n /** dependency ranges that are acceptable, but not forced */\n acceptDependencies?: Record<string, string>\n /** names of dependencies included in the package tarball */\n bundleDependencies?: string[]\n /** a message indicating that this is not to be used */\n deprecated?: string\n /** executable built and linked by this package */\n bin?: Record<string, string> | string\n /** run-script actions for this package */\n scripts?: Record<string, string>\n /** supported run-time platforms this package can run on */\n engines?: Record<string, string>\n /** supported operating systems this package can run on */\n os?: string[] | string\n /** supported CPU architectures this package can run on */\n cpu?: string[] | string\n /** URLs that can be visited to fund this project */\n funding?: Funding\n /** The homepage of the repository */\n homepage?: string\n /**\n * Only present in Manifests served by a registry. Contains information\n * about the artifact served for this package release.\n */\n dist?: Dist\n /** a short description of the package */\n description?: string\n /** search keywords */\n keywords?: Keywords\n /** where to go to file issues */\n bugs?: Bugs\n /** where the development happens */\n repository?: Repository\n /** the main module, if exports['.'] is not set */\n main?: string\n /** named subpath exports */\n exports?: Exports\n /** named #identifier imports */\n imports?: Imports\n /**\n * the HEAD of the git repo this was published from\n * only present in published packages\n */\n gitHead?: string\n /** whether the package is private */\n private?: boolean\n /** whether this is ESM or CommonJS by default */\n type?: 'commonjs' | 'module'\n /** npm puts this on published manifests */\n gypfile?: boolean\n /** the author of a package */\n author?: Person\n /** contributors to the package */\n contributors?: Person[]\n /** the license of the package */\n license?: string\n}\n\nexport type NormalizedFields = {\n bugs: NormalizedBugs | undefined\n author: NormalizedContributorEntry | undefined\n contributors: NormalizedContributors | undefined\n funding: NormalizedFunding | undefined\n keywords: NormalizedKeywords | undefined\n}\n\n/**\n * A {@link Manifest} object that contains normalized fields.\n */\nexport type NormalizedManifest = Override<Manifest, NormalizedFields>\n\n/**\n * A {@link ManifestRegistry} object that contains normalized fields.\n */\nexport type NormalizedManifestRegistry = Override<\n ManifestRegistry,\n NormalizedFields\n>\n\n/**\n * A specific type of {@link Manifest} that represents manifests that were\n * retrieved from a registry, these will always have `name`, `version`\n * and `dist` information along with an optional `maintainers` field.\n */\nexport type ManifestRegistry = Manifest &\n Required<Pick<Manifest, 'name' | 'version' | 'dist'>> & {\n maintainers?: unknown\n }\n\n/**\n * Maps the manifest type to the equivalent normalized manifest type.\n */\nexport type SomeNormalizedManifest<T> =\n T extends ManifestRegistry ? NormalizedManifestRegistry\n : NormalizedManifest\n\n/**\n * A document that represents available package versions in a given registry\n * along with extra information, such as `dist-tags` and `maintainers` info.\n * The `versions` field is key-value structure in which keys are the\n * available versions of a given package and values are\n * {@link ManifestRegistry} objects.\n */\nexport type Packument = {\n name: string\n 'dist-tags': Record<string, string>\n versions: Record<string, Manifest>\n modified?: string\n time?: Record<string, string>\n readme?: string\n contributors?: Person[]\n maintainers?: Person[]\n}\n\nexport type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag'\n\n/**\n * A representation of a given remote ref in a {@link RevDoc} object.\n */\nexport type RevDocEntry = Omit<Manifest, 'type'> &\n Required<Pick<Manifest, 'version'>> & {\n /** sha this references */\n sha: string\n /** ref as passed git locally */\n ref: string\n /** canonical full ref, like `refs/tags/blahblah` */\n rawRef: string\n /** what type of ref this is: 'branch', 'tag', etc. */\n type: RefType\n }\n\n/**\n * An object kind of resembling a packument, but about a git repo.\n */\nexport type RevDoc = Omit<Packument, 'versions'> & {\n /** all semver-looking tags go in this record */\n versions: Record<string, RevDocEntry>\n /** all named things that can be cloned down remotely */\n refs: Record<string, RevDocEntry>\n /** all named shas referenced above */\n shas: Record<string, string[]>\n}\n\n/**\n * A type guard to check if a value is a boolean.\n */\nexport const isBoolean = (value: unknown): value is boolean =>\n typeof value === 'boolean'\n\nexport const integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/\nexport const isIntegrity = (i: unknown): i is Integrity =>\n typeof i === 'string' && integrityRE.test(i)\n\nexport const asIntegrity = (i: unknown): Integrity => {\n if (!isIntegrity(i)) {\n throw error(\n 'invalid integrity',\n {\n found: i,\n wanted: integrityRE,\n },\n asIntegrity,\n )\n }\n return i\n}\n\nexport const assertIntegrity: (\n i: unknown,\n) => asserts i is Integrity = i => {\n asIntegrity(i)\n}\n\nexport const keyIDRE = /^SHA256:[a-zA-Z0-9/+]{43}$/\nexport const isKeyID = (k: unknown): k is KeyID =>\n typeof k === 'string' && keyIDRE.test(k)\n\nexport const asKeyID = (k: unknown): KeyID => {\n if (!isKeyID(k)) {\n throw error(\n 'invalid key ID',\n {\n found: k,\n wanted: keyIDRE,\n },\n asKeyID,\n )\n }\n return k\n}\n\nexport const assertKeyID: (k: unknown) => asserts k is KeyID = k => {\n asKeyID(k)\n}\n\n/**\n * Convert an unknown value to an error.\n */\nexport const asError = (\n er: unknown,\n fallbackMessage = 'Unknown error',\n): Error =>\n er instanceof Error ? er : new Error(String(er) || fallbackMessage)\n\n/**\n * Check if a value is an error.\n */\nexport const isError = (er: unknown): er is Error =>\n er instanceof Error\n\n/**\n * Check if an error has a cause property.\n */\nexport const isErrorWithCause = (\n er: unknown,\n): er is Error & { cause: unknown } => isError(er) && 'cause' in er\n\n/**\n * Check if an unknown value is a plain object.\n */\nexport const isObject = (v: unknown): v is Record<string, unknown> =>\n !!v &&\n typeof v === 'object' &&\n (v.constructor === Object ||\n (v.constructor as unknown) === undefined)\n\nexport const maybeRecordStringString = (\n o: unknown,\n): o is Record<string, string> | undefined =>\n o === undefined || isRecordStringString(o)\n\nexport const isRecordStringString = (\n o: unknown,\n): o is Record<string, string> =>\n isRecordStringT<string>(o, s => typeof s === 'string')\n\nexport const assertRecordStringString: (o: unknown) => void = (\n o: unknown,\n): asserts o is Record<string, string> =>\n assertRecordStringT<string>(\n o,\n s => typeof s === 'string',\n 'Record<string, string>',\n )\n\nexport const isRecordStringT = <T>(\n o: unknown,\n check: (o: unknown) => o is T,\n): o is Record<string, T> =>\n isObject(o) &&\n Object.entries(o).every(\n ([k, v]) => typeof k === 'string' && check(v),\n )\n\nexport const assertRecordStringT: <T>(\n o: unknown,\n check: (o: unknown) => o is T,\n wanted: string,\n) => asserts o is Record<string, T> = <T>(\n o: unknown,\n check: (o: unknown) => o is T,\n /** a type description, like 'Record<string, Record<string, string>>' */\n wanted: string,\n): asserts o is Record<string, T> => {\n if (!isRecordStringT(o, check)) {\n throw error('Invalid record', {\n found: o,\n wanted,\n })\n }\n}\n\nexport const isRecordStringManifest = (\n o: unknown,\n): o is Record<string, Manifest> =>\n isRecordStringT<Manifest>(o, v => isManifest(v))\n\nexport const maybePeerDependenciesMetaSet = (\n o: unknown,\n): o is Record<string, PeerDependenciesMetaValue> | undefined =>\n o === undefined ||\n isRecordStringT<PeerDependenciesMetaValue>(o, v =>\n isPeerDependenciesMetaValue(v),\n )\n\nexport const maybeBoolean = (o: unknown): o is boolean =>\n o === undefined || typeof o === 'boolean'\n\nexport const isPeerDependenciesMetaValue = (\n o: unknown,\n): o is PeerDependenciesMetaValue =>\n isObject(o) && maybeBoolean(o.optional)\n\nexport const maybeString = (a: unknown): a is string | undefined =>\n a === undefined || typeof a === 'string'\n\nexport const maybeDist = (a: unknown): a is Manifest['dist'] =>\n a === undefined || (isObject(a) && maybeString(a.tarball))\n\n/**\n * Is a given unknown value a valid {@link Manifest} object?\n * Returns `true` if so.\n */\nexport const isManifest = (m: unknown): m is Manifest =>\n isObject(m) &&\n !Array.isArray(m) &&\n maybeString(m.name) &&\n maybeString(m.version) &&\n maybeRecordStringString(m.dependencies) &&\n maybeRecordStringString(m.devDependencies) &&\n maybeRecordStringString(m.optionalDependencies) &&\n maybeRecordStringString(m.peerDependencies) &&\n maybeRecordStringString(m.acceptDependencies) &&\n maybePeerDependenciesMetaSet(m.peerDependenciesMeta) &&\n maybeDist(m.dist)\n\n/**\n * A specific {@link Manifest} that is retrieved uniquely from reading\n * registry packument and manifest endpoints, it has `dist`, `name` and\n * `version` fields defined.\n */\nexport const isManifestRegistry = (\n m: unknown,\n): m is ManifestRegistry =>\n isManifest(m) && !!m.dist && !!m.name && !!m.version\n\n/**\n * Given an unknown value, convert it to a {@link Manifest}.\n */\nexport const asManifest = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): Manifest => {\n if (!isManifest(m)) {\n throw error('invalid manifest', { found: m }, from ?? asManifest)\n }\n return m\n}\n\n/**\n * Given a {@link Manifest} returns a {@link NormalizedManifest} that\n * contains normalized author, bugs, funding, contributors, keywords and\n * version fields.\n */\nexport const normalizeManifest = <\n T extends Manifest | ManifestRegistry,\n>(\n manifest: T,\n): SomeNormalizedManifest<T> => {\n manifest = fixManifestVersion(manifest)\n\n const normalizedAuthor = parsePerson(manifest.author)\n const normalizedFunding = normalizeFunding(manifest.funding)\n const normalizedContributors = normalizeContributors(\n manifest.contributors,\n (manifest as ManifestRegistry).maintainers,\n )\n const normalizedBugs = normalizeBugs(manifest.bugs)\n const normalizedKeywords = normalizeKeywords(manifest.keywords)\n\n // holds the same object reference but renames the variable here\n // so that it's simpler to cast it to the normalized type\n const normalizedManifest = manifest as SomeNormalizedManifest<T>\n\n if (normalizedAuthor) {\n normalizedManifest.author = normalizedAuthor\n } else {\n delete normalizedManifest.author\n }\n\n if (normalizedFunding) {\n normalizedManifest.funding = normalizedFunding\n } else {\n delete normalizedManifest.funding\n }\n\n if (normalizedContributors) {\n normalizedManifest.contributors = normalizedContributors\n } else {\n delete normalizedManifest.contributors\n }\n\n if (normalizedBugs) {\n normalizedManifest.bugs = normalizedBugs\n } else {\n delete normalizedManifest.bugs\n }\n\n if (normalizedKeywords) {\n normalizedManifest.keywords = normalizedKeywords\n } else {\n delete normalizedManifest.keywords\n }\n\n // Remove maintainers field if it exists in the raw manifest\n // this can only happen if the manifest is of ManifestRegistry type\n if (\n 'maintainers' in normalizedManifest &&\n normalizedManifest.maintainers\n ) {\n delete normalizedManifest.maintainers\n return normalizedManifest\n }\n\n return normalizedManifest\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedManifest}.\n */\nexport const isNormalizedManifest = (\n o: unknown,\n): o is NormalizedManifest => {\n return (\n isManifest(o) &&\n // given that all these values are optional and potentially undefined\n // we only check their value content if they are present\n ('author' in o ? isNormalizedContributorEntry(o.author) : true) &&\n ('contributors' in o ?\n isNormalizedContributors(o.contributors)\n : true) &&\n ('funding' in o ? isNormalizedFunding(o.funding) : true) &&\n ('bugs' in o ? isNormalizedBugs(o.bugs) : true) &&\n ('keywords' in o ? isNormalizedKeywords(o.keywords) : true)\n )\n}\n\n/**\n * Given an unknown value, convert it to a {@link NormalizedManifest}.\n */\nexport const asNormalizedManifest = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): NormalizedManifest => {\n if (!isNormalizedManifest(m)) {\n throw error(\n 'invalid normalized manifest',\n { found: m },\n from ?? asNormalizedManifest,\n )\n }\n return m\n}\n\n/**\n * Given an unknown value, convert it to a {@link ManifestRegistry}.\n */\nexport const asManifestRegistry = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): ManifestRegistry => {\n if (!isManifestRegistry(m)) {\n throw error(\n 'invalid registry manifest',\n { found: m },\n from ?? asManifestRegistry,\n )\n }\n return m\n}\n\n/**\n * Type guard to check if a value is a {@link NormalizedManifestRegistry}.\n */\nexport const isNormalizedManifestRegistry = (\n o: unknown,\n): o is NormalizedManifestRegistry => {\n return isNormalizedManifest(o) && isManifestRegistry(o)\n}\n\n/**\n * Given an unknown value, convert it to a {@link NormalizedManifestRegistry}.\n */\nexport const asNormalizedManifestRegistry = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): NormalizedManifestRegistry => {\n if (!isNormalizedManifestRegistry(m)) {\n throw error(\n 'invalid normalized manifest registry',\n { found: m },\n from ?? asNormalizedManifestRegistry,\n )\n }\n return m\n}\n\n/**\n * Expands a normalized contributor entry by converting the\n * in-memory symbols to their plain values.\n */\nconst expandNormalizedContributorEntrySymbols = (\n c: NormalizedContributorEntry,\n): NormalizedContributorEntry => {\n return {\n ...c,\n writeAccess: c[kWriteAccess],\n isPublisher: c[kIsPublisher],\n }\n}\n\n/**\n * Walks a normalized manifest and expands any symbols found\n * in the `author` and `contributors` fields.\n */\nexport const expandNormalizedManifestSymbols = (\n m: NormalizedManifest,\n): NormalizedManifest => {\n const res = { ...m }\n\n if (isNormalizedContributorEntry(m.author)) {\n res.author = expandNormalizedContributorEntrySymbols(m.author)\n }\n\n if (isNormalizedContributors(m.contributors)) {\n res.contributors = m.contributors.map(\n expandNormalizedContributorEntrySymbols,\n )\n }\n\n return res\n}\n\nexport const assertManifest: (\n m: unknown,\n) => asserts m is Manifest = m => {\n asManifest(m, assertManifest)\n}\nexport const assertManifestRegistry: (\n m: unknown,\n) => asserts m is ManifestRegistry = m => {\n asManifestRegistry(m, assertManifestRegistry)\n}\n\nexport const isPackument = (p: unknown): p is Packument => {\n if (!isObject(p) || typeof p.name !== 'string') return false\n const { versions, 'dist-tags': distTags, time } = p\n return (\n isRecordStringString(distTags) &&\n isRecordStringManifest(versions) &&\n maybeRecordStringString(time) &&\n Object.values(distTags).every(v => versions[v]?.name == p.name)\n )\n}\n\nexport const asPackument = (\n p: unknown,\n from?: (...a: unknown[]) => any,\n): Packument => {\n if (!isPackument(p)) {\n throw error(\n 'invalid packument',\n { found: p },\n from ?? asPackument,\n )\n }\n return p\n}\n\nexport const assertPackument: (\n m: unknown,\n) => asserts m is Packument = m => {\n asPackument(m)\n}\n\n/**\n * Name of the package.json keys used to define different types of dependencies.\n */\nexport type DependencyTypeLong =\n | 'dependencies'\n | 'devDependencies'\n | 'optionalDependencies'\n | 'peerDependencies'\n\n/**\n * Unique keys that define different types of dependencies relationship.\n */\nexport type DependencyTypeShort =\n | 'dev'\n | 'optional'\n | 'peer'\n | 'peerOptional'\n | 'prod'\n\n/**\n * Unique keys that indicate how a new or updated dependency should be saved\n * back to a manifest.\n *\n * `'implicit'` is used to indicate that a dependency should be saved as\n * whatever type it already exists as. If the dependency does not exist,\n * then `'implicit'` is equivalent to `'prod'`, as that is the default\n * save type.\n */\nexport type DependencySaveType = DependencyTypeShort | 'implicit'\n\n/**\n * A set of the possible long dependency type names,\n * as used in `package.json` files.\n */\nexport const longDependencyTypes = new Set<DependencyTypeLong>([\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n])\n\n/**\n * A set of the short type keys used to represent dependency relationships.\n */\nexport const shortDependencyTypes = new Set<DependencyTypeShort>([\n 'prod',\n 'dev',\n 'peer',\n 'optional',\n 'peerOptional',\n])\n\n/**\n * Maps between long form names usually used in `package.json` files\n * to a corresponding short form name, used in lockfiles.\n */\nexport const dependencyTypes = new Map<\n DependencyTypeLong,\n DependencyTypeShort\n>([\n ['dependencies', 'prod'],\n ['devDependencies', 'dev'],\n ['peerDependencies', 'peer'],\n ['optionalDependencies', 'optional'],\n])\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/types",
|
|
3
3
|
"description": "definitions for some of vlt's core types",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-20",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
22
|
+
"@vltpkg/error-cause": "0.0.0-20",
|
|
23
|
+
"@vltpkg/semver": "0.0.0-20"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@eslint/js": "^9.
|
|
26
|
-
"@types/
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"prettier": "^3.4.2",
|
|
26
|
+
"@eslint/js": "^9.28.0",
|
|
27
|
+
"@types/node": "^22.15.29",
|
|
28
|
+
"eslint": "^9.28.0",
|
|
29
|
+
"prettier": "^3.6.0",
|
|
30
30
|
"tap": "^21.1.0",
|
|
31
31
|
"tshy": "^3.0.2",
|
|
32
|
-
"typedoc": "0.27.
|
|
32
|
+
"typedoc": "~0.27.9",
|
|
33
33
|
"typescript": "5.7.3",
|
|
34
|
-
"typescript-eslint": "^8.
|
|
34
|
+
"typescript-eslint": "^8.33.1"
|
|
35
35
|
},
|
|
36
36
|
"license": "BSD-2-Clause-Patent",
|
|
37
37
|
"engines": {
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"snap": "tap",
|
|
64
64
|
"test": "tap",
|
|
65
65
|
"posttest": "tsc --noEmit",
|
|
66
|
+
"tshy": "tshy",
|
|
66
67
|
"typecheck": "tsc --noEmit"
|
|
67
68
|
}
|
|
68
69
|
}
|