node_modules ignore

This commit is contained in:
oier committed 2025-05-08 23:43:47 +02:00
1 parent e19d52f172
commit 4574544c9f
65041 files changed
+10593536

No files matched your search

@@ -0,0 +1,18 @@
import type { Database } from '../..';
export interface RemoveOrphanMorphTypeOptions {
pivot: string;
}
/**
* Removes morph relation data with invalid or non-existent morph type.
*
* This function iterates over the database metadata to identify morph relationships
* (relations with a `joinTable` containing the specified pivot column) and removes
* any entries in the relation's join table where the morph type is invalid.
*
* Note: This function does not check for orphaned IDs, only orphaned morph types.
*
* @param db - The database object containing metadata and a Knex connection.
* @param options.pivot - The name of the column in the join table representing the morph type.
*/
export declare const removeOrphanMorphType: (db: Database, { pivot }: RemoveOrphanMorphTypeOptions) => Promise<void>;
//# sourceMappingURL=remove-orphan-morph-types.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"remove-orphan-morph-types.d.ts","sourceRoot":"","sources":["../../../src/repairs/operations/remove-orphan-morph-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;CACf;AAyBD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,OAC5B,QAAQ,aACD,4BAA4B,kBA2CxC,CAAC"}
@@ -0,0 +1,54 @@
'use strict';
const isMorphRelationWithPivot = (attribute, pivot)=>{
return attribute.type === 'relation' && 'relation' in attribute && 'joinTable' in attribute && 'name' in attribute.joinTable && 'pivotColumns' in attribute.joinTable && attribute.joinTable.pivotColumns.includes(pivot);
};
const filterMorphRelationalAttributes = (attributes, pivot)=>{
return Object.values(attributes).filter((attribute)=>isMorphRelationWithPivot(attribute, pivot));
};
/**
* Removes morph relation data with invalid or non-existent morph type.
*
* This function iterates over the database metadata to identify morph relationships
* (relations with a `joinTable` containing the specified pivot column) and removes
* any entries in the relation's join table where the morph type is invalid.
*
* Note: This function does not check for orphaned IDs, only orphaned morph types.
*
* @param db - The database object containing metadata and a Knex connection.
* @param options.pivot - The name of the column in the join table representing the morph type.
*/ const removeOrphanMorphType = async (db, { pivot })=>{
db.logger.debug(`Removing orphaned morph type: ${JSON.stringify(pivot)}`);
const mdValues = db.metadata.values();
for (const model of mdValues){
const attributes = filterMorphRelationalAttributes(model.attributes || {}, pivot);
for (const attribute of attributes){
const joinTableName = attribute.joinTable.name;
// Query distinct morph types from the join table
const morphTypes = await db.connection(joinTableName).distinct(pivot).pluck(pivot);
for (const morphType of morphTypes){
// Check if metadata for the morph type exists
const deleteComponentType = await (async ()=>{
try {
return !db.metadata.get(morphType); // If no metadata found, mark for deletion
} catch {
db.logger.debug(`Metadata for morph type "${morphType}" in table "${joinTableName}" not found`);
return true; // Return true to delete if metadata is missing
}
})();
if (deleteComponentType) {
db.logger.debug(`Removing invalid morph type "${morphType}" from table "${joinTableName}".`);
try {
await db.connection(joinTableName).where(pivot, morphType).del();
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
db.logger.error(`Failed to remove invalid morph type "${morphType}" from table "${joinTableName}": ${errorMessage}`);
}
}
}
}
}
};
exports.removeOrphanMorphType = removeOrphanMorphType;
//# sourceMappingURL=remove-orphan-morph-types.js.map
@@ -0,0 +1 @@
{"version":3,"file":"remove-orphan-morph-types.js","sources":["../../../src/repairs/operations/remove-orphan-morph-types.ts"],"sourcesContent":["import type { Database } from '../..';\nimport type { Attribute, MorphRelationalAttribute } from '../../types';\n\nexport interface RemoveOrphanMorphTypeOptions {\n pivot: string;\n}\n\nconst isMorphRelationWithPivot = (\n attribute: Attribute,\n pivot: string\n): attribute is MorphRelationalAttribute => {\n return (\n attribute.type === 'relation' &&\n 'relation' in attribute &&\n 'joinTable' in attribute &&\n 'name' in attribute.joinTable &&\n 'pivotColumns' in attribute.joinTable &&\n attribute.joinTable.pivotColumns.includes(pivot)\n );\n};\n\nconst filterMorphRelationalAttributes = (\n attributes: Record<string, Attribute>,\n pivot: string\n): MorphRelationalAttribute[] => {\n return Object.values(attributes).filter((attribute): attribute is MorphRelationalAttribute =>\n isMorphRelationWithPivot(attribute, pivot)\n );\n};\n\n/**\n * Removes morph relation data with invalid or non-existent morph type.\n *\n * This function iterates over the database metadata to identify morph relationships\n * (relations with a `joinTable` containing the specified pivot column) and removes\n * any entries in the relation's join table where the morph type is invalid.\n *\n * Note: This function does not check for orphaned IDs, only orphaned morph types.\n *\n * @param db - The database object containing metadata and a Knex connection.\n * @param options.pivot - The name of the column in the join table representing the morph type.\n */\nexport const removeOrphanMorphType = async (\n db: Database,\n { pivot }: RemoveOrphanMorphTypeOptions\n) => {\n db.logger.debug(`Removing orphaned morph type: ${JSON.stringify(pivot)}`);\n\n const mdValues = db.metadata.values();\n for (const model of mdValues) {\n const attributes = filterMorphRelationalAttributes(model.attributes || {}, pivot);\n\n for (const attribute of attributes) {\n const joinTableName = attribute.joinTable.name;\n\n // Query distinct morph types from the join table\n const morphTypes = await db.connection(joinTableName).distinct(pivot).pluck(pivot);\n\n for (const morphType of morphTypes) {\n // Check if metadata for the morph type exists\n const deleteComponentType = await (async () => {\n try {\n return !db.metadata.get(morphType); // If no metadata found, mark for deletion\n } catch {\n db.logger.debug(\n `Metadata for morph type \"${morphType}\" in table \"${joinTableName}\" not found`\n );\n return true; // Return true to delete if metadata is missing\n }\n })();\n\n if (deleteComponentType) {\n db.logger.debug(\n `Removing invalid morph type \"${morphType}\" from table \"${joinTableName}\".`\n );\n try {\n await db.connection(joinTableName).where(pivot, morphType).del();\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n db.logger.error(\n `Failed to remove invalid morph type \"${morphType}\" from table \"${joinTableName}\": ${errorMessage}`\n );\n }\n }\n }\n }\n }\n};\n"],"names":["isMorphRelationWithPivot","attribute","pivot","type","joinTable","pivotColumns","includes","filterMorphRelationalAttributes","attributes","Object","values","filter","removeOrphanMorphType","db","logger","debug","JSON","stringify","mdValues","metadata","model","joinTableName","name","morphTypes","connection","distinct","pluck","morphType","deleteComponentType","get","where","del","error","err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xB,KAAAA,CAAAA;YAE5E,KAAK,MAAMyB,aAAaJ,UAAY,CAAA;;gBAElC,MAAMK,mBAAAA,GAAsB,MAAO,CAAA,UAAA;oBACjC,IAAI;AACF,wBAAA,OAAO,CAACf,EAAGM,CAAAA,QAAQLine truncated
@@ -0,0 +1,52 @@
const isMorphRelationWithPivot = (attribute, pivot)=>{
return attribute.type === 'relation' && 'relation' in attribute && 'joinTable' in attribute && 'name' in attribute.joinTable && 'pivotColumns' in attribute.joinTable && attribute.joinTable.pivotColumns.includes(pivot);
};
const filterMorphRelationalAttributes = (attributes, pivot)=>{
return Object.values(attributes).filter((attribute)=>isMorphRelationWithPivot(attribute, pivot));
};
/**
* Removes morph relation data with invalid or non-existent morph type.
*
* This function iterates over the database metadata to identify morph relationships
* (relations with a `joinTable` containing the specified pivot column) and removes
* any entries in the relation's join table where the morph type is invalid.
*
* Note: This function does not check for orphaned IDs, only orphaned morph types.
*
* @param db - The database object containing metadata and a Knex connection.
* @param options.pivot - The name of the column in the join table representing the morph type.
*/ const removeOrphanMorphType = async (db, { pivot })=>{
db.logger.debug(`Removing orphaned morph type: ${JSON.stringify(pivot)}`);
const mdValues = db.metadata.values();
for (const model of mdValues){
const attributes = filterMorphRelationalAttributes(model.attributes || {}, pivot);
for (const attribute of attributes){
const joinTableName = attribute.joinTable.name;
// Query distinct morph types from the join table
const morphTypes = await db.connection(joinTableName).distinct(pivot).pluck(pivot);
for (const morphType of morphTypes){
// Check if metadata for the morph type exists
const deleteComponentType = await (async ()=>{
try {
return !db.metadata.get(morphType); // If no metadata found, mark for deletion
} catch {
db.logger.debug(`Metadata for morph type "${morphType}" in table "${joinTableName}" not found`);
return true; // Return true to delete if metadata is missing
}
})();
if (deleteComponentType) {
db.logger.debug(`Removing invalid morph type "${morphType}" from table "${joinTableName}".`);
try {
await db.connection(joinTableName).where(pivot, morphType).del();
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
db.logger.error(`Failed to remove invalid morph type "${morphType}" from table "${joinTableName}": ${errorMessage}`);
}
}
}
}
}
};
export { removeOrphanMorphType };
//# sourceMappingURL=remove-orphan-morph-types.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"remove-orphan-morph-types.mjs","sources":["../../../src/repairs/operations/remove-orphan-morph-types.ts"],"sourcesContent":["import type { Database } from '../..';\nimport type { Attribute, MorphRelationalAttribute } from '../../types';\n\nexport interface RemoveOrphanMorphTypeOptions {\n pivot: string;\n}\n\nconst isMorphRelationWithPivot = (\n attribute: Attribute,\n pivot: string\n): attribute is MorphRelationalAttribute => {\n return (\n attribute.type === 'relation' &&\n 'relation' in attribute &&\n 'joinTable' in attribute &&\n 'name' in attribute.joinTable &&\n 'pivotColumns' in attribute.joinTable &&\n attribute.joinTable.pivotColumns.includes(pivot)\n );\n};\n\nconst filterMorphRelationalAttributes = (\n attributes: Record<string, Attribute>,\n pivot: string\n): MorphRelationalAttribute[] => {\n return Object.values(attributes).filter((attribute): attribute is MorphRelationalAttribute =>\n isMorphRelationWithPivot(attribute, pivot)\n );\n};\n\n/**\n * Removes morph relation data with invalid or non-existent morph type.\n *\n * This function iterates over the database metadata to identify morph relationships\n * (relations with a `joinTable` containing the specified pivot column) and removes\n * any entries in the relation's join table where the morph type is invalid.\n *\n * Note: This function does not check for orphaned IDs, only orphaned morph types.\n *\n * @param db - The database object containing metadata and a Knex connection.\n * @param options.pivot - The name of the column in the join table representing the morph type.\n */\nexport const removeOrphanMorphType = async (\n db: Database,\n { pivot }: RemoveOrphanMorphTypeOptions\n) => {\n db.logger.debug(`Removing orphaned morph type: ${JSON.stringify(pivot)}`);\n\n const mdValues = db.metadata.values();\n for (const model of mdValues) {\n const attributes = filterMorphRelationalAttributes(model.attributes || {}, pivot);\n\n for (const attribute of attributes) {\n const joinTableName = attribute.joinTable.name;\n\n // Query distinct morph types from the join table\n const morphTypes = await db.connection(joinTableName).distinct(pivot).pluck(pivot);\n\n for (const morphType of morphTypes) {\n // Check if metadata for the morph type exists\n const deleteComponentType = await (async () => {\n try {\n return !db.metadata.get(morphType); // If no metadata found, mark for deletion\n } catch {\n db.logger.debug(\n `Metadata for morph type \"${morphType}\" in table \"${joinTableName}\" not found`\n );\n return true; // Return true to delete if metadata is missing\n }\n })();\n\n if (deleteComponentType) {\n db.logger.debug(\n `Removing invalid morph type \"${morphType}\" from table \"${joinTableName}\".`\n );\n try {\n await db.connection(joinTableName).where(pivot, morphType).del();\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n db.logger.error(\n `Failed to remove invalid morph type \"${morphType}\" from table \"${joinTableName}\": ${errorMessage}`\n );\n }\n }\n }\n }\n }\n};\n"],"names":["isMorphRelationWithPivot","attribute","pivot","type","joinTable","pivotColumns","includes","filterMorphRelationalAttributes","attributes","Object","values","filter","removeOrphanMorphType","db","logger","debug","JSON","stringify","mdValues","metadata","model","joinTableName","name","morphTypes","connection","distinct","pluck","morphType","deleteComponentType","get","where","del","error","errorMessage","Error","message","String"],"mappings":"AAOA,MAAMA,wBAAAA,GAA2B,CAC/BC,SACAC,EAAAA,KAAAA,GAAAA;IAEA,OACED,SAAAA,CAAUE,IAAI,KAAK,UAAA,IACnB,cAAcF,SACd,IAAA,WAAA,IAAeA,SACf,IAAA,MAAA,IAAUA,SAAUG,CAAAA,SAAS,IAC7B,cAAkBH,IAAAA,SAAAA,CAAUG,SAAS,IACrCH,SAAAA,CAAUG,SAAS,CAACC,YAAY,CAACC,QAAQ,CAACJ,KAAAA,CAAAA;AAE9C,CAAA;AAEA,MAAMK,+BAAAA,GAAkC,CACtCC,UACAN,EAAAA,KAAAA,GAAAA;IAEA,OAAOO,MAAAA,CAAOC,MAAM,CAACF,UAAAA,CAAAA,CAAYG,MAAM,CAAC,CAACV,SACvCD,GAAAA,wBAAAA,CAAyBC,SAAWC,EAAAA,KAAAA,CAAAA,CAAAA;AAExC,CAAA;AAEA;;;;;;;;;;;AAWC,IACYU,MAAAA,qBAAAA,GAAwB,OACnCC,EACA,EAAA,EAAEX,KAAK,EAAg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