@vltpkg/types 0.0.0-15 → 0.0.0-17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +36 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +143 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.d.ts
CHANGED
|
@@ -33,8 +33,34 @@ export type Exports = Exclude<ConditionalValue, null> | ExportsSubpaths;
|
|
|
33
33
|
export type Imports = Record<`#${string}`, ConditionalValue>;
|
|
34
34
|
export type FundingEntry = string | {
|
|
35
35
|
url: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
[key: string]: JSONField;
|
|
36
38
|
};
|
|
37
39
|
export type Funding = FundingEntry | FundingEntry[];
|
|
40
|
+
/** Normalized funding entry - always an object with url and optional additional properties */
|
|
41
|
+
export type NormalizedFundingEntry = {
|
|
42
|
+
url: string;
|
|
43
|
+
type?: string;
|
|
44
|
+
[key: string]: JSONField;
|
|
45
|
+
};
|
|
46
|
+
/** Normalized funding - always an array of objects */
|
|
47
|
+
export type NormalizedFunding = NormalizedFundingEntry[];
|
|
48
|
+
/** Normalize funding information to a consistent format. */
|
|
49
|
+
export declare const normalizeFunding: (funding: unknown) => NormalizedFunding | undefined;
|
|
50
|
+
export declare const parsePerson: (author: unknown, writeAccess?: boolean, isPublisher?: boolean) => NormalizedContributor | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Represents a normalized contributor object.
|
|
53
|
+
*/
|
|
54
|
+
export type NormalizedContributor = {
|
|
55
|
+
email?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
writeAccess?: boolean;
|
|
58
|
+
isPublisher?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Normalize contributors and maintainers from various formats
|
|
62
|
+
*/
|
|
63
|
+
export declare const normalizeContributors: (contributors: unknown, maintainers?: unknown) => NormalizedContributor[] | undefined;
|
|
38
64
|
export type Person = string | {
|
|
39
65
|
name: string;
|
|
40
66
|
url?: string;
|
|
@@ -116,11 +142,13 @@ export type Manifest = {
|
|
|
116
142
|
/** the author of a package */
|
|
117
143
|
author?: Person;
|
|
118
144
|
/** contributors to the package */
|
|
119
|
-
contributors?:
|
|
145
|
+
contributors?: NormalizedContributor[];
|
|
120
146
|
/** the license of the package */
|
|
121
147
|
license?: string;
|
|
122
148
|
};
|
|
123
|
-
export type ManifestRegistry = Manifest & Required<Pick<Manifest, 'name' | 'version' | 'dist'
|
|
149
|
+
export type ManifestRegistry = Manifest & Required<Pick<Manifest, 'name' | 'version' | 'dist'>> & {
|
|
150
|
+
maintainers?: unknown;
|
|
151
|
+
};
|
|
124
152
|
export type Packument = {
|
|
125
153
|
name: string;
|
|
126
154
|
'dist-tags': Record<string, string>;
|
|
@@ -128,6 +156,8 @@ export type Packument = {
|
|
|
128
156
|
modified?: string;
|
|
129
157
|
time?: Record<string, string>;
|
|
130
158
|
readme?: string;
|
|
159
|
+
contributors?: Person[];
|
|
160
|
+
maintainers?: Person[];
|
|
131
161
|
};
|
|
132
162
|
export type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag';
|
|
133
163
|
/**
|
|
@@ -194,6 +224,10 @@ export declare const maybeDist: (a: unknown) => a is Manifest["dist"];
|
|
|
194
224
|
export declare const isManifest: (m: unknown) => m is Manifest;
|
|
195
225
|
export declare const isManifestRegistry: (m: unknown) => m is ManifestRegistry;
|
|
196
226
|
export declare const asManifest: (m: unknown, from?: (...a: unknown[]) => any) => Manifest;
|
|
227
|
+
/**
|
|
228
|
+
* Returns a {@link Manifest} with normalized data.
|
|
229
|
+
*/
|
|
230
|
+
export declare const normalizeManifest: (manifest: Manifest | ManifestRegistry) => Manifest;
|
|
197
231
|
export declare const asManifestRegistry: (m: unknown, from?: (...a: unknown[]) => any) => ManifestRegistry;
|
|
198
232
|
export declare const assertManifest: (m: unknown) => asserts m is Manifest;
|
|
199
233
|
export declare const assertManifestRegistry: (m: unknown) => asserts m is ManifestRegistry;
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GACjB,SAAS,EAAE,GACX,OAAO,GACP,MAAM,GACN,MAAM,GACN;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC1B,IAAI,GACJ,SAAS,CAAA;AAEb,wBAAwB;AACxB,MAAM,MAAM,SAAS,GAAG,UAAU,MAAM,EAAE,CAAA;AAE1C,4BAA4B;AAC5B,MAAM,MAAM,KAAK,GAAG,UAAU,MAAM,EAAE,CAAA;AAEtC,+DAA+D;AAC/D,MAAM,MAAM,IAAI,GAAG;IACjB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,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,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AED,eAAO,MAAM,kBAAkB,MAC1B,OAAO,SACH,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,GAAG,KAC9B,gBASF,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,CAC3B,CAAC,EAAE,OAAO,KACP,OAAO,CAAC,CAAC,IAAI,QAEjB,CAAA;AACD,eAAO,MAAM,sBAAsB,EAAE,CACnC,CAAC,EAAE,OAAO,KACP,OAAO,CAAC,CAAC,IAAI,gBAEjB,CAAA;AAED,eAAO,MAAM,WAAW,MAAO,OAAO,KAAG,CAAC,IAAI,SAS7C,CAAA;AAED,eAAO,MAAM,WAAW,MACnB,OAAO,SACH,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,GAAG,KAC9B,SASF,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,CAC5B,CAAC,EAAE,OAAO,KACP,OAAO,CAAC,CAAC,IAAI,SAEjB,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,4 +1,117 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
/** Normalize funding information to a consistent format. */
|
|
3
|
+
export const normalizeFunding = (funding) => {
|
|
4
|
+
if (funding === undefined || funding === null) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const normalizeItem = (item) => {
|
|
8
|
+
const getTypeFromUrl = (url) => {
|
|
9
|
+
try {
|
|
10
|
+
const { hostname } = new URL(url);
|
|
11
|
+
const domain = hostname.startsWith('www.') ? hostname.slice(4) : hostname;
|
|
12
|
+
if (domain === 'github.com')
|
|
13
|
+
return 'github';
|
|
14
|
+
if (domain === 'patreon.com')
|
|
15
|
+
return 'patreon';
|
|
16
|
+
if (domain === 'opencollective.com')
|
|
17
|
+
return 'opencollective';
|
|
18
|
+
return 'individual';
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return 'invalid';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const validateType = (url, type) => {
|
|
25
|
+
const urlType = getTypeFromUrl(url);
|
|
26
|
+
if (!type ||
|
|
27
|
+
['github', 'patreon', 'opencollective'].includes(urlType))
|
|
28
|
+
return urlType;
|
|
29
|
+
if (urlType === 'invalid')
|
|
30
|
+
return undefined;
|
|
31
|
+
return type;
|
|
32
|
+
};
|
|
33
|
+
if (typeof item === 'string') {
|
|
34
|
+
return { url: item, type: getTypeFromUrl(item) };
|
|
35
|
+
}
|
|
36
|
+
if (isObject(item) &&
|
|
37
|
+
'url' in item &&
|
|
38
|
+
typeof item.url === 'string') {
|
|
39
|
+
const obj = item;
|
|
40
|
+
const url = obj.url;
|
|
41
|
+
const validatedType = validateType(url, obj.type);
|
|
42
|
+
const result = { ...obj, url };
|
|
43
|
+
if (validatedType) {
|
|
44
|
+
result.type = validatedType;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
delete result.type;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
return { url: '', type: 'individual' };
|
|
52
|
+
};
|
|
53
|
+
const fundingArray = Array.isArray(funding) ? funding : [funding];
|
|
54
|
+
const sources = fundingArray.map(normalizeItem);
|
|
55
|
+
return sources;
|
|
56
|
+
};
|
|
57
|
+
/* Parse a string or object into a normalized contributor */
|
|
58
|
+
export const parsePerson = (author, writeAccess, isPublisher) => {
|
|
59
|
+
if (typeof author === 'string') {
|
|
60
|
+
const NAME_PATTERN = /^([^(<]+)/;
|
|
61
|
+
const EMAIL_PATTERN = /<([^<>]+)>/;
|
|
62
|
+
const name = NAME_PATTERN.exec(author)?.[0].trim() || '';
|
|
63
|
+
const email = EMAIL_PATTERN.exec(author)?.[1] || '';
|
|
64
|
+
if (!name && !email)
|
|
65
|
+
return undefined;
|
|
66
|
+
return {
|
|
67
|
+
name: name || undefined,
|
|
68
|
+
email: email || undefined,
|
|
69
|
+
writeAccess: writeAccess ?? false,
|
|
70
|
+
isPublisher: isPublisher ?? false,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else if (isObject(author)) {
|
|
74
|
+
const name = typeof author.name === 'string' ? author.name : undefined;
|
|
75
|
+
const email = typeof author.email === 'string' ? author.email
|
|
76
|
+
: typeof author.mail === 'string' ? author.mail
|
|
77
|
+
: undefined;
|
|
78
|
+
if (!name && !email)
|
|
79
|
+
return undefined;
|
|
80
|
+
return {
|
|
81
|
+
name,
|
|
82
|
+
email,
|
|
83
|
+
writeAccess: writeAccess ?? false,
|
|
84
|
+
isPublisher: isPublisher ?? false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Normalize contributors and maintainers from various formats
|
|
91
|
+
*/
|
|
92
|
+
export const normalizeContributors = (contributors, maintainers) => {
|
|
93
|
+
if (!contributors && !maintainers) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const result = [];
|
|
97
|
+
// Parse regular contributors (if any)
|
|
98
|
+
if (contributors) {
|
|
99
|
+
const contributorsArray = Array.isArray(contributors) ? contributors : [contributors];
|
|
100
|
+
const parsedContributors = contributorsArray
|
|
101
|
+
.map(person => parsePerson(person))
|
|
102
|
+
.filter((c) => c !== undefined);
|
|
103
|
+
result.push(...parsedContributors);
|
|
104
|
+
}
|
|
105
|
+
// Parse maintainers with special flags
|
|
106
|
+
if (maintainers) {
|
|
107
|
+
const maintainersArray = Array.isArray(maintainers) ? maintainers : [maintainers];
|
|
108
|
+
const parsedMaintainers = maintainersArray
|
|
109
|
+
.map(person => parsePerson(person, true, true))
|
|
110
|
+
.filter((c) => c !== undefined);
|
|
111
|
+
result.push(...parsedMaintainers);
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
2
115
|
export const integrityRE = /^sha512-[a-zA-Z0-9/+]{86}==$/;
|
|
3
116
|
export const isIntegrity = (i) => typeof i === 'string' && integrityRE.test(i);
|
|
4
117
|
export const asIntegrity = (i) => {
|
|
@@ -84,13 +197,41 @@ export const asManifest = (m, from) => {
|
|
|
84
197
|
if (!isManifest(m)) {
|
|
85
198
|
throw error('invalid manifest', { found: m }, from ?? asManifest);
|
|
86
199
|
}
|
|
87
|
-
return m;
|
|
200
|
+
return normalizeManifest(m);
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Returns a {@link Manifest} with normalized data.
|
|
204
|
+
*/
|
|
205
|
+
export const normalizeManifest = (manifest) => {
|
|
206
|
+
// checks for properties with specific normalization helper methods,
|
|
207
|
+
// if there's nothing to normalize then we just return the original manifest
|
|
208
|
+
if (manifest.funding === undefined &&
|
|
209
|
+
manifest.contributors === undefined &&
|
|
210
|
+
!('maintainers' in manifest)) {
|
|
211
|
+
return manifest;
|
|
212
|
+
}
|
|
213
|
+
const normalizedFunding = normalizeFunding(manifest.funding);
|
|
214
|
+
const normalizedContributors = normalizeContributors(manifest.contributors, manifest.maintainers);
|
|
215
|
+
// Create result with normalized data
|
|
216
|
+
const result = {
|
|
217
|
+
...manifest,
|
|
218
|
+
funding: normalizedFunding,
|
|
219
|
+
contributors: normalizedContributors,
|
|
220
|
+
};
|
|
221
|
+
// Remove maintainers field if it exists in the raw manifest
|
|
222
|
+
if ('maintainers' in manifest && manifest.maintainers) {
|
|
223
|
+
// Return a new manifest without the maintainers field
|
|
224
|
+
const resultWithoutMaintainers = structuredClone(result);
|
|
225
|
+
delete resultWithoutMaintainers.maintainers;
|
|
226
|
+
return resultWithoutMaintainers;
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
88
229
|
};
|
|
89
230
|
export const asManifestRegistry = (m, from) => {
|
|
90
231
|
if (!isManifestRegistry(m)) {
|
|
91
232
|
throw error('invalid registry manifest', { found: m }, from ?? asManifestRegistry);
|
|
92
233
|
}
|
|
93
|
-
return m;
|
|
234
|
+
return normalizeManifest(m);
|
|
94
235
|
};
|
|
95
236
|
export const assertManifest = m => {
|
|
96
237
|
asManifest(m, assertManifest);
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAqM3C,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAA;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAkB,EAAE,CACxD,OAAO,CAAC,KAAK,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAE9C,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAa,EAAE;IACnD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;QACpB,MAAM,KAAK,CACT,mBAAmB,EACnB;YACE,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,WAAW;SACpB,EACD,WAAW,CACZ,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;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAA;AACnD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC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sourcesContent":["import { error } from '@vltpkg/error-cause'\n\n/** anything that can be encoded in JSON */\nexport type JSONField =\n | JSONField[]\n | boolean\n | number\n | string\n | { [k: string]: JSONField }\n | null\n | undefined\n\n/** sha512 SRI string */\nexport type Integrity = `sha512-${string}`\n\n/** SHA256 key identifier */\nexport type KeyID = `SHA256:${string}`\n\n/** The Manifest['dist'] field present in registry manifests */\nexport type Dist = {\n integrity?: Integrity\n shasum?: string\n tarball?: string\n fileCount?: number\n unpackedSize?: number\n signatures?: {\n keyid: KeyID\n sig: string\n }[]\n}\n\n/** An object used to mark some peerDeps as optional */\nexport type PeerDependenciesMetaValue = {\n optional?: boolean\n}\n\n// Don't use Record here since TS cant do circular references with that\n// https://github.com/microsoft/TypeScript/issues/41164#issuecomment-1427073368\nexport type ConditionalValueObject = {\n [k: string]: ConditionalValue\n}\n\nexport type ConditionalValue =\n | ConditionalValue[]\n | ConditionalValueObject\n | string\n | null\n\nexport type ExportsSubpaths = {\n [path in '.' | `./${string}`]?: ConditionalValue\n}\n\nexport type Exports =\n | Exclude<ConditionalValue, null>\n | ExportsSubpaths\n\nexport type Imports = Record<`#${string}`, ConditionalValue>\n\nexport type FundingEntry = string | { url: string }\nexport type Funding = FundingEntry | FundingEntry[]\n\nexport type Person =\n | string\n | {\n name: string\n url?: string\n email?: string\n }\n\nexport type Repository =\n | string\n | {\n type: string\n url: string\n }\n\nexport type Bugs =\n | string\n | {\n url?: string\n email?: string\n }\n\nexport type Manifest = {\n /** The name of the package. optional because {} is a valid package.json */\n name?: string\n /** The version of the package. optional because {} is a valid package.json */\n version?: string\n /** production dependencies, name:specifier */\n dependencies?: Record<string, string>\n /** development dependencies, name:specifier */\n devDependencies?: Record<string, string>\n /** optional dependencies, name:specifier */\n optionalDependencies?: Record<string, string>\n /** peer dependencies, name:specifier */\n peerDependencies?: Record<string, string>\n /** peer dependencies marked as optional */\n peerDependenciesMeta?: Record<string, PeerDependenciesMetaValue>\n /** dependency ranges that are acceptable, but not forced */\n acceptDependencies?: Record<string, string>\n /** names of dependencies included in the package tarball */\n bundleDependencies?: string[]\n /** a message indicating that this is not to be used */\n deprecated?: string\n /** executable built and linked by this package */\n bin?: Record<string, string> | string\n /** run-script actions for this package */\n scripts?: Record<string, string>\n /** supported run-time platforms this package can run on */\n engines?: Record<string, string>\n /** supported operating systems this package can run on */\n os?: string[] | string\n /** supported CPU architectures this package can run on */\n cpu?: string[] | string\n /** URLs that can be visited to fund this project */\n funding?: Funding\n /** 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?: string[]\n /** where to go to file issues */\n bugs?: Bugs\n /** where the development happens */\n repository?: Repository\n /** the main module, if exports['.'] is not set */\n main?: string\n /** named subpath exports */\n exports?: Exports\n /** named #identifier imports */\n imports?: Imports\n /**\n * the HEAD of the git repo this was published from\n * only present in published packages\n */\n gitHead?: string\n /** whether the package is private */\n private?: boolean\n /** whether this is ESM or CommonJS by default */\n type?: 'commonjs' | 'module'\n /** npm puts this on published manifests */\n gypfile?: boolean\n /** the author of a package */\n author?: Person\n /** contributors to the package */\n contributors?: Person[]\n /** the license of the package */\n license?: string\n}\n\nexport type ManifestRegistry = Manifest &\n Required<Pick<Manifest, 'name' | 'version' | 'dist'>>\n\nexport type Packument = {\n name: string\n 'dist-tags': Record<string, string>\n versions: Record<string, Manifest>\n modified?: string\n time?: Record<string, string>\n readme?: string\n}\n\nexport type RefType = 'branch' | 'head' | 'other' | 'pull' | 'tag'\n\n/**\n * A representation of a given remote ref in a {@link RevDoc} object.\n */\nexport type RevDocEntry = Omit<Manifest, 'type'> &\n Required<Pick<Manifest, 'version'>> & {\n /** sha this references */\n sha: string\n /** ref as passed git locally */\n ref: string\n /** canonical full ref, like `refs/tags/blahblah` */\n rawRef: string\n /** what type of ref this is: 'branch', 'tag', etc. */\n type: RefType\n }\n\n/**\n * An object kind of resembling a packument, but about a git repo.\n */\nexport type RevDoc = Omit<Packument, 'versions'> & {\n /** all semver-looking tags go in this record */\n versions: Record<string, RevDocEntry>\n /** all named things that can be cloned down remotely */\n refs: Record<string, RevDocEntry>\n /** all named shas referenced above */\n shas: Record<string, string[]>\n}\n\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 m\n}\n\nexport const asManifestRegistry = (\n m: unknown,\n from?: (...a: unknown[]) => any,\n): ManifestRegistry => {\n if (!isManifestRegistry(m)) {\n throw error(\n 'invalid registry manifest',\n { found: m },\n from ?? asManifestRegistry,\n )\n }\n return m\n}\n\nexport const assertManifest: (\n m: unknown,\n) => asserts m is Manifest = m => {\n asManifest(m, assertManifest)\n}\nexport const assertManifestRegistry: (\n m: unknown,\n) => asserts m is ManifestRegistry = m => {\n asManifestRegistry(m, assertManifestRegistry)\n}\n\nexport const isPackument = (p: unknown): p is Packument => {\n if (!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;AAwE3C,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,K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AAM,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'\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/* 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 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?: string[]\n /** where to go to file issues */\n bugs?: Bugs\n /** where the development happens */\n repository?: Repository\n /** the main module, if exports['.'] is not set */\n main?: string\n /** named subpath exports */\n exports?: Exports\n /** named #identifier imports */\n imports?: Imports\n /**\n * the HEAD of the git repo this was published from\n * only present in published packages\n */\n gitHead?: string\n /** whether the package is private */\n private?: boolean\n /** whether this is ESM or CommonJS by default */\n type?: 'commonjs' | 'module'\n /** npm puts this on published manifests */\n gypfile?: boolean\n /** the author of a package */\n author?: Person\n /** contributors to the package */\n contributors?: 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 // 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 !('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\n // Create result with normalized data\n const result: Manifest = {\n ...manifest,\n funding: normalizedFunding as Funding,\n contributors: normalizedContributors,\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"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/types",
|
|
3
3
|
"description": "definitions for some of vlt's core types",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-17",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@vltpkg/error-cause": "0.0.0-
|
|
22
|
+
"@vltpkg/error-cause": "0.0.0-17"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@eslint/js": "^9.28.0",
|
|
26
26
|
"@types/node": "^22.15.29",
|
|
27
27
|
"eslint": "^9.28.0",
|
|
28
|
-
"prettier": "^3.
|
|
28
|
+
"prettier": "^3.6.0",
|
|
29
29
|
"tap": "^21.1.0",
|
|
30
30
|
"tshy": "^3.0.2",
|
|
31
31
|
"typedoc": "~0.27.9",
|