@vnodes/autowire 0.0.5 → 0.0.11

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 +1 @@
1
- {"version":3,"file":"auto-controller.d.ts","sourceRoot":"","sources":["../src/auto-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAOrE,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CA4B7E"}
1
+ {"version":3,"file":"auto-controller.d.ts","sourceRoot":"","sources":["../src/auto-controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAOrE,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAkC7E"}
@@ -1,4 +1,6 @@
1
1
  import { Controller } from '@nestjs/common';
2
+ import { ApiBearerAuth } from '@nestjs/swagger';
3
+ import { OperationName, operationRegistry, ResourceName } from '@vnodes/metadata';
2
4
  import { names, pluralize } from '@vnodes/names';
3
5
  import { AutoDelete } from './auto-delete.js';
4
6
  import { AutoGet } from './auto-get.js';
@@ -8,25 +10,32 @@ import { getAllMethodNames, getInheritedPropertyDescriptor } from './helpers.js'
8
10
  export function AutoController(options) {
9
11
  return (target) => {
10
12
  const className = target.name;
11
- const { kebabCase } = names(className.replace('Controller', ''));
13
+ const { pascalCase: resourceName, kebabCase } = names(className.replace('Controller', ''));
12
14
  const pluralPath = pluralize(kebabCase);
13
15
  Controller(pluralPath)(target);
16
+ ResourceName(resourceName)(target);
17
+ ApiBearerAuth()(target);
14
18
  const methodNames = getAllMethodNames(target).filter((e) => e !== 'constructor');
15
- for (const methodName of methodNames) {
16
- const descriptor = getInheritedPropertyDescriptor(target, methodName);
19
+ for (const operationName of methodNames) {
20
+ const descriptor = getInheritedPropertyDescriptor(target, operationName);
17
21
  if (!descriptor)
18
- throw new Error(`Descriptor not found for ${target.name}.${methodName}`);
19
- const args = [target.prototype, methodName, descriptor];
20
- if (methodName.startsWith('find')) {
22
+ throw new Error(`Descriptor not found for ${target.name}.${operationName}`);
23
+ const args = [target.prototype, operationName, descriptor];
24
+ OperationName(operationName)(...args);
25
+ operationRegistry.add({
26
+ resourceName,
27
+ operationName,
28
+ });
29
+ if (operationName.startsWith('find')) {
21
30
  AutoGet(options)(...args);
22
31
  }
23
- else if (methodName.startsWith('create')) {
32
+ else if (operationName.startsWith('create')) {
24
33
  AutoPost(options)(...args);
25
34
  }
26
- else if (methodName.startsWith('update')) {
35
+ else if (operationName.startsWith('update')) {
27
36
  AutoPut(options)(...args);
28
37
  }
29
- else if (methodName.startsWith('delete')) {
38
+ else if (operationName.startsWith('delete')) {
30
39
  AutoDelete(options)(...args);
31
40
  }
32
41
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"auto-delete.d.ts","sourceRoot":"","sources":["../src/auto-delete.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,oBAAY,gBAAgB;IACxB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;CACtC;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAIvD;AAED,wBAAgB,iBAAiB,IAAI,eAAe,CAInD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAwB1E"}
1
+ {"version":3,"file":"auto-delete.d.ts","sourceRoot":"","sources":["../src/auto-delete.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,oBAAY,gBAAgB;IACxB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;CACtC;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAIvD;AAED,wBAAgB,iBAAiB,IAAI,eAAe,CAInD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAyB1E"}
@@ -1,4 +1,4 @@
1
- import { Delete, Param } from '@nestjs/common';
1
+ import { Delete, Param, ParseIntPipe } from '@nestjs/common';
2
2
  import { ApiOkResponse } from '@nestjs/swagger';
3
3
  export var DeleteMethodName;
4
4
  (function (DeleteMethodName) {
@@ -22,7 +22,7 @@ export function AutoDelete(options) {
22
22
  case DeleteMethodName.deleteOneById: {
23
23
  __DeleteOneByIdMethod()(...args);
24
24
  ApiOkResponse({ type: options.readDto })(...args);
25
- Param('id')(args[0], args[1], 0);
25
+ Param('id', ParseIntPipe)(args[0], args[1], 0);
26
26
  Reflect.defineMetadata('design:paramtypes', [Number], args[0], args[1]);
27
27
  break;
28
28
  }
package/dist/auto-get.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Get, Param, Query } from '@nestjs/common';
1
+ import { Get, Param, ParseIntPipe, Query } from '@nestjs/common';
2
2
  import { ApiOkResponse } from '@nestjs/swagger';
3
3
  export var FindMethodName;
4
4
  (function (FindMethodName) {
@@ -35,7 +35,7 @@ export function AutoGet(options) {
35
35
  case FindMethodName.findOneById: {
36
36
  __FindOneByIdMethod()(...args);
37
37
  ApiOkResponse({ type: options.readDto })(...args);
38
- Param('id')(args[0], args[1], 0);
38
+ Param('id', ParseIntPipe)(args[0], args[1], 0);
39
39
  Reflect.defineMetadata('design:paramtypes', [Number], args[0], args[1]);
40
40
  break;
41
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auto-put.d.ts","sourceRoot":"","sources":["../src/auto-put.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,oBAAY,gBAAgB;IACxB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;CACtC;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAIvD;AAED,wBAAgB,iBAAiB,IAAI,eAAe,CAInD;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAsBvE"}
1
+ {"version":3,"file":"auto-put.d.ts","sourceRoot":"","sources":["../src/auto-put.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,oBAAY,gBAAgB;IACxB,aAAa,kBAAkB;IAC/B,eAAe,oBAAoB;CACtC;AAED,wBAAgB,qBAAqB,IAAI,eAAe,CAIvD;AAED,wBAAgB,iBAAiB,IAAI,eAAe,CAInD;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAwBvE"}
package/dist/auto-put.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Body, Put } from '@nestjs/common';
1
+ import { Body, Param, ParseIntPipe, Put } from '@nestjs/common';
2
2
  export var UpdateMethodName;
3
3
  (function (UpdateMethodName) {
4
4
  UpdateMethodName["updateOneById"] = "updateOneById";
@@ -20,12 +20,14 @@ export function AutoPut(options) {
20
20
  switch (methodName.toString()) {
21
21
  case UpdateMethodName.updateOneById: {
22
22
  __UpdateOneByIdMethod()(...args);
23
+ Param('id', ParseIntPipe)(args[0], args[1], 0);
23
24
  Body()(args[0], args[1], 1);
24
25
  Reflect.defineMetadata('design:paramtypes', [Number, options.updateDto], args[0], args[1]);
25
26
  break;
26
27
  }
27
28
  case UpdateMethodName.updateOneByUuid: {
28
29
  __UpdateOneByUuid()(...args);
30
+ Param('uuid')(args[0], args[1], 0);
29
31
  Body()(args[0], args[1], 1);
30
32
  Reflect.defineMetadata('design:paramtypes', [String, options.updateDto], args[0], args[1]);
31
33
  break;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './auto-controller.js';
2
+ export * from './auto-controller-options.js';
2
3
  export * from './auto-delete.js';
3
4
  export * from './auto-get.js';
4
5
  export * from './auto-post.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // @index(['./**/*.ts', '!./**/*.spec.ts', '!./**/{main,serve,index}.ts', '!./**/prisma', '!./**/generated'], f => `export * from '${f.path}.js'`)
2
2
  export * from './auto-controller.js';
3
+ export * from './auto-controller-options.js';
3
4
  export * from './auto-delete.js';
4
5
  export * from './auto-get.js';
5
6
  export * from './auto-post.js';
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "url": "https://cash.app/$puqlib"
20
20
  }
21
21
  ],
22
- "version": "0.0.5",
22
+ "version": "0.0.11",
23
23
  "type": "module",
24
24
  "main": "./dist/index.js",
25
25
  "module": "./dist/index.js",
@@ -57,7 +57,7 @@
57
57
  "@nestjs/common": "^11.1.14",
58
58
  "@nestjs/core": "^11.1.14",
59
59
  "@nestjs/swagger": "^11.2.6",
60
- "@vnodes/metadata": "0.0.5",
61
- "@vnodes/names": "0.0.5"
60
+ "@vnodes/metadata": "0.0.11",
61
+ "@vnodes/names": "0.0.11"
62
62
  }
63
63
  }