Socket
Socket
Sign inDemoInstall

@prismicio/mock

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/mock - npm Package Compare versions

Comparing version 0.3.8-alpha.1 to 0.3.8

3

dist/api/repository.js

@@ -21,3 +21,4 @@ import { capitalCase } from './../_node_modules/change-case/dist/index.js';

id: faker.word(),
name: capitalCase(faker.word())
name: capitalCase(faker.word()),
is_master: true
}

@@ -24,0 +25,0 @@ ],

import * as prismic from "@prismicio/client";
type BuildContentRelationshipFieldConfig<Document extends prismic.PrismicDocument> = {
type BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {
document: Document;
text?: string;
};
export declare const buildContentRelationshipField: <Document extends prismic.PrismicDocument<Record<string, any>, string, string>>(config: BuildContentRelationshipFieldConfig<Document>) => prismic.ContentRelationshipField<Document["type"], Document["lang"], never, "filled">;
export declare const buildContentRelationshipField: <Document extends prismic.PrismicDocument<Record<string, any>, string, string>>(config: BuildEmbedFieldConfig<Document>) => prismic.ContentRelationshipField<Document["type"], Document["lang"], never, "filled">;
export {};

@@ -12,4 +12,3 @@ import * as prismic from "@prismicio/client";

slug: config.document.slugs[0],
isBroken: false,
text: config.text
isBroken: false
};

@@ -16,0 +15,0 @@ };

@@ -7,2 +7,3 @@ import { sentenceCase } from './../_node_modules/change-case/dist/index.js';

return {
id: null,
url: null,

@@ -24,2 +25,3 @@ dimensions: null,

return {
id: faker.hash(11),
url: url.toString(),

@@ -26,0 +28,0 @@ dimensions,

import * as prismic from "@prismicio/client";
import { MockModelConfig } from "../types";
type MockContentRelationshipModel<CustomTypeIDs extends string = string, Tags extends string = string, WithText extends boolean = boolean> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
config: WithText extends true ? {
text: prismic.CustomTypeModelKeyTextField;
} : {
text?: undefined;
};
};
export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string, WithText extends boolean = boolean> = {
export type MockContentRelationshipModelConfig<CustomTypeIDs extends string = string, Tags extends string = string> = {
customTypeIDs?: readonly CustomTypeIDs[];
tags?: readonly Tags[];
withText?: WithText;
} & MockModelConfig;
export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string, WithText extends boolean = boolean>(config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>) => MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;
export {};
export declare const contentRelationship: <CustomTypeIDs extends string, Tags extends string>(config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>) => prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags>;

@@ -13,4 +13,3 @@ import * as prismic from "@prismicio/client";

customtypes: config.customTypeIDs,
tags: config.tags,
text: config.withText ? { type: prismic.CustomTypeModelFieldType.Text } : void 0
tags: config.tags
}

@@ -17,0 +16,0 @@ };

@@ -41,9 +41,3 @@ import * as prismic from "@prismicio/client";

color(config?: WithoutFakerConfig<MockColorModelConfig>): prismic.CustomTypeModelColorField;
contentRelationship<CustomTypeIDs extends string, Tags extends string>(config?: WithoutFakerConfig<MockContentRelationshipModelConfig<CustomTypeIDs, Tags>>): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
config: {
text: prismic.CustomTypeModelKeyTextField;
} | {
text?: undefined;
};
};
contentRelationship<CustomTypeIDs extends string, Tags extends string>(config?: WithoutFakerConfig<MockContentRelationshipModelConfig<CustomTypeIDs, Tags>>): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags>;
customType<Definition extends prismic.CustomTypeModelTab | prismic.CustomTypeModelDefinition>(config?: WithoutFakerConfig<MockCustomTypeModelConfig<Definition>>): (Definition extends Record<string, prismic.CustomTypeModelField> ? prismic.CustomTypeModel<string, Record<"Main", Definition>> : Definition extends prismic.CustomTypeModelDefinition ? prismic.CustomTypeModel<string, Definition> : never) & {

@@ -59,22 +53,4 @@ label: string;

keyText(config?: WithoutFakerConfig<MockKeyTextModelConfig>): prismic.CustomTypeModelKeyTextField;
link<AllowTargetBlank extends boolean = boolean>(config?: WithoutFakerConfig<MockLinkModelConfig<AllowTargetBlank>>): prismic.CustomTypeModelLinkField & {
config: AllowTargetBlank extends true ? {
allowTargetBlank: true;
} : {
allowTargetBlank?: undefined;
};
} & {
config: {
text: prismic.CustomTypeModelKeyTextField;
} | {
text?: undefined;
};
};
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField & {
config: {
text: prismic.CustomTypeModelKeyTextField;
} | {
text?: undefined;
};
};
link<AllowTargetBlank extends boolean = boolean>(config?: WithoutFakerConfig<MockLinkModelConfig<AllowTargetBlank>>): import("./link").MockLinkModel<AllowTargetBlank>;
linkToMedia(config?: WithoutFakerConfig<MockLinkToMediaModelConfig>): prismic.CustomTypeModelLinkToMediaField;
number(config?: WithoutFakerConfig<MockNumberModelConfig>): prismic.CustomTypeModelNumberField;

@@ -81,0 +57,0 @@ richText<WithMultipleBlocks extends boolean = boolean>(config?: WithoutFakerConfig<MockRichTextModelConfig<WithMultipleBlocks>>): WithMultipleBlocks extends true ? prismic.CustomTypeModelRichTextMultiField : prismic.CustomTypeModelRichTextSingleField;

import * as prismic from "@prismicio/client";
import { MockModelConfig } from "../types";
type MockLinkModel<AllowTargetBlank extends boolean = boolean, WithText extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
export type MockLinkModel<AllowTargetBlank extends boolean = boolean> = prismic.CustomTypeModelLinkField & {
config: AllowTargetBlank extends true ? {

@@ -9,14 +9,6 @@ allowTargetBlank: true;

};
} & {
config: WithText extends true ? {
text: prismic.CustomTypeModelKeyTextField;
} : {
text?: undefined;
};
};
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean, WithText extends boolean = boolean> = {
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
allowTargetBlank?: AllowTargetBlank;
withText?: WithText;
} & MockModelConfig;
export declare const link: <AllowTargetBlank extends boolean = boolean, WithText extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank, WithText>) => MockLinkModel<AllowTargetBlank, WithText>;
export {};
export declare const link: <AllowTargetBlank extends boolean = boolean>(config: MockLinkModelConfig<AllowTargetBlank>) => MockLinkModel<AllowTargetBlank>;

@@ -12,4 +12,3 @@ import * as prismic from "@prismicio/client";

select: null,
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0,
text: config.withText ? { type: prismic.CustomTypeModelFieldType.Text } : void 0
allowTargetBlank: ("allowTargetBlank" in config ? config.allowTargetBlank : faker.boolean()) || void 0
}

@@ -16,0 +15,0 @@ };

import * as prismic from "@prismicio/client";
import { MockModelConfig } from "../types";
type MockLinkToMediaModel<WithText extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
config: WithText extends true ? {
text: prismic.CustomTypeModelKeyTextField;
} : {
text?: undefined;
};
};
export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
withText?: WithText;
} & MockModelConfig;
export declare const linkToMedia: <WithText extends boolean = boolean>(config: MockLinkToMediaModelConfig<WithText>) => MockLinkToMediaModel<WithText>;
export {};
export type MockLinkToMediaModelConfig = MockModelConfig;
export declare const linkToMedia: (config: MockLinkToMediaModelConfig) => prismic.CustomTypeModelLinkToMediaField;

@@ -11,6 +11,3 @@ import * as prismic from "@prismicio/client";

placeholder: sentenceCase(faker.words(3)),
select: prismic.CustomTypeModelLinkSelectType.Media,
text: config.withText ? {
type: prismic.CustomTypeModelFieldType.Text
} : void 0
select: prismic.CustomTypeModelLinkSelectType.Media
}

@@ -17,0 +14,0 @@ };

import * as prismic from "@prismicio/client";
import { MockValueStateConfig, MockValueConfig, IterableElement } from "../types";
export type MockContentRelationshipValueConfig<Model extends prismic.CustomTypeModelContentRelationshipField = prismic.CustomTypeModelContentRelationshipField, State extends prismic.FieldState = prismic.FieldState> = {
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
/**

@@ -6,0 +5,0 @@ * A list of potential documents to which the field can be linked.

import * as prismic from "@prismicio/client";
import { sentenceCase } from './../_node_modules/change-case/dist/index.js';
import { buildContentRelationshipField } from "../lib/buildContentRelationshipField.js";

@@ -10,3 +9,3 @@ import { createFaker } from "../lib/createFaker.js";

const contentRelationship = (config) => {
var _a, _b, _c;
var _a, _b;
const faker = config.faker || createFaker(config.seed);

@@ -41,4 +40,3 @@ if (config.state === "empty") {

return buildContentRelationshipField({
document,
text: config.withText ?? ((_c = model.config) == null ? void 0 : _c.text) ? sentenceCase(faker.words(2)) : void 0
document
});

@@ -45,0 +43,0 @@ }

@@ -6,3 +6,2 @@ import * as prismic from "@prismicio/client";

withTargetBlank?: NonNullable<Model["config"]>["allowTargetBlank"] extends undefined ? false : boolean;
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
/**

@@ -9,0 +8,0 @@ * A list of potential documents to which the field can be linked.

import * as prismic from "@prismicio/client";
import { sentenceCase } from './../_node_modules/change-case/dist/index.js';
import { createFaker } from "../lib/createFaker.js";

@@ -8,3 +7,3 @@ import { contentRelationship } from "./contentRelationship.js";

const link = (config) => {
var _a, _b;
var _a;
const faker = config.faker || createFaker(config.seed);

@@ -26,4 +25,3 @@ const type = config.type || faker.randomElement([

state: config.state,
linkableDocuments: config.linkableDocuments,
withText: config.withText
linkableDocuments: config.linkableDocuments
});

@@ -34,4 +32,3 @@ }

faker,
state: config.state,
withText: config.withText
state: config.state
});

@@ -45,4 +42,3 @@ }

url: faker.url(),
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0,
text: config.withText ?? ((_b = model.config) == null ? void 0 : _b.text) ? sentenceCase(faker.words(2)) : void 0
target: config.withTargetBlank ?? (((_a = model.config) == null ? void 0 : _a.allowTargetBlank) && faker.boolean()) ? "_blank" : void 0
};

@@ -49,0 +45,0 @@ }

import * as prismic from "@prismicio/client";
import { MockValueStateConfig, MockValueConfig } from "../types";
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> = {
withText?: NonNullable<Model["config"]>["text"] extends undefined ? false : boolean;
} & MockValueConfig<Model> & MockValueStateConfig<State>;
export type MockLinkToMediaValueConfig<Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = prismic.FieldState> = MockValueConfig<Model> & MockValueStateConfig<State>;
type MockLinkToMediaValue<State extends prismic.FieldState = prismic.FieldState> = prismic.LinkToMediaField<State>;
export declare const linkToMedia: <Model extends prismic.CustomTypeModelLinkToMediaField = prismic.CustomTypeModelLinkToMediaField, State extends prismic.FieldState = "filled">(config: MockLinkToMediaValueConfig<Model, State>) => MockLinkToMediaValue<State>;
export {};
import * as prismic from "@prismicio/client";
import { snakeCase, sentenceCase } from './../_node_modules/change-case/dist/index.js';
import { snakeCase } from './../_node_modules/change-case/dist/index.js';
import { createFaker } from "../lib/createFaker.js";
import { link } from "../model/link.js";
const linkToMedia = (config) => {
var _a;
const faker = config.faker || createFaker(config.seed);

@@ -13,5 +11,5 @@ if (config.state === "empty") {

} else {
const model = config.model || link({ faker });
return {
link_type: prismic.LinkType.Media,
id: faker.hash(11),
name: `${snakeCase(faker.words(faker.range(1, 2)))}.example`,

@@ -22,4 +20,3 @@ kind: snakeCase(faker.word()),

height: faker.range(500, 3e3).toString(),
width: faker.range(500, 3e3).toString(),
text: config.withText ?? ((_a = model.config) == null ? void 0 : _a.text) ? sentenceCase(faker.words(2)) : void 0
width: faker.range(500, 3e3).toString()
};

@@ -26,0 +23,0 @@ }

{
"name": "@prismicio/mock",
"version": "0.3.8-alpha.1",
"version": "0.3.8",
"description": "Generate mock Prismic documents, fields, Slices, and models for development and testing environments",

@@ -58,4 +58,3 @@ "keywords": [

"types": "tsc --noEmit",
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava",
"unit:watch": "npm run unit -- --watch"
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava"
},

@@ -66,3 +65,3 @@ "dependencies": {

"devDependencies": {
"@prismicio/client": "^7.9.0-alpha.1",
"@prismicio/client": "^7.8.1",
"@size-limit/preset-small-lib": "^11.1.2",

@@ -69,0 +68,0 @@ "@types/node": "^20.12.7",

@@ -40,2 +40,3 @@ import * as prismic from "@prismicio/client";

name: changeCase.capitalCase(faker.word()),
is_master: true,
},

@@ -42,0 +43,0 @@ ],

import * as prismic from "@prismicio/client";
type BuildContentRelationshipFieldConfig<
Document extends prismic.PrismicDocument,
> = {
type BuildEmbedFieldConfig<Document extends prismic.PrismicDocument> = {
document: Document;
text?: string;
};

@@ -13,3 +10,3 @@

>(
config: BuildContentRelationshipFieldConfig<Document>,
config: BuildEmbedFieldConfig<Document>,
): prismic.ContentRelationshipField<

@@ -31,4 +28,3 @@ Document["type"],

isBroken: false,
text: config.text,
};
};

@@ -34,2 +34,3 @@ import * as prismic from "@prismicio/client";

return {
id: null,
url: null,

@@ -55,2 +56,3 @@ dimensions: null,

return {
id: faker.hash(11),
url: url.toString(),

@@ -57,0 +59,0 @@ dimensions,

@@ -8,20 +8,8 @@ import * as prismic from "@prismicio/client";

type MockContentRelationshipModel<
CustomTypeIDs extends string = string,
Tags extends string = string,
WithText extends boolean = boolean,
> = prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> & {
config: WithText extends true
? { text: prismic.CustomTypeModelKeyTextField }
: { text?: undefined };
};
export type MockContentRelationshipModelConfig<
CustomTypeIDs extends string = string,
Tags extends string = string,
WithText extends boolean = boolean,
> = {
customTypeIDs?: readonly CustomTypeIDs[];
tags?: readonly Tags[];
withText?: WithText;
} & MockModelConfig;

@@ -32,6 +20,5 @@

Tags extends string,
WithText extends boolean = boolean,
>(
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags, WithText>,
): MockContentRelationshipModel<CustomTypeIDs, Tags, WithText> => {
config: MockContentRelationshipModelConfig<CustomTypeIDs, Tags>,
): prismic.CustomTypeModelContentRelationshipField<CustomTypeIDs, Tags> => {
const faker = config.faker || createFaker(config.seed);

@@ -47,7 +34,4 @@

tags: config.tags,
text: config.withText
? { type: prismic.CustomTypeModelFieldType.Text }
: undefined,
},
} as MockContentRelationshipModel<CustomTypeIDs, Tags, WithText>;
};
};

@@ -8,29 +8,20 @@ import * as prismic from "@prismicio/client";

type MockLinkModel<
AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
> = prismic.CustomTypeModelLinkField & {
config: AllowTargetBlank extends true
? { allowTargetBlank: true }
: { allowTargetBlank?: undefined };
} & {
config: WithText extends true
? { text: prismic.CustomTypeModelKeyTextField }
: { text?: undefined };
};
export type MockLinkModel<AllowTargetBlank extends boolean = boolean> =
prismic.CustomTypeModelLinkField & {
config: AllowTargetBlank extends true
? {
allowTargetBlank: true;
}
: {
allowTargetBlank?: undefined;
};
};
export type MockLinkModelConfig<
AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
> = {
export type MockLinkModelConfig<AllowTargetBlank extends boolean = boolean> = {
allowTargetBlank?: AllowTargetBlank;
withText?: WithText;
} & MockModelConfig;
export const link = <
AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
>(
config: MockLinkModelConfig<AllowTargetBlank, WithText>,
): MockLinkModel<AllowTargetBlank, WithText> => {
export const link = <AllowTargetBlank extends boolean = boolean>(
config: MockLinkModelConfig<AllowTargetBlank>,
): MockLinkModel<AllowTargetBlank> => {
const faker = config.faker || createFaker(config.seed);

@@ -48,7 +39,4 @@

: faker.boolean()) || undefined,
text: config.withText
? { type: prismic.CustomTypeModelFieldType.Text }
: undefined,
},
} as MockLinkModel<AllowTargetBlank, WithText>;
} as MockLinkModel<AllowTargetBlank>;
};

@@ -8,16 +8,7 @@ import * as prismic from "@prismicio/client";

type MockLinkToMediaModel<WithText extends boolean = boolean> =
prismic.CustomTypeModelLinkToMediaField & {
config: WithText extends true
? { text: prismic.CustomTypeModelKeyTextField }
: { text?: undefined };
};
export type MockLinkToMediaModelConfig = MockModelConfig;
export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
withText?: WithText;
} & MockModelConfig;
export const linkToMedia = <WithText extends boolean = boolean>(
config: MockLinkToMediaModelConfig<WithText>,
): MockLinkToMediaModel<WithText> => {
export const linkToMedia = (
config: MockLinkToMediaModelConfig,
): prismic.CustomTypeModelLinkToMediaField => {
const faker = config.faker || createFaker(config.seed);

@@ -31,9 +22,4 @@

select: prismic.CustomTypeModelLinkSelectType.Media,
text: config.withText
? {
type: prismic.CustomTypeModelFieldType.Text,
}
: undefined,
},
} as MockLinkToMediaModel<WithText>;
};
};
import * as prismic from "@prismicio/client";
import * as changeCase from "change-case";

@@ -24,5 +23,2 @@ import { buildContentRelationshipField } from "../lib/buildContentRelationshipField";

> = {
withText?: NonNullable<Model["config"]>["text"] extends undefined
? false
: boolean;
/**

@@ -109,8 +105,4 @@ * A list of potential documents to which the field can be linked.

document,
text:
config.withText ?? model.config?.text
? changeCase.sentenceCase(faker.words(2))
: undefined,
}) as unknown as MockContentRelationshipValue<Model, State>;
}
};
import * as prismic from "@prismicio/client";
import * as changeCase from "change-case";

@@ -26,5 +25,2 @@ import { createFaker } from "../lib/createFaker";

: boolean;
withText?: NonNullable<Model["config"]>["text"] extends undefined
? false
: boolean;
/**

@@ -83,3 +79,2 @@ * A list of potential documents to which the field can be linked.

linkableDocuments: config.linkableDocuments,
withText: config.withText,
}) as unknown as MockLinkValue<LinkType, State>;

@@ -92,3 +87,2 @@ }

state: config.state,
withText: config.withText,
}) as MockLinkValue<LinkType, State>;

@@ -109,6 +103,2 @@ }

: undefined,
text:
config.withText ?? model.config?.text
? changeCase.sentenceCase(faker.words(2))
: undefined,
} as MockLinkValue<LinkType, State>;

@@ -115,0 +105,0 @@ }

@@ -8,4 +8,2 @@ import * as prismic from "@prismicio/client";

import * as modelGen from "../model";
export type MockLinkToMediaValueConfig<

@@ -15,8 +13,3 @@ Model extends

State extends prismic.FieldState = prismic.FieldState,
> = {
withText?: NonNullable<Model["config"]>["text"] extends undefined
? false
: boolean;
} & MockValueConfig<Model> &
MockValueStateConfig<State>;
> = MockValueConfig<Model> & MockValueStateConfig<State>;

@@ -41,6 +34,5 @@ type MockLinkToMediaValue<

} else {
const model = config.model || modelGen.link({ faker });
return {
link_type: prismic.LinkType.Media,
id: faker.hash(11),
name: `${changeCase.snakeCase(faker.words(faker.range(1, 2)))}.example`,

@@ -52,8 +44,4 @@ kind: changeCase.snakeCase(faker.word()),

width: faker.range(500, 3000).toString(),
text:
config.withText ?? model.config?.text
? changeCase.sentenceCase(faker.words(2))
: undefined,
} as MockLinkToMediaValue<State>;
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc