@vidyano-labs/virtual-service 0.4.1 → 0.4.3
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/index.d.ts +2 -6
- package/index.js +13 -27
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -735,14 +735,10 @@ declare class VirtualService extends Service {
|
|
|
735
735
|
static set messages(value: Record<string, string>);
|
|
736
736
|
/**
|
|
737
737
|
* Converts a service string value to a primitive JavaScript type.
|
|
738
|
-
* Unlike
|
|
738
|
+
* Unlike Service.fromServiceString, this returns number instead of BigNumber
|
|
739
739
|
* for numeric types (Decimal, Double, Int64, etc.).
|
|
740
740
|
*/
|
|
741
|
-
static
|
|
742
|
-
/**
|
|
743
|
-
* Converts a primitive JavaScript value to a service string.
|
|
744
|
-
*/
|
|
745
|
-
static toServiceValue(value: any, type: string): string;
|
|
741
|
+
static fromServiceString(value: string, typeName: string): any;
|
|
746
742
|
/**
|
|
747
743
|
* Gets a message by key with optional parameters.
|
|
748
744
|
* Resolution: static messages → return key unchanged
|
package/index.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
import { DataType, ServiceHooks, Service } from '@vidyano/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* Wraps core DataType conversions to return JavaScript primitives instead of BigNumber.
|
|
4
|
+
* Internal value conversion utilities for the virtual service.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* fromServiceValue("True", "Boolean") // => true (boolean)
|
|
11
|
-
* fromServiceValue("15-01-2024 10:30:00", "DateTime") // => Date object
|
|
6
|
+
* NOTE: This file exists to avoid circular dependencies. Files like
|
|
7
|
+
* virtual-persistent-object.ts cannot import VirtualService directly
|
|
8
|
+
* (it would create a cycle), so they import these helpers instead.
|
|
12
9
|
*
|
|
13
|
-
*
|
|
14
|
-
* // Convert from primitive to service string
|
|
15
|
-
* toServiceValue(100.5, "Decimal") // => "100.5"
|
|
16
|
-
* toServiceValue(true, "Boolean") // => "True"
|
|
17
|
-
* toServiceValue(new Date(2024, 0, 15), "Date") // => "15-01-2024 00:00:00"
|
|
10
|
+
* Public API: Use VirtualService.fromServiceString() and VirtualService.toServiceString().
|
|
18
11
|
*/
|
|
19
12
|
/**
|
|
20
13
|
* Converts a service string value to a primitive JavaScript type.
|
|
21
14
|
* Unlike DataType.fromServiceString, this returns number instead of BigNumber
|
|
22
15
|
* for numeric types (Decimal, Double, Int64, etc.).
|
|
23
16
|
*/
|
|
24
|
-
function
|
|
17
|
+
function fromServiceString(value, type) {
|
|
25
18
|
const result = DataType.fromServiceString(value, type);
|
|
26
19
|
// Check for BigNumber (has toNumber method) and convert to number primitive
|
|
27
20
|
if (result && typeof result.toNumber === "function")
|
|
@@ -31,7 +24,7 @@ function fromServiceValue(value, type) {
|
|
|
31
24
|
/**
|
|
32
25
|
* Converts a primitive JavaScript value to a service string.
|
|
33
26
|
*/
|
|
34
|
-
function
|
|
27
|
+
function toServiceString(value, type) {
|
|
35
28
|
return DataType.toServiceString(value, type);
|
|
36
29
|
}
|
|
37
30
|
|
|
@@ -389,7 +382,7 @@ class VirtualQueryRegistry {
|
|
|
389
382
|
const rawValue = data[column.name];
|
|
390
383
|
return {
|
|
391
384
|
key: column.name,
|
|
392
|
-
value: rawValue == null ? null :
|
|
385
|
+
value: rawValue == null ? null : toServiceString(rawValue, column.type),
|
|
393
386
|
objectId: data[column.name + "Id"],
|
|
394
387
|
typeHints: data[column.name + "$typeHints"]
|
|
395
388
|
};
|
|
@@ -530,10 +523,10 @@ function createVirtualQueryResultItem(dto, query) {
|
|
|
530
523
|
function createVirtualPersistentObjectAttribute(attr, persistentObject, service) {
|
|
531
524
|
const helpers = {
|
|
532
525
|
getValue() {
|
|
533
|
-
return
|
|
526
|
+
return fromServiceString(attr.value, attr.type);
|
|
534
527
|
},
|
|
535
528
|
setValue(value) {
|
|
536
|
-
attr.value =
|
|
529
|
+
attr.value = toServiceString(value, attr.type);
|
|
537
530
|
attr.isValueChanged = true;
|
|
538
531
|
},
|
|
539
532
|
setValidationError(error) {
|
|
@@ -858,7 +851,6 @@ class VirtualServiceHooks extends ServiceHooks {
|
|
|
858
851
|
clientAttr.tab = configAttr.tab || "";
|
|
859
852
|
clientAttr.column = configAttr.column;
|
|
860
853
|
clientAttr.columnSpan = configAttr.columnSpan;
|
|
861
|
-
clientAttr.options = configAttr.options;
|
|
862
854
|
// Reference attribute properties - only set if explicitly configured
|
|
863
855
|
if (configAttr.lookup) {
|
|
864
856
|
const refAttr = clientAttr;
|
|
@@ -1704,17 +1696,11 @@ class VirtualService extends Service {
|
|
|
1704
1696
|
}
|
|
1705
1697
|
/**
|
|
1706
1698
|
* Converts a service string value to a primitive JavaScript type.
|
|
1707
|
-
* Unlike
|
|
1699
|
+
* Unlike Service.fromServiceString, this returns number instead of BigNumber
|
|
1708
1700
|
* for numeric types (Decimal, Double, Int64, etc.).
|
|
1709
1701
|
*/
|
|
1710
|
-
static
|
|
1711
|
-
return
|
|
1712
|
-
}
|
|
1713
|
-
/**
|
|
1714
|
-
* Converts a primitive JavaScript value to a service string.
|
|
1715
|
-
*/
|
|
1716
|
-
static toServiceValue(value, type) {
|
|
1717
|
-
return toServiceValue(value, type);
|
|
1702
|
+
static fromServiceString(value, typeName) {
|
|
1703
|
+
return fromServiceString(value, typeName);
|
|
1718
1704
|
}
|
|
1719
1705
|
/**
|
|
1720
1706
|
* Gets a message by key with optional parameters.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vidyano-labs/virtual-service",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Virtual service implementation for testing Vidyano applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"gitHash": "
|
|
23
|
+
"gitHash": "61b241fe7c8e867fb6ee9b2c1d7acc19e6a6dc60"
|
|
24
24
|
}
|