@roundtreasury/prisma-extension-soft-delete 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/esm/lib/createSoftDeleteExtension.js +2 -4
- package/dist/esm/lib/helpers/createParams.d.ts +1 -1
- package/dist/esm/lib/types.d.ts +3 -3
- package/dist/lib/createSoftDeleteExtension.js +2 -4
- package/dist/lib/helpers/createParams.d.ts +1 -1
- package/dist/lib/types.d.ts +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>Prisma Extension Soft Delete</h1>
|
|
3
3
|
|
|
4
|
-
<p>
|
|
4
|
+
<p>Prisma extension for soft deleting records.</p>
|
|
5
5
|
|
|
6
6
|
<p>
|
|
7
7
|
Soft deleting records is a common pattern in many applications. This library provides an extension for Prisma that
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Prisma } from "@prisma/client";
|
|
2
1
|
import { Prisma as PrismaExtensions } from "@prisma/client/extension";
|
|
3
2
|
import { withNestedOperations, } from "@roundtreasury/prisma-extension-nested-operations";
|
|
4
3
|
import { createAggregateParams, createCountParams, createDeleteManyParams, createDeleteParams, createFindFirstParams, createFindFirstOrThrowParams, createFindManyParams, createFindUniqueParams, createFindUniqueOrThrowParams, createIncludeParams, createSelectParams, createUpdateManyParams, createUpdateParams, createUpsertParams, createWhereParams, createGroupByParams, createContext, } from "./helpers/createParams";
|
|
@@ -15,7 +14,6 @@ export function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
15
14
|
if (!defaultConfig.createValue) {
|
|
16
15
|
throw new Error("prisma-extension-soft-delete: defaultConfig.createValue is required");
|
|
17
16
|
}
|
|
18
|
-
const dmmfToUse = dmmf !== null && dmmf !== void 0 ? dmmf : Prisma.dmmf;
|
|
19
17
|
const modelConfig = {};
|
|
20
18
|
Object.keys(models).forEach((model) => {
|
|
21
19
|
const modelName = model;
|
|
@@ -25,7 +23,7 @@ export function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
25
23
|
typeof config === "boolean" && config ? defaultConfig : config;
|
|
26
24
|
}
|
|
27
25
|
});
|
|
28
|
-
const context = createContext(
|
|
26
|
+
const context = createContext(dmmf);
|
|
29
27
|
const createParamsByModel = Object.keys(modelConfig).reduce((acc, model) => {
|
|
30
28
|
const config = modelConfig[model];
|
|
31
29
|
return {
|
|
@@ -68,7 +66,7 @@ export function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
68
66
|
$allModels: {
|
|
69
67
|
// @ts-expect-error - we don't know what the client is
|
|
70
68
|
$allOperations: withNestedOperations({
|
|
71
|
-
dmmf
|
|
69
|
+
dmmf,
|
|
72
70
|
async $rootOperation(initialParams) {
|
|
73
71
|
var _a, _b;
|
|
74
72
|
const createParams = (_a = createParamsByModel[initialParams.model || ""]) === null || _a === void 0 ? void 0 : _a[initialParams.operation];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NestedParams } from "@roundtreasury/prisma-extension-nested-operations";
|
|
2
|
-
import { BaseDMMF } from "@prisma/client/runtime/library";
|
|
2
|
+
import type { BaseDMMF } from "@prisma/client/runtime/library";
|
|
3
3
|
import { Context, ModelConfig } from "../types";
|
|
4
4
|
export declare const createContext: (dmmf: BaseDMMF) => Context;
|
|
5
5
|
export type Params = Omit<NestedParams<any>, "operation"> & {
|
package/dist/esm/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Prisma } from "@prisma/client";
|
|
2
|
-
import { BaseDMMF } from "@prisma/client/runtime/library";
|
|
1
|
+
import type { Prisma } from "@prisma/client";
|
|
2
|
+
import type { BaseDMMF } from "@prisma/client/runtime/library";
|
|
3
3
|
export type Context = {
|
|
4
4
|
uniqueFieldsByModel: Record<string, string[]>;
|
|
5
5
|
uniqueIndexFieldsByModel: Record<string, string[]>;
|
|
@@ -13,5 +13,5 @@ export type ModelConfig = {
|
|
|
13
13
|
export type Config = {
|
|
14
14
|
models: Partial<Record<Prisma.ModelName, ModelConfig | boolean>>;
|
|
15
15
|
defaultConfig?: ModelConfig;
|
|
16
|
-
dmmf
|
|
16
|
+
dmmf: BaseDMMF;
|
|
17
17
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSoftDeleteExtension = void 0;
|
|
4
|
-
const client_1 = require("@prisma/client");
|
|
5
4
|
const extension_1 = require("@prisma/client/extension");
|
|
6
5
|
const prisma_extension_nested_operations_1 = require("@roundtreasury/prisma-extension-nested-operations");
|
|
7
6
|
const createParams_1 = require("./helpers/createParams");
|
|
@@ -18,7 +17,6 @@ function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
18
17
|
if (!defaultConfig.createValue) {
|
|
19
18
|
throw new Error("prisma-extension-soft-delete: defaultConfig.createValue is required");
|
|
20
19
|
}
|
|
21
|
-
const dmmfToUse = dmmf !== null && dmmf !== void 0 ? dmmf : client_1.Prisma.dmmf;
|
|
22
20
|
const modelConfig = {};
|
|
23
21
|
Object.keys(models).forEach((model) => {
|
|
24
22
|
const modelName = model;
|
|
@@ -28,7 +26,7 @@ function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
28
26
|
typeof config === "boolean" && config ? defaultConfig : config;
|
|
29
27
|
}
|
|
30
28
|
});
|
|
31
|
-
const context = (0, createParams_1.createContext)(
|
|
29
|
+
const context = (0, createParams_1.createContext)(dmmf);
|
|
32
30
|
const createParamsByModel = Object.keys(modelConfig).reduce((acc, model) => {
|
|
33
31
|
const config = modelConfig[model];
|
|
34
32
|
return {
|
|
@@ -71,7 +69,7 @@ function createSoftDeleteExtension({ models, defaultConfig = {
|
|
|
71
69
|
$allModels: {
|
|
72
70
|
// @ts-expect-error - we don't know what the client is
|
|
73
71
|
$allOperations: (0, prisma_extension_nested_operations_1.withNestedOperations)({
|
|
74
|
-
dmmf
|
|
72
|
+
dmmf,
|
|
75
73
|
async $rootOperation(initialParams) {
|
|
76
74
|
var _a, _b;
|
|
77
75
|
const createParams = (_a = createParamsByModel[initialParams.model || ""]) === null || _a === void 0 ? void 0 : _a[initialParams.operation];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NestedParams } from "@roundtreasury/prisma-extension-nested-operations";
|
|
2
|
-
import { BaseDMMF } from "@prisma/client/runtime/library";
|
|
2
|
+
import type { BaseDMMF } from "@prisma/client/runtime/library";
|
|
3
3
|
import { Context, ModelConfig } from "../types";
|
|
4
4
|
export declare const createContext: (dmmf: BaseDMMF) => Context;
|
|
5
5
|
export type Params = Omit<NestedParams<any>, "operation"> & {
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Prisma } from "@prisma/client";
|
|
2
|
-
import { BaseDMMF } from "@prisma/client/runtime/library";
|
|
1
|
+
import type { Prisma } from "@prisma/client";
|
|
2
|
+
import type { BaseDMMF } from "@prisma/client/runtime/library";
|
|
3
3
|
export type Context = {
|
|
4
4
|
uniqueFieldsByModel: Record<string, string[]>;
|
|
5
5
|
uniqueIndexFieldsByModel: Record<string, string[]>;
|
|
@@ -13,5 +13,5 @@ export type ModelConfig = {
|
|
|
13
13
|
export type Config = {
|
|
14
14
|
models: Partial<Record<Prisma.ModelName, ModelConfig | boolean>>;
|
|
15
15
|
defaultConfig?: ModelConfig;
|
|
16
|
-
dmmf
|
|
16
|
+
dmmf: BaseDMMF;
|
|
17
17
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roundtreasury/prisma-extension-soft-delete",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Prisma extension for soft deleting records",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"author": "Olivier Wilkinson",
|
|
30
30
|
"license": "Apache-2.0",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@roundtreasury/prisma-extension-nested-operations": "
|
|
32
|
+
"@roundtreasury/prisma-extension-nested-operations": "1.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@prisma/client": "*"
|