@prismicio/client 7.19.1 → 7.19.2
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 +109 -93
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.ts +66 -27
- package/dist/Client.js +109 -93
- package/dist/Client.js.map +1 -1
- package/dist/WriteClient.cjs +151 -100
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.ts +2 -26
- package/dist/WriteClient.js +151 -100
- 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 +2 -2
- 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 +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/src/Client.ts +197 -167
- package/src/WriteClient.ts +214 -157
- package/src/errors/InvalidDataError.ts +5 -0
- package/src/errors/ParsingError.ts +6 -4
- package/src/index.ts +7 -8
- package/src/lib/request.ts +166 -0
- 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.cjs
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __typeError = (msg) => {
|
|
4
|
+
throw TypeError(msg);
|
|
5
|
+
};
|
|
3
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
9
|
+
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);
|
|
10
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
11
|
+
var _WriteClient_instances, request_fn, handleAssetAPIError_fn, handleMigrationAPIError_fn;
|
|
5
12
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
13
|
const devMsg = require("./lib/devMsg.cjs");
|
|
7
14
|
const pLimit = require("./lib/pLimit.cjs");
|
|
15
|
+
const request = require("./lib/request.cjs");
|
|
8
16
|
const resolveMigrationDocumentData = require("./lib/resolveMigrationDocumentData.cjs");
|
|
17
|
+
const ForbiddenError = require("./errors/ForbiddenError.cjs");
|
|
18
|
+
const InvalidDataError = require("./errors/InvalidDataError.cjs");
|
|
19
|
+
const NotFoundError = require("./errors/NotFoundError.cjs");
|
|
9
20
|
const PrismicError = require("./errors/PrismicError.cjs");
|
|
10
21
|
const Client = require("./Client.cjs");
|
|
11
22
|
class WriteClient extends Client.Client {
|
|
@@ -25,6 +36,7 @@ class WriteClient extends Client.Client {
|
|
|
25
36
|
*/
|
|
26
37
|
constructor(repositoryName, options) {
|
|
27
38
|
super(repositoryName, options);
|
|
39
|
+
__privateAdd(this, _WriteClient_instances);
|
|
28
40
|
__publicField(this, "writeToken");
|
|
29
41
|
__publicField(this, "assetAPIEndpoint", "https://asset-api.prismic.io/");
|
|
30
42
|
__publicField(this, "migrationAPIEndpoint", "https://migration.prismic.io/");
|
|
@@ -256,15 +268,22 @@ class WriteClient extends Client.Client {
|
|
|
256
268
|
if (alt) {
|
|
257
269
|
formData.append("alt", alt);
|
|
258
270
|
}
|
|
259
|
-
const
|
|
271
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
260
272
|
method: "POST",
|
|
261
|
-
body: formData
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
}
|
|
266
286
|
}
|
|
267
|
-
return asset;
|
|
268
287
|
}
|
|
269
288
|
/**
|
|
270
289
|
* Updates an asset in the Prismic media library.
|
|
@@ -282,17 +301,27 @@ class WriteClient extends Client.Client {
|
|
|
282
301
|
...params
|
|
283
302
|
});
|
|
284
303
|
}
|
|
285
|
-
|
|
304
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
286
305
|
method: "PATCH",
|
|
287
|
-
body: {
|
|
306
|
+
body: JSON.stringify({
|
|
288
307
|
notes,
|
|
289
308
|
credits,
|
|
290
309
|
alt,
|
|
291
310
|
filename,
|
|
292
311
|
tags
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
|
|
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
|
+
}
|
|
296
325
|
}
|
|
297
326
|
/**
|
|
298
327
|
* Fetches a foreign asset from a URL.
|
|
@@ -303,17 +332,7 @@ class WriteClient extends Client.Client {
|
|
|
303
332
|
* @returns A file representing the fetched asset.
|
|
304
333
|
*/
|
|
305
334
|
async fetchForeignAsset(url, params = {}) {
|
|
306
|
-
|
|
307
|
-
const requestInit = {
|
|
308
|
-
...this.fetchOptions,
|
|
309
|
-
...params.fetchOptions,
|
|
310
|
-
headers: {
|
|
311
|
-
...(_a = this.fetchOptions) == null ? void 0 : _a.headers,
|
|
312
|
-
...(_b = params.fetchOptions) == null ? void 0 : _b.headers
|
|
313
|
-
},
|
|
314
|
-
signal: ((_c = params.fetchOptions) == null ? void 0 : _c.signal) || params.signal || ((_d = this.fetchOptions) == null ? void 0 : _d.signal)
|
|
315
|
-
};
|
|
316
|
-
const res = await this.fetchFn(url, requestInit);
|
|
335
|
+
const res = await this.fetchFn(url, this._buildRequestInit(params));
|
|
317
336
|
if (!res.ok) {
|
|
318
337
|
throw new PrismicError.PrismicError("Could not fetch foreign asset", url, void 0);
|
|
319
338
|
}
|
|
@@ -363,11 +382,21 @@ class WriteClient extends Client.Client {
|
|
|
363
382
|
*/
|
|
364
383
|
async createAssetTag(name, params) {
|
|
365
384
|
const url = new URL("tags", this.assetAPIEndpoint);
|
|
366
|
-
|
|
385
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
367
386
|
method: "POST",
|
|
368
|
-
body: { name },
|
|
369
|
-
|
|
370
|
-
|
|
387
|
+
body: JSON.stringify({ name }),
|
|
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
|
+
}
|
|
371
400
|
}
|
|
372
401
|
/**
|
|
373
402
|
* Queries existing tags from the Asset API.
|
|
@@ -378,8 +407,16 @@ class WriteClient extends Client.Client {
|
|
|
378
407
|
*/
|
|
379
408
|
async getAssetTags(params) {
|
|
380
409
|
const url = new URL("tags", this.assetAPIEndpoint);
|
|
381
|
-
const
|
|
382
|
-
|
|
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
|
+
}
|
|
383
420
|
}
|
|
384
421
|
/**
|
|
385
422
|
* Creates a document in the repository's migration release.
|
|
@@ -398,9 +435,9 @@ class WriteClient extends Client.Client {
|
|
|
398
435
|
*/
|
|
399
436
|
async createDocument(document, documentTitle, { masterLanguageDocumentID, ...params } = {}) {
|
|
400
437
|
const url = new URL("documents", this.migrationAPIEndpoint);
|
|
401
|
-
const
|
|
438
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
402
439
|
method: "POST",
|
|
403
|
-
body: {
|
|
440
|
+
body: JSON.stringify({
|
|
404
441
|
title: documentTitle,
|
|
405
442
|
type: document.type,
|
|
406
443
|
uid: document.uid || void 0,
|
|
@@ -408,10 +445,20 @@ class WriteClient extends Client.Client {
|
|
|
408
445
|
alternate_language_id: masterLanguageDocumentID,
|
|
409
446
|
tags: document.tags,
|
|
410
447
|
data: document.data
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
448
|
+
}),
|
|
449
|
+
headers: {
|
|
450
|
+
"content-type": "application/json"
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
switch (response.status) {
|
|
454
|
+
case 201: {
|
|
455
|
+
const json = await response.json();
|
|
456
|
+
return { id: json.id };
|
|
457
|
+
}
|
|
458
|
+
default: {
|
|
459
|
+
return await __privateMethod(this, _WriteClient_instances, handleMigrationAPIError_fn).call(this, response);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
415
462
|
}
|
|
416
463
|
/**
|
|
417
464
|
* Updates an existing document in the repository's migration release.
|
|
@@ -426,80 +473,84 @@ class WriteClient extends Client.Client {
|
|
|
426
473
|
*/
|
|
427
474
|
async updateDocument(id, document, params) {
|
|
428
475
|
const url = new URL(`documents/${id}`, this.migrationAPIEndpoint);
|
|
429
|
-
await this.
|
|
476
|
+
const response = await __privateMethod(this, _WriteClient_instances, request_fn).call(this, url, params, {
|
|
430
477
|
method: "PUT",
|
|
431
|
-
body: {
|
|
478
|
+
body: JSON.stringify({
|
|
432
479
|
title: document.documentTitle,
|
|
433
480
|
uid: document.uid || void 0,
|
|
434
481
|
tags: document.tags,
|
|
435
482
|
data: document.data
|
|
436
|
-
},
|
|
437
|
-
|
|
438
|
-
|
|
483
|
+
}),
|
|
484
|
+
headers: {
|
|
485
|
+
"content-type": "application/json"
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
switch (response.status) {
|
|
489
|
+
case 200: {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
default: {
|
|
493
|
+
await __privateMethod(this, _WriteClient_instances, handleMigrationAPIError_fn).call(this, response);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
439
496
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
var _a;
|
|
453
|
-
const headers = {
|
|
454
|
-
...(_a = params == null ? void 0 : params.fetchOptions) == null ? void 0 : _a.headers,
|
|
455
|
-
authorization: `Bearer ${this.writeToken}`,
|
|
456
|
-
repository: this.repositoryName
|
|
457
|
-
};
|
|
458
|
-
let _body;
|
|
459
|
-
if (body instanceof FormData) {
|
|
460
|
-
_body = body;
|
|
461
|
-
} else if (body) {
|
|
462
|
-
_body = JSON.stringify(body);
|
|
463
|
-
headers["content-type"] = "application/json";
|
|
497
|
+
}
|
|
498
|
+
_WriteClient_instances = new WeakSet();
|
|
499
|
+
request_fn = async function(url, params, init) {
|
|
500
|
+
const baseInit = this._buildRequestInit(params);
|
|
501
|
+
return await request.request(url, {
|
|
502
|
+
...baseInit,
|
|
503
|
+
...init,
|
|
504
|
+
headers: {
|
|
505
|
+
...baseInit.headers,
|
|
506
|
+
...init == null ? void 0 : init.headers,
|
|
507
|
+
repository: this.repositoryName,
|
|
508
|
+
authorization: `Bearer ${this.writeToken}`
|
|
464
509
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
510
|
+
}, this.fetchFn);
|
|
511
|
+
};
|
|
512
|
+
handleAssetAPIError_fn = async function(response) {
|
|
513
|
+
const json = await response.json();
|
|
514
|
+
switch (response.status) {
|
|
515
|
+
case 401:
|
|
516
|
+
case 403:
|
|
517
|
+
throw new ForbiddenError.ForbiddenError(json.error, response.url, json);
|
|
518
|
+
case 404:
|
|
519
|
+
throw new NotFoundError.NotFoundError(json.error, response.url, json);
|
|
520
|
+
case 400:
|
|
521
|
+
throw new InvalidDataError.InvalidDataError(json.error, response.url, json);
|
|
522
|
+
case 500:
|
|
523
|
+
case 503:
|
|
524
|
+
default:
|
|
525
|
+
throw new PrismicError.PrismicError(json.error, response.url, json);
|
|
474
526
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
headers: {
|
|
495
|
-
...(_a = params == null ? void 0 : params.fetchOptions) == null ? void 0 : _a.headers,
|
|
496
|
-
"content-type": "application/json",
|
|
497
|
-
repository: this.repositoryName,
|
|
498
|
-
authorization: `Bearer ${this.writeToken}`
|
|
499
|
-
}
|
|
527
|
+
};
|
|
528
|
+
handleMigrationAPIError_fn = async function(response) {
|
|
529
|
+
const text = await response.text();
|
|
530
|
+
let json;
|
|
531
|
+
try {
|
|
532
|
+
json = JSON.parse(text);
|
|
533
|
+
} catch {
|
|
534
|
+
}
|
|
535
|
+
switch (response.status) {
|
|
536
|
+
case 400:
|
|
537
|
+
if (json) {
|
|
538
|
+
throw new InvalidDataError.InvalidDataError("Validation failed, check the response property of the error for details", response.url, json);
|
|
539
|
+
}
|
|
540
|
+
throw new InvalidDataError.InvalidDataError(text, response.url, text);
|
|
541
|
+
case 401:
|
|
542
|
+
throw new ForbiddenError.ForbiddenError(text, response.url, text);
|
|
543
|
+
case 403:
|
|
544
|
+
if (json) {
|
|
545
|
+
throw new ForbiddenError.ForbiddenError(json.Message, response.url, json);
|
|
500
546
|
}
|
|
501
|
-
|
|
547
|
+
throw new ForbiddenError.ForbiddenError(text, response.url, text);
|
|
548
|
+
case 404:
|
|
549
|
+
throw new NotFoundError.NotFoundError(text, response.url, text);
|
|
550
|
+
case 500:
|
|
551
|
+
default:
|
|
552
|
+
throw new PrismicError.PrismicError(text, response.url, text);
|
|
502
553
|
}
|
|
503
|
-
}
|
|
554
|
+
};
|
|
504
555
|
exports.WriteClient = WriteClient;
|
|
505
556
|
//# sourceMappingURL=WriteClient.cjs.map
|
package/dist/WriteClient.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.cjs","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},\n\t\t}\n\t}\n}\n"],"names":["Client","pLimit","devMsg","resolveMigrationContentRelationship","resolveMigrationDocumentData","PrismicError"],"mappings":";;;;;;;;;;AAuMM,MAAO,oBAEHA,OAAAA,OAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB3B,YAAY,gBAAw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AAG,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.cjs","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 { 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\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},\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},\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":["Client","pLimit","devMsg","resolveMigrationContentRelationship","resolveMigrationDocumentData","PrismicError","request","ForbiddenError","NotFoundError","InvalidDataError"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoMM,MAAO,oBAEHA,OAAAA,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,oDAA2BC,OAAAA,OAAM;AAhapC,QAAA,OAAO,WAAW,WAAW,aAAa;AAC7C,cAAQ,KACP,mSAAmSC,OAAAA,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;AAAA;AAAA,EAYD,MAAM,QACL,WACA,SAEkB,IAAE;;AAEpB,iBAAO,aAAP,gCAAkB;AAAA,MACjB,MAAM;AAAA,MACN,MAAM;AAAA,QACL,SAAS;AAAA,UACR,WAAW,UAAU,WAAW;AAAA,UAChC,QAAQ,UAAU,QAAQ;AAAA,QAAA;AAAA,MAC1B;AAAA,IACD;AAGI,UAAA,KAAK,oBAAoB,WAAW,MAAM;AAC1C,UAAA,KAAK,uBAAuB,WAAW,MAA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AAAA,EAAA;AACjD;;"}
|
package/dist/WriteClient.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { PrismicMigrationAsset } from "./types/migration/Asset";
|
|
2
2
|
import type { PrismicMigrationDocument } from "./types/migration/Document";
|
|
3
3
|
import type { PrismicDocument } from "./types/value/document";
|
|
4
|
-
import type { FetchParams } from "./BaseClient";
|
|
5
4
|
import { Client } from "./Client";
|
|
6
|
-
import type { ClientConfig } from "./Client";
|
|
5
|
+
import type { ClientConfig, FetchParams } from "./Client";
|
|
7
6
|
import type { Migration } from "./Migration";
|
|
8
7
|
/**
|
|
9
8
|
* Utility type to construct events reported by the migration process.
|
|
@@ -129,6 +128,7 @@ export type WriteClientConfig = {
|
|
|
129
128
|
* repository. Query methods will automatically be typed based on this type.
|
|
130
129
|
*/
|
|
131
130
|
export declare class WriteClient<TDocuments extends PrismicDocument = PrismicDocument> extends Client<TDocuments> {
|
|
131
|
+
#private;
|
|
132
132
|
writeToken: string;
|
|
133
133
|
assetAPIEndpoint: string;
|
|
134
134
|
migrationAPIEndpoint: string;
|
|
@@ -277,29 +277,5 @@ export declare class WriteClient<TDocuments extends PrismicDocument = PrismicDoc
|
|
|
277
277
|
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
278
278
|
*/
|
|
279
279
|
private updateDocument;
|
|
280
|
-
/**
|
|
281
|
-
* Builds fetch parameters for the Asset API.
|
|
282
|
-
*
|
|
283
|
-
* @typeParam TBody - Type of the body to send in the fetch request.
|
|
284
|
-
*
|
|
285
|
-
* @param params - Method, body, and additional fetch parameters.
|
|
286
|
-
*
|
|
287
|
-
* @returns An object that can be fetched to interact with the Asset API.
|
|
288
|
-
*
|
|
289
|
-
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
290
|
-
*/
|
|
291
|
-
private buildAssetAPIQueryParams;
|
|
292
|
-
/**
|
|
293
|
-
* Builds fetch parameters for the Migration API.
|
|
294
|
-
*
|
|
295
|
-
* @typeParam TBody - Type of the body to send in the fetch request.
|
|
296
|
-
*
|
|
297
|
-
* @param params - Method, body, and additional fetch options.
|
|
298
|
-
*
|
|
299
|
-
* @returns An object that can be fetched to interact with the Migration API.
|
|
300
|
-
*
|
|
301
|
-
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
302
|
-
*/
|
|
303
|
-
private buildMigrationAPIQueryParams;
|
|
304
280
|
}
|
|
305
281
|
export {};
|