Initial commit - Event Planner application

This commit is contained in:
mberlin
2026-03-18 14:55:56 -03:00
commit 86d779eb4d
7548 changed files with 1006324 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import type { QueryResult } from '../../driver/database-connection.js';
import type { RootOperationNode } from '../../query-compiler/query-compiler.js';
import type { UnknownRow } from '../../util/type-utils.js';
import type { KyselyPlugin, PluginTransformQueryArgs, PluginTransformResultArgs } from '../kysely-plugin.js';
/**
* Plugin that removes duplicate joins from queries.
*
* See [this recipe](https://github.com/kysely-org/kysely/blob/master/site/docs/recipes/0008-deduplicate-joins.md)
*/
export declare class DeduplicateJoinsPlugin implements KyselyPlugin {
#private;
/**
* This is called for each query before it is executed. You can modify the query by
* transforming its {@link OperationNode} tree provided in {@link PluginTransformQueryArgs.node | args.node}
* and returning the transformed tree. You'd usually want to use an {@link OperationNodeTransformer}
* for this.
*
* If you need to pass some query-related data between this method and `transformResult` you
* can use a `WeakMap` with {@link PluginTransformQueryArgs.queryId | args.queryId} as the key:
*
* ```ts
* import type {
* KyselyPlugin,
* QueryResult,
* RootOperationNode,
* UnknownRow
* } from 'kysely'
*
* interface MyData {
* // ...
* }
* const data = new WeakMap<any, MyData>()
*
* const plugin = {
* transformQuery(args: PluginTransformQueryArgs): RootOperationNode {
* const something: MyData = {}
*
* // ...
*
* data.set(args.queryId, something)
*
* // ...
*
* return args.node
* },
*
* async transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>> {
* // ...
*
* const something = data.get(args.queryId)
*
* // ...
*
* return args.result
* }
* } satisfies KyselyPlugin
* ```
*
* You should use a `WeakMap` instead of a `Map` or some other strong references because `transformQuery`
* is not always matched by a call to `transformResult` which would leave orphaned items in the map
* and cause a memory leak.
*/
transformQuery(args: PluginTransformQueryArgs): RootOperationNode;
/**
* This method is called for each query after it has been executed. The result
* of the query can be accessed through {@link PluginTransformResultArgs.result | args.result}.
* You can modify the result and return the modifier result.
*/
transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>>;
}

View File

@@ -0,0 +1,16 @@
/// <reference types="./deduplicate-joins-plugin.d.ts" />
import { DeduplicateJoinsTransformer } from './deduplicate-joins-transformer.js';
/**
* Plugin that removes duplicate joins from queries.
*
* See [this recipe](https://github.com/kysely-org/kysely/blob/master/site/docs/recipes/0008-deduplicate-joins.md)
*/
export class DeduplicateJoinsPlugin {
#transformer = new DeduplicateJoinsTransformer();
transformQuery(args) {
return this.#transformer.transformNode(args.node, args.queryId);
}
transformResult(args) {
return Promise.resolve(args.result);
}
}

View File

@@ -0,0 +1,11 @@
import type { DeleteQueryNode } from '../../operation-node/delete-query-node.js';
import { OperationNodeTransformer } from '../../operation-node/operation-node-transformer.js';
import type { SelectQueryNode } from '../../operation-node/select-query-node.js';
import type { UpdateQueryNode } from '../../operation-node/update-query-node.js';
import type { QueryId } from '../../util/query-id.js';
export declare class DeduplicateJoinsTransformer extends OperationNodeTransformer {
#private;
protected transformSelectQuery(node: SelectQueryNode, queryId: QueryId): SelectQueryNode;
protected transformUpdateQuery(node: UpdateQueryNode, queryId: QueryId): UpdateQueryNode;
protected transformDeleteQuery(node: DeleteQueryNode, queryId: QueryId): DeleteQueryNode;
}

View File

@@ -0,0 +1,39 @@
/// <reference types="./deduplicate-joins-transformer.d.ts" />
import { OperationNodeTransformer } from '../../operation-node/operation-node-transformer.js';
import { compare, freeze } from '../../util/object-utils.js';
export class DeduplicateJoinsTransformer extends OperationNodeTransformer {
transformSelectQuery(node, queryId) {
return this.#transformQuery(super.transformSelectQuery(node, queryId));
}
transformUpdateQuery(node, queryId) {
return this.#transformQuery(super.transformUpdateQuery(node, queryId));
}
transformDeleteQuery(node, queryId) {
return this.#transformQuery(super.transformDeleteQuery(node, queryId));
}
#transformQuery(node) {
if (!node.joins || node.joins.length === 0) {
return node;
}
return freeze({
...node,
joins: this.#deduplicateJoins(node.joins),
});
}
#deduplicateJoins(joins) {
const out = [];
for (let i = 0; i < joins.length; ++i) {
let foundDuplicate = false;
for (let j = 0; j < out.length; ++j) {
if (compare(joins[i], out[j])) {
foundDuplicate = true;
break;
}
}
if (!foundDuplicate) {
out.push(joins[i]);
}
}
return freeze(out);
}
}