@superdurable/connector-google-youtube 0.0.0-stage → 0.2.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 +400 -0
- package/dist/chunk-UAP7AK3Z.js +422 -0
- package/dist/connection-cA6SHIc_.d.ts +332 -0
- package/dist/index.d.ts +364 -0
- package/dist/index.js +953 -0
- package/dist/mock.d.ts +163 -0
- package/dist/mock.js +397 -0
- package/package.json +64 -4
|
@@ -0,0 +1,422 @@
|
|
|
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
|
+
Uncertain: "uncertain",
|
|
296
|
+
Defect: "defect"
|
|
297
|
+
};
|
|
298
|
+
var AddPlaylistItemBranchAdded = AddPlaylistItemBranch.Added;
|
|
299
|
+
var AddPlaylistItemBranchNotFound = AddPlaylistItemBranch.NotFound;
|
|
300
|
+
var AddPlaylistItemBranchQuotaExhausted = AddPlaylistItemBranch.QuotaExhausted;
|
|
301
|
+
var AddPlaylistItemBranchProviderRejected = AddPlaylistItemBranch.ProviderRejected;
|
|
302
|
+
var AddPlaylistItemBranchInvalidResponse = AddPlaylistItemBranch.InvalidResponse;
|
|
303
|
+
var AddPlaylistItemBranchUncertain = AddPlaylistItemBranch.Uncertain;
|
|
304
|
+
var AddPlaylistItemBranchDefect = AddPlaylistItemBranch.Defect;
|
|
305
|
+
var AddPlaylistItemDefinition = {
|
|
306
|
+
operation: { connectorId: ConnectorID, operationId: "addPlaylistItem" },
|
|
307
|
+
branches: [
|
|
308
|
+
{ id: "added", description: "The playlist holds the video, added now or found already present." },
|
|
309
|
+
{ id: "notFound", description: "No playlist the account can manage or no visible video has the ID.", optional: true },
|
|
310
|
+
{ id: "quotaExhausted", description: "The project's daily YouTube Data API quota is spent; it resets at midnight Pacific Time.", optional: true },
|
|
311
|
+
{ id: "providerRejected", description: "YouTube conclusively rejected the insert, such as a playlist of another account, a full playlist, or a revoked grant.", optional: true },
|
|
312
|
+
{ id: "invalidResponse", description: "YouTube returned an invalid or oversized check response, or an invalid item after accepting the insert.", optional: true },
|
|
313
|
+
{ id: "uncertain", description: "An earlier insert may have added the video, but the playlist listing does not show it; check the playlist before adding it again.", optional: true },
|
|
314
|
+
{ id: "defect", description: "Local input, connection configuration, or credentials are invalid.", optional: true }
|
|
315
|
+
],
|
|
316
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 5, totalDurationMs: 12e4 } }
|
|
317
|
+
};
|
|
318
|
+
var AddPlaylistItemMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
319
|
+
|
|
320
|
+
// src/generated/connection.ts
|
|
321
|
+
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
322
|
+
import { newRefreshingCredentialProvider } from "@superdurable/connectors-sdk/projectconfig";
|
|
323
|
+
var Connection = class {
|
|
324
|
+
/** Stable provider and connection name. */
|
|
325
|
+
reference;
|
|
326
|
+
/** Bound provider operations. */
|
|
327
|
+
operations;
|
|
328
|
+
/** Validate a reference and bind operations. */
|
|
329
|
+
constructor(reference, operations) {
|
|
330
|
+
this.reference = ConnectionRefSchema.parse(reference);
|
|
331
|
+
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
332
|
+
if (!operations) throw new TypeError("connector operations are required");
|
|
333
|
+
this.operations = operations;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
function newConnection(client, reference) {
|
|
337
|
+
if (!client) throw new TypeError("connector client is required");
|
|
338
|
+
return new Connection(reference, client);
|
|
339
|
+
}
|
|
340
|
+
function newConnectionWithOperations(operations, reference) {
|
|
341
|
+
return new Connection(reference, operations);
|
|
342
|
+
}
|
|
343
|
+
function newProjectConnection(project, connectionName, createClient) {
|
|
344
|
+
if (!project) throw new TypeError("loaded project is required");
|
|
345
|
+
const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
|
|
346
|
+
const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
|
|
347
|
+
if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
|
|
348
|
+
return newConnection(createClient(project, connectionName), reference);
|
|
349
|
+
}
|
|
350
|
+
function newProjectCredentialProvider(project, connectionName, decode, encode, decodeShared) {
|
|
351
|
+
return newRefreshingCredentialProvider(project.connections, { connectorId: ConnectorID, connectionName }, decode, encode, decodeShared);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export {
|
|
355
|
+
ConfigSchema,
|
|
356
|
+
decodeCredentials,
|
|
357
|
+
decodeSharedCredentials,
|
|
358
|
+
SearchVideosInputSchema,
|
|
359
|
+
VideoSearchResultSchema,
|
|
360
|
+
VideoSearchPageSchema,
|
|
361
|
+
GetVideoInputSchema,
|
|
362
|
+
VideoSchema,
|
|
363
|
+
GetChannelInputSchema,
|
|
364
|
+
ChannelSchema,
|
|
365
|
+
ListPlaylistItemsInputSchema,
|
|
366
|
+
PlaylistItemSchema,
|
|
367
|
+
PlaylistItemPageSchema,
|
|
368
|
+
AddPlaylistItemInputSchema,
|
|
369
|
+
AddedPlaylistItemSchema,
|
|
370
|
+
ConnectorID,
|
|
371
|
+
ProviderID,
|
|
372
|
+
SearchVideosBranch,
|
|
373
|
+
SearchVideosBranchSearched,
|
|
374
|
+
SearchVideosBranchQuotaExhausted,
|
|
375
|
+
SearchVideosBranchProviderRejected,
|
|
376
|
+
SearchVideosBranchInvalidResponse,
|
|
377
|
+
SearchVideosBranchDefect,
|
|
378
|
+
SearchVideosDefinition,
|
|
379
|
+
SearchVideosMetadata,
|
|
380
|
+
GetVideoBranch,
|
|
381
|
+
GetVideoBranchFound,
|
|
382
|
+
GetVideoBranchNotFound,
|
|
383
|
+
GetVideoBranchQuotaExhausted,
|
|
384
|
+
GetVideoBranchProviderRejected,
|
|
385
|
+
GetVideoBranchInvalidResponse,
|
|
386
|
+
GetVideoBranchDefect,
|
|
387
|
+
GetVideoDefinition,
|
|
388
|
+
GetVideoMetadata,
|
|
389
|
+
GetChannelBranch,
|
|
390
|
+
GetChannelBranchFound,
|
|
391
|
+
GetChannelBranchNotFound,
|
|
392
|
+
GetChannelBranchQuotaExhausted,
|
|
393
|
+
GetChannelBranchProviderRejected,
|
|
394
|
+
GetChannelBranchInvalidResponse,
|
|
395
|
+
GetChannelBranchDefect,
|
|
396
|
+
GetChannelDefinition,
|
|
397
|
+
GetChannelMetadata,
|
|
398
|
+
ListPlaylistItemsBranch,
|
|
399
|
+
ListPlaylistItemsBranchListed,
|
|
400
|
+
ListPlaylistItemsBranchNotFound,
|
|
401
|
+
ListPlaylistItemsBranchQuotaExhausted,
|
|
402
|
+
ListPlaylistItemsBranchProviderRejected,
|
|
403
|
+
ListPlaylistItemsBranchInvalidResponse,
|
|
404
|
+
ListPlaylistItemsBranchDefect,
|
|
405
|
+
ListPlaylistItemsDefinition,
|
|
406
|
+
ListPlaylistItemsMetadata,
|
|
407
|
+
AddPlaylistItemBranch,
|
|
408
|
+
AddPlaylistItemBranchAdded,
|
|
409
|
+
AddPlaylistItemBranchNotFound,
|
|
410
|
+
AddPlaylistItemBranchQuotaExhausted,
|
|
411
|
+
AddPlaylistItemBranchProviderRejected,
|
|
412
|
+
AddPlaylistItemBranchInvalidResponse,
|
|
413
|
+
AddPlaylistItemBranchUncertain,
|
|
414
|
+
AddPlaylistItemBranchDefect,
|
|
415
|
+
AddPlaylistItemDefinition,
|
|
416
|
+
AddPlaylistItemMetadata,
|
|
417
|
+
Connection,
|
|
418
|
+
newConnection,
|
|
419
|
+
newConnectionWithOperations,
|
|
420
|
+
newProjectConnection,
|
|
421
|
+
newProjectCredentialProvider
|
|
422
|
+
};
|