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-alpha.2

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> = {
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 {};

@@ -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 @@ };

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) & {

@@ -67,5 +61,5 @@ label: string;

config: {
text: prismic.CustomTypeModelKeyTextField;
allowText: true;
} | {
text?: undefined;
allowText?: undefined;
};

@@ -75,5 +69,5 @@ };

config: {
text: prismic.CustomTypeModelKeyTextField;
allowText: true;
} | {
text?: undefined;
allowText?: undefined;
};

@@ -80,0 +74,0 @@ };

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

@@ -10,13 +10,13 @@ allowTargetBlank: true;

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

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

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

@@ -16,0 +16,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;
type MockLinkToMediaModel<AllowText extends boolean = boolean> = prismic.CustomTypeModelLinkToMediaField & {
config: AllowText extends true ? {
allowText: true;
} : {
text?: undefined;
allowText?: undefined;
};
};
export type MockLinkToMediaModelConfig<WithText extends boolean = boolean> = {
withText?: WithText;
export type MockLinkToMediaModelConfig<AllowText extends boolean = boolean> = {
allowText?: AllowText;
} & MockModelConfig;
export declare const linkToMedia: <WithText extends boolean = boolean>(config: MockLinkToMediaModelConfig<WithText>) => MockLinkToMediaModel<WithText>;
export declare const linkToMedia: <AllowText extends boolean = boolean>(config: MockLinkToMediaModelConfig<AllowText>) => MockLinkToMediaModel<AllowText>;
export {};

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

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

@@ -17,0 +15,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,3 @@ import * as prismic from "@prismicio/client";

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

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

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

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

@@ -44,3 +43,3 @@ }

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
text: config.withText ?? (((_b = model.config) == null ? void 0 : _b.allowText) && faker.boolean()) ? sentenceCase(faker.words(2)) : void 0
};

@@ -47,0 +46,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;
withText?: NonNullable<Model["config"]>["allowText"] extends undefined ? false : boolean;
} & MockValueConfig<Model> & MockValueStateConfig<State>;

@@ -6,0 +6,0 @@ type MockLinkToMediaValue<State extends prismic.FieldState = prismic.FieldState> = prismic.LinkToMediaField<State>;

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

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

@@ -25,0 +25,0 @@ }

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

@@ -65,3 +65,3 @@ "keywords": [

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

@@ -68,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 @@ ],

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

document: Document;
text?: string;
};

@@ -31,4 +30,3 @@

isBroken: false,
text: config.text,
};
};
import * as prismic from "@prismicio/client";
import * as changeCase from "change-case";
import { createFaker } from "../lib/createFaker";

@@ -8,20 +7,8 @@

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 +19,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 +33,4 @@

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

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

AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
AllowText extends boolean = boolean,
> = prismic.CustomTypeModelLinkField & {

@@ -17,5 +17,5 @@ config: AllowTargetBlank extends true

} & {
config: WithText extends true
? { text: prismic.CustomTypeModelKeyTextField }
: { text?: undefined };
config: AllowText extends true
? { allowText: true }
: { allowText?: undefined };
};

@@ -25,6 +25,6 @@

AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
AllowText extends boolean = boolean,
> = {
allowTargetBlank?: AllowTargetBlank;
withText?: WithText;
allowText?: AllowText;
} & MockModelConfig;

@@ -34,6 +34,6 @@

AllowTargetBlank extends boolean = boolean,
WithText extends boolean = boolean,
AllowText extends boolean = boolean,
>(
config: MockLinkModelConfig<AllowTargetBlank, WithText>,
): MockLinkModel<AllowTargetBlank, WithText> => {
config: MockLinkModelConfig<AllowTargetBlank, AllowText>,
): MockLinkModel<AllowTargetBlank, AllowText> => {
const faker = config.faker || createFaker(config.seed);

@@ -51,7 +51,7 @@

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

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

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

@@ -31,9 +31,7 @@

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

@@ -8,3 +7,2 @@ import { buildContentRelationshipField } from "../lib/buildContentRelationshipField";

import { generateTags } from "../lib/generateTags";
import {

@@ -15,7 +13,4 @@ MockValueStateConfig,

} from "../types";
import * as modelGen from "../model";
import { document as documentGen } from "./document";
export type MockContentRelationshipValueConfig<

@@ -26,5 +21,2 @@ Model extends

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

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

MockValueStateConfig<State>;
type MockContentRelationshipValue<

@@ -48,3 +39,2 @@ Model extends

>;
export const contentRelationship = <

@@ -58,3 +48,2 @@ Model extends

const faker = config.faker || createFaker(config.seed);
if (config.state === "empty") {

@@ -66,3 +55,2 @@ return {

const model = config.model || modelGen.contentRelationship({ faker });
const linkableDocuments = config.linkableDocuments

@@ -77,3 +65,2 @@ ? config.linkableDocuments.filter(

let shouldKeep = true;
if (model.config?.customtypes) {

@@ -83,3 +70,2 @@ shouldKeep =

}
if (model.config?.tags) {

@@ -108,5 +94,3 @@ shouldKeep =

];
const document = faker.randomElement(linkableDocuments);
if (!document) {

@@ -118,8 +102,4 @@ throw new Error("A linkable document could not be found.");

document,
text:
config.withText ?? model.config?.text
? changeCase.sentenceCase(faker.words(2))
: undefined,
}) as unknown as MockContentRelationshipValue<Model, State>;
}
};

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

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

@@ -83,3 +83,2 @@ : boolean;

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

@@ -109,3 +108,3 @@ }

text:
config.withText ?? model.config?.text
config.withText ?? (model.config?.allowText && faker.boolean())
? changeCase.sentenceCase(faker.words(2))

@@ -112,0 +111,0 @@ : undefined,

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

> = {
withText?: NonNullable<Model["config"]>["text"] extends undefined
withText?: NonNullable<Model["config"]>["allowText"] extends undefined
? false

@@ -51,3 +51,3 @@ : boolean;

text:
config.withText ?? model.config?.text
config.withText ?? (model.config?.allowText && faker.boolean())
? changeCase.sentenceCase(faker.words(2))

@@ -54,0 +54,0 @@ : undefined,

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