@hed-hog/catalog 0.0.299 → 0.0.301

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,20 +1,20 @@
1
1
  import { Role } from '@hed-hog/api';
2
2
  import { Locale } from '@hed-hog/api-locale';
3
3
  import { Pagination } from '@hed-hog/api-pagination';
4
- import {
5
- Body,
6
- Controller,
7
- Delete,
8
- Get,
9
- BadRequestException,
10
- Param,
11
- ParseIntPipe,
12
- Patch,
13
- Post,
14
- Put,
15
- Query,
16
- } from '@nestjs/common';
17
- import { CatalogService } from './catalog.service';
4
+ import {
5
+ Body,
6
+ Controller,
7
+ Delete,
8
+ Get,
9
+ BadRequestException,
10
+ Param,
11
+ ParseIntPipe,
12
+ Patch,
13
+ Post,
14
+ Put,
15
+ Query,
16
+ } from '@nestjs/common';
17
+ import { CatalogService } from './catalog.service';
18
18
 
19
19
  @Role()
20
20
  @Controller('catalog')
@@ -22,83 +22,83 @@ export class CatalogController {
22
22
  constructor(private readonly catalogService: CatalogService) {}
23
23
 
24
24
  @Get('products/:id/images')
25
- async listProductImages(
26
- @Param('id', ParseIntPipe) id: number,
27
- @Pagination() paginationParams,
28
- @Locale() locale: string,
29
- ) {
30
- return this.catalogService.listProductImages(id, locale, paginationParams);
31
- }
32
-
33
- @Get('categories/tree')
34
- async categoriesTree() {
35
- return this.catalogService.getCategoriesTree();
36
- }
37
-
38
- @Get('categories/:id/attributes')
39
- async listCategoryAttributes(@Param('id', ParseIntPipe) id: number) {
40
- return this.catalogService.listCategoryAttributes(id);
41
- }
42
-
43
- @Get('products/:id/attributes')
44
- async listProductAttributes(@Param('id', ParseIntPipe) id: number) {
45
- return this.catalogService.listProductAttributes(id);
46
- }
47
-
48
- @Get('products/:id/structured')
49
- async structuredProduct(@Param('id', ParseIntPipe) id: number) {
50
- return this.catalogService.getProductStructuredPayload(id);
51
- }
52
-
53
- @Get('products/:id/comparison-payload')
54
- async comparisonPayload(@Param('id', ParseIntPipe) id: number) {
55
- return this.catalogService.getProductComparisonPayload(id);
56
- }
57
-
58
- @Post('forms/:resource/ai-assist')
59
- async generateFormAssistSuggestion(
60
- @Param('resource') resource: string,
61
- @Body() body: Record<string, unknown>,
62
- @Locale() locale: string,
63
- ) {
64
- const prompt = String(body.prompt ?? '').trim();
65
-
66
- if (!prompt) {
67
- throw new BadRequestException('Prompt is required');
68
- }
69
-
70
- return this.catalogService.generateFormAssistSuggestion(resource, {
71
- prompt,
72
- current_values:
73
- body.current_values && typeof body.current_values === 'object'
74
- ? (body.current_values as Record<string, unknown>)
75
- : {},
76
- fields: Array.isArray(body.fields)
77
- ? (body.fields as Record<string, unknown>[])
78
- : [],
79
- current_attribute_values: Array.isArray(body.current_attribute_values)
80
- ? (body.current_attribute_values as Record<string, unknown>[])
81
- : [],
82
- }, locale);
83
- }
84
-
85
- @Put('products/:id/attributes')
86
- async updateProductAttributes(
87
- @Param('id', ParseIntPipe) id: number,
88
- @Body('values') values: Record<string, unknown>[],
89
- ) {
90
- return this.catalogService.updateProductAttributes(id, values ?? []);
91
- }
92
-
93
- @Post('products/:id/materialize-snapshots')
94
- async materializeProductSnapshots(@Param('id', ParseIntPipe) id: number) {
95
- return this.catalogService.materializeProductSnapshots(id);
96
- }
97
-
98
- @Get(':resource/stats')
99
- async stats(@Param('resource') resource: string, @Locale() locale: string) {
100
- return this.catalogService.stats(resource, locale);
101
- }
25
+ async listProductImages(
26
+ @Param('id', ParseIntPipe) id: number,
27
+ @Pagination() paginationParams,
28
+ @Locale() locale: string,
29
+ ) {
30
+ return this.catalogService.listProductImages(id, locale, paginationParams);
31
+ }
32
+
33
+ @Get('categories/tree')
34
+ async categoriesTree() {
35
+ return this.catalogService.getCategoriesTree();
36
+ }
37
+
38
+ @Get('categories/:id/attributes')
39
+ async listCategoryAttributes(@Param('id', ParseIntPipe) id: number) {
40
+ return this.catalogService.listCategoryAttributes(id);
41
+ }
42
+
43
+ @Get('products/:id/attributes')
44
+ async listProductAttributes(@Param('id', ParseIntPipe) id: number) {
45
+ return this.catalogService.listProductAttributes(id);
46
+ }
47
+
48
+ @Get('products/:id/structured')
49
+ async structuredProduct(@Param('id', ParseIntPipe) id: number) {
50
+ return this.catalogService.getProductStructuredPayload(id);
51
+ }
52
+
53
+ @Get('products/:id/comparison-payload')
54
+ async comparisonPayload(@Param('id', ParseIntPipe) id: number) {
55
+ return this.catalogService.getProductComparisonPayload(id);
56
+ }
57
+
58
+ @Post('forms/:resource/ai-assist')
59
+ async generateFormAssistSuggestion(
60
+ @Param('resource') resource: string,
61
+ @Body() body: Record<string, unknown>,
62
+ @Locale() locale: string,
63
+ ) {
64
+ const prompt = String(body.prompt ?? '').trim();
65
+
66
+ if (!prompt) {
67
+ throw new BadRequestException('Prompt is required');
68
+ }
69
+
70
+ return this.catalogService.generateFormAssistSuggestion(resource, {
71
+ prompt,
72
+ current_values:
73
+ body.current_values && typeof body.current_values === 'object'
74
+ ? (body.current_values as Record<string, unknown>)
75
+ : {},
76
+ fields: Array.isArray(body.fields)
77
+ ? (body.fields as Record<string, unknown>[])
78
+ : [],
79
+ current_attribute_values: Array.isArray(body.current_attribute_values)
80
+ ? (body.current_attribute_values as Record<string, unknown>[])
81
+ : [],
82
+ }, locale);
83
+ }
84
+
85
+ @Put('products/:id/attributes')
86
+ async updateProductAttributes(
87
+ @Param('id', ParseIntPipe) id: number,
88
+ @Body('values') values: Record<string, unknown>[],
89
+ ) {
90
+ return this.catalogService.updateProductAttributes(id, values ?? []);
91
+ }
92
+
93
+ @Post('products/:id/materialize-snapshots')
94
+ async materializeProductSnapshots(@Param('id', ParseIntPipe) id: number) {
95
+ return this.catalogService.materializeProductSnapshots(id);
96
+ }
97
+
98
+ @Get(':resource/stats')
99
+ async stats(@Param('resource') resource: string, @Locale() locale: string) {
100
+ return this.catalogService.stats(resource, locale);
101
+ }
102
102
 
103
103
  @Get(':resource/:id')
104
104
  async getById(
@@ -1,16 +1,16 @@
1
- import { PaginationModule } from '@hed-hog/api-pagination';
2
- import { AiModule } from '@hed-hog/core';
3
- import { Module, forwardRef } from '@nestjs/common';
4
- import { CatalogController } from './catalog.controller';
5
- import { CatalogService } from './catalog.service';
6
-
7
- @Module({
8
- imports: [
9
- forwardRef(() => PaginationModule),
10
- forwardRef(() => AiModule),
11
- ],
12
- controllers: [CatalogController],
13
- providers: [CatalogService],
14
- exports: [CatalogService],
15
- })
16
- export class CatalogModule {}
1
+ import { PaginationModule } from '@hed-hog/api-pagination';
2
+ import { AiModule } from '@hed-hog/core';
3
+ import { Module, forwardRef } from '@nestjs/common';
4
+ import { CatalogController } from './catalog.controller';
5
+ import { CatalogService } from './catalog.service';
6
+
7
+ @Module({
8
+ imports: [
9
+ forwardRef(() => PaginationModule),
10
+ forwardRef(() => AiModule),
11
+ ],
12
+ controllers: [CatalogController],
13
+ providers: [CatalogService],
14
+ exports: [CatalogService],
15
+ })
16
+ export class CatalogModule {}