@prismicio/mock 0.3.8-alpha.1 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/repository.cjs +2 -1
- package/dist/api/repository.cjs.map +1 -1
- package/dist/api/repository.js +2 -1
- package/dist/api/repository.js.map +1 -1
- package/dist/lib/buildContentRelationshipField.cjs +1 -2
- package/dist/lib/buildContentRelationshipField.cjs.map +1 -1
- package/dist/lib/buildContentRelationshipField.d.ts +2 -3
- package/dist/lib/buildContentRelationshipField.js +1 -2
- package/dist/lib/buildContentRelationshipField.js.map +1 -1
- package/dist/lib/buildImageFieldImage.cjs +2 -0
- package/dist/lib/buildImageFieldImage.cjs.map +1 -1
- package/dist/lib/buildImageFieldImage.js +2 -0
- package/dist/lib/buildImageFieldImage.js.map +1 -1
- package/dist/model/contentRelationship.cjs +1 -2
- package/dist/model/contentRelationship.cjs.map +1 -1
- package/dist/model/contentRelationship.d.ts +2 -11
- package/dist/model/contentRelationship.js +1 -2
- package/dist/model/contentRelationship.js.map +1 -1
- package/dist/model/createModelMockFactory.d.ts +3 -27
- package/dist/model/link.cjs +1 -2
- package/dist/model/link.cjs.map +1 -1
- package/dist/model/link.d.ts +3 -11
- package/dist/model/link.js +1 -2
- package/dist/model/link.js.map +1 -1
- package/dist/model/linkToMedia.cjs +1 -4
- package/dist/model/linkToMedia.cjs.map +1 -1
- package/dist/model/linkToMedia.d.ts +2 -12
- package/dist/model/linkToMedia.js +1 -4
- package/dist/model/linkToMedia.js.map +1 -1
- package/dist/value/contentRelationship.cjs +2 -4
- package/dist/value/contentRelationship.cjs.map +1 -1
- package/dist/value/contentRelationship.d.ts +0 -1
- package/dist/value/contentRelationship.js +2 -4
- package/dist/value/contentRelationship.js.map +1 -1
- package/dist/value/link.cjs +4 -8
- package/dist/value/link.cjs.map +1 -1
- package/dist/value/link.d.ts +0 -1
- package/dist/value/link.js +4 -8
- package/dist/value/link.js.map +1 -1
- package/dist/value/linkToMedia.cjs +2 -5
- package/dist/value/linkToMedia.cjs.map +1 -1
- package/dist/value/linkToMedia.d.ts +1 -3
- package/dist/value/linkToMedia.js +3 -6
- package/dist/value/linkToMedia.js.map +1 -1
- package/dist/value/sharedSliceVariation.cjs +1 -0
- package/dist/value/sharedSliceVariation.cjs.map +1 -1
- package/dist/value/sharedSliceVariation.js +1 -0
- package/dist/value/sharedSliceVariation.js.map +1 -1
- package/dist/value/slice.cjs +1 -0
- package/dist/value/slice.cjs.map +1 -1
- package/dist/value/slice.js +1 -0
- package/dist/value/slice.js.map +1 -1
- package/package.json +3 -4
- package/src/api/repository.ts +1 -0
- package/src/lib/buildContentRelationshipField.ts +2 -6
- package/src/lib/buildImageFieldImage.ts +2 -0
- package/src/model/contentRelationship.ts +3 -19
- package/src/model/link.ts +15 -27
- package/src/model/linkToMedia.ts +5 -19
- package/src/value/contentRelationship.ts +0 -8
- package/src/value/link.ts +0 -10
- package/src/value/linkToMedia.ts +2 -14
- package/src/value/sharedSliceVariation.ts +1 -0
- package/src/value/slice.ts +1 -0
package/dist/value/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { contentRelationship } from \"./contentRelationship\";\nimport { linkToMedia } from \"./linkToMedia\";\n\nexport type MockLinkValueConfig<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\ttype?: LinkType;\n\twithTargetBlank?: NonNullable<\n\t\tModel[\"config\"]\n\t>[\"allowTargetBlank\"] extends undefined\n\t\t? false\n\t\t: boolean;\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: LinkType extends typeof prismic.LinkType.Document\n\t\t? prismic.PrismicDocument[]\n\t\t: never;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockLinkValue<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tState extends prismic.FieldState = \"filled\",\n> = State extends \"empty\"\n\t? prismic.EmptyLinkField<LinkType>\n\t: LinkType extends typeof prismic.LinkType.Web\n\t\t? prismic.FilledLinkToWebField\n\t\t: LinkType extends typeof prismic.LinkType.Media\n\t\t\t? prismic.FilledLinkToMediaField\n\t\t\t: LinkType extends typeof prismic.LinkType.Document\n\t\t\t\t? prismic.FilledContentRelationshipField\n\t\t\t\t: never;\n\nexport const link = <\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkValueConfig<LinkType, Model, State>,\n): MockLinkValue<LinkType, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst type =\n\t\tconfig.type ||\n\t\tfaker.randomElement([\n\t\t\tprismic.LinkType.Web,\n\t\t\tprismic.LinkType.Document,\n\t\t\tprismic.LinkType.Media,\n\t\t]);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: type,\n\t\t} as MockLinkValue<LinkType, State>;\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase prismic.LinkType.Document: {\n\t\t\t\treturn contentRelationship({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t\tlinkableDocuments: config.linkableDocuments,\n\t\t\t\t}) as unknown as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Media: {\n\t\t\t\treturn linkToMedia({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t}) as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Web:\n\t\t\tdefault: {\n\t\t\t\tconst model = config.model || modelGen.link({ faker });\n\n\t\t\t\treturn {\n\t\t\t\t\tlink_type: prismic.LinkType.Web,\n\t\t\t\t\turl: faker.url(),\n\t\t\t\t\ttarget:\n\t\t\t\t\t\tconfig.withTargetBlank ??\n\t\t\t\t\t\t(model.config?.allowTargetBlank && faker.boolean())\n\t\t\t\t\t\t\t? \"_blank\"\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} as MockLinkValue<LinkType, State>;\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["createFaker","prismic","contentRelationship","linkToMedia","modelGen.link"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+Ca,MAAA,OAAO,CAOnB,WACmC;;AACnC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,OACL,OAAO,QACP,MAAM,cAAc;AAAA,IACnBC,mBAAQ,SAAS;AAAA,IACjBA,mBAAQ,SAAS;AAAA,IACjBA,mBAAQ,SAAS;AAAA,EAAA,CACjB;AAEE,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,YAAQ,MAAM;AAAA,MACb,KAAKA,mBAAQ,SAAS,UAAU;AAC/B,eAAOC,wCAAoB;AAAA,UAC1B;AAAA,UACA,OAAO,OAAO;AAAA,UACd,mBAAmB,OAAO;AAAA,QAAA,CAC1B;AAAA,MACF;AAAA,MAEA,KAAKD,mBAAQ,SAAS,OAAO;AAC5B,eAAOE,wBAAY;AAAA,UAClB;AAAA,UACA,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEA,KAAKF,mBAAQ,SAAS;AAAA,MACtB,SAAS;AACR,cAAM,QAAQ,OAAO,SAASG,OAAAA,KAAc,EAAE,OAAO;AAE9C,eAAA;AAAA,UACN,WAAWH,mBAAQ,SAAS;AAAA,UAC5B,KAAK,MAAM,IAAK;AAAA,UAChB,QACC,OAAO,sBACN,WAAM,WAAN,mBAAc,qBAAoB,MAAM,QAAO,KAC7C,WACA;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;;"}
|
package/dist/value/link.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
|
3
3
|
export type MockLinkValueConfig<LinkType extends (typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType], Model extends prismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField, State extends prismic.FieldState = prismic.FieldState> = {
|
|
4
4
|
type?: LinkType;
|
|
5
5
|
withTargetBlank?: NonNullable<Model["config"]>["allowTargetBlank"] extends undefined ? false : boolean;
|
|
6
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
|
|
7
6
|
/**
|
|
8
7
|
* A list of potential documents to which the field can be linked.
|
|
9
8
|
*/
|
package/dist/value/link.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { sentenceCase } from './../_node_modules/change-case/dist/index.js';
|
|
3
2
|
import { createFaker } from "../lib/createFaker.js";
|
|
4
3
|
import { contentRelationship } from "./contentRelationship.js";
|
|
5
4
|
import { linkToMedia } from "./linkToMedia.js";
|
|
6
5
|
import { link as link$1 } from "../model/link.js";
|
|
7
6
|
const link = (config) => {
|
|
8
|
-
var _a
|
|
7
|
+
var _a;
|
|
9
8
|
const faker = config.faker || createFaker(config.seed);
|
|
10
9
|
const type = config.type || faker.randomElement([
|
|
11
10
|
prismic.LinkType.Web,
|
|
@@ -22,15 +21,13 @@ const link = (config) => {
|
|
|
22
21
|
return contentRelationship({
|
|
23
22
|
faker,
|
|
24
23
|
state: config.state,
|
|
25
|
-
linkableDocuments: config.linkableDocuments
|
|
26
|
-
withText: config.withText
|
|
24
|
+
linkableDocuments: config.linkableDocuments
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
case prismic.LinkType.Media: {
|
|
30
28
|
return linkToMedia({
|
|
31
29
|
faker,
|
|
32
|
-
state: config.state
|
|
33
|
-
withText: config.withText
|
|
30
|
+
state: config.state
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
case prismic.LinkType.Web:
|
|
@@ -39,8 +36,7 @@ const link = (config) => {
|
|
|
39
36
|
return {
|
|
40
37
|
link_type: prismic.LinkType.Web,
|
|
41
38
|
url: faker.url(),
|
|
42
|
-
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
43
|
-
text: config.withText ?? ((_b = model.config) == null ? void 0 : _b.text) ? sentenceCase(faker.words(2)) : void 0
|
|
39
|
+
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
|
|
44
40
|
};
|
|
45
41
|
}
|
|
46
42
|
}
|
package/dist/value/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/value/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { contentRelationship } from \"./contentRelationship\";\nimport { linkToMedia } from \"./linkToMedia\";\n\nexport type MockLinkValueConfig<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\ttype?: LinkType;\n\twithTargetBlank?: NonNullable<\n\t\tModel[\"config\"]\n\t>[\"allowTargetBlank\"] extends undefined\n\t\t? false\n\t\t: boolean;\n\t/**\n\t * A list of potential documents to which the field can be linked.\n\t */\n\tlinkableDocuments?: LinkType extends typeof prismic.LinkType.Document\n\t\t? prismic.PrismicDocument[]\n\t\t: never;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\ntype MockLinkValue<\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tState extends prismic.FieldState = \"filled\",\n> = State extends \"empty\"\n\t? prismic.EmptyLinkField<LinkType>\n\t: LinkType extends typeof prismic.LinkType.Web\n\t\t? prismic.FilledLinkToWebField\n\t\t: LinkType extends typeof prismic.LinkType.Media\n\t\t\t? prismic.FilledLinkToMediaField\n\t\t\t: LinkType extends typeof prismic.LinkType.Document\n\t\t\t\t? prismic.FilledContentRelationshipField\n\t\t\t\t: never;\n\nexport const link = <\n\tLinkType extends\n\t\t(typeof prismic.LinkType)[keyof typeof prismic.LinkType] = (typeof prismic.LinkType)[keyof typeof prismic.LinkType],\n\tModel extends\n\t\tprismic.CustomTypeModelLinkField = prismic.CustomTypeModelLinkField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkValueConfig<LinkType, Model, State>,\n): MockLinkValue<LinkType, State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst type =\n\t\tconfig.type ||\n\t\tfaker.randomElement([\n\t\t\tprismic.LinkType.Web,\n\t\t\tprismic.LinkType.Document,\n\t\t\tprismic.LinkType.Media,\n\t\t]);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: type,\n\t\t} as MockLinkValue<LinkType, State>;\n\t} else {\n\t\tswitch (type) {\n\t\t\tcase prismic.LinkType.Document: {\n\t\t\t\treturn contentRelationship({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t\tlinkableDocuments: config.linkableDocuments,\n\t\t\t\t}) as unknown as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Media: {\n\t\t\t\treturn linkToMedia({\n\t\t\t\t\tfaker,\n\t\t\t\t\tstate: config.state,\n\t\t\t\t}) as MockLinkValue<LinkType, State>;\n\t\t\t}\n\n\t\t\tcase prismic.LinkType.Web:\n\t\t\tdefault: {\n\t\t\t\tconst model = config.model || modelGen.link({ faker });\n\n\t\t\t\treturn {\n\t\t\t\t\tlink_type: prismic.LinkType.Web,\n\t\t\t\t\turl: faker.url(),\n\t\t\t\t\ttarget:\n\t\t\t\t\t\tconfig.withTargetBlank ??\n\t\t\t\t\t\t(model.config?.allowTargetBlank && faker.boolean())\n\t\t\t\t\t\t\t? \"_blank\"\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t} as MockLinkValue<LinkType, State>;\n\t\t\t}\n\t\t}\n\t}\n};\n"],"names":["modelGen.link"],"mappings":";;;;;AA+Ca,MAAA,OAAO,CAOnB,WACmC;;AACnC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,OACL,OAAO,QACP,MAAM,cAAc;AAAA,IACnB,QAAQ,SAAS;AAAA,IACjB,QAAQ,SAAS;AAAA,IACjB,QAAQ,SAAS;AAAA,EAAA,CACjB;AAEE,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW;AAAA,IAAA;AAAA,SAEN;AACN,YAAQ,MAAM;AAAA,MACb,KAAK,QAAQ,SAAS,UAAU;AAC/B,eAAO,oBAAoB;AAAA,UAC1B;AAAA,UACA,OAAO,OAAO;AAAA,UACd,mBAAmB,OAAO;AAAA,QAAA,CAC1B;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ,SAAS,OAAO;AAC5B,eAAO,YAAY;AAAA,UAClB;AAAA,UACA,OAAO,OAAO;AAAA,QAAA,CACd;AAAA,MACF;AAAA,MAEA,KAAK,QAAQ,SAAS;AAAA,MACtB,SAAS;AACR,cAAM,QAAQ,OAAO,SAASA,OAAc,EAAE,OAAO;AAE9C,eAAA;AAAA,UACN,WAAW,QAAQ,SAAS;AAAA,UAC5B,KAAK,MAAM,IAAK;AAAA,UAChB,QACC,OAAO,sBACN,WAAM,WAAN,mBAAc,qBAAoB,MAAM,QAAO,KAC7C,WACA;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const prismic = require("@prismicio/client");
|
|
4
4
|
const index = require('./../_node_modules/change-case/dist/index.cjs');
|
|
5
5
|
const createFaker = require("../lib/createFaker.cjs");
|
|
6
|
-
const link = require("../model/link.cjs");
|
|
7
6
|
function _interopNamespaceDefault(e) {
|
|
8
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
8
|
if (e) {
|
|
@@ -22,23 +21,21 @@ function _interopNamespaceDefault(e) {
|
|
|
22
21
|
}
|
|
23
22
|
const prismic__namespace = /* @__PURE__ */ _interopNamespaceDefault(prismic);
|
|
24
23
|
const linkToMedia = (config) => {
|
|
25
|
-
var _a;
|
|
26
24
|
const faker = config.faker || createFaker.createFaker(config.seed);
|
|
27
25
|
if (config.state === "empty") {
|
|
28
26
|
return {
|
|
29
27
|
link_type: prismic__namespace.LinkType.Media
|
|
30
28
|
};
|
|
31
29
|
} else {
|
|
32
|
-
const model = config.model || link.link({ faker });
|
|
33
30
|
return {
|
|
34
31
|
link_type: prismic__namespace.LinkType.Media,
|
|
32
|
+
id: faker.hash(11),
|
|
35
33
|
name: `${index.snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
36
34
|
kind: index.snakeCase(faker.word()),
|
|
37
35
|
url: faker.url(),
|
|
38
36
|
size: faker.range(500, 3e3).toString(),
|
|
39
37
|
height: faker.range(500, 3e3).toString(),
|
|
40
|
-
width: faker.range(500, 3e3).toString()
|
|
41
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.text) ? index.sentenceCase(faker.words(2)) : void 0
|
|
38
|
+
width: faker.range(500, 3e3).toString()
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\
|
|
1
|
+
{"version":3,"file":"linkToMedia.cjs","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = MockValueConfig<Model> & MockValueStateConfig<State>;\n\ntype MockLinkToMediaValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.LinkToMediaField<State>;\n\nexport const linkToMedia = <\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkToMediaValueConfig<Model, State>,\n): MockLinkToMediaValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t} as MockLinkToMediaValue<State>;\n\t} else {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t\tid: faker.hash(11),\n\t\t\tname: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: changeCase.snakeCase(faker.word()),\n\t\t\turl: faker.url(),\n\t\t\tsize: faker.range(500, 3000).toString(),\n\t\t\theight: faker.range(500, 3000).toString(),\n\t\t\twidth: faker.range(500, 3000).toString(),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["createFaker","prismic","changeCase.snakeCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBa,MAAA,cAAc,CAK1B,WACgC;AAChC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAWC,mBAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACC,WAAA;AAAA,MACN,WAAWA,mBAAQ,SAAS;AAAA,MAC5B,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAGC,gBAAqB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAC7D,MAAMA,MAAqB,UAAA,MAAM,MAAM;AAAA,MACvC,KAAK,MAAM,IAAK;AAAA,MAChB,MAAM,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACvC,QAAQ,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACzC,OAAO,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,IAAA;AAAA,EAE1C;AACD;;"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
3
|
-
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> =
|
|
4
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
|
|
5
|
-
} & MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
3
|
+
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> = MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
6
4
|
type MockLinkToMediaValue<State extends prismic.FieldState = prismic.FieldState> = prismic.LinkToMediaField<State>;
|
|
7
5
|
export declare const linkToMedia: <Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = "filled">(config: MockLinkToMediaValueConfig<Model, State>) => MockLinkToMediaValue<State>;
|
|
8
6
|
export {};
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import { snakeCase
|
|
2
|
+
import { snakeCase } from './../_node_modules/change-case/dist/index.js';
|
|
3
3
|
import { createFaker } from "../lib/createFaker.js";
|
|
4
|
-
import { link } from "../model/link.js";
|
|
5
4
|
const linkToMedia = (config) => {
|
|
6
|
-
var _a;
|
|
7
5
|
const faker = config.faker || createFaker(config.seed);
|
|
8
6
|
if (config.state === "empty") {
|
|
9
7
|
return {
|
|
10
8
|
link_type: prismic.LinkType.Media
|
|
11
9
|
};
|
|
12
10
|
} else {
|
|
13
|
-
const model = config.model || link({ faker });
|
|
14
11
|
return {
|
|
15
12
|
link_type: prismic.LinkType.Media,
|
|
13
|
+
id: faker.hash(11),
|
|
16
14
|
name: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,
|
|
17
15
|
kind: snakeCase(faker.word()),
|
|
18
16
|
url: faker.url(),
|
|
19
17
|
size: faker.range(500, 3e3).toString(),
|
|
20
18
|
height: faker.range(500, 3e3).toString(),
|
|
21
|
-
width: faker.range(500, 3e3).toString()
|
|
22
|
-
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.text) ? sentenceCase(faker.words(2)) : void 0
|
|
19
|
+
width: faker.range(500, 3e3).toString()
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\
|
|
1
|
+
{"version":3,"file":"linkToMedia.js","sources":["../../../src/value/linkToMedia.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockLinkToMediaValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = MockValueConfig<Model> & MockValueStateConfig<State>;\n\ntype MockLinkToMediaValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.LinkToMediaField<State>;\n\nexport const linkToMedia = <\n\tModel extends\n\t\tprismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockLinkToMediaValueConfig<Model, State>,\n): MockLinkToMediaValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t} as MockLinkToMediaValue<State>;\n\t} else {\n\t\treturn {\n\t\t\tlink_type: prismic.LinkType.Media,\n\t\t\tid: faker.hash(11),\n\t\t\tname: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,\n\t\t\tkind: changeCase.snakeCase(faker.word()),\n\t\t\turl: faker.url(),\n\t\t\tsize: faker.range(500, 3000).toString(),\n\t\t\theight: faker.range(500, 3000).toString(),\n\t\t\twidth: faker.range(500, 3000).toString(),\n\t\t} as MockLinkToMediaValue<State>;\n\t}\n};\n"],"names":["changeCase.snakeCase"],"mappings":";;;AAiBa,MAAA,cAAc,CAK1B,WACgC;AAChC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,IAAA;AAAA,SAEvB;AACC,WAAA;AAAA,MACN,WAAW,QAAQ,SAAS;AAAA,MAC5B,IAAI,MAAM,KAAK,EAAE;AAAA,MACjB,MAAM,GAAGA,UAAqB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;AAAA,MAC7D,MAAMA,UAAqB,MAAM,MAAM;AAAA,MACvC,KAAK,MAAM,IAAK;AAAA,MAChB,MAAM,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACvC,QAAQ,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,MACzC,OAAO,MAAM,MAAM,KAAK,GAAI,EAAE,SAAU;AAAA,IAAA;AAAA,EAE1C;AACD;"}
|
|
@@ -10,6 +10,7 @@ const sharedSliceVariation = (config) => {
|
|
|
10
10
|
const sliceType = config.type ?? generateFieldId.generateFieldId({ faker });
|
|
11
11
|
const itemsCount = model.items && Object.keys(model.items).length > 0 ? config.itemsCount ?? faker.range(1, 6) : 0;
|
|
12
12
|
return {
|
|
13
|
+
id: faker.hash(11),
|
|
13
14
|
slice_type: sliceType,
|
|
14
15
|
slice_label: null,
|
|
15
16
|
variation: model.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSliceVariation.cjs","sources":["../../../src/value/sharedSliceVariation.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSharedSliceVariationValueConfig<\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n> = {\n\ttype?: string;\n\tlabel?: string;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const sharedSliceVariation = <\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n>(\n\tconfig: MockSharedSliceVariationValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.sharedSliceVariation({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\n\tconst itemsCount =\n\t\tmodel.items && Object.keys(model.items).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tslice_type: sliceType,\n\t\tslice_label: null,\n\t\tvariation: model.id,\n\t\tversion: faker.hash(7),\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model.primary || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.items || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["createFaker","modelGen.sharedSliceVariation","generateFieldId","valueForModelMap"],"mappings":";;;;;;AAwBa,MAAA,uBAAuB,CAInC,WACsB;AACtB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASC,uBAAAA,qBAA8B,EAAE,OAAO;AAErE,QAAM,YAAY,OAAO,QAAQC,gBAAAA,gBAAgB,EAAE,OAAO;AAE1D,QAAM,aACL,MAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,SAAS,IAC9C,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,SAASC,iBAAAA,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,WAAW,CAAE;AAAA,MACxB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAOA,kCAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,SAAS,CAAE;AAAA,QACtB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"sharedSliceVariation.cjs","sources":["../../../src/value/sharedSliceVariation.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSharedSliceVariationValueConfig<\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n> = {\n\ttype?: string;\n\tlabel?: string;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const sharedSliceVariation = <\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n>(\n\tconfig: MockSharedSliceVariationValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.sharedSliceVariation({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\n\tconst itemsCount =\n\t\tmodel.items && Object.keys(model.items).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tid: faker.hash(11),\n\t\tslice_type: sliceType,\n\t\tslice_label: null,\n\t\tvariation: model.id,\n\t\tversion: faker.hash(7),\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model.primary || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.items || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["createFaker","modelGen.sharedSliceVariation","generateFieldId","valueForModelMap"],"mappings":";;;;;;AAwBa,MAAA,uBAAuB,CAInC,WACsB;AACtB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASC,uBAAAA,qBAA8B,EAAE,OAAO;AAErE,QAAM,YAAY,OAAO,QAAQC,gBAAAA,gBAAgB,EAAE,OAAO;AAE1D,QAAM,aACL,MAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,SAAS,IAC9C,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,IAAI,MAAM,KAAK,EAAE;AAAA,IACjB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,SAASC,iBAAAA,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,WAAW,CAAE;AAAA,MACxB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAOA,kCAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,SAAS,CAAE;AAAA,QACtB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;;"}
|
|
@@ -8,6 +8,7 @@ const sharedSliceVariation = (config) => {
|
|
|
8
8
|
const sliceType = config.type ?? generateFieldId({ faker });
|
|
9
9
|
const itemsCount = model.items && Object.keys(model.items).length > 0 ? config.itemsCount ?? faker.range(1, 6) : 0;
|
|
10
10
|
return {
|
|
11
|
+
id: faker.hash(11),
|
|
11
12
|
slice_type: sliceType,
|
|
12
13
|
slice_label: null,
|
|
13
14
|
variation: model.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSliceVariation.js","sources":["../../../src/value/sharedSliceVariation.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSharedSliceVariationValueConfig<\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n> = {\n\ttype?: string;\n\tlabel?: string;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const sharedSliceVariation = <\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n>(\n\tconfig: MockSharedSliceVariationValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.sharedSliceVariation({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\n\tconst itemsCount =\n\t\tmodel.items && Object.keys(model.items).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tslice_type: sliceType,\n\t\tslice_label: null,\n\t\tvariation: model.id,\n\t\tversion: faker.hash(7),\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model.primary || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.items || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["modelGen.sharedSliceVariation"],"mappings":";;;;AAwBa,MAAA,uBAAuB,CAInC,WACsB;AACtB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASA,uBAA8B,EAAE,OAAO;AAErE,QAAM,YAAY,OAAO,QAAQ,gBAAgB,EAAE,OAAO;AAE1D,QAAM,aACL,MAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,SAAS,IAC9C,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,SAAS,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,WAAW,CAAE;AAAA,MACxB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAO,iBAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,SAAS,CAAE;AAAA,QACtB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"sharedSliceVariation.js","sources":["../../../src/value/sharedSliceVariation.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSharedSliceVariationValueConfig<\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n> = {\n\ttype?: string;\n\tlabel?: string;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const sharedSliceVariation = <\n\tModel extends\n\t\tprismic.SharedSliceModelVariation = prismic.SharedSliceModelVariation,\n>(\n\tconfig: MockSharedSliceVariationValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.sharedSliceVariation({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\n\tconst itemsCount =\n\t\tmodel.items && Object.keys(model.items).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tid: faker.hash(11),\n\t\tslice_type: sliceType,\n\t\tslice_label: null,\n\t\tvariation: model.id,\n\t\tversion: faker.hash(7),\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model.primary || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.items || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["modelGen.sharedSliceVariation"],"mappings":";;;;AAwBa,MAAA,uBAAuB,CAInC,WACsB;AACtB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASA,uBAA8B,EAAE,OAAO;AAErE,QAAM,YAAY,OAAO,QAAQ,gBAAgB,EAAE,OAAO;AAE1D,QAAM,aACL,MAAM,SAAS,OAAO,KAAK,MAAM,KAAK,EAAE,SAAS,IAC9C,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,IAAI,MAAM,KAAK,EAAE;AAAA,IACjB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,WAAW,MAAM;AAAA,IACjB,SAAS,MAAM,KAAK,CAAC;AAAA,IACrB,SAAS,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,WAAW,CAAE;AAAA,MACxB,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAO,iBAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,SAAS,CAAE;AAAA,QACtB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;"}
|
package/dist/value/slice.cjs
CHANGED
|
@@ -12,6 +12,7 @@ const slice = (config) => {
|
|
|
12
12
|
const sliceLabel = config.label !== void 0 ? config.label : index.capitalCase(faker.words(faker.range(1, 2)));
|
|
13
13
|
const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? config.itemsCount ?? faker.range(1, 6) : 0;
|
|
14
14
|
return {
|
|
15
|
+
id: faker.hash(11),
|
|
15
16
|
slice_type: sliceType,
|
|
16
17
|
slice_label: sliceLabel,
|
|
17
18
|
primary: valueForModelMap.valueForModelMap({
|
package/dist/value/slice.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.cjs","sources":["../../../src/value/slice.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSliceValueConfig<\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n> = {\n\ttype?: string;\n\tlabel?: string | null;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const slice = <\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n>(\n\tconfig: MockSliceValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.slice({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\tconst sliceLabel =\n\t\tconfig.label !== undefined\n\t\t\t? config.label\n\t\t\t: changeCase.capitalCase(faker.words(faker.range(1, 2)));\n\n\tconst itemsCount =\n\t\tmodel.repeat && Object.keys(model.repeat).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tslice_type: sliceType,\n\t\tslice_label: sliceLabel,\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model[\"non-repeat\"] || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.repeat || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["createFaker","modelGen.slice","generateFieldId","changeCase.capitalCase","valueForModelMap"],"mappings":";;;;;;;AAwBa,MAAA,QAAQ,CAGpB,WACsB;AACtB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASC,QAAAA,MAAe,EAAE,OAAO;AAEtD,QAAM,YAAY,OAAO,QAAQC,gBAAAA,gBAAgB,EAAE,OAAO;AAC1D,QAAM,aACL,OAAO,UAAU,SACd,OAAO,QACPC,MAAAA,YAAuB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAEzD,QAAM,aACL,MAAM,UAAU,OAAO,KAAK,MAAM,MAAM,EAAE,SAAS,IAChD,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAASC,iBAAAA,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,YAAY,KAAK,CAAE;AAAA,MAC9B,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAOA,kCAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,UAAU,CAAE;AAAA,QACvB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;;"}
|
|
1
|
+
{"version":3,"file":"slice.cjs","sources":["../../../src/value/slice.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSliceValueConfig<\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n> = {\n\ttype?: string;\n\tlabel?: string | null;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const slice = <\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n>(\n\tconfig: MockSliceValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.slice({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\tconst sliceLabel =\n\t\tconfig.label !== undefined\n\t\t\t? config.label\n\t\t\t: changeCase.capitalCase(faker.words(faker.range(1, 2)));\n\n\tconst itemsCount =\n\t\tmodel.repeat && Object.keys(model.repeat).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tid: faker.hash(11),\n\t\tslice_type: sliceType,\n\t\tslice_label: sliceLabel,\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model[\"non-repeat\"] || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.repeat || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["createFaker","modelGen.slice","generateFieldId","changeCase.capitalCase","valueForModelMap"],"mappings":";;;;;;;AAwBa,MAAA,QAAQ,CAGpB,WACsB;AACtB,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASC,QAAAA,MAAe,EAAE,OAAO;AAEtD,QAAM,YAAY,OAAO,QAAQC,gBAAAA,gBAAgB,EAAE,OAAO;AAC1D,QAAM,aACL,OAAO,UAAU,SACd,OAAO,QACPC,MAAAA,YAAuB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAEzD,QAAM,aACL,MAAM,UAAU,OAAO,KAAK,MAAM,MAAM,EAAE,SAAS,IAChD,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,IAAI,MAAM,KAAK,EAAE;AAAA,IACjB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAASC,iBAAAA,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,YAAY,KAAK,CAAE;AAAA,MAC9B,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAOA,kCAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,UAAU,CAAE;AAAA,QACvB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;;"}
|
package/dist/value/slice.js
CHANGED
|
@@ -10,6 +10,7 @@ const slice = (config) => {
|
|
|
10
10
|
const sliceLabel = config.label !== void 0 ? config.label : capitalCase(faker.words(faker.range(1, 2)));
|
|
11
11
|
const itemsCount = model.repeat && Object.keys(model.repeat).length > 0 ? config.itemsCount ?? faker.range(1, 6) : 0;
|
|
12
12
|
return {
|
|
13
|
+
id: faker.hash(11),
|
|
13
14
|
slice_type: sliceType,
|
|
14
15
|
slice_label: sliceLabel,
|
|
15
16
|
primary: valueForModelMap({
|
package/dist/value/slice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slice.js","sources":["../../../src/value/slice.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSliceValueConfig<\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n> = {\n\ttype?: string;\n\tlabel?: string | null;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const slice = <\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n>(\n\tconfig: MockSliceValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.slice({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\tconst sliceLabel =\n\t\tconfig.label !== undefined\n\t\t\t? config.label\n\t\t\t: changeCase.capitalCase(faker.words(faker.range(1, 2)));\n\n\tconst itemsCount =\n\t\tmodel.repeat && Object.keys(model.repeat).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tslice_type: sliceType,\n\t\tslice_label: sliceLabel,\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model[\"non-repeat\"] || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.repeat || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["modelGen.slice","changeCase.capitalCase"],"mappings":";;;;;AAwBa,MAAA,QAAQ,CAGpB,WACsB;AACtB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASA,QAAe,EAAE,OAAO;AAEtD,QAAM,YAAY,OAAO,QAAQ,gBAAgB,EAAE,OAAO;AAC1D,QAAM,aACL,OAAO,UAAU,SACd,OAAO,QACPC,YAAuB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAEzD,QAAM,aACL,MAAM,UAAU,OAAO,KAAK,MAAM,MAAM,EAAE,SAAS,IAChD,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,YAAY,KAAK,CAAE;AAAA,MAC9B,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAO,iBAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,UAAU,CAAE;AAAA,QACvB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"slice.js","sources":["../../../src/value/slice.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { MockValueConfig, ModelValue } from \"../types\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { generateFieldId } from \"../lib/generateFieldId\";\nimport {\n\tvalueForModelMap,\n\tValueForModelMapConfigs,\n} from \"../lib/valueForModelMap\";\n\nimport * as modelGen from \"../model\";\n\nexport type MockSliceValueConfig<\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n> = {\n\ttype?: string;\n\tlabel?: string | null;\n\titemsCount?: number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model>;\n\nexport const slice = <\n\tModel extends prismic.CustomTypeModelSlice = prismic.CustomTypeModelSlice,\n>(\n\tconfig: MockSliceValueConfig<Model>,\n): ModelValue<Model> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tconst model = config.model || modelGen.slice({ faker });\n\n\tconst sliceType = config.type ?? generateFieldId({ faker });\n\tconst sliceLabel =\n\t\tconfig.label !== undefined\n\t\t\t? config.label\n\t\t\t: changeCase.capitalCase(faker.words(faker.range(1, 2)));\n\n\tconst itemsCount =\n\t\tmodel.repeat && Object.keys(model.repeat).length > 0\n\t\t\t? config.itemsCount ?? faker.range(1, 6)\n\t\t\t: 0;\n\n\treturn {\n\t\tid: faker.hash(11),\n\t\tslice_type: sliceType,\n\t\tslice_label: sliceLabel,\n\t\tprimary: valueForModelMap({\n\t\t\tfaker,\n\t\t\tmap: model[\"non-repeat\"] || {},\n\t\t\tconfigs: config.primaryFieldConfigs,\n\t\t}),\n\t\titems: Array(itemsCount)\n\t\t\t.fill(undefined)\n\t\t\t.map(() => {\n\t\t\t\treturn valueForModelMap({\n\t\t\t\t\tfaker,\n\t\t\t\t\tmap: model.repeat || {},\n\t\t\t\t\tconfigs: config.itemsFieldConfigs,\n\t\t\t\t});\n\t\t\t}),\n\t} as ModelValue<Model>;\n};\n"],"names":["modelGen.slice","changeCase.capitalCase"],"mappings":";;;;;AAwBa,MAAA,QAAQ,CAGpB,WACsB;AACtB,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,QAAM,QAAQ,OAAO,SAASA,QAAe,EAAE,OAAO;AAEtD,QAAM,YAAY,OAAO,QAAQ,gBAAgB,EAAE,OAAO;AAC1D,QAAM,aACL,OAAO,UAAU,SACd,OAAO,QACPC,YAAuB,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAEzD,QAAM,aACL,MAAM,UAAU,OAAO,KAAK,MAAM,MAAM,EAAE,SAAS,IAChD,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IACrC;AAEG,SAAA;AAAA,IACN,IAAI,MAAM,KAAK,EAAE;AAAA,IACjB,YAAY;AAAA,IACZ,aAAa;AAAA,IACb,SAAS,iBAAiB;AAAA,MACzB;AAAA,MACA,KAAK,MAAM,YAAY,KAAK,CAAE;AAAA,MAC9B,SAAS,OAAO;AAAA,IAAA,CAChB;AAAA,IACD,OAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;AACT,aAAO,iBAAiB;AAAA,QACvB;AAAA,QACA,KAAK,MAAM,UAAU,CAAE;AAAA,QACvB,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA,CACD;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/mock",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -55,14 +55,13 @@
|
|
|
55
55
|
"size": "size-limit",
|
|
56
56
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
|
57
57
|
"types": "tsc --noEmit",
|
|
58
|
-
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
59
|
-
"unit:watch": "npm run unit -- --watch"
|
|
58
|
+
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
60
59
|
},
|
|
61
60
|
"dependencies": {
|
|
62
61
|
"change-case": "^5.4.4"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
|
-
"@prismicio/client": "^7.
|
|
64
|
+
"@prismicio/client": "^7.8.1",
|
|
66
65
|
"@size-limit/preset-small-lib": "^11.1.2",
|
|
67
66
|
"@types/node": "^20.12.7",
|
|
68
67
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
package/src/api/repository.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
Document extends prismic.PrismicDocument,
|
|
5
|
-
> = {
|
|
3
|
+
type BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {
|
|
6
4
|
document: Document;
|
|
7
|
-
text?: string;
|
|
8
5
|
};
|
|
9
6
|
|
|
10
7
|
export const buildContentRelationshipField = <
|
|
11
8
|
Document extends prismic.PrismicDocument,
|
|
12
9
|
>(
|
|
13
|
-
config:
|
|
10
|
+
config: BuildEmbedFieldConfig<Document>,
|
|
14
11
|
): prismic.ContentRelationshipField<
|
|
15
12
|
Document["type"],
|
|
16
13
|
Document["lang"],
|
|
@@ -27,6 +24,5 @@ export const buildContentRelationshipField = <
|
|
|
27
24
|
url: config.document.url || undefined,
|
|
28
25
|
slug: config.document.slugs[0],
|
|
29
26
|
isBroken: false,
|
|
30
|
-
text: config.text,
|
|
31
27
|
};
|
|
32
28
|
};
|
|
@@ -31,6 +31,7 @@ export const buildImageFieldImage = <
|
|
|
31
31
|
): prismic.ImageFieldImage<State> => {
|
|
32
32
|
if (config.state === "empty") {
|
|
33
33
|
return {
|
|
34
|
+
id: null,
|
|
34
35
|
url: null,
|
|
35
36
|
dimensions: null,
|
|
36
37
|
alt: null,
|
|
@@ -51,6 +52,7 @@ export const buildImageFieldImage = <
|
|
|
51
52
|
url.searchParams.set("fit", "crop");
|
|
52
53
|
|
|
53
54
|
return {
|
|
55
|
+
id: faker.hash(11),
|
|
54
56
|
url: url.toString(),
|
|
55
57
|
dimensions,
|
|
56
58
|
alt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),
|
|
@@ -5,33 +5,20 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
type MockContentRelationshipModel<
|
|
9
|
-
CustomTypeIDs extends string = string,
|
|
10
|
-
Tags extends string = string,
|
|
11
|
-
WithText extends boolean = boolean,
|
|
12
|
-
> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
|
|
13
|
-
config: WithText extends true
|
|
14
|
-
? { text: prismic.CustomTypeModelKeyTextField }
|
|
15
|
-
: { text?: undefined };
|
|
16
|
-
};
|
|
17
|
-
|
|
18
8
|
export type MockContentRelationshipModelConfig<
|
|
19
9
|
CustomTypeIDs extends string = string,
|
|
20
10
|
Tags extends string = string,
|
|
21
|
-
WithText extends boolean = boolean,
|
|
22
11
|
> = {
|
|
23
12
|
customTypeIDs?: readonly CustomTypeIDs[];
|
|
24
13
|
tags?: readonly Tags[];
|
|
25
|
-
withText?: WithText;
|
|
26
14
|
} & MockModelConfig;
|
|
27
15
|
|
|
28
16
|
export const contentRelationship = <
|
|
29
17
|
CustomTypeIDs extends string,
|
|
30
18
|
Tags extends string,
|
|
31
|
-
WithText extends boolean = boolean,
|
|
32
19
|
>(
|
|
33
|
-
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags
|
|
34
|
-
):
|
|
20
|
+
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,
|
|
21
|
+
): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {
|
|
35
22
|
const faker = config.faker || createFaker(config.seed);
|
|
36
23
|
|
|
37
24
|
return {
|
|
@@ -42,9 +29,6 @@ export const contentRelationship = <
|
|
|
42
29
|
select: prismic.CustomTypeModelLinkSelectType.Document,
|
|
43
30
|
customtypes: config.customTypeIDs,
|
|
44
31
|
tags: config.tags,
|
|
45
|
-
text: config.withText
|
|
46
|
-
? { type: prismic.CustomTypeModelFieldType.Text }
|
|
47
|
-
: undefined,
|
|
48
32
|
},
|
|
49
|
-
}
|
|
33
|
+
};
|
|
50
34
|
};
|
package/src/model/link.ts
CHANGED
|
@@ -5,33 +5,24 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
type MockLinkModel<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
: { text?: undefined };
|
|
19
|
-
};
|
|
8
|
+
export type MockLinkModel<AllowTargetBlank extends boolean = boolean> =
|
|
9
|
+
prismic.CustomTypeModelLinkField & {
|
|
10
|
+
config: AllowTargetBlank extends true
|
|
11
|
+
? {
|
|
12
|
+
allowTargetBlank: true;
|
|
13
|
+
}
|
|
14
|
+
: {
|
|
15
|
+
allowTargetBlank?: undefined;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
20
18
|
|
|
21
|
-
export type MockLinkModelConfig<
|
|
22
|
-
AllowTargetBlank extends boolean = boolean,
|
|
23
|
-
WithText extends boolean = boolean,
|
|
24
|
-
> = {
|
|
19
|
+
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
|
|
25
20
|
allowTargetBlank?: AllowTargetBlank;
|
|
26
|
-
withText?: WithText;
|
|
27
21
|
} & MockModelConfig;
|
|
28
22
|
|
|
29
|
-
export const link = <
|
|
30
|
-
AllowTargetBlank
|
|
31
|
-
|
|
32
|
-
>(
|
|
33
|
-
config: MockLinkModelConfig<AllowTargetBlank, WithText>,
|
|
34
|
-
): MockLinkModel<AllowTargetBlank, WithText> => {
|
|
23
|
+
export const link = <AllowTargetBlank extends boolean = boolean>(
|
|
24
|
+
config: MockLinkModelConfig<AllowTargetBlank>,
|
|
25
|
+
): MockLinkModel<AllowTargetBlank> => {
|
|
35
26
|
const faker = config.faker || createFaker(config.seed);
|
|
36
27
|
|
|
37
28
|
return {
|
|
@@ -44,9 +35,6 @@ export const link = <
|
|
|
44
35
|
("allowTargetBlank" in config
|
|
45
36
|
? config.allowTargetBlank
|
|
46
37
|
: faker.boolean()) || undefined,
|
|
47
|
-
text: config.withText
|
|
48
|
-
? { type: prismic.CustomTypeModelFieldType.Text }
|
|
49
|
-
: undefined,
|
|
50
38
|
},
|
|
51
|
-
} as MockLinkModel<AllowTargetBlank
|
|
39
|
+
} as MockLinkModel<AllowTargetBlank>;
|
|
52
40
|
};
|
package/src/model/linkToMedia.ts
CHANGED
|
@@ -5,20 +5,11 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
prismic.CustomTypeModelLinkToMediaField & {
|
|
10
|
-
config: WithText extends true
|
|
11
|
-
? { text: prismic.CustomTypeModelKeyTextField }
|
|
12
|
-
: { text?: undefined };
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
|
|
16
|
-
withText?: WithText;
|
|
17
|
-
} & MockModelConfig;
|
|
8
|
+
export type MockLinkToMediaModelConfig = MockModelConfig;
|
|
18
9
|
|
|
19
|
-
export const linkToMedia =
|
|
20
|
-
config: MockLinkToMediaModelConfig
|
|
21
|
-
):
|
|
10
|
+
export const linkToMedia = (
|
|
11
|
+
config: MockLinkToMediaModelConfig,
|
|
12
|
+
): prismic.CustomTypeModelLinkToMediaField => {
|
|
22
13
|
const faker = config.faker || createFaker(config.seed);
|
|
23
14
|
|
|
24
15
|
return {
|
|
@@ -27,11 +18,6 @@ export const linkToMedia = <WithText extends boolean = boolean>(
|
|
|
27
18
|
label: changeCase.capitalCase(faker.word()),
|
|
28
19
|
placeholder: changeCase.sentenceCase(faker.words(3)),
|
|
29
20
|
select: prismic.CustomTypeModelLinkSelectType.Media,
|
|
30
|
-
text: config.withText
|
|
31
|
-
? {
|
|
32
|
-
type: prismic.CustomTypeModelFieldType.Text,
|
|
33
|
-
}
|
|
34
|
-
: undefined,
|
|
35
21
|
},
|
|
36
|
-
}
|
|
22
|
+
};
|
|
37
23
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import * as changeCase from "change-case";
|
|
3
2
|
|
|
4
3
|
import { buildContentRelationshipField } from "../lib/buildContentRelationshipField";
|
|
5
4
|
import { createFaker } from "../lib/createFaker";
|
|
@@ -21,9 +20,6 @@ export type MockContentRelationshipValueConfig<
|
|
|
21
20
|
prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField,
|
|
22
21
|
State extends prismic.FieldState = prismic.FieldState,
|
|
23
22
|
> = {
|
|
24
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
25
|
-
? false
|
|
26
|
-
: boolean;
|
|
27
23
|
/**
|
|
28
24
|
* A list of potential documents to which the field can be linked.
|
|
29
25
|
*/
|
|
@@ -105,10 +101,6 @@ export const contentRelationship = <
|
|
|
105
101
|
|
|
106
102
|
return buildContentRelationshipField({
|
|
107
103
|
document,
|
|
108
|
-
text:
|
|
109
|
-
config.withText ?? model.config?.text
|
|
110
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
111
|
-
: undefined,
|
|
112
104
|
}) as unknown as MockContentRelationshipValue<Model, State>;
|
|
113
105
|
}
|
|
114
106
|
};
|
package/src/value/link.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
|
-
import * as changeCase from "change-case";
|
|
3
2
|
|
|
4
3
|
import { createFaker } from "../lib/createFaker";
|
|
5
4
|
|
|
@@ -23,9 +22,6 @@ export type MockLinkValueConfig<
|
|
|
23
22
|
>["allowTargetBlank"] extends undefined
|
|
24
23
|
? false
|
|
25
24
|
: boolean;
|
|
26
|
-
withText?: NonNullable<Model["config"]>["text"] extends undefined
|
|
27
|
-
? false
|
|
28
|
-
: boolean;
|
|
29
25
|
/**
|
|
30
26
|
* A list of potential documents to which the field can be linked.
|
|
31
27
|
*/
|
|
@@ -79,7 +75,6 @@ export const link = <
|
|
|
79
75
|
faker,
|
|
80
76
|
state: config.state,
|
|
81
77
|
linkableDocuments: config.linkableDocuments,
|
|
82
|
-
withText: config.withText,
|
|
83
78
|
}) as unknown as MockLinkValue<LinkType, State>;
|
|
84
79
|
}
|
|
85
80
|
|
|
@@ -87,7 +82,6 @@ export const link = <
|
|
|
87
82
|
return linkToMedia({
|
|
88
83
|
faker,
|
|
89
84
|
state: config.state,
|
|
90
|
-
withText: config.withText,
|
|
91
85
|
}) as MockLinkValue<LinkType, State>;
|
|
92
86
|
}
|
|
93
87
|
|
|
@@ -103,10 +97,6 @@ export const link = <
|
|
|
103
97
|
(model.config?.allowTargetBlank && faker.boolean())
|
|
104
98
|
? "_blank"
|
|
105
99
|
: undefined,
|
|
106
|
-
text:
|
|
107
|
-
config.withText ?? model.config?.text
|
|
108
|
-
? changeCase.sentenceCase(faker.words(2))
|
|
109
|
-
: undefined,
|
|
110
100
|
} as MockLinkValue<LinkType, State>;
|
|
111
101
|
}
|
|
112
102
|
}
|