@terascope/data-types 2.15.0 → 2.15.1
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/src/data-type.d.ts +55 -1
- package/dist/src/data-type.d.ts.map +1 -1
- package/dist/src/data-type.js +55 -1
- package/dist/src/data-type.js.map +1 -1
- package/dist/src/types/base-type.d.ts +29 -0
- package/dist/src/types/base-type.d.ts.map +1 -1
- package/dist/src/types/base-type.js +29 -0
- package/dist/src/types/base-type.js.map +1 -1
- package/dist/src/types/group-type.d.ts +25 -0
- package/dist/src/types/group-type.d.ts.map +1 -1
- package/dist/src/types/group-type.js +25 -0
- package/dist/src/types/group-type.js.map +1 -1
- package/dist/src/types/tuple-type.d.ts +34 -0
- package/dist/src/types/tuple-type.d.ts.map +1 -1
- package/dist/src/types/tuple-type.js +34 -0
- package/dist/src/types/tuple-type.js.map +1 -1
- package/dist/src/types/v1/any.d.ts +26 -0
- package/dist/src/types/v1/any.d.ts.map +1 -1
- package/dist/src/types/v1/any.js +26 -0
- package/dist/src/types/v1/any.js.map +1 -1
- package/dist/src/types/v1/binary.d.ts +24 -0
- package/dist/src/types/v1/binary.d.ts.map +1 -1
- package/dist/src/types/v1/binary.js +24 -0
- package/dist/src/types/v1/binary.js.map +1 -1
- package/dist/src/types/v1/boolean.d.ts +14 -0
- package/dist/src/types/v1/boolean.d.ts.map +1 -1
- package/dist/src/types/v1/boolean.js +14 -0
- package/dist/src/types/v1/boolean.js.map +1 -1
- package/dist/src/types/v1/boundary.d.ts +21 -0
- package/dist/src/types/v1/boundary.d.ts.map +1 -1
- package/dist/src/types/v1/boundary.js +21 -0
- package/dist/src/types/v1/boundary.js.map +1 -1
- package/dist/src/types/v1/byte.d.ts +18 -0
- package/dist/src/types/v1/byte.d.ts.map +1 -1
- package/dist/src/types/v1/byte.js +18 -0
- package/dist/src/types/v1/byte.js.map +1 -1
- package/dist/src/types/v1/date.d.ts +19 -0
- package/dist/src/types/v1/date.d.ts.map +1 -1
- package/dist/src/types/v1/date.js +19 -0
- package/dist/src/types/v1/date.js.map +1 -1
- package/dist/src/types/v1/domain.d.ts +24 -0
- package/dist/src/types/v1/domain.d.ts.map +1 -1
- package/dist/src/types/v1/domain.js +24 -0
- package/dist/src/types/v1/domain.js.map +1 -1
- package/dist/src/types/v1/double.d.ts +15 -0
- package/dist/src/types/v1/double.d.ts.map +1 -1
- package/dist/src/types/v1/double.js +15 -0
- package/dist/src/types/v1/double.js.map +1 -1
- package/dist/src/types/v1/float.d.ts +17 -0
- package/dist/src/types/v1/float.d.ts.map +1 -1
- package/dist/src/types/v1/float.js +17 -0
- package/dist/src/types/v1/float.js.map +1 -1
- package/dist/src/types/v1/geo-json.d.ts +18 -0
- package/dist/src/types/v1/geo-json.d.ts.map +1 -1
- package/dist/src/types/v1/geo-json.js +18 -0
- package/dist/src/types/v1/geo-json.js.map +1 -1
- package/dist/src/types/v1/geo-point.d.ts +19 -0
- package/dist/src/types/v1/geo-point.d.ts.map +1 -1
- package/dist/src/types/v1/geo-point.js +19 -0
- package/dist/src/types/v1/geo-point.js.map +1 -1
- package/dist/src/types/v1/geo.d.ts +20 -0
- package/dist/src/types/v1/geo.d.ts.map +1 -1
- package/dist/src/types/v1/geo.js +20 -1
- package/dist/src/types/v1/geo.js.map +1 -1
- package/dist/src/types/v1/hostname.d.ts +20 -0
- package/dist/src/types/v1/hostname.d.ts.map +1 -1
- package/dist/src/types/v1/hostname.js +20 -0
- package/dist/src/types/v1/hostname.js.map +1 -1
- package/dist/src/types/v1/integer.d.ts +18 -0
- package/dist/src/types/v1/integer.d.ts.map +1 -1
- package/dist/src/types/v1/integer.js +18 -0
- package/dist/src/types/v1/integer.js.map +1 -1
- package/dist/src/types/v1/ip-range.d.ts +16 -0
- package/dist/src/types/v1/ip-range.d.ts.map +1 -1
- package/dist/src/types/v1/ip-range.js +16 -0
- package/dist/src/types/v1/ip-range.js.map +1 -1
- package/dist/src/types/v1/ip.d.ts +15 -0
- package/dist/src/types/v1/ip.d.ts.map +1 -1
- package/dist/src/types/v1/ip.js +15 -0
- package/dist/src/types/v1/ip.js.map +1 -1
- package/dist/src/types/v1/keyword-case-insensitive.d.ts +23 -0
- package/dist/src/types/v1/keyword-case-insensitive.d.ts.map +1 -1
- package/dist/src/types/v1/keyword-case-insensitive.js +23 -0
- package/dist/src/types/v1/keyword-case-insensitive.js.map +1 -1
- package/dist/src/types/v1/keyword-path-analyzer.d.ts +19 -0
- package/dist/src/types/v1/keyword-path-analyzer.d.ts.map +1 -1
- package/dist/src/types/v1/keyword-path-analyzer.js +19 -0
- package/dist/src/types/v1/keyword-path-analyzer.js.map +1 -1
- package/dist/src/types/v1/keyword-tokens-case-insensitive.d.ts +20 -0
- package/dist/src/types/v1/keyword-tokens-case-insensitive.d.ts.map +1 -1
- package/dist/src/types/v1/keyword-tokens-case-insensitive.js +20 -0
- package/dist/src/types/v1/keyword-tokens-case-insensitive.js.map +1 -1
- package/dist/src/types/v1/keyword-tokens.d.ts +18 -0
- package/dist/src/types/v1/keyword-tokens.d.ts.map +1 -1
- package/dist/src/types/v1/keyword-tokens.js +18 -0
- package/dist/src/types/v1/keyword-tokens.js.map +1 -1
- package/dist/src/types/v1/keyword.d.ts +20 -0
- package/dist/src/types/v1/keyword.d.ts.map +1 -1
- package/dist/src/types/v1/keyword.js +20 -0
- package/dist/src/types/v1/keyword.js.map +1 -1
- package/dist/src/types/v1/long.d.ts +19 -0
- package/dist/src/types/v1/long.d.ts.map +1 -1
- package/dist/src/types/v1/long.js +19 -0
- package/dist/src/types/v1/long.js.map +1 -1
- package/dist/src/types/v1/ngram-tokens.d.ts +21 -0
- package/dist/src/types/v1/ngram-tokens.d.ts.map +1 -1
- package/dist/src/types/v1/ngram-tokens.js +21 -0
- package/dist/src/types/v1/ngram-tokens.js.map +1 -1
- package/dist/src/types/v1/number.d.ts +20 -0
- package/dist/src/types/v1/number.d.ts.map +1 -1
- package/dist/src/types/v1/number.js +20 -0
- package/dist/src/types/v1/number.js.map +1 -1
- package/dist/src/types/v1/object.d.ts +18 -0
- package/dist/src/types/v1/object.d.ts.map +1 -1
- package/dist/src/types/v1/object.js +18 -0
- package/dist/src/types/v1/object.js.map +1 -1
- package/dist/src/types/v1/short.d.ts +17 -0
- package/dist/src/types/v1/short.d.ts.map +1 -1
- package/dist/src/types/v1/short.js +17 -0
- package/dist/src/types/v1/short.js.map +1 -1
- package/dist/src/types/v1/string.d.ts +19 -0
- package/dist/src/types/v1/string.d.ts.map +1 -1
- package/dist/src/types/v1/string.js +19 -0
- package/dist/src/types/v1/string.js.map +1 -1
- package/dist/src/types/v1/text.d.ts +17 -0
- package/dist/src/types/v1/text.d.ts.map +1 -1
- package/dist/src/types/v1/text.js +17 -0
- package/dist/src/types/v1/text.js.map +1 -1
- package/dist/src/types/v1/vector.d.ts +38 -0
- package/dist/src/types/v1/vector.d.ts.map +1 -1
- package/dist/src/types/v1/vector.js +38 -0
- package/dist/src/types/v1/vector.js.map +1 -1
- package/package.json +3 -3
package/dist/src/data-type.d.ts
CHANGED
|
@@ -7,6 +7,24 @@ import * as i from './interfaces.js';
|
|
|
7
7
|
* - Elasticsearch Mappings
|
|
8
8
|
* - GraphQL Schemas
|
|
9
9
|
* - xLucene
|
|
10
|
+
*
|
|
11
|
+
* It is constructed from a `DataTypeConfig` (a `version` plus a map of field
|
|
12
|
+
* names to their {@link BaseType} configs); nested `Object` and `Tuple` fields
|
|
13
|
+
* declared with dot-notation are grouped into {@link GroupType} /
|
|
14
|
+
* {@link TupleType} instances during construction.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const dataType = new DataType({
|
|
18
|
+
* version: 1,
|
|
19
|
+
* fields: {
|
|
20
|
+
* name: { type: 'Keyword' },
|
|
21
|
+
* location: { type: 'GeoPoint' },
|
|
22
|
+
* },
|
|
23
|
+
* }, 'Person');
|
|
24
|
+
*
|
|
25
|
+
* dataType.toESMapping(); // Elasticsearch/OpenSearch mapping
|
|
26
|
+
* dataType.toGraphQL(); // GraphQL schema string
|
|
27
|
+
* dataType.toXlucene(); // xLucene type config
|
|
10
28
|
*/
|
|
11
29
|
export declare class DataType {
|
|
12
30
|
readonly name: string;
|
|
@@ -16,15 +34,51 @@ export declare class DataType {
|
|
|
16
34
|
/** An object of base fields with their child fields */
|
|
17
35
|
readonly groupedFields: i.GroupedFields;
|
|
18
36
|
private readonly _types;
|
|
19
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Merge multiple data types into a single GraphQL schema, de-duplicating
|
|
39
|
+
* shared custom types and scalars. Throws on a missing or duplicate type
|
|
40
|
+
* name (or duplicate input name when `createInputTypes` is set). Options
|
|
41
|
+
* control input-type generation, snake_case naming, scalar removal, and
|
|
42
|
+
* per-type reference/virtual fields.
|
|
43
|
+
*/
|
|
20
44
|
static mergeGraphQLDataTypes(types: DataType[], options?: i.MergeGraphQLOptions): string;
|
|
45
|
+
/**
|
|
46
|
+
* @param config the data type config; `version` defaults to the latest and
|
|
47
|
+
* `fields` to `{}`, and the config is validated (throwing on an unknown
|
|
48
|
+
* version or invalid field config).
|
|
49
|
+
* @param typeName optional name for the type (required by some conversions,
|
|
50
|
+
* e.g. GraphQL).
|
|
51
|
+
* @param description optional description carried into the GraphQL output.
|
|
52
|
+
*/
|
|
21
53
|
constructor(config: Partial<DataTypeConfig>, typeName?: string, description?: string);
|
|
22
54
|
/**
|
|
23
55
|
* Convert the DataType to an elasticsearch mapping.
|
|
24
56
|
*/
|
|
25
57
|
toESMapping({ overrides, distribution, majorVersion, minorVersion, version, _meta }?: Partial<i.ESMappingOptions>): ESMapping;
|
|
58
|
+
/**
|
|
59
|
+
* Convert the DataType to a formatted GraphQL schema string. Combines the
|
|
60
|
+
* generated custom types, the base type, an optional input type, and any
|
|
61
|
+
* `args.customTypes`, then validates and prints the result. Pass
|
|
62
|
+
* `removeScalars` to strip `scalar` declarations from the output.
|
|
63
|
+
*
|
|
64
|
+
* Note: fields that reference an undeclared scalar (e.g. `Any`/`Tuple` →
|
|
65
|
+
* `JSON`) require that scalar to be supplied for the schema to validate.
|
|
66
|
+
*/
|
|
26
67
|
toGraphQL(args?: i.GraphQLOptions, removeScalars?: boolean): string;
|
|
68
|
+
/**
|
|
69
|
+
* Build the GraphQL type parts without assembling/validating a full schema:
|
|
70
|
+
* the `baseType` definition, an optional `inputType`, and the `customTypes`
|
|
71
|
+
* (scalars and generated nested types) the fields reference. Use this when
|
|
72
|
+
* composing several data types into one schema (see
|
|
73
|
+
* {@link DataType.mergeGraphQLDataTypes}); use `toGraphQL` for a single,
|
|
74
|
+
* ready-to-use schema string. Throws if no type name is available.
|
|
75
|
+
*/
|
|
27
76
|
toGraphQLTypes(args?: i.GraphQLOptions): i.GraphQLTypesResult;
|
|
77
|
+
/**
|
|
78
|
+
* Convert the DataType to an xLucene type config — a flat map of field name
|
|
79
|
+
* (including nested dot-notation paths) to its xLucene field type, merged
|
|
80
|
+
* across every field.
|
|
81
|
+
*/
|
|
28
82
|
toXlucene(): xLuceneTypeConfig;
|
|
29
83
|
}
|
|
30
84
|
//# sourceMappingURL=data-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-type.d.ts","sourceRoot":"","sources":["../../src/data-type.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EAA6B,SAAS,EACpC,sBAAsB,EAAE,iBAAiB,EAC5D,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AAKrC
|
|
1
|
+
{"version":3,"file":"data-type.d.ts","sourceRoot":"","sources":["../../src/data-type.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,cAAc,EAA6B,SAAS,EACpC,sBAAsB,EAAE,iBAAiB,EAC5D,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAC;AAKrC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,QAAQ;IACjB,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,aAAa,CAAC;IAExC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IAEpC;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAE,CAAC,CAAC,mBAAwB,GAAG,MAAM;IAyD5F;;;;;;;OAOG;gBACS,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAgBpF;;OAEG;IACH,WAAW,CAAC,EACR,SAAS,EAAE,YAAmD,EAC9D,YAAgB,EAAE,YAAiB,EAAE,OAAkB,EAAE,KAAK,EACjE,GAAE,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAM,GAAG,SAAS;IA6C/C;;;;;;;;OAQG;IACH,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,cAAc,EAAE,aAAa,UAAQ,GAAG,MAAM;IAQjE;;;;;;;OAOG;IACH,cAAc,CAAC,IAAI,GAAE,CAAC,CAAC,cAAmB,GAAG,CAAC,CAAC,kBAAkB;IA0EjE;;;;OAIG;IACH,SAAS,IAAI,iBAAiB;CAGjC"}
|
package/dist/src/data-type.js
CHANGED
|
@@ -10,6 +10,24 @@ import { getTypes, LATEST_VERSION, getGroupedFields } from './types/index.js';
|
|
|
10
10
|
* - Elasticsearch Mappings
|
|
11
11
|
* - GraphQL Schemas
|
|
12
12
|
* - xLucene
|
|
13
|
+
*
|
|
14
|
+
* It is constructed from a `DataTypeConfig` (a `version` plus a map of field
|
|
15
|
+
* names to their {@link BaseType} configs); nested `Object` and `Tuple` fields
|
|
16
|
+
* declared with dot-notation are grouped into {@link GroupType} /
|
|
17
|
+
* {@link TupleType} instances during construction.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* const dataType = new DataType({
|
|
21
|
+
* version: 1,
|
|
22
|
+
* fields: {
|
|
23
|
+
* name: { type: 'Keyword' },
|
|
24
|
+
* location: { type: 'GeoPoint' },
|
|
25
|
+
* },
|
|
26
|
+
* }, 'Person');
|
|
27
|
+
*
|
|
28
|
+
* dataType.toESMapping(); // Elasticsearch/OpenSearch mapping
|
|
29
|
+
* dataType.toGraphQL(); // GraphQL schema string
|
|
30
|
+
* dataType.toXlucene(); // xLucene type config
|
|
13
31
|
*/
|
|
14
32
|
export class DataType {
|
|
15
33
|
name;
|
|
@@ -19,7 +37,13 @@ export class DataType {
|
|
|
19
37
|
/** An object of base fields with their child fields */
|
|
20
38
|
groupedFields;
|
|
21
39
|
_types;
|
|
22
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Merge multiple data types into a single GraphQL schema, de-duplicating
|
|
42
|
+
* shared custom types and scalars. Throws on a missing or duplicate type
|
|
43
|
+
* name (or duplicate input name when `createInputTypes` is set). Options
|
|
44
|
+
* control input-type generation, snake_case naming, scalar removal, and
|
|
45
|
+
* per-type reference/virtual fields.
|
|
46
|
+
*/
|
|
23
47
|
static mergeGraphQLDataTypes(types, options = {}) {
|
|
24
48
|
const { references: typeReferences = {}, removeScalars = false, useSnakeCase = false } = options;
|
|
25
49
|
const customTypes = [...(options.customTypes ?? [])];
|
|
@@ -58,6 +82,14 @@ export class DataType {
|
|
|
58
82
|
const strSchema = utils.joinStrings(customTypes, customTypes, typeDefs);
|
|
59
83
|
return formatSchema(strSchema, removeScalars);
|
|
60
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* @param config the data type config; `version` defaults to the latest and
|
|
87
|
+
* `fields` to `{}`, and the config is validated (throwing on an unknown
|
|
88
|
+
* version or invalid field config).
|
|
89
|
+
* @param typeName optional name for the type (required by some conversions,
|
|
90
|
+
* e.g. GraphQL).
|
|
91
|
+
* @param description optional description carried into the GraphQL output.
|
|
92
|
+
*/
|
|
61
93
|
constructor(config, typeName, description) {
|
|
62
94
|
if (typeName)
|
|
63
95
|
this.name = typeName;
|
|
@@ -114,11 +146,28 @@ export class DataType {
|
|
|
114
146
|
}
|
|
115
147
|
return defaultsDeep({}, overrides, esMapping);
|
|
116
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Convert the DataType to a formatted GraphQL schema string. Combines the
|
|
151
|
+
* generated custom types, the base type, an optional input type, and any
|
|
152
|
+
* `args.customTypes`, then validates and prints the result. Pass
|
|
153
|
+
* `removeScalars` to strip `scalar` declarations from the output.
|
|
154
|
+
*
|
|
155
|
+
* Note: fields that reference an undeclared scalar (e.g. `Any`/`Tuple` →
|
|
156
|
+
* `JSON`) require that scalar to be supplied for the schema to validate.
|
|
157
|
+
*/
|
|
117
158
|
toGraphQL(args, removeScalars = false) {
|
|
118
159
|
const { baseType, inputType, customTypes } = this.toGraphQLTypes(args);
|
|
119
160
|
const schema = utils.joinStrings(customTypes, baseType, inputType, args?.customTypes);
|
|
120
161
|
return formatSchema(schema, removeScalars);
|
|
121
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Build the GraphQL type parts without assembling/validating a full schema:
|
|
165
|
+
* the `baseType` definition, an optional `inputType`, and the `customTypes`
|
|
166
|
+
* (scalars and generated nested types) the fields reference. Use this when
|
|
167
|
+
* composing several data types into one schema (see
|
|
168
|
+
* {@link DataType.mergeGraphQLDataTypes}); use `toGraphQL` for a single,
|
|
169
|
+
* ready-to-use schema string. Throws if no type name is available.
|
|
170
|
+
*/
|
|
122
171
|
toGraphQLTypes(args = {}) {
|
|
123
172
|
const { typeName = this.name, references = [], useSnakeCase = false, description = this.description, createInputType = false } = args;
|
|
124
173
|
if (!typeName) {
|
|
@@ -167,6 +216,11 @@ export class DataType {
|
|
|
167
216
|
customTypes,
|
|
168
217
|
};
|
|
169
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Convert the DataType to an xLucene type config — a flat map of field name
|
|
221
|
+
* (including nested dot-notation paths) to its xLucene field type, merged
|
|
222
|
+
* across every field.
|
|
223
|
+
*/
|
|
170
224
|
toXlucene() {
|
|
171
225
|
return this._types.reduce((accum, type) => ({ ...accum, ...type.toXlucene() }), {});
|
|
172
226
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-type.js","sourceRoot":"","sources":["../../src/data-type.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAAE,GAAG,EAAE,UAAU,EACzB,YAAY,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACa,yBAAyB,EAE5C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE9E
|
|
1
|
+
{"version":3,"file":"data-type.js","sourceRoot":"","sources":["../../src/data-type.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EAAE,GAAG,EAAE,UAAU,EACzB,YAAY,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACa,yBAAyB,EAE5C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE9E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,QAAQ;IACR,IAAI,CAAU;IACd,WAAW,CAAU;IACrB,MAAM,CAAyB;IAC/B,OAAO,CAAS;IACzB,uDAAuD;IAC9C,aAAa,CAAkB;IAEvB,MAAM,CA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ACrD,UAAU,CACb,CAAC,CAAC;QACP,CAAC;QAED,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAC9B,oBAAoB,CAAC,WAAW,CAAC,EACjC,QAAQ,QAAQ;kBACV,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC;cACrC,CACL,CAAC;QAEF,IAAI,SAA6B,CAAC;QAElC,IAAI,eAAe,EAAE,CAAC;YAClB,SAAS,GAAG,KAAK,CAAC,WAAW,CACzB,oBAAoB,CAAC,WAAW,EAAE,aAAa,QAAQ,EAAE,CAAC,EAC1D,SAAS,SAAS;sBACZ,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC;kBACtC,CACL,CAAC;QACN,CAAC;QAED,OAAO;YACH,QAAQ;YACR,SAAS;YACT,WAAW;SACd,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;CACJ"}
|
|
@@ -3,23 +3,52 @@ import { GraphQLType, TypeESMapping } from '../interfaces.js';
|
|
|
3
3
|
export interface IBaseType {
|
|
4
4
|
new (field: string, config: DataTypeFieldConfig): BaseType;
|
|
5
5
|
}
|
|
6
|
+
/** Options controlling how a field is rendered into GraphQL. */
|
|
6
7
|
export type ToGraphQLOptions = {
|
|
7
8
|
typeName?: string;
|
|
8
9
|
isInput?: boolean;
|
|
9
10
|
includePrivate?: boolean;
|
|
10
11
|
useSnakeCase?: boolean;
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* The abstract base class every field type extends. It captures a single
|
|
15
|
+
* field's identity (`field` name, its `DataTypeFieldConfig`, and the data-type
|
|
16
|
+
* `version`) and defines the contract for converting that field into each
|
|
17
|
+
* supported output format.
|
|
18
|
+
*
|
|
19
|
+
* Concrete subclasses implement the three conversion methods; `BaseType`
|
|
20
|
+
* itself provides the shared validation and GraphQL-formatting helpers they
|
|
21
|
+
* build on. Subclasses live in `types/v1/` (the versioned field types) plus the
|
|
22
|
+
* grouping types {@link GroupType} and {@link TupleType} in `types/`.
|
|
23
|
+
*/
|
|
12
24
|
export default abstract class BaseType {
|
|
13
25
|
readonly field: string;
|
|
14
26
|
readonly config: DataTypeFieldConfig;
|
|
15
27
|
readonly version: number;
|
|
16
28
|
constructor(field: string, config: DataTypeFieldConfig, version?: number);
|
|
29
|
+
/**
|
|
30
|
+
* Guard used by subclasses before emitting an ES mapping: throws if the
|
|
31
|
+
* field is configured `indexed: false` but its type is in
|
|
32
|
+
* `indexedRequiredFieldTypes` (types that cannot be left unindexed).
|
|
33
|
+
*/
|
|
17
34
|
protected _validateESMapping(): void;
|
|
18
35
|
abstract toESMapping(config: ClientMetadata): TypeESMapping;
|
|
19
36
|
abstract toGraphQL(options?: ToGraphQLOptions): GraphQLType;
|
|
20
37
|
abstract toXlucene(): xLuceneTypeConfig;
|
|
38
|
+
/**
|
|
39
|
+
* Build the `{ type, customTypes }` GraphQL result for a field of the given
|
|
40
|
+
* GraphQL `type`. Honors the field's `description` and `array` config
|
|
41
|
+
* (wrapping the type as a `[list]`), and carries along any `customType`
|
|
42
|
+
* SDL definitions (e.g. `scalar`/nested-type declarations) the field needs.
|
|
43
|
+
*/
|
|
21
44
|
protected _formatGql(type: string, customType?: string | (string[])): GraphQLType;
|
|
45
|
+
/**
|
|
46
|
+
* Build the generated name for a custom GraphQL type, e.g.
|
|
47
|
+
* `DT<TypeName>V<version>` (with an `Input` suffix for input types). Used by
|
|
48
|
+
* the grouping types to name the nested types they emit.
|
|
49
|
+
*/
|
|
22
50
|
_formatGQLTypeName(typeName: string, isInput?: boolean, inputSuffix?: string): string;
|
|
23
51
|
}
|
|
52
|
+
/** Prefix a GraphQL type/field line with its formatted description, when present. */
|
|
24
53
|
export declare function formatGQLType(type: string, des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IACH,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,SAAU,GAAG,MAAM;CAQzF;AAQD,qFAAqF;AACrF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAGjE"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { indexedRequiredFieldTypes } from '@terascope/types';
|
|
2
2
|
import { castArray } from '@terascope/core-utils';
|
|
3
3
|
import { formatGQLDescription } from '../graphql-helper.js';
|
|
4
|
+
/**
|
|
5
|
+
* The abstract base class every field type extends. It captures a single
|
|
6
|
+
* field's identity (`field` name, its `DataTypeFieldConfig`, and the data-type
|
|
7
|
+
* `version`) and defines the contract for converting that field into each
|
|
8
|
+
* supported output format.
|
|
9
|
+
*
|
|
10
|
+
* Concrete subclasses implement the three conversion methods; `BaseType`
|
|
11
|
+
* itself provides the shared validation and GraphQL-formatting helpers they
|
|
12
|
+
* build on. Subclasses live in `types/v1/` (the versioned field types) plus the
|
|
13
|
+
* grouping types {@link GroupType} and {@link TupleType} in `types/`.
|
|
14
|
+
*/
|
|
4
15
|
export default class BaseType {
|
|
5
16
|
field;
|
|
6
17
|
config;
|
|
@@ -10,6 +21,11 @@ export default class BaseType {
|
|
|
10
21
|
this.field = field;
|
|
11
22
|
this.config = config;
|
|
12
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Guard used by subclasses before emitting an ES mapping: throws if the
|
|
26
|
+
* field is configured `indexed: false` but its type is in
|
|
27
|
+
* `indexedRequiredFieldTypes` (types that cannot be left unindexed).
|
|
28
|
+
*/
|
|
13
29
|
_validateESMapping() {
|
|
14
30
|
if (this.config.indexed === false) {
|
|
15
31
|
if (this.config.type in indexedRequiredFieldTypes) {
|
|
@@ -17,6 +33,12 @@ export default class BaseType {
|
|
|
17
33
|
}
|
|
18
34
|
}
|
|
19
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Build the `{ type, customTypes }` GraphQL result for a field of the given
|
|
38
|
+
* GraphQL `type`. Honors the field's `description` and `array` config
|
|
39
|
+
* (wrapping the type as a `[list]`), and carries along any `customType`
|
|
40
|
+
* SDL definitions (e.g. `scalar`/nested-type declarations) the field needs.
|
|
41
|
+
*/
|
|
20
42
|
_formatGql(type, customType) {
|
|
21
43
|
const desc = this.config.description;
|
|
22
44
|
if (this.config.array) {
|
|
@@ -30,6 +52,11 @@ export default class BaseType {
|
|
|
30
52
|
customTypes: makeCustomTypes(customType)
|
|
31
53
|
};
|
|
32
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the generated name for a custom GraphQL type, e.g.
|
|
57
|
+
* `DT<TypeName>V<version>` (with an `Input` suffix for input types). Used by
|
|
58
|
+
* the grouping types to name the nested types they emit.
|
|
59
|
+
*/
|
|
33
60
|
_formatGQLTypeName(typeName, isInput, inputSuffix = 'Input') {
|
|
34
61
|
return [
|
|
35
62
|
'DT',
|
|
@@ -39,11 +66,13 @@ export default class BaseType {
|
|
|
39
66
|
].join('');
|
|
40
67
|
}
|
|
41
68
|
}
|
|
69
|
+
/** Normalize the optional custom-type argument into an array. */
|
|
42
70
|
function makeCustomTypes(customType) {
|
|
43
71
|
if (!customType?.length)
|
|
44
72
|
return [];
|
|
45
73
|
return castArray(customType);
|
|
46
74
|
}
|
|
75
|
+
/** Prefix a GraphQL type/field line with its formatted description, when present. */
|
|
47
76
|
export function formatGQLType(type, desc) {
|
|
48
77
|
if (!desc)
|
|
49
78
|
return type;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-type.js","sourceRoot":"","sources":["../../../src/types/base-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":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AAE,IAAI,CAAC;YACnD,WAAW,EAAE,eAAe,CAAC,UAAU,CAAC;SAC3C,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,QAAgB,EAAE,OAAiB,EAAE,WAAW,GAAG,OAAO;QACzE,OAAO;YACH,IAAI;YACJ,QAAQ;YACR,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE;YAC1B,IAAI,IAAI,CAAC,OAAO,EAAE;SACrB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;CACJ;AAED,iEAAiE;AACjE,SAAS,eAAe,CAAC,UAA8B;IACnD,IAAI,CAAC,UAAU,EAAE,MAAM;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAa;IACrD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -4,10 +4,35 @@ import { GraphQLType, TypeESMapping } from '../interfaces.js';
|
|
|
4
4
|
export type NestedTypes = {
|
|
5
5
|
[field: string]: BaseType;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Represents an `Object` field together with its nested children as a single
|
|
9
|
+
* grouped unit. This is not a `FieldType` you declare directly — it is
|
|
10
|
+
* assembled during field grouping (`getGroupType`) from an `Object` parent and
|
|
11
|
+
* its dot-notation children (e.g. `user` + `user.id` + `user.name`), so the
|
|
12
|
+
* parent and its descendants convert together into one nested structure.
|
|
13
|
+
*
|
|
14
|
+
* - **ES/OpenSearch mapping:** the parent's `object`/`nested` mapping with each
|
|
15
|
+
* child folded into its `properties` (recursively, since a child may itself
|
|
16
|
+
* be a group), merging any analyzers/tokenizers the children contribute.
|
|
17
|
+
* - **GraphQL:** a generated nested type (`DT<Parent><Field>V<version>`) whose
|
|
18
|
+
* fields are the children, referenced from the parent type.
|
|
19
|
+
* - **xLucene:** the merged xLucene configs of the parent and all children,
|
|
20
|
+
* keyed by their full dot-notation paths.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link TupleType} for the ordered-set analogue.
|
|
23
|
+
*/
|
|
7
24
|
export default class GroupType extends BaseType {
|
|
8
25
|
readonly types: NestedTypes;
|
|
9
26
|
constructor(field: string, version: number, types: NestedTypes);
|
|
27
|
+
/**
|
|
28
|
+
* Emit the parent's mapping with each child nested under its `properties`,
|
|
29
|
+
* accumulating any analyzers/tokenizers contributed by the children.
|
|
30
|
+
*/
|
|
10
31
|
toESMapping(config: ClientMetadata): TypeESMapping;
|
|
32
|
+
/**
|
|
33
|
+
* Emit a generated nested GraphQL type built from the children and return
|
|
34
|
+
* the parent field referencing it (as `[list]` when the parent is an array).
|
|
35
|
+
*/
|
|
11
36
|
toGraphQL(options?: ToGraphQLOptions): GraphQLType;
|
|
12
37
|
toXlucene(): xLuceneTypeConfig;
|
|
13
38
|
private _removeBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-type.d.ts","sourceRoot":"","sources":["../../../src/types/group-type.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,cAAc,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAExD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;gBAEhB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAK9D,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa;IAiClD,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,WAAW;IA0CtD,SAAS,IAAI,iBAAiB;IAK9B,OAAO,CAAC,WAAW;CAGtB"}
|
|
1
|
+
{"version":3,"file":"group-type.d.ts","sourceRoot":"","sources":["../../../src/types/group-type.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,cAAc,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;gBAEhB,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW;IAK9D;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa;IAiClD;;;OAGG;IACH,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,WAAW;IA0CtD,SAAS,IAAI,iBAAiB;IAK9B,OAAO,CAAC,WAAW;CAGtB"}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { firstToUpper } from '@terascope/core-utils';
|
|
2
2
|
import BaseType from './base-type.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents an `Object` field together with its nested children as a single
|
|
5
|
+
* grouped unit. This is not a `FieldType` you declare directly — it is
|
|
6
|
+
* assembled during field grouping (`getGroupType`) from an `Object` parent and
|
|
7
|
+
* its dot-notation children (e.g. `user` + `user.id` + `user.name`), so the
|
|
8
|
+
* parent and its descendants convert together into one nested structure.
|
|
9
|
+
*
|
|
10
|
+
* - **ES/OpenSearch mapping:** the parent's `object`/`nested` mapping with each
|
|
11
|
+
* child folded into its `properties` (recursively, since a child may itself
|
|
12
|
+
* be a group), merging any analyzers/tokenizers the children contribute.
|
|
13
|
+
* - **GraphQL:** a generated nested type (`DT<Parent><Field>V<version>`) whose
|
|
14
|
+
* fields are the children, referenced from the parent type.
|
|
15
|
+
* - **xLucene:** the merged xLucene configs of the parent and all children,
|
|
16
|
+
* keyed by their full dot-notation paths.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link TupleType} for the ordered-set analogue.
|
|
19
|
+
*/
|
|
3
20
|
export default class GroupType extends BaseType {
|
|
4
21
|
types;
|
|
5
22
|
constructor(field, version, types) {
|
|
6
23
|
super(field, types[field].config, version);
|
|
7
24
|
this.types = types;
|
|
8
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Emit the parent's mapping with each child nested under its `properties`,
|
|
28
|
+
* accumulating any analyzers/tokenizers contributed by the children.
|
|
29
|
+
*/
|
|
9
30
|
toESMapping(config) {
|
|
10
31
|
const { mapping, analyzer = {}, tokenizer = {}, } = this.types[this.field].toESMapping(config);
|
|
11
32
|
const baseMapping = mapping[this.field];
|
|
@@ -29,6 +50,10 @@ export default class GroupType extends BaseType {
|
|
|
29
50
|
tokenizer,
|
|
30
51
|
};
|
|
31
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Emit a generated nested GraphQL type built from the children and return
|
|
55
|
+
* the parent field referencing it (as `[list]` when the parent is an array).
|
|
56
|
+
*/
|
|
32
57
|
toGraphQL(options = {}) {
|
|
33
58
|
const { typeName = 'Object', isInput, includePrivate } = options;
|
|
34
59
|
const customTypeName = this._formatGQLTypeName(options.useSnakeCase
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-type.js","sourceRoot":"","sources":["../../../src/types/group-type.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAA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S;QACL,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC1E,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,WAAW,CAAC,GAAW;QAC3B,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;CACJ"}
|
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
import { DataTypeFieldConfig, xLuceneTypeConfig } from '@terascope/types';
|
|
2
2
|
import BaseType from './base-type.js';
|
|
3
3
|
import { GraphQLType, TypeESMapping } from '../interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* An ordered, fixed set of values where each position (element) has its own
|
|
6
|
+
* type — the data-types analogue of a tuple. Declare the parent field as
|
|
7
|
+
* `Tuple` and give each element a dot-notation, zero-based index name
|
|
8
|
+
* (`field.0`, `field.1`, …), the same way {@link GroupType} object children
|
|
9
|
+
* are declared. At least one element field is required (the builder throws
|
|
10
|
+
* `Tuple field types require at least one field` otherwise).
|
|
11
|
+
*
|
|
12
|
+
* Unlike the v1 field types, this is not version-specific: it lives in
|
|
13
|
+
* `src/types/` (not `src/types/v1/`) and is selected during field grouping
|
|
14
|
+
* (`getTupleType`) rather than through the version registry. The `Tuple` entry
|
|
15
|
+
* in `types/mapping.ts` points at {@link AnyType} but is never reached.
|
|
16
|
+
*
|
|
17
|
+
* - **ES/OpenSearch mapping:** `{ enabled: false }` on the parent field — the
|
|
18
|
+
* tuple is kept in `_source` but not indexed, and the element sub-fields are
|
|
19
|
+
* **not** emitted as individual mappings, so a tuple cannot be searched,
|
|
20
|
+
* sorted, or aggregated on.
|
|
21
|
+
* - **GraphQL:** `JSON`. As with {@link AnyType}, no `scalar JSON` definition
|
|
22
|
+
* is emitted, so the surrounding schema must provide a `JSON` scalar — via
|
|
23
|
+
* a GraphQL patch or a scalar library — for the field to resolve.
|
|
24
|
+
* - **xLucene:** the merged xLucene configs of the element types, keyed by
|
|
25
|
+
* their dot paths (e.g. `{ 'field.0': 'float', 'field.1': 'float' }`). The
|
|
26
|
+
* parent tuple field itself contributes no xLucene entry.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const config: DataTypeConfig = {
|
|
30
|
+
* version: 1,
|
|
31
|
+
* fields: {
|
|
32
|
+
* location: { type: 'Tuple' },
|
|
33
|
+
* 'location.0': { type: 'Float' },
|
|
34
|
+
* 'location.1': { type: 'Float' },
|
|
35
|
+
* }
|
|
36
|
+
* };
|
|
37
|
+
*/
|
|
4
38
|
export default class TupleType extends BaseType {
|
|
5
39
|
readonly types: readonly BaseType[];
|
|
6
40
|
constructor(field: string, version: number, baseConfig: DataTypeFieldConfig, types: BaseType[]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple-type.d.ts","sourceRoot":"","sources":["../../../src/types/tuple-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;gBAGhC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAE,QAAQ,EAAE;IAMrB,WAAW,IAAI,aAAa;IAM5B,SAAS,IAAI,WAAW;IAIxB,SAAS,IAAI,iBAAiB;CAIjC"}
|
|
1
|
+
{"version":3,"file":"tuple-type.d.ts","sourceRoot":"","sources":["../../../src/types/tuple-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;gBAGhC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAE,QAAQ,EAAE;IAMrB,WAAW,IAAI,aAAa;IAM5B,SAAS,IAAI,WAAW;IAIxB,SAAS,IAAI,iBAAiB;CAIjC"}
|
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
import BaseType from './base-type.js';
|
|
2
|
+
/**
|
|
3
|
+
* An ordered, fixed set of values where each position (element) has its own
|
|
4
|
+
* type — the data-types analogue of a tuple. Declare the parent field as
|
|
5
|
+
* `Tuple` and give each element a dot-notation, zero-based index name
|
|
6
|
+
* (`field.0`, `field.1`, …), the same way {@link GroupType} object children
|
|
7
|
+
* are declared. At least one element field is required (the builder throws
|
|
8
|
+
* `Tuple field types require at least one field` otherwise).
|
|
9
|
+
*
|
|
10
|
+
* Unlike the v1 field types, this is not version-specific: it lives in
|
|
11
|
+
* `src/types/` (not `src/types/v1/`) and is selected during field grouping
|
|
12
|
+
* (`getTupleType`) rather than through the version registry. The `Tuple` entry
|
|
13
|
+
* in `types/mapping.ts` points at {@link AnyType} but is never reached.
|
|
14
|
+
*
|
|
15
|
+
* - **ES/OpenSearch mapping:** `{ enabled: false }` on the parent field — the
|
|
16
|
+
* tuple is kept in `_source` but not indexed, and the element sub-fields are
|
|
17
|
+
* **not** emitted as individual mappings, so a tuple cannot be searched,
|
|
18
|
+
* sorted, or aggregated on.
|
|
19
|
+
* - **GraphQL:** `JSON`. As with {@link AnyType}, no `scalar JSON` definition
|
|
20
|
+
* is emitted, so the surrounding schema must provide a `JSON` scalar — via
|
|
21
|
+
* a GraphQL patch or a scalar library — for the field to resolve.
|
|
22
|
+
* - **xLucene:** the merged xLucene configs of the element types, keyed by
|
|
23
|
+
* their dot paths (e.g. `{ 'field.0': 'float', 'field.1': 'float' }`). The
|
|
24
|
+
* parent tuple field itself contributes no xLucene entry.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const config: DataTypeConfig = {
|
|
28
|
+
* version: 1,
|
|
29
|
+
* fields: {
|
|
30
|
+
* location: { type: 'Tuple' },
|
|
31
|
+
* 'location.0': { type: 'Float' },
|
|
32
|
+
* 'location.1': { type: 'Float' },
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
*/
|
|
2
36
|
export default class TupleType extends BaseType {
|
|
3
37
|
types;
|
|
4
38
|
constructor(field, version, baseConfig, types) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tuple-type.js","sourceRoot":"","sources":["../../../src/types/tuple-type.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAClC,KAAK,CAAsB;IAEpC,YACI,KAAa,EACb,OAAe,EACf,UAA+B,EAC/B,KAAiB;QAEjB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,WAAW;QACP,OAAO;YACH,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;SAChD,CAAC;IACN,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,SAAS;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC;IACzC,CAAC;CACJ"}
|
|
1
|
+
{"version":3,"file":"tuple-type.js","sourceRoot":"","sources":["../../../src/types/tuple-type.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,QAAQ;IAClC,KAAK,CAAsB;IAEpC,YACI,KAAa,EACb,OAAe,EACf,UAA+B,EAC/B,KAAiB;QAEjB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IAED,WAAW;QACP,OAAO;YACH,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;SAChD,CAAC;IACN,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,SAAS;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC;IACzC,CAAC;CACJ"}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
import { xLuceneTypeConfig } from '@terascope/types';
|
|
2
2
|
import BaseType from '../base-type.js';
|
|
3
3
|
import { GraphQLType, TypeESMapping } from '../../interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* A field of unrestricted shape. The value is stored but excluded from
|
|
6
|
+
* indexing, so it can hold arbitrary JSON without imposing a mapping.
|
|
7
|
+
*
|
|
8
|
+
* The type registry (`types/mapping.ts`) also maps `Tuple` to this class, but
|
|
9
|
+
* that entry is a never-reached fallback — `Tuple` fields are intercepted
|
|
10
|
+
* during field grouping and handled by their own {@link TupleType} class, so
|
|
11
|
+
* `Any` does not actually back `Tuple` at runtime.
|
|
12
|
+
*
|
|
13
|
+
* - **ES/OpenSearch mapping:** `{ enabled: false }` — ES stores the value in
|
|
14
|
+
* `_source` but does not index it, so it cannot be searched, sorted, or
|
|
15
|
+
* aggregated on.
|
|
16
|
+
* - **GraphQL:** `JSON`. Unlike `Object`/`GeoJSON` (which emit their own
|
|
17
|
+
* `scalar JSONObject`/`scalar GeoJSON` definitions), this type does not emit
|
|
18
|
+
* a `scalar JSON` definition, so the surrounding schema must provide a `JSON`
|
|
19
|
+
* scalar — via a GraphQL patch or a scalar library — for the field to
|
|
20
|
+
* resolve.
|
|
21
|
+
* - **xLucene:** none — `toXlucene()` returns `{}`, so the field contributes
|
|
22
|
+
* no xLucene type.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const config: DataTypeConfig = {
|
|
26
|
+
* version: 1,
|
|
27
|
+
* fields: { payload: { type: 'Any' } }
|
|
28
|
+
* };
|
|
29
|
+
*/
|
|
4
30
|
export default class AnyType extends BaseType {
|
|
5
31
|
toESMapping(): TypeESMapping;
|
|
6
32
|
toGraphQL(): GraphQLType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any.d.ts","sourceRoot":"","sources":["../../../../src/types/v1/any.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AACtE,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjE,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,QAAQ;IACzC,WAAW,IAAI,aAAa;IAU5B,SAAS,IAAI,WAAW;IAIxB,SAAS,IAAI,iBAAiB;CAGjC"}
|
|
1
|
+
{"version":3,"file":"any.d.ts","sourceRoot":"","sources":["../../../../src/types/v1/any.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,kBAAkB,CAAC;AACtE,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,QAAQ;IACzC,WAAW,IAAI,aAAa;IAU5B,SAAS,IAAI,WAAW;IAIxB,SAAS,IAAI,iBAAiB;CAGjC"}
|
package/dist/src/types/v1/any.js
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import BaseType from '../base-type.js';
|
|
2
|
+
/**
|
|
3
|
+
* A field of unrestricted shape. The value is stored but excluded from
|
|
4
|
+
* indexing, so it can hold arbitrary JSON without imposing a mapping.
|
|
5
|
+
*
|
|
6
|
+
* The type registry (`types/mapping.ts`) also maps `Tuple` to this class, but
|
|
7
|
+
* that entry is a never-reached fallback — `Tuple` fields are intercepted
|
|
8
|
+
* during field grouping and handled by their own {@link TupleType} class, so
|
|
9
|
+
* `Any` does not actually back `Tuple` at runtime.
|
|
10
|
+
*
|
|
11
|
+
* - **ES/OpenSearch mapping:** `{ enabled: false }` — ES stores the value in
|
|
12
|
+
* `_source` but does not index it, so it cannot be searched, sorted, or
|
|
13
|
+
* aggregated on.
|
|
14
|
+
* - **GraphQL:** `JSON`. Unlike `Object`/`GeoJSON` (which emit their own
|
|
15
|
+
* `scalar JSONObject`/`scalar GeoJSON` definitions), this type does not emit
|
|
16
|
+
* a `scalar JSON` definition, so the surrounding schema must provide a `JSON`
|
|
17
|
+
* scalar — via a GraphQL patch or a scalar library — for the field to
|
|
18
|
+
* resolve.
|
|
19
|
+
* - **xLucene:** none — `toXlucene()` returns `{}`, so the field contributes
|
|
20
|
+
* no xLucene type.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const config: DataTypeConfig = {
|
|
24
|
+
* version: 1,
|
|
25
|
+
* fields: { payload: { type: 'Any' } }
|
|
26
|
+
* };
|
|
27
|
+
*/
|
|
2
28
|
export default class AnyType extends BaseType {
|
|
3
29
|
toESMapping() {
|
|
4
30
|
this._validateESMapping();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any.js","sourceRoot":"","sources":["../../../../src/types/v1/any.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,QAAQ;IACzC,WAAW;QACP,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAE1B,MAAM,MAAM,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAEnD,OAAO;YACH,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE;SACpC,CAAC;IACN,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,SAAS;QACL,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
|
|
1
|
+
{"version":3,"file":"any.js","sourceRoot":"","sources":["../../../../src/types/v1/any.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,QAAQ;IACzC,WAAW;QACP,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAE1B,MAAM,MAAM,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAEnD,OAAO;YACH,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE;SACpC,CAAC;IACN,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,SAAS;QACL,OAAO,EAAE,CAAC;IACd,CAAC;CACJ"}
|