@prismicio/mock 0.3.8-alpha.0 → 0.3.8-alpha.1

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.
@@ -30,9 +30,7 @@ const contentRelationship = (config) => {
30
30
  select: prismic__namespace.CustomTypeModelLinkSelectType.Document,
31
31
  customtypes: config.customTypeIDs,
32
32
  tags: config.tags,
33
- text: config.text ? {
34
- type: prismic__namespace.CustomTypeModelFieldType.Text
35
- } : void 0
33
+ text: config.withText ? { type: prismic__namespace.CustomTypeModelFieldType.Text } : void 0
36
34
  }
37
35
  };
38
36
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contentRelationship.cjs","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { LinkText } from \"./link\";\nimport { MockModelConfig } from \"../types\";\n\ntype MockContentRelationshipModel<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tText extends boolean = boolean,\n> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {\n\tconfig: Text extends true\n\t\t? {\n\t\t\t\ttext: LinkText;\n\t\t\t}\n\t\t: {\n\t\t\t\ttext?: undefined;\n\t\t\t};\n};\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tText extends boolean = boolean,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n\tText extends boolean = boolean,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, Text>,\n): MockContentRelationshipModel<CustomTypeIDs, Tags, Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockContentRelationshipModel<CustomTypeIDs, Tags, Text>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCa,MAAA,sBAAsB,CAKlC,WAC4D;AAC5D,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,MACb,MAAM,OAAO,OACV;AAAA,QACA,MAAMA,mBAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;;"}
1
+ {"version":3,"file":"contentRelationship.cjs","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockContentRelationshipModel<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tWithText extends boolean = boolean,\n> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {\n\tconfig: WithText extends true\n\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t: { text?: undefined };\n};\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tWithText extends boolean = boolean,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n\tWithText extends boolean = boolean,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>,\n): MockContentRelationshipModel<CustomTypeIDs, Tags, WithText> => {\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\ttext: config.withText\n\t\t\t\t? { type: prismic.CustomTypeModelFieldType.Text }\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2Ba,MAAA,sBAAsB,CAKlC,WACgE;AAChE,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,MACb,MAAM,OAAO,WACV,EAAE,MAAMA,mBAAQ,yBAAyB,KACzC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;;"}
@@ -1,17 +1,16 @@
1
1
  import * as prismic from "@prismicio/client";
2
- import { LinkText } from "./link";
3
2
  import { MockModelConfig } from "../types";
4
- type MockContentRelationshipModel<CustomTypeIDs extends string = string, Tags extends string = string, Text extends boolean = boolean> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
5
- config: Text extends true ? {
6
- text: LinkText;
3
+ type MockContentRelationshipModel<CustomTypeIDs extends string = string, Tags extends string = string, WithText extends boolean = boolean> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
4
+ config: WithText extends true ? {
5
+ text: prismic.CustomTypeModelKeyTextField;
7
6
  } : {
8
7
  text?: undefined;
9
8
  };
10
9
  };
11
- export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string, Text extends boolean = boolean> = {
10
+ export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string, WithText extends boolean = boolean> = {
12
11
  customTypeIDs?: readonly CustomTypeIDs[];
13
12
  tags?: readonly Tags[];
14
- text?: Text;
13
+ withText?: WithText;
15
14
  } & MockModelConfig;
16
- export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string, Text extends boolean = boolean>(config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, Text>) => MockContentRelationshipModel<CustomTypeIDs, Tags, Text>;
15
+ export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string, WithText extends boolean = boolean>(config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>) => MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;
17
16
  export {};
@@ -11,9 +11,7 @@ const contentRelationship = (config) => {
11
11
  select: prismic.CustomTypeModelLinkSelectType.Document,
12
12
  customtypes: config.customTypeIDs,
13
13
  tags: config.tags,
14
- text: config.text ? {
15
- type: prismic.CustomTypeModelFieldType.Text
16
- } : void 0
14
+ text: config.withText ? { type: prismic.CustomTypeModelFieldType.Text } : void 0
17
15
  }
18
16
  };
19
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"contentRelationship.js","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { LinkText } from \"./link\";\nimport { MockModelConfig } from \"../types\";\n\ntype MockContentRelationshipModel<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tText extends boolean = boolean,\n> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {\n\tconfig: Text extends true\n\t\t? {\n\t\t\t\ttext: LinkText;\n\t\t\t}\n\t\t: {\n\t\t\t\ttext?: undefined;\n\t\t\t};\n};\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tText extends boolean = boolean,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n\tText extends boolean = boolean,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, Text>,\n): MockContentRelationshipModel<CustomTypeIDs, Tags, Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockContentRelationshipModel<CustomTypeIDs, Tags, Text>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAgCa,MAAA,sBAAsB,CAKlC,WAC4D;AAC5D,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,MACb,MAAM,OAAO,OACV;AAAA,QACA,MAAM,QAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
1
+ {"version":3,"file":"contentRelationship.js","sources":["../../../src/model/contentRelationship.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockContentRelationshipModel<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tWithText extends boolean = boolean,\n> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {\n\tconfig: WithText extends true\n\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t: { text?: undefined };\n};\n\nexport type MockContentRelationshipModelConfig<\n\tCustomTypeIDs extends string = string,\n\tTags extends string = string,\n\tWithText extends boolean = boolean,\n> = {\n\tcustomTypeIDs?: readonly CustomTypeIDs[];\n\ttags?: readonly Tags[];\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const contentRelationship = <\n\tCustomTypeIDs extends string,\n\tTags extends string,\n\tWithText extends boolean = boolean,\n>(\n\tconfig: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>,\n): MockContentRelationshipModel<CustomTypeIDs, Tags, WithText> => {\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\ttext: config.withText\n\t\t\t\t? { type: prismic.CustomTypeModelFieldType.Text }\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AA2Ba,MAAA,sBAAsB,CAKlC,WACgE;AAChE,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,MACb,MAAM,OAAO,WACV,EAAE,MAAM,QAAQ,yBAAyB,KACzC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
@@ -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
- text: config.text ? {
33
- type: prismic__namespace.CustomTypeModelFieldType.Text
34
- } : void 0
32
+ text: config.withText ? { type: prismic__namespace.CustomTypeModelFieldType.Text } : void 0
35
33
  }
36
34
  };
37
35
  };
@@ -1 +1 @@
1
- {"version":3,"file":"link.cjs","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type LinkText = prismic.CustomTypeModelKeyTextField;\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? {\n\t\t\t\tallowTargetBlank: true;\n\t\t\t}\n\t\t: {\n\t\t\t\tallowTargetBlank?: undefined;\n\t\t\t};\n} & {\n\tconfig: Text extends true\n\t\t? {\n\t\t\t\ttext: LinkText;\n\t\t\t}\n\t\t: {\n\t\t\t\ttext?: undefined;\n\t\t\t};\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, Text>,\n): MockLinkModel<AllowTargetBlank, Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, Text>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsCa,MAAA,OAAO,CAInB,WAC0C;AAC1C,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,MAAM,OAAO,OACV;AAAA,QACA,MAAMF,mBAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;;"}
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\tWithText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: WithText extends true\n\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t: { text?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tWithText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tWithText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, WithText>,\n): MockLinkModel<AllowTargetBlank, WithText> => {\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\ttext: config.withText\n\t\t\t\t? { type: prismic.CustomTypeModelFieldType.Text }\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, WithText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4Ba,MAAA,OAAO,CAInB,WAC8C;AAC9C,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,MAAM,OAAO,WACV,EAAE,MAAMF,mBAAQ,yBAAyB,KACzC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;;"}
@@ -1,22 +1,21 @@
1
1
  import * as prismic from "@prismicio/client";
2
2
  import { MockModelConfig } from "../types";
3
- export type LinkText = prismic.CustomTypeModelKeyTextField;
4
- type MockLinkModel<AllowTargetBlank extends boolean = boolean, Text extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
3
+ type MockLinkModel<AllowTargetBlank extends boolean = boolean, WithText 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: Text extends true ? {
12
- text: LinkText;
10
+ config: WithText extends true ? {
11
+ text: prismic.CustomTypeModelKeyTextField;
13
12
  } : {
14
13
  text?: undefined;
15
14
  };
16
15
  };
17
- export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, Text extends boolean = boolean> = {
16
+ export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, WithText extends boolean = boolean> = {
18
17
  allowTargetBlank?: AllowTargetBlank;
19
- text?: Text;
18
+ withText?: WithText;
20
19
  } & MockModelConfig;
21
- export declare const link: <AllowTargetBlank extends boolean = boolean, Text extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, Text>) => MockLinkModel<AllowTargetBlank, Text>;
20
+ export declare const link: <AllowTargetBlank extends boolean = boolean, WithText extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, WithText>) => MockLinkModel<AllowTargetBlank, WithText>;
22
21
  export {};
@@ -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
- text: config.text ? {
14
- type: prismic.CustomTypeModelFieldType.Text
15
- } : void 0
13
+ text: config.withText ? { type: prismic.CustomTypeModelFieldType.Text } : void 0
16
14
  }
17
15
  };
18
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"link.js","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\nexport type LinkText = prismic.CustomTypeModelKeyTextField;\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? {\n\t\t\t\tallowTargetBlank: true;\n\t\t\t}\n\t\t: {\n\t\t\t\tallowTargetBlank?: undefined;\n\t\t\t};\n} & {\n\tconfig: Text extends true\n\t\t? {\n\t\t\t\ttext: LinkText;\n\t\t\t}\n\t\t: {\n\t\t\t\ttext?: undefined;\n\t\t\t};\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, Text>,\n): MockLinkModel<AllowTargetBlank, Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, Text>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAsCa,MAAA,OAAO,CAInB,WAC0C;AAC1C,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,MAAM,OAAO,OACV;AAAA,QACA,MAAM,QAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
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\tWithText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: WithText extends true\n\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t: { text?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tWithText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tWithText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, WithText>,\n): MockLinkModel<AllowTargetBlank, WithText> => {\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\ttext: config.withText\n\t\t\t\t? { type: prismic.CustomTypeModelFieldType.Text }\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, WithText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AA4Ba,MAAA,OAAO,CAInB,WAC8C;AAC9C,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,MAAM,OAAO,WACV,EAAE,MAAM,QAAQ,yBAAyB,KACzC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
@@ -28,7 +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
- text: config.text ? {
31
+ text: config.withText ? {
32
32
  type: prismic__namespace.CustomTypeModelFieldType.Text
33
33
  } : void 0
34
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 { LinkText } from \"./link\";\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkToMediaModel<Text extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: Text extends true\n\t\t\t? {\n\t\t\t\t\ttext: LinkText;\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttext?: undefined;\n\t\t\t\t};\n\t};\n\nexport type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const linkToMedia = <Text extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<Text>,\n): MockLinkToMediaModel<Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkToMediaModel<Text>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuBa,MAAA,cAAc,CAC1B,WAC+B;AAC/B,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,MAAM,OAAO,OACV;AAAA,QACA,MAAMA,mBAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;;"}
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<WithText extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: WithText extends true\n\t\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t\t: { text?: undefined };\n\t};\n\nexport type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const linkToMedia = <WithText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<WithText>,\n): MockLinkToMediaModel<WithText> => {\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\ttext: config.withText\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkToMediaModel<WithText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkBa,MAAA,cAAc,CAC1B,WACmC;AACnC,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,MAAM,OAAO,WACV;AAAA,QACA,MAAMA,mBAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;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<Text extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
5
- config: Text extends true ? {
6
- text: LinkText;
3
+ type MockLinkToMediaModel<WithText extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
4
+ config: WithText extends true ? {
5
+ text: prismic.CustomTypeModelKeyTextField;
7
6
  } : {
8
7
  text?: undefined;
9
8
  };
10
9
  };
11
- export type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {
12
- text?: Text;
10
+ export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
11
+ withText?: WithText;
13
12
  } & MockModelConfig;
14
- export declare const linkToMedia: <Text extends boolean = boolean>(config: MockLinkToMediaModelConfig<Text>) => MockLinkToMediaModel<Text>;
13
+ export declare const linkToMedia: <WithText extends boolean = boolean>(config: MockLinkToMediaModelConfig<WithText>) => MockLinkToMediaModel<WithText>;
15
14
  export {};
@@ -9,7 +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
- text: config.text ? {
12
+ text: config.withText ? {
13
13
  type: prismic.CustomTypeModelFieldType.Text
14
14
  } : void 0
15
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 { LinkText } from \"./link\";\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkToMediaModel<Text extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: Text extends true\n\t\t\t? {\n\t\t\t\t\ttext: LinkText;\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\ttext?: undefined;\n\t\t\t\t};\n\t};\n\nexport type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {\n\ttext?: Text;\n} & MockModelConfig;\n\nexport const linkToMedia = <Text extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<Text>,\n): MockLinkToMediaModel<Text> => {\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\ttext: config.text\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkToMediaModel<Text>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAuBa,MAAA,cAAc,CAC1B,WAC+B;AAC/B,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,MAAM,OAAO,OACV;AAAA,QACA,MAAM,QAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
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<WithText extends boolean = boolean> =\n\tprismic.CustomTypeModelLinkToMediaField & {\n\t\tconfig: WithText extends true\n\t\t\t? { text: prismic.CustomTypeModelKeyTextField }\n\t\t\t: { text?: undefined };\n\t};\n\nexport type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {\n\twithText?: WithText;\n} & MockModelConfig;\n\nexport const linkToMedia = <WithText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<WithText>,\n): MockLinkToMediaModel<WithText> => {\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\ttext: config.withText\n\t\t\t\t? {\n\t\t\t\t\t\ttype: prismic.CustomTypeModelFieldType.Text,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t},\n\t} as MockLinkToMediaModel<WithText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAkBa,MAAA,cAAc,CAC1B,WACmC;AACnC,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,MAAM,OAAO,WACV;AAAA,QACA,MAAM,QAAQ,yBAAyB;AAAA,MAEvC,IAAA;AAAA,IACH;AAAA,EAAA;AAEH;"}
@@ -41,13 +41,15 @@ const link = (config) => {
41
41
  return contentRelationship.contentRelationship({
42
42
  faker,
43
43
  state: config.state,
44
- linkableDocuments: config.linkableDocuments
44
+ linkableDocuments: config.linkableDocuments,
45
+ withText: config.withText
45
46
  });
46
47
  }
47
48
  case prismic__namespace.LinkType.Media: {
48
49
  return linkToMedia.linkToMedia({
49
50
  faker,
50
- state: config.state
51
+ state: config.state,
52
+ withText: config.withText
51
53
  });
52
54
  }
53
55
  case prismic__namespace.LinkType.Web:
@@ -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\"]>[\"text\"] 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\ttext:\n\t\t\t\t\t\tconfig.withText ?? model.config?.text\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,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,UACJ,MACC,OAAO,cAAY,WAAM,WAAN,mBAAc,QAC9BI,MAAW,aAAa,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;;"}
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\"]>[\"text\"] 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\twithText: config.withText,\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?.text\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,UAC1B,UAAU,OAAO;AAAA,QAAA,CACjB;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,cAAY,WAAM,WAAN,mBAAc,QAC9BI,MAAW,aAAa,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -22,13 +22,15 @@ const link = (config) => {
22
22
  return contentRelationship({
23
23
  faker,
24
24
  state: config.state,
25
- linkableDocuments: config.linkableDocuments
25
+ linkableDocuments: config.linkableDocuments,
26
+ withText: config.withText
26
27
  });
27
28
  }
28
29
  case prismic.LinkType.Media: {
29
30
  return linkToMedia({
30
31
  faker,
31
- state: config.state
32
+ state: config.state,
33
+ withText: config.withText
32
34
  });
33
35
  }
34
36
  case prismic.LinkType.Web:
@@ -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\"]>[\"text\"] 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\ttext:\n\t\t\t\t\t\tconfig.withText ?? model.config?.text\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,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,UACJ,MACC,OAAO,cAAY,WAAM,WAAN,mBAAc,QAC9BC,aAAwB,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;"}
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\"]>[\"text\"] 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\twithText: config.withText,\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?.text\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,UAC1B,UAAU,OAAO;AAAA,QAAA,CACjB;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,cAAY,WAAM,WAAN,mBAAc,QAC9BC,aAAwB,MAAM,MAAM,CAAC,CAAC,IACtC;AAAA,QAAA;AAAA,MAEN;AAAA,IACD;AAAA,EACD;AACD;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismicio/mock",
3
- "version": "0.3.8-alpha.0",
3
+ "version": "0.3.8-alpha.1",
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": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava --watch",
60
- "unit:update-1": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava --update-snapshots --match='creates mock field models for group field'"
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.0",
65
+ "@prismicio/client": "^7.9.0-alpha.1",
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",
@@ -3,40 +3,35 @@ 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
8
  type MockContentRelationshipModel<
10
9
  CustomTypeIDs extends string = string,
11
10
  Tags extends string = string,
12
- Text extends boolean = boolean,
11
+ WithText extends boolean = boolean,
13
12
  > = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
14
- config: Text extends true
15
- ? {
16
- text: LinkText;
17
- }
18
- : {
19
- text?: undefined;
20
- };
13
+ config: WithText extends true
14
+ ? { text: prismic.CustomTypeModelKeyTextField }
15
+ : { text?: undefined };
21
16
  };
22
17
 
23
18
  export type MockContentRelationshipModelConfig<
24
19
  CustomTypeIDs extends string = string,
25
20
  Tags extends string = string,
26
- Text extends boolean = boolean,
21
+ WithText extends boolean = boolean,
27
22
  > = {
28
23
  customTypeIDs?: readonly CustomTypeIDs[];
29
24
  tags?: readonly Tags[];
30
- text?: Text;
25
+ withText?: WithText;
31
26
  } & MockModelConfig;
32
27
 
33
28
  export const contentRelationship = <
34
29
  CustomTypeIDs extends string,
35
30
  Tags extends string,
36
- Text extends boolean = boolean,
31
+ WithText extends boolean = boolean,
37
32
  >(
38
- config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, Text>,
39
- ): MockContentRelationshipModel<CustomTypeIDs, Tags, Text> => {
33
+ config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>,
34
+ ): MockContentRelationshipModel<CustomTypeIDs, Tags, WithText> => {
40
35
  const faker = config.faker || createFaker(config.seed);
41
36
 
42
37
  return {
@@ -47,11 +42,9 @@ export const contentRelationship = <
47
42
  select: prismic.CustomTypeModelLinkSelectType.Document,
48
43
  customtypes: config.customTypeIDs,
49
44
  tags: config.tags,
50
- text: config.text
51
- ? {
52
- type: prismic.CustomTypeModelFieldType.Text,
53
- }
45
+ text: config.withText
46
+ ? { type: prismic.CustomTypeModelFieldType.Text }
54
47
  : undefined,
55
48
  },
56
- } as MockContentRelationshipModel<CustomTypeIDs, Tags, Text>;
49
+ } as MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;
57
50
  };
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
- Text extends boolean = boolean,
10
+ WithText extends boolean = boolean,
13
11
  > = prismic.CustomTypeModelLinkField & {
14
12
  config: AllowTargetBlank extends true
15
- ? {
16
- allowTargetBlank: true;
17
- }
18
- : {
19
- allowTargetBlank?: undefined;
20
- };
13
+ ? { allowTargetBlank: true }
14
+ : { allowTargetBlank?: undefined };
21
15
  } & {
22
- config: Text extends true
23
- ? {
24
- text: LinkText;
25
- }
26
- : {
27
- text?: undefined;
28
- };
16
+ config: WithText extends true
17
+ ? { text: prismic.CustomTypeModelKeyTextField }
18
+ : { text?: undefined };
29
19
  };
30
20
 
31
21
  export type MockLinkModelConfig<
32
22
  AllowTargetBlank extends boolean = boolean,
33
- Text extends boolean = boolean,
23
+ WithText extends boolean = boolean,
34
24
  > = {
35
25
  allowTargetBlank?: AllowTargetBlank;
36
- text?: Text;
26
+ withText?: WithText;
37
27
  } & MockModelConfig;
38
28
 
39
29
  export const link = <
40
30
  AllowTargetBlank extends boolean = boolean,
41
- Text extends boolean = boolean,
31
+ WithText extends boolean = boolean,
42
32
  >(
43
- config: MockLinkModelConfig<AllowTargetBlank, Text>,
44
- ): MockLinkModel<AllowTargetBlank, Text> => {
33
+ config: MockLinkModelConfig<AllowTargetBlank, WithText>,
34
+ ): MockLinkModel<AllowTargetBlank, WithText> => {
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
- text: config.text
58
- ? {
59
- type: prismic.CustomTypeModelFieldType.Text,
60
- }
47
+ text: config.withText
48
+ ? { type: prismic.CustomTypeModelFieldType.Text }
61
49
  : undefined,
62
50
  },
63
- } as MockLinkModel<AllowTargetBlank, Text>;
51
+ } as MockLinkModel<AllowTargetBlank, WithText>;
64
52
  };
@@ -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<Text extends boolean = boolean> =
8
+ type MockLinkToMediaModel<WithText extends boolean = boolean> =
10
9
  prismic.CustomTypeModelLinkToMediaField & {
11
- config: Text extends true
12
- ? {
13
- text: LinkText;
14
- }
15
- : {
16
- text?: undefined;
17
- };
10
+ config: WithText extends true
11
+ ? { text: prismic.CustomTypeModelKeyTextField }
12
+ : { text?: undefined };
18
13
  };
19
14
 
20
- export type MockLinkToMediaModelConfig<Text extends boolean = boolean> = {
21
- text?: Text;
15
+ export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
16
+ withText?: WithText;
22
17
  } & MockModelConfig;
23
18
 
24
- export const linkToMedia = <Text extends boolean = boolean>(
25
- config: MockLinkToMediaModelConfig<Text>,
26
- ): MockLinkToMediaModel<Text> => {
19
+ export const linkToMedia = <WithText extends boolean = boolean>(
20
+ config: MockLinkToMediaModelConfig<WithText>,
21
+ ): MockLinkToMediaModel<WithText> => {
27
22
  const faker = config.faker || createFaker(config.seed);
28
23
 
29
24
  return {
@@ -32,11 +27,11 @@ 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
- text: config.text
30
+ text: config.withText
36
31
  ? {
37
32
  type: prismic.CustomTypeModelFieldType.Text,
38
33
  }
39
34
  : undefined,
40
35
  },
41
- } as MockLinkToMediaModel<Text>;
36
+ } as MockLinkToMediaModel<WithText>;
42
37
  };
package/src/value/link.ts CHANGED
@@ -79,6 +79,7 @@ export const link = <
79
79
  faker,
80
80
  state: config.state,
81
81
  linkableDocuments: config.linkableDocuments,
82
+ withText: config.withText,
82
83
  }) as unknown as MockLinkValue<LinkType, State>;
83
84
  }
84
85
 
@@ -86,6 +87,7 @@ export const link = <
86
87
  return linkToMedia({
87
88
  faker,
88
89
  state: config.state,
90
+ withText: config.withText,
89
91
  }) as MockLinkValue<LinkType, State>;
90
92
  }
91
93