Skip to content

Commit

Permalink
Merge pull request #16 from smartive/feat/change-type-of-analyzer-to-…
Browse files Browse the repository at this point in the history
…string

feat: Change type of `search_analyzer` and `analyzer` to string
  • Loading branch information
petermanser authored Jul 30, 2019
2 parents 9ed1930 + 023a9cc commit b53b361
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 35 deletions.
34 changes: 17 additions & 17 deletions jest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"collectCoverage": true,
"transform": {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testMatch": [
"**/test/**/*.spec.ts"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
"collectCoverage": true,
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testMatch": [
"**/test/**/*.spec.ts"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"json"
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
"@smartive/tslint-config": "^4.0.0",
"@types/jest": "^23.0.0",
"del-cli": "^1.1.0",
"jest": "^22.4.3",
"jest": "^24.8.0",
"semantic-release": "^15.1.5",
"ts-jest": "^23.0.0",
"ts-jest": "^24.0.2",
"tslint": "^5.9.1",
"tslint-config-airbnb": "^5.8.0",
"tsutils": "^2.26.0",
Expand Down
8 changes: 4 additions & 4 deletions src/models/Mapping.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export type SimpleFieldType = 'text' | 'keyword' | 'date' | 'long' | 'double' | 'boolean' | 'ip';
export type SimpleFieldType = 'text' | 'keyword' | 'date' | 'long' | 'integer' | 'double' | 'boolean' | 'ip';
export type ObjectFieldType = 'object' | 'nested';
export type SpecializedFieldType = 'geo_point' | 'geo_shape' | 'completion';

export type Field = {
type?: SimpleFieldType | SpecializedFieldType | Function;
search_analyzer?: 'suggestion_query_analyzer';
analyzer?: 'suggestion_analyzer' | 'default_analyzer';
search_analyzer?: string;
analyzer?: string;
format?: 'date' | 'hour_minute';
};

export type Fields = {
[name: string]: Field,
[name: string]: Field;
};

export type MappingMeta = {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export function generatePropertyDecorator<T>(key: string): (data?: T) => Propert
mapping = {};
setMetadata(target, mapping, key);
}
mapping[name] = data;
mapping[name.toString()] = data;
};
}
3 changes: 3 additions & 0 deletions test/__snapshots__/decorators.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Object {
"b": Object {
"type": [Function],
},
"c": Object {
"type": [Function],
},
"keyword": undefined,
"keywordArray": Object {
"type": [Function],
Expand Down
8 changes: 8 additions & 0 deletions test/__snapshots__/template.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Object {
"dynamic": "strict",
"properties": Object {
"b": Object {
"properties": Object {
"aProperty": Object {
"type": "keyword",
},
},
"type": "object",
},
"c": Object {
"properties": Object {
"aProperty": Object {
"type": "keyword",
Expand Down
5 changes: 2 additions & 3 deletions test/decorators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { getMetadata } from '../src/utils/metadata';
describe('decorators', () => {
describe('EsObject ', () => {
it('generates metadata', () => {

@EsSubMapping()
class Obj {
@EsProperty()
Expand Down Expand Up @@ -43,12 +42,12 @@ describe('decorators', () => {

@EsProperty({ type: 'text' })
text: string;

@EsProperty({ type: Obj })
b: Obj;

@EsProperty({ type: Nested })
b: Nested;
c: Nested;

@EsProperty({ type: WithFields })
withFields: WithFields;
Expand Down
5 changes: 2 additions & 3 deletions test/template.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { buildMappings } from '../src/utils/template';
describe('decorators', () => {
describe('EsObject ', () => {
it('generates metadata', () => {

@EsSubMapping()
class Obj {
@EsProperty()
Expand Down Expand Up @@ -43,12 +42,12 @@ describe('decorators', () => {

@EsProperty({ type: 'text' })
text: string;

@EsProperty({ type: Obj })
b: Obj;

@EsProperty({ type: Nested })
b: Nested;
c: Nested;

@EsProperty({ type: WithFields })
withFields: WithFields;
Expand Down
12 changes: 7 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "./config/tsconfig.base.json",
"compilerOptions": {
"watch": true,
"sourceMap": true
}
"extends": "./config/tsconfig.base.json",
"compilerOptions": {
"strictPropertyInitialization": false,
"experimentalDecorators": true,
"watch": true,
"sourceMap": true
}
}

0 comments on commit b53b361

Please sign in to comment.