node-ejs-renderer/node_modules/sequelize/lib/hooks.js.map

8 lines
20 KiB
Plaintext
Raw Normal View History

2024-06-09 13:55:01 -04:00
{
"version": 3,
"sources": ["../src/hooks.js"],
"sourcesContent": ["'use strict';\n\nconst _ = require('lodash');\nconst { logger } = require('./utils/logger');\nconst debug = logger.debugContext('hooks');\n\nconst hookTypes = {\n beforeValidate: { params: 2 },\n afterValidate: { params: 2 },\n validationFailed: { params: 3 },\n beforeCreate: { params: 2 },\n afterCreate: { params: 2 },\n beforeDestroy: { params: 2 },\n afterDestroy: { params: 2 },\n beforeRestore: { params: 2 },\n afterRestore: { params: 2 },\n beforeUpdate: { params: 2 },\n afterUpdate: { params: 2 },\n beforeSave: { params: 2, proxies: ['beforeUpdate', 'beforeCreate'] },\n afterSave: { params: 2, proxies: ['afterUpdate', 'afterCreate'] },\n beforeUpsert: { params: 2 },\n afterUpsert: { params: 2 },\n beforeBulkCreate: { params: 2 },\n afterBulkCreate: { params: 2 },\n beforeBulkDestroy: { params: 1 },\n afterBulkDestroy: { params: 1 },\n beforeBulkRestore: { params: 1 },\n afterBulkRestore: { params: 1 },\n beforeBulkUpdate: { params: 1 },\n afterBulkUpdate: { params: 1 },\n beforeFind: { params: 1 },\n beforeFindAfterExpandIncludeAll: { params: 1 },\n beforeFindAfterOptions: { params: 1 },\n afterFind: { params: 2 },\n beforeCount: { params: 1 },\n beforeDefine: { params: 2, sync: true, noModel: true },\n afterDefine: { params: 1, sync: true, noModel: true },\n beforeInit: { params: 2, sync: true, noModel: true },\n afterInit: { params: 1, sync: true, noModel: true },\n beforeAssociate: { params: 2, sync: true },\n afterAssociate: { params: 2, sync: true },\n beforeConnect: { params: 1, noModel: true },\n afterConnect: { params: 2, noModel: true },\n beforeDisconnect: { params: 1, noModel: true },\n afterDisconnect: { params: 1, noModel: true },\n beforePoolAcquire: { params: 1, noModel: true },\n afterPoolAcquire: { params: 2, noModel: true },\n beforeSync: { params: 1 },\n afterSync: { params: 1 },\n beforeBulkSync: { params: 1 },\n afterBulkSync: { params: 1 },\n beforeQuery: { params: 2 },\n afterQuery: { params: 2 }\n};\nexports.hooks = hookTypes;\n\n\n/**\n * get array of current hook and its proxies combined\n *\n * @param {string} hookType any hook type @see {@link hookTypes}\n *\n * @private\n */\nconst getProxiedHooks = hookType =>\n hookTypes[hookType].proxies\n ? hookTypes[hookType].proxies.concat(hookType)\n : [hookType]\n;\n\nfunction getHooks(hooked, hookType) {\n return (hooked.options.hooks || {})[hookType] || [];\n}\n\nconst Hooks = {\n /**\n * Process user supplied hooks definition\n *\n * @param {object} hooks hooks definition\n *\n * @private\n * @memberof Sequelize\n * @memberof Sequelize.Model\n */\n _setupHooks(hooks) {\n this.options.hooks = {};\n _.map(hooks || {}, (hooksArray, hookName) => {\n if (!Array.isArray(hooksArray)) hooksArray = [hooksArray];\n hooksArray.forEach(hookFn => this.addHook(hookName, hookFn));\n });\n },\n\n async runHooks(hooks, ...hookArgs) {\n if (!hooks) throw new Error('runHooks requires at least 1 argument');\n\n let hookType;\n\n if (typeof hooks === 'string') {\n hookType = hooks;\n hooks = getHooks(this, hookType);\n\n if (this.sequelize) {\n hooks = hooks.concat(getHooks(this.sequelize, hookType));\n }\n }\n\n if (!Array.isArray(hooks)) {\n hooks = [hooks];\n }\n\n // synchronous hooks\n if (hookTypes[hookType] && hookTypes[hookType].sync) {\n for (let hook of hooks) {\n if (typeof hook === 'object') {\n hook = hook.fn;\n }\n\n debug(`running hook(sync) ${hookType}`);\n hook.apply(this, hookArgs);\n }\n return;\n }\n\n // asynchronous hooks (default)\n for (let hook of hooks) {\n if (typeof hook === 'object') {\n hook = hook.fn;\n }\n\n debug(`running hook ${hookType}`);\n await hook.apply(this, hookArgs);\n }\n },\n\n /**\n * Add a hook to the model\n *\n * @param {string} hookType hook name @see {@link hookTypes}\n * @param {string|Function} [name] Provide a name for the hook funct
"mappings": ";AAEA,MAAM,IAAI,QAAQ;AAClB,MAAM,EAAE,WAAW,QAAQ;AAC3B,MAAM,QAAQ,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