Skip to content

Commit fbe40ab

Browse files
author
Adrien Maret
authored
Fix the MappingsProperties type (#705)
Fix the MappingsProperties type to reflect the real mappings object structure
1 parent 3786e1f commit fbe40ab

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

src/types/Mappings.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,42 @@
11
import { JSONObject } from './JSONObject';
22

3-
export type MappingsProperties = {
4-
/**
5-
* Properties types definition
6-
*
7-
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-properties
8-
*/
9-
properties?: MappingsProperties | JSONObject,
3+
type PropertyObject = {
4+
properties?: MappingsProperties;
5+
}
6+
7+
type PropertyDynamic = {
108
/**
119
* Dynamic mapping policy
1210
*
1311
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-dynamic-policy
1412
*/
15-
dynamic?: 'true' | 'false' | 'strict'
13+
dynamic?: 'true' | 'false' | 'strict';
1614
}
1715

16+
type PropertyType = {
17+
[name: string]: { type?: string; } | PropertyObject | JSONObject
18+
}
19+
20+
export type MappingsProperties = PropertyObject | PropertyDynamic | PropertyType;
21+
1822
/**
1923
* Collection mappings definition
2024
*
2125
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#collection-mappings
26+
*
27+
* @example
28+
* ```
29+
* {
30+
* properties: {
31+
* name: { type: 'keyword' },
32+
* address: {
33+
* properties: {
34+
* zipcode: { type: 'integer' }
35+
* }
36+
* }
37+
* }
38+
* }
39+
* ```
2240
*/
2341
export type CollectionMappings = {
2442
/**
@@ -27,16 +45,18 @@ export type CollectionMappings = {
2745
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-metadata
2846
*/
2947
_meta?: JSONObject;
48+
3049
/**
3150
* Properties types definition
3251
*
3352
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-properties
3453
*/
35-
properties?: MappingsProperties,
54+
properties?: MappingsProperties;
55+
3656
/**
3757
* Dynamic mapping policy
3858
*
3959
* @see https://docs.kuzzle.io/core/2/guides/main-concepts/data-storage/#mappings-dynamic-polic
4060
*/
41-
dynamic?: 'true' | 'false' | 'strict',
61+
dynamic?: 'true' | 'false' | 'strict';
4262
}

0 commit comments

Comments
 (0)