@agentproto/collect 0.0.0-stage → 0.0.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 +202 -0
- package/README.md +45 -2
- package/dist/index.d.ts +629 -0
- package/dist/index.mjs +348 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +60 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @agentproto/collect
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Building blocks for collecting public posts, articles and metrics with
|
|
4
|
+
provenance. This first release is the data layer only. It is pure: no
|
|
5
|
+
filesystem, no network, one runtime dependency (`zod`).
|
|
6
|
+
|
|
7
|
+
## What is in it
|
|
8
|
+
|
|
9
|
+
- **Schemas** (zod, with inferred types): `CollectItem`, `Observation`,
|
|
10
|
+
`Actor` (with audience readings), `Pickup`, `Recipe`, `RunReport`,
|
|
11
|
+
`Coverage`.
|
|
12
|
+
- **Ids**: `itemId(source, nativeId)` gives `source:nativeId`;
|
|
13
|
+
`itemIdFromUrl(source, url)` hashes the canonical URL when a platform gives
|
|
14
|
+
no id.
|
|
15
|
+
- **`canonicalUrl(url)`**: lowercase host, no fragment, no credentials, no
|
|
16
|
+
default port, tracking parameters removed (`utm_*`, `fbclid`, `gclid`,
|
|
17
|
+
`mc_cid`, `mc_eid`, `ref_src`, `igshid`, ...; `si` on YouTube hosts only), remaining
|
|
18
|
+
parameters sorted, no trailing slash. It only normalises http(s); any other
|
|
19
|
+
input comes back trimmed and unchanged. The result is a dedup key: keep the
|
|
20
|
+
original URL too, and pass the final URL (redirects are not followed).
|
|
21
|
+
- **`textFingerprint(text)`**: SHA-256 of the text after case, whitespace and
|
|
22
|
+
punctuation normalisation. Hashing goes through Web Crypto
|
|
23
|
+
(`crypto.subtle`), so it is async and needs no Node built-in. Text that normalises to nothing
|
|
24
|
+
returns `undefined` (no content id).
|
|
25
|
+
- **`STORE_SCHEMA_VERSION`**: version of the stored shapes.
|
|
26
|
+
|
|
27
|
+
## Rules baked into the schemas
|
|
28
|
+
|
|
29
|
+
- A counter that is not available is absent from `metrics` and listed in
|
|
30
|
+
`missing` with a reason. It is never zero.
|
|
31
|
+
- An item may have no subject and no author audience.
|
|
32
|
+
- An unknown audience is a reading with an `unknown` reason, never a zero.
|
|
33
|
+
Karma stays typed `karma`.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { CollectItem, canonicalUrl, itemIdFromUrl, textFingerprint } from "@agentproto/collect"
|
|
37
|
+
|
|
38
|
+
const url = canonicalUrl("https://Example.com/a/?utm_source=x#top") // https://example.com/a
|
|
39
|
+
const id = await itemIdFromUrl("web", url)
|
|
40
|
+
const contentId = await textFingerprint("Some article text")
|
|
41
|
+
CollectItem.parse({ id, source: "web", kind: "article", contentId, firstSeenAt: new Date().toISOString() })
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const ItemKind: z.ZodEnum<{
|
|
4
|
+
article: "article";
|
|
5
|
+
post: "post";
|
|
6
|
+
thread: "thread";
|
|
7
|
+
submission: "submission";
|
|
8
|
+
review: "review";
|
|
9
|
+
video: "video";
|
|
10
|
+
query: "query";
|
|
11
|
+
}>;
|
|
12
|
+
type ItemKind = z.infer<typeof ItemKind>;
|
|
13
|
+
declare const MissingReason: z.ZodEnum<{
|
|
14
|
+
not_exposed: "not_exposed";
|
|
15
|
+
hidden: "hidden";
|
|
16
|
+
blocked: "blocked";
|
|
17
|
+
}>;
|
|
18
|
+
type MissingReason = z.infer<typeof MissingReason>;
|
|
19
|
+
declare const MetricName: z.ZodEnum<{
|
|
20
|
+
views: "views";
|
|
21
|
+
likes: "likes";
|
|
22
|
+
reposts: "reposts";
|
|
23
|
+
replies: "replies";
|
|
24
|
+
bookmarks: "bookmarks";
|
|
25
|
+
points: "points";
|
|
26
|
+
comments: "comments";
|
|
27
|
+
reactions: "reactions";
|
|
28
|
+
score: "score";
|
|
29
|
+
rating: "rating";
|
|
30
|
+
helpfulVotes: "helpfulVotes";
|
|
31
|
+
}>;
|
|
32
|
+
type MetricName = z.infer<typeof MetricName>;
|
|
33
|
+
declare const Subject: z.ZodObject<{
|
|
34
|
+
label: z.ZodString;
|
|
35
|
+
provenance: z.ZodEnum<{
|
|
36
|
+
query: "query";
|
|
37
|
+
source_tag: "source_tag";
|
|
38
|
+
classifier: "classifier";
|
|
39
|
+
}>;
|
|
40
|
+
classifier: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
version: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
type Subject = z.infer<typeof Subject>;
|
|
46
|
+
declare const ItemLinks: z.ZodObject<{
|
|
47
|
+
target: z.ZodOptional<z.ZodString>;
|
|
48
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
49
|
+
root: z.ZodOptional<z.ZodString>;
|
|
50
|
+
quoted: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
type ItemLinks = z.infer<typeof ItemLinks>;
|
|
53
|
+
declare const ItemPart: z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
text: z.ZodString;
|
|
56
|
+
authorRef: z.ZodOptional<z.ZodString>;
|
|
57
|
+
postedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
type ItemPart = z.infer<typeof ItemPart>;
|
|
60
|
+
declare const CollectItem: z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
source: z.ZodString;
|
|
63
|
+
sourceInstance: z.ZodOptional<z.ZodString>;
|
|
64
|
+
kind: z.ZodEnum<{
|
|
65
|
+
article: "article";
|
|
66
|
+
post: "post";
|
|
67
|
+
thread: "thread";
|
|
68
|
+
submission: "submission";
|
|
69
|
+
review: "review";
|
|
70
|
+
video: "video";
|
|
71
|
+
query: "query";
|
|
72
|
+
}>;
|
|
73
|
+
url: z.ZodOptional<z.ZodString>;
|
|
74
|
+
canonicalUrl: z.ZodOptional<z.ZodString>;
|
|
75
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
contentGroupId: z.ZodOptional<z.ZodString>;
|
|
77
|
+
subjects: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
78
|
+
label: z.ZodString;
|
|
79
|
+
provenance: z.ZodEnum<{
|
|
80
|
+
query: "query";
|
|
81
|
+
source_tag: "source_tag";
|
|
82
|
+
classifier: "classifier";
|
|
83
|
+
}>;
|
|
84
|
+
classifier: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
name: z.ZodString;
|
|
86
|
+
version: z.ZodString;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
}, z.core.$strip>>>;
|
|
89
|
+
title: z.ZodOptional<z.ZodString>;
|
|
90
|
+
text: z.ZodOptional<z.ZodString>;
|
|
91
|
+
textTruncated: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
language: z.ZodOptional<z.ZodString>;
|
|
93
|
+
wordCount: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
format: z.ZodOptional<z.ZodString>;
|
|
95
|
+
authorRef: z.ZodOptional<z.ZodString>;
|
|
96
|
+
submitterRef: z.ZodOptional<z.ZodString>;
|
|
97
|
+
publishedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
98
|
+
postedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
99
|
+
firstSeenAt: z.ZodISODateTime;
|
|
100
|
+
links: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
target: z.ZodOptional<z.ZodString>;
|
|
102
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
103
|
+
root: z.ZodOptional<z.ZodString>;
|
|
104
|
+
quoted: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strip>>;
|
|
106
|
+
outboundLinks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
107
|
+
parts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
text: z.ZodString;
|
|
110
|
+
authorRef: z.ZodOptional<z.ZodString>;
|
|
111
|
+
postedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
112
|
+
}, z.core.$strip>>>;
|
|
113
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
114
|
+
hasMedia: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
query: z.ZodOptional<z.ZodString>;
|
|
116
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
117
|
+
rawRefs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
118
|
+
ext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
type CollectItem = z.infer<typeof CollectItem>;
|
|
121
|
+
declare const ObservationBase: z.ZodObject<{
|
|
122
|
+
itemId: z.ZodString;
|
|
123
|
+
measuredAt: z.ZodISODateTime;
|
|
124
|
+
metrics: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
125
|
+
views: "views";
|
|
126
|
+
likes: "likes";
|
|
127
|
+
reposts: "reposts";
|
|
128
|
+
replies: "replies";
|
|
129
|
+
bookmarks: "bookmarks";
|
|
130
|
+
points: "points";
|
|
131
|
+
comments: "comments";
|
|
132
|
+
reactions: "reactions";
|
|
133
|
+
score: "score";
|
|
134
|
+
rating: "rating";
|
|
135
|
+
helpfulVotes: "helpfulVotes";
|
|
136
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
137
|
+
partMetrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
138
|
+
views: "views";
|
|
139
|
+
likes: "likes";
|
|
140
|
+
reposts: "reposts";
|
|
141
|
+
replies: "replies";
|
|
142
|
+
bookmarks: "bookmarks";
|
|
143
|
+
points: "points";
|
|
144
|
+
comments: "comments";
|
|
145
|
+
reactions: "reactions";
|
|
146
|
+
score: "score";
|
|
147
|
+
rating: "rating";
|
|
148
|
+
helpfulVotes: "helpfulVotes";
|
|
149
|
+
}> & z.core.$partial, z.ZodNumber>>>;
|
|
150
|
+
rawValues: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
151
|
+
views: "views";
|
|
152
|
+
likes: "likes";
|
|
153
|
+
reposts: "reposts";
|
|
154
|
+
replies: "replies";
|
|
155
|
+
bookmarks: "bookmarks";
|
|
156
|
+
points: "points";
|
|
157
|
+
comments: "comments";
|
|
158
|
+
reactions: "reactions";
|
|
159
|
+
score: "score";
|
|
160
|
+
rating: "rating";
|
|
161
|
+
helpfulVotes: "helpfulVotes";
|
|
162
|
+
}> & z.core.$partial, z.ZodString>>;
|
|
163
|
+
missing: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
164
|
+
views: "views";
|
|
165
|
+
likes: "likes";
|
|
166
|
+
reposts: "reposts";
|
|
167
|
+
replies: "replies";
|
|
168
|
+
bookmarks: "bookmarks";
|
|
169
|
+
points: "points";
|
|
170
|
+
comments: "comments";
|
|
171
|
+
reactions: "reactions";
|
|
172
|
+
score: "score";
|
|
173
|
+
rating: "rating";
|
|
174
|
+
helpfulVotes: "helpfulVotes";
|
|
175
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
176
|
+
not_exposed: "not_exposed";
|
|
177
|
+
hidden: "hidden";
|
|
178
|
+
blocked: "blocked";
|
|
179
|
+
}>>>;
|
|
180
|
+
transport: z.ZodOptional<z.ZodString>;
|
|
181
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
182
|
+
rawRef: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
/** Unrefined shape of `Observation`, for consumers that need `.extend()`, `.pick()` or `.partial()`. */
|
|
185
|
+
declare const Observation: z.ZodObject<{
|
|
186
|
+
itemId: z.ZodString;
|
|
187
|
+
measuredAt: z.ZodISODateTime;
|
|
188
|
+
metrics: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
189
|
+
views: "views";
|
|
190
|
+
likes: "likes";
|
|
191
|
+
reposts: "reposts";
|
|
192
|
+
replies: "replies";
|
|
193
|
+
bookmarks: "bookmarks";
|
|
194
|
+
points: "points";
|
|
195
|
+
comments: "comments";
|
|
196
|
+
reactions: "reactions";
|
|
197
|
+
score: "score";
|
|
198
|
+
rating: "rating";
|
|
199
|
+
helpfulVotes: "helpfulVotes";
|
|
200
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
201
|
+
partMetrics: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
202
|
+
views: "views";
|
|
203
|
+
likes: "likes";
|
|
204
|
+
reposts: "reposts";
|
|
205
|
+
replies: "replies";
|
|
206
|
+
bookmarks: "bookmarks";
|
|
207
|
+
points: "points";
|
|
208
|
+
comments: "comments";
|
|
209
|
+
reactions: "reactions";
|
|
210
|
+
score: "score";
|
|
211
|
+
rating: "rating";
|
|
212
|
+
helpfulVotes: "helpfulVotes";
|
|
213
|
+
}> & z.core.$partial, z.ZodNumber>>>;
|
|
214
|
+
rawValues: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
215
|
+
views: "views";
|
|
216
|
+
likes: "likes";
|
|
217
|
+
reposts: "reposts";
|
|
218
|
+
replies: "replies";
|
|
219
|
+
bookmarks: "bookmarks";
|
|
220
|
+
points: "points";
|
|
221
|
+
comments: "comments";
|
|
222
|
+
reactions: "reactions";
|
|
223
|
+
score: "score";
|
|
224
|
+
rating: "rating";
|
|
225
|
+
helpfulVotes: "helpfulVotes";
|
|
226
|
+
}> & z.core.$partial, z.ZodString>>;
|
|
227
|
+
missing: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
228
|
+
views: "views";
|
|
229
|
+
likes: "likes";
|
|
230
|
+
reposts: "reposts";
|
|
231
|
+
replies: "replies";
|
|
232
|
+
bookmarks: "bookmarks";
|
|
233
|
+
points: "points";
|
|
234
|
+
comments: "comments";
|
|
235
|
+
reactions: "reactions";
|
|
236
|
+
score: "score";
|
|
237
|
+
rating: "rating";
|
|
238
|
+
helpfulVotes: "helpfulVotes";
|
|
239
|
+
}> & z.core.$partial, z.ZodEnum<{
|
|
240
|
+
not_exposed: "not_exposed";
|
|
241
|
+
hidden: "hidden";
|
|
242
|
+
blocked: "blocked";
|
|
243
|
+
}>>>;
|
|
244
|
+
transport: z.ZodOptional<z.ZodString>;
|
|
245
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
246
|
+
rawRef: z.ZodOptional<z.ZodString>;
|
|
247
|
+
}, z.core.$strip>;
|
|
248
|
+
type Observation = z.infer<typeof Observation>;
|
|
249
|
+
declare const AudienceKind: z.ZodEnum<{
|
|
250
|
+
followers: "followers";
|
|
251
|
+
karma: "karma";
|
|
252
|
+
subscribers: "subscribers";
|
|
253
|
+
}>;
|
|
254
|
+
type AudienceKind = z.infer<typeof AudienceKind>;
|
|
255
|
+
declare const AudienceUnknownReason: z.ZodEnum<{
|
|
256
|
+
not_exposed: "not_exposed";
|
|
257
|
+
blocked: "blocked";
|
|
258
|
+
not_fetched: "not_fetched";
|
|
259
|
+
}>;
|
|
260
|
+
type AudienceUnknownReason = z.infer<typeof AudienceUnknownReason>;
|
|
261
|
+
/** One reading of an audience figure. Either `value` is known or `unknown` says why not. */
|
|
262
|
+
declare const AudienceReading: z.ZodObject<{
|
|
263
|
+
measuredAt: z.ZodISODateTime;
|
|
264
|
+
kind: z.ZodEnum<{
|
|
265
|
+
followers: "followers";
|
|
266
|
+
karma: "karma";
|
|
267
|
+
subscribers: "subscribers";
|
|
268
|
+
}>;
|
|
269
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
rawValue: z.ZodOptional<z.ZodString>;
|
|
271
|
+
unknown: z.ZodOptional<z.ZodEnum<{
|
|
272
|
+
not_exposed: "not_exposed";
|
|
273
|
+
blocked: "blocked";
|
|
274
|
+
not_fetched: "not_fetched";
|
|
275
|
+
}>>;
|
|
276
|
+
}, z.core.$strip>;
|
|
277
|
+
type AudienceReading = z.infer<typeof AudienceReading>;
|
|
278
|
+
declare const Actor: z.ZodObject<{
|
|
279
|
+
ref: z.ZodString;
|
|
280
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
281
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
282
|
+
profileUrl: z.ZodOptional<z.ZodString>;
|
|
283
|
+
accountCreatedAt: z.ZodOptional<z.ZodUnion<readonly [z.ZodISODate, z.ZodISODateTime]>>;
|
|
284
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
285
|
+
audience: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
286
|
+
measuredAt: z.ZodISODateTime;
|
|
287
|
+
kind: z.ZodEnum<{
|
|
288
|
+
followers: "followers";
|
|
289
|
+
karma: "karma";
|
|
290
|
+
subscribers: "subscribers";
|
|
291
|
+
}>;
|
|
292
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
293
|
+
rawValue: z.ZodOptional<z.ZodString>;
|
|
294
|
+
unknown: z.ZodOptional<z.ZodEnum<{
|
|
295
|
+
not_exposed: "not_exposed";
|
|
296
|
+
blocked: "blocked";
|
|
297
|
+
not_fetched: "not_fetched";
|
|
298
|
+
}>>;
|
|
299
|
+
}, z.core.$strip>>>;
|
|
300
|
+
}, z.core.$strip>;
|
|
301
|
+
type Actor = z.infer<typeof Actor>;
|
|
302
|
+
declare const PickupKind: z.ZodEnum<{
|
|
303
|
+
media_pickup: "media_pickup";
|
|
304
|
+
crosspost: "crosspost";
|
|
305
|
+
media_publication: "media_publication";
|
|
306
|
+
}>;
|
|
307
|
+
type PickupKind = z.infer<typeof PickupKind>;
|
|
308
|
+
declare const PickupMethod: z.ZodEnum<{
|
|
309
|
+
link: "link";
|
|
310
|
+
content_id: "content_id";
|
|
311
|
+
near_text: "near_text";
|
|
312
|
+
declared: "declared";
|
|
313
|
+
legacy_flag: "legacy_flag";
|
|
314
|
+
}>;
|
|
315
|
+
type PickupMethod = z.infer<typeof PickupMethod>;
|
|
316
|
+
/** Methods whose evidence is exact, so the pickup counts as verified. */
|
|
317
|
+
declare const VERIFIED_PICKUP_METHODS: readonly PickupMethod[];
|
|
318
|
+
declare const PickupBase: z.ZodObject<{
|
|
319
|
+
itemId: z.ZodString;
|
|
320
|
+
kind: z.ZodEnum<{
|
|
321
|
+
media_pickup: "media_pickup";
|
|
322
|
+
crosspost: "crosspost";
|
|
323
|
+
media_publication: "media_publication";
|
|
324
|
+
}>;
|
|
325
|
+
pickupItemId: z.ZodOptional<z.ZodString>;
|
|
326
|
+
pickupUrl: z.ZodOptional<z.ZodString>;
|
|
327
|
+
outlet: z.ZodOptional<z.ZodString>;
|
|
328
|
+
relation: z.ZodEnum<{
|
|
329
|
+
republication: "republication";
|
|
330
|
+
citation: "citation";
|
|
331
|
+
}>;
|
|
332
|
+
evidence: z.ZodObject<{
|
|
333
|
+
outboundLink: z.ZodOptional<z.ZodString>;
|
|
334
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
335
|
+
similarity: z.ZodOptional<z.ZodNumber>;
|
|
336
|
+
rawRef: z.ZodOptional<z.ZodString>;
|
|
337
|
+
}, z.core.$strip>;
|
|
338
|
+
method: z.ZodEnum<{
|
|
339
|
+
link: "link";
|
|
340
|
+
content_id: "content_id";
|
|
341
|
+
near_text: "near_text";
|
|
342
|
+
declared: "declared";
|
|
343
|
+
legacy_flag: "legacy_flag";
|
|
344
|
+
}>;
|
|
345
|
+
verified: z.ZodBoolean;
|
|
346
|
+
firstSeenAt: z.ZodISODateTime;
|
|
347
|
+
measuredAt: z.ZodISODateTime;
|
|
348
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
349
|
+
}, z.core.$strip>;
|
|
350
|
+
/** Unrefined shape of `Pickup`, for consumers that need `.extend()`, `.pick()` or `.partial()`. */
|
|
351
|
+
declare const Pickup: z.ZodObject<{
|
|
352
|
+
itemId: z.ZodString;
|
|
353
|
+
kind: z.ZodEnum<{
|
|
354
|
+
media_pickup: "media_pickup";
|
|
355
|
+
crosspost: "crosspost";
|
|
356
|
+
media_publication: "media_publication";
|
|
357
|
+
}>;
|
|
358
|
+
pickupItemId: z.ZodOptional<z.ZodString>;
|
|
359
|
+
pickupUrl: z.ZodOptional<z.ZodString>;
|
|
360
|
+
outlet: z.ZodOptional<z.ZodString>;
|
|
361
|
+
relation: z.ZodEnum<{
|
|
362
|
+
republication: "republication";
|
|
363
|
+
citation: "citation";
|
|
364
|
+
}>;
|
|
365
|
+
evidence: z.ZodObject<{
|
|
366
|
+
outboundLink: z.ZodOptional<z.ZodString>;
|
|
367
|
+
excerpt: z.ZodOptional<z.ZodString>;
|
|
368
|
+
similarity: z.ZodOptional<z.ZodNumber>;
|
|
369
|
+
rawRef: z.ZodOptional<z.ZodString>;
|
|
370
|
+
}, z.core.$strip>;
|
|
371
|
+
method: z.ZodEnum<{
|
|
372
|
+
link: "link";
|
|
373
|
+
content_id: "content_id";
|
|
374
|
+
near_text: "near_text";
|
|
375
|
+
declared: "declared";
|
|
376
|
+
legacy_flag: "legacy_flag";
|
|
377
|
+
}>;
|
|
378
|
+
verified: z.ZodBoolean;
|
|
379
|
+
firstSeenAt: z.ZodISODateTime;
|
|
380
|
+
measuredAt: z.ZodISODateTime;
|
|
381
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
type Pickup = z.infer<typeof Pickup>;
|
|
384
|
+
declare const Recipe: z.ZodObject<{
|
|
385
|
+
name: z.ZodOptional<z.ZodString>;
|
|
386
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
387
|
+
connector: z.ZodString;
|
|
388
|
+
instance: z.ZodOptional<z.ZodString>;
|
|
389
|
+
queries: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
390
|
+
text: z.ZodString;
|
|
391
|
+
subject: z.ZodString;
|
|
392
|
+
}, z.core.$strip>>>;
|
|
393
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
394
|
+
}, z.core.$strip>>;
|
|
395
|
+
window: z.ZodOptional<z.ZodObject<{
|
|
396
|
+
from: z.ZodOptional<z.ZodISODateTime>;
|
|
397
|
+
to: z.ZodOptional<z.ZodISODateTime>;
|
|
398
|
+
}, z.core.$strip>>;
|
|
399
|
+
sampling: z.ZodOptional<z.ZodObject<{
|
|
400
|
+
bands: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
401
|
+
metric: z.ZodEnum<{
|
|
402
|
+
views: "views";
|
|
403
|
+
likes: "likes";
|
|
404
|
+
reposts: "reposts";
|
|
405
|
+
replies: "replies";
|
|
406
|
+
bookmarks: "bookmarks";
|
|
407
|
+
points: "points";
|
|
408
|
+
comments: "comments";
|
|
409
|
+
reactions: "reactions";
|
|
410
|
+
score: "score";
|
|
411
|
+
rating: "rating";
|
|
412
|
+
helpfulVotes: "helpfulVotes";
|
|
413
|
+
}>;
|
|
414
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
415
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
416
|
+
}, z.core.$strip>>>;
|
|
417
|
+
perDomainCap: z.ZodOptional<z.ZodNumber>;
|
|
418
|
+
seed: z.ZodOptional<z.ZodNumber>;
|
|
419
|
+
}, z.core.$strip>>;
|
|
420
|
+
caps: z.ZodOptional<z.ZodObject<{
|
|
421
|
+
perConnector: z.ZodOptional<z.ZodNumber>;
|
|
422
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
423
|
+
}, z.core.$strip>>;
|
|
424
|
+
workers: z.ZodDefault<z.ZodNumber>;
|
|
425
|
+
sinks: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
426
|
+
}, z.core.$strip>;
|
|
427
|
+
type Recipe = z.infer<typeof Recipe>;
|
|
428
|
+
declare const FailureCause: z.ZodEnum<{
|
|
429
|
+
blocked: "blocked";
|
|
430
|
+
empty: "empty";
|
|
431
|
+
network: "network";
|
|
432
|
+
parse: "parse";
|
|
433
|
+
other: "other";
|
|
434
|
+
}>;
|
|
435
|
+
type FailureCause = z.infer<typeof FailureCause>;
|
|
436
|
+
/** Every `with*` field and `eligible` is a count of items; shares are computed by the reader. */
|
|
437
|
+
declare const CoverageCell: z.ZodObject<{
|
|
438
|
+
platform: z.ZodString;
|
|
439
|
+
format: z.ZodString;
|
|
440
|
+
language: z.ZodString;
|
|
441
|
+
subject: z.ZodString;
|
|
442
|
+
items: z.ZodNumber;
|
|
443
|
+
withAuthorAudience: z.ZodNumber;
|
|
444
|
+
withPrimaryMetric: z.ZodNumber;
|
|
445
|
+
withAge: z.ZodNumber;
|
|
446
|
+
withAuthorId: z.ZodNumber;
|
|
447
|
+
withUniqueContent: z.ZodNumber;
|
|
448
|
+
eligible: z.ZodNumber;
|
|
449
|
+
}, z.core.$strip>;
|
|
450
|
+
type CoverageCell = z.infer<typeof CoverageCell>;
|
|
451
|
+
declare const Coverage: z.ZodObject<{
|
|
452
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
453
|
+
platform: z.ZodString;
|
|
454
|
+
format: z.ZodString;
|
|
455
|
+
language: z.ZodString;
|
|
456
|
+
subject: z.ZodString;
|
|
457
|
+
items: z.ZodNumber;
|
|
458
|
+
withAuthorAudience: z.ZodNumber;
|
|
459
|
+
withPrimaryMetric: z.ZodNumber;
|
|
460
|
+
withAge: z.ZodNumber;
|
|
461
|
+
withAuthorId: z.ZodNumber;
|
|
462
|
+
withUniqueContent: z.ZodNumber;
|
|
463
|
+
eligible: z.ZodNumber;
|
|
464
|
+
}, z.core.$strip>>;
|
|
465
|
+
}, z.core.$strip>;
|
|
466
|
+
type Coverage = z.infer<typeof Coverage>;
|
|
467
|
+
declare const ConnectorReport: z.ZodObject<{
|
|
468
|
+
connector: z.ZodString;
|
|
469
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
470
|
+
ok: "ok";
|
|
471
|
+
partial: "partial";
|
|
472
|
+
failed: "failed";
|
|
473
|
+
skipped: "skipped";
|
|
474
|
+
}>>;
|
|
475
|
+
skippedReason: z.ZodOptional<z.ZodString>;
|
|
476
|
+
tasks: z.ZodObject<{
|
|
477
|
+
planned: z.ZodNumber;
|
|
478
|
+
done: z.ZodNumber;
|
|
479
|
+
failed: z.ZodNumber;
|
|
480
|
+
skipped: z.ZodNumber;
|
|
481
|
+
}, z.core.$strip>;
|
|
482
|
+
newItems: z.ZodNumber;
|
|
483
|
+
observations: z.ZodNumber;
|
|
484
|
+
duplicates: z.ZodNumber;
|
|
485
|
+
failures: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
486
|
+
blocked: "blocked";
|
|
487
|
+
empty: "empty";
|
|
488
|
+
network: "network";
|
|
489
|
+
parse: "parse";
|
|
490
|
+
other: "other";
|
|
491
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
492
|
+
escalations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
493
|
+
from: z.ZodString;
|
|
494
|
+
to: z.ZodString;
|
|
495
|
+
count: z.ZodNumber;
|
|
496
|
+
}, z.core.$strip>>>;
|
|
497
|
+
durationMs: z.ZodNumber;
|
|
498
|
+
coverage: z.ZodOptional<z.ZodObject<{
|
|
499
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
500
|
+
platform: z.ZodString;
|
|
501
|
+
format: z.ZodString;
|
|
502
|
+
language: z.ZodString;
|
|
503
|
+
subject: z.ZodString;
|
|
504
|
+
items: z.ZodNumber;
|
|
505
|
+
withAuthorAudience: z.ZodNumber;
|
|
506
|
+
withPrimaryMetric: z.ZodNumber;
|
|
507
|
+
withAge: z.ZodNumber;
|
|
508
|
+
withAuthorId: z.ZodNumber;
|
|
509
|
+
withUniqueContent: z.ZodNumber;
|
|
510
|
+
eligible: z.ZodNumber;
|
|
511
|
+
}, z.core.$strip>>;
|
|
512
|
+
}, z.core.$strip>>;
|
|
513
|
+
}, z.core.$strip>;
|
|
514
|
+
type ConnectorReport = z.infer<typeof ConnectorReport>;
|
|
515
|
+
declare const RunReport: z.ZodObject<{
|
|
516
|
+
runId: z.ZodString;
|
|
517
|
+
startedAt: z.ZodISODateTime;
|
|
518
|
+
finishedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
519
|
+
connectors: z.ZodArray<z.ZodObject<{
|
|
520
|
+
connector: z.ZodString;
|
|
521
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
522
|
+
ok: "ok";
|
|
523
|
+
partial: "partial";
|
|
524
|
+
failed: "failed";
|
|
525
|
+
skipped: "skipped";
|
|
526
|
+
}>>;
|
|
527
|
+
skippedReason: z.ZodOptional<z.ZodString>;
|
|
528
|
+
tasks: z.ZodObject<{
|
|
529
|
+
planned: z.ZodNumber;
|
|
530
|
+
done: z.ZodNumber;
|
|
531
|
+
failed: z.ZodNumber;
|
|
532
|
+
skipped: z.ZodNumber;
|
|
533
|
+
}, z.core.$strip>;
|
|
534
|
+
newItems: z.ZodNumber;
|
|
535
|
+
observations: z.ZodNumber;
|
|
536
|
+
duplicates: z.ZodNumber;
|
|
537
|
+
failures: z.ZodDefault<z.ZodRecord<z.ZodEnum<{
|
|
538
|
+
blocked: "blocked";
|
|
539
|
+
empty: "empty";
|
|
540
|
+
network: "network";
|
|
541
|
+
parse: "parse";
|
|
542
|
+
other: "other";
|
|
543
|
+
}> & z.core.$partial, z.ZodNumber>>;
|
|
544
|
+
escalations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
545
|
+
from: z.ZodString;
|
|
546
|
+
to: z.ZodString;
|
|
547
|
+
count: z.ZodNumber;
|
|
548
|
+
}, z.core.$strip>>>;
|
|
549
|
+
durationMs: z.ZodNumber;
|
|
550
|
+
coverage: z.ZodOptional<z.ZodObject<{
|
|
551
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
552
|
+
platform: z.ZodString;
|
|
553
|
+
format: z.ZodString;
|
|
554
|
+
language: z.ZodString;
|
|
555
|
+
subject: z.ZodString;
|
|
556
|
+
items: z.ZodNumber;
|
|
557
|
+
withAuthorAudience: z.ZodNumber;
|
|
558
|
+
withPrimaryMetric: z.ZodNumber;
|
|
559
|
+
withAge: z.ZodNumber;
|
|
560
|
+
withAuthorId: z.ZodNumber;
|
|
561
|
+
withUniqueContent: z.ZodNumber;
|
|
562
|
+
eligible: z.ZodNumber;
|
|
563
|
+
}, z.core.$strip>>;
|
|
564
|
+
}, z.core.$strip>>;
|
|
565
|
+
}, z.core.$strip>>;
|
|
566
|
+
coverage: z.ZodOptional<z.ZodObject<{
|
|
567
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
568
|
+
platform: z.ZodString;
|
|
569
|
+
format: z.ZodString;
|
|
570
|
+
language: z.ZodString;
|
|
571
|
+
subject: z.ZodString;
|
|
572
|
+
items: z.ZodNumber;
|
|
573
|
+
withAuthorAudience: z.ZodNumber;
|
|
574
|
+
withPrimaryMetric: z.ZodNumber;
|
|
575
|
+
withAge: z.ZodNumber;
|
|
576
|
+
withAuthorId: z.ZodNumber;
|
|
577
|
+
withUniqueContent: z.ZodNumber;
|
|
578
|
+
eligible: z.ZodNumber;
|
|
579
|
+
}, z.core.$strip>>;
|
|
580
|
+
}, z.core.$strip>>;
|
|
581
|
+
}, z.core.$strip>;
|
|
582
|
+
type RunReport = z.infer<typeof RunReport>;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Stable ids, URL canonicalisation and text fingerprints.
|
|
586
|
+
*
|
|
587
|
+
* Hashing uses Web Crypto (`crypto.subtle`, async), which exists in Node 20+,
|
|
588
|
+
* browsers and edge runtimes. No Node built-in is imported.
|
|
589
|
+
*/
|
|
590
|
+
/**
|
|
591
|
+
* Clean an http(s) URL into a dedup key: lowercase scheme and host (the path
|
|
592
|
+
* keeps its case), no credentials, no fragment, no default port, tracking
|
|
593
|
+
* parameters removed, remaining parameters ordered by key only (the relative
|
|
594
|
+
* order of a repeated key is kept, so `?a=2&a=1` differs from `?a=1&a=2`), no
|
|
595
|
+
* trailing slash (root included, so `/a/` and `/a` are the same key, and
|
|
596
|
+
* `https://example.com/?a=1` becomes `https://example.com?a=1`).
|
|
597
|
+
*
|
|
598
|
+
* The result is only a key for deduplication: the original URL is always
|
|
599
|
+
* kept next to it. Callers pass the final URL; redirects are not followed
|
|
600
|
+
* here, so a known redirect target must be resolved before calling.
|
|
601
|
+
*
|
|
602
|
+
* Any non-http(s) scheme (`mailto:`, `urn:`, `data:`, ...) and any input that
|
|
603
|
+
* is not an absolute URL is returned trimmed and otherwise unchanged.
|
|
604
|
+
*/
|
|
605
|
+
declare function canonicalUrl(input: string): string;
|
|
606
|
+
/** SHA-256 of a UTF-8 string, lowercase hex. */
|
|
607
|
+
declare function sha256Hex(text: string): Promise<string>;
|
|
608
|
+
/**
|
|
609
|
+
* Id of an item that has a platform id: `source:nativeId`. Strings are used
|
|
610
|
+
* as given; a number must be a safe integer (larger ids lose digits, so pass
|
|
611
|
+
* them as strings) or this throws.
|
|
612
|
+
*/
|
|
613
|
+
declare function itemId(source: string, nativeId: string | number): string;
|
|
614
|
+
/** Id of an item without a platform id: `source:` plus a hash of its canonical URL. */
|
|
615
|
+
declare function itemIdFromUrl(source: string, url: string): Promise<string>;
|
|
616
|
+
/** Text reduced to lowercase words separated by single spaces. */
|
|
617
|
+
declare function normalizeText(text: string): string;
|
|
618
|
+
/**
|
|
619
|
+
* Exact-content id: SHA-256 of the normalised text. Same words, same
|
|
620
|
+
* fingerprint. Text that normalises to nothing (empty, only punctuation or
|
|
621
|
+
* symbols) has no content id: returns `undefined`, so unrelated empty items
|
|
622
|
+
* never share one.
|
|
623
|
+
*/
|
|
624
|
+
declare function textFingerprint(text: string): Promise<string | undefined>;
|
|
625
|
+
|
|
626
|
+
/** Version written to `collect.json` at a store root. Bump on any change to the stored shapes. */
|
|
627
|
+
declare const STORE_SCHEMA_VERSION = 1;
|
|
628
|
+
|
|
629
|
+
export { Actor, AudienceKind, AudienceReading, AudienceUnknownReason, CollectItem, ConnectorReport, Coverage, CoverageCell, FailureCause, ItemKind, ItemLinks, ItemPart, MetricName, MissingReason, Observation, ObservationBase, Pickup, PickupBase, PickupKind, PickupMethod, Recipe, RunReport, STORE_SCHEMA_VERSION, Subject, VERIFIED_PICKUP_METHODS, canonicalUrl, itemId, itemIdFromUrl, normalizeText, sha256Hex, textFingerprint };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentproto/collect
|
|
5
|
+
* Schemas, ids, URL canonicalisation and text fingerprints for collected public content.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var timestamp = z.iso.datetime({ offset: true });
|
|
9
|
+
var dateOrTimestamp = z.union([z.iso.date(), z.iso.datetime({ offset: true })]);
|
|
10
|
+
var ItemKind = z.enum(["article", "post", "thread", "submission", "review", "video", "query"]);
|
|
11
|
+
var MissingReason = z.enum(["not_exposed", "hidden", "blocked"]);
|
|
12
|
+
var MetricName = z.enum([
|
|
13
|
+
"views",
|
|
14
|
+
"likes",
|
|
15
|
+
"reposts",
|
|
16
|
+
"replies",
|
|
17
|
+
"bookmarks",
|
|
18
|
+
"points",
|
|
19
|
+
"comments",
|
|
20
|
+
"reactions",
|
|
21
|
+
"score",
|
|
22
|
+
"rating",
|
|
23
|
+
"helpfulVotes"
|
|
24
|
+
]);
|
|
25
|
+
var Subject = z.object({
|
|
26
|
+
label: z.string().min(1),
|
|
27
|
+
provenance: z.enum(["query", "source_tag", "classifier"]),
|
|
28
|
+
classifier: z.object({ name: z.string().min(1), version: z.string().min(1) }).optional()
|
|
29
|
+
});
|
|
30
|
+
var ItemLinks = z.object({
|
|
31
|
+
target: z.string().optional(),
|
|
32
|
+
parent: z.string().optional(),
|
|
33
|
+
root: z.string().optional(),
|
|
34
|
+
quoted: z.string().optional()
|
|
35
|
+
});
|
|
36
|
+
var ItemPart = z.object({
|
|
37
|
+
id: z.string().min(1),
|
|
38
|
+
text: z.string(),
|
|
39
|
+
authorRef: z.string().optional(),
|
|
40
|
+
// A bare day is accepted: some platforms only display the date of a post.
|
|
41
|
+
postedAt: dateOrTimestamp.optional()
|
|
42
|
+
});
|
|
43
|
+
var CollectItem = z.object({
|
|
44
|
+
id: z.string().min(1),
|
|
45
|
+
source: z.string().min(1),
|
|
46
|
+
sourceInstance: z.string().optional(),
|
|
47
|
+
kind: ItemKind,
|
|
48
|
+
url: z.string().optional(),
|
|
49
|
+
canonicalUrl: z.string().optional(),
|
|
50
|
+
contentId: z.string().optional(),
|
|
51
|
+
contentGroupId: z.string().optional(),
|
|
52
|
+
subjects: z.array(Subject).default([]),
|
|
53
|
+
title: z.string().optional(),
|
|
54
|
+
text: z.string().optional(),
|
|
55
|
+
textTruncated: z.boolean().optional(),
|
|
56
|
+
language: z.string().optional(),
|
|
57
|
+
wordCount: z.number().int().nonnegative().optional(),
|
|
58
|
+
format: z.string().optional(),
|
|
59
|
+
authorRef: z.string().optional(),
|
|
60
|
+
submitterRef: z.string().optional(),
|
|
61
|
+
publishedAt: dateOrTimestamp.optional(),
|
|
62
|
+
// A bare day is accepted: some platforms only display the date of a post.
|
|
63
|
+
postedAt: dateOrTimestamp.optional(),
|
|
64
|
+
firstSeenAt: timestamp,
|
|
65
|
+
links: ItemLinks.optional(),
|
|
66
|
+
outboundLinks: z.array(z.string()).optional(),
|
|
67
|
+
parts: z.array(ItemPart).optional(),
|
|
68
|
+
tags: z.array(z.string()).optional(),
|
|
69
|
+
hasMedia: z.boolean().optional(),
|
|
70
|
+
query: z.string().optional(),
|
|
71
|
+
runId: z.string().optional(),
|
|
72
|
+
rawRefs: z.array(z.string()).optional(),
|
|
73
|
+
ext: z.record(z.string(), z.unknown()).optional()
|
|
74
|
+
});
|
|
75
|
+
var metricValues = z.partialRecord(MetricName, z.number());
|
|
76
|
+
var ObservationBase = z.object({
|
|
77
|
+
itemId: z.string().min(1),
|
|
78
|
+
measuredAt: timestamp,
|
|
79
|
+
metrics: metricValues.default({}),
|
|
80
|
+
partMetrics: z.record(z.string(), metricValues).optional(),
|
|
81
|
+
rawValues: z.partialRecord(MetricName, z.string()).optional(),
|
|
82
|
+
missing: z.partialRecord(MetricName, MissingReason).optional(),
|
|
83
|
+
transport: z.string().optional(),
|
|
84
|
+
runId: z.string().optional(),
|
|
85
|
+
rawRef: z.string().optional()
|
|
86
|
+
});
|
|
87
|
+
var Observation = ObservationBase.superRefine((o, ctx) => {
|
|
88
|
+
for (const key of Object.keys(o.missing ?? {})) {
|
|
89
|
+
if (key in o.metrics) {
|
|
90
|
+
ctx.addIssue({
|
|
91
|
+
code: "custom",
|
|
92
|
+
path: ["missing", key],
|
|
93
|
+
message: `${key} is both a metric and missing`
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
for (const key of Object.keys(o.rawValues ?? {})) {
|
|
98
|
+
if (!(key in o.metrics)) {
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
path: ["rawValues", key],
|
|
102
|
+
message: `${key} has a raw value but no metric`
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
var AudienceKind = z.enum(["followers", "karma", "subscribers"]);
|
|
108
|
+
var AudienceUnknownReason = z.enum(["not_exposed", "not_fetched", "blocked"]);
|
|
109
|
+
var AudienceReading = z.object({
|
|
110
|
+
measuredAt: timestamp,
|
|
111
|
+
kind: AudienceKind,
|
|
112
|
+
value: z.number().nonnegative().optional(),
|
|
113
|
+
rawValue: z.string().optional(),
|
|
114
|
+
unknown: AudienceUnknownReason.optional()
|
|
115
|
+
}).refine((r) => r.value === void 0 !== (r.unknown === void 0), {
|
|
116
|
+
message: "an audience reading has either a value or an unknown reason"
|
|
117
|
+
});
|
|
118
|
+
var Actor = z.object({
|
|
119
|
+
ref: z.string().min(1),
|
|
120
|
+
displayName: z.string().optional(),
|
|
121
|
+
handle: z.string().optional(),
|
|
122
|
+
profileUrl: z.string().optional(),
|
|
123
|
+
accountCreatedAt: dateOrTimestamp.optional(),
|
|
124
|
+
verified: z.boolean().optional(),
|
|
125
|
+
audience: z.array(AudienceReading).default([])
|
|
126
|
+
});
|
|
127
|
+
var PickupKind = z.enum(["media_pickup", "crosspost", "media_publication"]);
|
|
128
|
+
var PickupMethod = z.enum(["link", "content_id", "near_text", "declared", "legacy_flag"]);
|
|
129
|
+
var VERIFIED_PICKUP_METHODS = ["link", "content_id", "declared"];
|
|
130
|
+
var PickupBase = z.object({
|
|
131
|
+
itemId: z.string().min(1),
|
|
132
|
+
kind: PickupKind,
|
|
133
|
+
pickupItemId: z.string().optional(),
|
|
134
|
+
pickupUrl: z.string().optional(),
|
|
135
|
+
outlet: z.string().optional(),
|
|
136
|
+
relation: z.enum(["republication", "citation"]),
|
|
137
|
+
evidence: z.object({
|
|
138
|
+
outboundLink: z.string().optional(),
|
|
139
|
+
excerpt: z.string().optional(),
|
|
140
|
+
similarity: z.number().min(0).max(1).optional(),
|
|
141
|
+
rawRef: z.string().optional()
|
|
142
|
+
}),
|
|
143
|
+
method: PickupMethod,
|
|
144
|
+
verified: z.boolean(),
|
|
145
|
+
firstSeenAt: timestamp,
|
|
146
|
+
measuredAt: timestamp,
|
|
147
|
+
runId: z.string().optional()
|
|
148
|
+
});
|
|
149
|
+
var Pickup = PickupBase.superRefine((p, ctx) => {
|
|
150
|
+
if (p.verified !== VERIFIED_PICKUP_METHODS.includes(p.method)) {
|
|
151
|
+
ctx.addIssue({
|
|
152
|
+
code: "custom",
|
|
153
|
+
path: ["verified"],
|
|
154
|
+
message: "verified must be true exactly for link, content_id and declared methods"
|
|
155
|
+
});
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const e = p.evidence;
|
|
159
|
+
const hasEvidence = e.outboundLink !== void 0 || e.excerpt !== void 0 || e.similarity !== void 0;
|
|
160
|
+
if (p.method === "link" || p.method === "content_id") {
|
|
161
|
+
if (!hasEvidence) {
|
|
162
|
+
ctx.addIssue({ code: "custom", path: ["evidence"], message: `${p.method} pickup needs evidence` });
|
|
163
|
+
}
|
|
164
|
+
if (!e.rawRef) {
|
|
165
|
+
ctx.addIssue({
|
|
166
|
+
code: "custom",
|
|
167
|
+
path: ["evidence", "rawRef"],
|
|
168
|
+
message: `${p.method} pickup needs evidence.rawRef`
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
} else if (p.method === "declared") {
|
|
172
|
+
if (e.outboundLink === void 0 && e.excerpt === void 0 && !p.outlet) {
|
|
173
|
+
ctx.addIssue({
|
|
174
|
+
code: "custom",
|
|
175
|
+
path: ["evidence"],
|
|
176
|
+
message: "declared pickup needs an excerpt, an outbound link or an outlet"
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
var Recipe = z.object({
|
|
182
|
+
name: z.string().optional(),
|
|
183
|
+
sources: z.array(
|
|
184
|
+
z.object({
|
|
185
|
+
connector: z.string().min(1),
|
|
186
|
+
instance: z.string().optional(),
|
|
187
|
+
queries: z.array(
|
|
188
|
+
z.object({
|
|
189
|
+
text: z.string().min(1),
|
|
190
|
+
subject: z.string().min(1)
|
|
191
|
+
})
|
|
192
|
+
).default([]),
|
|
193
|
+
options: z.record(z.string(), z.unknown()).optional()
|
|
194
|
+
})
|
|
195
|
+
).min(1),
|
|
196
|
+
window: z.object({ from: timestamp.optional(), to: timestamp.optional() }).optional(),
|
|
197
|
+
sampling: z.object({
|
|
198
|
+
bands: z.array(
|
|
199
|
+
z.object({
|
|
200
|
+
metric: MetricName,
|
|
201
|
+
min: z.number().optional(),
|
|
202
|
+
max: z.number().optional()
|
|
203
|
+
})
|
|
204
|
+
).optional(),
|
|
205
|
+
perDomainCap: z.number().int().positive().optional(),
|
|
206
|
+
seed: z.number().int().optional()
|
|
207
|
+
}).optional(),
|
|
208
|
+
caps: z.object({
|
|
209
|
+
perConnector: z.number().int().positive().optional(),
|
|
210
|
+
total: z.number().int().positive().optional()
|
|
211
|
+
}).optional(),
|
|
212
|
+
workers: z.number().int().positive().default(8),
|
|
213
|
+
sinks: z.array(z.string()).optional()
|
|
214
|
+
});
|
|
215
|
+
var FailureCause = z.enum(["blocked", "empty", "network", "parse", "other"]);
|
|
216
|
+
var CoverageCell = z.object({
|
|
217
|
+
platform: z.string(),
|
|
218
|
+
format: z.string(),
|
|
219
|
+
language: z.string(),
|
|
220
|
+
subject: z.string(),
|
|
221
|
+
items: z.number().int().nonnegative(),
|
|
222
|
+
/** At least one `followers` or `subscribers` reading. Karma is not counted here. */
|
|
223
|
+
withAuthorAudience: z.number().int().nonnegative(),
|
|
224
|
+
withPrimaryMetric: z.number().int().nonnegative(),
|
|
225
|
+
/** `postedAt` and `measuredAt` both present. */
|
|
226
|
+
withAge: z.number().int().nonnegative(),
|
|
227
|
+
withAuthorId: z.number().int().nonnegative(),
|
|
228
|
+
/** `contentId` shared with no other item. */
|
|
229
|
+
withUniqueContent: z.number().int().nonnegative(),
|
|
230
|
+
/** Audience, primary metric, age and author id all present. */
|
|
231
|
+
eligible: z.number().int().nonnegative()
|
|
232
|
+
});
|
|
233
|
+
var Coverage = z.object({ cells: z.array(CoverageCell) });
|
|
234
|
+
var ConnectorReport = z.object({
|
|
235
|
+
connector: z.string().min(1),
|
|
236
|
+
status: z.enum(["ok", "partial", "failed", "skipped"]).default("ok"),
|
|
237
|
+
skippedReason: z.string().optional(),
|
|
238
|
+
tasks: z.object({
|
|
239
|
+
planned: z.number().int().nonnegative(),
|
|
240
|
+
done: z.number().int().nonnegative(),
|
|
241
|
+
failed: z.number().int().nonnegative(),
|
|
242
|
+
skipped: z.number().int().nonnegative()
|
|
243
|
+
}),
|
|
244
|
+
newItems: z.number().int().nonnegative(),
|
|
245
|
+
observations: z.number().int().nonnegative(),
|
|
246
|
+
duplicates: z.number().int().nonnegative(),
|
|
247
|
+
failures: z.partialRecord(FailureCause, z.number().int().nonnegative()).default({}),
|
|
248
|
+
escalations: z.array(
|
|
249
|
+
z.object({
|
|
250
|
+
from: z.string(),
|
|
251
|
+
to: z.string(),
|
|
252
|
+
count: z.number().int().positive()
|
|
253
|
+
})
|
|
254
|
+
).default([]),
|
|
255
|
+
durationMs: z.number().nonnegative(),
|
|
256
|
+
coverage: Coverage.optional()
|
|
257
|
+
});
|
|
258
|
+
var RunReport = z.object({
|
|
259
|
+
runId: z.string().min(1),
|
|
260
|
+
startedAt: timestamp,
|
|
261
|
+
finishedAt: timestamp.optional(),
|
|
262
|
+
connectors: z.array(ConnectorReport),
|
|
263
|
+
coverage: Coverage.optional()
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// src/ids.ts
|
|
267
|
+
var TRACKING_PARAMS = /* @__PURE__ */ new Set([
|
|
268
|
+
"fbclid",
|
|
269
|
+
"gclid",
|
|
270
|
+
"dclid",
|
|
271
|
+
"gbraid",
|
|
272
|
+
"wbraid",
|
|
273
|
+
"msclkid",
|
|
274
|
+
"yclid",
|
|
275
|
+
"twclid",
|
|
276
|
+
"ttclid",
|
|
277
|
+
"mc_cid",
|
|
278
|
+
"mc_eid",
|
|
279
|
+
"ref_src",
|
|
280
|
+
"ref_url",
|
|
281
|
+
"igshid",
|
|
282
|
+
"_hsenc",
|
|
283
|
+
"_hsmi",
|
|
284
|
+
"mkt_tok"
|
|
285
|
+
]);
|
|
286
|
+
var DEFAULT_PORTS = {
|
|
287
|
+
"http:": "80",
|
|
288
|
+
"https:": "443"
|
|
289
|
+
};
|
|
290
|
+
var YOUTUBE_HOSTS = /* @__PURE__ */ new Set(["youtube.com", "youtu.be"]);
|
|
291
|
+
function isYoutubeHost(hostname) {
|
|
292
|
+
const host = hostname.toLowerCase().replace(/^(www|m|music)\./, "");
|
|
293
|
+
return YOUTUBE_HOSTS.has(host);
|
|
294
|
+
}
|
|
295
|
+
function isTrackingParam(name, hostname) {
|
|
296
|
+
const key = name.toLowerCase();
|
|
297
|
+
if (key === "si") return isYoutubeHost(hostname);
|
|
298
|
+
return key.startsWith("utm_") || TRACKING_PARAMS.has(key);
|
|
299
|
+
}
|
|
300
|
+
function canonicalUrl(input) {
|
|
301
|
+
const raw = input.trim();
|
|
302
|
+
let url;
|
|
303
|
+
try {
|
|
304
|
+
url = new URL(raw);
|
|
305
|
+
} catch {
|
|
306
|
+
return raw;
|
|
307
|
+
}
|
|
308
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") return raw;
|
|
309
|
+
url.hash = "";
|
|
310
|
+
url.username = "";
|
|
311
|
+
url.password = "";
|
|
312
|
+
if (DEFAULT_PORTS[url.protocol] === url.port) url.port = "";
|
|
313
|
+
const kept = [];
|
|
314
|
+
url.searchParams.forEach((value, name) => {
|
|
315
|
+
if (!isTrackingParam(name, url.hostname)) kept.push([name, value]);
|
|
316
|
+
});
|
|
317
|
+
kept.sort((a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
|
|
318
|
+
const query = new URLSearchParams(kept).toString();
|
|
319
|
+
const path = url.pathname.length > 1 ? url.pathname.replace(/\/+$/, "") : "";
|
|
320
|
+
return `${url.protocol}//${url.host}${path}${query ? `?${query}` : ""}`;
|
|
321
|
+
}
|
|
322
|
+
async function sha256Hex(text) {
|
|
323
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
|
|
324
|
+
return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
325
|
+
}
|
|
326
|
+
function itemId(source, nativeId) {
|
|
327
|
+
if (typeof nativeId === "number" && !Number.isSafeInteger(nativeId)) {
|
|
328
|
+
throw new RangeError(`native id ${nativeId} is not a safe integer; pass it as a string`);
|
|
329
|
+
}
|
|
330
|
+
return `${source}:${String(nativeId)}`;
|
|
331
|
+
}
|
|
332
|
+
async function itemIdFromUrl(source, url) {
|
|
333
|
+
return `${source}:${await sha256Hex(canonicalUrl(url))}`;
|
|
334
|
+
}
|
|
335
|
+
function normalizeText(text) {
|
|
336
|
+
return text.normalize("NFKC").toLowerCase().replace(/[\p{P}\p{S}]+/gu, " ").replace(/\s+/gu, " ").trim();
|
|
337
|
+
}
|
|
338
|
+
async function textFingerprint(text) {
|
|
339
|
+
const normalized = normalizeText(text);
|
|
340
|
+
return normalized === "" ? void 0 : sha256Hex(normalized);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// src/version.ts
|
|
344
|
+
var STORE_SCHEMA_VERSION = 1;
|
|
345
|
+
|
|
346
|
+
export { Actor, AudienceKind, AudienceReading, AudienceUnknownReason, CollectItem, ConnectorReport, Coverage, CoverageCell, FailureCause, ItemKind, ItemLinks, ItemPart, MetricName, MissingReason, Observation, ObservationBase, Pickup, PickupBase, PickupKind, PickupMethod, Recipe, RunReport, STORE_SCHEMA_VERSION, Subject, VERIFIED_PICKUP_METHODS, canonicalUrl, itemId, itemIdFromUrl, normalizeText, sha256Hex, textFingerprint };
|
|
347
|
+
//# sourceMappingURL=index.mjs.map
|
|
348
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas.ts","../src/ids.ts","../src/version.ts"],"names":[],"mappings":";;;;;;;AAGA,IAAM,YAAY,CAAA,CAAE,GAAA,CAAI,SAAS,EAAE,MAAA,EAAQ,MAAM,CAAA;A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,MAAM,CAAA,EAAG,CAAC,CAAA,KAAM,CAAA,CAAE,QAAA,CAAS,EAAE,EAAE,QAAA,CAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAE,KAAK,EAAE,CAAA;AAC3F;AAOO,SAAS,MAAA,CAAO,QAAgB,QAAA,EAAmC;AACxE,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,IAAY,CAAC,MAAA,CAAO,aAAA,CAAc,QAAQ,CAAA,EAAG;AACnE,IAAA,MAAM,IAAI,UAAA,CAAW,CAAA,UAAA,EAAa,QAAQ,CAAA,2CAAA,CAA6C,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,MAAA,CAAO,QAAQ,CAAC,CAAA,CAAA;AACtC;AAGA,eAAsB,aAAA,CAAc,QAAgB,GAAA,EAA8B;AAChF,EAAA,OAAO,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,MAAM,UAAU,YAAA,CAAa,GAAG,CAAC,CAAC,CAAA,CAAA;AACxD;AAGO,SAAS,cAAc,IAAA,EAAsB;AAClD,EAAA,OAAO,IAAA,CACJ,SAAA,CAAU,MAAM,CAAA,CAChB,aAAY,CACZ,OAAA,CAAQ,iBAAA,EAAmB,GAAG,CAAA,CAC9B,OAAA,CAAQ,OAAA,EAAS,GAAG,EACpB,IAAA,EAAK;AACV;AAQA,eAAsB,gBAAgB,IAAA,EAA2C;AAC/E,EAAA,MAAM,UAAA,GAAa,cAAc,IAAI,CAAA;AACrC,EAAA,OAAO,UAAA,KAAe,EAAA,GAAK,MAAA,GAAY,SAAA,CAAU,UAAU,CAAA;AAC7D;;;ACjIO,IAAM,oBAAA,GAAuB","file":"index.mjs","sourcesContent":["import { z } from \"zod\"\n\n/** Full timestamp with offset, e.g. 2026-11-28T10:00:00Z or 2026-11-28T10:00:00+01:00. */\nconst timestamp = z.iso.datetime({ offset: true })\n/** Editorial or platform date: a calendar day or a full timestamp. */\nconst dateOrTimestamp = z.union([z.iso.date(), z.iso.datetime({ offset: true })])\n\nexport const ItemKind = z.enum([\"article\", \"post\", \"thread\", \"submission\", \"review\", \"video\", \"query\"])\nexport type ItemKind = z.infer<typeof ItemKind>\n\nexport const MissingReason = z.enum([\"not_exposed\", \"hidden\", \"blocked\"])\nexport type MissingReason = z.infer<typeof MissingReason>\n\nexport const MetricName = z.enum([\n \"views\",\n \"likes\",\n \"reposts\",\n \"replies\",\n \"bookmarks\",\n \"points\",\n \"comments\",\n \"reactions\",\n \"score\",\n \"rating\",\n \"helpfulVotes\",\n])\nexport type MetricName = z.infer<typeof MetricName>\n\nexport const Subject = z.object({\n label: z.string().min(1),\n provenance: z.enum([\"query\", \"source_tag\", \"classifier\"]),\n classifier: z.object({ name: z.string().min(1), version: z.string().min(1) }).optional(),\n})\nexport type Subject = z.infer<typeof Subject>\n\nexport const ItemLinks = z.object({\n target: z.string().optional(),\n parent: z.string().optional(),\n root: z.string().optional(),\n quoted: z.string().optional(),\n})\nexport type ItemLinks = z.infer<typeof ItemLinks>\n\nexport const ItemPart = z.object({\n id: z.string().min(1),\n text: z.string(),\n authorRef: z.string().optional(),\n // A bare day is accepted: some platforms only display the date of a post.\n postedAt: dateOrTimestamp.optional(),\n})\nexport type ItemPart = z.infer<typeof ItemPart>\n\nexport const CollectItem = z.object({\n id: z.string().min(1),\n source: z.string().min(1),\n sourceInstance: z.string().optional(),\n kind: ItemKind,\n url: z.string().optional(),\n canonicalUrl: z.string().optional(),\n contentId: z.string().optional(),\n contentGroupId: z.string().optional(),\n subjects: z.array(Subject).default([]),\n title: z.string().optional(),\n text: z.string().optional(),\n textTruncated: z.boolean().optional(),\n language: z.string().optional(),\n wordCount: z.number().int().nonnegative().optional(),\n format: z.string().optional(),\n authorRef: z.string().optional(),\n submitterRef: z.string().optional(),\n publishedAt: dateOrTimestamp.optional(),\n // A bare day is accepted: some platforms only display the date of a post.\n postedAt: dateOrTimestamp.optional(),\n firstSeenAt: timestamp,\n links: ItemLinks.optional(),\n outboundLinks: z.array(z.string()).optional(),\n parts: z.array(ItemPart).optional(),\n tags: z.array(z.string()).optional(),\n hasMedia: z.boolean().optional(),\n query: z.string().optional(),\n runId: z.string().optional(),\n rawRefs: z.array(z.string()).optional(),\n ext: z.record(z.string(), z.unknown()).optional(),\n})\nexport type CollectItem = z.infer<typeof CollectItem>\n\n/** A counter is a number or absent. Absent is never read as zero: see `missing`. */\nconst metricValues = z.partialRecord(MetricName, z.number())\n\nexport const ObservationBase = z.object({\n itemId: z.string().min(1),\n measuredAt: timestamp,\n metrics: metricValues.default({}),\n partMetrics: z.record(z.string(), metricValues).optional(),\n rawValues: z.partialRecord(MetricName, z.string()).optional(),\n missing: z.partialRecord(MetricName, MissingReason).optional(),\n transport: z.string().optional(),\n runId: z.string().optional(),\n rawRef: z.string().optional(),\n})\n\n/** Unrefined shape of `Observation`, for consumers that need `.extend()`, `.pick()` or `.partial()`. */\nexport const Observation = ObservationBase.superRefine((o, ctx) => {\n for (const key of Object.keys(o.missing ?? {})) {\n if (key in o.metrics) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"missing\", key],\n message: `${key} is both a metric and missing`,\n })\n }\n }\n // A displayed value always belongs to a parsed number.\n for (const key of Object.keys(o.rawValues ?? {})) {\n if (!(key in o.metrics)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"rawValues\", key],\n message: `${key} has a raw value but no metric`,\n })\n }\n }\n})\nexport type Observation = z.infer<typeof Observation>\n\nexport const AudienceKind = z.enum([\"followers\", \"karma\", \"subscribers\"])\nexport type AudienceKind = z.infer<typeof AudienceKind>\n\nexport const AudienceUnknownReason = z.enum([\"not_exposed\", \"not_fetched\", \"blocked\"])\nexport type AudienceUnknownReason = z.infer<typeof AudienceUnknownReason>\n\n/** One reading of an audience figure. Either `value` is known or `unknown` says why not. */\nexport const AudienceReading = z\n .object({\n measuredAt: timestamp,\n kind: AudienceKind,\n value: z.number().nonnegative().optional(),\n rawValue: z.string().optional(),\n unknown: AudienceUnknownReason.optional(),\n })\n .refine((r) => (r.value === undefined) !== (r.unknown === undefined), {\n message: \"an audience reading has either a value or an unknown reason\",\n })\nexport type AudienceReading = z.infer<typeof AudienceReading>\n\nexport const Actor = z.object({\n ref: z.string().min(1),\n displayName: z.string().optional(),\n handle: z.string().optional(),\n profileUrl: z.string().optional(),\n accountCreatedAt: dateOrTimestamp.optional(),\n verified: z.boolean().optional(),\n audience: z.array(AudienceReading).default([]),\n})\nexport type Actor = z.infer<typeof Actor>\n\nexport const PickupKind = z.enum([\"media_pickup\", \"crosspost\", \"media_publication\"])\nexport type PickupKind = z.infer<typeof PickupKind>\nexport const PickupMethod = z.enum([\"link\", \"content_id\", \"near_text\", \"declared\", \"legacy_flag\"])\nexport type PickupMethod = z.infer<typeof PickupMethod>\n\n/** Methods whose evidence is exact, so the pickup counts as verified. */\nexport const VERIFIED_PICKUP_METHODS: readonly PickupMethod[] = [\"link\", \"content_id\", \"declared\"]\n\nexport const PickupBase = z.object({\n itemId: z.string().min(1),\n kind: PickupKind,\n pickupItemId: z.string().optional(),\n pickupUrl: z.string().optional(),\n outlet: z.string().optional(),\n relation: z.enum([\"republication\", \"citation\"]),\n evidence: z.object({\n outboundLink: z.string().optional(),\n excerpt: z.string().optional(),\n similarity: z.number().min(0).max(1).optional(),\n rawRef: z.string().optional(),\n }),\n method: PickupMethod,\n verified: z.boolean(),\n firstSeenAt: timestamp,\n measuredAt: timestamp,\n runId: z.string().optional(),\n})\n\n/** Unrefined shape of `Pickup`, for consumers that need `.extend()`, `.pick()` or `.partial()`. */\nexport const Pickup = PickupBase.superRefine((p, ctx) => {\n if (p.verified !== VERIFIED_PICKUP_METHODS.includes(p.method)) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"verified\"],\n message: \"verified must be true exactly for link, content_id and declared methods\",\n })\n return\n }\n const e = p.evidence\n const hasEvidence = e.outboundLink !== undefined || e.excerpt !== undefined || e.similarity !== undefined\n if (p.method === \"link\" || p.method === \"content_id\") {\n if (!hasEvidence) {\n ctx.addIssue({ code: \"custom\", path: [\"evidence\"], message: `${p.method} pickup needs evidence` })\n }\n if (!e.rawRef) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"evidence\", \"rawRef\"],\n message: `${p.method} pickup needs evidence.rawRef`,\n })\n }\n } else if (p.method === \"declared\") {\n if (e.outboundLink === undefined && e.excerpt === undefined && !p.outlet) {\n ctx.addIssue({\n code: \"custom\",\n path: [\"evidence\"],\n message: \"declared pickup needs an excerpt, an outbound link or an outlet\",\n })\n }\n }\n})\nexport type Pickup = z.infer<typeof Pickup>\n\nexport const Recipe = z.object({\n name: z.string().optional(),\n sources: z\n .array(\n z.object({\n connector: z.string().min(1),\n instance: z.string().optional(),\n queries: z\n .array(\n z.object({\n text: z.string().min(1),\n subject: z.string().min(1),\n }),\n )\n .default([]),\n options: z.record(z.string(), z.unknown()).optional(),\n }),\n )\n .min(1),\n window: z.object({ from: timestamp.optional(), to: timestamp.optional() }).optional(),\n sampling: z\n .object({\n bands: z\n .array(\n z.object({\n metric: MetricName,\n min: z.number().optional(),\n max: z.number().optional(),\n }),\n )\n .optional(),\n perDomainCap: z.number().int().positive().optional(),\n seed: z.number().int().optional(),\n })\n .optional(),\n caps: z\n .object({\n perConnector: z.number().int().positive().optional(),\n total: z.number().int().positive().optional(),\n })\n .optional(),\n workers: z.number().int().positive().default(8),\n sinks: z.array(z.string()).optional(),\n})\nexport type Recipe = z.infer<typeof Recipe>\n\nexport const FailureCause = z.enum([\"blocked\", \"empty\", \"network\", \"parse\", \"other\"])\nexport type FailureCause = z.infer<typeof FailureCause>\n\n/** Every `with*` field and `eligible` is a count of items; shares are computed by the reader. */\nexport const CoverageCell = z.object({\n platform: z.string(),\n format: z.string(),\n language: z.string(),\n subject: z.string(),\n items: z.number().int().nonnegative(),\n /** At least one `followers` or `subscribers` reading. Karma is not counted here. */\n withAuthorAudience: z.number().int().nonnegative(),\n withPrimaryMetric: z.number().int().nonnegative(),\n /** `postedAt` and `measuredAt` both present. */\n withAge: z.number().int().nonnegative(),\n withAuthorId: z.number().int().nonnegative(),\n /** `contentId` shared with no other item. */\n withUniqueContent: z.number().int().nonnegative(),\n /** Audience, primary metric, age and author id all present. */\n eligible: z.number().int().nonnegative(),\n})\nexport type CoverageCell = z.infer<typeof CoverageCell>\n\nexport const Coverage = z.object({ cells: z.array(CoverageCell) })\nexport type Coverage = z.infer<typeof Coverage>\n\nexport const ConnectorReport = z.object({\n connector: z.string().min(1),\n status: z.enum([\"ok\", \"partial\", \"failed\", \"skipped\"]).default(\"ok\"),\n skippedReason: z.string().optional(),\n tasks: z.object({\n planned: z.number().int().nonnegative(),\n done: z.number().int().nonnegative(),\n failed: z.number().int().nonnegative(),\n skipped: z.number().int().nonnegative(),\n }),\n newItems: z.number().int().nonnegative(),\n observations: z.number().int().nonnegative(),\n duplicates: z.number().int().nonnegative(),\n failures: z.partialRecord(FailureCause, z.number().int().nonnegative()).default({}),\n escalations: z\n .array(\n z.object({\n from: z.string(),\n to: z.string(),\n count: z.number().int().positive(),\n }),\n )\n .default([]),\n durationMs: z.number().nonnegative(),\n coverage: Coverage.optional(),\n})\nexport type ConnectorReport = z.infer<typeof ConnectorReport>\n\nexport const RunReport = z.object({\n runId: z.string().min(1),\n startedAt: timestamp,\n finishedAt: timestamp.optional(),\n connectors: z.array(ConnectorReport),\n coverage: Coverage.optional(),\n})\nexport type RunReport = z.infer<typeof RunReport>\n","/**\n * Stable ids, URL canonicalisation and text fingerprints.\n *\n * Hashing uses Web Crypto (`crypto.subtle`, async), which exists in Node 20+,\n * browsers and edge runtimes. No Node built-in is imported.\n */\n\n/** Query parameters that only carry tracking information. */\nconst TRACKING_PARAMS = new Set([\n \"fbclid\",\n \"gclid\",\n \"dclid\",\n \"gbraid\",\n \"wbraid\",\n \"msclkid\",\n \"yclid\",\n \"twclid\",\n \"ttclid\",\n \"mc_cid\",\n \"mc_eid\",\n \"ref_src\",\n \"ref_url\",\n \"igshid\",\n \"_hsenc\",\n \"_hsmi\",\n \"mkt_tok\",\n])\n\nconst DEFAULT_PORTS: Record<string, string> = {\n \"http:\": \"80\",\n \"https:\": \"443\",\n}\n\n/** `si` is a share-tracking parameter on these hosts only; elsewhere it can carry meaning. */\nconst YOUTUBE_HOSTS = new Set([\"youtube.com\", \"youtu.be\"])\n\nfunction isYoutubeHost(hostname: string): boolean {\n const host = hostname.toLowerCase().replace(/^(www|m|music)\\./, \"\")\n return YOUTUBE_HOSTS.has(host)\n}\n\nfunction isTrackingParam(name: string, hostname: string): boolean {\n const key = name.toLowerCase()\n if (key === \"si\") return isYoutubeHost(hostname)\n return key.startsWith(\"utm_\") || TRACKING_PARAMS.has(key)\n}\n\n/**\n * Clean an http(s) URL into a dedup key: lowercase scheme and host (the path\n * keeps its case), no credentials, no fragment, no default port, tracking\n * parameters removed, remaining parameters ordered by key only (the relative\n * order of a repeated key is kept, so `?a=2&a=1` differs from `?a=1&a=2`), no\n * trailing slash (root included, so `/a/` and `/a` are the same key, and\n * `https://example.com/?a=1` becomes `https://example.com?a=1`).\n *\n * The result is only a key for deduplication: the original URL is always\n * kept next to it. Callers pass the final URL; redirects are not followed\n * here, so a known redirect target must be resolved before calling.\n *\n * Any non-http(s) scheme (`mailto:`, `urn:`, `data:`, ...) and any input that\n * is not an absolute URL is returned trimmed and otherwise unchanged.\n */\nexport function canonicalUrl(input: string): string {\n const raw = input.trim()\n let url: URL\n try {\n url = new URL(raw)\n } catch {\n return raw\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") return raw\n url.hash = \"\"\n url.username = \"\"\n url.password = \"\"\n if (DEFAULT_PORTS[url.protocol] === url.port) url.port = \"\"\n\n const kept: Array<[string, string]> = []\n url.searchParams.forEach((value, name) => {\n if (!isTrackingParam(name, url.hostname)) kept.push([name, value])\n })\n // Array.prototype.sort is stable: equal keys keep their original order.\n kept.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0))\n const query = new URLSearchParams(kept).toString()\n\n const path = url.pathname.length > 1 ? url.pathname.replace(/\\/+$/, \"\") : \"\"\n return `${url.protocol}//${url.host}${path}${query ? `?${query}` : \"\"}`\n}\n\n/** SHA-256 of a UTF-8 string, lowercase hex. */\nexport async function sha256Hex(text: string): Promise<string> {\n const digest = await globalThis.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(text))\n return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, \"0\")).join(\"\")\n}\n\n/**\n * Id of an item that has a platform id: `source:nativeId`. Strings are used\n * as given; a number must be a safe integer (larger ids lose digits, so pass\n * them as strings) or this throws.\n */\nexport function itemId(source: string, nativeId: string | number): string {\n if (typeof nativeId === \"number\" && !Number.isSafeInteger(nativeId)) {\n throw new RangeError(`native id ${nativeId} is not a safe integer; pass it as a string`)\n }\n return `${source}:${String(nativeId)}`\n}\n\n/** Id of an item without a platform id: `source:` plus a hash of its canonical URL. */\nexport async function itemIdFromUrl(source: string, url: string): Promise<string> {\n return `${source}:${await sha256Hex(canonicalUrl(url))}`\n}\n\n/** Text reduced to lowercase words separated by single spaces. */\nexport function normalizeText(text: string): string {\n return text\n .normalize(\"NFKC\")\n .toLowerCase()\n .replace(/[\\p{P}\\p{S}]+/gu, \" \")\n .replace(/\\s+/gu, \" \")\n .trim()\n}\n\n/**\n * Exact-content id: SHA-256 of the normalised text. Same words, same\n * fingerprint. Text that normalises to nothing (empty, only punctuation or\n * symbols) has no content id: returns `undefined`, so unrelated empty items\n * never share one.\n */\nexport async function textFingerprint(text: string): Promise<string | undefined> {\n const normalized = normalizeText(text)\n return normalized === \"\" ? undefined : sha256Hex(normalized)\n}\n","/** Version written to `collect.json` at a store root. Bump on any change to the stored shapes. */\nexport const STORE_SCHEMA_VERSION = 1\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentproto/collect",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Collect public posts, articles and metrics with provenance: zod schemas, stable ids, URL canonicalisation and text fingerprints. Pure: no filesystem, no network.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"collect",
|
|
8
|
+
"scraping",
|
|
9
|
+
"provenance",
|
|
10
|
+
"metrics",
|
|
11
|
+
"deduplication",
|
|
12
|
+
"zod"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://agentproto.sh/docs/collect",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/agentproto/ts",
|
|
18
|
+
"directory": "packages/collect"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/agentproto/ts/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.mjs",
|
|
26
|
+
"module": "dist/index.mjs",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.mjs",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"sideEffects": false,
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"zod": "^4.6.7"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^25.9.9",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^3.2.7",
|
|
53
|
+
"@agentproto/tooling": "0.1.1"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"dev": "tsup --watch",
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"check-types": "tsc --noEmit",
|
|
60
|
+
"test": "vitest run --passWithNoTests",
|
|
61
|
+
"test:watch": "vitest"
|
|
62
|
+
}
|
|
6
63
|
}
|