@prismicio/plugin-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_node_modules/lower-case/dist.es2015/index.js +7 -0
- package/dist/_node_modules/lower-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/no-case/dist.es2015/index.js +28 -0
- package/dist/_node_modules/no-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js +68 -0
- package/dist/_node_modules/p-limit/_node_modules/yocto-queue/index.js.map +1 -0
- package/dist/_node_modules/p-limit/index.js +77 -0
- package/dist/_node_modules/p-limit/index.js.map +1 -0
- package/dist/_node_modules/pascal-case/dist.es2015/index.js +25 -0
- package/dist/_node_modules/pascal-case/dist.es2015/index.js.map +1 -0
- package/dist/_node_modules/tslib/tslib.es6.js +14 -0
- package/dist/_node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/createPluginHookSystem.d.ts +6 -0
- package/dist/createPluginHookSystem.js +8 -0
- package/dist/createPluginHookSystem.js.map +1 -0
- package/dist/createPluginSystemActions.d.ts +46 -0
- package/dist/createPluginSystemActions.js +96 -0
- package/dist/createPluginSystemActions.js.map +1 -0
- package/dist/createPluginSystemContext.d.ts +31 -0
- package/dist/createPluginSystemContext.js +12 -0
- package/dist/createPluginSystemContext.js.map +1 -0
- package/dist/createPluginSystemHelpers.d.ts +37 -0
- package/dist/createPluginSystemHelpers.js +72 -0
- package/dist/createPluginSystemHelpers.js.map +1 -0
- package/dist/createPluginSystemRunner.d.ts +58 -0
- package/dist/createPluginSystemRunner.js +128 -0
- package/dist/createPluginSystemRunner.js.map +1 -0
- package/dist/definePlugin.d.ts +30 -0
- package/dist/definePlugin.js +5 -0
- package/dist/definePlugin.js.map +1 -0
- package/dist/fs/buildCustomTypeDirectoryPath.d.ts +5 -0
- package/dist/fs/buildCustomTypeDirectoryPath.js +9 -0
- package/dist/fs/buildCustomTypeDirectoryPath.js.map +1 -0
- package/dist/fs/buildCustomTypeFilePath.d.ts +5 -0
- package/dist/fs/buildCustomTypeFilePath.js +9 -0
- package/dist/fs/buildCustomTypeFilePath.js.map +1 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.d.ts +6 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.js +8 -0
- package/dist/fs/buildCustomTypeLibraryDirectoryPath.js.map +1 -0
- package/dist/fs/buildSliceDirectoryPath.d.ts +4 -0
- package/dist/fs/buildSliceDirectoryPath.js +12 -0
- package/dist/fs/buildSliceDirectoryPath.js.map +1 -0
- package/dist/fs/buildSliceFilePath.d.ts +5 -0
- package/dist/fs/buildSliceFilePath.js +9 -0
- package/dist/fs/buildSliceFilePath.js.map +1 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.d.ts +7 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.js +8 -0
- package/dist/fs/buildSliceLibraryDirectoryPath.js.map +1 -0
- package/dist/fs/checkHasProjectFile.d.ts +6 -0
- package/dist/fs/checkHasProjectFile.js +9 -0
- package/dist/fs/checkHasProjectFile.js.map +1 -0
- package/dist/fs/checkIsTypeScriptProject.d.ts +4 -0
- package/dist/fs/checkIsTypeScriptProject.js +12 -0
- package/dist/fs/checkIsTypeScriptProject.js.map +1 -0
- package/dist/fs/constants.d.ts +9 -0
- package/dist/fs/constants.js +15 -0
- package/dist/fs/constants.js.map +1 -0
- package/dist/fs/deleteCustomTypeDirectory.d.ts +3 -0
- package/dist/fs/deleteCustomTypeDirectory.js +18 -0
- package/dist/fs/deleteCustomTypeDirectory.js.map +1 -0
- package/dist/fs/deleteProjectFile.d.ts +6 -0
- package/dist/fs/deleteProjectFile.js +10 -0
- package/dist/fs/deleteProjectFile.js.map +1 -0
- package/dist/fs/deleteSliceDirectory.d.ts +3 -0
- package/dist/fs/deleteSliceDirectory.js +18 -0
- package/dist/fs/deleteSliceDirectory.js.map +1 -0
- package/dist/fs/deleteSliceFile.d.ts +3 -0
- package/dist/fs/deleteSliceFile.js +18 -0
- package/dist/fs/deleteSliceFile.js.map +1 -0
- package/dist/fs/index.d.ts +49 -0
- package/dist/fs/index.js +53 -0
- package/dist/fs/index.js.map +1 -0
- package/dist/fs/lib/checkPathExists.d.ts +2 -0
- package/dist/fs/lib/checkPathExists.js +13 -0
- package/dist/fs/lib/checkPathExists.js.map +1 -0
- package/dist/fs/lib/fsLimit.d.ts +31 -0
- package/dist/fs/lib/fsLimit.js +23 -0
- package/dist/fs/lib/fsLimit.js.map +1 -0
- package/dist/fs/lib/isCustomTypeModel.d.ts +2 -0
- package/dist/fs/lib/isCustomTypeModel.js +7 -0
- package/dist/fs/lib/isCustomTypeModel.js.map +1 -0
- package/dist/fs/lib/isSharedSliceModel.d.ts +2 -0
- package/dist/fs/lib/isSharedSliceModel.js +7 -0
- package/dist/fs/lib/isSharedSliceModel.js.map +1 -0
- package/dist/fs/lib/pascalCase.d.ts +8 -0
- package/dist/fs/lib/pascalCase.js +10 -0
- package/dist/fs/lib/pascalCase.js.map +1 -0
- package/dist/fs/lib/readJSONFile.d.ts +1 -0
- package/dist/fs/lib/readJSONFile.js +9 -0
- package/dist/fs/lib/readJSONFile.js.map +1 -0
- package/dist/fs/lib/resolveSliceModel.d.ts +10 -0
- package/dist/fs/lib/resolveSliceModel.js +14 -0
- package/dist/fs/lib/resolveSliceModel.js.map +1 -0
- package/dist/fs/readCustomTypeFile.d.ts +8 -0
- package/dist/fs/readCustomTypeFile.js +14 -0
- package/dist/fs/readCustomTypeFile.js.map +1 -0
- package/dist/fs/readCustomTypeLibrary.d.ts +6 -0
- package/dist/fs/readCustomTypeLibrary.js +53 -0
- package/dist/fs/readCustomTypeLibrary.js.map +1 -0
- package/dist/fs/readCustomTypeModel.d.ts +7 -0
- package/dist/fs/readCustomTypeModel.js +16 -0
- package/dist/fs/readCustomTypeModel.js.map +1 -0
- package/dist/fs/readProjectFile.d.ts +12 -0
- package/dist/fs/readProjectFile.js +9 -0
- package/dist/fs/readProjectFile.js.map +1 -0
- package/dist/fs/readSliceFile.d.ts +8 -0
- package/dist/fs/readSliceFile.js +17 -0
- package/dist/fs/readSliceFile.js.map +1 -0
- package/dist/fs/readSliceLibrary.d.ts +7 -0
- package/dist/fs/readSliceLibrary.js +56 -0
- package/dist/fs/readSliceLibrary.js.map +1 -0
- package/dist/fs/readSliceModel.d.ts +11 -0
- package/dist/fs/readSliceModel.js +46 -0
- package/dist/fs/readSliceModel.js.map +1 -0
- package/dist/fs/renameCustomType.d.ts +3 -0
- package/dist/fs/renameCustomType.js +8 -0
- package/dist/fs/renameCustomType.js.map +1 -0
- package/dist/fs/renameSlice.d.ts +7 -0
- package/dist/fs/renameSlice.js +22 -0
- package/dist/fs/renameSlice.js.map +1 -0
- package/dist/fs/types.d.ts +3 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.d.ts +16 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.js +37 -0
- package/dist/fs/upsertGlobalTypeScriptTypes.js.map +1 -0
- package/dist/fs/writeCustomTypeFile.d.ts +9 -0
- package/dist/fs/writeCustomTypeFile.js +18 -0
- package/dist/fs/writeCustomTypeFile.js.map +1 -0
- package/dist/fs/writeCustomTypeModel.d.ts +12 -0
- package/dist/fs/writeCustomTypeModel.js +14 -0
- package/dist/fs/writeCustomTypeModel.js.map +1 -0
- package/dist/fs/writeProjectFile.d.ts +15 -0
- package/dist/fs/writeProjectFile.js +16 -0
- package/dist/fs/writeProjectFile.js.map +1 -0
- package/dist/fs/writeSliceFile.d.ts +9 -0
- package/dist/fs/writeSliceFile.js +18 -0
- package/dist/fs/writeSliceFile.js.map +1 -0
- package/dist/fs/writeSliceModel.d.ts +11 -0
- package/dist/fs/writeSliceModel.js +13 -0
- package/dist/fs/writeSliceModel.js.map +1 -0
- package/dist/hooks/customType-create.d.ts +28 -0
- package/dist/hooks/customType-delete.d.ts +26 -0
- package/dist/hooks/customType-read.d.ts +32 -0
- package/dist/hooks/customType-rename.d.ts +29 -0
- package/dist/hooks/customType-update.d.ts +29 -0
- package/dist/hooks/customTypeLibrary-read.d.ts +25 -0
- package/dist/hooks/debug.d.ts +22 -0
- package/dist/hooks/project-init.d.ts +35 -0
- package/dist/hooks/slice-create.d.ts +30 -0
- package/dist/hooks/slice-delete.d.ts +26 -0
- package/dist/hooks/slice-read.d.ts +32 -0
- package/dist/hooks/slice-rename.d.ts +26 -0
- package/dist/hooks/slice-update.d.ts +29 -0
- package/dist/hooks/sliceLibrary-read.d.ts +27 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/DecodeError.d.ts +13 -0
- package/dist/lib/DecodeError.js +21 -0
- package/dist/lib/DecodeError.js.map +1 -0
- package/dist/lib/HookSystem.d.ts +93 -0
- package/dist/lib/HookSystem.js +121 -0
- package/dist/lib/HookSystem.js.map +1 -0
- package/dist/lib/decode.d.ts +10 -0
- package/dist/lib/decode.js +16 -0
- package/dist/lib/decode.js.map +1 -0
- package/dist/lib/decodePrismicConfig.d.ts +3 -0
- package/dist/lib/decodePrismicConfig.js +22 -0
- package/dist/lib/decodePrismicConfig.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/package.json +90 -0
- package/src/createPluginHookSystem.ts +9 -0
- package/src/createPluginSystemActions.ts +188 -0
- package/src/createPluginSystemContext.ts +51 -0
- package/src/createPluginSystemHelpers.ts +129 -0
- package/src/createPluginSystemRunner.ts +216 -0
- package/src/definePlugin.ts +48 -0
- package/src/fs/buildCustomTypeDirectoryPath.ts +19 -0
- package/src/fs/buildCustomTypeFilePath.ts +16 -0
- package/src/fs/buildCustomTypeLibraryDirectoryPath.ts +16 -0
- package/src/fs/buildSliceDirectoryPath.ts +25 -0
- package/src/fs/buildSliceFilePath.ts +16 -0
- package/src/fs/buildSliceLibraryDirectoryPath.ts +17 -0
- package/src/fs/checkHasProjectFile.ts +16 -0
- package/src/fs/checkIsTypeScriptProject.ts +16 -0
- package/src/fs/constants.ts +15 -0
- package/src/fs/deleteCustomTypeDirectory.ts +24 -0
- package/src/fs/deleteProjectFile.ts +18 -0
- package/src/fs/deleteSliceDirectory.ts +24 -0
- package/src/fs/deleteSliceFile.ts +24 -0
- package/src/fs/index.ts +103 -0
- package/src/fs/lib/checkPathExists.ts +13 -0
- package/src/fs/lib/fsLimit.ts +72 -0
- package/src/fs/lib/isCustomTypeModel.ts +7 -0
- package/src/fs/lib/isSharedSliceModel.ts +14 -0
- package/src/fs/lib/pascalCase.ts +17 -0
- package/src/fs/lib/readJSONFile.ts +7 -0
- package/src/fs/lib/resolveSliceModel.ts +28 -0
- package/src/fs/readCustomTypeFile.ts +27 -0
- package/src/fs/readCustomTypeLibrary.ts +86 -0
- package/src/fs/readCustomTypeModel.ts +27 -0
- package/src/fs/readProjectFile.ts +24 -0
- package/src/fs/readSliceFile.ts +27 -0
- package/src/fs/readSliceLibrary.ts +91 -0
- package/src/fs/readSliceModel.ts +90 -0
- package/src/fs/renameCustomType.ts +12 -0
- package/src/fs/renameSlice.ts +35 -0
- package/src/fs/types.ts +5 -0
- package/src/fs/upsertGlobalTypeScriptTypes.ts +64 -0
- package/src/fs/writeCustomTypeFile.ts +30 -0
- package/src/fs/writeCustomTypeModel.ts +31 -0
- package/src/fs/writeProjectFile.ts +39 -0
- package/src/fs/writeSliceFile.ts +30 -0
- package/src/fs/writeSliceModel.ts +26 -0
- package/src/hooks/customType-create.ts +42 -0
- package/src/hooks/customType-delete.ts +40 -0
- package/src/hooks/customType-read.ts +46 -0
- package/src/hooks/customType-rename.ts +43 -0
- package/src/hooks/customType-update.ts +43 -0
- package/src/hooks/customTypeLibrary-read.ts +38 -0
- package/src/hooks/debug.ts +31 -0
- package/src/hooks/project-init.ts +48 -0
- package/src/hooks/slice-create.ts +44 -0
- package/src/hooks/slice-delete.ts +40 -0
- package/src/hooks/slice-read.ts +44 -0
- package/src/hooks/slice-rename.ts +40 -0
- package/src/hooks/slice-update.ts +43 -0
- package/src/hooks/sliceLibrary-read.ts +41 -0
- package/src/index.ts +141 -0
- package/src/lib/DecodeError.ts +31 -0
- package/src/lib/HookSystem.ts +277 -0
- package/src/lib/decode.ts +30 -0
- package/src/lib/decodePrismicConfig.ts +26 -0
- package/src/types.ts +175 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import { CUSTOM_TYPE_MODEL_FILENAME } from "./constants";
|
|
4
|
+
import {
|
|
5
|
+
writeCustomTypeFile,
|
|
6
|
+
WriteCustomTypeFileArgs,
|
|
7
|
+
} from "./writeCustomTypeFile";
|
|
8
|
+
|
|
9
|
+
export type WriteCustomTypeModelArgs = Omit<
|
|
10
|
+
WriteCustomTypeFileArgs,
|
|
11
|
+
"customTypeID" | "filename" | "contents"
|
|
12
|
+
> & {
|
|
13
|
+
model: TypesInternal.CustomType;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Writes a CustomType model to the file system in the CustomType's CustomType
|
|
18
|
+
* library.
|
|
19
|
+
*
|
|
20
|
+
* @returns The file path to the written model.
|
|
21
|
+
*/
|
|
22
|
+
export const writeCustomTypeModel = async (
|
|
23
|
+
args: WriteCustomTypeModelArgs,
|
|
24
|
+
): Promise<string> => {
|
|
25
|
+
return await writeCustomTypeFile({
|
|
26
|
+
...args,
|
|
27
|
+
customTypeID: args.model.id,
|
|
28
|
+
filename: CUSTOM_TYPE_MODEL_FILENAME,
|
|
29
|
+
contents: JSON.stringify(args.model, null, 2),
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { PluginSystemHelpers } from "../createPluginSystemHelpers";
|
|
4
|
+
|
|
5
|
+
import * as fs from "./lib/fsLimit";
|
|
6
|
+
|
|
7
|
+
export type WriteProjectFileArgs = {
|
|
8
|
+
filename: string;
|
|
9
|
+
contents: Parameters<typeof fs.writeFile>[1];
|
|
10
|
+
format?: boolean;
|
|
11
|
+
formatOptions?: Parameters<PluginSystemHelpers["format"]>[2];
|
|
12
|
+
helpers: PluginSystemHelpers;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Writes a file to the project with optional formatting.
|
|
17
|
+
*
|
|
18
|
+
* @returns The file path to the written file.
|
|
19
|
+
*/
|
|
20
|
+
export const writeProjectFile = async (
|
|
21
|
+
args: WriteProjectFileArgs,
|
|
22
|
+
): Promise<string> => {
|
|
23
|
+
const filePath = args.helpers.joinPathFromRoot(args.filename);
|
|
24
|
+
|
|
25
|
+
let contents = args.contents;
|
|
26
|
+
|
|
27
|
+
if (args.format) {
|
|
28
|
+
contents = await args.helpers.format(
|
|
29
|
+
contents.toString(),
|
|
30
|
+
filePath,
|
|
31
|
+
args.formatOptions,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
36
|
+
await fs.writeFile(filePath, contents);
|
|
37
|
+
|
|
38
|
+
return filePath;
|
|
39
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildSliceFilePath,
|
|
3
|
+
BuildSliceFilePathArgs,
|
|
4
|
+
} from "./buildSliceFilePath";
|
|
5
|
+
import { writeProjectFile, WriteProjectFileArgs } from "./writeProjectFile";
|
|
6
|
+
|
|
7
|
+
export type WriteSliceFileArgs = Omit<WriteProjectFileArgs, "filePath"> &
|
|
8
|
+
BuildSliceFilePathArgs;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Writes a Slice model to the file system in the Slice's Slice library.
|
|
12
|
+
*
|
|
13
|
+
* @returns The file path to the written file.
|
|
14
|
+
*/
|
|
15
|
+
export const writeSliceFile = async (
|
|
16
|
+
args: WriteSliceFileArgs,
|
|
17
|
+
): Promise<string> => {
|
|
18
|
+
const filePath = await buildSliceFilePath(args);
|
|
19
|
+
const relativeFilePath = await buildSliceFilePath({
|
|
20
|
+
...args,
|
|
21
|
+
absolute: false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
await writeProjectFile({
|
|
25
|
+
...args,
|
|
26
|
+
filename: relativeFilePath,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return filePath;
|
|
30
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import { SHARED_SLICE_MODEL_FILENAME } from "./constants";
|
|
4
|
+
import { writeSliceFile, WriteSliceFileArgs } from "./writeSliceFile";
|
|
5
|
+
|
|
6
|
+
export type WriteSliceModelArgs = Omit<
|
|
7
|
+
WriteSliceFileArgs,
|
|
8
|
+
"filename" | "contents" | "sliceID"
|
|
9
|
+
> & {
|
|
10
|
+
model: TypesInternal.SharedSlice;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Writes a Slice model to the file system in the Slice's Slice library.
|
|
15
|
+
*
|
|
16
|
+
* @returns The file path to the written model.
|
|
17
|
+
*/
|
|
18
|
+
export const writeSliceModel = async (
|
|
19
|
+
args: WriteSliceModelArgs,
|
|
20
|
+
): Promise<string> => {
|
|
21
|
+
return await writeSliceFile({
|
|
22
|
+
...args,
|
|
23
|
+
filename: SHARED_SLICE_MODEL_FILENAME,
|
|
24
|
+
contents: JSON.stringify(args.model, null, 2),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `custom-type:create` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomTypeCreateHookData = {
|
|
13
|
+
model: TypesInternal.CustomType;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return value for `custom-type:create` hook handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomTypeCreateHookReturnType = void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base version of `custom-type:create` without plugin runner context.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export type CustomTypeCreateHookBase = PluginHook<
|
|
27
|
+
CustomTypeCreateHookData,
|
|
28
|
+
CustomTypeCreateHookReturnType
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Handler for the `custom-type:create` hook. The hook is called when a Custom
|
|
33
|
+
* Type is created.
|
|
34
|
+
*
|
|
35
|
+
* `custom-type:create` is only called the first time a Custom Type is saved.
|
|
36
|
+
* Subsequent saves will call the `custom-type:update` hook.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
39
|
+
*/
|
|
40
|
+
export type CustomTypeCreateHook<
|
|
41
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
42
|
+
> = ExtendPluginSystemHook<CustomTypeCreateHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `custom-type:delete` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomTypeDeleteHookData = {
|
|
13
|
+
model: TypesInternal.CustomType;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return value for `custom-type:delete` hook handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomTypeDeleteHookReturnType = void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base version of a `custom-type:delete` hook handler without plugin runner
|
|
23
|
+
* context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type CustomTypeDeleteHookBase = PluginHook<
|
|
28
|
+
CustomTypeDeleteHookData,
|
|
29
|
+
CustomTypeDeleteHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `custom-type:delete` hook. The hook is called when a Custom
|
|
34
|
+
* Type is deleted.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
37
|
+
*/
|
|
38
|
+
export type CustomTypeDeleteHook<
|
|
39
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
40
|
+
> = ExtendPluginSystemHook<CustomTypeDeleteHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `custom-type:read` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomTypeReadHookData = {
|
|
13
|
+
id: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return value for `custom-type:read` hook handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomTypeReadHookReturnType = {
|
|
20
|
+
model: TypesInternal.CustomType;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base version of a `custom-type:read` hook handler without plugin runner
|
|
25
|
+
* context.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export type CustomTypeReadHookBase = PluginHook<
|
|
30
|
+
CustomTypeReadHookData,
|
|
31
|
+
CustomTypeReadHookReturnType
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Handler for the `custom-type:read` hook. The hook is called when a Custom
|
|
36
|
+
* Type's model is needed.
|
|
37
|
+
*
|
|
38
|
+
* This hook is **required** to be implemented by adapters.
|
|
39
|
+
*
|
|
40
|
+
* This hook will only be called in adapters.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
43
|
+
*/
|
|
44
|
+
export type CustomTypeReadHook<
|
|
45
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
46
|
+
> = ExtendPluginSystemHook<CustomTypeReadHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `custom-type:rename` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomTypeRenameHookData = {
|
|
13
|
+
model: TypesInternal.CustomType;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return value for `custom-type:rename` hook handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomTypeRenameHookReturnType = void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base version of a `custom-type:rename` hook handler without plugin runner
|
|
23
|
+
* context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type CustomTypeRenameHookBase = PluginHook<
|
|
28
|
+
CustomTypeRenameHookData,
|
|
29
|
+
CustomTypeRenameHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `custom-type:rename` hook. The hook is called when a Custom
|
|
34
|
+
* Type is renamed.
|
|
35
|
+
*
|
|
36
|
+
* `custom-type:rename` is not called the first time a Custom Type is saved. The
|
|
37
|
+
* `custom-type:create` hook is called instead.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
40
|
+
*/
|
|
41
|
+
export type CustomTypeRenameHook<
|
|
42
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
43
|
+
> = ExtendPluginSystemHook<CustomTypeRenameHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `custom-type:update` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type CustomTypeUpdateHookData = {
|
|
13
|
+
model: TypesInternal.CustomType;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Return value for `custom-type:update` hook handlers.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomTypeUpdateHookReturnType = void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base version of a `custom-type:update` hook handler without plugin runner
|
|
23
|
+
* context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type CustomTypeUpdateHookBase = PluginHook<
|
|
28
|
+
CustomTypeUpdateHookData,
|
|
29
|
+
CustomTypeUpdateHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `custom-type:update` hook. The hook is called when a Custom
|
|
34
|
+
* Type is updated.
|
|
35
|
+
*
|
|
36
|
+
* `custom-type:update` is not called the first time a Custom Type is saved. The
|
|
37
|
+
* `custom-type:create` hook is called instead.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
40
|
+
*/
|
|
41
|
+
export type CustomTypeUpdateHook<
|
|
42
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
43
|
+
> = ExtendPluginSystemHook<CustomTypeUpdateHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendPluginSystemHook,
|
|
3
|
+
PluginOptions,
|
|
4
|
+
PluginHook,
|
|
5
|
+
} from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Data provided to `custom-type-library:read` hook handlers.
|
|
9
|
+
*/
|
|
10
|
+
export type CustomTypeLibraryReadHookData = undefined;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Return value for `custom-type-library:read` hook handlers.
|
|
14
|
+
*/
|
|
15
|
+
export type CustomTypeLibraryReadHookReturnType = {
|
|
16
|
+
ids: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base version of a `custom-type-library:read` hook handler without plugin
|
|
21
|
+
* runner context.
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export type CustomTypeLibraryReadHookBase = PluginHook<
|
|
26
|
+
CustomTypeLibraryReadHookData,
|
|
27
|
+
CustomTypeLibraryReadHookReturnType
|
|
28
|
+
>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Handler for the `custom-type-library:read` hook. The hook is called when a
|
|
32
|
+
* Custom Type Library's metadata is needed.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
35
|
+
*/
|
|
36
|
+
export type CustomTypeLibraryReadHook<
|
|
37
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
38
|
+
> = ExtendPluginSystemHook<CustomTypeLibraryReadHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendPluginSystemHook,
|
|
3
|
+
PluginOptions,
|
|
4
|
+
PluginHook,
|
|
5
|
+
} from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Data provided to `debug` hook handlers.
|
|
9
|
+
*/
|
|
10
|
+
export type DebugHookData = unknown;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Return value for `debug` hook handlers.
|
|
14
|
+
*/
|
|
15
|
+
export type DebugHookReturnType = unknown;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Base version of a `debug` hook handler without plugin runner context.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export type DebugHookBase = PluginHook<DebugHookData, DebugHookReturnType>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handler for the `debug` hook. This hook is never called in a production app.
|
|
26
|
+
* It can be used for testing purposes.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
29
|
+
*/
|
|
30
|
+
export type DebugHook<TPluginOptions extends PluginOptions = PluginOptions> =
|
|
31
|
+
ExtendPluginSystemHook<DebugHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtendPluginSystemHook,
|
|
3
|
+
PluginOptions,
|
|
4
|
+
PluginHook,
|
|
5
|
+
} from "../types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Data provided to `project:init` hook handlers.
|
|
9
|
+
*/
|
|
10
|
+
export type ProjectInitHookData = {
|
|
11
|
+
/**
|
|
12
|
+
* Log messages. The message may be sent to the console or elsewhere.
|
|
13
|
+
*/
|
|
14
|
+
log: (message: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Install package dependencies. The correct package manager will
|
|
17
|
+
* automatically be used (npm/Yarn/pnpm/etc.).
|
|
18
|
+
*/
|
|
19
|
+
installDependencies: (args: {
|
|
20
|
+
dependencies: Record<string, string>;
|
|
21
|
+
dev?: boolean;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Return value for `project:init` hook handlers.
|
|
27
|
+
*/
|
|
28
|
+
export type ProjectInitHookReturnType = void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Base version of `project:init` without plugin runner context.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export type ProjectInitHookBase = PluginHook<
|
|
36
|
+
ProjectInitHookData,
|
|
37
|
+
ProjectInitHookReturnType
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Handler for the `project:init` hook. The hook is called during the init
|
|
42
|
+
* Project for plugins to init
|
|
43
|
+
*
|
|
44
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
45
|
+
*/
|
|
46
|
+
export type ProjectInitHook<
|
|
47
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
48
|
+
> = ExtendPluginSystemHook<ProjectInitHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `slice:create` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceCreateHookData = {
|
|
13
|
+
libraryID: string;
|
|
14
|
+
model: TypesInternal.SharedSlice;
|
|
15
|
+
componentContents?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Return value for `slice:create` hook handlers.
|
|
20
|
+
*/
|
|
21
|
+
export type SliceCreateHookReturnType = void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Base version of `slice:create` without plugin runner context.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export type SliceCreateHookBase = PluginHook<
|
|
29
|
+
SliceCreateHookData,
|
|
30
|
+
SliceCreateHookReturnType
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Handler for the `slice:create` hook. The hook is called when a Slice is
|
|
35
|
+
* created.
|
|
36
|
+
*
|
|
37
|
+
* `slice:create` is only called the first time a Slice is saved. Subsequent
|
|
38
|
+
* saves will call the `slice:update` hook.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
41
|
+
*/
|
|
42
|
+
export type SliceCreateHook<
|
|
43
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
44
|
+
> = ExtendPluginSystemHook<SliceCreateHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `slice:delete` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceDeleteHookData = {
|
|
13
|
+
libraryID: string;
|
|
14
|
+
model: TypesInternal.SharedSlice;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return value for `slice:delete` hook handlers.
|
|
19
|
+
*/
|
|
20
|
+
export type SliceDeleteHookReturnType = void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base version of a `slice:delete` hook handler without plugin runner context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type SliceDeleteHookBase = PluginHook<
|
|
28
|
+
SliceDeleteHookData,
|
|
29
|
+
SliceDeleteHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `slice:delete` hook. The hook is called when a Slice is
|
|
34
|
+
* deleted.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
37
|
+
*/
|
|
38
|
+
export type SliceDeleteHook<
|
|
39
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
40
|
+
> = ExtendPluginSystemHook<SliceDeleteHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `slice:read` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceReadHookData = {
|
|
13
|
+
libraryID: string;
|
|
14
|
+
sliceID: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return value for `slice:read` hook handlers.
|
|
19
|
+
*/
|
|
20
|
+
export type SliceReadHookReturnType = { model: TypesInternal.SharedSlice };
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base version of a `slice:read` hook handler without plugin runner context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type SliceReadHookBase = PluginHook<
|
|
28
|
+
SliceReadHookData,
|
|
29
|
+
SliceReadHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `slice:read` hook. The hook is called when a Slice's model is
|
|
34
|
+
* needed.
|
|
35
|
+
*
|
|
36
|
+
* This hook is **required** to be implemented by adapters.
|
|
37
|
+
*
|
|
38
|
+
* This hook will only be called in adapters.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
41
|
+
*/
|
|
42
|
+
export type SliceReadHook<
|
|
43
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
44
|
+
> = ExtendPluginSystemHook<SliceReadHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `slice:rename` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceRenameHookData = {
|
|
13
|
+
libraryID: string;
|
|
14
|
+
model: TypesInternal.SharedSlice;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return value for `slice:rename` hook handlers.
|
|
19
|
+
*/
|
|
20
|
+
export type SliceRenameHookReturnType = void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base version of a `slice:rename` hook handler without plugin runner context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type SliceRenameHookBase = PluginHook<
|
|
28
|
+
SliceRenameHookData,
|
|
29
|
+
SliceRenameHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `slice:rename` hook. The hook is called when a Slice is
|
|
34
|
+
* renamed.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
37
|
+
*/
|
|
38
|
+
export type SliceRenameHook<
|
|
39
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
40
|
+
> = ExtendPluginSystemHook<SliceRenameHookBase, TPluginOptions>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TypesInternal from "@prismicio/types-internal/lib/customtypes/index.js";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ExtendPluginSystemHook,
|
|
5
|
+
PluginOptions,
|
|
6
|
+
PluginHook,
|
|
7
|
+
} from "../types";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Data provided to `slice:update` hook handlers.
|
|
11
|
+
*/
|
|
12
|
+
export type SliceUpdateHookData = {
|
|
13
|
+
libraryID: string;
|
|
14
|
+
model: TypesInternal.SharedSlice;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return value for `slice:update` hook handlers.
|
|
19
|
+
*/
|
|
20
|
+
export type SliceUpdateHookReturnType = void;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Base version of a `slice:update` hook handler without plugin runner context.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export type SliceUpdateHookBase = PluginHook<
|
|
28
|
+
SliceUpdateHookData,
|
|
29
|
+
SliceUpdateHookReturnType
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Handler for the `slice:update` hook. The hook is called when a Slice is
|
|
34
|
+
* updated.
|
|
35
|
+
*
|
|
36
|
+
* `slice:update` is not called the first time a Slice is saved. The
|
|
37
|
+
* `slice:create` hook is called instead.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam TPluginOptions - User-provided options for the hook's plugin.
|
|
40
|
+
*/
|
|
41
|
+
export type SliceUpdateHook<
|
|
42
|
+
TPluginOptions extends PluginOptions = PluginOptions,
|
|
43
|
+
> = ExtendPluginSystemHook<SliceUpdateHookBase, TPluginOptions>;
|