@vltpkg/types 0.0.0-18 → 0.0.0-19

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.
@@ -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;
@@ -37,34 +47,69 @@ export type FundingEntry = string | {
37
47
  [key: string]: JSONField;
38
48
  };
39
49
  export type Funding = FundingEntry | FundingEntry[];
40
- /** Normalized funding entry - always an object with url and optional additional properties */
50
+ /**
51
+ * An object with url and optional additional properties
52
+ */
41
53
  export type NormalizedFundingEntry = {
42
54
  url: string;
43
55
  type?: string;
44
56
  [key: string]: JSONField;
45
57
  };
46
- /** Normalized funding - always an array of objects */
58
+ /**
59
+ * Normalized funding information, an array of {@link NormalizedFundingEntry}.
60
+ */
47
61
  export type NormalizedFunding = NormalizedFundingEntry[];
48
- /** Normalize funding information to a consistent format. */
62
+ /**
63
+ * Normalize funding information to a consistent format.
64
+ */
49
65
  export declare const normalizeFunding: (funding: unknown) => NormalizedFunding | undefined;
50
66
  /**
51
- * Normalize the version field in a manifest.
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.
52
82
  */
53
- export declare const normalizeVersion: (manifest: Manifest | ManifestRegistry) => Manifest | ManifestRegistry;
54
- export declare const parsePerson: (author: unknown, writeAccess?: boolean, isPublisher?: boolean) => NormalizedContributor | undefined;
83
+ export declare const parsePerson: (person: unknown, writeAccess?: boolean, isPublisher?: boolean) => NormalizedContributorEntry | undefined;
55
84
  /**
56
- * Represents a normalized contributor object.
85
+ * Normalized contributors - always an array of {@link NormalizedContributorEntry}.
57
86
  */
58
- export type NormalizedContributor = {
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 = {
59
94
  email?: string;
60
95
  name?: string;
96
+ [kWriteAccess]?: boolean;
97
+ [kIsPublisher]?: boolean;
61
98
  writeAccess?: boolean;
62
99
  isPublisher?: boolean;
63
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;
64
109
  /**
65
110
  * Normalize contributors and maintainers from various formats
66
111
  */
67
- export declare const normalizeContributors: (contributors: unknown, maintainers?: unknown) => NormalizedContributor[] | undefined;
112
+ export declare const normalizeContributors: (contributors: unknown, maintainers?: unknown) => NormalizedContributorEntry[] | undefined;
68
113
  export type Person = string | {
69
114
  name: string;
70
115
  url?: string;
@@ -92,17 +137,29 @@ export type NormalizedBugsEntry = {
92
137
  */
93
138
  export type NormalizedKeywords = string[];
94
139
  /**
95
- * Normalized bugs - always an array of objects
140
+ * Normalized bugs - always an array of {@link NormalizedBugsEntry}
96
141
  */
97
142
  export type NormalizedBugs = NormalizedBugsEntry[];
98
143
  /**
99
144
  * Normalize bugs information to a {@link NormalizedBugs} consistent format.
100
145
  */
101
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;
102
155
  /**
103
156
  * Normalize keywords information to a {@link NormalizedKeywords} consistent format.
104
157
  */
105
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;
106
163
  export type Manifest = {
107
164
  /** The name of the package. optional because {} is a valid package.json */
108
165
  name?: string;
@@ -171,13 +228,44 @@ export type Manifest = {
171
228
  /** the author of a package */
172
229
  author?: Person;
173
230
  /** contributors to the package */
174
- contributors?: NormalizedContributor[];
231
+ contributors?: Person[];
175
232
  /** the license of the package */
176
233
  license?: string;
177
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
+ */
178
255
  export type ManifestRegistry = Manifest & Required<Pick<Manifest, 'name' | 'version' | 'dist'>> & {
179
256
  maintainers?: unknown;
180
257
  };
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
+ */
181
269
  export type Packument = {
182
270
  name: string;
183
271
  'dist-tags': Record<string, string>;
@@ -213,6 +301,10 @@ export type RevDoc = Omit<Packument, 'versions'> & {
213
301
  /** all named shas referenced above */
214
302
  shas: Record<string, string[]>;
215
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;
216
308
  export declare const integrityRE: RegExp;
217
309
  export declare const isIntegrity: (i: unknown) => i is Integrity;
218
310
  export declare const asIntegrity: (i: unknown) => Integrity;
@@ -250,14 +342,52 @@ export declare const maybeBoolean: (o: unknown) => o is boolean;
250
342
  export declare const isPeerDependenciesMetaValue: (o: unknown) => o is PeerDependenciesMetaValue;
251
343
  export declare const maybeString: (a: unknown) => a is string | undefined;
252
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
+ */
253
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
+ */
254
355
  export declare const isManifestRegistry: (m: unknown) => m is ManifestRegistry;
356
+ /**
357
+ * Given an unknown value, convert it to a {@link Manifest}.
358
+ */
255
359
  export declare const asManifest: (m: unknown, from?: (...a: unknown[]) => any) => Manifest;
256
360
  /**
257
- * Returns a {@link Manifest} with normalized data.
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}.
258
376
  */
259
- export declare const normalizeManifest: (manifest: Manifest | ManifestRegistry) => Manifest;
260
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;
261
391
  export declare const assertManifest: (m: unknown) => asserts m is Manifest;
262
392
  export declare const assertManifestRegistry: (m: unknown) => asserts m is ManifestRegistry;
263
393
  export declare const isPackument: (p: unknown) => p is Packument;
@@ -295,4 +425,5 @@ export declare const shortDependencyTypes: Set<DependencyTypeShort>;
295
425
  * to a corresponding short form name, used in lockfiles.
296
426
  */
297
427
  export declare const dependencyTypes: Map<DependencyTypeLong, DependencyTypeShort>;
428
+ export {};
298
429
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,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,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE;QACX,KAAK,EAAE,KAAK,CAAA;QACZ,GAAG,EAAE,MAAM,CAAA;KACZ,EAAE,CAAA;CACJ,CAAA;AAED,uDAAuD;AACvD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAID,MAAM,MAAM,sBAAsB,GAAG;IACnC,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,EAAE,GAClB,sBAAsB,GACtB,MAAM,GACN,IAAI,CAAA;AAER,MAAM,MAAM,eAAe,GAAG;KAC3B,IAAI,IAAI,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC,EAAE,gBAAgB;CACjD,CAAA;AAED,MAAM,MAAM,OAAO,GACf,OAAO,CAAC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CAAA;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,cAAc,GACd,iBAAiB,GACjB,sBAAsB,GACtB,kBAAkB,CAAA;AAEtB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,KAAK,GACL,UAAU,GACV,MAAM,GACN,cAAc,GACd,MAAM,CAAA;AAEV;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,UAAU,CAAA;AAEjE;;;GAGG;AACH,eAAO,MAAM,mBAAmB,yBAK9B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,0BAM/B,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,8CAQ1B,CAAA"}
package/dist/esm/index.js CHANGED
@@ -1,64 +1,92 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
2
  import { Version } from '@vltpkg/semver';
3
- /** Normalize funding information to a consistent format. */
4
- export const normalizeFunding = (funding) => {
5
- if (funding === undefined || funding === null) {
6
- return undefined;
7
- }
8
- const normalizeItem = (item) => {
9
- const getTypeFromUrl = (url) => {
10
- try {
11
- const { hostname } = new URL(url);
12
- const domain = hostname.startsWith('www.') ? hostname.slice(4) : hostname;
13
- if (domain === 'github.com')
14
- return 'github';
15
- if (domain === 'patreon.com')
16
- return 'patreon';
17
- if (domain === 'opencollective.com')
18
- return 'opencollective';
19
- return 'individual';
20
- }
21
- catch {
22
- return 'invalid';
23
- }
24
- };
25
- const validateType = (url, type) => {
26
- const urlType = getTypeFromUrl(url);
27
- if (!type ||
28
- ['github', 'patreon', 'opencollective'].includes(urlType))
29
- return urlType;
30
- if (urlType === 'invalid')
31
- return undefined;
32
- return type;
33
- };
34
- if (typeof item === 'string') {
35
- return { url: item, type: getTypeFromUrl(item) };
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';
36
18
  }
37
- if (isObject(item) &&
38
- 'url' in item &&
39
- typeof item.url === 'string') {
40
- const obj = item;
41
- const url = obj.url;
42
- const validatedType = validateType(url, obj.type);
43
- const result = { ...obj, url };
44
- if (validatedType) {
45
- result.type = validatedType;
46
- }
47
- else {
48
- delete result.type;
49
- }
50
- return result;
19
+ catch {
20
+ return 'invalid';
51
21
  }
52
- return { url: '', type: 'individual' };
53
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;
54
62
  const fundingArray = Array.isArray(funding) ? funding : [funding];
55
- const sources = fundingArray.map(normalizeItem);
56
- return sources;
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));
57
77
  };
58
78
  /**
59
- * Normalize the version field in a manifest.
79
+ * Type guard to check if a value is a {@link NormalizedFunding}.
60
80
  */
61
- export const normalizeVersion = (manifest) => {
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) => {
62
90
  if (!Object.hasOwn(manifest, 'version')) {
63
91
  return manifest;
64
92
  }
@@ -71,49 +99,96 @@ export const normalizeVersion = (manifest) => {
71
99
  manifest.version = version.toString();
72
100
  return manifest;
73
101
  };
74
- /* Parse a string or object into a normalized contributor */
75
- export const parsePerson = (author, writeAccess, isPublisher) => {
76
- if (typeof author === 'string') {
77
- const NAME_PATTERN = /^([^(<]+)/;
78
- const EMAIL_PATTERN = /<([^<>]+)>/;
79
- const name = NAME_PATTERN.exec(author)?.[0].trim() || '';
80
- const email = EMAIL_PATTERN.exec(author)?.[1] || '';
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;
81
119
  if (!name && !email)
82
120
  return undefined;
83
121
  return {
84
- name: name || undefined,
85
- email: email || undefined,
86
- writeAccess: writeAccess ?? false,
87
- isPublisher: isPublisher ?? false,
122
+ name,
123
+ email,
124
+ [kWriteAccess]: writeAccess ?? false,
125
+ [kIsPublisher]: isPublisher ?? false,
88
126
  };
89
127
  }
90
- else if (isObject(author)) {
91
- const name = typeof author.name === 'string' ? author.name : undefined;
92
- const email = typeof author.email === 'string' ? author.email
93
- : typeof author.mail === 'string' ? author.mail
94
- : undefined;
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] || '';
95
133
  if (!name && !email)
96
134
  return undefined;
97
135
  return {
98
- name,
99
- email,
100
- writeAccess: writeAccess ?? false,
101
- isPublisher: isPublisher ?? false,
136
+ name: name || undefined,
137
+ email: email || undefined,
138
+ [kWriteAccess]: writeAccess ?? false,
139
+ [kIsPublisher]: isPublisher ?? false,
102
140
  };
103
141
  }
104
- return undefined;
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));
105
165
  };
106
166
  /**
107
167
  * Normalize contributors and maintainers from various formats
108
168
  */
109
169
  export const normalizeContributors = (contributors, maintainers) => {
110
- if (!contributors && !maintainers) {
111
- return undefined;
112
- }
170
+ if (!contributors && !maintainers)
171
+ return;
113
172
  const result = [];
114
173
  // Parse regular contributors (if any)
115
174
  if (contributors) {
116
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
117
192
  const parsedContributors = contributorsArray
118
193
  .map(person => parsePerson(person))
119
194
  .filter((c) => c !== undefined);
@@ -127,54 +202,89 @@ export const normalizeContributors = (contributors, maintainers) => {
127
202
  .filter((c) => c !== undefined);
128
203
  result.push(...parsedMaintainers);
129
204
  }
130
- return result;
205
+ return result.length > 0 ? result : undefined;
131
206
  };
132
207
  /**
133
- * Normalize bugs information to a {@link NormalizedBugs} consistent format.
208
+ * Helper function to normalize a single {@link Bugs} entry.
134
209
  */
135
- export const normalizeBugs = (bugs) => {
136
- if (bugs === undefined || bugs === null) {
137
- return undefined;
138
- }
139
- if (typeof bugs === 'string') {
210
+ const normalizeSingleBug = (bug) => {
211
+ const res = [];
212
+ if (typeof bug === 'string') {
140
213
  // Try to parse as URL first - if it succeeds, treat as link
141
214
  try {
142
- new URL(bugs);
143
- return [{ type: 'link', url: bugs }];
215
+ new URL(bug);
216
+ res.push({ type: 'link', url: bug });
144
217
  }
145
218
  catch {
146
219
  // TODO: need a more robust email validation, likely
147
220
  // to be replaced with valibot / zod
148
221
  // If URL parsing fails, check if it's a valid email
149
222
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
150
- if (emailRegex.test(bugs)) {
151
- return [{ type: 'email', email: bugs }];
223
+ if (emailRegex.test(bug)) {
224
+ res.push({ type: 'email', email: bug });
152
225
  }
153
226
  else {
154
227
  // Default to link for plain strings like 'example.com'
155
- return [{ type: 'link', url: bugs }];
228
+ res.push({ type: 'link', url: bug });
156
229
  }
157
230
  }
158
231
  }
159
- if (isObject(bugs)) {
160
- const obj = bugs;
161
- const result = [];
232
+ else if (isObject(bug)) {
233
+ if (isNormalizedBugsEntry(bug)) {
234
+ res.push(bug);
235
+ }
236
+ const obj = bug;
162
237
  if (obj.url) {
163
- result.push({ type: 'link', url: obj.url });
238
+ res.push({ type: 'link', url: obj.url });
164
239
  }
165
240
  if (obj.email) {
166
- result.push({ type: 'email', email: obj.email });
241
+ res.push({ type: 'email', email: obj.email });
167
242
  }
168
- return result.length > 0 ? result : undefined;
169
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));
170
281
  };
171
282
  /**
172
283
  * Normalize keywords information to a {@link NormalizedKeywords} consistent format.
173
284
  */
174
285
  export const normalizeKeywords = (keywords) => {
175
- if (keywords === undefined || keywords === null) {
176
- return undefined;
177
- }
286
+ if (!keywords)
287
+ return;
178
288
  let keywordArray = [];
179
289
  if (typeof keywords === 'string') {
180
290
  // Handle comma-separated string values
@@ -184,6 +294,10 @@ export const normalizeKeywords = (keywords) => {
184
294
  .filter(keyword => keyword.length > 0);
185
295
  }
186
296
  else if (Array.isArray(keywords)) {
297
+ // If all keywords are already normalized, return them directly
298
+ if (isNormalizedKeywords(keywords)) {
299
+ return keywords;
300
+ }
187
301
  // Handle array of strings, filter out empty/invalid entries
188
302
  keywordArray = keywords
189
303
  .filter((keyword) => typeof keyword === 'string')
@@ -191,12 +305,26 @@ export const normalizeKeywords = (keywords) => {
191
305
  .filter(keyword => keyword.length > 0);
192
306
  }
193
307
  else {
194
- // Invalid format, return undefined
195
- return undefined;
308
+ // Invalid format
309
+ return;
196
310
  }
197
- // Return undefined if no valid keywords remain
198
311
  return keywordArray.length > 0 ? keywordArray : undefined;
199
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';
200
328
  export const integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/;
201
329
  export const isIntegrity = (i) => typeof i === 'string' && integrityRE.test(i);
202
330
  export const asIntegrity = (i) => {
@@ -266,6 +394,10 @@ export const maybeBoolean = (o) => o === undefined || typeof o === 'boolean';
266
394
  export const isPeerDependenciesMetaValue = (o) => isObject(o) && maybeBoolean(o.optional);
267
395
  export const maybeString = (a) => a === undefined || typeof a === 'string';
268
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
+ */
269
401
  export const isManifest = (m) => isObject(m) &&
270
402
  !Array.isArray(m) &&
271
403
  maybeString(m.name) &&
@@ -277,53 +409,147 @@ export const isManifest = (m) => isObject(m) &&
277
409
  maybeRecordStringString(m.acceptDependencies) &&
278
410
  maybePeerDependenciesMetaSet(m.peerDependenciesMeta) &&
279
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
+ */
280
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
+ */
281
421
  export const asManifest = (m, from) => {
282
422
  if (!isManifest(m)) {
283
423
  throw error('invalid manifest', { found: m }, from ?? asManifest);
284
424
  }
285
- return normalizeManifest(m);
425
+ return m;
286
426
  };
287
427
  /**
288
- * Returns a {@link Manifest} with normalized data.
428
+ * Given a {@link Manifest} returns a {@link NormalizedManifest} that
429
+ * contains normalized author, bugs, funding, contributors, keywords and
430
+ * version fields.
289
431
  */
290
432
  export const normalizeManifest = (manifest) => {
291
- manifest = normalizeVersion(manifest);
292
- // checks for properties with specific normalization helper methods,
293
- // if there's nothing to normalize then we just return the original manifest
294
- if (manifest.funding === undefined &&
295
- manifest.contributors === undefined &&
296
- manifest.bugs === undefined &&
297
- manifest.keywords === undefined &&
298
- !('maintainers' in manifest)) {
299
- return manifest;
300
- }
433
+ manifest = fixManifestVersion(manifest);
434
+ const normalizedAuthor = parsePerson(manifest.author);
301
435
  const normalizedFunding = normalizeFunding(manifest.funding);
302
436
  const normalizedContributors = normalizeContributors(manifest.contributors, manifest.maintainers);
303
437
  const normalizedBugs = normalizeBugs(manifest.bugs);
304
438
  const normalizedKeywords = normalizeKeywords(manifest.keywords);
305
- // Create result with normalized data
306
- const result = {
307
- ...manifest,
308
- funding: normalizedFunding,
309
- contributors: normalizedContributors,
310
- bugs: normalizedBugs,
311
- keywords: normalizedKeywords,
312
- };
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
+ }
313
472
  // Remove maintainers field if it exists in the raw manifest
314
- if ('maintainers' in manifest && manifest.maintainers) {
315
- // Return a new manifest without the maintainers field
316
- const resultWithoutMaintainers = structuredClone(result);
317
- delete resultWithoutMaintainers.maintainers;
318
- return resultWithoutMaintainers;
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;
319
478
  }
320
- return result;
479
+ return normalizedManifest;
321
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
+ */
322
508
  export const asManifestRegistry = (m, from) => {
323
509
  if (!isManifestRegistry(m)) {
324
510
  throw error('invalid registry manifest', { found: m }, from ?? asManifestRegistry);
325
511
  }
326
- return normalizeManifest(m);
512
+ return m;
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;
327
553
  };
328
554
  export const assertManifest = m => {
329
555
  asManifest(m, assertManifest);
@@ -1 +1 @@
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;AAwExC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAgB,EACe,EAAE;IACjC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,aAAa,GAAG,CAAC,IAAa,EAA0B,EAAE;QAC9D,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;YAC7C,IAAI,CAAC;gBACH,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;gBACjC,MAAM,MAAM,GACV,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;gBAC5D,IAAI,MAAM,KAAK,YAAY;oBAAE,OAAO,QAAQ,CAAA;gBAC5C,IAAI,MAAM,KAAK,aAAa;oBAAE,OAAO,SAAS,CAAA;gBAC9C,IAAI,MAAM,KAAK,oBAAoB;oBAAE,OAAO,gBAAgB,CAAA;gBAC5D,OAAO,YAAY,CAAA;YACrB,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,SAAS,CAAA;YAClB,CAAC;QACH,CAAC,CAAA;QAED,MAAM,YAAY,GAAG,CACnB,GAAW,EACX,IAAa,EACO,EAAE;YACtB,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAA;Y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AAuB,CAAC,IAAI,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,CAChE,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,CAAU,EACV,IAA+B,EACpB,EAAE;IACb,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CACT,mBAAmB,EACnB,EAAE,KAAK,EAAE,CAAC,EAAE,EACZ,IAAI,IAAI,WAAW,CACpB,CAAA;IACH,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAEE,CAAC,CAAC,EAAE;IAChC,WAAW,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAA;AAgCD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,GAAG,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/** 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/** Normalized funding entry - always an object with url and optional additional properties */\nexport type NormalizedFundingEntry = {\n url: string\n type?: string\n [key: string]: JSONField\n}\n/** Normalized funding - always an array of objects */\nexport type NormalizedFunding = NormalizedFundingEntry[]\n\n/** Normalize funding information to a consistent format. */\nexport const normalizeFunding = (\n funding: unknown,\n): NormalizedFunding | undefined => {\n if (funding === undefined || funding === null) {\n return undefined\n }\n\n const normalizeItem = (item: unknown): 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 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 const fundingArray = Array.isArray(funding) ? funding : [funding]\n const sources = fundingArray.map(normalizeItem)\n return sources\n}\n\n/**\n * Normalize the version field in a manifest.\n */\nexport const normalizeVersion = (\n manifest: Manifest | ManifestRegistry,\n): Manifest | ManifestRegistry => {\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\n/* Parse a string or object into a normalized contributor */\nexport const parsePerson = (\n author: unknown,\n writeAccess?: boolean,\n isPublisher?: boolean,\n): NormalizedContributor | undefined => {\n if (typeof author === 'string') {\n const NAME_PATTERN = /^([^(<]+)/\n const EMAIL_PATTERN = /<([^<>]+)>/\n const name = NAME_PATTERN.exec(author)?.[0].trim() || ''\n const email = EMAIL_PATTERN.exec(author)?.[1] || ''\n if (!name && !email) return undefined\n return {\n name: name || undefined,\n email: email || undefined,\n writeAccess: writeAccess ?? false,\n isPublisher: isPublisher ?? false,\n }\n } else if (isObject(author)) {\n const name =\n typeof author.name === 'string' ? author.name : undefined\n const email =\n typeof author.email === 'string' ? author.email\n : typeof author.mail === 'string' ? author.mail\n : undefined\n\n if (!name && !email) return undefined\n\n return {\n name,\n email,\n writeAccess: writeAccess ?? false,\n isPublisher: isPublisher ?? false,\n }\n }\n return undefined\n}\n\n/**\n * Represents a normalized contributor object.\n */\nexport type NormalizedContributor = {\n email?: string\n name?: string\n writeAccess?: boolean\n isPublisher?: boolean\n}\n\n/**\n * Normalize contributors and maintainers from various formats\n */\nexport const normalizeContributors = (\n contributors: unknown,\n maintainers?: unknown,\n): NormalizedContributor[] | undefined => {\n if (!contributors && !maintainers) {\n return undefined\n }\n\n const result: NormalizedContributor[] = []\n\n // Parse regular contributors (if any)\n if (contributors) {\n const contributorsArray: unknown[] =\n Array.isArray(contributors) ? contributors : [contributors]\n const parsedContributors = contributorsArray\n .map(person => parsePerson(person))\n .filter((c): c is NormalizedContributor => 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 NormalizedContributor => c !== undefined)\n result.push(...parsedMaintainers)\n }\n\n return result\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 objects\n */\nexport type NormalizedBugs = NormalizedBugsEntry[]\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 === undefined || bugs === null) {\n return undefined\n }\n\n if (typeof bugs === 'string') {\n // Try to parse as URL first - if it succeeds, treat as link\n try {\n new URL(bugs)\n return [{ type: 'link', url: bugs }]\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(bugs)) {\n return [{ type: 'email', email: bugs }]\n } else {\n // Default to link for plain strings like 'example.com'\n return [{ type: 'link', url: bugs }]\n }\n }\n }\n\n if (isObject(bugs)) {\n const obj = bugs as { url?: string; email?: string }\n const result: NormalizedBugsEntry[] = []\n\n if (obj.url) {\n result.push({ type: 'link', url: obj.url })\n }\n if (obj.email) {\n result.push({ type: 'email', email: obj.email })\n }\n\n return result.length > 0 ? result : undefined\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 === undefined || keywords === null) {\n return undefined\n }\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 // 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, return undefined\n return undefined\n }\n\n // Return undefined if no valid keywords remain\n return keywordArray.length > 0 ? keywordArray : undefined\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?: NormalizedContributor[]\n /** the license of the package */\n license?: string\n}\n\nexport type ManifestRegistry = Manifest &\n Required<Pick<Manifest, 'name' | 'version' | 'dist'>> & {\n maintainers?: unknown\n }\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\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\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\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 normalizeManifest(m)\n}\n\n/**\n * Returns a {@link Manifest} with normalized data.\n */\nexport const normalizeManifest = (\n manifest: Manifest | ManifestRegistry,\n): Manifest => {\n manifest = normalizeVersion(manifest)\n\n // checks for properties with specific normalization helper methods,\n // if there's nothing to normalize then we just return the original manifest\n if (\n manifest.funding === undefined &&\n manifest.contributors === undefined &&\n manifest.bugs === undefined &&\n manifest.keywords === undefined &&\n !('maintainers' in manifest)\n ) {\n return manifest\n }\n\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 // Create result with normalized data\n const result: Manifest = {\n ...manifest,\n funding: normalizedFunding as Funding,\n contributors: normalizedContributors,\n bugs: normalizedBugs as Bugs,\n keywords: normalizedKeywords as Keywords,\n }\n\n // Remove maintainers field if it exists in the raw manifest\n if ('maintainers' in manifest && manifest.maintainers) {\n // Return a new manifest without the maintainers field\n const resultWithoutMaintainers: Record<string, unknown> =\n structuredClone(result)\n delete resultWithoutMaintainers.maintainers\n return resultWithoutMaintainers as Manifest\n }\n\n return result\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 normalizeManifest(m) as ManifestRegistry\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"]}
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,CA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AE;IAChC,WAAW,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAA;AAgCD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,GAAG,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-18",
4
+ "version": "0.0.0-19",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -19,8 +19,8 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@vltpkg/error-cause": "0.0.0-18",
23
- "@vltpkg/semver": "0.0.0-18"
22
+ "@vltpkg/error-cause": "0.0.0-19",
23
+ "@vltpkg/semver": "0.0.0-19"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/js": "^9.28.0",