@prismicio/client 7.20.0-alpha.0 → 7.20.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/dist/Client.cjs +111 -95
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.ts +66 -27
- package/dist/Client.js +111 -95
- package/dist/Client.js.map +1 -1
- package/dist/WriteClient.cjs +156 -101
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.ts +2 -26
- package/dist/WriteClient.js +156 -101
- package/dist/WriteClient.js.map +1 -1
- package/dist/errors/InvalidDataError.cjs +7 -0
- package/dist/errors/InvalidDataError.cjs.map +1 -0
- package/dist/errors/InvalidDataError.d.ts +3 -0
- package/dist/errors/InvalidDataError.js +7 -0
- package/dist/errors/InvalidDataError.js.map +1 -0
- package/dist/errors/ParsingError.cjs.map +1 -1
- package/dist/errors/ParsingError.d.ts +6 -4
- package/dist/errors/ParsingError.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/request.cjs +43 -0
- package/dist/lib/request.cjs.map +1 -0
- package/dist/lib/request.d.ts +73 -0
- package/dist/lib/request.js +43 -0
- package/dist/lib/request.js.map +1 -0
- package/dist/package.json.cjs +3 -1
- package/dist/package.json.cjs.map +1 -1
- package/dist/package.json.js +3 -1
- package/dist/package.json.js.map +1 -1
- package/dist/types/{integration.d.ts → api/integration.d.ts} +1 -1
- package/package.json +1 -1
- package/src/Client.ts +201 -171
- package/src/WriteClient.ts +220 -157
- package/src/errors/InvalidDataError.ts +5 -0
- package/src/errors/ParsingError.ts +6 -4
- package/src/index.ts +13 -11
- package/src/lib/request.ts +166 -0
- package/src/types/{integration.ts → api/integration.ts} +1 -1
- package/dist/BaseClient.cjs +0 -108
- package/dist/BaseClient.cjs.map +0 -1
- package/dist/BaseClient.d.ts +0 -152
- package/dist/BaseClient.js +0 -108
- package/dist/BaseClient.js.map +0 -1
- package/src/BaseClient.ts +0 -330
package/dist/WriteClient.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
2
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
9
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
+
var _WriteClient_instances, request_fn, handleAssetAPIError_fn, handleMigrationAPIError_fn;
|
|
4
11
|
import { devMsg } from "./lib/devMsg.js";
|
|
5
12
|
import { pLimit } from "./lib/pLimit.js";
|
|
13
|
+
import { request } from "./lib/request.js";
|
|
6
14
|
import { resolveMigrationContentRelationship, resolveMigrationDocumentData } from "./lib/resolveMigrationDocumentData.js";
|
|
15
|
+
import { ForbiddenError } from "./errors/ForbiddenError.js";
|
|
16
|
+
import { InvalidDataError } from "./errors/InvalidDataError.js";
|
|
17
|
+
import { NotFoundError } from "./errors/NotFoundError.js";
|
|
7
18
|
import { PrismicError } from "./errors/PrismicError.js";
|
|
19
|
+
import { name, version } from "./package.json.js";
|
|
8
20
|
import { Client } from "./Client.js";
|
|
21
|
+
const CLIENT_IDENTIFIER = `${name.replace("@", "").replace("/", "-")}/${version}`;
|
|
9
22
|
class WriteClient extends Client {
|
|
10
23
|
/**
|
|
11
24
|
* Creates a Prismic client that can be used to query and write content to a
|
|
@@ -23,6 +36,7 @@ class WriteClient extends Client {
|
|
|
23
36
|
*/
|
|
24
37
|
constructor(repositoryName, options) {
|
|
25
38
|
super(repositoryName, options);
|
|
39
|
+
__privateAdd(this, _WriteClient_instances);
|
|
26
40
|
__publicField(this, "writeToken");
|
|
27
41
|
__publicField(this, "assetAPIEndpoint", "https://asset-api.prismic.io/");
|
|
28
42
|
__publicField(this, "migrationAPIEndpoint", "https://migration.prismic.io/");
|
|
@@ -254,15 +268,22 @@ class WriteClient extends Client {
|
|
|
254
268
|
if (alt) {
|
|
255
269
|
formData.append("alt", alt);
|
|
256
270
|
}
|
|
257
|
-
const
|
|
271
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
258
272
|
method: "POST",
|
|
259
|
-
body: formData
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
273
|
+
body: formData
|
|
274
|
+
});
|
|
275
|
+
switch (response.status) {
|
|
276
|
+
case 200: {
|
|
277
|
+
const asset = await response.json();
|
|
278
|
+
if (tags && tags.length) {
|
|
279
|
+
return this.updateAsset(asset.id, { tags });
|
|
280
|
+
}
|
|
281
|
+
return asset;
|
|
282
|
+
}
|
|
283
|
+
default: {
|
|
284
|
+
return await __privateMethod(this, _WriteClient_instances, handleAssetAPIError_fn).call(this, response);
|
|
285
|
+
}
|
|
264
286
|
}
|
|
265
|
-
return asset;
|
|
266
287
|
}
|
|
267
288
|
/**
|
|
268
289
|
* Updates an asset in the Prismic media library.
|
|
@@ -280,17 +301,27 @@ class WriteClient extends Client {
|
|
|
280
301
|
...params
|
|
281
302
|
});
|
|
282
303
|
}
|
|
283
|
-
|
|
304
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
284
305
|
method: "PATCH",
|
|
285
|
-
body: {
|
|
306
|
+
body: JSON.stringify({
|
|
286
307
|
notes,
|
|
287
308
|
credits,
|
|
288
309
|
alt,
|
|
289
310
|
filename,
|
|
290
311
|
tags
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
|
|
312
|
+
}),
|
|
313
|
+
headers: {
|
|
314
|
+
"content-type": "application/json"
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
switch (response.status) {
|
|
318
|
+
case 200: {
|
|
319
|
+
return await response.json();
|
|
320
|
+
}
|
|
321
|
+
default: {
|
|
322
|
+
return await __privateMethod(this, _WriteClient_instances, handleAssetAPIError_fn).call(this, response);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
294
325
|
}
|
|
295
326
|
/**
|
|
296
327
|
* Fetches a foreign asset from a URL.
|
|
@@ -301,17 +332,7 @@ class WriteClient extends Client {
|
|
|
301
332
|
* @returns A file representing the fetched asset.
|
|
302
333
|
*/
|
|
303
334
|
async fetchForeignAsset(url, params = {}) {
|
|
304
|
-
|
|
305
|
-
const requestInit = {
|
|
306
|
-
...this.fetchOptions,
|
|
307
|
-
...params.fetchOptions,
|
|
308
|
-
headers: {
|
|
309
|
-
...(_a = this.fetchOptions) == null ? void 0 : _a.headers,
|
|
310
|
-
...(_b = params.fetchOptions) == null ? void 0 : _b.headers
|
|
311
|
-
},
|
|
312
|
-
signal: ((_c = params.fetchOptions) == null ? void 0 : _c.signal) || params.signal || ((_d = this.fetchOptions) == null ? void 0 : _d.signal)
|
|
313
|
-
};
|
|
314
|
-
const res = await this.fetchFn(url, requestInit);
|
|
335
|
+
const res = await this.fetchFn(url, this._buildRequestInit(params));
|
|
315
336
|
if (!res.ok) {
|
|
316
337
|
throw new PrismicError("Could not fetch foreign asset", url, void 0);
|
|
317
338
|
}
|
|
@@ -359,13 +380,23 @@ class WriteClient extends Client {
|
|
|
359
380
|
*
|
|
360
381
|
* @returns The created tag.
|
|
361
382
|
*/
|
|
362
|
-
async createAssetTag(
|
|
383
|
+
async createAssetTag(name2, params) {
|
|
363
384
|
const url = new URL("tags", this.assetAPIEndpoint);
|
|
364
|
-
|
|
385
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
365
386
|
method: "POST",
|
|
366
|
-
body: { name },
|
|
367
|
-
|
|
368
|
-
|
|
387
|
+
body: JSON.stringify({ name: name2 }),
|
|
388
|
+
headers: {
|
|
389
|
+
"content-type": "application/json"
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
switch (response.status) {
|
|
393
|
+
case 201: {
|
|
394
|
+
return await response.json();
|
|
395
|
+
}
|
|
396
|
+
default: {
|
|
397
|
+
return await __privateMethod(this, _WriteClient_instances, handleAssetAPIError_fn).call(this, response);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
369
400
|
}
|
|
370
401
|
/**
|
|
371
402
|
* Queries existing tags from the Asset API.
|
|
@@ -376,8 +407,16 @@ class WriteClient extends Client {
|
|
|
376
407
|
*/
|
|
377
408
|
async getAssetTags(params) {
|
|
378
409
|
const url = new URL("tags", this.assetAPIEndpoint);
|
|
379
|
-
const
|
|
380
|
-
|
|
410
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params);
|
|
411
|
+
switch (response.status) {
|
|
412
|
+
case 200: {
|
|
413
|
+
const json = await response.json();
|
|
414
|
+
return json.items;
|
|
415
|
+
}
|
|
416
|
+
default: {
|
|
417
|
+
return await __privateMethod(this, _WriteClient_instances, handleAssetAPIError_fn).call(this, response);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
381
420
|
}
|
|
382
421
|
/**
|
|
383
422
|
* Creates a document in the repository's migration release.
|
|
@@ -396,9 +435,9 @@ class WriteClient extends Client {
|
|
|
396
435
|
*/
|
|
397
436
|
async createDocument(document, documentTitle, { masterLanguageDocumentID, ...params } = {}) {
|
|
398
437
|
const url = new URL("documents", this.migrationAPIEndpoint);
|
|
399
|
-
const
|
|
438
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
400
439
|
method: "POST",
|
|
401
|
-
body: {
|
|
440
|
+
body: JSON.stringify({
|
|
402
441
|
title: documentTitle,
|
|
403
442
|
type: document.type,
|
|
404
443
|
uid: document.uid || void 0,
|
|
@@ -406,10 +445,21 @@ class WriteClient extends Client {
|
|
|
406
445
|
alternate_language_id: masterLanguageDocumentID,
|
|
407
446
|
tags: document.tags,
|
|
408
447
|
data: document.data
|
|
409
|
-
},
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
448
|
+
}),
|
|
449
|
+
headers: {
|
|
450
|
+
"content-type": "application/json",
|
|
451
|
+
"x-client": CLIENT_IDENTIFIER
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
switch (response.status) {
|
|
455
|
+
case 201: {
|
|
456
|
+
const json = await response.json();
|
|
457
|
+
return { id: json.id };
|
|
458
|
+
}
|
|
459
|
+
default: {
|
|
460
|
+
return await __privateMethod(this, _WriteClient_instances, handleMigrationAPIError_fn).call(this, response);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
413
463
|
}
|
|
414
464
|
/**
|
|
415
465
|
* Updates an existing document in the repository's migration release.
|
|
@@ -424,81 +474,86 @@ class WriteClient extends Client {
|
|
|
424
474
|
*/
|
|
425
475
|
async updateDocument(id, document, params) {
|
|
426
476
|
const url = new URL(`documents/${id}`, this.migrationAPIEndpoint);
|
|
427
|
-
await this.
|
|
477
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
428
478
|
method: "PUT",
|
|
429
|
-
body: {
|
|
479
|
+
body: JSON.stringify({
|
|
430
480
|
title: document.documentTitle,
|
|
431
481
|
uid: document.uid || void 0,
|
|
432
482
|
tags: document.tags,
|
|
433
483
|
data: document.data
|
|
434
|
-
},
|
|
435
|
-
|
|
436
|
-
|
|
484
|
+
}),
|
|
485
|
+
headers: {
|
|
486
|
+
"content-type": "application/json",
|
|
487
|
+
"x-client": CLIENT_IDENTIFIER
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
switch (response.status) {
|
|
491
|
+
case 200: {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
default: {
|
|
495
|
+
await __privateMethod(this, _WriteClient_instances, handleMigrationAPIError_fn).call(this, response);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
437
498
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
var _a;
|
|
451
|
-
const headers = {
|
|
452
|
-
...(_a = params == null ? void 0 : params.fetchOptions) == null ? void 0 : _a.headers,
|
|
453
|
-
authorization: `Bearer ${this.writeToken}`,
|
|
454
|
-
repository: this.repositoryName
|
|
455
|
-
};
|
|
456
|
-
let _body;
|
|
457
|
-
if (body instanceof FormData) {
|
|
458
|
-
_body = body;
|
|
459
|
-
} else if (body) {
|
|
460
|
-
_body = JSON.stringify(body);
|
|
461
|
-
headers["content-type"] = "application/json";
|
|
499
|
+
}
|
|
500
|
+
_WriteClient_instances = new WeakSet();
|
|
501
|
+
request_fn = async function(url, params, init) {
|
|
502
|
+
const baseInit = this._buildRequestInit(params);
|
|
503
|
+
return await request(url, {
|
|
504
|
+
...baseInit,
|
|
505
|
+
...init,
|
|
506
|
+
headers: {
|
|
507
|
+
...baseInit.headers,
|
|
508
|
+
...init == null ? void 0 : init.headers,
|
|
509
|
+
repository: this.repositoryName,
|
|
510
|
+
authorization: `Bearer ${this.writeToken}`
|
|
462
511
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
512
|
+
}, this.fetchFn);
|
|
513
|
+
};
|
|
514
|
+
handleAssetAPIError_fn = async function(response) {
|
|
515
|
+
const json = await response.json();
|
|
516
|
+
switch (response.status) {
|
|
517
|
+
case 401:
|
|
518
|
+
case 403:
|
|
519
|
+
throw new ForbiddenError(json.error, response.url, json);
|
|
520
|
+
case 404:
|
|
521
|
+
throw new NotFoundError(json.error, response.url, json);
|
|
522
|
+
case 400:
|
|
523
|
+
throw new InvalidDataError(json.error, response.url, json);
|
|
524
|
+
case 500:
|
|
525
|
+
case 503:
|
|
526
|
+
default:
|
|
527
|
+
throw new PrismicError(json.error, response.url, json);
|
|
472
528
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
var _a;
|
|
486
|
-
return {
|
|
487
|
-
...params,
|
|
488
|
-
fetchOptions: {
|
|
489
|
-
...params == null ? void 0 : params.fetchOptions,
|
|
490
|
-
method,
|
|
491
|
-
body: JSON.stringify(body),
|
|
492
|
-
headers: {
|
|
493
|
-
...(_a = params == null ? void 0 : params.fetchOptions) == null ? void 0 : _a.headers,
|
|
494
|
-
"content-type": "application/json",
|
|
495
|
-
repository: this.repositoryName,
|
|
496
|
-
authorization: `Bearer ${this.writeToken}`
|
|
497
|
-
}
|
|
529
|
+
};
|
|
530
|
+
handleMigrationAPIError_fn = async function(response) {
|
|
531
|
+
const text = await response.text();
|
|
532
|
+
let json;
|
|
533
|
+
try {
|
|
534
|
+
json = JSON.parse(text);
|
|
535
|
+
} catch {
|
|
536
|
+
}
|
|
537
|
+
switch (response.status) {
|
|
538
|
+
case 400:
|
|
539
|
+
if (json) {
|
|
540
|
+
throw new InvalidDataError("Validation failed, check the response property of the error for details", response.url, json);
|
|
498
541
|
}
|
|
499
|
-
|
|
542
|
+
throw new InvalidDataError(text, response.url, text);
|
|
543
|
+
case 401:
|
|
544
|
+
throw new ForbiddenError(text, response.url, text);
|
|
545
|
+
case 403:
|
|
546
|
+
if (json) {
|
|
547
|
+
throw new ForbiddenError(json.Message, response.url, json);
|
|
548
|
+
}
|
|
549
|
+
throw new ForbiddenError(text, response.url, text);
|
|
550
|
+
case 404:
|
|
551
|
+
throw new NotFoundError(text, response.url, text);
|
|
552
|
+
case 500:
|
|
553
|
+
default:
|
|
554
|
+
throw new PrismicError(text, response.url, text);
|
|
500
555
|
}
|
|
501
|
-
}
|
|
556
|
+
};
|
|
502
557
|
export {
|
|
503
558
|
WriteClient
|
|
504
559
|
};
|
package/dist/WriteClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.js","sources":["../../src/WriteClient.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\"\nimport { pLimit } from \"./lib/pLimit\"\nimport {\n\tresolveMigrationContentRelationship,\n\tresolveMigrationDocumentData,\n} from \"./lib/resolveMigrationDocumentData\"\n\nimport type {\n\tAsset,\n\tPatchAssetParams,\n\tPatchAssetResult,\n\tPostAssetParams,\n\tPostAssetResult,\n} from \"./types/api/asset/asset\"\nimport type {\n\tAssetTag,\n\tGetAssetTagsResult,\n\tPostAssetTagParams,\n\tPostAssetTagResult,\n} from \"./types/api/asset/tag\"\nimport type { PutDocumentResult } from \"./types/api/migration/document\"\nimport {\n\ttype PostDocumentParams,\n\ttype PostDocumentResult,\n\ttype PutDocumentParams,\n} from \"./types/api/migration/document\"\nimport type { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type {\n\tMigrationDocument,\n\tPendingPrismicDocument,\n\tPrismicMigrationDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nimport { PrismicError } from \"./errors/PrismicError\"\n\nimport type { FetchParams, RequestInitLike } from \"./BaseClient\"\nimport { Client } from \"./Client\"\nimport type { ClientConfig } from \"./Client\"\nimport type { Migration } from \"./Migration\"\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { createMigration } from \"./createMigration\"\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * Utility type to construct events reported by the migration process.\n */\ntype MigrateReporterEvent<\n\tTType extends string,\n\tTData = never,\n> = TData extends never\n\t? { type: TType }\n\t: {\n\t\t\ttype: TType\n\t\t\tdata: TData\n\t\t}\n\n/**\n * A map of event types and their data reported by the migration process.\n */\ntype MigrateReporterEventMap = {\n\tstart: {\n\t\tpending: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\tend: {\n\t\tmigrated: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\t\"assets:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tasset: PrismicMigrationAsset\n\t}\n\t\"assets:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:masterLocale\": {\n\t\tmasterLocale: string\n\t}\n\t\"documents:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:updating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:updated\": {\n\t\tupdated: number\n\t}\n}\n\n/**\n * Available event types reported by the migration process.\n */\ntype MigrateReporterEventTypes = keyof MigrateReporterEventMap\n\n/**\n * All events reported by the migration process. Events can be listened to by\n * providing a `reporter` function to the `migrate` method.\n */\nexport type MigrateReporterEvents = {\n\t[K in MigrateReporterEventTypes]: MigrateReporterEvent<\n\t\tK,\n\t\tMigrateReporterEventMap[K]\n\t>\n}[MigrateReporterEventTypes]\n\n/**\n * Additional parameters for creating an asset in the Prismic media library.\n */\nexport type CreateAssetParams = {\n\t/**\n\t * Asset notes.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Asset credits.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Asset alt text.\n\t */\n\talt?: string\n\n\t/**\n\t * Asset tags.\n\t */\n\ttags?: string[]\n}\n\n/**\n * Configuration for clients that determine how content is queried.\n */\nexport type WriteClientConfig = {\n\t/**\n\t * A Prismic write token that allows writing content to the repository.\n\t */\n\twriteToken: string\n\n\t/**\n\t * The Prismic Asset API endpoint.\n\t *\n\t * @defaultValue `\"https://asset-api.prismic.io/\"`\n\t *\n\t * @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}\n\t */\n\tassetAPIEndpoint?: string\n\n\t/**\n\t * The Prismic Migration API endpoint.\n\t *\n\t * @defaultValue `\"https://migration.prismic.io/\"`\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tmigrationAPIEndpoint?: string\n} & ClientConfig\n\n/**\n * A client that allows querying and writing content to a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable,\n * such as Node.js, the `fetch` option must be provided as part of the `options`\n * parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class WriteClient<\n\tTDocuments extends PrismicDocument = PrismicDocument,\n> extends Client<TDocuments> {\n\twriteToken: string\n\n\tassetAPIEndpoint = \"https://asset-api.prismic.io/\"\n\tmigrationAPIEndpoint = \"https://migration.prismic.io/\"\n\n\t/**\n\t * Creates a Prismic client that can be used to query and write content to a\n\t * repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable,\n\t * such as in some Node.js versions, the `fetch` option must be provided as\n\t * part of the `options` parameter.\n\t *\n\t * @param repositoryName - The Prismic repository name for the repository.\n\t * @param options - Configuration that determines how content will be queried\n\t * from and written to the Prismic repository.\n\t *\n\t * @returns A client that can query and write content to the repository.\n\t */\n\tconstructor(repositoryName: string, options: WriteClientConfig) {\n\t\tsuper(repositoryName, options)\n\n\t\tif (typeof globalThis.window !== \"undefined\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] Prismic write client appears to be running in a browser environment. This is not recommended as it exposes your write token. Consider using Prismic write client in a server environment only, preferring the regular client for browser environment. For more details, see ${devMsg(\"avoid-write-client-in-browser\")}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.writeToken = options.writeToken\n\n\t\tif (options.assetAPIEndpoint) {\n\t\t\tthis.assetAPIEndpoint = `${options.assetAPIEndpoint}/`\n\t\t}\n\n\t\tif (options.migrationAPIEndpoint) {\n\t\t\tthis.migrationAPIEndpoint = `${options.migrationAPIEndpoint}/`\n\t\t}\n\t}\n\n\t/**\n\t * Creates a migration release on the Prismic repository based on the provided\n\t * prepared migration.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync migrate(\n\t\tmigration: Migration<TDocuments>,\n\t\tparams: {\n\t\t\treporter?: (event: MigrateReporterEvents) => void\n\t\t} & FetchParams = {},\n\t): Promise<void> {\n\t\tparams.reporter?.({\n\t\t\ttype: \"start\",\n\t\t\tdata: {\n\t\t\t\tpending: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\n\t\tawait this.migrateCreateAssets(migration, params)\n\t\tawait this.migrateCreateDocuments(migration, params)\n\t\tawait this.migrateUpdateDocuments(migration, params)\n\n\t\tparams.reporter?.({\n\t\t\ttype: \"end\",\n\t\t\tdata: {\n\t\t\t\tmigrated: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates assets in the Prismic repository's media library.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateAssets(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet created = 0\n\t\tfor (const [_, migrationAsset] of migration._assets) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"assets:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: migration._assets.size - created,\n\t\t\t\t\ttotal: migration._assets.size,\n\t\t\t\t\tasset: migrationAsset,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { file, filename, notes, credits, alt, tags } =\n\t\t\t\tmigrationAsset.config\n\n\t\t\tlet resolvedFile: PostAssetParams[\"file\"] | File\n\t\t\tif (typeof file === \"string\") {\n\t\t\t\tlet url: URL | undefined\n\t\t\t\ttry {\n\t\t\t\t\turl = new URL(file)\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// noop only on invalid URL, fetch errors will throw in the next if statement\n\t\t\t\t}\n\n\t\t\t\tif (url) {\n\t\t\t\t\t// File is a URL, fetch it\n\t\t\t\t\tresolvedFile = await this.fetchForeignAsset(\n\t\t\t\t\t\turl.toString(),\n\t\t\t\t\t\tfetchParams,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\t// File is actual file content, use it as-is\n\t\t\t\t\tresolvedFile = file\n\t\t\t\t}\n\t\t\t} else if (file instanceof URL) {\n\t\t\t\t// File is a URL instance, fetch it\n\t\t\t\tresolvedFile = await this.fetchForeignAsset(\n\t\t\t\t\tfile.toString(),\n\t\t\t\t\tfetchParams,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tresolvedFile = file\n\t\t\t}\n\n\t\t\tconst asset = await this.createAsset(resolvedFile, filename, {\n\t\t\t\t...{ notes, credits, alt, tags },\n\t\t\t\t...fetchParams,\n\t\t\t})\n\n\t\t\tmigrationAsset.asset = asset\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"assets:created\",\n\t\t\tdata: {\n\t\t\t\tcreated,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates documents in the Prismic repository's migration release.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\t// Resolve master locale\n\t\tconst repository = await this.getRepository(fetchParams)\n\t\tconst masterLocale = repository.languages.find((lang) => lang.is_master)!.id\n\t\treporter?.({\n\t\t\ttype: \"documents:masterLocale\",\n\t\t\tdata: {\n\t\t\t\tmasterLocale,\n\t\t\t},\n\t\t})\n\n\t\tconst documentsToCreate: PrismicMigrationDocument<TDocuments>[] = []\n\t\t// We create an array with non-master locale documents last because\n\t\t// we need their master locale document to be created first.\n\t\tfor (const doc of migration._documents) {\n\t\t\tif (!doc.document.id) {\n\t\t\t\tif (doc.document.lang === masterLocale) {\n\t\t\t\t\tdocumentsToCreate.unshift(doc)\n\t\t\t\t} else {\n\t\t\t\t\tdocumentsToCreate.push(doc)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet created = 0\n\t\tfor (const doc of documentsToCreate) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: documentsToCreate.length - created,\n\t\t\t\t\ttotal: documentsToCreate.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Resolve master language document ID for non-master locale documents\n\t\t\tlet masterLanguageDocumentID: string | undefined\n\t\t\tif (doc.masterLanguageDocument) {\n\t\t\t\tconst masterLanguageDocument =\n\t\t\t\t\tawait resolveMigrationContentRelationship(doc.masterLanguageDocument)\n\n\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\"id\" in masterLanguageDocument ? masterLanguageDocument.id : undefined\n\t\t\t} else if (doc.originalPrismicDocument) {\n\t\t\t\tconst maybeOriginalID =\n\t\t\t\t\tdoc.originalPrismicDocument.alternate_languages.find(\n\t\t\t\t\t\t({ lang }) => lang === masterLocale,\n\t\t\t\t\t)?.id\n\n\t\t\t\tif (maybeOriginalID) {\n\t\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\tmigration._getByOriginalID(maybeOriginalID)?.document.id\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { id } = await this.createDocument(\n\t\t\t\t// We'll upload documents data later on.\n\t\t\t\t{ ...doc.document, data: {} },\n\t\t\t\tdoc.title!,\n\t\t\t\t{\n\t\t\t\t\tmasterLanguageDocumentID,\n\t\t\t\t\t...fetchParams,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tdoc.document.id = id\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:created\",\n\t\t\tdata: { created },\n\t\t})\n\t}\n\n\t/**\n\t * Updates documents in the Prismic repository's migration release with their\n\t * patched data.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateUpdateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet i = 0\n\t\tfor (const doc of migration._documents) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:updating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++i,\n\t\t\t\t\tremaining: migration._documents.length - i,\n\t\t\t\t\ttotal: migration._documents.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tawait this.updateDocument(\n\t\t\t\tdoc.document.id!,\n\t\t\t\t// We need to forward again document name and tags to update them\n\t\t\t\t// in case the document already existed during the previous step.\n\t\t\t\t{\n\t\t\t\t\t...doc.document,\n\t\t\t\t\tdocumentTitle: doc.title,\n\t\t\t\t\tdata: await resolveMigrationDocumentData(\n\t\t\t\t\t\tdoc.document.data,\n\t\t\t\t\t\tmigration,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tfetchParams,\n\t\t\t)\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:updated\",\n\t\t\tdata: {\n\t\t\t\tupdated: migration._documents.length,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates an asset in the Prismic media library.\n\t *\n\t * @param file - The file to upload as an asset.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data and fetch parameters.\n\t *\n\t * @returns The created asset.\n\t */\n\tprivate async createAsset(\n\t\tfile: PostAssetParams[\"file\"] | File,\n\t\tfilename: string,\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t\t...params\n\t\t}: CreateAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(\"assets\", this.assetAPIEndpoint)\n\n\t\tconst formData = new FormData()\n\t\tformData.append(\n\t\t\t\"file\",\n\t\t\tnew File([file], filename, {\n\t\t\t\ttype: file instanceof File ? file.type : undefined,\n\t\t\t}),\n\t\t)\n\n\t\tif (notes) {\n\t\t\tformData.append(\"notes\", notes)\n\t\t}\n\n\t\tif (credits) {\n\t\t\tformData.append(\"credits\", credits)\n\t\t}\n\n\t\tif (alt) {\n\t\t\tformData.append(\"alt\", alt)\n\t\t}\n\n\t\tconst asset = await this.fetch<PostAssetResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildAssetAPIQueryParams({\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: formData,\n\t\t\t\tparams,\n\t\t\t}),\n\t\t)\n\n\t\tif (tags && tags.length) {\n\t\t\treturn this.updateAsset(asset.id, { tags })\n\t\t}\n\n\t\treturn asset\n\t}\n\n\t/**\n\t * Updates an asset in the Prismic media library.\n\t *\n\t * @param id - The ID of the asset to update.\n\t * @param params - The asset data to update and additional fetch parameters.\n\t *\n\t * @returns The updated asset.\n\t */\n\tprivate async updateAsset(\n\t\tid: string,\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\tfilename,\n\t\t\ttags,\n\t\t\t...params\n\t\t}: PatchAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(`assets/${id}`, this.assetAPIEndpoint)\n\n\t\t// Resolve tags if any and create missing ones\n\t\tif (tags && tags.length) {\n\t\t\ttags = await this.resolveAssetTagIDs(tags, {\n\t\t\t\tcreateTags: true,\n\t\t\t\t...params,\n\t\t\t})\n\t\t}\n\n\t\treturn this.fetch<PatchAssetResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildAssetAPIQueryParams<PatchAssetParams>({\n\t\t\t\tmethod: \"PATCH\",\n\t\t\t\tbody: {\n\t\t\t\t\tnotes,\n\t\t\t\t\tcredits,\n\t\t\t\t\talt,\n\t\t\t\t\tfilename,\n\t\t\t\t\ttags,\n\t\t\t\t},\n\t\t\t\tparams,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Fetches a foreign asset from a URL.\n\t *\n\t * @param url - The URL of the asset to fetch.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns A file representing the fetched asset.\n\t */\n\tprivate async fetchForeignAsset(\n\t\turl: string,\n\t\tparams: FetchParams = {},\n\t): Promise<Blob> {\n\t\tconst requestInit: RequestInitLike = {\n\t\t\t...this.fetchOptions,\n\t\t\t...params.fetchOptions,\n\t\t\theaders: {\n\t\t\t\t...this.fetchOptions?.headers,\n\t\t\t\t...params.fetchOptions?.headers,\n\t\t\t},\n\t\t\tsignal:\n\t\t\t\tparams.fetchOptions?.signal ||\n\t\t\t\tparams.signal ||\n\t\t\t\tthis.fetchOptions?.signal,\n\t\t}\n\n\t\tconst res = await this.fetchFn(url, requestInit)\n\n\t\tif (!res.ok) {\n\t\t\tthrow new PrismicError(\"Could not fetch foreign asset\", url, undefined)\n\t\t}\n\n\t\tconst blob = await res.blob()\n\n\t\t// Ensure a correct content type is attached to the blob.\n\t\treturn new File([blob], \"\", {\n\t\t\ttype: res.headers.get(\"content-type\") || undefined,\n\t\t})\n\t}\n\n\t/**\n\t * {@link resolveAssetTagIDs} rate limiter.\n\t */\n\tprivate _resolveAssetTagIDsLimit = pLimit()\n\n\t/**\n\t * Resolves asset tag IDs from tag names.\n\t *\n\t * @param tagNames - An array of tag names to resolve.\n\t * @param params - Whether or not missing tags should be created and\n\t * additional fetch parameters.\n\t *\n\t * @returns An array of resolved tag IDs.\n\t */\n\tprivate async resolveAssetTagIDs(\n\t\ttagNames: string[] = [],\n\t\t{ createTags, ...params }: { createTags?: boolean } & FetchParams = {},\n\t): Promise<string[]> {\n\t\treturn this._resolveAssetTagIDsLimit(async () => {\n\t\t\tconst existingTags = await this.getAssetTags(params)\n\t\t\tconst existingTagMap: Record<string, AssetTag> = {}\n\t\t\tfor (const tag of existingTags) {\n\t\t\t\texistingTagMap[tag.name] = tag\n\t\t\t}\n\n\t\t\tconst resolvedTagIDs = []\n\t\t\tfor (const tagName of tagNames) {\n\t\t\t\t// Tag does not exists yet, we create it if `createTags` is set\n\t\t\t\tif (!existingTagMap[tagName] && createTags) {\n\t\t\t\t\texistingTagMap[tagName] = await this.createAssetTag(tagName, params)\n\t\t\t\t}\n\n\t\t\t\t// Add tag if found\n\t\t\t\tif (existingTagMap[tagName]) {\n\t\t\t\t\tresolvedTagIDs.push(existingTagMap[tagName].id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resolvedTagIDs\n\t\t})\n\t}\n\n\t/**\n\t * Creates a tag in the Asset API.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t *\n\t * @param name - The name of the tag to create.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns The created tag.\n\t */\n\tprivate async createAssetTag(\n\t\tname: string,\n\t\tparams?: FetchParams,\n\t): Promise<AssetTag> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\treturn this.fetch<PostAssetTagResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildAssetAPIQueryParams<PostAssetTagParams>({\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: { name },\n\t\t\t\tparams,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Queries existing tags from the Asset API.\n\t *\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns An array of existing tags.\n\t */\n\tprivate async getAssetTags(params?: FetchParams): Promise<AssetTag[]> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst { items } = await this.fetch<GetAssetTagsResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildAssetAPIQueryParams({ params }),\n\t\t)\n\n\t\treturn items\n\t}\n\n\t/**\n\t * Creates a document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to create.\n\t *\n\t * @param document - The document to create.\n\t * @param documentTitle - The title of the document to create which will be\n\t * displayed in the editor.\n\t * @param params - Document master language document ID and additional fetch\n\t * parameters.\n\t *\n\t * @returns The ID of the created document.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async createDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\tdocumentTitle: string,\n\t\t{\n\t\t\tmasterLanguageDocumentID,\n\t\t\t...params\n\t\t}: { masterLanguageDocumentID?: string } & FetchParams = {},\n\t): Promise<{ id: string }> {\n\t\tconst url = new URL(\"documents\", this.migrationAPIEndpoint)\n\n\t\tconst result = await this.fetch<PostDocumentResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildMigrationAPIQueryParams<PostDocumentParams>({\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\ttitle: documentTitle,\n\t\t\t\t\ttype: document.type,\n\t\t\t\t\tuid: document.uid || undefined,\n\t\t\t\t\tlang: document.lang,\n\t\t\t\t\talternate_language_id: masterLanguageDocumentID,\n\t\t\t\t\ttags: document.tags,\n\t\t\t\t\tdata: document.data,\n\t\t\t\t},\n\t\t\t\tparams,\n\t\t\t}),\n\t\t)\n\n\t\treturn { id: result.id }\n\t}\n\n\t/**\n\t * Updates an existing document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param id - The ID of the document to update.\n\t * @param document - The document content to update.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async updateDocument<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t\tdocument: MigrationDocument<ExtractDocumentType<TDocuments, TType>> & {\n\t\t\tdocumentTitle?: string\n\t\t},\n\t\tparams?: FetchParams,\n\t): Promise<void> {\n\t\tconst url = new URL(`documents/${id}`, this.migrationAPIEndpoint)\n\n\t\tawait this.fetch<PutDocumentResult>(\n\t\t\turl.toString(),\n\t\t\tthis.buildMigrationAPIQueryParams({\n\t\t\t\tmethod: \"PUT\",\n\t\t\t\tbody: {\n\t\t\t\t\ttitle: document.documentTitle,\n\t\t\t\t\tuid: document.uid || undefined,\n\t\t\t\t\ttags: document.tags,\n\t\t\t\t\tdata: document.data,\n\t\t\t\t},\n\t\t\t\tparams,\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Builds fetch parameters for the Asset API.\n\t *\n\t * @typeParam TBody - Type of the body to send in the fetch request.\n\t *\n\t * @param params - Method, body, and additional fetch parameters.\n\t *\n\t * @returns An object that can be fetched to interact with the Asset API.\n\t *\n\t * @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}\n\t */\n\tprivate buildAssetAPIQueryParams<TBody = FormData | Record<string, unknown>>({\n\t\tmethod,\n\t\tbody,\n\t\tparams,\n\t}: {\n\t\tmethod?: string\n\t\tbody?: TBody\n\t\tparams?: FetchParams\n\t}): FetchParams {\n\t\tconst headers: Record<string, string> = {\n\t\t\t...params?.fetchOptions?.headers,\n\t\t\tauthorization: `Bearer ${this.writeToken}`,\n\t\t\trepository: this.repositoryName,\n\t\t}\n\n\t\tlet _body: FormData | string | undefined\n\t\tif (body instanceof FormData) {\n\t\t\t_body = body\n\t\t} else if (body) {\n\t\t\t_body = JSON.stringify(body)\n\t\t\theaders[\"content-type\"] = \"application/json\"\n\t\t}\n\n\t\treturn {\n\t\t\t...params,\n\t\t\tfetchOptions: {\n\t\t\t\t...params?.fetchOptions,\n\t\t\t\tmethod,\n\t\t\t\tbody: _body,\n\t\t\t\theaders,\n\t\t\t},\n\t\t}\n\t}\n\n\t/**\n\t * Builds fetch parameters for the Migration API.\n\t *\n\t * @typeParam TBody - Type of the body to send in the fetch request.\n\t *\n\t * @param params - Method, body, and additional fetch options.\n\t *\n\t * @returns An object that can be fetched to interact with the Migration API.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate buildMigrationAPIQueryParams<\n\t\tTBody extends PostDocumentParams | PutDocumentParams,\n\t>({\n\t\tmethod,\n\t\tbody,\n\t\tparams,\n\t}: {\n\t\tmethod?: string\n\t\tbody: TBody\n\t\tparams?: FetchParams\n\t}): FetchParams {\n\t\treturn {\n\t\t\t...params,\n\t\t\tfetchOptions: {\n\t\t\t\t...params?.fetchOptions,\n\t\t\t\tmethod,\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\theaders: {\n\t\t\t\t\t...params?.fetchOptions?.headers,\n\t\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\trepository: this.repositoryName,\n\t\t\t\t\tauthorization: `Bearer ${this.writeToken}`,\n\t\t\t\t},\n\t\t\t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,cAAA;AAAA,eACE,MAAM;AACR,cAAA,KAAK,UAAU,IAAI;AAC3B,cAAQ,cAAc,IAAI;AAAA,IAAA;AAGpB,WAAA;AAAA,MACN,GAAG;AAAA,MACH,cAAc;AAAA,QACb,GAAG,iCAAQ;AAAA,QACX;AAAA,QACA,MAAM;AAAA,QACN;AAAA,MAAA;AAAA;;;;;;;;;;;;;EAgBK,6BAEN,EACD,QACA,MACA,UAKA;;AACO,WAAA;AAAA,MACN,GAAG;AAAA,MACH,cAAc;AAAA,QACb,GAAG,iCAAQ;AAAA,QACX;AAAA,QACA,MAAM,KAAK,UAAU,IAAI;AAAA,QACzB,SAAS;AAAA,UACR,IAAG,sCAAQ,iBAAR,mBAAsB;AAAA,UACzB,gBAAgB;AAAA,UAChB,YAAY,KAAK;AAAA,UACjB,eAAe,UAAU,KAAK,UAAU;AAAA,QAAA;AAAA,MACxC;AAAA;;AAIJ;"}
|
|
1
|
+
{"version":3,"file":"WriteClient.js","sources":["../../src/WriteClient.ts"],"sourcesContent":["import { devMsg } from \"./lib/devMsg\"\nimport { pLimit } from \"./lib/pLimit\"\nimport type { ResponseLike } from \"./lib/request\"\nimport { type RequestInitLike, request } from \"./lib/request\"\nimport {\n\tresolveMigrationContentRelationship,\n\tresolveMigrationDocumentData,\n} from \"./lib/resolveMigrationDocumentData\"\n\nimport type {\n\tAsset,\n\tPatchAssetParams,\n\tPostAssetParams,\n\tPostAssetResult,\n} from \"./types/api/asset/asset\"\nimport type {\n\tAssetTag,\n\tGetAssetTagsResult,\n\tPostAssetTagResult,\n} from \"./types/api/asset/tag\"\nimport { type PostDocumentResult } from \"./types/api/migration/document\"\nimport type { PrismicMigrationAsset } from \"./types/migration/Asset\"\nimport type {\n\tMigrationDocument,\n\tPendingPrismicDocument,\n\tPrismicMigrationDocument,\n} from \"./types/migration/Document\"\nimport type { PrismicDocument } from \"./types/value/document\"\n\nimport { ForbiddenError } from \"./errors/ForbiddenError\"\nimport { InvalidDataError } from \"./errors/InvalidDataError\"\nimport { NotFoundError } from \"./errors/NotFoundError\"\nimport { PrismicError } from \"./errors/PrismicError\"\n\nimport { name, version } from \"../package.json\"\n\nimport { Client } from \"./Client\"\nimport type { ClientConfig, FetchParams } from \"./Client\"\nimport type { Migration } from \"./Migration\"\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { createMigration } from \"./createMigration\"\n\nconst CLIENT_IDENTIFIER = `${name.replace(\"@\", \"\").replace(\"/\", \"-\")}/${version}`\n\n/**\n * Extracts one or more Prismic document types that match a given Prismic\n * document type. If no matches are found, no extraction is performed and the\n * union of all provided Prismic document types are returned.\n *\n * @typeParam TDocuments - Prismic document types from which to extract.\n * @typeParam TDocumentType - Type(s) to match `TDocuments` against.\n */\ntype ExtractDocumentType<\n\tTDocuments extends { type: string },\n\tTDocumentType extends TDocuments[\"type\"],\n> =\n\tExtract<TDocuments, { type: TDocumentType }> extends never\n\t\t? TDocuments\n\t\t: Extract<TDocuments, { type: TDocumentType }>\n\n/**\n * Utility type to construct events reported by the migration process.\n */\ntype MigrateReporterEvent<\n\tTType extends string,\n\tTData = never,\n> = TData extends never\n\t? { type: TType }\n\t: {\n\t\t\ttype: TType\n\t\t\tdata: TData\n\t\t}\n\n/**\n * A map of event types and their data reported by the migration process.\n */\ntype MigrateReporterEventMap = {\n\tstart: {\n\t\tpending: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\tend: {\n\t\tmigrated: {\n\t\t\tdocuments: number\n\t\t\tassets: number\n\t\t}\n\t}\n\t\"assets:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tasset: PrismicMigrationAsset\n\t}\n\t\"assets:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:masterLocale\": {\n\t\tmasterLocale: string\n\t}\n\t\"documents:creating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:created\": {\n\t\tcreated: number\n\t}\n\t\"documents:updating\": {\n\t\tcurrent: number\n\t\tremaining: number\n\t\ttotal: number\n\t\tdocument: PrismicMigrationDocument\n\t}\n\t\"documents:updated\": {\n\t\tupdated: number\n\t}\n}\n\n/**\n * Available event types reported by the migration process.\n */\ntype MigrateReporterEventTypes = keyof MigrateReporterEventMap\n\n/**\n * All events reported by the migration process. Events can be listened to by\n * providing a `reporter` function to the `migrate` method.\n */\nexport type MigrateReporterEvents = {\n\t[K in MigrateReporterEventTypes]: MigrateReporterEvent<\n\t\tK,\n\t\tMigrateReporterEventMap[K]\n\t>\n}[MigrateReporterEventTypes]\n\n/**\n * Additional parameters for creating an asset in the Prismic media library.\n */\nexport type CreateAssetParams = {\n\t/**\n\t * Asset notes.\n\t */\n\tnotes?: string\n\n\t/**\n\t * Asset credits.\n\t */\n\tcredits?: string\n\n\t/**\n\t * Asset alt text.\n\t */\n\talt?: string\n\n\t/**\n\t * Asset tags.\n\t */\n\ttags?: string[]\n}\n\n/**\n * Configuration for clients that determine how content is queried.\n */\nexport type WriteClientConfig = {\n\t/**\n\t * A Prismic write token that allows writing content to the repository.\n\t */\n\twriteToken: string\n\n\t/**\n\t * The Prismic Asset API endpoint.\n\t *\n\t * @defaultValue `\"https://asset-api.prismic.io/\"`\n\t *\n\t * @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}\n\t */\n\tassetAPIEndpoint?: string\n\n\t/**\n\t * The Prismic Migration API endpoint.\n\t *\n\t * @defaultValue `\"https://migration.prismic.io/\"`\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tmigrationAPIEndpoint?: string\n} & ClientConfig\n\n/**\n * A client that allows querying and writing content to a Prismic repository.\n *\n * If used in an environment where a global `fetch` function is unavailable,\n * such as Node.js, the `fetch` option must be provided as part of the `options`\n * parameter.\n *\n * @typeParam TDocuments - Document types that are registered for the Prismic\n * repository. Query methods will automatically be typed based on this type.\n */\nexport class WriteClient<\n\tTDocuments extends PrismicDocument = PrismicDocument,\n> extends Client<TDocuments> {\n\twriteToken: string\n\n\tassetAPIEndpoint = \"https://asset-api.prismic.io/\"\n\tmigrationAPIEndpoint = \"https://migration.prismic.io/\"\n\n\t/**\n\t * Creates a Prismic client that can be used to query and write content to a\n\t * repository.\n\t *\n\t * If used in an environment where a global `fetch` function is unavailable,\n\t * such as in some Node.js versions, the `fetch` option must be provided as\n\t * part of the `options` parameter.\n\t *\n\t * @param repositoryName - The Prismic repository name for the repository.\n\t * @param options - Configuration that determines how content will be queried\n\t * from and written to the Prismic repository.\n\t *\n\t * @returns A client that can query and write content to the repository.\n\t */\n\tconstructor(repositoryName: string, options: WriteClientConfig) {\n\t\tsuper(repositoryName, options)\n\n\t\tif (typeof globalThis.window !== \"undefined\") {\n\t\t\tconsole.warn(\n\t\t\t\t`[@prismicio/client] Prismic write client appears to be running in a browser environment. This is not recommended as it exposes your write token. Consider using Prismic write client in a server environment only, preferring the regular client for browser environment. For more details, see ${devMsg(\"avoid-write-client-in-browser\")}`,\n\t\t\t)\n\t\t}\n\n\t\tthis.writeToken = options.writeToken\n\n\t\tif (options.assetAPIEndpoint) {\n\t\t\tthis.assetAPIEndpoint = `${options.assetAPIEndpoint}/`\n\t\t}\n\n\t\tif (options.migrationAPIEndpoint) {\n\t\t\tthis.migrationAPIEndpoint = `${options.migrationAPIEndpoint}/`\n\t\t}\n\t}\n\n\t/**\n\t * Creates a migration release on the Prismic repository based on the provided\n\t * prepared migration.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tasync migrate(\n\t\tmigration: Migration<TDocuments>,\n\t\tparams: {\n\t\t\treporter?: (event: MigrateReporterEvents) => void\n\t\t} & FetchParams = {},\n\t): Promise<void> {\n\t\tparams.reporter?.({\n\t\t\ttype: \"start\",\n\t\t\tdata: {\n\t\t\t\tpending: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\n\t\tawait this.migrateCreateAssets(migration, params)\n\t\tawait this.migrateCreateDocuments(migration, params)\n\t\tawait this.migrateUpdateDocuments(migration, params)\n\n\t\tparams.reporter?.({\n\t\t\ttype: \"end\",\n\t\t\tdata: {\n\t\t\t\tmigrated: {\n\t\t\t\t\tdocuments: migration._documents.length,\n\t\t\t\t\tassets: migration._assets.size,\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates assets in the Prismic repository's media library.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateAssets(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet created = 0\n\t\tfor (const [_, migrationAsset] of migration._assets) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"assets:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: migration._assets.size - created,\n\t\t\t\t\ttotal: migration._assets.size,\n\t\t\t\t\tasset: migrationAsset,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tconst { file, filename, notes, credits, alt, tags } =\n\t\t\t\tmigrationAsset.config\n\n\t\t\tlet resolvedFile: PostAssetParams[\"file\"] | File\n\t\t\tif (typeof file === \"string\") {\n\t\t\t\tlet url: URL | undefined\n\t\t\t\ttry {\n\t\t\t\t\turl = new URL(file)\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// noop only on invalid URL, fetch errors will throw in the next if statement\n\t\t\t\t}\n\n\t\t\t\tif (url) {\n\t\t\t\t\t// File is a URL, fetch it\n\t\t\t\t\tresolvedFile = await this.fetchForeignAsset(\n\t\t\t\t\t\turl.toString(),\n\t\t\t\t\t\tfetchParams,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\t// File is actual file content, use it as-is\n\t\t\t\t\tresolvedFile = file\n\t\t\t\t}\n\t\t\t} else if (file instanceof URL) {\n\t\t\t\t// File is a URL instance, fetch it\n\t\t\t\tresolvedFile = await this.fetchForeignAsset(\n\t\t\t\t\tfile.toString(),\n\t\t\t\t\tfetchParams,\n\t\t\t\t)\n\t\t\t} else {\n\t\t\t\tresolvedFile = file\n\t\t\t}\n\n\t\t\tconst asset = await this.createAsset(resolvedFile, filename, {\n\t\t\t\t...{ notes, credits, alt, tags },\n\t\t\t\t...fetchParams,\n\t\t\t})\n\n\t\t\tmigrationAsset.asset = asset\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"assets:created\",\n\t\t\tdata: {\n\t\t\t\tcreated,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates documents in the Prismic repository's migration release.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateCreateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\t// Resolve master locale\n\t\tconst repository = await this.getRepository(fetchParams)\n\t\tconst masterLocale = repository.languages.find((lang) => lang.is_master)!.id\n\t\treporter?.({\n\t\t\ttype: \"documents:masterLocale\",\n\t\t\tdata: {\n\t\t\t\tmasterLocale,\n\t\t\t},\n\t\t})\n\n\t\tconst documentsToCreate: PrismicMigrationDocument<TDocuments>[] = []\n\t\t// We create an array with non-master locale documents last because\n\t\t// we need their master locale document to be created first.\n\t\tfor (const doc of migration._documents) {\n\t\t\tif (!doc.document.id) {\n\t\t\t\tif (doc.document.lang === masterLocale) {\n\t\t\t\t\tdocumentsToCreate.unshift(doc)\n\t\t\t\t} else {\n\t\t\t\t\tdocumentsToCreate.push(doc)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tlet created = 0\n\t\tfor (const doc of documentsToCreate) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:creating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++created,\n\t\t\t\t\tremaining: documentsToCreate.length - created,\n\t\t\t\t\ttotal: documentsToCreate.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\t// Resolve master language document ID for non-master locale documents\n\t\t\tlet masterLanguageDocumentID: string | undefined\n\t\t\tif (doc.masterLanguageDocument) {\n\t\t\t\tconst masterLanguageDocument =\n\t\t\t\t\tawait resolveMigrationContentRelationship(doc.masterLanguageDocument)\n\n\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\"id\" in masterLanguageDocument ? masterLanguageDocument.id : undefined\n\t\t\t} else if (doc.originalPrismicDocument) {\n\t\t\t\tconst maybeOriginalID =\n\t\t\t\t\tdoc.originalPrismicDocument.alternate_languages.find(\n\t\t\t\t\t\t({ lang }) => lang === masterLocale,\n\t\t\t\t\t)?.id\n\n\t\t\t\tif (maybeOriginalID) {\n\t\t\t\t\tmasterLanguageDocumentID =\n\t\t\t\t\t\tmigration._getByOriginalID(maybeOriginalID)?.document.id\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst { id } = await this.createDocument(\n\t\t\t\t// We'll upload documents data later on.\n\t\t\t\t{ ...doc.document, data: {} },\n\t\t\t\tdoc.title!,\n\t\t\t\t{\n\t\t\t\t\tmasterLanguageDocumentID,\n\t\t\t\t\t...fetchParams,\n\t\t\t\t},\n\t\t\t)\n\n\t\t\tdoc.document.id = id\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:created\",\n\t\t\tdata: { created },\n\t\t})\n\t}\n\n\t/**\n\t * Updates documents in the Prismic repository's migration release with their\n\t * patched data.\n\t *\n\t * @param migration - A migration prepared with {@link createMigration}.\n\t * @param params - An event listener and additional fetch parameters.\n\t *\n\t * @internal This method is one of the step performed by the {@link migrate} method.\n\t */\n\tprivate async migrateUpdateDocuments(\n\t\tmigration: Migration<TDocuments>,\n\t\t{\n\t\t\treporter,\n\t\t\t...fetchParams\n\t\t}: { reporter?: (event: MigrateReporterEvents) => void } & FetchParams = {},\n\t): Promise<void> {\n\t\tlet i = 0\n\t\tfor (const doc of migration._documents) {\n\t\t\treporter?.({\n\t\t\t\ttype: \"documents:updating\",\n\t\t\t\tdata: {\n\t\t\t\t\tcurrent: ++i,\n\t\t\t\t\tremaining: migration._documents.length - i,\n\t\t\t\t\ttotal: migration._documents.length,\n\t\t\t\t\tdocument: doc,\n\t\t\t\t},\n\t\t\t})\n\n\t\t\tawait this.updateDocument(\n\t\t\t\tdoc.document.id!,\n\t\t\t\t// We need to forward again document name and tags to update them\n\t\t\t\t// in case the document already existed during the previous step.\n\t\t\t\t{\n\t\t\t\t\t...doc.document,\n\t\t\t\t\tdocumentTitle: doc.title,\n\t\t\t\t\tdata: await resolveMigrationDocumentData(\n\t\t\t\t\t\tdoc.document.data,\n\t\t\t\t\t\tmigration,\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tfetchParams,\n\t\t\t)\n\t\t}\n\n\t\treporter?.({\n\t\t\ttype: \"documents:updated\",\n\t\t\tdata: {\n\t\t\t\tupdated: migration._documents.length,\n\t\t\t},\n\t\t})\n\t}\n\n\t/**\n\t * Creates an asset in the Prismic media library.\n\t *\n\t * @param file - The file to upload as an asset.\n\t * @param filename - The filename of the asset.\n\t * @param params - Additional asset data and fetch parameters.\n\t *\n\t * @returns The created asset.\n\t */\n\tprivate async createAsset(\n\t\tfile: PostAssetParams[\"file\"] | File,\n\t\tfilename: string,\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\ttags,\n\t\t\t...params\n\t\t}: CreateAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(\"assets\", this.assetAPIEndpoint)\n\n\t\tconst formData = new FormData()\n\t\tformData.append(\n\t\t\t\"file\",\n\t\t\tnew File([file], filename, {\n\t\t\t\ttype: file instanceof File ? file.type : undefined,\n\t\t\t}),\n\t\t)\n\n\t\tif (notes) {\n\t\t\tformData.append(\"notes\", notes)\n\t\t}\n\n\t\tif (credits) {\n\t\t\tformData.append(\"credits\", credits)\n\t\t}\n\n\t\tif (alt) {\n\t\t\tformData.append(\"alt\", alt)\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: formData,\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst asset = (await response.json()) as PostAssetResult\n\n\t\t\t\tif (tags && tags.length) {\n\t\t\t\t\treturn this.updateAsset(asset.id, { tags })\n\t\t\t\t}\n\n\t\t\t\treturn asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an asset in the Prismic media library.\n\t *\n\t * @param id - The ID of the asset to update.\n\t * @param params - The asset data to update and additional fetch parameters.\n\t *\n\t * @returns The updated asset.\n\t */\n\tprivate async updateAsset(\n\t\tid: string,\n\t\t{\n\t\t\tnotes,\n\t\t\tcredits,\n\t\t\talt,\n\t\t\tfilename,\n\t\t\ttags,\n\t\t\t...params\n\t\t}: PatchAssetParams & FetchParams = {},\n\t): Promise<Asset> {\n\t\tconst url = new URL(`assets/${id}`, this.assetAPIEndpoint)\n\n\t\t// Resolve tags if any and create missing ones\n\t\tif (tags && tags.length) {\n\t\t\ttags = await this.resolveAssetTagIDs(tags, {\n\t\t\t\tcreateTags: true,\n\t\t\t\t...params,\n\t\t\t})\n\t\t}\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PATCH\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\tnotes,\n\t\t\t\tcredits,\n\t\t\t\talt,\n\t\t\t\tfilename,\n\t\t\t\ttags,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn (await response.json()) as Asset\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Fetches a foreign asset from a URL.\n\t *\n\t * @param url - The URL of the asset to fetch.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns A file representing the fetched asset.\n\t */\n\tprivate async fetchForeignAsset(\n\t\turl: string,\n\t\tparams: FetchParams = {},\n\t): Promise<Blob> {\n\t\tconst res = await this.fetchFn(url, this._buildRequestInit(params))\n\n\t\tif (!res.ok) {\n\t\t\tthrow new PrismicError(\"Could not fetch foreign asset\", url, undefined)\n\t\t}\n\n\t\tconst blob = await res.blob()\n\n\t\t// Ensure a correct content type is attached to the blob.\n\t\treturn new File([blob], \"\", {\n\t\t\ttype: res.headers.get(\"content-type\") || undefined,\n\t\t})\n\t}\n\n\t/**\n\t * {@link resolveAssetTagIDs} rate limiter.\n\t */\n\tprivate _resolveAssetTagIDsLimit = pLimit()\n\n\t/**\n\t * Resolves asset tag IDs from tag names.\n\t *\n\t * @param tagNames - An array of tag names to resolve.\n\t * @param params - Whether or not missing tags should be created and\n\t * additional fetch parameters.\n\t *\n\t * @returns An array of resolved tag IDs.\n\t */\n\tprivate async resolveAssetTagIDs(\n\t\ttagNames: string[] = [],\n\t\t{ createTags, ...params }: { createTags?: boolean } & FetchParams = {},\n\t): Promise<string[]> {\n\t\treturn this._resolveAssetTagIDsLimit(async () => {\n\t\t\tconst existingTags = await this.getAssetTags(params)\n\t\t\tconst existingTagMap: Record<string, AssetTag> = {}\n\t\t\tfor (const tag of existingTags) {\n\t\t\t\texistingTagMap[tag.name] = tag\n\t\t\t}\n\n\t\t\tconst resolvedTagIDs = []\n\t\t\tfor (const tagName of tagNames) {\n\t\t\t\t// Tag does not exists yet, we create it if `createTags` is set\n\t\t\t\tif (!existingTagMap[tagName] && createTags) {\n\t\t\t\t\texistingTagMap[tagName] = await this.createAssetTag(tagName, params)\n\t\t\t\t}\n\n\t\t\t\t// Add tag if found\n\t\t\t\tif (existingTagMap[tagName]) {\n\t\t\t\t\tresolvedTagIDs.push(existingTagMap[tagName].id)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn resolvedTagIDs\n\t\t})\n\t}\n\n\t/**\n\t * Creates a tag in the Asset API.\n\t *\n\t * @remarks\n\t * Tags should be at least 3 characters long and 20 characters at most.\n\t *\n\t * @param name - The name of the tag to create.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns The created tag.\n\t */\n\tprivate async createAssetTag(\n\t\tname: string,\n\t\tparams?: FetchParams,\n\t): Promise<AssetTag> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({ name }),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\treturn (await response.json()) as PostAssetTagResult\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Queries existing tags from the Asset API.\n\t *\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @returns An array of existing tags.\n\t */\n\tprivate async getAssetTags(params?: FetchParams): Promise<AssetTag[]> {\n\t\tconst url = new URL(\"tags\", this.assetAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params)\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\tconst json = (await response.json()) as GetAssetTagsResult\n\n\t\t\t\treturn json.items\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleAssetAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Creates a document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to create.\n\t *\n\t * @param document - The document to create.\n\t * @param documentTitle - The title of the document to create which will be\n\t * displayed in the editor.\n\t * @param params - Document master language document ID and additional fetch\n\t * parameters.\n\t *\n\t * @returns The ID of the created document.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async createDocument<TType extends TDocuments[\"type\"]>(\n\t\tdocument: PendingPrismicDocument<ExtractDocumentType<TDocuments, TType>>,\n\t\tdocumentTitle: string,\n\t\t{\n\t\t\tmasterLanguageDocumentID,\n\t\t\t...params\n\t\t}: { masterLanguageDocumentID?: string } & FetchParams = {},\n\t): Promise<{ id: string }> {\n\t\tconst url = new URL(\"documents\", this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: documentTitle,\n\t\t\t\ttype: document.type,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\tlang: document.lang,\n\t\t\t\talternate_language_id: masterLanguageDocumentID,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 201: {\n\t\t\t\tconst json = (await response.json()) as PostDocumentResult\n\n\t\t\t\treturn { id: json.id }\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn await this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Updates an existing document in the repository's migration release.\n\t *\n\t * @typeParam TType - Type of Prismic documents to update.\n\t *\n\t * @param id - The ID of the document to update.\n\t * @param document - The document content to update.\n\t * @param params - Additional fetch parameters.\n\t *\n\t * @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}\n\t */\n\tprivate async updateDocument<TType extends TDocuments[\"type\"]>(\n\t\tid: string,\n\t\tdocument: MigrationDocument<ExtractDocumentType<TDocuments, TType>> & {\n\t\t\tdocumentTitle?: string\n\t\t},\n\t\tparams?: FetchParams,\n\t): Promise<void> {\n\t\tconst url = new URL(`documents/${id}`, this.migrationAPIEndpoint)\n\n\t\tconst response = await this.#request(url, params, {\n\t\t\tmethod: \"PUT\",\n\t\t\tbody: JSON.stringify({\n\t\t\t\ttitle: document.documentTitle,\n\t\t\t\tuid: document.uid || undefined,\n\t\t\t\ttags: document.tags,\n\t\t\t\tdata: document.data,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\t\"content-type\": \"application/json\",\n\t\t\t\t\"x-client\": CLIENT_IDENTIFIER,\n\t\t\t},\n\t\t})\n\t\tswitch (response.status) {\n\t\t\tcase 200: {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tawait this.#handleMigrationAPIError(response)\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Makes an authenticated HTTP request for write operations using the client's\n\t * configured fetch function and options.\n\t *\n\t * @param url - The URL to request.\n\t * @param params - Fetch options from the user.\n\t * @param init - Additional fetch options to merge with the user-provided\n\t * options.\n\t *\n\t * @returns The response from the fetch request.\n\t */\n\tasync #request(\n\t\turl: URL,\n\t\tparams?: RequestInitLike,\n\t\tinit?: RequestInitLike,\n\t): Promise<ResponseLike> {\n\t\tconst baseInit = this._buildRequestInit(params)\n\n\t\treturn await request(\n\t\t\turl,\n\t\t\t{\n\t\t\t\t...baseInit,\n\t\t\t\t...init,\n\t\t\t\theaders: {\n\t\t\t\t\t...baseInit.headers,\n\t\t\t\t\t...init?.headers,\n\t\t\t\t\trepository: this.repositoryName,\n\t\t\t\t\tauthorization: `Bearer ${this.writeToken}`,\n\t\t\t\t},\n\t\t\t},\n\t\t\tthis.fetchFn,\n\t\t)\n\t}\n\n\t/**\n\t * Handles error responses from the Asset API with comprehensive error\n\t * parsing.\n\t *\n\t * @param response - The HTTP response from the Asset API.\n\t *\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, 503, and other unexpected errors.\n\t */\n\tasync #handleAssetAPIError(response: ResponseLike): Promise<never> {\n\t\tconst json = await response.json()\n\t\tswitch (response.status) {\n\t\t\tcase 401:\n\t\t\tcase 403:\n\t\t\t\tthrow new ForbiddenError(json.error, response.url, json)\n\n\t\t\tcase 404:\n\t\t\t\tthrow new NotFoundError(json.error, response.url, json)\n\n\t\t\tcase 400:\n\t\t\t\tthrow new InvalidDataError(json.error, response.url, json)\n\n\t\t\tcase 500:\n\t\t\tcase 503:\n\t\t\tdefault:\n\t\t\t\tthrow new PrismicError(json.error, response.url, json)\n\t\t}\n\t}\n\n\t/**\n\t * Handles error responses from the Migration API with comprehensive error\n\t * parsing.\n\t *\n\t * @param response - The HTTP response from the Migration API.\n\t *\n\t * @throws {@link InvalidDataError} For 400 errors.\n\t * @throws {@link ForbiddenError} For 401 and 403 errors.\n\t * @throws {@link NotFoundError} For 404 errors.\n\t * @throws {@link PrismicError} For 500, and other unexpected errors.\n\t */\n\tasync #handleMigrationAPIError(response: ResponseLike): Promise<never> {\n\t\t// Some responses come with a JSON body, some with a text body.\n\t\tconst text = await response.text()\n\t\tlet json: unknown\n\t\ttry {\n\t\t\tjson = JSON.parse(text)\n\t\t} catch {\n\t\t\t// no-op\n\t\t}\n\n\t\tswitch (response.status) {\n\t\t\tcase 400:\n\t\t\t\tif (json) {\n\t\t\t\t\tthrow new InvalidDataError(\n\t\t\t\t\t\t\"Validation failed, check the response property of the error for details\",\n\t\t\t\t\t\tresponse.url,\n\t\t\t\t\t\tjson, // `json` has the shape Array<{ property: string, value: unknown, error: string }>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tthrow new InvalidDataError(text, response.url, text)\n\n\t\t\tcase 401:\n\t\t\t\tthrow new ForbiddenError(text, response.url, text)\n\n\t\t\tcase 403:\n\t\t\t\tif (json) {\n\t\t\t\t\tthrow new ForbiddenError(\n\t\t\t\t\t\t(json as { Message: string }).Message,\n\t\t\t\t\t\tresponse.url,\n\t\t\t\t\t\tjson,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tthrow new ForbiddenError(text, response.url, text)\n\n\t\t\tcase 404:\n\t\t\t\tthrow new NotFoundError(text, response.url, text)\n\n\t\t\tcase 500:\n\t\t\tdefault:\n\t\t\t\tthrow new PrismicError(text, response.url, text)\n\t\t}\n\t}\n}\n"],"names":["name"],"mappings":";;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,oBAAoB,GAAG,KAAK,QAAQ,KAAK,EAAE,EAAE,QAAQ,KAAK,GAAG,CAAC,IAAI,OAAO;AA8JzE,MAAO,oBAEH,OAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB3B,YAAY,gBAAwB,SAA0B;AAC7D,UAAM,gBAAgB,OAAO;AAvBzB;AAGL;AAEA,4CAAmB;AACnB,gDAAuB;AAmbf;AAAA;AAAA;AAAA,oDAA2B,OAAM;AAhapC,QAAA,OAAO,WAAW,WAAW,aAAa;AAC7C,cAAQ,KACP,mSAAmS,OAAO,+BAA+B,CAAC,EAAE;AAAA,IAAA;AAI9U,SAAK,aAAa,QAAQ;AAE1B,QAAI,QAAQ,kBAAkB;AACxB,WAAA,mBAAmB,GAAG,QAAQ,gBAAgB;AAAA,IAAA;AAGpD,QAAI,QAAQ,sBAAsB;AAC5B,WAAA,uBAAuB,GAAG,QAAQ,oBAAoB;AAAA,IAAA;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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R,KAA6B,SAC9B,SAAS,KACT,IAAI;AAAA,MAAA;AAGN,YAAM,IAAI,eAAe,MAAM,SAAS,KAAK,IAAI;AAAA,IAElD,KAAK;AACJ,YAAM,IAAI,cAAc,MAAM,SAAS,KAAK,IAAI;AAAA,IAEjD,KAAK;AAAA,IACL;AACC,YAAM,IAAI,aAAa,MAAM,SAAS,KAAK,IAAI;AAAA,EAAA;AACjD;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const PrismicError = require("./PrismicError.cjs");
|
|
4
|
+
class InvalidDataError extends PrismicError.PrismicError {
|
|
5
|
+
}
|
|
6
|
+
exports.InvalidDataError = InvalidDataError;
|
|
7
|
+
//# sourceMappingURL=InvalidDataError.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidDataError.cjs","sources":["../../../src/errors/InvalidDataError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\nexport class InvalidDataError<\n\tTResponse = undefined,\n> extends PrismicError<TResponse> {}\n"],"names":["PrismicError"],"mappings":";;;AAEM,MAAO,yBAEHA,aAAAA,aAAuB;AAAG;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidDataError.js","sources":["../../../src/errors/InvalidDataError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\nexport class InvalidDataError<\n\tTResponse = undefined,\n> extends PrismicError<TResponse> {}\n"],"names":[],"mappings":";AAEM,MAAO,yBAEH,aAAuB;AAAG;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsingError.cjs","sources":["../../../src/errors/ParsingError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\ntype ParsingErrorAPIResponse = {\n\ttype: \"parsing-error\"\n\tmessage: string\n\tline: number\n\tcolumn: number\n\tid: number\n\tlocation: string\n}\n\nexport class ParsingError<\n\tTResponse = ParsingErrorAPIResponse,\n> extends PrismicError<TResponse> {}\n"],"names":["PrismicError"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ParsingError.cjs","sources":["../../../src/errors/ParsingError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\ntype ParsingErrorAPIResponse = {\n\ttype: \"parsing-error\"\n\tmessage: string\n\tpos: {\n\t\tline: number\n\t\tcolumn: number\n\t\tid: number\n\t\tlocation: string\n\t}\n}\n\nexport class ParsingError<\n\tTResponse = ParsingErrorAPIResponse,\n> extends PrismicError<TResponse> {}\n"],"names":["PrismicError"],"mappings":";;;AAaM,MAAO,qBAEHA,aAAAA,aAAuB;AAAG;;"}
|
|
@@ -2,10 +2,12 @@ import { PrismicError } from "./PrismicError";
|
|
|
2
2
|
type ParsingErrorAPIResponse = {
|
|
3
3
|
type: "parsing-error";
|
|
4
4
|
message: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
pos: {
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
id: number;
|
|
9
|
+
location: string;
|
|
10
|
+
};
|
|
9
11
|
};
|
|
10
12
|
export declare class ParsingError<TResponse = ParsingErrorAPIResponse> extends PrismicError<TResponse> {
|
|
11
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParsingError.js","sources":["../../../src/errors/ParsingError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\ntype ParsingErrorAPIResponse = {\n\ttype: \"parsing-error\"\n\tmessage: string\n\tline: number\n\tcolumn: number\n\tid: number\n\tlocation: string\n}\n\nexport class ParsingError<\n\tTResponse = ParsingErrorAPIResponse,\n> extends PrismicError<TResponse> {}\n"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ParsingError.js","sources":["../../../src/errors/ParsingError.ts"],"sourcesContent":["import { PrismicError } from \"./PrismicError\"\n\ntype ParsingErrorAPIResponse = {\n\ttype: \"parsing-error\"\n\tmessage: string\n\tpos: {\n\t\tline: number\n\t\tcolumn: number\n\t\tid: number\n\t\tlocation: string\n\t}\n}\n\nexport class ParsingError<\n\tTResponse = ParsingErrorAPIResponse,\n> extends PrismicError<TResponse> {}\n"],"names":[],"mappings":";AAaM,MAAO,qBAEH,aAAuB;AAAG;"}
|