spacetimedb 2.3.0 → 2.4.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 (59) hide show
  1. package/LICENSE.txt +2 -2
  2. package/dist/index.browser.mjs +50 -4
  3. package/dist/index.browser.mjs.map +1 -1
  4. package/dist/index.cjs +50 -4
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.mjs +50 -4
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/lib/autogen/types.d.ts +674 -18
  9. package/dist/lib/autogen/types.d.ts.map +1 -1
  10. package/dist/lib/schema.d.ts.map +1 -1
  11. package/dist/min/index.browser.mjs +1 -1
  12. package/dist/min/index.browser.mjs.map +1 -1
  13. package/dist/min/sdk/index.browser.mjs +1 -1
  14. package/dist/min/sdk/index.browser.mjs.map +1 -1
  15. package/dist/sdk/decompress.d.ts.map +1 -1
  16. package/dist/sdk/index.browser.mjs +50 -4
  17. package/dist/sdk/index.browser.mjs.map +1 -1
  18. package/dist/sdk/index.cjs +50 -4
  19. package/dist/sdk/index.cjs.map +1 -1
  20. package/dist/sdk/index.mjs +50 -4
  21. package/dist/sdk/index.mjs.map +1 -1
  22. package/dist/server/http.d.ts +1 -2
  23. package/dist/server/http.d.ts.map +1 -1
  24. package/dist/server/http.test-d.d.ts +2 -0
  25. package/dist/server/http.test-d.d.ts.map +1 -0
  26. package/dist/server/http_handlers.d.ts +82 -0
  27. package/dist/server/http_handlers.d.ts.map +1 -0
  28. package/dist/server/http_internal.d.ts +1 -32
  29. package/dist/server/http_internal.d.ts.map +1 -1
  30. package/dist/server/http_shared.d.ts +44 -0
  31. package/dist/server/http_shared.d.ts.map +1 -0
  32. package/dist/server/index.d.ts +2 -0
  33. package/dist/server/index.d.ts.map +1 -1
  34. package/dist/server/index.mjs +582 -134
  35. package/dist/server/index.mjs.map +1 -1
  36. package/dist/server/runtime.d.ts +1 -0
  37. package/dist/server/runtime.d.ts.map +1 -1
  38. package/dist/server/schema.d.ts +16 -1
  39. package/dist/server/schema.d.ts.map +1 -1
  40. package/dist/server/views.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/lib/autogen/types.ts +29 -0
  43. package/src/lib/schema.ts +14 -0
  44. package/src/sdk/decompress.ts +19 -4
  45. package/src/sdk/logger.ts +1 -1
  46. package/src/server/http.test-d.ts +80 -0
  47. package/src/server/http.ts +14 -2
  48. package/src/server/http_handlers.ts +413 -0
  49. package/src/server/http_internal.ts +15 -142
  50. package/src/server/http_shared.ts +186 -0
  51. package/src/server/index.ts +11 -0
  52. package/src/server/procedures.ts +8 -30
  53. package/src/server/runtime.ts +137 -1
  54. package/src/server/schema.ts +71 -2
  55. package/src/server/sys.d.ts +7 -0
  56. package/src/server/views.ts +1 -0
  57. package/dist/lib/http_types.d.ts +0 -2
  58. package/dist/lib/http_types.d.ts.map +0 -1
  59. package/src/lib/http_types.ts +0 -8
@@ -4869,11 +4869,21 @@ async function decompress(buffer, type, chunkSize = 128 * 1024) {
4869
4869
  });
4870
4870
  const decompressionStream = new DecompressionStream(type);
4871
4871
  const decompressedStream = readableStream.pipeThrough(decompressionStream);
4872
+ const reader = decompressedStream.getReader();
4872
4873
  const chunks = [];
4873
- for await (const chunk of decompressedStream) {
4874
- chunks.push(chunk);
4875
- }
4876
- return new Blob(chunks).bytes();
4874
+ let totalLength = 0;
4875
+ let result;
4876
+ while (!(result = await reader.read()).done) {
4877
+ chunks.push(result.value);
4878
+ totalLength += result.value.length;
4879
+ }
4880
+ const decompressedArray = new Uint8Array(totalLength);
4881
+ let chunkOffset = 0;
4882
+ for (const chunk of chunks) {
4883
+ decompressedArray.set(chunk, chunkOffset);
4884
+ chunkOffset += chunk.length;
4885
+ }
4886
+ return decompressedArray;
4877
4887
  }
4878
4888
 
4879
4889
  // src/sdk/ws.ts
@@ -6549,6 +6559,8 @@ var ModuleContext = class {
6549
6559
  procedures: [],
6550
6560
  views: [],
6551
6561
  lifeCycleReducers: [],
6562
+ httpHandlers: [],
6563
+ httpRoutes: [],
6552
6564
  caseConversionPolicy: { tag: "SnakeCase" },
6553
6565
  explicitNames: {
6554
6566
  entries: []
@@ -6576,6 +6588,18 @@ var ModuleContext = class {
6576
6588
  value: module.lifeCycleReducers
6577
6589
  }
6578
6590
  );
6591
+ push(
6592
+ module.httpHandlers && {
6593
+ tag: "HttpHandlers",
6594
+ value: module.httpHandlers
6595
+ }
6596
+ );
6597
+ push(
6598
+ module.httpRoutes && {
6599
+ tag: "HttpRoutes",
6600
+ value: module.httpRoutes
6601
+ }
6602
+ );
6579
6603
  push(
6580
6604
  module.rowLevelSecurity && {
6581
6605
  tag: "RowLevelSecurity",
@@ -6834,6 +6858,12 @@ var Lifecycle = t.enum("Lifecycle", {
6834
6858
  OnConnect: t.unit(),
6835
6859
  OnDisconnect: t.unit()
6836
6860
  });
6861
+ var MethodOrAny = t.enum("MethodOrAny", {
6862
+ Any: t.unit(),
6863
+ get Method() {
6864
+ return HttpMethod;
6865
+ }
6866
+ });
6837
6867
  var MiscModuleExport = t.enum("MiscModuleExport", {
6838
6868
  get TypeAlias() {
6839
6869
  return TypeAlias;
@@ -6891,6 +6921,16 @@ var RawConstraintDefV9 = t.object("RawConstraintDefV9", {
6891
6921
  return RawConstraintDataV9;
6892
6922
  }
6893
6923
  });
6924
+ var RawHttpHandlerDefV10 = t.object("RawHttpHandlerDefV10", {
6925
+ sourceName: t.string()
6926
+ });
6927
+ var RawHttpRouteDefV10 = t.object("RawHttpRouteDefV10", {
6928
+ handlerFunction: t.string(),
6929
+ get method() {
6930
+ return MethodOrAny;
6931
+ },
6932
+ path: t.string()
6933
+ });
6894
6934
  var RawIndexAlgorithm = t.enum("RawIndexAlgorithm", {
6895
6935
  BTree: t.array(t.u16()),
6896
6936
  Hash: t.array(t.u16()),
@@ -6987,6 +7027,12 @@ var RawModuleDefV10Section = t.enum("RawModuleDefV10Section", {
6987
7027
  },
6988
7028
  get ExplicitNames() {
6989
7029
  return ExplicitNames;
7030
+ },
7031
+ get HttpHandlers() {
7032
+ return t.array(RawHttpHandlerDefV10);
7033
+ },
7034
+ get HttpRoutes() {
7035
+ return t.array(RawHttpRouteDefV10);
6990
7036
  }
6991
7037
  });
6992
7038
  var RawModuleDefV8 = t.object("RawModuleDefV8", {