@prismicio/mock 0.7.0-alpha.2 → 0.7.0-alpha.3
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/value/link.cjs +1 -1
- package/dist/value/link.cjs.map +1 -1
- package/dist/value/link.js +1 -1
- 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.js +1 -1
- package/dist/value/linkToMedia.js.map +1 -1
- package/package.json +1 -1
- package/src/value/link.ts +3 -4
- package/src/value/linkToMedia.ts +3 -4
package/dist/value/link.cjs
CHANGED
|
@@ -58,7 +58,7 @@ const link = (config) => {
|
|
|
58
58
|
link_type: prismic__namespace.LinkType.Web,
|
|
59
59
|
url: faker.url(),
|
|
60
60
|
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0,
|
|
61
|
-
|
|
61
|
+
...config.withText ?? (((_b = model.config) == null ? void 0 : _b.allowText) && faker.boolean()) ? { text: changeCase.sentenceCase(faker.words(2)) } : {}
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
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\";\n\nimport { sentenceCase } from \"../lib/changeCase\";\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\
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase } from \"../lib/changeCase\";\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\t...(config.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t\t? { text: sentenceCase(faker.words(2)) }\n\t\t\t\t\t\t: {}),\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","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,GAAI,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aACtD,EAAE,MAAMI,WAAAA,aAAa,MAAM,MAAM,CAAC,CAAC,EAAA,IACnC;;MAEL;AAAA,IACD;AAAA,EACD;AACD;;"}
|
package/dist/value/link.js
CHANGED
|
@@ -39,7 +39,7 @@ const link = (config) => {
|
|
|
39
39
|
link_type: prismic.LinkType.Web,
|
|
40
40
|
url: faker.url(),
|
|
41
41
|
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0,
|
|
42
|
-
|
|
42
|
+
...config.withText ?? (((_b = model.config) == null ? void 0 : _b.allowText) && faker.boolean()) ? { text: sentenceCase(faker.words(2)) } : {}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
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\";\n\nimport { sentenceCase } from \"../lib/changeCase\";\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\
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase } from \"../lib/changeCase\";\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\t...(config.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t\t\t? { text: sentenceCase(faker.words(2)) }\n\t\t\t\t\t\t: {}),\n\t\t\t\t} as MockLinkValue<LinkType, State>;\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["modelGen.link"],"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,GAAI,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aACtD,EAAE,MAAM,aAAa,MAAM,MAAM,CAAC,CAAC,EAAA,IACnC;;MAEL;AAAA,IACD;AAAA,EACD;AACD;"}
|
|
@@ -39,7 +39,7 @@ const linkToMedia = (config) => {
|
|
|
39
39
|
size: faker.range(500, 3e3).toString(),
|
|
40
40
|
height: faker.range(500, 3e3).toString(),
|
|
41
41
|
width: faker.range(500, 3e3).toString(),
|
|
42
|
-
|
|
42
|
+
...config.withText ?? (((_a = model.config) == null ? void 0 : _a.allowText) && faker.boolean()) ? { text: changeCase.sentenceCase(faker.words(2)) } : {}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase, snakeCase } from \"../lib/changeCase\";\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\tid: faker.hash(11),\n\t\t\tname: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: 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\
|
|
1
|
+
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase, snakeCase } from \"../lib/changeCase\";\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\tid: faker.hash(11),\n\t\t\tname: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: 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\t...(config.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t? { text: sentenceCase(faker.words(2)) }\n\t\t\t\t: {}),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["createFaker","prismic","modelGen.link","snakeCase","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,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAGE,qBAAU,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAClD,MAAMA,WAAA,UAAU,MAAM,MAAM;AAAA,MAC5B,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,GAAI,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aACtD,EAAE,MAAMC,WAAAA,aAAa,MAAM,MAAM,CAAC,CAAC,EAAA,IACnC;;EAEL;AACD;;"}
|
|
@@ -20,7 +20,7 @@ const linkToMedia = (config) => {
|
|
|
20
20
|
size: faker.range(500, 3e3).toString(),
|
|
21
21
|
height: faker.range(500, 3e3).toString(),
|
|
22
22
|
width: faker.range(500, 3e3).toString(),
|
|
23
|
-
|
|
23
|
+
...config.withText ?? (((_a = model.config) == null ? void 0 : _a.allowText) && faker.boolean()) ? { text: sentenceCase(faker.words(2)) } : {}
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase, snakeCase } from \"../lib/changeCase\";\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\tid: faker.hash(11),\n\t\t\tname: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: 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\
|
|
1
|
+
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { sentenceCase, snakeCase } from \"../lib/changeCase\";\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\tid: faker.hash(11),\n\t\t\tname: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: 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\t...(config.withText ?? (model.config?.allowText && faker.boolean())\n\t\t\t\t? { text: sentenceCase(faker.words(2)) }\n\t\t\t\t: {}),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["modelGen.link"],"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,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAG,UAAU,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAClD,MAAM,UAAU,MAAM,MAAM;AAAA,MAC5B,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,GAAI,OAAO,eAAa,WAAM,WAAN,mBAAc,cAAa,MAAM,aACtD,EAAE,MAAM,aAAa,MAAM,MAAM,CAAC,CAAC,EAAA,IACnC;;EAEL;AACD;"}
|
package/package.json
CHANGED
package/src/value/link.ts
CHANGED
|
@@ -102,10 +102,9 @@ export const link = <
|
|
|
102
102
|
(model.config?.allowTargetBlank && faker.boolean())
|
|
103
103
|
? "_blank"
|
|
104
104
|
: undefined,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
: undefined,
|
|
105
|
+
...(config.withText ?? (model.config?.allowText && faker.boolean())
|
|
106
|
+
? { text: sentenceCase(faker.words(2)) }
|
|
107
|
+
: {}),
|
|
109
108
|
} as MockLinkValue<LinkType, State>;
|
|
110
109
|
}
|
|
111
110
|
}
|
package/src/value/linkToMedia.ts
CHANGED
|
@@ -47,10 +47,9 @@ export const linkToMedia = <
|
|
|
47
47
|
size: faker.range(500, 3000).toString(),
|
|
48
48
|
height: faker.range(500, 3000).toString(),
|
|
49
49
|
width: faker.range(500, 3000).toString(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
: undefined,
|
|
50
|
+
...(config.withText ?? (model.config?.allowText && faker.boolean())
|
|
51
|
+
? { text: sentenceCase(faker.words(2)) }
|
|
52
|
+
: {}),
|
|
54
53
|
} as MockLinkToMediaValue<State>;
|
|
55
54
|
}
|
|
56
55
|
};
|