@prismicio/client 7.19.2 → 7.20.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseClient.cjs +108 -0
- package/dist/BaseClient.cjs.map +1 -0
- package/dist/BaseClient.d.ts +152 -0
- package/dist/BaseClient.js +108 -0
- package/dist/BaseClient.js.map +1 -0
- package/dist/Client.cjs +95 -111
- package/dist/Client.cjs.map +1 -1
- package/dist/Client.d.ts +27 -66
- package/dist/Client.js +95 -111
- package/dist/Client.js.map +1 -1
- package/dist/WriteClient.cjs +100 -151
- package/dist/WriteClient.cjs.map +1 -1
- package/dist/WriteClient.d.ts +26 -2
- package/dist/WriteClient.js +100 -151
- package/dist/WriteClient.js.map +1 -1
- package/dist/errors/ParsingError.cjs.map +1 -1
- package/dist/errors/ParsingError.d.ts +4 -6
- package/dist/errors/ParsingError.js.map +1 -1
- package/dist/helpers/isFilled.cjs.map +1 -1
- package/dist/helpers/isFilled.d.ts +4 -4
- package/dist/helpers/isFilled.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/types/integration.d.ts +28 -0
- package/dist/types/value/integration.d.ts +8 -2
- package/package.json +1 -1
- package/src/BaseClient.ts +330 -0
- package/src/Client.ts +171 -201
- package/src/WriteClient.ts +157 -214
- package/src/errors/ParsingError.ts +4 -6
- package/src/helpers/isFilled.ts +5 -4
- package/src/index.ts +13 -8
- package/src/types/integration.ts +34 -0
- package/src/types/value/integration.ts +9 -2
- package/dist/errors/InvalidDataError.cjs +0 -7
- package/dist/errors/InvalidDataError.cjs.map +0 -1
- package/dist/errors/InvalidDataError.d.ts +0 -3
- package/dist/errors/InvalidDataError.js +0 -7
- package/dist/errors/InvalidDataError.js.map +0 -1
- package/dist/lib/request.cjs +0 -43
- package/dist/lib/request.cjs.map +0 -1
- package/dist/lib/request.d.ts +0 -73
- package/dist/lib/request.js +0 -43
- package/dist/lib/request.js.map +0 -1
- package/src/errors/InvalidDataError.ts +0 -5
- package/src/lib/request.ts +0 -166
package/src/WriteClient.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { devMsg } from "./lib/devMsg"
|
|
2
2
|
import { pLimit } from "./lib/pLimit"
|
|
3
|
-
import type { ResponseLike } from "./lib/request"
|
|
4
|
-
import { type RequestInitLike, request } from "./lib/request"
|
|
5
3
|
import {
|
|
6
4
|
resolveMigrationContentRelationship,
|
|
7
5
|
resolveMigrationDocumentData,
|
|
@@ -10,15 +8,22 @@ import {
|
|
|
10
8
|
import type {
|
|
11
9
|
Asset,
|
|
12
10
|
PatchAssetParams,
|
|
11
|
+
PatchAssetResult,
|
|
13
12
|
PostAssetParams,
|
|
14
13
|
PostAssetResult,
|
|
15
14
|
} from "./types/api/asset/asset"
|
|
16
15
|
import type {
|
|
17
16
|
AssetTag,
|
|
18
17
|
GetAssetTagsResult,
|
|
18
|
+
PostAssetTagParams,
|
|
19
19
|
PostAssetTagResult,
|
|
20
20
|
} from "./types/api/asset/tag"
|
|
21
|
-
import {
|
|
21
|
+
import type { PutDocumentResult } from "./types/api/migration/document"
|
|
22
|
+
import {
|
|
23
|
+
type PostDocumentParams,
|
|
24
|
+
type PostDocumentResult,
|
|
25
|
+
type PutDocumentParams,
|
|
26
|
+
} from "./types/api/migration/document"
|
|
22
27
|
import type { PrismicMigrationAsset } from "./types/migration/Asset"
|
|
23
28
|
import type {
|
|
24
29
|
MigrationDocument,
|
|
@@ -27,13 +32,11 @@ import type {
|
|
|
27
32
|
} from "./types/migration/Document"
|
|
28
33
|
import type { PrismicDocument } from "./types/value/document"
|
|
29
34
|
|
|
30
|
-
import { ForbiddenError } from "./errors/ForbiddenError"
|
|
31
|
-
import { InvalidDataError } from "./errors/InvalidDataError"
|
|
32
|
-
import { NotFoundError } from "./errors/NotFoundError"
|
|
33
35
|
import { PrismicError } from "./errors/PrismicError"
|
|
34
36
|
|
|
37
|
+
import type { FetchParams, RequestInitLike } from "./BaseClient"
|
|
35
38
|
import { Client } from "./Client"
|
|
36
|
-
import type { ClientConfig
|
|
39
|
+
import type { ClientConfig } from "./Client"
|
|
37
40
|
import type { Migration } from "./Migration"
|
|
38
41
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
42
|
import type { createMigration } from "./createMigration"
|
|
@@ -534,24 +537,20 @@ export class WriteClient<
|
|
|
534
537
|
formData.append("alt", alt)
|
|
535
538
|
}
|
|
536
539
|
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (tags && tags.length) {
|
|
546
|
-
return this.updateAsset(asset.id, { tags })
|
|
547
|
-
}
|
|
540
|
+
const asset = await this.fetch<PostAssetResult>(
|
|
541
|
+
url.toString(),
|
|
542
|
+
this.buildAssetAPIQueryParams({
|
|
543
|
+
method: "POST",
|
|
544
|
+
body: formData,
|
|
545
|
+
params,
|
|
546
|
+
}),
|
|
547
|
+
)
|
|
548
548
|
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
default: {
|
|
552
|
-
return await this.#handleAssetAPIError(response)
|
|
553
|
-
}
|
|
549
|
+
if (tags && tags.length) {
|
|
550
|
+
return this.updateAsset(asset.id, { tags })
|
|
554
551
|
}
|
|
552
|
+
|
|
553
|
+
return asset
|
|
555
554
|
}
|
|
556
555
|
|
|
557
556
|
/**
|
|
@@ -583,27 +582,20 @@ export class WriteClient<
|
|
|
583
582
|
})
|
|
584
583
|
}
|
|
585
584
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
585
|
+
return this.fetch<PatchAssetResult>(
|
|
586
|
+
url.toString(),
|
|
587
|
+
this.buildAssetAPIQueryParams<PatchAssetParams>({
|
|
588
|
+
method: "PATCH",
|
|
589
|
+
body: {
|
|
590
|
+
notes,
|
|
591
|
+
credits,
|
|
592
|
+
alt,
|
|
593
|
+
filename,
|
|
594
|
+
tags,
|
|
595
|
+
},
|
|
596
|
+
params,
|
|
594
597
|
}),
|
|
595
|
-
|
|
596
|
-
"content-type": "application/json",
|
|
597
|
-
},
|
|
598
|
-
})
|
|
599
|
-
switch (response.status) {
|
|
600
|
-
case 200: {
|
|
601
|
-
return (await response.json()) as Asset
|
|
602
|
-
}
|
|
603
|
-
default: {
|
|
604
|
-
return await this.#handleAssetAPIError(response)
|
|
605
|
-
}
|
|
606
|
-
}
|
|
598
|
+
)
|
|
607
599
|
}
|
|
608
600
|
|
|
609
601
|
/**
|
|
@@ -618,7 +610,20 @@ export class WriteClient<
|
|
|
618
610
|
url: string,
|
|
619
611
|
params: FetchParams = {},
|
|
620
612
|
): Promise<Blob> {
|
|
621
|
-
const
|
|
613
|
+
const requestInit: RequestInitLike = {
|
|
614
|
+
...this.fetchOptions,
|
|
615
|
+
...params.fetchOptions,
|
|
616
|
+
headers: {
|
|
617
|
+
...this.fetchOptions?.headers,
|
|
618
|
+
...params.fetchOptions?.headers,
|
|
619
|
+
},
|
|
620
|
+
signal:
|
|
621
|
+
params.fetchOptions?.signal ||
|
|
622
|
+
params.signal ||
|
|
623
|
+
this.fetchOptions?.signal,
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const res = await this.fetchFn(url, requestInit)
|
|
622
627
|
|
|
623
628
|
if (!res.ok) {
|
|
624
629
|
throw new PrismicError("Could not fetch foreign asset", url, undefined)
|
|
@@ -691,21 +696,14 @@ export class WriteClient<
|
|
|
691
696
|
): Promise<AssetTag> {
|
|
692
697
|
const url = new URL("tags", this.assetAPIEndpoint)
|
|
693
698
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
case 201: {
|
|
703
|
-
return (await response.json()) as PostAssetTagResult
|
|
704
|
-
}
|
|
705
|
-
default: {
|
|
706
|
-
return await this.#handleAssetAPIError(response)
|
|
707
|
-
}
|
|
708
|
-
}
|
|
699
|
+
return this.fetch<PostAssetTagResult>(
|
|
700
|
+
url.toString(),
|
|
701
|
+
this.buildAssetAPIQueryParams<PostAssetTagParams>({
|
|
702
|
+
method: "POST",
|
|
703
|
+
body: { name },
|
|
704
|
+
params,
|
|
705
|
+
}),
|
|
706
|
+
)
|
|
709
707
|
}
|
|
710
708
|
|
|
711
709
|
/**
|
|
@@ -718,17 +716,12 @@ export class WriteClient<
|
|
|
718
716
|
private async getAssetTags(params?: FetchParams): Promise<AssetTag[]> {
|
|
719
717
|
const url = new URL("tags", this.assetAPIEndpoint)
|
|
720
718
|
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
719
|
+
const { items } = await this.fetch<GetAssetTagsResult>(
|
|
720
|
+
url.toString(),
|
|
721
|
+
this.buildAssetAPIQueryParams({ params }),
|
|
722
|
+
)
|
|
725
723
|
|
|
726
|
-
|
|
727
|
-
}
|
|
728
|
-
default: {
|
|
729
|
-
return await this.#handleAssetAPIError(response)
|
|
730
|
-
}
|
|
731
|
-
}
|
|
724
|
+
return items
|
|
732
725
|
}
|
|
733
726
|
|
|
734
727
|
/**
|
|
@@ -756,31 +749,24 @@ export class WriteClient<
|
|
|
756
749
|
): Promise<{ id: string }> {
|
|
757
750
|
const url = new URL("documents", this.migrationAPIEndpoint)
|
|
758
751
|
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
752
|
+
const result = await this.fetch<PostDocumentResult>(
|
|
753
|
+
url.toString(),
|
|
754
|
+
this.buildMigrationAPIQueryParams<PostDocumentParams>({
|
|
755
|
+
method: "POST",
|
|
756
|
+
body: {
|
|
757
|
+
title: documentTitle,
|
|
758
|
+
type: document.type,
|
|
759
|
+
uid: document.uid || undefined,
|
|
760
|
+
lang: document.lang,
|
|
761
|
+
alternate_language_id: masterLanguageDocumentID,
|
|
762
|
+
tags: document.tags,
|
|
763
|
+
data: document.data,
|
|
764
|
+
},
|
|
765
|
+
params,
|
|
769
766
|
}),
|
|
770
|
-
|
|
771
|
-
"content-type": "application/json",
|
|
772
|
-
},
|
|
773
|
-
})
|
|
774
|
-
switch (response.status) {
|
|
775
|
-
case 201: {
|
|
776
|
-
const json = (await response.json()) as PostDocumentResult
|
|
767
|
+
)
|
|
777
768
|
|
|
778
|
-
|
|
779
|
-
}
|
|
780
|
-
default: {
|
|
781
|
-
return await this.#handleMigrationAPIError(response)
|
|
782
|
-
}
|
|
783
|
-
}
|
|
769
|
+
return { id: result.id }
|
|
784
770
|
}
|
|
785
771
|
|
|
786
772
|
/**
|
|
@@ -803,144 +789,101 @@ export class WriteClient<
|
|
|
803
789
|
): Promise<void> {
|
|
804
790
|
const url = new URL(`documents/${id}`, this.migrationAPIEndpoint)
|
|
805
791
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
792
|
+
await this.fetch<PutDocumentResult>(
|
|
793
|
+
url.toString(),
|
|
794
|
+
this.buildMigrationAPIQueryParams({
|
|
795
|
+
method: "PUT",
|
|
796
|
+
body: {
|
|
797
|
+
title: document.documentTitle,
|
|
798
|
+
uid: document.uid || undefined,
|
|
799
|
+
tags: document.tags,
|
|
800
|
+
data: document.data,
|
|
801
|
+
},
|
|
802
|
+
params,
|
|
813
803
|
}),
|
|
814
|
-
|
|
815
|
-
"content-type": "application/json",
|
|
816
|
-
},
|
|
817
|
-
})
|
|
818
|
-
switch (response.status) {
|
|
819
|
-
case 200: {
|
|
820
|
-
return
|
|
821
|
-
}
|
|
822
|
-
default: {
|
|
823
|
-
await this.#handleMigrationAPIError(response)
|
|
824
|
-
}
|
|
825
|
-
}
|
|
804
|
+
)
|
|
826
805
|
}
|
|
827
806
|
|
|
828
807
|
/**
|
|
829
|
-
*
|
|
830
|
-
* configured fetch function and options.
|
|
808
|
+
* Builds fetch parameters for the Asset API.
|
|
831
809
|
*
|
|
832
|
-
* @
|
|
833
|
-
* @param params - Fetch options from the user.
|
|
834
|
-
* @param init - Additional fetch options to merge with the user-provided
|
|
835
|
-
* options.
|
|
810
|
+
* @typeParam TBody - Type of the body to send in the fetch request.
|
|
836
811
|
*
|
|
837
|
-
* @
|
|
838
|
-
*/
|
|
839
|
-
async #request(
|
|
840
|
-
url: URL,
|
|
841
|
-
params?: RequestInitLike,
|
|
842
|
-
init?: RequestInitLike,
|
|
843
|
-
): Promise<ResponseLike> {
|
|
844
|
-
const baseInit = this._buildRequestInit(params)
|
|
845
|
-
|
|
846
|
-
return await request(
|
|
847
|
-
url,
|
|
848
|
-
{
|
|
849
|
-
...baseInit,
|
|
850
|
-
...init,
|
|
851
|
-
headers: {
|
|
852
|
-
...baseInit.headers,
|
|
853
|
-
...init?.headers,
|
|
854
|
-
repository: this.repositoryName,
|
|
855
|
-
authorization: `Bearer ${this.writeToken}`,
|
|
856
|
-
},
|
|
857
|
-
},
|
|
858
|
-
this.fetchFn,
|
|
859
|
-
)
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Handles error responses from the Asset API with comprehensive error
|
|
864
|
-
* parsing.
|
|
812
|
+
* @param params - Method, body, and additional fetch parameters.
|
|
865
813
|
*
|
|
866
|
-
* @
|
|
814
|
+
* @returns An object that can be fetched to interact with the Asset API.
|
|
867
815
|
*
|
|
868
|
-
* @
|
|
869
|
-
* @throws {@link ForbiddenError} For 401 and 403 errors.
|
|
870
|
-
* @throws {@link NotFoundError} For 404 errors.
|
|
871
|
-
* @throws {@link PrismicError} For 500, 503, and other unexpected errors.
|
|
816
|
+
* @see Prismic Asset API technical reference: {@link https://prismic.io/docs/asset-api-technical-reference}
|
|
872
817
|
*/
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
818
|
+
private buildAssetAPIQueryParams<TBody = FormData | Record<string, unknown>>({
|
|
819
|
+
method,
|
|
820
|
+
body,
|
|
821
|
+
params,
|
|
822
|
+
}: {
|
|
823
|
+
method?: string
|
|
824
|
+
body?: TBody
|
|
825
|
+
params?: FetchParams
|
|
826
|
+
}): FetchParams {
|
|
827
|
+
const headers: Record<string, string> = {
|
|
828
|
+
...params?.fetchOptions?.headers,
|
|
829
|
+
authorization: `Bearer ${this.writeToken}`,
|
|
830
|
+
repository: this.repositoryName,
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
let _body: FormData | string | undefined
|
|
834
|
+
if (body instanceof FormData) {
|
|
835
|
+
_body = body
|
|
836
|
+
} else if (body) {
|
|
837
|
+
_body = JSON.stringify(body)
|
|
838
|
+
headers["content-type"] = "application/json"
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return {
|
|
842
|
+
...params,
|
|
843
|
+
fetchOptions: {
|
|
844
|
+
...params?.fetchOptions,
|
|
845
|
+
method,
|
|
846
|
+
body: _body,
|
|
847
|
+
headers,
|
|
848
|
+
},
|
|
890
849
|
}
|
|
891
850
|
}
|
|
892
851
|
|
|
893
852
|
/**
|
|
894
|
-
*
|
|
895
|
-
* parsing.
|
|
853
|
+
* Builds fetch parameters for the Migration API.
|
|
896
854
|
*
|
|
897
|
-
* @
|
|
855
|
+
* @typeParam TBody - Type of the body to send in the fetch request.
|
|
898
856
|
*
|
|
899
|
-
* @
|
|
900
|
-
*
|
|
901
|
-
* @
|
|
902
|
-
*
|
|
857
|
+
* @param params - Method, body, and additional fetch options.
|
|
858
|
+
*
|
|
859
|
+
* @returns An object that can be fetched to interact with the Migration API.
|
|
860
|
+
*
|
|
861
|
+
* @see Prismic Migration API technical reference: {@link https://prismic.io/docs/migration-api-technical-reference}
|
|
903
862
|
*/
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
case 403:
|
|
929
|
-
if (json) {
|
|
930
|
-
throw new ForbiddenError(
|
|
931
|
-
(json as { Message: string }).Message,
|
|
932
|
-
response.url,
|
|
933
|
-
json,
|
|
934
|
-
)
|
|
935
|
-
}
|
|
936
|
-
throw new ForbiddenError(text, response.url, text)
|
|
937
|
-
|
|
938
|
-
case 404:
|
|
939
|
-
throw new NotFoundError(text, response.url, text)
|
|
940
|
-
|
|
941
|
-
case 500:
|
|
942
|
-
default:
|
|
943
|
-
throw new PrismicError(text, response.url, text)
|
|
863
|
+
private buildMigrationAPIQueryParams<
|
|
864
|
+
TBody extends PostDocumentParams | PutDocumentParams,
|
|
865
|
+
>({
|
|
866
|
+
method,
|
|
867
|
+
body,
|
|
868
|
+
params,
|
|
869
|
+
}: {
|
|
870
|
+
method?: string
|
|
871
|
+
body: TBody
|
|
872
|
+
params?: FetchParams
|
|
873
|
+
}): FetchParams {
|
|
874
|
+
return {
|
|
875
|
+
...params,
|
|
876
|
+
fetchOptions: {
|
|
877
|
+
...params?.fetchOptions,
|
|
878
|
+
method,
|
|
879
|
+
body: JSON.stringify(body),
|
|
880
|
+
headers: {
|
|
881
|
+
...params?.fetchOptions?.headers,
|
|
882
|
+
"content-type": "application/json",
|
|
883
|
+
repository: this.repositoryName,
|
|
884
|
+
authorization: `Bearer ${this.writeToken}`,
|
|
885
|
+
},
|
|
886
|
+
},
|
|
944
887
|
}
|
|
945
888
|
}
|
|
946
889
|
}
|
|
@@ -3,12 +3,10 @@ import { PrismicError } from "./PrismicError"
|
|
|
3
3
|
type ParsingErrorAPIResponse = {
|
|
4
4
|
type: "parsing-error"
|
|
5
5
|
message: string
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
location: string
|
|
11
|
-
}
|
|
6
|
+
line: number
|
|
7
|
+
column: number
|
|
8
|
+
id: number
|
|
9
|
+
location: string
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
export class ParsingError<
|
package/src/helpers/isFilled.ts
CHANGED
|
@@ -8,7 +8,10 @@ import type { AnyOEmbed, EmbedField } from "../types/value/embed"
|
|
|
8
8
|
import type { GeoPointField } from "../types/value/geoPoint"
|
|
9
9
|
import type { GroupField, NestedGroupField } from "../types/value/group"
|
|
10
10
|
import type { ImageField, ImageFieldImage } from "../types/value/image"
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
IntegrationField,
|
|
13
|
+
IntegrationFieldData,
|
|
14
|
+
} from "../types/value/integration"
|
|
12
15
|
import type { KeyTextField } from "../types/value/keyText"
|
|
13
16
|
import type { LinkField } from "../types/value/link"
|
|
14
17
|
import type { LinkToMediaField } from "../types/value/linkToMedia"
|
|
@@ -258,9 +261,7 @@ export const table = isNonNullish as (
|
|
|
258
261
|
*
|
|
259
262
|
* @returns `true` if `field` is filled, `false` otherwise.
|
|
260
263
|
*/
|
|
261
|
-
export const integration = isNonNullish as <
|
|
262
|
-
Data extends Record<string, unknown>,
|
|
263
|
-
>(
|
|
264
|
+
export const integration = isNonNullish as <Data extends IntegrationFieldData>(
|
|
264
265
|
field: IntegrationField<Data> | null | undefined,
|
|
265
266
|
) => field is IntegrationField<Data, "filled">
|
|
266
267
|
/**
|
package/src/index.ts
CHANGED
|
@@ -51,9 +51,16 @@ export * as cookie from "./cookie"
|
|
|
51
51
|
|
|
52
52
|
// General types used to query content from Prismic. These are made public to allow users to better type their projects.
|
|
53
53
|
export type { CreateClient } from "./createClient"
|
|
54
|
-
export type { ClientConfig
|
|
54
|
+
export type { ClientConfig } from "./Client"
|
|
55
55
|
export type { CreateWriteClient } from "./createWriteClient"
|
|
56
56
|
export type { WriteClientConfig, MigrateReporterEvents } from "./WriteClient"
|
|
57
|
+
export type {
|
|
58
|
+
AbortSignalLike,
|
|
59
|
+
FetchLike,
|
|
60
|
+
HttpRequestLike,
|
|
61
|
+
RequestInitLike,
|
|
62
|
+
ResponseLike,
|
|
63
|
+
} from "./BaseClient"
|
|
57
64
|
export type {
|
|
58
65
|
BuildQueryURLArgs,
|
|
59
66
|
Ordering,
|
|
@@ -61,12 +68,6 @@ export type {
|
|
|
61
68
|
Route,
|
|
62
69
|
} from "./buildQueryURL"
|
|
63
70
|
export type { CreateMigration } from "./createMigration"
|
|
64
|
-
export type {
|
|
65
|
-
AbortSignalLike,
|
|
66
|
-
FetchLike,
|
|
67
|
-
RequestInitLike,
|
|
68
|
-
ResponseLike,
|
|
69
|
-
} from "./lib/request"
|
|
70
71
|
|
|
71
72
|
//=============================================================================
|
|
72
73
|
// Helpers - Manipulate content from Prismic.
|
|
@@ -242,7 +243,8 @@ export type { GeoPointField } from "./types/value/geoPoint"
|
|
|
242
243
|
*/
|
|
243
244
|
// TODO: Remove when we remove support for deprecated `IntegrationFields` export.
|
|
244
245
|
type IntegrationFields = IntegrationField
|
|
245
|
-
export { IntegrationField, IntegrationFields }
|
|
246
|
+
export type { IntegrationField, IntegrationFields }
|
|
247
|
+
export type { IntegrationFieldData } from "./types/value/integration"
|
|
246
248
|
|
|
247
249
|
export type { GroupField, NestedGroupField } from "./types/value/group"
|
|
248
250
|
|
|
@@ -383,3 +385,6 @@ export type { WebhookBody } from "./types/webhook/types"
|
|
|
383
385
|
export type { WebhookBodyAPIUpdate } from "./types/webhook/apiUpdate"
|
|
384
386
|
|
|
385
387
|
export type { WebhookBodyTestTrigger } from "./types/webhook/testTrigger"
|
|
388
|
+
|
|
389
|
+
// Integration - Types representing integration catalogs.
|
|
390
|
+
export { IntegrationAPIItem, IntegrationAPIResults } from "./types/integration"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IntegrationFieldData } from "./value/integration"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A catalog item from an integration field.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TData - The data shape for the catalog item.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://prismic.io/docs/fields/integration#create-an-integration-catalog}
|
|
9
|
+
*/
|
|
10
|
+
export type IntegrationAPIItem<
|
|
11
|
+
TData extends IntegrationFieldData = IntegrationFieldData,
|
|
12
|
+
> = {
|
|
13
|
+
id: string
|
|
14
|
+
title: string
|
|
15
|
+
description: string
|
|
16
|
+
image_url?: string
|
|
17
|
+
last_update?: number
|
|
18
|
+
blob: TData
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Response payload from a custom integration catalog API. Contains an array of
|
|
23
|
+
* catalog items and the total count.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam TData - The shape of each catalog item's data.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://prismic.io/docs/fields/integration#create-an-integration-catalog}
|
|
28
|
+
*/
|
|
29
|
+
export type IntegrationAPIResults<
|
|
30
|
+
TData extends IntegrationFieldData = IntegrationFieldData,
|
|
31
|
+
> = {
|
|
32
|
+
results_size: number
|
|
33
|
+
results: IntegrationAPIItem<TData>[]
|
|
34
|
+
}
|
|
@@ -6,9 +6,16 @@ import type { FieldState } from "./types"
|
|
|
6
6
|
* @typeParam Data - Data from the integrated API.
|
|
7
7
|
* @typeParam State - State of the field which determines its shape.
|
|
8
8
|
*
|
|
9
|
-
* @see More details: {@link https://prismic.io/docs/integration
|
|
9
|
+
* @see More details: {@link https://prismic.io/docs/fields/integration}
|
|
10
10
|
*/
|
|
11
11
|
export type IntegrationField<
|
|
12
|
-
Data extends
|
|
12
|
+
Data extends IntegrationFieldData = IntegrationFieldData,
|
|
13
13
|
State extends FieldState = FieldState,
|
|
14
14
|
> = State extends "empty" ? null : Data
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Data from an integration field.
|
|
18
|
+
*
|
|
19
|
+
* @see More details: {@link https://prismic.io/docs/fields/integration}
|
|
20
|
+
*/
|
|
21
|
+
export type IntegrationFieldData = Record<string | number, unknown>
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;;"}
|
|
@@ -1 +0,0 @@
|
|
|
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;"}
|