@prismicio/mock 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/query.d.ts +1 -1
- package/dist/api/ref.cjs.map +1 -1
- package/dist/api/ref.js.map +1 -1
- package/dist/api/repository.cjs.map +1 -1
- package/dist/api/repository.js.map +1 -1
- package/dist/lib/PRNG.cjs.map +1 -1
- package/dist/lib/PRNG.js.map +1 -1
- package/dist/lib/buildAlternativeLanguage.d.ts +1 -1
- package/dist/lib/buildContentRelationshipField.d.ts +1 -1
- package/dist/lib/buildEmbedField.d.ts +1 -4
- package/dist/lib/buildImageFieldImage.cjs +7 -1
- package/dist/lib/buildImageFieldImage.cjs.map +1 -1
- package/dist/lib/buildImageFieldImage.js +7 -1
- package/dist/lib/buildImageFieldImage.js.map +1 -1
- package/dist/lib/createFaker.cjs.map +1 -1
- package/dist/lib/createFaker.js.map +1 -1
- package/dist/lib/lorem.cjs.map +1 -1
- package/dist/lib/lorem.js.map +1 -1
- package/dist/lib/valueForModel.cjs.map +1 -1
- package/dist/lib/valueForModel.js.map +1 -1
- package/dist/lib/valueForModelMap.cjs +1 -1
- package/dist/lib/valueForModelMap.cjs.map +1 -1
- package/dist/lib/valueForModelMap.js +1 -1
- package/dist/lib/valueForModelMap.js.map +1 -1
- package/dist/model/buildMockGroupFieldMap.cjs.map +1 -1
- package/dist/model/buildMockGroupFieldMap.js.map +1 -1
- package/dist/model/customType.cjs +2 -0
- package/dist/model/customType.cjs.map +1 -1
- package/dist/model/customType.d.ts +1 -0
- package/dist/model/customType.js +2 -0
- package/dist/model/customType.js.map +1 -1
- package/dist/model/link.cjs.map +1 -1
- package/dist/model/link.js.map +1 -1
- package/dist/model/sharedSlice.cjs.map +1 -1
- package/dist/model/sharedSlice.js.map +1 -1
- package/dist/model/sharedSliceVariation.cjs.map +1 -1
- package/dist/model/sharedSliceVariation.js.map +1 -1
- package/dist/model/sliceZone.cjs.map +1 -1
- package/dist/model/sliceZone.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/value/boolean.cjs.map +1 -1
- package/dist/value/boolean.js.map +1 -1
- package/dist/value/color.cjs.map +1 -1
- package/dist/value/color.d.ts +1 -1
- package/dist/value/color.js.map +1 -1
- package/dist/value/contentRelationship.cjs.map +1 -1
- package/dist/value/contentRelationship.d.ts +1 -1
- package/dist/value/contentRelationship.js.map +1 -1
- package/dist/value/createValueMockFactory.cjs.map +1 -1
- package/dist/value/createValueMockFactory.d.ts +1 -1
- package/dist/value/createValueMockFactory.js.map +1 -1
- package/dist/value/customType.cjs.map +1 -1
- package/dist/value/customType.js.map +1 -1
- package/dist/value/date.cjs.map +1 -1
- package/dist/value/date.d.ts +1 -1
- package/dist/value/date.js.map +1 -1
- package/dist/value/embed.cjs.map +1 -1
- package/dist/value/embed.d.ts +1 -1
- package/dist/value/embed.js.map +1 -1
- package/dist/value/geoPoint.cjs.map +1 -1
- package/dist/value/geoPoint.d.ts +1 -1
- package/dist/value/geoPoint.js.map +1 -1
- package/dist/value/group.cjs.map +1 -1
- package/dist/value/group.js.map +1 -1
- package/dist/value/image.cjs.map +1 -1
- package/dist/value/image.d.ts +3 -2
- package/dist/value/image.js.map +1 -1
- package/dist/value/integration.cjs.map +1 -1
- package/dist/value/integration.d.ts +1 -1
- package/dist/value/integration.js.map +1 -1
- package/dist/value/keyText.cjs.map +1 -1
- package/dist/value/keyText.d.ts +1 -1
- package/dist/value/keyText.js.map +1 -1
- package/dist/value/link.cjs.map +1 -1
- package/dist/value/link.d.ts +1 -1
- package/dist/value/link.js.map +1 -1
- package/dist/value/linkToMedia.cjs.map +1 -1
- package/dist/value/linkToMedia.d.ts +1 -1
- package/dist/value/linkToMedia.js.map +1 -1
- package/dist/value/number.cjs.map +1 -1
- package/dist/value/number.d.ts +1 -1
- package/dist/value/number.js.map +1 -1
- package/dist/value/richText/heading.cjs.map +1 -1
- package/dist/value/richText/heading.js.map +1 -1
- package/dist/value/richText/image.cjs +3 -1
- package/dist/value/richText/image.cjs.map +1 -1
- package/dist/value/richText/image.js +3 -1
- package/dist/value/richText/image.js.map +1 -1
- package/dist/value/richText/index.cjs.map +1 -1
- package/dist/value/richText/index.d.ts +1 -1
- package/dist/value/richText/index.js.map +1 -1
- package/dist/value/select.cjs.map +1 -1
- package/dist/value/select.d.ts +1 -1
- package/dist/value/select.js.map +1 -1
- package/dist/value/sharedSliceVariation.cjs.map +1 -1
- package/dist/value/sharedSliceVariation.js.map +1 -1
- package/dist/value/sliceZone.cjs.map +1 -1
- package/dist/value/sliceZone.js.map +1 -1
- package/dist/value/timestamp.cjs.map +1 -1
- package/dist/value/timestamp.d.ts +1 -1
- package/dist/value/timestamp.js.map +1 -1
- package/dist/value/title.cjs.map +1 -1
- package/dist/value/title.d.ts +1 -1
- package/dist/value/title.js.map +1 -1
- package/dist/value/uid.cjs.map +1 -1
- package/dist/value/uid.js.map +1 -1
- package/package.json +21 -20
- package/src/api/repository.ts +7 -4
- package/src/lib/buildImageFieldImage.ts +6 -0
- package/src/lib/valueForModelMap.ts +1 -1
- package/src/model/customType.ts +6 -2
- package/src/model/link.ts +2 -2
- package/src/types.ts +113 -107
- package/src/value/boolean.ts +2 -1
- package/src/value/color.ts +4 -2
- package/src/value/contentRelationship.ts +8 -5
- package/src/value/createValueMockFactory.ts +40 -20
- package/src/value/date.ts +5 -3
- package/src/value/embed.ts +5 -3
- package/src/value/geoPoint.ts +5 -3
- package/src/value/group.ts +4 -2
- package/src/value/image.ts +12 -5
- package/src/value/integration.ts +4 -2
- package/src/value/keyText.ts +4 -2
- package/src/value/link.ts +16 -11
- package/src/value/linkToMedia.ts +4 -2
- package/src/value/number.ts +4 -2
- package/src/value/richText/image.ts +2 -0
- package/src/value/richText/index.ts +4 -2
- package/src/value/select.ts +6 -3
- package/src/value/sharedSliceVariation.ts +4 -2
- package/src/value/sliceZone.ts +4 -2
- package/src/value/timestamp.ts +4 -2
- package/src/value/title.ts +4 -2
- package/src/value/uid.ts +4 -2
|
@@ -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
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceZone.cjs","sources":["../../../src/value/sliceZone.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { ValueForModelMapConfigs } from \"../lib/valueForModelMap\";\n\nimport { MockValueConfig, MockValueStateConfig, ModelValue } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { slice } from \"./slice\";\nimport { sharedSlice } from \"./sharedSlice\";\n\nexport type MockSliceZoneValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"sliceZone.cjs","sources":["../../../src/value/sliceZone.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { ValueForModelMapConfigs } from \"../lib/valueForModelMap\";\n\nimport { MockValueConfig, MockValueStateConfig, ModelValue } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { slice } from \"./slice\";\nimport { sharedSlice } from \"./sharedSlice\";\n\nexport type MockSliceZoneValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelSliceZoneField = prismic.CustomTypeModelSliceZoneField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tsharedSliceModels?: prismic.SharedSliceModel[];\n\titemsCount?: State extends \"empty\" ? 0 : number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport const sliceZone = <\n\tModel extends\n\t\tprismic.CustomTypeModelSliceZoneField = prismic.CustomTypeModelSliceZoneField,\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: MockSliceZoneValueConfig<Model, State>,\n): ModelValue<Model, State> => {\n\tif (config.state === \"empty\") {\n\t\treturn [] as ModelValue<Model, State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst model = config.model || modelGen.sliceZone({ faker });\n\n\t\tif (model.config?.choices && Object.keys(model.config.choices).length > 0) {\n\t\t\tconst itemsCount = config.itemsCount ?? faker.range(1, 6);\n\n\t\t\treturn Array(itemsCount)\n\t\t\t\t.fill(undefined)\n\t\t\t\t.map(() => {\n\t\t\t\t\tconst choices =\n\t\t\t\t\t\t(model.config?.choices && Object.entries(model.config.choices)) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst [choiceType, choiceModel] = faker.randomElement(choices);\n\n\t\t\t\t\tconst choiceLabels = model.config?.labels?.[choiceType] || [];\n\t\t\t\t\tconst choiceLabel = faker.randomElement(choiceLabels);\n\n\t\t\t\t\tswitch (choiceModel.type) {\n\t\t\t\t\t\tcase prismic.CustomTypeModelSliceType.Slice: {\n\t\t\t\t\t\t\treturn slice({\n\t\t\t\t\t\t\t\tfaker,\n\t\t\t\t\t\t\t\tmodel: choiceModel,\n\t\t\t\t\t\t\t\ttype: choiceType,\n\t\t\t\t\t\t\t\tlabel: choiceLabel ? choiceLabel.name : null,\n\t\t\t\t\t\t\t\tprimaryFieldConfigs: config.primaryFieldConfigs,\n\t\t\t\t\t\t\t\titemsFieldConfigs: config.itemsFieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcase prismic.CustomTypeModelSliceType.SharedSlice: {\n\t\t\t\t\t\t\tconst sharedSliceModel = config.sharedSliceModels?.find(\n\t\t\t\t\t\t\t\t(sharedSliceModel) => sharedSliceModel.id === choiceType,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (sharedSliceModel) {\n\t\t\t\t\t\t\t\treturn sharedSlice({\n\t\t\t\t\t\t\t\t\tfaker,\n\t\t\t\t\t\t\t\t\tmodel: sharedSliceModel,\n\t\t\t\t\t\t\t\t\tprimaryFieldConfigs: config.primaryFieldConfigs,\n\t\t\t\t\t\t\t\t\titemsFieldConfigs: config.itemsFieldConfigs,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.filter(\n\t\t\t\t\t(slice): slice is NonNullable<typeof slice> => slice !== undefined,\n\t\t\t\t) as ModelValue<Model, State>;\n\t\t} else {\n\t\t\treturn [] as unknown as ModelValue<Model, State>;\n\t\t}\n\t}\n};\n"],"names":["createFaker","modelGen.sliceZone","_a","prismic","slice","sharedSliceModel","sharedSlice"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBa,MAAA,YAAY,CAKxB,WAC6B;;AACzB,MAAA,OAAO,UAAU,SAAS;AAC7B,WAAO;SACD;AACN,UAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAErD,UAAM,QAAQ,OAAO,SAASC,YAAAA,UAAmB,EAAE,OAAO;AAEtD,UAAA,WAAM,WAAN,mBAAc,YAAW,OAAO,KAAK,MAAM,OAAO,OAAO,EAAE,SAAS,GAAG;AAC1E,YAAM,aAAa,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC;AAExD,aAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;;AACH,cAAA,YACJC,MAAA,MAAM,WAAN,gBAAAA,IAAc,YAAW,OAAO,QAAQ,MAAM,OAAO,OAAO,KAC7D,CAAA;AACD,cAAM,CAAC,YAAY,WAAW,IAAI,MAAM,cAAc,OAAO;AAE7D,cAAM,iBAAe,iBAAM,WAAN,mBAAc,WAAd,mBAAuB,gBAAe;AACrD,cAAA,cAAc,MAAM,cAAc,YAAY;AAEpD,gBAAQ,YAAY,MAAM;AAAA,UACzB,KAAKC,mBAAQ,yBAAyB,OAAO;AAC5C,mBAAOC,YAAM;AAAA,cACZ;AAAA,cACA,OAAO;AAAA,cACP,MAAM;AAAA,cACN,OAAO,cAAc,YAAY,OAAO;AAAA,cACxC,qBAAqB,OAAO;AAAA,cAC5B,mBAAmB,OAAO;AAAA,YAAA,CAC1B;AAAA,UACF;AAAA,UAEA,KAAKD,mBAAQ,yBAAyB,aAAa;AAC5C,kBAAA,oBAAmB,YAAO,sBAAP,mBAA0B,KAClD,CAACE,sBAAqBA,kBAAiB,OAAO;AAG/C,gBAAI,kBAAkB;AACrB,qBAAOC,wBAAY;AAAA,gBAClB;AAAA,gBACA,OAAO;AAAA,gBACP,qBAAqB,OAAO;AAAA,gBAC5B,mBAAmB,OAAO;AAAA,cAAA,CAC1B;AAAA,YACF;AAAA,UACD;AAAA,QACD;AAAA,MAAA,CACA,EACA,OACA,CAACF,WAA8CA,WAAU,MAAS;AAAA,IAAA,OAE9D;AACN,aAAO;IACR;AAAA,EACD;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliceZone.js","sources":["../../../src/value/sliceZone.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { ValueForModelMapConfigs } from \"../lib/valueForModelMap\";\n\nimport { MockValueConfig, MockValueStateConfig, ModelValue } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { slice } from \"./slice\";\nimport { sharedSlice } from \"./sharedSlice\";\n\nexport type MockSliceZoneValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"sliceZone.js","sources":["../../../src/value/sliceZone.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\nimport { ValueForModelMapConfigs } from \"../lib/valueForModelMap\";\n\nimport { MockValueConfig, MockValueStateConfig, ModelValue } from \"../types\";\n\nimport * as modelGen from \"../model\";\n\nimport { slice } from \"./slice\";\nimport { sharedSlice } from \"./sharedSlice\";\n\nexport type MockSliceZoneValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelSliceZoneField = prismic.CustomTypeModelSliceZoneField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tsharedSliceModels?: prismic.SharedSliceModel[];\n\titemsCount?: State extends \"empty\" ? 0 : number;\n\tprimaryFieldConfigs?: ValueForModelMapConfigs;\n\titemsFieldConfigs?: ValueForModelMapConfigs;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport const sliceZone = <\n\tModel extends\n\t\tprismic.CustomTypeModelSliceZoneField = prismic.CustomTypeModelSliceZoneField,\n\tState extends prismic.FieldState = prismic.FieldState,\n>(\n\tconfig: MockSliceZoneValueConfig<Model, State>,\n): ModelValue<Model, State> => {\n\tif (config.state === \"empty\") {\n\t\treturn [] as ModelValue<Model, State>;\n\t} else {\n\t\tconst faker = config.faker || createFaker(config.seed);\n\n\t\tconst model = config.model || modelGen.sliceZone({ faker });\n\n\t\tif (model.config?.choices && Object.keys(model.config.choices).length > 0) {\n\t\t\tconst itemsCount = config.itemsCount ?? faker.range(1, 6);\n\n\t\t\treturn Array(itemsCount)\n\t\t\t\t.fill(undefined)\n\t\t\t\t.map(() => {\n\t\t\t\t\tconst choices =\n\t\t\t\t\t\t(model.config?.choices && Object.entries(model.config.choices)) ||\n\t\t\t\t\t\t[];\n\t\t\t\t\tconst [choiceType, choiceModel] = faker.randomElement(choices);\n\n\t\t\t\t\tconst choiceLabels = model.config?.labels?.[choiceType] || [];\n\t\t\t\t\tconst choiceLabel = faker.randomElement(choiceLabels);\n\n\t\t\t\t\tswitch (choiceModel.type) {\n\t\t\t\t\t\tcase prismic.CustomTypeModelSliceType.Slice: {\n\t\t\t\t\t\t\treturn slice({\n\t\t\t\t\t\t\t\tfaker,\n\t\t\t\t\t\t\t\tmodel: choiceModel,\n\t\t\t\t\t\t\t\ttype: choiceType,\n\t\t\t\t\t\t\t\tlabel: choiceLabel ? choiceLabel.name : null,\n\t\t\t\t\t\t\t\tprimaryFieldConfigs: config.primaryFieldConfigs,\n\t\t\t\t\t\t\t\titemsFieldConfigs: config.itemsFieldConfigs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcase prismic.CustomTypeModelSliceType.SharedSlice: {\n\t\t\t\t\t\t\tconst sharedSliceModel = config.sharedSliceModels?.find(\n\t\t\t\t\t\t\t\t(sharedSliceModel) => sharedSliceModel.id === choiceType,\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (sharedSliceModel) {\n\t\t\t\t\t\t\t\treturn sharedSlice({\n\t\t\t\t\t\t\t\t\tfaker,\n\t\t\t\t\t\t\t\t\tmodel: sharedSliceModel,\n\t\t\t\t\t\t\t\t\tprimaryFieldConfigs: config.primaryFieldConfigs,\n\t\t\t\t\t\t\t\t\titemsFieldConfigs: config.itemsFieldConfigs,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.filter(\n\t\t\t\t\t(slice): slice is NonNullable<typeof slice> => slice !== undefined,\n\t\t\t\t) as ModelValue<Model, State>;\n\t\t} else {\n\t\t\treturn [] as unknown as ModelValue<Model, State>;\n\t\t}\n\t}\n};\n"],"names":["modelGen.sliceZone","_a","sharedSliceModel","slice"],"mappings":";;;;;AAwBa,MAAA,YAAY,CAKxB,WAC6B;;AACzB,MAAA,OAAO,UAAU,SAAS;AAC7B,WAAO;SACD;AACN,UAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAErD,UAAM,QAAQ,OAAO,SAASA,YAAmB,EAAE,OAAO;AAEtD,UAAA,WAAM,WAAN,mBAAc,YAAW,OAAO,KAAK,MAAM,OAAO,OAAO,EAAE,SAAS,GAAG;AAC1E,YAAM,aAAa,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC;AAExD,aAAO,MAAM,UAAU,EACrB,KAAK,MAAS,EACd,IAAI,MAAK;;AACH,cAAA,YACJC,MAAA,MAAM,WAAN,gBAAAA,IAAc,YAAW,OAAO,QAAQ,MAAM,OAAO,OAAO,KAC7D,CAAA;AACD,cAAM,CAAC,YAAY,WAAW,IAAI,MAAM,cAAc,OAAO;AAE7D,cAAM,iBAAe,iBAAM,WAAN,mBAAc,WAAd,mBAAuB,gBAAe;AACrD,cAAA,cAAc,MAAM,cAAc,YAAY;AAEpD,gBAAQ,YAAY,MAAM;AAAA,UACzB,KAAK,QAAQ,yBAAyB,OAAO;AAC5C,mBAAO,MAAM;AAAA,cACZ;AAAA,cACA,OAAO;AAAA,cACP,MAAM;AAAA,cACN,OAAO,cAAc,YAAY,OAAO;AAAA,cACxC,qBAAqB,OAAO;AAAA,cAC5B,mBAAmB,OAAO;AAAA,YAAA,CAC1B;AAAA,UACF;AAAA,UAEA,KAAK,QAAQ,yBAAyB,aAAa;AAC5C,kBAAA,oBAAmB,YAAO,sBAAP,mBAA0B,KAClD,CAACC,sBAAqBA,kBAAiB,OAAO;AAG/C,gBAAI,kBAAkB;AACrB,qBAAO,YAAY;AAAA,gBAClB;AAAA,gBACA,OAAO;AAAA,gBACP,qBAAqB,OAAO;AAAA,gBAC5B,mBAAmB,OAAO;AAAA,cAAA,CAC1B;AAAA,YACF;AAAA,UACD;AAAA,QACD;AAAA,MAAA,CACA,EACA,OACA,CAACC,WAA8CA,WAAU,MAAS;AAAA,IAAA,OAE9D;AACN,aAAO;IACR;AAAA,EACD;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestamp.cjs","sources":["../../../src/value/timestamp.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockTimestampValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"timestamp.cjs","sources":["../../../src/value/timestamp.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockTimestampValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tafter?: Date;\n\tbefore?: Date;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport type MockTimestampValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.TimestampField<State>;\n\nexport const timestamp = <\n\tModel extends\n\t\tprismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockTimestampValueConfig<Model, State>,\n): MockTimestampValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn null as MockTimestampValue<State>;\n\t} else {\n\t\tlet date: Date;\n\n\t\t// Working with Date objects produces non-deterministic values;\n\t\t// machines can return different values due to differing\n\t\t// timezones and other unknown factors. To get around this, we\n\t\t// can can remove time from the given values and only use their dates.\n\t\tconst after = config.after\n\t\t\t? new Date(config.after.toISOString().split(\"T\")[0])\n\t\t\t: undefined;\n\t\tconst before = config.before\n\t\t\t? new Date(config.before.toISOString().split(\"T\")[0])\n\t\t\t: undefined;\n\n\t\tif (after && before) {\n\t\t\tdate = faker.dateBetween(after, before);\n\t\t} else if (after) {\n\t\t\tdate = faker.dateAfter(after);\n\t\t} else if (before) {\n\t\t\tdate = faker.dateBefore(before);\n\t\t} else {\n\t\t\tdate = faker.date();\n\t\t}\n\n\t\treturn date.toISOString() as MockTimestampValue<State>;\n\t}\n};\n"],"names":["createFaker"],"mappings":";;;AAoBa,MAAA,YAAY,CAKxB,WAC8B;AAC9B,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,EAAA,OACD;AACF,QAAA;AAMJ,UAAM,QAAQ,OAAO,QAClB,IAAI,KAAK,OAAO,MAAM,YAAa,EAAC,MAAM,GAAG,EAAE,CAAC,CAAC,IACjD;AACH,UAAM,SAAS,OAAO,SACnB,IAAI,KAAK,OAAO,OAAO,YAAa,EAAC,MAAM,GAAG,EAAE,CAAC,CAAC,IAClD;AAEH,QAAI,SAAS,QAAQ;AACb,aAAA,MAAM,YAAY,OAAO,MAAM;AAAA,eAC5B,OAAO;AACV,aAAA,MAAM,UAAU,KAAK;AAAA,eAClB,QAAQ;AACX,aAAA,MAAM,WAAW,MAAM;AAAA,IAAA,OACxB;AACN,aAAO,MAAM;IACd;AAEA,WAAO,KAAK;EACb;AACD;;"}
|
|
@@ -5,4 +5,4 @@ export type MockTimestampValueConfig<Model extends prismic.CustomTypeModelTimest
|
|
|
5
5
|
before?: Date;
|
|
6
6
|
} & MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
7
7
|
export type MockTimestampValue<State extends prismic.FieldState = prismic.FieldState> = prismic.TimestampField<State>;
|
|
8
|
-
export declare const timestamp: <Model extends prismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField, State extends prismic.FieldState = "filled">(config: MockTimestampValueConfig<Model, State>) =>
|
|
8
|
+
export declare const timestamp: <Model extends prismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField, State extends prismic.FieldState = "filled">(config: MockTimestampValueConfig<Model, State>) => MockTimestampValue<State>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timestamp.js","sources":["../../../src/value/timestamp.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockTimestampValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"timestamp.js","sources":["../../../src/value/timestamp.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueStateConfig, MockValueConfig } from \"../types\";\n\nexport type MockTimestampValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tafter?: Date;\n\tbefore?: Date;\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport type MockTimestampValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.TimestampField<State>;\n\nexport const timestamp = <\n\tModel extends\n\t\tprismic.CustomTypeModelTimestampField = prismic.CustomTypeModelTimestampField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockTimestampValueConfig<Model, State>,\n): MockTimestampValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn null as MockTimestampValue<State>;\n\t} else {\n\t\tlet date: Date;\n\n\t\t// Working with Date objects produces non-deterministic values;\n\t\t// machines can return different values due to differing\n\t\t// timezones and other unknown factors. To get around this, we\n\t\t// can can remove time from the given values and only use their dates.\n\t\tconst after = config.after\n\t\t\t? new Date(config.after.toISOString().split(\"T\")[0])\n\t\t\t: undefined;\n\t\tconst before = config.before\n\t\t\t? new Date(config.before.toISOString().split(\"T\")[0])\n\t\t\t: undefined;\n\n\t\tif (after && before) {\n\t\t\tdate = faker.dateBetween(after, before);\n\t\t} else if (after) {\n\t\t\tdate = faker.dateAfter(after);\n\t\t} else if (before) {\n\t\t\tdate = faker.dateBefore(before);\n\t\t} else {\n\t\t\tdate = faker.date();\n\t\t}\n\n\t\treturn date.toISOString() as MockTimestampValue<State>;\n\t}\n};\n"],"names":[],"mappings":";AAoBa,MAAA,YAAY,CAKxB,WAC8B;AAC9B,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AACtB,WAAA;AAAA,EAAA,OACD;AACF,QAAA;AAMJ,UAAM,QAAQ,OAAO,QAClB,IAAI,KAAK,OAAO,MAAM,YAAa,EAAC,MAAM,GAAG,EAAE,CAAC,CAAC,IACjD;AACH,UAAM,SAAS,OAAO,SACnB,IAAI,KAAK,OAAO,OAAO,YAAa,EAAC,MAAM,GAAG,EAAE,CAAC,CAAC,IAClD;AAEH,QAAI,SAAS,QAAQ;AACb,aAAA,MAAM,YAAY,OAAO,MAAM;AAAA,eAC5B,OAAO;AACV,aAAA,MAAM,UAAU,KAAK;AAAA,eAClB,QAAQ;AACX,aAAA,MAAM,WAAW,MAAM;AAAA,IAAA,OACxB;AACN,aAAO,MAAM;IACd;AAEA,WAAO,KAAK;EACb;AACD;"}
|
package/dist/value/title.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.cjs","sources":["../../../src/value/title.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig, MockValueStateConfig } from \"../types\";\n\nimport { heading, MockRichTextHeadingValueConfig } from \"./richText/heading\";\n\nexport type MockTitleValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"title.cjs","sources":["../../../src/value/title.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig, MockValueStateConfig } from \"../types\";\n\nimport { heading, MockRichTextHeadingValueConfig } from \"./richText/heading\";\n\nexport type MockTitleValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelTitleField = prismic.CustomTypeModelTitleField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tpattern?: MockRichTextHeadingValueConfig[\"pattern\"];\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport type MockTitleValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.TitleField<State>;\n\nexport const title = <\n\tModel extends\n\t\tprismic.CustomTypeModelTitleField = prismic.CustomTypeModelTitleField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockTitleValueConfig<Model, State>,\n): MockTitleValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn [] as MockTitleValue<State>;\n\t} else {\n\t\treturn [\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\theading({\n\t\t\t\tfaker,\n\t\t\t\tmodel: config.model,\n\t\t\t\tpattern: config.pattern,\n\t\t\t})!,\n\t\t] as MockTitleValue<State>;\n\t}\n};\n"],"names":["createFaker","heading"],"mappings":";;;;AAqBa,MAAA,QAAQ,CAKpB,WAC0B;AAC1B,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AAC7B,WAAO;SACD;AACC,WAAA;AAAA;AAAA,MAENC,gBAAQ;AAAA,QACP;AAAA,QACA,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA;AAAA,EAEH;AACD;;"}
|
package/dist/value/title.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export type MockTitleValueConfig<Model extends prismic.CustomTypeModelTitleField
|
|
|
5
5
|
pattern?: MockRichTextHeadingValueConfig["pattern"];
|
|
6
6
|
} & MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
7
7
|
export type MockTitleValue<State extends prismic.FieldState = prismic.FieldState> = prismic.TitleField<State>;
|
|
8
|
-
export declare const title: <Model extends prismic.CustomTypeModelRichTextSingleField = prismic.CustomTypeModelRichTextSingleField, State extends prismic.FieldState = "filled">(config: MockTitleValueConfig<Model, State>) =>
|
|
8
|
+
export declare const title: <Model extends prismic.CustomTypeModelRichTextSingleField = prismic.CustomTypeModelRichTextSingleField, State extends prismic.FieldState = "filled">(config: MockTitleValueConfig<Model, State>) => MockTitleValue<State>;
|
package/dist/value/title.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.js","sources":["../../../src/value/title.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig, MockValueStateConfig } from \"../types\";\n\nimport { heading, MockRichTextHeadingValueConfig } from \"./richText/heading\";\n\nexport type MockTitleValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"title.js","sources":["../../../src/value/title.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig, MockValueStateConfig } from \"../types\";\n\nimport { heading, MockRichTextHeadingValueConfig } from \"./richText/heading\";\n\nexport type MockTitleValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelTitleField = prismic.CustomTypeModelTitleField,\n\tState extends prismic.FieldState = prismic.FieldState,\n> = {\n\tpattern?: MockRichTextHeadingValueConfig[\"pattern\"];\n} & MockValueConfig<Model> &\n\tMockValueStateConfig<State>;\n\nexport type MockTitleValue<\n\tState extends prismic.FieldState = prismic.FieldState,\n> = prismic.TitleField<State>;\n\nexport const title = <\n\tModel extends\n\t\tprismic.CustomTypeModelTitleField = prismic.CustomTypeModelTitleField,\n\tState extends prismic.FieldState = \"filled\",\n>(\n\tconfig: MockTitleValueConfig<Model, State>,\n): MockTitleValue<State> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\tif (config.state === \"empty\") {\n\t\treturn [] as MockTitleValue<State>;\n\t} else {\n\t\treturn [\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\theading({\n\t\t\t\tfaker,\n\t\t\t\tmodel: config.model,\n\t\t\t\tpattern: config.pattern,\n\t\t\t})!,\n\t\t] as MockTitleValue<State>;\n\t}\n};\n"],"names":[],"mappings":";;AAqBa,MAAA,QAAQ,CAKpB,WAC0B;AAC1B,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAEjD,MAAA,OAAO,UAAU,SAAS;AAC7B,WAAO;SACD;AACC,WAAA;AAAA;AAAA,MAEN,QAAQ;AAAA,QACP;AAAA,QACA,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,MAAA,CAChB;AAAA,IAAA;AAAA,EAEH;AACD;"}
|
package/dist/value/uid.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uid.cjs","sources":["../../../src/value/uid.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig } from \"../types\";\n\nexport type MockUIDValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"uid.cjs","sources":["../../../src/value/uid.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig } from \"../types\";\n\nexport type MockUIDValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelUIDField = prismic.CustomTypeModelUIDField,\n> = MockValueConfig<Model>;\n\nexport const uid = <\n\tModel extends\n\t\tprismic.CustomTypeModelUIDField = prismic.CustomTypeModelUIDField,\n>(\n\tconfig: MockUIDValueConfig<Model>,\n): NonNullable<prismic.PrismicDocument[\"uid\"]> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn changeCase.snakeCase(faker.words(faker.range(1, 3)));\n};\n"],"names":["createFaker","changeCase"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYa,MAAA,MAAM,CAIlB,WACgD;AAChD,QAAM,QAAQ,OAAO,SAASA,YAAAA,YAAY,OAAO,IAAI;AAE9C,SAAAC,sBAAW,UAAU,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3D;;"}
|
package/dist/value/uid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uid.js","sources":["../../../src/value/uid.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig } from \"../types\";\n\nexport type MockUIDValueConfig<\n\tModel extends
|
|
1
|
+
{"version":3,"file":"uid.js","sources":["../../../src/value/uid.ts"],"sourcesContent":["import * as prismic from \"@prismicio/client\";\nimport * as changeCase from \"change-case\";\n\nimport { createFaker } from \"../lib/createFaker\";\n\nimport { MockValueConfig } from \"../types\";\n\nexport type MockUIDValueConfig<\n\tModel extends\n\t\tprismic.CustomTypeModelUIDField = prismic.CustomTypeModelUIDField,\n> = MockValueConfig<Model>;\n\nexport const uid = <\n\tModel extends\n\t\tprismic.CustomTypeModelUIDField = prismic.CustomTypeModelUIDField,\n>(\n\tconfig: MockUIDValueConfig<Model>,\n): NonNullable<prismic.PrismicDocument[\"uid\"]> => {\n\tconst faker = config.faker || createFaker(config.seed);\n\n\treturn changeCase.snakeCase(faker.words(faker.range(1, 3)));\n};\n"],"names":[],"mappings":";;AAYa,MAAA,MAAM,CAIlB,WACgD;AAChD,QAAM,QAAQ,OAAO,SAAS,YAAY,OAAO,IAAI;AAE9C,SAAA,WAAW,UAAU,MAAM,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAC3D;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/mock",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -53,38 +53,39 @@
|
|
|
53
53
|
"release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run",
|
|
54
54
|
"release:dry": "standard-version --dry-run",
|
|
55
55
|
"size": "size-limit",
|
|
56
|
-
"test": "npm run lint && npm run unit && npm run build && npm run size",
|
|
56
|
+
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size",
|
|
57
|
+
"types": "tsc --noEmit",
|
|
57
58
|
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"change-case": "^4.
|
|
61
|
+
"change-case": "^5.4.4"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
66
|
-
"@typescript-eslint/parser": "^
|
|
67
|
-
"ava": "^
|
|
68
|
-
"esbuild": "^0.
|
|
69
|
-
"esbuild-register": "^3.
|
|
70
|
-
"eslint": "^8.
|
|
71
|
-
"eslint-config-prettier": "^
|
|
72
|
-
"eslint-plugin-prettier": "^
|
|
64
|
+
"@size-limit/preset-small-lib": "^11.1.2",
|
|
65
|
+
"@types/node": "^20.12.7",
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
67
|
+
"@typescript-eslint/parser": "^7.6.0",
|
|
68
|
+
"ava": "^6.1.2",
|
|
69
|
+
"esbuild": "^0.20.2",
|
|
70
|
+
"esbuild-register": "^3.5.0",
|
|
71
|
+
"eslint": "^8.57.0",
|
|
72
|
+
"eslint-config-prettier": "^9.1.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
73
74
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
74
75
|
"nyc": "^15.1.0",
|
|
75
|
-
"prettier": "^2.
|
|
76
|
-
"prettier-plugin-jsdoc": "^
|
|
77
|
-
"size-limit": "^
|
|
76
|
+
"prettier": "^3.2.5",
|
|
77
|
+
"prettier-plugin-jsdoc": "^1.3.0",
|
|
78
|
+
"size-limit": "^11.1.2",
|
|
78
79
|
"standard-version": "^9.5.0",
|
|
79
|
-
"typescript": "^5.
|
|
80
|
-
"vite": "^
|
|
81
|
-
"vite-plugin-sdk": "^0.1.
|
|
80
|
+
"typescript": "^5.4.5",
|
|
81
|
+
"vite": "^5.2.8",
|
|
82
|
+
"vite-plugin-sdk": "^0.1.2"
|
|
82
83
|
},
|
|
83
84
|
"peerDependencies": {
|
|
84
85
|
"@prismicio/client": "^7"
|
|
85
86
|
},
|
|
86
87
|
"engines": {
|
|
87
|
-
"node": ">=
|
|
88
|
+
"node": ">=18"
|
|
88
89
|
},
|
|
89
90
|
"publishConfig": {
|
|
90
91
|
"access": "public"
|
package/src/api/repository.ts
CHANGED
|
@@ -17,11 +17,14 @@ export const repository = (
|
|
|
17
17
|
): prismic.Repository => {
|
|
18
18
|
const faker = config.faker || createFaker(config.seed);
|
|
19
19
|
|
|
20
|
-
const types = (config.customTypeModels || []).reduce(
|
|
21
|
-
acc
|
|
20
|
+
const types = (config.customTypeModels || []).reduce(
|
|
21
|
+
(acc, model) => {
|
|
22
|
+
acc[model.id] = model.label || model.id;
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
return acc;
|
|
25
|
+
},
|
|
26
|
+
{} as prismic.Repository["types"],
|
|
27
|
+
);
|
|
25
28
|
|
|
26
29
|
return {
|
|
27
30
|
refs: [
|
|
@@ -55,6 +55,12 @@ export const buildImageFieldImage = <
|
|
|
55
55
|
dimensions,
|
|
56
56
|
alt: changeCase.sentenceCase(faker.words(faker.range(5, 15))),
|
|
57
57
|
copyright: changeCase.sentenceCase(faker.words(faker.range(5, 15))),
|
|
58
|
+
edit: {
|
|
59
|
+
x: faker.range(-dimensions.width / 2, dimensions.width / 2),
|
|
60
|
+
y: faker.range(-dimensions.width / 2, dimensions.height / 2),
|
|
61
|
+
zoom: faker.rangeFloat(1, 2),
|
|
62
|
+
background: faker.hexColor(),
|
|
63
|
+
},
|
|
58
64
|
} as prismic.ImageFieldImage<State>;
|
|
59
65
|
}
|
|
60
66
|
};
|
|
@@ -92,7 +92,7 @@ const getValueConfigType = <Model extends prismic.CustomTypeModelField>(
|
|
|
92
92
|
case prismic.CustomTypeModelFieldType.UID:
|
|
93
93
|
return "uid";
|
|
94
94
|
|
|
95
|
-
case prismic.CustomTypeModelFieldType.
|
|
95
|
+
case prismic.CustomTypeModelFieldType.Integration:
|
|
96
96
|
return "integration";
|
|
97
97
|
|
|
98
98
|
case prismic.CustomTypeModelFieldType.Slices:
|
package/src/model/customType.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type MockCustomTypeModelConfig<
|
|
|
16
16
|
label?: string;
|
|
17
17
|
status?: boolean;
|
|
18
18
|
repeatable?: boolean;
|
|
19
|
+
format?: prismic.CustomTypeModel["format"];
|
|
19
20
|
} & (
|
|
20
21
|
| {
|
|
21
22
|
fields?: Definition;
|
|
@@ -35,8 +36,8 @@ type MockCustomTypeModel<
|
|
|
35
36
|
> = Definition extends prismic.CustomTypeModelTab
|
|
36
37
|
? prismic.CustomTypeModel<string, Record<"Main", Definition>>
|
|
37
38
|
: Definition extends prismic.CustomTypeModelDefinition
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
? prismic.CustomTypeModel<string, Definition>
|
|
40
|
+
: never;
|
|
40
41
|
|
|
41
42
|
export const customType = <
|
|
42
43
|
Definition extends
|
|
@@ -57,6 +58,8 @@ export const customType = <
|
|
|
57
58
|
id = changeCase.snakeCase(config.label);
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
const format = config.format ?? faker.randomElement(["page", "custom"]);
|
|
62
|
+
|
|
60
63
|
let json = {} as MockCustomTypeModel<Definition>["json"];
|
|
61
64
|
|
|
62
65
|
if ("fields" in config && config.fields) {
|
|
@@ -70,6 +73,7 @@ export const customType = <
|
|
|
70
73
|
label,
|
|
71
74
|
status: config.status ?? faker.boolean(),
|
|
72
75
|
repeatable: config.repeatable ?? faker.boolean(),
|
|
76
|
+
format,
|
|
73
77
|
json,
|
|
74
78
|
} as MockCustomTypeModel<Definition>;
|
|
75
79
|
};
|
package/src/model/link.ts
CHANGED
|
@@ -10,10 +10,10 @@ export type MockLinkModel<AllowTargetBlank extends boolean = boolean> =
|
|
|
10
10
|
config: AllowTargetBlank extends true
|
|
11
11
|
? {
|
|
12
12
|
allowTargetBlank: true;
|
|
13
|
-
|
|
13
|
+
}
|
|
14
14
|
: {
|
|
15
15
|
allowTargetBlank?: undefined;
|
|
16
|
-
|
|
16
|
+
};
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
|
package/src/types.ts
CHANGED
|
@@ -3,13 +3,12 @@ import { Faker } from "./lib/createFaker";
|
|
|
3
3
|
|
|
4
4
|
import * as value from "./value";
|
|
5
5
|
|
|
6
|
-
export type IterableElement<TargetIterable> =
|
|
7
|
-
infer ElementType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
: never;
|
|
6
|
+
export type IterableElement<TargetIterable> =
|
|
7
|
+
TargetIterable extends Iterable<infer ElementType>
|
|
8
|
+
? ElementType
|
|
9
|
+
: TargetIterable extends AsyncIterable<infer ElementType>
|
|
10
|
+
? ElementType
|
|
11
|
+
: never;
|
|
13
12
|
|
|
14
13
|
export type ValueOf<
|
|
15
14
|
ObjectType,
|
|
@@ -104,47 +103,48 @@ export type MockValueConfigForModel<
|
|
|
104
103
|
> = Model extends prismic.CustomTypeModelBooleanField
|
|
105
104
|
? value.MockBooleanValueConfig<Model>
|
|
106
105
|
: Model extends prismic.CustomTypeModelColorField
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
106
|
+
? value.MockColorValueConfig<Model, State>
|
|
107
|
+
: Model extends prismic.CustomTypeModelContentRelationshipField
|
|
108
|
+
? value.MockContentRelationshipValueConfig<Model, State>
|
|
109
|
+
: Model extends prismic.CustomTypeModelDateField
|
|
110
|
+
? value.MockDateValueConfig<Model, State>
|
|
111
|
+
: Model extends prismic.CustomTypeModelEmbedField
|
|
112
|
+
? value.MockEmbedValueConfig<Model, prismic.AnyOEmbed, State>
|
|
113
|
+
: Model extends prismic.CustomTypeModelGeoPointField
|
|
114
|
+
? value.MockGeoPointValueConfig<Model, State>
|
|
115
|
+
: Model extends prismic.CustomTypeModelImageField
|
|
116
|
+
? value.MockImageValueConfig<Model, State>
|
|
117
|
+
: Model extends prismic.CustomTypeModelKeyTextField
|
|
118
|
+
? value.MockKeyTextValueConfig<Model, State>
|
|
119
|
+
: Model extends prismic.CustomTypeModelLinkField
|
|
120
|
+
? value.MockLinkValueConfig<
|
|
121
|
+
(typeof prismic.LinkType)[keyof typeof prismic.LinkType],
|
|
122
|
+
Model,
|
|
123
|
+
State
|
|
124
|
+
>
|
|
125
|
+
: Model extends prismic.CustomTypeModelLinkToMediaField
|
|
126
|
+
? value.MockLinkToMediaValueConfig<Model, State>
|
|
127
|
+
: Model extends prismic.CustomTypeModelNumberField
|
|
128
|
+
? value.MockNumberValueConfig<Model, State>
|
|
129
|
+
: Model extends prismic.CustomTypeModelRichTextField
|
|
130
|
+
? value.MockRichTextValueConfig
|
|
131
|
+
: Model extends prismic.CustomTypeModelSelectField
|
|
132
|
+
? value.MockSelectValueConfig<Model, State>
|
|
133
|
+
: Model extends prismic.CustomTypeModelTimestampField
|
|
134
|
+
? value.MockTimestampValueConfig<Model, State>
|
|
135
|
+
: Model extends prismic.CustomTypeModelTitleField
|
|
136
|
+
? value.MockTitleValueConfig<Model, State>
|
|
137
|
+
: Model extends prismic.CustomTypeModelUIDField
|
|
138
|
+
? value.MockUIDValueConfig<Model>
|
|
139
|
+
: never;
|
|
141
140
|
|
|
142
141
|
type CustomTypeModelStructuredTextField =
|
|
143
142
|
| prismic.CustomTypeModelRichTextField
|
|
144
143
|
| prismic.CustomTypeModelTitleField;
|
|
145
144
|
|
|
146
145
|
export type MockRichTextValueConfig<
|
|
147
|
-
Model extends
|
|
146
|
+
Model extends
|
|
147
|
+
CustomTypeModelStructuredTextField = CustomTypeModelStructuredTextField,
|
|
148
148
|
> = {
|
|
149
149
|
model?: Model;
|
|
150
150
|
} & (
|
|
@@ -170,41 +170,41 @@ export type ModelValue<
|
|
|
170
170
|
> = T extends prismic.CustomTypeModel
|
|
171
171
|
? CustomTypeModelValue<T>
|
|
172
172
|
: T extends prismic.CustomTypeModelUIDField
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
173
|
+
? prismic.PrismicDocument["uid"]
|
|
174
|
+
: T extends prismic.CustomTypeModelFieldForGroup
|
|
175
|
+
? CustomTypeModelFieldForGroupValue<T, State>
|
|
176
|
+
: T extends prismic.CustomTypeModelGroupField
|
|
177
|
+
? CustomTypeModelGroupFieldValue<T, State>
|
|
178
|
+
: T extends prismic.CustomTypeModelSliceZoneField
|
|
179
|
+
? prismic.SliceZone<
|
|
180
|
+
ValueOf<{
|
|
181
|
+
[P in keyof NonNullable<
|
|
182
|
+
NonNullable<T["config"]>["choices"]
|
|
183
|
+
> as P extends string ? P : never]: NonNullable<
|
|
184
|
+
NonNullable<T["config"]>["choices"]
|
|
185
|
+
>[P] extends prismic.CustomTypeModelSlice
|
|
186
|
+
? CustomTypeModelSliceValue<
|
|
187
|
+
NonNullable<NonNullable<T["config"]>["choices"]>[P],
|
|
188
|
+
P extends string ? P : string
|
|
189
|
+
>
|
|
190
|
+
: NonNullable<
|
|
191
|
+
NonNullable<T["config"]>["choices"]
|
|
192
|
+
>[P] extends prismic.CustomTypeModelSharedSlice
|
|
193
|
+
? prismic.SharedSlice<P extends string ? P : string>
|
|
194
|
+
: never;
|
|
195
|
+
}>,
|
|
196
|
+
State
|
|
197
|
+
>
|
|
198
|
+
: T extends prismic.CustomTypeModelSlice
|
|
199
|
+
? CustomTypeModelSliceValue<T>
|
|
200
|
+
: T extends prismic.CustomTypeModelSharedSlice
|
|
201
|
+
? // TODO: Allow providing a union of of Shared Slices
|
|
202
|
+
prismic.SharedSlice
|
|
203
|
+
: T extends prismic.SharedSliceModel
|
|
204
|
+
? SharedSliceModelValue<T>
|
|
205
|
+
: T extends prismic.SharedSliceModelVariation
|
|
206
|
+
? SharedSliceModelVariationValue<T>
|
|
207
|
+
: never;
|
|
208
208
|
|
|
209
209
|
type CustomTypeModelValue<T extends prismic.CustomTypeModel> =
|
|
210
210
|
prismic.PrismicDocument<
|
|
@@ -223,36 +223,42 @@ type CustomTypeModelFieldForGroupValue<
|
|
|
223
223
|
> = T extends prismic.CustomTypeModelBooleanField
|
|
224
224
|
? prismic.BooleanField
|
|
225
225
|
: T extends prismic.CustomTypeModelColorField
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
226
|
+
? prismic.ColorField<State>
|
|
227
|
+
: T extends prismic.CustomTypeModelRichTextField
|
|
228
|
+
? prismic.RichTextField<State>
|
|
229
|
+
: T extends prismic.CustomTypeModelTitleField
|
|
230
|
+
? prismic.TitleField<State>
|
|
231
|
+
: T extends prismic.CustomTypeModelImageField<infer TThumbnailNames>
|
|
232
|
+
? prismic.ImageField<TThumbnailNames, State>
|
|
233
|
+
: T extends prismic.CustomTypeModelLinkField
|
|
234
|
+
? prismic.LinkField<string, string, never, State>
|
|
235
|
+
: T extends prismic.CustomTypeModelLinkToMediaField
|
|
236
|
+
? prismic.LinkToMediaField<State>
|
|
237
|
+
: T extends prismic.CustomTypeModelContentRelationshipField
|
|
238
|
+
? prismic.ContentRelationshipField<string, string, never, State>
|
|
239
|
+
: T extends prismic.CustomTypeModelDateField
|
|
240
|
+
? prismic.DateField<State>
|
|
241
|
+
: T extends prismic.CustomTypeModelTimestampField
|
|
242
|
+
? prismic.TimestampField<State>
|
|
243
|
+
: T extends prismic.CustomTypeModelNumberField
|
|
244
|
+
? prismic.NumberField<State>
|
|
245
|
+
: T extends prismic.CustomTypeModelKeyTextField
|
|
246
|
+
? prismic.KeyTextField<State>
|
|
247
|
+
: T extends prismic.CustomTypeModelSelectField
|
|
248
|
+
? prismic.SelectField<string, State>
|
|
249
|
+
: T extends prismic.CustomTypeModelEmbedField
|
|
250
|
+
? prismic.EmbedField<
|
|
251
|
+
prismic.AnyOEmbed & prismic.OEmbedExtra,
|
|
252
|
+
State
|
|
253
|
+
>
|
|
254
|
+
: T extends prismic.CustomTypeModelGeoPointField
|
|
255
|
+
? prismic.GeoPointField<State>
|
|
256
|
+
: T extends prismic.CustomTypeModelIntegrationField
|
|
257
|
+
? prismic.IntegrationField<
|
|
258
|
+
Record<string, unknown>,
|
|
259
|
+
State
|
|
260
|
+
>
|
|
261
|
+
: never;
|
|
256
262
|
|
|
257
263
|
type CustomTypeModelGroupFieldValue<
|
|
258
264
|
T extends prismic.CustomTypeModelGroupField,
|
package/src/value/boolean.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
import { MockValueConfig } from "../types";
|
|
6
6
|
|
|
7
7
|
export type MockBooleanValueConfig<
|
|
8
|
-
Model extends
|
|
8
|
+
Model extends
|
|
9
|
+
prismic.CustomTypeModelBooleanField = prismic.CustomTypeModelBooleanField,
|
|
9
10
|
> = MockValueConfig<Model>;
|
|
10
11
|
|
|
11
12
|
export const boolean = <Model extends prismic.CustomTypeModelBooleanField>(
|
package/src/value/color.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { createFaker } from "../lib/createFaker";
|
|
|
5
5
|
import { MockValueStateConfig, MockValueConfig } from "../types";
|
|
6
6
|
|
|
7
7
|
export type MockColorValueConfig<
|
|
8
|
-
Model extends
|
|
8
|
+
Model extends
|
|
9
|
+
prismic.CustomTypeModelColorField = prismic.CustomTypeModelColorField,
|
|
9
10
|
State extends prismic.FieldState = prismic.FieldState,
|
|
10
11
|
> = MockValueConfig<Model> & MockValueStateConfig<State>;
|
|
11
12
|
|
|
@@ -14,7 +15,8 @@ export type MockColorValue<
|
|
|
14
15
|
> = prismic.ColorField<State>;
|
|
15
16
|
|
|
16
17
|
export const color = <
|
|
17
|
-
Model extends
|
|
18
|
+
Model extends
|
|
19
|
+
prismic.CustomTypeModelColorField = prismic.CustomTypeModelColorField,
|
|
18
20
|
State extends prismic.FieldState = "filled",
|
|
19
21
|
>(
|
|
20
22
|
config: MockColorValueConfig<Model, State>,
|