@solidstarters/solid-core 1.2.31 → 1.2.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/solid-core",
3
- "version": "1.2.31",
3
+ "version": "1.2.32",
4
4
  "description": "This module is a NestJS module containing all the required core providers required by a Solid application",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,47 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { Injectable } from "@nestjs/common";
3
+ import { ComputedFieldProvider } from "src/decorators/computed-field-provider.decorator";
4
+ import { IComputedFieldProvider } from "../../interfaces";
5
+ import { kebabCase } from "lodash";
6
+
7
+ @ComputedFieldProvider()
8
+ @Injectable()
9
+ export class ConcatComputedFieldProvider implements IComputedFieldProvider<any> {
10
+
11
+ name(): string {
12
+ return "ConcatComputedFieldProvider";
13
+ }
14
+
15
+ help(): string {
16
+ return "Computed field provider used to create fields whose value is a concatenation of other fields in the same model.";
17
+ }
18
+
19
+ valueType(): string {
20
+ return "string";
21
+ }
22
+
23
+ async computeValue(dto: any, ctxt: any): Promise<string> {
24
+ const separator = ctxt.separator;
25
+ const fields = ctxt.fields;
26
+ const slugify = ctxt.slugify || false;
27
+
28
+ let concatenatedString = '';
29
+ for (let i = 0; i < fields.length; i++) {
30
+ const field = fields[i];
31
+
32
+ // if slugify then each field val to be converted to a slug before concatenation
33
+ let fieldVal = dto[field];
34
+ if (slugify) {
35
+ fieldVal = kebabCase(fieldVal);
36
+ }
37
+
38
+ if (concatenatedString) {
39
+ concatenatedString += separator;
40
+ }
41
+ concatenatedString += fieldVal;
42
+ }
43
+
44
+ return concatenatedString;
45
+ }
46
+
47
+ }
@@ -136,6 +136,7 @@ import { Setting } from './entities/setting.entity';
136
136
  import { SettingService } from './services/setting.service';
137
137
  import { SettingController } from './controllers/setting.controller';
138
138
  import { ModuleMetadataHelperService } from './helpers/module-metadata-helper.service';
139
+ import { ConcatComputedFieldProvider } from './services/computed-fields/concat-computed-field-provider.service';
139
140
 
140
141
 
141
142
  @Global()
@@ -294,6 +295,7 @@ import { ModuleMetadataHelperService } from './helpers/module-metadata-helper.se
294
295
  PermissionMetadataSeederService,
295
296
  UserService,
296
297
  SettingService,
298
+ ConcatComputedFieldProvider,
297
299
  ],
298
300
  exports: [
299
301
  ModuleMetadataService,