@prismicio/mock 0.3.8-alpha.0 → 0.3.8
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/api/repository.cjs +2 -1
- package/dist/api/repository.cjs.map +1 -1
- package/dist/api/repository.js +2 -1
- package/dist/api/repository.js.map +1 -1
- package/dist/lib/buildContentRelationshipField.cjs +1 -2
- package/dist/lib/buildContentRelationshipField.cjs.map +1 -1
- package/dist/lib/buildContentRelationshipField.d.ts +2 -3
- package/dist/lib/buildContentRelationshipField.js +1 -2
- package/dist/lib/buildContentRelationshipField.js.map +1 -1
- package/dist/lib/buildImageFieldImage.cjs +2 -0
- package/dist/lib/buildImageFieldImage.cjs.map +1 -1
- package/dist/lib/buildImageFieldImage.js +2 -0
- package/dist/lib/buildImageFieldImage.js.map +1 -1
- package/dist/model/contentRelationship.cjs +1 -4
- package/dist/model/contentRelationship.cjs.map +1 -1
- package/dist/model/contentRelationship.d.ts +2 -12
- package/dist/model/contentRelationship.js +1 -4
- package/dist/model/contentRelationship.js.map +1 -1
- package/dist/model/createModelMockFactory.d.ts +3 -27
- package/dist/model/link.cjs +1 -4
- package/dist/model/link.cjs.map +1 -1
- package/dist/model/link.d.ts +3 -12
- package/dist/model/link.js +1 -4
- package/dist/model/link.js.map +1 -1
- package/dist/model/linkToMedia.cjs +1 -4
- package/dist/model/linkToMedia.cjs.map +1 -1
- package/dist/model/linkToMedia.d.ts +2 -13
- package/dist/model/linkToMedia.js +1 -4
- package/dist/model/linkToMedia.js.map +1 -1
- package/dist/value/contentRelationship.cjs +2 -4
- package/dist/value/contentRelationship.cjs.map +1 -1
- package/dist/value/contentRelationship.d.ts +0 -1
- package/dist/value/contentRelationship.js +2 -4
- package/dist/value/contentRelationship.js.map +1 -1
- package/dist/value/link.cjs +2 -4
- package/dist/value/link.cjs.map +1 -1
- package/dist/value/link.d.ts +0 -1
- package/dist/value/link.js +2 -4
- package/dist/value/link.js.map +1 -1
- package/dist/value/linkToMedia.cjs +2 -5
- package/dist/value/linkToMedia.cjs.map +1 -1
- package/dist/value/linkToMedia.d.ts +1 -3
- package/dist/value/linkToMedia.js +3 -6
- package/dist/value/linkToMedia.js.map +1 -1
- package/package.json +3 -5
- package/src/api/repository.ts +1 -0
- package/src/lib/buildContentRelationshipField.ts +2 -6
- package/src/lib/buildImageFieldImage.ts +2 -0
- package/src/model/contentRelationship.ts +3 -26
- package/src/model/link.ts +15 -39
- package/src/model/linkToMedia.ts +5 -24
- package/src/value/contentRelationship.ts +0 -8
- package/src/value/link.ts +0 -8
- package/src/value/linkToMedia.ts +2 -14
package/dist/api/repository.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.cjs","sources":["../../../src/api/repository.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport { MockRestApiConfig } from \"../types\";\nimport { ref } from \"./ref\";\n\nexport type MockRestApiRepositoryConfig = {\n\tcustomTypeModels?: prismic.CustomTypeModel[];\n\twithReleases?: boolean;\n} & MockRestApiConfig;\n\nexport const repository = (\n\tconfig: MockRestApiRepositoryConfig,\n): prismic.Repository => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst types = (config.customTypeModels || []).reduce(\n\t\t(acc, model) => {\n\t\t\tacc[model.id] = model.label || model.id;\n\n\t\t\treturn acc;\n\t\t},\n\t\t{} as prismic.Repository[\"types\"],\n\t);\n\n\treturn {\n\t\trefs: [\n\t\t\tref({ faker, isMasterRef: true }),\n\t\t\t...(config.withReleases ? [ref({ faker }), ref({ faker })] : []),\n\t\t],\n\t\tintegrationFieldsRef: ref({ faker }).ref,\n\t\ttypes,\n\t\tlanguages: [\n\t\t\t{\n\t\t\t\tid: faker.word(),\n\t\t\t\tname: changeCase.capitalCase(faker.word()),\n\t\t\t},\n\t\t],\n\t\ttags: generateTags({\n\t\t\tfaker,\n\t\t\tmin: 1,\n\t\t\tmax: 10,\n\t\t}),\n\t\tforms: {},\n\t\tlicense: \"All Rights Reserved\",\n\t\tversion: faker.hash(7),\n\t\tbookmarks: {},\n\t\texperiments: {},\n\t\toauth_token: faker.url(),\n\t\toauth_initiate: faker.url(),\n\t};\n};\n"],"names":["createFaker","ref","changeCase.capitalCase","generateTags"],"mappings":";;;;;;AAca,MAAA,aAAa,CACzB,WACuB;AACvB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE/C,QAAA,SAAS,OAAO,oBAAoB,IAAI,OAC7C,CAAC,KAAK,UAAS;AACd,QAAI,MAAM,EAAE,IAAI,MAAM,SAAS,MAAM;AAE9B,WAAA;AAAA,EACR,GACA,CAAiC,CAAA;AAG3B,SAAA;AAAA,IACN,MAAM;AAAA,MACLC,IAAAA,IAAI,EAAE,OAAO,aAAa,MAAM;AAAA,MAChC,GAAI,OAAO,eAAe,CAACA,IAAAA,IAAI,EAAE,OAAO,GAAGA,QAAI,EAAE,MAAO,CAAA,CAAC,IAAI,CAAA;AAAA,IAC7D;AAAA,IACD,sBAAsBA,IAAA,IAAI,EAAE,MAAA,CAAO,EAAE;AAAA,IACrC;AAAA,IACA,WAAW;AAAA,MACV;AAAA,QACC,IAAI,MAAM,KAAM;AAAA,QAChB,MAAMC,MAAuB,YAAA,MAAM,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"repository.cjs","sources":["../../../src/api/repository.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport { MockRestApiConfig } from \"../types\";\nimport { ref } from \"./ref\";\n\nexport type MockRestApiRepositoryConfig = {\n\tcustomTypeModels?: prismic.CustomTypeModel[];\n\twithReleases?: boolean;\n} & MockRestApiConfig;\n\nexport const repository = (\n\tconfig: MockRestApiRepositoryConfig,\n): prismic.Repository => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst types = (config.customTypeModels || []).reduce(\n\t\t(acc, model) => {\n\t\t\tacc[model.id] = model.label || model.id;\n\n\t\t\treturn acc;\n\t\t},\n\t\t{} as prismic.Repository[\"types\"],\n\t);\n\n\treturn {\n\t\trefs: [\n\t\t\tref({ faker, isMasterRef: true }),\n\t\t\t...(config.withReleases ? [ref({ faker }), ref({ faker })] : []),\n\t\t],\n\t\tintegrationFieldsRef: ref({ faker }).ref,\n\t\ttypes,\n\t\tlanguages: [\n\t\t\t{\n\t\t\t\tid: faker.word(),\n\t\t\t\tname: changeCase.capitalCase(faker.word()),\n\t\t\t\tis_master: true,\n\t\t\t},\n\t\t],\n\t\ttags: generateTags({\n\t\t\tfaker,\n\t\t\tmin: 1,\n\t\t\tmax: 10,\n\t\t}),\n\t\tforms: {},\n\t\tlicense: \"All Rights Reserved\",\n\t\tversion: faker.hash(7),\n\t\tbookmarks: {},\n\t\texperiments: {},\n\t\toauth_token: faker.url(),\n\t\toauth_initiate: faker.url(),\n\t};\n};\n"],"names":["createFaker","ref","changeCase.capitalCase","generateTags"],"mappings":";;;;;;AAca,MAAA,aAAa,CACzB,WACuB;AACvB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE/C,QAAA,SAAS,OAAO,oBAAoB,IAAI,OAC7C,CAAC,KAAK,UAAS;AACd,QAAI,MAAM,EAAE,IAAI,MAAM,SAAS,MAAM;AAE9B,WAAA;AAAA,EACR,GACA,CAAiC,CAAA;AAG3B,SAAA;AAAA,IACN,MAAM;AAAA,MACLC,IAAAA,IAAI,EAAE,OAAO,aAAa,MAAM;AAAA,MAChC,GAAI,OAAO,eAAe,CAACA,IAAAA,IAAI,EAAE,OAAO,GAAGA,QAAI,EAAE,MAAO,CAAA,CAAC,IAAI,CAAA;AAAA,IAC7D;AAAA,IACD,sBAAsBA,IAAA,IAAI,EAAE,MAAA,CAAO,EAAE;AAAA,IACrC;AAAA,IACA,WAAW;AAAA,MACV;AAAA,QACC,IAAI,MAAM,KAAM;AAAA,QAChB,MAAMC,MAAuB,YAAA,MAAM,MAAM;AAAA,QACzC,WAAW;AAAA,MACX;AAAA,IACD;AAAA,IACD,MAAMC,aAAAA,aAAa;AAAA,MAClB;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IAAA,CACL;AAAA,IACD,OAAO,CAAE;AAAA,IACT,SAAS;AAAA,IACT,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,WAAW,CAAE;AAAA,IACb,aAAa,CAAE;AAAA,IACf,aAAa,MAAM,IAAK;AAAA,IACxB,gBAAgB,MAAM,IAAK;AAAA,EAAA;AAE7B;;"}
|
package/dist/api/repository.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.js","sources":["../../../src/api/repository.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport { MockRestApiConfig } from \"../types\";\nimport { ref } from \"./ref\";\n\nexport type MockRestApiRepositoryConfig = {\n\tcustomTypeModels?: prismic.CustomTypeModel[];\n\twithReleases?: boolean;\n} & MockRestApiConfig;\n\nexport const repository = (\n\tconfig: MockRestApiRepositoryConfig,\n): prismic.Repository => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst types = (config.customTypeModels || []).reduce(\n\t\t(acc, model) => {\n\t\t\tacc[model.id] = model.label || model.id;\n\n\t\t\treturn acc;\n\t\t},\n\t\t{} as prismic.Repository[\"types\"],\n\t);\n\n\treturn {\n\t\trefs: [\n\t\t\tref({ faker, isMasterRef: true }),\n\t\t\t...(config.withReleases ? [ref({ faker }), ref({ faker })] : []),\n\t\t],\n\t\tintegrationFieldsRef: ref({ faker }).ref,\n\t\ttypes,\n\t\tlanguages: [\n\t\t\t{\n\t\t\t\tid: faker.word(),\n\t\t\t\tname: changeCase.capitalCase(faker.word()),\n\t\t\t},\n\t\t],\n\t\ttags: generateTags({\n\t\t\tfaker,\n\t\t\tmin: 1,\n\t\t\tmax: 10,\n\t\t}),\n\t\tforms: {},\n\t\tlicense: \"All Rights Reserved\",\n\t\tversion: faker.hash(7),\n\t\tbookmarks: {},\n\t\texperiments: {},\n\t\toauth_token: faker.url(),\n\t\toauth_initiate: faker.url(),\n\t};\n};\n"],"names":["changeCase.capitalCase"],"mappings":";;;;AAca,MAAA,aAAa,CACzB,WACuB;AACvB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE/C,QAAA,SAAS,OAAO,oBAAoB,IAAI,OAC7C,CAAC,KAAK,UAAS;AACd,QAAI,MAAM,EAAE,IAAI,MAAM,SAAS,MAAM;AAE9B,WAAA;AAAA,EACR,GACA,CAAiC,CAAA;AAG3B,SAAA;AAAA,IACN,MAAM;AAAA,MACL,IAAI,EAAE,OAAO,aAAa,MAAM;AAAA,MAChC,GAAI,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,MAAO,CAAA,CAAC,IAAI,CAAA;AAAA,IAC7D;AAAA,IACD,sBAAsB,IAAI,EAAE,MAAA,CAAO,EAAE;AAAA,IACrC;AAAA,IACA,WAAW;AAAA,MACV;AAAA,QACC,IAAI,MAAM,KAAM;AAAA,QAChB,MAAMA,YAAuB,MAAM,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"repository.js","sources":["../../../src/api/repository.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport { MockRestApiConfig } from \"../types\";\nimport { ref } from \"./ref\";\n\nexport type MockRestApiRepositoryConfig = {\n\tcustomTypeModels?: prismic.CustomTypeModel[];\n\twithReleases?: boolean;\n} & MockRestApiConfig;\n\nexport const repository = (\n\tconfig: MockRestApiRepositoryConfig,\n): prismic.Repository => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst types = (config.customTypeModels || []).reduce(\n\t\t(acc, model) => {\n\t\t\tacc[model.id] = model.label || model.id;\n\n\t\t\treturn acc;\n\t\t},\n\t\t{} as prismic.Repository[\"types\"],\n\t);\n\n\treturn {\n\t\trefs: [\n\t\t\tref({ faker, isMasterRef: true }),\n\t\t\t...(config.withReleases ? [ref({ faker }), ref({ faker })] : []),\n\t\t],\n\t\tintegrationFieldsRef: ref({ faker }).ref,\n\t\ttypes,\n\t\tlanguages: [\n\t\t\t{\n\t\t\t\tid: faker.word(),\n\t\t\t\tname: changeCase.capitalCase(faker.word()),\n\t\t\t\tis_master: true,\n\t\t\t},\n\t\t],\n\t\ttags: generateTags({\n\t\t\tfaker,\n\t\t\tmin: 1,\n\t\t\tmax: 10,\n\t\t}),\n\t\tforms: {},\n\t\tlicense: \"All Rights Reserved\",\n\t\tversion: faker.hash(7),\n\t\tbookmarks: {},\n\t\texperiments: {},\n\t\toauth_token: faker.url(),\n\t\toauth_initiate: faker.url(),\n\t};\n};\n"],"names":["changeCase.capitalCase"],"mappings":";;;;AAca,MAAA,aAAa,CACzB,WACuB;AACvB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE/C,QAAA,SAAS,OAAO,oBAAoB,IAAI,OAC7C,CAAC,KAAK,UAAS;AACd,QAAI,MAAM,EAAE,IAAI,MAAM,SAAS,MAAM;AAE9B,WAAA;AAAA,EACR,GACA,CAAiC,CAAA;AAG3B,SAAA;AAAA,IACN,MAAM;AAAA,MACL,IAAI,EAAE,OAAO,aAAa,MAAM;AAAA,MAChC,GAAI,OAAO,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,MAAO,CAAA,CAAC,IAAI,CAAA;AAAA,IAC7D;AAAA,IACD,sBAAsB,IAAI,EAAE,MAAA,CAAO,EAAE;AAAA,IACrC;AAAA,IACA,WAAW;AAAA,MACV;AAAA,QACC,IAAI,MAAM,KAAM;AAAA,QAChB,MAAMA,YAAuB,MAAM,MAAM;AAAA,QACzC,WAAW;AAAA,MACX;AAAA,IACD;AAAA,IACD,MAAM,aAAa;AAAA,MAClB;AAAA,MACA,KAAK;AAAA,MACL,KAAK;AAAA,IAAA,CACL;AAAA,IACD,OAAO,CAAE;AAAA,IACT,SAAS;AAAA,IACT,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,WAAW,CAAE;AAAA,IACb,aAAa,CAAE;AAAA,IACf,aAAa,MAAM,IAAK;AAAA,IACxB,gBAAgB,MAAM,IAAK;AAAA,EAAA;AAE7B;"}
|
|
@@ -28,8 +28,7 @@ const buildContentRelationshipField = (config) => {
|
|
|
28
28
|
lang: config.document.lang,
|
|
29
29
|
url: config.document.url || void 0,
|
|
30
30
|
slug: config.document.slugs[0],
|
|
31
|
-
isBroken: false
|
|
32
|
-
text: config.text
|
|
31
|
+
isBroken: false
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
34
|
exports.buildContentRelationshipField = buildContentRelationshipField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildContentRelationshipField.cjs","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype
|
|
1
|
+
{"version":3,"file":"buildContentRelationshipField.cjs","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {\n\tdocument: Document;\n};\n\nexport const buildContentRelationshipField = <\n\tDocument extends prismic.PrismicDocument,\n>(\n\tconfig: BuildEmbedFieldConfig<Document>,\n): prismic.ContentRelationshipField<\n\tDocument[\"type\"],\n\tDocument[\"lang\"],\n\tnever,\n\t\"filled\"\n> => {\n\treturn {\n\t\tlink_type: prismic.LinkType.Document,\n\t\tid: config.document.id,\n\t\tuid: config.document.uid || undefined,\n\t\ttype: config.document.type,\n\t\ttags: config.document.tags,\n\t\tlang: config.document.lang,\n\t\turl: config.document.url || undefined,\n\t\tslug: config.document.slugs[0],\n\t\tisBroken: false,\n\t};\n};\n"],"names":["prismic"],"mappings":";;;;;;;;;;;;;;;;;;;;AAMa,MAAA,gCAAgC,CAG5C,WAMG;AACI,SAAA;AAAA,IACN,WAAWA,mBAAQ,SAAS;AAAA,IAC5B,IAAI,OAAO,SAAS;AAAA,IACpB,KAAK,OAAO,SAAS,OAAO;AAAA,IAC5B,MAAM,OAAO,SAAS;AAAA,IACtB,MAAM,OAAO,SAAS;AAAA,IACtB,MAAM,OAAO,SAAS;AAAA,IACtB,KAAK,OAAO,SAAS,OAAO;AAAA,IAC5B,MAAM,OAAO,SAAS,MAAM,CAAC;AAAA,IAC7B,UAAU;AAAA,EAAA;AAEZ;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
type
|
|
2
|
+
type BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {
|
|
3
3
|
document: Document;
|
|
4
|
-
text?: string;
|
|
5
4
|
};
|
|
6
|
-
export declare const buildContentRelationshipField: <Document extends prismic.PrismicDocument<Record<string, any>, string, string>>(config:
|
|
5
|
+
export declare const buildContentRelationshipField: <Document extends prismic.PrismicDocument<Record<string, any>, string, string>>(config: BuildEmbedFieldConfig<Document>) => prismic.ContentRelationshipField<Document["type"], Document["lang"], never, "filled">;
|
|
7
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildContentRelationshipField.js","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype
|
|
1
|
+
{"version":3,"file":"buildContentRelationshipField.js","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {\n\tdocument: Document;\n};\n\nexport const buildContentRelationshipField = <\n\tDocument extends prismic.PrismicDocument,\n>(\n\tconfig: BuildEmbedFieldConfig<Document>,\n): prismic.ContentRelationshipField<\n\tDocument[\"type\"],\n\tDocument[\"lang\"],\n\tnever,\n\t\"filled\"\n> => {\n\treturn {\n\t\tlink_type: prismic.LinkType.Document,\n\t\tid: config.document.id,\n\t\tuid: config.document.uid || undefined,\n\t\ttype: config.document.type,\n\t\ttags: config.document.tags,\n\t\tlang: config.document.lang,\n\t\turl: config.document.url || undefined,\n\t\tslug: config.document.slugs[0],\n\t\tisBroken: false,\n\t};\n};\n"],"names":[],"mappings":";AAMa,MAAA,gCAAgC,CAG5C,WAMG;AACI,SAAA;AAAA,IACN,WAAW,QAAQ,SAAS;AAAA,IAC5B,IAAI,OAAO,SAAS;AAAA,IACpB,KAAK,OAAO,SAAS,OAAO;AAAA,IAC5B,MAAM,OAAO,SAAS;AAAA,IACtB,MAAM,OAAO,SAAS;AAAA,IACtB,MAAM,OAAO,SAAS;AAAA,IACtB,KAAK,OAAO,SAAS,OAAO;AAAA,IAC5B,MAAM,OAAO,SAAS,MAAM,CAAC;AAAA,IAC7B,UAAU;AAAA,EAAA;AAEZ;"}
|
|
@@ -6,6 +6,7 @@ const buildImageFieldImage = (config) => {
|
|
|
6
6
|
var _a, _b;
|
|
7
7
|
if (config.state === "empty") {
|
|
8
8
|
return {
|
|
9
|
+
id: null,
|
|
9
10
|
url: null,
|
|
10
11
|
dimensions: null,
|
|
11
12
|
alt: null,
|
|
@@ -22,6 +23,7 @@ const buildImageFieldImage = (config) => {
|
|
|
22
23
|
url.searchParams.set("h", dimensions.height.toString());
|
|
23
24
|
url.searchParams.set("fit", "crop");
|
|
24
25
|
return {
|
|
26
|
+
id: faker.hash(11),
|
|
25
27
|
url: url.toString(),
|
|
26
28
|
dimensions,
|
|
27
29
|
alt: index.sentenceCase(faker.words(faker.range(5, 15))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildImageFieldImage.cjs","sources":["../../../src/lib/buildImageFieldImage.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker, Faker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockImageData, Seed } from \"../types\";\n\ntype BuildImageFieldConfig<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\timageData: MockImageData;\n\tconstraint?: NonNullable<\n\t\tprismic.CustomTypeModelImageField[\"config\"]\n\t>[\"constraint\"];\n} & (\n\t| {\n\t\t\tseed: Seed;\n\t\t\tfaker?: never;\n\t }\n\t| {\n\t\t\tfaker: Faker;\n\t\t\tseed?: never;\n\t }\n) &\n\tPick<MockValueStateConfig<State>, \"state\">;\n\nexport const buildImageFieldImage = <\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: BuildImageFieldConfig<State>,\n): prismic.ImageFieldImage<State> => {\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\turl: null,\n\t\t\tdimensions: null,\n\t\t\talt: null,\n\t\t\tcopyright: null,\n\t\t} as prismic.ImageFieldImage<State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst url = new URL(config.imageData.url);\n\n\t\tconst dimensions = {\n\t\t\twidth: config.constraint?.width ?? config.imageData.width,\n\t\t\theight: config.constraint?.height ?? config.imageData.height,\n\t\t};\n\n\t\turl.searchParams.set(\"w\", dimensions.width.toString());\n\t\turl.searchParams.set(\"h\", dimensions.height.toString());\n\t\turl.searchParams.set(\"fit\", \"crop\");\n\n\t\treturn {\n\t\t\turl: url.toString(),\n\t\t\tdimensions,\n\t\t\talt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tcopyright: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tedit: {\n\t\t\t\tx: faker.range(-dimensions.width / 2, dimensions.width / 2),\n\t\t\t\ty: faker.range(-dimensions.width / 2, dimensions.height / 2),\n\t\t\t\tzoom: faker.rangeFloat(1, 2),\n\t\t\t\tbackground: faker.hexColor(),\n\t\t\t},\n\t\t} as prismic.ImageFieldImage<State>;\n\t}\n};\n"],"names":["createFaker","changeCase.sentenceCase"],"mappings":";;;;AA0Ba,MAAA,uBAAuB,CAGnC,WACmC;;AAC/B,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,KAAK;AAAA,MACL,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,UAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,UAAM,MAAM,IAAI,IAAI,OAAO,UAAU,GAAG;AAExC,UAAM,aAAa;AAAA,MAClB,SAAO,YAAO,eAAP,mBAAmB,UAAS,OAAO,UAAU;AAAA,MACpD,UAAQ,YAAO,eAAP,mBAAmB,WAAU,OAAO,UAAU;AAAA,IAAA;AAGvD,QAAI,aAAa,IAAI,KAAK,WAAW,MAAM,UAAU;AACrD,QAAI,aAAa,IAAI,KAAK,WAAW,OAAO,UAAU;AAClD,QAAA,aAAa,IAAI,OAAO,MAAM;AAE3B,WAAA;AAAA,MACN,KAAK,IAAI,SAAU;AAAA,MACnB;AAAA,MACA,KAAKC,MAAAA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAC5D,WAAWA,MAAAA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAClE,MAAM;AAAA,QACL,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,QAAQ,CAAC;AAAA,QAC1D,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,SAAS,CAAC;AAAA,QAC3D,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,QAC3B,YAAY,MAAM,SAAU;AAAA,MAC5B;AAAA,IAAA;AAAA,EAEH;AACD;;"}
|
|
1
|
+
{"version":3,"file":"buildImageFieldImage.cjs","sources":["../../../src/lib/buildImageFieldImage.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker, Faker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockImageData, Seed } from \"../types\";\n\ntype BuildImageFieldConfig<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\timageData: MockImageData;\n\tconstraint?: NonNullable<\n\t\tprismic.CustomTypeModelImageField[\"config\"]\n\t>[\"constraint\"];\n} & (\n\t| {\n\t\t\tseed: Seed;\n\t\t\tfaker?: never;\n\t }\n\t| {\n\t\t\tfaker: Faker;\n\t\t\tseed?: never;\n\t }\n) &\n\tPick<MockValueStateConfig<State>, \"state\">;\n\nexport const buildImageFieldImage = <\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: BuildImageFieldConfig<State>,\n): prismic.ImageFieldImage<State> => {\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tid: null,\n\t\t\turl: null,\n\t\t\tdimensions: null,\n\t\t\talt: null,\n\t\t\tcopyright: null,\n\t\t} as prismic.ImageFieldImage<State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst url = new URL(config.imageData.url);\n\n\t\tconst dimensions = {\n\t\t\twidth: config.constraint?.width ?? config.imageData.width,\n\t\t\theight: config.constraint?.height ?? config.imageData.height,\n\t\t};\n\n\t\turl.searchParams.set(\"w\", dimensions.width.toString());\n\t\turl.searchParams.set(\"h\", dimensions.height.toString());\n\t\turl.searchParams.set(\"fit\", \"crop\");\n\n\t\treturn {\n\t\t\tid: faker.hash(11),\n\t\t\turl: url.toString(),\n\t\t\tdimensions,\n\t\t\talt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tcopyright: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tedit: {\n\t\t\t\tx: faker.range(-dimensions.width / 2, dimensions.width / 2),\n\t\t\t\ty: faker.range(-dimensions.width / 2, dimensions.height / 2),\n\t\t\t\tzoom: faker.rangeFloat(1, 2),\n\t\t\t\tbackground: faker.hexColor(),\n\t\t\t},\n\t\t} as prismic.ImageFieldImage<State>;\n\t}\n};\n"],"names":["createFaker","changeCase.sentenceCase"],"mappings":";;;;AA0Ba,MAAA,uBAAuB,CAGnC,WACmC;;AAC/B,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,KAAK;AAAA,MACL,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,UAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,UAAM,MAAM,IAAI,IAAI,OAAO,UAAU,GAAG;AAExC,UAAM,aAAa;AAAA,MAClB,SAAO,YAAO,eAAP,mBAAmB,UAAS,OAAO,UAAU;AAAA,MACpD,UAAQ,YAAO,eAAP,mBAAmB,WAAU,OAAO,UAAU;AAAA,IAAA;AAGvD,QAAI,aAAa,IAAI,KAAK,WAAW,MAAM,UAAU;AACrD,QAAI,aAAa,IAAI,KAAK,WAAW,OAAO,UAAU;AAClD,QAAA,aAAa,IAAI,OAAO,MAAM;AAE3B,WAAA;AAAA,MACN,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,KAAK,IAAI,SAAU;AAAA,MACnB;AAAA,MACA,KAAKC,MAAAA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAC5D,WAAWA,MAAAA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAClE,MAAM;AAAA,QACL,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,QAAQ,CAAC;AAAA,QAC1D,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,SAAS,CAAC;AAAA,QAC3D,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,QAC3B,YAAY,MAAM,SAAU;AAAA,MAC5B;AAAA,IAAA;AAAA,EAEH;AACD;;"}
|
|
@@ -4,6 +4,7 @@ const buildImageFieldImage = (config) => {
|
|
|
4
4
|
var _a, _b;
|
|
5
5
|
if (config.state === "empty") {
|
|
6
6
|
return {
|
|
7
|
+
id: null,
|
|
7
8
|
url: null,
|
|
8
9
|
dimensions: null,
|
|
9
10
|
alt: null,
|
|
@@ -20,6 +21,7 @@ const buildImageFieldImage = (config) => {
|
|
|
20
21
|
url.searchParams.set("h", dimensions.height.toString());
|
|
21
22
|
url.searchParams.set("fit", "crop");
|
|
22
23
|
return {
|
|
24
|
+
id: faker.hash(11),
|
|
23
25
|
url: url.toString(),
|
|
24
26
|
dimensions,
|
|
25
27
|
alt: sentenceCase(faker.words(faker.range(5, 15))),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildImageFieldImage.js","sources":["../../../src/lib/buildImageFieldImage.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker, Faker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockImageData, Seed } from \"../types\";\n\ntype BuildImageFieldConfig<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\timageData: MockImageData;\n\tconstraint?: NonNullable<\n\t\tprismic.CustomTypeModelImageField[\"config\"]\n\t>[\"constraint\"];\n} & (\n\t| {\n\t\t\tseed: Seed;\n\t\t\tfaker?: never;\n\t }\n\t| {\n\t\t\tfaker: Faker;\n\t\t\tseed?: never;\n\t }\n) &\n\tPick<MockValueStateConfig<State>, \"state\">;\n\nexport const buildImageFieldImage = <\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: BuildImageFieldConfig<State>,\n): prismic.ImageFieldImage<State> => {\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\turl: null,\n\t\t\tdimensions: null,\n\t\t\talt: null,\n\t\t\tcopyright: null,\n\t\t} as prismic.ImageFieldImage<State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst url = new URL(config.imageData.url);\n\n\t\tconst dimensions = {\n\t\t\twidth: config.constraint?.width ?? config.imageData.width,\n\t\t\theight: config.constraint?.height ?? config.imageData.height,\n\t\t};\n\n\t\turl.searchParams.set(\"w\", dimensions.width.toString());\n\t\turl.searchParams.set(\"h\", dimensions.height.toString());\n\t\turl.searchParams.set(\"fit\", \"crop\");\n\n\t\treturn {\n\t\t\turl: url.toString(),\n\t\t\tdimensions,\n\t\t\talt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tcopyright: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tedit: {\n\t\t\t\tx: faker.range(-dimensions.width / 2, dimensions.width / 2),\n\t\t\t\ty: faker.range(-dimensions.width / 2, dimensions.height / 2),\n\t\t\t\tzoom: faker.rangeFloat(1, 2),\n\t\t\t\tbackground: faker.hexColor(),\n\t\t\t},\n\t\t} as prismic.ImageFieldImage<State>;\n\t}\n};\n"],"names":["changeCase.sentenceCase"],"mappings":";;AA0Ba,MAAA,uBAAuB,CAGnC,WACmC;;AAC/B,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,KAAK;AAAA,MACL,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,UAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,UAAM,MAAM,IAAI,IAAI,OAAO,UAAU,GAAG;AAExC,UAAM,aAAa;AAAA,MAClB,SAAO,YAAO,eAAP,mBAAmB,UAAS,OAAO,UAAU;AAAA,MACpD,UAAQ,YAAO,eAAP,mBAAmB,WAAU,OAAO,UAAU;AAAA,IAAA;AAGvD,QAAI,aAAa,IAAI,KAAK,WAAW,MAAM,UAAU;AACrD,QAAI,aAAa,IAAI,KAAK,WAAW,OAAO,UAAU;AAClD,QAAA,aAAa,IAAI,OAAO,MAAM;AAE3B,WAAA;AAAA,MACN,KAAK,IAAI,SAAU;AAAA,MACnB;AAAA,MACA,KAAKA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAC5D,WAAWA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAClE,MAAM;AAAA,QACL,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,QAAQ,CAAC;AAAA,QAC1D,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,SAAS,CAAC;AAAA,QAC3D,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,QAC3B,YAAY,MAAM,SAAU;AAAA,MAC5B;AAAA,IAAA;AAAA,EAEH;AACD;"}
|
|
1
|
+
{"version":3,"file":"buildImageFieldImage.js","sources":["../../../src/lib/buildImageFieldImage.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker, Faker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockImageData, Seed } from \"../types\";\n\ntype BuildImageFieldConfig<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\timageData: MockImageData;\n\tconstraint?: NonNullable<\n\t\tprismic.CustomTypeModelImageField[\"config\"]\n\t>[\"constraint\"];\n} & (\n\t| {\n\t\t\tseed: Seed;\n\t\t\tfaker?: never;\n\t }\n\t| {\n\t\t\tfaker: Faker;\n\t\t\tseed?: never;\n\t }\n) &\n\tPick<MockValueStateConfig<State>, \"state\">;\n\nexport const buildImageFieldImage = <\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: BuildImageFieldConfig<State>,\n): prismic.ImageFieldImage<State> => {\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tid: null,\n\t\t\turl: null,\n\t\t\tdimensions: null,\n\t\t\talt: null,\n\t\t\tcopyright: null,\n\t\t} as prismic.ImageFieldImage<State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst url = new URL(config.imageData.url);\n\n\t\tconst dimensions = {\n\t\t\twidth: config.constraint?.width ?? config.imageData.width,\n\t\t\theight: config.constraint?.height ?? config.imageData.height,\n\t\t};\n\n\t\turl.searchParams.set(\"w\", dimensions.width.toString());\n\t\turl.searchParams.set(\"h\", dimensions.height.toString());\n\t\turl.searchParams.set(\"fit\", \"crop\");\n\n\t\treturn {\n\t\t\tid: faker.hash(11),\n\t\t\turl: url.toString(),\n\t\t\tdimensions,\n\t\t\talt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tcopyright: changeCase.sentenceCase(faker.words(faker.range(5, 15))),\n\t\t\tedit: {\n\t\t\t\tx: faker.range(-dimensions.width / 2, dimensions.width / 2),\n\t\t\t\ty: faker.range(-dimensions.width / 2, dimensions.height / 2),\n\t\t\t\tzoom: faker.rangeFloat(1, 2),\n\t\t\t\tbackground: faker.hexColor(),\n\t\t\t},\n\t\t} as prismic.ImageFieldImage<State>;\n\t}\n};\n"],"names":["changeCase.sentenceCase"],"mappings":";;AA0Ba,MAAA,uBAAuB,CAGnC,WACmC;;AAC/B,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,YAAY;AAAA,MACZ,KAAK;AAAA,MACL,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,UAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,UAAM,MAAM,IAAI,IAAI,OAAO,UAAU,GAAG;AAExC,UAAM,aAAa;AAAA,MAClB,SAAO,YAAO,eAAP,mBAAmB,UAAS,OAAO,UAAU;AAAA,MACpD,UAAQ,YAAO,eAAP,mBAAmB,WAAU,OAAO,UAAU;AAAA,IAAA;AAGvD,QAAI,aAAa,IAAI,KAAK,WAAW,MAAM,UAAU;AACrD,QAAI,aAAa,IAAI,KAAK,WAAW,OAAO,UAAU;AAClD,QAAA,aAAa,IAAI,OAAO,MAAM;AAE3B,WAAA;AAAA,MACN,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,KAAK,IAAI,SAAU;AAAA,MACnB;AAAA,MACA,KAAKA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAC5D,WAAWA,aAAwB,MAAM,MAAM,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC;AAAA,MAClE,MAAM;AAAA,QACL,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,QAAQ,CAAC;AAAA,QAC1D,GAAG,MAAM,MAAM,CAAC,WAAW,QAAQ,GAAG,WAAW,SAAS,CAAC;AAAA,QAC3D,MAAM,MAAM,WAAW,GAAG,CAAC;AAAA,QAC3B,YAAY,MAAM,SAAU;AAAA,MAC5B;AAAA,IAAA;AAAA,EAEH;AACD;"}
|
|
@@ -29,10 +29,7 @@ const contentRelationship = (config) => {
|
|
|
29
29
|
placeholder: index.sentenceCase(faker.words(3)),
|
|
30
30
|
select: prismic__namespace.CustomTypeModelLinkSelectType.Document,
|
|
31
31
|
customtypes: config.customTypeIDs,
|
|
32
|
-
tags: config.tags
|
|
33
|
-
text: config.text ? {
|
|
34
|
-
type: prismic__namespace.CustomTypeModelFieldType.Text
|
|
35
|
-
} : void 0
|
|
32
|
+
tags: config.tags
|
|
36
33
|
}
|
|
37
34
|
};
|
|
38
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentRelationship.cjs","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"contentRelationship.cjs","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,\n): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Document,\n\t\t\tcustomtypes: config.customTypeIDs,\n\t\t\ttags: config.tags,\n\t\t},\n\t};\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAea,MAAA,sBAAsB,CAIlC,WACyE;AACzE,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAMC,mBAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOC,MAAuB,YAAA,MAAM,MAAM;AAAA,MAC1C,aAAaC,MAAAA,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQF,mBAAQ,8BAA8B;AAAA,MAC9C,aAAa,OAAO;AAAA,MACpB,MAAM,OAAO;AAAA,IACb;AAAA,EAAA;AAEH;;"}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { LinkText } from "./link";
|
|
3
2
|
import { MockModelConfig } from "../types";
|
|
4
|
-
type
|
|
5
|
-
config: Text extends true ? {
|
|
6
|
-
text: LinkText;
|
|
7
|
-
} : {
|
|
8
|
-
text?: undefined;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string, Text extends boolean = boolean> = {
|
|
3
|
+
export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string> = {
|
|
12
4
|
customTypeIDs?: readonly CustomTypeIDs[];
|
|
13
5
|
tags?: readonly Tags[];
|
|
14
|
-
text?: Text;
|
|
15
6
|
} & MockModelConfig;
|
|
16
|
-
export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string
|
|
17
|
-
export {};
|
|
7
|
+
export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string>(config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>) => prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags>;
|
|
@@ -10,10 +10,7 @@ const contentRelationship = (config) => {
|
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
11
|
select: prismic.CustomTypeModelLinkSelectType.Document,
|
|
12
12
|
customtypes: config.customTypeIDs,
|
|
13
|
-
tags: config.tags
|
|
14
|
-
text: config.text ? {
|
|
15
|
-
type: prismic.CustomTypeModelFieldType.Text
|
|
16
|
-
} : void 0
|
|
13
|
+
tags: config.tags
|
|
17
14
|
}
|
|
18
15
|
};
|
|
19
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentRelationship.js","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"contentRelationship.js","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,\n): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Document,\n\t\t\tcustomtypes: config.customTypeIDs,\n\t\t\ttags: config.tags,\n\t\t},\n\t};\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAea,MAAA,sBAAsB,CAIlC,WACyE;AACzE,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAM,QAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOA,YAAuB,MAAM,MAAM;AAAA,MAC1C,aAAaC,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ,QAAQ,8BAA8B;AAAA,MAC9C,aAAa,OAAO;AAAA,MACpB,MAAM,OAAO;AAAA,IACb;AAAA,EAAA;AAEH;"}
|
|
@@ -38,13 +38,7 @@ export declare class ModelMockFactory {
|
|
|
38
38
|
buildMockGroupFieldMap(config?: WithoutFakerConfig<BuildMockGroupFieldMapConfig>): NestedGroupFieldModelMap;
|
|
39
39
|
boolean(config?: WithoutFakerConfig<MockBooleanModelConfig>): prismic.CustomTypeModelBooleanField;
|
|
40
40
|
color(config?: WithoutFakerConfig<MockColorModelConfig>): prismic.CustomTypeModelColorField;
|
|
41
|
-
contentRelationship<CustomTypeIDs extends string, Tags extends string>(config?: WithoutFakerConfig<MockContentRelationshipModelConfig<CustomTypeIDs, Tags>>): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags
|
|
42
|
-
config: {
|
|
43
|
-
text: prismic.CustomTypeModelKeyTextField;
|
|
44
|
-
} | {
|
|
45
|
-
text?: undefined;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
41
|
+
contentRelationship<CustomTypeIDs extends string, Tags extends string>(config?: WithoutFakerConfig<MockContentRelationshipModelConfig<CustomTypeIDs, Tags>>): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags>;
|
|
48
42
|
customType<Definition extends prismic.CustomTypeModelTab | prismic.CustomTypeModelDefinition>(config?: WithoutFakerConfig<MockCustomTypeModelConfig<Definition>>): (Definition extends Record<string, prismic.CustomTypeModelField> ? prismic.CustomTypeModel<string, Record<"Main", Definition>> : Definition extends prismic.CustomTypeModelDefinition ? prismic.CustomTypeModel<string, Definition> : never) & {
|
|
49
43
|
label: string;
|
|
50
44
|
};
|
|
@@ -55,26 +49,8 @@ export declare class ModelMockFactory {
|
|
|
55
49
|
image<ThumbnailNames extends string = string>(config?: WithoutFakerConfig<MockImageModelConfig<ThumbnailNames>>): prismic.CustomTypeModelImageField<ThumbnailNames>;
|
|
56
50
|
integration(config?: WithoutFakerConfig<MockIntegrationFieldModelConfig>): prismic.CustomTypeModelIntegrationField;
|
|
57
51
|
keyText(config?: WithoutFakerConfig<MockKeyTextModelConfig>): prismic.CustomTypeModelKeyTextField;
|
|
58
|
-
link<AllowTargetBlank extends boolean = boolean>(config?: WithoutFakerConfig<MockLinkModelConfig<AllowTargetBlank>>):
|
|
59
|
-
|
|
60
|
-
allowTargetBlank: true;
|
|
61
|
-
} : {
|
|
62
|
-
allowTargetBlank?: undefined;
|
|
63
|
-
};
|
|
64
|
-
} & {
|
|
65
|
-
config: {
|
|
66
|
-
text: prismic.CustomTypeModelKeyTextField;
|
|
67
|
-
} | {
|
|
68
|
-
text?: undefined;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField & {
|
|
72
|
-
config: {
|
|
73
|
-
text: prismic.CustomTypeModelKeyTextField;
|
|
74
|
-
} | {
|
|
75
|
-
text?: undefined;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
52
|
+
link<AllowTargetBlank extends boolean = boolean>(config?: WithoutFakerConfig<MockLinkModelConfig<AllowTargetBlank>>): import("./link").MockLinkModel<AllowTargetBlank>;
|
|
53
|
+
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField;
|
|
78
54
|
number(config?: WithoutFakerConfig<MockNumberModelConfig>): prismic.CustomTypeModelNumberField;
|
|
79
55
|
richText<WithMultipleBlocks extends boolean = boolean>(config?: WithoutFakerConfig<MockRichTextModelConfig<WithMultipleBlocks>>): WithMultipleBlocks extends true ? prismic.CustomTypeModelRichTextMultiField : prismic.CustomTypeModelRichTextSingleField;
|
|
80
56
|
select<Option extends string, DefaultOption extends Option>(config?: WithoutFakerConfig<MockSelectModelConfig<Option, DefaultOption>>): prismic.CustomTypeModelSelectField<Option, DefaultOption>;
|
package/dist/model/link.cjs
CHANGED
|
@@ -28,10 +28,7 @@ const link = (config) => {
|
|
|
28
28
|
label: index.capitalCase(faker.word()),
|
|
29
29
|
placeholder: index.sentenceCase(faker.words(3)),
|
|
30
30
|
select: null,
|
|
31
|
-
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
32
|
-
text: config.text ? {
|
|
33
|
-
type: prismic__namespace.CustomTypeModelFieldType.Text
|
|
34
|
-
} : void 0
|
|
31
|
+
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
34
|
};
|
package/dist/model/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockLinkModel<AllowTargetBlank extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkField & {\n\t\tconfig: AllowTargetBlank extends true\n\t\t\t? {\n\t\t\t\t\tallowTargetBlank: true;\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tallowTargetBlank?: undefined;\n\t\t\t\t};\n\t};\n\nexport type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {\n\tallowTargetBlank?: AllowTargetBlank;\n} & MockModelConfig;\n\nexport const link = <AllowTargetBlank extends boolean = boolean>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank>,\n): MockLinkModel<AllowTargetBlank> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBa,MAAA,OAAO,CACnB,WACoC;AACpC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAMC,mBAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOC,MAAuB,YAAA,MAAM,MAAM;AAAA,MAC1C,aAAaC,MAAAA,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ;AAAA,MACR,mBACE,sBAAsB,SACpB,OAAO,mBACP,MAAM,QAAc,MAAA;AAAA,IACxB;AAAA,EAAA;AAEH;;"}
|
package/dist/model/link.d.ts
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockModelConfig } from "../types";
|
|
3
|
-
export type
|
|
4
|
-
type MockLinkModel<AllowTargetBlank extends boolean = boolean, Text extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
3
|
+
export type MockLinkModel<AllowTargetBlank extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
5
4
|
config: AllowTargetBlank extends true ? {
|
|
6
5
|
allowTargetBlank: true;
|
|
7
6
|
} : {
|
|
8
7
|
allowTargetBlank?: undefined;
|
|
9
8
|
};
|
|
10
|
-
} & {
|
|
11
|
-
config: Text extends true ? {
|
|
12
|
-
text: LinkText;
|
|
13
|
-
} : {
|
|
14
|
-
text?: undefined;
|
|
15
|
-
};
|
|
16
9
|
};
|
|
17
|
-
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean
|
|
10
|
+
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
|
|
18
11
|
allowTargetBlank?: AllowTargetBlank;
|
|
19
|
-
text?: Text;
|
|
20
12
|
} & MockModelConfig;
|
|
21
|
-
export declare const link: <AllowTargetBlank extends boolean = boolean
|
|
22
|
-
export {};
|
|
13
|
+
export declare const link: <AllowTargetBlank extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank>) => MockLinkModel<AllowTargetBlank>;
|
package/dist/model/link.js
CHANGED
|
@@ -9,10 +9,7 @@ const link = (config) => {
|
|
|
9
9
|
label: capitalCase(faker.word()),
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
11
|
select: null,
|
|
12
|
-
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
13
|
-
text: config.text ? {
|
|
14
|
-
type: prismic.CustomTypeModelFieldType.Text
|
|
15
|
-
} : void 0
|
|
12
|
+
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
|
|
16
13
|
}
|
|
17
14
|
};
|
|
18
15
|
};
|
package/dist/model/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockLinkModel<AllowTargetBlank extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkField & {\n\t\tconfig: AllowTargetBlank extends true\n\t\t\t? {\n\t\t\t\t\tallowTargetBlank: true;\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tallowTargetBlank?: undefined;\n\t\t\t\t};\n\t};\n\nexport type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {\n\tallowTargetBlank?: AllowTargetBlank;\n} & MockModelConfig;\n\nexport const link = <AllowTargetBlank extends boolean = boolean>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank>,\n): MockLinkModel<AllowTargetBlank> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAsBa,MAAA,OAAO,CACnB,WACoC;AACpC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAM,QAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOA,YAAuB,MAAM,MAAM;AAAA,MAC1C,aAAaC,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ;AAAA,MACR,mBACE,sBAAsB,SACpB,OAAO,mBACP,MAAM,QAAc,MAAA;AAAA,IACxB;AAAA,EAAA;AAEH;"}
|
|
@@ -27,10 +27,7 @@ const linkToMedia = (config) => {
|
|
|
27
27
|
config: {
|
|
28
28
|
label: index.capitalCase(faker.word()),
|
|
29
29
|
placeholder: index.sentenceCase(faker.words(3)),
|
|
30
|
-
select: prismic__namespace.CustomTypeModelLinkSelectType.Media
|
|
31
|
-
text: config.text ? {
|
|
32
|
-
type: prismic__namespace.CustomTypeModelFieldType.Text
|
|
33
|
-
} : void 0
|
|
30
|
+
select: prismic__namespace.CustomTypeModelLinkSelectType.Media
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/model/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/model/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockLinkToMediaModelConfig = MockModelConfig;\n\nexport const linkToMedia = (\n\tconfig: MockLinkToMediaModelConfig,\n): prismic.CustomTypeModelLinkToMediaField => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Media,\n\t\t},\n\t};\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASa,MAAA,cAAc,CAC1B,WAC4C;AAC5C,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAMC,mBAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOC,MAAuB,YAAA,MAAM,MAAM;AAAA,MAC1C,aAAaC,MAAAA,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQF,mBAAQ,8BAA8B;AAAA,IAC9C;AAAA,EAAA;AAEH;;"}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { LinkText } from "./link";
|
|
3
2
|
import { MockModelConfig } from "../types";
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
text: LinkText;
|
|
7
|
-
} : {
|
|
8
|
-
text?: undefined;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {
|
|
12
|
-
text?: Text;
|
|
13
|
-
} & MockModelConfig;
|
|
14
|
-
export declare const linkToMedia: <Text extends boolean = boolean>(config: MockLinkToMediaModelConfig<Text>) => MockLinkToMediaModel<Text>;
|
|
15
|
-
export {};
|
|
3
|
+
export type MockLinkToMediaModelConfig = MockModelConfig;
|
|
4
|
+
export declare const linkToMedia: (config: MockLinkToMediaModelConfig) => prismic.CustomTypeModelLinkToMediaField;
|
|
@@ -8,10 +8,7 @@ const linkToMedia = (config) => {
|
|
|
8
8
|
config: {
|
|
9
9
|
label: capitalCase(faker.word()),
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
|
-
select: prismic.CustomTypeModelLinkSelectType.Media
|
|
12
|
-
text: config.text ? {
|
|
13
|
-
type: prismic.CustomTypeModelFieldType.Text
|
|
14
|
-
} : void 0
|
|
11
|
+
select: prismic.CustomTypeModelLinkSelectType.Media
|
|
15
12
|
}
|
|
16
13
|
};
|
|
17
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.js","sources":["../../../src/model/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport {
|
|
1
|
+
{"version":3,"file":"linkToMedia.js","sources":["../../../src/model/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type MockLinkToMediaModelConfig = MockModelConfig;\n\nexport const linkToMedia = (\n\tconfig: MockLinkToMediaModelConfig,\n): prismic.CustomTypeModelLinkToMediaField => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Media,\n\t\t},\n\t};\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AASa,MAAA,cAAc,CAC1B,WAC4C;AAC5C,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAM,QAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOA,YAAuB,MAAM,MAAM;AAAA,MAC1C,aAAaC,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ,QAAQ,8BAA8B;AAAA,IAC9C;AAAA,EAAA;AAEH;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const prismic = require("@prismicio/client");
|
|
4
|
-
const index = require('./../_node_modules/change-case/dist/index.cjs');
|
|
5
4
|
const buildContentRelationshipField = require("../lib/buildContentRelationshipField.cjs");
|
|
6
5
|
const createFaker = require("../lib/createFaker.cjs");
|
|
7
6
|
const generateCustomTypeId = require("../lib/generateCustomTypeId.cjs");
|
|
@@ -26,7 +25,7 @@ function _interopNamespaceDefault(e) {
|
|
|
26
25
|
}
|
|
27
26
|
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
28
27
|
const contentRelationship = (config) => {
|
|
29
|
-
var _a, _b
|
|
28
|
+
var _a, _b;
|
|
30
29
|
const faker = config.faker || createFaker.createFaker(config.seed);
|
|
31
30
|
if (config.state === "empty") {
|
|
32
31
|
return {
|
|
@@ -56,8 +55,7 @@ const contentRelationship = (config) => {
|
|
|
56
55
|
throw new Error("A linkable document could not be found.");
|
|
57
56
|
}
|
|
58
57
|
return buildContentRelationshipField.buildContentRelationshipField({
|
|
59
|
-
document
|
|
60
|
-
text: config.withText ?? ((_c = model.config) == null ? void 0 : _c.text) ? index.sentenceCase(faker.words(2)) : void 0
|
|
58
|
+
document
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentRelationship.cjs","sources":["../../../src/value/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"contentRelationship.cjs","sources":["../../../src/value/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { buildContentRelationshipField } from \"../lib/buildContentRelationshipField\";\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateCustomTypeId } from \"../lib/generateCustomTypeId\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport {\n\tMockValueStateConfig,\n\tMockValueConfig,\n\tIterableElement,\n} from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { document as documentGen } from \"./document\";\n\nexport type MockContentRelationshipValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: prismic.PrismicDocument[];\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockContentRelationshipValue<\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.ContentRelationshipField<\n\tIterableElement<NonNullable<Model[\"config\"]>[\"customtypes\"]>,\n\tstring,\n\tnever,\n\tState\n>;\n\nexport const contentRelationship = <\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockContentRelationshipValueConfig<Model, State>,\n): MockContentRelationshipValue<Model, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Document,\n\t\t} as MockContentRelationshipValue<Model, State>;\n\t} else {\n\t\tconst model = config.model || modelGen.contentRelationship({ faker });\n\n\t\tconst linkableDocuments = config.linkableDocuments\n\t\t\t? config.linkableDocuments.filter(\n\t\t\t\t\t(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t): document is prismic.PrismicDocument<\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tNonNullable<NonNullable<Model[\"config\"]>[\"customtypes\"]>[number]\n\t\t\t\t\t> => {\n\t\t\t\t\t\tlet shouldKeep = true;\n\n\t\t\t\t\t\tif (model.config?.customtypes) {\n\t\t\t\t\t\t\tshouldKeep =\n\t\t\t\t\t\t\t\tshouldKeep && model.config.customtypes.includes(document.type);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (model.config?.tags) {\n\t\t\t\t\t\t\tshouldKeep =\n\t\t\t\t\t\t\t\tshouldKeep &&\n\t\t\t\t\t\t\t\tmodel.config.tags.some((tag) => document.tags.includes(tag));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn shouldKeep;\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\t...documentGen({ faker }),\n\t\t\t\t\t\ttype: model.config?.customtypes\n\t\t\t\t\t\t\t? faker.randomElement(model.config.customtypes)\n\t\t\t\t\t\t\t: generateCustomTypeId({ faker }),\n\t\t\t\t\t\ttags: model.config?.tags\n\t\t\t\t\t\t\t? faker.randomElements(model.config.tags)\n\t\t\t\t\t\t\t: generateTags({ faker }),\n\t\t\t\t\t} as prismic.PrismicDocument<\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tNonNullable<NonNullable<Model[\"config\"]>[\"customtypes\"]>[number]\n\t\t\t\t\t>,\n\t\t\t\t];\n\n\t\tconst document = faker.randomElement(linkableDocuments);\n\n\t\tif (!document) {\n\t\t\tthrow new Error(\"A linkable document could not be found.\");\n\t\t}\n\n\t\treturn buildContentRelationshipField({\n\t\t\tdocument,\n\t\t}) as unknown as MockContentRelationshipValue<Model, State>;\n\t}\n};\n"],"names":["createFaker","prismic","modelGen.contentRelationship","document","_a","_b","documentGen","generateCustomTypeId","generateTags","buildContentRelationshipField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCa,MAAA,sBAAsB,CAKlC,WAC+C;;AAC/C,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAWC,mBAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACN,UAAM,QAAQ,OAAO,SAASC,sBAAAA,oBAA6B,EAAE,OAAO;AAEpE,UAAM,oBAAoB,OAAO,oBAC9B,OAAO,kBAAkB,OACzB,CACCC,cAIG;;AACH,UAAI,aAAa;AAEb,WAAAC,MAAA,MAAM,WAAN,gBAAAA,IAAc,aAAa;AAC9B,qBACC,cAAc,MAAM,OAAO,YAAY,SAASD,UAAS,IAAI;AAAA,MAC/D;AAEI,WAAAE,MAAA,MAAM,WAAN,gBAAAA,IAAc,MAAM;AAEtB,qBAAA,cACA,MAAM,OAAO,KAAK,KAAK,CAAC,QAAQF,UAAS,KAAK,SAAS,GAAG,CAAC;AAAA,MAC7D;AAEO,aAAA;AAAA,IAAA,CACP,IAED;AAAA,MACA;AAAA,QACC,GAAGG,WAAA,WAAY,EAAE,OAAO;AAAA,QACxB,QAAM,WAAM,WAAN,mBAAc,eACjB,MAAM,cAAc,MAAM,OAAO,WAAW,IAC5CC,0CAAqB,EAAE,OAAO;AAAA,QACjC,QAAM,WAAM,WAAN,mBAAc,QACjB,MAAM,eAAe,MAAM,OAAO,IAAI,IACtCC,0BAAa,EAAE,OAAO;AAAA,MAIzB;AAAA,IAAA;AAGE,UAAA,WAAW,MAAM,cAAc,iBAAiB;AAEtD,QAAI,CAAC,UAAU;AACR,YAAA,IAAI,MAAM,yCAAyC;AAAA,IAC1D;AAEA,WAAOC,4DAA8B;AAAA,MACpC;AAAA,IAAA,CACA;AAAA,EACF;AACD;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockValueStateConfig, MockValueConfig, IterableElement } from "../types";
|
|
3
3
|
export type MockContentRelationshipValueConfig<Model extends prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField, State extends prismic.FieldState = prismic.FieldState> = {
|
|
4
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
|
|
5
4
|
/**
|
|
6
5
|
* A list of potential documents to which the field can be linked.
|
|
7
6
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { sentenceCase } from './../_node_modules/change-case/dist/index.js';
|
|
3
2
|
import { buildContentRelationshipField } from "../lib/buildContentRelationshipField.js";
|
|
4
3
|
import { createFaker } from "../lib/createFaker.js";
|
|
5
4
|
import { generateCustomTypeId } from "../lib/generateCustomTypeId.js";
|
|
@@ -7,7 +6,7 @@ import { generateTags } from "../lib/generateTags.js";
|
|
|
7
6
|
import { customType } from "./customType.js";
|
|
8
7
|
import { contentRelationship as contentRelationship$1 } from "../model/contentRelationship.js";
|
|
9
8
|
const contentRelationship = (config) => {
|
|
10
|
-
var _a, _b
|
|
9
|
+
var _a, _b;
|
|
11
10
|
const faker = config.faker || createFaker(config.seed);
|
|
12
11
|
if (config.state === "empty") {
|
|
13
12
|
return {
|
|
@@ -37,8 +36,7 @@ const contentRelationship = (config) => {
|
|
|
37
36
|
throw new Error("A linkable document could not be found.");
|
|
38
37
|
}
|
|
39
38
|
return buildContentRelationshipField({
|
|
40
|
-
document
|
|
41
|
-
text: config.withText ?? ((_c = model.config) == null ? void 0 : _c.text) ? sentenceCase(faker.words(2)) : void 0
|
|
39
|
+
document
|
|
42
40
|
});
|
|
43
41
|
}
|
|
44
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentRelationship.js","sources":["../../../src/value/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"contentRelationship.js","sources":["../../../src/value/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { buildContentRelationshipField } from \"../lib/buildContentRelationshipField\";\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateCustomTypeId } from \"../lib/generateCustomTypeId\";\nimport { generateTags } from \"../lib/generateTags\";\n\nimport {\n\tMockValueStateConfig,\n\tMockValueConfig,\n\tIterableElement,\n} from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { document as documentGen } from \"./document\";\n\nexport type MockContentRelationshipValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: prismic.PrismicDocument[];\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockContentRelationshipValue<\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.ContentRelationshipField<\n\tIterableElement<NonNullable<Model[\"config\"]>[\"customtypes\"]>,\n\tstring,\n\tnever,\n\tState\n>;\n\nexport const contentRelationship = <\n\tModel extends\n\t\tprismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockContentRelationshipValueConfig<Model, State>,\n): MockContentRelationshipValue<Model, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Document,\n\t\t} as MockContentRelationshipValue<Model, State>;\n\t} else {\n\t\tconst model = config.model || modelGen.contentRelationship({ faker });\n\n\t\tconst linkableDocuments = config.linkableDocuments\n\t\t\t? config.linkableDocuments.filter(\n\t\t\t\t\t(\n\t\t\t\t\t\tdocument,\n\t\t\t\t\t): document is prismic.PrismicDocument<\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tNonNullable<NonNullable<Model[\"config\"]>[\"customtypes\"]>[number]\n\t\t\t\t\t> => {\n\t\t\t\t\t\tlet shouldKeep = true;\n\n\t\t\t\t\t\tif (model.config?.customtypes) {\n\t\t\t\t\t\t\tshouldKeep =\n\t\t\t\t\t\t\t\tshouldKeep && model.config.customtypes.includes(document.type);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (model.config?.tags) {\n\t\t\t\t\t\t\tshouldKeep =\n\t\t\t\t\t\t\t\tshouldKeep &&\n\t\t\t\t\t\t\t\tmodel.config.tags.some((tag) => document.tags.includes(tag));\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn shouldKeep;\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t: [\n\t\t\t\t\t{\n\t\t\t\t\t\t...documentGen({ faker }),\n\t\t\t\t\t\ttype: model.config?.customtypes\n\t\t\t\t\t\t\t? faker.randomElement(model.config.customtypes)\n\t\t\t\t\t\t\t: generateCustomTypeId({ faker }),\n\t\t\t\t\t\ttags: model.config?.tags\n\t\t\t\t\t\t\t? faker.randomElements(model.config.tags)\n\t\t\t\t\t\t\t: generateTags({ faker }),\n\t\t\t\t\t} as prismic.PrismicDocument<\n\t\t\t\t\t\tnever,\n\t\t\t\t\t\tNonNullable<NonNullable<Model[\"config\"]>[\"customtypes\"]>[number]\n\t\t\t\t\t>,\n\t\t\t\t];\n\n\t\tconst document = faker.randomElement(linkableDocuments);\n\n\t\tif (!document) {\n\t\t\tthrow new Error(\"A linkable document could not be found.\");\n\t\t}\n\n\t\treturn buildContentRelationshipField({\n\t\t\tdocument,\n\t\t}) as unknown as MockContentRelationshipValue<Model, State>;\n\t}\n};\n"],"names":["modelGen.contentRelationship","document","_a","_b","documentGen"],"mappings":";;;;;;;AAwCa,MAAA,sBAAsB,CAKlC,WAC+C;;AAC/C,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACN,UAAM,QAAQ,OAAO,SAASA,sBAA6B,EAAE,OAAO;AAEpE,UAAM,oBAAoB,OAAO,oBAC9B,OAAO,kBAAkB,OACzB,CACCC,cAIG;;AACH,UAAI,aAAa;AAEb,WAAAC,MAAA,MAAM,WAAN,gBAAAA,IAAc,aAAa;AAC9B,qBACC,cAAc,MAAM,OAAO,YAAY,SAASD,UAAS,IAAI;AAAA,MAC/D;AAEI,WAAAE,MAAA,MAAM,WAAN,gBAAAA,IAAc,MAAM;AAEtB,qBAAA,cACA,MAAM,OAAO,KAAK,KAAK,CAAC,QAAQF,UAAS,KAAK,SAAS,GAAG,CAAC;AAAA,MAC7D;AAEO,aAAA;AAAA,IAAA,CACP,IAED;AAAA,MACA;AAAA,QACC,GAAGG,WAAY,EAAE,OAAO;AAAA,QACxB,QAAM,WAAM,WAAN,mBAAc,eACjB,MAAM,cAAc,MAAM,OAAO,WAAW,IAC5C,qBAAqB,EAAE,OAAO;AAAA,QACjC,QAAM,WAAM,WAAN,mBAAc,QACjB,MAAM,eAAe,MAAM,OAAO,IAAI,IACtC,aAAa,EAAE,OAAO;AAAA,MAIzB;AAAA,IAAA;AAGE,UAAA,WAAW,MAAM,cAAc,iBAAiB;AAEtD,QAAI,CAAC,UAAU;AACR,YAAA,IAAI,MAAM,yCAAyC;AAAA,IAC1D;AAEA,WAAO,8BAA8B;AAAA,MACpC;AAAA,IAAA,CACA;AAAA,EACF;AACD;"}
|
package/dist/value/link.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const prismic = require("@prismicio/client");
|
|
4
|
-
const index = require('./../_node_modules/change-case/dist/index.cjs');
|
|
5
4
|
const createFaker = require("../lib/createFaker.cjs");
|
|
6
5
|
const contentRelationship = require("./contentRelationship.cjs");
|
|
7
6
|
const linkToMedia = require("./linkToMedia.cjs");
|
|
@@ -24,7 +23,7 @@ function _interopNamespaceDefault(e) {
|
|
|
24
23
|
}
|
|
25
24
|
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
26
25
|
const link = (config) => {
|
|
27
|
-
var _a
|
|
26
|
+
var _a;
|
|
28
27
|
const faker = config.faker || createFaker.createFaker(config.seed);
|
|
29
28
|
const type = config.type || faker.randomElement([
|
|
30
29
|
prismic__namespace.LinkType.Web,
|
|
@@ -56,8 +55,7 @@ const link = (config) => {
|
|
|
56
55
|
return {
|
|
57
56
|
link_type: prismic__namespace.LinkType.Web,
|
|
58
57
|
url: faker.url(),
|
|
59
|
-
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
60
|
-
text: config.withText ?? ((_b = model.config) == null ? void 0 : _b.text) ? index.sentenceCase(faker.words(2)) : void 0
|
|
58
|
+
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
61
59
|
};
|
|
62
60
|
}
|
|
63
61
|
}
|
package/dist/value/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { contentRelationship } from \"./contentRelationship\";\nimport { linkToMedia } from \"./linkToMedia\";\n\nexport type MockLinkValueConfig<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\ttype?: LinkType;\n\twithTargetBlank?: NonNullable<\n\t\tModel[\"config\"]\n\t>[\"allowTargetBlank\"] extends undefined\n\t\t? false\n\t\t: boolean;\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: LinkType extends typeof prismic.LinkType.Document\n\t\t? prismic.PrismicDocument[]\n\t\t: never;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockLinkValue<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tState extends prismic.FieldState = \"filled\",\n> = State extends \"empty\"\n\t? prismic.EmptyLinkField<LinkType>\n\t: LinkType extends typeof prismic.LinkType.Web\n\t\t? prismic.FilledLinkToWebField\n\t\t: LinkType extends typeof prismic.LinkType.Media\n\t\t\t? prismic.FilledLinkToMediaField\n\t\t\t: LinkType extends typeof prismic.LinkType.Document\n\t\t\t\t? prismic.FilledContentRelationshipField\n\t\t\t\t: never;\n\nexport const link = <\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkValueConfig<LinkType, Model, State>,\n): MockLinkValue<LinkType, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst type =\n\t\tconfig.type ||\n\t\tfaker.randomElement([\n\t\t\tprismic.LinkType.Web,\n\t\t\tprismic.LinkType.Document,\n\t\t\tprismic.LinkType.Media,\n\t\t]);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: type,\n\t\t} as MockLinkValue<LinkType, State>;\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase prismic.LinkType.Document: {\n\t\t\t\treturn contentRelationship({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t\tlinkableDocuments: config.linkableDocuments,\n\t\t\t\t}) as unknown as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Media: {\n\t\t\t\treturn linkToMedia({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t}) as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Web:\n\t\t\tdefault: {\n\t\t\t\tconst model = config.model || modelGen.link({ faker });\n\n\t\t\t\treturn {\n\t\t\t\t\tlink_type: prismic.LinkType.Web,\n\t\t\t\t\turl: faker.url(),\n\t\t\t\t\ttarget:\n\t\t\t\t\t\tconfig.withTargetBlank ??\n\t\t\t\t\t\t(model.config?.allowTargetBlank && faker.boolean())\n\t\t\t\t\t\t\t? \"_blank\"\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} as MockLinkValue<LinkType, State>;\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["createFaker","prismic","contentRelationship","linkToMedia","modelGen.link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+Ca,MAAA,OAAO,CAOnB,WACmC;;AACnC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,OACL,OAAO,QACP,MAAM,cAAc;AAAA,IACnBC,mBAAQ,SAAS;AAAA,IACjBA,mBAAQ,SAAS;AAAA,IACjBA,mBAAQ,SAAS;AAAA,EAAA,CACjB;AAEE,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,YAAQ,MAAM;AAAA,MACb,KAAKA,mBAAQ,SAAS,UAAU;AAC/B,eAAOC,wCAAoB;AAAA,UAC1B;AAAA,UACA,OAAO,OAAO;AAAA,UACd,mBAAmB,OAAO;AAAA,QAAA,CAC1B;AAAA,MACF;AAAA,MAEA,KAAKD,mBAAQ,SAAS,OAAO;AAC5B,eAAOE,wBAAY;AAAA,UAClB;AAAA,UACA,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEA,KAAKF,mBAAQ,SAAS;AAAA,MACtB,SAAS;AACR,cAAM,QAAQ,OAAO,SAASG,OAAAA,KAAc,EAAE,OAAO;AAE9C,eAAA;AAAA,UACN,WAAWH,mBAAQ,SAAS;AAAA,UAC5B,KAAK,MAAM,IAAK;AAAA,UAChB,QACC,OAAO,sBACN,WAAM,WAAN,mBAAc,qBAAoB,MAAM,QAAO,KAC7C,WACA;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;;"}
|
package/dist/value/link.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
|
3
3
|
export type MockLinkValueConfig<LinkType extends (typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType], Model extends prismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField, State extends prismic.FieldState = prismic.FieldState> = {
|
|
4
4
|
type?: LinkType;
|
|
5
5
|
withTargetBlank?: NonNullable<Model["config"]>["allowTargetBlank"] extends undefined ? false : boolean;
|
|
6
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
|
|
7
6
|
/**
|
|
8
7
|
* A list of potential documents to which the field can be linked.
|
|
9
8
|
*/
|
package/dist/value/link.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { sentenceCase } from './../_node_modules/change-case/dist/index.js';
|
|
3
2
|
import { createFaker } from "../lib/createFaker.js";
|
|
4
3
|
import { contentRelationship } from "./contentRelationship.js";
|
|
5
4
|
import { linkToMedia } from "./linkToMedia.js";
|
|
6
5
|
import { link as link$1 } from "../model/link.js";
|
|
7
6
|
const link = (config) => {
|
|
8
|
-
var _a
|
|
7
|
+
var _a;
|
|
9
8
|
const faker = config.faker || createFaker(config.seed);
|
|
10
9
|
const type = config.type || faker.randomElement([
|
|
11
10
|
prismic.LinkType.Web,
|
|
@@ -37,8 +36,7 @@ const link = (config) => {
|
|
|
37
36
|
return {
|
|
38
37
|
link_type: prismic.LinkType.Web,
|
|
39
38
|
url: faker.url(),
|
|
40
|
-
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
41
|
-
text: config.withText ?? ((_b = model.config) == null ? void 0 : _b.text) ? sentenceCase(faker.words(2)) : void 0
|
|
39
|
+
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
42
40
|
};
|
|
43
41
|
}
|
|
44
42
|
}
|
package/dist/value/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { contentRelationship } from \"./contentRelationship\";\nimport { linkToMedia } from \"./linkToMedia\";\n\nexport type MockLinkValueConfig<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\ttype?: LinkType;\n\twithTargetBlank?: NonNullable<\n\t\tModel[\"config\"]\n\t>[\"allowTargetBlank\"] extends undefined\n\t\t? false\n\t\t: boolean;\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: LinkType extends typeof prismic.LinkType.Document\n\t\t? prismic.PrismicDocument[]\n\t\t: never;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockLinkValue<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tState extends prismic.FieldState = \"filled\",\n> = State extends \"empty\"\n\t? prismic.EmptyLinkField<LinkType>\n\t: LinkType extends typeof prismic.LinkType.Web\n\t\t? prismic.FilledLinkToWebField\n\t\t: LinkType extends typeof prismic.LinkType.Media\n\t\t\t? prismic.FilledLinkToMediaField\n\t\t\t: LinkType extends typeof prismic.LinkType.Document\n\t\t\t\t? prismic.FilledContentRelationshipField\n\t\t\t\t: never;\n\nexport const link = <\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkValueConfig<LinkType, Model, State>,\n): MockLinkValue<LinkType, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst type =\n\t\tconfig.type ||\n\t\tfaker.randomElement([\n\t\t\tprismic.LinkType.Web,\n\t\t\tprismic.LinkType.Document,\n\t\t\tprismic.LinkType.Media,\n\t\t]);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: type,\n\t\t} as MockLinkValue<LinkType, State>;\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase prismic.LinkType.Document: {\n\t\t\t\treturn contentRelationship({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t\tlinkableDocuments: config.linkableDocuments,\n\t\t\t\t}) as unknown as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Media: {\n\t\t\t\treturn linkToMedia({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t}) as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Web:\n\t\t\tdefault: {\n\t\t\t\tconst model = config.model || modelGen.link({ faker });\n\n\t\t\t\treturn {\n\t\t\t\t\tlink_type: prismic.LinkType.Web,\n\t\t\t\t\turl: faker.url(),\n\t\t\t\t\ttarget:\n\t\t\t\t\t\tconfig.withTargetBlank ??\n\t\t\t\t\t\t(model.config?.allowTargetBlank && faker.boolean())\n\t\t\t\t\t\t\t? \"_blank\"\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} as MockLinkValue<LinkType, State>;\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["modelGen.link"],"mappings":";;;;;AA+Ca,MAAA,OAAO,CAOnB,WACmC;;AACnC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,OACL,OAAO,QACP,MAAM,cAAc;AAAA,IACnB,QAAQ,SAAS;AAAA,IACjB,QAAQ,SAAS;AAAA,IACjB,QAAQ,SAAS;AAAA,EAAA,CACjB;AAEE,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,YAAQ,MAAM;AAAA,MACb,KAAK,QAAQ,SAAS,UAAU;AAC/B,eAAO,oBAAoB;AAAA,UAC1B;AAAA,UACA,OAAO,OAAO;AAAA,UACd,mBAAmB,OAAO;AAAA,QAAA,CAC1B;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ,SAAS,OAAO;AAC5B,eAAO,YAAY;AAAA,UAClB;AAAA,UACA,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ,SAAS;AAAA,MACtB,SAAS;AACR,cAAM,QAAQ,OAAO,SAASA,OAAc,EAAE,OAAO;AAE9C,eAAA;AAAA,UACN,WAAW,QAAQ,SAAS;AAAA,UAC5B,KAAK,MAAM,IAAK;AAAA,UAChB,QACC,OAAO,sBACN,WAAM,WAAN,mBAAc,qBAAoB,MAAM,QAAO,KAC7C,WACA;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const prismic = require("@prismicio/client");
|
|
4
4
|
const index = require('./../_node_modules/change-case/dist/index.cjs');
|
|
5
5
|
const createFaker = require("../lib/createFaker.cjs");
|
|
6
|
-
const link = require("../model/link.cjs");
|
|
7
6
|
function _interopNamespaceDefault(e) {
|
|
8
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
8
|
if (e) {
|
|
@@ -22,23 +21,21 @@ function _interopNamespaceDefault(e) {
|
|
|
22
21
|
}
|
|
23
22
|
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
24
23
|
const linkToMedia = (config) => {
|
|
25
|
-
var _a;
|
|
26
24
|
const faker = config.faker || createFaker.createFaker(config.seed);
|
|
27
25
|
if (config.state === "empty") {
|
|
28
26
|
return {
|
|
29
27
|
link_type: prismic__namespace.LinkType.Media
|
|
30
28
|
};
|
|
31
29
|
} else {
|
|
32
|
-
const model = config.model || link.link({ faker });
|
|
33
30
|
return {
|
|
34
31
|
link_type: prismic__namespace.LinkType.Media,
|
|
32
|
+
id: faker.hash(11),
|
|
35
33
|
name: `${index.snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
36
34
|
kind: index.snakeCase(faker.word()),
|
|
37
35
|
url: faker.url(),
|
|
38
36
|
size: faker.range(500, 3e3).toString(),
|
|
39
37
|
height: faker.range(500, 3e3).toString(),
|
|
40
|
-
width: faker.range(500, 3e3).toString()
|
|
41
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.text) ? index.sentenceCase(faker.words(2)) : void 0
|
|
38
|
+
width: faker.range(500, 3e3).toString()
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\
|
|
1
|
+
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = MockValueConfig<Model> & MockValueStateConfig<State>;\n\ntype MockLinkToMediaValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.LinkToMediaField<State>;\n\nexport const linkToMedia = <\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkToMediaValueConfig<Model, State>,\n): MockLinkToMediaValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t} as MockLinkToMediaValue<State>;\n\t} else {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t\tid: faker.hash(11),\n\t\t\tname: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: changeCase.snakeCase(faker.word()),\n\t\t\turl: faker.url(),\n\t\t\tsize: faker.range(500, 3000).toString(),\n\t\t\theight: faker.range(500, 3000).toString(),\n\t\t\twidth: faker.range(500, 3000).toString(),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["createFaker","prismic","changeCase.snakeCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBa,MAAA,cAAc,CAK1B,WACgC;AAChC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAWC,mBAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACC,WAAA;AAAA,MACN,WAAWA,mBAAQ,SAAS;AAAA,MAC5B,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAGC,gBAAqB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAC7D,MAAMA,MAAqB,UAAA,MAAM,MAAM;AAAA,MACvC,KAAK,MAAM,IAAK;AAAA,MAChB,MAAM,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACvC,QAAQ,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACzC,OAAO,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,IAAA;AAAA,EAE1C;AACD;;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
3
|
-
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> =
|
|
4
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
|
|
5
|
-
} & MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
3
|
+
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> = MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
6
4
|
type MockLinkToMediaValue<State extends prismic.FieldState = prismic.FieldState> = prismic.LinkToMediaField<State>;
|
|
7
5
|
export declare const linkToMedia: <Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = "filled">(config: MockLinkToMediaValueConfig<Model, State>) => MockLinkToMediaValue<State>;
|
|
8
6
|
export {};
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { snakeCase
|
|
2
|
+
import { snakeCase } from './../_node_modules/change-case/dist/index.js';
|
|
3
3
|
import { createFaker } from "../lib/createFaker.js";
|
|
4
|
-
import { link } from "../model/link.js";
|
|
5
4
|
const linkToMedia = (config) => {
|
|
6
|
-
var _a;
|
|
7
5
|
const faker = config.faker || createFaker(config.seed);
|
|
8
6
|
if (config.state === "empty") {
|
|
9
7
|
return {
|
|
10
8
|
link_type: prismic.LinkType.Media
|
|
11
9
|
};
|
|
12
10
|
} else {
|
|
13
|
-
const model = config.model || link({ faker });
|
|
14
11
|
return {
|
|
15
12
|
link_type: prismic.LinkType.Media,
|
|
13
|
+
id: faker.hash(11),
|
|
16
14
|
name: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
17
15
|
kind: snakeCase(faker.word()),
|
|
18
16
|
url: faker.url(),
|
|
19
17
|
size: faker.range(500, 3e3).toString(),
|
|
20
18
|
height: faker.range(500, 3e3).toString(),
|
|
21
|
-
width: faker.range(500, 3e3).toString()
|
|
22
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.text) ? sentenceCase(faker.words(2)) : void 0
|
|
19
|
+
width: faker.range(500, 3e3).toString()
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\
|
|
1
|
+
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = MockValueConfig<Model> & MockValueStateConfig<State>;\n\ntype MockLinkToMediaValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.LinkToMediaField<State>;\n\nexport const linkToMedia = <\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkToMediaValueConfig<Model, State>,\n): MockLinkToMediaValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t} as MockLinkToMediaValue<State>;\n\t} else {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t\tid: faker.hash(11),\n\t\t\tname: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: changeCase.snakeCase(faker.word()),\n\t\t\turl: faker.url(),\n\t\t\tsize: faker.range(500, 3000).toString(),\n\t\t\theight: faker.range(500, 3000).toString(),\n\t\t\twidth: faker.range(500, 3000).toString(),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["changeCase.snakeCase"],"mappings":";;;AAiBa,MAAA,cAAc,CAK1B,WACgC;AAChC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACC,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,MAC5B,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAGA,UAAqB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAC7D,MAAMA,UAAqB,MAAM,MAAM;AAAA,MACvC,KAAK,MAAM,IAAK;AAAA,MAChB,MAAM,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACvC,QAAQ,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACzC,OAAO,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,IAAA;AAAA,EAE1C;AACD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/mock",
|
|
3
|
-
"version": "0.3.8
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -55,15 +55,13 @@
|
|
|
55
55
|
"size": "size-limit",
|
|
56
56
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
|
57
57
|
"types": "tsc --noEmit",
|
|
58
|
-
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
59
|
-
"unit:watch": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava --watch",
|
|
60
|
-
"unit:update-1": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava --update-snapshots --match='creates mock field models for group field'"
|
|
58
|
+
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
61
59
|
},
|
|
62
60
|
"dependencies": {
|
|
63
61
|
"change-case": "^5.4.4"
|
|
64
62
|
},
|
|
65
63
|
"devDependencies": {
|
|
66
|
-
"@prismicio/client": "^7.
|
|
64
|
+
"@prismicio/client": "^7.8.1",
|
|
67
65
|
"@size-limit/preset-small-lib": "^11.1.2",
|
|
68
66
|
"@types/node": "^20.12.7",
|
|
69
67
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
package/src/api/repository.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
Document extends prismic.PrismicDocument,
|
|
5
|
-
> = {
|
|
3
|
+
type BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {
|
|
6
4
|
document: Document;
|
|
7
|
-
text?: string;
|
|
8
5
|
};
|
|
9
6
|
|
|
10
7
|
export const buildContentRelationshipField = <
|
|
11
8
|
Document extends prismic.PrismicDocument,
|
|
12
9
|
>(
|
|
13
|
-
config:
|
|
10
|
+
config: BuildEmbedFieldConfig<Document>,
|
|
14
11
|
): prismic.ContentRelationshipField<
|
|
15
12
|
Document["type"],
|
|
16
13
|
Document["lang"],
|
|
@@ -27,6 +24,5 @@ export const buildContentRelationshipField = <
|
|
|
27
24
|
url: config.document.url || undefined,
|
|
28
25
|
slug: config.document.slugs[0],
|
|
29
26
|
isBroken: false,
|
|
30
|
-
text: config.text,
|
|
31
27
|
};
|
|
32
28
|
};
|
|
@@ -31,6 +31,7 @@ export const buildImageFieldImage = <
|
|
|
31
31
|
): prismic.ImageFieldImage<State> => {
|
|
32
32
|
if (config.state === "empty") {
|
|
33
33
|
return {
|
|
34
|
+
id: null,
|
|
34
35
|
url: null,
|
|
35
36
|
dimensions: null,
|
|
36
37
|
alt: null,
|
|
@@ -51,6 +52,7 @@ export const buildImageFieldImage = <
|
|
|
51
52
|
url.searchParams.set("fit", "crop");
|
|
52
53
|
|
|
53
54
|
return {
|
|
55
|
+
id: faker.hash(11),
|
|
54
56
|
url: url.toString(),
|
|
55
57
|
dimensions,
|
|
56
58
|
alt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),
|
|
@@ -3,40 +3,22 @@ import * as changeCase from "change-case";
|
|
|
3
3
|
|
|
4
4
|
import { createFaker } from "../lib/createFaker";
|
|
5
5
|
|
|
6
|
-
import { LinkText } from "./link";
|
|
7
6
|
import { MockModelConfig } from "../types";
|
|
8
7
|
|
|
9
|
-
type MockContentRelationshipModel<
|
|
10
|
-
CustomTypeIDs extends string = string,
|
|
11
|
-
Tags extends string = string,
|
|
12
|
-
Text extends boolean = boolean,
|
|
13
|
-
> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
|
|
14
|
-
config: Text extends true
|
|
15
|
-
? {
|
|
16
|
-
text: LinkText;
|
|
17
|
-
}
|
|
18
|
-
: {
|
|
19
|
-
text?: undefined;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
|
|
23
8
|
export type MockContentRelationshipModelConfig<
|
|
24
9
|
CustomTypeIDs extends string = string,
|
|
25
10
|
Tags extends string = string,
|
|
26
|
-
Text extends boolean = boolean,
|
|
27
11
|
> = {
|
|
28
12
|
customTypeIDs?: readonly CustomTypeIDs[];
|
|
29
13
|
tags?: readonly Tags[];
|
|
30
|
-
text?: Text;
|
|
31
14
|
} & MockModelConfig;
|
|
32
15
|
|
|
33
16
|
export const contentRelationship = <
|
|
34
17
|
CustomTypeIDs extends string,
|
|
35
18
|
Tags extends string,
|
|
36
|
-
Text extends boolean = boolean,
|
|
37
19
|
>(
|
|
38
|
-
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags
|
|
39
|
-
):
|
|
20
|
+
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,
|
|
21
|
+
): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {
|
|
40
22
|
const faker = config.faker || createFaker(config.seed);
|
|
41
23
|
|
|
42
24
|
return {
|
|
@@ -47,11 +29,6 @@ export const contentRelationship = <
|
|
|
47
29
|
select: prismic.CustomTypeModelLinkSelectType.Document,
|
|
48
30
|
customtypes: config.customTypeIDs,
|
|
49
31
|
tags: config.tags,
|
|
50
|
-
text: config.text
|
|
51
|
-
? {
|
|
52
|
-
type: prismic.CustomTypeModelFieldType.Text,
|
|
53
|
-
}
|
|
54
|
-
: undefined,
|
|
55
32
|
},
|
|
56
|
-
}
|
|
33
|
+
};
|
|
57
34
|
};
|
package/src/model/link.ts
CHANGED
|
@@ -5,43 +5,24 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type MockLinkModel<AllowTargetBlank extends boolean = boolean> =
|
|
9
|
+
prismic.CustomTypeModelLinkField & {
|
|
10
|
+
config: AllowTargetBlank extends true
|
|
11
|
+
? {
|
|
12
|
+
allowTargetBlank: true;
|
|
13
|
+
}
|
|
14
|
+
: {
|
|
15
|
+
allowTargetBlank?: undefined;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
9
18
|
|
|
10
|
-
type
|
|
11
|
-
AllowTargetBlank extends boolean = boolean,
|
|
12
|
-
Text extends boolean = boolean,
|
|
13
|
-
> = prismic.CustomTypeModelLinkField & {
|
|
14
|
-
config: AllowTargetBlank extends true
|
|
15
|
-
? {
|
|
16
|
-
allowTargetBlank: true;
|
|
17
|
-
}
|
|
18
|
-
: {
|
|
19
|
-
allowTargetBlank?: undefined;
|
|
20
|
-
};
|
|
21
|
-
} & {
|
|
22
|
-
config: Text extends true
|
|
23
|
-
? {
|
|
24
|
-
text: LinkText;
|
|
25
|
-
}
|
|
26
|
-
: {
|
|
27
|
-
text?: undefined;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type MockLinkModelConfig<
|
|
32
|
-
AllowTargetBlank extends boolean = boolean,
|
|
33
|
-
Text extends boolean = boolean,
|
|
34
|
-
> = {
|
|
19
|
+
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
|
|
35
20
|
allowTargetBlank?: AllowTargetBlank;
|
|
36
|
-
text?: Text;
|
|
37
21
|
} & MockModelConfig;
|
|
38
22
|
|
|
39
|
-
export const link = <
|
|
40
|
-
AllowTargetBlank
|
|
41
|
-
|
|
42
|
-
>(
|
|
43
|
-
config: MockLinkModelConfig<AllowTargetBlank, Text>,
|
|
44
|
-
): MockLinkModel<AllowTargetBlank, Text> => {
|
|
23
|
+
export const link = <AllowTargetBlank extends boolean = boolean>(
|
|
24
|
+
config: MockLinkModelConfig<AllowTargetBlank>,
|
|
25
|
+
): MockLinkModel<AllowTargetBlank> => {
|
|
45
26
|
const faker = config.faker || createFaker(config.seed);
|
|
46
27
|
|
|
47
28
|
return {
|
|
@@ -54,11 +35,6 @@ export const link = <
|
|
|
54
35
|
("allowTargetBlank" in config
|
|
55
36
|
? config.allowTargetBlank
|
|
56
37
|
: faker.boolean()) || undefined,
|
|
57
|
-
text: config.text
|
|
58
|
-
? {
|
|
59
|
-
type: prismic.CustomTypeModelFieldType.Text,
|
|
60
|
-
}
|
|
61
|
-
: undefined,
|
|
62
38
|
},
|
|
63
|
-
} as MockLinkModel<AllowTargetBlank
|
|
39
|
+
} as MockLinkModel<AllowTargetBlank>;
|
|
64
40
|
};
|
package/src/model/linkToMedia.ts
CHANGED
|
@@ -3,27 +3,13 @@ import * as changeCase from "change-case";
|
|
|
3
3
|
|
|
4
4
|
import { createFaker } from "../lib/createFaker";
|
|
5
5
|
|
|
6
|
-
import { LinkText } from "./link";
|
|
7
6
|
import { MockModelConfig } from "../types";
|
|
8
7
|
|
|
9
|
-
type
|
|
10
|
-
prismic.CustomTypeModelLinkToMediaField & {
|
|
11
|
-
config: Text extends true
|
|
12
|
-
? {
|
|
13
|
-
text: LinkText;
|
|
14
|
-
}
|
|
15
|
-
: {
|
|
16
|
-
text?: undefined;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {
|
|
21
|
-
text?: Text;
|
|
22
|
-
} & MockModelConfig;
|
|
8
|
+
export type MockLinkToMediaModelConfig = MockModelConfig;
|
|
23
9
|
|
|
24
|
-
export const linkToMedia =
|
|
25
|
-
config: MockLinkToMediaModelConfig
|
|
26
|
-
):
|
|
10
|
+
export const linkToMedia = (
|
|
11
|
+
config: MockLinkToMediaModelConfig,
|
|
12
|
+
): prismic.CustomTypeModelLinkToMediaField => {
|
|
27
13
|
const faker = config.faker || createFaker(config.seed);
|
|
28
14
|
|
|
29
15
|
return {
|
|
@@ -32,11 +18,6 @@ export const linkToMedia = <Text extends boolean = boolean>(
|
|
|
32
18
|
label: changeCase.capitalCase(faker.word()),
|
|
33
19
|
placeholder: changeCase.sentenceCase(faker.words(3)),
|
|
34
20
|
select: prismic.CustomTypeModelLinkSelectType.Media,
|
|
35
|
-
text: config.text
|
|
36
|
-
? {
|
|
37
|
-
type: prismic.CustomTypeModelFieldType.Text,
|
|
38
|
-
}
|
|
39
|
-
: undefined,
|
|
40
21
|
},
|
|
41
|
-
}
|
|
22
|
+
};
|
|
42
23
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import * as changeCase from "change-case";
|
|
3
2
|
|
|
4
3
|
import { buildContentRelationshipField } from "../lib/buildContentRelationshipField";
|
|
5
4
|
import { createFaker } from "../lib/createFaker";
|
|
@@ -21,9 +20,6 @@ export type MockContentRelationshipValueConfig<
|
|
|
21
20
|
prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,
|
|
22
21
|
State extends prismic.FieldState = prismic.FieldState,
|
|
23
22
|
> = {
|
|
24
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
25
|
-
? false
|
|
26
|
-
: boolean;
|
|
27
23
|
/**
|
|
28
24
|
* A list of potential documents to which the field can be linked.
|
|
29
25
|
*/
|
|
@@ -105,10 +101,6 @@ export const contentRelationship = <
|
|
|
105
101
|
|
|
106
102
|
return buildContentRelationshipField({
|
|
107
103
|
document,
|
|
108
|
-
text:
|
|
109
|
-
config.withText ?? model.config?.text
|
|
110
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
111
|
-
: undefined,
|
|
112
104
|
}) as unknown as MockContentRelationshipValue<Model, State>;
|
|
113
105
|
}
|
|
114
106
|
};
|
package/src/value/link.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import * as changeCase from "change-case";
|
|
3
2
|
|
|
4
3
|
import { createFaker } from "../lib/createFaker";
|
|
5
4
|
|
|
@@ -23,9 +22,6 @@ export type MockLinkValueConfig<
|
|
|
23
22
|
>["allowTargetBlank"] extends undefined
|
|
24
23
|
? false
|
|
25
24
|
: boolean;
|
|
26
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
27
|
-
? false
|
|
28
|
-
: boolean;
|
|
29
25
|
/**
|
|
30
26
|
* A list of potential documents to which the field can be linked.
|
|
31
27
|
*/
|
|
@@ -101,10 +97,6 @@ export const link = <
|
|
|
101
97
|
(model.config?.allowTargetBlank && faker.boolean())
|
|
102
98
|
? "_blank"
|
|
103
99
|
: undefined,
|
|
104
|
-
text:
|
|
105
|
-
config.withText ?? model.config?.text
|
|
106
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
107
|
-
: undefined,
|
|
108
100
|
} as MockLinkValue<LinkType, State>;
|
|
109
101
|
}
|
|
110
102
|
}
|
package/src/value/linkToMedia.ts
CHANGED
|
@@ -5,18 +5,11 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
import * as modelGen from "../model";
|
|
9
|
-
|
|
10
8
|
export type MockLinkToMediaValueConfig<
|
|
11
9
|
Model extends
|
|
12
10
|
prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,
|
|
13
11
|
State extends prismic.FieldState = prismic.FieldState,
|
|
14
|
-
> =
|
|
15
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
16
|
-
? false
|
|
17
|
-
: boolean;
|
|
18
|
-
} & MockValueConfig<Model> &
|
|
19
|
-
MockValueStateConfig<State>;
|
|
12
|
+
> = MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
20
13
|
|
|
21
14
|
type MockLinkToMediaValue<
|
|
22
15
|
State extends prismic.FieldState = prismic.FieldState,
|
|
@@ -36,20 +29,15 @@ export const linkToMedia = <
|
|
|
36
29
|
link_type: prismic.LinkType.Media,
|
|
37
30
|
} as MockLinkToMediaValue<State>;
|
|
38
31
|
} else {
|
|
39
|
-
const model = config.model || modelGen.link({ faker });
|
|
40
|
-
|
|
41
32
|
return {
|
|
42
33
|
link_type: prismic.LinkType.Media,
|
|
34
|
+
id: faker.hash(11),
|
|
43
35
|
name: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
44
36
|
kind: changeCase.snakeCase(faker.word()),
|
|
45
37
|
url: faker.url(),
|
|
46
38
|
size: faker.range(500, 3000).toString(),
|
|
47
39
|
height: faker.range(500, 3000).toString(),
|
|
48
40
|
width: faker.range(500, 3000).toString(),
|
|
49
|
-
text:
|
|
50
|
-
config.withText ?? model.config?.text
|
|
51
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
52
|
-
: undefined,
|
|
53
41
|
} as MockLinkToMediaValue<State>;
|
|
54
42
|
}
|
|
55
43
|
};
|