elastiq-ts 0.1.0-beta

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1157 -0
  3. package/dist/__tests__/elastic.helpers.d.ts +17 -0
  4. package/dist/__tests__/elastic.helpers.d.ts.map +1 -0
  5. package/dist/__tests__/elastic.helpers.js +46 -0
  6. package/dist/aggregation-builder.d.ts +4 -0
  7. package/dist/aggregation-builder.d.ts.map +1 -0
  8. package/dist/aggregation-builder.js +153 -0
  9. package/dist/aggregation-types.d.ts +234 -0
  10. package/dist/aggregation-types.d.ts.map +1 -0
  11. package/dist/aggregation-types.js +6 -0
  12. package/dist/bulk-types.d.ts +67 -0
  13. package/dist/bulk-types.d.ts.map +1 -0
  14. package/dist/bulk-types.js +6 -0
  15. package/dist/bulk.d.ts +22 -0
  16. package/dist/bulk.d.ts.map +1 -0
  17. package/dist/bulk.js +55 -0
  18. package/dist/index-management.d.ts +30 -0
  19. package/dist/index-management.d.ts.map +1 -0
  20. package/dist/index-management.js +48 -0
  21. package/dist/index-types.d.ts +87 -0
  22. package/dist/index-types.d.ts.map +1 -0
  23. package/dist/index-types.js +6 -0
  24. package/dist/index.d.ts +12 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +25 -0
  27. package/dist/multi-search-types.d.ts +41 -0
  28. package/dist/multi-search-types.d.ts.map +1 -0
  29. package/dist/multi-search-types.js +6 -0
  30. package/dist/multi-search.d.ts +20 -0
  31. package/dist/multi-search.d.ts.map +1 -0
  32. package/dist/multi-search.js +42 -0
  33. package/dist/query-builder.d.ts +12 -0
  34. package/dist/query-builder.d.ts.map +1 -0
  35. package/dist/query-builder.js +396 -0
  36. package/dist/suggester-types.d.ts +130 -0
  37. package/dist/suggester-types.d.ts.map +1 -0
  38. package/dist/suggester-types.js +6 -0
  39. package/dist/suggester.d.ts +21 -0
  40. package/dist/suggester.d.ts.map +1 -0
  41. package/dist/suggester.js +55 -0
  42. package/dist/types.d.ts +378 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +6 -0
  45. package/dist/vector-types.d.ts +42 -0
  46. package/dist/vector-types.d.ts.map +1 -0
  47. package/dist/vector-types.js +6 -0
  48. package/package.json +69 -0
@@ -0,0 +1,17 @@
1
+ export type TestDocument = {
2
+ type: string;
3
+ name: string;
4
+ price: number;
5
+ size: number;
6
+ };
7
+ export type Request = {
8
+ method?: 'POST' | 'PUT' | 'DELETE';
9
+ path?: string;
10
+ body?: any;
11
+ };
12
+ export declare function esRequest({ method, path, body }: Request): Promise<any>;
13
+ export declare function createIndex(): Promise<void>;
14
+ export declare function indexDocuments(): Promise<void>;
15
+ export declare function refreshIndex(): Promise<void>;
16
+ export declare function deleteIndex(): Promise<void>;
17
+ //# sourceMappingURL=elastic.helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elastic.helpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/elastic.helpers.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAQF,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,wBAAsB,SAAS,CAAC,EAC9B,MAAe,EACf,IAAS,EACT,IAAI,EACL,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CASxB;AAED,wBAAsB,WAAW,kBAEhC;AAED,wBAAsB,cAAc,kBAInC;AAED,wBAAsB,YAAY,kBAEjC;AAED,wBAAsB,WAAW,kBAEhC"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.esRequest = esRequest;
4
+ exports.createIndex = createIndex;
5
+ exports.indexDocuments = indexDocuments;
6
+ exports.refreshIndex = refreshIndex;
7
+ exports.deleteIndex = deleteIndex;
8
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
+ const ES_URL = process.env.ELASTICSEARCH_URL || 'http://localhost:9200';
10
+ const INDEX_NAME = 'test-index';
11
+ const mappings = {
12
+ properties: {
13
+ type: { type: 'keyword' }, // exact, term-level queries
14
+ name: { type: 'text' }, // tokenizes for partial match
15
+ price: { type: 'integer' },
16
+ size: { type: 'integer' }
17
+ }
18
+ };
19
+ const docs = [
20
+ { type: 'condo', name: 'Beach condo', price: 1_000_000, size: 1000 },
21
+ { type: 'co-op', name: 'City co-op', price: 2_000_000, size: 2000 },
22
+ { type: 'house', name: 'City house', price: 3_000_000, size: 3000 }
23
+ ];
24
+ async function esRequest({ method = 'POST', path = '', body }) {
25
+ const fetchPath = `${ES_URL}/${INDEX_NAME}${path}`;
26
+ const response = await fetch(fetchPath, {
27
+ method,
28
+ headers: { 'Content-Type': 'application/json' },
29
+ ...(body && { body: JSON.stringify(body) })
30
+ });
31
+ return response.json();
32
+ }
33
+ async function createIndex() {
34
+ await esRequest({ method: 'PUT', body: { mappings } });
35
+ }
36
+ async function indexDocuments() {
37
+ for (const doc of docs) {
38
+ await esRequest({ path: '/_doc', body: doc });
39
+ }
40
+ }
41
+ async function refreshIndex() {
42
+ await esRequest({ path: '/_refresh' });
43
+ }
44
+ async function deleteIndex() {
45
+ await esRequest({ method: 'DELETE' });
46
+ }
@@ -0,0 +1,4 @@
1
+ import { AggregationBuilder, AggregationState } from './aggregation-types';
2
+ export declare const createAggregationBuilder: <T>(state?: AggregationState) => AggregationBuilder<T>;
3
+ export declare const aggregations: <T>() => AggregationBuilder<T>;
4
+ //# sourceMappingURL=aggregation-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregation-builder.d.ts","sourceRoot":"","sources":["../src/aggregation-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAajB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,QAAO,gBAAqB,KAC3B,kBAAkB,CAAC,CAAC,CAiMrB,CAAC;AAGH,eAAO,MAAM,YAAY,GAAI,CAAC,4BAAoC,CAAC"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aggregations = exports.createAggregationBuilder = void 0;
4
+ const createAggregationBuilder = (state = {}) => ({
5
+ // Bucket aggregations
6
+ terms: (name, field, options) => {
7
+ const aggregations = { ...state };
8
+ aggregations[name] = {
9
+ terms: {
10
+ field: String(field),
11
+ ...(options && Object.keys(options).length > 0 ? options : {})
12
+ }
13
+ };
14
+ return (0, exports.createAggregationBuilder)(aggregations);
15
+ },
16
+ dateHistogram: (name, field, options) => {
17
+ const aggregations = { ...state };
18
+ aggregations[name] = {
19
+ date_histogram: {
20
+ field: String(field),
21
+ ...options
22
+ }
23
+ };
24
+ return (0, exports.createAggregationBuilder)(aggregations);
25
+ },
26
+ range: (name, field, options) => {
27
+ const aggregations = { ...state };
28
+ aggregations[name] = {
29
+ range: {
30
+ field: String(field),
31
+ ranges: options.ranges
32
+ }
33
+ };
34
+ return (0, exports.createAggregationBuilder)(aggregations);
35
+ },
36
+ histogram: (name, field, options) => {
37
+ const aggregations = { ...state };
38
+ aggregations[name] = {
39
+ histogram: {
40
+ field: String(field),
41
+ ...options
42
+ }
43
+ };
44
+ return (0, exports.createAggregationBuilder)(aggregations);
45
+ },
46
+ // Metric aggregations
47
+ avg: (name, field, options) => {
48
+ const aggregations = { ...state };
49
+ aggregations[name] = {
50
+ avg: {
51
+ field: String(field),
52
+ ...(options && Object.keys(options).length > 0 ? options : {})
53
+ }
54
+ };
55
+ return (0, exports.createAggregationBuilder)(aggregations);
56
+ },
57
+ sum: (name, field, options) => {
58
+ const aggregations = { ...state };
59
+ aggregations[name] = {
60
+ sum: {
61
+ field: String(field),
62
+ ...(options && Object.keys(options).length > 0 ? options : {})
63
+ }
64
+ };
65
+ return (0, exports.createAggregationBuilder)(aggregations);
66
+ },
67
+ min: (name, field, options) => {
68
+ const aggregations = { ...state };
69
+ aggregations[name] = {
70
+ min: {
71
+ field: String(field),
72
+ ...(options && Object.keys(options).length > 0 ? options : {})
73
+ }
74
+ };
75
+ return (0, exports.createAggregationBuilder)(aggregations);
76
+ },
77
+ max: (name, field, options) => {
78
+ const aggregations = { ...state };
79
+ aggregations[name] = {
80
+ max: {
81
+ field: String(field),
82
+ ...(options && Object.keys(options).length > 0 ? options : {})
83
+ }
84
+ };
85
+ return (0, exports.createAggregationBuilder)(aggregations);
86
+ },
87
+ cardinality: (name, field, options) => {
88
+ const aggregations = { ...state };
89
+ aggregations[name] = {
90
+ cardinality: {
91
+ field: String(field),
92
+ ...(options && Object.keys(options).length > 0 ? options : {})
93
+ }
94
+ };
95
+ return (0, exports.createAggregationBuilder)(aggregations);
96
+ },
97
+ percentiles: (name, field, options) => {
98
+ const aggregations = { ...state };
99
+ aggregations[name] = {
100
+ percentiles: {
101
+ field: String(field),
102
+ ...(options && Object.keys(options).length > 0 ? options : {})
103
+ }
104
+ };
105
+ return (0, exports.createAggregationBuilder)(aggregations);
106
+ },
107
+ stats: (name, field, options) => {
108
+ const aggregations = { ...state };
109
+ aggregations[name] = {
110
+ stats: {
111
+ field: String(field),
112
+ ...(options && Object.keys(options).length > 0 ? options : {})
113
+ }
114
+ };
115
+ return (0, exports.createAggregationBuilder)(aggregations);
116
+ },
117
+ valueCount: (name, field, options) => {
118
+ const aggregations = { ...state };
119
+ aggregations[name] = {
120
+ value_count: {
121
+ field: String(field),
122
+ ...(options && Object.keys(options).length > 0 ? options : {})
123
+ }
124
+ };
125
+ return (0, exports.createAggregationBuilder)(aggregations);
126
+ },
127
+ // Sub-aggregations
128
+ subAgg: (fn) => {
129
+ // Get the last aggregation added
130
+ const keys = Object.keys(state);
131
+ if (keys.length === 0) {
132
+ throw new Error('No aggregation to add sub-aggregation to');
133
+ }
134
+ const lastKey = keys[keys.length - 1];
135
+ const lastAgg = state[lastKey];
136
+ // Apply sub-aggregations
137
+ const subAggs = fn((0, exports.createAggregationBuilder)({})).build();
138
+ const updatedState = {
139
+ ...state,
140
+ [lastKey]: {
141
+ ...lastAgg,
142
+ aggs: subAggs
143
+ }
144
+ };
145
+ return (0, exports.createAggregationBuilder)(updatedState);
146
+ },
147
+ // Build
148
+ build: () => state
149
+ });
150
+ exports.createAggregationBuilder = createAggregationBuilder;
151
+ // Helper function to create aggregations without needing to import the builder
152
+ const aggregations = () => (0, exports.createAggregationBuilder)();
153
+ exports.aggregations = aggregations;
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Type definitions for Aggregations
3
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
4
+ */
5
+ /**
6
+ * Options for terms aggregation
7
+ */
8
+ export type TermsAggOptions = {
9
+ /** Maximum number of buckets to return */
10
+ size?: number;
11
+ /** Minimum document count per bucket */
12
+ min_doc_count?: number;
13
+ /** Sort order for buckets */
14
+ order?: {
15
+ [key: string]: 'asc' | 'desc';
16
+ };
17
+ /** Default value for missing fields */
18
+ missing?: string;
19
+ };
20
+ /**
21
+ * Date histogram interval units
22
+ */
23
+ export type DateHistogramInterval = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
24
+ /**
25
+ * Options for date_histogram aggregation
26
+ */
27
+ export type DateHistogramAggOptions = {
28
+ /** Time interval for buckets */
29
+ interval: string | DateHistogramInterval;
30
+ /** Minimum document count per bucket */
31
+ min_doc_count?: number;
32
+ /** Sort order for buckets */
33
+ order?: {
34
+ [key: string]: 'asc' | 'desc';
35
+ };
36
+ /** Extend bucket range beyond data */
37
+ extended_bounds?: {
38
+ min?: number | string;
39
+ max?: number | string;
40
+ };
41
+ /** Time zone for date calculations */
42
+ time_zone?: string;
43
+ };
44
+ /**
45
+ * Options for range aggregation
46
+ */
47
+ export type RangeAggOptions = {
48
+ /** Range definitions */
49
+ ranges: Array<{
50
+ from?: number | string;
51
+ to?: number | string;
52
+ key?: string;
53
+ }>;
54
+ };
55
+ /**
56
+ * Options for histogram aggregation
57
+ */
58
+ export type HistogramAggOptions = {
59
+ /** Numeric interval for buckets */
60
+ interval: number;
61
+ /** Minimum document count per bucket */
62
+ min_doc_count?: number;
63
+ /** Sort order for buckets */
64
+ order?: {
65
+ [key: string]: 'asc' | 'desc';
66
+ };
67
+ /** Extend bucket range beyond data */
68
+ extended_bounds?: {
69
+ min?: number;
70
+ max?: number;
71
+ };
72
+ };
73
+ /**
74
+ * Options for avg aggregation
75
+ */
76
+ export type AvgAggOptions = {
77
+ /** Default value for missing fields */
78
+ missing?: number;
79
+ };
80
+ /**
81
+ * Options for sum aggregation
82
+ */
83
+ export type SumAggOptions = {
84
+ /** Default value for missing fields */
85
+ missing?: number;
86
+ };
87
+ /**
88
+ * Options for min aggregation
89
+ */
90
+ export type MinAggOptions = {
91
+ /** Default value for missing fields */
92
+ missing?: number;
93
+ };
94
+ /**
95
+ * Options for max aggregation
96
+ */
97
+ export type MaxAggOptions = {
98
+ /** Default value for missing fields */
99
+ missing?: number;
100
+ };
101
+ /**
102
+ * Options for cardinality aggregation
103
+ */
104
+ export type CardinalityAggOptions = {
105
+ /** Precision threshold for accuracy */
106
+ precision_threshold?: number;
107
+ /** Default value for missing fields */
108
+ missing?: any;
109
+ };
110
+ /**
111
+ * Options for percentiles aggregation
112
+ */
113
+ export type PercentilesAggOptions = {
114
+ /** Percentile values to calculate */
115
+ percents?: number[];
116
+ /** Return as object (true) or array (false) */
117
+ keyed?: boolean;
118
+ /** Default value for missing fields */
119
+ missing?: number;
120
+ };
121
+ /**
122
+ * Options for stats aggregation
123
+ */
124
+ export type StatsAggOptions = {
125
+ /** Default value for missing fields */
126
+ missing?: number;
127
+ };
128
+ /**
129
+ * Options for value_count aggregation
130
+ */
131
+ export type ValueCountAggOptions = {
132
+ /** Default value for missing fields */
133
+ missing?: any;
134
+ };
135
+ /**
136
+ * Aggregation state for build output
137
+ */
138
+ export type AggregationState = {
139
+ [key: string]: any;
140
+ };
141
+ /**
142
+ * Aggregation builder interface
143
+ */
144
+ export type AggregationBuilder<T> = {
145
+ /** Terms aggregation - group by field values */
146
+ terms: <K extends keyof T>(name: string, field: K, options?: TermsAggOptions) => AggregationBuilder<T>;
147
+ /** Date histogram aggregation - group by time intervals */
148
+ dateHistogram: <K extends keyof T>(name: string, field: K, options: DateHistogramAggOptions) => AggregationBuilder<T>;
149
+ /** Range aggregation - group by numeric/date ranges */
150
+ range: <K extends keyof T>(name: string, field: K, options: RangeAggOptions) => AggregationBuilder<T>;
151
+ /** Histogram aggregation - group by numeric intervals */
152
+ histogram: <K extends keyof T>(name: string, field: K, options: HistogramAggOptions) => AggregationBuilder<T>;
153
+ /** Average aggregation */
154
+ avg: <K extends keyof T>(name: string, field: K, options?: AvgAggOptions) => AggregationBuilder<T>;
155
+ /** Sum aggregation */
156
+ sum: <K extends keyof T>(name: string, field: K, options?: SumAggOptions) => AggregationBuilder<T>;
157
+ /** Minimum value aggregation */
158
+ min: <K extends keyof T>(name: string, field: K, options?: MinAggOptions) => AggregationBuilder<T>;
159
+ /** Maximum value aggregation */
160
+ max: <K extends keyof T>(name: string, field: K, options?: MaxAggOptions) => AggregationBuilder<T>;
161
+ /** Cardinality aggregation - count unique values */
162
+ cardinality: <K extends keyof T>(name: string, field: K, options?: CardinalityAggOptions) => AggregationBuilder<T>;
163
+ /** Percentiles aggregation */
164
+ percentiles: <K extends keyof T>(name: string, field: K, options?: PercentilesAggOptions) => AggregationBuilder<T>;
165
+ /** Statistics aggregation (count, min, max, avg, sum) */
166
+ stats: <K extends keyof T>(name: string, field: K, options?: StatsAggOptions) => AggregationBuilder<T>;
167
+ /** Value count aggregation */
168
+ valueCount: <K extends keyof T>(name: string, field: K, options?: ValueCountAggOptions) => AggregationBuilder<T>;
169
+ /** Add sub-aggregation to parent bucket aggregation */
170
+ subAgg: (fn: (agg: AggregationBuilder<T>) => AggregationBuilder<T>) => AggregationBuilder<T>;
171
+ /** Build aggregation DSL */
172
+ build: () => AggregationState;
173
+ };
174
+ /**
175
+ * Geo distance options
176
+ */
177
+ export type GeoDistance = {
178
+ /** Distance from center point */
179
+ distance: string | number;
180
+ /** Distance unit */
181
+ unit?: 'mi' | 'km' | 'mm' | 'cm' | 'm' | 'yd' | 'ft' | 'in' | 'nmi';
182
+ };
183
+ /**
184
+ * Geo bounding box coordinates
185
+ */
186
+ export type GeoBoundingBox = {
187
+ /** Top-left corner */
188
+ top_left?: {
189
+ lat: number;
190
+ lon: number;
191
+ };
192
+ /** Bottom-right corner */
193
+ bottom_right?: {
194
+ lat: number;
195
+ lon: number;
196
+ };
197
+ /** Top latitude */
198
+ top?: number;
199
+ /** Left longitude */
200
+ left?: number;
201
+ /** Bottom latitude */
202
+ bottom?: number;
203
+ /** Right longitude */
204
+ right?: number;
205
+ };
206
+ /**
207
+ * Geo polygon vertices
208
+ */
209
+ export type GeoPolygon = {
210
+ /** Polygon points */
211
+ points: Array<{
212
+ lat: number;
213
+ lon: number;
214
+ }>;
215
+ };
216
+ /**
217
+ * Regular expression query options
218
+ */
219
+ export type RegexpOptions = {
220
+ /** Regexp flags */
221
+ flags?: string;
222
+ /** Maximum automaton states */
223
+ max_determinized_states?: number;
224
+ /** Score multiplier */
225
+ boost?: number;
226
+ };
227
+ /**
228
+ * Constant score query options
229
+ */
230
+ export type ConstantScoreOptions = {
231
+ /** Constant score value */
232
+ boost?: number;
233
+ };
234
+ //# sourceMappingURL=aggregation-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aggregation-types.d.ts","sourceRoot":"","sources":["../src/aggregation-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,0CAA0C;IAC1C,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,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for Aggregations
4
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Type definitions for Bulk API
3
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
4
+ */
5
+ import { ScriptOptions } from './types';
6
+ /**
7
+ * Metadata for bulk index operation
8
+ */
9
+ export type BulkIndexMeta = {
10
+ _index?: string;
11
+ _id?: string;
12
+ routing?: string;
13
+ version?: number;
14
+ version_type?: 'internal' | 'external' | 'external_gte';
15
+ };
16
+ /**
17
+ * Metadata for bulk create operation
18
+ */
19
+ export type BulkCreateMeta = {
20
+ _index?: string;
21
+ _id?: string;
22
+ routing?: string;
23
+ };
24
+ /**
25
+ * Metadata for bulk update operation
26
+ */
27
+ export type BulkUpdateMeta<T> = {
28
+ _index?: string;
29
+ _id: string;
30
+ routing?: string;
31
+ retry_on_conflict?: number;
32
+ /** Partial document update */
33
+ doc?: Partial<T>;
34
+ /** Insert document if it doesn't exist */
35
+ doc_as_upsert?: boolean;
36
+ /** Script-based update */
37
+ script?: ScriptOptions;
38
+ /** Document to insert if not exists */
39
+ upsert?: T;
40
+ };
41
+ /**
42
+ * Metadata for bulk delete operation
43
+ */
44
+ export type BulkDeleteMeta = {
45
+ _index?: string;
46
+ _id: string;
47
+ routing?: string;
48
+ version?: number;
49
+ };
50
+ /**
51
+ * Bulk operations builder interface
52
+ */
53
+ export type BulkBuilder<T> = {
54
+ /** Index a document (create or replace) */
55
+ index: (doc: T, meta?: BulkIndexMeta) => BulkBuilder<T>;
56
+ /** Create a new document (fails if already exists) */
57
+ create: (doc: T, meta?: BulkCreateMeta) => BulkBuilder<T>;
58
+ /** Update an existing document */
59
+ update: (meta: BulkUpdateMeta<T>) => BulkBuilder<T>;
60
+ /** Delete a document */
61
+ delete: (meta: BulkDeleteMeta) => BulkBuilder<T>;
62
+ /** Build as NDJSON string format for Elasticsearch */
63
+ build: () => string;
64
+ /** Build as array of objects */
65
+ buildArray: () => any[];
66
+ };
67
+ //# sourceMappingURL=bulk-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-types.d.ts","sourceRoot":"","sources":["../src/bulk-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8BAA8B;IAC9B,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACjB,0CAA0C;IAC1C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0BAA0B;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,uCAAuC;IACvC,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,2CAA2C;IAC3C,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,aAAa,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACxD,sDAAsD;IACtD,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1D,kCAAkC;IAClC,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACpD,wBAAwB;IACxB,MAAM,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC;IACjD,sDAAsD;IACtD,KAAK,EAAE,MAAM,MAAM,CAAC;IACpB,gCAAgC;IAEhC,UAAU,EAAE,MAAM,GAAG,EAAE,CAAC;CACzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for Bulk API
4
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/bulk.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Bulk API builder
3
+ * Enables batching multiple index/create/update/delete operations
4
+ */
5
+ import { BulkBuilder } from './bulk-types';
6
+ /**
7
+ * Creates a bulk operations builder
8
+ * @returns BulkBuilder instance
9
+ */
10
+ export declare const createBulkBuilder: <T>(operations?: any[]) => BulkBuilder<T>;
11
+ /**
12
+ * Create a new bulk operations builder
13
+ * @example
14
+ * const bulkOp = bulk<Product>()
15
+ * .index({ id: '1', name: 'Product 1' }, { _index: 'products', _id: '1' })
16
+ * .create({ id: '2', name: 'Product 2' }, { _index: 'products', _id: '2' })
17
+ * .update({ _index: 'products', _id: '3', doc: { name: 'Updated' } })
18
+ * .delete({ _index: 'products', _id: '4' })
19
+ * .build();
20
+ */
21
+ export declare const bulk: <T>() => BulkBuilder<T>;
22
+ //# sourceMappingURL=bulk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk.d.ts","sourceRoot":"","sources":["../src/bulk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAEjC,aAAY,GAAG,EAAO,KACrB,WAAW,CAAC,CAAC,CA8Bd,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,qBAA6B,CAAC"}
package/dist/bulk.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Bulk API builder
4
+ * Enables batching multiple index/create/update/delete operations
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.bulk = exports.createBulkBuilder = void 0;
8
+ /**
9
+ * Creates a bulk operations builder
10
+ * @returns BulkBuilder instance
11
+ */
12
+ const createBulkBuilder = (
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ operations = []) => ({
15
+ index: (doc, meta = {}) => {
16
+ return (0, exports.createBulkBuilder)([...operations, { index: meta }, doc]);
17
+ },
18
+ create: (doc, meta = {}) => {
19
+ return (0, exports.createBulkBuilder)([...operations, { create: meta }, doc]);
20
+ },
21
+ update: (meta) => {
22
+ const { doc, script, upsert, doc_as_upsert, ...header } = meta;
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ const updateDoc = {};
25
+ if (doc)
26
+ updateDoc.doc = doc;
27
+ if (script)
28
+ updateDoc.script = script;
29
+ if (upsert)
30
+ updateDoc.upsert = upsert;
31
+ if (doc_as_upsert !== undefined)
32
+ updateDoc.doc_as_upsert = doc_as_upsert;
33
+ return (0, exports.createBulkBuilder)([...operations, { update: header }, updateDoc]);
34
+ },
35
+ delete: (meta) => {
36
+ return (0, exports.createBulkBuilder)([...operations, { delete: meta }]);
37
+ },
38
+ build: () => {
39
+ return operations.map((op) => JSON.stringify(op)).join('\n') + '\n';
40
+ },
41
+ buildArray: () => operations
42
+ });
43
+ exports.createBulkBuilder = createBulkBuilder;
44
+ /**
45
+ * Create a new bulk operations builder
46
+ * @example
47
+ * const bulkOp = bulk<Product>()
48
+ * .index({ id: '1', name: 'Product 1' }, { _index: 'products', _id: '1' })
49
+ * .create({ id: '2', name: 'Product 2' }, { _index: 'products', _id: '2' })
50
+ * .update({ _index: 'products', _id: '3', doc: { name: 'Updated' } })
51
+ * .delete({ _index: 'products', _id: '4' })
52
+ * .build();
53
+ */
54
+ const bulk = () => (0, exports.createBulkBuilder)();
55
+ exports.bulk = bulk;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Index Management builder
3
+ * Create and configure Elasticsearch indices
4
+ */
5
+ import { IndexBuilder, CreateIndexOptions } from './index-types';
6
+ /**
7
+ * Creates an index builder
8
+ * @returns IndexBuilder instance
9
+ */
10
+ export declare const createIndexBuilder: <T>(state?: CreateIndexOptions<T>) => IndexBuilder<T>;
11
+ /**
12
+ * Create a new index builder
13
+ * @example
14
+ * const indexConfig = indexBuilder<Product>()
15
+ * .mappings({
16
+ * properties: {
17
+ * name: { type: 'text' },
18
+ * price: { type: 'float' },
19
+ * category: { type: 'keyword' }
20
+ * }
21
+ * })
22
+ * .settings({
23
+ * number_of_shards: 1,
24
+ * number_of_replicas: 1
25
+ * })
26
+ * .alias('products_alias')
27
+ * .build();
28
+ */
29
+ export declare const indexBuilder: <T>() => IndexBuilder<T>;
30
+ //# sourceMappingURL=index-management.d.ts.map