prisma-flare 1.3.0 → 1.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/cli/db-migrate.cjs +119 -49
- package/dist/cli/db-migrate.js +125 -49
- package/dist/cli/db-reset.cjs +119 -49
- package/dist/cli/db-reset.js +125 -49
- package/dist/cli/index.cjs +119 -49
- package/dist/cli/index.js +125 -49
- package/dist/core/flareBuilder.d.cts +17 -45
- package/dist/core/flareBuilder.d.ts +17 -45
- package/dist/core/hooks.cjs +44 -22
- package/dist/core/hooks.d.cts +8 -8
- package/dist/core/hooks.d.ts +8 -8
- package/dist/core/hooks.js +44 -22
- package/dist/{hookRegistry-CjujesJK.d.cts → hookRegistry-B8oyCNJ9.d.cts} +14 -2
- package/dist/{hookRegistry--2l0ARPy.d.ts → hookRegistry-C2bTS4YN.d.ts} +14 -2
- package/dist/hooks.cjs +44 -22
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +44 -22
- package/dist/index.cjs +30 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +30 -8
- package/dist/{prisma.types-CIEFXVL-.d.cts → prisma.types-WBv5kOSl.d.cts} +18 -1
- package/dist/{prisma.types-CIEFXVL-.d.ts → prisma.types-WBv5kOSl.d.ts} +18 -1
- package/package.json +2 -2
package/dist/hooks.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { afterChange, afterCreate, afterDelete, afterUpdate, afterUpsert, beforeCreate, beforeDelete, beforeUpdate } from './core/hooks.cjs';
|
|
2
|
-
export { h as hookRegistry } from './hookRegistry-
|
|
3
|
-
import './prisma.types-
|
|
2
|
+
export { h as hookRegistry } from './hookRegistry-B8oyCNJ9.cjs';
|
|
3
|
+
import './prisma.types-WBv5kOSl.cjs';
|
|
4
4
|
import '@prisma/client';
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { afterChange, afterCreate, afterDelete, afterUpdate, afterUpsert, beforeCreate, beforeDelete, beforeUpdate } from './core/hooks.js';
|
|
2
|
-
export { h as hookRegistry } from './hookRegistry
|
|
3
|
-
import './prisma.types-
|
|
2
|
+
export { h as hookRegistry } from './hookRegistry-C2bTS4YN.js';
|
|
3
|
+
import './prisma.types-WBv5kOSl.js';
|
|
4
4
|
import '@prisma/client';
|
package/dist/hooks.js
CHANGED
|
@@ -38,6 +38,7 @@ var HookRegistry = class {
|
|
|
38
38
|
this.fieldCache = {};
|
|
39
39
|
this.modelsWithColumnHooks = /* @__PURE__ */ new Set();
|
|
40
40
|
this.config = { ...DEFAULT_CONFIG };
|
|
41
|
+
this.disabledTags = /* @__PURE__ */ new Set();
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
44
|
* Configure the hook system.
|
|
@@ -64,30 +65,48 @@ var HookRegistry = class {
|
|
|
64
65
|
getConfig() {
|
|
65
66
|
return this.config;
|
|
66
67
|
}
|
|
67
|
-
addHook(model, action, timing, fn) {
|
|
68
|
+
addHook(model, action, timing, fn, tag) {
|
|
68
69
|
const key = `${model}:${action}`;
|
|
69
70
|
if (!this.hooks[timing][key]) {
|
|
70
71
|
this.hooks[timing][key] = [];
|
|
71
72
|
}
|
|
72
|
-
this.hooks[timing][key].push(fn);
|
|
73
|
+
this.hooks[timing][key].push({ callback: fn, tag });
|
|
73
74
|
}
|
|
74
75
|
addColumnHook(model, column, fn, options) {
|
|
75
76
|
const key = `${model}:${column}`;
|
|
76
77
|
if (!this.columnHooks.afterChange[key]) {
|
|
77
78
|
this.columnHooks.afterChange[key] = [];
|
|
78
79
|
}
|
|
79
|
-
this.columnHooks.afterChange[key].push({ callback: fn, options });
|
|
80
|
+
this.columnHooks.afterChange[key].push({ callback: fn, options, tag: options?.tag });
|
|
80
81
|
this.modelsWithColumnHooks.add(model);
|
|
81
82
|
delete this.fieldCache[model];
|
|
82
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Disable all hooks with the given tag.
|
|
86
|
+
* @example hookRegistry.disable('changelog');
|
|
87
|
+
*/
|
|
88
|
+
disable(tag) {
|
|
89
|
+
this.disabledTags.add(tag);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Re-enable hooks with the given tag.
|
|
93
|
+
* @example hookRegistry.enable('changelog');
|
|
94
|
+
*/
|
|
95
|
+
enable(tag) {
|
|
96
|
+
this.disabledTags.delete(tag);
|
|
97
|
+
}
|
|
98
|
+
isEnabled(tag) {
|
|
99
|
+
return !tag || !this.disabledTags.has(tag);
|
|
100
|
+
}
|
|
83
101
|
async runHooks(timing, model, action, args, prisma) {
|
|
84
102
|
const key = `${model}:${action}`;
|
|
85
|
-
const
|
|
103
|
+
const entries = this.hooks[timing]?.[key] ?? [];
|
|
104
|
+
const active = entries.filter((e) => this.isEnabled(e.tag));
|
|
86
105
|
if (timing === "after") {
|
|
87
|
-
await Promise.all(
|
|
106
|
+
await Promise.all(active.map((e) => e.callback(...args, prisma)));
|
|
88
107
|
} else {
|
|
89
|
-
for (const
|
|
90
|
-
await
|
|
108
|
+
for (const entry of active) {
|
|
109
|
+
await entry.callback(...args, prisma);
|
|
91
110
|
}
|
|
92
111
|
}
|
|
93
112
|
}
|
|
@@ -98,7 +117,9 @@ var HookRegistry = class {
|
|
|
98
117
|
const entries = this.columnHooks.afterChange[key];
|
|
99
118
|
if (entries && !valuesEqual(newData[column], prevData[column])) {
|
|
100
119
|
for (const entry of entries) {
|
|
101
|
-
|
|
120
|
+
if (this.isEnabled(entry.tag)) {
|
|
121
|
+
promises.push(entry.callback(prevData[column], newData[column], newData, prisma));
|
|
122
|
+
}
|
|
102
123
|
}
|
|
103
124
|
}
|
|
104
125
|
}
|
|
@@ -173,6 +194,7 @@ var HookRegistry = class {
|
|
|
173
194
|
this.fieldCache = {};
|
|
174
195
|
this.modelsWithColumnHooks.clear();
|
|
175
196
|
this.config = { ...DEFAULT_CONFIG };
|
|
197
|
+
this.disabledTags.clear();
|
|
176
198
|
}
|
|
177
199
|
};
|
|
178
200
|
var HOOK_REGISTRY_SYMBOL = /* @__PURE__ */ Symbol.for("prisma-flare.hookRegistry");
|
|
@@ -187,29 +209,29 @@ var hookRegistry_default = hookRegistry;
|
|
|
187
209
|
function normalizeModelName(model) {
|
|
188
210
|
return model.toLowerCase();
|
|
189
211
|
}
|
|
190
|
-
function beforeCreate(model, callback) {
|
|
191
|
-
hookRegistry_default.addHook(normalizeModelName(model), "create", "before", callback);
|
|
212
|
+
function beforeCreate(model, callback, options) {
|
|
213
|
+
hookRegistry_default.addHook(normalizeModelName(model), "create", "before", callback, options?.tag);
|
|
192
214
|
}
|
|
193
|
-
function beforeDelete(model, callback) {
|
|
194
|
-
hookRegistry_default.addHook(normalizeModelName(model), "delete", "before", callback);
|
|
215
|
+
function beforeDelete(model, callback, options) {
|
|
216
|
+
hookRegistry_default.addHook(normalizeModelName(model), "delete", "before", callback, options?.tag);
|
|
195
217
|
}
|
|
196
|
-
function afterCreate(model, callback) {
|
|
197
|
-
hookRegistry_default.addHook(normalizeModelName(model), "create", "after", callback);
|
|
218
|
+
function afterCreate(model, callback, options) {
|
|
219
|
+
hookRegistry_default.addHook(normalizeModelName(model), "create", "after", callback, options?.tag);
|
|
198
220
|
}
|
|
199
|
-
function afterDelete(model, callback) {
|
|
200
|
-
hookRegistry_default.addHook(normalizeModelName(model), "delete", "after", callback);
|
|
221
|
+
function afterDelete(model, callback, options) {
|
|
222
|
+
hookRegistry_default.addHook(normalizeModelName(model), "delete", "after", callback, options?.tag);
|
|
201
223
|
}
|
|
202
|
-
function beforeUpdate(model, callback) {
|
|
203
|
-
hookRegistry_default.addHook(normalizeModelName(model), "update", "before", callback);
|
|
224
|
+
function beforeUpdate(model, callback, options) {
|
|
225
|
+
hookRegistry_default.addHook(normalizeModelName(model), "update", "before", callback, options?.tag);
|
|
204
226
|
}
|
|
205
|
-
function afterUpdate(model, callback) {
|
|
206
|
-
hookRegistry_default.addHook(normalizeModelName(model), "update", "after", callback);
|
|
227
|
+
function afterUpdate(model, callback, options) {
|
|
228
|
+
hookRegistry_default.addHook(normalizeModelName(model), "update", "after", callback, options?.tag);
|
|
207
229
|
}
|
|
208
230
|
function afterChange(model, column, callback, options) {
|
|
209
231
|
hookRegistry_default.addColumnHook(normalizeModelName(model), column, callback, options);
|
|
210
232
|
}
|
|
211
|
-
function afterUpsert(model, callback) {
|
|
212
|
-
hookRegistry_default.addHook(normalizeModelName(model), "upsert", "after", callback);
|
|
233
|
+
function afterUpsert(model, callback, options) {
|
|
234
|
+
hookRegistry_default.addHook(normalizeModelName(model), "upsert", "after", callback, options?.tag);
|
|
213
235
|
}
|
|
214
236
|
export {
|
|
215
237
|
afterChange,
|
package/dist/index.cjs
CHANGED
|
@@ -743,6 +743,7 @@ var HookRegistry = class {
|
|
|
743
743
|
this.fieldCache = {};
|
|
744
744
|
this.modelsWithColumnHooks = /* @__PURE__ */ new Set();
|
|
745
745
|
this.config = { ...DEFAULT_CONFIG };
|
|
746
|
+
this.disabledTags = /* @__PURE__ */ new Set();
|
|
746
747
|
}
|
|
747
748
|
/**
|
|
748
749
|
* Configure the hook system.
|
|
@@ -769,30 +770,48 @@ var HookRegistry = class {
|
|
|
769
770
|
getConfig() {
|
|
770
771
|
return this.config;
|
|
771
772
|
}
|
|
772
|
-
addHook(model, action, timing, fn) {
|
|
773
|
+
addHook(model, action, timing, fn, tag) {
|
|
773
774
|
const key = `${model}:${action}`;
|
|
774
775
|
if (!this.hooks[timing][key]) {
|
|
775
776
|
this.hooks[timing][key] = [];
|
|
776
777
|
}
|
|
777
|
-
this.hooks[timing][key].push(fn);
|
|
778
|
+
this.hooks[timing][key].push({ callback: fn, tag });
|
|
778
779
|
}
|
|
779
780
|
addColumnHook(model, column, fn, options) {
|
|
780
781
|
const key = `${model}:${column}`;
|
|
781
782
|
if (!this.columnHooks.afterChange[key]) {
|
|
782
783
|
this.columnHooks.afterChange[key] = [];
|
|
783
784
|
}
|
|
784
|
-
this.columnHooks.afterChange[key].push({ callback: fn, options });
|
|
785
|
+
this.columnHooks.afterChange[key].push({ callback: fn, options, tag: options?.tag });
|
|
785
786
|
this.modelsWithColumnHooks.add(model);
|
|
786
787
|
delete this.fieldCache[model];
|
|
787
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* Disable all hooks with the given tag.
|
|
791
|
+
* @example hookRegistry.disable('changelog');
|
|
792
|
+
*/
|
|
793
|
+
disable(tag) {
|
|
794
|
+
this.disabledTags.add(tag);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Re-enable hooks with the given tag.
|
|
798
|
+
* @example hookRegistry.enable('changelog');
|
|
799
|
+
*/
|
|
800
|
+
enable(tag) {
|
|
801
|
+
this.disabledTags.delete(tag);
|
|
802
|
+
}
|
|
803
|
+
isEnabled(tag) {
|
|
804
|
+
return !tag || !this.disabledTags.has(tag);
|
|
805
|
+
}
|
|
788
806
|
async runHooks(timing, model, action, args, prisma) {
|
|
789
807
|
const key = `${model}:${action}`;
|
|
790
|
-
const
|
|
808
|
+
const entries = this.hooks[timing]?.[key] ?? [];
|
|
809
|
+
const active = entries.filter((e) => this.isEnabled(e.tag));
|
|
791
810
|
if (timing === "after") {
|
|
792
|
-
await Promise.all(
|
|
811
|
+
await Promise.all(active.map((e) => e.callback(...args, prisma)));
|
|
793
812
|
} else {
|
|
794
|
-
for (const
|
|
795
|
-
await
|
|
813
|
+
for (const entry of active) {
|
|
814
|
+
await entry.callback(...args, prisma);
|
|
796
815
|
}
|
|
797
816
|
}
|
|
798
817
|
}
|
|
@@ -803,7 +822,9 @@ var HookRegistry = class {
|
|
|
803
822
|
const entries = this.columnHooks.afterChange[key];
|
|
804
823
|
if (entries && !valuesEqual(newData[column], prevData[column])) {
|
|
805
824
|
for (const entry of entries) {
|
|
806
|
-
|
|
825
|
+
if (this.isEnabled(entry.tag)) {
|
|
826
|
+
promises.push(entry.callback(prevData[column], newData[column], newData, prisma));
|
|
827
|
+
}
|
|
807
828
|
}
|
|
808
829
|
}
|
|
809
830
|
}
|
|
@@ -878,6 +899,7 @@ var HookRegistry = class {
|
|
|
878
899
|
this.fieldCache = {};
|
|
879
900
|
this.modelsWithColumnHooks.clear();
|
|
880
901
|
this.config = { ...DEFAULT_CONFIG };
|
|
902
|
+
this.disabledTags.clear();
|
|
881
903
|
}
|
|
882
904
|
};
|
|
883
905
|
var HOOK_REGISTRY_SYMBOL = /* @__PURE__ */ Symbol.for("prisma-flare.hookRegistry");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PrismaClient } from '@prisma/client';
|
|
2
2
|
import FlareBuilder from './core/flareBuilder.cjs';
|
|
3
3
|
export { RelationModelMap } from './core/flareBuilder.cjs';
|
|
4
|
-
import { M as ModelName } from './prisma.types-
|
|
5
|
-
export { A as AfterHookCallback,
|
|
6
|
-
export { H as HookConfig } from './hookRegistry-
|
|
4
|
+
import { M as ModelName } from './prisma.types-WBv5kOSl.cjs';
|
|
5
|
+
export { A as AfterHookCallback, u as AggregateResult, B as BeforeHookCallback, C as ColumnChangeCallback, a as ColumnChangeOptions, r as CreateArgs, e as CreateData, s as CreateManyArgs, f as CreateManyData, g as DeleteArgs, F as FieldName, q as FindFirstArgs, p as FindManyArgs, o as HookOptions, H as HookTiming, b as ModelDelegate, d as PaginatedResult, P as PrismaOperation, R as RecordType, t as UpdateArgs, j as UpsertArgs } from './prisma.types-WBv5kOSl.cjs';
|
|
6
|
+
export { H as HookConfig } from './hookRegistry-B8oyCNJ9.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Options for FlareClient created via the factory.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PrismaClient } from '@prisma/client';
|
|
2
2
|
import FlareBuilder from './core/flareBuilder.js';
|
|
3
3
|
export { RelationModelMap } from './core/flareBuilder.js';
|
|
4
|
-
import { M as ModelName } from './prisma.types-
|
|
5
|
-
export { A as AfterHookCallback,
|
|
6
|
-
export { H as HookConfig } from './hookRegistry
|
|
4
|
+
import { M as ModelName } from './prisma.types-WBv5kOSl.js';
|
|
5
|
+
export { A as AfterHookCallback, u as AggregateResult, B as BeforeHookCallback, C as ColumnChangeCallback, a as ColumnChangeOptions, r as CreateArgs, e as CreateData, s as CreateManyArgs, f as CreateManyData, g as DeleteArgs, F as FieldName, q as FindFirstArgs, p as FindManyArgs, o as HookOptions, H as HookTiming, b as ModelDelegate, d as PaginatedResult, P as PrismaOperation, R as RecordType, t as UpdateArgs, j as UpsertArgs } from './prisma.types-WBv5kOSl.js';
|
|
6
|
+
export { H as HookConfig } from './hookRegistry-C2bTS4YN.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Options for FlareClient created via the factory.
|
package/dist/index.js
CHANGED
|
@@ -699,6 +699,7 @@ var HookRegistry = class {
|
|
|
699
699
|
this.fieldCache = {};
|
|
700
700
|
this.modelsWithColumnHooks = /* @__PURE__ */ new Set();
|
|
701
701
|
this.config = { ...DEFAULT_CONFIG };
|
|
702
|
+
this.disabledTags = /* @__PURE__ */ new Set();
|
|
702
703
|
}
|
|
703
704
|
/**
|
|
704
705
|
* Configure the hook system.
|
|
@@ -725,30 +726,48 @@ var HookRegistry = class {
|
|
|
725
726
|
getConfig() {
|
|
726
727
|
return this.config;
|
|
727
728
|
}
|
|
728
|
-
addHook(model, action, timing, fn) {
|
|
729
|
+
addHook(model, action, timing, fn, tag) {
|
|
729
730
|
const key = `${model}:${action}`;
|
|
730
731
|
if (!this.hooks[timing][key]) {
|
|
731
732
|
this.hooks[timing][key] = [];
|
|
732
733
|
}
|
|
733
|
-
this.hooks[timing][key].push(fn);
|
|
734
|
+
this.hooks[timing][key].push({ callback: fn, tag });
|
|
734
735
|
}
|
|
735
736
|
addColumnHook(model, column, fn, options) {
|
|
736
737
|
const key = `${model}:${column}`;
|
|
737
738
|
if (!this.columnHooks.afterChange[key]) {
|
|
738
739
|
this.columnHooks.afterChange[key] = [];
|
|
739
740
|
}
|
|
740
|
-
this.columnHooks.afterChange[key].push({ callback: fn, options });
|
|
741
|
+
this.columnHooks.afterChange[key].push({ callback: fn, options, tag: options?.tag });
|
|
741
742
|
this.modelsWithColumnHooks.add(model);
|
|
742
743
|
delete this.fieldCache[model];
|
|
743
744
|
}
|
|
745
|
+
/**
|
|
746
|
+
* Disable all hooks with the given tag.
|
|
747
|
+
* @example hookRegistry.disable('changelog');
|
|
748
|
+
*/
|
|
749
|
+
disable(tag) {
|
|
750
|
+
this.disabledTags.add(tag);
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Re-enable hooks with the given tag.
|
|
754
|
+
* @example hookRegistry.enable('changelog');
|
|
755
|
+
*/
|
|
756
|
+
enable(tag) {
|
|
757
|
+
this.disabledTags.delete(tag);
|
|
758
|
+
}
|
|
759
|
+
isEnabled(tag) {
|
|
760
|
+
return !tag || !this.disabledTags.has(tag);
|
|
761
|
+
}
|
|
744
762
|
async runHooks(timing, model, action, args, prisma) {
|
|
745
763
|
const key = `${model}:${action}`;
|
|
746
|
-
const
|
|
764
|
+
const entries = this.hooks[timing]?.[key] ?? [];
|
|
765
|
+
const active = entries.filter((e) => this.isEnabled(e.tag));
|
|
747
766
|
if (timing === "after") {
|
|
748
|
-
await Promise.all(
|
|
767
|
+
await Promise.all(active.map((e) => e.callback(...args, prisma)));
|
|
749
768
|
} else {
|
|
750
|
-
for (const
|
|
751
|
-
await
|
|
769
|
+
for (const entry of active) {
|
|
770
|
+
await entry.callback(...args, prisma);
|
|
752
771
|
}
|
|
753
772
|
}
|
|
754
773
|
}
|
|
@@ -759,7 +778,9 @@ var HookRegistry = class {
|
|
|
759
778
|
const entries = this.columnHooks.afterChange[key];
|
|
760
779
|
if (entries && !valuesEqual(newData[column], prevData[column])) {
|
|
761
780
|
for (const entry of entries) {
|
|
762
|
-
|
|
781
|
+
if (this.isEnabled(entry.tag)) {
|
|
782
|
+
promises.push(entry.callback(prevData[column], newData[column], newData, prisma));
|
|
783
|
+
}
|
|
763
784
|
}
|
|
764
785
|
}
|
|
765
786
|
}
|
|
@@ -834,6 +855,7 @@ var HookRegistry = class {
|
|
|
834
855
|
this.fieldCache = {};
|
|
835
856
|
this.modelsWithColumnHooks.clear();
|
|
836
857
|
this.config = { ...DEFAULT_CONFIG };
|
|
858
|
+
this.disabledTags.clear();
|
|
837
859
|
}
|
|
838
860
|
};
|
|
839
861
|
var HOOK_REGISTRY_SYMBOL = /* @__PURE__ */ Symbol.for("prisma-flare.hookRegistry");
|
|
@@ -174,6 +174,19 @@ type FieldName<T extends ModelName> = string extends T ? string : keyof NonNulla
|
|
|
174
174
|
* Callback function for column change hooks
|
|
175
175
|
*/
|
|
176
176
|
type ColumnChangeCallback<T extends ModelName = ModelName> = (oldValue: any, newValue: any, record: NonNullable<RecordType<T>>, prisma: PrismaClient) => Promise<void> | void;
|
|
177
|
+
/**
|
|
178
|
+
* Options for hook registration (beforeCreate, afterCreate, etc.)
|
|
179
|
+
*/
|
|
180
|
+
interface HookOptions {
|
|
181
|
+
/**
|
|
182
|
+
* Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* afterCreate('user', callback, { tag: 'audit' });
|
|
186
|
+
* hookRegistry.disable('audit'); // disables all hooks tagged 'audit'
|
|
187
|
+
*/
|
|
188
|
+
tag?: string;
|
|
189
|
+
}
|
|
177
190
|
/**
|
|
178
191
|
* Options for column change hooks (afterChange)
|
|
179
192
|
*/
|
|
@@ -190,6 +203,10 @@ interface ColumnChangeOptions<T extends ModelName = ModelName> {
|
|
|
190
203
|
* });
|
|
191
204
|
*/
|
|
192
205
|
includeFields?: FieldName<T>[];
|
|
206
|
+
/**
|
|
207
|
+
* Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.
|
|
208
|
+
*/
|
|
209
|
+
tag?: string;
|
|
193
210
|
}
|
|
194
211
|
/**
|
|
195
212
|
* Query builder aggregation result types
|
|
@@ -220,4 +237,4 @@ interface PaginatedResult<T> {
|
|
|
220
237
|
};
|
|
221
238
|
}
|
|
222
239
|
|
|
223
|
-
export type { AfterHookCallback as A, BeforeHookCallback as B, ColumnChangeCallback as C, DistinctInput as D, FieldName as F, GroupByInput as G, HookTiming as H, IncludeKey as I, ModelName as M, OrderByInput as O, PrismaOperation as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ColumnChangeOptions as a, ModelDelegate as b, HavingInput as c, PaginatedResult as d, CreateData as e, CreateManyData as f, DeleteArgs as g, DeleteManyArgs as h, UpdateManyData as i, UpsertArgs as j, SumFields as k, AvgFields as l, MinFields as m, MaxFields as n,
|
|
240
|
+
export type { AfterHookCallback as A, BeforeHookCallback as B, ColumnChangeCallback as C, DistinctInput as D, FieldName as F, GroupByInput as G, HookTiming as H, IncludeKey as I, ModelName as M, OrderByInput as O, PrismaOperation as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ColumnChangeOptions as a, ModelDelegate as b, HavingInput as c, PaginatedResult as d, CreateData as e, CreateManyData as f, DeleteArgs as g, DeleteManyArgs as h, UpdateManyData as i, UpsertArgs as j, SumFields as k, AvgFields as l, MinFields as m, MaxFields as n, HookOptions as o, FindManyArgs as p, FindFirstArgs as q, CreateArgs as r, CreateManyArgs as s, UpdateArgs as t, AggregateResult as u };
|
|
@@ -174,6 +174,19 @@ type FieldName<T extends ModelName> = string extends T ? string : keyof NonNulla
|
|
|
174
174
|
* Callback function for column change hooks
|
|
175
175
|
*/
|
|
176
176
|
type ColumnChangeCallback<T extends ModelName = ModelName> = (oldValue: any, newValue: any, record: NonNullable<RecordType<T>>, prisma: PrismaClient) => Promise<void> | void;
|
|
177
|
+
/**
|
|
178
|
+
* Options for hook registration (beforeCreate, afterCreate, etc.)
|
|
179
|
+
*/
|
|
180
|
+
interface HookOptions {
|
|
181
|
+
/**
|
|
182
|
+
* Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* afterCreate('user', callback, { tag: 'audit' });
|
|
186
|
+
* hookRegistry.disable('audit'); // disables all hooks tagged 'audit'
|
|
187
|
+
*/
|
|
188
|
+
tag?: string;
|
|
189
|
+
}
|
|
177
190
|
/**
|
|
178
191
|
* Options for column change hooks (afterChange)
|
|
179
192
|
*/
|
|
@@ -190,6 +203,10 @@ interface ColumnChangeOptions<T extends ModelName = ModelName> {
|
|
|
190
203
|
* });
|
|
191
204
|
*/
|
|
192
205
|
includeFields?: FieldName<T>[];
|
|
206
|
+
/**
|
|
207
|
+
* Tag to group hooks. Tagged hooks can be disabled/enabled via hookRegistry.
|
|
208
|
+
*/
|
|
209
|
+
tag?: string;
|
|
193
210
|
}
|
|
194
211
|
/**
|
|
195
212
|
* Query builder aggregation result types
|
|
@@ -220,4 +237,4 @@ interface PaginatedResult<T> {
|
|
|
220
237
|
};
|
|
221
238
|
}
|
|
222
239
|
|
|
223
|
-
export type { AfterHookCallback as A, BeforeHookCallback as B, ColumnChangeCallback as C, DistinctInput as D, FieldName as F, GroupByInput as G, HookTiming as H, IncludeKey as I, ModelName as M, OrderByInput as O, PrismaOperation as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ColumnChangeOptions as a, ModelDelegate as b, HavingInput as c, PaginatedResult as d, CreateData as e, CreateManyData as f, DeleteArgs as g, DeleteManyArgs as h, UpdateManyData as i, UpsertArgs as j, SumFields as k, AvgFields as l, MinFields as m, MaxFields as n,
|
|
240
|
+
export type { AfterHookCallback as A, BeforeHookCallback as B, ColumnChangeCallback as C, DistinctInput as D, FieldName as F, GroupByInput as G, HookTiming as H, IncludeKey as I, ModelName as M, OrderByInput as O, PrismaOperation as P, QueryArgs as Q, RecordType as R, SelectInput as S, UpdateData as U, WhereInput as W, ColumnChangeOptions as a, ModelDelegate as b, HavingInput as c, PaginatedResult as d, CreateData as e, CreateManyData as f, DeleteArgs as g, DeleteManyArgs as h, UpdateManyData as i, UpsertArgs as j, SumFields as k, AvgFields as l, MinFields as m, MaxFields as n, HookOptions as o, FindManyArgs as p, FindFirstArgs as q, CreateArgs as r, CreateManyArgs as s, UpdateArgs as t, AggregateResult as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-flare",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Prisma utilities package with callback system and query builder for chained operations",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -108,4 +108,4 @@
|
|
|
108
108
|
"dist",
|
|
109
109
|
"README.md"
|
|
110
110
|
]
|
|
111
|
-
}
|
|
111
|
+
}
|