Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kysely-mapper

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-mapper - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

dist/cjs/mappers/uniform-table-mapper-options.d.ts

4

dist/cjs/index.d.ts
export * from './mappers/table-mapper';
export * from './mappers/table-mapper-options';
export * from './mappers/KeyedTableMapper';
export * from './mappers/UniformTableMapper';
export * from './mappers/uniform-table-mapper-options';
export * from './mappers/uniform-table-mapper';
export * from './queries/delete-query';

@@ -6,0 +6,0 @@ export * from './queries/insert-query';

@@ -19,4 +19,4 @@ "use strict";

__exportStar(require("./mappers/table-mapper-options"), exports);
__exportStar(require("./mappers/KeyedTableMapper"), exports);
__exportStar(require("./mappers/UniformTableMapper"), exports);
__exportStar(require("./mappers/uniform-table-mapper-options"), exports);
__exportStar(require("./mappers/uniform-table-mapper"), exports);
__exportStar(require("./queries/delete-query"), exports);

@@ -23,0 +23,0 @@ __exportStar(require("./queries/insert-query"), exports);

@@ -9,14 +9,27 @@ import { Insertable, Selectable, Updateable } from 'kysely';

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedCount Type of count query results.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam ReturnCount Type of count query results.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/
export interface TableMapperOptions<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'], SelectedObject extends object, InsertedObject extends object, UpdaterObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedCount, ReturnedObject extends object> {
export interface TableMapperOptions<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdatingObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnCount = bigint, InsertReturnsSelectedObject extends boolean = false, UpdateReturnsSelectedObjectWhenProvided extends boolean = false, DefaultReturnObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
/** Transformation to apply to inserted objects before insertion. */
readonly insertTransform?: (obj: InsertedObject) => Insertable<DB[TB]>;
/** Whether insert queries return `SelectedObject` or `DefaultReturnObject`. */
readonly insertReturnsSelectedObject?: InsertReturnsSelectedObject;
/** Transformation to apply to objects provided for updating values. */
readonly updaterTransform?: (update: UpdaterObject) => Updateable<DB[TB]>;
readonly updateTransform?: (update: UpdatingObject) => Updateable<DB[TB]>;
/**
* Whether update queries return `SelectedObject` when the updating object
* is a `SelectedObject`; update queries otherwise return `DefaultReturnObject`.
*/
readonly updateReturnsSelectedObjectWhenProvided?: UpdateReturnsSelectedObjectWhenProvided;
/** Columns to return from selection queries. */

@@ -32,8 +45,8 @@ readonly selectedColumns?: SelectedColumns;

/** Transformation to apply to column values returned from inserts. */
readonly insertReturnTransform?: (source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject;
readonly insertReturnTransform?: (source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject;
/** Transformation to apply to column values returned from updates. */
readonly updateReturnTransform?: (source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject;
readonly updateReturnTransform?: (source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject;
/** Transformation to apply to bigint count results. */
readonly countTransform?: (count: bigint) => ReturnedCount;
readonly countTransform?: (count: bigint) => ReturnCount;
}
//# sourceMappingURL=table-mapper-options.d.ts.map

@@ -16,14 +16,20 @@ import { Kysely, Insertable, ReferenceExpression, Selectable, InsertQueryBuilder, InsertResult, SelectQueryBuilder, Selection, DeleteQueryBuilder, DeleteResult, UpdateResult, UpdateQueryBuilder } from 'kysely';

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam ReturnedCount Type of count query results.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnCount Type of count query results.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/
export declare class TableMapper<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdaterObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnedCount = bigint, ReturnedObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
export declare class TableMapper<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdatingObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnCount = bigint, InsertReturnsSelectedObject extends boolean = false, UpdateReturnsSelectedObjectWhenProvided extends boolean = false, DefaultReturnObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
#private;
readonly db: Kysely<DB>;
readonly tableName: TB;
readonly options: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
readonly options: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdatingObject, ReturnColumns, ReturnCount, InsertReturnsSelectedObject, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/** Columns to return from selection queries. `[]` => all columns. */

@@ -33,4 +39,4 @@ protected readonly selectedColumns: SelectionColumn<DB, TB>[];

protected returnColumns: (keyof Selectable<DB[TB]> & string)[] | ['*'];
/** Transforms query counts into `ReturnedCount`. */
protected countTransform: (count: bigint) => ReturnedCount;
/** Transforms query counts into `ReturnCount`. */
protected countTransform: (count: bigint) => ReturnCount;
/**

@@ -40,6 +46,6 @@ * Constructs a new table mapper.

* @param tableName The name of the table.
* @param options Options governing mapper behavior. `returnColumns`
* defaults to returning no columns.
* @param options Options governing mapper behavior. Default to selecting
* all columns and to returning no columns on insert or update.
*/
constructor(db: Kysely<DB>, tableName: TB, options?: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>);
constructor(db: Kysely<DB>, tableName: TB, options?: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdatingObject, ReturnColumns, ReturnCount, InsertReturnsSelectedObject, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>);
/**

@@ -67,3 +73,3 @@ * Creates and returns a parameterized mapping query, which can be repeatedly

*/
delete<RE extends ReferenceExpression<DB, TB>, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>>(filter?: QueryFilter<DB, TB, RE, DeleteQueryBuilder<DB, any, DeleteResult>, QB>): MappingDeleteQuery<DB, TB, DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnedCount>;
delete<RE extends ReferenceExpression<DB, TB>, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>>(filter?: QueryFilter<DB, TB, RE, DeleteQueryBuilder<DB, any, DeleteResult>, QB>): MappingDeleteQuery<DB, TB, DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnCount>;
/**

@@ -73,3 +79,3 @@ * Returns a query for inserting rows into the table.

*/
insert(): MappingInsertQuery<DB, TB, InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject, ReturnColumns, ReturnedObject>;
insert(): MappingInsertQuery<DB, TB, InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject, SelectedObject, ReturnColumns, InsertReturnsSelectedObject, DefaultReturnObject>;
/**

@@ -94,3 +100,3 @@ * Returns a reference to a column, which can be a generated string.

*/
update<RE extends ReferenceExpression<DB, TB>, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>>(filter?: QueryFilter<DB, TB, RE, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, QB>): MappingUpdateQuery<DB, TB, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
update<RE extends ReferenceExpression<DB, TB>, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>>(filter?: QueryFilter<DB, TB, RE, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, QB>): MappingUpdateQuery<DB, TB, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdatingObject, SelectedObject, ReturnColumns, ReturnCount, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/**

@@ -97,0 +103,0 @@ * Returns a query builder for deleting rows from the table, caching the

@@ -28,8 +28,14 @@ "use strict";

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam ReturnedCount Type of count query results.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnCount Type of count query results.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/

@@ -41,4 +47,4 @@ class TableMapper {

* @param tableName The name of the table.
* @param options Options governing mapper behavior. `returnColumns`
* defaults to returning no columns.
* @param options Options governing mapper behavior. Default to selecting
* all columns and to returning no columns on insert or update.
*/

@@ -54,3 +60,3 @@ constructor(db, tableName, options = {}) {

_TableMapper_baseUpdateQB.set(this, null);
/** Transforms query counts into `ReturnedCount`. */
/** Transforms query counts into `ReturnCount`. */
this.countTransform = (count) => count;

@@ -151,3 +157,3 @@ this.returnColumns = (_a = options.returnColumns) !== null && _a !== void 0 ? _a : [];

? this.getUpdateQB()
: (0, query_filter_1.applyQueryFilter)(this.db, this.getUpdateQB(), filter), this.countTransform, this.options.updaterTransform, this.options.returnColumns, this.options.updateReturnTransform);
: (0, query_filter_1.applyQueryFilter)(this.db, this.getUpdateQB(), filter), this.countTransform, this.options.updateTransform, this.options.returnColumns, this.options.updateReturnTransform);
}

@@ -154,0 +160,0 @@ /**

@@ -5,6 +5,6 @@ import { DeleteQueryBuilder, DeleteResult, Kysely } from 'kysely';

*/
export declare class MappingDeleteQuery<DB, TB extends keyof DB & string, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnedCount> {
export declare class MappingDeleteQuery<DB, TB extends keyof DB & string, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnCount> {
protected readonly db: Kysely<DB>;
protected readonly qb: QB;
protected readonly countTransform: (count: bigint) => ReturnedCount;
protected readonly countTransform: (count: bigint) => ReturnCount;
/**

@@ -15,3 +15,3 @@ * @param db Kysely database instance.

*/
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnedCount);
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnCount);
/**

@@ -22,3 +22,3 @@ * Runs the query, returning the number of rows deleted, converted to

*/
getCount(): Promise<ReturnedCount>;
getCount(): Promise<ReturnCount>;
/**

@@ -29,3 +29,3 @@ * Modifies the underlying Kysely query builder.

*/
modify<NextQB extends DeleteQueryBuilder<DB, any, DeleteResult>>(factory: (qb: QB) => NextQB): MappingDeleteQuery<DB, TB, NextQB, ReturnedCount>;
modify<NextQB extends DeleteQueryBuilder<DB, any, DeleteResult>>(factory: (qb: QB) => NextQB): MappingDeleteQuery<DB, TB, NextQB, ReturnCount>;
/**

@@ -32,0 +32,0 @@ * Runs the query, deleting the indicated rows, returning nothing.

@@ -6,3 +6,3 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selectable, Insertable } from 'kysely';

*/
export declare class MappingInsertQuery<DB, TB extends keyof DB & string, QB extends InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedObject extends object> {
export declare class MappingInsertQuery<DB, TB extends keyof DB & string, QB extends InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject extends object, SelectedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], InsertReturnsSelectedObject extends boolean, DefaultReturnObject extends object> {
#private;

@@ -12,3 +12,3 @@ protected readonly db: Kysely<DB>;

protected readonly insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined;
protected readonly insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined;
protected readonly insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject) | undefined;
protected readonly returnColumns: ReturnColumns;

@@ -25,5 +25,7 @@ /**

* to be inserted and the returned row into the object to be returned
* from the insert query.
* from the insert query. When `InsertReturnsSelectedObject` is `true`,
* the returned object is of type `SelectedObject`; otherwise it is of
* type `DefaultReturnObject`.
*/
constructor(db: Kysely<DB>, qb: QB, insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined);
constructor(db: Kysely<DB>, qb: QB, insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject) | undefined);
/**

@@ -33,18 +35,20 @@ * Inserts the provided objects into the table as rows, first transforming

* retrieves the columns specified in `returnColumns`, returning them to
* the caller as an object, unless `insertReturnTransform` transforms them
* into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* the caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `InsertReturnsSelectedObject` is `true`, after transformation by
* `insertReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an array containing one
* `ReturnedObject` for each inserted object; otherwise returns `undefined`.
* object for each inserted object; otherwise returns `undefined`.
*/
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>;
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>;
/**
* Inserts the provided object into the table as a row, first transforming
* it into rows via `insertTransform` (if defined). Retrieves the columns
* specified in `returnColumns` (if any), returning them to the caller as
* an objectunless `insertReturnTransform` transforms them into a
* `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns a `ReturnedObject`;
* it into a row via `insertTransform` (if defined). Also retrieves the
* columns specified in `returnColumns`, returning them to the caller as
* either `DefaultReturnObject` or `SelectedObject`, depending on whether
* `InsertReturnsSelectedObject` is `true`, after transformation by
* `insertReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an object;
* otherwise returns `undefined`.
*/
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>;
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>;
/**

@@ -61,3 +65,3 @@ * Runs the query, inserting rows into the table without returning any columns.

*/
modify<NextQB extends InsertQueryBuilder<DB, TB, any>>(factory: (qb: QB) => NextQB): MappingInsertQuery<DB, TB, NextQB, InsertedObject, ReturnColumns, ReturnedObject>;
modify<NextQB extends InsertQueryBuilder<DB, TB, any>>(factory: (qb: QB) => NextQB): MappingInsertQuery<DB, TB, NextQB, InsertedObject, SelectedObject, ReturnColumns, InsertReturnsSelectedObject, DefaultReturnObject>;
/**

@@ -64,0 +68,0 @@ * Returns a query builder for inserting rows into the table and

@@ -41,3 +41,5 @@ "use strict";

* to be inserted and the returned row into the object to be returned
* from the insert query.
* from the insert query. When `InsertReturnsSelectedObject` is `true`,
* the returned object is of type `SelectedObject`; otherwise it is of
* type `DefaultReturnObject`.
*/

@@ -44,0 +46,0 @@ constructor(db, qb, insertTransform, returnColumns, insertReturnTransform) {

@@ -8,6 +8,6 @@ import { Compilable, Kysely } from 'kysely';

*/
export declare class ParameterizedCountQuery<P extends ParametersObject<P>, ReturnedCount> {
export declare class ParameterizedCountQuery<P extends ParametersObject<P>, ReturnCount> {
#private;
protected readonly countTransform: (count: bigint) => ReturnedCount;
constructor(qb: Compilable<any>, countTransform: (count: bigint) => ReturnedCount);
protected readonly countTransform: (count: bigint) => ReturnCount;
constructor(qb: Compilable<any>, countTransform: (count: bigint) => ReturnCount);
/**

@@ -22,4 +22,4 @@ * Runs the query with all parameters replaced, returning the number

*/
run<DB>(db: Kysely<DB>, params: P): Promise<ReturnedCount>;
run<DB>(db: Kysely<DB>, params: P): Promise<ReturnCount>;
}
//# sourceMappingURL=paramed-count-query.d.ts.map

@@ -6,9 +6,9 @@ import { Kysely, Selectable, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely';

*/
export declare class MappingUpdateQuery<DB, TB extends keyof DB & string, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdaterObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedCount, ReturnedObject extends object> {
export declare class MappingUpdateQuery<DB, TB extends keyof DB & string, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdatingObject extends object, SelectedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnCount, UpdateReturnsSelectedObjectWhenProvided extends boolean, DefaultReturnObject extends object> {
#private;
readonly db: Kysely<DB>;
readonly qb: QB;
protected readonly countTransform: (count: bigint) => ReturnedCount;
protected readonly updaterTransform?: ((update: UpdaterObject) => Updateable<DB[TB]>) | undefined;
protected readonly updateReturnTransform?: ((source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined;
protected readonly countTransform: (count: bigint) => ReturnCount;
protected readonly updateTransform?: ((update: UpdatingObject) => Updateable<DB[TB]>) | undefined;
protected readonly updateReturnTransform?: ((source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject) | undefined;
protected readonly returnColumns: ReturnColumns;

@@ -20,3 +20,3 @@ /**

* rows into the representation required by the client.
* @param updaterTransform A function that transforms the updating object
* @param updateTransform A function that transforms the updating object
* into a row for updating the database.

@@ -27,5 +27,8 @@ * @param returnColumns The columns to return from the update query.

* @param updateReturnTransform A function that transforms the returned
* row into the object to be returned from the update query.
* row into the object to be returned from the update query. When
* `UpdateReturnsSelectedObjectWhenProvided` is `true`, the returned
* object is of type `SelectedObject` if the function's input is also
* of this type; otherwise it is of type `DefaultReturnObject`.
*/
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnedCount, updaterTransform?: ((update: UpdaterObject) => Updateable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, updateReturnTransform?: ((source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined);
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnCount, updateTransform?: ((update: UpdatingObject) => Updateable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, updateReturnTransform?: ((source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject) | undefined);
/**

@@ -37,23 +40,30 @@ * Runs the query, returning the number of rows updated, in

*/
getCount(obj: UpdaterObject): Promise<ReturnedCount>;
getCount(obj: UpdatingObject): Promise<ReturnCount>;
/**
* Runs the query, updating rows with the values in the provided object.
* For each row updated, retrieves the columns specified in `returnColumns`,
* returning them as an object, unless `updateReturnTransform` transforms
* them into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* Updates rows with the values that result from transforming the object via
* `insertTransform` (if defined). For each row updated, retrieves the
* columns specified in `returnColumns` (if defined), returning them to the
* caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `UpdateReturnsSelectedObjectWhenProvided` is `true` and the
* provided object is a `SelectedObject`, after transformation by
* `updateReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an array containing one
* `ReturnedObject` for each updated object; otherwise returns `undefined`.
* object for each row updated; otherwise returns `undefined`.
*/
getAll(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>;
getAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>;
getAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>;
/**
* Runs the query, updating rows with the values in the provided object.
* For the first updated row, retrieves the columns given in `returnColumns`,
* returning them as an object, unless `updateReturnTransform` transforms
* them into a `ReturnedObject`. If `returnColumns` is empty, returns
* `undefined`.
* @returns If `returnColumns` is empty, returned `undefined`. Otherwise,
* returns a `ReturnedObject` if at least one row was updated, or `null` if
* no rows were updated.
* Updates rows with the values that result from transforming the object via
* `insertTransform` (if defined). For the first row updated, retrieves the
* columns specified in `returnColumns` (if defined), returning them to the
* caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `UpdateReturnsSelectedObjectWhenProvided` is `true` and the
* provided object is a `SelectedObject`, after transformation by
* `updateReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is empty, returns `undefined`. Otherwise,
* returns the first object if at least one row was updated, or `null` if
* no rows were updated.
*/
getOne(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject | null>;
getOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>;
getOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>;
/**

@@ -64,3 +74,3 @@ * Runs the query, updating rows, without returning any columns.

*/
run(obj: UpdaterObject): Promise<boolean>;
run(obj: UpdatingObject): Promise<boolean>;
/**

@@ -71,3 +81,3 @@ * Modifies the underlying Kysely query builder.

*/
modify<NextQB extends UpdateQueryBuilder<DB, TB, TB, any>>(factory: (qb: QB) => NextQB): MappingUpdateQuery<DB, TB, NextQB, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
modify<NextQB extends UpdateQueryBuilder<DB, TB, TB, any>>(factory: (qb: QB) => NextQB): MappingUpdateQuery<DB, TB, NextQB, UpdatingObject, SelectedObject, ReturnColumns, ReturnCount, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/**

@@ -86,4 +96,4 @@ * Returns a query builder for updating rows in the table and

*/
protected loadUpdaterObject(qb: UpdateQueryBuilder<DB, TB, TB, UpdateResult>, obj: UpdaterObject): UpdateQueryBuilder<DB, TB, TB, UpdateResult>;
protected loadUpdatingObject(qb: UpdateQueryBuilder<DB, TB, TB, UpdateResult>, obj: UpdatingObject): UpdateQueryBuilder<DB, TB, TB, UpdateResult>;
}
//# sourceMappingURL=update-query.d.ts.map

@@ -35,3 +35,3 @@ "use strict";

* rows into the representation required by the client.
* @param updaterTransform A function that transforms the updating object
* @param updateTransform A function that transforms the updating object
* into a row for updating the database.

@@ -42,9 +42,12 @@ * @param returnColumns The columns to return from the update query.

* @param updateReturnTransform A function that transforms the returned
* row into the object to be returned from the update query.
* row into the object to be returned from the update query. When
* `UpdateReturnsSelectedObjectWhenProvided` is `true`, the returned
* object is of type `SelectedObject` if the function's input is also
* of this type; otherwise it is of type `DefaultReturnObject`.
*/
constructor(db, qb, countTransform, updaterTransform, returnColumns, updateReturnTransform) {
constructor(db, qb, countTransform, updateTransform, returnColumns, updateReturnTransform) {
this.db = db;
this.qb = qb;
this.countTransform = countTransform;
this.updaterTransform = updaterTransform;
this.updateTransform = updateTransform;
this.updateReturnTransform = updateReturnTransform;

@@ -62,3 +65,3 @@ _MappingUpdateQuery_returningQB.set(this, null);

return __awaiter(this, void 0, void 0, function* () {
const result = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst();
const result = yield this.loadUpdatingObject(this.qb, obj).executeTakeFirst();
return this.countTransform(result.numUpdatedRows);

@@ -70,6 +73,6 @@ });

if (this.returnColumns.length === 0) {
yield this.loadUpdaterObject(this.qb, obj).execute();
yield this.loadUpdatingObject(this.qb, obj).execute();
return;
}
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute();
const returns = yield this.loadUpdatingObject(this.getReturningQB(), obj).execute();
if (returns === undefined) {

@@ -86,6 +89,6 @@ throw Error('No rows returned from update expecting returned columns');

if (this.returnColumns.length === 0) {
yield this.loadUpdaterObject(this.qb, obj).execute();
yield this.loadUpdatingObject(this.qb, obj).execute();
return;
}
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute();
const returns = yield this.loadUpdatingObject(this.getReturningQB(), obj).execute();
if (returns === undefined) {

@@ -109,3 +112,3 @@ throw Error('No rows returned from update expecting returned columns');

return __awaiter(this, void 0, void 0, function* () {
const results = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst();
const results = yield this.loadUpdatingObject(this.qb, obj).executeTakeFirst();
return results.numUpdatedRows !== BigInt(0);

@@ -120,3 +123,3 @@ });

modify(factory) {
return new MappingUpdateQuery(this.db, factory(this.qb), this.countTransform, this.updaterTransform, this.returnColumns, this.updateReturnTransform);
return new MappingUpdateQuery(this.db, factory(this.qb), this.countTransform, this.updateTransform, this.returnColumns, this.updateReturnTransform);
}

@@ -143,4 +146,4 @@ /**

*/
loadUpdaterObject(qb, obj) {
const transformedObj = this.updaterTransform === undefined ? obj : this.updaterTransform(obj);
loadUpdatingObject(qb, obj) {
const transformedObj = this.updateTransform === undefined ? obj : this.updateTransform(obj);
return qb.set(transformedObj);

@@ -147,0 +150,0 @@ }

@@ -124,10 +124,10 @@ "use strict";

const post2 = Object.assign({}, test_objects_1.POSTS[2], { userId: insertReturns[2].id });
const updaterPosts = yield postTableMapperReturningIDAndTitle
const updatingPosts = yield postTableMapperReturningIDAndTitle
.insert()
.getAll([post0, post1, post2]);
expect(updaterPosts.length).toEqual(3);
for (let i = 0; i < updaterPosts.length; i++) {
expect(updaterPosts[i].id).toBeGreaterThan(0);
expect(updaterPosts[i].title).toEqual(test_objects_1.POSTS[i].title);
expect(Object.keys(updaterPosts[i]).length).toEqual(2);
expect(updatingPosts.length).toEqual(3);
for (let i = 0; i < updatingPosts.length; i++) {
expect(updatingPosts[i].id).toBeGreaterThan(0);
expect(updatingPosts[i].title).toEqual(test_objects_1.POSTS[i].title);
expect(Object.keys(updatingPosts[i]).length).toEqual(2);
}

@@ -205,12 +205,12 @@ }));

const post0 = Object.assign({}, test_objects_1.POSTS[0], { userId: insertReturn.id });
const updaterPost = yield postTableMapperReturningIDAndTitle
const updatingPost = yield postTableMapperReturningIDAndTitle
.insert()
.getOne(post0);
expect(updaterPost.id).toBeGreaterThan(0);
expect(updaterPost.title).toEqual(test_objects_1.POSTS[0].title);
expect(Object.keys(updaterPost).length).toEqual(2);
expect(updatingPost.id).toBeGreaterThan(0);
expect(updatingPost.title).toEqual(test_objects_1.POSTS[0].title);
expect(Object.keys(updatingPost).length).toEqual(2);
const readPost0 = yield postTableMapper
.select(({ and, cmpr }) => and([
cmpr('id', '=', updaterPost.id),
cmpr('title', '=', updaterPost.title),
cmpr('id', '=', updatingPost.id),
cmpr('title', '=', updatingPost.title),
]))

@@ -217,0 +217,0 @@ .getOne();

@@ -12,5 +12,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// TODO: revisit what tests are necessary here; and wht to call this file
// Because tests for `UniformTableMapper` cover transform behavior,
// this file only checks for valid types.
const table_mapper_1 = require("../mappers/table-mapper");
const test_setup_1 = require("./utils/test-setup");
const test_types_1 = require("./utils/test-types");
const test_utils_1 = require("./utils/test-utils");

@@ -35,2 +37,67 @@ let db;

});
(0, test_utils_1.ignore)('detects invalid return count configuration', () => {
class TestMapper extends table_mapper_1.TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid return count
countTransform: (count) => BigInt(count),
});
});
(0, test_utils_1.ignore)('detects invalid select transform configuration', () => {
class TestMapper extends table_mapper_1.TableMapper {
}
// @ts-expect-error - invalid select transform
new TestMapper(db, 'users', { selectTransform: (user) => user });
});
(0, test_utils_1.ignore)('detects invalid insert transform configuration', () => {
class TestMapper extends table_mapper_1.TableMapper {
}
// @ts-expect-error - invalid insert transform
new TestMapper(db, 'users', { insertTransform: (user) => user });
});
(0, test_utils_1.ignore)('detects invalid insert return transform configurations', () => {
class TestMapper extends table_mapper_1.TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid insert return transform
insertReturnTransform: (_user) => {
return { noId: 1 };
},
});
new TestMapper(db, 'users', {
// @ts-expect-error - invalid insert return transform
insertReturnTransform: (user) => user,
});
});
(0, test_utils_1.ignore)('detects invalid update transform configuration', () => {
class TestMapper extends table_mapper_1.TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update transform
updateTransform: (_user) => {
return { noId: 1 };
},
});
});
(0, test_utils_1.ignore)('detects invalid update return transform configurations', () => __awaiter(void 0, void 0, void 0, function* () {
class TestMapper extends table_mapper_1.TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update return transform
updateReturnTransform: (_user) => {
return { noId: 1 };
},
});
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update return transform
updateReturnTransform: (_user) => {
return { noId: 1 };
},
});
const testMapper = new TestMapper(db, 'users');
(yield testMapper
.update({ id: 1 })
// @ts-expect-error - ensure that return type is User
.getOne(new test_types_1.User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name;
}));
it('dummy test', () => {

@@ -37,0 +104,0 @@ // gets test to run without error

@@ -302,3 +302,3 @@ "use strict";

super(db, 'users', {
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -317,3 +317,3 @@ handle: source.handle,

.getAll([test_objects_1.userRow1, test_objects_1.userRow2, test_objects_1.userRow3]);
const updaterUser1 = test_types_1.UpdaterUser.create(0, Object.assign({}, test_objects_1.userObject1, { firstName: 'Suzanne' }));
const updatingUser1 = test_types_1.UpdatingUser.create(0, Object.assign({}, test_objects_1.userObject1, { firstName: 'Suzanne' }));
const updateReturns = yield mapper

@@ -324,3 +324,3 @@ .update(({ or, cmpr }) => or([

]))
.getAll(updaterUser1);
.getAll(updatingUser1);
expect(updateReturns).toEqual([

@@ -370,3 +370,3 @@ { id: insertReturns[0].id },

super(db, 'users', {
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -387,3 +387,3 @@ handle: source.handle,

.update({ id: insertReturn.id })
.getAll(test_types_1.UpdaterUser.create(0, test_objects_1.userObject1));
.getAll(test_types_1.UpdatingUser.create(0, test_objects_1.userObject1));
expect(updateReturn).toEqual([

@@ -390,0 +390,0 @@ new test_types_1.ReturnedUser(insertReturn.id, test_objects_1.userObject1.firstName, test_objects_1.userObject1.lastName, test_objects_1.userObject1.handle, test_objects_1.userObject1.email),

@@ -14,3 +14,3 @@ "use strict";

const test_objects_1 = require("./utils/test-objects");
const UniformTableMapper_1 = require("../mappers/UniformTableMapper");
const uniform_table_mapper_1 = require("../mappers/uniform-table-mapper");
let db;

@@ -23,3 +23,3 @@ beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {

it('inserts/updates/deletes a mapped object w/ default transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
class MappedUser {
constructor(id, name, handle, email) {

@@ -31,46 +31,69 @@ this.id = id;

}
getKey() {
return [this.id];
}
}
const userMapper = new UniformTableMapper_1.UniformTableMapper(db, 'users', ['id']);
const userMapper = new uniform_table_mapper_1.UniformTableMapper(db, 'users', { isMappedObject: (obj) => obj instanceof MappedUser });
// test updating a non-existent user
const userWithID = new KeyedUser(1, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email);
const updateReturn1 = yield userMapper.updateTODO(userWithID);
const userWithID = new MappedUser(1, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email);
const updateReturn1 = yield userMapper.update({ id: 1 }).getOne(userWithID);
expect(updateReturn1).toEqual(null);
// test inserting a user with falsy id
const insertedUser1 = new KeyedUser(0, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email);
const insertedUser1 = new MappedUser(0, test_objects_1.USERS[0].name, test_objects_1.USERS[0].handle, test_objects_1.USERS[0].email);
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1));
expect(insertReturn1).not.toBeNull();
expect(insertReturn1.id).toBeGreaterThan(0);
insertReturn1.name; // ensure 'name' is accessible
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser1).toEqual(insertReturn1);
const selectedUser1 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser1).toEqual(Object.assign(Object.assign({}, insertedUser1), { id: insertReturn1.id }));
// ensure 'id' is accessible
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.id).toEqual(insertReturn1.id);
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.name; // ensure 'name' is accessible
// test inserting a user with truthy id
const insertedUser2 = new KeyedUser(10, test_objects_1.USERS[1].name, test_objects_1.USERS[1].handle, test_objects_1.USERS[1].email);
const insertedUser2 = new MappedUser(10, test_objects_1.USERS[1].name, test_objects_1.USERS[1].handle, test_objects_1.USERS[1].email);
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2));
expect(insertReturn2).toEqual(insertedUser2);
const selectedUser2 = yield userMapper.selectByKey(insertReturn2.id);
insertReturn2 === null || insertReturn2 === void 0 ? void 0 : insertReturn2.name; // ensure 'name' is accessible
const selectedUser2 = yield userMapper
.select({ id: insertReturn2.id })
.getOne();
expect(selectedUser2).toEqual(insertedUser2);
// test updating a user, with returned object
const updaterUser = new KeyedUser(selectedUser1.id, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser3 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser3).toEqual(updateReturn);
const updatingUser = new MappedUser(selectedUser1.id, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper
.update({ id: updatingUser.id })
.getOne(updatingUser);
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.name; // ensure 'name' is accessible
expect(updateReturn).toEqual(updatingUser);
const selectedUser3 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser3).toEqual(updatingUser);
// test updating a user, without returned object
const updaterUser2 = new KeyedUser(selectedUser3.id, 'Freddy', selectedUser3.handle, selectedUser3.email);
const updateReturn2 = yield userMapper.updateNoReturns(updaterUser2);
const updatingUser2 = new MappedUser(selectedUser3.id, 'Freddy', selectedUser3.handle, selectedUser3.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser2.id })
.run(updatingUser2);
expect(updateReturn2).toBe(true);
const selectedUser4 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser4).toEqual(updaterUser2);
const selectedUser4 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser4).toEqual(updatingUser2);
// test updating multiple users returning select columns
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' });
expect(updateReturn3).toEqual([{ id: 1 }, { id: 10 }]);
updateReturn3[0].id; // ensure 'id' is accessible
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' });
expect(updateReturn4).toEqual({ id: 1 });
updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn1.id);
const deleted = yield userMapper.delete({ id: insertReturn1.id }).run();
expect(deleted).toEqual(true);
const selectedUser5 = yield userMapper.selectByKey(insertReturn1.id);
const selectedUser5 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser5).toBeNull();
}));
it('inserts/updates/deletes a mapped object class w/ all custom transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
class MappedUser {
constructor(serialNo, firstName, lastName, handle, email) {

@@ -83,7 +106,5 @@ this.serialNo = serialNo;

}
getKey() {
return [this.serialNo];
}
}
const userMapper = new UniformTableMapper_1.UniformTableMapper(db, 'users', ['id'], {
const userMapper = new uniform_table_mapper_1.UniformTableMapper(db, 'users', {
isMappedObject: (obj) => obj instanceof MappedUser,
insertTransform: (user) => {

@@ -97,5 +118,8 @@ return {

insertReturnTransform: (user, returns) => {
return new KeyedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
return new MappedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
},
updaterTransform: (user) => {
updateTransform: (user) => {
if (!(user instanceof MappedUser)) {
return user;
}
return {

@@ -108,26 +132,41 @@ name: `${user.firstName} ${user.lastName}`,

updateReturnTransform: (user, _returns) => {
return new KeyedUser(user.serialNo, user.firstName, user.lastName, user.handle, user.email);
if (!(user instanceof MappedUser)) {
return _returns;
}
return new MappedUser(user.serialNo, user.firstName, user.lastName, user.handle, user.email);
},
selectTransform: (row) => {
const names = row.name.split(' ');
return new KeyedUser(row.id, names[0], names[1], row.handle, row.email);
return new MappedUser(row.id, names[0], names[1], row.handle, row.email);
},
});
// test updating a non-existent user
const updateReturn1 = yield userMapper.updateTODO(new KeyedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email));
const updateReturn1 = yield userMapper
.update({ id: 1 })
.getOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email));
expect(updateReturn1).toEqual(null);
// test inserting a user
const insertedUser = new KeyedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email);
const insertedUser = new MappedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email);
const insertReturn = (yield userMapper.insert().getOne(insertedUser));
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible
expect(insertReturn).not.toBeNull();
expect(insertReturn.serialNo).toBeGreaterThan(0);
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser1 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible
expect(selectedUser1).toEqual(insertReturn);
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.serialNo).toEqual(insertReturn.serialNo);
// test updating a user, with returned object
const updaterUser = new KeyedUser(selectedUser1.serialNo, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser2 = yield userMapper.selectByKey(insertReturn.serialNo);
const updatingUser = new MappedUser(selectedUser1.serialNo, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser.serialNo })
.getOne(updatingUser);
updateReturn2 === null || updateReturn2 === void 0 ? void 0 : updateReturn2.firstName; // ensure 'firstName' is accessible
expect(updateReturn2).toEqual(updatingUser);
const selectedUser2 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.firstName; // ensure 'firstName' is accessible
expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.serialNo).toEqual(selectedUser1.serialNo);

@@ -141,13 +180,25 @@ expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.handle).toEqual(selectedUser1.handle + '2');

});
updateColumnReturns[0].id; // ensure 'id' is accessible
expect(updateColumnReturns).toEqual([{ id: selectedUser1.serialNo }]);
const selectedUser4 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser4 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
expect(selectedUser4 === null || selectedUser4 === void 0 ? void 0 : selectedUser4.firstName).toEqual('Foo');
// test updating multiple users returning select columns
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' });
expect(updateReturn3).toEqual([{ id: 1 }]);
updateReturn3[0].id; // ensure 'id' is accessible
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' });
expect(updateReturn4).toEqual({ id: 1 });
updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn.serialNo);
const deleted = yield userMapper.delete({ id: insertReturn.serialNo }).run();
expect(deleted).toEqual(true);
const selectedUser3 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser3 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
expect(selectedUser3).toBeNull();
}));
it('inserts/updates/deletes a mapped object class w/ inferred update transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
it('inserts/updates/deletes a mapped object class w/ default update transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class MappedUser {
constructor(id, firstName, lastName, handle, email) {

@@ -160,7 +211,5 @@ this.id = id;

}
getKey() {
return [this.id];
}
}
const userMapper = new UniformTableMapper_1.UniformTableMapper(db, 'users', ['id'], {
const userMapper = new uniform_table_mapper_1.UniformTableMapper(db, 'users', {
isMappedObject: (obj) => obj instanceof MappedUser,
insertTransform: (user) => {

@@ -173,47 +222,57 @@ return {

},
updaterTransform: (user) => {
return {
name: `${user.firstName} ${user.lastName}`,
handle: user.handle,
email: user.email,
};
},
insertReturnTransform: (user, returns) => {
return new KeyedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
return new MappedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
},
selectTransform: (row) => {
const names = row.name.split(' ');
return new KeyedUser(row.id, names[0], names[1], row.handle, row.email);
return new MappedUser(row.id, names[0], names[1], row.handle, row.email);
},
});
// test updating a non-existent user
const updateReturn1 = yield userMapper.updateTODO(new KeyedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email));
const updateReturn1 = yield userMapper
.update({ id: 1 })
.getOne(new MappedUser(1, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email));
expect(updateReturn1).toEqual(null);
// test inserting a user
const insertedUser = new KeyedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email);
const insertedUser = new MappedUser(0, test_objects_1.insertedUser1.firstName, test_objects_1.insertedUser1.lastName, test_objects_1.insertedUser1.handle, test_objects_1.insertedUser1.email);
const insertReturn = (yield userMapper.insert().getOne(insertedUser));
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible
expect(insertReturn).not.toBeNull();
expect(insertReturn.id).toBeGreaterThan(0);
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn.id);
const selectedUser1 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible
expect(selectedUser1).toEqual(insertReturn);
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.id).toEqual(insertReturn.id);
// test updating a user
const updaterUser = new KeyedUser(selectedUser1.id, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser2 = yield userMapper.selectByKey(insertReturn.id);
expect(selectedUser2).toEqual(updateReturn);
const updatingUser = new MappedUser(selectedUser1.id, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper
.update({ id: updatingUser.id })
.getOne(updatingUser);
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.firstName; // ensure 'firstName' is accessible
expect(updateReturn).toEqual(updatingUser);
const selectedUser2 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser2).toEqual(updatingUser);
// test updating a user, without returned object
const updaterUser2 = new KeyedUser(selectedUser2.id, 'Super', 'Man', selectedUser2.handle, selectedUser2.email);
const updateReturn2 = yield userMapper.updateNoReturns(updaterUser2);
const updatingUser2 = new MappedUser(selectedUser2.id, 'Super', 'Man', selectedUser2.handle, selectedUser2.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser2.id })
.run(updatingUser2);
expect(updateReturn2).toBe(true);
const selectedUser3 = yield userMapper.selectByKey(insertReturn.id);
expect(selectedUser3).toEqual(updaterUser2);
const selectedUser3 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser3).toEqual(updatingUser2);
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn.id);
const deleted = yield userMapper.delete({ id: insertReturn.id }).run();
expect(deleted).toEqual(true);
const selectedUser4 = yield userMapper.selectByKey(insertReturn.id);
const selectedUser4 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser4).toBeNull();
}));
//# sourceMappingURL=UniformTableMapper.test.js.map
import { Insertable, Selectable } from 'kysely';
import { Users, Posts } from './test-tables';
import { InsertedUser, ReturnedUser, SelectedUser, UpdaterUser } from './test-types';
import { InsertedUser, ReturnedUser, SelectedUser, UpdatingUser } from './test-types';
export declare const USERS: Insertable<Users>[];

@@ -55,3 +55,3 @@ export declare const POSTS: Insertable<Posts>[];

};
updaterTransform: (source: UpdaterUser) => {
updateTransform: (source: UpdatingUser) => {
name: string;

@@ -62,5 +62,5 @@ handle: string;

insertReturnTransform: (source: InsertedUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
updateReturnTransform: (source: UpdaterUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
updateReturnTransform: (source: UpdatingUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
returnColumns: ["id"];
};
//# sourceMappingURL=test-objects.d.ts.map

@@ -89,3 +89,3 @@ "use strict";

}),
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -92,0 +92,0 @@ handle: source.handle,

@@ -22,5 +22,5 @@ /**

}
export declare class UpdaterUser extends User {
readonly __type = "UpdaterUser";
static create(id: number, obj: VariableFieldsOf<UpdaterUser>): UpdaterUser;
export declare class UpdatingUser extends User {
readonly __type = "UpdatingUser";
static create(id: number, obj: VariableFieldsOf<UpdatingUser>): UpdatingUser;
}

@@ -27,0 +27,0 @@ export declare class ReturnedUser extends User {

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ReturnedUser = exports.UpdaterUser = exports.SelectedUser = exports.InsertedUser = exports.User = void 0;
exports.ReturnedUser = exports.UpdatingUser = exports.SelectedUser = exports.InsertedUser = exports.User = void 0;
class User {

@@ -41,12 +41,12 @@ constructor(id, firstName, lastName, handle, email) {

exports.SelectedUser = SelectedUser;
class UpdaterUser extends User {
class UpdatingUser extends User {
constructor() {
super(...arguments);
this.__type = 'UpdaterUser';
this.__type = 'UpdatingUser';
}
static create(id, obj) {
return new UpdaterUser(id, obj.firstName, obj.lastName, obj.handle, obj.email);
return new UpdatingUser(id, obj.firstName, obj.lastName, obj.handle, obj.email);
}
}
exports.UpdaterUser = UpdaterUser;
exports.UpdatingUser = UpdatingUser;
class ReturnedUser extends User {

@@ -53,0 +53,0 @@ constructor() {

export * from './mappers/table-mapper';
export * from './mappers/table-mapper-options';
export * from './mappers/KeyedTableMapper';
export * from './mappers/UniformTableMapper';
export * from './mappers/uniform-table-mapper-options';
export * from './mappers/uniform-table-mapper';
export * from './queries/delete-query';

@@ -6,0 +6,0 @@ export * from './queries/insert-query';

export * from './mappers/table-mapper';
export * from './mappers/table-mapper-options';
export * from './mappers/KeyedTableMapper';
export * from './mappers/UniformTableMapper';
export * from './mappers/uniform-table-mapper-options';
export * from './mappers/uniform-table-mapper';
export * from './queries/delete-query';

@@ -6,0 +6,0 @@ export * from './queries/insert-query';

@@ -9,14 +9,27 @@ import { Insertable, Selectable, Updateable } from 'kysely';

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedCount Type of count query results.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam ReturnCount Type of count query results.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/
export interface TableMapperOptions<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'], SelectedObject extends object, InsertedObject extends object, UpdaterObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedCount, ReturnedObject extends object> {
export interface TableMapperOptions<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdatingObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnCount = bigint, InsertReturnsSelectedObject extends boolean = false, UpdateReturnsSelectedObjectWhenProvided extends boolean = false, DefaultReturnObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
/** Transformation to apply to inserted objects before insertion. */
readonly insertTransform?: (obj: InsertedObject) => Insertable<DB[TB]>;
/** Whether insert queries return `SelectedObject` or `DefaultReturnObject`. */
readonly insertReturnsSelectedObject?: InsertReturnsSelectedObject;
/** Transformation to apply to objects provided for updating values. */
readonly updaterTransform?: (update: UpdaterObject) => Updateable<DB[TB]>;
readonly updateTransform?: (update: UpdatingObject) => Updateable<DB[TB]>;
/**
* Whether update queries return `SelectedObject` when the updating object
* is a `SelectedObject`; update queries otherwise return `DefaultReturnObject`.
*/
readonly updateReturnsSelectedObjectWhenProvided?: UpdateReturnsSelectedObjectWhenProvided;
/** Columns to return from selection queries. */

@@ -32,8 +45,8 @@ readonly selectedColumns?: SelectedColumns;

/** Transformation to apply to column values returned from inserts. */
readonly insertReturnTransform?: (source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject;
readonly insertReturnTransform?: (source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject;
/** Transformation to apply to column values returned from updates. */
readonly updateReturnTransform?: (source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject;
readonly updateReturnTransform?: (source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject;
/** Transformation to apply to bigint count results. */
readonly countTransform?: (count: bigint) => ReturnedCount;
readonly countTransform?: (count: bigint) => ReturnCount;
}
//# sourceMappingURL=table-mapper-options.d.ts.map

@@ -16,14 +16,20 @@ import { Kysely, Insertable, ReferenceExpression, Selectable, InsertQueryBuilder, InsertResult, SelectQueryBuilder, Selection, DeleteQueryBuilder, DeleteResult, UpdateResult, UpdateQueryBuilder } from 'kysely';

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam ReturnedCount Type of count query results.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnCount Type of count query results.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/
export declare class TableMapper<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdaterObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnedCount = bigint, ReturnedObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
export declare class TableMapper<DB, TB extends keyof DB & string, SelectedColumns extends SelectionColumn<DB, TB>[] | ['*'] = ['*'], SelectedObject extends object = SelectedRow<DB, TB, SelectedColumns extends ['*'] ? never : SelectedColumns[number], SelectedColumns>, InsertedObject extends object = Insertable<DB[TB]>, UpdatingObject extends object = Partial<Insertable<DB[TB]>>, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'] = [], ReturnCount = bigint, InsertReturnsSelectedObject extends boolean = false, UpdateReturnsSelectedObjectWhenProvided extends boolean = false, DefaultReturnObject extends object = ReturnColumns extends ['*'] ? Selectable<DB[TB]> : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>> {
#private;
readonly db: Kysely<DB>;
readonly tableName: TB;
readonly options: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
readonly options: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdatingObject, ReturnColumns, ReturnCount, InsertReturnsSelectedObject, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/** Columns to return from selection queries. `[]` => all columns. */

@@ -33,4 +39,4 @@ protected readonly selectedColumns: SelectionColumn<DB, TB>[];

protected returnColumns: (keyof Selectable<DB[TB]> & string)[] | ['*'];
/** Transforms query counts into `ReturnedCount`. */
protected countTransform: (count: bigint) => ReturnedCount;
/** Transforms query counts into `ReturnCount`. */
protected countTransform: (count: bigint) => ReturnCount;
/**

@@ -40,6 +46,6 @@ * Constructs a new table mapper.

* @param tableName The name of the table.
* @param options Options governing mapper behavior. `returnColumns`
* defaults to returning no columns.
* @param options Options governing mapper behavior. Default to selecting
* all columns and to returning no columns on insert or update.
*/
constructor(db: Kysely<DB>, tableName: TB, options?: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>);
constructor(db: Kysely<DB>, tableName: TB, options?: TableMapperOptions<DB, TB, SelectedColumns, SelectedObject, InsertedObject, UpdatingObject, ReturnColumns, ReturnCount, InsertReturnsSelectedObject, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>);
/**

@@ -67,3 +73,3 @@ * Creates and returns a parameterized mapping query, which can be repeatedly

*/
delete<RE extends ReferenceExpression<DB, TB>, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>>(filter?: QueryFilter<DB, TB, RE, DeleteQueryBuilder<DB, any, DeleteResult>, QB>): MappingDeleteQuery<DB, TB, DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnedCount>;
delete<RE extends ReferenceExpression<DB, TB>, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>>(filter?: QueryFilter<DB, TB, RE, DeleteQueryBuilder<DB, any, DeleteResult>, QB>): MappingDeleteQuery<DB, TB, DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnCount>;
/**

@@ -73,3 +79,3 @@ * Returns a query for inserting rows into the table.

*/
insert(): MappingInsertQuery<DB, TB, InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject, ReturnColumns, ReturnedObject>;
insert(): MappingInsertQuery<DB, TB, InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject, SelectedObject, ReturnColumns, InsertReturnsSelectedObject, DefaultReturnObject>;
/**

@@ -94,3 +100,3 @@ * Returns a reference to a column, which can be a generated string.

*/
update<RE extends ReferenceExpression<DB, TB>, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>>(filter?: QueryFilter<DB, TB, RE, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, QB>): MappingUpdateQuery<DB, TB, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
update<RE extends ReferenceExpression<DB, TB>, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>>(filter?: QueryFilter<DB, TB, RE, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, QB>): MappingUpdateQuery<DB, TB, UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdatingObject, SelectedObject, ReturnColumns, ReturnCount, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/**

@@ -97,0 +103,0 @@ * Returns a query builder for deleting rows from the table, caching the

@@ -25,8 +25,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {

* @typeparam InsertedObject Type of objects inserted into the table.
* @typeparam UpdaterObject Type of objects used to update rows of the table.
* @typeparam ReturnedCount Type of count query results.
* @typeparam UpdatingObject Type of objects used to update rows of the table.
* @typeparam ReturnCount Type of count query results.
* @typeparam ReturnColumns Columns to return from the table on insert or
* update, except when explicitly requesting no columns. `['*']` returns
* all columns; `[]` returns none and is the default.
* @typeparam ReturnedObject Objects to return from inserts and updates.
* @typeparam InsertReturnsSelectedObject Whether insert queries return
* `SelectedObject` or `DefaultReturnObject`.
* @typeparam UpdateReturnsSelectedObjectWhenProvided Whether update queries
* return `SelectedObject` when the updating object is a `SelectedObject`;
* update queries otherwise return `DefaultReturnObject`.
* @typeparam DefaultReturnObject Type of objects returned from inserts and
* updates, unless configured to return `SelectedObject`.
*/

@@ -38,4 +44,4 @@ export class TableMapper {

* @param tableName The name of the table.
* @param options Options governing mapper behavior. `returnColumns`
* defaults to returning no columns.
* @param options Options governing mapper behavior. Default to selecting
* all columns and to returning no columns on insert or update.
*/

@@ -51,3 +57,3 @@ constructor(db, tableName, options = {}) {

_TableMapper_baseUpdateQB.set(this, null);
/** Transforms query counts into `ReturnedCount`. */
/** Transforms query counts into `ReturnCount`. */
this.countTransform = (count) => count;

@@ -148,3 +154,3 @@ this.returnColumns = (_a = options.returnColumns) !== null && _a !== void 0 ? _a : [];

? this.getUpdateQB()
: applyQueryFilter(this.db, this.getUpdateQB(), filter), this.countTransform, this.options.updaterTransform, this.options.returnColumns, this.options.updateReturnTransform);
: applyQueryFilter(this.db, this.getUpdateQB(), filter), this.countTransform, this.options.updateTransform, this.options.returnColumns, this.options.updateReturnTransform);
}

@@ -151,0 +157,0 @@ /**

@@ -5,6 +5,6 @@ import { DeleteQueryBuilder, DeleteResult, Kysely } from 'kysely';

*/
export declare class MappingDeleteQuery<DB, TB extends keyof DB & string, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnedCount> {
export declare class MappingDeleteQuery<DB, TB extends keyof DB & string, QB extends DeleteQueryBuilder<DB, TB, DeleteResult>, ReturnCount> {
protected readonly db: Kysely<DB>;
protected readonly qb: QB;
protected readonly countTransform: (count: bigint) => ReturnedCount;
protected readonly countTransform: (count: bigint) => ReturnCount;
/**

@@ -15,3 +15,3 @@ * @param db Kysely database instance.

*/
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnedCount);
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnCount);
/**

@@ -22,3 +22,3 @@ * Runs the query, returning the number of rows deleted, converted to

*/
getCount(): Promise<ReturnedCount>;
getCount(): Promise<ReturnCount>;
/**

@@ -29,3 +29,3 @@ * Modifies the underlying Kysely query builder.

*/
modify<NextQB extends DeleteQueryBuilder<DB, any, DeleteResult>>(factory: (qb: QB) => NextQB): MappingDeleteQuery<DB, TB, NextQB, ReturnedCount>;
modify<NextQB extends DeleteQueryBuilder<DB, any, DeleteResult>>(factory: (qb: QB) => NextQB): MappingDeleteQuery<DB, TB, NextQB, ReturnCount>;
/**

@@ -32,0 +32,0 @@ * Runs the query, deleting the indicated rows, returning nothing.

@@ -6,3 +6,3 @@ import { Kysely, InsertQueryBuilder, InsertResult, Selectable, Insertable } from 'kysely';

*/
export declare class MappingInsertQuery<DB, TB extends keyof DB & string, QB extends InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedObject extends object> {
export declare class MappingInsertQuery<DB, TB extends keyof DB & string, QB extends InsertQueryBuilder<DB, TB, InsertResult>, InsertedObject extends object, SelectedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], InsertReturnsSelectedObject extends boolean, DefaultReturnObject extends object> {
#private;

@@ -12,3 +12,3 @@ protected readonly db: Kysely<DB>;

protected readonly insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined;
protected readonly insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined;
protected readonly insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject) | undefined;
protected readonly returnColumns: ReturnColumns;

@@ -25,5 +25,7 @@ /**

* to be inserted and the returned row into the object to be returned
* from the insert query.
* from the insert query. When `InsertReturnsSelectedObject` is `true`,
* the returned object is of type `SelectedObject`; otherwise it is of
* type `DefaultReturnObject`.
*/
constructor(db: Kysely<DB>, qb: QB, insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined);
constructor(db: Kysely<DB>, qb: QB, insertTransform?: ((obj: InsertedObject) => Insertable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, insertReturnTransform?: ((source: InsertedObject, returns: ReturnColumns extends [] ? never : ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject) | undefined);
/**

@@ -33,18 +35,20 @@ * Inserts the provided objects into the table as rows, first transforming

* retrieves the columns specified in `returnColumns`, returning them to
* the caller as an object, unless `insertReturnTransform` transforms them
* into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* the caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `InsertReturnsSelectedObject` is `true`, after transformation by
* `insertReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an array containing one
* `ReturnedObject` for each inserted object; otherwise returns `undefined`.
* object for each inserted object; otherwise returns `undefined`.
*/
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>;
getAll(objs: InsertedObject[]): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject[] : DefaultReturnObject[]>;
/**
* Inserts the provided object into the table as a row, first transforming
* it into rows via `insertTransform` (if defined). Retrieves the columns
* specified in `returnColumns` (if any), returning them to the caller as
* an objectunless `insertReturnTransform` transforms them into a
* `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns a `ReturnedObject`;
* it into a row via `insertTransform` (if defined). Also retrieves the
* columns specified in `returnColumns`, returning them to the caller as
* either `DefaultReturnObject` or `SelectedObject`, depending on whether
* `InsertReturnsSelectedObject` is `true`, after transformation by
* `insertReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an object;
* otherwise returns `undefined`.
*/
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : ReturnedObject>;
getOne(obj: InsertedObject): Promise<ReturnColumns extends [] ? void : InsertReturnsSelectedObject extends true ? SelectedObject : DefaultReturnObject>;
/**

@@ -61,3 +65,3 @@ * Runs the query, inserting rows into the table without returning any columns.

*/
modify<NextQB extends InsertQueryBuilder<DB, TB, any>>(factory: (qb: QB) => NextQB): MappingInsertQuery<DB, TB, NextQB, InsertedObject, ReturnColumns, ReturnedObject>;
modify<NextQB extends InsertQueryBuilder<DB, TB, any>>(factory: (qb: QB) => NextQB): MappingInsertQuery<DB, TB, NextQB, InsertedObject, SelectedObject, ReturnColumns, InsertReturnsSelectedObject, DefaultReturnObject>;
/**

@@ -64,0 +68,0 @@ * Returns a query builder for inserting rows into the table and

@@ -38,3 +38,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* to be inserted and the returned row into the object to be returned
* from the insert query.
* from the insert query. When `InsertReturnsSelectedObject` is `true`,
* the returned object is of type `SelectedObject`; otherwise it is of
* type `DefaultReturnObject`.
*/

@@ -41,0 +43,0 @@ constructor(db, qb, insertTransform, returnColumns, insertReturnTransform) {

@@ -8,6 +8,6 @@ import { Compilable, Kysely } from 'kysely';

*/
export declare class ParameterizedCountQuery<P extends ParametersObject<P>, ReturnedCount> {
export declare class ParameterizedCountQuery<P extends ParametersObject<P>, ReturnCount> {
#private;
protected readonly countTransform: (count: bigint) => ReturnedCount;
constructor(qb: Compilable<any>, countTransform: (count: bigint) => ReturnedCount);
protected readonly countTransform: (count: bigint) => ReturnCount;
constructor(qb: Compilable<any>, countTransform: (count: bigint) => ReturnCount);
/**

@@ -22,4 +22,4 @@ * Runs the query with all parameters replaced, returning the number

*/
run<DB>(db: Kysely<DB>, params: P): Promise<ReturnedCount>;
run<DB>(db: Kysely<DB>, params: P): Promise<ReturnCount>;
}
//# sourceMappingURL=paramed-count-query.d.ts.map

@@ -6,9 +6,9 @@ import { Kysely, Selectable, UpdateQueryBuilder, UpdateResult, Updateable } from 'kysely';

*/
export declare class MappingUpdateQuery<DB, TB extends keyof DB & string, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdaterObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnedCount, ReturnedObject extends object> {
export declare class MappingUpdateQuery<DB, TB extends keyof DB & string, QB extends UpdateQueryBuilder<DB, TB, TB, UpdateResult>, UpdatingObject extends object, SelectedObject extends object, ReturnColumns extends (keyof Selectable<DB[TB]> & string)[] | ['*'], ReturnCount, UpdateReturnsSelectedObjectWhenProvided extends boolean, DefaultReturnObject extends object> {
#private;
readonly db: Kysely<DB>;
readonly qb: QB;
protected readonly countTransform: (count: bigint) => ReturnedCount;
protected readonly updaterTransform?: ((update: UpdaterObject) => Updateable<DB[TB]>) | undefined;
protected readonly updateReturnTransform?: ((source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined;
protected readonly countTransform: (count: bigint) => ReturnCount;
protected readonly updateTransform?: ((update: UpdatingObject) => Updateable<DB[TB]>) | undefined;
protected readonly updateReturnTransform?: ((source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject) | undefined;
protected readonly returnColumns: ReturnColumns;

@@ -20,3 +20,3 @@ /**

* rows into the representation required by the client.
* @param updaterTransform A function that transforms the updating object
* @param updateTransform A function that transforms the updating object
* into a row for updating the database.

@@ -27,5 +27,8 @@ * @param returnColumns The columns to return from the update query.

* @param updateReturnTransform A function that transforms the returned
* row into the object to be returned from the update query.
* row into the object to be returned from the update query. When
* `UpdateReturnsSelectedObjectWhenProvided` is `true`, the returned
* object is of type `SelectedObject` if the function's input is also
* of this type; otherwise it is of type `DefaultReturnObject`.
*/
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnedCount, updaterTransform?: ((update: UpdaterObject) => Updateable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, updateReturnTransform?: ((source: UpdaterObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => ReturnedObject) | undefined);
constructor(db: Kysely<DB>, qb: QB, countTransform: (count: bigint) => ReturnCount, updateTransform?: ((update: UpdatingObject) => Updateable<DB[TB]>) | undefined, returnColumns?: ReturnColumns, updateReturnTransform?: ((source: UpdatingObject, returns: ObjectWithKeys<Selectable<DB[TB]>, ReturnColumns>) => UpdateReturnsSelectedObjectWhenProvided extends true ? UpdatingObject extends SelectedObject ? SelectedObject : DefaultReturnObject : DefaultReturnObject) | undefined);
/**

@@ -37,23 +40,30 @@ * Runs the query, returning the number of rows updated, in

*/
getCount(obj: UpdaterObject): Promise<ReturnedCount>;
getCount(obj: UpdatingObject): Promise<ReturnCount>;
/**
* Runs the query, updating rows with the values in the provided object.
* For each row updated, retrieves the columns specified in `returnColumns`,
* returning them as an object, unless `updateReturnTransform` transforms
* them into `ReturnedObject`. If `returnColumns` is empty, returns `undefined`.
* Updates rows with the values that result from transforming the object via
* `insertTransform` (if defined). For each row updated, retrieves the
* columns specified in `returnColumns` (if defined), returning them to the
* caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `UpdateReturnsSelectedObjectWhenProvided` is `true` and the
* provided object is a `SelectedObject`, after transformation by
* `updateReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is not empty, returns an array containing one
* `ReturnedObject` for each updated object; otherwise returns `undefined`.
* object for each row updated; otherwise returns `undefined`.
*/
getAll(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject[]>;
getAll(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject[] : DefaultReturnObject[]>;
getAll(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject[]>;
/**
* Runs the query, updating rows with the values in the provided object.
* For the first updated row, retrieves the columns given in `returnColumns`,
* returning them as an object, unless `updateReturnTransform` transforms
* them into a `ReturnedObject`. If `returnColumns` is empty, returns
* `undefined`.
* @returns If `returnColumns` is empty, returned `undefined`. Otherwise,
* returns a `ReturnedObject` if at least one row was updated, or `null` if
* no rows were updated.
* Updates rows with the values that result from transforming the object via
* `insertTransform` (if defined). For the first row updated, retrieves the
* columns specified in `returnColumns` (if defined), returning them to the
* caller as either `DefaultReturnObject` or `SelectedObject`, depending
* on whether `UpdateReturnsSelectedObjectWhenProvided` is `true` and the
* provided object is a `SelectedObject`, after transformation by
* `updateReturnTransform`. If `returnColumns` is empty, returns `undefined`.
* @returns If `returnColumns` is empty, returns `undefined`. Otherwise,
* returns the first object if at least one row was updated, or `null` if
* no rows were updated.
*/
getOne(obj: UpdaterObject): Promise<ReturnColumns extends [] ? void : ReturnedObject | null>;
getOne(obj: SelectedObject): Promise<ReturnColumns extends [] ? void : (UpdateReturnsSelectedObjectWhenProvided extends true ? SelectedObject : DefaultReturnObject) | null>;
getOne(obj: UpdatingObject): Promise<ReturnColumns extends [] ? void : DefaultReturnObject | null>;
/**

@@ -64,3 +74,3 @@ * Runs the query, updating rows, without returning any columns.

*/
run(obj: UpdaterObject): Promise<boolean>;
run(obj: UpdatingObject): Promise<boolean>;
/**

@@ -71,3 +81,3 @@ * Modifies the underlying Kysely query builder.

*/
modify<NextQB extends UpdateQueryBuilder<DB, TB, TB, any>>(factory: (qb: QB) => NextQB): MappingUpdateQuery<DB, TB, NextQB, UpdaterObject, ReturnColumns, ReturnedCount, ReturnedObject>;
modify<NextQB extends UpdateQueryBuilder<DB, TB, TB, any>>(factory: (qb: QB) => NextQB): MappingUpdateQuery<DB, TB, NextQB, UpdatingObject, SelectedObject, ReturnColumns, ReturnCount, UpdateReturnsSelectedObjectWhenProvided, DefaultReturnObject>;
/**

@@ -86,4 +96,4 @@ * Returns a query builder for updating rows in the table and

*/
protected loadUpdaterObject(qb: UpdateQueryBuilder<DB, TB, TB, UpdateResult>, obj: UpdaterObject): UpdateQueryBuilder<DB, TB, TB, UpdateResult>;
protected loadUpdatingObject(qb: UpdateQueryBuilder<DB, TB, TB, UpdateResult>, obj: UpdatingObject): UpdateQueryBuilder<DB, TB, TB, UpdateResult>;
}
//# sourceMappingURL=update-query.d.ts.map

@@ -32,3 +32,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

* rows into the representation required by the client.
* @param updaterTransform A function that transforms the updating object
* @param updateTransform A function that transforms the updating object
* into a row for updating the database.

@@ -39,9 +39,12 @@ * @param returnColumns The columns to return from the update query.

* @param updateReturnTransform A function that transforms the returned
* row into the object to be returned from the update query.
* row into the object to be returned from the update query. When
* `UpdateReturnsSelectedObjectWhenProvided` is `true`, the returned
* object is of type `SelectedObject` if the function's input is also
* of this type; otherwise it is of type `DefaultReturnObject`.
*/
constructor(db, qb, countTransform, updaterTransform, returnColumns, updateReturnTransform) {
constructor(db, qb, countTransform, updateTransform, returnColumns, updateReturnTransform) {
this.db = db;
this.qb = qb;
this.countTransform = countTransform;
this.updaterTransform = updaterTransform;
this.updateTransform = updateTransform;
this.updateReturnTransform = updateReturnTransform;

@@ -59,3 +62,3 @@ _MappingUpdateQuery_returningQB.set(this, null);

return __awaiter(this, void 0, void 0, function* () {
const result = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst();
const result = yield this.loadUpdatingObject(this.qb, obj).executeTakeFirst();
return this.countTransform(result.numUpdatedRows);

@@ -67,6 +70,6 @@ });

if (this.returnColumns.length === 0) {
yield this.loadUpdaterObject(this.qb, obj).execute();
yield this.loadUpdatingObject(this.qb, obj).execute();
return;
}
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute();
const returns = yield this.loadUpdatingObject(this.getReturningQB(), obj).execute();
if (returns === undefined) {

@@ -83,6 +86,6 @@ throw Error('No rows returned from update expecting returned columns');

if (this.returnColumns.length === 0) {
yield this.loadUpdaterObject(this.qb, obj).execute();
yield this.loadUpdatingObject(this.qb, obj).execute();
return;
}
const returns = yield this.loadUpdaterObject(this.getReturningQB(), obj).execute();
const returns = yield this.loadUpdatingObject(this.getReturningQB(), obj).execute();
if (returns === undefined) {

@@ -106,3 +109,3 @@ throw Error('No rows returned from update expecting returned columns');

return __awaiter(this, void 0, void 0, function* () {
const results = yield this.loadUpdaterObject(this.qb, obj).executeTakeFirst();
const results = yield this.loadUpdatingObject(this.qb, obj).executeTakeFirst();
return results.numUpdatedRows !== BigInt(0);

@@ -117,3 +120,3 @@ });

modify(factory) {
return new MappingUpdateQuery(this.db, factory(this.qb), this.countTransform, this.updaterTransform, this.returnColumns, this.updateReturnTransform);
return new MappingUpdateQuery(this.db, factory(this.qb), this.countTransform, this.updateTransform, this.returnColumns, this.updateReturnTransform);
}

@@ -140,4 +143,4 @@ /**

*/
loadUpdaterObject(qb, obj) {
const transformedObj = this.updaterTransform === undefined ? obj : this.updaterTransform(obj);
loadUpdatingObject(qb, obj) {
const transformedObj = this.updateTransform === undefined ? obj : this.updateTransform(obj);
return qb.set(transformedObj);

@@ -144,0 +147,0 @@ }

@@ -122,10 +122,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

const post2 = Object.assign({}, POSTS[2], { userId: insertReturns[2].id });
const updaterPosts = yield postTableMapperReturningIDAndTitle
const updatingPosts = yield postTableMapperReturningIDAndTitle
.insert()
.getAll([post0, post1, post2]);
expect(updaterPosts.length).toEqual(3);
for (let i = 0; i < updaterPosts.length; i++) {
expect(updaterPosts[i].id).toBeGreaterThan(0);
expect(updaterPosts[i].title).toEqual(POSTS[i].title);
expect(Object.keys(updaterPosts[i]).length).toEqual(2);
expect(updatingPosts.length).toEqual(3);
for (let i = 0; i < updatingPosts.length; i++) {
expect(updatingPosts[i].id).toBeGreaterThan(0);
expect(updatingPosts[i].title).toEqual(POSTS[i].title);
expect(Object.keys(updatingPosts[i]).length).toEqual(2);
}

@@ -203,12 +203,12 @@ }));

const post0 = Object.assign({}, POSTS[0], { userId: insertReturn.id });
const updaterPost = yield postTableMapperReturningIDAndTitle
const updatingPost = yield postTableMapperReturningIDAndTitle
.insert()
.getOne(post0);
expect(updaterPost.id).toBeGreaterThan(0);
expect(updaterPost.title).toEqual(POSTS[0].title);
expect(Object.keys(updaterPost).length).toEqual(2);
expect(updatingPost.id).toBeGreaterThan(0);
expect(updatingPost.title).toEqual(POSTS[0].title);
expect(Object.keys(updatingPost).length).toEqual(2);
const readPost0 = yield postTableMapper
.select(({ and, cmpr }) => and([
cmpr('id', '=', updaterPost.id),
cmpr('title', '=', updaterPost.title),
cmpr('id', '=', updatingPost.id),
cmpr('title', '=', updatingPost.title),
]))

@@ -215,0 +215,0 @@ .getOne();

@@ -10,5 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
// TODO: revisit what tests are necessary here; and wht to call this file
// Because tests for `UniformTableMapper` cover transform behavior,
// this file only checks for valid types.
import { TableMapper } from '../mappers/table-mapper';
import { createDB, resetDB, destroyDB } from './utils/test-setup';
import { User } from './utils/test-types';
import { ignore } from './utils/test-utils';

@@ -33,2 +35,67 @@ let db;

});
ignore('detects invalid return count configuration', () => {
class TestMapper extends TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid return count
countTransform: (count) => BigInt(count),
});
});
ignore('detects invalid select transform configuration', () => {
class TestMapper extends TableMapper {
}
// @ts-expect-error - invalid select transform
new TestMapper(db, 'users', { selectTransform: (user) => user });
});
ignore('detects invalid insert transform configuration', () => {
class TestMapper extends TableMapper {
}
// @ts-expect-error - invalid insert transform
new TestMapper(db, 'users', { insertTransform: (user) => user });
});
ignore('detects invalid insert return transform configurations', () => {
class TestMapper extends TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid insert return transform
insertReturnTransform: (_user) => {
return { noId: 1 };
},
});
new TestMapper(db, 'users', {
// @ts-expect-error - invalid insert return transform
insertReturnTransform: (user) => user,
});
});
ignore('detects invalid update transform configuration', () => {
class TestMapper extends TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update transform
updateTransform: (_user) => {
return { noId: 1 };
},
});
});
ignore('detects invalid update return transform configurations', () => __awaiter(void 0, void 0, void 0, function* () {
class TestMapper extends TableMapper {
}
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update return transform
updateReturnTransform: (_user) => {
return { noId: 1 };
},
});
new TestMapper(db, 'users', {
// @ts-expect-error - invalid update return transform
updateReturnTransform: (_user) => {
return { noId: 1 };
},
});
const testMapper = new TestMapper(db, 'users');
(yield testMapper
.update({ id: 1 })
// @ts-expect-error - ensure that return type is User
.getOne(new User(1, 'John', 'Doe', 'jdoe', 'jdoe@abc.def'))).name;
}));
it('dummy test', () => {

@@ -35,0 +102,0 @@ // gets test to run without error

@@ -16,3 +16,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { ignore } from './utils/test-utils';
import { ReturnedUser, UpdaterUser } from './utils/test-types';
import { ReturnedUser, UpdatingUser } from './utils/test-types';
let db;

@@ -301,3 +301,3 @@ let userMapperReturningDefault;

super(db, 'users', {
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -316,3 +316,3 @@ handle: source.handle,

.getAll([userRow1, userRow2, userRow3]);
const updaterUser1 = UpdaterUser.create(0, Object.assign({}, userObject1, { firstName: 'Suzanne' }));
const updatingUser1 = UpdatingUser.create(0, Object.assign({}, userObject1, { firstName: 'Suzanne' }));
const updateReturns = yield mapper

@@ -323,3 +323,3 @@ .update(({ or, cmpr }) => or([

]))
.getAll(updaterUser1);
.getAll(updatingUser1);
expect(updateReturns).toEqual([

@@ -369,3 +369,3 @@ { id: insertReturns[0].id },

super(db, 'users', {
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -386,3 +386,3 @@ handle: source.handle,

.update({ id: insertReturn.id })
.getAll(UpdaterUser.create(0, userObject1));
.getAll(UpdatingUser.create(0, userObject1));
expect(updateReturn).toEqual([

@@ -389,0 +389,0 @@ new ReturnedUser(insertReturn.id, userObject1.firstName, userObject1.lastName, userObject1.handle, userObject1.email),

@@ -12,3 +12,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { USERS, insertedUser1 } from './utils/test-objects';
import { UniformTableMapper } from '../mappers/UniformTableMapper';
import { UniformTableMapper } from '../mappers/uniform-table-mapper';
let db;

@@ -21,3 +21,3 @@ beforeAll(() => __awaiter(void 0, void 0, void 0, function* () {

it('inserts/updates/deletes a mapped object w/ default transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
class MappedUser {
constructor(id, name, handle, email) {

@@ -29,46 +29,69 @@ this.id = id;

}
getKey() {
return [this.id];
}
}
const userMapper = new UniformTableMapper(db, 'users', ['id']);
const userMapper = new UniformTableMapper(db, 'users', { isMappedObject: (obj) => obj instanceof MappedUser });
// test updating a non-existent user
const userWithID = new KeyedUser(1, USERS[0].name, USERS[0].handle, USERS[0].email);
const updateReturn1 = yield userMapper.updateTODO(userWithID);
const userWithID = new MappedUser(1, USERS[0].name, USERS[0].handle, USERS[0].email);
const updateReturn1 = yield userMapper.update({ id: 1 }).getOne(userWithID);
expect(updateReturn1).toEqual(null);
// test inserting a user with falsy id
const insertedUser1 = new KeyedUser(0, USERS[0].name, USERS[0].handle, USERS[0].email);
const insertedUser1 = new MappedUser(0, USERS[0].name, USERS[0].handle, USERS[0].email);
const insertReturn1 = (yield userMapper.insert().getOne(insertedUser1));
expect(insertReturn1).not.toBeNull();
expect(insertReturn1.id).toBeGreaterThan(0);
insertReturn1.name; // ensure 'name' is accessible
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser1).toEqual(insertReturn1);
const selectedUser1 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser1).toEqual(Object.assign(Object.assign({}, insertedUser1), { id: insertReturn1.id }));
// ensure 'id' is accessible
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.id).toEqual(insertReturn1.id);
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.name; // ensure 'name' is accessible
// test inserting a user with truthy id
const insertedUser2 = new KeyedUser(10, USERS[1].name, USERS[1].handle, USERS[1].email);
const insertedUser2 = new MappedUser(10, USERS[1].name, USERS[1].handle, USERS[1].email);
const insertReturn2 = (yield userMapper.insert().getOne(insertedUser2));
expect(insertReturn2).toEqual(insertedUser2);
const selectedUser2 = yield userMapper.selectByKey(insertReturn2.id);
insertReturn2 === null || insertReturn2 === void 0 ? void 0 : insertReturn2.name; // ensure 'name' is accessible
const selectedUser2 = yield userMapper
.select({ id: insertReturn2.id })
.getOne();
expect(selectedUser2).toEqual(insertedUser2);
// test updating a user, with returned object
const updaterUser = new KeyedUser(selectedUser1.id, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser3 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser3).toEqual(updateReturn);
const updatingUser = new MappedUser(selectedUser1.id, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper
.update({ id: updatingUser.id })
.getOne(updatingUser);
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.name; // ensure 'name' is accessible
expect(updateReturn).toEqual(updatingUser);
const selectedUser3 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser3).toEqual(updatingUser);
// test updating a user, without returned object
const updaterUser2 = new KeyedUser(selectedUser3.id, 'Freddy', selectedUser3.handle, selectedUser3.email);
const updateReturn2 = yield userMapper.updateNoReturns(updaterUser2);
const updatingUser2 = new MappedUser(selectedUser3.id, 'Freddy', selectedUser3.handle, selectedUser3.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser2.id })
.run(updatingUser2);
expect(updateReturn2).toBe(true);
const selectedUser4 = yield userMapper.selectByKey(insertReturn1.id);
expect(selectedUser4).toEqual(updaterUser2);
const selectedUser4 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser4).toEqual(updatingUser2);
// test updating multiple users returning select columns
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' });
expect(updateReturn3).toEqual([{ id: 1 }, { id: 10 }]);
updateReturn3[0].id; // ensure 'id' is accessible
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' });
expect(updateReturn4).toEqual({ id: 1 });
updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn1.id);
const deleted = yield userMapper.delete({ id: insertReturn1.id }).run();
expect(deleted).toEqual(true);
const selectedUser5 = yield userMapper.selectByKey(insertReturn1.id);
const selectedUser5 = yield userMapper
.select({ id: insertReturn1.id })
.getOne();
expect(selectedUser5).toBeNull();
}));
it('inserts/updates/deletes a mapped object class w/ all custom transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
class MappedUser {
constructor(serialNo, firstName, lastName, handle, email) {

@@ -81,7 +104,5 @@ this.serialNo = serialNo;

}
getKey() {
return [this.serialNo];
}
}
const userMapper = new UniformTableMapper(db, 'users', ['id'], {
const userMapper = new UniformTableMapper(db, 'users', {
isMappedObject: (obj) => obj instanceof MappedUser,
insertTransform: (user) => {

@@ -95,5 +116,8 @@ return {

insertReturnTransform: (user, returns) => {
return new KeyedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
return new MappedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
},
updaterTransform: (user) => {
updateTransform: (user) => {
if (!(user instanceof MappedUser)) {
return user;
}
return {

@@ -106,26 +130,41 @@ name: `${user.firstName} ${user.lastName}`,

updateReturnTransform: (user, _returns) => {
return new KeyedUser(user.serialNo, user.firstName, user.lastName, user.handle, user.email);
if (!(user instanceof MappedUser)) {
return _returns;
}
return new MappedUser(user.serialNo, user.firstName, user.lastName, user.handle, user.email);
},
selectTransform: (row) => {
const names = row.name.split(' ');
return new KeyedUser(row.id, names[0], names[1], row.handle, row.email);
return new MappedUser(row.id, names[0], names[1], row.handle, row.email);
},
});
// test updating a non-existent user
const updateReturn1 = yield userMapper.updateTODO(new KeyedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email));
const updateReturn1 = yield userMapper
.update({ id: 1 })
.getOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email));
expect(updateReturn1).toEqual(null);
// test inserting a user
const insertedUser = new KeyedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email);
const insertedUser = new MappedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email);
const insertReturn = (yield userMapper.insert().getOne(insertedUser));
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible
expect(insertReturn).not.toBeNull();
expect(insertReturn.serialNo).toBeGreaterThan(0);
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser1 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible
expect(selectedUser1).toEqual(insertReturn);
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.serialNo).toEqual(insertReturn.serialNo);
// test updating a user, with returned object
const updaterUser = new KeyedUser(selectedUser1.serialNo, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser2 = yield userMapper.selectByKey(insertReturn.serialNo);
const updatingUser = new MappedUser(selectedUser1.serialNo, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser.serialNo })
.getOne(updatingUser);
updateReturn2 === null || updateReturn2 === void 0 ? void 0 : updateReturn2.firstName; // ensure 'firstName' is accessible
expect(updateReturn2).toEqual(updatingUser);
const selectedUser2 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.firstName; // ensure 'firstName' is accessible
expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.serialNo).toEqual(selectedUser1.serialNo);

@@ -139,13 +178,25 @@ expect(selectedUser2 === null || selectedUser2 === void 0 ? void 0 : selectedUser2.handle).toEqual(selectedUser1.handle + '2');

});
updateColumnReturns[0].id; // ensure 'id' is accessible
expect(updateColumnReturns).toEqual([{ id: selectedUser1.serialNo }]);
const selectedUser4 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser4 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
expect(selectedUser4 === null || selectedUser4 === void 0 ? void 0 : selectedUser4.firstName).toEqual('Foo');
// test updating multiple users returning select columns
const updateReturn3 = yield userMapper.update().getAll({ name: 'Everyone' });
expect(updateReturn3).toEqual([{ id: 1 }]);
updateReturn3[0].id; // ensure 'id' is accessible
const updateReturn4 = yield userMapper.update().getOne({ name: 'Everyone' });
expect(updateReturn4).toEqual({ id: 1 });
updateReturn4 === null || updateReturn4 === void 0 ? void 0 : updateReturn4.id; // ensure 'id' is accessible
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn.serialNo);
const deleted = yield userMapper.delete({ id: insertReturn.serialNo }).run();
expect(deleted).toEqual(true);
const selectedUser3 = yield userMapper.selectByKey(insertReturn.serialNo);
const selectedUser3 = yield userMapper
.select({ id: insertReturn.serialNo })
.getOne();
expect(selectedUser3).toBeNull();
}));
it('inserts/updates/deletes a mapped object class w/ inferred update transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class KeyedUser {
it('inserts/updates/deletes a mapped object class w/ default update transforms', () => __awaiter(void 0, void 0, void 0, function* () {
class MappedUser {
constructor(id, firstName, lastName, handle, email) {

@@ -158,7 +209,5 @@ this.id = id;

}
getKey() {
return [this.id];
}
}
const userMapper = new UniformTableMapper(db, 'users', ['id'], {
const userMapper = new UniformTableMapper(db, 'users', {
isMappedObject: (obj) => obj instanceof MappedUser,
insertTransform: (user) => {

@@ -171,47 +220,57 @@ return {

},
updaterTransform: (user) => {
return {
name: `${user.firstName} ${user.lastName}`,
handle: user.handle,
email: user.email,
};
},
insertReturnTransform: (user, returns) => {
return new KeyedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
return new MappedUser(returns.id, user.firstName, user.lastName, user.handle, user.email);
},
selectTransform: (row) => {
const names = row.name.split(' ');
return new KeyedUser(row.id, names[0], names[1], row.handle, row.email);
return new MappedUser(row.id, names[0], names[1], row.handle, row.email);
},
});
// test updating a non-existent user
const updateReturn1 = yield userMapper.updateTODO(new KeyedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email));
const updateReturn1 = yield userMapper
.update({ id: 1 })
.getOne(new MappedUser(1, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email));
expect(updateReturn1).toEqual(null);
// test inserting a user
const insertedUser = new KeyedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email);
const insertedUser = new MappedUser(0, insertedUser1.firstName, insertedUser1.lastName, insertedUser1.handle, insertedUser1.email);
const insertReturn = (yield userMapper.insert().getOne(insertedUser));
insertReturn === null || insertReturn === void 0 ? void 0 : insertReturn.firstName; // ensure 'firstName' is accessible
expect(insertReturn).not.toBeNull();
expect(insertReturn.id).toBeGreaterThan(0);
// test getting a user by ID
const selectedUser1 = yield userMapper.selectByKey(insertReturn.id);
const selectedUser1 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.firstName; // ensure 'firstName' is accessible
expect(selectedUser1).toEqual(insertReturn);
expect(selectedUser1 === null || selectedUser1 === void 0 ? void 0 : selectedUser1.id).toEqual(insertReturn.id);
// test updating a user
const updaterUser = new KeyedUser(selectedUser1.id, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper.updateTODO(updaterUser);
expect(updateReturn).toEqual(updaterUser);
const selectedUser2 = yield userMapper.selectByKey(insertReturn.id);
expect(selectedUser2).toEqual(updateReturn);
const updatingUser = new MappedUser(selectedUser1.id, selectedUser1.firstName, 'Xana', selectedUser1.handle, selectedUser1.email);
const updateReturn = yield userMapper
.update({ id: updatingUser.id })
.getOne(updatingUser);
updateReturn === null || updateReturn === void 0 ? void 0 : updateReturn.firstName; // ensure 'firstName' is accessible
expect(updateReturn).toEqual(updatingUser);
const selectedUser2 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser2).toEqual(updatingUser);
// test updating a user, without returned object
const updaterUser2 = new KeyedUser(selectedUser2.id, 'Super', 'Man', selectedUser2.handle, selectedUser2.email);
const updateReturn2 = yield userMapper.updateNoReturns(updaterUser2);
const updatingUser2 = new MappedUser(selectedUser2.id, 'Super', 'Man', selectedUser2.handle, selectedUser2.email);
const updateReturn2 = yield userMapper
.update({ id: updatingUser2.id })
.run(updatingUser2);
expect(updateReturn2).toBe(true);
const selectedUser3 = yield userMapper.selectByKey(insertReturn.id);
expect(selectedUser3).toEqual(updaterUser2);
const selectedUser3 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser3).toEqual(updatingUser2);
// test deleting a user
const deleted = yield userMapper.deleteByKey(insertReturn.id);
const deleted = yield userMapper.delete({ id: insertReturn.id }).run();
expect(deleted).toEqual(true);
const selectedUser4 = yield userMapper.selectByKey(insertReturn.id);
const selectedUser4 = yield userMapper
.select({ id: insertReturn.id })
.getOne();
expect(selectedUser4).toBeNull();
}));
//# sourceMappingURL=UniformTableMapper.test.js.map
import { Insertable, Selectable } from 'kysely';
import { Users, Posts } from './test-tables';
import { InsertedUser, ReturnedUser, SelectedUser, UpdaterUser } from './test-types';
import { InsertedUser, ReturnedUser, SelectedUser, UpdatingUser } from './test-types';
export declare const USERS: Insertable<Users>[];

@@ -55,3 +55,3 @@ export declare const POSTS: Insertable<Posts>[];

};
updaterTransform: (source: UpdaterUser) => {
updateTransform: (source: UpdatingUser) => {
name: string;

@@ -62,5 +62,5 @@ handle: string;

insertReturnTransform: (source: InsertedUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
updateReturnTransform: (source: UpdaterUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
updateReturnTransform: (source: UpdatingUser, returns: Partial<Selectable<Users>>) => ReturnedUser;
returnColumns: ["id"];
};
//# sourceMappingURL=test-objects.d.ts.map

@@ -86,3 +86,3 @@ import { InsertedUser, ReturnedUser, SelectedUser, } from './test-types';

}),
updaterTransform: (source) => ({
updateTransform: (source) => ({
name: `${source.firstName} ${source.lastName}`,

@@ -89,0 +89,0 @@ handle: source.handle,

@@ -22,5 +22,5 @@ /**

}
export declare class UpdaterUser extends User {
readonly __type = "UpdaterUser";
static create(id: number, obj: VariableFieldsOf<UpdaterUser>): UpdaterUser;
export declare class UpdatingUser extends User {
readonly __type = "UpdatingUser";
static create(id: number, obj: VariableFieldsOf<UpdatingUser>): UpdatingUser;
}

@@ -27,0 +27,0 @@ export declare class ReturnedUser extends User {

@@ -34,9 +34,9 @@ /**

}
export class UpdaterUser extends User {
export class UpdatingUser extends User {
constructor() {
super(...arguments);
this.__type = 'UpdaterUser';
this.__type = 'UpdatingUser';
}
static create(id, obj) {
return new UpdaterUser(id, obj.firstName, obj.lastName, obj.handle, obj.email);
return new UpdatingUser(id, obj.firstName, obj.lastName, obj.handle, obj.email);
}

@@ -43,0 +43,0 @@ }

{
"name": "kysely-mapper",
"version": "0.2.1",
"version": "0.2.2",
"author": "Joseph T. Lapp <arachnojoe@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc