@superartifacts/sdk 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 +21 -0
- package/README.md +158 -2
- package/dist/index.cjs +788 -0
- package/dist/index.d.cts +2399 -0
- package/dist/index.d.ts +2399 -0
- package/dist/index.js +745 -0
- package/package.json +58 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AuthenticationError: () => AuthenticationError,
|
|
24
|
+
ConflictError: () => ConflictError,
|
|
25
|
+
ConnectionError: () => ConnectionError,
|
|
26
|
+
InternalError: () => InternalError,
|
|
27
|
+
InvalidArgumentsError: () => InvalidArgumentsError,
|
|
28
|
+
NotFoundError: () => NotFoundError,
|
|
29
|
+
OPERATIONS: () => OPERATIONS,
|
|
30
|
+
PayloadTooLargeError: () => PayloadTooLargeError,
|
|
31
|
+
PermissionError: () => PermissionError,
|
|
32
|
+
PlanLimitError: () => PlanLimitError,
|
|
33
|
+
RateLimitError: () => RateLimitError,
|
|
34
|
+
ScopeRequiredError: () => ScopeRequiredError,
|
|
35
|
+
SuperArtifacts: () => SuperArtifacts,
|
|
36
|
+
SuperArtifactsError: () => SuperArtifactsError,
|
|
37
|
+
TimeoutError: () => TimeoutError,
|
|
38
|
+
VERSION: () => VERSION,
|
|
39
|
+
default: () => SuperArtifacts,
|
|
40
|
+
errorFor: () => errorFor
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
|
+
|
|
44
|
+
// src/errors.ts
|
|
45
|
+
var SuperArtifactsError = class extends Error {
|
|
46
|
+
status;
|
|
47
|
+
/** Stable and machine-readable; `message` is for a person. */
|
|
48
|
+
code;
|
|
49
|
+
/** Seconds the API asked to wait. */
|
|
50
|
+
retryAfter;
|
|
51
|
+
/** Everything else the API said, e.g. `fix` or `approvalUrl`. */
|
|
52
|
+
details;
|
|
53
|
+
constructor(status, code, message, retryAfter, details = {}, options) {
|
|
54
|
+
super(message, options);
|
|
55
|
+
this.name = new.target.name;
|
|
56
|
+
if (status !== void 0) this.status = status;
|
|
57
|
+
if (code !== void 0) this.code = code;
|
|
58
|
+
if (retryAfter !== void 0) this.retryAfter = retryAfter;
|
|
59
|
+
this.details = details;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var InvalidArgumentsError = class extends SuperArtifactsError {
|
|
63
|
+
};
|
|
64
|
+
var AuthenticationError = class extends SuperArtifactsError {
|
|
65
|
+
};
|
|
66
|
+
var PlanLimitError = class extends SuperArtifactsError {
|
|
67
|
+
};
|
|
68
|
+
var PermissionError = class extends SuperArtifactsError {
|
|
69
|
+
};
|
|
70
|
+
var ScopeRequiredError = class extends SuperArtifactsError {
|
|
71
|
+
};
|
|
72
|
+
var NotFoundError = class extends SuperArtifactsError {
|
|
73
|
+
};
|
|
74
|
+
var ConflictError = class extends SuperArtifactsError {
|
|
75
|
+
};
|
|
76
|
+
var PayloadTooLargeError = class extends SuperArtifactsError {
|
|
77
|
+
};
|
|
78
|
+
var RateLimitError = class extends SuperArtifactsError {
|
|
79
|
+
};
|
|
80
|
+
var InternalError = class extends SuperArtifactsError {
|
|
81
|
+
};
|
|
82
|
+
var ConnectionError = class extends SuperArtifactsError {
|
|
83
|
+
};
|
|
84
|
+
var TimeoutError = class extends SuperArtifactsError {
|
|
85
|
+
};
|
|
86
|
+
function errorClass(status, code) {
|
|
87
|
+
if (status >= 500) return InternalError;
|
|
88
|
+
if (status === 403) return code === "scope_required" ? ScopeRequiredError : PermissionError;
|
|
89
|
+
const byStatus = {
|
|
90
|
+
400: InvalidArgumentsError,
|
|
91
|
+
401: AuthenticationError,
|
|
92
|
+
402: PlanLimitError,
|
|
93
|
+
404: NotFoundError,
|
|
94
|
+
409: ConflictError,
|
|
95
|
+
413: PayloadTooLargeError,
|
|
96
|
+
422: InvalidArgumentsError,
|
|
97
|
+
429: RateLimitError
|
|
98
|
+
};
|
|
99
|
+
return byStatus[status] ?? SuperArtifactsError;
|
|
100
|
+
}
|
|
101
|
+
function errorFor(status, text, retryAfterHeader) {
|
|
102
|
+
let error = {};
|
|
103
|
+
try {
|
|
104
|
+
const parsed = JSON.parse(text);
|
|
105
|
+
if (typeof parsed?.error === "object" && parsed.error !== null) {
|
|
106
|
+
error = parsed.error;
|
|
107
|
+
}
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
const { code, message, retryAfterSeconds, ...details } = error;
|
|
111
|
+
const named = typeof code === "string" ? code : "http_error";
|
|
112
|
+
const seconds = Number(retryAfterHeader ?? retryAfterSeconds);
|
|
113
|
+
const retryAfter = (retryAfterHeader !== null || retryAfterSeconds !== void 0) && Number.isFinite(seconds) ? seconds : void 0;
|
|
114
|
+
return new (errorClass(status, named))(
|
|
115
|
+
status,
|
|
116
|
+
named,
|
|
117
|
+
typeof message === "string" ? message : `The API answered ${status} without an error body.`,
|
|
118
|
+
retryAfter,
|
|
119
|
+
details
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/core.ts
|
|
124
|
+
var VERSION = "0.1.1";
|
|
125
|
+
var DEFAULT_BASE_URL = "https://superartifacts.app";
|
|
126
|
+
var API_KEY_ENV = "SUPERARTIFACTS_API_KEY";
|
|
127
|
+
var MAX_RETRY_AFTER_SECONDS = 60;
|
|
128
|
+
var BACKOFF_BASE_MS = 500;
|
|
129
|
+
var BACKOFF_MAX_MS = 8e3;
|
|
130
|
+
var sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
131
|
+
const timer = setTimeout(resolve, ms);
|
|
132
|
+
signal?.addEventListener(
|
|
133
|
+
"abort",
|
|
134
|
+
() => {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
reject(signal.reason);
|
|
137
|
+
},
|
|
138
|
+
{ once: true }
|
|
139
|
+
);
|
|
140
|
+
});
|
|
141
|
+
var backoff = (attempt) => {
|
|
142
|
+
const ceiling = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** attempt);
|
|
143
|
+
return ceiling / 2 + Math.random() * (ceiling / 2);
|
|
144
|
+
};
|
|
145
|
+
function isBrowser() {
|
|
146
|
+
const scope = globalThis;
|
|
147
|
+
return scope.window !== void 0 && scope.document !== void 0;
|
|
148
|
+
}
|
|
149
|
+
var Core = class {
|
|
150
|
+
#apiKey;
|
|
151
|
+
#baseUrl;
|
|
152
|
+
#timeout;
|
|
153
|
+
#maxRetries;
|
|
154
|
+
#fetch;
|
|
155
|
+
constructor(options = {}) {
|
|
156
|
+
if (isBrowser() && options.dangerouslyAllowBrowser !== true) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
"The Super Artifacts API refuses requests from a browser, and a key on a page is a leaked key. Call it from your server. Behind your own proxy, pass dangerouslyAllowBrowser: true."
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const apiKey = options.apiKey ?? globalThis.process?.env?.[API_KEY_ENV];
|
|
162
|
+
if (!apiKey) {
|
|
163
|
+
throw new AuthenticationError(
|
|
164
|
+
void 0,
|
|
165
|
+
void 0,
|
|
166
|
+
`No API key. Pass { apiKey } or set ${API_KEY_ENV}. Create one at https://superartifacts.app/settings/api-keys.`
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
this.#apiKey = apiKey;
|
|
170
|
+
this.#baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
171
|
+
this.#timeout = options.timeout ?? 6e4;
|
|
172
|
+
this.#maxRetries = options.maxRetries ?? 2;
|
|
173
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
174
|
+
}
|
|
175
|
+
/** Call one operation with its fields in one object. The generated resources all land here. */
|
|
176
|
+
call(operation, params = {}, options = {}) {
|
|
177
|
+
const { method } = operation;
|
|
178
|
+
const rest = new Map(Object.entries(params).filter(([, value]) => value !== void 0));
|
|
179
|
+
const take = (name) => {
|
|
180
|
+
const value = rest.get(name);
|
|
181
|
+
rest.delete(name);
|
|
182
|
+
return value;
|
|
183
|
+
};
|
|
184
|
+
const pathNames = [];
|
|
185
|
+
const path = operation.path.replace(/\{(\w+)\}/g, (_, name) => {
|
|
186
|
+
const value = take(name);
|
|
187
|
+
if (value === null || value === void 0 || value === "") {
|
|
188
|
+
throw new TypeError(`${method} ${operation.path} needs ${name}.`);
|
|
189
|
+
}
|
|
190
|
+
pathNames.push(name);
|
|
191
|
+
return encodeURIComponent(String(value));
|
|
192
|
+
});
|
|
193
|
+
const url = new URL(`${this.#baseUrl}${path}`);
|
|
194
|
+
for (const name of operation.query) {
|
|
195
|
+
for (const value of [take(name)].flat()) {
|
|
196
|
+
if (value !== void 0) url.searchParams.append(name, String(value));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (operation.confirm !== void 0) {
|
|
200
|
+
take("confirm");
|
|
201
|
+
url.searchParams.set("confirm", String(params[operation.confirm]));
|
|
202
|
+
}
|
|
203
|
+
const bodied = method !== "GET" && method !== "DELETE";
|
|
204
|
+
if (!bodied) for (const [name, value] of rest) url.searchParams.append(name, String(value));
|
|
205
|
+
const body = bodied && rest.size > 0 ? JSON.stringify(Object.fromEntries(rest)) : void 0;
|
|
206
|
+
const key = method === "POST" ? options.idempotencyKey ?? crypto.randomUUID() : options.idempotencyKey;
|
|
207
|
+
const headers = {
|
|
208
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
209
|
+
"Content-Type": "application/json",
|
|
210
|
+
...typeof key === "string" ? { "Idempotency-Key": key } : {},
|
|
211
|
+
...options.headers
|
|
212
|
+
};
|
|
213
|
+
const repeatable = method === "GET" || method === "DELETE" || method === "POST" && !!key;
|
|
214
|
+
return this.send(url, { method, headers, ...body ? { body } : {} }, repeatable, options);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* PUT staged bytes, one file at a time. The URL is the credential, so no key goes with
|
|
218
|
+
* it, and it takes the same bytes twice, so it is always safe to repeat.
|
|
219
|
+
*/
|
|
220
|
+
async putFiles(targets, files, options) {
|
|
221
|
+
for (const [index, { url }] of targets.entries()) {
|
|
222
|
+
await this.send(url, { method: "PUT", body: files[index] ?? null }, true, options);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** One request with the retry rules. A 429 ran nothing, so it repeats whatever `repeatable` says. */
|
|
226
|
+
async send(url, init, repeatable, options = {}) {
|
|
227
|
+
const headers = { "User-Agent": `superartifacts-typescript/${VERSION}`, ...init.headers };
|
|
228
|
+
for (let attempt = 0; ; attempt++) {
|
|
229
|
+
const left = attempt < this.#maxRetries;
|
|
230
|
+
let failure;
|
|
231
|
+
let delay = backoff(attempt);
|
|
232
|
+
let retry = left && repeatable;
|
|
233
|
+
try {
|
|
234
|
+
const timeout = AbortSignal.timeout(options.timeout ?? this.#timeout);
|
|
235
|
+
const signal = options.signal ? AbortSignal.any([timeout, options.signal]) : timeout;
|
|
236
|
+
const response = await this.#fetch(url, { ...init, headers, signal });
|
|
237
|
+
const text = await response.text();
|
|
238
|
+
if (response.ok) return parseAnswer(text, response.status);
|
|
239
|
+
failure = errorFor(response.status, text, response.headers.get("retry-after"));
|
|
240
|
+
const { status } = response;
|
|
241
|
+
const { retryAfter } = failure;
|
|
242
|
+
if (status === 429 || retry && [502, 503, 504].includes(status)) {
|
|
243
|
+
if (retryAfter !== void 0) delay = retryAfter * 1e3;
|
|
244
|
+
retry = left && (retryAfter ?? 0) <= MAX_RETRY_AFTER_SECONDS;
|
|
245
|
+
} else {
|
|
246
|
+
retry = false;
|
|
247
|
+
}
|
|
248
|
+
} catch (cause) {
|
|
249
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
250
|
+
if (cause instanceof SuperArtifactsError) throw cause;
|
|
251
|
+
const timedOut = cause?.name === "TimeoutError";
|
|
252
|
+
const message = timedOut ? "The request timed out." : `Could not reach the API: ${cause?.message ?? "unknown error"}`;
|
|
253
|
+
const ErrorClass = timedOut ? TimeoutError : ConnectionError;
|
|
254
|
+
const code = timedOut ? "timeout" : "connection_error";
|
|
255
|
+
failure = new ErrorClass(0, code, message, void 0, {}, { cause });
|
|
256
|
+
}
|
|
257
|
+
if (!retry) throw failure;
|
|
258
|
+
await sleep(delay, options.signal);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
function parseAnswer(text, status) {
|
|
263
|
+
if (text === "") return {};
|
|
264
|
+
try {
|
|
265
|
+
return JSON.parse(text);
|
|
266
|
+
} catch (cause) {
|
|
267
|
+
throw new SuperArtifactsError(
|
|
268
|
+
status,
|
|
269
|
+
"invalid_response",
|
|
270
|
+
"The API answered with something that is not JSON.",
|
|
271
|
+
void 0,
|
|
272
|
+
{},
|
|
273
|
+
{ cause }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/generated/resources.ts
|
|
279
|
+
var OPERATIONS = {
|
|
280
|
+
whoami: { method: "GET", path: "/v1/whoami", query: [] },
|
|
281
|
+
getHelp: { method: "GET", path: "/v1/help", query: ["topic"] },
|
|
282
|
+
listArtifacts: { method: "GET", path: "/v1/artifacts", query: [] },
|
|
283
|
+
publishArtifact: { method: "POST", path: "/v1/artifacts", query: [] },
|
|
284
|
+
getArtifact: { method: "GET", path: "/v1/artifacts/{artifact}", query: [] },
|
|
285
|
+
updateArtifact: { method: "PATCH", path: "/v1/artifacts/{artifact}", query: [] },
|
|
286
|
+
deleteArtifact: {
|
|
287
|
+
method: "DELETE",
|
|
288
|
+
path: "/v1/artifacts/{artifact}",
|
|
289
|
+
query: [],
|
|
290
|
+
confirm: "artifact"
|
|
291
|
+
},
|
|
292
|
+
readArtifactFile: {
|
|
293
|
+
method: "GET",
|
|
294
|
+
path: "/v1/artifacts/{artifact}/file",
|
|
295
|
+
query: ["path", "version"]
|
|
296
|
+
},
|
|
297
|
+
openArtifact: { method: "POST", path: "/v1/artifacts/{artifact}/open", query: [] },
|
|
298
|
+
serveVersion: {
|
|
299
|
+
method: "POST",
|
|
300
|
+
path: "/v1/artifacts/{artifact}/versions/{version}/serve",
|
|
301
|
+
query: []
|
|
302
|
+
},
|
|
303
|
+
startLiveRoom: { method: "POST", path: "/v1/artifacts/{artifact}/live", query: [] },
|
|
304
|
+
stopLiveRoom: { method: "DELETE", path: "/v1/artifacts/{artifact}/live", query: [] },
|
|
305
|
+
stageUploads: { method: "POST", path: "/v1/uploads", query: [] },
|
|
306
|
+
listArtifactRows: {
|
|
307
|
+
method: "GET",
|
|
308
|
+
path: "/v1/artifacts/{artifact}/data",
|
|
309
|
+
query: ["filter", "since", "until", "sort", "limit", "cursor", "fields"]
|
|
310
|
+
},
|
|
311
|
+
writeArtifactRows: { method: "POST", path: "/v1/artifacts/{artifact}/data/rows", query: [] },
|
|
312
|
+
listRows: {
|
|
313
|
+
method: "GET",
|
|
314
|
+
path: "/v1/data",
|
|
315
|
+
query: [
|
|
316
|
+
"dataset",
|
|
317
|
+
"collection",
|
|
318
|
+
"filter",
|
|
319
|
+
"since",
|
|
320
|
+
"until",
|
|
321
|
+
"sort",
|
|
322
|
+
"limit",
|
|
323
|
+
"cursor",
|
|
324
|
+
"fields"
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
queryData: { method: "POST", path: "/v1/data/query", query: [] },
|
|
328
|
+
getSchema: {
|
|
329
|
+
method: "GET",
|
|
330
|
+
path: "/v1/schema",
|
|
331
|
+
query: ["series", "tags", "artifact", "compare", "since", "workspace"]
|
|
332
|
+
},
|
|
333
|
+
defineCollection: { method: "PUT", path: "/v1/schema", query: [] },
|
|
334
|
+
listEntries: {
|
|
335
|
+
method: "GET",
|
|
336
|
+
path: "/v1/collections/{collection}/entries",
|
|
337
|
+
query: ["workspace", "filter", "search", "sort", "direction", "page", "limit"]
|
|
338
|
+
},
|
|
339
|
+
createEntries: { method: "POST", path: "/v1/collections/{collection}/entries", query: [] },
|
|
340
|
+
useSecret: {
|
|
341
|
+
method: "POST",
|
|
342
|
+
path: "/v1/collections/{collection}/entries/{entry}/fields/{field}/use",
|
|
343
|
+
query: []
|
|
344
|
+
},
|
|
345
|
+
listTemplates: {
|
|
346
|
+
method: "GET",
|
|
347
|
+
path: "/v1/templates",
|
|
348
|
+
query: [
|
|
349
|
+
"request",
|
|
350
|
+
"scope",
|
|
351
|
+
"kind",
|
|
352
|
+
"sort",
|
|
353
|
+
"limit",
|
|
354
|
+
"jobs",
|
|
355
|
+
"audience",
|
|
356
|
+
"needs",
|
|
357
|
+
"cost",
|
|
358
|
+
"tier",
|
|
359
|
+
"mine"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
saveTemplate: { method: "POST", path: "/v1/templates", query: [] },
|
|
363
|
+
getTemplate: { method: "GET", path: "/v1/templates/{slug}", query: ["version"] },
|
|
364
|
+
getTemplateHistory: { method: "GET", path: "/v1/templates/{slug}/history", query: [] },
|
|
365
|
+
getTemplateFeedback: { method: "GET", path: "/v1/templates/{slug}/feedback", query: [] },
|
|
366
|
+
actOnTemplate: { method: "POST", path: "/v1/templates/{slug}/actions", query: [] },
|
|
367
|
+
releaseTemplate: { method: "POST", path: "/v1/templates/{slug}/release", query: [] },
|
|
368
|
+
listProjects: { method: "GET", path: "/v1/projects", query: ["workspace"] },
|
|
369
|
+
createProject: { method: "POST", path: "/v1/projects", query: [] },
|
|
370
|
+
getProject: { method: "GET", path: "/v1/projects/{project}", query: ["workspace"] },
|
|
371
|
+
updateProject: { method: "PATCH", path: "/v1/projects/{project}", query: [] },
|
|
372
|
+
deleteProject: {
|
|
373
|
+
method: "DELETE",
|
|
374
|
+
path: "/v1/projects/{project}",
|
|
375
|
+
query: [],
|
|
376
|
+
confirm: "project"
|
|
377
|
+
},
|
|
378
|
+
addProjectArtifacts: { method: "POST", path: "/v1/projects/{project}/artifacts", query: [] },
|
|
379
|
+
removeProjectArtifact: {
|
|
380
|
+
method: "DELETE",
|
|
381
|
+
path: "/v1/projects/{project}/artifacts/{remove}",
|
|
382
|
+
query: []
|
|
383
|
+
},
|
|
384
|
+
shareArtifact: { method: "POST", path: "/v1/artifacts/{artifact}/shares", query: [] },
|
|
385
|
+
shareProject: { method: "POST", path: "/v1/projects/{project}/shares", query: [] },
|
|
386
|
+
shareWorkspace: { method: "POST", path: "/v1/workspace/shares", query: [] },
|
|
387
|
+
listComments: {
|
|
388
|
+
method: "GET",
|
|
389
|
+
path: "/v1/artifacts/{artifact}/comments",
|
|
390
|
+
query: ["status", "page", "limit", "cursor"]
|
|
391
|
+
},
|
|
392
|
+
respondToComments: {
|
|
393
|
+
method: "POST",
|
|
394
|
+
path: "/v1/artifacts/{artifact}/comments/responses",
|
|
395
|
+
query: []
|
|
396
|
+
},
|
|
397
|
+
getCommentScreenshot: {
|
|
398
|
+
method: "GET",
|
|
399
|
+
path: "/v1/artifacts/{artifact}/comments/screenshots/{screenshot}",
|
|
400
|
+
query: []
|
|
401
|
+
},
|
|
402
|
+
listMentions: { method: "GET", path: "/v1/mentions", query: ["artifact", "limit", "cursor"] },
|
|
403
|
+
listSignatureRequests: { method: "GET", path: "/v1/signatures", query: ["artifact"] },
|
|
404
|
+
requestSignatures: { method: "POST", path: "/v1/signatures", query: [] },
|
|
405
|
+
getSignatureRequest: { method: "GET", path: "/v1/signatures/{request}", query: [] },
|
|
406
|
+
remindSigner: { method: "POST", path: "/v1/signatures/{request}/remind", query: [] },
|
|
407
|
+
withdrawSignatureRequest: {
|
|
408
|
+
method: "POST",
|
|
409
|
+
path: "/v1/signatures/{request}/withdraw",
|
|
410
|
+
query: []
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
var AccountResource = class {
|
|
414
|
+
constructor(client) {
|
|
415
|
+
this.client = client;
|
|
416
|
+
}
|
|
417
|
+
client;
|
|
418
|
+
/** Who this key publishes as */
|
|
419
|
+
whoami(params, options) {
|
|
420
|
+
return this.client.call(OPERATIONS.whoami, params, options);
|
|
421
|
+
}
|
|
422
|
+
/** How the operations fit together */
|
|
423
|
+
help(params, options) {
|
|
424
|
+
return this.client.call(OPERATIONS.getHelp, params, options);
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var ArtifactsResource = class {
|
|
428
|
+
constructor(client) {
|
|
429
|
+
this.client = client;
|
|
430
|
+
}
|
|
431
|
+
client;
|
|
432
|
+
/** List your artifacts, newest first */
|
|
433
|
+
list(params, options) {
|
|
434
|
+
return this.client.call(OPERATIONS.listArtifacts, params, options);
|
|
435
|
+
}
|
|
436
|
+
/** Publish an artifact, or a new version of one */
|
|
437
|
+
publish(params, options) {
|
|
438
|
+
return this.client.call(OPERATIONS.publishArtifact, params, options);
|
|
439
|
+
}
|
|
440
|
+
/** One artifact: its versions, published version and declaration */
|
|
441
|
+
get(params, options) {
|
|
442
|
+
return this.client.call(OPERATIONS.getArtifact, params, options);
|
|
443
|
+
}
|
|
444
|
+
/** Change visibility, gallery label, live phase or submission email */
|
|
445
|
+
update(params, options) {
|
|
446
|
+
return this.client.call(OPERATIONS.updateArtifact, params, options);
|
|
447
|
+
}
|
|
448
|
+
/** Delete an artifact with every version, permanently */
|
|
449
|
+
delete(params, options) {
|
|
450
|
+
return this.client.call(OPERATIONS.deleteArtifact, params, options);
|
|
451
|
+
}
|
|
452
|
+
/** Read one file of a version as text (default: the published index.html) */
|
|
453
|
+
readFile(params, options) {
|
|
454
|
+
return this.client.call(OPERATIONS.readArtifactFile, params, options);
|
|
455
|
+
}
|
|
456
|
+
/** A ten-minute viewer URL for an artifact, private included */
|
|
457
|
+
open(params, options) {
|
|
458
|
+
return this.client.call(OPERATIONS.openArtifact, params, options);
|
|
459
|
+
}
|
|
460
|
+
/** Serve an existing version again */
|
|
461
|
+
serveVersion(params, options) {
|
|
462
|
+
return this.client.call(OPERATIONS.serveVersion, params, options);
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
var LiveResource = class {
|
|
466
|
+
constructor(client) {
|
|
467
|
+
this.client = client;
|
|
468
|
+
}
|
|
469
|
+
client;
|
|
470
|
+
/** Turn an artifact's live room on */
|
|
471
|
+
start(params, options) {
|
|
472
|
+
return this.client.call(OPERATIONS.startLiveRoom, params, options);
|
|
473
|
+
}
|
|
474
|
+
/** Turn an artifact's live room off, disconnecting every visitor */
|
|
475
|
+
stop(params, options) {
|
|
476
|
+
return this.client.call(OPERATIONS.stopLiveRoom, params, options);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
var UploadsResource = class {
|
|
480
|
+
constructor(client) {
|
|
481
|
+
this.client = client;
|
|
482
|
+
}
|
|
483
|
+
client;
|
|
484
|
+
/** Stage big files for a publish; PUT each to its URL */
|
|
485
|
+
stage(params, options) {
|
|
486
|
+
return this.client.call(OPERATIONS.stageUploads, params, options);
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
var DataResource = class {
|
|
490
|
+
constructor(client) {
|
|
491
|
+
this.client = client;
|
|
492
|
+
}
|
|
493
|
+
client;
|
|
494
|
+
/** Rows visitors submitted to one artifact, newest first */
|
|
495
|
+
listArtifactRows(params, options) {
|
|
496
|
+
return this.client.call(OPERATIONS.listArtifactRows, params, options);
|
|
497
|
+
}
|
|
498
|
+
/** Write rows into an artifact you may edit */
|
|
499
|
+
writeArtifactRows(params, options) {
|
|
500
|
+
return this.client.call(OPERATIONS.writeArtifactRows, params, options);
|
|
501
|
+
}
|
|
502
|
+
/** Rows submitted to a dataset or a gallery label */
|
|
503
|
+
listRows(params, options) {
|
|
504
|
+
return this.client.call(OPERATIONS.listRows, params, options);
|
|
505
|
+
}
|
|
506
|
+
/** Aggregate what was collected: numbers, never rows */
|
|
507
|
+
query(params, options) {
|
|
508
|
+
return this.client.call(OPERATIONS.queryData, params, options);
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
var SchemaResource = class {
|
|
512
|
+
constructor(client) {
|
|
513
|
+
this.client = client;
|
|
514
|
+
}
|
|
515
|
+
client;
|
|
516
|
+
/** The data catalog: datasets and content collections, or a comparison */
|
|
517
|
+
get(params, options) {
|
|
518
|
+
return this.client.call(OPERATIONS.getSchema, params, options);
|
|
519
|
+
}
|
|
520
|
+
/** Create or replace a content collection */
|
|
521
|
+
defineCollection(params, options) {
|
|
522
|
+
return this.client.call(OPERATIONS.defineCollection, params, options);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
var EntriesResource = class {
|
|
526
|
+
constructor(client) {
|
|
527
|
+
this.client = client;
|
|
528
|
+
}
|
|
529
|
+
client;
|
|
530
|
+
/** One page of a content collection's entries */
|
|
531
|
+
list(params, options) {
|
|
532
|
+
return this.client.call(OPERATIONS.listEntries, params, options);
|
|
533
|
+
}
|
|
534
|
+
/** Create one entry, or a batch */
|
|
535
|
+
create(params, options) {
|
|
536
|
+
return this.client.call(OPERATIONS.createEntries, params, options);
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
var SecretsResource = class {
|
|
540
|
+
constructor(client) {
|
|
541
|
+
this.client = client;
|
|
542
|
+
}
|
|
543
|
+
client;
|
|
544
|
+
/** Call an approved API with a stored secret you cannot read (workspace keys) */
|
|
545
|
+
use(params, options) {
|
|
546
|
+
return this.client.call(OPERATIONS.useSecret, params, options);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
var TemplatesResource = class {
|
|
550
|
+
constructor(client) {
|
|
551
|
+
this.client = client;
|
|
552
|
+
}
|
|
553
|
+
client;
|
|
554
|
+
/** Find, rank or list templates */
|
|
555
|
+
list(params, options) {
|
|
556
|
+
return this.client.call(OPERATIONS.listTemplates, params, options);
|
|
557
|
+
}
|
|
558
|
+
/** Create or revise a template draft */
|
|
559
|
+
save(params, options) {
|
|
560
|
+
return this.client.call(OPERATIONS.saveTemplate, params, options);
|
|
561
|
+
}
|
|
562
|
+
/** One template in full, with its install prompt */
|
|
563
|
+
get(params, options) {
|
|
564
|
+
return this.client.call(OPERATIONS.getTemplate, params, options);
|
|
565
|
+
}
|
|
566
|
+
/** A template's changelog */
|
|
567
|
+
getHistory(params, options) {
|
|
568
|
+
return this.client.call(OPERATIONS.getTemplateHistory, params, options);
|
|
569
|
+
}
|
|
570
|
+
/** Comments on a template's artifacts, as themes */
|
|
571
|
+
getFeedback(params, options) {
|
|
572
|
+
return this.client.call(OPERATIONS.getTemplateFeedback, params, options);
|
|
573
|
+
}
|
|
574
|
+
/** Install, uninstall, rate, report, roll back or request verification */
|
|
575
|
+
act(params, options) {
|
|
576
|
+
return this.client.call(OPERATIONS.actOnTemplate, params, options);
|
|
577
|
+
}
|
|
578
|
+
/** Release one version of your template */
|
|
579
|
+
release(params, options) {
|
|
580
|
+
return this.client.call(OPERATIONS.releaseTemplate, params, options);
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
var ProjectsResource = class {
|
|
584
|
+
constructor(client) {
|
|
585
|
+
this.client = client;
|
|
586
|
+
}
|
|
587
|
+
client;
|
|
588
|
+
/** Your projects */
|
|
589
|
+
list(params, options) {
|
|
590
|
+
return this.client.call(OPERATIONS.listProjects, params, options);
|
|
591
|
+
}
|
|
592
|
+
/** Create a project, optionally seeded with artifacts */
|
|
593
|
+
create(params, options) {
|
|
594
|
+
return this.client.call(OPERATIONS.createProject, params, options);
|
|
595
|
+
}
|
|
596
|
+
/** One project and its items */
|
|
597
|
+
get(params, options) {
|
|
598
|
+
return this.client.call(OPERATIONS.getProject, params, options);
|
|
599
|
+
}
|
|
600
|
+
/** Rename, set visibility, reorder, move, fold groups or set a rule */
|
|
601
|
+
update(params, options) {
|
|
602
|
+
return this.client.call(OPERATIONS.updateProject, params, options);
|
|
603
|
+
}
|
|
604
|
+
/** Delete a project; its artifacts stay */
|
|
605
|
+
delete(params, options) {
|
|
606
|
+
return this.client.call(OPERATIONS.deleteProject, params, options);
|
|
607
|
+
}
|
|
608
|
+
/** Add artifacts to a project */
|
|
609
|
+
addArtifacts(params, options) {
|
|
610
|
+
return this.client.call(OPERATIONS.addProjectArtifacts, params, options);
|
|
611
|
+
}
|
|
612
|
+
/** Remove one artifact (or item) from a project */
|
|
613
|
+
removeArtifact(params, options) {
|
|
614
|
+
return this.client.call(OPERATIONS.removeProjectArtifact, params, options);
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
var SharesResource = class {
|
|
618
|
+
constructor(client) {
|
|
619
|
+
this.client = client;
|
|
620
|
+
}
|
|
621
|
+
client;
|
|
622
|
+
/** Give named people access to an artifact */
|
|
623
|
+
addToArtifact(params, options) {
|
|
624
|
+
return this.client.call(OPERATIONS.shareArtifact, params, options);
|
|
625
|
+
}
|
|
626
|
+
/** Give named people access to a project */
|
|
627
|
+
addToProject(params, options) {
|
|
628
|
+
return this.client.call(OPERATIONS.shareProject, params, options);
|
|
629
|
+
}
|
|
630
|
+
/** Invite editors to a workspace (returns accept links) */
|
|
631
|
+
addToWorkspace(params, options) {
|
|
632
|
+
return this.client.call(OPERATIONS.shareWorkspace, params, options);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
var CommentsResource = class {
|
|
636
|
+
constructor(client) {
|
|
637
|
+
this.client = client;
|
|
638
|
+
}
|
|
639
|
+
client;
|
|
640
|
+
/** Comment threads on an artifact, newest first */
|
|
641
|
+
list(params, options) {
|
|
642
|
+
return this.client.call(OPERATIONS.listComments, params, options);
|
|
643
|
+
}
|
|
644
|
+
/** Reply to and/or resolve threads, one outcome each */
|
|
645
|
+
respond(params, options) {
|
|
646
|
+
return this.client.call(OPERATIONS.respondToComments, params, options);
|
|
647
|
+
}
|
|
648
|
+
/** One message's screenshot, base64 in `image` */
|
|
649
|
+
getScreenshot(params, options) {
|
|
650
|
+
return this.client.call(OPERATIONS.getCommentScreenshot, params, options);
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
var MentionsResource = class {
|
|
654
|
+
constructor(client) {
|
|
655
|
+
this.client = client;
|
|
656
|
+
}
|
|
657
|
+
client;
|
|
658
|
+
/** Where people @mentioned you; listing marks them seen */
|
|
659
|
+
list(params, options) {
|
|
660
|
+
return this.client.call(OPERATIONS.listMentions, params, options);
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
var SignaturesResource = class {
|
|
664
|
+
constructor(client) {
|
|
665
|
+
this.client = client;
|
|
666
|
+
}
|
|
667
|
+
client;
|
|
668
|
+
/** An artifact's signature requests, newest first */
|
|
669
|
+
list(params, options) {
|
|
670
|
+
return this.client.call(OPERATIONS.listSignatureRequests, params, options);
|
|
671
|
+
}
|
|
672
|
+
/** Ask named people to sign one version of an artifact */
|
|
673
|
+
request(params, options) {
|
|
674
|
+
return this.client.call(OPERATIONS.requestSignatures, params, options);
|
|
675
|
+
}
|
|
676
|
+
/** One signature request and its signers */
|
|
677
|
+
get(params, options) {
|
|
678
|
+
return this.client.call(OPERATIONS.getSignatureRequest, params, options);
|
|
679
|
+
}
|
|
680
|
+
/** Email a signer their link again */
|
|
681
|
+
remind(params, options) {
|
|
682
|
+
return this.client.call(OPERATIONS.remindSigner, params, options);
|
|
683
|
+
}
|
|
684
|
+
/** Close an open signature request */
|
|
685
|
+
withdraw(params, options) {
|
|
686
|
+
return this.client.call(OPERATIONS.withdrawSignatureRequest, params, options);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
var Resources = class extends Core {
|
|
690
|
+
account = new AccountResource(this);
|
|
691
|
+
artifacts = new ArtifactsResource(this);
|
|
692
|
+
live = new LiveResource(this);
|
|
693
|
+
uploads = new UploadsResource(this);
|
|
694
|
+
data = new DataResource(this);
|
|
695
|
+
schema = new SchemaResource(this);
|
|
696
|
+
entries = new EntriesResource(this);
|
|
697
|
+
secrets = new SecretsResource(this);
|
|
698
|
+
templates = new TemplatesResource(this);
|
|
699
|
+
projects = new ProjectsResource(this);
|
|
700
|
+
shares = new SharesResource(this);
|
|
701
|
+
comments = new CommentsResource(this);
|
|
702
|
+
mentions = new MentionsResource(this);
|
|
703
|
+
signatures = new SignaturesResource(this);
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
// src/super-artifacts.ts
|
|
707
|
+
async function* byCursor(read, start, items, next) {
|
|
708
|
+
let cursor = start;
|
|
709
|
+
do {
|
|
710
|
+
const page = await read(cursor);
|
|
711
|
+
yield* page[items] ?? [];
|
|
712
|
+
cursor = next(page) ?? void 0;
|
|
713
|
+
} while (cursor !== void 0);
|
|
714
|
+
}
|
|
715
|
+
var cursorNext = (page) => page.cursor?.next;
|
|
716
|
+
var Data = class extends DataResource {
|
|
717
|
+
/** Every row `listArtifactRows` matches, page by page. */
|
|
718
|
+
iterArtifactRows(params, options) {
|
|
719
|
+
const read = (cursor) => this.listArtifactRows({ ...params, ...cursor && { cursor } }, options);
|
|
720
|
+
return byCursor(read, params.cursor, "responses", cursorNext);
|
|
721
|
+
}
|
|
722
|
+
/** Every row `listRows` matches, page by page. */
|
|
723
|
+
iterRows(params = {}, options) {
|
|
724
|
+
const read = (cursor) => this.listRows({ ...params, ...cursor && { cursor } }, options);
|
|
725
|
+
return byCursor(read, params.cursor, "responses", cursorNext);
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
var Entries = class extends EntriesResource {
|
|
729
|
+
/** Every entry `list` matches, page by page from `params.page` (0 by default). */
|
|
730
|
+
async *iter(params, options) {
|
|
731
|
+
for (let page = params.page ?? 0; ; page++) {
|
|
732
|
+
const answer = await this.list({ ...params, page }, options);
|
|
733
|
+
const entries = answer.entries ?? [];
|
|
734
|
+
yield* entries;
|
|
735
|
+
const { total, pageSize } = answer;
|
|
736
|
+
if (entries.length === 0 || (page + 1) * (pageSize ?? entries.length) >= (total ?? 0)) return;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
var Mentions = class extends MentionsResource {
|
|
741
|
+
/** Every mention, page by page. Listing marks them seen. */
|
|
742
|
+
iter(params = {}, options) {
|
|
743
|
+
const read = (cursor) => this.list({ ...params, ...cursor && { cursor } }, options);
|
|
744
|
+
return byCursor(read, params.cursor, "mentions", (page) => page.cursorNext);
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
var Uploads = class extends UploadsResource {
|
|
748
|
+
/** Stage files and PUT their bytes. Pass the answer's `uploadId` to `artifacts.publish` as `uploads`. */
|
|
749
|
+
async upload(files, options) {
|
|
750
|
+
const blobs = files.map(
|
|
751
|
+
({ data, contentType }) => data instanceof Blob ? data : new Blob([data], contentType === void 0 ? {} : { type: contentType })
|
|
752
|
+
);
|
|
753
|
+
const stage = files.map(({ path, contentType }, index) => ({
|
|
754
|
+
path,
|
|
755
|
+
bytes: blobs[index]?.size ?? 0,
|
|
756
|
+
...contentType === void 0 ? {} : { contentType }
|
|
757
|
+
}));
|
|
758
|
+
const staged = await this.stage({ files: stage }, options);
|
|
759
|
+
await this.client.putFiles(staged.uploads, blobs, options);
|
|
760
|
+
return { uploadId: staged.uploadId, expiresAt: staged.expiresAt };
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
var SuperArtifacts = class extends Resources {
|
|
764
|
+
data = new Data(this);
|
|
765
|
+
entries = new Entries(this);
|
|
766
|
+
mentions = new Mentions(this);
|
|
767
|
+
uploads = new Uploads(this);
|
|
768
|
+
};
|
|
769
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
770
|
+
0 && (module.exports = {
|
|
771
|
+
AuthenticationError,
|
|
772
|
+
ConflictError,
|
|
773
|
+
ConnectionError,
|
|
774
|
+
InternalError,
|
|
775
|
+
InvalidArgumentsError,
|
|
776
|
+
NotFoundError,
|
|
777
|
+
OPERATIONS,
|
|
778
|
+
PayloadTooLargeError,
|
|
779
|
+
PermissionError,
|
|
780
|
+
PlanLimitError,
|
|
781
|
+
RateLimitError,
|
|
782
|
+
ScopeRequiredError,
|
|
783
|
+
SuperArtifacts,
|
|
784
|
+
SuperArtifactsError,
|
|
785
|
+
TimeoutError,
|
|
786
|
+
VERSION,
|
|
787
|
+
errorFor
|
|
788
|
+
});
|