@prismicio/mock 0.3.8-alpha.0 → 0.3.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +0 -1
- package/dist/lib/buildContentRelationshipField.js +1 -2
- package/dist/lib/buildContentRelationshipField.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 +5 -11
- package/dist/model/link.cjs +1 -3
- package/dist/model/link.cjs.map +1 -1
- package/dist/model/link.d.ts +7 -8
- package/dist/model/link.js +1 -3
- package/dist/model/link.js.map +1 -1
- package/dist/model/linkToMedia.cjs +1 -3
- package/dist/model/linkToMedia.cjs.map +1 -1
- package/dist/model/linkToMedia.d.ts +7 -8
- package/dist/model/linkToMedia.js +1 -3
- 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 +3 -2
- package/dist/value/link.cjs.map +1 -1
- package/dist/value/link.d.ts +1 -1
- package/dist/value/link.js +3 -2
- package/dist/value/link.js.map +1 -1
- package/dist/value/linkToMedia.cjs +1 -1
- package/dist/value/linkToMedia.cjs.map +1 -1
- package/dist/value/linkToMedia.d.ts +1 -1
- package/dist/value/linkToMedia.js +1 -1
- package/dist/value/linkToMedia.js.map +1 -1
- package/package.json +3 -4
- package/src/api/repository.ts +1 -0
- package/src/lib/buildContentRelationshipField.ts +0 -2
- package/src/model/contentRelationship.ts +3 -27
- package/src/model/link.ts +15 -27
- package/src/model/linkToMedia.ts +13 -20
- package/src/value/contentRelationship.ts +0 -20
- package/src/value/link.ts +3 -2
- package/src/value/linkToMedia.ts +2 -2
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 BuildContentRelationshipFieldConfig<\n\tDocument extends prismic.PrismicDocument,\n> = {\n\tdocument: Document;\n
|
|
1
|
+
{"version":3,"file":"buildContentRelationshipField.cjs","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype BuildContentRelationshipFieldConfig<\n\tDocument extends prismic.PrismicDocument,\n> = {\n\tdocument: Document;\n};\n\nexport const buildContentRelationshipField = <\n\tDocument extends prismic.PrismicDocument,\n>(\n\tconfig: BuildContentRelationshipFieldConfig<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":";;;;;;;;;;;;;;;;;;;;AAQa,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
2
|
type BuildContentRelationshipFieldConfig<Document extends prismic.PrismicDocument> = {
|
|
3
3
|
document: Document;
|
|
4
|
-
text?: string;
|
|
5
4
|
};
|
|
6
5
|
export declare const buildContentRelationshipField: <Document extends prismic.PrismicDocument<Record<string, any>, string, string>>(config: BuildContentRelationshipFieldConfig<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 BuildContentRelationshipFieldConfig<\n\tDocument extends prismic.PrismicDocument,\n> = {\n\tdocument: Document;\n
|
|
1
|
+
{"version":3,"file":"buildContentRelationshipField.js","sources":["../../../src/lib/buildContentRelationshipField.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\ntype BuildContentRelationshipFieldConfig<\n\tDocument extends prismic.PrismicDocument,\n> = {\n\tdocument: Document;\n};\n\nexport const buildContentRelationshipField = <\n\tDocument extends prismic.PrismicDocument,\n>(\n\tconfig: BuildContentRelationshipFieldConfig<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":";AAQa,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;"}
|
|
@@ -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\";\
|
|
1
|
+
{"version":3,"file":"contentRelationship.cjs","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\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":";;;;;;;;;;;;;;;;;;;;;;AAca,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\";\
|
|
1
|
+
{"version":3,"file":"contentRelationship.js","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\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":";;;AAca,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
|
};
|
|
@@ -63,16 +57,16 @@ export declare class ModelMockFactory {
|
|
|
63
57
|
};
|
|
64
58
|
} & {
|
|
65
59
|
config: {
|
|
66
|
-
|
|
60
|
+
allowText: true;
|
|
67
61
|
} | {
|
|
68
|
-
|
|
62
|
+
allowText?: undefined;
|
|
69
63
|
};
|
|
70
64
|
};
|
|
71
65
|
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField & {
|
|
72
66
|
config: {
|
|
73
|
-
|
|
67
|
+
allowText: true;
|
|
74
68
|
} | {
|
|
75
|
-
|
|
69
|
+
allowText?: undefined;
|
|
76
70
|
};
|
|
77
71
|
};
|
|
78
72
|
number(config?: WithoutFakerConfig<MockNumberModelConfig>): prismic.CustomTypeModelNumberField;
|
package/dist/model/link.cjs
CHANGED
|
@@ -29,9 +29,7 @@ const link = (config) => {
|
|
|
29
29
|
placeholder: index.sentenceCase(faker.words(3)),
|
|
30
30
|
select: null,
|
|
31
31
|
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0,
|
|
32
|
-
|
|
33
|
-
type: prismic__namespace.CustomTypeModelFieldType.Text
|
|
34
|
-
} : void 0
|
|
32
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
35
|
};
|
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\
|
|
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\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText>,\n): MockLinkModel<AllowTargetBlank, AllowText> => {\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\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4Ba,MAAA,OAAO,CAInB,WAC+C;AAC/C,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,MACxB,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,IACD;AAAA,EAAA;AAEH;;"}
|
package/dist/model/link.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockModelConfig } from "../types";
|
|
3
|
-
|
|
4
|
-
type MockLinkModel<AllowTargetBlank extends boolean = boolean, Text extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
3
|
+
type MockLinkModel<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
5
4
|
config: AllowTargetBlank extends true ? {
|
|
6
5
|
allowTargetBlank: true;
|
|
7
6
|
} : {
|
|
8
7
|
allowTargetBlank?: undefined;
|
|
9
8
|
};
|
|
10
9
|
} & {
|
|
11
|
-
config:
|
|
12
|
-
|
|
10
|
+
config: AllowText extends true ? {
|
|
11
|
+
allowText: true;
|
|
13
12
|
} : {
|
|
14
|
-
|
|
13
|
+
allowText?: undefined;
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean,
|
|
16
|
+
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean> = {
|
|
18
17
|
allowTargetBlank?: AllowTargetBlank;
|
|
19
|
-
|
|
18
|
+
allowText?: AllowText;
|
|
20
19
|
} & MockModelConfig;
|
|
21
|
-
export declare const link: <AllowTargetBlank extends boolean = boolean,
|
|
20
|
+
export declare const link: <AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, AllowText>) => MockLinkModel<AllowTargetBlank, AllowText>;
|
|
22
21
|
export {};
|
package/dist/model/link.js
CHANGED
|
@@ -10,9 +10,7 @@ const link = (config) => {
|
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
11
|
select: null,
|
|
12
12
|
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0,
|
|
13
|
-
|
|
14
|
-
type: prismic.CustomTypeModelFieldType.Text
|
|
15
|
-
} : void 0
|
|
13
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
16
14
|
}
|
|
17
15
|
};
|
|
18
16
|
};
|
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\
|
|
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\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText>,\n): MockLinkModel<AllowTargetBlank, AllowText> => {\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\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AA4Ba,MAAA,OAAO,CAInB,WAC+C;AAC/C,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,MACxB,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,IACD;AAAA,EAAA;AAEH;"}
|
|
@@ -28,9 +28,7 @@ const linkToMedia = (config) => {
|
|
|
28
28
|
label: index.capitalCase(faker.word()),
|
|
29
29
|
placeholder: index.sentenceCase(faker.words(3)),
|
|
30
30
|
select: prismic__namespace.CustomTypeModelLinkSelectType.Media,
|
|
31
|
-
|
|
32
|
-
type: prismic__namespace.CustomTypeModelFieldType.Text
|
|
33
|
-
} : void 0
|
|
31
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
34
|
};
|
|
@@ -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\ntype MockLinkToMediaModel<AllowText extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: AllowText extends true\n\t\t\t? { allowText: true }\n\t\t\t: { allowText?: undefined };\n\t};\n\nexport type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const linkToMedia = <AllowText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<AllowText>,\n): MockLinkToMediaModel<AllowText> => {\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\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkToMediaModel<AllowText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBa,MAAA,cAAc,CAC1B,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,QAAQF,mBAAQ,8BAA8B;AAAA,MAC9C,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,IACD;AAAA,EAAA;AAEH;;"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { LinkText } from "./link";
|
|
3
2
|
import { MockModelConfig } from "../types";
|
|
4
|
-
type MockLinkToMediaModel<
|
|
5
|
-
config:
|
|
6
|
-
|
|
3
|
+
type MockLinkToMediaModel<AllowText extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
|
|
4
|
+
config: AllowText extends true ? {
|
|
5
|
+
allowText: true;
|
|
7
6
|
} : {
|
|
8
|
-
|
|
7
|
+
allowText?: undefined;
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
|
-
export type MockLinkToMediaModelConfig<
|
|
12
|
-
|
|
10
|
+
export type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {
|
|
11
|
+
allowText?: AllowText;
|
|
13
12
|
} & MockModelConfig;
|
|
14
|
-
export declare const linkToMedia: <
|
|
13
|
+
export declare const linkToMedia: <AllowText extends boolean = boolean>(config: MockLinkToMediaModelConfig<AllowText>) => MockLinkToMediaModel<AllowText>;
|
|
15
14
|
export {};
|
|
@@ -9,9 +9,7 @@ const linkToMedia = (config) => {
|
|
|
9
9
|
label: capitalCase(faker.word()),
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
11
|
select: prismic.CustomTypeModelLinkSelectType.Media,
|
|
12
|
-
|
|
13
|
-
type: prismic.CustomTypeModelFieldType.Text
|
|
14
|
-
} : void 0
|
|
12
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
15
13
|
}
|
|
16
14
|
};
|
|
17
15
|
};
|
|
@@ -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\ntype MockLinkToMediaModel<AllowText extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: AllowText extends true\n\t\t\t? { allowText: true }\n\t\t\t: { allowText?: undefined };\n\t};\n\nexport type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const linkToMedia = <AllowText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<AllowText>,\n): MockLinkToMediaModel<AllowText> => {\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\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkToMediaModel<AllowText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAkBa,MAAA,cAAc,CAC1B,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,QAAQ,8BAA8B;AAAA,MAC9C,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,IACD;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\";\nimport {\n\tMockValueStateConfig,\n\tMockValueConfig,\n\tIterableElement,\n} from \"../types\";\nimport * as modelGen from \"../model\";\nimport { document as documentGen } from \"./document\";\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>;\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>;\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\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\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\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\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\t\tconst document = faker.randomElement(linkableDocuments);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkCa,MAAA,sBAAsB,CAKlC,WAC+C;;AAC/C,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AACjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAWC,mBAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACN,UAAM,QAAQ,OAAO,SAASC,sBAAAA,oBAA6B,EAAE,OAAO;AACpE,UAAM,oBAAoB,OAAO,oBAC9B,OAAO,kBAAkB,OACzB,CACCC,cAIG;;AACH,UAAI,aAAa;AACb,WAAAC,MAAA,MAAM,WAAN,gBAAAA,IAAc,aAAa;AAC9B,qBACC,cAAc,MAAM,OAAO,YAAY,SAASD,UAAS,IAAI;AAAA,MAC/D;AACI,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;AAEE,UAAA,WAAW,MAAM,cAAc,iBAAiB;AACtD,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\";\nimport {\n\tMockValueStateConfig,\n\tMockValueConfig,\n\tIterableElement,\n} from \"../types\";\nimport * as modelGen from \"../model\";\nimport { document as documentGen } from \"./document\";\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>;\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>;\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\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\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\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\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\t\tconst document = faker.randomElement(linkableDocuments);\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":";;;;;;;AAkCa,MAAA,sBAAsB,CAKlC,WAC+C;;AAC/C,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AACjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACN,UAAM,QAAQ,OAAO,SAASA,sBAA6B,EAAE,OAAO;AACpE,UAAM,oBAAoB,OAAO,oBAC9B,OAAO,kBAAkB,OACzB,CACCC,cAIG;;AACH,UAAI,aAAa;AACb,WAAAC,MAAA,MAAM,WAAN,gBAAAA,IAAc,aAAa;AAC9B,qBACC,cAAc,MAAM,OAAO,YAAY,SAASD,UAAS,IAAI;AAAA,MAC/D;AACI,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;AAEE,UAAA,WAAW,MAAM,cAAc,iBAAiB;AACtD,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
|
@@ -47,7 +47,8 @@ const link = (config) => {
|
|
|
47
47
|
case prismic__namespace.LinkType.Media: {
|
|
48
48
|
return linkToMedia.linkToMedia({
|
|
49
49
|
faker,
|
|
50
|
-
state: config.state
|
|
50
|
+
state: config.state,
|
|
51
|
+
withText: config.withText
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
case prismic__namespace.LinkType.Web:
|
|
@@ -57,7 +58,7 @@ const link = (config) => {
|
|
|
57
58
|
link_type: prismic__namespace.LinkType.Web,
|
|
58
59
|
url: faker.url(),
|
|
59
60
|
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.
|
|
61
|
+
text: config.withText ?? (((_b = model.config) == null ? void 0 : _b.allowText) && faker.boolean()) ? index.sentenceCase(faker.words(2)) : void 0
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
}
|
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\";\nimport * as changeCase from \"change-case\";\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\twithText?: NonNullable<Model[\"config\"]>[\"
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.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\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\twithText?: NonNullable<Model[\"config\"]>[\"allowText\"] 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\twithText: config.withText,\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\ttext:\n\t\t\t\t\t\tconfig.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t\t\t? changeCase.sentenceCase(faker.words(2))\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","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDa,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,UACd,UAAU,OAAO;AAAA,QAAA,CACjB;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,UACJ,MACC,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aAClDI,MAAwB,aAAA,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;;"}
|
package/dist/value/link.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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"]>["
|
|
6
|
+
withText?: NonNullable<Model["config"]>["allowText"] extends undefined ? false : boolean;
|
|
7
7
|
/**
|
|
8
8
|
* A list of potential documents to which the field can be linked.
|
|
9
9
|
*/
|
package/dist/value/link.js
CHANGED
|
@@ -28,7 +28,8 @@ const link = (config) => {
|
|
|
28
28
|
case prismic.LinkType.Media: {
|
|
29
29
|
return linkToMedia({
|
|
30
30
|
faker,
|
|
31
|
-
state: config.state
|
|
31
|
+
state: config.state,
|
|
32
|
+
withText: config.withText
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
case prismic.LinkType.Web:
|
|
@@ -38,7 +39,7 @@ const link = (config) => {
|
|
|
38
39
|
link_type: prismic.LinkType.Web,
|
|
39
40
|
url: faker.url(),
|
|
40
41
|
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.
|
|
42
|
+
text: config.withText ?? (((_b = model.config) == null ? void 0 : _b.allowText) && faker.boolean()) ? sentenceCase(faker.words(2)) : void 0
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
45
|
}
|
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\";\nimport * as changeCase from \"change-case\";\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\twithText?: NonNullable<Model[\"config\"]>[\"
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/value/link.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\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\twithText?: NonNullable<Model[\"config\"]>[\"allowText\"] 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\twithText: config.withText,\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\ttext:\n\t\t\t\t\t\tconfig.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t\t\t? changeCase.sentenceCase(faker.words(2))\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","changeCase.sentenceCase"],"mappings":";;;;;;AAmDa,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,UACd,UAAU,OAAO;AAAA,QAAA,CACjB;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,UACJ,MACC,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aAClDC,aAAwB,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;"}
|
|
@@ -38,7 +38,7 @@ const linkToMedia = (config) => {
|
|
|
38
38
|
size: faker.range(500, 3e3).toString(),
|
|
39
39
|
height: faker.range(500, 3e3).toString(),
|
|
40
40
|
width: faker.range(500, 3e3).toString(),
|
|
41
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.
|
|
41
|
+
text: config.withText ?? (((_a = model.config) == null ? void 0 : _a.allowText) && faker.boolean()) ? index.sentenceCase(faker.words(2)) : void 0
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
};
|
|
@@ -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\nimport * as modelGen from \"../model\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\twithText?: NonNullable<Model[\"config\"]>[\"
|
|
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\nimport * as modelGen from \"../model\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\twithText?: NonNullable<Model[\"config\"]>[\"allowText\"] extends undefined\n\t\t? false\n\t\t: boolean;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<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\tconst model = config.model || modelGen.link({ faker });\n\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\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\ttext:\n\t\t\t\tconfig.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t? changeCase.sentenceCase(faker.words(2))\n\t\t\t\t\t: undefined,\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["createFaker","prismic","modelGen.link","changeCase.snakeCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBa,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;AACN,UAAM,QAAQ,OAAO,SAASC,KAAAA,KAAc,EAAE,OAAO;AAE9C,WAAA;AAAA,MACN,WAAWD,mBAAQ,SAAS;AAAA,MAC5B,MAAM,GAAGE,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,MACxC,MACC,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aAClDC,MAAwB,aAAA,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,IAAA;AAAA,EAEN;AACD;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
3
3
|
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> = {
|
|
4
|
-
withText?: NonNullable<Model["config"]>["
|
|
4
|
+
withText?: NonNullable<Model["config"]>["allowText"] extends undefined ? false : boolean;
|
|
5
5
|
} & MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
6
6
|
type MockLinkToMediaValue<State extends prismic.FieldState = prismic.FieldState> = prismic.LinkToMediaField<State>;
|
|
7
7
|
export declare const linkToMedia: <Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = "filled">(config: MockLinkToMediaValueConfig<Model, State>) => MockLinkToMediaValue<State>;
|
|
@@ -19,7 +19,7 @@ const linkToMedia = (config) => {
|
|
|
19
19
|
size: faker.range(500, 3e3).toString(),
|
|
20
20
|
height: faker.range(500, 3e3).toString(),
|
|
21
21
|
width: faker.range(500, 3e3).toString(),
|
|
22
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.
|
|
22
|
+
text: config.withText ?? (((_a = model.config) == null ? void 0 : _a.allowText) && faker.boolean()) ? sentenceCase(faker.words(2)) : void 0
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
};
|
|
@@ -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\nimport * as modelGen from \"../model\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\twithText?: NonNullable<Model[\"config\"]>[\"
|
|
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\nimport * as modelGen from \"../model\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\twithText?: NonNullable<Model[\"config\"]>[\"allowText\"] extends undefined\n\t\t? false\n\t\t: boolean;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<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\tconst model = config.model || modelGen.link({ faker });\n\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\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\ttext:\n\t\t\t\tconfig.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t? changeCase.sentenceCase(faker.words(2))\n\t\t\t\t\t: undefined,\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["modelGen.link","changeCase.snakeCase","changeCase.sentenceCase"],"mappings":";;;;AAwBa,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;AACN,UAAM,QAAQ,OAAO,SAASA,KAAc,EAAE,OAAO;AAE9C,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,MAC5B,MAAM,GAAGC,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,MACxC,MACC,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aAClDC,aAAwB,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,IAAA;AAAA,EAEN;AACD;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/mock",
|
|
3
|
-
"version": "0.3.8-alpha.
|
|
3
|
+
"version": "0.3.8-alpha.2",
|
|
4
4
|
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -56,14 +56,13 @@
|
|
|
56
56
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
|
57
57
|
"types": "tsc --noEmit",
|
|
58
58
|
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava",
|
|
59
|
-
"unit: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'"
|
|
59
|
+
"unit:watch": "npm run unit -- --watch"
|
|
61
60
|
},
|
|
62
61
|
"dependencies": {
|
|
63
62
|
"change-case": "^5.4.4"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
|
-
"@prismicio/client": "^7.9.0-alpha.
|
|
65
|
+
"@prismicio/client": "^7.9.0-alpha.3",
|
|
67
66
|
"@size-limit/preset-small-lib": "^11.1.2",
|
|
68
67
|
"@types/node": "^20.12.7",
|
|
69
68
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
package/src/api/repository.ts
CHANGED
|
@@ -4,7 +4,6 @@ type BuildContentRelationshipFieldConfig<
|
|
|
4
4
|
Document extends prismic.PrismicDocument,
|
|
5
5
|
> = {
|
|
6
6
|
document: Document;
|
|
7
|
-
text?: string;
|
|
8
7
|
};
|
|
9
8
|
|
|
10
9
|
export const buildContentRelationshipField = <
|
|
@@ -27,6 +26,5 @@ export const buildContentRelationshipField = <
|
|
|
27
26
|
url: config.document.url || undefined,
|
|
28
27
|
slug: config.document.slugs[0],
|
|
29
28
|
isBroken: false,
|
|
30
|
-
text: config.text,
|
|
31
29
|
};
|
|
32
30
|
};
|
|
@@ -1,42 +1,23 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import * as changeCase from "change-case";
|
|
3
|
-
|
|
4
3
|
import { createFaker } from "../lib/createFaker";
|
|
5
4
|
|
|
6
|
-
import { LinkText } from "./link";
|
|
7
5
|
import { MockModelConfig } from "../types";
|
|
8
6
|
|
|
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
7
|
export type MockContentRelationshipModelConfig<
|
|
24
8
|
CustomTypeIDs extends string = string,
|
|
25
9
|
Tags extends string = string,
|
|
26
|
-
Text extends boolean = boolean,
|
|
27
10
|
> = {
|
|
28
11
|
customTypeIDs?: readonly CustomTypeIDs[];
|
|
29
12
|
tags?: readonly Tags[];
|
|
30
|
-
text?: Text;
|
|
31
13
|
} & MockModelConfig;
|
|
32
14
|
|
|
33
15
|
export const contentRelationship = <
|
|
34
16
|
CustomTypeIDs extends string,
|
|
35
17
|
Tags extends string,
|
|
36
|
-
Text extends boolean = boolean,
|
|
37
18
|
>(
|
|
38
|
-
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags
|
|
39
|
-
):
|
|
19
|
+
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,
|
|
20
|
+
): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {
|
|
40
21
|
const faker = config.faker || createFaker(config.seed);
|
|
41
22
|
|
|
42
23
|
return {
|
|
@@ -47,11 +28,6 @@ export const contentRelationship = <
|
|
|
47
28
|
select: prismic.CustomTypeModelLinkSelectType.Document,
|
|
48
29
|
customtypes: config.customTypeIDs,
|
|
49
30
|
tags: config.tags,
|
|
50
|
-
text: config.text
|
|
51
|
-
? {
|
|
52
|
-
type: prismic.CustomTypeModelFieldType.Text,
|
|
53
|
-
}
|
|
54
|
-
: undefined,
|
|
55
31
|
},
|
|
56
|
-
}
|
|
32
|
+
};
|
|
57
33
|
};
|
package/src/model/link.ts
CHANGED
|
@@ -5,43 +5,33 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
export type LinkText = prismic.CustomTypeModelKeyTextField;
|
|
9
|
-
|
|
10
8
|
type MockLinkModel<
|
|
11
9
|
AllowTargetBlank extends boolean = boolean,
|
|
12
|
-
|
|
10
|
+
AllowText extends boolean = boolean,
|
|
13
11
|
> = prismic.CustomTypeModelLinkField & {
|
|
14
12
|
config: AllowTargetBlank extends true
|
|
15
|
-
? {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
: {
|
|
19
|
-
allowTargetBlank?: undefined;
|
|
20
|
-
};
|
|
13
|
+
? { allowTargetBlank: true }
|
|
14
|
+
: { allowTargetBlank?: undefined };
|
|
21
15
|
} & {
|
|
22
|
-
config:
|
|
23
|
-
? {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
: {
|
|
27
|
-
text?: undefined;
|
|
28
|
-
};
|
|
16
|
+
config: AllowText extends true
|
|
17
|
+
? { allowText: true }
|
|
18
|
+
: { allowText?: undefined };
|
|
29
19
|
};
|
|
30
20
|
|
|
31
21
|
export type MockLinkModelConfig<
|
|
32
22
|
AllowTargetBlank extends boolean = boolean,
|
|
33
|
-
|
|
23
|
+
AllowText extends boolean = boolean,
|
|
34
24
|
> = {
|
|
35
25
|
allowTargetBlank?: AllowTargetBlank;
|
|
36
|
-
|
|
26
|
+
allowText?: AllowText;
|
|
37
27
|
} & MockModelConfig;
|
|
38
28
|
|
|
39
29
|
export const link = <
|
|
40
30
|
AllowTargetBlank extends boolean = boolean,
|
|
41
|
-
|
|
31
|
+
AllowText extends boolean = boolean,
|
|
42
32
|
>(
|
|
43
|
-
config: MockLinkModelConfig<AllowTargetBlank,
|
|
44
|
-
): MockLinkModel<AllowTargetBlank,
|
|
33
|
+
config: MockLinkModelConfig<AllowTargetBlank, AllowText>,
|
|
34
|
+
): MockLinkModel<AllowTargetBlank, AllowText> => {
|
|
45
35
|
const faker = config.faker || createFaker(config.seed);
|
|
46
36
|
|
|
47
37
|
return {
|
|
@@ -54,11 +44,9 @@ export const link = <
|
|
|
54
44
|
("allowTargetBlank" in config
|
|
55
45
|
? config.allowTargetBlank
|
|
56
46
|
: faker.boolean()) || undefined,
|
|
57
|
-
|
|
58
|
-
?
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
: undefined,
|
|
47
|
+
allowText:
|
|
48
|
+
("allowText" in config ? config.allowText : faker.boolean()) ||
|
|
49
|
+
undefined,
|
|
62
50
|
},
|
|
63
|
-
} as MockLinkModel<AllowTargetBlank,
|
|
51
|
+
} as MockLinkModel<AllowTargetBlank, AllowText>;
|
|
64
52
|
};
|
package/src/model/linkToMedia.ts
CHANGED
|
@@ -3,27 +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 MockLinkToMediaModel<
|
|
8
|
+
type MockLinkToMediaModel<AllowText extends boolean = boolean> =
|
|
10
9
|
prismic.CustomTypeModelLinkToMediaField & {
|
|
11
|
-
config:
|
|
12
|
-
? {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
: {
|
|
16
|
-
text?: undefined;
|
|
17
|
-
};
|
|
10
|
+
config: AllowText extends true
|
|
11
|
+
? { allowText: true }
|
|
12
|
+
: { allowText?: undefined };
|
|
18
13
|
};
|
|
19
14
|
|
|
20
|
-
export type MockLinkToMediaModelConfig<
|
|
21
|
-
|
|
15
|
+
export type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {
|
|
16
|
+
allowText?: AllowText;
|
|
22
17
|
} & MockModelConfig;
|
|
23
18
|
|
|
24
|
-
export const linkToMedia = <
|
|
25
|
-
config: MockLinkToMediaModelConfig<
|
|
26
|
-
): MockLinkToMediaModel<
|
|
19
|
+
export const linkToMedia = <AllowText extends boolean = boolean>(
|
|
20
|
+
config: MockLinkToMediaModelConfig<AllowText>,
|
|
21
|
+
): MockLinkToMediaModel<AllowText> => {
|
|
27
22
|
const faker = config.faker || createFaker(config.seed);
|
|
28
23
|
|
|
29
24
|
return {
|
|
@@ -32,11 +27,9 @@ export const linkToMedia = <Text extends boolean = boolean>(
|
|
|
32
27
|
label: changeCase.capitalCase(faker.word()),
|
|
33
28
|
placeholder: changeCase.sentenceCase(faker.words(3)),
|
|
34
29
|
select: prismic.CustomTypeModelLinkSelectType.Media,
|
|
35
|
-
|
|
36
|
-
?
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
: undefined,
|
|
30
|
+
allowText:
|
|
31
|
+
("allowText" in config ? config.allowText : faker.boolean()) ||
|
|
32
|
+
undefined,
|
|
40
33
|
},
|
|
41
|
-
} as MockLinkToMediaModel<
|
|
34
|
+
} as MockLinkToMediaModel<AllowText>;
|
|
42
35
|
};
|
|
@@ -1,36 +1,27 @@
|
|
|
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";
|
|
6
5
|
import { generateCustomTypeId } from "../lib/generateCustomTypeId";
|
|
7
6
|
import { generateTags } from "../lib/generateTags";
|
|
8
|
-
|
|
9
7
|
import {
|
|
10
8
|
MockValueStateConfig,
|
|
11
9
|
MockValueConfig,
|
|
12
10
|
IterableElement,
|
|
13
11
|
} from "../types";
|
|
14
|
-
|
|
15
12
|
import * as modelGen from "../model";
|
|
16
|
-
|
|
17
13
|
import { document as documentGen } from "./document";
|
|
18
|
-
|
|
19
14
|
export type MockContentRelationshipValueConfig<
|
|
20
15
|
Model extends
|
|
21
16
|
prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,
|
|
22
17
|
State extends prismic.FieldState = prismic.FieldState,
|
|
23
18
|
> = {
|
|
24
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
25
|
-
? false
|
|
26
|
-
: boolean;
|
|
27
19
|
/**
|
|
28
20
|
* A list of potential documents to which the field can be linked.
|
|
29
21
|
*/
|
|
30
22
|
linkableDocuments?: prismic.PrismicDocument[];
|
|
31
23
|
} & MockValueConfig<Model> &
|
|
32
24
|
MockValueStateConfig<State>;
|
|
33
|
-
|
|
34
25
|
type MockContentRelationshipValue<
|
|
35
26
|
Model extends
|
|
36
27
|
prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,
|
|
@@ -41,7 +32,6 @@ type MockContentRelationshipValue<
|
|
|
41
32
|
never,
|
|
42
33
|
State
|
|
43
34
|
>;
|
|
44
|
-
|
|
45
35
|
export const contentRelationship = <
|
|
46
36
|
Model extends
|
|
47
37
|
prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,
|
|
@@ -50,14 +40,12 @@ export const contentRelationship = <
|
|
|
50
40
|
config: MockContentRelationshipValueConfig<Model, State>,
|
|
51
41
|
): MockContentRelationshipValue<Model, State> => {
|
|
52
42
|
const faker = config.faker || createFaker(config.seed);
|
|
53
|
-
|
|
54
43
|
if (config.state === "empty") {
|
|
55
44
|
return {
|
|
56
45
|
link_type: prismic.LinkType.Document,
|
|
57
46
|
} as MockContentRelationshipValue<Model, State>;
|
|
58
47
|
} else {
|
|
59
48
|
const model = config.model || modelGen.contentRelationship({ faker });
|
|
60
|
-
|
|
61
49
|
const linkableDocuments = config.linkableDocuments
|
|
62
50
|
? config.linkableDocuments.filter(
|
|
63
51
|
(
|
|
@@ -67,12 +55,10 @@ export const contentRelationship = <
|
|
|
67
55
|
NonNullable<NonNullable<Model["config"]>["customtypes"]>[number]
|
|
68
56
|
> => {
|
|
69
57
|
let shouldKeep = true;
|
|
70
|
-
|
|
71
58
|
if (model.config?.customtypes) {
|
|
72
59
|
shouldKeep =
|
|
73
60
|
shouldKeep && model.config.customtypes.includes(document.type);
|
|
74
61
|
}
|
|
75
|
-
|
|
76
62
|
if (model.config?.tags) {
|
|
77
63
|
shouldKeep =
|
|
78
64
|
shouldKeep &&
|
|
@@ -96,19 +82,13 @@ export const contentRelationship = <
|
|
|
96
82
|
NonNullable<NonNullable<Model["config"]>["customtypes"]>[number]
|
|
97
83
|
>,
|
|
98
84
|
];
|
|
99
|
-
|
|
100
85
|
const document = faker.randomElement(linkableDocuments);
|
|
101
|
-
|
|
102
86
|
if (!document) {
|
|
103
87
|
throw new Error("A linkable document could not be found.");
|
|
104
88
|
}
|
|
105
89
|
|
|
106
90
|
return buildContentRelationshipField({
|
|
107
91
|
document,
|
|
108
|
-
text:
|
|
109
|
-
config.withText ?? model.config?.text
|
|
110
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
111
|
-
: undefined,
|
|
112
92
|
}) as unknown as MockContentRelationshipValue<Model, State>;
|
|
113
93
|
}
|
|
114
94
|
};
|
package/src/value/link.ts
CHANGED
|
@@ -23,7 +23,7 @@ export type MockLinkValueConfig<
|
|
|
23
23
|
>["allowTargetBlank"] extends undefined
|
|
24
24
|
? false
|
|
25
25
|
: boolean;
|
|
26
|
-
withText?: NonNullable<Model["config"]>["
|
|
26
|
+
withText?: NonNullable<Model["config"]>["allowText"] extends undefined
|
|
27
27
|
? false
|
|
28
28
|
: boolean;
|
|
29
29
|
/**
|
|
@@ -86,6 +86,7 @@ export const link = <
|
|
|
86
86
|
return linkToMedia({
|
|
87
87
|
faker,
|
|
88
88
|
state: config.state,
|
|
89
|
+
withText: config.withText,
|
|
89
90
|
}) as MockLinkValue<LinkType, State>;
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -102,7 +103,7 @@ export const link = <
|
|
|
102
103
|
? "_blank"
|
|
103
104
|
: undefined,
|
|
104
105
|
text:
|
|
105
|
-
config.withText ?? model.config?.
|
|
106
|
+
config.withText ?? (model.config?.allowText && faker.boolean())
|
|
106
107
|
? changeCase.sentenceCase(faker.words(2))
|
|
107
108
|
: undefined,
|
|
108
109
|
} as MockLinkValue<LinkType, State>;
|
package/src/value/linkToMedia.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type MockLinkToMediaValueConfig<
|
|
|
12
12
|
prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,
|
|
13
13
|
State extends prismic.FieldState = prismic.FieldState,
|
|
14
14
|
> = {
|
|
15
|
-
withText?: NonNullable<Model["config"]>["
|
|
15
|
+
withText?: NonNullable<Model["config"]>["allowText"] extends undefined
|
|
16
16
|
? false
|
|
17
17
|
: boolean;
|
|
18
18
|
} & MockValueConfig<Model> &
|
|
@@ -47,7 +47,7 @@ export const linkToMedia = <
|
|
|
47
47
|
height: faker.range(500, 3000).toString(),
|
|
48
48
|
width: faker.range(500, 3000).toString(),
|
|
49
49
|
text:
|
|
50
|
-
config.withText ?? model.config?.
|
|
50
|
+
config.withText ?? (model.config?.allowText && faker.boolean())
|
|
51
51
|
? changeCase.sentenceCase(faker.words(2))
|
|
52
52
|
: undefined,
|
|
53
53
|
} as MockLinkToMediaValue<State>;
|