@superdurable/connector-google-youtube 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +10 -2
- package/dex-connector.json +221 -0
- package/dist/chunk-QT3UHJH2.js +418 -0
- package/dist/connection-C8RRmMTa.d.ts +331 -0
- package/dist/index.d.ts +346 -0
- package/dist/index.js +880 -0
- package/dist/mock.d.ts +159 -0
- package/dist/mock.js +388 -0
- package/package.json +63 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# YouTube TypeScript connector
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@superdurable/connector-google-youtube` provides Dex Query Steps for video search, video and channel reads, and playlist pages, plus an add-once playlist Mutation. The package follows the Go connector's YouTube Data API v3 request and retry behavior. OAuth credentials are resolved and refreshed through the host-owned connection using the generated authorization declaration.
|
|
4
|
+
|
|
5
|
+
The checked-in [video lookup example](examples/video-lookup/README.md) binds the static `youtube-video-reader` connection and runs a real Dex Flow. Configure Google OAuth in Dex Web Connections. The read-only method is sufficient for the example; `addPlaylistItem` requires the manage method.
|
|
6
|
+
|
|
7
|
+
## Verify
|
|
8
|
+
|
|
9
|
+
From this package directory, run `npm ci`, `npm run check`, and `npm run test:integration` with `DEX_FLOW_SERVICE_ADDRESS` set to a running `dexcli dev` server. The conformance test replays Go-recorded provider requests, branches, retries, and outputs. The integration test uses a local YouTube stand-in through a real Dex Worker and Client.
|
|
10
|
+
|
|
11
|
+
The TypeScript package is `v0.1.0`. A live Google OAuth grant and live YouTube API call have not been verified by this example's local integration test.
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
{
|
|
2
|
+
"connectorId": "google-youtube",
|
|
3
|
+
"releaseTag": "connectors/google/youtube/go/v0.3.0",
|
|
4
|
+
"package": {
|
|
5
|
+
"ecosystem": "npm",
|
|
6
|
+
"name": "@superdurable/connector-google-youtube",
|
|
7
|
+
"version": "0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"factories": [
|
|
10
|
+
{
|
|
11
|
+
"name": "newSearchVideosStep",
|
|
12
|
+
"kind": "query",
|
|
13
|
+
"operationId": "searchVideos",
|
|
14
|
+
"fields": {
|
|
15
|
+
"stepType": "stepType",
|
|
16
|
+
"annotations": "annotations",
|
|
17
|
+
"connectionName": "connectionName",
|
|
18
|
+
"resultAttribute": "resultAttribute"
|
|
19
|
+
},
|
|
20
|
+
"branches": [
|
|
21
|
+
{
|
|
22
|
+
"id": "searched",
|
|
23
|
+
"field": "searched",
|
|
24
|
+
"optional": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "quotaExhausted",
|
|
28
|
+
"field": "quotaExhausted",
|
|
29
|
+
"optional": true
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "providerRejected",
|
|
33
|
+
"field": "providerRejected",
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "invalidResponse",
|
|
38
|
+
"field": "invalidResponse",
|
|
39
|
+
"optional": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "defect",
|
|
43
|
+
"field": "defect",
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "newGetVideoStep",
|
|
50
|
+
"kind": "query",
|
|
51
|
+
"operationId": "getVideo",
|
|
52
|
+
"fields": {
|
|
53
|
+
"stepType": "stepType",
|
|
54
|
+
"annotations": "annotations",
|
|
55
|
+
"connectionName": "connectionName",
|
|
56
|
+
"resultAttribute": "resultAttribute"
|
|
57
|
+
},
|
|
58
|
+
"branches": [
|
|
59
|
+
{
|
|
60
|
+
"id": "found",
|
|
61
|
+
"field": "found",
|
|
62
|
+
"optional": false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "notFound",
|
|
66
|
+
"field": "notFound",
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "quotaExhausted",
|
|
71
|
+
"field": "quotaExhausted",
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "providerRejected",
|
|
76
|
+
"field": "providerRejected",
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "invalidResponse",
|
|
81
|
+
"field": "invalidResponse",
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "defect",
|
|
86
|
+
"field": "defect",
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "newGetChannelStep",
|
|
93
|
+
"kind": "query",
|
|
94
|
+
"operationId": "getChannel",
|
|
95
|
+
"fields": {
|
|
96
|
+
"stepType": "stepType",
|
|
97
|
+
"annotations": "annotations",
|
|
98
|
+
"connectionName": "connectionName",
|
|
99
|
+
"resultAttribute": "resultAttribute"
|
|
100
|
+
},
|
|
101
|
+
"branches": [
|
|
102
|
+
{
|
|
103
|
+
"id": "found",
|
|
104
|
+
"field": "found",
|
|
105
|
+
"optional": false
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "notFound",
|
|
109
|
+
"field": "notFound",
|
|
110
|
+
"optional": true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "quotaExhausted",
|
|
114
|
+
"field": "quotaExhausted",
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "providerRejected",
|
|
119
|
+
"field": "providerRejected",
|
|
120
|
+
"optional": true
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "invalidResponse",
|
|
124
|
+
"field": "invalidResponse",
|
|
125
|
+
"optional": true
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "defect",
|
|
129
|
+
"field": "defect",
|
|
130
|
+
"optional": true
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "newListPlaylistItemsStep",
|
|
136
|
+
"kind": "query",
|
|
137
|
+
"operationId": "listPlaylistItems",
|
|
138
|
+
"fields": {
|
|
139
|
+
"stepType": "stepType",
|
|
140
|
+
"annotations": "annotations",
|
|
141
|
+
"connectionName": "connectionName",
|
|
142
|
+
"resultAttribute": "resultAttribute"
|
|
143
|
+
},
|
|
144
|
+
"branches": [
|
|
145
|
+
{
|
|
146
|
+
"id": "listed",
|
|
147
|
+
"field": "listed",
|
|
148
|
+
"optional": false
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "notFound",
|
|
152
|
+
"field": "notFound",
|
|
153
|
+
"optional": true
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "quotaExhausted",
|
|
157
|
+
"field": "quotaExhausted",
|
|
158
|
+
"optional": true
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": "providerRejected",
|
|
162
|
+
"field": "providerRejected",
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "invalidResponse",
|
|
167
|
+
"field": "invalidResponse",
|
|
168
|
+
"optional": true
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": "defect",
|
|
172
|
+
"field": "defect",
|
|
173
|
+
"optional": true
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "newAddPlaylistItemStep",
|
|
179
|
+
"kind": "mutation",
|
|
180
|
+
"operationId": "addPlaylistItem",
|
|
181
|
+
"fields": {
|
|
182
|
+
"stepType": "stepType",
|
|
183
|
+
"annotations": "annotations",
|
|
184
|
+
"connectionName": "connectionName",
|
|
185
|
+
"resultAttribute": "resultAttribute"
|
|
186
|
+
},
|
|
187
|
+
"branches": [
|
|
188
|
+
{
|
|
189
|
+
"id": "added",
|
|
190
|
+
"field": "added",
|
|
191
|
+
"optional": false
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"id": "notFound",
|
|
195
|
+
"field": "notFound",
|
|
196
|
+
"optional": true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"id": "quotaExhausted",
|
|
200
|
+
"field": "quotaExhausted",
|
|
201
|
+
"optional": true
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "providerRejected",
|
|
205
|
+
"field": "providerRejected",
|
|
206
|
+
"optional": true
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "invalidResponse",
|
|
210
|
+
"field": "invalidResponse",
|
|
211
|
+
"optional": true
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "defect",
|
|
215
|
+
"field": "defect",
|
|
216
|
+
"optional": true
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
// src/generated/models.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
+
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
+
function isGoTimeJSON(value) {
|
|
6
|
+
const match = goTimeJSONPattern.exec(value);
|
|
7
|
+
if (!match) return false;
|
|
8
|
+
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
+
const year = Number(yearText);
|
|
10
|
+
const month = Number(monthText);
|
|
11
|
+
const day = Number(dayText);
|
|
12
|
+
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
+
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
+
}
|
|
16
|
+
function canonicalGoTimeJSON(value) {
|
|
17
|
+
const match = goTimeJSONPattern.exec(value);
|
|
18
|
+
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
+
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
+
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
+
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
+
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
+
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
+
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
+
}
|
|
26
|
+
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
27
|
+
var ConfigSchema = z.object({
|
|
28
|
+
"endpoint": z.string().optional(),
|
|
29
|
+
"maxResponseBytes": z.number().int().optional()
|
|
30
|
+
});
|
|
31
|
+
function decodeCredentials(value) {
|
|
32
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
33
|
+
const fields = value;
|
|
34
|
+
const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
35
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
36
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
37
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
38
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
39
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
40
|
+
const selectedMethod = fields["auth_method"] ?? "";
|
|
41
|
+
if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
|
|
42
|
+
const method = selectedMethod || "google-oauth-readonly";
|
|
43
|
+
const credentials = { authMethodId: method };
|
|
44
|
+
if (method === "google-oauth-readonly") {
|
|
45
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
46
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
47
|
+
if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
|
|
48
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
49
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
50
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
51
|
+
if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
|
|
52
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
53
|
+
} else if (method === "google-oauth-manage") {
|
|
54
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
55
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
56
|
+
if (!fields["oauth_client_secret"]) throw new TypeError("credential oauth_client_secret is required");
|
|
57
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
58
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
59
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
60
|
+
if (!fields["refresh_token"]) throw new TypeError("credential refresh_token is required");
|
|
61
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
62
|
+
} else {
|
|
63
|
+
throw new TypeError("credential auth_method is invalid");
|
|
64
|
+
}
|
|
65
|
+
return credentials;
|
|
66
|
+
}
|
|
67
|
+
function decodeSharedCredentials(value) {
|
|
68
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new TypeError("credential fields are invalid");
|
|
69
|
+
const fields = value;
|
|
70
|
+
const allowed = /* @__PURE__ */ new Set(["auth_method", "access_token", "oauth_client_id", "oauth_client_secret", "refresh_token"]);
|
|
71
|
+
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new TypeError("stored credential does not match the connector credential fields");
|
|
72
|
+
if (fields["access_token"] != null && !(typeof fields["access_token"] === "string")) throw new TypeError("credential access_token has an invalid type");
|
|
73
|
+
if (fields["oauth_client_id"] != null && !(typeof fields["oauth_client_id"] === "string")) throw new TypeError("credential oauth_client_id has an invalid type");
|
|
74
|
+
if (fields["oauth_client_secret"] != null && !(typeof fields["oauth_client_secret"] === "string")) throw new TypeError("credential oauth_client_secret has an invalid type");
|
|
75
|
+
if (fields["refresh_token"] != null && !(typeof fields["refresh_token"] === "string")) throw new TypeError("credential refresh_token has an invalid type");
|
|
76
|
+
const selectedMethod = fields["auth_method"] ?? "";
|
|
77
|
+
if (typeof selectedMethod !== "string") throw new TypeError("credential auth_method is invalid");
|
|
78
|
+
const method = selectedMethod || "google-oauth-readonly";
|
|
79
|
+
const credentials = { authMethodId: method };
|
|
80
|
+
if (method === "google-oauth-readonly") {
|
|
81
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
82
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
83
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
84
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
85
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
86
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
87
|
+
} else if (method === "google-oauth-manage") {
|
|
88
|
+
if (!fields["oauth_client_id"]) throw new TypeError("credential oauth_client_id is required");
|
|
89
|
+
if (fields["oauth_client_id"]) credentials.oauthClientId = fields["oauth_client_id"];
|
|
90
|
+
if (fields["oauth_client_secret"]) credentials.oauthClientSecret = new SecretString(fields["oauth_client_secret"]);
|
|
91
|
+
if (!fields["access_token"]) throw new TypeError("credential access_token is required");
|
|
92
|
+
if (fields["access_token"]) credentials.accessToken = new SecretString(fields["access_token"]);
|
|
93
|
+
if (fields["refresh_token"]) credentials.refreshToken = new SecretString(fields["refresh_token"]);
|
|
94
|
+
} else {
|
|
95
|
+
throw new TypeError("credential auth_method is invalid");
|
|
96
|
+
}
|
|
97
|
+
return credentials;
|
|
98
|
+
}
|
|
99
|
+
var SearchVideosInputSchema = z.strictObject({
|
|
100
|
+
"query": z.string().optional(),
|
|
101
|
+
"channelId": z.string().optional(),
|
|
102
|
+
"order": z.string().optional(),
|
|
103
|
+
"publishedAfter": GoTimeJSONSchema.nullable().optional(),
|
|
104
|
+
"maxResults": z.number().int().optional(),
|
|
105
|
+
"pageToken": z.string().optional()
|
|
106
|
+
});
|
|
107
|
+
var VideoSearchResultSchema = z.strictObject({
|
|
108
|
+
"videoId": z.string(),
|
|
109
|
+
"channelId": z.string(),
|
|
110
|
+
"channelTitle": z.string(),
|
|
111
|
+
"title": z.string(),
|
|
112
|
+
"description": z.string(),
|
|
113
|
+
"publishedAt": GoTimeJSONSchema
|
|
114
|
+
});
|
|
115
|
+
var VideoSearchPageSchema = z.strictObject({
|
|
116
|
+
"results": z.array(VideoSearchResultSchema).nullable(),
|
|
117
|
+
"nextPageToken": z.string().optional(),
|
|
118
|
+
"totalResults": z.number().int()
|
|
119
|
+
});
|
|
120
|
+
var GetVideoInputSchema = z.strictObject({
|
|
121
|
+
"videoId": z.string()
|
|
122
|
+
});
|
|
123
|
+
var VideoSchema = z.strictObject({
|
|
124
|
+
"id": z.string(),
|
|
125
|
+
"channelId": z.string(),
|
|
126
|
+
"channelTitle": z.string(),
|
|
127
|
+
"title": z.string(),
|
|
128
|
+
"description": z.string(),
|
|
129
|
+
"publishedAt": GoTimeJSONSchema,
|
|
130
|
+
"duration": z.string().optional(),
|
|
131
|
+
"privacyStatus": z.string(),
|
|
132
|
+
"viewCount": z.number().int().optional(),
|
|
133
|
+
"likeCount": z.number().int().optional(),
|
|
134
|
+
"commentCount": z.number().int().optional()
|
|
135
|
+
});
|
|
136
|
+
var GetChannelInputSchema = z.strictObject({
|
|
137
|
+
"channelId": z.string().optional(),
|
|
138
|
+
"handle": z.string().optional(),
|
|
139
|
+
"mine": z.boolean().optional()
|
|
140
|
+
});
|
|
141
|
+
var ChannelSchema = z.strictObject({
|
|
142
|
+
"id": z.string(),
|
|
143
|
+
"title": z.string(),
|
|
144
|
+
"description": z.string(),
|
|
145
|
+
"customUrl": z.string().optional(),
|
|
146
|
+
"publishedAt": GoTimeJSONSchema,
|
|
147
|
+
"uploadsPlaylistId": z.string(),
|
|
148
|
+
"subscriberCount": z.number().int().optional(),
|
|
149
|
+
"videoCount": z.number().int().optional(),
|
|
150
|
+
"viewCount": z.number().int().optional()
|
|
151
|
+
});
|
|
152
|
+
var ListPlaylistItemsInputSchema = z.strictObject({
|
|
153
|
+
"playlistId": z.string(),
|
|
154
|
+
"videoId": z.string().optional(),
|
|
155
|
+
"maxResults": z.number().int().optional(),
|
|
156
|
+
"pageToken": z.string().optional()
|
|
157
|
+
});
|
|
158
|
+
var PlaylistItemSchema = z.strictObject({
|
|
159
|
+
"id": z.string(),
|
|
160
|
+
"playlistId": z.string(),
|
|
161
|
+
"videoId": z.string(),
|
|
162
|
+
"title": z.string(),
|
|
163
|
+
"position": z.number().int(),
|
|
164
|
+
"addedAt": GoTimeJSONSchema,
|
|
165
|
+
"videoPublishedAt": GoTimeJSONSchema.nullable().optional()
|
|
166
|
+
});
|
|
167
|
+
var PlaylistItemPageSchema = z.strictObject({
|
|
168
|
+
"items": z.array(PlaylistItemSchema).nullable(),
|
|
169
|
+
"nextPageToken": z.string().optional(),
|
|
170
|
+
"totalResults": z.number().int()
|
|
171
|
+
});
|
|
172
|
+
var AddPlaylistItemInputSchema = z.strictObject({
|
|
173
|
+
"playlistId": z.string(),
|
|
174
|
+
"videoId": z.string()
|
|
175
|
+
});
|
|
176
|
+
var AddedPlaylistItemSchema = z.strictObject({
|
|
177
|
+
"item": PlaylistItemSchema,
|
|
178
|
+
"wasAlreadyPresent": z.boolean()
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// src/generated/definitions.ts
|
|
182
|
+
var ConnectorID = "google-youtube";
|
|
183
|
+
var ProviderID = "google";
|
|
184
|
+
var SearchVideosBranch = {
|
|
185
|
+
Searched: "searched",
|
|
186
|
+
QuotaExhausted: "quotaExhausted",
|
|
187
|
+
ProviderRejected: "providerRejected",
|
|
188
|
+
InvalidResponse: "invalidResponse",
|
|
189
|
+
Defect: "defect"
|
|
190
|
+
};
|
|
191
|
+
var SearchVideosBranchSearched = SearchVideosBranch.Searched;
|
|
192
|
+
var SearchVideosBranchQuotaExhausted = SearchVideosBranch.QuotaExhausted;
|
|
193
|
+
var SearchVideosBranchProviderRejected = SearchVideosBranch.ProviderRejected;
|
|
194
|
+
var SearchVideosBranchInvalidResponse = SearchVideosBranch.InvalidResponse;
|
|
195
|
+
var SearchVideosBranchDefect = SearchVideosBranch.Defect;
|
|
196
|
+
var SearchVideosDefinition = {
|
|
197
|
+
operation: { connectorId: ConnectorID, operationId: "searchVideos" },
|
|
198
|
+
branches: [
|
|
199
|
+
{ id: "searched", description: "YouTube returned one page of matching videos; the page may be empty." },
|
|
200
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
201
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the search, such as an invalid parameter, a missing scope, or a revoked grant.", optional: true },
|
|
202
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized search response.", optional: true },
|
|
203
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
204
|
+
],
|
|
205
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
206
|
+
};
|
|
207
|
+
var SearchVideosMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
208
|
+
var GetVideoBranch = {
|
|
209
|
+
Found: "found",
|
|
210
|
+
NotFound: "notFound",
|
|
211
|
+
QuotaExhausted: "quotaExhausted",
|
|
212
|
+
ProviderRejected: "providerRejected",
|
|
213
|
+
InvalidResponse: "invalidResponse",
|
|
214
|
+
Defect: "defect"
|
|
215
|
+
};
|
|
216
|
+
var GetVideoBranchFound = GetVideoBranch.Found;
|
|
217
|
+
var GetVideoBranchNotFound = GetVideoBranch.NotFound;
|
|
218
|
+
var GetVideoBranchQuotaExhausted = GetVideoBranch.QuotaExhausted;
|
|
219
|
+
var GetVideoBranchProviderRejected = GetVideoBranch.ProviderRejected;
|
|
220
|
+
var GetVideoBranchInvalidResponse = GetVideoBranch.InvalidResponse;
|
|
221
|
+
var GetVideoBranchDefect = GetVideoBranch.Defect;
|
|
222
|
+
var GetVideoDefinition = {
|
|
223
|
+
operation: { connectorId: ConnectorID, operationId: "getVideo" },
|
|
224
|
+
branches: [
|
|
225
|
+
{ id: "found", description: "The video exists and the account can see it." },
|
|
226
|
+
{ id: "notFound", description: "No visible video has the ID, such as a deleted or private video.", optional: true },
|
|
227
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
228
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the read, such as a missing scope or a revoked grant.", optional: true },
|
|
229
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized video response.", optional: true },
|
|
230
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
231
|
+
],
|
|
232
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
233
|
+
};
|
|
234
|
+
var GetVideoMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
235
|
+
var GetChannelBranch = {
|
|
236
|
+
Found: "found",
|
|
237
|
+
NotFound: "notFound",
|
|
238
|
+
QuotaExhausted: "quotaExhausted",
|
|
239
|
+
ProviderRejected: "providerRejected",
|
|
240
|
+
InvalidResponse: "invalidResponse",
|
|
241
|
+
Defect: "defect"
|
|
242
|
+
};
|
|
243
|
+
var GetChannelBranchFound = GetChannelBranch.Found;
|
|
244
|
+
var GetChannelBranchNotFound = GetChannelBranch.NotFound;
|
|
245
|
+
var GetChannelBranchQuotaExhausted = GetChannelBranch.QuotaExhausted;
|
|
246
|
+
var GetChannelBranchProviderRejected = GetChannelBranch.ProviderRejected;
|
|
247
|
+
var GetChannelBranchInvalidResponse = GetChannelBranch.InvalidResponse;
|
|
248
|
+
var GetChannelBranchDefect = GetChannelBranch.Defect;
|
|
249
|
+
var GetChannelDefinition = {
|
|
250
|
+
operation: { connectorId: ConnectorID, operationId: "getChannel" },
|
|
251
|
+
branches: [
|
|
252
|
+
{ id: "found", description: "The channel exists and was returned." },
|
|
253
|
+
{ id: "notFound", description: "No channel has the ID or handle, or the authorized account has no channel.", optional: true },
|
|
254
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
255
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the read, such as a missing scope or a revoked grant.", optional: true },
|
|
256
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized channel response.", optional: true },
|
|
257
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
258
|
+
],
|
|
259
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
260
|
+
};
|
|
261
|
+
var GetChannelMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
262
|
+
var ListPlaylistItemsBranch = {
|
|
263
|
+
Listed: "listed",
|
|
264
|
+
NotFound: "notFound",
|
|
265
|
+
QuotaExhausted: "quotaExhausted",
|
|
266
|
+
ProviderRejected: "providerRejected",
|
|
267
|
+
InvalidResponse: "invalidResponse",
|
|
268
|
+
Defect: "defect"
|
|
269
|
+
};
|
|
270
|
+
var ListPlaylistItemsBranchListed = ListPlaylistItemsBranch.Listed;
|
|
271
|
+
var ListPlaylistItemsBranchNotFound = ListPlaylistItemsBranch.NotFound;
|
|
272
|
+
var ListPlaylistItemsBranchQuotaExhausted = ListPlaylistItemsBranch.QuotaExhausted;
|
|
273
|
+
var ListPlaylistItemsBranchProviderRejected = ListPlaylistItemsBranch.ProviderRejected;
|
|
274
|
+
var ListPlaylistItemsBranchInvalidResponse = ListPlaylistItemsBranch.InvalidResponse;
|
|
275
|
+
var ListPlaylistItemsBranchDefect = ListPlaylistItemsBranch.Defect;
|
|
276
|
+
var ListPlaylistItemsDefinition = {
|
|
277
|
+
operation: { connectorId: ConnectorID, operationId: "listPlaylistItems" },
|
|
278
|
+
branches: [
|
|
279
|
+
{ id: "listed", description: "YouTube returned one page of playlist items; the page may be empty." },
|
|
280
|
+
{ id: "notFound", description: "No playlist visible to the account has the ID.", optional: true },
|
|
281
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
282
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the listing, such as a private playlist of another account or a revoked grant.", optional: true },
|
|
283
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized playlist page.", optional: true },
|
|
284
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
285
|
+
],
|
|
286
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
287
|
+
};
|
|
288
|
+
var ListPlaylistItemsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
289
|
+
var AddPlaylistItemBranch = {
|
|
290
|
+
Added: "added",
|
|
291
|
+
NotFound: "notFound",
|
|
292
|
+
QuotaExhausted: "quotaExhausted",
|
|
293
|
+
ProviderRejected: "providerRejected",
|
|
294
|
+
InvalidResponse: "invalidResponse",
|
|
295
|
+
Defect: "defect"
|
|
296
|
+
};
|
|
297
|
+
var AddPlaylistItemBranchAdded = AddPlaylistItemBranch.Added;
|
|
298
|
+
var AddPlaylistItemBranchNotFound = AddPlaylistItemBranch.NotFound;
|
|
299
|
+
var AddPlaylistItemBranchQuotaExhausted = AddPlaylistItemBranch.QuotaExhausted;
|
|
300
|
+
var AddPlaylistItemBranchProviderRejected = AddPlaylistItemBranch.ProviderRejected;
|
|
301
|
+
var AddPlaylistItemBranchInvalidResponse = AddPlaylistItemBranch.InvalidResponse;
|
|
302
|
+
var AddPlaylistItemBranchDefect = AddPlaylistItemBranch.Defect;
|
|
303
|
+
var AddPlaylistItemDefinition = {
|
|
304
|
+
operation: { connectorId: ConnectorID, operationId: "addPlaylistItem" },
|
|
305
|
+
branches: [
|
|
306
|
+
{ id: "added", description: "The playlist holds the video, added now or found already present." },
|
|
307
|
+
{ id: "notFound", description: "No playlist the account can manage or no visible video has the ID.", optional: true },
|
|
308
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
309
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the insert, such as a playlist of another account, a full playlist, or a revoked grant.", optional: true },
|
|
310
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized response to the check or the insert.", optional: true },
|
|
311
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
312
|
+
],
|
|
313
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
|
|
314
|
+
};
|
|
315
|
+
var AddPlaylistItemMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
316
|
+
|
|
317
|
+
// src/generated/connection.ts
|
|
318
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
319
|
+
import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
320
|
+
var Connection = class {
|
|
321
|
+
/** Stable provider and connection name. */
|
|
322
|
+
reference;
|
|
323
|
+
/** Bound provider operations. */
|
|
324
|
+
operations;
|
|
325
|
+
/** Validate a reference and bind operations. */
|
|
326
|
+
constructor(reference, operations) {
|
|
327
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
328
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
329
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
330
|
+
this.operations = operations;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function newConnection(client, reference) {
|
|
334
|
+
if (!client) throw new TypeError("connector client is required");
|
|
335
|
+
return new Connection(reference, client);
|
|
336
|
+
}
|
|
337
|
+
function newConnectionWithOperations(operations, reference) {
|
|
338
|
+
return new Connection(reference, operations);
|
|
339
|
+
}
|
|
340
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
341
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
342
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
343
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
344
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
345
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
346
|
+
}
|
|
347
|
+
function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
|
|
348
|
+
return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export {
|
|
352
|
+
ConfigSchema,
|
|
353
|
+
decodeCredentials,
|
|
354
|
+
decodeSharedCredentials,
|
|
355
|
+
SearchVideosInputSchema,
|
|
356
|
+
VideoSearchResultSchema,
|
|
357
|
+
VideoSearchPageSchema,
|
|
358
|
+
GetVideoInputSchema,
|
|
359
|
+
VideoSchema,
|
|
360
|
+
GetChannelInputSchema,
|
|
361
|
+
ChannelSchema,
|
|
362
|
+
ListPlaylistItemsInputSchema,
|
|
363
|
+
PlaylistItemSchema,
|
|
364
|
+
PlaylistItemPageSchema,
|
|
365
|
+
AddPlaylistItemInputSchema,
|
|
366
|
+
AddedPlaylistItemSchema,
|
|
367
|
+
ConnectorID,
|
|
368
|
+
ProviderID,
|
|
369
|
+
SearchVideosBranch,
|
|
370
|
+
SearchVideosBranchSearched,
|
|
371
|
+
SearchVideosBranchQuotaExhausted,
|
|
372
|
+
SearchVideosBranchProviderRejected,
|
|
373
|
+
SearchVideosBranchInvalidResponse,
|
|
374
|
+
SearchVideosBranchDefect,
|
|
375
|
+
SearchVideosDefinition,
|
|
376
|
+
SearchVideosMetadata,
|
|
377
|
+
GetVideoBranch,
|
|
378
|
+
GetVideoBranchFound,
|
|
379
|
+
GetVideoBranchNotFound,
|
|
380
|
+
GetVideoBranchQuotaExhausted,
|
|
381
|
+
GetVideoBranchProviderRejected,
|
|
382
|
+
GetVideoBranchInvalidResponse,
|
|
383
|
+
GetVideoBranchDefect,
|
|
384
|
+
GetVideoDefinition,
|
|
385
|
+
GetVideoMetadata,
|
|
386
|
+
GetChannelBranch,
|
|
387
|
+
GetChannelBranchFound,
|
|
388
|
+
GetChannelBranchNotFound,
|
|
389
|
+
GetChannelBranchQuotaExhausted,
|
|
390
|
+
GetChannelBranchProviderRejected,
|
|
391
|
+
GetChannelBranchInvalidResponse,
|
|
392
|
+
GetChannelBranchDefect,
|
|
393
|
+
GetChannelDefinition,
|
|
394
|
+
GetChannelMetadata,
|
|
395
|
+
ListPlaylistItemsBranch,
|
|
396
|
+
ListPlaylistItemsBranchListed,
|
|
397
|
+
ListPlaylistItemsBranchNotFound,
|
|
398
|
+
ListPlaylistItemsBranchQuotaExhausted,
|
|
399
|
+
ListPlaylistItemsBranchProviderRejected,
|
|
400
|
+
ListPlaylistItemsBranchInvalidResponse,
|
|
401
|
+
ListPlaylistItemsBranchDefect,
|
|
402
|
+
ListPlaylistItemsDefinition,
|
|
403
|
+
ListPlaylistItemsMetadata,
|
|
404
|
+
AddPlaylistItemBranch,
|
|
405
|
+
AddPlaylistItemBranchAdded,
|
|
406
|
+
AddPlaylistItemBranchNotFound,
|
|
407
|
+
AddPlaylistItemBranchQuotaExhausted,
|
|
408
|
+
AddPlaylistItemBranchProviderRejected,
|
|
409
|
+
AddPlaylistItemBranchInvalidResponse,
|
|
410
|
+
AddPlaylistItemBranchDefect,
|
|
411
|
+
AddPlaylistItemDefinition,
|
|
412
|
+
AddPlaylistItemMetadata,
|
|
413
|
+
Connection,
|
|
414
|
+
newConnection,
|
|
415
|
+
newConnectionWithOperations,
|
|
416
|
+
newProjectConnection,
|
|
417
|
+
newProjectCredentialProvider
|
|
418
|
+
};
|