@itrocks/core-transformers 0.0.13 → 0.0.14

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,11 +1,12 @@
1
1
  import { AnyObject } from '@itrocks/class-type';
2
- import { Type } from '@itrocks/class-type';
2
+ import { KeyOf, Type } from '@itrocks/class-type';
3
3
  export type Dependencies = {
4
4
  displayOf: (object: AnyObject, property: string) => string;
5
5
  fieldNameOf: (property: string) => string;
6
6
  fieldIdOf: (property: string) => string;
7
7
  ignoreTransformedValue: any;
8
- representativeValueOf: (object: object) => string;
8
+ propertyOutput: <T extends object>(object: T, property: KeyOf<T>) => Promise<string>;
9
+ representativeValueOf: (object: object) => Promise<string>;
9
10
  routeOf: (type: Type) => string;
10
11
  tr: (text: string) => string;
11
12
  };
@@ -18,7 +18,8 @@ const depends = {
18
18
  fieldNameOf: property => property,
19
19
  fieldIdOf: property => property,
20
20
  ignoreTransformedValue: Symbol('ignoreTransformedValue'),
21
- representativeValueOf: object => (0, class_type_1.baseType)((0, class_type_2.typeOf)(object)).name,
21
+ propertyOutput: async (object, property) => '' + await object[property],
22
+ representativeValueOf: async (object) => (0, class_type_1.baseType)((0, class_type_2.typeOf)(object)).name,
22
23
  routeOf: type => '/' + (0, class_type_1.baseType)(type).name,
23
24
  tr: text => text
24
25
  };
@@ -76,7 +77,7 @@ async function collectionOutput(values, object, property, askFor) {
76
77
  + '</tr>');
77
78
  html.push(...await Promise.all(values.map(async (value) => '<tr>'
78
79
  + (await Promise.all(properties.map(async (property) => '<td>'
79
- + (await value[property])
80
+ + (await depends.propertyOutput(value, property))
80
81
  + '</td>'))).join('')
81
82
  + '</tr>')));
82
83
  html.push('</table>');
@@ -85,9 +86,9 @@ async function collectionOutput(values, object, property, askFor) {
85
86
  if (askFor?.container) {
86
87
  askFor.container = false;
87
88
  return '<ul>'
88
- + values.map(object => '<li>'
89
- + depends.representativeValueOf(object)
90
- + '</li>').join('')
89
+ + (await Promise.all(values.map(async (object) => '<li>'
90
+ + (await depends.representativeValueOf(object))
91
+ + '</li>'))).join('')
91
92
  + '</ul>';
92
93
  }
93
94
  return values.map(object => depends.representativeValueOf(object)).join(', ');
@@ -1,11 +1,12 @@
1
1
  import { AnyObject } from '@itrocks/class-type';
2
- import { Type } from '@itrocks/class-type';
2
+ import { KeyOf, Type } from '@itrocks/class-type';
3
3
  export type Dependencies = {
4
4
  displayOf: (object: AnyObject, property: string) => string;
5
5
  fieldNameOf: (property: string) => string;
6
6
  fieldIdOf: (property: string) => string;
7
7
  ignoreTransformedValue: any;
8
- representativeValueOf: (object: object) => string;
8
+ propertyOutput: <T extends object>(object: T, property: KeyOf<T>) => Promise<string>;
9
+ representativeValueOf: (object: object) => Promise<string>;
9
10
  routeOf: (type: Type) => string;
10
11
  tr: (text: string) => string;
11
12
  };
@@ -14,7 +14,8 @@ const depends = {
14
14
  fieldNameOf: property => property,
15
15
  fieldIdOf: property => property,
16
16
  ignoreTransformedValue: Symbol('ignoreTransformedValue'),
17
- representativeValueOf: object => baseType(typeOf(object)).name,
17
+ propertyOutput: async (object, property) => '' + await object[property],
18
+ representativeValueOf: async (object) => baseType(typeOf(object)).name,
18
19
  routeOf: type => '/' + baseType(type).name,
19
20
  tr: text => text
20
21
  };
@@ -72,7 +73,7 @@ async function collectionOutput(values, object, property, askFor) {
72
73
  + '</tr>');
73
74
  html.push(...await Promise.all(values.map(async (value) => '<tr>'
74
75
  + (await Promise.all(properties.map(async (property) => '<td>'
75
- + (await value[property])
76
+ + (await depends.propertyOutput(value, property))
76
77
  + '</td>'))).join('')
77
78
  + '</tr>')));
78
79
  html.push('</table>');
@@ -81,9 +82,9 @@ async function collectionOutput(values, object, property, askFor) {
81
82
  if (askFor?.container) {
82
83
  askFor.container = false;
83
84
  return '<ul>'
84
- + values.map(object => '<li>'
85
- + depends.representativeValueOf(object)
86
- + '</li>').join('')
85
+ + (await Promise.all(values.map(async (object) => '<li>'
86
+ + (await depends.representativeValueOf(object))
87
+ + '</li>'))).join('')
87
88
  + '</ul>';
88
89
  }
89
90
  return values.map(object => depends.representativeValueOf(object)).join(', ');
package/package.json CHANGED
@@ -48,5 +48,5 @@
48
48
  "build:esm": "tsc -p tsconfig.esm.json && node esm/esm"
49
49
  },
50
50
  "types": "./esm/core-transformers.d.ts",
51
- "version": "0.0.13"
51
+ "version": "0.0.14"
52
52
  }