@genesislcap/foundation-utils 14.258.3 → 14.259.0
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/custom-elements.json +175 -73
- package/dist/dts/mappers/genesis-json-schema/index.d.ts +36 -0
- package/dist/dts/mappers/genesis-json-schema/index.d.ts.map +1 -0
- package/dist/dts/mappers/genesis-json-schema/types.d.ts +15 -0
- package/dist/dts/mappers/genesis-json-schema/types.d.ts.map +1 -0
- package/dist/dts/mappers/index.d.ts +1 -0
- package/dist/dts/mappers/index.d.ts.map +1 -1
- package/dist/esm/mappers/genesis-json-schema/index.js +77 -0
- package/dist/esm/mappers/genesis-json-schema/types.js +18 -0
- package/dist/esm/mappers/index.js +1 -0
- package/dist/foundation-utils.api.json +265 -0
- package/dist/foundation-utils.d.ts +49 -0
- package/docs/api/foundation-utils.genesis.fieldjsonschema.md +13 -0
- package/docs/api/foundation-utils.genesis.genesisfieldtypes.md +11 -0
- package/docs/api/foundation-utils.genesis.jsonschema7.md +19 -0
- package/docs/api/foundation-utils.genesis.md +27 -0
- package/docs/api/foundation-utils.mapgenesisjsonschema.md +26 -0
- package/docs/api/foundation-utils.mapjsonschemafieldtoexprbuilderfield.md +41 -0
- package/docs/api/foundation-utils.md +3 -0
- package/docs/api-report.md +31 -0
- package/package.json +12 -10
|
@@ -367,6 +367,29 @@
|
|
|
367
367
|
}
|
|
368
368
|
]
|
|
369
369
|
},
|
|
370
|
+
{
|
|
371
|
+
"kind": "javascript-module",
|
|
372
|
+
"path": "src/directives/index.ts",
|
|
373
|
+
"declarations": [],
|
|
374
|
+
"exports": [
|
|
375
|
+
{
|
|
376
|
+
"kind": "js",
|
|
377
|
+
"name": "*",
|
|
378
|
+
"declaration": {
|
|
379
|
+
"name": "*",
|
|
380
|
+
"package": "./sync"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"kind": "js",
|
|
385
|
+
"name": "*",
|
|
386
|
+
"declaration": {
|
|
387
|
+
"name": "*",
|
|
388
|
+
"package": "./when-else"
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
},
|
|
370
393
|
{
|
|
371
394
|
"kind": "javascript-module",
|
|
372
395
|
"path": "src/decorators/index.ts",
|
|
@@ -420,79 +443,6 @@
|
|
|
420
443
|
}
|
|
421
444
|
]
|
|
422
445
|
},
|
|
423
|
-
{
|
|
424
|
-
"kind": "javascript-module",
|
|
425
|
-
"path": "src/design-system/design-system.ts",
|
|
426
|
-
"declarations": [
|
|
427
|
-
{
|
|
428
|
-
"kind": "function",
|
|
429
|
-
"name": "assureDesignSystem",
|
|
430
|
-
"return": {
|
|
431
|
-
"type": {
|
|
432
|
-
"text": "DesignSystemModule"
|
|
433
|
-
}
|
|
434
|
-
},
|
|
435
|
-
"parameters": [
|
|
436
|
-
{
|
|
437
|
-
"name": "module",
|
|
438
|
-
"type": {
|
|
439
|
-
"text": "DesignSystemModule"
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
],
|
|
443
|
-
"description": "assureDesignSystem.",
|
|
444
|
-
"privacy": "public"
|
|
445
|
-
}
|
|
446
|
-
],
|
|
447
|
-
"exports": [
|
|
448
|
-
{
|
|
449
|
-
"kind": "js",
|
|
450
|
-
"name": "assureDesignSystem",
|
|
451
|
-
"declaration": {
|
|
452
|
-
"name": "assureDesignSystem",
|
|
453
|
-
"module": "src/design-system/design-system.ts"
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
]
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
"kind": "javascript-module",
|
|
460
|
-
"path": "src/design-system/index.ts",
|
|
461
|
-
"declarations": [],
|
|
462
|
-
"exports": [
|
|
463
|
-
{
|
|
464
|
-
"kind": "js",
|
|
465
|
-
"name": "*",
|
|
466
|
-
"declaration": {
|
|
467
|
-
"name": "*",
|
|
468
|
-
"package": "./design-system"
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
]
|
|
472
|
-
},
|
|
473
|
-
{
|
|
474
|
-
"kind": "javascript-module",
|
|
475
|
-
"path": "src/directives/index.ts",
|
|
476
|
-
"declarations": [],
|
|
477
|
-
"exports": [
|
|
478
|
-
{
|
|
479
|
-
"kind": "js",
|
|
480
|
-
"name": "*",
|
|
481
|
-
"declaration": {
|
|
482
|
-
"name": "*",
|
|
483
|
-
"package": "./sync"
|
|
484
|
-
}
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
"kind": "js",
|
|
488
|
-
"name": "*",
|
|
489
|
-
"declaration": {
|
|
490
|
-
"name": "*",
|
|
491
|
-
"package": "./when-else"
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
]
|
|
495
|
-
},
|
|
496
446
|
{
|
|
497
447
|
"kind": "javascript-module",
|
|
498
448
|
"path": "src/encoding/index.ts",
|
|
@@ -949,6 +899,56 @@
|
|
|
949
899
|
}
|
|
950
900
|
]
|
|
951
901
|
},
|
|
902
|
+
{
|
|
903
|
+
"kind": "javascript-module",
|
|
904
|
+
"path": "src/design-system/design-system.ts",
|
|
905
|
+
"declarations": [
|
|
906
|
+
{
|
|
907
|
+
"kind": "function",
|
|
908
|
+
"name": "assureDesignSystem",
|
|
909
|
+
"return": {
|
|
910
|
+
"type": {
|
|
911
|
+
"text": "DesignSystemModule"
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
"parameters": [
|
|
915
|
+
{
|
|
916
|
+
"name": "module",
|
|
917
|
+
"type": {
|
|
918
|
+
"text": "DesignSystemModule"
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
],
|
|
922
|
+
"description": "assureDesignSystem.",
|
|
923
|
+
"privacy": "public"
|
|
924
|
+
}
|
|
925
|
+
],
|
|
926
|
+
"exports": [
|
|
927
|
+
{
|
|
928
|
+
"kind": "js",
|
|
929
|
+
"name": "assureDesignSystem",
|
|
930
|
+
"declaration": {
|
|
931
|
+
"name": "assureDesignSystem",
|
|
932
|
+
"module": "src/design-system/design-system.ts"
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
]
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
"kind": "javascript-module",
|
|
939
|
+
"path": "src/design-system/index.ts",
|
|
940
|
+
"declarations": [],
|
|
941
|
+
"exports": [
|
|
942
|
+
{
|
|
943
|
+
"kind": "js",
|
|
944
|
+
"name": "*",
|
|
945
|
+
"declaration": {
|
|
946
|
+
"name": "*",
|
|
947
|
+
"package": "./design-system"
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
]
|
|
951
|
+
},
|
|
952
952
|
{
|
|
953
953
|
"kind": "javascript-module",
|
|
954
954
|
"path": "src/error/errorMap.ts",
|
|
@@ -1531,6 +1531,14 @@
|
|
|
1531
1531
|
"name": "*",
|
|
1532
1532
|
"package": "./dto"
|
|
1533
1533
|
}
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
"kind": "js",
|
|
1537
|
+
"name": "*",
|
|
1538
|
+
"declaration": {
|
|
1539
|
+
"name": "*",
|
|
1540
|
+
"package": "./genesis-json-schema"
|
|
1541
|
+
}
|
|
1534
1542
|
}
|
|
1535
1543
|
]
|
|
1536
1544
|
},
|
|
@@ -2844,6 +2852,100 @@
|
|
|
2844
2852
|
"declarations": [],
|
|
2845
2853
|
"exports": []
|
|
2846
2854
|
},
|
|
2855
|
+
{
|
|
2856
|
+
"kind": "javascript-module",
|
|
2857
|
+
"path": "src/mappers/genesis-json-schema/index.ts",
|
|
2858
|
+
"declarations": [
|
|
2859
|
+
{
|
|
2860
|
+
"kind": "function",
|
|
2861
|
+
"name": "mapGenesisJsonSchema",
|
|
2862
|
+
"return": {
|
|
2863
|
+
"type": {
|
|
2864
|
+
"text": "Genesis.JSONSchema7"
|
|
2865
|
+
}
|
|
2866
|
+
},
|
|
2867
|
+
"parameters": [
|
|
2868
|
+
{
|
|
2869
|
+
"name": "jsonSchemResponse",
|
|
2870
|
+
"type": {
|
|
2871
|
+
"text": "{\n OUTBOUND: JSONSchema7;\n}"
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
],
|
|
2875
|
+
"description": "Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to\na JsonSchema extended with the genesisType metadata for a field",
|
|
2876
|
+
"privacy": "public"
|
|
2877
|
+
},
|
|
2878
|
+
{
|
|
2879
|
+
"kind": "function",
|
|
2880
|
+
"name": "mapJsonSchemaFieldToExprBuilderField",
|
|
2881
|
+
"return": {
|
|
2882
|
+
"type": {
|
|
2883
|
+
"text": "Types.Field | null"
|
|
2884
|
+
}
|
|
2885
|
+
},
|
|
2886
|
+
"parameters": [
|
|
2887
|
+
{
|
|
2888
|
+
"name": "[name, schema]",
|
|
2889
|
+
"type": {
|
|
2890
|
+
"text": "[\n string,\n Genesis.FieldJsonSchema,\n]"
|
|
2891
|
+
}
|
|
2892
|
+
}
|
|
2893
|
+
],
|
|
2894
|
+
"description": "Maps fields contained in a JSON schema block enhanced with genesisType metadata\nto the field shape required by the expression builder component.\n\nOnly sets the properties that are *required*. Optional properties, such as\n`defaultValue`, must be explicitly set by the user separately.",
|
|
2895
|
+
"privacy": "public"
|
|
2896
|
+
}
|
|
2897
|
+
],
|
|
2898
|
+
"exports": [
|
|
2899
|
+
{
|
|
2900
|
+
"kind": "js",
|
|
2901
|
+
"name": "*",
|
|
2902
|
+
"declaration": {
|
|
2903
|
+
"name": "*",
|
|
2904
|
+
"package": "./types"
|
|
2905
|
+
}
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
"kind": "js",
|
|
2909
|
+
"name": "mapGenesisJsonSchema",
|
|
2910
|
+
"declaration": {
|
|
2911
|
+
"name": "mapGenesisJsonSchema",
|
|
2912
|
+
"module": "src/mappers/genesis-json-schema/index.ts"
|
|
2913
|
+
}
|
|
2914
|
+
},
|
|
2915
|
+
{
|
|
2916
|
+
"kind": "js",
|
|
2917
|
+
"name": "mapJsonSchemaFieldToExprBuilderField",
|
|
2918
|
+
"declaration": {
|
|
2919
|
+
"name": "mapJsonSchemaFieldToExprBuilderField",
|
|
2920
|
+
"module": "src/mappers/genesis-json-schema/index.ts"
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
]
|
|
2924
|
+
},
|
|
2925
|
+
{
|
|
2926
|
+
"kind": "javascript-module",
|
|
2927
|
+
"path": "src/mappers/genesis-json-schema/types.ts",
|
|
2928
|
+
"declarations": [
|
|
2929
|
+
{
|
|
2930
|
+
"kind": "variable",
|
|
2931
|
+
"name": "genesisFieldTypes",
|
|
2932
|
+
"type": {
|
|
2933
|
+
"text": "[\n 'STRING',\n 'ENUM',\n 'INT',\n 'SHORT',\n 'DOUBLE',\n 'LONG',\n 'BOOLEAN',\n 'BIGDECIMAL',\n 'DATE',\n 'DATETIME',\n 'RAW',\n 'NANO_TIMESTAMP',\n ]"
|
|
2934
|
+
},
|
|
2935
|
+
"default": "[\n 'STRING',\n 'ENUM',\n 'INT',\n 'SHORT',\n 'DOUBLE',\n 'LONG',\n 'BOOLEAN',\n 'BIGDECIMAL',\n 'DATE',\n 'DATETIME',\n 'RAW',\n 'NANO_TIMESTAMP',\n ]"
|
|
2936
|
+
}
|
|
2937
|
+
],
|
|
2938
|
+
"exports": [
|
|
2939
|
+
{
|
|
2940
|
+
"kind": "js",
|
|
2941
|
+
"name": "genesisFieldTypes",
|
|
2942
|
+
"declaration": {
|
|
2943
|
+
"name": "genesisFieldTypes",
|
|
2944
|
+
"module": "src/mappers/genesis-json-schema/types.ts"
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
]
|
|
2948
|
+
},
|
|
2847
2949
|
{
|
|
2848
2950
|
"kind": "javascript-module",
|
|
2849
2951
|
"path": "src/mixins/lifecycle/index.ts",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Types } from '@genesislcap/expression-builder';
|
|
2
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
3
|
+
import { Genesis } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to
|
|
7
|
+
* a JsonSchema extended with the genesisType metadata for a field
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare function mapGenesisJsonSchema(jsonSchemResponse: {
|
|
12
|
+
OUTBOUND: JSONSchema7;
|
|
13
|
+
}): Genesis.JSONSchema7;
|
|
14
|
+
/**
|
|
15
|
+
* Maps fields contained in a JSON schema block enhanced with genesisType metadata
|
|
16
|
+
* to the field shape required by the expression builder component.
|
|
17
|
+
*
|
|
18
|
+
* Only sets the properties that are *required*. Optional properties, such as
|
|
19
|
+
* `defaultValue`, must be explicitly set by the user separately.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { mapGenesisJsonSchema, mapJsonSchemaFieldToExprBuilderField } from '@genesislcap/foundation-utils';
|
|
24
|
+
*
|
|
25
|
+
* const response = await connect.getJsonSchema("RESOURCE_NAME");
|
|
26
|
+
* // Assuming the response is valid, requires checking
|
|
27
|
+
* const schema = mapGenesisJsonSchema(response);
|
|
28
|
+
* const fields = Object.entries(schema.properties).map(mapJsonSchemaFieldToExprBuilderField);
|
|
29
|
+
* ```
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare function mapJsonSchemaFieldToExprBuilderField([name, schema]: [
|
|
33
|
+
string,
|
|
34
|
+
Genesis.FieldJsonSchema
|
|
35
|
+
]): Types.Field | null;
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/mappers/genesis-json-schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,cAAc,SAAS,CAAC;AAExB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,iBAAiB,EAAE;IACtD,QAAQ,EAAE,WAAW,CAAC;CACvB,GAAG,OAAO,CAAC,WAAW,CAwBtB;AAsCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oCAAoC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;IACnE,MAAM;IACN,OAAO,CAAC,eAAe;CACxB,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CASrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JSONSchema7 as JSONShemaBase } from 'json-schema';
|
|
2
|
+
/** @public */
|
|
3
|
+
export declare namespace Genesis {
|
|
4
|
+
const genesisFieldTypes: readonly ["STRING", "ENUM", "INT", "SHORT", "DOUBLE", "LONG", "BOOLEAN", "BIGDECIMAL", "DATE", "DATETIME", "RAW", "NANO_TIMESTAMP"];
|
|
5
|
+
type GenesisFieldTypes = (typeof genesisFieldTypes)[number];
|
|
6
|
+
type JSONSchema7 = JSONShemaBase & {
|
|
7
|
+
properties?: {
|
|
8
|
+
[key: string]: JSONShemaBase & {
|
|
9
|
+
genesisType: GenesisFieldTypes;
|
|
10
|
+
};
|
|
11
|
+
} | undefined;
|
|
12
|
+
};
|
|
13
|
+
type FieldJsonSchema = JSONSchema7['properties'][string];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/mappers/genesis-json-schema/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,cAAc;AACd,yBAAiB,OAAO,CAAC;IAChB,MAAM,iBAAiB,qIAapB,CAAC;IAEX,KAAY,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IAEnE,KAAY,WAAW,GAAG,aAAa,GAAG;QACxC,UAAU,CAAC,EACP;YACE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG;gBAAE,WAAW,EAAE,iBAAiB,CAAA;aAAE,CAAC;SACnE,GACD,SAAS,CAAC;KACf,CAAC;IAEF,KAAY,eAAe,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;CACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mappers/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to
|
|
4
|
+
* a JsonSchema extended with the genesisType metadata for a field
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export function mapGenesisJsonSchema(jsonSchemResponse) {
|
|
9
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
10
|
+
const result = jsonSchemResponse;
|
|
11
|
+
if (typeof ((_b = (_a = result.OUTBOUND) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b['REPLY']) !== 'object' ||
|
|
12
|
+
!((_d = (_c = result.OUTBOUND) === null || _c === void 0 ? void 0 : _c.properties) === null || _d === void 0 ? void 0 : _d['REPLY'].items) ||
|
|
13
|
+
typeof ((_f = (_e = result.OUTBOUND) === null || _e === void 0 ? void 0 : _e.properties) === null || _f === void 0 ? void 0 : _f['REPLY'].items) === 'boolean')
|
|
14
|
+
throw new Error(`Invalid response shape for parsing json schema 7`);
|
|
15
|
+
// TODO: Need to check this with server people, it seems it never should be an array from what I have seen
|
|
16
|
+
if (Array.isArray((_j = (_h = (_g = result.OUTBOUND) === null || _g === void 0 ? void 0 : _g.properties) === null || _h === void 0 ? void 0 : _h['REPLY']) === null || _j === void 0 ? void 0 : _j.items))
|
|
17
|
+
throw new Error(`Items is an array`);
|
|
18
|
+
if (Object.values((_p = (_o = (_m = (_l = (_k = result.OUTBOUND) === null || _k === void 0 ? void 0 : _k.properties) === null || _l === void 0 ? void 0 : _l['REPLY']) === null || _m === void 0 ? void 0 : _m.items) === null || _o === void 0 ? void 0 : _o.properties) !== null && _p !== void 0 ? _p : {}).some((p) => typeof p === 'boolean'))
|
|
19
|
+
throw new Error(`Properties contain invalid values`);
|
|
20
|
+
if (Object.values((_u = (_t = (_s = (_r = (_q = result.OUTBOUND) === null || _q === void 0 ? void 0 : _q.properties) === null || _r === void 0 ? void 0 : _r['REPLY']) === null || _s === void 0 ? void 0 : _s.items) === null || _t === void 0 ? void 0 : _t.properties) !== null && _u !== void 0 ? _u : {}).some((p) => !p.genesisType))
|
|
21
|
+
throw new Error(`Schema properties don't contain 'genesisType' field`);
|
|
22
|
+
return (_x = (_w = (_v = result.OUTBOUND) === null || _v === void 0 ? void 0 : _v.properties) === null || _w === void 0 ? void 0 : _w['REPLY']) === null || _x === void 0 ? void 0 : _x.items;
|
|
23
|
+
}
|
|
24
|
+
function mapGenesisFieldTypeToFieldInputAndType(partialData, schema) {
|
|
25
|
+
switch (schema.genesisType) {
|
|
26
|
+
case 'STRING':
|
|
27
|
+
return Object.assign(Object.assign({}, partialData), { type: 'string', input: 'text' });
|
|
28
|
+
case 'ENUM':
|
|
29
|
+
if (!schema.enum)
|
|
30
|
+
throw new Error('Enum type but without enum values');
|
|
31
|
+
return Object.assign(Object.assign({}, partialData), { type: 'enum', input: 'select', values: schema.enum.reduce((acum, v) => (Object.assign(Object.assign({}, acum), { [v]: v })), {}) });
|
|
32
|
+
case 'INT':
|
|
33
|
+
return Object.assign(Object.assign({}, partialData), { type: 'int', input: 'number' });
|
|
34
|
+
case 'SHORT':
|
|
35
|
+
return Object.assign(Object.assign({}, partialData), { type: 'short', input: 'number' });
|
|
36
|
+
case 'DOUBLE':
|
|
37
|
+
return Object.assign(Object.assign({}, partialData), { type: 'double', input: 'number' });
|
|
38
|
+
case 'LONG':
|
|
39
|
+
return Object.assign(Object.assign({}, partialData), { type: 'long', input: 'number' });
|
|
40
|
+
case 'BOOLEAN':
|
|
41
|
+
return Object.assign(Object.assign({}, partialData), { type: 'boolean', input: 'checkbox' });
|
|
42
|
+
case 'BIGDECIMAL':
|
|
43
|
+
return Object.assign(Object.assign({}, partialData), { type: 'bigdecimal', input: 'number' }); // TODO; this may need to be a string
|
|
44
|
+
case 'DATE':
|
|
45
|
+
return Object.assign(Object.assign({}, partialData), { type: 'date', input: 'date' });
|
|
46
|
+
case 'DATETIME':
|
|
47
|
+
return Object.assign(Object.assign({}, partialData), { type: 'date-time', input: 'datetime-local' });
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`mapGenesisFieldTypeToFieldType type not supported "${schema.genesisType}"`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Maps fields contained in a JSON schema block enhanced with genesisType metadata
|
|
54
|
+
* to the field shape required by the expression builder component.
|
|
55
|
+
*
|
|
56
|
+
* Only sets the properties that are *required*. Optional properties, such as
|
|
57
|
+
* `defaultValue`, must be explicitly set by the user separately.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { mapGenesisJsonSchema, mapJsonSchemaFieldToExprBuilderField } from '@genesislcap/foundation-utils';
|
|
62
|
+
*
|
|
63
|
+
* const response = await connect.getJsonSchema("RESOURCE_NAME");
|
|
64
|
+
* // Assuming the response is valid, requires checking
|
|
65
|
+
* const schema = mapGenesisJsonSchema(response);
|
|
66
|
+
* const fields = Object.entries(schema.properties).map(mapJsonSchemaFieldToExprBuilderField);
|
|
67
|
+
* ```
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export function mapJsonSchemaFieldToExprBuilderField([name, schema]) {
|
|
71
|
+
if (schema.genesisType === 'RAW' || schema.genesisType === 'NANO_TIMESTAMP')
|
|
72
|
+
return null;
|
|
73
|
+
return mapGenesisFieldTypeToFieldInputAndType({
|
|
74
|
+
fieldId: name,
|
|
75
|
+
label: name,
|
|
76
|
+
}, schema);
|
|
77
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
export var Genesis;
|
|
3
|
+
(function (Genesis) {
|
|
4
|
+
Genesis.genesisFieldTypes = [
|
|
5
|
+
'STRING',
|
|
6
|
+
'ENUM',
|
|
7
|
+
'INT',
|
|
8
|
+
'SHORT',
|
|
9
|
+
'DOUBLE',
|
|
10
|
+
'LONG',
|
|
11
|
+
'BOOLEAN',
|
|
12
|
+
'BIGDECIMAL',
|
|
13
|
+
'DATE',
|
|
14
|
+
'DATETIME',
|
|
15
|
+
'RAW',
|
|
16
|
+
'NANO_TIMESTAMP',
|
|
17
|
+
];
|
|
18
|
+
})(Genesis || (Genesis = {}));
|
|
@@ -3565,6 +3565,157 @@
|
|
|
3565
3565
|
"endIndex": 2
|
|
3566
3566
|
}
|
|
3567
3567
|
},
|
|
3568
|
+
{
|
|
3569
|
+
"kind": "Namespace",
|
|
3570
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis:namespace",
|
|
3571
|
+
"docComment": "/**\n * @public\n */\n",
|
|
3572
|
+
"excerptTokens": [
|
|
3573
|
+
{
|
|
3574
|
+
"kind": "Content",
|
|
3575
|
+
"text": "export declare namespace Genesis "
|
|
3576
|
+
}
|
|
3577
|
+
],
|
|
3578
|
+
"fileUrlPath": "src/mappers/genesis-json-schema/types.ts",
|
|
3579
|
+
"releaseTag": "Public",
|
|
3580
|
+
"name": "Genesis",
|
|
3581
|
+
"preserveMemberOrder": false,
|
|
3582
|
+
"members": [
|
|
3583
|
+
{
|
|
3584
|
+
"kind": "TypeAlias",
|
|
3585
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.FieldJsonSchema:type",
|
|
3586
|
+
"docComment": "",
|
|
3587
|
+
"excerptTokens": [
|
|
3588
|
+
{
|
|
3589
|
+
"kind": "Content",
|
|
3590
|
+
"text": "type FieldJsonSchema = "
|
|
3591
|
+
},
|
|
3592
|
+
{
|
|
3593
|
+
"kind": "Reference",
|
|
3594
|
+
"text": "JSONSchema7",
|
|
3595
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.JSONSchema7:type"
|
|
3596
|
+
},
|
|
3597
|
+
{
|
|
3598
|
+
"kind": "Content",
|
|
3599
|
+
"text": "['properties'][string]"
|
|
3600
|
+
},
|
|
3601
|
+
{
|
|
3602
|
+
"kind": "Content",
|
|
3603
|
+
"text": ";"
|
|
3604
|
+
}
|
|
3605
|
+
],
|
|
3606
|
+
"releaseTag": "Public",
|
|
3607
|
+
"name": "FieldJsonSchema",
|
|
3608
|
+
"typeTokenRange": {
|
|
3609
|
+
"startIndex": 1,
|
|
3610
|
+
"endIndex": 3
|
|
3611
|
+
}
|
|
3612
|
+
},
|
|
3613
|
+
{
|
|
3614
|
+
"kind": "TypeAlias",
|
|
3615
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.GenesisFieldTypes:type",
|
|
3616
|
+
"docComment": "",
|
|
3617
|
+
"excerptTokens": [
|
|
3618
|
+
{
|
|
3619
|
+
"kind": "Content",
|
|
3620
|
+
"text": "type GenesisFieldTypes = "
|
|
3621
|
+
},
|
|
3622
|
+
{
|
|
3623
|
+
"kind": "Content",
|
|
3624
|
+
"text": "(typeof "
|
|
3625
|
+
},
|
|
3626
|
+
{
|
|
3627
|
+
"kind": "Reference",
|
|
3628
|
+
"text": "genesisFieldTypes",
|
|
3629
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.genesisFieldTypes:var"
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
"kind": "Content",
|
|
3633
|
+
"text": ")[number]"
|
|
3634
|
+
},
|
|
3635
|
+
{
|
|
3636
|
+
"kind": "Content",
|
|
3637
|
+
"text": ";"
|
|
3638
|
+
}
|
|
3639
|
+
],
|
|
3640
|
+
"releaseTag": "Public",
|
|
3641
|
+
"name": "GenesisFieldTypes",
|
|
3642
|
+
"typeTokenRange": {
|
|
3643
|
+
"startIndex": 1,
|
|
3644
|
+
"endIndex": 4
|
|
3645
|
+
}
|
|
3646
|
+
},
|
|
3647
|
+
{
|
|
3648
|
+
"kind": "Variable",
|
|
3649
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.genesisFieldTypes:var",
|
|
3650
|
+
"docComment": "",
|
|
3651
|
+
"excerptTokens": [
|
|
3652
|
+
{
|
|
3653
|
+
"kind": "Content",
|
|
3654
|
+
"text": "genesisFieldTypes: "
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
"kind": "Content",
|
|
3658
|
+
"text": "readonly [\"STRING\", \"ENUM\", \"INT\", \"SHORT\", \"DOUBLE\", \"LONG\", \"BOOLEAN\", \"BIGDECIMAL\", \"DATE\", \"DATETIME\", \"RAW\", \"NANO_TIMESTAMP\"]"
|
|
3659
|
+
}
|
|
3660
|
+
],
|
|
3661
|
+
"isReadonly": true,
|
|
3662
|
+
"releaseTag": "Public",
|
|
3663
|
+
"name": "genesisFieldTypes",
|
|
3664
|
+
"variableTypeTokenRange": {
|
|
3665
|
+
"startIndex": 1,
|
|
3666
|
+
"endIndex": 2
|
|
3667
|
+
}
|
|
3668
|
+
},
|
|
3669
|
+
{
|
|
3670
|
+
"kind": "TypeAlias",
|
|
3671
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.JSONSchema7:type",
|
|
3672
|
+
"docComment": "",
|
|
3673
|
+
"excerptTokens": [
|
|
3674
|
+
{
|
|
3675
|
+
"kind": "Content",
|
|
3676
|
+
"text": "type JSONSchema7 = "
|
|
3677
|
+
},
|
|
3678
|
+
{
|
|
3679
|
+
"kind": "Reference",
|
|
3680
|
+
"text": "JSONShemaBase",
|
|
3681
|
+
"canonicalReference": "@types/json-schema!JSONSchema7:interface"
|
|
3682
|
+
},
|
|
3683
|
+
{
|
|
3684
|
+
"kind": "Content",
|
|
3685
|
+
"text": " & {\n properties?: {\n [key: string]: "
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
"kind": "Reference",
|
|
3689
|
+
"text": "JSONShemaBase",
|
|
3690
|
+
"canonicalReference": "@types/json-schema!JSONSchema7:interface"
|
|
3691
|
+
},
|
|
3692
|
+
{
|
|
3693
|
+
"kind": "Content",
|
|
3694
|
+
"text": " & {\n genesisType: "
|
|
3695
|
+
},
|
|
3696
|
+
{
|
|
3697
|
+
"kind": "Reference",
|
|
3698
|
+
"text": "GenesisFieldTypes",
|
|
3699
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.GenesisFieldTypes:type"
|
|
3700
|
+
},
|
|
3701
|
+
{
|
|
3702
|
+
"kind": "Content",
|
|
3703
|
+
"text": ";\n };\n } | undefined;\n }"
|
|
3704
|
+
},
|
|
3705
|
+
{
|
|
3706
|
+
"kind": "Content",
|
|
3707
|
+
"text": ";"
|
|
3708
|
+
}
|
|
3709
|
+
],
|
|
3710
|
+
"releaseTag": "Public",
|
|
3711
|
+
"name": "JSONSchema7",
|
|
3712
|
+
"typeTokenRange": {
|
|
3713
|
+
"startIndex": 1,
|
|
3714
|
+
"endIndex": 7
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
]
|
|
3718
|
+
},
|
|
3568
3719
|
{
|
|
3569
3720
|
"kind": "Function",
|
|
3570
3721
|
"canonicalReference": "@genesislcap/foundation-utils!getDateFormatter:function(1)",
|
|
@@ -8474,6 +8625,120 @@
|
|
|
8474
8625
|
"endIndex": 2
|
|
8475
8626
|
}
|
|
8476
8627
|
},
|
|
8628
|
+
{
|
|
8629
|
+
"kind": "Function",
|
|
8630
|
+
"canonicalReference": "@genesislcap/foundation-utils!mapGenesisJsonSchema:function(1)",
|
|
8631
|
+
"docComment": "/**\n * Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to a JsonSchema extended with the genesisType metadata for a field\n *\n * @public\n */\n",
|
|
8632
|
+
"excerptTokens": [
|
|
8633
|
+
{
|
|
8634
|
+
"kind": "Content",
|
|
8635
|
+
"text": "export declare function mapGenesisJsonSchema(jsonSchemResponse: "
|
|
8636
|
+
},
|
|
8637
|
+
{
|
|
8638
|
+
"kind": "Content",
|
|
8639
|
+
"text": "{\n OUTBOUND: "
|
|
8640
|
+
},
|
|
8641
|
+
{
|
|
8642
|
+
"kind": "Reference",
|
|
8643
|
+
"text": "JSONSchema7",
|
|
8644
|
+
"canonicalReference": "@types/json-schema!JSONSchema7:interface"
|
|
8645
|
+
},
|
|
8646
|
+
{
|
|
8647
|
+
"kind": "Content",
|
|
8648
|
+
"text": ";\n}"
|
|
8649
|
+
},
|
|
8650
|
+
{
|
|
8651
|
+
"kind": "Content",
|
|
8652
|
+
"text": "): "
|
|
8653
|
+
},
|
|
8654
|
+
{
|
|
8655
|
+
"kind": "Reference",
|
|
8656
|
+
"text": "Genesis.JSONSchema7",
|
|
8657
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.JSONSchema7:type"
|
|
8658
|
+
},
|
|
8659
|
+
{
|
|
8660
|
+
"kind": "Content",
|
|
8661
|
+
"text": ";"
|
|
8662
|
+
}
|
|
8663
|
+
],
|
|
8664
|
+
"fileUrlPath": "src/mappers/genesis-json-schema/index.ts",
|
|
8665
|
+
"returnTypeTokenRange": {
|
|
8666
|
+
"startIndex": 5,
|
|
8667
|
+
"endIndex": 6
|
|
8668
|
+
},
|
|
8669
|
+
"releaseTag": "Public",
|
|
8670
|
+
"overloadIndex": 1,
|
|
8671
|
+
"parameters": [
|
|
8672
|
+
{
|
|
8673
|
+
"parameterName": "jsonSchemResponse",
|
|
8674
|
+
"parameterTypeTokenRange": {
|
|
8675
|
+
"startIndex": 1,
|
|
8676
|
+
"endIndex": 4
|
|
8677
|
+
},
|
|
8678
|
+
"isOptional": false
|
|
8679
|
+
}
|
|
8680
|
+
],
|
|
8681
|
+
"name": "mapGenesisJsonSchema"
|
|
8682
|
+
},
|
|
8683
|
+
{
|
|
8684
|
+
"kind": "Function",
|
|
8685
|
+
"canonicalReference": "@genesislcap/foundation-utils!mapJsonSchemaFieldToExprBuilderField:function(1)",
|
|
8686
|
+
"docComment": "/**\n * Maps fields contained in a JSON schema block enhanced with genesisType metadata to the field shape required by the expression builder component.\n *\n * Only sets the properties that are *required*. Optional properties, such as `defaultValue`, must be explicitly set by the user separately.\n *\n * @example\n * ```ts\n * import { mapGenesisJsonSchema, mapJsonSchemaFieldToExprBuilderField } from '@genesislcap/foundation-utils';\n *\n * const response = await connect.getJsonSchema(\"RESOURCE_NAME\");\n * // Assuming the response is valid, requires checking\n * const schema = mapGenesisJsonSchema(response);\n * const fields = Object.entries(schema.properties).map(mapJsonSchemaFieldToExprBuilderField);\n * ```\n *\n * @public\n */\n",
|
|
8687
|
+
"excerptTokens": [
|
|
8688
|
+
{
|
|
8689
|
+
"kind": "Content",
|
|
8690
|
+
"text": "export declare function mapJsonSchemaFieldToExprBuilderField([name, schema]: "
|
|
8691
|
+
},
|
|
8692
|
+
{
|
|
8693
|
+
"kind": "Content",
|
|
8694
|
+
"text": "[\n string,\n "
|
|
8695
|
+
},
|
|
8696
|
+
{
|
|
8697
|
+
"kind": "Reference",
|
|
8698
|
+
"text": "Genesis.FieldJsonSchema",
|
|
8699
|
+
"canonicalReference": "@genesislcap/foundation-utils!Genesis.FieldJsonSchema:type"
|
|
8700
|
+
},
|
|
8701
|
+
{
|
|
8702
|
+
"kind": "Content",
|
|
8703
|
+
"text": "\n]"
|
|
8704
|
+
},
|
|
8705
|
+
{
|
|
8706
|
+
"kind": "Content",
|
|
8707
|
+
"text": "): "
|
|
8708
|
+
},
|
|
8709
|
+
{
|
|
8710
|
+
"kind": "Reference",
|
|
8711
|
+
"text": "Types.Field",
|
|
8712
|
+
"canonicalReference": "@genesislcap/expression-builder!Field:type"
|
|
8713
|
+
},
|
|
8714
|
+
{
|
|
8715
|
+
"kind": "Content",
|
|
8716
|
+
"text": " | null"
|
|
8717
|
+
},
|
|
8718
|
+
{
|
|
8719
|
+
"kind": "Content",
|
|
8720
|
+
"text": ";"
|
|
8721
|
+
}
|
|
8722
|
+
],
|
|
8723
|
+
"fileUrlPath": "src/mappers/genesis-json-schema/index.ts",
|
|
8724
|
+
"returnTypeTokenRange": {
|
|
8725
|
+
"startIndex": 5,
|
|
8726
|
+
"endIndex": 7
|
|
8727
|
+
},
|
|
8728
|
+
"releaseTag": "Public",
|
|
8729
|
+
"overloadIndex": 1,
|
|
8730
|
+
"parameters": [
|
|
8731
|
+
{
|
|
8732
|
+
"parameterName": "[name, schema]",
|
|
8733
|
+
"parameterTypeTokenRange": {
|
|
8734
|
+
"startIndex": 1,
|
|
8735
|
+
"endIndex": 4
|
|
8736
|
+
},
|
|
8737
|
+
"isOptional": false
|
|
8738
|
+
}
|
|
8739
|
+
],
|
|
8740
|
+
"name": "mapJsonSchemaFieldToExprBuilderField"
|
|
8741
|
+
},
|
|
8477
8742
|
{
|
|
8478
8743
|
"kind": "Class",
|
|
8479
8744
|
"canonicalReference": "@genesislcap/foundation-utils!NumberParser:class",
|
|
@@ -8,10 +8,12 @@ import { DesignSystem } from '@microsoft/fast-foundation';
|
|
|
8
8
|
import { ElementStyles } from '@microsoft/fast-element';
|
|
9
9
|
import { FASTElement } from '@microsoft/fast-element';
|
|
10
10
|
import { InterfaceSymbol } from '@microsoft/fast-foundation';
|
|
11
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
11
12
|
import { Logger as Logger_2 } from '@genesislcap/foundation-logger';
|
|
12
13
|
import { LoggerOptions as LoggerOptions_2 } from '@genesislcap/foundation-logger';
|
|
13
14
|
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
14
15
|
import { SyntheticViewTemplate } from '@microsoft/fast-element';
|
|
16
|
+
import { Types } from '@genesislcap/expression-builder';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* A design token that represents the active color scheme (light or dark).
|
|
@@ -493,6 +495,20 @@ export declare type FoundationLayoutContainer = {
|
|
|
493
495
|
_key: 'foundation-layout';
|
|
494
496
|
};
|
|
495
497
|
|
|
498
|
+
/** @public */
|
|
499
|
+
export declare namespace Genesis {
|
|
500
|
+
const genesisFieldTypes: readonly ["STRING", "ENUM", "INT", "SHORT", "DOUBLE", "LONG", "BOOLEAN", "BIGDECIMAL", "DATE", "DATETIME", "RAW", "NANO_TIMESTAMP"];
|
|
501
|
+
export type GenesisFieldTypes = (typeof genesisFieldTypes)[number];
|
|
502
|
+
export type JSONSchema7 = JSONSchema7 & {
|
|
503
|
+
properties?: {
|
|
504
|
+
[key: string]: JSONSchema7 & {
|
|
505
|
+
genesisType: GenesisFieldTypes;
|
|
506
|
+
};
|
|
507
|
+
} | undefined;
|
|
508
|
+
};
|
|
509
|
+
export type FieldJsonSchema = JSONSchema7['properties'][string];
|
|
510
|
+
}
|
|
511
|
+
|
|
496
512
|
/**
|
|
497
513
|
* Genesis Socket URL
|
|
498
514
|
* @remarks
|
|
@@ -1154,6 +1170,39 @@ export declare let LOGOUT_URL: string;
|
|
|
1154
1170
|
*/
|
|
1155
1171
|
declare type LowercaseOperation = 'insert' | 'modify' | 'delete';
|
|
1156
1172
|
|
|
1173
|
+
/**
|
|
1174
|
+
* Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to
|
|
1175
|
+
* a JsonSchema extended with the genesisType metadata for a field
|
|
1176
|
+
*
|
|
1177
|
+
* @public
|
|
1178
|
+
*/
|
|
1179
|
+
export declare function mapGenesisJsonSchema(jsonSchemResponse: {
|
|
1180
|
+
OUTBOUND: JSONSchema7;
|
|
1181
|
+
}): Genesis.JSONSchema7;
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Maps fields contained in a JSON schema block enhanced with genesisType metadata
|
|
1185
|
+
* to the field shape required by the expression builder component.
|
|
1186
|
+
*
|
|
1187
|
+
* Only sets the properties that are *required*. Optional properties, such as
|
|
1188
|
+
* `defaultValue`, must be explicitly set by the user separately.
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* ```ts
|
|
1192
|
+
* import { mapGenesisJsonSchema, mapJsonSchemaFieldToExprBuilderField } from '@genesislcap/foundation-utils';
|
|
1193
|
+
*
|
|
1194
|
+
* const response = await connect.getJsonSchema("RESOURCE_NAME");
|
|
1195
|
+
* // Assuming the response is valid, requires checking
|
|
1196
|
+
* const schema = mapGenesisJsonSchema(response);
|
|
1197
|
+
* const fields = Object.entries(schema.properties).map(mapJsonSchemaFieldToExprBuilderField);
|
|
1198
|
+
* ```
|
|
1199
|
+
* @public
|
|
1200
|
+
*/
|
|
1201
|
+
export declare function mapJsonSchemaFieldToExprBuilderField([name, schema]: [
|
|
1202
|
+
string,
|
|
1203
|
+
Genesis.FieldJsonSchema
|
|
1204
|
+
]): Types.Field | null;
|
|
1205
|
+
|
|
1157
1206
|
/**
|
|
1158
1207
|
* @public
|
|
1159
1208
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [Genesis](./foundation-utils.genesis.md) > [FieldJsonSchema](./foundation-utils.genesis.fieldjsonschema.md)
|
|
4
|
+
|
|
5
|
+
## Genesis.FieldJsonSchema type
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
type FieldJsonSchema = JSONSchema7['properties'][string];
|
|
11
|
+
```
|
|
12
|
+
**References:** [JSONSchema7](./foundation-utils.genesis.jsonschema7.md)
|
|
13
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [Genesis](./foundation-utils.genesis.md) > [genesisFieldTypes](./foundation-utils.genesis.genesisfieldtypes.md)
|
|
4
|
+
|
|
5
|
+
## Genesis.genesisFieldTypes variable
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
genesisFieldTypes: readonly ["STRING", "ENUM", "INT", "SHORT", "DOUBLE", "LONG", "BOOLEAN", "BIGDECIMAL", "DATE", "DATETIME", "RAW", "NANO_TIMESTAMP"]
|
|
11
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [Genesis](./foundation-utils.genesis.md) > [JSONSchema7](./foundation-utils.genesis.jsonschema7.md)
|
|
4
|
+
|
|
5
|
+
## Genesis.JSONSchema7 type
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
type JSONSchema7 = JSONShemaBase & {
|
|
11
|
+
properties?: {
|
|
12
|
+
[key: string]: JSONShemaBase & {
|
|
13
|
+
genesisType: GenesisFieldTypes;
|
|
14
|
+
};
|
|
15
|
+
} | undefined;
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
**References:** [GenesisFieldTypes](./foundation-utils.genesis.genesisfieldtypes.md)
|
|
19
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [Genesis](./foundation-utils.genesis.md)
|
|
4
|
+
|
|
5
|
+
## Genesis namespace
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
**Signature:**
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
export declare namespace Genesis
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Variables
|
|
15
|
+
|
|
16
|
+
| Variable | Description |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| [genesisFieldTypes](./foundation-utils.genesis.genesisfieldtypes.md) | |
|
|
19
|
+
|
|
20
|
+
## Type Aliases
|
|
21
|
+
|
|
22
|
+
| Type Alias | Description |
|
|
23
|
+
| --- | --- |
|
|
24
|
+
| [FieldJsonSchema](./foundation-utils.genesis.fieldjsonschema.md) | |
|
|
25
|
+
| [GenesisFieldTypes](./foundation-utils.genesis.genesisfieldtypes.md) | |
|
|
26
|
+
| [JSONSchema7](./foundation-utils.genesis.jsonschema7.md) | |
|
|
27
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [mapGenesisJsonSchema](./foundation-utils.mapgenesisjsonschema.md)
|
|
4
|
+
|
|
5
|
+
## mapGenesisJsonSchema() function
|
|
6
|
+
|
|
7
|
+
Takes in a valid response from `connect.getJsonSchema(resourceName)` and maps it to a JsonSchema extended with the genesisType metadata for a field
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
export declare function mapGenesisJsonSchema(jsonSchemResponse: {
|
|
13
|
+
OUTBOUND: JSONSchema7;
|
|
14
|
+
}): Genesis.JSONSchema7;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
| Parameter | Type | Description |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| jsonSchemResponse | { OUTBOUND: JSONSchema7; } | |
|
|
22
|
+
|
|
23
|
+
**Returns:**
|
|
24
|
+
|
|
25
|
+
[Genesis.JSONSchema7](./foundation-utils.genesis.jsonschema7.md)
|
|
26
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-utils](./foundation-utils.md) > [mapJsonSchemaFieldToExprBuilderField](./foundation-utils.mapjsonschemafieldtoexprbuilderfield.md)
|
|
4
|
+
|
|
5
|
+
## mapJsonSchemaFieldToExprBuilderField() function
|
|
6
|
+
|
|
7
|
+
Maps fields contained in a JSON schema block enhanced with genesisType metadata to the field shape required by the expression builder component.
|
|
8
|
+
|
|
9
|
+
Only sets the properties that are \*required\*. Optional properties, such as `defaultValue`<!-- -->, must be explicitly set by the user separately.
|
|
10
|
+
|
|
11
|
+
**Signature:**
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
export declare function mapJsonSchemaFieldToExprBuilderField([name, schema]: [
|
|
15
|
+
string,
|
|
16
|
+
Genesis.FieldJsonSchema
|
|
17
|
+
]): Types.Field | null;
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
| Parameter | Type | Description |
|
|
23
|
+
| --- | --- | --- |
|
|
24
|
+
| \[name, schema\] | \[ string, [Genesis.FieldJsonSchema](./foundation-utils.genesis.fieldjsonschema.md) \] | |
|
|
25
|
+
|
|
26
|
+
**Returns:**
|
|
27
|
+
|
|
28
|
+
Types.Field \| null
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { mapGenesisJsonSchema, mapJsonSchemaFieldToExprBuilderField } from '@genesislcap/foundation-utils';
|
|
35
|
+
|
|
36
|
+
const response = await connect.getJsonSchema("RESOURCE_NAME");
|
|
37
|
+
// Assuming the response is valid, requires checking
|
|
38
|
+
const schema = mapGenesisJsonSchema(response);
|
|
39
|
+
const fields = Object.entries(schema.properties).map(mapJsonSchemaFieldToExprBuilderField);
|
|
40
|
+
```
|
|
41
|
+
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
| [getNumberFormatter(format, locale)](./foundation-utils.getnumberformatter.md) | |
|
|
37
37
|
| [JSONReplacer(key, value)](./foundation-utils.jsonreplacer.md) | JSON replacer function. |
|
|
38
38
|
| [JSONReviver(key, value)](./foundation-utils.jsonreviver.md) | JSON reviver function. |
|
|
39
|
+
| [mapGenesisJsonSchema(jsonSchemResponse)](./foundation-utils.mapgenesisjsonschema.md) | Takes in a valid response from <code>connect.getJsonSchema(resourceName)</code> and maps it to a JsonSchema extended with the genesisType metadata for a field |
|
|
40
|
+
| [mapJsonSchemaFieldToExprBuilderField(\[name, schema\])](./foundation-utils.mapjsonschemafieldtoexprbuilderfield.md) | <p>Maps fields contained in a JSON schema block enhanced with genesisType metadata to the field shape required by the expression builder component.</p><p>Only sets the properties that are \*required\*. Optional properties, such as <code>defaultValue</code>, must be explicitly set by the user separately.</p> |
|
|
39
41
|
| [reactive(object, deep)](./foundation-utils.reactive.md) | **_(BETA)_** Converts a plain object to a reactive, observable object. |
|
|
40
42
|
| [renderOnChange(target, name)](./foundation-utils.renderonchange.md) | Defines a property changed handler that calls a render() method on the target as an internal observation enhancement. |
|
|
41
43
|
| [sync(binding, conversionType, eventName, keyAttr)](./foundation-utils.sync.md) | Creates a synchronization directive that binds a data source to an HTML element, |
|
|
@@ -68,6 +70,7 @@
|
|
|
68
70
|
| --- | --- |
|
|
69
71
|
| [DatabaseAccessResult](./foundation-utils.databaseaccessresult.md) | Namespace for database access result types. |
|
|
70
72
|
| [DatabaseEvent](./foundation-utils.databaseevent.md) | Namespace for database events. |
|
|
73
|
+
| [Genesis](./foundation-utils.genesis.md) | |
|
|
71
74
|
|
|
72
75
|
## Variables
|
|
73
76
|
|
package/docs/api-report.md
CHANGED
|
@@ -14,10 +14,12 @@ import { DesignSystem } from '@microsoft/fast-foundation';
|
|
|
14
14
|
import { ElementStyles } from '@microsoft/fast-element';
|
|
15
15
|
import { FASTElement } from '@microsoft/fast-element';
|
|
16
16
|
import { InterfaceSymbol } from '@microsoft/fast-foundation';
|
|
17
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
17
18
|
import { Logger as Logger_2 } from '@genesislcap/foundation-logger';
|
|
18
19
|
import { LoggerOptions as LoggerOptions_2 } from '@genesislcap/foundation-logger';
|
|
19
20
|
import { LogLevel } from '@genesislcap/foundation-logger';
|
|
20
21
|
import { SyntheticViewTemplate } from '@microsoft/fast-element';
|
|
22
|
+
import { Types } from '@genesislcap/expression-builder';
|
|
21
23
|
|
|
22
24
|
// @public
|
|
23
25
|
export const activeColorScheme: CSSDesignToken<string>;
|
|
@@ -274,6 +276,24 @@ export type FoundationLayoutContainer = {
|
|
|
274
276
|
_key: 'foundation-layout';
|
|
275
277
|
};
|
|
276
278
|
|
|
279
|
+
// @public (undocumented)
|
|
280
|
+
export namespace Genesis {
|
|
281
|
+
const // (undocumented)
|
|
282
|
+
genesisFieldTypes: readonly ["STRING", "ENUM", "INT", "SHORT", "DOUBLE", "LONG", "BOOLEAN", "BIGDECIMAL", "DATE", "DATETIME", "RAW", "NANO_TIMESTAMP"];
|
|
283
|
+
// (undocumented)
|
|
284
|
+
export type FieldJsonSchema = JSONSchema7['properties'][string];
|
|
285
|
+
// (undocumented)
|
|
286
|
+
export type GenesisFieldTypes = (typeof genesisFieldTypes)[number];
|
|
287
|
+
// (undocumented)
|
|
288
|
+
export type JSONSchema7 = JSONSchema7 & {
|
|
289
|
+
properties?: {
|
|
290
|
+
[key: string]: JSONSchema7 & {
|
|
291
|
+
genesisType: GenesisFieldTypes;
|
|
292
|
+
};
|
|
293
|
+
} | undefined;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
277
297
|
// @public
|
|
278
298
|
export const GENESIS_SOCKET_URL: string;
|
|
279
299
|
|
|
@@ -730,6 +750,17 @@ export { LogLevel }
|
|
|
730
750
|
// @public (undocumented)
|
|
731
751
|
export let LOGOUT_URL: string;
|
|
732
752
|
|
|
753
|
+
// @public
|
|
754
|
+
export function mapGenesisJsonSchema(jsonSchemResponse: {
|
|
755
|
+
OUTBOUND: JSONSchema7;
|
|
756
|
+
}): Genesis.JSONSchema7;
|
|
757
|
+
|
|
758
|
+
// @public
|
|
759
|
+
export function mapJsonSchemaFieldToExprBuilderField([name, schema]: [
|
|
760
|
+
string,
|
|
761
|
+
Genesis.FieldJsonSchema
|
|
762
|
+
]): Types.Field | null;
|
|
763
|
+
|
|
733
764
|
// @public (undocumented)
|
|
734
765
|
export class NumberParser {
|
|
735
766
|
constructor(locale: string);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-utils",
|
|
3
3
|
"description": "Genesis Foundation Utils",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.259.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@genesislcap/foundation-testing": "14.
|
|
31
|
-
"@genesislcap/genx": "14.
|
|
32
|
-
"@genesislcap/rollup-builder": "14.
|
|
33
|
-
"@genesislcap/ts-builder": "14.
|
|
34
|
-
"@genesislcap/uvu-playwright-builder": "14.
|
|
35
|
-
"@genesislcap/vite-builder": "14.
|
|
36
|
-
"@genesislcap/webpack-builder": "14.
|
|
30
|
+
"@genesislcap/foundation-testing": "14.259.0",
|
|
31
|
+
"@genesislcap/genx": "14.259.0",
|
|
32
|
+
"@genesislcap/rollup-builder": "14.259.0",
|
|
33
|
+
"@genesislcap/ts-builder": "14.259.0",
|
|
34
|
+
"@genesislcap/uvu-playwright-builder": "14.259.0",
|
|
35
|
+
"@genesislcap/vite-builder": "14.259.0",
|
|
36
|
+
"@genesislcap/webpack-builder": "14.259.0",
|
|
37
|
+
"@types/json-schema": "^7.0.11",
|
|
37
38
|
"rimraf": "^5.0.0"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@genesislcap/
|
|
41
|
+
"@genesislcap/expression-builder": "14.258.1",
|
|
42
|
+
"@genesislcap/foundation-logger": "14.259.0",
|
|
41
43
|
"@microsoft/fast-components": "2.30.6",
|
|
42
44
|
"@microsoft/fast-element": "1.14.0",
|
|
43
45
|
"@microsoft/fast-foundation": "2.49.6",
|
|
@@ -55,5 +57,5 @@
|
|
|
55
57
|
"access": "public"
|
|
56
58
|
},
|
|
57
59
|
"customElements": "dist/custom-elements.json",
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "6656bbcddf94db7587bab3339ca021718ce54709"
|
|
59
61
|
}
|