@supalive/core 1.3.0 → 1.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 (43) hide show
  1. package/dist/index-BGITtVcD.d.ts +2106 -0
  2. package/dist/index-BGITtVcD.d.ts.map +1 -0
  3. package/dist/index-CbYOjwGh.d.ts +2105 -0
  4. package/dist/index-CbYOjwGh.d.ts.map +1 -0
  5. package/dist/index-DTNBHQPY.d.ts +2106 -0
  6. package/dist/index-DTNBHQPY.d.ts.map +1 -0
  7. package/dist/mysql-BRyidTZD.d.ts +109 -0
  8. package/dist/mysql-BRyidTZD.d.ts.map +1 -0
  9. package/dist/mysql-CLcFRLam.d.ts +109 -0
  10. package/dist/mysql-CLcFRLam.d.ts.map +1 -0
  11. package/dist/mysql-Dp6BDecZ.d.ts +109 -0
  12. package/dist/mysql-Dp6BDecZ.d.ts.map +1 -0
  13. package/dist/object-storage-354KU6Mj.d.ts +77 -0
  14. package/dist/object-storage-354KU6Mj.d.ts.map +1 -0
  15. package/dist/object-storage-hhZSz8qM.d.ts +69 -0
  16. package/dist/object-storage-hhZSz8qM.d.ts.map +1 -0
  17. package/dist/postgres-CONYSAv6.d.ts +113 -0
  18. package/dist/postgres-CONYSAv6.d.ts.map +1 -0
  19. package/dist/postgres-Dh4ATweM.d.ts +113 -0
  20. package/dist/postgres-Dh4ATweM.d.ts.map +1 -0
  21. package/dist/postgres-Dsa4m0wv.d.ts +113 -0
  22. package/dist/postgres-Dsa4m0wv.d.ts.map +1 -0
  23. package/dist/src/client/index.d.ts +1 -1
  24. package/dist/src/exports/mysql.d.ts +1 -1
  25. package/dist/src/exports/postgres.d.ts +1 -1
  26. package/dist/src/exports/procedure.d.ts +1 -1
  27. package/dist/src/exports/schema-sql.d.ts +1 -1
  28. package/dist/src/exports/server.d.ts +4 -4
  29. package/dist/src/exports/server.d.ts.map +1 -1
  30. package/dist/src/exports/server.js +5 -2
  31. package/dist/src/exports/server.js.map +1 -1
  32. package/dist/src/exports/storage.d.ts +30 -13
  33. package/dist/src/exports/storage.d.ts.map +1 -1
  34. package/dist/src/exports/storage.js +19 -10
  35. package/dist/src/exports/storage.js.map +1 -1
  36. package/dist/src/exports/types.d.ts +2 -2
  37. package/dist/types_server-BXn_YC0a.d.ts +301 -0
  38. package/dist/types_server-BXn_YC0a.d.ts.map +1 -0
  39. package/dist/types_server-CDu9dPnG.d.ts +301 -0
  40. package/dist/types_server-CDu9dPnG.d.ts.map +1 -0
  41. package/dist/types_server-CmofdaIn.d.ts +301 -0
  42. package/dist/types_server-CmofdaIn.d.ts.map +1 -0
  43. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { i as PresignedUpload, n as CreateUploadUrlOptions, r as ObjectStorage, t as CreateDownloadUrlOptions } from "../../object-storage-4t7JvpuK.js";
1
+ import { i as PresignedUpload, n as CreateUploadUrlOptions, r as ObjectStorage, t as CreateDownloadUrlOptions } from "../../object-storage-354KU6Mj.js";
2
2
 
3
3
  //#region src/storage/s3-storage.d.ts
4
4
  /**
@@ -7,11 +7,32 @@ import { i as PresignedUpload, n as CreateUploadUrlOptions, r as ObjectStorage,
7
7
  * for its types costs nothing. Only constructing {@link S3CompatibleStorage}
8
8
  * requires the SDK to be installed by the consuming app.
9
9
  */
10
+ /** Per-bucket settings. A bucket with a `publicBaseUrl` is served publicly. */
11
+ interface S3BucketConfig {
12
+ /**
13
+ * Public base URL for this bucket (an R2 public-bucket domain or custom
14
+ * domain, no trailing slash). Its presence marks the bucket PUBLIC:
15
+ * {@link ObjectStorage.publicUrl} returns a stable, non-expiring link. Omit to
16
+ * keep the bucket private (reads go through presigned download URLs).
17
+ */
18
+ publicBaseUrl?: string;
19
+ }
10
20
  interface S3StorageOptions {
11
- /** Bucket the objects live in. */
12
- bucket: string;
13
21
  accessKeyId: string;
14
22
  secretAccessKey: string;
23
+ /**
24
+ * The buckets this storage can address, keyed by bucket name. Register every
25
+ * bucket you upload to / read from; give the public ones a `publicBaseUrl` and
26
+ * leave the private ones as `{}`. Supports many public buckets, each on its
27
+ * own domain.
28
+ *
29
+ * @example
30
+ * buckets: {
31
+ * "mygifty": {}, // private
32
+ * "mygifty-pub": { publicBaseUrl: "https://r2p.mygiftyapp.com" }, // public
33
+ * }
34
+ */
35
+ buckets: Record<string, S3BucketConfig>;
15
36
  /**
16
37
  * S3 endpoint. Omit for AWS S3; for Cloudflare R2 use
17
38
  * `https://<accountid>.r2.cloudflarestorage.com`.
@@ -24,12 +45,6 @@ interface S3StorageOptions {
24
45
  * virtual-hosted (`bucket.endpoint/key`). Handy for MinIO / some R2 setups.
25
46
  */
26
47
  forcePathStyle?: boolean;
27
- /**
28
- * Public base URL for {@link ObjectStorage.publicUrl} (R2 public bucket domain
29
- * or a custom domain, no trailing slash). When unset, reads fall back to
30
- * presigned download URLs.
31
- */
32
- publicBaseUrl?: string;
33
48
  /** Default upload-URL validity, seconds (default 900 = 15 min). */
34
49
  uploadExpiresIn?: number;
35
50
  /** Default download-URL validity, seconds (default 3600 * 24 * 7 = 7 days). */
@@ -42,15 +57,17 @@ interface S3StorageOptions {
42
57
  */
43
58
  declare class S3CompatibleStorage implements ObjectStorage {
44
59
  private readonly client;
45
- private readonly bucket;
46
- private readonly publicBaseUrl;
60
+ /** bucket name → normalized public base URL (null when the bucket is private). */
61
+ private readonly buckets;
47
62
  private readonly uploadExpiresIn;
48
63
  private readonly downloadExpiresIn;
49
64
  constructor(opts: S3StorageOptions);
65
+ /** Guard that a bucket was registered, so typos fail loudly at call time. */
66
+ private assertBucket;
50
67
  createUploadUrl(opts: CreateUploadUrlOptions): Promise<PresignedUpload>;
51
68
  createDownloadUrl(opts: CreateDownloadUrlOptions): Promise<string>;
52
- publicUrl(key: string): string | null;
69
+ publicUrl(bucket: string, key: string): string | null;
53
70
  }
54
71
  //#endregion
55
- export { type CreateDownloadUrlOptions, type CreateUploadUrlOptions, type ObjectStorage, type PresignedUpload, S3CompatibleStorage, type S3StorageOptions };
72
+ export { type CreateDownloadUrlOptions, type CreateUploadUrlOptions, type ObjectStorage, type PresignedUpload, type S3BucketConfig, S3CompatibleStorage, type S3StorageOptions };
56
73
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","names":[],"sources":["../../../src/storage/s3-storage.ts"],"mappings":";;;;;AAeA;;;;UAAiB,gBAAA;EAGf;EADA,MAAA;EACA,WAAA;EACA,eAAA;EAYA;;;;EAPA,QAAA;EAiBiB;EAfjB,MAAA;EAuB+B;;;;EAlB/B,cAAA;EAyCqD;;;;;EAnCrD,aAAA;EAY0C;EAV1C,eAAA;EAYiB;EAVjB,iBAAA;AAAA;;;;;;cAQW,mBAAA,YAA+B,aAAA;EAAA,iBACzB,MAAA;EAAA,iBACA,MAAA;EAAA,iBACA,aAAA;EAAA,iBACA,eAAA;EAAA,iBACA,iBAAA;cAEL,IAAA,EAAM,gBAAA;EAgBZ,eAAA,CAAgB,IAAA,EAAM,sBAAA,GAAyB,OAAA,CAAQ,eAAA;EAoBvD,iBAAA,CAAkB,IAAA,EAAM,wBAAA,GAA2B,OAAA;EAQzD,SAAA,CAAU,GAAA;AAAA"}
1
+ {"version":3,"file":"storage.d.ts","names":[],"sources":["../../../src/storage/s3-storage.ts"],"mappings":";;;;;AAgBA;;;;AAOe;AAAA,UAPE,cAAA;EAUgB;;;;;;EAH/B,aAAa;AAAA;AAAA,UAGE,gBAAA;EACf,WAAA;EACA,eAAA;EA2BA;;;AAEiB;AAQnB;;;;;;;;EAxBE,OAAA,EAAS,MAAM,SAAS,cAAA;EAwBkB;;;;EAnB1C,QAAA;EAsBiB;EApBjB,MAAA;EAsBiB;;;;EAjBjB,cAAA;EAoDM;EAlDN,eAAA;EAkDsB;EAhDtB,iBAAA;AAAA;;;;;;cAQW,mBAAA,YAA+B,aAAA;EAAA,iBACzB,MAAA;EAsEoB;EAAA,iBApEpB,OAAA;EAAA,iBACA,eAAA;EAAA,iBACA,iBAAA;cAEL,IAAA,EAAM,gBAAA;;UAwBV,YAAA;EASF,eAAA,CAAgB,IAAA,EAAM,sBAAA,GAAyB,OAAA,CAAQ,eAAA;EAsBvD,iBAAA,CAAkB,IAAA,EAAM,wBAAA,GAA2B,OAAA;EASzD,SAAA,CAAU,MAAA,UAAgB,GAAA;AAAA"}
@@ -8,8 +8,8 @@ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
8
8
  */
9
9
  var S3CompatibleStorage = class {
10
10
  client;
11
- bucket;
12
- publicBaseUrl;
11
+ /** bucket name → normalized public base URL (null when the bucket is private). */
12
+ buckets;
13
13
  uploadExpiresIn;
14
14
  downloadExpiresIn;
15
15
  constructor(opts) {
@@ -22,20 +22,28 @@ var S3CompatibleStorage = class {
22
22
  secretAccessKey: opts.secretAccessKey
23
23
  }
24
24
  });
25
- this.bucket = opts.bucket;
26
- this.publicBaseUrl = opts.publicBaseUrl?.replace(/\/+$/, "") ?? null;
25
+ this.buckets = new Map(Object.entries(opts.buckets).map(([name, cfg]) => {
26
+ const base = cfg.publicBaseUrl?.trim().replace(/\/+$/, "");
27
+ return [name, base ? base : null];
28
+ }));
27
29
  this.uploadExpiresIn = opts.uploadExpiresIn ?? 900;
28
30
  this.downloadExpiresIn = opts.downloadExpiresIn ?? 3600 * 24 * 7;
29
31
  }
32
+ /** Guard that a bucket was registered, so typos fail loudly at call time. */
33
+ assertBucket(bucket) {
34
+ if (!this.buckets.has(bucket)) throw new Error(`Unknown storage bucket "${bucket}". Configured buckets: ${[...this.buckets.keys()].join(", ") || "(none)"}.`);
35
+ }
30
36
  async createUploadUrl(opts) {
37
+ this.assertBucket(opts.bucket);
31
38
  const expiresIn = opts.expiresIn ?? this.uploadExpiresIn;
32
39
  const command = new PutObjectCommand({
33
- Bucket: this.bucket,
40
+ Bucket: opts.bucket,
34
41
  Key: opts.key,
35
42
  ContentType: opts.contentType
36
43
  });
37
44
  const uploadUrl = await getSignedUrl(this.client, command, { expiresIn });
38
45
  return {
46
+ bucket: opts.bucket,
39
47
  key: opts.key,
40
48
  uploadUrl,
41
49
  method: "PUT",
@@ -44,16 +52,17 @@ var S3CompatibleStorage = class {
44
52
  };
45
53
  }
46
54
  async createDownloadUrl(opts) {
55
+ this.assertBucket(opts.bucket);
47
56
  const command = new GetObjectCommand({
48
- Bucket: this.bucket,
57
+ Bucket: opts.bucket,
49
58
  Key: opts.key
50
59
  });
51
60
  return getSignedUrl(this.client, command, { expiresIn: opts.expiresIn ?? this.downloadExpiresIn });
52
61
  }
53
- publicUrl(key) {
54
- if (!this.publicBaseUrl) return null;
55
- const encoded = key.split("/").map(encodeURIComponent).join("/");
56
- return `${this.publicBaseUrl}/${encoded}`;
62
+ publicUrl(bucket, key) {
63
+ const base = this.buckets.get(bucket);
64
+ if (!base) return null;
65
+ return `${base}/${key.split("/").map(encodeURIComponent).join("/")}`;
57
66
  }
58
67
  };
59
68
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","names":[],"sources":["../../../src/storage/s3-storage.ts"],"sourcesContent":["import { S3Client, PutObjectCommand, GetObjectCommand } from \"@aws-sdk/client-s3\";\nimport { getSignedUrl } from \"@aws-sdk/s3-request-presigner\";\nimport type {\n ObjectStorage,\n PresignedUpload,\n CreateUploadUrlOptions,\n CreateDownloadUrlOptions,\n} from \"./object-storage\";\n\n/**\n * `@aws-sdk/*` is an OPTIONAL peer dependency: the interface in\n * `./object-storage` has no dependency on it, so importing the storage module\n * for its types costs nothing. Only constructing {@link S3CompatibleStorage}\n * requires the SDK to be installed by the consuming app.\n */\nexport interface S3StorageOptions {\n /** Bucket the objects live in. */\n bucket: string;\n accessKeyId: string;\n secretAccessKey: string;\n /**\n * S3 endpoint. Omit for AWS S3; for Cloudflare R2 use\n * `https://<accountid>.r2.cloudflarestorage.com`.\n */\n endpoint?: string;\n /** Region. Use `\"auto\"` for R2 (the default). */\n region?: string;\n /**\n * Force path-style addressing (`endpoint/bucket/key`) instead of\n * virtual-hosted (`bucket.endpoint/key`). Handy for MinIO / some R2 setups.\n */\n forcePathStyle?: boolean;\n /**\n * Public base URL for {@link ObjectStorage.publicUrl} (R2 public bucket domain\n * or a custom domain, no trailing slash). When unset, reads fall back to\n * presigned download URLs.\n */\n publicBaseUrl?: string;\n /** Default upload-URL validity, seconds (default 900 = 15 min). */\n uploadExpiresIn?: number;\n /** Default download-URL validity, seconds (default 3600 * 24 * 7 = 7 days). */\n downloadExpiresIn?: number;\n}\n\n/**\n * {@link ObjectStorage} backed by any S3-compatible provider (AWS S3,\n * Cloudflare R2, MinIO). Presigns upload (PUT) and download (GET) URLs with\n * SigV4 via the AWS SDK; the app server never handles the file bytes itself.\n */\nexport class S3CompatibleStorage implements ObjectStorage {\n private readonly client: S3Client;\n private readonly bucket: string;\n private readonly publicBaseUrl: string | null;\n private readonly uploadExpiresIn: number;\n private readonly downloadExpiresIn: number;\n\n constructor(opts: S3StorageOptions) {\n this.client = new S3Client({\n region: opts.region ?? \"auto\",\n endpoint: opts.endpoint,\n forcePathStyle: opts.forcePathStyle ?? false,\n credentials: {\n accessKeyId: opts.accessKeyId,\n secretAccessKey: opts.secretAccessKey,\n },\n });\n this.bucket = opts.bucket;\n this.publicBaseUrl = opts.publicBaseUrl?.replace(/\\/+$/, \"\") ?? null;\n this.uploadExpiresIn = opts.uploadExpiresIn ?? 900;\n this.downloadExpiresIn = opts.downloadExpiresIn ?? 3600 * 24 * 7;\n }\n\n async createUploadUrl(opts: CreateUploadUrlOptions): Promise<PresignedUpload> {\n const expiresIn = opts.expiresIn ?? this.uploadExpiresIn;\n const command = new PutObjectCommand({\n Bucket: this.bucket,\n Key: opts.key,\n ContentType: opts.contentType,\n });\n const uploadUrl = await getSignedUrl(this.client, command, { expiresIn });\n\n return {\n key: opts.key,\n uploadUrl,\n method: \"PUT\",\n // The client must echo the exact Content-Type that was signed, or the\n // upload is rejected with a signature mismatch.\n headers: opts.contentType ? { \"Content-Type\": opts.contentType } : {},\n expiresAt: new Date(Date.now() + expiresIn * 1000),\n };\n }\n\n async createDownloadUrl(opts: CreateDownloadUrlOptions): Promise<string> {\n const command = new GetObjectCommand({ Bucket: this.bucket, Key: opts.key });\n\n return getSignedUrl(this.client, command, {\n expiresIn: opts.expiresIn ?? this.downloadExpiresIn,\n });\n }\n\n publicUrl(key: string): string | null {\n if (!this.publicBaseUrl) return null;\n \n const encoded = key.split(\"/\").map(encodeURIComponent).join(\"/\");\n return `${this.publicBaseUrl}/${encoded}`;\n }\n}\n"],"mappings":";;;;;;;;AAiDA,IAAa,sBAAb,MAA0D;CACxD;CACA;CACA;CACA;CACA;CAEA,YAAY,MAAwB;EAClC,KAAK,SAAS,IAAI,SAAS;GACzB,QAAQ,KAAK,UAAU;GACvB,UAAU,KAAK;GACf,gBAAgB,KAAK,kBAAkB;GACvC,aAAa;IACX,aAAa,KAAK;IAClB,iBAAiB,KAAK;GACxB;EACF,CAAC;EACD,KAAK,SAAS,KAAK;EACnB,KAAK,gBAAgB,KAAK,eAAe,QAAQ,QAAQ,EAAE,KAAK;EAChE,KAAK,kBAAkB,KAAK,mBAAmB;EAC/C,KAAK,oBAAoB,KAAK,qBAAqB,OAAO,KAAK;CACjE;CAEA,MAAM,gBAAgB,MAAwD;EAC5E,MAAM,YAAY,KAAK,aAAa,KAAK;EACzC,MAAM,UAAU,IAAI,iBAAiB;GACnC,QAAQ,KAAK;GACb,KAAK,KAAK;GACV,aAAa,KAAK;EACpB,CAAC;EACD,MAAM,YAAY,MAAM,aAAa,KAAK,QAAQ,SAAS,EAAE,UAAU,CAAC;EAExE,OAAO;GACL,KAAK,KAAK;GACV;GACA,QAAQ;GAGR,SAAS,KAAK,cAAc,EAAE,gBAAgB,KAAK,YAAY,IAAI,CAAC;GACpE,WAAW,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,GAAI;EACnD;CACF;CAEA,MAAM,kBAAkB,MAAiD;EACvE,MAAM,UAAU,IAAI,iBAAiB;GAAE,QAAQ,KAAK;GAAQ,KAAK,KAAK;EAAI,CAAC;EAE3E,OAAO,aAAa,KAAK,QAAQ,SAAS,EACxC,WAAW,KAAK,aAAa,KAAK,kBACpC,CAAC;CACH;CAEA,UAAU,KAA4B;EACpC,IAAI,CAAC,KAAK,eAAe,OAAO;EAEhC,MAAM,UAAU,IAAI,MAAM,GAAG,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,KAAK,GAAG;EAC/D,OAAO,GAAG,KAAK,cAAc,GAAG;CAClC;AACF"}
1
+ {"version":3,"file":"storage.js","names":[],"sources":["../../../src/storage/s3-storage.ts"],"sourcesContent":["import { S3Client, PutObjectCommand, GetObjectCommand } from \"@aws-sdk/client-s3\";\nimport { getSignedUrl } from \"@aws-sdk/s3-request-presigner\";\nimport type {\n ObjectStorage,\n PresignedUpload,\n CreateUploadUrlOptions,\n CreateDownloadUrlOptions,\n} from \"./object-storage\";\n\n/**\n * `@aws-sdk/*` is an OPTIONAL peer dependency: the interface in\n * `./object-storage` has no dependency on it, so importing the storage module\n * for its types costs nothing. Only constructing {@link S3CompatibleStorage}\n * requires the SDK to be installed by the consuming app.\n */\n/** Per-bucket settings. A bucket with a `publicBaseUrl` is served publicly. */\nexport interface S3BucketConfig {\n /**\n * Public base URL for this bucket (an R2 public-bucket domain or custom\n * domain, no trailing slash). Its presence marks the bucket PUBLIC:\n * {@link ObjectStorage.publicUrl} returns a stable, non-expiring link. Omit to\n * keep the bucket private (reads go through presigned download URLs).\n */\n publicBaseUrl?: string;\n}\n\nexport interface S3StorageOptions {\n accessKeyId: string;\n secretAccessKey: string;\n /**\n * The buckets this storage can address, keyed by bucket name. Register every\n * bucket you upload to / read from; give the public ones a `publicBaseUrl` and\n * leave the private ones as `{}`. Supports many public buckets, each on its\n * own domain.\n *\n * @example\n * buckets: {\n * \"mygifty\": {}, // private\n * \"mygifty-pub\": { publicBaseUrl: \"https://r2p.mygiftyapp.com\" }, // public\n * }\n */\n buckets: Record<string, S3BucketConfig>;\n /**\n * S3 endpoint. Omit for AWS S3; for Cloudflare R2 use\n * `https://<accountid>.r2.cloudflarestorage.com`.\n */\n endpoint?: string;\n /** Region. Use `\"auto\"` for R2 (the default). */\n region?: string;\n /**\n * Force path-style addressing (`endpoint/bucket/key`) instead of\n * virtual-hosted (`bucket.endpoint/key`). Handy for MinIO / some R2 setups.\n */\n forcePathStyle?: boolean;\n /** Default upload-URL validity, seconds (default 900 = 15 min). */\n uploadExpiresIn?: number;\n /** Default download-URL validity, seconds (default 3600 * 24 * 7 = 7 days). */\n downloadExpiresIn?: number;\n}\n\n/**\n * {@link ObjectStorage} backed by any S3-compatible provider (AWS S3,\n * Cloudflare R2, MinIO). Presigns upload (PUT) and download (GET) URLs with\n * SigV4 via the AWS SDK; the app server never handles the file bytes itself.\n */\nexport class S3CompatibleStorage implements ObjectStorage {\n private readonly client: S3Client;\n /** bucket name → normalized public base URL (null when the bucket is private). */\n private readonly buckets: Map<string, string | null>;\n private readonly uploadExpiresIn: number;\n private readonly downloadExpiresIn: number;\n\n constructor(opts: S3StorageOptions) {\n this.client = new S3Client({\n region: opts.region ?? \"auto\",\n endpoint: opts.endpoint,\n forcePathStyle: opts.forcePathStyle ?? false,\n credentials: {\n accessKeyId: opts.accessKeyId,\n secretAccessKey: opts.secretAccessKey,\n },\n });\n this.buckets = new Map(\n Object.entries(opts.buckets).map(([name, cfg]) => {\n // Treat null / undefined / empty / whitespace-only as \"no public base\"\n // (private bucket) — otherwise an empty string would make the bucket\n // look public and produce broken `/key` URLs.\n const base = cfg.publicBaseUrl?.trim().replace(/\\/+$/, \"\");\n return [name, base ? base : null];\n }),\n );\n this.uploadExpiresIn = opts.uploadExpiresIn ?? 900;\n this.downloadExpiresIn = opts.downloadExpiresIn ?? 3600 * 24 * 7;\n }\n\n /** Guard that a bucket was registered, so typos fail loudly at call time. */\n private assertBucket(bucket: string): void {\n if (!this.buckets.has(bucket)) {\n throw new Error(\n `Unknown storage bucket \"${bucket}\". Configured buckets: ` +\n `${[...this.buckets.keys()].join(\", \") || \"(none)\"}.`,\n );\n }\n }\n\n async createUploadUrl(opts: CreateUploadUrlOptions): Promise<PresignedUpload> {\n this.assertBucket(opts.bucket);\n const expiresIn = opts.expiresIn ?? this.uploadExpiresIn;\n const command = new PutObjectCommand({\n Bucket: opts.bucket,\n Key: opts.key,\n ContentType: opts.contentType,\n });\n const uploadUrl = await getSignedUrl(this.client, command, { expiresIn });\n\n return {\n bucket: opts.bucket,\n key: opts.key,\n uploadUrl,\n method: \"PUT\",\n // The client must echo the exact Content-Type that was signed, or the\n // upload is rejected with a signature mismatch.\n headers: opts.contentType ? { \"Content-Type\": opts.contentType } : {},\n expiresAt: new Date(Date.now() + expiresIn * 1000),\n };\n }\n\n async createDownloadUrl(opts: CreateDownloadUrlOptions): Promise<string> {\n this.assertBucket(opts.bucket);\n const command = new GetObjectCommand({ Bucket: opts.bucket, Key: opts.key });\n\n return getSignedUrl(this.client, command, {\n expiresIn: opts.expiresIn ?? this.downloadExpiresIn,\n });\n }\n\n publicUrl(bucket: string, key: string): string | null {\n const base = this.buckets.get(bucket);\n if (!base) return null; // unknown bucket or a private one → no public URL\n\n const encoded = key.split(\"/\").map(encodeURIComponent).join(\"/\");\n return `${base}/${encoded}`;\n }\n}\n"],"mappings":";;;;;;;;AAiEA,IAAa,sBAAb,MAA0D;CACxD;;CAEA;CACA;CACA;CAEA,YAAY,MAAwB;EAClC,KAAK,SAAS,IAAI,SAAS;GACzB,QAAQ,KAAK,UAAU;GACvB,UAAU,KAAK;GACf,gBAAgB,KAAK,kBAAkB;GACvC,aAAa;IACX,aAAa,KAAK;IAClB,iBAAiB,KAAK;GACxB;EACF,CAAC;EACD,KAAK,UAAU,IAAI,IACjB,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS;GAIhD,MAAM,OAAO,IAAI,eAAe,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE;GACzD,OAAO,CAAC,MAAM,OAAO,OAAO,IAAI;EAClC,CAAC,CACH;EACA,KAAK,kBAAkB,KAAK,mBAAmB;EAC/C,KAAK,oBAA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ema, C as ClientMessageSchema, Cr as NO_RETRY, D as ErrorMessage, Dr as OrPredicateSchema, E as Context, Er as OrPredicate, F as SubscribeMessage, Fr as QueryCacheMetadataSchema, Gr as ReadEntry, H as UnsubscribeMessageSchema, Hr as RawRangeReadSchema, I as SubscribeMessageSchema, Ir as QuerySpec, Jr as WriteEntry, Kr as ReadEntrySchema, L as SubscriptionGoneMessage, Lr as RangeRead, M as ServerMessageSchema, Mr as QueryCacheEntry, N as ServerPingMessage, Nr as QueryCacheEntrySchema, O as IsInternal, Or as PointRead, P as ServerPingMessageSchema, Pr as QueryCacheMetadata, Qr as bytesFromJson, R as SubscriptionGoneMessageSchema, Rr as RangeReadSchema, S as ClientMessage, Sr as MutationResult, T as ConnectedMessageSchema, Tr as OccConflictError, Ur as RawReadEntry, V as UnsubscribeMessage, Vr as RawRangeRead, Wr as RawReadEntrySchema, Xr as WriteOp, Yr as WriteEntrySchema, Zr as WriteOpSchema, _ as AuthSuccessMessage, _r as CompareOperatorSchema, b as CallMessage, br as LeafPredicateSchema, dr as BigIntSchema, ei as normalizeToBytes, fr as CachedPgMetadata, g as AuthMessageSchema, gr as CompareOperator, h as AuthMessage, hr as CommitTs, j as ServerMessage, jr as PredicateSchema, k as ResponseMessage, kr as PointReadSchema, lr as AndPredicate, m as AuthFailedMessageSchema, mr as CommitLogEntry, p as AuthFailedMessage, pr as CachedPgMetadataSchema, qr as RetryConfig, ur as AndPredicateSchema, v as AuthSuccessMessageSchema, vr as DEFAULT_RETRY, w as ConnectedMessage, wr as OccAbortError, x as CallMessageSchema, xr as LiveResult, y as AuthenticationError, yr as LeafPredicate, z as SubscriptionUpdateMessage, zr as RawPointRead } from "../../index-DDK9ZIYb.js";
1
+ import { $r as normalizeIdToBytes, A as ResponseMessageSchema, Ar as Predicate, B as SubscriptionUpdateMessageSchema, Br as RawPointReadSchema, C as ClientMessageSchema, Cr as NO_RETRY, D as ErrorMessage, Dr as OrPredicateSchema, E as Context, Er as OrPredicate, F as SubscribeMessage, Fr as QueryCacheMetadataSchema, Gr as ReadEntry, H as UnsubscribeMessageSchema, Hr as RawRangeReadSchema, I as SubscribeMessageSchema, Ir as QuerySpec, Jr as WriteEntry, Kr as ReadEntrySchema, L as SubscriptionGoneMessage, Lr as RangeRead, M as ServerMessageSchema, Mr as QueryCacheEntry, N as ServerPingMessage, Nr as QueryCacheEntrySchema, O as IsInternal, Or as PointRead, P as ServerPingMessageSchema, Pr as QueryCacheMetadata, Qr as bytesFromJson, R as SubscriptionGoneMessageSchema, Rr as RangeReadSchema, S as ClientMessage, Sr as MutationResult, T as ConnectedMessageSchema, Tr as OccConflictError, Ur as RawReadEntry, V as UnsubscribeMessage, Vr as RawRangeRead, Wr as RawReadEntrySchema, Xr as WriteOp, Yr as WriteEntrySchema, Zr as WriteOpSchema, _ as AuthSuccessMessage, _r as CompareOperatorSchema, b as CallMessage, br as LeafPredicateSchema, dr as BigIntSchema, ei as normalizeToBytes, fr as CachedPgMetadata, g as AuthMessageSchema, gr as CompareOperator, h as AuthMessage, hr as CommitTs, j as ServerMessage, jr as PredicateSchema, k as ResponseMessage, kr as PointReadSchema, lr as AndPredicate, m as AuthFailedMessageSchema, mr as CommitLogEntry, p as AuthFailedMessage, pr as CachedPgMetadataSchema, qr as RetryConfig, ur as AndPredicateSchema, v as AuthSuccessMessageSchema, vr as DEFAULT_RETRY, w as ConnectedMessage, wr as OccAbortError, x as CallMessageSchema, xr as LiveResult, y as AuthenticationError, yr as LeafPredicate, z as SubscriptionUpdateMessage, zr as RawPointRead } from "../../index-DTNBHQPY.js";
2
2
  import { n as stableStringify, r as supaliveStringify, t as groupByToMap } from "../../helper-CiacMqje.js";
3
- import { _ as RpcRateLimitConfig, a as RemoteSubscriptionMessage, b as UpstashConfig, c as RemoteSubscriptionUpdateSchema, d as SubscriptionEntry, f as DatabaseConfig, g as RpcCorsConfig, h as RpcConfig, i as RemoteRecomputeRaceSchema, l as Session, m as PostgresConfig, n as PendingMutation, o as RemoteSubscriptionMessageSchema, p as MySQLConfig, r as RemoteRecomputeRace, s as RemoteSubscriptionUpdate, t as InstanceId, u as SubId, v as SubscriptionManagerConfig, y as SupaliveServerConfig } from "../../types_server-C9owgeSs.js";
3
+ import { _ as RpcRateLimitConfig, a as RemoteSubscriptionMessage, b as UpstashConfig, c as RemoteSubscriptionUpdateSchema, d as SubscriptionEntry, f as DatabaseConfig, g as RpcCorsConfig, h as RpcConfig, i as RemoteRecomputeRaceSchema, l as Session, m as PostgresConfig, n as PendingMutation, o as RemoteSubscriptionMessageSchema, p as MySQLConfig, r as RemoteRecomputeRace, s as RemoteSubscriptionUpdate, t as InstanceId, u as SubId, v as SubscriptionManagerConfig, y as SupaliveServerConfig } from "../../types_server-CDu9dPnG.js";
4
4
  export { AndPredicate, AndPredicateSchema, AuthFailedMessage, AuthFailedMessageSchema, AuthMessage, AuthMessageSchema, AuthSuccessMessage, AuthSuccessMessageSchema, AuthenticationError, BigIntSchema, CachedPgMetadata, CachedPgMetadataSchema, CallMessage, CallMessageSchema, ClientMessage, ClientMessageSchema, CommitLogEntry, CommitTs, CompareOperator, CompareOperatorSchema, ConnectedMessage, ConnectedMessageSchema, Context, DEFAULT_RETRY, DatabaseConfig, ErrorMessage, InstanceId, IsInternal, LeafPredicate, LeafPredicateSchema, LiveResult, MutationResult, MySQLConfig, NO_RETRY, OccAbortError, OccConflictError, OrPredicate, OrPredicateSchema, PendingMutation, PointRead, PointReadSchema, PostgresConfig, Predicate, PredicateSchema, QueryCacheEntry, QueryCacheEntrySchema, QueryCacheMetadata, QueryCacheMetadataSchema, QuerySpec, RangeRead, RangeReadSchema, RawPointRead, RawPointReadSchema, RawRangeRead, RawRangeReadSchema, RawReadEntry, RawReadEntrySchema, ReadEntry, ReadEntrySchema, RemoteRecomputeRace, RemoteRecomputeRaceSchema, RemoteSubscriptionMessage, RemoteSubscriptionMessageSchema, RemoteSubscriptionUpdate, RemoteSubscriptionUpdateSchema, ResponseMessage, ResponseMessageSchema, RetryConfig, RpcConfig, RpcCorsConfig, RpcRateLimitConfig, ServerMessage, ServerMessageSchema, ServerPingMessage, ServerPingMessageSchema, Session, SubId, SubscribeMessage, SubscribeMessageSchema, SubscriptionEntry, SubscriptionGoneMessage, SubscriptionGoneMessageSchema, SubscriptionManagerConfig, SubscriptionUpdateMessage, SubscriptionUpdateMessageSchema, SupaliveServerConfig, UnsubscribeMessage, UnsubscribeMessageSchema, UpstashConfig, WriteEntry, WriteEntrySchema, WriteOp, WriteOpSchema, bytesFromJson, groupByToMap, normalizeIdToBytes, normalizeToBytes, stableStringify, supaliveStringify };
@@ -0,0 +1,301 @@
1
+ import { Bt as SupaliveDb, Ft as JobScheduler, Sr as MutationResult, nt as RegisteredProcedure, qn as CacheLayer } from "./index-CbYOjwGh.js";
2
+ import { r as ObjectStorage } from "./object-storage-hhZSz8qM.js";
3
+ import z from "zod";
4
+ import { IncomingMessage } from "http";
5
+ import { WebSocket } from "ws";
6
+ import { Level } from "pino";
7
+ import { Redis } from "ioredis";
8
+
9
+ //#region src/config.d.ts
10
+ /** CORS policy for the HTTP RPC endpoint. */
11
+ interface RpcCorsConfig {
12
+ /**
13
+ * Allowed origins. `"*"` sends `Access-Control-Allow-Origin: *`; a list
14
+ * echoes back a request's `Origin` only when it matches (and sets `Vary`).
15
+ * Omit `cors` entirely to send no CORS headers (same-origin only).
16
+ */
17
+ origins: string[] | "*";
18
+ }
19
+ /** Rate-limit policy for the HTTP RPC endpoint (fixed window, per instance). */
20
+ interface RpcRateLimitConfig {
21
+ /** Window length in ms. Default 60000. */
22
+ windowMs?: number;
23
+ /** Max requests per window per key. Default 120. */
24
+ max?: number;
25
+ /**
26
+ * Derive the limiter key from the request. Default: client IP
27
+ * (`X-Forwarded-For` first hop, else socket address). Return a stable string.
28
+ */
29
+ keyBy?: (req: IncomingMessage) => string;
30
+ }
31
+ /**
32
+ * Enables a one-shot HTTP RPC transport for `query`/`mutation`/`action`
33
+ * (no subscriptions — those stay WebSocket-only). Lets clients that don't need
34
+ * live queries call procedures without holding a socket open. Omit to disable
35
+ * the endpoint entirely.
36
+ */
37
+ interface RpcConfig<TContext = unknown> {
38
+ /**
39
+ * URL path prefix. Default `/_rpc`. A procedure `foo` is called as
40
+ * `POST {path}/foo`. Keep this distinct from `jobPath`.
41
+ */
42
+ path?: string;
43
+ /**
44
+ * Map an HTTP request to the auth `data` handed to `verifyAuth` (the same
45
+ * callback the WebSocket path uses). Default: `Authorization: Bearer <token>`
46
+ * → `{ token }`. Return `undefined` for an anonymous request.
47
+ */
48
+ auth?: (req: IncomingMessage) => Record<string, unknown> | undefined;
49
+ /** CORS policy. Omit for same-origin only (no CORS headers). */
50
+ cors?: RpcCorsConfig;
51
+ /** Rate limiting. Omit for defaults (120/min per IP); set `false` to disable. */
52
+ rateLimit?: RpcRateLimitConfig | false;
53
+ }
54
+ interface UpstashConfig {
55
+ url: string;
56
+ token: string;
57
+ redisUrl: string;
58
+ }
59
+ /** Database configuration for PostgreSQL */
60
+ interface PostgresConfig {
61
+ type: "postgres";
62
+ connectionString: string;
63
+ /** Optional max connections for the Postgres connection pool. Defaults to 10.*/
64
+ maxConnections?: number;
65
+ /** Optional min connections for the Postgres connection pool. Defaults to 1.*/
66
+ minConnections?: number;
67
+ /** Optional idle timeout for Postgres connections in milliseconds. Defaults to 30000 (30 seconds). */
68
+ idleTimeoutMillis?: number;
69
+ /** Optional connection timeout for acquiring Postgres connections in milliseconds. Defaults to 7000 (7 seconds). */
70
+ connectionTimeoutMillis?: number;
71
+ }
72
+ /** Database configuration for MySQL */
73
+ interface MySQLConfig {
74
+ type: "mysql";
75
+ connectionString: string;
76
+ /** Optional max connections for the MySQL connection pool. Defaults to 20.*/
77
+ maxConnections?: number;
78
+ /** Optional min connections for the MySQL connection pool. Defaults to 1.*/
79
+ minConnections?: number;
80
+ /** Optional idle timeout for MySQL connections in milliseconds. Defaults to 30000 (30 seconds). */
81
+ idleTimeoutMillis?: number;
82
+ /** Optional connection timeout for acquiring MySQL connections in milliseconds. Defaults to 7000 (7 seconds). */
83
+ connectionTimeoutMillis?: number;
84
+ /** Optional flag to queue connection requests when pool is exhausted. Defaults to true (queue requests). */
85
+ queueLimit?: number;
86
+ }
87
+ type DatabaseConfig = PostgresConfig | MySQLConfig;
88
+ /**
89
+ * Configuration for the Supalive WebSocket server.
90
+ */
91
+ interface SupaliveServerConfig<TContext = Record<string, unknown>> {
92
+ /** Server port (default: 3000) */
93
+ port?: number;
94
+ /** Server host (default: "0.0.0.0") */
95
+ host?: string;
96
+ cacheLayer: CacheLayer;
97
+ redisSubClient: Redis;
98
+ /**
99
+ * Subscription Manager WebSocket URL for RPC communication.
100
+ * A single sub-manager process owns all subscription state for this
101
+ * deployment. Internally it spawns N logical workers (configured on the
102
+ * sub-manager side) and routes by hash(subId) to spread CPU across them.
103
+ */
104
+ subManagerUrl: string;
105
+ /** Database instance */
106
+ database: SupaliveDb;
107
+ /**
108
+ * Optional authentication callback.
109
+ * Called when client sends auth message.
110
+ * Return null to reject authentication.
111
+ */
112
+ verifyAuth?: (data: Record<string, unknown>, sessionId: string) => Promise<TContext | null>;
113
+ /**
114
+ * Server context name for procedure routing.
115
+ * Must match the router's contextName.
116
+ */
117
+ contextName?: string;
118
+ /**
119
+ * Session TTL in seconds (default: 3600 = 1 hour).
120
+ * Sessions are kept alive while connected and expire after disconnect.
121
+ */
122
+ sessionTtlSeconds?: number;
123
+ /**
124
+ * Enable detailed logging.
125
+ */
126
+ logLevel?: Level;
127
+ /**
128
+ * Extract user ID from context for cache key generation.
129
+ * If not provided, caching is disabled (each sub recomputes independently).
130
+ */
131
+ getUserId?: (ctx: TContext | undefined) => string | null;
132
+ /**
133
+ * Cache TTL in seconds (default: 3600).
134
+ * How long query results are cached in Redis.
135
+ */
136
+ cacheTtlSeconds?: number;
137
+ /**
138
+ * Scheduler backing the job system. When provided, the server exposes an
139
+ * HTTP endpoint (`{jobPath}/<jobName>`) that the scheduler POSTs to, and
140
+ * syncs every registered recurring (cron) job at startup. Omit to disable
141
+ * jobs entirely. Use `DevScheduler` locally and `QStashScheduler` in prod.
142
+ */
143
+ scheduler: JobScheduler;
144
+ /**
145
+ * Builds the system server context handed to a job handler's `serverCtx`.
146
+ * Jobs run without a client, so this is where a deployment injects its
147
+ * "system"/service identity. Called per job invocation.
148
+ */
149
+ jobContext?: () => TContext | Promise<TContext>;
150
+ /**
151
+ * Absolute, externally-reachable base URL of this server (no trailing
152
+ * slash), e.g. `https://api.example.com` in prod or `http://127.0.0.1:3000`
153
+ * in dev. Used to build the job endpoint the scheduler calls.
154
+ */
155
+ publicUrl: string;
156
+ /**
157
+ * URL path prefix for the job webhook endpoint. Default `/_jobs`. The full
158
+ * endpoint for a job is `{publicUrl}{jobPath}/<jobName>`.
159
+ */
160
+ jobPath?: string;
161
+ /**
162
+ * Enable the one-shot HTTP RPC transport (query/mutation/action over
163
+ * `POST {rpc.path}/<name>`). Uses the same `verifyAuth` as the WebSocket
164
+ * path. Omit to disable. See {@link RpcConfig}.
165
+ */
166
+ rpc?: RpcConfig<TContext>;
167
+ /**
168
+ * Object storage, exposed to every procedure as `ctx.storage`. When set,
169
+ * query/mutation/action/job handlers can presign uploads/downloads and
170
+ * resolve public URLs without reaching for a module-level singleton. Omit
171
+ * to leave `ctx.storage` undefined (handlers should treat uploads as
172
+ * unconfigured). Build one with `S3CompatibleStorage` from
173
+ * `@supalive/core/storage`.
174
+ */
175
+ storage: ObjectStorage;
176
+ }
177
+ interface SubscriptionManagerConfig {
178
+ port: number;
179
+ upstash: {
180
+ url: string;
181
+ token: string;
182
+ redisUrl: string;
183
+ };
184
+ database: DatabaseConfig;
185
+ cacheTTLSeconds: number;
186
+ /**
187
+ * Number of logical workers inside the sub-manager process.
188
+ *
189
+ * Subscriptions are routed by FNV-1a(subId) % workers so that all operations
190
+ * for a given subId always land on the same worker (preserving the existing
191
+ * `instances: Set<string>` dedup). Each worker owns an independent
192
+ * subscriptions Map; on invalidate, all workers scan their own slice in
193
+ * parallel (logically — JS still runs one at a time inside one event loop,
194
+ * but per-worker scans are smaller so total work is split N ways).
195
+ *
196
+ * Defaults to `SUPALIVE_SUB_MANAGER_WORKERS` env var if set, else 1.
197
+ */
198
+ workers?: number;
199
+ /**
200
+ * Connection pool size *per worker*. If omitted, falls back to
201
+ * `floor(database.maxConnections / workers)` (min 1) so the total pool
202
+ * size stays close to the legacy single-worker configuration.
203
+ */
204
+ maxConnectionsPerWorker?: number;
205
+ }
206
+ //#endregion
207
+ //#region src/server/types_server.d.ts
208
+ type InstanceId = string;
209
+ type SubId = string;
210
+ /** Local tracking of an active subscription (per-session) */
211
+ interface SubscriptionEntry {
212
+ subId: SubId;
213
+ cacheKey: string;
214
+ subscribedTimes: number;
215
+ }
216
+ /**
217
+ * A mutation that has been validated and parked on the per-session FIFO
218
+ * queue, waiting for the in-flight mutation on this socket to finish. Each
219
+ * `handleCall` for a mutation owns one of these and awaits its own
220
+ * resolve/reject so it can send the response.
221
+ */
222
+ interface PendingMutation<TContext = Record<string, unknown>> {
223
+ procedure: RegisteredProcedure<TContext>;
224
+ validatedInput: unknown;
225
+ resolve: (result: MutationResult<unknown>) => void;
226
+ reject: (err: unknown) => void;
227
+ }
228
+ /** WebSocket session (runtime, with WebSocket) */
229
+ interface Session<TContext = Record<string, unknown>> {
230
+ id: string;
231
+ ws: WebSocket;
232
+ /** Auth context from verifyAuth callback */
233
+ serverCtx?: TContext;
234
+ subIds: Set<string>;
235
+ /**
236
+ * Per-socket FIFO mutation queue. at most one mutation
237
+ * drains at a time so a single client cannot saturate the OCC retry
238
+ * loop or fan out concurrent commits that race the same rows.
239
+ */
240
+ mutationQueue: PendingMutation<TContext>[];
241
+ mutationInFlight: boolean;
242
+ /** Per-socket count of currently executing actions. */
243
+ actionInFlight: number;
244
+ /**
245
+ * Wall-clock of the last inbound frame (text message, ws-ping, or ws-pong).
246
+ * Used by the per-session heartbeat to terminate sockets that have gone
247
+ * silent past `CLIENT_TIMEOUT_MS`.
248
+ */
249
+ lastReceivedAt: number;
250
+ /**
251
+ * Wall-clock of the last outbound frame. Gates the idle-only app-level
252
+ * ping so a busy session (frequent sub:updates etc.) doesn't emit a
253
+ * redundant `{type:"ping"}` on every heartbeat tick.
254
+ */
255
+ lastSentAt: number;
256
+ /**
257
+ * Per-session combined heartbeat. Single `setInterval` that handles
258
+ * both dead-TCP detection (ws-ping or terminate) and client-watchdog
259
+ * refresh (idle-only app-level ping) on each tick.
260
+ */
261
+ heartbeatTimer: ReturnType<typeof setInterval> | null;
262
+ }
263
+ declare const RemoteSubscriptionUpdateSchema: z.ZodObject<{
264
+ type: z.ZodLiteral<"update">;
265
+ subId: z.ZodString;
266
+ data: z.ZodUnknown;
267
+ dataHash: z.ZodString;
268
+ originInstance: z.ZodString;
269
+ }, z.core.$strip>;
270
+ type RemoteSubscriptionUpdate = z.infer<typeof RemoteSubscriptionUpdateSchema>;
271
+ declare const RemoteRecomputeRaceSchema: z.ZodObject<{
272
+ type: z.ZodLiteral<"recompute-race">;
273
+ subId: z.ZodString;
274
+ cacheKey: z.ZodString;
275
+ queryName: z.ZodString;
276
+ args: z.ZodUnknown;
277
+ notifyInstances: z.ZodArray<z.ZodString>;
278
+ commitTs: z.ZodString;
279
+ originInstance: z.ZodString;
280
+ }, z.core.$strip>;
281
+ type RemoteRecomputeRace = z.infer<typeof RemoteRecomputeRaceSchema>;
282
+ declare const RemoteSubscriptionMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
283
+ type: z.ZodLiteral<"update">;
284
+ subId: z.ZodString;
285
+ data: z.ZodUnknown;
286
+ dataHash: z.ZodString;
287
+ originInstance: z.ZodString;
288
+ }, z.core.$strip>, z.ZodObject<{
289
+ type: z.ZodLiteral<"recompute-race">;
290
+ subId: z.ZodString;
291
+ cacheKey: z.ZodString;
292
+ queryName: z.ZodString;
293
+ args: z.ZodUnknown;
294
+ notifyInstances: z.ZodArray<z.ZodString>;
295
+ commitTs: z.ZodString;
296
+ originInstance: z.ZodString;
297
+ }, z.core.$strip>], "type">;
298
+ type RemoteSubscriptionMessage = z.infer<typeof RemoteSubscriptionMessageSchema>;
299
+ //#endregion
300
+ export { RpcRateLimitConfig as _, RemoteSubscriptionMessage as a, UpstashConfig as b, RemoteSubscriptionUpdateSchema as c, SubscriptionEntry as d, DatabaseConfig as f, RpcCorsConfig as g, RpcConfig as h, RemoteRecomputeRaceSchema as i, Session as l, PostgresConfig as m, PendingMutation as n, RemoteSubscriptionMessageSchema as o, MySQLConfig as p, RemoteRecomputeRace as r, RemoteSubscriptionUpdate as s, InstanceId as t, SubId as u, SubscriptionManagerConfig as v, SupaliveServerConfig as y };
301
+ //# sourceMappingURL=types_server-BXn_YC0a.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types_server-BXn_YC0a.d.ts","names":[],"sources":["../src/config.ts","../src/server/types_server.ts"],"mappings":";;;;;;;;;;UASiB,aAAA;EAAA;;;;AAMR;EAAP,OAAO;AAAA;;UAIQ,kBAAA;EAEf;EAAA,QAAA;EAOA;EALA,GAAA;EAKS;;AAAoB;AAS/B;EATE,KAAA,IAAS,GAAA,EAAK,eAAe;AAAA;;;;;;;UASd,SAAA;EAKf;;;;EAAA,IAAA;EAQA;;;;;EAFA,IAAA,IAAQ,GAAA,EAAK,eAAA,KAAoB,MAAA;EAOlB;EALf,IAAA,GAAO,aAAA;;EAEP,SAAA,GAAY,kBAAA;AAAA;AAAA,UAGG,aAAA;EACb,GAAA;EACA,KAAA;EACA,QAAA;AAAA;;UAIa,cAAA;EACb,IAAA;EACA,gBAAA;EAAA;EAEA,cAAA;EAGA;EAAA,cAAA;EAMA;EAHA,iBAAA;EAGuB;EAAvB,uBAAA;AAAA;;UAIa,WAAA;EACb,IAAA;EACA,gBAAA;EAEA;EAAA,cAAA;EAMA;EAHA,cAAA;EASA;EANA,iBAAA;EAMU;EAHV,uBAAA;EAMsB;EAHtB,UAAA;AAAA;AAAA,KAGQ,cAAA,GAAiB,cAAA,GAAiB,WAAW;AAKzD;;;AAAA,UAAiB,oBAAA,YAAgC,MAAA;EA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