@hono-di/core 0.0.7 → 0.0.15

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.
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
 
3
- // src/decorators.ts
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
5
 
5
6
  // src/constants.ts
6
7
  var METADATA_KEYS = {
@@ -24,15 +25,15 @@ var METADATA_KEYS = {
24
25
  };
25
26
 
26
27
  // src/injector/scope.ts
27
- var Scope = /* @__PURE__ */ ((Scope2) => {
28
+ var Scope = /* @__PURE__ */ (function(Scope2) {
28
29
  Scope2[Scope2["DEFAULT"] = 0] = "DEFAULT";
29
30
  Scope2[Scope2["TRANSIENT"] = 1] = "TRANSIENT";
30
31
  Scope2[Scope2["REQUEST"] = 2] = "REQUEST";
31
32
  return Scope2;
32
- })(Scope || {});
33
+ })({});
33
34
 
34
35
  // src/interfaces.ts
35
- var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
36
+ var RequestMethod = /* @__PURE__ */ (function(RequestMethod2) {
36
37
  RequestMethod2["GET"] = "get";
37
38
  RequestMethod2["POST"] = "post";
38
39
  RequestMethod2["PUT"] = "put";
@@ -42,7 +43,7 @@ var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
42
43
  RequestMethod2["OPTIONS"] = "options";
43
44
  RequestMethod2["HEAD"] = "head";
44
45
  return RequestMethod2;
45
- })(RequestMethod || {});
46
+ })({});
46
47
 
47
48
  // src/decorators.ts
48
49
  function Global() {
@@ -50,22 +51,28 @@ function Global() {
50
51
  Reflect.defineMetadata(METADATA_KEYS.GLOBAL, true, target);
51
52
  };
52
53
  }
54
+ __name(Global, "Global");
53
55
  function Module(options) {
54
56
  return (target) => {
55
57
  Reflect.defineMetadata(METADATA_KEYS.MODULE, options, target);
56
58
  };
57
59
  }
60
+ __name(Module, "Module");
58
61
  function Injectable(options) {
59
62
  return (target) => {
60
- Reflect.defineMetadata(METADATA_KEYS.SCOPE, options?.scope ?? 0 /* DEFAULT */, target);
63
+ Reflect.defineMetadata(METADATA_KEYS.SCOPE, options?.scope ?? Scope.DEFAULT, target);
61
64
  };
62
65
  }
66
+ __name(Injectable, "Injectable");
63
67
  function Controller(prefix = "") {
64
68
  return (target) => {
65
- Reflect.defineMetadata(METADATA_KEYS.CONTROLLER, { prefix }, target);
66
- Reflect.defineMetadata(METADATA_KEYS.SCOPE, 0 /* DEFAULT */, target);
69
+ Reflect.defineMetadata(METADATA_KEYS.CONTROLLER, {
70
+ prefix
71
+ }, target);
72
+ Reflect.defineMetadata(METADATA_KEYS.SCOPE, Scope.DEFAULT, target);
67
73
  };
68
74
  }
75
+ __name(Controller, "Controller");
69
76
  function createRouteDecorator(method) {
70
77
  return (path = "/") => {
71
78
  return (target, propertyKey, descriptor) => {
@@ -82,20 +89,22 @@ function createRouteDecorator(method) {
82
89
  };
83
90
  };
84
91
  }
85
- var Get = createRouteDecorator("get" /* GET */);
86
- var Post = createRouteDecorator("post" /* POST */);
87
- var Put = createRouteDecorator("put" /* PUT */);
88
- var Delete = createRouteDecorator("delete" /* DELETE */);
89
- var Patch = createRouteDecorator("patch" /* PATCH */);
90
- var Options = createRouteDecorator("options" /* OPTIONS */);
91
- var Head = createRouteDecorator("head" /* HEAD */);
92
- var All = createRouteDecorator("all" /* ALL */);
92
+ __name(createRouteDecorator, "createRouteDecorator");
93
+ var Get = createRouteDecorator(RequestMethod.GET);
94
+ var Post = createRouteDecorator(RequestMethod.POST);
95
+ var Put = createRouteDecorator(RequestMethod.PUT);
96
+ var Delete = createRouteDecorator(RequestMethod.DELETE);
97
+ var Patch = createRouteDecorator(RequestMethod.PATCH);
98
+ var Options = createRouteDecorator(RequestMethod.OPTIONS);
99
+ var Head = createRouteDecorator(RequestMethod.HEAD);
100
+ var All = createRouteDecorator(RequestMethod.ALL);
93
101
  function Catch(...exceptions) {
94
102
  return (target) => {
95
103
  Reflect.defineMetadata(METADATA_KEYS.FILTER_CATCH, exceptions, target);
96
- Reflect.defineMetadata(METADATA_KEYS.SCOPE, 0 /* DEFAULT */, target);
104
+ Reflect.defineMetadata(METADATA_KEYS.SCOPE, Scope.DEFAULT, target);
97
105
  };
98
106
  }
107
+ __name(Catch, "Catch");
99
108
  function UseFilters(...filters) {
100
109
  return (target, propertyKey, descriptor) => {
101
110
  if (descriptor) {
@@ -106,6 +115,7 @@ function UseFilters(...filters) {
106
115
  return target;
107
116
  };
108
117
  }
118
+ __name(UseFilters, "UseFilters");
109
119
  function Inject(token) {
110
120
  return (target, propertyKey, parameterIndex) => {
111
121
  if (parameterIndex !== void 0) {
@@ -114,11 +124,15 @@ function Inject(token) {
114
124
  Reflect.defineMetadata(METADATA_KEYS.INJECTIONS, injections, target);
115
125
  } else {
116
126
  const properties = Reflect.getMetadata(METADATA_KEYS.PROPERTY_DEPS, target.constructor) || [];
117
- properties.push({ key: propertyKey, token });
127
+ properties.push({
128
+ key: propertyKey,
129
+ token
130
+ });
118
131
  Reflect.defineMetadata(METADATA_KEYS.PROPERTY_DEPS, properties, target.constructor);
119
132
  }
120
133
  };
121
134
  }
135
+ __name(Inject, "Inject");
122
136
  function Optional() {
123
137
  return (target, propertyKey, parameterIndex) => {
124
138
  if (parameterIndex !== void 0) {
@@ -132,6 +146,7 @@ function Optional() {
132
146
  }
133
147
  };
134
148
  }
149
+ __name(Optional, "Optional");
135
150
  function UseGuards(...guards) {
136
151
  return (target, propertyKey, descriptor) => {
137
152
  if (descriptor) {
@@ -142,6 +157,7 @@ function UseGuards(...guards) {
142
157
  return target;
143
158
  };
144
159
  }
160
+ __name(UseGuards, "UseGuards");
145
161
  function UseInterceptors(...interceptors) {
146
162
  return (target, propertyKey, descriptor) => {
147
163
  if (descriptor) {
@@ -152,6 +168,7 @@ function UseInterceptors(...interceptors) {
152
168
  return target;
153
169
  };
154
170
  }
171
+ __name(UseInterceptors, "UseInterceptors");
155
172
  function UsePipes(...pipes) {
156
173
  return (target, propertyKey, descriptor) => {
157
174
  if (descriptor) {
@@ -162,7 +179,8 @@ function UsePipes(...pipes) {
162
179
  return target;
163
180
  };
164
181
  }
165
- var RouteParamtypes = /* @__PURE__ */ ((RouteParamtypes2) => {
182
+ __name(UsePipes, "UsePipes");
183
+ var RouteParamtypes = /* @__PURE__ */ (function(RouteParamtypes2) {
166
184
  RouteParamtypes2[RouteParamtypes2["REQUEST"] = 0] = "REQUEST";
167
185
  RouteParamtypes2[RouteParamtypes2["RESPONSE"] = 1] = "RESPONSE";
168
186
  RouteParamtypes2[RouteParamtypes2["NEXT"] = 2] = "NEXT";
@@ -178,7 +196,7 @@ var RouteParamtypes = /* @__PURE__ */ ((RouteParamtypes2) => {
178
196
  RouteParamtypes2[RouteParamtypes2["CONTEXT"] = 12] = "CONTEXT";
179
197
  RouteParamtypes2[RouteParamtypes2["CUSTOM"] = 13] = "CUSTOM";
180
198
  return RouteParamtypes2;
181
- })(RouteParamtypes || {});
199
+ })({});
182
200
  function assignMetadata(args, paramtype, index, data, ...pipes) {
183
201
  return {
184
202
  ...args,
@@ -190,53 +208,50 @@ function assignMetadata(args, paramtype, index, data, ...pipes) {
190
208
  }
191
209
  };
192
210
  }
211
+ __name(assignMetadata, "assignMetadata");
193
212
  function createRouteParamDecorator(paramtype) {
194
213
  return (data) => {
195
214
  return (target, key, index) => {
196
215
  const args = Reflect.getMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, target.constructor, key) || {};
197
- Reflect.defineMetadata(
198
- METADATA_KEYS.ROUTE_ARGS_METADATA,
199
- assignMetadata(args, paramtype, index, data),
200
- target.constructor,
201
- key
202
- );
216
+ Reflect.defineMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target.constructor, key);
203
217
  };
204
218
  };
205
219
  }
220
+ __name(createRouteParamDecorator, "createRouteParamDecorator");
206
221
  function createPipesRouteParamDecorator(paramtype) {
207
222
  return (data, ...pipes) => {
208
223
  return (target, key, index) => {
209
224
  const args = Reflect.getMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, target.constructor, key) || {};
210
- Reflect.defineMetadata(
211
- METADATA_KEYS.ROUTE_ARGS_METADATA,
212
- assignMetadata(args, paramtype, index, data, ...pipes),
213
- target.constructor,
214
- key
215
- );
225
+ Reflect.defineMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data, ...pipes), target.constructor, key);
216
226
  };
217
227
  };
218
228
  }
219
- var Request = createRouteParamDecorator(0 /* REQUEST */);
220
- var Response = createRouteParamDecorator(1 /* RESPONSE */);
221
- var Next = createRouteParamDecorator(2 /* NEXT */);
222
- var Session = createRouteParamDecorator(7 /* SESSION */);
223
- var FileParam = createRouteParamDecorator(8 /* FILE */);
224
- var Files = createRouteParamDecorator(9 /* FILES */);
225
- var Ip = createRouteParamDecorator(11 /* IP */);
226
- var HostParam = createRouteParamDecorator(10 /* HOST */);
227
- var Ctx = createRouteParamDecorator(12 /* CONTEXT */);
229
+ __name(createPipesRouteParamDecorator, "createPipesRouteParamDecorator");
230
+ var Request = createRouteParamDecorator(0);
231
+ var Response = createRouteParamDecorator(1);
232
+ var Next = createRouteParamDecorator(2);
233
+ var Session = createRouteParamDecorator(7);
234
+ var FileParam = createRouteParamDecorator(8);
235
+ var Files = createRouteParamDecorator(9);
236
+ var Ip = createRouteParamDecorator(11);
237
+ var HostParam = createRouteParamDecorator(10);
238
+ var Ctx = createRouteParamDecorator(12);
228
239
  function Body(property, ...pipes) {
229
- return createPipesRouteParamDecorator(3 /* BODY */)(property, ...pipes);
240
+ return createPipesRouteParamDecorator(3)(property, ...pipes);
230
241
  }
242
+ __name(Body, "Body");
231
243
  function Query(property, ...pipes) {
232
- return createPipesRouteParamDecorator(4 /* QUERY */)(property, ...pipes);
244
+ return createPipesRouteParamDecorator(4)(property, ...pipes);
233
245
  }
246
+ __name(Query, "Query");
234
247
  function Param(property, ...pipes) {
235
- return createPipesRouteParamDecorator(5 /* PARAM */)(property, ...pipes);
248
+ return createPipesRouteParamDecorator(5)(property, ...pipes);
236
249
  }
250
+ __name(Param, "Param");
237
251
  function Headers(property, ...pipes) {
238
- return createPipesRouteParamDecorator(6 /* HEADERS */)(property, ...pipes);
252
+ return createPipesRouteParamDecorator(6)(property, ...pipes);
239
253
  }
254
+ __name(Headers, "Headers");
240
255
  function SetMetadata(metadataKey, metadataValue) {
241
256
  return (target, key, descriptor) => {
242
257
  if (descriptor) {
@@ -247,26 +262,36 @@ function SetMetadata(metadataKey, metadataValue) {
247
262
  return target;
248
263
  };
249
264
  }
265
+ __name(SetMetadata, "SetMetadata");
250
266
  function HttpCode(statusCode) {
251
267
  return (target, key, descriptor) => {
252
268
  Reflect.defineMetadata(METADATA_KEYS.HTTP_CODE, statusCode, descriptor.value);
253
269
  return descriptor;
254
270
  };
255
271
  }
272
+ __name(HttpCode, "HttpCode");
256
273
  function Header(name, value) {
257
274
  return (target, key, descriptor) => {
258
275
  const headers = Reflect.getMetadata(METADATA_KEYS.HEADERS, descriptor.value) || [];
259
- headers.push({ name, value });
276
+ headers.push({
277
+ name,
278
+ value
279
+ });
260
280
  Reflect.defineMetadata(METADATA_KEYS.HEADERS, headers, descriptor.value);
261
281
  return descriptor;
262
282
  };
263
283
  }
284
+ __name(Header, "Header");
264
285
  function Redirect(url, statusCode = 302) {
265
286
  return (target, key, descriptor) => {
266
- Reflect.defineMetadata(METADATA_KEYS.REDIRECT, { url, statusCode }, descriptor.value);
287
+ Reflect.defineMetadata(METADATA_KEYS.REDIRECT, {
288
+ url,
289
+ statusCode
290
+ }, descriptor.value);
267
291
  return descriptor;
268
292
  };
269
293
  }
294
+ __name(Redirect, "Redirect");
270
295
  function applyDecorators(...decorators) {
271
296
  return (target, propertyKey, descriptor) => {
272
297
  for (const decorator of decorators) {
@@ -282,19 +307,16 @@ function applyDecorators(...decorators) {
282
307
  }
283
308
  };
284
309
  }
310
+ __name(applyDecorators, "applyDecorators");
285
311
  function createParamDecorator(factory) {
286
- const paramtype = 13 /* CUSTOM */;
312
+ const paramtype = 13;
287
313
  return (data) => {
288
314
  return (target, key, index) => {
289
315
  const args = Reflect.getMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, target.constructor, key) || {};
290
- Reflect.defineMetadata(
291
- METADATA_KEYS.ROUTE_ARGS_METADATA,
292
- assignMetadata(args, paramtype, index, data, factory),
293
- target.constructor,
294
- key
295
- );
316
+ Reflect.defineMetadata(METADATA_KEYS.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data, factory), target.constructor, key);
296
317
  };
297
318
  };
298
319
  }
320
+ __name(createParamDecorator, "createParamDecorator");
299
321
 
300
322
  export { All, Body, Catch, Controller, Ctx, Delete, FileParam, Files, Get, Global, Head, Header, Headers, HostParam, HttpCode, Inject, Injectable, Ip, Module, Next, Optional, Options, Param, Patch, Post, Put, Query, Redirect, Request, RequestMethod, Response, RouteParamtypes, Scope, Session, SetMetadata, UseFilters, UseGuards, UseInterceptors, UsePipes, applyDecorators, assignMetadata, createParamDecorator };