@supacloud/elysia 0.39.0 → 0.40.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.
@@ -3,9 +3,8 @@
3
3
  "packages": {
4
4
  "elysia": "2.0.0-rc.1",
5
5
  "effect": "4.0.5",
6
- "typescript": "7.0.2",
6
+ "typescript": "7.1.0-beta",
7
7
  "typebox": "1.4.3",
8
- "exact-mirror": "1.2.6",
9
- "@typescript/typescript6": "6.0.2"
8
+ "exact-mirror": "1.2.6"
10
9
  }
11
10
  }
package/dist/bun-aot.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import { Elysia as Elysia3, setupTypebox, Validator as Validator2 } from "elysia";
3
3
  import { requireFeatureRequestContext } from "@supacloud/app";
4
+ import { composeAspects as composeApplicationAspects, invokeAspect, freezeAspectData } from "@supacloud/app/execution";
4
5
  import { PendingWorkRegistry as PendingWorkRegistry2, PendingWorkTimeoutError, PendingWorkCapacityError } from "@supacloud/app/runtime";
5
6
  import { commandFailureMetadata as commandFailureMetadata3, decodeCommandPreview } from "@supacloud/contracts";
6
7
 
@@ -2054,22 +2055,7 @@ var IDEMPOTENCY_KEY_HEADER = "idempotency-key";
2054
2055
  var idempotencyKeyPattern = /^[A-Za-z0-9._:-]{1,512}$/;
2055
2056
  function composeAspects(...aspects) {
2056
2057
  const active = aspects.filter((aspect) => typeof aspect === "function");
2057
- if (active.length === 0)
2058
- return (_context, next) => next();
2059
- return (context, next) => {
2060
- let index = -1;
2061
- const dispatch = (current) => {
2062
- if (current <= index) {
2063
- return Promise.reject(new Error("next() called multiple times"));
2064
- }
2065
- index = current;
2066
- const aspect = active[current];
2067
- if (!aspect)
2068
- return Promise.resolve(next());
2069
- return Promise.resolve(aspect(context, () => dispatch(current + 1)));
2070
- };
2071
- return dispatch(0);
2072
- };
2058
+ return composeApplicationAspects(...active);
2073
2059
  }
2074
2060
  function observedAspects(aspects, boundary, observer) {
2075
2061
  return composeAspects(...aspects.map((aspect, index) => (context, next) => observeExecution(observer, {
@@ -2839,6 +2825,7 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
2839
2825
  const routePipeline = descriptorPipeline(route, "route", options.onExecution);
2840
2826
  const command = route.command ? commandsByClassName.get(route.command) : undefined;
2841
2827
  const commandPipeline = route.command ? descriptorPipeline(command ?? {}, "command", options.onExecution) : undefined;
2828
+ const routeHasAspects = compiled.aspectPipeline !== undefined || (compiled.aspects?.length ?? 0) > 0 || route.aspectPipeline !== undefined || (route.aspects?.length ?? 0) > 0 || command?.aspectPipeline !== undefined || (command?.aspects?.length ?? 0) > 0;
2842
2829
  const routeInvoker = route.invoker;
2843
2830
  if (mappingPolicies.length > 0) {
2844
2831
  const responseValidators = Validator2.response(schema.response, { normalize: options.normalize ?? true });
@@ -2951,7 +2938,10 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
2951
2938
  services,
2952
2939
  metadata: command ?? route
2953
2940
  };
2954
- const invokeRoute = () => modulePipeline(route.command ? commandContext : routeContext, once(() => routePipeline(routeContext, once(() => route.command ? commandPipeline(commandContext, once(invoke)) : invoke()))));
2941
+ const invokeRoute = () => route.command && routeHasAspects ? invokeAspect(commandContext, (_context, next) => modulePipeline(commandContext, () => routePipeline(routeContext, () => commandPipeline(commandContext, next))), invoke, (result) => {
2942
+ if (!(result instanceof Response))
2943
+ freezeAspectData(result);
2944
+ }) : modulePipeline(route.command ? commandContext : routeContext, once(() => routePipeline(routeContext, once(() => route.command ? commandPipeline(commandContext, once(invoke)) : invoke()))));
2955
2945
  const invokeCommand = () => {
2956
2946
  if (!route.command)
2957
2947
  return invokeRoute();
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/index.ts
2
2
  import { Elysia as Elysia3, setupTypebox, Validator as Validator2 } from "elysia";
3
3
  import { requireFeatureRequestContext } from "@supacloud/app";
4
+ import { composeAspects as composeApplicationAspects, invokeAspect, freezeAspectData } from "@supacloud/app/execution";
4
5
  import { PendingWorkRegistry as PendingWorkRegistry2, PendingWorkTimeoutError, PendingWorkCapacityError } from "@supacloud/app/runtime";
5
6
  import { commandFailureMetadata as commandFailureMetadata3, decodeCommandPreview } from "@supacloud/contracts";
6
7
 
@@ -2054,22 +2055,7 @@ var IDEMPOTENCY_KEY_HEADER = "idempotency-key";
2054
2055
  var idempotencyKeyPattern = /^[A-Za-z0-9._:-]{1,512}$/;
2055
2056
  function composeAspects(...aspects) {
2056
2057
  const active = aspects.filter((aspect) => typeof aspect === "function");
2057
- if (active.length === 0)
2058
- return (_context, next) => next();
2059
- return (context, next) => {
2060
- let index = -1;
2061
- const dispatch = (current) => {
2062
- if (current <= index) {
2063
- return Promise.reject(new Error("next() called multiple times"));
2064
- }
2065
- index = current;
2066
- const aspect = active[current];
2067
- if (!aspect)
2068
- return Promise.resolve(next());
2069
- return Promise.resolve(aspect(context, () => dispatch(current + 1)));
2070
- };
2071
- return dispatch(0);
2072
- };
2058
+ return composeApplicationAspects(...active);
2073
2059
  }
2074
2060
  function observedAspects(aspects, boundary, observer) {
2075
2061
  return composeAspects(...aspects.map((aspect, index) => (context, next) => observeExecution(observer, {
@@ -2839,6 +2825,7 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
2839
2825
  const routePipeline = descriptorPipeline(route, "route", options.onExecution);
2840
2826
  const command = route.command ? commandsByClassName.get(route.command) : undefined;
2841
2827
  const commandPipeline = route.command ? descriptorPipeline(command ?? {}, "command", options.onExecution) : undefined;
2828
+ const routeHasAspects = compiled.aspectPipeline !== undefined || (compiled.aspects?.length ?? 0) > 0 || route.aspectPipeline !== undefined || (route.aspects?.length ?? 0) > 0 || command?.aspectPipeline !== undefined || (command?.aspects?.length ?? 0) > 0;
2842
2829
  const routeInvoker = route.invoker;
2843
2830
  if (mappingPolicies.length > 0) {
2844
2831
  const responseValidators = Validator2.response(schema.response, { normalize: options.normalize ?? true });
@@ -2951,7 +2938,10 @@ function createModulePlugin(compiled, services, ctxFactory = defaultRequestConte
2951
2938
  services,
2952
2939
  metadata: command ?? route
2953
2940
  };
2954
- const invokeRoute = () => modulePipeline(route.command ? commandContext : routeContext, once(() => routePipeline(routeContext, once(() => route.command ? commandPipeline(commandContext, once(invoke)) : invoke()))));
2941
+ const invokeRoute = () => route.command && routeHasAspects ? invokeAspect(commandContext, (_context, next) => modulePipeline(commandContext, () => routePipeline(routeContext, () => commandPipeline(commandContext, next))), invoke, (result) => {
2942
+ if (!(result instanceof Response))
2943
+ freezeAspectData(result);
2944
+ }) : modulePipeline(route.command ? commandContext : routeContext, once(() => routePipeline(routeContext, once(() => route.command ? commandPipeline(commandContext, once(invoke)) : invoke()))));
2955
2945
  const invokeCommand = () => {
2956
2946
  if (!route.command)
2957
2947
  return invokeRoute();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/elysia",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Elysia runtime adapter for SupaCloud compiled modules: application/request scopes, route registration and validation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,29 +54,31 @@
54
54
  "directory": "packages/elysia"
55
55
  },
56
56
  "dependencies": {
57
- "@supacloud/app": "0.37.0",
58
- "@supacloud/commands": "0.11.2",
59
- "@supacloud/contracts": "0.15.2",
57
+ "@supacloud/app": "0.38.0",
58
+ "@supacloud/commands": "0.12.0",
59
+ "@supacloud/contracts": "0.16.0",
60
60
  "effect": "4.0.5",
61
61
  "exact-mirror": "1.2.6",
62
62
  "jose": "^6.2.13",
63
63
  "typebox": "1.4.3"
64
64
  },
65
65
  "overrides": {
66
- "@supacloud/delivery": "0.24.0",
67
- "@supacloud/contracts": "0.15.2",
68
- "@supacloud/commands": "0.11.2",
69
- "@graphql-tools/utils": "^12.0.4"
66
+ "@supacloud/delivery": "0.25.0",
67
+ "@supacloud/contracts": "0.16.0",
68
+ "@supacloud/commands": "0.12.0",
69
+ "@graphql-tools/utils": "^12.0.4",
70
+ "deepmerge-ts": "8.0.2",
71
+ "prisma": "6.19.3"
70
72
  },
71
73
  "peerDependencies": {
72
74
  "elysia": "2.0.0-rc.1"
73
75
  },
74
76
  "devDependencies": {
75
- "@supacloud/compiler": "0.56.0",
76
- "@supacloud/delivery": "0.24.0",
77
- "@supacloud/db": "0.20.5",
77
+ "@supacloud/compiler": "0.57.0",
78
+ "@supacloud/delivery": "0.25.0",
79
+ "@supacloud/db": "0.21.0",
78
80
  "@types/bun": "^1.4.4",
79
81
  "elysia": "2.0.0-rc.1",
80
- "typescript": "^7.0.2"
82
+ "typescript": "7.1.0-beta"
81
83
  }
82
84
  }