@zenstackhq/server 2.14.1 → 2.15.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.
@@ -0,0 +1,44 @@
1
+ import { Elysia, Context as ElysiaContext } from 'elysia';
2
+ import { AdapterBaseOptions } from '../types';
3
+ /**
4
+ * Options for initializing an Elysia middleware.
5
+ */
6
+ export interface ElysiaOptions extends AdapterBaseOptions {
7
+ /**
8
+ * Callback method for getting a Prisma instance for the given request context.
9
+ */
10
+ getPrisma: (context: ElysiaContext) => Promise<unknown> | unknown;
11
+ /**
12
+ * Optional base path to strip from the request path before passing to the API handler.
13
+ */
14
+ basePath?: string;
15
+ }
16
+ /**
17
+ * Creates an Elysia middleware handler for ZenStack.
18
+ * This handler provides automatic CRUD APIs through Elysia's routing system.
19
+ */
20
+ export declare function createElysiaHandler(options: ElysiaOptions): (app: Elysia) => Promise<Elysia<"", {
21
+ decorator: {};
22
+ store: {};
23
+ derive: {};
24
+ resolve: {};
25
+ }, {
26
+ typebox: {};
27
+ error: {};
28
+ }, {
29
+ schema: {};
30
+ standaloneSchema: {};
31
+ macro: {};
32
+ macroFn: {};
33
+ parser: {};
34
+ }, {}, {
35
+ derive: {};
36
+ resolve: {};
37
+ schema: {};
38
+ standaloneSchema: {};
39
+ }, {
40
+ derive: {};
41
+ resolve: {};
42
+ schema: {};
43
+ standaloneSchema: {};
44
+ }>>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createElysiaHandler = createElysiaHandler;
4
+ const api_1 = require("../api");
5
+ const shared_1 = require("../shared");
6
+ /**
7
+ * Creates an Elysia middleware handler for ZenStack.
8
+ * This handler provides automatic CRUD APIs through Elysia's routing system.
9
+ */
10
+ function createElysiaHandler(options) {
11
+ const { modelMeta, zodSchemas } = (0, shared_1.loadAssets)(options);
12
+ const requestHandler = options.handler ?? (0, api_1.RPCApiHandler)();
13
+ return async (app) => {
14
+ app.all('/*', async (ctx) => {
15
+ const { request, body, set } = ctx;
16
+ const prisma = (await options.getPrisma(ctx));
17
+ if (!prisma) {
18
+ set.status = 500;
19
+ return {
20
+ message: 'unable to get prisma from request context',
21
+ };
22
+ }
23
+ const url = new URL(request.url);
24
+ const query = Object.fromEntries(url.searchParams);
25
+ let path = url.pathname;
26
+ if (options.basePath && path.startsWith(options.basePath)) {
27
+ path = path.slice(options.basePath.length);
28
+ if (!path.startsWith('/')) {
29
+ path = '/' + path;
30
+ }
31
+ }
32
+ if (!path || path === '/') {
33
+ set.status = 400;
34
+ return {
35
+ message: 'missing path parameter',
36
+ };
37
+ }
38
+ try {
39
+ const r = await requestHandler({
40
+ method: request.method,
41
+ path,
42
+ query,
43
+ requestBody: body,
44
+ prisma,
45
+ modelMeta,
46
+ zodSchemas,
47
+ logger: options.logger,
48
+ });
49
+ set.status = r.status;
50
+ return r.body;
51
+ }
52
+ catch (err) {
53
+ set.status = 500;
54
+ return {
55
+ message: 'An internal server error occurred',
56
+ };
57
+ }
58
+ });
59
+ return app;
60
+ };
61
+ }
62
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/elysia/handler.ts"],"names":[],"mappings":";;AAwBA,kDAyDC;AA/ED,gCAAuC;AACvC,sCAAuC;AAiBvC;;;GAGG;AACH,SAAgB,mBAAmB,CAAC,OAAsB;IACtD,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,IAAA,mBAAU,EAAC,OAAO,CAAC,CAAC;IACtD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,IAAI,IAAA,mBAAa,GAAE,CAAC;IAE1D,OAAO,KAAK,EAAE,GAAW,EAAE,EAAE;QACzB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAkB,EAAE,EAAE;YACvC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;YACnC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AI,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC;gBACjB,OAAO;oBACH,OAAO,EAAE,mCAAmC;iBAC/C,CAAC;YACN,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACf,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './handler';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./handler"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/elysia/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
@@ -0,0 +1,15 @@
1
+ import { DbClientContract } from '@zenstackhq/runtime';
2
+ import { HttpAdapterHost } from "@nestjs/core";
3
+ import { ApiHandlerOptions } from './interfaces';
4
+ /**
5
+ * The ZenStack API handler service for NestJS. The service is used to handle API requests
6
+ * and forward them to the ZenStack API handler. It is platform agnostic and can be used
7
+ * with any HTTP adapter.
8
+ */
9
+ export declare class ApiHandlerService {
10
+ private readonly httpAdapterHost;
11
+ private readonly prisma;
12
+ private readonly request;
13
+ constructor(httpAdapterHost: HttpAdapterHost, prisma: DbClientContract, request: unknown);
14
+ handleRequest(options?: ApiHandlerOptions): Promise<unknown>;
15
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ApiHandlerService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const core_1 = require("@nestjs/core");
18
+ const shared_1 = require("../shared");
19
+ const rpc_1 = require("../api/rpc");
20
+ const zenstack_constants_1 = require("./zenstack.constants");
21
+ /**
22
+ * The ZenStack API handler service for NestJS. The service is used to handle API requests
23
+ * and forward them to the ZenStack API handler. It is platform agnostic and can be used
24
+ * with any HTTP adapter.
25
+ */
26
+ let ApiHandlerService = class ApiHandlerService {
27
+ constructor(httpAdapterHost, prisma, request) {
28
+ this.httpAdapterHost = httpAdapterHost;
29
+ this.prisma = prisma;
30
+ this.request = request;
31
+ }
32
+ async handleRequest(options) {
33
+ const { modelMeta, zodSchemas } = (0, shared_1.loadAssets)(options || {});
34
+ const requestHandler = options?.handler || (0, rpc_1.RPCApiHandler)();
35
+ const hostname = this.httpAdapterHost.httpAdapter.getRequestHostname(this.request);
36
+ const requestUrl = this.httpAdapterHost.httpAdapter.getRequestUrl(this.request);
37
+ // prefix with http:// to make a valid url accepted by URL constructor
38
+ const url = new URL(`http://${hostname}${requestUrl}`);
39
+ const method = this.httpAdapterHost.httpAdapter.getRequestMethod(this.request);
40
+ const path = options?.baseUrl && url.pathname.startsWith(options.baseUrl) ? url.pathname.slice(options.baseUrl.length) : url.pathname;
41
+ const searchParams = url.searchParams;
42
+ const query = Object.fromEntries(searchParams);
43
+ const requestBody = this.request.body;
44
+ const response = await requestHandler({
45
+ method,
46
+ path,
47
+ query,
48
+ requestBody,
49
+ prisma: this.prisma,
50
+ modelMeta,
51
+ zodSchemas,
52
+ logger: options?.logger,
53
+ });
54
+ // handle handler error
55
+ // if response code >= 400 throw nestjs HttpException
56
+ // the error response will be generated by nestjs
57
+ // caller can use try/catch to deal with this manually also
58
+ if (response.status >= 400) {
59
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
+ throw new common_1.HttpException(response.body, response.status);
61
+ }
62
+ return response.body;
63
+ }
64
+ };
65
+ exports.ApiHandlerService = ApiHandlerService;
66
+ exports.ApiHandlerService = ApiHandlerService = __decorate([
67
+ (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST }),
68
+ __param(1, (0, common_1.Inject)(zenstack_constants_1.ENHANCED_PRISMA)),
69
+ __param(2, (0, common_1.Inject)(core_1.REQUEST)),
70
+ __metadata("design:paramtypes", [core_1.HttpAdapterHost, Object, Object])
71
+ ], ApiHandlerService);
72
+ //# sourceMappingURL=api-handler.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-handler.service.js","sourceRoot":"","sources":["../../src/nestjs/api-handler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAA0E;AAC1E,uCAAwD;AACxD,sCAAuC;AACvC,oCAA2C;AAC3C,6DAAuD;AAGvD;;;;GAIG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC1B,YACqB,eAAgC,EACP,MAAwB,EACh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J,KAAK;YACL,WAAW;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS;YACT,UAAU;YACV,MAAM,EAAE,OAAO,EAAE,MAAM;SAC1B,CAAC,CAAC;QAEH,uBAAuB;QACvB,qDAAqD;QACrD,iDAAiD;QACjD,2DAA2D;QAC3D,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YACzB,8DAA8D;YAC9D,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,IAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;QAClF,CAAC;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACxB,CAAC;CACJ,CAAA;AAzCY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAI5B,WAAA,IAAA,eAAM,EAAC,oCAAe,CAAC,CAAA;IACvB,WAAA,IAAA,eAAM,EAAC,cAAO,CAAC,CAAA;qCAFkB,sBAAe;GAF5C,iBAAiB,CAyC7B"}
package/nestjs/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './zenstack.module';
2
+ export * from './api-handler.service';
3
+ export * from './zenstack.constants';
package/nestjs/index.js CHANGED
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./zenstack.module"), exports);
18
+ __exportStar(require("./api-handler.service"), exports);
19
+ __exportStar(require("./zenstack.constants"), exports);
18
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nestjs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,wDAAsC;AACtC,uDAAqC"}
@@ -0,0 +1,17 @@
1
+ import { AdapterBaseOptions } from "../../types";
2
+ export interface ApiHandlerOptions extends AdapterBaseOptions {
3
+ /**
4
+ * The base URL for the API handler. This is used to determine the base path for the API requests.
5
+ * If you are using the ApiHandlerService in a route with a prefix, you should set this to the prefix.
6
+ *
7
+ * e.g.
8
+ * without baseUrl(API handler default route):
9
+ * - RPC API handler: [model]/findMany
10
+ * - RESTful API handler: /:type
11
+ *
12
+ * with baseUrl(/api/crud):
13
+ * - RPC API handler: /api/crud/[model]/findMany
14
+ * - RESTful API handler: /api/crud/:type
15
+ */
16
+ baseUrl?: string;
17
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api-handler-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-handler-options.interface.js","sourceRoot":"","sources":["../../../src/nestjs/interfaces/api-handler-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './zenstack-module-options.interface';
2
+ export * from './api-handler-options.interface';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./zenstack-module-options.interface"), exports);
18
+ __exportStar(require("./api-handler-options.interface"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nestjs/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sEAAmD;AACnD,kEAA+C"}
@@ -0,0 +1,35 @@
1
+ import { FactoryProvider, ModuleMetadata, Provider } from "@nestjs/common";
2
+ /**
3
+ * ZenStack module options.
4
+ */
5
+ export interface ZenStackModuleOptions {
6
+ /**
7
+ * A callback for getting an enhanced `PrismaClient`.
8
+ */
9
+ getEnhancedPrisma: (model?: string | symbol) => unknown;
10
+ }
11
+ /**
12
+ * ZenStack module async registration options.
13
+ */
14
+ export interface ZenStackModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
15
+ /**
16
+ * Whether the module is global-scoped.
17
+ */
18
+ global?: boolean;
19
+ /**
20
+ * The token to export the enhanced Prisma service. Default is {@link ENHANCED_PRISMA}.
21
+ */
22
+ exportToken?: string;
23
+ /**
24
+ * The factory function to create the enhancement options.
25
+ */
26
+ useFactory: (...args: unknown[]) => Promise<ZenStackModuleOptions> | ZenStackModuleOptions;
27
+ /**
28
+ * The dependencies to inject into the factory function.
29
+ */
30
+ inject?: FactoryProvider['inject'];
31
+ /**
32
+ * Extra providers to facilitate dependency injection.
33
+ */
34
+ extraProviders?: Provider[];
35
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=zenstack-module-options.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zenstack-module-options.interface.js","sourceRoot":"","sources":["../../../src/nestjs/interfaces/zenstack-module-options.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The default token used to export the enhanced Prisma service.
3
+ */
4
+ export declare const ENHANCED_PRISMA = "ENHANCED_PRISMA";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ENHANCED_PRISMA = void 0;
4
+ /**
5
+ * The default token used to export the enhanced Prisma service.
6
+ */
7
+ exports.ENHANCED_PRISMA = 'ENHANCED_PRISMA';
8
+ //# sourceMappingURL=zenstack.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zenstack.constants.js","sourceRoot":"","sources":["../../src/nestjs/zenstack.constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,eAAe,GAAG,iBAAiB,CAAC"}
@@ -1,42 +1,5 @@
1
- import { type DynamicModule, type FactoryProvider, type ModuleMetadata, type Provider } from '@nestjs/common';
2
- /**
3
- * The default token used to export the enhanced Prisma service.
4
- */
5
- export declare const ENHANCED_PRISMA = "ENHANCED_PRISMA";
6
- /**
7
- * ZenStack module options.
8
- */
9
- export interface ZenStackModuleOptions {
10
- /**
11
- * A callback for getting an enhanced `PrismaClient`.
12
- */
13
- getEnhancedPrisma: (model?: string | symbol) => unknown;
14
- }
15
- /**
16
- * ZenStack module async registration options.
17
- */
18
- export interface ZenStackModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
19
- /**
20
- * Whether the module is global-scoped.
21
- */
22
- global?: boolean;
23
- /**
24
- * The token to export the enhanced Prisma service. Default is {@link ENHANCED_PRISMA}.
25
- */
26
- exportToken?: string;
27
- /**
28
- * The factory function to create the enhancement options.
29
- */
30
- useFactory: (...args: unknown[]) => Promise<ZenStackModuleOptions> | ZenStackModuleOptions;
31
- /**
32
- * The dependencies to inject into the factory function.
33
- */
34
- inject?: FactoryProvider['inject'];
35
- /**
36
- * Extra providers to facilitate dependency injection.
37
- */
38
- extraProviders?: Provider[];
39
- }
1
+ import { type DynamicModule } from '@nestjs/common';
2
+ import { ZenStackModuleAsyncOptions } from './interfaces';
40
3
  /**
41
4
  * The ZenStack module for NestJS. The module exports an enhanced Prisma service,
42
5
  * by default with token {@link ENHANCED_PRISMA}.
@@ -7,12 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  };
8
8
  var ZenStackModule_1;
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ZenStackModule = exports.ENHANCED_PRISMA = void 0;
10
+ exports.ZenStackModule = void 0;
11
11
  const common_1 = require("@nestjs/common");
12
- /**
13
- * The default token used to export the enhanced Prisma service.
14
- */
15
- exports.ENHANCED_PRISMA = 'ENHANCED_PRISMA';
12
+ const zenstack_constants_1 = require("./zenstack.constants");
16
13
  /**
17
14
  * The ZenStack module for NestJS. The module exports an enhanced Prisma service,
18
15
  * by default with token {@link ENHANCED_PRISMA}.
@@ -28,7 +25,7 @@ let ZenStackModule = ZenStackModule_1 = class ZenStackModule {
28
25
  imports: options.imports,
29
26
  providers: [
30
27
  {
31
- provide: options.exportToken ?? exports.ENHANCED_PRISMA,
28
+ provide: options.exportToken ?? zenstack_constants_1.ENHANCED_PRISMA,
32
29
  useFactory: async (
33
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
31
  ...args) => {
@@ -53,7 +50,7 @@ let ZenStackModule = ZenStackModule_1 = class ZenStackModule {
53
50
  },
54
51
  ...(options.extraProviders ?? []),
55
52
  ],
56
- exports: [options.exportToken ?? exports.ENHANCED_PRISMA],
53
+ exports: [options.exportToken ?? zenstack_constants_1.ENHANCED_PRISMA],
57
54
  };
58
55
  }
59
56
  };
@@ -1 +1 @@
1
- {"version":3,"file":"zenstack.module.js","sourceRoot":"","sources":["../../src/nestjs/zenstack.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAsH;AAEtH;;GAEG;AACU,QAAA,eAAe,GAAG,iBAAiB,CAAC;AA0CjD;;;GAGG;AAEI,IAAM,cAAc,sBAApB,MAAM,cAAc;IACvB;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,OAAmC;QACpD,OAAO;YACH,MAAM,EAAE,gBAAc;YACtB,MAAM,EAAE,OAAO,EAAE,MAAM;YACvB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,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H,MAAM,EAAE,gBAAc;YACtB,MAAM,EAAE,OAAO,EAAE,MAAM;YACvB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,OAAO,CAAC,WAAW,IAAI,oCAAe;oBAC/C,UAAU,EAAE,KAAK;oBACb,8DAA8D;oBAC9D,GAAG,IAAe,EACpB,EAAE;wBACA,MAAM,EAAE,iBAAiB,EAAE,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;wBAChE,IAAI,CAAC,iBAAiB,EAAE,CAAC;4BACrB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;wBAC3E,CAAC;wBAED,0EAA0E;wBAC1E,0BAA0B;wBAE1B,OAAO,IAAI,KAAK,CACZ,EAAE,EACF;4BACI,GAAG,CAAC,OAAO,EAAE,IAAI;gCACb,8DAA8D;gCAC9D,MAAM,cAAc,GAAQ,iBAAiB,CAAC,IAAI,CAAC,CAAC;gCACpD,IAAI,CAAC,cAAc,EAAE,CAAC;oCAClB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;gCAC7E,CAAC;gCACD,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;4BAChC,CAAC;yBACJ,CACJ,CAAC;oBACN,CAAC;oBACD,MAAM,EAAE,OAAO,CAAC,MAAM;iBACzB;gBACD,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;aACpC;YACD,OAAO,EAAE,CAAC,OAAO,CAAC,WAAW,IAAI,oCAAe,CAAC;SACpD,CAAC;IACN,CAAC;CACJ,CAAA;AA7CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,cAAc,CA6C1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zenstackhq/server",
3
- "version": "2.14.1",
3
+ "version": "2.15.0",
4
4
  "displayName": "ZenStack Server-side Adapters",
5
5
  "description": "ZenStack server-side adapters",
6
6
  "homepage": "https://zenstack.dev",
@@ -13,7 +13,8 @@
13
13
  "express",
14
14
  "nextjs",
15
15
  "sveltekit",
16
- "nuxtjs"
16
+ "nuxtjs",
17
+ "elysia"
17
18
  ],
18
19
  "author": "ZenStack Team",
19
20
  "license": "MIT",
@@ -28,7 +29,7 @@
28
29
  "zod": "^3.22.4",
29
30
  "zod-validation-error": "^1.5.0",
30
31
  "decimal.js": "^10.4.2",
31
- "@zenstackhq/runtime": "2.14.1"
32
+ "@zenstackhq/runtime": "2.15.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@nestjs/common": "^10.3.7",
@@ -39,6 +40,7 @@
39
40
  "@types/express": "^4.17.17",
40
41
  "@types/supertest": "^2.0.12",
41
42
  "body-parser": "^1.20.2",
43
+ "elysia": "^1.3.1",
42
44
  "express": "^4.19.2",
43
45
  "fastify": "^4.14.1",
44
46
  "fastify-plugin": "^4.5.0",
@@ -49,7 +51,7 @@
49
51
  "nuxt": "^3.7.4",
50
52
  "reflect-metadata": "^0.2.2",
51
53
  "supertest": "^6.3.3",
52
- "@zenstackhq/testtools": "2.14.1"
54
+ "@zenstackhq/testtools": "2.15.0"
53
55
  },
54
56
  "exports": {
55
57
  "./package.json": "./package.json",
@@ -65,6 +67,7 @@
65
67
  "./nuxt": "./nuxt/index.js",
66
68
  "./nestjs": "./nestjs/index.js",
67
69
  "./hono": "./hono/index.js",
70
+ "./elysia": "./elysia/index.js",
68
71
  "./types": "./types.js"
69
72
  },
70
73
  "scripts": {