@supalive/core 0.1.5 → 1.0.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.
- package/dist/bytes-AuEkyxeU.js +19 -0
- package/dist/bytes-AuEkyxeU.js.map +1 -0
- package/dist/codec-BHAmGEIQ.js +62 -0
- package/dist/codec-BHAmGEIQ.js.map +1 -0
- package/dist/{helper-zdJT5FUc.js → helper-wGbzz6zo.js} +2 -18
- package/dist/helper-wGbzz6zo.js.map +1 -0
- package/dist/{index-CTyXKcq_.d.ts → index-CaWMDqq0.d.ts} +21 -3
- package/dist/index-CaWMDqq0.d.ts.map +1 -0
- package/dist/index-DouKwYL6.d.ts +1754 -0
- package/dist/index-DouKwYL6.d.ts.map +1 -0
- package/dist/{mysql-C8SN443m.d.ts → mysql-Bxurg_PH.d.ts} +2 -2
- package/dist/{mysql-C8SN443m.d.ts.map → mysql-Bxurg_PH.d.ts.map} +1 -1
- package/dist/mysql-Cxd4Uq5p.d.ts +104 -0
- package/dist/mysql-Cxd4Uq5p.d.ts.map +1 -0
- package/dist/{mysql-DELSRrpY.js → mysql-bvnjYWvZ.js} +5 -4
- package/dist/{mysql-DELSRrpY.js.map → mysql-bvnjYWvZ.js.map} +1 -1
- package/dist/{overlap-checker-CVkbbuEQ.js → overlap-checker-Ct_HP_iB.js} +4 -4
- package/dist/{overlap-checker-CVkbbuEQ.js.map → overlap-checker-Ct_HP_iB.js.map} +1 -1
- package/dist/{postgres-DE-XyNAQ.js → postgres-B8u1YN8X.js} +5 -4
- package/dist/{postgres-DE-XyNAQ.js.map → postgres-B8u1YN8X.js.map} +1 -1
- package/dist/{postgres-D_gwCHx-.d.ts → postgres-CfT_aDx3.d.ts} +2 -2
- package/dist/{postgres-D_gwCHx-.d.ts.map → postgres-CfT_aDx3.d.ts.map} +1 -1
- package/dist/postgres-Ck-xt72U.d.ts +108 -0
- package/dist/postgres-Ck-xt72U.d.ts.map +1 -0
- package/dist/{schema-SKcIWHfo.js → procedure-DX87tyef.js} +2 -45
- package/dist/procedure-DX87tyef.js.map +1 -0
- package/dist/{query-CbQLjeME.js → query-Bh0RNxDz.js} +24 -64
- package/dist/query-Bh0RNxDz.js.map +1 -0
- package/dist/{realtime_db-D9p2X2PH.js → realtime_db-DOCgqbwi.js} +4 -3
- package/dist/{realtime_db-D9p2X2PH.js.map → realtime_db-DOCgqbwi.js.map} +1 -1
- package/dist/router-DlTYWpop.js.map +1 -1
- package/dist/schema-Dd7u0A1L.js +109 -0
- package/dist/schema-Dd7u0A1L.js.map +1 -0
- package/dist/src/client/index.d.ts +1 -1
- package/dist/src/client/index.js +6 -5
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/exports/codegen.d.ts +38 -0
- package/dist/src/exports/codegen.d.ts.map +1 -0
- package/dist/src/exports/codegen.js +134 -0
- package/dist/src/exports/codegen.js.map +1 -0
- package/dist/src/exports/mysql.d.ts +1 -1
- package/dist/src/exports/mysql.js +1 -1
- package/dist/src/exports/postgres.d.ts +1 -1
- package/dist/src/exports/postgres.js +1 -1
- package/dist/src/exports/procedure.d.ts +2 -2
- package/dist/src/exports/procedure.js +5 -4
- package/dist/src/exports/schema-sql.d.ts +18 -0
- package/dist/src/exports/schema-sql.d.ts.map +1 -0
- package/dist/src/exports/schema-sql.js +161 -0
- package/dist/src/exports/schema-sql.js.map +1 -0
- package/dist/src/exports/server.d.ts +4 -4
- package/dist/src/exports/server.d.ts.map +1 -1
- package/dist/src/exports/server.js +4 -9
- package/dist/src/exports/server.js.map +1 -1
- package/dist/src/exports/subscription-manager-worker-entry.js +2 -3
- package/dist/src/exports/subscription-manager-worker-entry.js.map +1 -1
- package/dist/src/exports/types.d.ts +2 -2
- package/dist/src/exports/types.js +2 -2
- package/dist/subscription-worker-CqoWp6zB.js +511 -0
- package/dist/subscription-worker-CqoWp6zB.js.map +1 -0
- package/dist/subscription-worker-PtmJWEj1.js +511 -0
- package/dist/subscription-worker-PtmJWEj1.js.map +1 -0
- package/dist/{subscription-worker-BurdPO8d.js → subscription-worker-pahX0zxg.js} +7 -7
- package/dist/{subscription-worker-BurdPO8d.js.map → subscription-worker-pahX0zxg.js.map} +1 -1
- package/dist/{types_db-Ctf-ksoy.js → types_db-DXj_l9n-.js} +2 -2
- package/dist/{types_db-Ctf-ksoy.js.map → types_db-DXj_l9n-.js.map} +1 -1
- package/dist/types_server-BW1ys_SK.d.ts +216 -0
- package/dist/types_server-BW1ys_SK.d.ts.map +1 -0
- package/dist/types_server-Dk6o_B7N.js.map +1 -1
- package/dist/types_server-Dpsi0wpG.d.ts +216 -0
- package/dist/types_server-Dpsi0wpG.d.ts.map +1 -0
- package/dist/types_server-DzrIccyO.d.ts +216 -0
- package/dist/types_server-DzrIccyO.d.ts.map +1 -0
- package/dist/{types_server-Ch56y8L3.d.ts → types_server-TFo6SWDH.d.ts} +2 -2
- package/dist/{types_server-Ch56y8L3.d.ts.map → types_server-TFo6SWDH.d.ts.map} +1 -1
- package/package.json +7 -2
- package/dist/helper-zdJT5FUc.js.map +0 -1
- package/dist/index-CTyXKcq_.d.ts.map +0 -1
- package/dist/query-CbQLjeME.js.map +0 -1
- package/dist/schema-SKcIWHfo.js.map +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
//#region src/db/codegen/zod-to-json.ts
|
|
3
|
+
function isOptionalField(schema) {
|
|
4
|
+
return schema instanceof z$1.ZodOptional || schema instanceof z$1.ZodNullable || schema instanceof z$1.ZodDefault;
|
|
5
|
+
}
|
|
6
|
+
function zodToJsonSchema(schema) {
|
|
7
|
+
if (schema instanceof z$1.ZodString) return { type: "string" };
|
|
8
|
+
if (schema instanceof z$1.ZodNumber) return { type: "number" };
|
|
9
|
+
if (schema instanceof z$1.ZodBoolean) return { type: "boolean" };
|
|
10
|
+
if (schema instanceof z$1.ZodBigInt) return {
|
|
11
|
+
type: "string",
|
|
12
|
+
format: "bigint"
|
|
13
|
+
};
|
|
14
|
+
if (schema instanceof z$1.ZodDate) return {
|
|
15
|
+
type: "string",
|
|
16
|
+
format: "date-time"
|
|
17
|
+
};
|
|
18
|
+
if (schema instanceof z$1.ZodEnum) {
|
|
19
|
+
const entries = schema._def?.entries;
|
|
20
|
+
if (entries && typeof entries === "object") {
|
|
21
|
+
const values = Object.values(entries).filter((v) => typeof v === "string");
|
|
22
|
+
if (values.length > 0) return {
|
|
23
|
+
type: "string",
|
|
24
|
+
enum: values
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { type: "string" };
|
|
28
|
+
}
|
|
29
|
+
if (schema instanceof z$1.ZodArray) {
|
|
30
|
+
const inner = schema._def?.type;
|
|
31
|
+
return {
|
|
32
|
+
type: "array",
|
|
33
|
+
items: inner ? zodToJsonSchema(inner) : { type: "string" }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (schema instanceof z$1.ZodObject) {
|
|
37
|
+
const shape = schema._def?.shape ?? schema.shape;
|
|
38
|
+
const properties = {};
|
|
39
|
+
const required = [];
|
|
40
|
+
if (shape && typeof shape === "object") for (const [key, field] of Object.entries(shape)) {
|
|
41
|
+
if (!field) continue;
|
|
42
|
+
properties[key] = zodToJsonSchema(field);
|
|
43
|
+
if (!isOptionalField(field)) required.push(key);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
type: "object",
|
|
47
|
+
properties,
|
|
48
|
+
required: required.length > 0 ? required : void 0
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (schema instanceof z$1.ZodRecord) {
|
|
52
|
+
const valueType = schema._def?.valueType;
|
|
53
|
+
return {
|
|
54
|
+
type: "object",
|
|
55
|
+
additionalProperties: valueType ? zodToJsonSchema(valueType) : { type: "string" }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (schema instanceof z$1.ZodOptional) {
|
|
59
|
+
const inner = schema._def?.innerType;
|
|
60
|
+
return {
|
|
61
|
+
...inner ? zodToJsonSchema(inner) : { type: "string" },
|
|
62
|
+
nullable: true
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (schema instanceof z$1.ZodNullable) {
|
|
66
|
+
const inner = schema._def?.innerType;
|
|
67
|
+
return {
|
|
68
|
+
...inner ? zodToJsonSchema(inner) : { type: "string" },
|
|
69
|
+
nullable: true
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (schema instanceof z$1.ZodDefault) {
|
|
73
|
+
const inner = schema._def?.innerType;
|
|
74
|
+
return inner ? zodToJsonSchema(inner) : { type: "string" };
|
|
75
|
+
}
|
|
76
|
+
if (schema instanceof z$1.ZodUnion) {
|
|
77
|
+
const options = schema._def?.options;
|
|
78
|
+
if (Array.isArray(options) && options.length > 0) return { anyOf: options.map((o) => zodToJsonSchema(o)) };
|
|
79
|
+
return { type: "string" };
|
|
80
|
+
}
|
|
81
|
+
if (schema instanceof z$1.ZodIntersection) {
|
|
82
|
+
const left = schema._def?.left;
|
|
83
|
+
const right = schema._def?.right;
|
|
84
|
+
if (left && right) return { allOf: [zodToJsonSchema(left), zodToJsonSchema(right)] };
|
|
85
|
+
return { type: "object" };
|
|
86
|
+
}
|
|
87
|
+
if (schema instanceof z$1.ZodLiteral) return { const: schema._def?.value };
|
|
88
|
+
if (schema instanceof z$1.ZodPipe || schema instanceof z$1.ZodTransform) {
|
|
89
|
+
const inner = schema._def?.schema ?? schema._def?.input;
|
|
90
|
+
return inner ? zodToJsonSchema(inner) : { type: "string" };
|
|
91
|
+
}
|
|
92
|
+
if (schema instanceof z$1.ZodAny || schema instanceof z$1.ZodUnknown) return {};
|
|
93
|
+
return { type: "string" };
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/db/codegen/manifest.ts
|
|
97
|
+
function extractGroup(name) {
|
|
98
|
+
const dot = name.indexOf(".");
|
|
99
|
+
return dot > 0 ? name.slice(0, dot) : name;
|
|
100
|
+
}
|
|
101
|
+
function isPublicProcedure(proc) {
|
|
102
|
+
return !proc.internal;
|
|
103
|
+
}
|
|
104
|
+
function extractRouterManifest(router) {
|
|
105
|
+
const procedures = [];
|
|
106
|
+
const definitions = {};
|
|
107
|
+
for (const [name, proc] of Object.entries(router.procedures)) {
|
|
108
|
+
if (!isPublicProcedure(proc)) continue;
|
|
109
|
+
let input = null;
|
|
110
|
+
try {
|
|
111
|
+
const inputSchema = proc.inputSchema;
|
|
112
|
+
if (inputSchema) input = zodToJsonSchema(inputSchema);
|
|
113
|
+
} catch {
|
|
114
|
+
input = null;
|
|
115
|
+
}
|
|
116
|
+
procedures.push({
|
|
117
|
+
name,
|
|
118
|
+
type: proc.procedureType,
|
|
119
|
+
group: extractGroup(name),
|
|
120
|
+
input,
|
|
121
|
+
output: null
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
procedures.sort((a, b) => a.name.localeCompare(b.name));
|
|
125
|
+
return {
|
|
126
|
+
version: "1",
|
|
127
|
+
procedures,
|
|
128
|
+
definitions
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//#endregion
|
|
132
|
+
export { extractRouterManifest, zodToJsonSchema };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=codegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.js","names":["z"],"sources":["../../../src/db/codegen/zod-to-json.ts","../../../src/db/codegen/manifest.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport interface JsonSchemaType {\n type?: \"string\" | \"number\" | \"boolean\" | \"integer\" | \"array\" | \"object\";\n format?: string;\n enum?: (string | number)[];\n items?: JsonSchemaType;\n properties?: Record<string, JsonSchemaType>;\n required?: string[];\n additionalProperties?: JsonSchemaType;\n nullable?: boolean;\n anyOf?: JsonSchemaType[];\n allOf?: JsonSchemaType[];\n $ref?: string;\n const?: string | number | boolean;\n description?: string;\n}\n\nfunction isOptionalField(schema: z.ZodType<any>): boolean {\n return (\n schema instanceof z.ZodOptional ||\n schema instanceof z.ZodNullable ||\n schema instanceof z.ZodDefault\n );\n}\n\nexport function zodToJsonSchema(schema: z.ZodType<any>): JsonSchemaType {\n if (schema instanceof z.ZodString) {\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodNumber) {\n return { type: \"number\" };\n }\n if (schema instanceof z.ZodBoolean) {\n return { type: \"boolean\" };\n }\n if (schema instanceof z.ZodBigInt) {\n return { type: \"string\", format: \"bigint\" };\n }\n if (schema instanceof z.ZodDate) {\n return { type: \"string\", format: \"date-time\" };\n }\n if (schema instanceof z.ZodEnum) {\n const entries = (schema as any)._def?.entries;\n if (entries && typeof entries === \"object\") {\n const values = Object.values(entries).filter(v => typeof v === \"string\") as string[];\n if (values.length > 0) {\n return { type: \"string\", enum: values };\n }\n }\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodArray) {\n const inner = (schema as any)._def?.type;\n return {\n type: \"array\",\n items: inner ? zodToJsonSchema(inner) : { type: \"string\" },\n };\n }\n if (schema instanceof z.ZodObject) {\n const shape = (schema as any)._def?.shape ?? (schema as any).shape;\n const properties: Record<string, JsonSchemaType> = {};\n const required: string[] = [];\n if (shape && typeof shape === \"object\") {\n for (const [key, field] of Object.entries(shape)) {\n if (!field) continue;\n const fieldSchema = zodToJsonSchema(field as z.ZodType<any>);\n properties[key] = fieldSchema;\n if (!isOptionalField(field as z.ZodType<any>)) {\n required.push(key);\n }\n }\n }\n return { type: \"object\", properties, required: required.length > 0 ? required : undefined };\n }\n if (schema instanceof z.ZodRecord) {\n const valueType = (schema as any)._def?.valueType;\n return {\n type: \"object\",\n additionalProperties: valueType ? zodToJsonSchema(valueType) : { type: \"string\" },\n };\n }\n if (schema instanceof z.ZodOptional) {\n const inner = (schema as any)._def?.innerType;\n const innerSchema = inner ? zodToJsonSchema(inner) : { type: \"string\" };\n return { ...innerSchema, nullable: true };\n }\n if (schema instanceof z.ZodNullable) {\n const inner = (schema as any)._def?.innerType;\n const innerSchema = inner ? zodToJsonSchema(inner) : { type: \"string\" };\n return { ...innerSchema, nullable: true };\n }\n if (schema instanceof z.ZodDefault) {\n const inner = (schema as any)._def?.innerType;\n return inner ? zodToJsonSchema(inner) : { type: \"string\" };\n }\n if (schema instanceof z.ZodUnion) {\n const options = (schema as any)._def?.options;\n if (Array.isArray(options) && options.length > 0) {\n return { anyOf: options.map(o => zodToJsonSchema(o)) };\n }\n return { type: \"string\" };\n }\n if (schema instanceof z.ZodIntersection) {\n const left = (schema as any)._def?.left;\n const right = (schema as any)._def?.right;\n if (left && right) {\n return { allOf: [zodToJsonSchema(left), zodToJsonSchema(right)] };\n }\n return { type: \"object\" };\n }\n if (schema instanceof z.ZodLiteral) {\n return { const: (schema as any)._def?.value };\n }\n if (schema instanceof z.ZodPipe || schema instanceof z.ZodTransform) {\n const inner = (schema as any)._def?.schema ?? (schema as any)._def?.input;\n return inner ? zodToJsonSchema(inner) : { type: \"string\" };\n }\n if (schema instanceof z.ZodAny || schema instanceof z.ZodUnknown) {\n return {};\n }\n return { type: \"string\" };\n}\n","import type { Router } from \"../../router/router\";\nimport type { AnyProcedure } from \"../../router/procedure\";\nimport { zodToJsonSchema, type JsonSchemaType } from \"./zod-to-json\";\n\nexport interface ProcedureManifest {\n name: string;\n type: \"query\" | \"mutation\" | \"action\";\n group: string;\n input: JsonSchemaType | null;\n output: null; // output type inference requires runtime annotation\n}\n\nexport interface RouterManifest {\n version: \"1\";\n procedures: ProcedureManifest[];\n definitions: Record<string, JsonSchemaType>;\n}\n\nfunction extractGroup(name: string): string {\n const dot = name.indexOf(\".\");\n return dot > 0 ? name.slice(0, dot) : name;\n}\n\nfunction isPublicProcedure(proc: AnyProcedure): boolean {\n return !proc.internal;\n}\n\nexport function extractRouterManifest(router: Router): RouterManifest {\n const procedures: ProcedureManifest[] = [];\n const definitions: Record<string, JsonSchemaType> = {};\n\n for (const [name, proc] of Object.entries(router.procedures)) {\n if (!isPublicProcedure(proc)) continue;\n\n let input: JsonSchemaType | null = null;\n try {\n const inputSchema = proc.inputSchema;\n if (inputSchema) {\n input = zodToJsonSchema(inputSchema as any);\n }\n } catch {\n input = null;\n }\n\n procedures.push({\n name,\n type: proc.procedureType as \"query\" | \"mutation\" | \"action\",\n group: extractGroup(name),\n input,\n output: null,\n });\n }\n\n procedures.sort((a, b) => a.name.localeCompare(b.name));\n\n return {\n version: \"1\",\n procedures,\n definitions,\n };\n}\n"],"mappings":";;AAkBA,SAAS,gBAAgB,QAAiC;CACtD,OACI,kBAAkBA,IAAE,eACpB,kBAAkBA,IAAE,eACpB,kBAAkBA,IAAE;AAE5B;AAEA,SAAgB,gBAAgB,QAAwC;CACpE,IAAI,kBAAkBA,IAAE,WACpB,OAAO,EAAE,MAAM,SAAS;CAE5B,IAAI,kBAAkBA,IAAE,WACpB,OAAO,EAAE,MAAM,SAAS;CAE5B,IAAI,kBAAkBA,IAAE,YACpB,OAAO,EAAE,MAAM,UAAU;CAE7B,IAAI,kBAAkBA,IAAE,WACpB,OAAO;EAAE,MAAM;EAAU,QAAQ;CAAS;CAE9C,IAAI,kBAAkBA,IAAE,SACpB,OAAO;EAAE,MAAM;EAAU,QAAQ;CAAY;CAEjD,IAAI,kBAAkBA,IAAE,SAAS;EAC7B,MAAM,UAAW,OAAe,MAAM;EACtC,IAAI,WAAW,OAAO,YAAY,UAAU;GACxC,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC,CAAC,QAAO,MAAK,OAAO,MAAM,QAAQ;GACvE,IAAI,OAAO,SAAS,GAChB,OAAO;IAAE,MAAM;IAAU,MAAM;GAAO;EAE9C;EACA,OAAO,EAAE,MAAM,SAAS;CAC5B;CACA,IAAI,kBAAkBA,IAAE,UAAU;EAC9B,MAAM,QAAS,OAAe,MAAM;EACpC,OAAO;GACH,MAAM;GACN,OAAO,QAAQ,gBAAgB,KAAK,IAAI,EAAE,MAAM,SAAS;EAC7D;CACJ;CACA,IAAI,kBAAkBA,IAAE,WAAW;EAC/B,MAAM,QAAS,OAAe,MAAM,SAAU,OAAe;EAC7D,MAAM,aAA6C,CAAC;EACpD,MAAM,WAAqB,CAAC;EAC5B,IAAI,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ql-
|
|
1
|
+
import { t as MySqlDatabase } from "../../mysql-Bxurg_PH.js";
|
|
2
2
|
export { MySqlDatabase };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MySqlDatabase } from "../../mysql-
|
|
1
|
+
import { t as MySqlDatabase } from "../../mysql-bvnjYWvZ.js";
|
|
2
2
|
export { MySqlDatabase };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PgDatabase } from "../../postgres-
|
|
1
|
+
import { t as PgDatabase } from "../../postgres-CfT_aDx3.js";
|
|
2
2
|
export { PgDatabase };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PgDatabase } from "../../postgres-
|
|
1
|
+
import { t as PgDatabase } from "../../postgres-B8u1YN8X.js";
|
|
2
2
|
export { PgDatabase };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as PublicProcedures, $t as
|
|
1
|
+
import { $ as PublicProcedures, $t as DefineSchemaConfig, Bt as QueryBuilder, Ct as createQueryBuilder, Gt as matchesPredicate, Ht as jsonContains, It as IdAndCommitTs, J as ActionProcedures, Jt as ComputedCodec, Kt as ActionArgs, Lt as JsonContainsOptions, Q as ProcedureNames, Qt as DeclarativeIndex, Rt as JsonHasKeyMultiOptions, St as createMutationBuilder, Ut as jsonPathExists, Vt as buildPredicateSql, Wt as jsonPathExtract, X as ContextRegistry, Xt as ComputedField, Y as AppRouter, Yt as ComputedDataType, Z as MutationProcedures, Zt as ComputedFieldConfig, _n as schemaRegistry, _t as QueryCtx, an as OverrideField, at as ActionConfig, bn as trackSchema, bt as TypeOf, cn as ReturnLiveQuery, ct as ActionProcedure, dn as SchemaColumnMapping, dt as MutationConfig, en as IndexDefinition, et as QueryProcedures, fn as SchemaColumnsOptions, ft as MutationCtx, gn as defineSchema, gt as QueryConfig, hn as defineComputedField, ht as OutputOf, in as MutationArgs, it as router, ln as ReturnQuery, lt as AnyProcedure, mn as StoredSchemaColumnsOptions, mt as MutationProcedure, nn as InsertData, nt as Router, on as Prettify, ot as ActionCtx, pn as SchemaDefinition, pt as MutationFn, qt as ColumnCodec, rn as Model, rt as getContextRegistry, sn as QueryArgs, st as ActionFn, tn as InferSchema, tt as RegisteredProcedure, un as SchemaCodecs, ut as ContextOf, vn as shouldTrackSchema, vt as QueryFn, xt as createActionBuilder, yn as tableNameToId, yt as QueryProcedure, zt as JsonOpOptions } from "../../index-DouKwYL6.js";
|
|
2
2
|
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-CiacMqje.js";
|
|
3
|
-
export { ActionArgs, type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, type AnyProcedure, type AppRouter, ColumnCodec, ComputedCodec, ComputedDataType, ComputedField, ComputedFieldConfig, type ContextOf, ContextRegistry, DefineSchemaConfig, IdAndCommitTs, InferSchema, InsertData, JsonContainsOptions, JsonHasKeyMultiOptions, JsonOpOptions, Model, MutationArgs, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, type OutputOf, OverrideField, Prettify, type ProcedureNames, type PublicProcedures, QueryArgs, QueryBuilder, type QueryConfig, type QueryCtx, type QueryFn, type QueryProcedure, type QueryProcedures, type RegisteredProcedure, ReturnLiveQuery, ReturnQuery, type Router, SchemaCodecs, SchemaColumnMapping, SchemaColumnsOptions, SchemaDefinition, StoredSchemaColumnsOptions, type TypeOf, buildPredicateSql, createActionBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, stableStringify, supaliveStringify, tableNameToId };
|
|
3
|
+
export { ActionArgs, type ActionConfig, type ActionCtx, type ActionFn, type ActionProcedure, type ActionProcedures, type AnyProcedure, type AppRouter, ColumnCodec, ComputedCodec, ComputedDataType, ComputedField, ComputedFieldConfig, type ContextOf, ContextRegistry, DeclarativeIndex, DefineSchemaConfig, IdAndCommitTs, IndexDefinition, InferSchema, InsertData, JsonContainsOptions, JsonHasKeyMultiOptions, JsonOpOptions, Model, MutationArgs, type MutationConfig, type MutationCtx, type MutationFn, type MutationProcedure, type MutationProcedures, type OutputOf, OverrideField, Prettify, type ProcedureNames, type PublicProcedures, QueryArgs, QueryBuilder, type QueryConfig, type QueryCtx, type QueryFn, type QueryProcedure, type QueryProcedures, type RegisteredProcedure, ReturnLiveQuery, ReturnQuery, type Router, SchemaCodecs, SchemaColumnMapping, SchemaColumnsOptions, SchemaDefinition, StoredSchemaColumnsOptions, type TypeOf, buildPredicateSql, createActionBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as createMutationBuilder, r as createQueryBuilder, t as createActionBuilder } from "../../procedure-DX87tyef.js";
|
|
2
2
|
import { n as getContextRegistry, r as router, t as ContextRegistry } from "../../router-DlTYWpop.js";
|
|
3
|
-
import { a as jsonPathExtract, i as jsonPathExists, n as buildPredicateSql, o as matchesPredicate, r as jsonContains, t as QueryBuilder } from "../../query-
|
|
4
|
-
import { n as
|
|
5
|
-
|
|
3
|
+
import { a as jsonPathExtract, i as jsonPathExists, n as buildPredicateSql, o as matchesPredicate, r as jsonContains, t as QueryBuilder } from "../../query-Bh0RNxDz.js";
|
|
4
|
+
import { a as tableNameToId, i as shouldTrackSchema, n as defineSchema, o as trackSchema, r as schemaRegistry, t as defineComputedField } from "../../schema-Dd7u0A1L.js";
|
|
5
|
+
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-wGbzz6zo.js";
|
|
6
|
+
export { ContextRegistry, QueryBuilder, buildPredicateSql, createActionBuilder, createMutationBuilder, createQueryBuilder, defineComputedField, defineSchema, getContextRegistry, groupByToMap, jsonContains, jsonPathExists, jsonPathExtract, matchesPredicate, router, schemaRegistry, shouldTrackSchema, stableStringify, supaliveStringify, tableNameToId, trackSchema };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _n as schemaRegistry, bn as trackSchema, pn as SchemaDefinition } from "../../index-DouKwYL6.js";
|
|
2
|
+
|
|
3
|
+
//#region src/db/schema-sql.d.ts
|
|
4
|
+
type SqlDialect = "postgres" | "mysql";
|
|
5
|
+
interface SchemaToCreateTableOptions {
|
|
6
|
+
dialect?: SqlDialect;
|
|
7
|
+
ifNotExists?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare function schemaToCreateTable(schema: SchemaDefinition<string, any, any>, options?: SchemaToCreateTableOptions): string;
|
|
10
|
+
interface GenerateSchemaSqlOptions {
|
|
11
|
+
dialect?: SqlDialect;
|
|
12
|
+
ifNotExists?: boolean;
|
|
13
|
+
header?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare function generateSchemaSql(schemas?: Map<string, SchemaDefinition<string, any, any>> | SchemaDefinition<string, any, any>[], options?: GenerateSchemaSqlOptions): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { type GenerateSchemaSqlOptions, type SchemaToCreateTableOptions, type SqlDialect, generateSchemaSql, schemaRegistry, schemaToCreateTable, trackSchema };
|
|
18
|
+
//# sourceMappingURL=schema-sql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-sql.d.ts","names":[],"sources":["../../../src/db/schema-sql.ts"],"mappings":";;;KAKY,UAAA;AAAA,UAgIK,0BAAA;EACb,OAAA,GAAU,UAAU;EACpB,WAAA;AAAA;AAAA,iBAGY,mBAAA,CACZ,MAAA,EAAQ,gBAAA,oBACR,OAAA,GAAU,0BAA0B;AAAA,UA4DvB,wBAAA;EACb,OAAA,GAAU,UAAU;EACpB,WAAA;EACA,MAAA;AAAA;AAAA,iBAGY,iBAAA,CACZ,OAAA,GAAU,GAAA,SAAY,gBAAA,sBAAsC,gBAAA,sBAC5D,OAAA,GAAU,wBAAA"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { r as unwrapZodType } from "../../codec-BHAmGEIQ.js";
|
|
2
|
+
import { o as trackSchema, r as schemaRegistry } from "../../schema-Dd7u0A1L.js";
|
|
3
|
+
import { z as z$1 } from "zod";
|
|
4
|
+
//#region src/db/schema-sql.ts
|
|
5
|
+
function getFieldMeta(field) {
|
|
6
|
+
const f = field;
|
|
7
|
+
const meta = typeof f.meta === "function" ? f.meta() : void 0;
|
|
8
|
+
if (meta) return meta;
|
|
9
|
+
const unwrapped = unwrapZodType(field);
|
|
10
|
+
if (unwrapped !== field) {
|
|
11
|
+
const innerMeta = typeof unwrapped.meta === "function" ? unwrapped.meta() : void 0;
|
|
12
|
+
if (innerMeta) return innerMeta;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function getStringMaxLength(field) {
|
|
16
|
+
const unwrapped = unwrapZodType(field);
|
|
17
|
+
if (!(unwrapped instanceof z$1.ZodString)) return void 0;
|
|
18
|
+
const checks = unwrapped._def?.checks ?? [];
|
|
19
|
+
let maxLength;
|
|
20
|
+
for (const check of checks) {
|
|
21
|
+
const c = check.def ?? check;
|
|
22
|
+
if (c.check === "length_equals" || c.check === "size_equals") {
|
|
23
|
+
const len = c.length ?? c.size;
|
|
24
|
+
if (typeof len === "number") maxLength = maxLength === void 0 ? len : Math.min(maxLength, len);
|
|
25
|
+
}
|
|
26
|
+
if (c.check === "max_length" || c.check === "max_size") {
|
|
27
|
+
const len = c.maximum ?? c.max;
|
|
28
|
+
if (typeof len === "number") maxLength = maxLength === void 0 ? len : Math.min(maxLength, len);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return maxLength;
|
|
32
|
+
}
|
|
33
|
+
function isOptional(field) {
|
|
34
|
+
return field instanceof z$1.ZodOptional || field instanceof z$1.ZodNullable;
|
|
35
|
+
}
|
|
36
|
+
function escapeSQLString(s) {
|
|
37
|
+
return `'${s.replace(/'/g, "''")}'`;
|
|
38
|
+
}
|
|
39
|
+
function getDefaultFromZod(field) {
|
|
40
|
+
if (!(field instanceof z$1.ZodDefault)) return void 0;
|
|
41
|
+
try {
|
|
42
|
+
const f = field;
|
|
43
|
+
let value = f.defaultValue;
|
|
44
|
+
if (value === void 0) value = f._def?.defaultValue;
|
|
45
|
+
if (typeof value === "function") value = value();
|
|
46
|
+
if (value === void 0) return void 0;
|
|
47
|
+
if (value === null) return "NULL";
|
|
48
|
+
if (typeof value === "string") return escapeSQLString(value);
|
|
49
|
+
if (typeof value === "number") return value.toString();
|
|
50
|
+
if (typeof value === "boolean") return value ? "TRUE" : "FALSE";
|
|
51
|
+
if (typeof value === "bigint") return value.toString();
|
|
52
|
+
return;
|
|
53
|
+
} catch {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const VARCHAR_MAX = 65535;
|
|
58
|
+
function getSqlType(field, dialect) {
|
|
59
|
+
const meta = getFieldMeta(field);
|
|
60
|
+
if (meta) {
|
|
61
|
+
const dialectKey = dialect === "mysql" ? "mysqlType" : "pgType";
|
|
62
|
+
if (typeof meta[dialectKey] === "string") return meta[dialectKey];
|
|
63
|
+
if (typeof meta.sql_type === "string") return meta.sql_type;
|
|
64
|
+
}
|
|
65
|
+
const unwrapped = unwrapZodType(field);
|
|
66
|
+
if (unwrapped instanceof z$1.ZodString) {
|
|
67
|
+
const maxLen = getStringMaxLength(field);
|
|
68
|
+
if (maxLen !== void 0 && maxLen <= VARCHAR_MAX) return `VARCHAR(${maxLen})`;
|
|
69
|
+
return "TEXT";
|
|
70
|
+
}
|
|
71
|
+
if (unwrapped instanceof z$1.ZodNumber) return "BIGINT";
|
|
72
|
+
if (unwrapped instanceof z$1.ZodBoolean) return dialect === "mysql" ? "TINYINT(1)" : "BOOLEAN";
|
|
73
|
+
if (unwrapped instanceof z$1.ZodDate) return dialect === "mysql" ? "DATETIME(3)" : "TIMESTAMPTZ";
|
|
74
|
+
if (unwrapped instanceof z$1.ZodBigInt) return "BIGINT";
|
|
75
|
+
if (unwrapped instanceof z$1.ZodArray) return dialect === "mysql" ? "JSON" : "JSONB";
|
|
76
|
+
if (unwrapped instanceof z$1.ZodObject || unwrapped instanceof z$1.ZodRecord) return dialect === "mysql" ? "JSON" : "JSONB";
|
|
77
|
+
if (unwrapped instanceof z$1.ZodEnum) return "TEXT";
|
|
78
|
+
return "TEXT";
|
|
79
|
+
}
|
|
80
|
+
function isPrimaryKey(field) {
|
|
81
|
+
return getFieldMeta(field)?.primaryKey === true;
|
|
82
|
+
}
|
|
83
|
+
function getDefaultValue(field) {
|
|
84
|
+
const meta = getFieldMeta(field);
|
|
85
|
+
if (meta && typeof meta.defaultValue === "string") return meta.defaultValue;
|
|
86
|
+
return getDefaultFromZod(field);
|
|
87
|
+
}
|
|
88
|
+
function schemaToCreateTable(schema, options) {
|
|
89
|
+
const dialect = options?.dialect ?? "postgres";
|
|
90
|
+
const ifNotExists = options?.ifNotExists ?? true;
|
|
91
|
+
const tableName = schema.table;
|
|
92
|
+
const shape = schema.schema.shape;
|
|
93
|
+
const columns = schema.columns;
|
|
94
|
+
const orderedKeys = [
|
|
95
|
+
"id",
|
|
96
|
+
...Object.keys(shape).filter((k) => k !== "id" && k !== "commitTs"),
|
|
97
|
+
"commitTs"
|
|
98
|
+
];
|
|
99
|
+
const lines = [];
|
|
100
|
+
for (const fieldName of orderedKeys) {
|
|
101
|
+
const field = shape[fieldName];
|
|
102
|
+
if (!field) continue;
|
|
103
|
+
const colName = columns[fieldName] ?? fieldName;
|
|
104
|
+
if (!colName) continue;
|
|
105
|
+
const sqlType = getSqlType(field, dialect);
|
|
106
|
+
const notNull = !isOptional(field);
|
|
107
|
+
const pk = isPrimaryKey(field);
|
|
108
|
+
const defaultVal = fieldName === "commitTs" ? "0" : getDefaultValue(field);
|
|
109
|
+
let line = ` ${colName} ${sqlType}`;
|
|
110
|
+
if (notNull) line += " NOT NULL";
|
|
111
|
+
if (pk) line += " PRIMARY KEY";
|
|
112
|
+
if (defaultVal !== void 0) line += ` DEFAULT ${defaultVal}`;
|
|
113
|
+
lines.push(line);
|
|
114
|
+
}
|
|
115
|
+
return `CREATE TABLE ${ifNotExists ? "IF NOT EXISTS " : ""}${tableName} (\n${lines.join(",\n")}\n);`;
|
|
116
|
+
}
|
|
117
|
+
function formatDeclarativeIndex(idx, tableName, columns) {
|
|
118
|
+
const colNames = idx.columns.map((c) => columns[c] ?? c).join(", ");
|
|
119
|
+
let sql = `CREATE ${idx.unique ? "UNIQUE " : ""}INDEX IF NOT EXISTS ${idx.name} ON ${tableName}`;
|
|
120
|
+
if (idx.type) sql += ` USING ${idx.type}`;
|
|
121
|
+
sql += ` (${colNames})`;
|
|
122
|
+
if (idx.where) sql += ` WHERE ${idx.where}`;
|
|
123
|
+
return sql + ";";
|
|
124
|
+
}
|
|
125
|
+
function schemaIndexes(schema) {
|
|
126
|
+
return (schema.indexes ?? []).map((idx) => {
|
|
127
|
+
if (typeof idx === "string") return idx;
|
|
128
|
+
return formatDeclarativeIndex(idx, schema.table, schema.columns);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function generateSchemaSql(schemas, options) {
|
|
132
|
+
const dialect = options?.dialect ?? "postgres";
|
|
133
|
+
const header = options?.header ?? true;
|
|
134
|
+
let list;
|
|
135
|
+
if (schemas instanceof Map) list = [...schemas.values()];
|
|
136
|
+
else if (Array.isArray(schemas)) list = schemas;
|
|
137
|
+
else list = [...schemaRegistry.values()];
|
|
138
|
+
list = list.filter((s) => s?.table);
|
|
139
|
+
list.sort((a, b) => a.table.localeCompare(b.table));
|
|
140
|
+
const parts = [];
|
|
141
|
+
if (header) {
|
|
142
|
+
parts.push("-- Generated by Supalive Schema Generator");
|
|
143
|
+
parts.push(`-- Dialect: ${dialect}`);
|
|
144
|
+
parts.push(`-- Tables: ${list.length}`);
|
|
145
|
+
parts.push("");
|
|
146
|
+
}
|
|
147
|
+
for (const schema of list) {
|
|
148
|
+
parts.push(schemaToCreateTable(schema, {
|
|
149
|
+
...options,
|
|
150
|
+
dialect
|
|
151
|
+
}));
|
|
152
|
+
const indexStmts = schemaIndexes(schema);
|
|
153
|
+
for (const stmt of indexStmts) parts.push(stmt);
|
|
154
|
+
parts.push("");
|
|
155
|
+
}
|
|
156
|
+
return parts.join("\n");
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { generateSchemaSql, schemaRegistry, schemaToCreateTable, trackSchema };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=schema-sql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-sql.js","names":["z"],"sources":["../../../src/db/schema-sql.ts"],"sourcesContent":["import { z, ZodRawShape } from \"zod\";\nimport { SchemaDefinition, schemaRegistry } from \"./schema\";\nimport type { DeclarativeIndex } from \"./schema\";\nimport { unwrapZodType } from \"./codec\";\n\nexport type SqlDialect = \"postgres\" | \"mysql\";\n\nfunction getFieldMeta(field: unknown): Record<string, unknown> | undefined {\n const f = field as any;\n const meta = typeof f.meta === \"function\" ? f.meta() : undefined;\n if (meta) return meta;\n\n const unwrapped = unwrapZodType(field);\n if (unwrapped !== field) {\n const innerMeta = typeof (unwrapped as any).meta === \"function\" ? (unwrapped as any).meta() : undefined;\n if (innerMeta) return innerMeta;\n }\n\n return undefined;\n}\n\nfunction getStringMaxLength(field: unknown): number | undefined {\n const unwrapped = unwrapZodType(field);\n if (!(unwrapped instanceof z.ZodString)) return undefined;\n\n const checks: any[] = (unwrapped as any)._def?.checks ?? [];\n let maxLength: number | undefined;\n\n for (const check of checks) {\n const c = check.def ?? check;\n if (c.check === \"length_equals\" || c.check === \"size_equals\") {\n const len = c.length ?? c.size;\n if (typeof len === \"number\") maxLength = maxLength === undefined ? len : Math.min(maxLength, len);\n }\n if (c.check === \"max_length\" || c.check === \"max_size\") {\n const len = c.maximum ?? c.max;\n if (typeof len === \"number\") maxLength = maxLength === undefined ? len : Math.min(maxLength, len);\n }\n }\n\n return maxLength;\n}\n\nfunction isOptional(field: unknown): boolean {\n return (\n field instanceof z.ZodOptional ||\n field instanceof z.ZodNullable\n );\n}\n\nfunction escapeSQLString(s: string): string {\n return `'${s.replace(/'/g, \"''\")}'`;\n}\n\nfunction getDefaultFromZod(field: unknown): string | undefined {\n if (!(field instanceof z.ZodDefault)) return undefined;\n\n try {\n const f = field as any;\n let value = f.defaultValue;\n if (value === undefined) value = f._def?.defaultValue;\n if (typeof value === \"function\") value = value();\n\n if (value === undefined) return undefined;\n if (value === null) return \"NULL\";\n if (typeof value === \"string\") return escapeSQLString(value);\n if (typeof value === \"number\") return value.toString();\n if (typeof value === \"boolean\") return value ? \"TRUE\" : \"FALSE\";\n if (typeof value === \"bigint\") return value.toString();\n\n return undefined;\n } catch {\n return undefined;\n }\n}\n\nconst VARCHAR_MAX = 65535;\n\nfunction getSqlType(field: unknown, dialect: SqlDialect): string {\n const meta = getFieldMeta(field);\n if (meta) {\n const dialectKey = dialect === \"mysql\" ? \"mysqlType\" : \"pgType\";\n if (typeof meta[dialectKey] === \"string\") return meta[dialectKey] as string;\n if (typeof meta.sql_type === \"string\") return meta.sql_type;\n }\n\n const unwrapped = unwrapZodType(field);\n\n if (unwrapped instanceof z.ZodString) {\n const maxLen = getStringMaxLength(field);\n if (maxLen !== undefined && maxLen <= VARCHAR_MAX) return `VARCHAR(${maxLen})`;\n return \"TEXT\";\n }\n\n if (unwrapped instanceof z.ZodNumber) return \"BIGINT\";\n\n if (unwrapped instanceof z.ZodBoolean) {\n return dialect === \"mysql\" ? \"TINYINT(1)\" : \"BOOLEAN\";\n }\n\n if (unwrapped instanceof z.ZodDate) {\n return dialect === \"mysql\" ? \"DATETIME(3)\" : \"TIMESTAMPTZ\";\n }\n\n if (unwrapped instanceof z.ZodBigInt) return \"BIGINT\";\n\n if (unwrapped instanceof z.ZodArray) {\n return dialect === \"mysql\" ? \"JSON\" : \"JSONB\";\n }\n\n if (unwrapped instanceof z.ZodObject || unwrapped instanceof z.ZodRecord) {\n return dialect === \"mysql\" ? \"JSON\" : \"JSONB\";\n }\n\n if (unwrapped instanceof z.ZodEnum) return \"TEXT\";\n\n return \"TEXT\";\n}\n\nfunction isPrimaryKey(field: unknown): boolean {\n const meta = getFieldMeta(field);\n return meta?.primaryKey === true;\n}\n\nfunction getDefaultValue(field: unknown): string | undefined {\n const meta = getFieldMeta(field);\n if (meta && typeof meta.defaultValue === \"string\") {\n return meta.defaultValue;\n }\n\n return getDefaultFromZod(field);\n}\n\nexport interface SchemaToCreateTableOptions {\n dialect?: SqlDialect;\n ifNotExists?: boolean;\n}\n\nexport function schemaToCreateTable(\n schema: SchemaDefinition<string, any, any>,\n options?: SchemaToCreateTableOptions,\n): string {\n const dialect = options?.dialect ?? \"postgres\";\n const ifNotExists = options?.ifNotExists ?? true;\n\n const tableName = schema.table;\n const shape = schema.schema.shape;\n const columns: Record<string, string> = schema.columns;\n\n const userKeys = Object.keys(shape).filter(k => k !== \"id\" && k !== \"commitTs\");\n const orderedKeys = [\"id\", ...userKeys, \"commitTs\"];\n\n const lines: string[] = [];\n\n for (const fieldName of orderedKeys) {\n const field = shape[fieldName];\n if (!field) continue;\n\n const colName = columns[fieldName] ?? fieldName;\n if (!colName) continue;\n\n const sqlType = getSqlType(field, dialect);\n const notNull = !isOptional(field);\n const pk = isPrimaryKey(field);\n const defaultVal = fieldName === \"commitTs\" ? \"0\" : getDefaultValue(field);\n\n let line = ` ${colName} ${sqlType}`;\n if (notNull) line += \" NOT NULL\";\n if (pk) line += \" PRIMARY KEY\";\n if (defaultVal !== undefined) line += ` DEFAULT ${defaultVal}`;\n\n lines.push(line);\n }\n\n const ifNot = ifNotExists ? \"IF NOT EXISTS \" : \"\";\n return `CREATE TABLE ${ifNot}${tableName} (\\n${lines.join(\",\\n\")}\\n);`;\n}\n\nexport function formatDeclarativeIndex(\n idx: DeclarativeIndex,\n tableName: string,\n columns: Record<string, string>,\n): string {\n const colNames = idx.columns.map(c => columns[c] ?? c).join(\", \");\n let sql = `CREATE ${idx.unique ? \"UNIQUE \" : \"\"}INDEX IF NOT EXISTS ${idx.name} ON ${tableName}`;\n if (idx.type) sql += ` USING ${idx.type}`;\n sql += ` (${colNames})`;\n if (idx.where) sql += ` WHERE ${idx.where}`;\n return sql + \";\";\n}\n\nexport function schemaIndexes(\n schema: SchemaDefinition<string, any, any>,\n): string[] {\n return (schema.indexes ?? []).map(idx => {\n if (typeof idx === \"string\") return idx;\n return formatDeclarativeIndex(idx, schema.table, schema.columns);\n });\n}\n\nexport interface GenerateSchemaSqlOptions {\n dialect?: SqlDialect;\n ifNotExists?: boolean;\n header?: boolean;\n}\n\nexport function generateSchemaSql(\n schemas?: Map<string, SchemaDefinition<string, any, any>> | SchemaDefinition<string, any, any>[],\n options?: GenerateSchemaSqlOptions,\n): string {\n const dialect = options?.dialect ?? \"postgres\";\n const header = options?.header ?? true;\n\n let list: SchemaDefinition<string, any, any>[];\n\n if (schemas instanceof Map) {\n list = [...schemas.values()];\n } else if (Array.isArray(schemas)) {\n list = schemas;\n } else {\n list = [...schemaRegistry.values()];\n }\n\n list = list.filter(s => s?.table);\n list.sort((a, b) => a.table.localeCompare(b.table));\n\n const parts: string[] = [];\n\n if (header) {\n parts.push(\"-- Generated by Supalive Schema Generator\");\n parts.push(`-- Dialect: ${dialect}`);\n parts.push(`-- Tables: ${list.length}`);\n parts.push(\"\");\n }\n\n for (const schema of list) {\n parts.push(schemaToCreateTable(schema, { ...options, dialect }));\n const indexStmts = schemaIndexes(schema);\n for (const stmt of indexStmts) {\n parts.push(stmt);\n }\n parts.push(\"\");\n }\n\n return parts.join(\"\\n\");\n}\n"],"mappings":";;;;AAOA,SAAS,aAAa,OAAqD;CACvE,MAAM,IAAI;CACV,MAAM,OAAO,OAAO,EAAE,SAAS,aAAa,EAAE,KAAK,IAAI,KAAA;CACvD,IAAI,MAAM,OAAO;CAEjB,MAAM,YAAY,cAAc,KAAK;CACrC,IAAI,cAAc,OAAO;EACrB,MAAM,YAAY,OAAQ,UAAkB,SAAS,aAAc,UAAkB,KAAK,IAAI,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C,OAAO,uBAAuB,KAAK,OAAO,OAAO,OAAO,OAAO;CACnE,CAAC;AACL;AAQA,SAAgB,kBACZ,SACA,SACM;CACN,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,SAAS,SAAS,UAAU;CAElC,IAAI;CAEJ,IAAI,mBAAmB,KACnB,OAAO,CAAC,GAAG,QAAQ,OAAO,CAAC;MACxB,IAAI,MAAM,QAAQ,OAAO,GAC5B,OAAO;MAEP,OAAO,CAAC,GAAG,eAAe,OAAO,CAAC;CAGtC,OAAO,KAAK,QAAO,MAAK,GAAG,KAAK;CAChC,KAAK,MAAM,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,CAAC;CAElD,MAAM,QAAkB,CAAC;CAEzB,IAAI,QAAQ;EACR,MAAM,KAAK,2CAA2C;EACtD,MAAM,KAAK,eAAe,SAAS;EACnC,MAAM,KAAK,cAAc,KAAK,QAAQ;EACtC,MAAM,KAAK,EAAE;CACjB;CAEA,KAAK,MAAM,UAAU,MAAM;EACvB,MAAM,KAAK,oBAAoB,QAAQ;GAAE,GAAG;GAAS;EAAQ,CAAC,CAAC;EAC/D,MAAM,aAAa,cAAc,MAAM;EACvC,KAAK,MAAM,QAAQ,YACf,MAAM,KAAK,IAAI;EAEnB,MAAM,KAAK,EAAE;CACjB;CAEA,OAAO,MAAM,KAAK,IAAI;AAC1B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { An as
|
|
2
|
-
import { t as MySqlDatabase } from "../../mysql-
|
|
3
|
-
import { t as PgDatabase } from "../../postgres-
|
|
4
|
-
import { _ as UpstashConfig, f as DatabaseConfig, g as SupaliveServerConfig, h as SubscriptionManagerConfig, u as SubId } from "../../types_server-
|
|
1
|
+
import { An as CacheLayer, Bn as UnregisterSubscriptionResult, E as Context, Fn as RegisterSubscriptionParams, Gn as UpdateSubscriptionReadSetResult, Hn as UnregisterSubscriptionsResult, In as RegisterSubscriptionParamsSchema, Ln as RegisterSubscriptionResult, Mn as InvalidateWritesetParams, Nn as InvalidateWritesetParamsSchema, Pn as InvalidateWritesetResult, Rn as UnregisterSubscriptionParams, Un as UpdateSubscriptionReadSetParams, Vn as UnregisterSubscriptionsParams, Wn as UpdateSubscriptionReadSetParamsSchema, jn as AffectedSubscription, nt as Router, wt as SupaliveDb, zn as UnregisterSubscriptionParamsSchema } from "../../index-DouKwYL6.js";
|
|
2
|
+
import { t as MySqlDatabase } from "../../mysql-Bxurg_PH.js";
|
|
3
|
+
import { t as PgDatabase } from "../../postgres-CfT_aDx3.js";
|
|
4
|
+
import { _ as UpstashConfig, f as DatabaseConfig, g as SupaliveServerConfig, h as SubscriptionManagerConfig, u as SubId } from "../../types_server-BW1ys_SK.js";
|
|
5
5
|
import pino, { Level } from "pino";
|
|
6
6
|
import Redis$1 from "ioredis";
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/subscription-manager.ts","../../../src/server/subscription-manager-client.ts","../../../src/db/init_db.ts","../../../src/server/sub_hash.ts"],"mappings":";;;;;;;;;;;cAuHa,uBAAA,kBAAyC,OAAA;EAAA,QAC5C,MAAA;EAAA,QACA,UAAA;EAAA,QAEA,UAAA;EAAA,QACA,GAAA;EAAA,QAEA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,EAAA;EAAA,QACA,eAAA;EAAA,QACA,MAAA;EAAA,QAEA,QAAA;EAAA,QACA,mBAAA;EAAA,QACA,gBAAA;EAAA,QAEA,KAAA;cAMI,MAAA,EAAQ,oBAAA,CAAqB,QAAA;EAvBN;;;;;;;;;;;;EAAA,QAuE3B,qBAAA;EAAA,QAqBA,kBAAA;EAOR,cAAA,CAAe,MAAA,EAAQ,MAAA,MAAY,QAAA;EAK7B,KAAA,IAAS,OAAA;EAST,IAAA,IAAQ,OAAA;EASd,QAAA;;;;;;EASA,aAAA;EAAA,QAIQ,sBAAA;EAAA,QAQM,gBAAA;EAAA,QAiDA,aAAA;EAAA,QAeA,cAAA;EAAA,QAiBA,UAAA;EAtGd;;;;;;;EAAA,QAyIQ,eAAA;EAnEM;;;;;EAAA,QA2FA,kBAAA;EAAA,QAwBA,UAAA;EAAA,QA4FA,eAAA;EAAA,
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../../../src/server/supalive-server.ts","../../../src/logger.ts","../../../src/server/subscription-manager.ts","../../../src/server/subscription-manager-client.ts","../../../src/db/init_db.ts","../../../src/server/sub_hash.ts"],"mappings":";;;;;;;;;;;cAuHa,uBAAA,kBAAyC,OAAA;EAAA,QAC5C,MAAA;EAAA,QACA,UAAA;EAAA,QAEA,UAAA;EAAA,QACA,GAAA;EAAA,QAEA,KAAA;EAAA,QACA,QAAA;EAAA,QACA,EAAA;EAAA,QACA,eAAA;EAAA,QACA,MAAA;EAAA,QAEA,QAAA;EAAA,QACA,mBAAA;EAAA,QACA,gBAAA;EAAA,QAEA,KAAA;cAMI,MAAA,EAAQ,oBAAA,CAAqB,QAAA;EAvBN;;;;;;;;;;;;EAAA,QAuE3B,qBAAA;EAAA,QAqBA,kBAAA;EAOR,cAAA,CAAe,MAAA,EAAQ,MAAA,MAAY,QAAA;EAK7B,KAAA,IAAS,OAAA;EAST,IAAA,IAAQ,OAAA;EASd,QAAA;;;;;;EASA,aAAA;EAAA,QAIQ,sBAAA;EAAA,QAQM,gBAAA;EAAA,QAiDA,aAAA;EAAA,QAeA,cAAA;EAAA,QAiBA,UAAA;EAtGd;;;;;;;EAAA,QAyIQ,eAAA;EAnEM;;;;;EAAA,QA2FA,kBAAA;EAAA,QAwBA,UAAA;EAAA,QA4FA,eAAA;EAAA,QA4GA,iBAAA;EAAA,QAuBA,gBAAA;EAqHA;;;;;;;;;;;;;;EAAA,QAhEA,qBAAA;EAAA,QAgEA,kBAAA;EA8SgC;;;;;AAsEP;EAtEO,QAlStC,uBAAA;EAAA,QAmBM,oBAAA;;ACxxBhB;;;;AAA+D;AAC/D;;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Q,UAAA;AAAA,iBAOpD,cAAA,CAAe,MAAA,EAAQ,cAAA,EAAgB,QAAA,YAAoB,UAAA,GAAa,aAAA;;;;;;;;;;;iBAgDlE,gBAAA,CAAiB,EAAA,EAAI,UAAA,EAAY,KAAA,EAAO,UAAA,EAAY,WAAA,aAAsB,OAAA;AAAA,KAsBpF,qBAAA;EACR,OAAA,EAAS,aAAa;EAEtB,eAAA;EAEA,iBAAA;EAEA,iBAAA;EAEA,oBAAA;EAEA,eAAA;AAAA;AAAA,iBAGY,cAAA,CAAe,MAAA,EAAQ,qBAAA;EAA0B,UAAA,EAAY,UAAA;EAAY,cAAA,GAAiB,OAAA;AAAA;;;;iBC5GpF,SAAA,CAAU,KAAA,YAAiB,OAAO;;;;;cAS3C,kBAAA;;ALuGb;;;;;;;iBK7FsB,sBAAA,CACpB,SAAA,UACA,KAAA,oBACA,aAAA,WACC,OAAO;;;;;;iBAWY,gBAAA,CACpB,SAAA,UACA,KAAA,oBACA,aAAA,WACC,OAAO"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as getContextRegistry } from "../../router-DlTYWpop.js";
|
|
2
|
-
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-
|
|
2
|
+
import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-wGbzz6zo.js";
|
|
3
3
|
import { i as AuthenticationError, o as ClientMessageSchema } from "../../types_client_rpc-CIsjQQGG.js";
|
|
4
4
|
import { n as RemoteSubscriptionMessageSchema } from "../../types_server-Dk6o_B7N.js";
|
|
5
|
-
import { n as sleep } from "../../realtime_db-
|
|
6
|
-
import { C as UpdateSubscriptionReadSetParamsSchema, S as UnregisterSubscriptionsResultSchema, _ as RegisterSubscriptionParamsSchema, a as initCacheLayer, b as UnregisterSubscriptionResultSchema, c as appInstanceId, d as logger, f as serializeMapValue, g as RegisterSubscriptionBatchResultSchema, i as createDatabase, l as isProduction, m as InvalidateWritesetResultSchema, n as DB_QUERY_TIMEOUT_MS, o as initDatabase, p as InvalidateWritesetParamsSchema, r as bootstrapDbTypes, s as CacheLayer, u as logLevelOf, v as RegisterSubscriptionResultSchema, w as UpdateSubscriptionReadSetResultSchema, y as UnregisterSubscriptionParamsSchema } from "../../subscription-worker-
|
|
5
|
+
import { n as sleep } from "../../realtime_db-DOCgqbwi.js";
|
|
6
|
+
import { C as UpdateSubscriptionReadSetParamsSchema, S as UnregisterSubscriptionsResultSchema, _ as RegisterSubscriptionParamsSchema, a as initCacheLayer, b as UnregisterSubscriptionResultSchema, c as appInstanceId, d as logger, f as serializeMapValue, g as RegisterSubscriptionBatchResultSchema, i as createDatabase, l as isProduction, m as InvalidateWritesetResultSchema, n as DB_QUERY_TIMEOUT_MS, o as initDatabase, p as InvalidateWritesetParamsSchema, r as bootstrapDbTypes, s as CacheLayer, u as logLevelOf, v as RegisterSubscriptionResultSchema, w as UpdateSubscriptionReadSetResultSchema, y as UnregisterSubscriptionParamsSchema } from "../../subscription-worker-CqoWp6zB.js";
|
|
7
7
|
import { createServer } from "http";
|
|
8
8
|
import { WebSocket, WebSocketServer } from "ws";
|
|
9
9
|
import { v4 } from "uuid";
|
|
@@ -399,7 +399,7 @@ var SupaliveWebSocketServer = class {
|
|
|
399
399
|
const session = {
|
|
400
400
|
id: v4(),
|
|
401
401
|
ws,
|
|
402
|
-
serverCtx:
|
|
402
|
+
serverCtx: void 0,
|
|
403
403
|
subIds: /* @__PURE__ */ new Set(),
|
|
404
404
|
mutationQueue: [],
|
|
405
405
|
mutationInFlight: false,
|
|
@@ -694,11 +694,6 @@ var SupaliveWebSocketServer = class {
|
|
|
694
694
|
logger$2.info(`Subscribed: ${subId} for session ${session.id}`);
|
|
695
695
|
} catch (err) {
|
|
696
696
|
logger$2.error(err, `Error subscribing to "${procedureName}"`);
|
|
697
|
-
this.sendMessage(session, {
|
|
698
|
-
type: "response",
|
|
699
|
-
id,
|
|
700
|
-
success: false
|
|
701
|
-
});
|
|
702
697
|
this.sendError(session, id, err instanceof Error ? err.message : "Subscribe failed", "SUBSCRIBE_ERROR");
|
|
703
698
|
}
|
|
704
699
|
}
|