@puppi/adapter-podcast-rss 0.0.0-stage → 0.1.1
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 +38 -2
- package/dist/define.d.ts +14 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +12 -0
- package/dist/define.js.map +1 -0
- package/dist/feed.d.ts +38 -0
- package/dist/feed.d.ts.map +1 -0
- package/dist/feed.js +336 -0
- package/dist/feed.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +216 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi.d.ts +75 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +6 -0
- package/dist/openapi.js.map +1 -0
- package/dist/operations.d.ts +10 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +9 -0
- package/dist/operations.js.map +1 -0
- package/package.json +40 -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,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @puppi/adapter-podcast-rss
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Source connector for podcast RSS 2.0 and Atom 1.0 documents. `episodes({ feed_url })` yields `podcasts/episodes` rows. `feed_url` is the feed's canonical URL and is hashed into `feed_id`. A cursor may point at another page of that same feed and is passed with the same `feed_url`. One binding reads many feeds. A producer that walks more than one feed keeps a separate checkpoint for each `feed_url`. The wire body is XML. The client normalizes it before the shared HTTP client, which only decodes JSON. A BOM selects the encoding, then the Content-Type charset, then the XML declaration, then UTF-8. An unrecognized charset is read as UTF-8.
|
|
4
|
+
|
|
5
|
+
## Config
|
|
6
|
+
|
|
7
|
+
The binding has no feed URL. User agent, the request timeout, and rate-limit waits stay on the HTTP client. There is no secret and no API version.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"podcast_rss": {
|
|
12
|
+
"config": {}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`check()` does not GET a feed. The call that names `feed_url` does. Tests use the fixtures under `test/fixtures/` and do not call the network.
|
|
18
|
+
|
|
19
|
+
## Rows
|
|
20
|
+
|
|
21
|
+
An `Episode` is a `podcasts/episodes` row:
|
|
22
|
+
|
|
23
|
+
| Column | Value |
|
|
24
|
+
|---|---|
|
|
25
|
+
| `episode_id` | The item guid, or the hex SHA-256 of `feed_id` + `audio_url` with nothing between them |
|
|
26
|
+
| `feed_id` | Hex SHA-256 of the `feed_url` argument (the rss URL) |
|
|
27
|
+
| `guid` | The item guid, or `episode_id` when the item has none |
|
|
28
|
+
| `title` | Item title, or `""` |
|
|
29
|
+
| `description` | `content:encoded`, then `description`, then `summary` |
|
|
30
|
+
| `published_at` | ISO 8601. The append watermark |
|
|
31
|
+
| `audio_url` | Enclosure URL. An audio type is preferred over video |
|
|
32
|
+
| `audio_type` | Enclosure MIME type, or null |
|
|
33
|
+
| `audio_bytes` | Enclosure length when it is a safe integer, or null |
|
|
34
|
+
| `duration_sec` | Seconds, or null. Accepts an integer, `hh:mm:ss`, or `mm:ss` |
|
|
35
|
+
| `episode_url` | Show-notes link, or null |
|
|
36
|
+
| `season`, `episode_n` | Whole numbers, or null |
|
|
37
|
+
| `observed_at` | ISO 8601 client clock when the page was read |
|
|
38
|
+
|
|
39
|
+
An item with no enclosure URL or no parseable publish date is skipped, so `audio_url` and `published_at` are always set. A `rel="next"` link is the next page. `limit` slices one document; pass that cursor back to resume.
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A public RSS 2.0 or Atom feed. The document URL is an argument of `episodes`. */
|
|
2
|
+
declare const _default: {
|
|
3
|
+
readonly type: "podcast-rss";
|
|
4
|
+
readonly docs: "https://www.rssboard.org/rss-specification";
|
|
5
|
+
readonly configSchema: {};
|
|
6
|
+
readonly secretFields: readonly [];
|
|
7
|
+
readonly auth: {
|
|
8
|
+
readonly scheme: "none";
|
|
9
|
+
};
|
|
10
|
+
readonly apiVersions: readonly ["unversioned"];
|
|
11
|
+
readonly defaultApiVersion: "unversioned";
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAEA,oFAAoF;;;;;;;;;;;;AACpF,wBAQG"}
|
package/dist/define.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConnector } from "@puppi/sdk";
|
|
2
|
+
/** A public RSS 2.0 or Atom feed. The document URL is an argument of `episodes`. */
|
|
3
|
+
export default defineConnector({
|
|
4
|
+
type: "podcast-rss",
|
|
5
|
+
docs: "https://www.rssboard.org/rss-specification",
|
|
6
|
+
configSchema: {},
|
|
7
|
+
secretFields: [],
|
|
8
|
+
auth: { scheme: "none" },
|
|
9
|
+
apiVersions: ["unversioned"],
|
|
10
|
+
defaultApiVersion: "unversioned",
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,oFAAoF;AACpF,eAAe,eAAe,CAAC;IAC7B,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,4CAA4C;IAClD,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IACxB,WAAW,EAAE,CAAC,aAAa,CAAC;IAC5B,iBAAiB,EAAE,aAAa;CACjC,CAAC,CAAC"}
|
package/dist/feed.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RSS 2.0 and Atom 1.0, normalized to the `podcasts/episodes` row.
|
|
3
|
+
* The HTTP client only decodes JSON, so the fetch wrapper rewrites a feed
|
|
4
|
+
* before that decode. `fast-xml-parser` reads the document.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Fields parsed from one item. `episodes()` adds `episode_id`, `feed_id`,
|
|
8
|
+
* and `observed_at`. Items with no enclosure URL or no parseable publish
|
|
9
|
+
* date are omitted, so `audio_url` and `published_at` are always set.
|
|
10
|
+
* `published_at` is UTC ISO 8601. An empty guid means the item had none.
|
|
11
|
+
*/
|
|
12
|
+
export interface EpisodeDraft {
|
|
13
|
+
guid: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string | null;
|
|
16
|
+
published_at: string;
|
|
17
|
+
audio_url: string;
|
|
18
|
+
audio_type: string | null;
|
|
19
|
+
audio_bytes: number | null;
|
|
20
|
+
duration_sec: number | null;
|
|
21
|
+
episode_url: string | null;
|
|
22
|
+
season: number | null;
|
|
23
|
+
episode_n: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** One `podcasts/episodes` row. */
|
|
26
|
+
export interface Episode extends EpisodeDraft {
|
|
27
|
+
episode_id: string;
|
|
28
|
+
feed_id: string;
|
|
29
|
+
observed_at: string;
|
|
30
|
+
}
|
|
31
|
+
export interface FeedPage {
|
|
32
|
+
next: string | null;
|
|
33
|
+
episodes: EpisodeDraft[];
|
|
34
|
+
}
|
|
35
|
+
/** `fetch` that turns an RSS or Atom body into the JSON `send` decodes. */
|
|
36
|
+
export declare function normalizeFeedFetch(inner: typeof fetch): typeof fetch;
|
|
37
|
+
export declare function isFeedPage(body: unknown): body is FeedPage;
|
|
38
|
+
//# sourceMappingURL=feed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,mCAAmC;AACnC,MAAM,WAAW,OAAQ,SAAQ,YAAY;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,YAAY,EAAE,CAAC;CAC1B;AA2BD,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,KAAK,GAAG,OAAO,KAAK,CAsCpE;AA+FD,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,QAAQ,CAI1D"}
|
package/dist/feed.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RSS 2.0 and Atom 1.0, normalized to the `podcasts/episodes` row.
|
|
3
|
+
* The HTTP client only decodes JSON, so the fetch wrapper rewrites a feed
|
|
4
|
+
* before that decode. `fast-xml-parser` reads the document.
|
|
5
|
+
*/
|
|
6
|
+
import { XMLParser } from "fast-xml-parser";
|
|
7
|
+
const parser = new XMLParser({
|
|
8
|
+
ignoreAttributes: false,
|
|
9
|
+
attributeNamePrefix: "@_",
|
|
10
|
+
ignoreDeclaration: true,
|
|
11
|
+
ignorePiTags: true,
|
|
12
|
+
parseTagValue: false,
|
|
13
|
+
parseAttributeValue: false,
|
|
14
|
+
trimValues: false,
|
|
15
|
+
});
|
|
16
|
+
/** `fetch` that turns an RSS or Atom body into the JSON `send` decodes. */
|
|
17
|
+
export function normalizeFeedFetch(inner) {
|
|
18
|
+
const wrapped = async (input, init) => {
|
|
19
|
+
const response = await inner(input, init);
|
|
20
|
+
if (!response.ok)
|
|
21
|
+
return response;
|
|
22
|
+
const body = new Uint8Array(await response.arrayBuffer());
|
|
23
|
+
const raw = decodeFeed(body, response.headers.get("content-type"));
|
|
24
|
+
const trimmed = raw.replace(/^\uFEFF/, "").trimStart();
|
|
25
|
+
if (!trimmed.startsWith("<")) {
|
|
26
|
+
return new Response(raw, {
|
|
27
|
+
status: response.status,
|
|
28
|
+
statusText: response.statusText,
|
|
29
|
+
headers: response.headers,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const url = requestUrl(input);
|
|
33
|
+
let page;
|
|
34
|
+
try {
|
|
35
|
+
page = parseFeed(trimmed, url);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
39
|
+
throw new Error(`podcast-rss could not parse ${url}: ${detail}`, { cause: error });
|
|
40
|
+
}
|
|
41
|
+
return new Response(JSON.stringify(page), {
|
|
42
|
+
status: response.status,
|
|
43
|
+
statusText: response.statusText,
|
|
44
|
+
headers: { "content-type": "application/json" },
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
return wrapped;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decodes the feed body for the `<` check and the XML parser.
|
|
51
|
+
* A BOM wins, then the Content-Type charset, then `encoding` on the XML
|
|
52
|
+
* declaration, then UTF-8. TextDecoder throws on an unknown label, and
|
|
53
|
+
* this wrapper has no log, so that label is read as UTF-8.
|
|
54
|
+
*/
|
|
55
|
+
function decodeFeed(body, contentType) {
|
|
56
|
+
const label = bomEncoding(body) ?? charsetOf(contentType) ?? declaredEncoding(body) ?? "utf-8";
|
|
57
|
+
try {
|
|
58
|
+
return new TextDecoder(label).decode(body);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (!(error instanceof RangeError))
|
|
62
|
+
throw error;
|
|
63
|
+
return new TextDecoder("utf-8").decode(body);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function bomEncoding(body) {
|
|
67
|
+
if (body.length >= 3 && body[0] === 0xef && body[1] === 0xbb && body[2] === 0xbf) {
|
|
68
|
+
return "utf-8";
|
|
69
|
+
}
|
|
70
|
+
if (body.length >= 2 && body[0] === 0xff && body[1] === 0xfe)
|
|
71
|
+
return "utf-16le";
|
|
72
|
+
if (body.length >= 2 && body[0] === 0xfe && body[1] === 0xff)
|
|
73
|
+
return "utf-16be";
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function charsetOf(contentType) {
|
|
77
|
+
if (!contentType)
|
|
78
|
+
return null;
|
|
79
|
+
const match = /;\s*charset\s*=\s*(?:"([^"]*)"|'([^']*)'|([^;\s]+))/i.exec(contentType);
|
|
80
|
+
const label = (match?.[1] ?? match?.[2] ?? match?.[3])?.trim();
|
|
81
|
+
if (!label)
|
|
82
|
+
return null;
|
|
83
|
+
return label;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Reads the charset named by the XML declaration.
|
|
87
|
+
* The declaration is ASCII, so the sniff stops at the first high byte
|
|
88
|
+
* and does not assume the charset it is trying to discover.
|
|
89
|
+
*/
|
|
90
|
+
function declaredEncoding(body) {
|
|
91
|
+
const limit = Math.min(body.length, 256);
|
|
92
|
+
const codes = [];
|
|
93
|
+
for (let index = 0; index < limit; index++) {
|
|
94
|
+
const byte = body[index];
|
|
95
|
+
if (byte === undefined || byte > 0x7f)
|
|
96
|
+
break;
|
|
97
|
+
codes.push(byte);
|
|
98
|
+
}
|
|
99
|
+
const head = String.fromCharCode(...codes);
|
|
100
|
+
const match = /^<\?xml\s[^?]*?\sencoding\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(head);
|
|
101
|
+
const label = (match?.[1] ?? match?.[2])?.trim();
|
|
102
|
+
if (!label)
|
|
103
|
+
return null;
|
|
104
|
+
return label;
|
|
105
|
+
}
|
|
106
|
+
function requestUrl(input) {
|
|
107
|
+
if (typeof input === "string")
|
|
108
|
+
return input;
|
|
109
|
+
if (input instanceof URL)
|
|
110
|
+
return input.href;
|
|
111
|
+
return input.url;
|
|
112
|
+
}
|
|
113
|
+
function parseFeed(xml, pageUrl) {
|
|
114
|
+
const root = parseXml(xml);
|
|
115
|
+
if (root.name !== "rss" && root.name !== "feed" && root.name !== "RDF") {
|
|
116
|
+
throw new Error(`unsupported root <${root.qualified}>`);
|
|
117
|
+
}
|
|
118
|
+
const { meta, items } = entries(root);
|
|
119
|
+
const href = nextHref(meta);
|
|
120
|
+
return {
|
|
121
|
+
next: href ? absolute(href, pageUrl) : null,
|
|
122
|
+
episodes: items.flatMap((item) => {
|
|
123
|
+
const episode = episodeFrom(item);
|
|
124
|
+
return episode === null ? [] : [episode];
|
|
125
|
+
}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export function isFeedPage(body) {
|
|
129
|
+
return (body !== null && typeof body === "object" && "episodes" in body && Array.isArray(body.episodes));
|
|
130
|
+
}
|
|
131
|
+
function episodeFrom(item) {
|
|
132
|
+
const media = pickAudio(mediasOf(item));
|
|
133
|
+
const published = publishedOf(item);
|
|
134
|
+
if (!media?.url || published === null)
|
|
135
|
+
return null;
|
|
136
|
+
return {
|
|
137
|
+
guid: textNamed(item, "guid") ?? textNamed(item, "id") ?? "",
|
|
138
|
+
title: textNamed(item, "title") ?? "",
|
|
139
|
+
description: textNamed(item, "encoded") ?? textNamed(item, "description") ?? textNamed(item, "summary"),
|
|
140
|
+
published_at: published,
|
|
141
|
+
audio_url: media.url,
|
|
142
|
+
audio_type: media.type,
|
|
143
|
+
audio_bytes: media.length,
|
|
144
|
+
duration_sec: durationSec(textNamed(item, "duration")),
|
|
145
|
+
episode_url: linkOf(item),
|
|
146
|
+
season: whole(textNamed(item, "season")),
|
|
147
|
+
episode_n: whole(textNamed(item, "episode")),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function entries(root) {
|
|
151
|
+
if (root.name === "feed")
|
|
152
|
+
return { meta: root, items: children(root, "entry") };
|
|
153
|
+
const channel = root.children.find((child) => child.name === "channel");
|
|
154
|
+
const meta = channel ?? root;
|
|
155
|
+
const items = children(meta, "item");
|
|
156
|
+
if (channel) {
|
|
157
|
+
for (const item of children(root, "item")) {
|
|
158
|
+
if (!items.includes(item))
|
|
159
|
+
items.push(item);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return { meta, items };
|
|
163
|
+
}
|
|
164
|
+
function publishedOf(item) {
|
|
165
|
+
for (const name of ["pubDate", "published", "updated", "date"]) {
|
|
166
|
+
const text = textNamed(item, name);
|
|
167
|
+
if (text)
|
|
168
|
+
return publishedAt(text);
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
function publishedAt(value) {
|
|
173
|
+
const parsed = Date.parse(value);
|
|
174
|
+
if (Number.isNaN(parsed))
|
|
175
|
+
return null;
|
|
176
|
+
return new Date(parsed).toISOString();
|
|
177
|
+
}
|
|
178
|
+
function durationSec(value) {
|
|
179
|
+
if (!value)
|
|
180
|
+
return null;
|
|
181
|
+
const trimmed = value.trim();
|
|
182
|
+
if (/^\d+$/.test(trimmed))
|
|
183
|
+
return Number(trimmed);
|
|
184
|
+
const parts = trimmed.split(":");
|
|
185
|
+
if (parts.length !== 2 && parts.length !== 3)
|
|
186
|
+
return null;
|
|
187
|
+
const numbers = parts.map((part) => Number(part));
|
|
188
|
+
if (numbers.some((part) => !Number.isInteger(part) || part < 0))
|
|
189
|
+
return null;
|
|
190
|
+
const seconds = numbers.at(-1);
|
|
191
|
+
const minutes = numbers.at(-2);
|
|
192
|
+
const hours = numbers.length === 3 ? numbers[0] : 0;
|
|
193
|
+
if (seconds === undefined || minutes === undefined || hours === undefined)
|
|
194
|
+
return null;
|
|
195
|
+
return hours * 3600 + minutes * 60 + seconds;
|
|
196
|
+
}
|
|
197
|
+
function whole(value) {
|
|
198
|
+
if (!value || !/^\d+$/.test(value.trim()))
|
|
199
|
+
return null;
|
|
200
|
+
return Number(value.trim());
|
|
201
|
+
}
|
|
202
|
+
function linkOf(item) {
|
|
203
|
+
for (const child of item.children) {
|
|
204
|
+
if (child.name !== "link" || child.attrs["rel"] === "enclosure")
|
|
205
|
+
continue;
|
|
206
|
+
const href = child.attrs["href"];
|
|
207
|
+
if (href && (child.attrs["rel"] === undefined || child.attrs["rel"] === "alternate")) {
|
|
208
|
+
return href;
|
|
209
|
+
}
|
|
210
|
+
const text = textOf(child);
|
|
211
|
+
if (text && !href)
|
|
212
|
+
return text;
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
function mediasOf(item) {
|
|
217
|
+
const found = [];
|
|
218
|
+
for (const child of item.children) {
|
|
219
|
+
if (child.name === "enclosure" && child.attrs["url"]) {
|
|
220
|
+
found.push(toMedia(child.attrs["url"], child.attrs["type"], child.attrs["length"]));
|
|
221
|
+
}
|
|
222
|
+
else if (child.name === "link" && child.attrs["rel"] === "enclosure" && child.attrs["href"]) {
|
|
223
|
+
found.push(toMedia(child.attrs["href"], child.attrs["type"], child.attrs["length"]));
|
|
224
|
+
}
|
|
225
|
+
else if (child.name === "content" && child.attrs["url"] && isAudioMedium(child)) {
|
|
226
|
+
found.push(toMedia(child.attrs["url"], child.attrs["type"], child.attrs["fileSize"] ?? child.attrs["length"]));
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return found;
|
|
230
|
+
}
|
|
231
|
+
function isAudioMedium(node) {
|
|
232
|
+
const type = node.attrs["type"];
|
|
233
|
+
return node.attrs["medium"] === "audio" || (type !== undefined && type.startsWith("audio/"));
|
|
234
|
+
}
|
|
235
|
+
function toMedia(url, type, length) {
|
|
236
|
+
return {
|
|
237
|
+
url,
|
|
238
|
+
type: type ?? null,
|
|
239
|
+
length: bytes(length),
|
|
240
|
+
audio: type !== undefined && type.startsWith("audio/"),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
function pickAudio(medias) {
|
|
244
|
+
return medias.find((media) => media.audio) ?? medias[0] ?? null;
|
|
245
|
+
}
|
|
246
|
+
function bytes(value) {
|
|
247
|
+
if (!value || !/^\d+$/.test(value))
|
|
248
|
+
return null;
|
|
249
|
+
const parsed = Number(value);
|
|
250
|
+
return Number.isSafeInteger(parsed) ? parsed : null;
|
|
251
|
+
}
|
|
252
|
+
function nextHref(node) {
|
|
253
|
+
for (const child of node.children) {
|
|
254
|
+
if (child.name === "link" && child.attrs["rel"] === "next" && child.attrs["href"]) {
|
|
255
|
+
return child.attrs["href"];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
function absolute(href, base) {
|
|
261
|
+
try {
|
|
262
|
+
return new URL(href, base).href;
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function textNamed(node, name) {
|
|
269
|
+
const exact = node.children.find((child) => child.qualified === name);
|
|
270
|
+
const any = node.children.find((child) => child.name === name);
|
|
271
|
+
return textOf(exact ?? any);
|
|
272
|
+
}
|
|
273
|
+
function children(node, name) {
|
|
274
|
+
return node.children.filter((child) => child.name === name);
|
|
275
|
+
}
|
|
276
|
+
function textOf(node) {
|
|
277
|
+
if (!node)
|
|
278
|
+
return null;
|
|
279
|
+
const parts = [];
|
|
280
|
+
collect(node, parts);
|
|
281
|
+
const text = parts.join("").replace(/\s+/g, " ").trim();
|
|
282
|
+
return text === "" ? null : text;
|
|
283
|
+
}
|
|
284
|
+
function collect(node, parts) {
|
|
285
|
+
if (node.text)
|
|
286
|
+
parts.push(node.text);
|
|
287
|
+
for (const child of node.children)
|
|
288
|
+
collect(child, parts);
|
|
289
|
+
}
|
|
290
|
+
function parseXml(xml) {
|
|
291
|
+
const parsed = parser.parse(xml);
|
|
292
|
+
if (!isRecord(parsed))
|
|
293
|
+
throw new Error("feed has no root element");
|
|
294
|
+
const rootName = Object.keys(parsed).find((key) => key !== "?xml");
|
|
295
|
+
const root = rootName === undefined ? undefined : parsed[rootName];
|
|
296
|
+
if (rootName === undefined || root === undefined)
|
|
297
|
+
throw new Error("feed has no root element");
|
|
298
|
+
return toNode(rootName, root);
|
|
299
|
+
}
|
|
300
|
+
function toNode(qualified, value) {
|
|
301
|
+
const name = local(qualified);
|
|
302
|
+
if (!isRecord(value)) {
|
|
303
|
+
return { qualified, name, attrs: {}, children: [], text: textValue(value) };
|
|
304
|
+
}
|
|
305
|
+
const attrs = {};
|
|
306
|
+
const nodes = [];
|
|
307
|
+
let text = "";
|
|
308
|
+
for (const [key, child] of Object.entries(value)) {
|
|
309
|
+
if (key.startsWith("@_")) {
|
|
310
|
+
attrs[local(key.slice(2))] = textValue(child);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (key === "#text") {
|
|
314
|
+
text += textValue(child);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
for (const one of Array.isArray(child) ? child : [child])
|
|
318
|
+
nodes.push(toNode(key, one));
|
|
319
|
+
}
|
|
320
|
+
return { qualified, name, attrs, children: nodes, text };
|
|
321
|
+
}
|
|
322
|
+
function textValue(value) {
|
|
323
|
+
if (typeof value === "string")
|
|
324
|
+
return value;
|
|
325
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
326
|
+
return String(value);
|
|
327
|
+
return "";
|
|
328
|
+
}
|
|
329
|
+
function isRecord(value) {
|
|
330
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
331
|
+
}
|
|
332
|
+
function local(qualified) {
|
|
333
|
+
const index = qualified.indexOf(":");
|
|
334
|
+
return index === -1 ? qualified : qualified.slice(index + 1);
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=feed.js.map
|
package/dist/feed.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feed.js","sourceRoot":"","sources":["../src/feed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAiD5C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,gBAAgB,EAAE,KAAK;IACvB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,IAAI;IACvB,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,mBAAmB,EAAE,KAAK;IAC1B,UAAU,EAAE,KAAK;CAClB,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,MAAM,OAAO,GAAiB,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAClD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,QAAQ,CAAC;QAElC,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QACnE,MAAM,O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I,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,KAAK,CAAC,SAAiB;IAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAErC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@puppi/adapter-podcast-rss`: a source connector over RSS 2.0 and Atom 1.0
|
|
3
|
+
* feeds. `episodes({ feed_url })` GETs that URL (`podcasts/feeds.rss_url`),
|
|
4
|
+
* so one binding reads many feeds. No key. A `rel="next"` link is the next
|
|
5
|
+
* page. `limit` slices one document; pass that cursor back to resume.
|
|
6
|
+
*/
|
|
7
|
+
import { type CredentialCheck, type ClientOptions, OpenApiClient, type PageArgs } from "@puppi/sdk";
|
|
8
|
+
import connector from "./define.js";
|
|
9
|
+
import { type Episode } from "./feed.js";
|
|
10
|
+
import { type Api } from "./operations.js";
|
|
11
|
+
export type { Episode };
|
|
12
|
+
export default connector;
|
|
13
|
+
export declare class Client extends OpenApiClient<Api> {
|
|
14
|
+
private readonly now;
|
|
15
|
+
constructor(config: Record<string, unknown>, secrets?: Record<string, string>, options?: ClientOptions & {
|
|
16
|
+
now?: () => Date;
|
|
17
|
+
});
|
|
18
|
+
/** The binding names no host. `episodes` is what GETs a feed. */
|
|
19
|
+
check(): Promise<CredentialCheck>;
|
|
20
|
+
/**
|
|
21
|
+
* Every remaining page of `feed_url`. `cursor` is the next-page URL, or a
|
|
22
|
+
* `{ offset, url }` token when `limit` stopped inside one document. Null
|
|
23
|
+
* on the last page. `published_at` is the append watermark; pass `cursor`
|
|
24
|
+
* back to resume the walk. Older episodes stay in the page.
|
|
25
|
+
*/
|
|
26
|
+
episodes(args: {
|
|
27
|
+
feed_url: string;
|
|
28
|
+
limit?: number;
|
|
29
|
+
cursor?: PageArgs["cursor"];
|
|
30
|
+
}): AsyncGenerator<{
|
|
31
|
+
cursor: string | null;
|
|
32
|
+
data: Episode[];
|
|
33
|
+
}>;
|
|
34
|
+
private walk;
|
|
35
|
+
private load;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,aAAa,EAEb,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,OAAO,EAAqD,MAAM,WAAW,CAAC;AAC5F,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,iBAAiB,CAAC;AAEvD,YAAY,EAAE,OAAO,EAAE,CAAC;AAExB,eAAe,SAAS,CAAC;AAUzB,qBAAa,MAAO,SAAQ,aAAa,CAAC,GAAG,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAG/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,OAAO,GAAE,aAAa,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;KAAO;IAepD,iEAAiE;IACxD,KAAK,IAAI,OAAO,CAAC,eAAe,CAAC;IAI1C;;;;;OAKG;IAEH,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC7B,GAAG,cAAc,CAAC;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,OAAO,EAAE,CAAA;KAAE,CAAC;YAI/C,IAAI;YA4DL,IAAI;CAYnB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@puppi/adapter-podcast-rss`: a source connector over RSS 2.0 and Atom 1.0
|
|
3
|
+
* feeds. `episodes({ feed_url })` GETs that URL (`podcasts/feeds.rss_url`),
|
|
4
|
+
* so one binding reads many feeds. No key. A `rel="next"` link is the next
|
|
5
|
+
* page. `limit` slices one document; pass that cursor back to resume.
|
|
6
|
+
*/
|
|
7
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
8
|
+
var useValue = arguments.length > 2;
|
|
9
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
10
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
11
|
+
}
|
|
12
|
+
return useValue ? value : void 0;
|
|
13
|
+
};
|
|
14
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
15
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
16
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
17
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
18
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
19
|
+
var _, done = false;
|
|
20
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
21
|
+
var context = {};
|
|
22
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
23
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
24
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
25
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
26
|
+
if (kind === "accessor") {
|
|
27
|
+
if (result === void 0) continue;
|
|
28
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
29
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
30
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
31
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
32
|
+
}
|
|
33
|
+
else if (_ = accept(result)) {
|
|
34
|
+
if (kind === "field") initializers.unshift(_);
|
|
35
|
+
else descriptor[key] = _;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
39
|
+
done = true;
|
|
40
|
+
};
|
|
41
|
+
import { createHash } from "node:crypto";
|
|
42
|
+
import { read, OpenApiClient, openApiClientOptions, } from "@puppi/sdk";
|
|
43
|
+
import connector from "./define.js";
|
|
44
|
+
import { isFeedPage, normalizeFeedFetch } from "./feed.js";
|
|
45
|
+
import { operations } from "./operations.js";
|
|
46
|
+
export default connector;
|
|
47
|
+
const FEED_ACCEPT = "application/rss+xml, application/atom+xml, application/xml, text/xml, application/json;q=0.1";
|
|
48
|
+
let Client = (() => {
|
|
49
|
+
let _classSuper = OpenApiClient;
|
|
50
|
+
let _instanceExtraInitializers = [];
|
|
51
|
+
let _episodes_decorators;
|
|
52
|
+
return class Client extends _classSuper {
|
|
53
|
+
static {
|
|
54
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
55
|
+
_episodes_decorators = [read];
|
|
56
|
+
__esDecorate(this, null, _episodes_decorators, { kind: "method", name: "episodes", static: false, private: false, access: { has: obj => "episodes" in obj, get: obj => obj.episodes }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
57
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
58
|
+
}
|
|
59
|
+
now = __runInitializers(this, _instanceExtraInitializers);
|
|
60
|
+
constructor(config, secrets = {}, options = {}) {
|
|
61
|
+
const { now, ...clientOptions } = options;
|
|
62
|
+
super(config, { ...clientOptions, fetch: normalizeFeedFetch(clientOptions.fetch ?? fetch) }, ...openApiClientOptions(connector, config, secrets, operations, {
|
|
63
|
+
baseUrl: "",
|
|
64
|
+
headers: { accept: FEED_ACCEPT },
|
|
65
|
+
}));
|
|
66
|
+
this.now = now ?? (() => new Date());
|
|
67
|
+
}
|
|
68
|
+
/** The binding names no host. `episodes` is what GETs a feed. */
|
|
69
|
+
check() {
|
|
70
|
+
return Promise.resolve({ ok: true });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Every remaining page of `feed_url`. `cursor` is the next-page URL, or a
|
|
74
|
+
* `{ offset, url }` token when `limit` stopped inside one document. Null
|
|
75
|
+
* on the last page. `published_at` is the append watermark; pass `cursor`
|
|
76
|
+
* back to resume the walk. Older episodes stay in the page.
|
|
77
|
+
*/
|
|
78
|
+
episodes(args) {
|
|
79
|
+
return this.walk(args);
|
|
80
|
+
}
|
|
81
|
+
async *walk(args) {
|
|
82
|
+
const feed = feedUrl(args?.feed_url);
|
|
83
|
+
const feedId = sha256(feed);
|
|
84
|
+
const size = pageSize(args?.limit);
|
|
85
|
+
let walk = parseCursor(args?.cursor ?? null, feed);
|
|
86
|
+
const seen = new Set();
|
|
87
|
+
for (;;) {
|
|
88
|
+
const key = `${walk.offset}\n${walk.url}`;
|
|
89
|
+
if (seen.has(key))
|
|
90
|
+
return;
|
|
91
|
+
seen.add(key);
|
|
92
|
+
const page = await this.load(walk.url);
|
|
93
|
+
const observedAt = this.now().toISOString();
|
|
94
|
+
const rows = page.episodes.map((episode) => stamp(episode, feedId, observedAt));
|
|
95
|
+
const nextUrl = follow(page.next, walk.url);
|
|
96
|
+
if (size === undefined) {
|
|
97
|
+
const data = rows.slice(walk.offset);
|
|
98
|
+
if (data.length > 0)
|
|
99
|
+
yield { cursor: nextUrl, data };
|
|
100
|
+
if (nextUrl === null)
|
|
101
|
+
return;
|
|
102
|
+
walk = { url: nextUrl, offset: 0 };
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
let offset = walk.offset;
|
|
106
|
+
if (offset >= rows.length) {
|
|
107
|
+
if (nextUrl === null)
|
|
108
|
+
return;
|
|
109
|
+
walk = { url: nextUrl, offset: 0 };
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
while (offset < rows.length) {
|
|
113
|
+
const data = rows.slice(offset, offset + size);
|
|
114
|
+
offset += data.length;
|
|
115
|
+
const more = offset < rows.length;
|
|
116
|
+
const cursor = more ? offsetCursor(offset, walk.url) : nextUrl;
|
|
117
|
+
if (data.length > 0)
|
|
118
|
+
yield { cursor, data };
|
|
119
|
+
if (more)
|
|
120
|
+
continue;
|
|
121
|
+
if (cursor === null)
|
|
122
|
+
return;
|
|
123
|
+
walk = { url: cursor, offset: 0 };
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async load(url) {
|
|
129
|
+
const result = await this.send(url);
|
|
130
|
+
if (!isFeedPage(result.data)) {
|
|
131
|
+
throw new Error(`podcast-rss answered ${url} without a feed document`);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
next: typeof result.data.next === "string" ? result.data.next : null,
|
|
135
|
+
episodes: result.data.episodes,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
})();
|
|
140
|
+
export { Client };
|
|
141
|
+
function stamp(episode, feedId, observedAt) {
|
|
142
|
+
const episodeId = episode.guid !== "" ? episode.guid : sha256(feedId + episode.audio_url);
|
|
143
|
+
return {
|
|
144
|
+
episode_id: episodeId,
|
|
145
|
+
feed_id: feedId,
|
|
146
|
+
guid: episode.guid !== "" ? episode.guid : episodeId,
|
|
147
|
+
title: episode.title,
|
|
148
|
+
description: episode.description,
|
|
149
|
+
published_at: episode.published_at,
|
|
150
|
+
audio_url: episode.audio_url,
|
|
151
|
+
audio_type: episode.audio_type,
|
|
152
|
+
audio_bytes: episode.audio_bytes,
|
|
153
|
+
duration_sec: episode.duration_sec,
|
|
154
|
+
episode_url: episode.episode_url,
|
|
155
|
+
season: episode.season,
|
|
156
|
+
episode_n: episode.episode_n,
|
|
157
|
+
observed_at: observedAt,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** Lowercase hex SHA-256. `feed_id` is this of the `feed_url` argument (the rss URL). */
|
|
161
|
+
function sha256(value) {
|
|
162
|
+
return createHash("sha256").update(value).digest("hex");
|
|
163
|
+
}
|
|
164
|
+
function feedUrl(value) {
|
|
165
|
+
if (typeof value !== "string" || value === "")
|
|
166
|
+
throw new Error("podcast-rss requires feed_url");
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
function pageSize(limit) {
|
|
170
|
+
if (limit === undefined)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (!Number.isInteger(limit) || limit < 1) {
|
|
173
|
+
throw new Error("podcast-rss limit must be a positive integer");
|
|
174
|
+
}
|
|
175
|
+
return limit;
|
|
176
|
+
}
|
|
177
|
+
function parseCursor(cursor, feed) {
|
|
178
|
+
if (cursor === null || cursor === "")
|
|
179
|
+
return { url: feed, offset: 0 };
|
|
180
|
+
const text = String(cursor);
|
|
181
|
+
if (text.startsWith("https://") || text.startsWith("http://"))
|
|
182
|
+
return { url: text, offset: 0 };
|
|
183
|
+
if (text.startsWith("{")) {
|
|
184
|
+
const parsed = offsetOf(text);
|
|
185
|
+
if (parsed)
|
|
186
|
+
return parsed;
|
|
187
|
+
}
|
|
188
|
+
throw new Error(`podcast-rss cursor is not a page token: ${text}`);
|
|
189
|
+
}
|
|
190
|
+
function offsetOf(text) {
|
|
191
|
+
try {
|
|
192
|
+
const parsed = JSON.parse(text);
|
|
193
|
+
if (typeof parsed.url === "string" &&
|
|
194
|
+
(parsed.url.startsWith("https://") || parsed.url.startsWith("http://")) &&
|
|
195
|
+
typeof parsed.offset === "number" &&
|
|
196
|
+
Number.isInteger(parsed.offset) &&
|
|
197
|
+
parsed.offset >= 0) {
|
|
198
|
+
return { url: parsed.url, offset: parsed.offset };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
function offsetCursor(offset, url) {
|
|
207
|
+
return JSON.stringify({ offset, url });
|
|
208
|
+
}
|
|
209
|
+
function follow(next, current) {
|
|
210
|
+
if (!next || next === current)
|
|
211
|
+
return null;
|
|
212
|
+
if (!next.startsWith("https://") && !next.startsWith("http://"))
|
|
213
|
+
return null;
|
|
214
|
+
return next;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,IAAI,EAGJ,aAAa,EACb,oBAAoB,GAErB,MAAM,YAAY,CAAC;AAEpB,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,EAAmC,UAAU,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC5F,OAAO,EAAY,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAIvD,eAAe,SAAS,CAAC;AAEzB,MAAM,WAAW,GACf,8FAA8F,CAAC;IAOpF,MAAM;sBAAS,aAAa;;;iBAA5B,MAAO,SAAQ,WAAkB;;;oCAgC3C,IAAI;YACL,2KAAA,QAAQ,6DAMP;;;QAtCgB,GAAG,GADT,mDAAM,CACgB;QAE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AAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAE,GAAW;IAC/C,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,MAAM,CAAC,IAAmB,EAAE,OAAe;IAClD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAE7E,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by openapi-typescript.
|
|
3
|
+
* Do not make direct changes to the file.
|
|
4
|
+
*/
|
|
5
|
+
export type paths = {
|
|
6
|
+
"/feed": {
|
|
7
|
+
parameters: {
|
|
8
|
+
query?: never;
|
|
9
|
+
header?: never;
|
|
10
|
+
path?: never;
|
|
11
|
+
cookie?: never;
|
|
12
|
+
};
|
|
13
|
+
get: operations["getFeed"];
|
|
14
|
+
put?: never;
|
|
15
|
+
post?: never;
|
|
16
|
+
delete?: never;
|
|
17
|
+
options?: never;
|
|
18
|
+
head?: never;
|
|
19
|
+
patch?: never;
|
|
20
|
+
trace?: never;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type webhooks = Record<string, never>;
|
|
24
|
+
export type components = {
|
|
25
|
+
schemas: {
|
|
26
|
+
episode: {
|
|
27
|
+
guid?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
description?: string | null;
|
|
30
|
+
/** Format: date-time */
|
|
31
|
+
published_at?: string;
|
|
32
|
+
audio_url?: string;
|
|
33
|
+
audio_type?: string | null;
|
|
34
|
+
/** Format: int64 */
|
|
35
|
+
audio_bytes?: number | null;
|
|
36
|
+
duration_sec?: number | null;
|
|
37
|
+
episode_url?: string | null;
|
|
38
|
+
season?: number | null;
|
|
39
|
+
episode_n?: number | null;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
responses: never;
|
|
43
|
+
parameters: never;
|
|
44
|
+
requestBodies: never;
|
|
45
|
+
headers: never;
|
|
46
|
+
pathItems: never;
|
|
47
|
+
};
|
|
48
|
+
export type SchemaEpisode = components["schemas"]["episode"];
|
|
49
|
+
export type $defs = Record<string, never>;
|
|
50
|
+
export interface operations {
|
|
51
|
+
getFeed: {
|
|
52
|
+
parameters: {
|
|
53
|
+
query?: never;
|
|
54
|
+
header?: never;
|
|
55
|
+
path?: never;
|
|
56
|
+
cookie?: never;
|
|
57
|
+
};
|
|
58
|
+
requestBody?: never;
|
|
59
|
+
responses: {
|
|
60
|
+
/** @description One normalized feed document. */
|
|
61
|
+
200: {
|
|
62
|
+
headers: {
|
|
63
|
+
[name: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
content: {
|
|
66
|
+
"application/json": {
|
|
67
|
+
next?: string | null;
|
|
68
|
+
episodes: components["schemas"]["episode"][];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE;QACP,UAAU,EAAE;YACV,KAAK,CAAC,EAAE,KAAK,CAAC;YACd,MAAM,CAAC,EAAE,KAAK,CAAC;YACf,IAAI,CAAC,EAAE,KAAK,CAAC;YACb,MAAM,CAAC,EAAE,KAAK,CAAC;SAChB,CAAC;QACF,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,CAA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M,EAAE,KAAK,CAAC,CAAC;AAC1C,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QACP,UAAU,EAAE;YACV,KAAK,CAAC,EAAE,KAAK,CAAC;YACd,MAAM,CAAC,EAAE,KAAK,CAAC;YACf,IAAI,CAAC,EAAE,KAAK,CAAC;YACb,MAAM,CAAC,EAAE,KAAK,CAAC;SAChB,CAAC;QACF,WAAW,CAAC,EAAE,KAAK,CAAC;QACpB,SAAS,EAAE;YACT,iDAAiD;YACjD,GAAG,EAAE;gBACH,OAAO,EAAE;oBACP,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;iBACzB,CAAC;gBACF,OAAO,EAAE;oBACP,kBAAkB,EAAE;wBAClB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;wBACrB,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;qBAC9C,CAAC;iBACH,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;CACH"}
|
package/dist/openapi.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../src/openapi.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Generated from openapi.json. Do not edit. */
|
|
2
|
+
import type { BodyOf, Operation } from "@puppi/sdk";
|
|
3
|
+
import type { operations as spec } from "./openapi.js";
|
|
4
|
+
export type Api = {
|
|
5
|
+
responses: {
|
|
6
|
+
getFeed: BodyOf<spec["getFeed"]>;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const operations: Record<keyof Api["responses"], Operation>;
|
|
10
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,IAAI,IAAI,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,MAAM,GAAG,GAAG;IAChB,SAAS,EAAE;QACT,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;KAClC,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,WAAW,CAAC,EAAE,SAAS,CAMhE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAYhD,MAAM,CAAC,MAAM,UAAU,GAA8C;IACnE,OAAO,EAAE;QACP,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE;KACV;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puppi/adapter-podcast-rss",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Source connector for podcast RSS and Atom feeds. episodes() takes feed_url per call.",
|
|
5
|
+
"homepage": "https://puppi.dev",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@puppi/sdk": "0.3.0",
|
|
25
|
+
"fast-xml-parser": "5.11.2"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@puppi/conformance": "0.1.0",
|
|
29
|
+
"@types/node": "^26.6.5",
|
|
30
|
+
"openapi-typescript": "7.13.0",
|
|
31
|
+
"typescript": "^5.6.3",
|
|
32
|
+
"vitest": "^2.1.4"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=26"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"generate": "openapi-typescript openapi.json -o src/openapi.ts --export-type --root-types --empty-objects-unknown && puppi-write-operations openapi.json src/operations.ts",
|
|
39
|
+
"build": "tsc -p tsconfig.json",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p test/tsconfig.json",
|
|
41
|
+
"test": "vitest run"
|
|
42
|
+
}
|
|
6
43
|
}
|