@geekmidas/db 10.0.0-alpha.6 → 10.0.0-alpha.60

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.
Files changed (138) hide show
  1. package/README.md +17 -0
  2. package/dist/errors.cjs +72 -5
  3. package/dist/errors.cjs.map +1 -0
  4. package/dist/errors.d.cts +4 -6
  5. package/dist/errors.d.cts.map +1 -1
  6. package/dist/errors.d.mts +4 -6
  7. package/dist/errors.d.mts.map +1 -1
  8. package/dist/errors.mjs +68 -2
  9. package/dist/errors.mjs.map +1 -0
  10. package/dist/introspect/DataBrowser.cjs +117 -0
  11. package/dist/introspect/DataBrowser.cjs.map +1 -0
  12. package/dist/introspect/DataBrowser.d.cts +51 -0
  13. package/dist/introspect/DataBrowser.d.cts.map +1 -0
  14. package/dist/introspect/DataBrowser.d.mts +51 -0
  15. package/dist/introspect/DataBrowser.d.mts.map +1 -0
  16. package/dist/introspect/DataBrowser.mjs +116 -0
  17. package/dist/introspect/DataBrowser.mjs.map +1 -0
  18. package/dist/introspect/errors.cjs +48 -0
  19. package/dist/introspect/errors.cjs.map +1 -0
  20. package/dist/introspect/errors.d.cts +27 -0
  21. package/dist/introspect/errors.d.cts.map +1 -0
  22. package/dist/introspect/errors.d.mts +27 -0
  23. package/dist/introspect/errors.d.mts.map +1 -0
  24. package/dist/introspect/errors.mjs +45 -0
  25. package/dist/introspect/errors.mjs.map +1 -0
  26. package/dist/introspect/filtering.cjs +101 -0
  27. package/dist/introspect/filtering.cjs.map +1 -0
  28. package/dist/introspect/filtering.d.cts +29 -0
  29. package/dist/introspect/filtering.d.cts.map +1 -0
  30. package/dist/introspect/filtering.d.mts +29 -0
  31. package/dist/introspect/filtering.d.mts.map +1 -0
  32. package/dist/introspect/filtering.mjs +98 -0
  33. package/dist/introspect/filtering.mjs.map +1 -0
  34. package/dist/introspect/handler.cjs +159 -0
  35. package/dist/introspect/handler.cjs.map +1 -0
  36. package/dist/introspect/handler.d.cts +43 -0
  37. package/dist/introspect/handler.d.cts.map +1 -0
  38. package/dist/introspect/handler.d.mts +43 -0
  39. package/dist/introspect/handler.d.mts.map +1 -0
  40. package/dist/introspect/handler.mjs +158 -0
  41. package/dist/introspect/handler.mjs.map +1 -0
  42. package/dist/introspect/index.cjs +22 -0
  43. package/dist/introspect/index.d.cts +8 -0
  44. package/dist/introspect/index.d.mts +8 -0
  45. package/dist/introspect/index.mjs +8 -0
  46. package/dist/introspect/introspection.cjs +149 -0
  47. package/dist/introspect/introspection.cjs.map +1 -0
  48. package/dist/introspect/introspection.d.cts +25 -0
  49. package/dist/introspect/introspection.d.cts.map +1 -0
  50. package/dist/introspect/introspection.d.mts +25 -0
  51. package/dist/introspect/introspection.d.mts.map +1 -0
  52. package/dist/introspect/introspection.mjs +146 -0
  53. package/dist/introspect/introspection.mjs.map +1 -0
  54. package/dist/introspect/types.cjs +24 -0
  55. package/dist/introspect/types.cjs.map +1 -0
  56. package/dist/introspect/types.d.cts +113 -0
  57. package/dist/introspect/types.d.cts.map +1 -0
  58. package/dist/introspect/types.d.mts +113 -0
  59. package/dist/introspect/types.d.mts.map +1 -0
  60. package/dist/introspect/types.mjs +23 -0
  61. package/dist/introspect/types.mjs.map +1 -0
  62. package/dist/kysely/pagination.cjs +8 -9
  63. package/dist/kysely/pagination.cjs.map +1 -1
  64. package/dist/kysely/pagination.d.cts +4 -14
  65. package/dist/kysely/pagination.d.cts.map +1 -1
  66. package/dist/kysely/pagination.d.mts +4 -14
  67. package/dist/kysely/pagination.d.mts.map +1 -1
  68. package/dist/kysely/pagination.mjs +7 -10
  69. package/dist/kysely/pagination.mjs.map +1 -1
  70. package/dist/kysely.cjs +11 -2
  71. package/dist/kysely.cjs.map +1 -0
  72. package/dist/kysely.d.cts +9 -2
  73. package/dist/kysely.d.cts.map +1 -0
  74. package/dist/kysely.d.mts +9 -2
  75. package/dist/kysely.d.mts.map +1 -0
  76. package/dist/kysely.mjs +10 -2
  77. package/dist/kysely.mjs.map +1 -0
  78. package/dist/objection/pagination.cjs +7 -7
  79. package/dist/objection/pagination.cjs.map +1 -1
  80. package/dist/objection/pagination.d.cts +4 -14
  81. package/dist/objection/pagination.d.cts.map +1 -1
  82. package/dist/objection/pagination.d.mts +4 -14
  83. package/dist/objection/pagination.d.mts.map +1 -1
  84. package/dist/objection/pagination.mjs +6 -8
  85. package/dist/objection/pagination.mjs.map +1 -1
  86. package/dist/{pagination-kv-KWS-7.d.mts → pagination-CrU89125.d.cts} +14 -4
  87. package/dist/pagination-CrU89125.d.cts.map +1 -0
  88. package/dist/{pagination-BAFX7C1I.d.cts → pagination-CrU89125.d.mts} +14 -4
  89. package/dist/pagination-CrU89125.d.mts.map +1 -0
  90. package/dist/pagination.cjs +55 -4
  91. package/dist/pagination.cjs.map +1 -0
  92. package/dist/pagination.d.cts +2 -2
  93. package/dist/pagination.d.mts +2 -2
  94. package/dist/pagination.mjs +51 -2
  95. package/dist/pagination.mjs.map +1 -0
  96. package/dist/pg/roles.cjs +26 -3
  97. package/dist/pg/roles.cjs.map +1 -1
  98. package/dist/pg/roles.d.cts +16 -8
  99. package/dist/pg/roles.d.cts.map +1 -1
  100. package/dist/pg/roles.d.mts +16 -8
  101. package/dist/pg/roles.d.mts.map +1 -1
  102. package/dist/pg/roles.mjs +25 -2
  103. package/dist/pg/roles.mjs.map +1 -1
  104. package/dist/pg/url.cjs +18 -3
  105. package/dist/pg/url.cjs.map +1 -1
  106. package/dist/pg/url.d.cts +2 -4
  107. package/dist/pg/url.d.cts.map +1 -1
  108. package/dist/pg/url.d.mts +2 -4
  109. package/dist/pg/url.d.mts.map +1 -1
  110. package/dist/pg/url.mjs +17 -3
  111. package/dist/pg/url.mjs.map +1 -1
  112. package/dist/rls.cjs +5 -29
  113. package/dist/rls.cjs.map +1 -1
  114. package/dist/rls.d.cts +6 -10
  115. package/dist/rls.d.cts.map +1 -1
  116. package/dist/rls.d.mts +6 -10
  117. package/dist/rls.d.mts.map +1 -1
  118. package/dist/rls.mjs +3 -5
  119. package/dist/rls.mjs.map +1 -1
  120. package/package.json +12 -2
  121. package/dist/errors-CfFCan-X.mjs +0 -69
  122. package/dist/errors-CfFCan-X.mjs.map +0 -1
  123. package/dist/errors-Cs5jlAv-.cjs +0 -93
  124. package/dist/errors-Cs5jlAv-.cjs.map +0 -1
  125. package/dist/kysely-BAedYsvn.d.mts +0 -13
  126. package/dist/kysely-BAedYsvn.d.mts.map +0 -1
  127. package/dist/kysely-Bo_Zg-D3.mjs +0 -11
  128. package/dist/kysely-Bo_Zg-D3.mjs.map +0 -1
  129. package/dist/kysely-D3eeuId4.d.cts +0 -13
  130. package/dist/kysely-D3eeuId4.d.cts.map +0 -1
  131. package/dist/kysely-LWvS2ekY.cjs +0 -17
  132. package/dist/kysely-LWvS2ekY.cjs.map +0 -1
  133. package/dist/pagination-BAFX7C1I.d.cts.map +0 -1
  134. package/dist/pagination-Bu1dqOy0.cjs +0 -55
  135. package/dist/pagination-Bu1dqOy0.cjs.map +0 -1
  136. package/dist/pagination-CQ8QHXaL.mjs +0 -37
  137. package/dist/pagination-CQ8QHXaL.mjs.map +0 -1
  138. package/dist/pagination-kv-KWS-7.d.mts.map +0 -1
package/dist/rls.cjs CHANGED
@@ -1,29 +1,6 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- const require_kysely = require('./kysely-LWvS2ekY.cjs');
25
- const kysely = __toESM(require("kysely"));
26
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_kysely = require("./kysely.cjs");
3
+ let kysely = require("kysely");
27
4
  //#region src/rls.ts
28
5
  /**
29
6
  * Execute a callback within a transaction with RLS context variables set.
@@ -55,8 +32,7 @@ async function withRlsContext(db, context, callback, options) {
55
32
  for (const [key, value] of Object.entries(context)) {
56
33
  if (value === null || value === void 0) continue;
57
34
  const settingName = `${prefix}.${key}`;
58
- const settingValue = String(value);
59
- await kysely.sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(trx);
35
+ await kysely.sql`SELECT set_config(${settingName}, ${String(value)}, true)`.execute(trx);
60
36
  }
61
37
  return callback(trx);
62
38
  }, options?.settings);
@@ -65,8 +41,8 @@ async function withRlsContext(db, context, callback, options) {
65
41
  * Bypass marker symbol for explicitly skipping RLS context.
66
42
  */
67
43
  const RLS_BYPASS = Symbol.for("geekmidas.rls.bypass");
68
-
69
44
  //#endregion
70
45
  exports.RLS_BYPASS = RLS_BYPASS;
71
46
  exports.withRlsContext = withRlsContext;
47
+
72
48
  //# sourceMappingURL=rls.cjs.map
package/dist/rls.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rls.cjs","names":["db: DatabaseConnection<DB>","context: RlsContext","callback: (trx: Transaction<DB>) => Promise<T>","options?: WithRlsContextOptions"],"sources":["../src/rls.ts"],"sourcesContent":["import type { Transaction } from 'kysely';\nimport { sql } from 'kysely';\nimport {\n\ttype DatabaseConnection,\n\ttype TransactionSettings,\n\twithTransaction,\n} from './kysely';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n\t[key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Options for withRlsContext function.\n */\nexport interface WithRlsContextOptions {\n\t/** Prefix for PostgreSQL session variables (default: 'app') */\n\tprefix?: string;\n\t/** Transaction settings (isolation level) */\n\tsettings?: TransactionSettings;\n}\n\n/**\n * Execute a callback within a transaction with RLS context variables set.\n *\n * Sets PostgreSQL session variables using `SET LOCAL` which scopes them to the\n * current transaction. Variables are automatically cleared when the transaction\n * ends (commit or rollback).\n *\n * @example\n * ```ts\n * await withRlsContext(\n * db,\n * { user_id: session.userId, tenant_id: session.tenantId },\n * async (trx) => {\n * // RLS policies can now use current_setting('app.user_id')\n * return trx.selectFrom('orders').selectAll().execute();\n * }\n * );\n * ```\n *\n * @param db - Database connection (Kysely, Transaction, or ControlledTransaction)\n * @param context - Key-value pairs to set as session variables\n * @param callback - Function to execute within the RLS context\n * @param options - Optional prefix and transaction settings\n */\nexport async function withRlsContext<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcontext: RlsContext,\n\tcallback: (trx: Transaction<DB>) => Promise<T>,\n\toptions?: WithRlsContextOptions,\n): Promise<T> {\n\tconst prefix = options?.prefix ?? 'app';\n\n\treturn withTransaction(\n\t\tdb,\n\t\tasync (trx) => {\n\t\t\t// Set each context variable using SET LOCAL (scoped to transaction)\n\t\t\tfor (const [key, value] of Object.entries(context)) {\n\t\t\t\tif (value === null || value === undefined) continue;\n\n\t\t\t\tconst settingName = `${prefix}.${key}`;\n\t\t\t\tconst settingValue = String(value);\n\n\t\t\t\t// Use raw SQL for SET LOCAL with proper escaping\n\t\t\t\t// The setting name is an identifier, value is a string literal\n\t\t\t\tawait sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(\n\t\t\t\t\ttrx,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn callback(trx);\n\t\t},\n\t\toptions?.settings,\n\t);\n}\n\n/**\n * Bypass marker symbol for explicitly skipping RLS context.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,eAAsB,eACrBA,IACAC,SACAC,UACAC,SACa;CACb,MAAM,SAAS,SAAS,UAAU;AAElC,QAAO,+BACN,IACA,OAAO,QAAQ;AAEd,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,EAAE;AACnD,OAAI,UAAU,QAAQ,iBAAqB;GAE3C,MAAM,eAAe,EAAE,OAAO,GAAG,IAAI;GACrC,MAAM,eAAe,OAAO,MAAM;AAIlC,SAAM,WAAI,oBAAoB,YAAY,IAAI,aAAa,SAAS,QACnE,IACA;EACD;AAED,SAAO,SAAS,IAAI;CACpB,GACD,SAAS,SACT;AACD;;;;AAKD,MAAa,aAAa,OAAO,IAAI,uBAAuB"}
1
+ {"version":3,"file":"rls.cjs","names":["withTransaction"],"sources":["../src/rls.ts"],"sourcesContent":["import type { Transaction } from 'kysely';\nimport { sql } from 'kysely';\nimport {\n\ttype DatabaseConnection,\n\ttype TransactionSettings,\n\twithTransaction,\n} from './kysely';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n\t[key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Options for withRlsContext function.\n */\nexport interface WithRlsContextOptions {\n\t/** Prefix for PostgreSQL session variables (default: 'app') */\n\tprefix?: string;\n\t/** Transaction settings (isolation level) */\n\tsettings?: TransactionSettings;\n}\n\n/**\n * Execute a callback within a transaction with RLS context variables set.\n *\n * Sets PostgreSQL session variables using `SET LOCAL` which scopes them to the\n * current transaction. Variables are automatically cleared when the transaction\n * ends (commit or rollback).\n *\n * @example\n * ```ts\n * await withRlsContext(\n * db,\n * { user_id: session.userId, tenant_id: session.tenantId },\n * async (trx) => {\n * // RLS policies can now use current_setting('app.user_id')\n * return trx.selectFrom('orders').selectAll().execute();\n * }\n * );\n * ```\n *\n * @param db - Database connection (Kysely, Transaction, or ControlledTransaction)\n * @param context - Key-value pairs to set as session variables\n * @param callback - Function to execute within the RLS context\n * @param options - Optional prefix and transaction settings\n */\nexport async function withRlsContext<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcontext: RlsContext,\n\tcallback: (trx: Transaction<DB>) => Promise<T>,\n\toptions?: WithRlsContextOptions,\n): Promise<T> {\n\tconst prefix = options?.prefix ?? 'app';\n\n\treturn withTransaction(\n\t\tdb,\n\t\tasync (trx) => {\n\t\t\t// Set each context variable using SET LOCAL (scoped to transaction)\n\t\t\tfor (const [key, value] of Object.entries(context)) {\n\t\t\t\tif (value === null || value === undefined) continue;\n\n\t\t\t\tconst settingName = `${prefix}.${key}`;\n\t\t\t\tconst settingValue = String(value);\n\n\t\t\t\t// Use raw SQL for SET LOCAL with proper escaping\n\t\t\t\t// The setting name is an identifier, value is a string literal\n\t\t\t\tawait sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(\n\t\t\t\t\ttrx,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn callback(trx);\n\t\t},\n\t\toptions?.settings,\n\t);\n}\n\n/**\n * Bypass marker symbol for explicitly skipping RLS context.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,eAAsB,eACrB,IACA,SACA,UACA,SACa;CACb,MAAM,SAAS,SAAS,UAAU;CAElC,OAAOA,eAAAA,gBACN,IACA,OAAO,QAAQ;EAEd,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;GACnD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW;GAE3C,MAAM,cAAc,GAAG,OAAO,GAAG;GAKjC,MAAM,OAAA,GAAG,qBAAqB,YAAY,IAJrB,OAAO,KAI6B,EAAE,SAAS,QACnE,GACD;EACD;EAEA,OAAO,SAAS,GAAG;CACpB,GACA,SAAS,QACV;AACD;;;;AAKA,MAAa,aAAa,OAAO,IAAI,sBAAsB"}
package/dist/rls.d.cts CHANGED
@@ -1,19 +1,17 @@
1
- import { DatabaseConnection, TransactionSettings } from "./kysely-D3eeuId4.cjs";
1
+ import { DatabaseConnection, TransactionSettings } from "./kysely.cjs";
2
2
  import { Transaction } from "kysely";
3
-
4
3
  //#region src/rls.d.ts
5
-
6
4
  /**
7
5
  * RLS context - key-value pairs to set as PostgreSQL session variables.
8
6
  * Keys become `prefix.key` (e.g., `app.user_id`).
9
7
  */
10
- interface RlsContext {
8
+ export interface RlsContext {
11
9
  [key: string]: string | number | boolean | null | undefined;
12
10
  }
13
11
  /**
14
12
  * Options for withRlsContext function.
15
13
  */
16
- interface WithRlsContextOptions {
14
+ export interface WithRlsContextOptions {
17
15
  /** Prefix for PostgreSQL session variables (default: 'app') */
18
16
  prefix?: string;
19
17
  /** Transaction settings (isolation level) */
@@ -43,16 +41,14 @@ interface WithRlsContextOptions {
43
41
  * @param callback - Function to execute within the RLS context
44
42
  * @param options - Optional prefix and transaction settings
45
43
  */
46
- declare function withRlsContext<DB, T>(db: DatabaseConnection<DB>, context: RlsContext, callback: (trx: Transaction<DB>) => Promise<T>, options?: WithRlsContextOptions): Promise<T>;
44
+ export declare function withRlsContext<DB, T>(db: DatabaseConnection<DB>, context: RlsContext, callback: (trx: Transaction<DB>) => Promise<T>, options?: WithRlsContextOptions): Promise<T>;
47
45
  /**
48
46
  * Bypass marker symbol for explicitly skipping RLS context.
49
47
  */
50
- declare const RLS_BYPASS: unique symbol;
48
+ export declare const RLS_BYPASS: unique symbol;
51
49
  /**
52
50
  * Type for RLS bypass marker.
53
51
  */
54
- type RlsBypass = typeof RLS_BYPASS;
55
- //# sourceMappingURL=rls.d.ts.map
52
+ export type RlsBypass = typeof RLS_BYPASS;
56
53
  //#endregion
57
- export { RLS_BYPASS, RlsBypass, RlsContext, WithRlsContextOptions, withRlsContext };
58
54
  //# sourceMappingURL=rls.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rls.d.cts","names":[],"sources":["../src/rls.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;AAOA;AA+BsB,UAtCL,UAAA,CAsCmB;EAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,IAAA,GAAA,SAAA;;;;;AAGnB,UAlCA,qBAAA,CAkCA;EAAW;EAAkB,MAAT,CAAA,EAAA,MAAA;EAAO;EACZ,QACrB,CAAA,EAhCC,mBAgCD;;AAAD;AA6BV;AAKA;;;;;;;;;;;;;;;;;;;;;;iBAvCsB,0BACjB,mBAAmB,cACd,4BACO,YAAY,QAAQ,QAAQ,cAClC,wBACR,QAAQ;;;;cA6BE;;;;KAKD,SAAA,UAAmB"}
1
+ {"version":3,"file":"rls.d.cts","names":[],"sources":["../src/rls.ts"],"mappings":";;;;;;;iBAYiB;GACf;;;;;iBAMe;;EAEhB;;EAEA,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BU,eAAe,IAAI,GACxC,IAAI,mBAAmB,KACvB,SAAS,YACT,WAAW,KAAK,YAAY,QAAQ,QAAQ,IAC5C,UAAU,wBACR,QAAQ;;;;qBA6BE;;;;YAKD,mBAAmB"}
package/dist/rls.d.mts CHANGED
@@ -1,19 +1,17 @@
1
- import { DatabaseConnection, TransactionSettings } from "./kysely-BAedYsvn.mjs";
1
+ import { DatabaseConnection, TransactionSettings } from "./kysely.mjs";
2
2
  import { Transaction } from "kysely";
3
-
4
3
  //#region src/rls.d.ts
5
-
6
4
  /**
7
5
  * RLS context - key-value pairs to set as PostgreSQL session variables.
8
6
  * Keys become `prefix.key` (e.g., `app.user_id`).
9
7
  */
10
- interface RlsContext {
8
+ export interface RlsContext {
11
9
  [key: string]: string | number | boolean | null | undefined;
12
10
  }
13
11
  /**
14
12
  * Options for withRlsContext function.
15
13
  */
16
- interface WithRlsContextOptions {
14
+ export interface WithRlsContextOptions {
17
15
  /** Prefix for PostgreSQL session variables (default: 'app') */
18
16
  prefix?: string;
19
17
  /** Transaction settings (isolation level) */
@@ -43,16 +41,14 @@ interface WithRlsContextOptions {
43
41
  * @param callback - Function to execute within the RLS context
44
42
  * @param options - Optional prefix and transaction settings
45
43
  */
46
- declare function withRlsContext<DB, T>(db: DatabaseConnection<DB>, context: RlsContext, callback: (trx: Transaction<DB>) => Promise<T>, options?: WithRlsContextOptions): Promise<T>;
44
+ export declare function withRlsContext<DB, T>(db: DatabaseConnection<DB>, context: RlsContext, callback: (trx: Transaction<DB>) => Promise<T>, options?: WithRlsContextOptions): Promise<T>;
47
45
  /**
48
46
  * Bypass marker symbol for explicitly skipping RLS context.
49
47
  */
50
- declare const RLS_BYPASS: unique symbol;
48
+ export declare const RLS_BYPASS: unique symbol;
51
49
  /**
52
50
  * Type for RLS bypass marker.
53
51
  */
54
- type RlsBypass = typeof RLS_BYPASS;
55
- //# sourceMappingURL=rls.d.ts.map
52
+ export type RlsBypass = typeof RLS_BYPASS;
56
53
  //#endregion
57
- export { RLS_BYPASS, RlsBypass, RlsContext, WithRlsContextOptions, withRlsContext };
58
54
  //# sourceMappingURL=rls.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rls.d.mts","names":[],"sources":["../src/rls.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;AAOA;AA+BsB,UAtCL,UAAA,CAsCmB;EAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,IAAA,GAAA,SAAA;;;;;AAGnB,UAlCA,qBAAA,CAkCA;EAAW;EAAkB,MAAT,CAAA,EAAA,MAAA;EAAO;EACZ,QACrB,CAAA,EAhCC,mBAgCD;;AAAD;AA6BV;AAKA;;;;;;;;;;;;;;;;;;;;;;iBAvCsB,0BACjB,mBAAmB,cACd,4BACO,YAAY,QAAQ,QAAQ,cAClC,wBACR,QAAQ;;;;cA6BE;;;;KAKD,SAAA,UAAmB"}
1
+ {"version":3,"file":"rls.d.mts","names":[],"sources":["../src/rls.ts"],"mappings":";;;;;;;iBAYiB;GACf;;;;;iBAMe;;EAEhB;;EAEA,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;wBA2BU,eAAe,IAAI,GACxC,IAAI,mBAAmB,KACvB,SAAS,YACT,WAAW,KAAK,YAAY,QAAQ,QAAQ,IAC5C,UAAU,wBACR,QAAQ;;;;qBA6BE;;;;YAKD,mBAAmB"}
package/dist/rls.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { withTransaction } from "./kysely-Bo_Zg-D3.mjs";
1
+ import { withTransaction } from "./kysely.mjs";
2
2
  import { sql } from "kysely";
3
-
4
3
  //#region src/rls.ts
5
4
  /**
6
5
  * Execute a callback within a transaction with RLS context variables set.
@@ -32,8 +31,7 @@ async function withRlsContext(db, context, callback, options) {
32
31
  for (const [key, value] of Object.entries(context)) {
33
32
  if (value === null || value === void 0) continue;
34
33
  const settingName = `${prefix}.${key}`;
35
- const settingValue = String(value);
36
- await sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(trx);
34
+ await sql`SELECT set_config(${settingName}, ${String(value)}, true)`.execute(trx);
37
35
  }
38
36
  return callback(trx);
39
37
  }, options?.settings);
@@ -42,7 +40,7 @@ async function withRlsContext(db, context, callback, options) {
42
40
  * Bypass marker symbol for explicitly skipping RLS context.
43
41
  */
44
42
  const RLS_BYPASS = Symbol.for("geekmidas.rls.bypass");
45
-
46
43
  //#endregion
47
44
  export { RLS_BYPASS, withRlsContext };
45
+
48
46
  //# sourceMappingURL=rls.mjs.map
package/dist/rls.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rls.mjs","names":["db: DatabaseConnection<DB>","context: RlsContext","callback: (trx: Transaction<DB>) => Promise<T>","options?: WithRlsContextOptions"],"sources":["../src/rls.ts"],"sourcesContent":["import type { Transaction } from 'kysely';\nimport { sql } from 'kysely';\nimport {\n\ttype DatabaseConnection,\n\ttype TransactionSettings,\n\twithTransaction,\n} from './kysely';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n\t[key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Options for withRlsContext function.\n */\nexport interface WithRlsContextOptions {\n\t/** Prefix for PostgreSQL session variables (default: 'app') */\n\tprefix?: string;\n\t/** Transaction settings (isolation level) */\n\tsettings?: TransactionSettings;\n}\n\n/**\n * Execute a callback within a transaction with RLS context variables set.\n *\n * Sets PostgreSQL session variables using `SET LOCAL` which scopes them to the\n * current transaction. Variables are automatically cleared when the transaction\n * ends (commit or rollback).\n *\n * @example\n * ```ts\n * await withRlsContext(\n * db,\n * { user_id: session.userId, tenant_id: session.tenantId },\n * async (trx) => {\n * // RLS policies can now use current_setting('app.user_id')\n * return trx.selectFrom('orders').selectAll().execute();\n * }\n * );\n * ```\n *\n * @param db - Database connection (Kysely, Transaction, or ControlledTransaction)\n * @param context - Key-value pairs to set as session variables\n * @param callback - Function to execute within the RLS context\n * @param options - Optional prefix and transaction settings\n */\nexport async function withRlsContext<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcontext: RlsContext,\n\tcallback: (trx: Transaction<DB>) => Promise<T>,\n\toptions?: WithRlsContextOptions,\n): Promise<T> {\n\tconst prefix = options?.prefix ?? 'app';\n\n\treturn withTransaction(\n\t\tdb,\n\t\tasync (trx) => {\n\t\t\t// Set each context variable using SET LOCAL (scoped to transaction)\n\t\t\tfor (const [key, value] of Object.entries(context)) {\n\t\t\t\tif (value === null || value === undefined) continue;\n\n\t\t\t\tconst settingName = `${prefix}.${key}`;\n\t\t\t\tconst settingValue = String(value);\n\n\t\t\t\t// Use raw SQL for SET LOCAL with proper escaping\n\t\t\t\t// The setting name is an identifier, value is a string literal\n\t\t\t\tawait sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(\n\t\t\t\t\ttrx,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn callback(trx);\n\t\t},\n\t\toptions?.settings,\n\t);\n}\n\n/**\n * Bypass marker symbol for explicitly skipping RLS context.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,eAAsB,eACrBA,IACAC,SACAC,UACAC,SACa;CACb,MAAM,SAAS,SAAS,UAAU;AAElC,QAAO,gBACN,IACA,OAAO,QAAQ;AAEd,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,EAAE;AACnD,OAAI,UAAU,QAAQ,iBAAqB;GAE3C,MAAM,eAAe,EAAE,OAAO,GAAG,IAAI;GACrC,MAAM,eAAe,OAAO,MAAM;AAIlC,SAAM,IAAI,oBAAoB,YAAY,IAAI,aAAa,SAAS,QACnE,IACA;EACD;AAED,SAAO,SAAS,IAAI;CACpB,GACD,SAAS,SACT;AACD;;;;AAKD,MAAa,aAAa,OAAO,IAAI,uBAAuB"}
1
+ {"version":3,"file":"rls.mjs","names":[],"sources":["../src/rls.ts"],"sourcesContent":["import type { Transaction } from 'kysely';\nimport { sql } from 'kysely';\nimport {\n\ttype DatabaseConnection,\n\ttype TransactionSettings,\n\twithTransaction,\n} from './kysely';\n\n/**\n * RLS context - key-value pairs to set as PostgreSQL session variables.\n * Keys become `prefix.key` (e.g., `app.user_id`).\n */\nexport interface RlsContext {\n\t[key: string]: string | number | boolean | null | undefined;\n}\n\n/**\n * Options for withRlsContext function.\n */\nexport interface WithRlsContextOptions {\n\t/** Prefix for PostgreSQL session variables (default: 'app') */\n\tprefix?: string;\n\t/** Transaction settings (isolation level) */\n\tsettings?: TransactionSettings;\n}\n\n/**\n * Execute a callback within a transaction with RLS context variables set.\n *\n * Sets PostgreSQL session variables using `SET LOCAL` which scopes them to the\n * current transaction. Variables are automatically cleared when the transaction\n * ends (commit or rollback).\n *\n * @example\n * ```ts\n * await withRlsContext(\n * db,\n * { user_id: session.userId, tenant_id: session.tenantId },\n * async (trx) => {\n * // RLS policies can now use current_setting('app.user_id')\n * return trx.selectFrom('orders').selectAll().execute();\n * }\n * );\n * ```\n *\n * @param db - Database connection (Kysely, Transaction, or ControlledTransaction)\n * @param context - Key-value pairs to set as session variables\n * @param callback - Function to execute within the RLS context\n * @param options - Optional prefix and transaction settings\n */\nexport async function withRlsContext<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcontext: RlsContext,\n\tcallback: (trx: Transaction<DB>) => Promise<T>,\n\toptions?: WithRlsContextOptions,\n): Promise<T> {\n\tconst prefix = options?.prefix ?? 'app';\n\n\treturn withTransaction(\n\t\tdb,\n\t\tasync (trx) => {\n\t\t\t// Set each context variable using SET LOCAL (scoped to transaction)\n\t\t\tfor (const [key, value] of Object.entries(context)) {\n\t\t\t\tif (value === null || value === undefined) continue;\n\n\t\t\t\tconst settingName = `${prefix}.${key}`;\n\t\t\t\tconst settingValue = String(value);\n\n\t\t\t\t// Use raw SQL for SET LOCAL with proper escaping\n\t\t\t\t// The setting name is an identifier, value is a string literal\n\t\t\t\tawait sql`SELECT set_config(${settingName}, ${settingValue}, true)`.execute(\n\t\t\t\t\ttrx,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn callback(trx);\n\t\t},\n\t\toptions?.settings,\n\t);\n}\n\n/**\n * Bypass marker symbol for explicitly skipping RLS context.\n */\nexport const RLS_BYPASS = Symbol.for('geekmidas.rls.bypass');\n\n/**\n * Type for RLS bypass marker.\n */\nexport type RlsBypass = typeof RLS_BYPASS;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,eAAsB,eACrB,IACA,SACA,UACA,SACa;CACb,MAAM,SAAS,SAAS,UAAU;CAElC,OAAO,gBACN,IACA,OAAO,QAAQ;EAEd,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;GACnD,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW;GAE3C,MAAM,cAAc,GAAG,OAAO,GAAG;GAKjC,MAAM,GAAG,qBAAqB,YAAY,IAJrB,OAAO,KAI6B,EAAE,SAAS,QACnE,GACD;EACD;EAEA,OAAO,SAAS,GAAG;CACpB,GACA,SAAS,QACV;AACD;;;;AAKA,MAAa,aAAa,OAAO,IAAI,sBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/db",
3
- "version": "10.0.0-alpha.6",
3
+ "version": "10.0.0-alpha.60",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -83,6 +83,16 @@
83
83
  "types": "./dist/errors.d.cts",
84
84
  "default": "./dist/errors.cjs"
85
85
  }
86
+ },
87
+ "./introspect": {
88
+ "import": {
89
+ "types": "./dist/introspect/index.d.mts",
90
+ "default": "./dist/introspect/index.mjs"
91
+ },
92
+ "require": {
93
+ "types": "./dist/introspect/index.d.cts",
94
+ "default": "./dist/introspect/index.cjs"
95
+ }
86
96
  }
87
97
  },
88
98
  "files": [
@@ -108,7 +118,7 @@
108
118
  "knex": ">=3.3.0",
109
119
  "objection": ">=3.1.5",
110
120
  "db-errors": "~0.2.3",
111
- "vitest": "~3.2.4"
121
+ "vitest": "~5.0.2"
112
122
  },
113
123
  "scripts": {
114
124
  "ts": "tsc --noEmit --skipLibCheck src/**/*.ts"
@@ -1,69 +0,0 @@
1
- //#region src/errors.ts
2
- /**
3
- * Database URL errors and redaction — engine-neutral.
4
- *
5
- * Nothing here is Postgres-specific: every engine addresses itself as a URL
6
- * carrying a password, and "must name a host" holds for all of them. The parts
7
- * that differ — libpq's `options=-c search_path=…`, which no other engine
8
- * accepts — live under the driver they belong to.
9
- *
10
- * Messages state the rule, which is constant; the offending value is a field.
11
- * An interpolated message cannot be matched on and carries user input into
12
- * every log line that touches it.
13
- */
14
- /**
15
- * Replace the password in a connection string with `***`.
16
- *
17
- * A connection string is a secret, and the places it is most likely to be
18
- * written down — a log line, an error, a crash report shipped to a third party
19
- * — are the places nobody is reading carefully. This exists so that redacting
20
- * is the easy thing to do at each of them.
21
- *
22
- * Safe on input that is not a URL: it returns a constant rather than throwing,
23
- * because this runs on paths that must not fail. Anything unparseable is
24
- * treated as potentially secret and withheld entirely rather than echoed.
25
- */
26
- function redactDatabaseUrl(url) {
27
- try {
28
- const parsed = new URL(url);
29
- if (!parsed.password) return url;
30
- parsed.password = "***";
31
- return parsed.toString();
32
- } catch {
33
- return "<unparseable url>";
34
- }
35
- }
36
- /**
37
- * Base for an address that cannot become a connection string.
38
- *
39
- * Deliberately carries no URL field: these are thrown while *composing* one, so
40
- * there is no URL yet — only the parts, which include the password.
41
- */
42
- var DatabaseAddressError = class extends Error {
43
- constructor(message) {
44
- super(message);
45
- this.name = new.target.name;
46
- }
47
- };
48
- /** An address with no host to connect to. */
49
- var MissingDatabaseHost = class extends DatabaseAddressError {
50
- constructor() {
51
- super("A database address must name a host");
52
- }
53
- };
54
- /**
55
- * An address with no database name.
56
- *
57
- * Postgres silently falls back to the connecting role's name, so the app
58
- * connects successfully to the wrong database and fails later with confusing
59
- * "relation does not exist" errors. Rejecting it here is much cheaper.
60
- */
61
- var MissingDatabaseName = class extends DatabaseAddressError {
62
- constructor() {
63
- super("A database address must name a database");
64
- }
65
- };
66
-
67
- //#endregion
68
- export { DatabaseAddressError, MissingDatabaseHost, MissingDatabaseName, redactDatabaseUrl };
69
- //# sourceMappingURL=errors-CfFCan-X.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-CfFCan-X.mjs","names":["url: string","message: string"],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Database URL errors and redaction — engine-neutral.\n *\n * Nothing here is Postgres-specific: every engine addresses itself as a URL\n * carrying a password, and \"must name a host\" holds for all of them. The parts\n * that differ — libpq's `options=-c search_path=…`, which no other engine\n * accepts — live under the driver they belong to.\n *\n * Messages state the rule, which is constant; the offending value is a field.\n * An interpolated message cannot be matched on and carries user input into\n * every log line that touches it.\n */\n\n/**\n * Replace the password in a connection string with `***`.\n *\n * A connection string is a secret, and the places it is most likely to be\n * written down — a log line, an error, a crash report shipped to a third party\n * — are the places nobody is reading carefully. This exists so that redacting\n * is the easy thing to do at each of them.\n *\n * Safe on input that is not a URL: it returns a constant rather than throwing,\n * because this runs on paths that must not fail. Anything unparseable is\n * treated as potentially secret and withheld entirely rather than echoed.\n */\nexport function redactDatabaseUrl(url: string): string {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tif (!parsed.password) return url;\n\t\tparsed.password = '***';\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn '<unparseable url>';\n\t}\n}\n\n/**\n * Base for an address that cannot become a connection string.\n *\n * Deliberately carries no URL field: these are thrown while *composing* one, so\n * there is no URL yet — only the parts, which include the password.\n */\nexport abstract class DatabaseAddressError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = new.target.name;\n\t}\n}\n\n/** An address with no host to connect to. */\nexport class MissingDatabaseHost extends DatabaseAddressError {\n\tconstructor() {\n\t\tsuper('A database address must name a host');\n\t}\n}\n\n/**\n * An address with no database name.\n *\n * Postgres silently falls back to the connecting role's name, so the app\n * connects successfully to the wrong database and fails later with confusing\n * \"relation does not exist\" errors. Rejecting it here is much cheaper.\n */\nexport class MissingDatabaseName extends DatabaseAddressError {\n\tconstructor() {\n\t\tsuper('A database address must name a database');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,kBAAkBA,KAAqB;AACtD,KAAI;EACH,MAAM,SAAS,IAAI,IAAI;AACvB,OAAK,OAAO,SAAU,QAAO;AAC7B,SAAO,WAAW;AAClB,SAAO,OAAO,UAAU;CACxB,QAAO;AACP,SAAO;CACP;AACD;;;;;;;AAQD,IAAsB,uBAAtB,cAAmD,MAAM;CACxD,YAAYC,SAAiB;AAC5B,QAAM,QAAQ;AACd,OAAK,OAAO,IAAI,OAAO;CACvB;AACD;;AAGD,IAAa,sBAAb,cAAyC,qBAAqB;CAC7D,cAAc;AACb,QAAM,sCAAsC;CAC5C;AACD;;;;;;;;AASD,IAAa,sBAAb,cAAyC,qBAAqB;CAC7D,cAAc;AACb,QAAM,0CAA0C;CAChD;AACD"}
@@ -1,93 +0,0 @@
1
-
2
- //#region src/errors.ts
3
- /**
4
- * Database URL errors and redaction — engine-neutral.
5
- *
6
- * Nothing here is Postgres-specific: every engine addresses itself as a URL
7
- * carrying a password, and "must name a host" holds for all of them. The parts
8
- * that differ — libpq's `options=-c search_path=…`, which no other engine
9
- * accepts — live under the driver they belong to.
10
- *
11
- * Messages state the rule, which is constant; the offending value is a field.
12
- * An interpolated message cannot be matched on and carries user input into
13
- * every log line that touches it.
14
- */
15
- /**
16
- * Replace the password in a connection string with `***`.
17
- *
18
- * A connection string is a secret, and the places it is most likely to be
19
- * written down — a log line, an error, a crash report shipped to a third party
20
- * — are the places nobody is reading carefully. This exists so that redacting
21
- * is the easy thing to do at each of them.
22
- *
23
- * Safe on input that is not a URL: it returns a constant rather than throwing,
24
- * because this runs on paths that must not fail. Anything unparseable is
25
- * treated as potentially secret and withheld entirely rather than echoed.
26
- */
27
- function redactDatabaseUrl(url) {
28
- try {
29
- const parsed = new URL(url);
30
- if (!parsed.password) return url;
31
- parsed.password = "***";
32
- return parsed.toString();
33
- } catch {
34
- return "<unparseable url>";
35
- }
36
- }
37
- /**
38
- * Base for an address that cannot become a connection string.
39
- *
40
- * Deliberately carries no URL field: these are thrown while *composing* one, so
41
- * there is no URL yet — only the parts, which include the password.
42
- */
43
- var DatabaseAddressError = class extends Error {
44
- constructor(message) {
45
- super(message);
46
- this.name = new.target.name;
47
- }
48
- };
49
- /** An address with no host to connect to. */
50
- var MissingDatabaseHost = class extends DatabaseAddressError {
51
- constructor() {
52
- super("A database address must name a host");
53
- }
54
- };
55
- /**
56
- * An address with no database name.
57
- *
58
- * Postgres silently falls back to the connecting role's name, so the app
59
- * connects successfully to the wrong database and fails later with confusing
60
- * "relation does not exist" errors. Rejecting it here is much cheaper.
61
- */
62
- var MissingDatabaseName = class extends DatabaseAddressError {
63
- constructor() {
64
- super("A database address must name a database");
65
- }
66
- };
67
-
68
- //#endregion
69
- Object.defineProperty(exports, 'DatabaseAddressError', {
70
- enumerable: true,
71
- get: function () {
72
- return DatabaseAddressError;
73
- }
74
- });
75
- Object.defineProperty(exports, 'MissingDatabaseHost', {
76
- enumerable: true,
77
- get: function () {
78
- return MissingDatabaseHost;
79
- }
80
- });
81
- Object.defineProperty(exports, 'MissingDatabaseName', {
82
- enumerable: true,
83
- get: function () {
84
- return MissingDatabaseName;
85
- }
86
- });
87
- Object.defineProperty(exports, 'redactDatabaseUrl', {
88
- enumerable: true,
89
- get: function () {
90
- return redactDatabaseUrl;
91
- }
92
- });
93
- //# sourceMappingURL=errors-Cs5jlAv-.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-Cs5jlAv-.cjs","names":["url: string","message: string"],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Database URL errors and redaction — engine-neutral.\n *\n * Nothing here is Postgres-specific: every engine addresses itself as a URL\n * carrying a password, and \"must name a host\" holds for all of them. The parts\n * that differ — libpq's `options=-c search_path=…`, which no other engine\n * accepts — live under the driver they belong to.\n *\n * Messages state the rule, which is constant; the offending value is a field.\n * An interpolated message cannot be matched on and carries user input into\n * every log line that touches it.\n */\n\n/**\n * Replace the password in a connection string with `***`.\n *\n * A connection string is a secret, and the places it is most likely to be\n * written down — a log line, an error, a crash report shipped to a third party\n * — are the places nobody is reading carefully. This exists so that redacting\n * is the easy thing to do at each of them.\n *\n * Safe on input that is not a URL: it returns a constant rather than throwing,\n * because this runs on paths that must not fail. Anything unparseable is\n * treated as potentially secret and withheld entirely rather than echoed.\n */\nexport function redactDatabaseUrl(url: string): string {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tif (!parsed.password) return url;\n\t\tparsed.password = '***';\n\t\treturn parsed.toString();\n\t} catch {\n\t\treturn '<unparseable url>';\n\t}\n}\n\n/**\n * Base for an address that cannot become a connection string.\n *\n * Deliberately carries no URL field: these are thrown while *composing* one, so\n * there is no URL yet — only the parts, which include the password.\n */\nexport abstract class DatabaseAddressError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = new.target.name;\n\t}\n}\n\n/** An address with no host to connect to. */\nexport class MissingDatabaseHost extends DatabaseAddressError {\n\tconstructor() {\n\t\tsuper('A database address must name a host');\n\t}\n}\n\n/**\n * An address with no database name.\n *\n * Postgres silently falls back to the connecting role's name, so the app\n * connects successfully to the wrong database and fails later with confusing\n * \"relation does not exist\" errors. Rejecting it here is much cheaper.\n */\nexport class MissingDatabaseName extends DatabaseAddressError {\n\tconstructor() {\n\t\tsuper('A database address must name a database');\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,kBAAkBA,KAAqB;AACtD,KAAI;EACH,MAAM,SAAS,IAAI,IAAI;AACvB,OAAK,OAAO,SAAU,QAAO;AAC7B,SAAO,WAAW;AAClB,SAAO,OAAO,UAAU;CACxB,QAAO;AACP,SAAO;CACP;AACD;;;;;;;AAQD,IAAsB,uBAAtB,cAAmD,MAAM;CACxD,YAAYC,SAAiB;AAC5B,QAAM,QAAQ;AACd,OAAK,OAAO,IAAI,OAAO;CACvB;AACD;;AAGD,IAAa,sBAAb,cAAyC,qBAAqB;CAC7D,cAAc;AACb,QAAM,sCAAsC;CAC5C;AACD;;;;;;;;AASD,IAAa,sBAAb,cAAyC,qBAAqB;CAC7D,cAAc;AACb,QAAM,0CAA0C;CAChD;AACD"}
@@ -1,13 +0,0 @@
1
- import { ControlledTransaction, IsolationLevel, Kysely, Transaction } from "kysely";
2
-
3
- //#region src/kysely.d.ts
4
- interface TransactionSettings {
5
- isolationLevel?: IsolationLevel;
6
- }
7
- declare function withTransaction<DB, T>(db: DatabaseConnection<DB>, cb: (trx: Transaction<DB>) => Promise<T>, settings?: TransactionSettings): Promise<T>;
8
- type DatabaseConnection<T> = ControlledTransaction<T> | Kysely<T> | Transaction<T>;
9
- //# sourceMappingURL=kysely.d.ts.map
10
-
11
- //#endregion
12
- export { DatabaseConnection, TransactionSettings, withTransaction };
13
- //# sourceMappingURL=kysely-BAedYsvn.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely-BAedYsvn.d.mts","names":[],"sources":["../src/kysely.ts"],"sourcesContent":[],"mappings":";;;UAOiB,mBAAA;mBACC;AADlB;AAIgB,iBAAA,eAAe,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,EAC1B,kBAD0B,CACP,EADO,CAAA,EAAA,EAAA,EAAA,CAAA,GAAA,EAEpB,WAFoB,CAER,EAFQ,CAAA,EAAA,GAEA,OAFA,CAEQ,CAFR,CAAA,EAAA,QAAA,CAAA,EAGnB,mBAHmB,CAAA,EAI5B,OAJ4B,CAIpB,CAJoB,CAAA;AAAA,KAkBnB,kBAlBmB,CAAA,CAAA,CAAA,GAmB5B,qBAnB4B,CAmBN,CAnBM,CAAA,GAoB5B,MApB4B,CAoBrB,CApBqB,CAAA,GAqB5B,WArB4B,CAqBhB,CArBgB,CAAA"}
@@ -1,11 +0,0 @@
1
- //#region src/kysely.ts
2
- function withTransaction(db, cb, settings) {
3
- if (db.isTransaction) return cb(db);
4
- const builder = db.transaction();
5
- if (settings?.isolationLevel) return builder.setIsolationLevel(settings.isolationLevel).execute(cb);
6
- return builder.execute(cb);
7
- }
8
-
9
- //#endregion
10
- export { withTransaction };
11
- //# sourceMappingURL=kysely-Bo_Zg-D3.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely-Bo_Zg-D3.mjs","names":["db: DatabaseConnection<DB>","cb: (trx: Transaction<DB>) => Promise<T>","settings?: TransactionSettings"],"sources":["../src/kysely.ts"],"sourcesContent":["import type {\n\tControlledTransaction,\n\tIsolationLevel,\n\tKysely,\n\tTransaction,\n} from 'kysely';\n\nexport interface TransactionSettings {\n\tisolationLevel?: IsolationLevel;\n}\n\nexport function withTransaction<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcb: (trx: Transaction<DB>) => Promise<T>,\n\tsettings?: TransactionSettings,\n): Promise<T> {\n\tif (db.isTransaction) {\n\t\treturn cb(db as Transaction<DB>);\n\t}\n\n\tconst builder = db.transaction();\n\n\tif (settings?.isolationLevel) {\n\t\treturn builder.setIsolationLevel(settings.isolationLevel).execute(cb);\n\t}\n\n\treturn builder.execute(cb);\n}\n\nexport type DatabaseConnection<T> =\n\t| ControlledTransaction<T>\n\t| Kysely<T>\n\t| Transaction<T>;\n"],"mappings":";AAWA,SAAgB,gBACfA,IACAC,IACAC,UACa;AACb,KAAI,GAAG,cACN,QAAO,GAAG,GAAsB;CAGjC,MAAM,UAAU,GAAG,aAAa;AAEhC,KAAI,UAAU,eACb,QAAO,QAAQ,kBAAkB,SAAS,eAAe,CAAC,QAAQ,GAAG;AAGtE,QAAO,QAAQ,QAAQ,GAAG;AAC1B"}
@@ -1,13 +0,0 @@
1
- import { ControlledTransaction, IsolationLevel, Kysely, Transaction } from "kysely";
2
-
3
- //#region src/kysely.d.ts
4
- interface TransactionSettings {
5
- isolationLevel?: IsolationLevel;
6
- }
7
- declare function withTransaction<DB, T>(db: DatabaseConnection<DB>, cb: (trx: Transaction<DB>) => Promise<T>, settings?: TransactionSettings): Promise<T>;
8
- type DatabaseConnection<T> = ControlledTransaction<T> | Kysely<T> | Transaction<T>;
9
- //# sourceMappingURL=kysely.d.ts.map
10
-
11
- //#endregion
12
- export { DatabaseConnection, TransactionSettings, withTransaction };
13
- //# sourceMappingURL=kysely-D3eeuId4.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely-D3eeuId4.d.cts","names":[],"sources":["../src/kysely.ts"],"sourcesContent":[],"mappings":";;;UAOiB,mBAAA;mBACC;AADlB;AAIgB,iBAAA,eAAe,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,EAC1B,kBAD0B,CACP,EADO,CAAA,EAAA,EAAA,EAAA,CAAA,GAAA,EAEpB,WAFoB,CAER,EAFQ,CAAA,EAAA,GAEA,OAFA,CAEQ,CAFR,CAAA,EAAA,QAAA,CAAA,EAGnB,mBAHmB,CAAA,EAI5B,OAJ4B,CAIpB,CAJoB,CAAA;AAAA,KAkBnB,kBAlBmB,CAAA,CAAA,CAAA,GAmB5B,qBAnB4B,CAmBN,CAnBM,CAAA,GAoB5B,MApB4B,CAoBrB,CApBqB,CAAA,GAqB5B,WArB4B,CAqBhB,CArBgB,CAAA"}
@@ -1,17 +0,0 @@
1
-
2
- //#region src/kysely.ts
3
- function withTransaction(db, cb, settings) {
4
- if (db.isTransaction) return cb(db);
5
- const builder = db.transaction();
6
- if (settings?.isolationLevel) return builder.setIsolationLevel(settings.isolationLevel).execute(cb);
7
- return builder.execute(cb);
8
- }
9
-
10
- //#endregion
11
- Object.defineProperty(exports, 'withTransaction', {
12
- enumerable: true,
13
- get: function () {
14
- return withTransaction;
15
- }
16
- });
17
- //# sourceMappingURL=kysely-LWvS2ekY.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kysely-LWvS2ekY.cjs","names":["db: DatabaseConnection<DB>","cb: (trx: Transaction<DB>) => Promise<T>","settings?: TransactionSettings"],"sources":["../src/kysely.ts"],"sourcesContent":["import type {\n\tControlledTransaction,\n\tIsolationLevel,\n\tKysely,\n\tTransaction,\n} from 'kysely';\n\nexport interface TransactionSettings {\n\tisolationLevel?: IsolationLevel;\n}\n\nexport function withTransaction<DB, T>(\n\tdb: DatabaseConnection<DB>,\n\tcb: (trx: Transaction<DB>) => Promise<T>,\n\tsettings?: TransactionSettings,\n): Promise<T> {\n\tif (db.isTransaction) {\n\t\treturn cb(db as Transaction<DB>);\n\t}\n\n\tconst builder = db.transaction();\n\n\tif (settings?.isolationLevel) {\n\t\treturn builder.setIsolationLevel(settings.isolationLevel).execute(cb);\n\t}\n\n\treturn builder.execute(cb);\n}\n\nexport type DatabaseConnection<T> =\n\t| ControlledTransaction<T>\n\t| Kysely<T>\n\t| Transaction<T>;\n"],"mappings":";;AAWA,SAAgB,gBACfA,IACAC,IACAC,UACa;AACb,KAAI,GAAG,cACN,QAAO,GAAG,GAAsB;CAGjC,MAAM,UAAU,GAAG,aAAa;AAEhC,KAAI,UAAU,eACb,QAAO,QAAQ,kBAAkB,SAAS,eAAe,CAAC,QAAQ,GAAG;AAGtE,QAAO,QAAQ,QAAQ,GAAG;AAC1B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-BAFX7C1I.d.cts","names":[],"sources":["../src/pagination.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AAagB,aArBJ,SAAA;EAgCI,GAAA,GAAA,KAAA;;;;;;UAxBC;SACT;;;;;;;;;;;iBAYQ,YAAA;;;;iBAWA,YAAA"}
@@ -1,55 +0,0 @@
1
-
2
- //#region src/pagination.ts
3
- /**
4
- * Sort direction for cursor-based pagination.
5
- */
6
- let Direction = /* @__PURE__ */ function(Direction$1) {
7
- Direction$1["Asc"] = "asc";
8
- Direction$1["Desc"] = "desc";
9
- return Direction$1;
10
- }({});
11
- /**
12
- * Encode a cursor value for safe URL transmission.
13
- * Supports various types: string, number, Date, etc.
14
- */
15
- function encodeCursor(value) {
16
- const payload = {
17
- v: value instanceof Date ? value.toISOString() : value,
18
- t: value instanceof Date ? "date" : typeof value
19
- };
20
- return Buffer.from(JSON.stringify(payload)).toString("base64url");
21
- }
22
- /**
23
- * Decode a cursor string back to its original value.
24
- */
25
- function decodeCursor(cursor) {
26
- try {
27
- const json = Buffer.from(cursor, "base64url").toString("utf-8");
28
- const payload = JSON.parse(json);
29
- if (payload.t === "date") return new Date(payload.v);
30
- return payload.v;
31
- } catch {
32
- throw new Error("Invalid cursor format");
33
- }
34
- }
35
-
36
- //#endregion
37
- Object.defineProperty(exports, 'Direction', {
38
- enumerable: true,
39
- get: function () {
40
- return Direction;
41
- }
42
- });
43
- Object.defineProperty(exports, 'decodeCursor', {
44
- enumerable: true,
45
- get: function () {
46
- return decodeCursor;
47
- }
48
- });
49
- Object.defineProperty(exports, 'encodeCursor', {
50
- enumerable: true,
51
- get: function () {
52
- return encodeCursor;
53
- }
54
- });
55
- //# sourceMappingURL=pagination-Bu1dqOy0.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-Bu1dqOy0.cjs","names":["value: unknown","cursor: string"],"sources":["../src/pagination.ts"],"sourcesContent":["/**\n * Sort direction for cursor-based pagination.\n */\nexport enum Direction {\n\tAsc = 'asc',\n\tDesc = 'desc',\n}\n\n/**\n * Result of a paginated query.\n */\nexport interface PaginationResult<TItem> {\n\titems: TItem[];\n\tpagination: {\n\t\ttotal: number;\n\t\thasMore: boolean;\n\t\tcursor?: string;\n\t};\n}\n\n/**\n * Encode a cursor value for safe URL transmission.\n * Supports various types: string, number, Date, etc.\n */\nexport function encodeCursor(value: unknown): string {\n\tconst payload = {\n\t\tv: value instanceof Date ? value.toISOString() : value,\n\t\tt: value instanceof Date ? 'date' : typeof value,\n\t};\n\treturn Buffer.from(JSON.stringify(payload)).toString('base64url');\n}\n\n/**\n * Decode a cursor string back to its original value.\n */\nexport function decodeCursor(cursor: string): unknown {\n\ttry {\n\t\tconst json = Buffer.from(cursor, 'base64url').toString('utf-8');\n\t\tconst payload = JSON.parse(json);\n\n\t\tif (payload.t === 'date') {\n\t\t\treturn new Date(payload.v);\n\t\t}\n\n\t\treturn payload.v;\n\t} catch {\n\t\tthrow new Error('Invalid cursor format');\n\t}\n}\n"],"mappings":";;;;;AAGA,IAAY,kDAAL;AACN;AACA;;AACA;;;;;AAkBD,SAAgB,aAAaA,OAAwB;CACpD,MAAM,UAAU;EACf,GAAG,iBAAiB,OAAO,MAAM,aAAa,GAAG;EACjD,GAAG,iBAAiB,OAAO,gBAAgB;CAC3C;AACD,QAAO,OAAO,KAAK,KAAK,UAAU,QAAQ,CAAC,CAAC,SAAS,YAAY;AACjE;;;;AAKD,SAAgB,aAAaC,QAAyB;AACrD,KAAI;EACH,MAAM,OAAO,OAAO,KAAK,QAAQ,YAAY,CAAC,SAAS,QAAQ;EAC/D,MAAM,UAAU,KAAK,MAAM,KAAK;AAEhC,MAAI,QAAQ,MAAM,OACjB,QAAO,IAAI,KAAK,QAAQ;AAGzB,SAAO,QAAQ;CACf,QAAO;AACP,QAAM,IAAI,MAAM;CAChB;AACD"}
@@ -1,37 +0,0 @@
1
- //#region src/pagination.ts
2
- /**
3
- * Sort direction for cursor-based pagination.
4
- */
5
- let Direction = /* @__PURE__ */ function(Direction$1) {
6
- Direction$1["Asc"] = "asc";
7
- Direction$1["Desc"] = "desc";
8
- return Direction$1;
9
- }({});
10
- /**
11
- * Encode a cursor value for safe URL transmission.
12
- * Supports various types: string, number, Date, etc.
13
- */
14
- function encodeCursor(value) {
15
- const payload = {
16
- v: value instanceof Date ? value.toISOString() : value,
17
- t: value instanceof Date ? "date" : typeof value
18
- };
19
- return Buffer.from(JSON.stringify(payload)).toString("base64url");
20
- }
21
- /**
22
- * Decode a cursor string back to its original value.
23
- */
24
- function decodeCursor(cursor) {
25
- try {
26
- const json = Buffer.from(cursor, "base64url").toString("utf-8");
27
- const payload = JSON.parse(json);
28
- if (payload.t === "date") return new Date(payload.v);
29
- return payload.v;
30
- } catch {
31
- throw new Error("Invalid cursor format");
32
- }
33
- }
34
-
35
- //#endregion
36
- export { Direction, decodeCursor, encodeCursor };
37
- //# sourceMappingURL=pagination-CQ8QHXaL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-CQ8QHXaL.mjs","names":["value: unknown","cursor: string"],"sources":["../src/pagination.ts"],"sourcesContent":["/**\n * Sort direction for cursor-based pagination.\n */\nexport enum Direction {\n\tAsc = 'asc',\n\tDesc = 'desc',\n}\n\n/**\n * Result of a paginated query.\n */\nexport interface PaginationResult<TItem> {\n\titems: TItem[];\n\tpagination: {\n\t\ttotal: number;\n\t\thasMore: boolean;\n\t\tcursor?: string;\n\t};\n}\n\n/**\n * Encode a cursor value for safe URL transmission.\n * Supports various types: string, number, Date, etc.\n */\nexport function encodeCursor(value: unknown): string {\n\tconst payload = {\n\t\tv: value instanceof Date ? value.toISOString() : value,\n\t\tt: value instanceof Date ? 'date' : typeof value,\n\t};\n\treturn Buffer.from(JSON.stringify(payload)).toString('base64url');\n}\n\n/**\n * Decode a cursor string back to its original value.\n */\nexport function decodeCursor(cursor: string): unknown {\n\ttry {\n\t\tconst json = Buffer.from(cursor, 'base64url').toString('utf-8');\n\t\tconst payload = JSON.parse(json);\n\n\t\tif (payload.t === 'date') {\n\t\t\treturn new Date(payload.v);\n\t\t}\n\n\t\treturn payload.v;\n\t} catch {\n\t\tthrow new Error('Invalid cursor format');\n\t}\n}\n"],"mappings":";;;;AAGA,IAAY,kDAAL;AACN;AACA;;AACA;;;;;AAkBD,SAAgB,aAAaA,OAAwB;CACpD,MAAM,UAAU;EACf,GAAG,iBAAiB,OAAO,MAAM,aAAa,GAAG;EACjD,GAAG,iBAAiB,OAAO,gBAAgB;CAC3C;AACD,QAAO,OAAO,KAAK,KAAK,UAAU,QAAQ,CAAC,CAAC,SAAS,YAAY;AACjE;;;;AAKD,SAAgB,aAAaC,QAAyB;AACrD,KAAI;EACH,MAAM,OAAO,OAAO,KAAK,QAAQ,YAAY,CAAC,SAAS,QAAQ;EAC/D,MAAM,UAAU,KAAK,MAAM,KAAK;AAEhC,MAAI,QAAQ,MAAM,OACjB,QAAO,IAAI,KAAK,QAAQ;AAGzB,SAAO,QAAQ;CACf,QAAO;AACP,QAAM,IAAI,MAAM;CAChB;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-kv-KWS-7.d.mts","names":[],"sources":["../src/pagination.ts"],"sourcesContent":[],"mappings":";;AAGA;AAQA;AAagB,aArBJ,SAAA;EAgCI,GAAA,GAAA,KAAA;;;;;;UAxBC;SACT;;;;;;;;;;;iBAYQ,YAAA;;;;iBAWA,YAAA"}