@betterinternship/schema 1.12.1 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.logAndHandleDBError = void 0;
4
- const db_1 = require("../db");
5
- const logAndHandleDBError = (error, description) => {
6
- const e = error;
7
- console.log(description);
8
- console.log("details:", e?.details);
9
- console.log("message:", e?.message);
10
- console.log("code:", e?.code);
11
- console.log(e?.stack);
12
- console.log("=================");
13
- return (0, db_1.handleDBError)(error, description);
14
- };
15
- exports.logAndHandleDBError = logAndHandleDBError;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logAndHandleDBError = void 0;
4
+ const db_1 = require("../db");
5
+ const logAndHandleDBError = (error, description) => {
6
+ const e = error;
7
+ console.log(description);
8
+ console.log("details:", e?.details);
9
+ console.log("message:", e?.message);
10
+ console.log("code:", e?.code);
11
+ console.log(e?.stack);
12
+ console.log("=================");
13
+ return (0, db_1.handleDBError)(error, description);
14
+ };
15
+ exports.logAndHandleDBError = logAndHandleDBError;
16
16
  //# sourceMappingURL=errors.js.map
@@ -1,20 +1,20 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./base"), exports);
18
- __exportStar(require("./factories"), exports);
19
- __exportStar(require("./paginator"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
18
+ __exportStar(require("./factories"), exports);
19
+ __exportStar(require("./paginator"), exports);
20
20
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import { Kysely } from "kysely";
2
- export type JsonColumnMap = Record<string, Set<string>>;
3
- export declare const loadJsonColumnMap: <DB>(db: Kysely<DB>) => Promise<JsonColumnMap>;
4
- export declare const jsonb: <T>(value: T) => import("kysely").RawBuilder<unknown>;
5
- export declare const wrapJsonColumns: <T extends Record<string, unknown>>(row: T, tableName: string, jsonCols: JsonColumnMap) => T;
1
+ import { Kysely } from "kysely";
2
+ export type JsonColumnMap = Record<string, Set<string>>;
3
+ export declare const loadJsonColumnMap: <DB>(db: Kysely<DB>) => Promise<JsonColumnMap>;
4
+ export declare const jsonb: <T>(value: T) => import("kysely").RawBuilder<unknown>;
5
+ export declare const wrapJsonColumns: <T extends Record<string, unknown>>(row: T, tableName: string, jsonCols: JsonColumnMap) => T;
@@ -1,44 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapJsonColumns = exports.jsonb = exports.loadJsonColumnMap = void 0;
4
- const kysely_1 = require("kysely");
5
- const cache = new WeakMap();
6
- const introspect = async (db) => {
7
- const tables = await db.introspection.getTables();
8
- const out = {};
9
- for (const table of tables) {
10
- const key = table.schema ? `${table.schema}.${table.name}` : table.name;
11
- out[key] = new Set(table.columns
12
- .filter((c) => c.dataType === "json" || c.dataType === "jsonb")
13
- .map((c) => c.name));
14
- }
15
- return out;
16
- };
17
- const loadJsonColumnMap = (db) => {
18
- let cached = cache.get(db);
19
- if (!cached) {
20
- cached = introspect(db);
21
- cached.catch(() => cache.delete(db));
22
- cache.set(db, cached);
23
- }
24
- return cached;
25
- };
26
- exports.loadJsonColumnMap = loadJsonColumnMap;
27
- const jsonb = (value) => {
28
- return (0, kysely_1.sql) `CAST(${JSON.stringify(value)} AS JSONB)`;
29
- };
30
- exports.jsonb = jsonb;
31
- const wrapJsonColumns = (row, tableName, jsonCols) => {
32
- const cols = jsonCols[tableName];
33
- if (!cols)
34
- return row;
35
- const out = { ...row };
36
- for (const [key, value] of Object.entries(out)) {
37
- if (!cols.has(key) || value === undefined)
38
- continue;
39
- out[key] = (0, exports.jsonb)(value);
40
- }
41
- return out;
42
- };
43
- exports.wrapJsonColumns = wrapJsonColumns;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapJsonColumns = exports.jsonb = exports.loadJsonColumnMap = void 0;
4
+ const kysely_1 = require("kysely");
5
+ const cache = new WeakMap();
6
+ const introspect = async (db) => {
7
+ const tables = await db.introspection.getTables();
8
+ const out = {};
9
+ for (const table of tables) {
10
+ const key = table.schema ? `${table.schema}.${table.name}` : table.name;
11
+ out[key] = new Set(table.columns
12
+ .filter((c) => c.dataType === "json" || c.dataType === "jsonb")
13
+ .map((c) => c.name));
14
+ }
15
+ return out;
16
+ };
17
+ const loadJsonColumnMap = (db) => {
18
+ let cached = cache.get(db);
19
+ if (!cached) {
20
+ cached = introspect(db);
21
+ cached.catch(() => cache.delete(db));
22
+ cache.set(db, cached);
23
+ }
24
+ return cached;
25
+ };
26
+ exports.loadJsonColumnMap = loadJsonColumnMap;
27
+ const jsonb = (value) => {
28
+ return (0, kysely_1.sql) `CAST(${JSON.stringify(value)} AS JSONB)`;
29
+ };
30
+ exports.jsonb = jsonb;
31
+ const wrapJsonColumns = (row, tableName, jsonCols) => {
32
+ const cols = jsonCols[tableName];
33
+ if (!cols)
34
+ return row;
35
+ const out = { ...row };
36
+ for (const [key, value] of Object.entries(out)) {
37
+ if (!cols.has(key) || value === undefined)
38
+ continue;
39
+ out[key] = (0, exports.jsonb)(value);
40
+ }
41
+ return out;
42
+ };
43
+ exports.wrapJsonColumns = wrapJsonColumns;
44
44
  //# sourceMappingURL=json-columns.js.map
@@ -1,4 +1,4 @@
1
- export interface PaginationOptions {
2
- limit?: number;
3
- offset?: number;
4
- }
1
+ export interface PaginationOptions {
2
+ limit?: number;
3
+ offset?: number;
4
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=paginator.js.map