Skip to content

Commit 699e601

Browse files
chore: project structure refactoring
1 parent 5a36444 commit 699e601

32 files changed

+172
-46
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```typescript
2+
import { IsString } from 'class-validator'
3+
import { Catalog } from 'nestjs/decorators'
4+
5+
@Catalog('example-catalog-name')
6+
export class ExampleDocument {
7+
@IsString()
8+
readonly field: string
9+
}
10+
```

src/nestjs/examples/registering-elasticsearch-module.ts renamed to docs/registering-elasticsearch-module.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
2+
```typescript
13
import { Module } from '@nestjs/common'
2-
import { ElasticsearchModule } from '..'
4+
import { ElasticsearchModule } from '../src/nestjs'
35
import { ExampleDocument } from './document'
46

57
@Module({
@@ -19,4 +21,5 @@ import { ExampleDocument } from './document'
1921
])
2022
]
2123
})
22-
export class AppModule {}
24+
export class AppModule {}
25+
```

src/lib/aggregations/get-avg.aggregation.spec.ts renamed to src/lib/aggregations/get-avg.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe } from 'node:test'
2-
import { ExampleDocument } from 'nestjs/examples'
3-
import { getAvgAggregation } from './get-avg.aggregation'
2+
import { ExampleCatalogDocument } from 'test/module'
3+
import { getAvgAggregation } from './get-avg'
44

55
describe('getAvgAggregation', () => {
66
it('accepts only schema fields', () => {
7-
const query = getAvgAggregation<ExampleDocument>('field')
7+
const query = getAvgAggregation<ExampleCatalogDocument>('field')
88

99
expect(query).toEqual({
1010
avg: {
@@ -14,7 +14,7 @@ describe('getAvgAggregation', () => {
1414
})
1515

1616
it('accepts only schema fields with keyword', () => {
17-
const query = getAvgAggregation<ExampleDocument>('field.keyword')
17+
const query = getAvgAggregation<ExampleCatalogDocument>('field.keyword')
1818

1919
expect(query).toEqual({
2020
avg: {
File renamed without changes.

src/lib/aggregations/get-sum.aggregation.spec.ts renamed to src/lib/aggregations/get-sum.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe } from 'node:test'
2-
import { ExampleDocument } from 'nestjs/examples'
3-
import { getSumAggregation } from './get-sum.aggregation'
2+
import { ExampleCatalogDocument } from 'test/module'
3+
import { getSumAggregation } from './get-sum'
44

55
describe('getSumAggregation', () => {
66
it('accepts only schema fields', () => {
7-
const query = getSumAggregation<ExampleDocument>('field')
7+
const query = getSumAggregation<ExampleCatalogDocument>('field')
88

99
expect(query).toEqual({
1010
sum: {
@@ -14,7 +14,7 @@ describe('getSumAggregation', () => {
1414
})
1515

1616
it('accepts only schema fields with keyword', () => {
17-
const query = getSumAggregation<ExampleDocument>('field.keyword')
17+
const query = getSumAggregation<ExampleCatalogDocument>('field.keyword')
1818

1919
expect(query).toEqual({
2020
sum: {
File renamed without changes.

src/lib/aggregations/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './get-sum.aggregation'
2-
export * from './get-avg.aggregation'
1+
export * from './get-sum'
2+
export * from './get-avg'

src/lib/builders/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './query-builder'

src/lib/builders/query-builder.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Document } from 'lib/types'
2+
import { Catalog } from 'nestjs/injectables'
3+
4+
export class QueryBuilder<TDocument extends Document> {
5+
constructor(
6+
private readonly catalog: Catalog<TDocument>
7+
) {}
8+
}

src/lib/elasticsearch/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './request'
2+
export * from './response'

0 commit comments

Comments
 (0)