@prismicio/mock 0.4.0 → 0.5.0-alpha.0
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/model/createModelMockFactory.d.ts +12 -0
- package/dist/model/link.cjs +2 -1
- package/dist/model/link.cjs.map +1 -1
- package/dist/model/link.d.ts +10 -3
- package/dist/model/link.js +2 -1
- package/dist/model/link.js.map +1 -1
- package/dist/model/linkToMedia.cjs +2 -1
- package/dist/model/linkToMedia.cjs.map +1 -1
- package/dist/model/linkToMedia.d.ts +10 -3
- package/dist/model/linkToMedia.js +2 -1
- package/dist/model/linkToMedia.js.map +1 -1
- package/package.json +3 -3
- package/src/model/link.ts +11 -3
- package/src/model/linkToMedia.ts +18 -8
|
@@ -61,6 +61,12 @@ export declare class ModelMockFactory {
|
|
|
61
61
|
} | {
|
|
62
62
|
allowText?: undefined;
|
|
63
63
|
};
|
|
64
|
+
} & {
|
|
65
|
+
config: {
|
|
66
|
+
repeat: true;
|
|
67
|
+
} | {
|
|
68
|
+
repeat?: undefined;
|
|
69
|
+
};
|
|
64
70
|
};
|
|
65
71
|
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField & {
|
|
66
72
|
config: {
|
|
@@ -68,6 +74,12 @@ export declare class ModelMockFactory {
|
|
|
68
74
|
} | {
|
|
69
75
|
allowText?: undefined;
|
|
70
76
|
};
|
|
77
|
+
} & {
|
|
78
|
+
config: {
|
|
79
|
+
repeat: true;
|
|
80
|
+
} | {
|
|
81
|
+
repeat?: undefined;
|
|
82
|
+
};
|
|
71
83
|
};
|
|
72
84
|
number(config?: WithoutFakerConfig<MockNumberModelConfig>): prismic.CustomTypeModelNumberField;
|
|
73
85
|
richText<WithMultipleBlocks extends boolean = boolean>(config?: WithoutFakerConfig<MockRichTextModelConfig<WithMultipleBlocks>>): WithMultipleBlocks extends true ? prismic.CustomTypeModelRichTextMultiField : prismic.CustomTypeModelRichTextSingleField;
|
package/dist/model/link.cjs
CHANGED
|
@@ -29,7 +29,8 @@ 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
|
-
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
32
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0,
|
|
33
|
+
repeat: ("repeat" in config ? config.repeat : faker.boolean()) || void 0
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
};
|
package/dist/model/link.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.cjs","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText>,\n): MockLinkModel<AllowTargetBlank, AllowText> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"link.cjs","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n} & {\n\tconfig: Repeat extends true ? { repeat: true } : { repeat?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n\trepeat?: Repeat;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText, Repeat>,\n): MockLinkModel<AllowTargetBlank, AllowText, Repeat> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t\trepeat:\n\t\t\t\t(\"repeat\" in config ? config.repeat : faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText, Repeat>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiCa,MAAA,OAAO,CAKnB,WACuD;AACvD,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAMC,mBAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOC,MAAuB,YAAA,MAAM,MAAM;AAAA,MAC1C,aAAaC,MAAAA,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ;AAAA,MACR,mBACE,sBAAsB,SACpB,OAAO,mBACP,MAAM,QAAc,MAAA;AAAA,MACxB,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,MACD,SACE,YAAY,SAAS,OAAO,SAAS,MAAM,QAAc,MAAA;AAAA,IAC3D;AAAA,EAAA;AAEH;;"}
|
package/dist/model/link.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockModelConfig } from "../types";
|
|
3
|
-
type MockLinkModel<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
3
|
+
type MockLinkModel<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean, Repeat extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
|
|
4
4
|
config: AllowTargetBlank extends true ? {
|
|
5
5
|
allowTargetBlank: true;
|
|
6
6
|
} : {
|
|
@@ -12,10 +12,17 @@ type MockLinkModel<AllowTargetBlank extends boolean = boolean, AllowText extends
|
|
|
12
12
|
} : {
|
|
13
13
|
allowText?: undefined;
|
|
14
14
|
};
|
|
15
|
+
} & {
|
|
16
|
+
config: Repeat extends true ? {
|
|
17
|
+
repeat: true;
|
|
18
|
+
} : {
|
|
19
|
+
repeat?: undefined;
|
|
20
|
+
};
|
|
15
21
|
};
|
|
16
|
-
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean> = {
|
|
22
|
+
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean, Repeat extends boolean = boolean> = {
|
|
17
23
|
allowTargetBlank?: AllowTargetBlank;
|
|
18
24
|
allowText?: AllowText;
|
|
25
|
+
repeat?: Repeat;
|
|
19
26
|
} & MockModelConfig;
|
|
20
|
-
export declare const link: <AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, AllowText>) => MockLinkModel<AllowTargetBlank, AllowText>;
|
|
27
|
+
export declare const link: <AllowTargetBlank extends boolean = boolean, AllowText extends boolean = boolean, Repeat extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, AllowText, Repeat>) => MockLinkModel<AllowTargetBlank, AllowText, Repeat>;
|
|
21
28
|
export {};
|
package/dist/model/link.js
CHANGED
|
@@ -10,7 +10,8 @@ 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
|
-
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
13
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0,
|
|
14
|
+
repeat: ("repeat" in config ? config.repeat : faker.boolean()) || void 0
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
};
|
package/dist/model/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText>,\n): MockLinkModel<AllowTargetBlank, AllowText> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../../src/model/link.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockModelConfig } from \"../types\";\n\ntype MockLinkModel<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = prismic.CustomTypeModelLinkField & {\n\tconfig: AllowTargetBlank extends true\n\t\t? { allowTargetBlank: true }\n\t\t: { allowTargetBlank?: undefined };\n} & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n} & {\n\tconfig: Repeat extends true ? { repeat: true } : { repeat?: undefined };\n};\n\nexport type MockLinkModelConfig<\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = {\n\tallowTargetBlank?: AllowTargetBlank;\n\tallowText?: AllowText;\n\trepeat?: Repeat;\n} & MockModelConfig;\n\nexport const link = <\n\tAllowTargetBlank extends boolean = boolean,\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n>(\n\tconfig: MockLinkModelConfig<AllowTargetBlank, AllowText, Repeat>,\n): MockLinkModel<AllowTargetBlank, AllowText, Repeat> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: null,\n\t\t\tallowTargetBlank:\n\t\t\t\t(\"allowTargetBlank\" in config\n\t\t\t\t\t? config.allowTargetBlank\n\t\t\t\t\t: faker.boolean()) || undefined,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t\trepeat:\n\t\t\t\t(\"repeat\" in config ? config.repeat : faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkModel<AllowTargetBlank, AllowText, Repeat>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AAiCa,MAAA,OAAO,CAKnB,WACuD;AACvD,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAM,QAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOA,YAAuB,MAAM,MAAM;AAAA,MAC1C,aAAaC,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ;AAAA,MACR,mBACE,sBAAsB,SACpB,OAAO,mBACP,MAAM,QAAc,MAAA;AAAA,MACxB,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,MACD,SACE,YAAY,SAAS,OAAO,SAAS,MAAM,QAAc,MAAA;AAAA,IAC3D;AAAA,EAAA;AAEH;"}
|
|
@@ -28,7 +28,8 @@ 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
|
-
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
31
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0,
|
|
32
|
+
repeat: ("repeat" in config ? config.repeat : faker.boolean()) || void 0
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
};
|
|
@@ -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 { MockModelConfig } from \"../types\";\n\ntype MockLinkToMediaModel
|
|
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<\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = prismic.CustomTypeModelLinkToMediaField & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n} & {\n\tconfig: Repeat extends true ? { repeat: true } : { repeat?: undefined };\n};\n\nexport type MockLinkToMediaModelConfig<\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = MockModelConfig & {\n\tallowText?: AllowText;\n\trepeat?: Repeat;\n};\n\nexport const linkToMedia = <AllowText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<AllowText>,\n): MockLinkToMediaModel<AllowText> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Media,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t\trepeat:\n\t\t\t\t(\"repeat\" in config ? config.repeat : faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkToMediaModel<AllowText>;\n};\n"],"names":["createFaker","prismic","changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0Ba,MAAA,cAAc,CAC1B,WACoC;AACpC,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAMC,mBAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOC,MAAuB,YAAA,MAAM,MAAM;AAAA,MAC1C,aAAaC,MAAAA,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQF,mBAAQ,8BAA8B;AAAA,MAC9C,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,MACD,SACE,YAAY,SAAS,OAAO,SAAS,MAAM,QAAc,MAAA;AAAA,IAC3D;AAAA,EAAA;AAEH;;"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as prismic from "@prismicio/client";
|
|
2
2
|
import { MockModelConfig } from "../types";
|
|
3
|
-
type MockLinkToMediaModel<AllowText extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
|
|
3
|
+
type MockLinkToMediaModel<AllowText extends boolean = boolean, Repeat extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
|
|
4
4
|
config: AllowText extends true ? {
|
|
5
5
|
allowText: true;
|
|
6
6
|
} : {
|
|
7
7
|
allowText?: undefined;
|
|
8
8
|
};
|
|
9
|
+
} & {
|
|
10
|
+
config: Repeat extends true ? {
|
|
11
|
+
repeat: true;
|
|
12
|
+
} : {
|
|
13
|
+
repeat?: undefined;
|
|
14
|
+
};
|
|
9
15
|
};
|
|
10
|
-
export type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {
|
|
16
|
+
export type MockLinkToMediaModelConfig<AllowText extends boolean = boolean, Repeat extends boolean = boolean> = MockModelConfig & {
|
|
11
17
|
allowText?: AllowText;
|
|
12
|
-
|
|
18
|
+
repeat?: Repeat;
|
|
19
|
+
};
|
|
13
20
|
export declare const linkToMedia: <AllowText extends boolean = boolean>(config: MockLinkToMediaModelConfig<AllowText>) => MockLinkToMediaModel<AllowText>;
|
|
14
21
|
export {};
|
|
@@ -9,7 +9,8 @@ const linkToMedia = (config) => {
|
|
|
9
9
|
label: capitalCase(faker.word()),
|
|
10
10
|
placeholder: sentenceCase(faker.words(3)),
|
|
11
11
|
select: prismic.CustomTypeModelLinkSelectType.Media,
|
|
12
|
-
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0
|
|
12
|
+
allowText: ("allowText" in config ? config.allowText : faker.boolean()) || void 0,
|
|
13
|
+
repeat: ("repeat" in config ? config.repeat : faker.boolean()) || void 0
|
|
13
14
|
}
|
|
14
15
|
};
|
|
15
16
|
};
|
|
@@ -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 { MockModelConfig } from \"../types\";\n\ntype MockLinkToMediaModel
|
|
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<\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = prismic.CustomTypeModelLinkToMediaField & {\n\tconfig: AllowText extends true\n\t\t? { allowText: true }\n\t\t: { allowText?: undefined };\n} & {\n\tconfig: Repeat extends true ? { repeat: true } : { repeat?: undefined };\n};\n\nexport type MockLinkToMediaModelConfig<\n\tAllowText extends boolean = boolean,\n\tRepeat extends boolean = boolean,\n> = MockModelConfig & {\n\tallowText?: AllowText;\n\trepeat?: Repeat;\n};\n\nexport const linkToMedia = <AllowText extends boolean = boolean>(\n\tconfig: MockLinkToMediaModelConfig<AllowText>,\n): MockLinkToMediaModel<AllowText> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn {\n\t\ttype: prismic.CustomTypeModelFieldType.Link,\n\t\tconfig: {\n\t\t\tlabel: changeCase.capitalCase(faker.word()),\n\t\t\tplaceholder: changeCase.sentenceCase(faker.words(3)),\n\t\t\tselect: prismic.CustomTypeModelLinkSelectType.Media,\n\t\t\tallowText:\n\t\t\t\t(\"allowText\" in config ? config.allowText : faker.boolean()) ||\n\t\t\t\tundefined,\n\t\t\trepeat:\n\t\t\t\t(\"repeat\" in config ? config.repeat : faker.boolean()) || undefined,\n\t\t},\n\t} as MockLinkToMediaModel<AllowText>;\n};\n"],"names":["changeCase.capitalCase","changeCase.sentenceCase"],"mappings":";;;AA0Ba,MAAA,cAAc,CAC1B,WACoC;AACpC,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA;AAAA,IACN,MAAM,QAAQ,yBAAyB;AAAA,IACvC,QAAQ;AAAA,MACP,OAAOA,YAAuB,MAAM,MAAM;AAAA,MAC1C,aAAaC,aAAwB,MAAM,MAAM,CAAC,CAAC;AAAA,MACnD,QAAQ,QAAQ,8BAA8B;AAAA,MAC9C,YACE,eAAe,SAAS,OAAO,YAAY,MAAM,QAClD,MAAA;AAAA,MACD,SACE,YAAY,SAAS,OAAO,SAAS,MAAM,QAAc,MAAA;AAAA,IAC3D;AAAA,EAAA;AAEH;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/mock",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.0",
|
|
4
4
|
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"lint": "eslint --ext .js,.ts .",
|
|
50
50
|
"prepare": "npm run build",
|
|
51
51
|
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish",
|
|
52
|
-
"release:alpha": "npm run test && standard-version --release-as
|
|
53
|
-
"release:alpha:dry": "standard-version --release-as
|
|
52
|
+
"release:alpha": "npm run test && standard-version --release-as minor --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha",
|
|
53
|
+
"release:alpha:dry": "npm run test && standard-version --release-as minor --prerelease alpha --dry-run",
|
|
54
54
|
"release:dry": "standard-version --dry-run",
|
|
55
55
|
"size": "size-limit",
|
|
56
56
|
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
package/src/model/link.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { MockModelConfig } from "../types";
|
|
|
8
8
|
type MockLinkModel<
|
|
9
9
|
AllowTargetBlank extends boolean = boolean,
|
|
10
10
|
AllowText extends boolean = boolean,
|
|
11
|
+
Repeat extends boolean = boolean,
|
|
11
12
|
> = prismic.CustomTypeModelLinkField & {
|
|
12
13
|
config: AllowTargetBlank extends true
|
|
13
14
|
? { allowTargetBlank: true }
|
|
@@ -16,22 +17,27 @@ type MockLinkModel<
|
|
|
16
17
|
config: AllowText extends true
|
|
17
18
|
? { allowText: true }
|
|
18
19
|
: { allowText?: undefined };
|
|
20
|
+
} & {
|
|
21
|
+
config: Repeat extends true ? { repeat: true } : { repeat?: undefined };
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
export type MockLinkModelConfig<
|
|
22
25
|
AllowTargetBlank extends boolean = boolean,
|
|
23
26
|
AllowText extends boolean = boolean,
|
|
27
|
+
Repeat extends boolean = boolean,
|
|
24
28
|
> = {
|
|
25
29
|
allowTargetBlank?: AllowTargetBlank;
|
|
26
30
|
allowText?: AllowText;
|
|
31
|
+
repeat?: Repeat;
|
|
27
32
|
} & MockModelConfig;
|
|
28
33
|
|
|
29
34
|
export const link = <
|
|
30
35
|
AllowTargetBlank extends boolean = boolean,
|
|
31
36
|
AllowText extends boolean = boolean,
|
|
37
|
+
Repeat extends boolean = boolean,
|
|
32
38
|
>(
|
|
33
|
-
config: MockLinkModelConfig<AllowTargetBlank, AllowText>,
|
|
34
|
-
): MockLinkModel<AllowTargetBlank, AllowText> => {
|
|
39
|
+
config: MockLinkModelConfig<AllowTargetBlank, AllowText, Repeat>,
|
|
40
|
+
): MockLinkModel<AllowTargetBlank, AllowText, Repeat> => {
|
|
35
41
|
const faker = config.faker || createFaker(config.seed);
|
|
36
42
|
|
|
37
43
|
return {
|
|
@@ -47,6 +53,8 @@ export const link = <
|
|
|
47
53
|
allowText:
|
|
48
54
|
("allowText" in config ? config.allowText : faker.boolean()) ||
|
|
49
55
|
undefined,
|
|
56
|
+
repeat:
|
|
57
|
+
("repeat" in config ? config.repeat : faker.boolean()) || undefined,
|
|
50
58
|
},
|
|
51
|
-
} as MockLinkModel<AllowTargetBlank, AllowText>;
|
|
59
|
+
} as MockLinkModel<AllowTargetBlank, AllowText, Repeat>;
|
|
52
60
|
};
|
package/src/model/linkToMedia.ts
CHANGED
|
@@ -5,16 +5,24 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
|
|
6
6
|
import { MockModelConfig } from "../types";
|
|
7
7
|
|
|
8
|
-
type MockLinkToMediaModel<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
type MockLinkToMediaModel<
|
|
9
|
+
AllowText extends boolean = boolean,
|
|
10
|
+
Repeat extends boolean = boolean,
|
|
11
|
+
> = prismic.CustomTypeModelLinkToMediaField & {
|
|
12
|
+
config: AllowText extends true
|
|
13
|
+
? { allowText: true }
|
|
14
|
+
: { allowText?: undefined };
|
|
15
|
+
} & {
|
|
16
|
+
config: Repeat extends true ? { repeat: true } : { repeat?: undefined };
|
|
17
|
+
};
|
|
14
18
|
|
|
15
|
-
export type MockLinkToMediaModelConfig<
|
|
19
|
+
export type MockLinkToMediaModelConfig<
|
|
20
|
+
AllowText extends boolean = boolean,
|
|
21
|
+
Repeat extends boolean = boolean,
|
|
22
|
+
> = MockModelConfig & {
|
|
16
23
|
allowText?: AllowText;
|
|
17
|
-
|
|
24
|
+
repeat?: Repeat;
|
|
25
|
+
};
|
|
18
26
|
|
|
19
27
|
export const linkToMedia = <AllowText extends boolean = boolean>(
|
|
20
28
|
config: MockLinkToMediaModelConfig<AllowText>,
|
|
@@ -30,6 +38,8 @@ export const linkToMedia = <AllowText extends boolean = boolean>(
|
|
|
30
38
|
allowText:
|
|
31
39
|
("allowText" in config ? config.allowText : faker.boolean()) ||
|
|
32
40
|
undefined,
|
|
41
|
+
repeat:
|
|
42
|
+
("repeat" in config ? config.repeat : faker.boolean()) || undefined,
|
|
33
43
|
},
|
|
34
44
|
} as MockLinkToMediaModel<AllowText>;
|
|
35
45
|
};
|