node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import type { Action, Event, Params, Subscriber } from './types';
import type { Database } from '..';
export type * from './types';
export type State = Record<string, unknown>;
export type States = Map<Subscriber, State>;
export interface Properties {
params: Params;
result?: unknown;
}
export interface LifecycleProvider {
subscribe(subscriber: Subscriber): () => void;
clear(): void;
run(action: Action, uid: string, properties: Properties, states?: States): Promise<States>;
createEvent(action: Action, uid: string, properties: Properties, state: State): Event;
disable(): void;
enable(): void;
}
export declare const createLifecyclesProvider: (db: Database) => LifecycleProvider;
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lifecycles/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAEnC,mBAAmB,SAAS,CAAC;AAE7B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,IAAI,CAAC;IAC9C,KAAK,IAAI,IAAI,CAAC;IACd,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3F,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC;IACtF,OAAO,IAAI,IAAI,CAAC;IAChB,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,eAAO,MAAM,wBAAwB,OAAQ,QAAQ,KAAG,iBAgFvD,CAAC"}

View File

@@ -0,0 +1,73 @@
'use strict';
var assert = require('assert');
var index = require('./subscribers/index.js');
var timestamps = require('./subscribers/timestamps.js');
var modelsLifecycles = require('./subscribers/models-lifecycles.js');
const createLifecyclesProvider = (db)=>{
let subscribers = [
timestamps.timestampsLifecyclesSubscriber,
modelsLifecycles.modelsLifecyclesSubscriber
];
let isLifecycleHooksDisabled = false;
return {
subscribe (subscriber) {
assert.strict(index.isValidSubscriber(subscriber), 'Invalid subscriber. Expected function or object');
subscribers.push(subscriber);
return ()=>subscribers.splice(subscribers.indexOf(subscriber), 1);
},
clear () {
subscribers = [];
},
disable () {
isLifecycleHooksDisabled = true;
},
enable () {
isLifecycleHooksDisabled = false;
},
createEvent (action, uid, properties, state) {
const model = db.metadata.get(uid);
return {
action,
model,
state,
...properties
};
},
/**
* @param {string} action
* @param {string} uid
* @param {{ params?: any, result?: any }} properties
* @param {Map<any, any>} states
*/ async run (action, uid, properties, states = new Map()) {
if (isLifecycleHooksDisabled) return states;
for(let i = 0; i < subscribers.length; i += 1){
const subscriber = subscribers[i];
if (typeof subscriber === 'function') {
const state = states.get(subscriber) || {};
const event = this.createEvent(action, uid, properties, state);
await subscriber(event);
if (event.state) {
states.set(subscriber, event.state || state);
}
continue;
}
const hasAction = action in subscriber;
const hasModel = !subscriber.models || subscriber.models.includes(uid);
if (hasAction && hasModel) {
const state = states.get(subscriber) || {};
const event = this.createEvent(action, uid, properties, state);
await subscriber[action]?.(event);
if (event.state) {
states.set(subscriber, event.state);
}
}
}
return states;
}
};
};
exports.createLifecyclesProvider = createLifecyclesProvider;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,71 @@
import { strict } from 'assert';
import { isValidSubscriber } from './subscribers/index.mjs';
import { timestampsLifecyclesSubscriber } from './subscribers/timestamps.mjs';
import { modelsLifecyclesSubscriber } from './subscribers/models-lifecycles.mjs';
const createLifecyclesProvider = (db)=>{
let subscribers = [
timestampsLifecyclesSubscriber,
modelsLifecyclesSubscriber
];
let isLifecycleHooksDisabled = false;
return {
subscribe (subscriber) {
strict(isValidSubscriber(subscriber), 'Invalid subscriber. Expected function or object');
subscribers.push(subscriber);
return ()=>subscribers.splice(subscribers.indexOf(subscriber), 1);
},
clear () {
subscribers = [];
},
disable () {
isLifecycleHooksDisabled = true;
},
enable () {
isLifecycleHooksDisabled = false;
},
createEvent (action, uid, properties, state) {
const model = db.metadata.get(uid);
return {
action,
model,
state,
...properties
};
},
/**
* @param {string} action
* @param {string} uid
* @param {{ params?: any, result?: any }} properties
* @param {Map<any, any>} states
*/ async run (action, uid, properties, states = new Map()) {
if (isLifecycleHooksDisabled) return states;
for(let i = 0; i < subscribers.length; i += 1){
const subscriber = subscribers[i];
if (typeof subscriber === 'function') {
const state = states.get(subscriber) || {};
const event = this.createEvent(action, uid, properties, state);
await subscriber(event);
if (event.state) {
states.set(subscriber, event.state || state);
}
continue;
}
const hasAction = action in subscriber;
const hasModel = !subscriber.models || subscriber.models.includes(uid);
if (hasAction && hasModel) {
const state = states.get(subscriber) || {};
const event = this.createEvent(action, uid, properties, state);
await subscriber[action]?.(event);
if (event.state) {
states.set(subscriber, event.state);
}
}
}
return states;
}
};
};
export { createLifecyclesProvider };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
import type { Subscriber } from '../types';
export declare const isValidSubscriber: (subscriber: Subscriber) => boolean;
export { modelsLifecyclesSubscriber } from './models-lifecycles';
export { timestampsLifecyclesSubscriber } from './timestamps';
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lifecycles/subscribers/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,iBAAiB,eAAgB,UAAU,YAIvD,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC"}

View File

@@ -0,0 +1,10 @@
'use strict';
require('lodash');
const isValidSubscriber = (subscriber)=>{
return typeof subscriber === 'function' || typeof subscriber === 'object' && subscriber !== null;
};
exports.isValidSubscriber = isValidSubscriber;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../src/lifecycles/subscribers/index.ts"],"sourcesContent":["import type { Subscriber } from '../types';\n\nexport const isValidSubscriber = (subscriber: Subscriber) => {\n return (\n typeof subscriber === 'function' || (typeof subscriber === 'object' && subscriber !== null)\n );\n};\n\nexport { modelsLifecyclesSubscriber } from './models-lifecycles';\nexport { timestampsLifecyclesSubscriber } from './timestamps';\n"],"names":["isValidSubscriber","subscriber"],"mappings":";;;;AAEO,MAAMA,oBAAoB,CAACC,UAAAA,GAAAA;AAChC,IAAA,OACE,OAAOA,UAAe,KAAA,UAAA,IAAe,OAAOA,UAAAA,KAAe,YAAYA,UAAe,KAAA,IAAA;AAE1F;;;;"}

View File

@@ -0,0 +1,8 @@
import 'lodash';
const isValidSubscriber = (subscriber)=>{
return typeof subscriber === 'function' || typeof subscriber === 'object' && subscriber !== null;
};
export { isValidSubscriber };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../src/lifecycles/subscribers/index.ts"],"sourcesContent":["import type { Subscriber } from '../types';\n\nexport const isValidSubscriber = (subscriber: Subscriber) => {\n return (\n typeof subscriber === 'function' || (typeof subscriber === 'object' && subscriber !== null)\n );\n};\n\nexport { modelsLifecyclesSubscriber } from './models-lifecycles';\nexport { timestampsLifecyclesSubscriber } from './timestamps';\n"],"names":["isValidSubscriber","subscriber"],"mappings":";;AAEO,MAAMA,oBAAoB,CAACC,UAAAA,GAAAA;AAChC,IAAA,OACE,OAAOA,UAAe,KAAA,UAAA,IAAe,OAAOA,UAAAA,KAAe,YAAYA,UAAe,KAAA,IAAA;AAE1F;;;;"}

View File

@@ -0,0 +1,6 @@
import type { Subscriber } from '../types';
/**
* For each model try to run it's lifecycles function if any is defined
*/
export declare const modelsLifecyclesSubscriber: Subscriber;
//# sourceMappingURL=models-lifecycles.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"models-lifecycles.d.ts","sourceRoot":"","sources":["../../../src/lifecycles/subscribers/models-lifecycles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAMxC,CAAC"}

View File

@@ -0,0 +1,13 @@
'use strict';
/**
* For each model try to run it's lifecycles function if any is defined
*/ const modelsLifecyclesSubscriber = async (event)=>{
const { model } = event;
if (model.lifecycles && event.action in model.lifecycles) {
await model.lifecycles[event.action]?.(event);
}
};
exports.modelsLifecyclesSubscriber = modelsLifecyclesSubscriber;
//# sourceMappingURL=models-lifecycles.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"models-lifecycles.js","sources":["../../../src/lifecycles/subscribers/models-lifecycles.ts"],"sourcesContent":["import type { Subscriber } from '../types';\n\n/**\n * For each model try to run it's lifecycles function if any is defined\n */\nexport const modelsLifecyclesSubscriber: Subscriber = async (event) => {\n const { model } = event;\n\n if (model.lifecycles && event.action in model.lifecycles) {\n await model.lifecycles[event.action]?.(event);\n }\n};\n"],"names":["modelsLifecyclesSubscriber","event","model","lifecycles","action"],"mappings":";;AAEA;;IAGaA,MAAAA,0BAAAA,GAAyC,OAAOC,KAAAA,GAAAA;IAC3D,MAAM,EAAEC,KAAK,EAAE,GAAGD,KAAAA;IAElB,IAAIC,KAAAA,CAAMC,UAAU,IAAIF,KAAAA,CAAMG,MAAM,IAAIF,KAAAA,CAAMC,UAAU,EAAE;AACxD,QAAA,MAAMD,MAAMC,UAAU,CAACF,KAAMG,CAAAA,MAAM,CAAC,GAAGH,KAAAA,CAAAA;AACzC;AACF;;;;"}

View File

@@ -0,0 +1,11 @@
/**
* For each model try to run it's lifecycles function if any is defined
*/ const modelsLifecyclesSubscriber = async (event)=>{
const { model } = event;
if (model.lifecycles && event.action in model.lifecycles) {
await model.lifecycles[event.action]?.(event);
}
};
export { modelsLifecyclesSubscriber };
//# sourceMappingURL=models-lifecycles.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"models-lifecycles.mjs","sources":["../../../src/lifecycles/subscribers/models-lifecycles.ts"],"sourcesContent":["import type { Subscriber } from '../types';\n\n/**\n * For each model try to run it's lifecycles function if any is defined\n */\nexport const modelsLifecyclesSubscriber: Subscriber = async (event) => {\n const { model } = event;\n\n if (model.lifecycles && event.action in model.lifecycles) {\n await model.lifecycles[event.action]?.(event);\n }\n};\n"],"names":["modelsLifecyclesSubscriber","event","model","lifecycles","action"],"mappings":"AAEA;;IAGaA,MAAAA,0BAAAA,GAAyC,OAAOC,KAAAA,GAAAA;IAC3D,MAAM,EAAEC,KAAK,EAAE,GAAGD,KAAAA;IAElB,IAAIC,KAAAA,CAAMC,UAAU,IAAIF,KAAAA,CAAMG,MAAM,IAAIF,KAAAA,CAAMC,UAAU,EAAE;AACxD,QAAA,MAAMD,MAAMC,UAAU,CAACF,KAAMG,CAAAA,MAAM,CAAC,GAAGH,KAAAA,CAAAA;AACzC;AACF;;;;"}

View File

@@ -0,0 +1,3 @@
import type { Subscriber } from '../types';
export declare const timestampsLifecyclesSubscriber: Subscriber;
//# sourceMappingURL=timestamps.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../../src/lifecycles/subscribers/timestamps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,UAAU,EAAE,MAAM,UAAU,CAAC;AAGlD,eAAO,MAAM,8BAA8B,EAAE,UA+C5C,CAAC"}

View File

@@ -0,0 +1,55 @@
'use strict';
var _ = require('lodash');
// NOTE: we could add onCreate & onUpdate on field level to do this instead
const timestampsLifecyclesSubscriber = {
/**
* Init createdAt & updatedAt before create
*/ beforeCreate (event) {
const { data } = event.params;
const now = new Date();
_.defaults(data, {
createdAt: now,
updatedAt: now
});
},
/**
* Init createdAt & updatedAt before create
* @param {Event} event
*/ beforeCreateMany (event) {
const { data } = event.params;
const now = new Date();
if (_.isArray(data)) {
data.forEach((data)=>_.defaults(data, {
createdAt: now,
updatedAt: now
}));
}
},
/**
* Update updatedAt before update
* @param {Event} event
*/ beforeUpdate (event) {
const { data } = event.params;
const now = new Date();
_.assign(data, {
updatedAt: now
});
},
/**
* Update updatedAt before update
* @param {Event} event
*/ beforeUpdateMany (event) {
const { data } = event.params;
const now = new Date();
if (_.isArray(data)) {
data.forEach((data)=>_.assign(data, {
updatedAt: now
}));
}
}
};
exports.timestampsLifecyclesSubscriber = timestampsLifecyclesSubscriber;
//# sourceMappingURL=timestamps.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timestamps.js","sources":["../../../src/lifecycles/subscribers/timestamps.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Event, Subscriber } from '../types';\n\n// NOTE: we could add onCreate & onUpdate on field level to do this instead\nexport const timestampsLifecyclesSubscriber: Subscriber = {\n /**\n * Init createdAt & updatedAt before create\n */\n beforeCreate(event: Event) {\n const { data } = event.params;\n\n const now = new Date();\n _.defaults(data, { createdAt: now, updatedAt: now });\n },\n\n /**\n * Init createdAt & updatedAt before create\n * @param {Event} event\n */\n beforeCreateMany(event) {\n const { data } = event.params;\n\n const now = new Date();\n if (_.isArray(data)) {\n data.forEach((data) => _.defaults(data, { createdAt: now, updatedAt: now }));\n }\n },\n\n /**\n * Update updatedAt before update\n * @param {Event} event\n */\n beforeUpdate(event) {\n const { data } = event.params;\n\n const now = new Date();\n _.assign(data, { updatedAt: now });\n },\n\n /**\n * Update updatedAt before update\n * @param {Event} event\n */\n beforeUpdateMany(event) {\n const { data } = event.params;\n\n const now = new Date();\n if (_.isArray(data)) {\n data.forEach((data) => _.assign(data, { updatedAt: now }));\n }\n },\n};\n"],"names":["timestampsLifecyclesSubscriber","beforeCreate","event","data","params","now","Date","_","defaults","createdAt","updatedAt","beforeCreateMany","isArray","forEach","beforeUpdate","assign","beforeUpdateMany"],"mappings":";;;;AAGA;MACaA,8BAA6C,GAAA;AACxD;;AAEC,MACDC,cAAaC,KAAY,EAAA;AACvB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChBC,CAAEC,CAAAA,QAAQ,CAACL,IAAM,EAAA;YAAEM,SAAWJ,EAAAA,GAAAA;YAAKK,SAAWL,EAAAA;AAAI,SAAA,CAAA;AACpD,KAAA;AAEA;;;AAGC,MACDM,kBAAiBT,KAAK,EAAA;AACpB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChB,IAAIC,CAAAA,CAAEK,OAAO,CAACT,IAAO,CAAA,EAAA;AACnBA,YAAAA,IAAAA,CAAKU,OAAO,CAAC,CAACV,OAASI,CAAEC,CAAAA,QAAQ,CAACL,IAAM,EAAA;oBAAEM,SAAWJ,EAAAA,GAAAA;oBAAKK,SAAWL,EAAAA;AAAI,iBAAA,CAAA,CAAA;AAC3E;AACF,KAAA;AAEA;;;AAGC,MACDS,cAAaZ,KAAK,EAAA;AAChB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChBC,CAAEQ,CAAAA,MAAM,CAACZ,IAAM,EAAA;YAAEO,SAAWL,EAAAA;AAAI,SAAA,CAAA;AAClC,KAAA;AAEA;;;AAGC,MACDW,kBAAiBd,KAAK,EAAA;AACpB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChB,IAAIC,CAAAA,CAAEK,OAAO,CAACT,IAAO,CAAA,EAAA;AACnBA,YAAAA,IAAAA,CAAKU,OAAO,CAAC,CAACV,OAASI,CAAEQ,CAAAA,MAAM,CAACZ,IAAM,EAAA;oBAAEO,SAAWL,EAAAA;AAAI,iBAAA,CAAA,CAAA;AACzD;AACF;AACF;;;;"}

View File

@@ -0,0 +1,53 @@
import _ from 'lodash';
// NOTE: we could add onCreate & onUpdate on field level to do this instead
const timestampsLifecyclesSubscriber = {
/**
* Init createdAt & updatedAt before create
*/ beforeCreate (event) {
const { data } = event.params;
const now = new Date();
_.defaults(data, {
createdAt: now,
updatedAt: now
});
},
/**
* Init createdAt & updatedAt before create
* @param {Event} event
*/ beforeCreateMany (event) {
const { data } = event.params;
const now = new Date();
if (_.isArray(data)) {
data.forEach((data)=>_.defaults(data, {
createdAt: now,
updatedAt: now
}));
}
},
/**
* Update updatedAt before update
* @param {Event} event
*/ beforeUpdate (event) {
const { data } = event.params;
const now = new Date();
_.assign(data, {
updatedAt: now
});
},
/**
* Update updatedAt before update
* @param {Event} event
*/ beforeUpdateMany (event) {
const { data } = event.params;
const now = new Date();
if (_.isArray(data)) {
data.forEach((data)=>_.assign(data, {
updatedAt: now
}));
}
}
};
export { timestampsLifecyclesSubscriber };
//# sourceMappingURL=timestamps.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"timestamps.mjs","sources":["../../../src/lifecycles/subscribers/timestamps.ts"],"sourcesContent":["import _ from 'lodash';\nimport type { Event, Subscriber } from '../types';\n\n// NOTE: we could add onCreate & onUpdate on field level to do this instead\nexport const timestampsLifecyclesSubscriber: Subscriber = {\n /**\n * Init createdAt & updatedAt before create\n */\n beforeCreate(event: Event) {\n const { data } = event.params;\n\n const now = new Date();\n _.defaults(data, { createdAt: now, updatedAt: now });\n },\n\n /**\n * Init createdAt & updatedAt before create\n * @param {Event} event\n */\n beforeCreateMany(event) {\n const { data } = event.params;\n\n const now = new Date();\n if (_.isArray(data)) {\n data.forEach((data) => _.defaults(data, { createdAt: now, updatedAt: now }));\n }\n },\n\n /**\n * Update updatedAt before update\n * @param {Event} event\n */\n beforeUpdate(event) {\n const { data } = event.params;\n\n const now = new Date();\n _.assign(data, { updatedAt: now });\n },\n\n /**\n * Update updatedAt before update\n * @param {Event} event\n */\n beforeUpdateMany(event) {\n const { data } = event.params;\n\n const now = new Date();\n if (_.isArray(data)) {\n data.forEach((data) => _.assign(data, { updatedAt: now }));\n }\n },\n};\n"],"names":["timestampsLifecyclesSubscriber","beforeCreate","event","data","params","now","Date","_","defaults","createdAt","updatedAt","beforeCreateMany","isArray","forEach","beforeUpdate","assign","beforeUpdateMany"],"mappings":";;AAGA;MACaA,8BAA6C,GAAA;AACxD;;AAEC,MACDC,cAAaC,KAAY,EAAA;AACvB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChBC,CAAEC,CAAAA,QAAQ,CAACL,IAAM,EAAA;YAAEM,SAAWJ,EAAAA,GAAAA;YAAKK,SAAWL,EAAAA;AAAI,SAAA,CAAA;AACpD,KAAA;AAEA;;;AAGC,MACDM,kBAAiBT,KAAK,EAAA;AACpB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChB,IAAIC,CAAAA,CAAEK,OAAO,CAACT,IAAO,CAAA,EAAA;AACnBA,YAAAA,IAAAA,CAAKU,OAAO,CAAC,CAACV,OAASI,CAAEC,CAAAA,QAAQ,CAACL,IAAM,EAAA;oBAAEM,SAAWJ,EAAAA,GAAAA;oBAAKK,SAAWL,EAAAA;AAAI,iBAAA,CAAA,CAAA;AAC3E;AACF,KAAA;AAEA;;;AAGC,MACDS,cAAaZ,KAAK,EAAA;AAChB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChBC,CAAEQ,CAAAA,MAAM,CAACZ,IAAM,EAAA;YAAEO,SAAWL,EAAAA;AAAI,SAAA,CAAA;AAClC,KAAA;AAEA;;;AAGC,MACDW,kBAAiBd,KAAK,EAAA;AACpB,QAAA,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAME,MAAM;AAE7B,QAAA,MAAMC,MAAM,IAAIC,IAAAA,EAAAA;QAChB,IAAIC,CAAAA,CAAEK,OAAO,CAACT,IAAO,CAAA,EAAA;AACnBA,YAAAA,IAAAA,CAAKU,OAAO,CAAC,CAACV,OAASI,CAAEQ,CAAAA,MAAM,CAACZ,IAAM,EAAA;oBAAEO,SAAWL,EAAAA;AAAI,iBAAA,CAAA,CAAA;AACzD;AACF;AACF;;;;"}

View File

@@ -0,0 +1,26 @@
import type { Meta } from '../metadata';
export type Action = 'beforeCreate' | 'afterCreate' | 'beforeFindOne' | 'afterFindOne' | 'beforeFindMany' | 'afterFindMany' | 'beforeCount' | 'afterCount' | 'beforeCreateMany' | 'afterCreateMany' | 'beforeUpdate' | 'afterUpdate' | 'beforeUpdateMany' | 'afterUpdateMany' | 'beforeDelete' | 'afterDelete' | 'beforeDeleteMany' | 'afterDeleteMany';
export interface Params {
select?: any;
where?: any;
_q?: any;
orderBy?: any;
groupBy?: any;
offset?: any;
limit?: any;
populate?: any;
data?: any;
}
export interface Event {
action: Action;
model: Meta;
params: Params;
state: Record<string, unknown>;
result?: any;
}
export type SubscriberFn = (event: Event) => Promise<void> | void;
export type SubscriberMap = {
models?: string[];
} & Partial<Record<Action, SubscriberFn>>;
export type Subscriber = SubscriberFn | SubscriberMap;
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lifecycles/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,MAAM,GACd,cAAc,GACd,aAAa,GACb,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,MAAM;IACrB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAE1C,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC"}