@vnodes/autowire 0.0.8 → 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.
- package/dist/auto-controller.d.ts.map +1 -1
- package/dist/auto-controller.js +18 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-controller.d.ts","sourceRoot":"","sources":["../src/auto-controller.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/auto-controller.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Controller } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiBearerAuth } from '@nestjs/swagger';
|
|
3
|
+
import { OperationName, operationRegistry, ResourceName } from '@vnodes/metadata';
|
|
3
4
|
import { names, pluralize } from '@vnodes/names';
|
|
4
5
|
import { AutoDelete } from './auto-delete.js';
|
|
5
6
|
import { AutoGet } from './auto-get.js';
|
|
@@ -9,26 +10,32 @@ import { getAllMethodNames, getInheritedPropertyDescriptor } from './helpers.js'
|
|
|
9
10
|
export function AutoController(options) {
|
|
10
11
|
return (target) => {
|
|
11
12
|
const className = target.name;
|
|
12
|
-
const { pascalCase, kebabCase } = names(className.replace('Controller', ''));
|
|
13
|
+
const { pascalCase: resourceName, kebabCase } = names(className.replace('Controller', ''));
|
|
13
14
|
const pluralPath = pluralize(kebabCase);
|
|
14
15
|
Controller(pluralPath)(target);
|
|
15
|
-
ResourceName(
|
|
16
|
+
ResourceName(resourceName)(target);
|
|
17
|
+
ApiBearerAuth()(target);
|
|
16
18
|
const methodNames = getAllMethodNames(target).filter((e) => e !== 'constructor');
|
|
17
|
-
for (const
|
|
18
|
-
const descriptor = getInheritedPropertyDescriptor(target,
|
|
19
|
+
for (const operationName of methodNames) {
|
|
20
|
+
const descriptor = getInheritedPropertyDescriptor(target, operationName);
|
|
19
21
|
if (!descriptor)
|
|
20
|
-
throw new Error(`Descriptor not found for ${target.name}.${
|
|
21
|
-
const args = [target.prototype,
|
|
22
|
-
|
|
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')) {
|
|
23
30
|
AutoGet(options)(...args);
|
|
24
31
|
}
|
|
25
|
-
else if (
|
|
32
|
+
else if (operationName.startsWith('create')) {
|
|
26
33
|
AutoPost(options)(...args);
|
|
27
34
|
}
|
|
28
|
-
else if (
|
|
35
|
+
else if (operationName.startsWith('update')) {
|
|
29
36
|
AutoPut(options)(...args);
|
|
30
37
|
}
|
|
31
|
-
else if (
|
|
38
|
+
else if (operationName.startsWith('delete')) {
|
|
32
39
|
AutoDelete(options)(...args);
|
|
33
40
|
}
|
|
34
41
|
else {
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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.
|
|
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/
|
|
61
|
-
"@vnodes/
|
|
60
|
+
"@vnodes/metadata": "0.0.11",
|
|
61
|
+
"@vnodes/names": "0.0.11"
|
|
62
62
|
}
|
|
63
63
|
}
|