better-supabase 0.3.0 → 0.5.0

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 (211) hide show
  1. package/README.md +9 -6
  2. package/bin/better-supabase.js +4 -0
  3. package/dist/{base64-CQeB1eSf.js → base64-D2gsioCY.js} +2 -2
  4. package/dist/channel-FQW-CnGR.d.ts +70 -0
  5. package/dist/claims-BAf6c7is.js +48 -0
  6. package/dist/cli/_format-Cax5EsM9.js +101 -0
  7. package/dist/cli/bin.d.ts +1 -0
  8. package/dist/cli/bin.js +48 -0
  9. package/dist/cli/codemod-DqV7612m.js +388 -0
  10. package/dist/cli/command-CK14fP91.js +502 -0
  11. package/dist/cli/compare-BmIWVEui.js +9 -0
  12. package/dist/cli/config-CPVpXP5I.js +1965 -0
  13. package/dist/cli/config-dtoekM0v.js +2 -0
  14. package/dist/cli/db-DOBPt660.js +52 -0
  15. package/dist/cli/diff-SjkO5rNr.js +752 -0
  16. package/dist/cli/dist-DBPdlPYK.js +1112 -0
  17. package/dist/cli/dist-DreZ24Sz.js +129 -0
  18. package/dist/cli/dist-xn4wlboc.js +732 -0
  19. package/dist/cli/doctor-L7Z8mYTx.js +2863 -0
  20. package/dist/cli/env-DmKv_G4A.js +108 -0
  21. package/dist/cli/env-jIFUADLY.js +511 -0
  22. package/dist/cli/errors-4v4DTtda.js +56 -0
  23. package/dist/cli/fastest-levenshtein-CFN-lNDv.js +120 -0
  24. package/dist/cli/gen-BJc9vdyu.js +2 -0
  25. package/dist/cli/gen-C2osRcr5.js +2204 -0
  26. package/dist/cli/index.d.ts +493 -0
  27. package/dist/cli/index.js +184 -0
  28. package/dist/cli/init-Saf5-R9T.js +550 -0
  29. package/dist/cli/introspect--H7oGmcd.js +81 -0
  30. package/dist/cli/io-k41_z-jT.js +24 -0
  31. package/dist/cli/json5-ChRycquj.js +787 -0
  32. package/dist/cli/jsonc-BUniUpOk.js +2 -0
  33. package/dist/cli/jsonc-D5Fu67jw.js +45 -0
  34. package/dist/cli/keys-ByKHnvP9.js +83 -0
  35. package/dist/cli/ohash-D7bG_EOb.js +277 -0
  36. package/dist/cli/openapi-Cp5Fyta-.js +66 -0
  37. package/dist/cli/project-B_GeXyHh.js +70 -0
  38. package/dist/cli/prompts-BNcNfAve.js +1142 -0
  39. package/dist/cli/prompts-BTYQGunc.js +2 -0
  40. package/dist/cli/read-sets-BfMQcKy8.js +289 -0
  41. package/dist/cli/rolldown-runtime-BPOCksWG.js +24 -0
  42. package/dist/cli/run-BKR2W_79.js +351 -0
  43. package/dist/cli/seed-CUlqWh-8.js +98 -0
  44. package/dist/cli/skills-LJJIhLFR.js +137 -0
  45. package/dist/cli/sql-DzPbfngx.js +348 -0
  46. package/dist/cli/style-C0NFdJRL.js +29 -0
  47. package/dist/cli/toml-DB-MNnFs.js +424 -0
  48. package/dist/cli/version-BDJuO0UR.js +4 -0
  49. package/dist/cli/yaml-CYCbJ6et.js +2252 -0
  50. package/dist/client/index.d.ts +2 -2
  51. package/dist/client/index.js +15 -22
  52. package/dist/clone-BfgmLU90.js +21 -0
  53. package/dist/{compiler-2zqGzxVZ.d.ts → compiler-BXH_aZ7N.d.ts} +2 -2
  54. package/dist/config/index.d.ts +4 -4
  55. package/dist/config/index.js +5 -5
  56. package/dist/{config-DOsGYSiT.js → config-DreERlKo.js} +1 -1
  57. package/dist/{config-C1CYcm6o.d.ts → config-T_ejwyd3.d.ts} +176 -11
  58. package/dist/{define-DUbydmJa.d.ts → define-Bp_BZa5h.d.ts} +37 -29
  59. package/dist/{define-DF341GDj.js → define-cNKzqwL_.js} +356 -89
  60. package/dist/edge/index.d.ts +20 -13
  61. package/dist/edge/index.js +55 -26
  62. package/dist/{entitlements-DvJXoI02.d.ts → entitlements-DUxU4oHe.d.ts} +2 -2
  63. package/dist/env/index.d.ts +2 -2
  64. package/dist/env/index.js +34 -1
  65. package/dist/{errors-Bl3rkOzo.js → errors-DtwXa6b8.js} +2 -1
  66. package/dist/events/index.d.ts +3 -2
  67. package/dist/events/index.js +69 -16
  68. package/dist/events-aIO7vsIk.d.ts +230 -0
  69. package/dist/executor-BunPOO-k.d.ts +402 -0
  70. package/dist/{executor-B26lgbHD.d.ts → executor-Cghdstwu.d.ts} +1 -2
  71. package/dist/{executor-C57jx2pn.js → executor-XycESQPH.js} +3 -3
  72. package/dist/hono/index.d.ts +27 -23
  73. package/dist/hono/index.js +46 -11
  74. package/dist/impersonation-VfaGc4Q_.js +41 -0
  75. package/dist/{index-BNsABq7P.d.ts → index-BGdgBPdf.d.ts} +66 -25
  76. package/dist/{index-qriRM9cZ.d.ts → index-C7f8cOBM.d.ts} +4 -4
  77. package/dist/{index-Dy6kuF0P.d.ts → index-CLg87OBW.d.ts} +6 -1
  78. package/dist/{index-GV77NpRP.d.ts → index-DOESKG27.d.ts} +34 -9
  79. package/dist/{index-CriFFJ_p.d.ts → index-DgILJRXj.d.ts} +43 -17
  80. package/dist/{index-UJ-LUxtI.d.ts → index-DmXSxbLi.d.ts} +14 -14
  81. package/dist/{index-Cf-D2jk1.d.ts → index-Dxn2a5cw.d.ts} +2 -2
  82. package/dist/{index-CTTMS6_1.d.ts → index-SaTsEfGP.d.ts} +86 -9
  83. package/dist/{index-CADlNHK-.d.ts → index-fag8VJZ2.d.ts} +5 -6
  84. package/dist/index.d.ts +34 -17
  85. package/dist/index.js +15 -14
  86. package/dist/jobs/index.d.ts +147 -95
  87. package/dist/jobs/index.js +773 -250
  88. package/dist/{json-schema--aOXAGfU.js → json-schema-m1fiwKgN.js} +23 -2
  89. package/dist/kit-events-CTFDfSwb.js +60 -0
  90. package/dist/kit-transport-B82k1djG.d.ts +33 -0
  91. package/dist/kit-transport-DJlHQUBU.js +55 -0
  92. package/dist/{config-Be4GwsqI.js → kits-CGLLrNPd.js} +38 -10
  93. package/dist/list/index.d.ts +1 -1
  94. package/dist/list/index.js +3 -3
  95. package/dist/{live-D8rV1Ldw.js → live-CdJBOc4f.js} +13 -9
  96. package/dist/{live-QE3UPbGm.d.ts → live-D9W2M5aO.d.ts} +16 -15
  97. package/dist/lookup-BaP5bI27.js +18 -0
  98. package/dist/mcp/index.d.ts +39 -22
  99. package/dist/mcp/index.js +39 -25
  100. package/dist/{mfa-x3V3vGh-.d.ts → mfa-CusDgPaD.d.ts} +5 -1
  101. package/dist/next/image/index.js +6 -3
  102. package/dist/next/index.d.ts +60 -36
  103. package/dist/next/index.js +167 -50
  104. package/dist/notifications/index.d.ts +162 -0
  105. package/dist/notifications/index.js +264 -0
  106. package/dist/openapi/index.d.ts +1 -1
  107. package/dist/openapi/index.js +6 -6
  108. package/dist/orgs/index.d.ts +132 -0
  109. package/dist/orgs/index.js +245 -0
  110. package/dist/orpc/index.d.ts +37 -20
  111. package/dist/orpc/index.js +24 -11
  112. package/dist/otel/index.d.ts +24 -5
  113. package/dist/otel/index.js +124 -64
  114. package/dist/permdock-sql-C2Inc6Xc.d.ts +29 -0
  115. package/dist/permdock-sql-DgOfeixi.js +51 -0
  116. package/dist/plugin-DwARMuQp.js +59 -0
  117. package/dist/{plugin-DVRB8qNE.d.ts → plugin-o144f322.d.ts} +17 -5
  118. package/dist/plugins/actor/index.d.ts +5 -2
  119. package/dist/plugins/actor/index.js +22 -8
  120. package/dist/plugins/rules/index.d.ts +2 -2
  121. package/dist/plugins/rules/index.js +52 -17
  122. package/dist/plugins/soft-delete/index.d.ts +3 -3
  123. package/dist/plugins/soft-delete/index.js +14 -5
  124. package/dist/plugins/tenant/index.d.ts +3 -3
  125. package/dist/plugins/tenant/index.js +45 -21
  126. package/dist/plugins/timestamps/index.d.ts +1 -1
  127. package/dist/plugins/timestamps/index.js +4 -3
  128. package/dist/plugins/validation/index.d.ts +2 -2
  129. package/dist/plugins/validation/index.js +26 -6
  130. package/dist/{pool-B9qsLyFR.d.ts → pool-C9voM4Kw.d.ts} +24 -6
  131. package/dist/postgres/index.d.ts +5 -5
  132. package/dist/postgres/index.js +20 -10
  133. package/dist/{postgrest-DmBlevh-.d.ts → postgrest-CruYKAvV.d.ts} +1 -1
  134. package/dist/{problem-CGt1ADix.js → problem-BW1KhzSG.js} +2 -1
  135. package/dist/{problem-Z2RTQjZD.d.ts → problem-Blxe8S31.d.ts} +1 -1
  136. package/dist/query/index.d.ts +2 -2
  137. package/dist/query/index.js +3 -3
  138. package/dist/{query-BdKLTPlj.js → query-CCbo44lG.js} +18 -18
  139. package/dist/queue-BYUCjr59.d.ts +252 -0
  140. package/dist/react/index.d.ts +8 -7
  141. package/dist/react/index.js +4 -3
  142. package/dist/react/server.d.ts +16 -5
  143. package/dist/react/server.js +12 -4
  144. package/dist/react/session.d.ts +10 -4
  145. package/dist/react/session.js +11 -3
  146. package/dist/{react-DNBYNazu.js → react-C_s7kiNz.js} +138 -46
  147. package/dist/{read-set-D0qBcboM.js → read-set-DQFt1N_Y.js} +71 -15
  148. package/dist/realtime/index.d.ts +3 -3
  149. package/dist/realtime/index.js +14 -12
  150. package/dist/{index-kpgopLNv.d.ts → refresh-BTrQ_ZTp.d.ts} +6 -3
  151. package/dist/{resolve-BRciX2jK.d.ts → resolve-C15TJq77.d.ts} +22 -11
  152. package/dist/{resource-D30rp0GN.js → resource-CRxxwkQq.js} +24 -9
  153. package/dist/{resource-CwVgiI5q.d.ts → resource-D8iqWMr-.d.ts} +6 -6
  154. package/dist/respond-D2OQl62-.d.ts +371 -0
  155. package/dist/{result-DWXatkd6.js → result-BKiliPY7.js} +2 -2
  156. package/dist/server/index.d.ts +17 -15
  157. package/dist/server/index.js +16 -22
  158. package/dist/server-Csx2sRjg.js +655 -0
  159. package/dist/{shared-_6-uPL7E.js → shared-D1dRUrAg.js} +19 -4
  160. package/dist/signers-Cc6r98SW.d.ts +162 -0
  161. package/dist/{simplify-LakqK1vH.js → simplify-_0oUKqCd.js} +27 -95
  162. package/dist/sql/index.d.ts +247 -10
  163. package/dist/sql/index.js +8591 -780
  164. package/dist/{sql-BIgk12ew.js → sql-Coh6n4cC.js} +11 -3
  165. package/dist/ssr/index.d.ts +4 -4
  166. package/dist/ssr/index.js +1 -2
  167. package/dist/{standard-FUi3Z3-7.js → standard-D7r6dMUu.js} +6 -3
  168. package/dist/{standard-eudBiRk1.d.ts → standard-J4YgMOLm.d.ts} +1 -1
  169. package/dist/{stats-D78UQ8Yu.js → stats-Bqob3WqT.js} +34 -9
  170. package/dist/storage/index.d.ts +4 -4
  171. package/dist/storage/index.js +174 -27
  172. package/dist/support-DT-OhSxD.d.ts +88 -0
  173. package/dist/support-Dk6vdmEw.js +291 -0
  174. package/dist/support-view-Da5peKFg.d.ts +17 -0
  175. package/dist/support-view-g4YLBeqX.js +18 -0
  176. package/dist/{tables-Dhha3BXM.js → tables-Cb-3_VWc.js} +14 -0
  177. package/dist/{permdock-sql-Bta_G0v-.js → template-TxrGI5jR.js} +2 -31
  178. package/dist/{temporal-BwshQk0W.js → temporal-CVlIV2DZ.js} +17 -4
  179. package/dist/{temporal-required-CMxeSVPo.js → temporal-required-CAt4Dc9Z.js} +2 -2
  180. package/dist/testing/index.d.ts +113 -24
  181. package/dist/testing/index.js +375 -47
  182. package/dist/{types-DONv9SHN.d.ts → types-Dnf_wRDz.d.ts} +26 -3
  183. package/dist/user-change-CHFEUro1.js +49 -0
  184. package/dist/{webhooks-CAIFQSTM.js → verify-Ce49ETPz.js} +38 -19
  185. package/dist/{version-BfpG2gks.js → version-DM_Roffb.js} +1 -1
  186. package/dist/{view-3Po_PVlr.d.ts → view-BEf0diC5.d.ts} +10 -5
  187. package/dist/{mfa-BxoR1RkN.js → view-Bq64ki8-.js} +210 -64
  188. package/dist/webhooks/index.d.ts +136 -5
  189. package/dist/webhooks/index.js +588 -2
  190. package/dist/wire-D2dT86vi.js +35 -0
  191. package/package.json +50 -10
  192. package/schemas/config-v1.json +131 -1
  193. package/schemas/doctor-report-v1.json +10 -0
  194. package/skills/better-supabase/SKILL.md +60 -10
  195. package/skills/better-supabase/references/plugins.md +13 -14
  196. package/skills/better-supabase/references/troubleshooting.md +25 -4
  197. package/skills/better-supabase-api/SKILL.md +74 -19
  198. package/skills/better-supabase-api/references/adapters.md +48 -27
  199. package/skills/better-supabase-auth/SKILL.md +149 -0
  200. package/skills/better-supabase-auth/references/permdock.md +100 -0
  201. package/skills/better-supabase-testing/SKILL.md +58 -4
  202. package/dist/claims-CoTobNC-.js +0 -25
  203. package/dist/events-Do8jXh4D.d.ts +0 -84
  204. package/dist/executor-DynmIWhq.d.ts +0 -195
  205. package/dist/invalidate-DbxuL2jL.js +0 -18
  206. package/dist/permdock-sql-DImJULY-.d.ts +0 -17
  207. package/dist/plugin-BqR6wKMB.js +0 -23
  208. package/dist/respond-C44EZAJo.js +0 -399
  209. package/dist/respond-DAkPIdTH.d.ts +0 -175
  210. package/dist/result-c2OYgCV2.d.ts +0 -203
  211. package/dist/view-wZ-9qIUz.js +0 -45
@@ -0,0 +1,1965 @@
1
+ import { n as CliError } from "./errors-4v4DTtda.js";
2
+ import { t as display } from "./io-k41_z-jT.js";
3
+ import { c as resolve$1, i as extname$1, n as basename$1, o as join$1, r as dirname$1, s as normalize$1, t as resolveModulePath } from "./dist-DBPdlPYK.js";
4
+ import { _ as unknown, a as literal, c as objectWithRest, f as record, g as union, h as string, i as getDotPath, l as optional, m as strictObject, n as boolean, o as nullable, p as safeParse, r as custom, s as number, t as array, u as picklist } from "./dist-xn4wlboc.js";
5
+ import * as nodeUtil from "node:util";
6
+ import { join, posix, resolve } from "node:path";
7
+ import { existsSync, readFileSync, statSync } from "node:fs";
8
+ import { glob, readFile, rm } from "node:fs/promises";
9
+ import { pathToFileURL } from "node:url";
10
+ import { homedir } from "node:os";
11
+ import { resolveConfig } from "better-supabase/config";
12
+ //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/_chunks/libs/flat.mjs
13
+ function isBuffer(obj) {
14
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
15
+ }
16
+ function keyIdentity(key) {
17
+ return key;
18
+ }
19
+ function flatten(target, opts) {
20
+ opts = opts || {};
21
+ const delimiter = opts.delimiter || ".";
22
+ const maxDepth = opts.maxDepth;
23
+ const transformKey = opts.transformKey || keyIdentity;
24
+ const output = {};
25
+ function step(object, prev, currentDepth) {
26
+ currentDepth = currentDepth || 1;
27
+ Object.keys(object).forEach(function(key) {
28
+ const value = object[key];
29
+ const isarray = opts.safe && Array.isArray(value);
30
+ const type = Object.prototype.toString.call(value);
31
+ const isbuffer = isBuffer(value);
32
+ const isobject = type === "[object Object]" || type === "[object Array]";
33
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
34
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
35
+ output[newKey] = value;
36
+ });
37
+ }
38
+ step(target);
39
+ return output;
40
+ }
41
+ function unflatten(target, opts) {
42
+ opts = opts || {};
43
+ const delimiter = opts.delimiter || ".";
44
+ const overwrite = opts.overwrite || false;
45
+ const transformKey = opts.transformKey || keyIdentity;
46
+ const result = {};
47
+ if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
48
+ function getkey(key) {
49
+ const parsedKey = Number(key);
50
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
51
+ }
52
+ function addKeys(keyPrefix, recipient, target) {
53
+ return Object.keys(target).reduce(function(result, key) {
54
+ result[keyPrefix + delimiter + key] = target[key];
55
+ return result;
56
+ }, recipient);
57
+ }
58
+ function isEmpty(val) {
59
+ const type = Object.prototype.toString.call(val);
60
+ const isArray = type === "[object Array]";
61
+ const isObject = type === "[object Object]";
62
+ if (!val) return true;
63
+ else if (isArray) return !val.length;
64
+ else if (isObject) return !Object.keys(val).length;
65
+ }
66
+ target = Object.keys(target).reduce(function(result, key) {
67
+ const type = Object.prototype.toString.call(target[key]);
68
+ if (!(type === "[object Object]" || type === "[object Array]") || isEmpty(target[key])) {
69
+ result[key] = target[key];
70
+ return result;
71
+ } else return addKeys(key, result, flatten(target[key], opts));
72
+ }, {});
73
+ Object.keys(target).forEach(function(key) {
74
+ const split = key.split(delimiter).map(transformKey);
75
+ let key1 = getkey(split.shift());
76
+ let key2 = getkey(split[0]);
77
+ let recipient = result;
78
+ while (key2 !== void 0) {
79
+ if (key1 === "__proto__") return;
80
+ const type = Object.prototype.toString.call(recipient[key1]);
81
+ const isobject = type === "[object Object]" || type === "[object Array]";
82
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
83
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
84
+ recipient = recipient[key1];
85
+ if (split.length > 0) {
86
+ key1 = getkey(split.shift());
87
+ key2 = getkey(split[0]);
88
+ }
89
+ }
90
+ recipient[key1] = unflatten(target[key], opts);
91
+ });
92
+ return result;
93
+ }
94
+ //#endregion
95
+ //#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
96
+ const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
97
+ const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
98
+ const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
99
+ function jsonParseTransform(key, value) {
100
+ if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
101
+ warnKeyDropped(key);
102
+ return;
103
+ }
104
+ return value;
105
+ }
106
+ function warnKeyDropped(key) {
107
+ console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
108
+ }
109
+ function destr(value, options = {}) {
110
+ if (typeof value !== "string") return value;
111
+ if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
112
+ const _value = value.trim();
113
+ if (_value.length <= 9) switch (_value.toLowerCase()) {
114
+ case "true": return true;
115
+ case "false": return false;
116
+ case "undefined": return;
117
+ case "null": return null;
118
+ case "nan": return NaN;
119
+ case "infinity": return Number.POSITIVE_INFINITY;
120
+ case "-infinity": return Number.NEGATIVE_INFINITY;
121
+ }
122
+ if (!JsonSigRx.test(value)) {
123
+ if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
124
+ return value;
125
+ }
126
+ try {
127
+ if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
128
+ if (options.strict) throw new Error("[destr] Possible prototype pollution");
129
+ return JSON.parse(value, jsonParseTransform);
130
+ }
131
+ return JSON.parse(value);
132
+ } catch (error) {
133
+ if (options.strict) throw error;
134
+ return value;
135
+ }
136
+ }
137
+ //#endregion
138
+ //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
139
+ function isPlainObject(value) {
140
+ if (value === null || typeof value !== "object") return false;
141
+ const prototype = Object.getPrototypeOf(value);
142
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
143
+ if (Symbol.iterator in value) return false;
144
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
145
+ return true;
146
+ }
147
+ function _defu(baseObject, defaults, namespace = ".", merger) {
148
+ if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
149
+ const object = { ...defaults };
150
+ for (const key of Object.keys(baseObject)) {
151
+ if (key === "__proto__" || key === "constructor") continue;
152
+ const value = baseObject[key];
153
+ if (value === null || value === void 0) continue;
154
+ if (merger && merger(object, key, value, namespace)) continue;
155
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
156
+ else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
157
+ else object[key] = value;
158
+ }
159
+ return object;
160
+ }
161
+ function createDefu(merger) {
162
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
163
+ }
164
+ const defu = createDefu();
165
+ //#endregion
166
+ //#region ../../node_modules/.pnpm/rc9@3.1.0/node_modules/rc9/dist/index.mjs
167
+ const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
168
+ const RE_LINES = /\n|\r|\r\n/;
169
+ const defaults = {
170
+ name: ".conf",
171
+ dir: process.cwd(),
172
+ flat: false
173
+ };
174
+ function withDefaults(options) {
175
+ if (typeof options === "string") options = { name: options };
176
+ return {
177
+ ...defaults,
178
+ ...options
179
+ };
180
+ }
181
+ function parse$1(contents, options = {}) {
182
+ const config = {};
183
+ const lines = contents.split(RE_LINES);
184
+ for (const line of lines) {
185
+ const match = line.match(RE_KEY_VAL);
186
+ if (!match) continue;
187
+ const key = match[1];
188
+ if (!key || key === "__proto__" || key === "constructor") continue;
189
+ const value = destr((match[2] || "").trim());
190
+ if (key.endsWith("[]")) {
191
+ const nkey = key.slice(0, Math.max(0, key.length - 2));
192
+ config[nkey] = (config[nkey] || []).concat(value);
193
+ continue;
194
+ }
195
+ config[key] = value;
196
+ }
197
+ return options.flat ? config : unflatten(config, { overwrite: true });
198
+ }
199
+ function parseFile(path, options) {
200
+ if (!existsSync(path)) return {};
201
+ return parse$1(readFileSync(path, "utf8"), options);
202
+ }
203
+ function read(options) {
204
+ options = withDefaults(options);
205
+ return parseFile(resolve(options.dir, options.name), options);
206
+ }
207
+ function userConfigDir() {
208
+ return process.env.XDG_CONFIG_HOME || resolve(homedir(), ".config");
209
+ }
210
+ function readUserConfig(options) {
211
+ options = withDefaults(options);
212
+ options.dir = userConfigDir();
213
+ return read(options);
214
+ }
215
+ //#endregion
216
+ //#region ../../node_modules/.pnpm/c12@4.0.0-rc.2_dotenv@17.4.2_jiti@2.7.0_magicast@0.5.5/node_modules/c12/dist/index.mjs
217
+ async function setupDotenv(options) {
218
+ const targetEnvironment = options.env ?? process.env;
219
+ const environment = await loadDotenv({
220
+ cwd: options.cwd,
221
+ fileName: options.fileName ?? ".env",
222
+ env: targetEnvironment,
223
+ interpolate: options.interpolate ?? true,
224
+ expandFileReferences: options.expandFileReferences ?? false,
225
+ parse: options.parse
226
+ });
227
+ const dotenvVars = getDotEnvVars(targetEnvironment);
228
+ for (const key in environment) {
229
+ if (key.startsWith("_")) continue;
230
+ if (targetEnvironment[key] === void 0 || dotenvVars.has(key)) targetEnvironment[key] = environment[key];
231
+ }
232
+ return environment;
233
+ }
234
+ async function loadDotenv(options) {
235
+ const environment = Object.create(null);
236
+ const cwd = resolve$1(options.cwd || ".");
237
+ const _fileName = options.fileName || ".env";
238
+ const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
239
+ const dotenvVars = getDotEnvVars(options.env || {});
240
+ Object.assign(environment, options.env);
241
+ for (const file of dotenvFiles) {
242
+ const dotenvFile = resolve$1(cwd, file);
243
+ if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
244
+ const parsed = await readEnvFile(dotenvFile, options.parse);
245
+ for (const key in parsed) {
246
+ if (key in environment && !dotenvVars.has(key)) continue;
247
+ environment[key] = parsed[key];
248
+ dotenvVars.add(key);
249
+ }
250
+ }
251
+ if (options.expandFileReferences) {
252
+ for (const key in environment) if (key.endsWith("_FILE")) {
253
+ const targetKey = key.slice(0, -5);
254
+ if (environment[targetKey] === void 0) {
255
+ const filePath = environment[key];
256
+ if (filePath && statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
257
+ environment[targetKey] = readFileSync(filePath, "utf8").trim();
258
+ dotenvVars.add(targetKey);
259
+ }
260
+ }
261
+ }
262
+ }
263
+ if (options.interpolate) interpolate(environment);
264
+ return environment;
265
+ }
266
+ let _parseEnv = nodeUtil.parseEnv;
267
+ async function readEnvFile(path, parse) {
268
+ const src = readFileSync(path, "utf8");
269
+ if (parse) return parse(src);
270
+ if (!_parseEnv) try {
271
+ const dotenv = await import("dotenv");
272
+ _parseEnv = (src) => dotenv.parse(src);
273
+ } catch {
274
+ throw new Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.");
275
+ }
276
+ return _parseEnv(src);
277
+ }
278
+ function interpolate(target, source = {}, parse = (v) => v) {
279
+ function getValue(key) {
280
+ return source[key] === void 0 ? target[key] : source[key];
281
+ }
282
+ function interpolate(value, parents = []) {
283
+ if (typeof value !== "string") return value;
284
+ let result = "";
285
+ let index = 0;
286
+ while (index < value.length) {
287
+ const char = value[index];
288
+ if (char === "\\" && value[index + 1] === "$") {
289
+ result += "$";
290
+ index += 2;
291
+ continue;
292
+ }
293
+ const ref = char === "$" ? parseRef(value, index) : void 0;
294
+ if (!ref) {
295
+ result += char;
296
+ index++;
297
+ continue;
298
+ }
299
+ if (parents.includes(ref.key)) {
300
+ if (ref.defaultValue !== void 0) {
301
+ result += interpolate(ref.defaultValue, parents);
302
+ index = ref.end;
303
+ continue;
304
+ }
305
+ console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${ref.key} )`);
306
+ return "";
307
+ }
308
+ let resolved = interpolate(getValue(ref.key), [...parents, ref.key]);
309
+ if (ref.defaultValue !== void 0 && (resolved === void 0 || ref.operator === ":-" && resolved === "")) resolved = interpolate(ref.defaultValue, parents);
310
+ result += resolved === void 0 ? value.slice(index, ref.end) : resolved;
311
+ index = ref.end;
312
+ }
313
+ return parse(result);
314
+ }
315
+ for (const key in target) target[key] = interpolate(getValue(key));
316
+ }
317
+ const REF_NAME_RE = /\w+/y;
318
+ const BRACED_REF_NAME_RE = /[\w:]+/y;
319
+ function parseRef(input, start) {
320
+ let index = start + 1;
321
+ const braced = input[index] === "{";
322
+ if (braced) index++;
323
+ const nameRe = braced ? BRACED_REF_NAME_RE : REF_NAME_RE;
324
+ nameRe.lastIndex = index;
325
+ const name = nameRe.exec(input);
326
+ if (!name) return;
327
+ let key = name[0];
328
+ index = nameRe.lastIndex;
329
+ if (!braced) return {
330
+ key,
331
+ end: index
332
+ };
333
+ if (input[index] === "}") return {
334
+ key,
335
+ end: index + 1
336
+ };
337
+ if (input[index] === "-") {
338
+ let operator = "-";
339
+ if (key.endsWith(":")) {
340
+ key = key.slice(0, -1);
341
+ operator = ":-";
342
+ }
343
+ const defaultValue = key ? readDefault(input, index + 1) : void 0;
344
+ if (!defaultValue) return;
345
+ return {
346
+ key,
347
+ operator,
348
+ defaultValue: defaultValue.value,
349
+ end: defaultValue.end
350
+ };
351
+ }
352
+ return {
353
+ key,
354
+ end: index
355
+ };
356
+ }
357
+ function readDefault(input, start) {
358
+ let value = "";
359
+ let depth = 1;
360
+ for (let index = start; index < input.length; index++) {
361
+ const char = input[index];
362
+ if (char === "\\" && index + 1 < input.length) {
363
+ const next = input[index + 1];
364
+ value += next === "{" || next === "}" ? next : char + next;
365
+ index++;
366
+ continue;
367
+ }
368
+ if (char === "$" && input[index + 1] === "{") {
369
+ depth++;
370
+ value += "${";
371
+ index++;
372
+ continue;
373
+ }
374
+ if (char === "{") depth++;
375
+ if (char === "}") {
376
+ depth--;
377
+ if (depth === 0) return {
378
+ value,
379
+ end: index + 1
380
+ };
381
+ }
382
+ value += char;
383
+ }
384
+ }
385
+ function getDotEnvVars(targetEnvironment) {
386
+ const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
387
+ if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
388
+ return globalRegistry.get(targetEnvironment);
389
+ }
390
+ const _normalize = (p) => p?.replace(/\\/g, "/");
391
+ let importCounter = 0;
392
+ const ASYNC_LOADERS = {
393
+ ".json": () => JSON.parse,
394
+ ".yaml": () => import("./yaml-CYCbJ6et.js").then((r) => r.parseYAML),
395
+ ".yml": () => import("./yaml-CYCbJ6et.js").then((r) => r.parseYAML),
396
+ ".jsonc": () => import("./jsonc-BUniUpOk.js").then((r) => (source) => r.parseJSONC(source, { allowTrailingComma: true })),
397
+ ".json5": () => import("./json5-ChRycquj.js").then((r) => r.parseJSON5),
398
+ ".toml": () => import("./toml-DB-MNnFs.js").then((r) => r.parseTOML)
399
+ };
400
+ const SUPPORTED_EXTENSIONS = Object.freeze([
401
+ ".js",
402
+ ".ts",
403
+ ".mjs",
404
+ ".cjs",
405
+ ".mts",
406
+ ".cts",
407
+ ".json",
408
+ ".jsonc",
409
+ ".json5",
410
+ ".yaml",
411
+ ".yml",
412
+ ".toml"
413
+ ]);
414
+ async function loadConfig$1(options) {
415
+ options.cwd = resolve$1(process.cwd(), options.cwd || ".");
416
+ options.name = options.name || "config";
417
+ options.envName = options.envName ?? process.env.NODE_ENV;
418
+ options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
419
+ options.rcFile = options.rcFile ?? `.${options.name}rc`;
420
+ if (options.extend !== false) options.extend = {
421
+ extendKey: "extends",
422
+ ...options.extend
423
+ };
424
+ const _merger = options.merger || defu;
425
+ const r = {
426
+ config: {},
427
+ cwd: options.cwd,
428
+ configFile: resolve$1(options.cwd, options.configFile),
429
+ layers: [],
430
+ _configFile: void 0
431
+ };
432
+ const rawConfigs = {
433
+ overrides: options.overrides,
434
+ main: void 0,
435
+ rc: void 0,
436
+ packageJson: void 0,
437
+ defaultConfig: options.defaultConfig
438
+ };
439
+ if (options.dotenv) await setupDotenv({
440
+ cwd: options.cwd,
441
+ ...options.dotenv === true ? {} : options.dotenv
442
+ });
443
+ const _mainConfig = await resolveConfig$1(".", options);
444
+ if (_mainConfig.configFile) {
445
+ rawConfigs.main = _mainConfig.config;
446
+ r.configFile = _mainConfig.configFile;
447
+ r._configFile = _mainConfig._configFile;
448
+ }
449
+ if (_mainConfig.meta) r.meta = _mainConfig.meta;
450
+ if (options.rcFile) {
451
+ const rcSources = [];
452
+ rcSources.push(read({
453
+ name: options.rcFile,
454
+ dir: options.cwd
455
+ }));
456
+ if (options.globalRc) {
457
+ const { findWorkspaceDir } = await import("./dist-DreZ24Sz.js");
458
+ const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {});
459
+ if (workspaceDir) rcSources.push(read({
460
+ name: options.rcFile,
461
+ dir: workspaceDir
462
+ }));
463
+ rcSources.push(readUserConfig({ name: options.rcFile }));
464
+ rcSources.push(read({
465
+ name: options.rcFile,
466
+ dir: homedir()
467
+ }));
468
+ }
469
+ rawConfigs.rc = _merger({}, ...rcSources);
470
+ }
471
+ if (options.packageJson) {
472
+ const keys = (Array.isArray(options.packageJson) ? options.packageJson : [typeof options.packageJson === "string" ? options.packageJson : options.name]).filter((t) => t && typeof t === "string");
473
+ const { readPackageJSON } = await import("./dist-DreZ24Sz.js");
474
+ const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {});
475
+ rawConfigs.packageJson = _merger({}, ...keys.map((key) => pkgJsonFile?.[key]));
476
+ }
477
+ const configs = {};
478
+ for (const key in rawConfigs) {
479
+ const value = rawConfigs[key];
480
+ configs[key] = await (typeof value === "function" ? value({
481
+ configs,
482
+ rawConfigs
483
+ }) : value);
484
+ }
485
+ if (Array.isArray(configs.main)) r.config = configs.main;
486
+ else {
487
+ r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
488
+ if (options.extend) {
489
+ await extendConfig(r.config, options);
490
+ r.layers = r.config._layers;
491
+ delete r.config._layers;
492
+ r.config = _merger(r.config, ...r.layers.map((e) => e.config));
493
+ }
494
+ }
495
+ r.layers = [...[
496
+ configs.overrides && {
497
+ config: configs.overrides,
498
+ configFile: void 0,
499
+ cwd: void 0
500
+ },
501
+ {
502
+ config: configs.main,
503
+ configFile: options.configFile,
504
+ cwd: options.cwd
505
+ },
506
+ configs.rc && {
507
+ config: configs.rc,
508
+ configFile: options.rcFile
509
+ },
510
+ configs.packageJson && {
511
+ config: configs.packageJson,
512
+ configFile: "package.json"
513
+ }
514
+ ].filter((l) => l && l.config), ...r.layers];
515
+ if (options.defaults) r.config = _merger(r.config, options.defaults);
516
+ if (options.omit$Keys) {
517
+ for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
518
+ }
519
+ if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
520
+ if (options.schema != null) r.config = await validateConfig(r.config, options.schema);
521
+ return r;
522
+ }
523
+ async function extendConfig(config, options) {
524
+ config._layers = config._layers || [];
525
+ if (!options.extend) return;
526
+ let keys = options.extend.extendKey;
527
+ if (typeof keys === "string") keys = [keys];
528
+ const extendSources = [];
529
+ for (const key of keys) {
530
+ extendSources.push(...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(Boolean));
531
+ delete config[key];
532
+ }
533
+ for (let extendSource of extendSources) {
534
+ const originalExtendSource = extendSource;
535
+ let sourceOptions = {};
536
+ if (extendSource.source) {
537
+ sourceOptions = extendSource.options || {};
538
+ extendSource = extendSource.source;
539
+ }
540
+ if (Array.isArray(extendSource)) {
541
+ sourceOptions = extendSource[1] || {};
542
+ extendSource = extendSource[0];
543
+ }
544
+ if (typeof extendSource !== "string") {
545
+ console.warn(`Cannot extend config from \`${JSON.stringify(originalExtendSource)}\` in ${options.cwd}`);
546
+ continue;
547
+ }
548
+ const _config = await resolveConfig$1(extendSource, options, sourceOptions);
549
+ if (!_config.config) {
550
+ console.warn(`Cannot extend config from \`${extendSource}\` in ${options.cwd}`);
551
+ continue;
552
+ }
553
+ await extendConfig(_config.config, {
554
+ ...options,
555
+ cwd: _config.cwd
556
+ });
557
+ config._layers.push(_config);
558
+ if (_config.config._layers) {
559
+ config._layers.push(..._config.config._layers);
560
+ delete _config.config._layers;
561
+ }
562
+ }
563
+ }
564
+ const GIGET_PREFIXES = [
565
+ "gh:",
566
+ "github:",
567
+ "gitlab:",
568
+ "bitbucket:",
569
+ "https://",
570
+ "http://"
571
+ ];
572
+ const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
573
+ async function resolveConfig$1(source, options, sourceOptions = {}) {
574
+ if (options.resolve) {
575
+ const res = await options.resolve(source, options);
576
+ if (res) return res;
577
+ }
578
+ const _merger = options.merger || defu;
579
+ const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
580
+ const gigetPrefixes = customProviderKeys.length > 0 ? [.../* @__PURE__ */ new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
581
+ if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
582
+ const { downloadTemplate } = await import("giget").catch((error) => {
583
+ throw new Error(`Extending config from \`${source}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``, { cause: error });
584
+ });
585
+ const { digest } = await import("./ohash-D7bG_EOb.js").then((n) => n.dist_exports);
586
+ const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
587
+ let cloneDir;
588
+ const localNodeModules = resolve$1(options.cwd, "node_modules");
589
+ const parentDir = dirname$1(options.cwd);
590
+ if (basename$1(parentDir) === ".c12") cloneDir = join$1(parentDir, cloneName);
591
+ else if (existsSync(localNodeModules)) cloneDir = join$1(localNodeModules, ".c12", cloneName);
592
+ else cloneDir = process.env.XDG_CACHE_HOME ? resolve$1(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve$1(homedir(), ".cache/c12", cloneName);
593
+ const install = sourceOptions.install ? defu(sourceOptions.install === true ? {} : sourceOptions.install, { ignoreWorkspace: true }) : false;
594
+ if (existsSync(cloneDir) && !install) await rm(cloneDir, { recursive: true });
595
+ source = (await downloadTemplate(source, {
596
+ dir: cloneDir,
597
+ install,
598
+ force: Boolean(install),
599
+ auth: sourceOptions.auth,
600
+ ...options.giget,
601
+ ...sourceOptions.giget
602
+ })).dir;
603
+ }
604
+ if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
605
+ const ext = extname$1(source);
606
+ const isDir = _isDirectory(resolve$1(options.cwd, source)) ?? (!ext || ext === basename$1(source));
607
+ const cwd = resolve$1(options.cwd, isDir ? source : dirname$1(source));
608
+ if (isDir) source = options.configFile;
609
+ const res = {
610
+ config: void 0,
611
+ configFile: void 0,
612
+ cwd,
613
+ source,
614
+ sourceOptions
615
+ };
616
+ res.configFile = tryResolve(resolve$1(cwd, source), options) || tryResolve(resolve$1(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve$1(cwd, ".config", source), options) || source;
617
+ if (!existsSync(res.configFile)) return res;
618
+ res._configFile = res.configFile;
619
+ const configFileExt = extname$1(res.configFile) || "";
620
+ if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
621
+ else {
622
+ const _resolveModule = options.resolveModule || ((mod) => mod.default || mod);
623
+ if (options.import) res.config = _resolveModule(await options.import(res.configFile));
624
+ else {
625
+ const _configURL = pathToFileURL(res.configFile);
626
+ _configURL.search = `_${++importCounter}`;
627
+ res.config = await import(_configURL.href).then(_resolveModule, async (error) => {
628
+ const { createJiti } = await import("jiti").catch(() => {
629
+ throw new Error(`Failed to load config file \`${res.configFile}\`: ${error?.message}. Hint install \`jiti\` for compatibility.`, { cause: error });
630
+ });
631
+ const jiti = createJiti(join$1(options.cwd || ".", options.configFile || "/"), {
632
+ interopDefault: true,
633
+ moduleCache: false,
634
+ extensions: [...SUPPORTED_EXTENSIONS],
635
+ ...options.jitiOptions
636
+ });
637
+ options.import = (id) => jiti.import(id);
638
+ return _resolveModule(await options.import(res.configFile));
639
+ });
640
+ }
641
+ }
642
+ if (typeof res.config === "function") res.config = await res.config(options.context);
643
+ if (res.config && typeof res.config === "object" && !Array.isArray(res.config) && !Object.isExtensible(res.config)) res.config = { ...res.config };
644
+ const envConfigs = (Array.isArray(options.envName) ? options.envName : [options.envName]).filter(Boolean).reverse().flatMap((envName) => [res.config.$env?.[envName], res.config["$" + envName]]).filter((c) => c && Object.keys(c).length > 0);
645
+ if (envConfigs.length > 0) res.config = (options.envMerger || _merger)({}, ...envConfigs, res.config);
646
+ res.meta = defu(res.sourceOptions.meta, res.config.$meta);
647
+ delete res.config.$meta;
648
+ if (res.sourceOptions.overrides) res.config = _merger(res.sourceOptions.overrides, res.config);
649
+ res.configFile = _normalize(res.configFile);
650
+ res.source = _normalize(res.source);
651
+ return res;
652
+ }
653
+ async function validateConfig(config, schema) {
654
+ if (typeof schema?.["~standard"]?.validate !== "function") throw new TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");
655
+ const result = await schema["~standard"].validate(config);
656
+ if (result.issues) {
657
+ const messages = result.issues.map((issue) => {
658
+ const path = issue.path?.map((p) => String(typeof p === "object" ? p.key : p)).join(".");
659
+ return ` - ${path ? `${path}: ` : ""}${issue.message}`;
660
+ });
661
+ throw new Error(`Config validation failed (${schema["~standard"].vendor}):\n${messages.join("\n")}`, { cause: result.issues });
662
+ }
663
+ return result.value;
664
+ }
665
+ function tryResolve(id, options) {
666
+ const res = resolveModulePath(id, {
667
+ try: true,
668
+ from: pathToFileURL(join$1(options.cwd || ".", options.configFile || "/")),
669
+ suffixes: ["", "/index"],
670
+ extensions: SUPPORTED_EXTENSIONS,
671
+ cache: false
672
+ });
673
+ return res ? normalize$1(res) : void 0;
674
+ }
675
+ function _isDirectory(path) {
676
+ try {
677
+ return statSync(path).isDirectory();
678
+ } catch {
679
+ return null;
680
+ }
681
+ }
682
+ //#endregion
683
+ //#region src/cli/config-schema.ts
684
+ const strings = array(string());
685
+ const stringRecord = record(string(), string());
686
+ const privileges = array(picklist([
687
+ "select",
688
+ "insert",
689
+ "update",
690
+ "delete"
691
+ ]));
692
+ const pluginFlag = union([boolean(), record(string(), unknown())]);
693
+ const isGenerator = (value) => typeof value === "object" && value !== null && "name" in value && typeof value.name === "string" && "generate" in value && typeof value.generate === "function";
694
+ /**
695
+ * The top level of `better-supabase.config.*`. It rejects unknown keys and
696
+ * checks the leaves a typo or an old value breaks; nested objects the
697
+ * library reads loosely stay loose.
698
+ */
699
+ const kitModuleEntries = {
700
+ mode: optional(picklist([
701
+ "managed",
702
+ "adopt",
703
+ "custom"
704
+ ])),
705
+ schema: optional(string()),
706
+ tables: optional(record(string(), nullable(string()))),
707
+ columns: optional(record(string(), record(string(), nullable(string())))),
708
+ idType: optional(string()),
709
+ permissions: optional(stringRecord),
710
+ options: optional(record(string(), unknown())),
711
+ hooks: optional(strictObject({
712
+ schema: optional(string()),
713
+ functions: optional(stringRecord)
714
+ })),
715
+ events: optional(boolean())
716
+ };
717
+ const accessKit = strictObject({
718
+ ...kitModuleEntries,
719
+ model: optional(picklist([
720
+ "roles",
721
+ "catalog",
722
+ "permdock",
723
+ "custom"
724
+ ])),
725
+ roles: optional(record(string(), strings)),
726
+ functions: optional(strictObject({
727
+ can: optional(string()),
728
+ tenantIdsWith: optional(string()),
729
+ isPlatform: optional(string()),
730
+ canUser: optional(string()),
731
+ canAssign: optional(string()),
732
+ permissionClaims: optional(string())
733
+ })),
734
+ platformClaim: optional(string()),
735
+ disabled: optional(strictObject({
736
+ tenant: optional(string()),
737
+ user: optional(string()),
738
+ userKey: optional(string())
739
+ })),
740
+ activeTenant: optional(union([picklist(["claim", "resolver"]), strictObject({
741
+ profileColumn: string(),
742
+ key: optional(string())
743
+ })])),
744
+ permdock: optional(strictObject({
745
+ schema: optional(string()),
746
+ scope: optional(string())
747
+ }))
748
+ });
749
+ const ConfigSchema = strictObject({
750
+ $schema: optional(string()),
751
+ source: optional(strictObject({
752
+ dbUrl: optional(string()),
753
+ projectRef: optional(string()),
754
+ accessToken: optional(string()),
755
+ snapshot: optional(string())
756
+ })),
757
+ schemas: optional(strings),
758
+ casing: optional(picklist(["snake", "camel"])),
759
+ tables: optional(record(string(), strictObject({
760
+ casing: optional(picklist(["snake", "camel"])),
761
+ exclude: optional(boolean()),
762
+ relations: optional(stringRecord)
763
+ }))),
764
+ output: optional(string()),
765
+ postgrestVersion: optional(string()),
766
+ json: optional(record(string(), unknown())),
767
+ codecs: optional(strictObject({
768
+ timestamptz: optional(picklist(["string", "instant"])),
769
+ int8: optional(picklist([
770
+ "number",
771
+ "string",
772
+ "bigint"
773
+ ])),
774
+ numeric: optional(picklist(["number", "string"]))
775
+ })),
776
+ sensitive: optional(strings),
777
+ storagePaths: optional(stringRecord),
778
+ expose: optional(record(string(), union([privileges, strictObject({
779
+ anon: optional(privileges),
780
+ authenticated: optional(privileges)
781
+ })]))),
782
+ readSets: optional(strings),
783
+ generators: optional(array(custom(isGenerator, "must be a generator: { name, generate(input) }"))),
784
+ plugins: optional(strictObject({
785
+ timestamps: optional(pluginFlag),
786
+ softDelete: optional(pluginFlag),
787
+ tenant: optional(pluginFlag),
788
+ actor: optional(pluginFlag)
789
+ })),
790
+ claims: optional(strictObject({
791
+ tenant: optional(string()),
792
+ scope: optional(string()),
793
+ features: optional(string())
794
+ })),
795
+ buckets: optional(record(string(), record(string(), unknown()))),
796
+ topics: optional(stringRecord),
797
+ realtime: optional(strictObject({
798
+ tables: optional(strings),
799
+ global: optional(strings)
800
+ })),
801
+ entitlements: optional(strictObject({
802
+ customer: optional(string()),
803
+ key: optional(string()),
804
+ permdock: optional(union([literal(false), strictObject({ scope: optional(string()) })]))
805
+ })),
806
+ permdock: optional(strictObject({
807
+ manifest: optional(string()),
808
+ catalog: optional(string())
809
+ })),
810
+ vectorSearch: optional(record(string(), union([string(), strictObject({
811
+ column: string(),
812
+ distance: optional(picklist([
813
+ "cosine",
814
+ "l2",
815
+ "inner_product"
816
+ ]))
817
+ })]))),
818
+ sql: optional(strictObject({
819
+ dir: optional(string()),
820
+ prefix: optional(string()),
821
+ testsDir: optional(string()),
822
+ kit: optional(strings)
823
+ })),
824
+ kits: optional(objectWithRest({ access: optional(accessKit) }, strictObject(kitModuleEntries))),
825
+ seed: optional(strictObject({
826
+ entry: optional(string()),
827
+ output: optional(string())
828
+ })),
829
+ openapi: optional(strictObject({
830
+ entry: optional(string()),
831
+ output: optional(string())
832
+ })),
833
+ doctor: optional(strictObject({
834
+ ignore: optional(strings),
835
+ strict: optional(boolean()),
836
+ sources: optional(strings),
837
+ policyHelperLimit: optional(number()),
838
+ claimsLimit: optional(number())
839
+ }))
840
+ });
841
+ /** Each issue as `path: message`, the path in config keys. */
842
+ function configIssues(value) {
843
+ const result = safeParse(ConfigSchema, value);
844
+ if (result.success) return [];
845
+ return result.issues.map((issue) => {
846
+ const path = getDotPath(issue);
847
+ return path ? `${path}: ${issue.message}` : issue.message;
848
+ });
849
+ }
850
+ //#endregion
851
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/error.js
852
+ /*!
853
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
854
+ * SPDX-License-Identifier: BSD-3-Clause
855
+ *
856
+ * Redistribution and use in source and binary forms, with or without
857
+ * modification, are permitted provided that the following conditions are met:
858
+ *
859
+ * 1. Redistributions of source code must retain the above copyright notice, this
860
+ * list of conditions and the following disclaimer.
861
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
862
+ * this list of conditions and the following disclaimer in the
863
+ * documentation and/or other materials provided with the distribution.
864
+ * 3. Neither the name of the copyright holder nor the names of its contributors
865
+ * may be used to endorse or promote products derived from this software without
866
+ * specific prior written permission.
867
+ *
868
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
869
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
870
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
871
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
872
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
873
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
874
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
875
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
876
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
877
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
878
+ */
879
+ function getLineColFromPtr(string, ptr) {
880
+ let lines = string.slice(0, ptr).split(/\r?\n/);
881
+ return [lines.length, lines.pop().length + 1];
882
+ }
883
+ function makeCodeBlock(string, line, column) {
884
+ let lines = string.split(/\r?\n/);
885
+ let codeblock = "";
886
+ let numberLen = (Math.log10(line + 1) | 0) + 1;
887
+ for (let i = line - 1; i <= line + 1; i++) {
888
+ let l = lines[i - 1];
889
+ if (!l) continue;
890
+ codeblock += i.toString().padEnd(numberLen, " ");
891
+ codeblock += ": ";
892
+ codeblock += l;
893
+ codeblock += "\n";
894
+ if (i === line) {
895
+ codeblock += " ".repeat(numberLen + column + 2);
896
+ codeblock += "^\n";
897
+ }
898
+ }
899
+ return codeblock;
900
+ }
901
+ var TomlError = class TomlError extends Error {
902
+ line;
903
+ column;
904
+ codeblock;
905
+ constructor(message, options) {
906
+ const [line, column] = getLineColFromPtr(options.toml, options.ptr);
907
+ const codeblock = makeCodeBlock(options.toml, line, column);
908
+ super(`Invalid TOML document: ${message}\n\n${codeblock}`, options);
909
+ this.line = line;
910
+ this.column = column;
911
+ this.codeblock = codeblock;
912
+ }
913
+ /** @internal */
914
+ static x(message, ctx, ptr) {
915
+ throw new TomlError(message, {
916
+ toml: ctx.s,
917
+ ptr: ptr ?? ctx.p
918
+ });
919
+ }
920
+ };
921
+ //#endregion
922
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/primitive.js
923
+ /*!
924
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
925
+ * SPDX-License-Identifier: BSD-3-Clause
926
+ *
927
+ * Redistribution and use in source and binary forms, with or without
928
+ * modification, are permitted provided that the following conditions are met:
929
+ *
930
+ * 1. Redistributions of source code must retain the above copyright notice, this
931
+ * list of conditions and the following disclaimer.
932
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
933
+ * this list of conditions and the following disclaimer in the
934
+ * documentation and/or other materials provided with the distribution.
935
+ * 3. Neither the name of the copyright holder nor the names of its contributors
936
+ * may be used to endorse or promote products derived from this software without
937
+ * specific prior written permission.
938
+ *
939
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
940
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
941
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
942
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
943
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
944
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
945
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
946
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
947
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
948
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
949
+ */
950
+ /** @internal */
951
+ function parseString(ctx) {
952
+ let startPtr = ctx.p;
953
+ let c = ctx.s.charCodeAt(ctx.p++);
954
+ let first = c;
955
+ let isLiteral = c === 39;
956
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
957
+ if (isMultiline) {
958
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10) ctx.p++;
959
+ else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) ctx.p += 2;
960
+ }
961
+ let parsed = "";
962
+ let sliceStart = ctx.p;
963
+ let state = 0;
964
+ for (; ctx.p < ctx.s.length; ctx.p++) {
965
+ c = ctx.s.charCodeAt(ctx.p);
966
+ if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) state = state && 3;
967
+ else if (c < 32 && c !== 9 || c === 127) TomlError.x("control characters are not allowed in strings", ctx);
968
+ else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
969
+ if (isMultiline) {
970
+ if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
971
+ if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
972
+ }
973
+ if (!state) {
974
+ let s = ctx.s.slice(sliceStart, ctx.p);
975
+ parsed = parsed ? parsed + s : s;
976
+ }
977
+ ctx.p += isMultiline ? 3 : 1;
978
+ return parsed;
979
+ } else if (!state) {
980
+ if (!isLiteral && c === 92) {
981
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
982
+ state = 1;
983
+ }
984
+ } else if (state === 1) {
985
+ if (c === 120 || c === 117 || c === 85) {
986
+ let errPtr = ctx.p++ - 1;
987
+ let value = 0;
988
+ let len = c === 120 ? 2 : c === 117 ? 4 : 8;
989
+ for (let j = 0; j < len; j++, ctx.p++) {
990
+ let hex = ctx.s.charCodeAt(ctx.p);
991
+ let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
992
+ if (digit < 0) TomlError.x("invalid non-hex character in unicode escape", ctx);
993
+ value = value << 4 | digit;
994
+ }
995
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) TomlError.x("invalid unicode escape", ctx, errPtr);
996
+ parsed += String.fromCodePoint(value);
997
+ sliceStart = ctx.p--;
998
+ state = 0;
999
+ } else if (isMultiline && (c === 32 || c === 9)) state = 2;
1000
+ else {
1001
+ if (c === 98) parsed += "\b";
1002
+ else if (c === 116) parsed += " ";
1003
+ else if (c === 110) parsed += "\n";
1004
+ else if (c === 102) parsed += "\f";
1005
+ else if (c === 114) parsed += "\r";
1006
+ else if (c === 101) parsed += "\x1B";
1007
+ else if (c === 34) parsed += "\"";
1008
+ else if (c === 92) parsed += "\\";
1009
+ else TomlError.x("unrecognised escape sequence", ctx);
1010
+ sliceStart = ctx.p + 1;
1011
+ state = 0;
1012
+ }
1013
+ } else if (c !== 32 && c !== 9) {
1014
+ if (state === 2) TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
1015
+ state = !isLiteral && c === 92 ? 1 : 0;
1016
+ sliceStart = ctx.p;
1017
+ }
1018
+ }
1019
+ TomlError.x("unfinished string", ctx, startPtr);
1020
+ }
1021
+ //#endregion
1022
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/date.js
1023
+ /*!
1024
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1025
+ * SPDX-License-Identifier: BSD-3-Clause
1026
+ *
1027
+ * Redistribution and use in source and binary forms, with or without
1028
+ * modification, are permitted provided that the following conditions are met:
1029
+ *
1030
+ * 1. Redistributions of source code must retain the above copyright notice, this
1031
+ * list of conditions and the following disclaimer.
1032
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1033
+ * this list of conditions and the following disclaimer in the
1034
+ * documentation and/or other materials provided with the distribution.
1035
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1036
+ * may be used to endorse or promote products derived from this software without
1037
+ * specific prior written permission.
1038
+ *
1039
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1040
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1041
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1042
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1043
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1044
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1045
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1046
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1047
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1048
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1049
+ */
1050
+ let DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
1051
+ var TomlDate = class TomlDate extends Date {
1052
+ #hasDate = false;
1053
+ #hasTime = false;
1054
+ #offset = null;
1055
+ constructor(date, fasttype, unsafeDelim) {
1056
+ let hasDate = true;
1057
+ let hasTime = true;
1058
+ let offset = "Z";
1059
+ let c;
1060
+ if (typeof date === "string") {
1061
+ if (fasttype) prep: {
1062
+ if (fasttype < 3) {
1063
+ if (+date.slice(11, 13) > 23) {
1064
+ date = "";
1065
+ break prep;
1066
+ }
1067
+ if (fasttype === 2) {
1068
+ offset = null;
1069
+ date += "Z";
1070
+ } else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) offset = date.slice(date.length - 6);
1071
+ if (unsafeDelim) date = date.slice(0, 10) + "T" + date.slice(11);
1072
+ } else if (fasttype === 4) date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
1073
+ hasDate = fasttype !== 4;
1074
+ hasTime = fasttype !== 3;
1075
+ }
1076
+ else {
1077
+ let match = date.match(DATE_TIME_RE);
1078
+ if (match) {
1079
+ if (!match[1]) {
1080
+ hasDate = false;
1081
+ date = `0000-01-01T${date}`;
1082
+ }
1083
+ hasTime = !!match[2];
1084
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
1085
+ if (match[2] && +match[2] > 23) date = "";
1086
+ else {
1087
+ offset = match[3] || null;
1088
+ if (!offset && hasTime) date += "Z";
1089
+ }
1090
+ } else date = "";
1091
+ }
1092
+ }
1093
+ super(date);
1094
+ if (!isNaN(this.getTime())) {
1095
+ this.#hasDate = hasDate;
1096
+ this.#hasTime = hasTime;
1097
+ this.#offset = offset;
1098
+ }
1099
+ }
1100
+ isDateTime() {
1101
+ return this.#hasDate && this.#hasTime;
1102
+ }
1103
+ isLocal() {
1104
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
1105
+ }
1106
+ isDate() {
1107
+ return this.#hasDate && !this.#hasTime;
1108
+ }
1109
+ isTime() {
1110
+ return this.#hasTime && !this.#hasDate;
1111
+ }
1112
+ isValid() {
1113
+ return this.#hasDate || this.#hasTime;
1114
+ }
1115
+ toISOString() {
1116
+ let iso = super.toISOString();
1117
+ if (this.isDate()) return iso.slice(0, 10);
1118
+ if (this.isTime()) return iso.slice(11, 23);
1119
+ if (this.#offset === null) return iso.slice(0, -1);
1120
+ if (this.#offset === "Z" || this.#offset === "z") return iso;
1121
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
1122
+ offset = this.#offset[0] === "-" ? offset : -offset;
1123
+ return (/* @__PURE__ */ new Date(this.getTime() - offset * 6e4)).toISOString().slice(0, -1) + this.#offset;
1124
+ }
1125
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
1126
+ let date = new TomlDate(jsDate);
1127
+ date.#offset = offset;
1128
+ return date;
1129
+ }
1130
+ static wrapAsLocalDateTime(jsDate) {
1131
+ let date = new TomlDate(jsDate);
1132
+ date.#offset = null;
1133
+ return date;
1134
+ }
1135
+ static wrapAsLocalDate(jsDate) {
1136
+ let date = new TomlDate(jsDate);
1137
+ date.#hasTime = false;
1138
+ date.#offset = null;
1139
+ return date;
1140
+ }
1141
+ static wrapAsLocalTime(jsDate) {
1142
+ let date = new TomlDate(jsDate);
1143
+ date.#hasDate = false;
1144
+ date.#offset = null;
1145
+ return date;
1146
+ }
1147
+ };
1148
+ //#endregion
1149
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/extract.js
1150
+ /*!
1151
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1152
+ * SPDX-License-Identifier: BSD-3-Clause
1153
+ *
1154
+ * Redistribution and use in source and binary forms, with or without
1155
+ * modification, are permitted provided that the following conditions are met:
1156
+ *
1157
+ * 1. Redistributions of source code must retain the above copyright notice, this
1158
+ * list of conditions and the following disclaimer.
1159
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1160
+ * this list of conditions and the following disclaimer in the
1161
+ * documentation and/or other materials provided with the distribution.
1162
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1163
+ * may be used to endorse or promote products derived from this software without
1164
+ * specific prior written permission.
1165
+ *
1166
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1167
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1168
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1169
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1170
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1171
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1172
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1173
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1174
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1175
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1176
+ */
1177
+ function isDigit(char, base = 10) {
1178
+ return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
1179
+ }
1180
+ function isEndOfValue(char, delim) {
1181
+ return char === 32 || char === 9 || char === 10 || char === 13 || delim && (char === delim || char === 44) || char === 35;
1182
+ }
1183
+ /** @internal */
1184
+ function extractValue(ctx, end) {
1185
+ let errPtr = ctx.p;
1186
+ let c = ctx.s.charCodeAt(ctx.p);
1187
+ if (c === 91 || c === 123) {
1188
+ ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
1189
+ let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
1190
+ ctx.d++;
1191
+ return value;
1192
+ }
1193
+ if (c === 34 || c === 39) return parseString(ctx);
1194
+ if (c === 116) {
1195
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101) TomlError.x("invalid value", ctx, errPtr);
1196
+ return ctx.p++, true;
1197
+ }
1198
+ if (c === 102) {
1199
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101) TomlError.x("invalid value", ctx, errPtr);
1200
+ return ctx.p++, false;
1201
+ }
1202
+ if (c === 43 || c === 45) return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
1203
+ if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) return parseDate(ctx, c, end);
1204
+ if (ctx.s.charCodeAt(ctx.p + 2) === 58) return parseTime(ctx, c, end);
1205
+ return parseNumber(ctx, ctx.p, c, 0, end);
1206
+ }
1207
+ function parseNumber(ctx, startPtr, startChr, sign, endChr) {
1208
+ let c = startChr;
1209
+ let state = 0;
1210
+ let hasUnderscores = false;
1211
+ if (c === 105) {
1212
+ if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102) TomlError.x("invalid value", ctx, startPtr);
1213
+ return ctx.p++, (sign || 1) / 0;
1214
+ }
1215
+ if (c === 110) {
1216
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110) TomlError.x("invalid value", ctx, startPtr);
1217
+ return ctx.p++, NaN;
1218
+ }
1219
+ if (c === 48) {
1220
+ if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr)) return ctx.bi === true ? 0n : 0;
1221
+ if (!sign) {
1222
+ if (c === 120) return parseIntegerBaseN(ctx, startPtr, 16, endChr);
1223
+ else if (c === 98) return parseIntegerBaseN(ctx, startPtr, 2, endChr);
1224
+ else if (c === 111) return parseIntegerBaseN(ctx, startPtr, 8, endChr);
1225
+ }
1226
+ if (c === 46) state = 2;
1227
+ else if (c === 101 || c === 69) state = 4;
1228
+ else TomlError.x("illegal leading zero", ctx, startPtr);
1229
+ } else if (!isDigit(c)) TomlError.x("invalid value", ctx, startPtr);
1230
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
1231
+ if (!state) state = 1;
1232
+ if (c === 95) {
1233
+ if (!(state & 1)) TomlError.x("illegal underscore", ctx);
1234
+ state += 11;
1235
+ hasUnderscores = true;
1236
+ } else if (state === 1 && c === 46) state = 2;
1237
+ else if ((state === 1 || state === 3) && (c === 101 || c === 69)) state = 4;
1238
+ else if (state === 4 && (c === 43 || c === 45)) {} else if (!isDigit(c)) TomlError.x(`illegal character in numeric literal`, ctx);
1239
+ else if (state > 9) state -= 11;
1240
+ else if (!(state & 1)) state++;
1241
+ }
1242
+ if (!state) {
1243
+ let val = (startChr - 48) * (sign || 1);
1244
+ return ctx.bi === true ? BigInt(val) : val;
1245
+ }
1246
+ if (!(state & 1)) TomlError.x("unfinished numeric value", ctx, startPtr);
1247
+ let str = ctx.s.slice(startPtr, ctx.p);
1248
+ if (hasUnderscores) str = str.replaceAll("_", "");
1249
+ return state > 1 ? parseFloat(str) : parseInteger(ctx, str, 10, startPtr);
1250
+ }
1251
+ function parseIntegerBaseN(ctx, startPtr, base, endChr) {
1252
+ let c, underscore = 1;
1253
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) if (c === 95) {
1254
+ if (underscore & 1) TomlError.x("illegal underscore", ctx);
1255
+ underscore = 3;
1256
+ } else if (!isDigit(c, base)) TomlError.x(`illegal character in numeric literal`, ctx);
1257
+ else if (underscore & 1) underscore--;
1258
+ if (underscore & 1) TomlError.x("unfinished numeric value", ctx);
1259
+ let str = ctx.s.slice(startPtr + 2, ctx.p);
1260
+ if (underscore) str = str.replaceAll("_", "");
1261
+ return parseInteger(ctx, str, base, startPtr);
1262
+ }
1263
+ function parseInteger(ctx, str, base, startPtr) {
1264
+ if (ctx.bi !== true) int: {
1265
+ let val = parseInt(str, base);
1266
+ if (!Number.isSafeInteger(val)) {
1267
+ if (ctx.bi) break int;
1268
+ TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
1269
+ }
1270
+ return val;
1271
+ }
1272
+ return base === 10 ? BigInt(str) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str);
1273
+ }
1274
+ function parseDate(ctx, c, endChr) {
1275
+ let startPtr = ctx.p++, unsafeSeparator;
1276
+ if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++)) || !isDigit(ctx.s.charCodeAt(ctx.p++))) return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
1277
+ ctx.p += 5;
1278
+ if (!isDigit(ctx.s.charCodeAt(ctx.p++))) TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
1279
+ if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) return readDate(ctx, ctx.s.slice(startPtr, ctx.p), 3, false, startPtr);
1280
+ if (ctx.s.charCodeAt(ctx.p += 3) !== 58) TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
1281
+ if (ctx.s.charCodeAt(ctx.p += 3) === 58) ctx.p += 3;
1282
+ if (ctx.s.charCodeAt(ctx.p) === 46) while (isDigit(ctx.s.charCodeAt(++ctx.p)));
1283
+ if (c = ctx.s.charCodeAt(ctx.p)) {
1284
+ if (c === 90 || c === 122) return readDate(ctx, ctx.s.slice(startPtr, ++ctx.p), 1, unsafeSeparator, startPtr, "[+00:00]");
1285
+ if (c === 43 || c === 45) return readDate(ctx, ctx.s.slice(startPtr, ctx.p += 6), 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
1286
+ }
1287
+ return readDate(ctx, ctx.s.slice(startPtr, ctx.p), 2, unsafeSeparator, startPtr);
1288
+ }
1289
+ function parseTime(ctx, c, endChr) {
1290
+ let start = ctx.p;
1291
+ if (!isDigit(c) || !isDigit(ctx.s.charCodeAt(++ctx.p))) return parseNumber(ctx, --ctx.p, c, 0, endChr);
1292
+ if (ctx.s.charCodeAt(ctx.p += 4) === 58) ctx.p += 3;
1293
+ if (ctx.s.charCodeAt(ctx.p) === 46) while (isDigit(ctx.s.charCodeAt(++ctx.p)));
1294
+ return readDate(ctx, ctx.s.slice(start, ctx.p), 4, false, start);
1295
+ }
1296
+ function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
1297
+ if (ctx.ld) {
1298
+ let date = new TomlDate(str, type, unsafeDelim);
1299
+ if (!date.isValid()) TomlError.x("invalid date", ctx, errPtr);
1300
+ return date;
1301
+ }
1302
+ try {
1303
+ if (temporalSuffix) str += temporalSuffix;
1304
+ switch (type) {
1305
+ case 1: return Temporal.ZonedDateTime.from(str);
1306
+ case 2: return Temporal.PlainDateTime.from(str);
1307
+ case 3: return Temporal.PlainDate.from(str);
1308
+ case 4: return Temporal.PlainTime.from(str);
1309
+ }
1310
+ } catch (e) {
1311
+ TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
1312
+ }
1313
+ }
1314
+ //#endregion
1315
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/util.js
1316
+ /*!
1317
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1318
+ * SPDX-License-Identifier: BSD-3-Clause
1319
+ *
1320
+ * Redistribution and use in source and binary forms, with or without
1321
+ * modification, are permitted provided that the following conditions are met:
1322
+ *
1323
+ * 1. Redistributions of source code must retain the above copyright notice, this
1324
+ * list of conditions and the following disclaimer.
1325
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1326
+ * this list of conditions and the following disclaimer in the
1327
+ * documentation and/or other materials provided with the distribution.
1328
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1329
+ * may be used to endorse or promote products derived from this software without
1330
+ * specific prior written permission.
1331
+ *
1332
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1333
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1334
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1335
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1336
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1337
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1338
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1339
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1340
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1341
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1342
+ */
1343
+ /** @internal */
1344
+ function skipComment(ctx) {
1345
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1346
+ let c = ctx.s.charCodeAt(ctx.p);
1347
+ if (c === 10) break;
1348
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
1349
+ ctx.p++;
1350
+ break;
1351
+ }
1352
+ if (c < 32 && c !== 9 || c === 127) TomlError.x("control characters are not allowed in comments", ctx);
1353
+ }
1354
+ }
1355
+ /** @internal */
1356
+ function skipVoid(ctx, banNewLines, banComments) {
1357
+ let c;
1358
+ while (ctx.p < ctx.s.length) {
1359
+ while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))) ctx.p++;
1360
+ if (banComments || c !== 35) break;
1361
+ skipComment(ctx);
1362
+ }
1363
+ }
1364
+ //#endregion
1365
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/struct.js
1366
+ /*!
1367
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1368
+ * SPDX-License-Identifier: BSD-3-Clause
1369
+ *
1370
+ * Redistribution and use in source and binary forms, with or without
1371
+ * modification, are permitted provided that the following conditions are met:
1372
+ *
1373
+ * 1. Redistributions of source code must retain the above copyright notice, this
1374
+ * list of conditions and the following disclaimer.
1375
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1376
+ * this list of conditions and the following disclaimer in the
1377
+ * documentation and/or other materials provided with the distribution.
1378
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1379
+ * may be used to endorse or promote products derived from this software without
1380
+ * specific prior written permission.
1381
+ *
1382
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1383
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1384
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1385
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1386
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1387
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1388
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1389
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1390
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1391
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1392
+ */
1393
+ /** @internal */
1394
+ function parseKey(ctx, end = 61) {
1395
+ let startPtr;
1396
+ let state = 0;
1397
+ let parsed = [];
1398
+ let sliceStart;
1399
+ let c = ctx.s.charCodeAt(startPtr = ctx.p);
1400
+ do
1401
+ if (c === end) {
1402
+ if (!state) TomlError.x("unexpected end of key", ctx);
1403
+ if (state === 1) parsed.push(ctx.s.slice(sliceStart, ctx.p));
1404
+ return ctx.p++, parsed;
1405
+ } else if (c === 46) {
1406
+ if (!state) TomlError.x("illegal empty bare key", ctx);
1407
+ if (state === 1) parsed.push(ctx.s.slice(sliceStart, ctx.p));
1408
+ state = 0;
1409
+ } else if (!state && (c === 34 || c === 39)) {
1410
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
1411
+ parsed.push(parseString(ctx));
1412
+ state = 2;
1413
+ ctx.p--;
1414
+ } else if (c === 32 || c === 9) {
1415
+ if (state === 1) {
1416
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
1417
+ state = 2;
1418
+ }
1419
+ } else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) TomlError.x("illegal character in key", ctx);
1420
+ else if (!state) {
1421
+ state = 1;
1422
+ sliceStart = ctx.p;
1423
+ }
1424
+ while (c = ctx.s.charCodeAt(++ctx.p));
1425
+ TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
1426
+ }
1427
+ /** @internal */
1428
+ function parseInlineTable(ctx) {
1429
+ let startPtr = ctx.p++;
1430
+ let res = Object.create(null);
1431
+ let seen = /* @__PURE__ */ new Set();
1432
+ let c;
1433
+ while (ctx.p < ctx.s.length) {
1434
+ skipVoid(ctx);
1435
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
1436
+ ctx.p++;
1437
+ return res;
1438
+ }
1439
+ let k;
1440
+ let t = res;
1441
+ let hasOwn = false;
1442
+ let errPtr = ctx.p;
1443
+ let key = parseKey(ctx);
1444
+ for (let i = 0; i < key.length; i++) {
1445
+ if (i) t = hasOwn ? t[k] : t[k] = Object.create(null);
1446
+ k = key[i];
1447
+ if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) TomlError.x("trying to redefine an already defined value", ctx, errPtr);
1448
+ let unsafe = k === "__proto__";
1449
+ if (ctx.uk && (unsafe || k === "constructor")) {
1450
+ t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
1451
+ break;
1452
+ }
1453
+ if (!hasOwn && unsafe) Object.defineProperty(t, k, {
1454
+ enumerable: true,
1455
+ configurable: true,
1456
+ writable: true
1457
+ });
1458
+ }
1459
+ if (hasOwn) TomlError.x("trying to redefine an already defined value", ctx, errPtr);
1460
+ skipVoid(ctx, true, true);
1461
+ let value = extractValue(ctx, 125);
1462
+ if (t && typeof (t[k] = value) === "object") seen.add(value);
1463
+ skipVoid(ctx);
1464
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) return res;
1465
+ if (c !== 44) TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
1466
+ }
1467
+ TomlError.x("unfinished table", ctx, startPtr);
1468
+ }
1469
+ /** @internal */
1470
+ function parseArray(ctx) {
1471
+ let startPtr = ctx.p++;
1472
+ let res = [];
1473
+ let c;
1474
+ while (ctx.p < ctx.s.length) {
1475
+ skipVoid(ctx);
1476
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
1477
+ ctx.p++;
1478
+ return res;
1479
+ }
1480
+ res.push(extractValue(ctx, 93));
1481
+ skipVoid(ctx);
1482
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) return res;
1483
+ if (c !== 44) TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
1484
+ }
1485
+ TomlError.x("unfinished array", ctx, startPtr);
1486
+ }
1487
+ //#endregion
1488
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/parse.js
1489
+ /*!
1490
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1491
+ * SPDX-License-Identifier: BSD-3-Clause
1492
+ *
1493
+ * Redistribution and use in source and binary forms, with or without
1494
+ * modification, are permitted provided that the following conditions are met:
1495
+ *
1496
+ * 1. Redistributions of source code must retain the above copyright notice, this
1497
+ * list of conditions and the following disclaimer.
1498
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1499
+ * this list of conditions and the following disclaimer in the
1500
+ * documentation and/or other materials provided with the distribution.
1501
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1502
+ * may be used to endorse or promote products derived from this software without
1503
+ * specific prior written permission.
1504
+ *
1505
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1506
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1507
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1508
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1509
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1510
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1511
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1512
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1513
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1514
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1515
+ */
1516
+ function peekTable(ctx, key, table, meta, type) {
1517
+ let t = table;
1518
+ let m = meta;
1519
+ let k;
1520
+ let hasOwn = false;
1521
+ let state;
1522
+ for (let i = 0; i < key.length; i++) {
1523
+ if (i) {
1524
+ t = hasOwn ? t[k] : t[k] = Object.create(null);
1525
+ m = (state = m[k]).c;
1526
+ if (type === 0 && (state.t === 1 || state.t === 2)) return null;
1527
+ if (state.t === 2) {
1528
+ let l = t.length - 1;
1529
+ t = t[l];
1530
+ m = m[l].c;
1531
+ }
1532
+ }
1533
+ k = key[i];
1534
+ if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) return null;
1535
+ if (!hasOwn) {
1536
+ let unsafe = k === "__proto__";
1537
+ if (ctx.uk && (unsafe || k === "constructor")) return false;
1538
+ if (unsafe) {
1539
+ Object.defineProperty(t, k, {
1540
+ enumerable: true,
1541
+ configurable: true,
1542
+ writable: true
1543
+ });
1544
+ Object.defineProperty(m, k, {
1545
+ enumerable: true,
1546
+ configurable: true,
1547
+ writable: true
1548
+ });
1549
+ }
1550
+ m[k] = {
1551
+ t: i < key.length - 1 && type === 2 ? 3 : type,
1552
+ d: false,
1553
+ i: 0,
1554
+ c: Object.create(null)
1555
+ };
1556
+ }
1557
+ }
1558
+ state = m[k];
1559
+ if (state.t !== type && !(type === 1 && state.t === 3)) return null;
1560
+ if (type === 2) {
1561
+ if (!state.d) {
1562
+ state.d = true;
1563
+ t[k] = [];
1564
+ }
1565
+ t[k].push(t = Object.create(null));
1566
+ state.c[state.i++] = state = {
1567
+ t: 1,
1568
+ d: false,
1569
+ i: 0,
1570
+ c: Object.create(null)
1571
+ };
1572
+ }
1573
+ if (state.d) return null;
1574
+ state.d = true;
1575
+ if (type === 1) t = hasOwn ? t[k] : t[k] = Object.create(null);
1576
+ else if (type === 0 && hasOwn) return null;
1577
+ return [
1578
+ k,
1579
+ t,
1580
+ state.c
1581
+ ];
1582
+ }
1583
+ function validateTablePeek(ctx, peek, ptr) {
1584
+ if (peek === null || ctx.uk === 2) TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
1585
+ }
1586
+ function parse(toml, options = {}) {
1587
+ let ctx = {
1588
+ s: toml,
1589
+ p: 0,
1590
+ d: options.maxDepth ?? 1e3,
1591
+ bi: options.integersAsBigInt ?? false,
1592
+ ld: options.useLegacyDate ?? true,
1593
+ uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
1594
+ };
1595
+ let res = Object.create(null);
1596
+ let meta = Object.create(null);
1597
+ let tmp;
1598
+ let skipping = false;
1599
+ let tbl = res;
1600
+ let m = meta;
1601
+ if (toml.charCodeAt(0) === 65279) ctx.p++;
1602
+ skipVoid(ctx);
1603
+ while (ctx.p < toml.length) {
1604
+ if (toml.charCodeAt(ctx.p) === 91) {
1605
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1606
+ tmp = ctx.p += +isTableArray;
1607
+ skipping = false;
1608
+ let k = parseKey(ctx, 93);
1609
+ if (isTableArray) {
1610
+ if (toml.charCodeAt(ctx.p) !== 93) TomlError.x("expected end of table array declaration", ctx);
1611
+ ctx.p++;
1612
+ }
1613
+ let p = peekTable(ctx, k, res, meta, isTableArray ? 2 : 1);
1614
+ if (!p) {
1615
+ validateTablePeek(ctx, p, tmp);
1616
+ skipping = true;
1617
+ } else {
1618
+ m = p[2];
1619
+ tbl = p[1];
1620
+ }
1621
+ } else {
1622
+ tmp = ctx.p;
1623
+ let p = peekTable(ctx, parseKey(ctx), tbl, m, 0);
1624
+ if (!p && !skipping) validateTablePeek(ctx, p, tmp);
1625
+ skipVoid(ctx, true, true);
1626
+ let v = extractValue(ctx, void 0);
1627
+ if (p && !skipping) p[1][p[0]] = v;
1628
+ }
1629
+ skipVoid(ctx, true);
1630
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
1631
+ skipVoid(ctx);
1632
+ }
1633
+ return res;
1634
+ }
1635
+ /*!
1636
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1637
+ * SPDX-License-Identifier: BSD-3-Clause
1638
+ *
1639
+ * Redistribution and use in source and binary forms, with or without
1640
+ * modification, are permitted provided that the following conditions are met:
1641
+ *
1642
+ * 1. Redistributions of source code must retain the above copyright notice, this
1643
+ * list of conditions and the following disclaimer.
1644
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1645
+ * this list of conditions and the following disclaimer in the
1646
+ * documentation and/or other materials provided with the distribution.
1647
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1648
+ * may be used to endorse or promote products derived from this software without
1649
+ * specific prior written permission.
1650
+ *
1651
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1652
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1653
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1654
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1655
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1656
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1657
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1658
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1659
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1660
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1661
+ */
1662
+ "".isWellFormed;
1663
+ //#endregion
1664
+ //#region ../../node_modules/.pnpm/smol-toml@1.9.0/node_modules/smol-toml/dist/index.js
1665
+ /*!
1666
+ * Copyright (c) Squirrel Chat et al., All rights reserved.
1667
+ * SPDX-License-Identifier: BSD-3-Clause
1668
+ *
1669
+ * Redistribution and use in source and binary forms, with or without
1670
+ * modification, are permitted provided that the following conditions are met:
1671
+ *
1672
+ * 1. Redistributions of source code must retain the above copyright notice, this
1673
+ * list of conditions and the following disclaimer.
1674
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
1675
+ * this list of conditions and the following disclaimer in the
1676
+ * documentation and/or other materials provided with the distribution.
1677
+ * 3. Neither the name of the copyright holder nor the names of its contributors
1678
+ * may be used to endorse or promote products derived from this software without
1679
+ * specific prior written permission.
1680
+ *
1681
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1682
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1683
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1684
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1685
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1686
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1687
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1688
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1689
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1690
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1691
+ */
1692
+ //#endregion
1693
+ //#region src/cli/supabase-toml.ts
1694
+ const CONFIG_TOML = "supabase/config.toml";
1695
+ /**
1696
+ * `@supabase/config` is an optional peer (it needs `effect` and
1697
+ * `@effect/platform-node`), so it is imported lazily through a variable:
1698
+ * projects without it get smol-toml instead of a load error.
1699
+ */
1700
+ async function loadSupabaseConfig() {
1701
+ const specifier = "@supabase/config/io";
1702
+ try {
1703
+ return await import(specifier);
1704
+ } catch {
1705
+ return;
1706
+ }
1707
+ }
1708
+ function toTomlValue(value) {
1709
+ if (Array.isArray(value)) return value.map(toTomlValue);
1710
+ if (value instanceof Date) return value.toISOString();
1711
+ if (typeof value === "bigint") return Number(value);
1712
+ if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, toTomlValue(item)]));
1713
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return value;
1714
+ return String(value);
1715
+ }
1716
+ /** `text` as TOML, with dates as ISO strings; an empty table when it does not parse. */
1717
+ function parseToml(text) {
1718
+ try {
1719
+ return Object.fromEntries(Object.entries(parse(text)).map(([key, value]) => [key, toTomlValue(value)]));
1720
+ } catch {
1721
+ return {};
1722
+ }
1723
+ }
1724
+ const parsed = /* @__PURE__ */ new Map();
1725
+ /**
1726
+ * Reads `supabase/config.toml`. A file with `env()` values goes through
1727
+ * `@supabase/config` when it is installed, which resolves them; any other
1728
+ * file, or a project without it, is parsed with smol-toml, since loading
1729
+ * `@supabase/config` costs hundreds of milliseconds. Parses are reused while
1730
+ * the file's text is unchanged.
1731
+ */
1732
+ async function readSupabaseToml(root) {
1733
+ const absolute = join(root, CONFIG_TOML);
1734
+ if (!existsSync(absolute)) return void 0;
1735
+ const text = await readFile(absolute, "utf8");
1736
+ const cached = parsed.get(absolute);
1737
+ if (cached?.text === text) return cached.toml;
1738
+ const toml = parseSupabaseToml(root, text);
1739
+ parsed.set(absolute, {
1740
+ text,
1741
+ toml
1742
+ });
1743
+ return toml;
1744
+ }
1745
+ async function parseSupabaseToml(root, text) {
1746
+ const io = text.includes("env(") ? await loadSupabaseConfig() : void 0;
1747
+ if (io) try {
1748
+ const loaded = await io.loadCliConfig(root, {
1749
+ tomlOnly: true,
1750
+ search: false
1751
+ });
1752
+ if (loaded?.document) return {
1753
+ path: CONFIG_TOML,
1754
+ text,
1755
+ document: loaded.document,
1756
+ parser: "@supabase/config"
1757
+ };
1758
+ } catch {}
1759
+ return {
1760
+ path: CONFIG_TOML,
1761
+ text,
1762
+ document: parseToml(text),
1763
+ parser: "smol-toml"
1764
+ };
1765
+ }
1766
+ /** The value at `path` (`['auth', 'jwt_expiry']`), if present. */
1767
+ function tomlGet(document, path) {
1768
+ let value = document;
1769
+ for (const key of path) {
1770
+ if (typeof value !== "object" || Array.isArray(value)) return void 0;
1771
+ value = value[key];
1772
+ }
1773
+ return value;
1774
+ }
1775
+ function tomlNumber(document, path) {
1776
+ const value = tomlGet(document, path);
1777
+ if (typeof value === "number") return value;
1778
+ if (typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value))) return Number(value);
1779
+ }
1780
+ /** `pg-functions://postgres/<schema>/<function>` as schema and name. */
1781
+ function parsePgFunctionUri(uri) {
1782
+ const match = /^pg-functions:\/\/[^/]+\/([^/]+)\/([^/?#]+)$/.exec(uri.trim());
1783
+ return match ? {
1784
+ schema: match[1],
1785
+ name: match[2]
1786
+ } : void 0;
1787
+ }
1788
+ /** The enabled Auth hooks with a `pg-functions://` URI, by hook name. */
1789
+ function pgFunctionHooks(document) {
1790
+ const hooks = tomlGet(document, ["auth", "hook"]);
1791
+ if (typeof hooks !== "object" || Array.isArray(hooks)) return [];
1792
+ return Object.entries(hooks).flatMap(([hook, table]) => {
1793
+ if (typeof table !== "object" || Array.isArray(table)) return [];
1794
+ const { enabled, uri } = table;
1795
+ if (enabled !== true && enabled !== "true" || typeof uri !== "string") return [];
1796
+ const target = parsePgFunctionUri(uri);
1797
+ return target ? [{
1798
+ hook,
1799
+ uri,
1800
+ ...target
1801
+ }] : [];
1802
+ });
1803
+ }
1804
+ /** The enabled Auth hooks with an `http://` or `https://` URI, by hook name. */
1805
+ function httpHooks(document) {
1806
+ const hooks = tomlGet(document, ["auth", "hook"]);
1807
+ if (typeof hooks !== "object" || Array.isArray(hooks)) return [];
1808
+ return Object.entries(hooks).flatMap(([hook, table]) => {
1809
+ if (typeof table !== "object" || Array.isArray(table)) return [];
1810
+ const { enabled, uri, secrets } = table;
1811
+ if (enabled !== true && enabled !== "true" || typeof uri !== "string") return [];
1812
+ if (!/^https?:\/\//i.test(uri.trim()) || !URL.canParse(uri.trim())) return [];
1813
+ return [{
1814
+ hook,
1815
+ uri: new URL(uri.trim()),
1816
+ secrets: typeof secrets === "string" ? secrets : void 0
1817
+ }];
1818
+ });
1819
+ }
1820
+ /** pg-delta when `[experimental.pgdelta] enabled = true`, otherwise the legacy migra engine. */
1821
+ function diffEngine(toml) {
1822
+ const enabled = tomlGet(toml?.document ?? {}, [
1823
+ "experimental",
1824
+ "pgdelta",
1825
+ "enabled"
1826
+ ]);
1827
+ return enabled === true || enabled === "true" ? "pg-delta" : "migra";
1828
+ }
1829
+ /** The command that writes a migration (named `name`, when given) from `supabase/schemas`. */
1830
+ function migrationCommand(toml, name) {
1831
+ const command = diffEngine(toml) === "pg-delta" ? "supabase db schema declarative sync" : "supabase db diff";
1832
+ return name === void 0 ? command : `${command} -f ${name}`;
1833
+ }
1834
+ const SCHEMAS_DIR = "supabase/schemas";
1835
+ /** `experimental.pgdelta.declarative_schema_path` (relative to `supabase/`), or `./schemas`. */
1836
+ function pgDeltaSchemasDir(toml) {
1837
+ const dir = tomlGet(toml?.document ?? {}, [
1838
+ "experimental",
1839
+ "pgdelta",
1840
+ "declarative_schema_path"
1841
+ ]);
1842
+ const relative = typeof dir === "string" && dir.trim() !== "" ? dir : "schemas";
1843
+ return posix.join("supabase", relative.replace(/^\.\//, "").replace(/\/$/, ""));
1844
+ }
1845
+ async function expand(cwd, pattern) {
1846
+ const matched = [];
1847
+ for await (const path of glob(pattern.replace(/^\.\//, ""), { cwd })) if (path.endsWith(".sql")) matched.push(path.replaceAll("\\", "/"));
1848
+ return matched.sort();
1849
+ }
1850
+ /**
1851
+ * `[db.migrations] schema_paths` (relative to `supabase/`) with each glob
1852
+ * expanded in name order and the entries kept in their listed order, then
1853
+ * the `supabase/schemas` files no entry matches. Without `schema_paths`, the
1854
+ * `supabase/schemas` files in name order, as the Supabase CLI reads them.
1855
+ * pg-delta ignores `schema_paths` and orders by dependency, so under it every
1856
+ * file in its schema directory counts, in name order.
1857
+ */
1858
+ async function schemaPaths(root, toml) {
1859
+ if (diffEngine(toml) === "pg-delta") {
1860
+ const dir = pgDeltaSchemasDir(toml);
1861
+ return {
1862
+ files: existsSync(join(root, dir)) ? await expand(root, `${dir}/**/*.sql`) : [],
1863
+ unlisted: [],
1864
+ configured: false
1865
+ };
1866
+ }
1867
+ const supabase = join(root, "supabase");
1868
+ const all = existsSync(join(root, SCHEMAS_DIR)) ? (await expand(supabase, "schemas/**/*.sql")).map((path) => posix.join("supabase", path)) : [];
1869
+ const entries = tomlGet(toml?.document ?? {}, [
1870
+ "db",
1871
+ "migrations",
1872
+ "schema_paths"
1873
+ ]);
1874
+ const patterns = Array.isArray(entries) ? entries.filter((entry) => typeof entry === "string") : [];
1875
+ if (patterns.length === 0) return {
1876
+ files: all,
1877
+ unlisted: [],
1878
+ configured: false
1879
+ };
1880
+ const listed = /* @__PURE__ */ new Set();
1881
+ for (const pattern of patterns) for (const path of await expand(supabase, pattern)) listed.add(posix.join("supabase", path));
1882
+ const unlisted = all.filter((path) => !listed.has(path));
1883
+ return {
1884
+ files: [...listed, ...unlisted],
1885
+ unlisted,
1886
+ configured: true
1887
+ };
1888
+ }
1889
+ //#endregion
1890
+ //#region src/cli/config.ts
1891
+ const CONFIG_FILES = [
1892
+ "better-supabase.config.ts",
1893
+ "better-supabase.config.mts",
1894
+ "better-supabase.config.js",
1895
+ "better-supabase.config.mjs",
1896
+ "better-supabase.config.json"
1897
+ ];
1898
+ function findConfig(cwd, explicit) {
1899
+ if (explicit) return resolve(cwd, explicit);
1900
+ for (const name of CONFIG_FILES) {
1901
+ const path = join(cwd, name);
1902
+ if (existsSync(path)) return path;
1903
+ }
1904
+ }
1905
+ /** Imports a project module fresh, so watch loops and tests see edits. */
1906
+ async function importModule(path) {
1907
+ return await import(`${pathToFileURL(path).href}?t=${Date.now()}`);
1908
+ }
1909
+ /** The named export, then `default`, of a project module. */
1910
+ async function importExport(path, name) {
1911
+ if (!existsSync(path)) throw new Error(`Module not found: ${path}`);
1912
+ const loaded = await importModule(path);
1913
+ return loaded[name] ?? loaded["default"];
1914
+ }
1915
+ function isConfig(value) {
1916
+ return configIssues(value).length === 0;
1917
+ }
1918
+ /**
1919
+ * Loads `better-supabase.config.*` with c12 and checks it against the config
1920
+ * schema. c12 imports `.ts` natively (Node 24 strips the types), so no
1921
+ * loader is needed; rc files, `package.json`, env overrides and `extends`
1922
+ * are off so the one file is the whole config.
1923
+ */
1924
+ async function loadConfig(cwd, explicit) {
1925
+ const path = findConfig(cwd, explicit);
1926
+ if (!path) return resolveConfig({}, cwd);
1927
+ if (!existsSync(path)) throw new CliError("config_not_found", `Config file not found: ${path}`);
1928
+ const { config } = await loadConfig$1({
1929
+ cwd,
1930
+ configFile: path,
1931
+ rcFile: false,
1932
+ globalRc: false,
1933
+ packageJson: false,
1934
+ dotenv: false,
1935
+ envName: false,
1936
+ extend: false,
1937
+ giget: false
1938
+ });
1939
+ if (!isConfig(config)) {
1940
+ const issues = configIssues(config);
1941
+ throw new CliError("config_invalid", `${display(cwd, path)} is not a valid config:\n${issues.map((issue) => ` ${issue}`).join("\n")}`, { issues });
1942
+ }
1943
+ return resolveConfig(config, cwd);
1944
+ }
1945
+ /** `[db] port` or `[api] port` from `supabase/config.toml`. */
1946
+ async function readSupabasePort(root, section) {
1947
+ const toml = await readSupabaseToml(root);
1948
+ return toml ? tomlNumber(toml.document, [section, "port"]) : void 0;
1949
+ }
1950
+ /** The connection string piped in for `--db-url-stdin`, when it was passed. */
1951
+ async function stdinDatabaseUrl(enabled, io) {
1952
+ if (enabled !== true) return void 0;
1953
+ const url = (await io.stdin?.())?.trim();
1954
+ if (!url) throw new CliError("missing_value", "--db-url-stdin read nothing from stdin. Pipe the connection string: printf %s \"$URL\" | better-supabase <command> --db-url-stdin", { flag: "--db-url-stdin" });
1955
+ return url;
1956
+ }
1957
+ /** Connection string: stdin, config, `$DATABASE_URL`, then the local stack. */
1958
+ async function databaseUrl(config, env, fromStdin) {
1959
+ if (fromStdin) return fromStdin;
1960
+ if (config.source.dbUrl) return config.source.dbUrl;
1961
+ if (env.DATABASE_URL) return env.DATABASE_URL;
1962
+ return `postgresql://postgres:postgres@127.0.0.1:${await readSupabasePort(config.root, "db") ?? 54322}/postgres`;
1963
+ }
1964
+ //#endregion
1965
+ export { loadConfig as a, diffEngine as c, pgFunctionHooks as d, readSupabaseToml as f, importModule as i, httpHooks as l, tomlGet as m, findConfig as n, readSupabasePort as o, schemaPaths as p, importExport as r, stdinDatabaseUrl as s, databaseUrl as t, migrationCommand as u };