Skip to content

Commit 6b9e354

Browse files
authored
Fixed compiler for node and for browser (#9)
1 parent 9c985c3 commit 6b9e354

File tree

186 files changed

+11103
-8345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

186 files changed

+11103
-8345
lines changed

dist/apisearch.js

+2,004-1,046
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.node.js

-6,994
This file was deleted.

dist/apisearch.node.js.map

-1
This file was deleted.

dist/apisearch.node.min.js

-9
This file was deleted.

dist/apisearch.node.min.js.map

-1
This file was deleted.

lib/Apisearch.d.ts

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { KeyValueCache } from "./Cache/KeyValueCache";
2+
import { Coordinate } from "./Model/Coordinate";
3+
import { ItemUUID } from "./Model/ItemUUID";
4+
import { Query } from "./Query/Query";
5+
import { SortBy } from "./Query/SortBy";
6+
import { Repository } from "./Repository/Repository";
7+
import { Result } from "./Result/Result";
8+
/**
9+
* Apisearch class
10+
*/
11+
export default class Apisearch {
12+
/**
13+
* Constructor
14+
*
15+
* @param config
16+
*
17+
* @returns {Repository}
18+
*/
19+
static createRepository(config: {
20+
app_id: string;
21+
index_id: string;
22+
token: string;
23+
options: {
24+
endpoint?: string;
25+
api_version?: string;
26+
timeout?: number;
27+
override_queries?: boolean;
28+
cache?: KeyValueCache;
29+
};
30+
}): Repository;
31+
/**
32+
* Created located
33+
*
34+
* @param coordinate
35+
* @param queryText
36+
* @param page
37+
* @param size
38+
*
39+
* @returns {Query}
40+
*/
41+
static createQueryLocated(coordinate: Coordinate, queryText: string, page?: number, size?: number): Query;
42+
/**
43+
* Create
44+
*
45+
* @param queryText
46+
* @param page
47+
* @param size
48+
*
49+
* @returns {Query}
50+
*/
51+
static createQuery(queryText: string, page?: number, size?: number): Query;
52+
/**
53+
* Create match all
54+
*
55+
* @return {Query}
56+
*/
57+
static createQueryMatchAll(): Query;
58+
/**
59+
* Create by UUID
60+
*
61+
* @param uuid
62+
*
63+
* @return {Query}
64+
*/
65+
static createQueryByUUID(uuid: ItemUUID): Query;
66+
/**
67+
* Create by UUIDs
68+
*
69+
* @param uuids
70+
*
71+
* @return {Query}
72+
*/
73+
static createQueryByUUIDs(...uuids: ItemUUID[]): Query;
74+
/**
75+
* Create empty result
76+
*
77+
* @return {Result}
78+
*/
79+
static createEmptyResult(): Result;
80+
/**
81+
* Create empty sortby
82+
*
83+
* @return {SortBy}
84+
*/
85+
static createEmptySortBy(): SortBy;
86+
}

lib/Apisearch.js

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
"use strict";
2+
var __assign = (this && this.__assign) || Object.assign || function(t) {
3+
for (var s, i = 1, n = arguments.length; i < n; i++) {
4+
s = arguments[i];
5+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6+
t[p] = s[p];
7+
}
8+
return t;
9+
};
10+
exports.__esModule = true;
11+
var NoCache_1 = require("./Cache/NoCache");
12+
var AxiosClient_1 = require("./Http/AxiosClient");
13+
var RetryMap_1 = require("./Http/RetryMap");
14+
var Query_1 = require("./Query/Query");
15+
var Query_2 = require("./Query/Query");
16+
var Query_3 = require("./Query/Query");
17+
var SortBy_1 = require("./Query/SortBy");
18+
var HttpRepository_1 = require("./Repository/HttpRepository");
19+
var ResultAggregations_1 = require("./Result/ResultAggregations");
20+
var Result_1 = require("./Result/Result");
21+
var Transformer_1 = require("./Transformer/Transformer");
22+
/**
23+
* Apisearch class
24+
*/
25+
var Apisearch = /** @class */ (function () {
26+
function Apisearch() {
27+
}
28+
/**
29+
* Constructor
30+
*
31+
* @param config
32+
*
33+
* @returns {Repository}
34+
*/
35+
Apisearch.createRepository = function (config) {
36+
config.options = __assign({ api_version: "v1", cache: new NoCache_1.NoCache(), timeout: 10000, override_queries: true }, config.options);
37+
/**
38+
* Client
39+
*/
40+
var httpClient = new AxiosClient_1.AxiosClient(config.options.endpoint, config.options.api_version, config.options.timeout, new RetryMap_1.RetryMap(), config.options.override_queries, config.options.cache);
41+
return new HttpRepository_1.HttpRepository(httpClient, config.app_id, config.index_id, config.token, new Transformer_1.Transformer());
42+
};
43+
/**
44+
* Created located
45+
*
46+
* @param coordinate
47+
* @param queryText
48+
* @param page
49+
* @param size
50+
*
51+
* @returns {Query}
52+
*/
53+
Apisearch.createQueryLocated = function (coordinate, queryText, page, size) {
54+
if (page === void 0) { page = Query_2.QUERY_DEFAULT_PAGE; }
55+
if (size === void 0) { size = Query_3.QUERY_DEFAULT_SIZE; }
56+
return Query_1.Query.createLocated(coordinate, queryText, page, size);
57+
};
58+
/**
59+
* Create
60+
*
61+
* @param queryText
62+
* @param page
63+
* @param size
64+
*
65+
* @returns {Query}
66+
*/
67+
Apisearch.createQuery = function (queryText, page, size) {
68+
if (page === void 0) { page = Query_2.QUERY_DEFAULT_PAGE; }
69+
if (size === void 0) { size = Query_3.QUERY_DEFAULT_SIZE; }
70+
return Query_1.Query.create(queryText, page, size);
71+
};
72+
/**
73+
* Create match all
74+
*
75+
* @return {Query}
76+
*/
77+
Apisearch.createQueryMatchAll = function () {
78+
return Query_1.Query.createMatchAll();
79+
};
80+
/**
81+
* Create by UUID
82+
*
83+
* @param uuid
84+
*
85+
* @return {Query}
86+
*/
87+
Apisearch.createQueryByUUID = function (uuid) {
88+
return Query_1.Query.createByUUID(uuid);
89+
};
90+
/**
91+
* Create by UUIDs
92+
*
93+
* @param uuids
94+
*
95+
* @return {Query}
96+
*/
97+
Apisearch.createQueryByUUIDs = function () {
98+
var uuids = [];
99+
for (var _i = 0; _i < arguments.length; _i++) {
100+
uuids[_i] = arguments[_i];
101+
}
102+
return Query_1.Query.createByUUIDs.apply(Query_1.Query, uuids);
103+
};
104+
/**
105+
* Create empty result
106+
*
107+
* @return {Result}
108+
*/
109+
Apisearch.createEmptyResult = function () {
110+
return Result_1.Result.create(Apisearch.createQueryMatchAll(), 0, 0, new ResultAggregations_1.ResultAggregations(0), [], []);
111+
};
112+
/**
113+
* Create empty sortby
114+
*
115+
* @return {SortBy}
116+
*/
117+
Apisearch.createEmptySortBy = function () {
118+
return SortBy_1.SortBy.create();
119+
};
120+
return Apisearch;
121+
}());
122+
exports["default"] = Apisearch;

lib/Cache/InMemoryCache.d.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { KeyValueCache } from "./KeyValueCache";
2+
/**
3+
* Cache class
4+
*/
5+
export declare class InMemoryCache implements KeyValueCache {
6+
private cache;
7+
private size;
8+
/**
9+
* Constructor
10+
*/
11+
constructor();
12+
/**
13+
* Set cache element
14+
*
15+
* @param key
16+
* @param value
17+
*
18+
* @returns {void}
19+
*/
20+
set(key: string, value: any): void;
21+
/**
22+
* Get element from cache
23+
*
24+
* @param key
25+
*
26+
* @returns {any}
27+
*/
28+
get(key: string): any | null;
29+
/**
30+
* Deletes element from cache
31+
*
32+
* @param key
33+
*/
34+
del(key: string): void;
35+
/**
36+
* Clear cache
37+
*/
38+
clear(): void;
39+
}

lib/Cache/InMemoryCache.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"use strict";
2+
var __assign = (this && this.__assign) || Object.assign || function(t) {
3+
for (var s, i = 1, n = arguments.length; i < n; i++) {
4+
s = arguments[i];
5+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6+
t[p] = s[p];
7+
}
8+
return t;
9+
};
10+
exports.__esModule = true;
11+
/**
12+
* Cache class
13+
*/
14+
var InMemoryCache = /** @class */ (function () {
15+
/**
16+
* Constructor
17+
*/
18+
function InMemoryCache() {
19+
this.cache = {};
20+
this.size = 0;
21+
this.cache = {};
22+
this.size = 0;
23+
}
24+
/**
25+
* Set cache element
26+
*
27+
* @param key
28+
* @param value
29+
*
30+
* @returns {void}
31+
*/
32+
InMemoryCache.prototype.set = function (key, value) {
33+
this.cache = __assign({}, this.cache, (_a = {}, _a[key] = value, _a));
34+
this.size = this.size + 1;
35+
var _a;
36+
};
37+
/**
38+
* Get element from cache
39+
*
40+
* @param key
41+
*
42+
* @returns {any}
43+
*/
44+
InMemoryCache.prototype.get = function (key) {
45+
return this.cache[key];
46+
};
47+
/**
48+
* Deletes element from cache
49+
*
50+
* @param key
51+
*/
52+
InMemoryCache.prototype.del = function (key) {
53+
delete this.cache[key];
54+
};
55+
/**
56+
* Clear cache
57+
*/
58+
InMemoryCache.prototype.clear = function () {
59+
this.cache = {};
60+
this.size = 0;
61+
};
62+
return InMemoryCache;
63+
}());
64+
exports.InMemoryCache = InMemoryCache;

lib/Cache/KeyValueCache.d.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Cache class
3+
*/
4+
export interface KeyValueCache {
5+
/**
6+
* Set cache element
7+
*
8+
* @param key
9+
* @param value
10+
*
11+
* @returns {void}
12+
*/
13+
set(key: string, value: any): void;
14+
/**
15+
* Get element from cache
16+
*
17+
* @param key
18+
*
19+
* @returns {any}
20+
*/
21+
get(key: string): any;
22+
/**
23+
* Deletes element from cache
24+
*
25+
* @param key
26+
*/
27+
del(key: string): any;
28+
/**
29+
* Clear cache
30+
*/
31+
clear(): any;
32+
}

lib/Cache/KeyValueCache.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
exports.__esModule = true;

lib/Cache/NoCache.d.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { KeyValueCache } from "./KeyValueCache";
2+
/**
3+
* Cache class
4+
*/
5+
export declare class NoCache implements KeyValueCache {
6+
/**
7+
* Set cache element
8+
*
9+
* @param key
10+
* @param value
11+
*
12+
* @returns {void}
13+
*/
14+
set(key: string, value: any): void;
15+
/**
16+
* Get element from cache
17+
*
18+
* @param key
19+
*
20+
* @returns {any}
21+
*/
22+
get(key: string): any;
23+
/**
24+
* Deletes element from cache
25+
*
26+
* @param key
27+
*/
28+
del(key: string): void;
29+
/**
30+
* Clear cache
31+
*/
32+
clear(): void;
33+
}

0 commit comments

Comments
 (0)