contensis-management-api
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -6,2 +6,3 @@ import * as Contensis from '../index'; | ||
import { toQuery } from 'contensis-core-api'; | ||
import { FreeTextSearchOperatorTypeEnum } from 'contensis-core-api/lib/models/search/FreeTextSearchOperatorType'; | ||
const Zengenti = { Contensis }; | ||
@@ -263,3 +264,3 @@ const global = window || this; | ||
}); | ||
it('with query as Query instance for distanceWithin operator', async () => { | ||
it('with query as Query instance distanceWithin operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
@@ -295,2 +296,130 @@ let query = new Contensis.Query(Contensis.Op.distanceWithin('authorLocation', 52.377, -2.749, '10mi')); | ||
}); | ||
it('with query as Object for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
...query, | ||
orderBy: JSON.stringify(orderBy), | ||
where: JSON.stringify(where) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Object for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: 'or' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
...query, | ||
orderBy: JSON.stringify(orderBy), | ||
where: JSON.stringify(where) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1')); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: false, | ||
operator: FreeTextSearchOperatorTypeEnum.And | ||
} | ||
}]) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1', true, FreeTextSearchOperatorTypeEnum.Or)); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: FreeTextSearchOperatorTypeEnum.Or | ||
} | ||
}]) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
}); | ||
@@ -297,0 +426,0 @@ describe('Search entries in IE browser', () => { |
@@ -8,2 +8,6 @@ # Changelog | ||
## [2.0.3] - 2021-10-15 | ||
### Added | ||
- added aditional parameters to *freeText* | ||
## [2.0.2] - 2021-08-19 | ||
@@ -10,0 +14,0 @@ ### Added |
@@ -43,2 +43,4 @@ // Karma configuration | ||
browsers: ['Chrome'], | ||
// browserDisconnectTimeout : 0, | ||
// browserNoActivityTimeout : 0, | ||
singleRun: true, | ||
@@ -45,0 +47,0 @@ concurrency: Infinity |
@@ -8,2 +8,3 @@ "use strict"; | ||
const contensis_core_api_1 = require("contensis-core-api"); | ||
const FreeTextSearchOperatorType_1 = require("contensis-core-api/lib/models/search/FreeTextSearchOperatorType"); | ||
const Zengenti = { Contensis }; | ||
@@ -257,3 +258,3 @@ const global = window || this; | ||
}); | ||
it('with query as Query instance for distanceWithin operator', async () => { | ||
it('with query as Query instance distanceWithin operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
@@ -289,2 +290,122 @@ let query = new Contensis.Query(Contensis.Op.distanceWithin('authorLocation', 52.377, -2.749, '10mi')); | ||
}); | ||
it('with query as Object for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = contensis_core_api_1.toQuery(Object.assign({}, query, { orderBy: JSON.stringify(orderBy), where: JSON.stringify(where) })); | ||
expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
specs_utils_spec_1.getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Object for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: 'or' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = contensis_core_api_1.toQuery(Object.assign({}, query, { orderBy: JSON.stringify(orderBy), where: JSON.stringify(where) })); | ||
expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
specs_utils_spec_1.getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1')); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = contensis_core_api_1.toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: false, | ||
operator: FreeTextSearchOperatorType_1.FreeTextSearchOperatorTypeEnum.And | ||
} | ||
}]) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
specs_utils_spec_1.getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(specs_utils_spec_1.getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1', true, FreeTextSearchOperatorType_1.FreeTextSearchOperatorTypeEnum.Or)); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = contensis_core_api_1.toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: FreeTextSearchOperatorType_1.FreeTextSearchOperatorTypeEnum.Or | ||
} | ||
}]) | ||
}); | ||
expect(global.fetch.calls.first().args[0]).toEqual(specs_utils_spec_1.getDefaultAuthenticateUrl()); | ||
expect(global.fetch.calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
specs_utils_spec_1.getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
}); | ||
@@ -291,0 +412,0 @@ describe('Search entries in IE browser', () => { |
{ | ||
"name": "contensis-management-api", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Contensis Javascript Management API", | ||
@@ -55,3 +55,3 @@ "engines": { | ||
"@types/graceful-fs": "^4.1.3", | ||
"contensis-core-api": "^1.0.3", | ||
"contensis-core-api": "1.0.4", | ||
"cross-fetch": "^3.0.6", | ||
@@ -58,0 +58,0 @@ "es6-promise": "^4.2.8", |
@@ -7,2 +7,3 @@ import * as Contensis from '../index'; | ||
import { PagedList, toQuery } from 'contensis-core-api'; | ||
import { FreeTextSearchOperatorTypeEnum } from 'contensis-core-api/lib/models/search/FreeTextSearchOperatorType'; | ||
@@ -333,3 +334,3 @@ const Zengenti = { Contensis }; | ||
it('with query as Query instance for distanceWithin operator', async () => { | ||
it('with query as Query instance distanceWithin operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
@@ -371,2 +372,160 @@ | ||
}); | ||
it('with query as Object for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
...query, | ||
orderBy: JSON.stringify(orderBy), | ||
where: JSON.stringify(where) | ||
}); | ||
expect((global.fetch as any).calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect((global.fetch as any).calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Object for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let orderBy = [{ | ||
asc: 'authorName' | ||
}]; | ||
let where = [{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: 'or' | ||
} | ||
}]; | ||
let query = { | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy, | ||
where | ||
}; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
...query, | ||
orderBy: JSON.stringify(orderBy), | ||
where: JSON.stringify(where) | ||
}); | ||
expect((global.fetch as any).calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect((global.fetch as any).calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText non-fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1')); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: false, | ||
operator: FreeTextSearchOperatorTypeEnum.And | ||
} | ||
}]) | ||
}); | ||
expect((global.fetch as any).calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect((global.fetch as any).calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
it('with query as Query instance for freeText fuzzy operator', async () => { | ||
let client = Zengenti.Contensis.Client.create(getDefaultConfig()); | ||
let query = new Contensis.Query(Contensis.Op.freeText('authorLocation', 'term1', true, FreeTextSearchOperatorTypeEnum.Or)); | ||
query.orderBy = Contensis.OrderBy.asc('authorName'); | ||
query.pageIndex = 1; | ||
query.pageSize = 50; | ||
let entries = await client.entries.search(query); | ||
let expectedQueryString = toQuery({ | ||
pageIndex: 1, | ||
pageSize: 50, | ||
orderBy: JSON.stringify([{ | ||
asc: 'authorName' | ||
}]), | ||
where: JSON.stringify([{ | ||
field: 'authorLocation', | ||
freeText: { | ||
term: 'term1', | ||
fuzzy: true, | ||
operator: FreeTextSearchOperatorTypeEnum.Or | ||
} | ||
}]) | ||
}); | ||
expect((global.fetch as any).calls.first().args[0]).toEqual(getDefaultAuthenticateUrl()); | ||
expect((global.fetch as any).calls.mostRecent().args).toEqual([ | ||
`http://my-website.com/api/management/projects/myProject/entries/search${expectedQueryString}`, | ||
getDefaultFetchRequest() | ||
]); | ||
expect(entries).not.toBeNull(); | ||
expect(entries.items.length).toEqual(2); | ||
expect(entries.items[1].title).toEqual('entry2'); | ||
}); | ||
}); | ||
@@ -373,0 +532,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
690174
14967
+ Addedcontensis-core-api@1.0.4(transitive)
- Removedcontensis-core-api@1.1.2(transitive)
Updatedcontensis-core-api@1.0.4