@helpers4/license 3.1.1-alpha.0
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/LICENSE.md +160 -0
- package/README.md +87 -0
- package/lib/index.d.ts +78 -0
- package/lib/index.js +234 -0
- package/lib/index.js.map +1 -0
- package/meta/api.json +129 -0
- package/meta/category.json +6 -0
- package/meta/examples.json +60 -0
- package/meta/licenses.json +4 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
### GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
|
|
3
|
+
Version 3, 29 June 2007
|
|
4
|
+
|
|
5
|
+
Copyright (C) 2007 Free Software Foundation, Inc.
|
|
6
|
+
<https://fsf.org/\>
|
|
7
|
+
|
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies of this
|
|
9
|
+
license document, but changing it is not allowed.
|
|
10
|
+
|
|
11
|
+
This version of the GNU Lesser General Public License incorporates the
|
|
12
|
+
terms and conditions of version 3 of the GNU General Public License,
|
|
13
|
+
supplemented by the additional permissions listed below.
|
|
14
|
+
|
|
15
|
+
#### 0. Additional Definitions.
|
|
16
|
+
|
|
17
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
18
|
+
General Public License, and the "GNU GPL" refers to version 3 of the
|
|
19
|
+
GNU General Public License.
|
|
20
|
+
|
|
21
|
+
"The Library" refers to a covered work governed by this License, other
|
|
22
|
+
than an Application or a Combined Work as defined below.
|
|
23
|
+
|
|
24
|
+
An "Application" is any work that makes use of an interface provided by
|
|
25
|
+
the Library, but which is not otherwise based on the Library. Defining a
|
|
26
|
+
subclass of a class defined by the Library is deemed a mode of using an
|
|
27
|
+
interface provided by the Library.
|
|
28
|
+
|
|
29
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
30
|
+
Application with the Library. The particular version of the Library with
|
|
31
|
+
which the Combined Work was made is also called the "Linked Version".
|
|
32
|
+
|
|
33
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
34
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
35
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
36
|
+
based on the Application, and not on the Linked Version.
|
|
37
|
+
|
|
38
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
39
|
+
object code and/or source code for the Application, including any data
|
|
40
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
41
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
42
|
+
|
|
43
|
+
#### 1. Exception to Section 3 of the GNU GPL.
|
|
44
|
+
|
|
45
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
46
|
+
without being bound by section 3 of the GNU GPL.
|
|
47
|
+
|
|
48
|
+
#### 2. Conveying Modified Versions.
|
|
49
|
+
|
|
50
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
51
|
+
facility refers to a function or data to be supplied by an Application
|
|
52
|
+
that uses the facility (other than as an argument passed when the
|
|
53
|
+
facility is invoked), then you may convey a copy of the modified version:
|
|
54
|
+
|
|
55
|
+
- **a)** under this License, provided that you make a good faith effort
|
|
56
|
+
to ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs whatever
|
|
58
|
+
part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
- **b)** under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
#### 3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from a
|
|
66
|
+
header file that is part of the Library. You may convey such object code
|
|
67
|
+
under terms of your choice, provided that, if the incorporated material
|
|
68
|
+
is not limited to numerical parameters, data structure layouts and
|
|
69
|
+
accessors, or small macros, inline functions and templates (ten or fewer
|
|
70
|
+
lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
- **a)** Give prominent notice with each copy of the object code that
|
|
73
|
+
the Library is used in it and that the Library and its use are covered
|
|
74
|
+
by this License.
|
|
75
|
+
|
|
76
|
+
- **b)** Accompany the object code with a copy of the GNU GPL and this
|
|
77
|
+
license document.
|
|
78
|
+
|
|
79
|
+
#### 4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that, taken
|
|
82
|
+
together, effectively do not restrict modification of the portions of
|
|
83
|
+
the Library contained in the Combined Work and reverse engineering for
|
|
84
|
+
debugging such modifications, if you also do each of the following:
|
|
85
|
+
|
|
86
|
+
- **a)** Give prominent notice with each copy of the Combined Work that
|
|
87
|
+
the Library is used in it and that the Library and its use are covered
|
|
88
|
+
by this License.
|
|
89
|
+
|
|
90
|
+
- **b)** Accompany the Combined Work with a copy of the GNU GPL and
|
|
91
|
+
this license document.
|
|
92
|
+
|
|
93
|
+
- **c)** For a Combined Work that displays copyright notices during
|
|
94
|
+
execution, include the copyright notice for the Library among these
|
|
95
|
+
notices, as well as a reference directing the user to the copies of
|
|
96
|
+
the GNU GPL and this license document.
|
|
97
|
+
|
|
98
|
+
- **d)** Do one of the following:
|
|
99
|
+
|
|
100
|
+
- **0)** Convey the Minimal Corresponding Source under the terms of
|
|
101
|
+
this License, and the Corresponding Application Code in a form
|
|
102
|
+
suitable for, and under terms that permit, the user to recombine or
|
|
103
|
+
relink the Application with a modified version of the Linked Version
|
|
104
|
+
to produce a modified Combined Work, in the manner specified by
|
|
105
|
+
section 6 of the GNU GPL for conveying Corresponding Source.
|
|
106
|
+
|
|
107
|
+
- **1)** Use a suitable shared library mechanism for linking with the
|
|
108
|
+
Library. A suitable mechanism is one that (a) uses at run time a copy
|
|
109
|
+
of the Library already present on the user's computer system, and (b)
|
|
110
|
+
will operate properly with a modified version of the Library that is
|
|
111
|
+
interface-compatible with the Linked Version.
|
|
112
|
+
|
|
113
|
+
- **e)** Provide Installation Information, but only if you would
|
|
114
|
+
otherwise be required to provide such information under section 6 of
|
|
115
|
+
the GNU GPL, and only to the extent that such information is necessary
|
|
116
|
+
to install and execute a modified version of the Combined Work produced
|
|
117
|
+
by recombining or relinking the Application with a modified version of
|
|
118
|
+
the Linked Version. (If you use option 4d0, the Installation
|
|
119
|
+
Information must accompany the Minimal Corresponding Source and
|
|
120
|
+
Corresponding Application Code. If you use option 4d1, you must
|
|
121
|
+
provide the Installation Information in the manner specified by
|
|
122
|
+
section 6 of the GNU GPL for conveying Corresponding Source.)
|
|
123
|
+
|
|
124
|
+
#### 5. Combined Libraries.
|
|
125
|
+
|
|
126
|
+
You may place library facilities that are a work based on the Library
|
|
127
|
+
side by side in a single library together with other library facilities
|
|
128
|
+
that are not Applications and are not covered by this License, and
|
|
129
|
+
convey such a combined library under terms of your choice, if you do
|
|
130
|
+
both of the following:
|
|
131
|
+
|
|
132
|
+
- **a)** Accompany the combined library with a copy of the same work
|
|
133
|
+
based on the Library, uncombined with any other library facilities,
|
|
134
|
+
conveyed under the terms of this License.
|
|
135
|
+
|
|
136
|
+
- **b)** Give prominent notice with the combined library that part of
|
|
137
|
+
it is a work based on the Library, and explaining where to find the
|
|
138
|
+
accompanying uncombined form of the same work.
|
|
139
|
+
|
|
140
|
+
#### 6. Revised Versions of the GNU Lesser General Public License.
|
|
141
|
+
|
|
142
|
+
The Free Software Foundation may publish revised and/or new versions of
|
|
143
|
+
the GNU Lesser General Public License from time to time. Such new
|
|
144
|
+
versions will be similar in spirit to the present version, but may
|
|
145
|
+
differ in detail to address new problems or concerns.
|
|
146
|
+
|
|
147
|
+
Each version is given a distinguishing version number. If the Library as
|
|
148
|
+
you received it specifies that a certain numbered version of the GNU
|
|
149
|
+
Lesser General Public License "or any later version" applies to it, you
|
|
150
|
+
have the option of following the terms and conditions either of that
|
|
151
|
+
published version or of any later version published by the Free Software
|
|
152
|
+
Foundation. If the Library as you received it does not specify a version
|
|
153
|
+
number of the GNU Lesser General Public License, you may choose any
|
|
154
|
+
version of the GNU Lesser General Public License ever published by the
|
|
155
|
+
Free Software Foundation.
|
|
156
|
+
|
|
157
|
+
If the Library as you received it specifies that a proxy can decide
|
|
158
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
159
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
160
|
+
permanent authorization for you to choose that version for the Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# @helpers4
|
|
2
|
+
|
|
3
|
+
The `@helpers4` are a collection of helper functions for use in any project, whatever the framework.
|
|
4
|
+
Every helper is a standalone module and supports tree-shaking, so you can use only the helpers you need without embedding the whole library.
|
|
5
|
+
|
|
6
|
+
## @helpers4/license
|
|
7
|
+
|
|
8
|
+
A set of helpers for working with URLs.
|
|
9
|
+
|
|
10
|
+
## Documentation
|
|
11
|
+
|
|
12
|
+
[https://helpers4.dev/typescript/categories/license/](https://helpers4.dev/typescript/categories/license/)
|
|
13
|
+
|
|
14
|
+
<!-- AUTOMATIC-METHODS -->
|
|
15
|
+
- agree
|
|
16
|
+
- families
|
|
17
|
+
- isKnown
|
|
18
|
+
<!-- /AUTOMATIC-METHODS -->
|
|
19
|
+
|
|
20
|
+
## See
|
|
21
|
+
|
|
22
|
+
<!-- AUTOMATIC-SIBLINGS -->
|
|
23
|
+
- [array](../array)
|
|
24
|
+
- [ci](../ci)
|
|
25
|
+
- [color](../color)
|
|
26
|
+
- [commit](../commit)
|
|
27
|
+
- [date](../date)
|
|
28
|
+
- [function](../function)
|
|
29
|
+
- [guard](../guard)
|
|
30
|
+
- [id](../id)
|
|
31
|
+
- [map](../map)
|
|
32
|
+
- [markdown](../markdown)
|
|
33
|
+
- [node](../node)
|
|
34
|
+
- [number](../number)
|
|
35
|
+
- [object](../object)
|
|
36
|
+
- [observable](../observable)
|
|
37
|
+
- [promise](../promise)
|
|
38
|
+
- [set](../set)
|
|
39
|
+
- [string](../string)
|
|
40
|
+
- [structure](../structure)
|
|
41
|
+
- [type](../type)
|
|
42
|
+
- [url](../url)
|
|
43
|
+
- [version](../version)
|
|
44
|
+
<!-- /AUTOMATIC-SIBLINGS -->
|
|
45
|
+
|
|
46
|
+
## All Available Packages
|
|
47
|
+
|
|
48
|
+
<!-- AUTOMATIC-CATEGORIES-TABLE -->
|
|
49
|
+
| Name | Package | Source Code | Description |
|
|
50
|
+
|------|---------|-------------|-------------|
|
|
51
|
+
| array | [@helpers4/array](https://www.npmjs.com/package/@helpers4/array) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/array) | Array manipulation utilities |
|
|
52
|
+
| ci | [@helpers4/ci](https://www.npmjs.com/package/@helpers4/ci) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/ci) | CI/CD workflow status utilities |
|
|
53
|
+
| color | [@helpers4/color](https://www.npmjs.com/package/@helpers4/color) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/color) | Color conversion and validation utilities |
|
|
54
|
+
| commit | [@helpers4/commit](https://www.npmjs.com/package/@helpers4/commit) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/commit) | Conventional Commits parsing and analysis |
|
|
55
|
+
| date | [@helpers4/date](https://www.npmjs.com/package/@helpers4/date) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/date) | Date and time utility functions |
|
|
56
|
+
| function | [@helpers4/function](https://www.npmjs.com/package/@helpers4/function) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/function) | Function utilities and type guards |
|
|
57
|
+
| guard | [@helpers4/guard](https://www.npmjs.com/package/@helpers4/guard) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/guard) | Runtime type guard utilities |
|
|
58
|
+
| id | [@helpers4/id](https://www.npmjs.com/package/@helpers4/id) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/id) | Unique identifier generation utilities |
|
|
59
|
+
| license | [@helpers4/license](https://www.npmjs.com/package/@helpers4/license) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/license) | License string classification and comparison |
|
|
60
|
+
| map | [@helpers4/map](https://www.npmjs.com/package/@helpers4/map) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/map) | Native Map manipulation utilities |
|
|
61
|
+
| markdown | [@helpers4/markdown](https://www.npmjs.com/package/@helpers4/markdown) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/markdown) | Markdown formatting and escaping utilities |
|
|
62
|
+
| node | [@helpers4/node](https://www.npmjs.com/package/@helpers4/node) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/node) | Node.js-specific utilities |
|
|
63
|
+
| number | [@helpers4/number](https://www.npmjs.com/package/@helpers4/number) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/number) | Number utility functions and validation |
|
|
64
|
+
| object | [@helpers4/object](https://www.npmjs.com/package/@helpers4/object) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/object) | Object manipulation utilities |
|
|
65
|
+
| observable | [@helpers4/observable](https://www.npmjs.com/package/@helpers4/observable) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/observable) | Observable utilities and combinators |
|
|
66
|
+
| promise | [@helpers4/promise](https://www.npmjs.com/package/@helpers4/promise) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/promise) | Promise utilities and error handling |
|
|
67
|
+
| set | [@helpers4/set](https://www.npmjs.com/package/@helpers4/set) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/set) | Native Set manipulation utilities |
|
|
68
|
+
| string | [@helpers4/string](https://www.npmjs.com/package/@helpers4/string) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/string) | String manipulation and formatting utilities |
|
|
69
|
+
| structure | [@helpers4/structure](https://www.npmjs.com/package/@helpers4/structure) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/structure) | Generic, domain-agnostic data structures |
|
|
70
|
+
| type | [@helpers4/type](https://www.npmjs.com/package/@helpers4/type) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/type) | Compile-time TypeScript utility types |
|
|
71
|
+
| url | [@helpers4/url](https://www.npmjs.com/package/@helpers4/url) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/url) | URL parsing and manipulation utilities |
|
|
72
|
+
| version | [@helpers4/version](https://www.npmjs.com/package/@helpers4/version) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/version) | Version string manipulation utilities |
|
|
73
|
+
<!-- /AUTOMATIC-CATEGORIES-TABLE -->
|
|
74
|
+
|
|
75
|
+
## Contributors
|
|
76
|
+
|
|
77
|
+
<table>
|
|
78
|
+
<tr>
|
|
79
|
+
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
|
|
80
|
+
<a href=https://github.com/baxyz>
|
|
81
|
+
<img src=https://avatars.githubusercontent.com/u/7852177?v=4 width="100;" alt=baxyz/>
|
|
82
|
+
<br />
|
|
83
|
+
<sub style="font-size:14px"><b>baxyz</b></sub>
|
|
84
|
+
</a>
|
|
85
|
+
</td>
|
|
86
|
+
</tr>
|
|
87
|
+
</table>
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of helpers4.
|
|
3
|
+
* Copyright (C) 2025 baxyz
|
|
4
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Whether two raw license strings agree closely enough to count as "no real conflict" — true
|
|
8
|
+
* when their family sets share at least one real (known) family, or when either side is entirely
|
|
9
|
+
* unknown (e.g. `"custom"`/`"unknown"`) — a vague claim is never itself evidence of disagreement.
|
|
10
|
+
* Only two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.
|
|
11
|
+
* @param a - The first raw license string
|
|
12
|
+
* @param b - The second raw license string
|
|
13
|
+
* @returns `true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict
|
|
14
|
+
* @example
|
|
15
|
+
* agree('GPL3', 'GPL-3.0-or-later')
|
|
16
|
+
* // => true
|
|
17
|
+
* @example
|
|
18
|
+
* agree('BSD-2-Clause', 'Apache-2.0')
|
|
19
|
+
* // => false
|
|
20
|
+
* @example
|
|
21
|
+
* agree('custom', 'MIT')
|
|
22
|
+
* // => true (a vague claim is never itself a conflict)
|
|
23
|
+
* @since next
|
|
24
|
+
*/
|
|
25
|
+
declare function agree(a: string, b: string): boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This file is part of helpers4.
|
|
29
|
+
* Copyright (C) 2025 baxyz
|
|
30
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Groups a raw, possibly compound license string into its coarse family set — e.g.
|
|
34
|
+
* `"GPL-3.0-or-later AND LGPL-3.0-or-later"` yields `{"gpl", "lgpl"}`. Two sources reporting the
|
|
35
|
+
* same real license under different notation (`"GPL3"` vs `"GPL-3.0-or-later"`, `"GPL"` vs
|
|
36
|
+
* `"GPL2"`) yield the same family, so they read as agreeing rather than conflicting.
|
|
37
|
+
*
|
|
38
|
+
* Proprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel
|
|
39
|
+
* rather than each becoming their own one-off family, so a batch of otherwise-identical
|
|
40
|
+
* `"custom:<vendor>"` strings don't look like dozens of distinct disagreeing licenses. Use
|
|
41
|
+
* {@link isKnown} to check whether any real (non-sentinel) family was found.
|
|
42
|
+
* @param raw - A raw license string, single (`"MIT"`) or compound (`"GPL-3.0+ AND LGPL-3.0+"`)
|
|
43
|
+
* @returns The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)
|
|
44
|
+
* @example
|
|
45
|
+
* families('GPL3')
|
|
46
|
+
* // => Set(1) { 'gpl' }
|
|
47
|
+
* @example
|
|
48
|
+
* families('GPL-3.0-or-later AND LGPL-3.0-or-later')
|
|
49
|
+
* // => Set(2) { 'gpl', 'lgpl' }
|
|
50
|
+
* @example
|
|
51
|
+
* families('custom:Acme End User License')
|
|
52
|
+
* // => Set(1) { 'unknown' }
|
|
53
|
+
* @since next
|
|
54
|
+
*/
|
|
55
|
+
declare function families(raw: string): Set<string>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* This file is part of helpers4.
|
|
59
|
+
* Copyright (C) 2025 baxyz
|
|
60
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Whether a raw license string resolves to at least one recognized family — `false` for an
|
|
64
|
+
* empty string, a purely non-informative claim (`"custom"`, `"unknown"`, `"LicenseRef-EULA"`,
|
|
65
|
+
* ...), or a compound expression where every token is non-informative.
|
|
66
|
+
* @param raw - The raw license string to check
|
|
67
|
+
* @returns `true` if at least one token in `raw` resolves to a real family
|
|
68
|
+
* @example
|
|
69
|
+
* isKnown('GPL-3.0-or-later')
|
|
70
|
+
* // => true
|
|
71
|
+
* @example
|
|
72
|
+
* isKnown('custom:Acme End User License')
|
|
73
|
+
* // => false
|
|
74
|
+
* @since next
|
|
75
|
+
*/
|
|
76
|
+
declare function isKnown(raw: string): boolean;
|
|
77
|
+
|
|
78
|
+
export { agree, families, isKnown };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
//#region helpers/license/_unknownFamily.ts
|
|
2
|
+
/**
|
|
3
|
+
* This file is part of helpers4.
|
|
4
|
+
* Copyright (C) 2025 baxyz
|
|
5
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Sentinel family for a license token that carries no comparable content — `custom`, a bare
|
|
9
|
+
* vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit "we don't know". Two
|
|
10
|
+
* unknown tokens are never treated as either agreeing or conflicting with each other, since
|
|
11
|
+
* neither is a real claim to compare against the other.
|
|
12
|
+
*
|
|
13
|
+
* Not exported from the package — `families()`, `agree()` and `isKnown()` already fully
|
|
14
|
+
* encapsulate this concept; a consumer never needs the sentinel's actual value.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
var UNKNOWN_FAMILY = "unknown";
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region helpers/license/families.ts
|
|
20
|
+
/**
|
|
21
|
+
* This file is part of helpers4.
|
|
22
|
+
* Copyright (C) 2025 baxyz
|
|
23
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
24
|
+
*/
|
|
25
|
+
var FAMILY_ALIASES = {
|
|
26
|
+
mit: ["mit-0", "mit"],
|
|
27
|
+
gpl: [
|
|
28
|
+
"gpl-3.0-or-later",
|
|
29
|
+
"gpl-3.0-only",
|
|
30
|
+
"gpl-2.0-or-later",
|
|
31
|
+
"gpl-2.0-only",
|
|
32
|
+
"gpl-1.0-or-later",
|
|
33
|
+
"gpl-3.0+",
|
|
34
|
+
"gpl-2.0+",
|
|
35
|
+
"gpl-3.0",
|
|
36
|
+
"gpl-2.0",
|
|
37
|
+
"gplv3",
|
|
38
|
+
"gplv2",
|
|
39
|
+
"gpl3+",
|
|
40
|
+
"gpl3",
|
|
41
|
+
"gpl2",
|
|
42
|
+
"gpl-3",
|
|
43
|
+
"gpl-2",
|
|
44
|
+
"gpl"
|
|
45
|
+
],
|
|
46
|
+
lgpl: [
|
|
47
|
+
"lgpl-3.0-or-later",
|
|
48
|
+
"lgpl-3.0-only",
|
|
49
|
+
"lgpl-2.1-or-later",
|
|
50
|
+
"lgpl-2.1-only",
|
|
51
|
+
"lgpl-2.0-or-later",
|
|
52
|
+
"lgpl-2.0-only",
|
|
53
|
+
"lgpl-3.0+",
|
|
54
|
+
"lgpl-2.1+",
|
|
55
|
+
"lgpl-3.0",
|
|
56
|
+
"lgpl-2.1",
|
|
57
|
+
"lgplv3",
|
|
58
|
+
"lgplv2.1",
|
|
59
|
+
"lgpl3",
|
|
60
|
+
"lgpl2.1",
|
|
61
|
+
"lgpl2",
|
|
62
|
+
"lgpl"
|
|
63
|
+
],
|
|
64
|
+
agpl: [
|
|
65
|
+
"agpl-3.0-or-later",
|
|
66
|
+
"agpl-3.0-only",
|
|
67
|
+
"agpl-3.0",
|
|
68
|
+
"agplv3",
|
|
69
|
+
"agpl3",
|
|
70
|
+
"agpl"
|
|
71
|
+
],
|
|
72
|
+
bsd: [
|
|
73
|
+
"bsd-3-clause",
|
|
74
|
+
"bsd-2-clause",
|
|
75
|
+
"0bsd",
|
|
76
|
+
"bsd3",
|
|
77
|
+
"bsd 3-clause",
|
|
78
|
+
"bsd 2-clause",
|
|
79
|
+
"bsd-3",
|
|
80
|
+
"bsd"
|
|
81
|
+
],
|
|
82
|
+
apache: [
|
|
83
|
+
"apache-2.0",
|
|
84
|
+
"apache license 2.0",
|
|
85
|
+
"apache license, version 2.0",
|
|
86
|
+
"apache2",
|
|
87
|
+
"apache 2.0",
|
|
88
|
+
"apache"
|
|
89
|
+
],
|
|
90
|
+
mpl: [
|
|
91
|
+
"mpl-2.0",
|
|
92
|
+
"mpl2",
|
|
93
|
+
"mpl"
|
|
94
|
+
],
|
|
95
|
+
artistic: [
|
|
96
|
+
"artistic-2.0",
|
|
97
|
+
"artistic2.0",
|
|
98
|
+
"perlartistic",
|
|
99
|
+
"artistic"
|
|
100
|
+
],
|
|
101
|
+
isc: ["isc"],
|
|
102
|
+
unlicense: ["unlicense"],
|
|
103
|
+
zlib: ["zlib"],
|
|
104
|
+
wtfpl: ["wtfpl"],
|
|
105
|
+
php: ["php"],
|
|
106
|
+
epl: ["epl"],
|
|
107
|
+
cc: [
|
|
108
|
+
"cc0-1.0",
|
|
109
|
+
"cc0",
|
|
110
|
+
"cc-by-sa-4.0",
|
|
111
|
+
"cc-by-nc-sa-4.0",
|
|
112
|
+
"cc-by-sa",
|
|
113
|
+
"ccpl"
|
|
114
|
+
],
|
|
115
|
+
"public-domain": ["public domain"],
|
|
116
|
+
boost: ["bsl-1.0", "boost"],
|
|
117
|
+
eupl: ["eupl-1.2", "eupl"],
|
|
118
|
+
postgresql: ["postgresql"],
|
|
119
|
+
psf: ["psf-2.0", "psf"],
|
|
120
|
+
gfdl: ["gfdl-1.3", "gfdl"],
|
|
121
|
+
sspl: ["sspl-1.0", "sspl"],
|
|
122
|
+
busl: ["busl-1.1", "busl"]
|
|
123
|
+
};
|
|
124
|
+
var UNKNOWN_PATTERNS = [
|
|
125
|
+
/^custom\b/,
|
|
126
|
+
/^licenseref-/,
|
|
127
|
+
/unknown/,
|
|
128
|
+
/^none$/,
|
|
129
|
+
/^various$/,
|
|
130
|
+
/^unknow$/
|
|
131
|
+
];
|
|
132
|
+
function matchAlias(normalized) {
|
|
133
|
+
for (const [family, aliases] of Object.entries(FAMILY_ALIASES)) if (aliases.includes(normalized)) return family;
|
|
134
|
+
}
|
|
135
|
+
function splitTokens(raw) {
|
|
136
|
+
return raw.split(/\s+(?:and|or)\s+/i).map((token) => token.split(/\s+with\s+/i)[0].trim()).filter((token) => token.length > 0);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Groups a raw, possibly compound license string into its coarse family set — e.g.
|
|
140
|
+
* `"GPL-3.0-or-later AND LGPL-3.0-or-later"` yields `{"gpl", "lgpl"}`. Two sources reporting the
|
|
141
|
+
* same real license under different notation (`"GPL3"` vs `"GPL-3.0-or-later"`, `"GPL"` vs
|
|
142
|
+
* `"GPL2"`) yield the same family, so they read as agreeing rather than conflicting.
|
|
143
|
+
*
|
|
144
|
+
* Proprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel
|
|
145
|
+
* rather than each becoming their own one-off family, so a batch of otherwise-identical
|
|
146
|
+
* `"custom:<vendor>"` strings don't look like dozens of distinct disagreeing licenses. Use
|
|
147
|
+
* {@link isKnown} to check whether any real (non-sentinel) family was found.
|
|
148
|
+
* @param raw - A raw license string, single (`"MIT"`) or compound (`"GPL-3.0+ AND LGPL-3.0+"`)
|
|
149
|
+
* @returns The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)
|
|
150
|
+
* @example
|
|
151
|
+
* families('GPL3')
|
|
152
|
+
* // => Set(1) { 'gpl' }
|
|
153
|
+
* @example
|
|
154
|
+
* families('GPL-3.0-or-later AND LGPL-3.0-or-later')
|
|
155
|
+
* // => Set(2) { 'gpl', 'lgpl' }
|
|
156
|
+
* @example
|
|
157
|
+
* families('custom:Acme End User License')
|
|
158
|
+
* // => Set(1) { 'unknown' }
|
|
159
|
+
* @since next
|
|
160
|
+
*/
|
|
161
|
+
function families(raw) {
|
|
162
|
+
const result = /* @__PURE__ */ new Set();
|
|
163
|
+
for (const token of splitTokens(raw)) {
|
|
164
|
+
const normalized = token.toLowerCase();
|
|
165
|
+
if (UNKNOWN_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
166
|
+
result.add(UNKNOWN_FAMILY);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
result.add(matchAlias(normalized) ?? "unknown");
|
|
170
|
+
}
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region helpers/license/agree.ts
|
|
175
|
+
/**
|
|
176
|
+
* This file is part of helpers4.
|
|
177
|
+
* Copyright (C) 2025 baxyz
|
|
178
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
179
|
+
*/
|
|
180
|
+
/**
|
|
181
|
+
* Whether two raw license strings agree closely enough to count as "no real conflict" — true
|
|
182
|
+
* when their family sets share at least one real (known) family, or when either side is entirely
|
|
183
|
+
* unknown (e.g. `"custom"`/`"unknown"`) — a vague claim is never itself evidence of disagreement.
|
|
184
|
+
* Only two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.
|
|
185
|
+
* @param a - The first raw license string
|
|
186
|
+
* @param b - The second raw license string
|
|
187
|
+
* @returns `true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict
|
|
188
|
+
* @example
|
|
189
|
+
* agree('GPL3', 'GPL-3.0-or-later')
|
|
190
|
+
* // => true
|
|
191
|
+
* @example
|
|
192
|
+
* agree('BSD-2-Clause', 'Apache-2.0')
|
|
193
|
+
* // => false
|
|
194
|
+
* @example
|
|
195
|
+
* agree('custom', 'MIT')
|
|
196
|
+
* // => true (a vague claim is never itself a conflict)
|
|
197
|
+
* @since next
|
|
198
|
+
*/
|
|
199
|
+
function agree(a, b) {
|
|
200
|
+
const knownA = new Set([...families(a)].filter((f) => f !== UNKNOWN_FAMILY));
|
|
201
|
+
const knownB = new Set([...families(b)].filter((f) => f !== UNKNOWN_FAMILY));
|
|
202
|
+
if (knownA.size === 0 || knownB.size === 0) return true;
|
|
203
|
+
for (const family of knownA) if (knownB.has(family)) return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
207
|
+
//#region helpers/license/isKnown.ts
|
|
208
|
+
/**
|
|
209
|
+
* This file is part of helpers4.
|
|
210
|
+
* Copyright (C) 2025 baxyz
|
|
211
|
+
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
212
|
+
*/
|
|
213
|
+
/**
|
|
214
|
+
* Whether a raw license string resolves to at least one recognized family — `false` for an
|
|
215
|
+
* empty string, a purely non-informative claim (`"custom"`, `"unknown"`, `"LicenseRef-EULA"`,
|
|
216
|
+
* ...), or a compound expression where every token is non-informative.
|
|
217
|
+
* @param raw - The raw license string to check
|
|
218
|
+
* @returns `true` if at least one token in `raw` resolves to a real family
|
|
219
|
+
* @example
|
|
220
|
+
* isKnown('GPL-3.0-or-later')
|
|
221
|
+
* // => true
|
|
222
|
+
* @example
|
|
223
|
+
* isKnown('custom:Acme End User License')
|
|
224
|
+
* // => false
|
|
225
|
+
* @since next
|
|
226
|
+
*/
|
|
227
|
+
function isKnown(raw) {
|
|
228
|
+
for (const family of families(raw)) if (family !== "unknown") return true;
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
export { agree, families, isKnown };
|
|
233
|
+
|
|
234
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../helpers/license/_unknownFamily.ts","../../../helpers/license/families.ts","../../../helpers/license/agree.ts","../../../helpers/license/isKnown.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Sentinel family for a license token that carries no comparable content — `custom`, a bare\n * vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we don't know\". Two\n * unknown tokens are never treated as either agreeing or conflicting with each other, since\n * neither is a real claim to compare against the other.\n *\n * Not exported from the package — `families()`, `agree()` and `isKnown()` already fully\n * encapsulate this concept; a consumer never needs the sentinel's actual value.\n * @ignore\n */\nexport const UNKNOWN_FAMILY = 'unknown';\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\n\n// Longest/most specific alias keys first within a family so a substring match never lets a\n// shorter, less specific alias shadow a longer one that also matches the same input.\nconst FAMILY_ALIASES: Record<string, readonly string[]> = {\n mit: ['mit-0', 'mit'],\n gpl: [\n 'gpl-3.0-or-later', 'gpl-3.0-only', 'gpl-2.0-or-later', 'gpl-2.0-only',\n 'gpl-1.0-or-later', 'gpl-3.0+', 'gpl-2.0+', 'gpl-3.0', 'gpl-2.0',\n 'gplv3', 'gplv2', 'gpl3+', 'gpl3', 'gpl2', 'gpl-3', 'gpl-2', 'gpl',\n ],\n lgpl: [\n 'lgpl-3.0-or-later', 'lgpl-3.0-only', 'lgpl-2.1-or-later', 'lgpl-2.1-only',\n 'lgpl-2.0-or-later', 'lgpl-2.0-only', 'lgpl-3.0+', 'lgpl-2.1+', 'lgpl-3.0', 'lgpl-2.1',\n 'lgplv3', 'lgplv2.1', 'lgpl3', 'lgpl2.1', 'lgpl2', 'lgpl',\n ],\n agpl: ['agpl-3.0-or-later', 'agpl-3.0-only', 'agpl-3.0', 'agplv3', 'agpl3', 'agpl'],\n bsd: [\n 'bsd-3-clause', 'bsd-2-clause', '0bsd', 'bsd3', 'bsd 3-clause',\n 'bsd 2-clause', 'bsd-3', 'bsd',\n ],\n apache: ['apache-2.0', 'apache license 2.0', 'apache license, version 2.0', 'apache2', 'apache 2.0', 'apache'],\n mpl: ['mpl-2.0', 'mpl2', 'mpl'],\n artistic: ['artistic-2.0', 'artistic2.0', 'perlartistic', 'artistic'],\n isc: ['isc'],\n unlicense: ['unlicense'],\n zlib: ['zlib'],\n wtfpl: ['wtfpl'],\n php: ['php'],\n epl: ['epl'],\n cc: ['cc0-1.0', 'cc0', 'cc-by-sa-4.0', 'cc-by-nc-sa-4.0', 'cc-by-sa', 'ccpl'],\n 'public-domain': ['public domain'],\n boost: ['bsl-1.0', 'boost'],\n eupl: ['eupl-1.2', 'eupl'],\n postgresql: ['postgresql'],\n psf: ['psf-2.0', 'psf'],\n gfdl: ['gfdl-1.3', 'gfdl'],\n sspl: ['sspl-1.0', 'sspl'],\n busl: ['busl-1.1', 'busl'],\n};\n\n// Non-informative tokens — a real license claim was made, but it carries no comparable content\n// (\"custom\", a bare vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we\n// don't know\"). Checked first, before the alias table, so e.g. \"custom:MIT\" reads as\n// UNKNOWN_FAMILY rather than incorrectly matching MIT's alias substring — a `custom:<...>`\n// convention names the *vendor's own license text*, not necessarily the SPDX license the name\n// resembles.\nconst UNKNOWN_PATTERNS = [/^custom\\b/, /^licenseref-/, /unknown/, /^none$/, /^various$/, /^unknow$/];\n\nfunction matchAlias(normalized: string): string | undefined {\n for (const [family, aliases] of Object.entries(FAMILY_ALIASES)) {\n if (aliases.includes(normalized)) return family;\n }\n return undefined;\n}\n\n// Splits an SPDX-ish compound expression (\"GPL-3.0+ AND LGPL-3.0+\", or a lowercase \"GPL-2.0+ and\n// GFDL-1.3\") into its individual license tokens. `WITH` exceptions (\"Apache-2.0 WITH\n// LLVM-exception\") are dropped entirely — the exception clause never itself resembles a distinct\n// license family, so it would otherwise either land in UNKNOWN_FAMILY for no reason or dilute the\n// comparison with a token that isn't really a separate license claim.\nfunction splitTokens(raw: string): string[] {\n return raw\n .split(/\\s+(?:and|or)\\s+/i)\n .map((token) => token.split(/\\s+with\\s+/i)[0].trim())\n .filter((token) => token.length > 0);\n}\n\n/**\n * Groups a raw, possibly compound license string into its coarse family set — e.g.\n * `\"GPL-3.0-or-later AND LGPL-3.0-or-later\"` yields `{\"gpl\", \"lgpl\"}`. Two sources reporting the\n * same real license under different notation (`\"GPL3\"` vs `\"GPL-3.0-or-later\"`, `\"GPL\"` vs\n * `\"GPL2\"`) yield the same family, so they read as agreeing rather than conflicting.\n *\n * Proprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel\n * rather than each becoming their own one-off family, so a batch of otherwise-identical\n * `\"custom:<vendor>\"` strings don't look like dozens of distinct disagreeing licenses. Use\n * {@link isKnown} to check whether any real (non-sentinel) family was found.\n * @param raw - A raw license string, single (`\"MIT\"`) or compound (`\"GPL-3.0+ AND LGPL-3.0+\"`)\n * @returns The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)\n * @example\n * families('GPL3')\n * // => Set(1) { 'gpl' }\n * @example\n * families('GPL-3.0-or-later AND LGPL-3.0-or-later')\n * // => Set(2) { 'gpl', 'lgpl' }\n * @example\n * families('custom:Acme End User License')\n * // => Set(1) { 'unknown' }\n * @since next\n */\nexport function families(raw: string): Set<string> {\n const result = new Set<string>();\n for (const token of splitTokens(raw)) {\n const normalized = token.toLowerCase();\n if (UNKNOWN_PATTERNS.some((pattern) => pattern.test(normalized))) {\n result.add(UNKNOWN_FAMILY);\n continue;\n }\n result.add(matchAlias(normalized) ?? UNKNOWN_FAMILY);\n }\n return result;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether two raw license strings agree closely enough to count as \"no real conflict\" — true\n * when their family sets share at least one real (known) family, or when either side is entirely\n * unknown (e.g. `\"custom\"`/`\"unknown\"`) — a vague claim is never itself evidence of disagreement.\n * Only two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.\n * @param a - The first raw license string\n * @param b - The second raw license string\n * @returns `true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict\n * @example\n * agree('GPL3', 'GPL-3.0-or-later')\n * // => true\n * @example\n * agree('BSD-2-Clause', 'Apache-2.0')\n * // => false\n * @example\n * agree('custom', 'MIT')\n * // => true (a vague claim is never itself a conflict)\n * @since next\n */\nexport function agree(a: string, b: string): boolean {\n const knownA = new Set([...families(a)].filter((f) => f !== UNKNOWN_FAMILY));\n const knownB = new Set([...families(b)].filter((f) => f !== UNKNOWN_FAMILY));\n\n if (knownA.size === 0 || knownB.size === 0) return true;\n for (const family of knownA) if (knownB.has(family)) return true;\n return false;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether a raw license string resolves to at least one recognized family — `false` for an\n * empty string, a purely non-informative claim (`\"custom\"`, `\"unknown\"`, `\"LicenseRef-EULA\"`,\n * ...), or a compound expression where every token is non-informative.\n * @param raw - The raw license string to check\n * @returns `true` if at least one token in `raw` resolves to a real family\n * @example\n * isKnown('GPL-3.0-or-later')\n * // => true\n * @example\n * isKnown('custom:Acme End User License')\n * // => false\n * @since next\n */\nexport function isKnown(raw: string): boolean {\n for (const family of families(raw)) {\n if (family !== UNKNOWN_FAMILY) return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,iBAAiB;;;;;;;;ACN9B,IAAM,iBAAoD;CACxD,KAAK,CAAC,SAAS,KAAK;CACpB,KAAK;EACH;EAAoB;EAAgB;EAAoB;EACxD;EAAoB;EAAY;EAAY;EAAW;EACvD;EAAS;EAAS;EAAS;EAAQ;EAAQ;EAAS;EAAS;CAC/D;CACA,MAAM;EACJ;EAAqB;EAAiB;EAAqB;EAC3D;EAAqB;EAAiB;EAAa;EAAa;EAAY;EAC5E;EAAU;EAAY;EAAS;EAAW;EAAS;CACrD;CACA,MAAM;EAAC;EAAqB;EAAiB;EAAY;EAAU;EAAS;CAAM;CAClF,KAAK;EACH;EAAgB;EAAgB;EAAQ;EAAQ;EAChD;EAAgB;EAAS;CAC3B;CACA,QAAQ;EAAC;EAAc;EAAsB;EAA+B;EAAW;EAAc;CAAQ;CAC7G,KAAK;EAAC;EAAW;EAAQ;CAAK;CAC9B,UAAU;EAAC;EAAgB;EAAe;EAAgB;CAAU;CACpE,KAAK,CAAC,KAAK;CACX,WAAW,CAAC,WAAW;CACvB,MAAM,CAAC,MAAM;CACb,OAAO,CAAC,OAAO;CACf,KAAK,CAAC,KAAK;CACX,KAAK,CAAC,KAAK;CACX,IAAI;EAAC;EAAW;EAAO;EAAgB;EAAmB;EAAY;CAAM;CAC5E,iBAAiB,CAAC,eAAe;CACjC,OAAO,CAAC,WAAW,OAAO;CAC1B,MAAM,CAAC,YAAY,MAAM;CACzB,YAAY,CAAC,YAAY;CACzB,KAAK,CAAC,WAAW,KAAK;CACtB,MAAM,CAAC,YAAY,MAAM;CACzB,MAAM,CAAC,YAAY,MAAM;CACzB,MAAM,CAAC,YAAY,MAAM;AAC3B;AAQA,IAAM,mBAAmB;CAAC;CAAa;CAAgB;CAAW;CAAU;CAAa;AAAU;AAEnG,SAAS,WAAW,YAAwC;CAC1D,KAAK,MAAM,CAAC,QAAQ,YAAY,OAAO,QAAQ,cAAc,GAC3D,IAAI,QAAQ,SAAS,UAAU,GAAG,OAAO;AAG7C;AAOA,SAAS,YAAY,KAAuB;CAC1C,OAAO,IACJ,MAAM,mBAAmB,CAAC,CAC1B,KAAK,UAAU,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CACpD,QAAQ,UAAU,MAAM,SAAS,CAAC;AACvC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,SAAS,KAA0B;CACjD,MAAM,yBAAS,IAAI,IAAY;CAC/B,KAAK,MAAM,SAAS,YAAY,GAAG,GAAG;EACpC,MAAM,aAAa,MAAM,YAAY;EACrC,IAAI,iBAAiB,MAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,GAAG;GAChE,OAAO,IAAI,cAAc;GACzB;EACF;EACA,OAAO,IAAI,WAAW,UAAU,KAAA,SAAmB;CACrD;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;AChFA,SAAgB,MAAM,GAAW,GAAoB;CACnD,MAAM,SAAS,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,MAAM,MAAM,cAAc,CAAC;CAC3E,MAAM,SAAS,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,MAAM,MAAM,cAAc,CAAC;CAE3E,IAAI,OAAO,SAAS,KAAK,OAAO,SAAS,GAAG,OAAO;CACnD,KAAK,MAAM,UAAU,QAAQ,IAAI,OAAO,IAAI,MAAM,GAAG,OAAO;CAC5D,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;ACZA,SAAgB,QAAQ,KAAsB;CAC5C,KAAK,MAAM,UAAU,SAAS,GAAG,GAC/B,IAAI,WAAA,WAA2B,OAAO;CAExC,OAAO;AACT"}
|
package/meta/api.json
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "license",
|
|
3
|
+
"version": "3.1.1",
|
|
4
|
+
"functions": [
|
|
5
|
+
{
|
|
6
|
+
"name": "agree",
|
|
7
|
+
"kind": "function",
|
|
8
|
+
"description": "Whether two raw license strings agree closely enough to count as \"no real conflict\" — true\nwhen their family sets share at least one real (known) family, or when either side is entirely\nunknown (e.g. `\"custom\"`/`\"unknown\"`) — a vague claim is never itself evidence of disagreement.\nOnly two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.",
|
|
9
|
+
"since": "next",
|
|
10
|
+
"signatures": [
|
|
11
|
+
{
|
|
12
|
+
"signature": "agree(a: string, b: string): boolean",
|
|
13
|
+
"description": "Whether two raw license strings agree closely enough to count as \"no real conflict\" — true\nwhen their family sets share at least one real (known) family, or when either side is entirely\nunknown (e.g. `\"custom\"`/`\"unknown\"`) — a vague claim is never itself evidence of disagreement.\nOnly two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.",
|
|
14
|
+
"params": [
|
|
15
|
+
{
|
|
16
|
+
"name": "a",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The first raw license string"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "b",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "The second raw license string"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"returns": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "`true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"examples": [
|
|
33
|
+
{
|
|
34
|
+
"title": "Reconcile notation drift across sources",
|
|
35
|
+
"description": "Two package sources reporting the same real license under different notation.",
|
|
36
|
+
"code": "agree('GPL3', 'GPL-3.0-or-later')\n// => true"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"title": "Flag a real license conflict",
|
|
40
|
+
"description": "Two sources genuinely disagreeing on the license family — a real data-quality signal.",
|
|
41
|
+
"code": "agree('BSD-2-Clause', 'Apache-2.0')\n// => false"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"title": "A vague claim is never itself a conflict",
|
|
45
|
+
"description": "When either side is non-informative (\"custom\", \"unknown\", ...), there is nothing real to disagree with.",
|
|
46
|
+
"code": "agree('custom', 'MIT')\n// => true"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"sourceFile": "agree.ts"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "families",
|
|
53
|
+
"kind": "function",
|
|
54
|
+
"description": "Groups a raw, possibly compound license string into its coarse family set — e.g.\n`\"GPL-3.0-or-later AND LGPL-3.0-or-later\"` yields `{\"gpl\", \"lgpl\"}`. Two sources reporting the\nsame real license under different notation (`\"GPL3\"` vs `\"GPL-3.0-or-later\"`, `\"GPL\"` vs\n`\"GPL2\"`) yield the same family, so they read as agreeing rather than conflicting.\n\nProprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel\nrather than each becoming their own one-off family, so a batch of otherwise-identical\n`\"custom:<vendor>\"` strings don't look like dozens of distinct disagreeing licenses. Use\nisKnown to check whether any real (non-sentinel) family was found.",
|
|
55
|
+
"since": "next",
|
|
56
|
+
"signatures": [
|
|
57
|
+
{
|
|
58
|
+
"signature": "families(raw: string): Set<string>",
|
|
59
|
+
"description": "Groups a raw, possibly compound license string into its coarse family set — e.g.\n`\"GPL-3.0-or-later AND LGPL-3.0-or-later\"` yields `{\"gpl\", \"lgpl\"}`. Two sources reporting the\nsame real license under different notation (`\"GPL3\"` vs `\"GPL-3.0-or-later\"`, `\"GPL\"` vs\n`\"GPL2\"`) yield the same family, so they read as agreeing rather than conflicting.\n\nProprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel\nrather than each becoming their own one-off family, so a batch of otherwise-identical\n`\"custom:<vendor>\"` strings don't look like dozens of distinct disagreeing licenses. Use\nisKnown to check whether any real (non-sentinel) family was found.",
|
|
60
|
+
"params": [
|
|
61
|
+
{
|
|
62
|
+
"name": "raw",
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "A raw license string, single (`\"MIT\"`) or compound (`\"GPL-3.0+ AND LGPL-3.0+\"`)"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"returns": {
|
|
68
|
+
"type": "Set<string>",
|
|
69
|
+
"description": "The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"examples": [
|
|
74
|
+
{
|
|
75
|
+
"title": "Collapse notation drift into one family",
|
|
76
|
+
"description": "\"GPL3\" and \"GPL-3.0-or-later\" are the same real license, reported differently by two sources.",
|
|
77
|
+
"code": "families('GPL3')\n// => Set(1) { 'gpl' }"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "Split a compound SPDX expression",
|
|
81
|
+
"description": "\"AND\"/\"OR\" (any case) separate multiple license claims; \"WITH\" exception clauses are dropped.",
|
|
82
|
+
"code": "families('GPL-3.0-or-later AND LGPL-3.0-or-later')\n// => Set(2) { 'gpl', 'lgpl' }"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"title": "Non-informative claims collapse to one shared \"unknown\" family",
|
|
86
|
+
"description": "A batch of different custom:<vendor> strings all read the same way — none of them is real evidence either way.",
|
|
87
|
+
"code": "families('custom:Acme End User License')\n// => Set(1) { 'unknown' }"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"sourceFile": "families.ts"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "isKnown",
|
|
94
|
+
"kind": "function",
|
|
95
|
+
"description": "Whether a raw license string resolves to at least one recognized family — `false` for an\nempty string, a purely non-informative claim (`\"custom\"`, `\"unknown\"`, `\"LicenseRef-EULA\"`,\n...), or a compound expression where every token is non-informative.",
|
|
96
|
+
"since": "next",
|
|
97
|
+
"signatures": [
|
|
98
|
+
{
|
|
99
|
+
"signature": "isKnown(raw: string): boolean",
|
|
100
|
+
"description": "Whether a raw license string resolves to at least one recognized family — `false` for an\nempty string, a purely non-informative claim (`\"custom\"`, `\"unknown\"`, `\"LicenseRef-EULA\"`,\n...), or a compound expression where every token is non-informative.",
|
|
101
|
+
"params": [
|
|
102
|
+
{
|
|
103
|
+
"name": "raw",
|
|
104
|
+
"type": "string",
|
|
105
|
+
"description": "The raw license string to check"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"returns": {
|
|
109
|
+
"type": "boolean",
|
|
110
|
+
"description": "`true` if at least one token in `raw` resolves to a real family"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"examples": [
|
|
115
|
+
{
|
|
116
|
+
"title": "Filter out entries with no real license information",
|
|
117
|
+
"description": "Handy for flagging catalog entries whose license field is not actually usable.",
|
|
118
|
+
"code": "['MIT', 'custom:Acme EULA', 'unknown'].filter(isKnown)\n// => ['MIT']"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"title": "A vendor-specific EULA is not a recognized family",
|
|
122
|
+
"description": "\"custom:<vendor>\" names the vendor's own license text, not a known open-source family.",
|
|
123
|
+
"code": "isKnown('custom:Acme End User License')\n// => false"
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
"sourceFile": "isKnown.ts"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "license",
|
|
3
|
+
"label": "License",
|
|
4
|
+
"smallDescription": "License string classification and comparison",
|
|
5
|
+
"description": "Groups real-world, SPDX-ish license strings into coarse families (MIT, GPL, LGPL, BSD, Apache, ...) so notation drift across sources (\"GPL3\" vs \"GPL-3.0-or-later\") doesn't read as a conflict. Not an SPDX validator or a full SPDX-expression parser, and never used to pick or display a license — only to compare two reported strings for \"same family\"."
|
|
6
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"category": "license",
|
|
3
|
+
"functions": [
|
|
4
|
+
{
|
|
5
|
+
"name": "agree",
|
|
6
|
+
"examples": [
|
|
7
|
+
{
|
|
8
|
+
"title": "Reconcile notation drift across sources",
|
|
9
|
+
"description": "Two package sources reporting the same real license under different notation.",
|
|
10
|
+
"code": "agree('GPL3', 'GPL-3.0-or-later')\n// => true"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"title": "Flag a real license conflict",
|
|
14
|
+
"description": "Two sources genuinely disagreeing on the license family — a real data-quality signal.",
|
|
15
|
+
"code": "agree('BSD-2-Clause', 'Apache-2.0')\n// => false"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"title": "A vague claim is never itself a conflict",
|
|
19
|
+
"description": "When either side is non-informative (\"custom\", \"unknown\", ...), there is nothing real to disagree with.",
|
|
20
|
+
"code": "agree('custom', 'MIT')\n// => true"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "families",
|
|
26
|
+
"examples": [
|
|
27
|
+
{
|
|
28
|
+
"title": "Collapse notation drift into one family",
|
|
29
|
+
"description": "\"GPL3\" and \"GPL-3.0-or-later\" are the same real license, reported differently by two sources.",
|
|
30
|
+
"code": "families('GPL3')\n// => Set(1) { 'gpl' }"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"title": "Split a compound SPDX expression",
|
|
34
|
+
"description": "\"AND\"/\"OR\" (any case) separate multiple license claims; \"WITH\" exception clauses are dropped.",
|
|
35
|
+
"code": "families('GPL-3.0-or-later AND LGPL-3.0-or-later')\n// => Set(2) { 'gpl', 'lgpl' }"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"title": "Non-informative claims collapse to one shared \"unknown\" family",
|
|
39
|
+
"description": "A batch of different custom:<vendor> strings all read the same way — none of them is real evidence either way.",
|
|
40
|
+
"code": "families('custom:Acme End User License')\n// => Set(1) { 'unknown' }"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "isKnown",
|
|
46
|
+
"examples": [
|
|
47
|
+
{
|
|
48
|
+
"title": "Filter out entries with no real license information",
|
|
49
|
+
"description": "Handy for flagging catalog entries whose license field is not actually usable.",
|
|
50
|
+
"code": "['MIT', 'custom:Acme EULA', 'unknown'].filter(isKnown)\n// => ['MIT']"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"title": "A vendor-specific EULA is not a recognized family",
|
|
54
|
+
"description": "\"custom:<vendor>\" names the vendor's own license text, not a known open-source family.",
|
|
55
|
+
"code": "isKnown('custom:Acme End User License')\n// => false"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@helpers4/license",
|
|
3
|
+
"version": "3.1.1-alpha.0",
|
|
4
|
+
"description": "A set of helpers in TS/JS, compatible with tree-shaking, for license.",
|
|
5
|
+
"author": "baxyz <craft@baxyz.dev>",
|
|
6
|
+
"license": "LGPL-3.0",
|
|
7
|
+
"homepage": "https://helpers4.dev/typescript/categories/license/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/helpers4/typescript.git"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"import": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./meta/api.json": "./meta/api.json",
|
|
22
|
+
"./meta/examples.json": "./meta/examples.json",
|
|
23
|
+
"./meta/licenses.json": "./meta/licenses.json",
|
|
24
|
+
"./llms.txt": "./llms.txt",
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"helpers",
|
|
29
|
+
"license",
|
|
30
|
+
"agree",
|
|
31
|
+
"families",
|
|
32
|
+
"isKnown"
|
|
33
|
+
],
|
|
34
|
+
"files": [
|
|
35
|
+
"lib/index.js",
|
|
36
|
+
"lib/index.d.ts",
|
|
37
|
+
"lib/index.js.map",
|
|
38
|
+
"meta/",
|
|
39
|
+
"llms.txt",
|
|
40
|
+
"LICENSE.md",
|
|
41
|
+
"package.json",
|
|
42
|
+
"README.md"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=26.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|