better-supabase 0.0.0 → 0.1.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 (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -1
  3. package/bin/better-supabase.js +3 -0
  4. package/dist/casing-da0uRTqt.js +14 -0
  5. package/dist/cli/bin.d.ts +1 -0
  6. package/dist/cli/bin.js +15 -0
  7. package/dist/cli/index.d.ts +226 -0
  8. package/dist/cli/index.js +3 -0
  9. package/dist/cli-CoByWYja.js +6472 -0
  10. package/dist/client/index.d.ts +2 -0
  11. package/dist/client/index.js +112 -0
  12. package/dist/compiler-DL18ukPe.d.ts +14 -0
  13. package/dist/config/index.d.ts +3 -0
  14. package/dist/config/index.js +3 -0
  15. package/dist/config-D-aR2ZoN.js +276 -0
  16. package/dist/define-CTfWw-SS.d.ts +662 -0
  17. package/dist/define-QGkq04oe.js +1068 -0
  18. package/dist/edge/index.d.ts +43 -0
  19. package/dist/edge/index.js +103 -0
  20. package/dist/entitlements-BBg61DQZ.d.ts +20 -0
  21. package/dist/entitlements-BC_khwRy.js +17 -0
  22. package/dist/env/index.d.ts +2 -0
  23. package/dist/env/index.js +2 -0
  24. package/dist/env-BEToab0I.js +204 -0
  25. package/dist/errors-Bl3rkOzo.js +196 -0
  26. package/dist/events/index.d.ts +2 -0
  27. package/dist/events/index.js +2 -0
  28. package/dist/events-2OJsVG_d.d.ts +84 -0
  29. package/dist/events-BuzTgn2D.js +135 -0
  30. package/dist/executor-Bazhgsgq.d.ts +195 -0
  31. package/dist/executor-Bje4suQF.d.ts +25 -0
  32. package/dist/executor-Ceq60hPM.js +89 -0
  33. package/dist/hono/index.d.ts +45 -0
  34. package/dist/hono/index.js +70 -0
  35. package/dist/index-BD6wKthp.d.ts +597 -0
  36. package/dist/index-DQVvHzjW.d.ts +74 -0
  37. package/dist/index-DRid0qIv.d.ts +76 -0
  38. package/dist/index-Dup-nSe9.d.ts +117 -0
  39. package/dist/index-Dy6kuF0P.d.ts +71 -0
  40. package/dist/index-Hf8PP9sP.d.ts +116 -0
  41. package/dist/index-JXHBuS53.d.ts +144 -0
  42. package/dist/index-Nxo3TJcm.d.ts +208 -0
  43. package/dist/index-Sw43J8HG.d.ts +62 -0
  44. package/dist/index-cEeweTeM.d.ts +38 -0
  45. package/dist/index.d.ts +110 -0
  46. package/dist/index.js +42 -0
  47. package/dist/invalidate-DbxuL2jL.js +18 -0
  48. package/dist/jobs/index.d.ts +173 -0
  49. package/dist/jobs/index.js +477 -0
  50. package/dist/json-schema-BbwO2mZg.js +181 -0
  51. package/dist/lint/index.d.ts +75 -0
  52. package/dist/lint/index.js +167 -0
  53. package/dist/list/index.d.ts +2 -0
  54. package/dist/list/index.js +410 -0
  55. package/dist/live-6b9i72Ux.d.ts +180 -0
  56. package/dist/live-D8rV1Ldw.js +168 -0
  57. package/dist/mcp/index.d.ts +105 -0
  58. package/dist/mcp/index.js +330 -0
  59. package/dist/mfa-CpogP66z.js +521 -0
  60. package/dist/mfa-TVia554c.d.ts +44 -0
  61. package/dist/next/image/index.d.ts +34 -0
  62. package/dist/next/image/index.js +40 -0
  63. package/dist/next/index.d.ts +210 -0
  64. package/dist/next/index.js +426 -0
  65. package/dist/openapi/index.d.ts +2 -0
  66. package/dist/openapi/index.js +332 -0
  67. package/dist/orpc/index.d.ts +46 -0
  68. package/dist/orpc/index.js +50 -0
  69. package/dist/otel/index.d.ts +40 -0
  70. package/dist/otel/index.js +168 -0
  71. package/dist/path-Cv__-OTj.d.ts +17 -0
  72. package/dist/plugin-BqR6wKMB.js +23 -0
  73. package/dist/plugin-HvGqCurB.d.ts +118 -0
  74. package/dist/plugins/actor/index.d.ts +13 -0
  75. package/dist/plugins/actor/index.js +43 -0
  76. package/dist/plugins/rules/index.d.ts +88 -0
  77. package/dist/plugins/rules/index.js +174 -0
  78. package/dist/plugins/soft-delete/index.d.ts +38 -0
  79. package/dist/plugins/soft-delete/index.js +69 -0
  80. package/dist/plugins/tenant/index.d.ts +43 -0
  81. package/dist/plugins/tenant/index.js +73 -0
  82. package/dist/plugins/timestamps/index.d.ts +9 -0
  83. package/dist/plugins/timestamps/index.js +37 -0
  84. package/dist/plugins/validation/index.d.ts +24 -0
  85. package/dist/plugins/validation/index.js +59 -0
  86. package/dist/pool-BFeqzwQS.d.ts +37 -0
  87. package/dist/postgres/index.d.ts +28 -0
  88. package/dist/postgres/index.js +79 -0
  89. package/dist/postgrest-Dm-vhY6R.d.ts +43 -0
  90. package/dist/problem-DPu6Fh-t.js +97 -0
  91. package/dist/problem-DlgB0lYl.d.ts +47 -0
  92. package/dist/query/index.d.ts +2 -0
  93. package/dist/query/index.js +3 -0
  94. package/dist/query-ChvDbsDE.js +186 -0
  95. package/dist/react/index.d.ts +7 -0
  96. package/dist/react/index.js +5 -0
  97. package/dist/react/server.d.ts +13 -0
  98. package/dist/react/server.js +25 -0
  99. package/dist/react/session.d.ts +2 -0
  100. package/dist/react/session.js +3 -0
  101. package/dist/react-CrOvrnIP.js +241 -0
  102. package/dist/read-set-DhX2d04c.js +216 -0
  103. package/dist/realtime/index.d.ts +3 -0
  104. package/dist/realtime/index.js +253 -0
  105. package/dist/resolve-DW8h9NPm.d.ts +155 -0
  106. package/dist/resource-CYiu6Ygi.js +175 -0
  107. package/dist/resource-SkPTRJDD.d.ts +65 -0
  108. package/dist/respond-4-dhoV7x.js +380 -0
  109. package/dist/respond-PoTpy5DT.d.ts +169 -0
  110. package/dist/result-CTkCZ6JA.d.ts +198 -0
  111. package/dist/result-DWXatkd6.js +103 -0
  112. package/dist/scope-CDHcS7dE.js +90 -0
  113. package/dist/seed-CzecODcJ.js +101 -0
  114. package/dist/server/index.d.ts +42 -0
  115. package/dist/server/index.js +68 -0
  116. package/dist/session-C3osL21k.d.ts +21 -0
  117. package/dist/session-CD-3orO_.js +19 -0
  118. package/dist/shared-_6-uPL7E.js +57 -0
  119. package/dist/simplify-oHiDKRVQ.js +665 -0
  120. package/dist/spec-pins-CJPVghHy.d.ts +20 -0
  121. package/dist/spec-pins-t6sPaHvl.js +20 -0
  122. package/dist/sql-M8l3fnS0.js +260 -0
  123. package/dist/ssr/index.d.ts +5 -0
  124. package/dist/ssr/index.js +4 -0
  125. package/dist/standard-CyhRzctb.d.ts +7 -0
  126. package/dist/standard-FUi3Z3-7.js +21 -0
  127. package/dist/stats-3iy8u3_P.js +566 -0
  128. package/dist/storage/index.d.ts +4 -0
  129. package/dist/storage/index.js +2 -0
  130. package/dist/storage-BWXVUXGk.js +461 -0
  131. package/dist/tables-rZxRxNPW.js +59 -0
  132. package/dist/template-BeOGnynM.js +93 -0
  133. package/dist/template-mbvlysOo.d.ts +6 -0
  134. package/dist/testing/index.d.ts +294 -0
  135. package/dist/testing/index.js +751 -0
  136. package/dist/types-6cYK9pbJ.js +29 -0
  137. package/dist/types-C2fslP1z.d.ts +195 -0
  138. package/dist/version-Cqq1m3UY.js +4 -0
  139. package/dist/view-B0ltUmTi.d.ts +43 -0
  140. package/dist/view-B6F9QbG-.js +35 -0
  141. package/dist/webhooks/index.d.ts +152 -0
  142. package/dist/webhooks/index.js +2 -0
  143. package/dist/webhooks-DbMTJJX2.js +139 -0
  144. package/package.json +246 -17
  145. package/schemas/config-v1.json +328 -0
  146. package/schemas/doctor-report-v1.json +105 -0
  147. package/schemas/snapshot-v2.json +1002 -0
  148. package/skills/better-supabase/SKILL.md +84 -0
  149. package/skills/better-supabase/references/plugins.md +56 -0
  150. package/skills/better-supabase/references/troubleshooting.md +39 -0
  151. package/skills/better-supabase-api/SKILL.md +67 -0
  152. package/skills/better-supabase-api/references/adapters.md +108 -0
  153. package/skills/better-supabase-testing/SKILL.md +65 -0
  154. package/index.js +0 -1
@@ -0,0 +1,260 @@
1
+ import { a as invalidRequest, n as simplifyOrFalse } from "./simplify-oHiDKRVQ.js";
2
+ //#region src/compile/sql.ts
3
+ const MAX_PAIRS = 50;
4
+ function quoteIdent(name) {
5
+ return `"${name.replaceAll("\"", "\"\"")}"`;
6
+ }
7
+ function tableRef(table) {
8
+ return `${quoteIdent(table.schema)}.${quoteIdent(table.name)}`;
9
+ }
10
+ function dbColumn(table, app) {
11
+ const meta = table.columns[app];
12
+ if (!meta) invalidRequest(`Unknown column "${app}" on "${table.key}"`, table.key);
13
+ return meta.db;
14
+ }
15
+ function columnType(table, db) {
16
+ return Object.values(table.columns).find((meta) => meta.db === db)?.type;
17
+ }
18
+ var SqlCompiler = class {
19
+ params = [];
20
+ #aliases = 0;
21
+ alias() {
22
+ const alias = `t${this.#aliases}`;
23
+ this.#aliases += 1;
24
+ return alias;
25
+ }
26
+ param(value, cast) {
27
+ this.params.push(value);
28
+ return cast ? `$${this.params.length}::${cast}` : `$${this.params.length}`;
29
+ }
30
+ column(alias, name) {
31
+ return `${alias}.${quoteIdent(name)}`;
32
+ }
33
+ condition(condition, table, alias) {
34
+ switch (condition.kind) {
35
+ case "and":
36
+ case "or": {
37
+ if (condition.items.length === 0) return condition.kind === "and" ? "true" : "false";
38
+ const joiner = condition.kind === "and" ? " and " : " or ";
39
+ return `(${condition.items.map((item) => this.condition(item, table, alias)).join(joiner)})`;
40
+ }
41
+ case "not": return `not ${this.condition(condition.item, table, alias)}`;
42
+ case "column": return this.columnCondition(condition, table, alias);
43
+ case "relation": {
44
+ const target = this.alias();
45
+ const join = this.join(condition.relation, table, alias, condition.target, target);
46
+ const where = condition.quantifier === "every" && condition.where ? `not ${this.condition(condition.where, condition.target, target)}` : condition.where ? this.condition(condition.where, condition.target, target) : void 0;
47
+ const body = `select 1 from ${tableRef(condition.target)} as ${target} where ${join}${where ? ` and ${where}` : ""}`;
48
+ return condition.quantifier === "some" ? `exists (${body})` : `not exists (${body})`;
49
+ }
50
+ default: return condition;
51
+ }
52
+ }
53
+ columnCondition(condition, table, alias) {
54
+ const column = this.column(alias, condition.column);
55
+ const { value } = condition;
56
+ switch (condition.op) {
57
+ case "eq": return `${column} = ${this.param(value)}`;
58
+ case "neq": return `${column} <> ${this.param(value)}`;
59
+ case "gt": return `${column} > ${this.param(value)}`;
60
+ case "gte": return `${column} >= ${this.param(value)}`;
61
+ case "lt": return `${column} < ${this.param(value)}`;
62
+ case "lte": return `${column} <= ${this.param(value)}`;
63
+ case "like": return `${column} like ${this.param(value)}`;
64
+ case "ilike": return `${column} ilike ${this.param(value)}`;
65
+ case "in":
66
+ if (!Array.isArray(value)) invalidRequest("\"in\" needs an array");
67
+ return `${column} = any(${this.param(value)})`;
68
+ case "is":
69
+ if (value === null) return `${column} is null`;
70
+ if (value === true) return `${column} is true`;
71
+ if (value === false) return `${column} is false`;
72
+ return invalidRequest("\"is\" needs null, true or false");
73
+ case "contains":
74
+ case "containedBy":
75
+ case "overlaps": {
76
+ const operator = condition.op === "contains" ? "@>" : condition.op === "containedBy" ? "<@" : "&&";
77
+ return Array.isArray(value) ? `${column} ${operator} ${this.param(value)}` : `${column} ${operator} ${this.param(JSON.stringify(value), "jsonb")}`;
78
+ }
79
+ case "fts": {
80
+ const config = condition.config ? `${this.param(condition.config, "regconfig")}, ` : "";
81
+ const query = `websearch_to_tsquery(${config}${this.param(value)})`;
82
+ return `${columnType(table, condition.column) === "tsvector" ? column : `to_tsvector(${config}${column})`} @@ ${query}`;
83
+ }
84
+ default: return condition.op;
85
+ }
86
+ }
87
+ join(relation, source, sourceAlias, target, targetAlias) {
88
+ return relation.columns.map((column, index) => {
89
+ const reference = relation.references[index];
90
+ if (reference === void 0) invalidRequest(`Relation to "${target.key}" has mismatched columns`);
91
+ return `${this.column(targetAlias, dbColumn(target, reference))} = ${this.column(sourceAlias, dbColumn(source, column))}`;
92
+ }).join(" and ");
93
+ }
94
+ orderBy(terms, alias) {
95
+ return terms.map((term) => {
96
+ const nulls = term.nulls ? ` nulls ${term.nulls}` : "";
97
+ return `${this.column(alias, term.column)} ${term.direction}${nulls}`;
98
+ }).join(", ");
99
+ }
100
+ /** `json_build_object('alias', t0."col", ...)` for a selection. */
101
+ rowExpression(selection, table, alias) {
102
+ const pairs = selection.columns.map((entry) => `'${entry.alias.replaceAll("'", "''")}', ${this.column(alias, entry.column)}${entry.cast ? `::${entry.cast}` : ""}`);
103
+ if (selection.aggregate) {
104
+ if (selection.aggregate.count) pairs.push(`'_count', count(*)`);
105
+ for (const measure of selection.aggregate.measures) pairs.push(`'${measure.key.replaceAll("'", "''")}', ${measure.fn}(${this.column(alias, measure.column)})${measure.cast ? `::${measure.cast}` : ""}`);
106
+ }
107
+ for (const include of selection.includes) pairs.push(`'${include.alias.replaceAll("'", "''")}', ${this.include(include, table, alias)}`);
108
+ if (pairs.length <= MAX_PAIRS) return `json_build_object(${pairs.join(", ")})`;
109
+ const chunks = [];
110
+ for (let index = 0; index < pairs.length; index += MAX_PAIRS) chunks.push(`jsonb_build_object(${pairs.slice(index, index + MAX_PAIRS).join(", ")})`);
111
+ return `(${chunks.join(" || ")})::json`;
112
+ }
113
+ /** Conditions an include adds to its parent: `required` includes need a match. */
114
+ requiredIncludes(selection, table, alias) {
115
+ return selection.includes.filter((include) => include.required).map((include) => {
116
+ const target = this.alias();
117
+ const where = this.includeWhere(include, table, alias, target);
118
+ return `exists (select 1 from ${tableRef(include.target)} as ${target} where ${where})`;
119
+ });
120
+ }
121
+ includeWhere(include, parent, parentAlias, alias) {
122
+ const parts = [this.join(include.relation, parent, parentAlias, include.target, alias)];
123
+ const simple = simplifyOrFalse(include.where);
124
+ if (simple.never) parts.push("false");
125
+ else if (simple.condition) parts.push(this.condition(simple.condition, include.target, alias));
126
+ parts.push(...this.requiredIncludes(include.selection, include.target, alias));
127
+ return parts.join(" and ");
128
+ }
129
+ include(include, parent, parentAlias) {
130
+ const alias = this.alias();
131
+ const where = this.includeWhere(include, parent, parentAlias, alias);
132
+ const from = `from ${tableRef(include.target)} as ${alias} where ${where}`;
133
+ if (include.count !== void 0) return `(select count(*) ${from})`;
134
+ const row = this.rowExpression(include.selection, include.target, alias);
135
+ if (include.selection.aggregate) return `(select ${row} ${from})`;
136
+ if (include.relation.kind === "one") return `(select ${row} ${from} limit 1)`;
137
+ const order = include.orderBy.length > 0 ? this.orderBy(include.orderBy, alias) : void 0;
138
+ const limit = include.limit === void 0 ? "" : ` limit ${integer(include.limit)}`;
139
+ return `(select coalesce(json_agg(s.r order by s.o), '[]'::json) from (${`select ${row} as r, ${`row_number() over (${order ? `order by ${order}` : ""})`} as o ${from}${order ? ` order by ${order}` : ""}${limit}`}) as s)`;
140
+ }
141
+ };
142
+ function integer(value) {
143
+ if (!Number.isInteger(value) || value < 0) invalidRequest(`Expected a non-negative integer, got ${value}`);
144
+ return value;
145
+ }
146
+ function whereClause(parts) {
147
+ const present = parts.filter((part) => part !== void 0);
148
+ return present.length > 0 ? ` where ${present.join(" and ")}` : "";
149
+ }
150
+ function insertColumns(op) {
151
+ const columns = /* @__PURE__ */ new Set();
152
+ for (const row of op.rows) for (const key of Object.keys(row)) columns.add(key);
153
+ return [...columns];
154
+ }
155
+ function returningRows(compiler, op, alias) {
156
+ return op.returning ? ` returning ${compiler.rowExpression(op.returning, op.table, alias)} as row` : " returning 1";
157
+ }
158
+ /** Compiles an operation to parameterized SQL. Rows come back as json. */
159
+ function compileSql(op) {
160
+ const compiler = new SqlCompiler();
161
+ const alias = compiler.alias();
162
+ const source = op.kind === "select" ? op.source : void 0;
163
+ const from = source ? `${quoteIdent(source.schema)}.${quoteIdent(source.name)}(${Object.entries(source.args).map(([name, value]) => `${quoteIdent(name)} => ${compiler.param(value)}`).join(", ")}) as ${alias}` : `${tableRef(op.table)} as ${alias}`;
164
+ switch (op.kind) {
165
+ case "select": {
166
+ const simple = simplifyOrFalse(op.where);
167
+ if (simple.never) return {
168
+ rows: void 0,
169
+ count: void 0,
170
+ never: true
171
+ };
172
+ const filter = whereClause([simple.condition ? compiler.condition(simple.condition, op.table, alias) : void 0, ...compiler.requiredIncludes(op.selection, op.table, alias)]);
173
+ const countText = op.count ? `select count(*)::int as count from ${from}${filter}` : void 0;
174
+ if (op.head) return {
175
+ rows: void 0,
176
+ count: {
177
+ text: countText ?? `select count(*)::int as count from ${from}${filter}`,
178
+ params: [...compiler.params]
179
+ },
180
+ never: false
181
+ };
182
+ const countQuery = countText ? {
183
+ text: countText,
184
+ params: [...compiler.params]
185
+ } : void 0;
186
+ return {
187
+ rows: {
188
+ text: `select ${compiler.rowExpression(op.selection, op.table, alias)} as row from ${from}${filter}${op.selection.aggregate && op.selection.columns.length > 0 ? ` group by ${op.selection.columns.map((entry) => compiler.column(alias, entry.column)).join(", ")}` : ""}${op.orderBy.length > 0 ? ` order by ${compiler.orderBy(op.orderBy, alias)}` : ""}${op.limit === void 0 ? "" : ` limit ${integer(op.limit)}`}${op.offset === void 0 ? "" : ` offset ${integer(op.offset)}`}`,
189
+ params: compiler.params
190
+ },
191
+ count: countQuery,
192
+ never: false
193
+ };
194
+ }
195
+ case "insert": {
196
+ if (op.rows.length === 0) return {
197
+ rows: void 0,
198
+ count: void 0,
199
+ never: true
200
+ };
201
+ const columns = insertColumns(op);
202
+ let body;
203
+ if (columns.length === 0) {
204
+ if (op.rows.length > 1) invalidRequest("Cannot insert several rows without columns");
205
+ body = "default values";
206
+ } else {
207
+ const values = op.rows.map((row) => `(${columns.map((column) => column in row ? compiler.param(row[column]) : op.defaultToNull ? "null" : "default").join(", ")})`);
208
+ body = `(${columns.map(quoteIdent).join(", ")}) values ${values.join(", ")}`;
209
+ }
210
+ let conflict = "";
211
+ if (op.onConflict) {
212
+ const target = `(${op.onConflict.columns.map(quoteIdent).join(", ")})`;
213
+ const updates = columns.map((column) => `${quoteIdent(column)} = excluded.${quoteIdent(column)}`);
214
+ conflict = op.onConflict.action === "ignore" || updates.length === 0 ? ` on conflict ${target} do nothing` : ` on conflict ${target} do update set ${updates.join(", ")}`;
215
+ }
216
+ return mutation(`insert into ${from} ${body}${conflict}${returningRows(compiler, op, alias)}`, op.returning !== void 0, compiler.params);
217
+ }
218
+ case "update": {
219
+ const simple = simplifyOrFalse(op.where);
220
+ if (simple.never) return {
221
+ rows: void 0,
222
+ count: void 0,
223
+ never: true
224
+ };
225
+ const entries = Object.entries(op.set);
226
+ if (entries.length === 0) invalidRequest(`Update on "${op.table.key}" sets no columns`);
227
+ return mutation(`update ${from} set ${entries.map(([column, value]) => `${quoteIdent(column)} = ${compiler.param(value)}`).join(", ")}${whereClause([simple.condition ? compiler.condition(simple.condition, op.table, alias) : void 0])}${returningRows(compiler, op, alias)}`, op.returning !== void 0, compiler.params);
228
+ }
229
+ case "delete": {
230
+ const simple = simplifyOrFalse(op.where);
231
+ if (simple.never) return {
232
+ rows: void 0,
233
+ count: void 0,
234
+ never: true
235
+ };
236
+ return mutation(`delete from ${from}${whereClause([simple.condition ? compiler.condition(simple.condition, op.table, alias) : void 0])}${returningRows(compiler, op, alias)}`, op.returning !== void 0, compiler.params);
237
+ }
238
+ default: return op;
239
+ }
240
+ }
241
+ function mutation(statement, returning, params) {
242
+ if (returning) return {
243
+ rows: {
244
+ text: statement,
245
+ params
246
+ },
247
+ count: void 0,
248
+ never: false
249
+ };
250
+ return {
251
+ rows: void 0,
252
+ count: {
253
+ text: `with m as (${statement}) select count(*)::int as count from m`,
254
+ params
255
+ },
256
+ never: false
257
+ };
258
+ }
259
+ //#endregion
260
+ export { quoteIdent as n, compileSql as t };
@@ -0,0 +1,5 @@
1
+ import { _ as readSession, a as ResolveAuthOptions, b as writeSession, d as CookieOptions, f as CookieRecord, g as parseCookies, h as applyCookieWrites, l as resolveAuth, m as StoredSession, n as AuthResolver, p as CookieWrite, r as AuthState, s as authContext, t as AuthResolution, u as AUTH_CACHE_HEADERS, v as serializeCookie, y as sessionCookieName } from "../resolve-DW8h9NPm.js";
2
+ import { n as toSession, t as AuthSession } from "../view-B0ltUmTi.js";
3
+ import { n as hasEntitlement, t as EntitlementKey } from "../entitlements-BBg61DQZ.js";
4
+ import { n as RefreshOutcome, r as refreshSession, t as RefreshOptions } from "../index-cEeweTeM.js";
5
+ export { AUTH_CACHE_HEADERS, type AuthResolution, type AuthResolver, type AuthSession, type AuthState, type CookieOptions, type CookieRecord, type CookieWrite, type EntitlementKey, type RefreshOptions, type RefreshOutcome, type ResolveAuthOptions, type StoredSession, applyCookieWrites, authContext, hasEntitlement, parseCookies, readSession, refreshSession, resolveAuth, serializeCookie, sessionCookieName, toSession, writeSession };
@@ -0,0 +1,4 @@
1
+ import { t as hasEntitlement } from "../entitlements-BC_khwRy.js";
2
+ import { c as applyCookieWrites, d as serializeCookie, f as sessionCookieName, i as authContext, l as parseCookies, m as refreshSession, o as resolveAuth, p as writeSession, s as AUTH_CACHE_HEADERS, u as readSession } from "../mfa-CpogP66z.js";
3
+ import { t as toSession } from "../view-B6F9QbG-.js";
4
+ export { AUTH_CACHE_HEADERS, applyCookieWrites, authContext, hasEntitlement, parseCookies, readSession, refreshSession, resolveAuth, serializeCookie, sessionCookieName, toSession, writeSession };
@@ -0,0 +1,7 @@
1
+ import { o as Result } from "./result-CTkCZ6JA.js";
2
+ import { StandardSchemaV1 as StandardSchemaV1$1 } from "@standard-schema/spec";
3
+ //#region src/core/standard.d.ts
4
+ /** Validates with any Standard Schema (zod, valibot, arktype, ...). */
5
+ declare function validate<S extends StandardSchemaV1$1>(schema: S, value: unknown, label?: string): Promise<Result<StandardSchemaV1$1.InferOutput<S>>>;
6
+ //#endregion
7
+ export { validate as n, StandardSchemaV1$1 as t };
@@ -0,0 +1,21 @@
1
+ import { n as dbError } from "./errors-Bl3rkOzo.js";
2
+ import { i as ok, n as err } from "./result-DWXatkd6.js";
3
+ //#region src/core/standard.ts
4
+ /** Validates with any Standard Schema (zod, valibot, arktype, ...). */
5
+ async function validate(schema, value, label = "value") {
6
+ let outcome = schema["~standard"].validate(value);
7
+ if (outcome instanceof Promise) outcome = await outcome;
8
+ if (outcome.issues) return err(dbError("validation", `Invalid ${label}`, { issues: toIssues(outcome.issues) }));
9
+ return ok(outcome.value);
10
+ }
11
+ function toIssues(issues) {
12
+ return issues.map((issue) => {
13
+ const path = issue.path?.map((segment) => typeof segment === "object" ? segment.key : segment);
14
+ return path && path.length > 0 ? {
15
+ message: issue.message,
16
+ path
17
+ } : { message: issue.message };
18
+ });
19
+ }
20
+ //#endregion
21
+ export { validate as t };