feathers-solr
Advanced tools
Comparing version 3.1.0 to 3.1.1-0
@@ -1,5 +0,1 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import http from 'http'; | ||
import https from 'https'; | ||
export interface httpClientOptions { | ||
@@ -20,7 +16,7 @@ hostname: string; | ||
url: string; | ||
requestOptions?: http.RequestOptions | https.RequestOptions; | ||
requestOptions?: RequestInit; | ||
data?: any; | ||
logger?: any; | ||
} | ||
export declare const httpClient: (hostname: string, requestOptions?: http.RequestOptions, logger?: any) => HttpClient; | ||
export declare const httpClient: (hostname: string, requestOptions?: RequestInit, logger?: any) => HttpClient; | ||
export {}; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.httpClient = void 0; | ||
const http_1 = __importDefault(require("http")); | ||
const https_1 = __importDefault(require("https")); | ||
const errors_1 = require("@feathersjs/errors"); | ||
const request = async (options) => { | ||
const { url, data, requestOptions, logger } = options; | ||
const { method } = requestOptions; | ||
const { protocol } = new URL(url); | ||
const transport = protocol === 'https:' ? https_1.default : http_1.default; | ||
logger({ url, data }); | ||
return new Promise((resolve, reject) => { | ||
const request = transport.request(url, { | ||
try { | ||
const response = await fetch(url, { | ||
...requestOptions, | ||
headers: method === 'GET' ? | ||
{ 'Content-Type': 'application/json' } : | ||
{ 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) } | ||
}, (res) => { | ||
if (res.statusCode < 200 || res.statusCode > 299) { | ||
logger({ statusCode: res.statusCode }); | ||
return reject(new Error(`HTTP status code ${res.statusCode}`)); | ||
} | ||
const body = []; | ||
res.on('data', (chunk) => body.push(chunk)); | ||
res.on('end', () => resolve(JSON.parse(Buffer.concat(body).toString('utf8')))); | ||
headers: { | ||
...((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) || {}), | ||
'Content-Type': 'application/json' | ||
}, | ||
body: data ? data : undefined | ||
}); | ||
request.on('error', (err) => { | ||
logger({ err }); | ||
reject(err); | ||
}); | ||
request.on('timeout', () => { | ||
request.destroy(); | ||
logger('timeout'); | ||
reject(new Error('timed out')); | ||
}); | ||
if (data) | ||
request.write(data); | ||
request.end(); | ||
}); | ||
if (!response.ok) { | ||
logger({ statusCode: response.status, statusText: response.statusText }); | ||
const error = new Error(`${response.status} ${response.statusText}`); | ||
error.name = `${response.status}`; | ||
throw (0, errors_1.convert)(error); | ||
} | ||
return response.json(); | ||
} | ||
catch (error) { | ||
logger(error); | ||
throw error; | ||
} | ||
}; | ||
@@ -44,0 +30,0 @@ const httpClient = (hostname, requestOptions = {}, logger = () => { }) => { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.addIds = void 0; | ||
const crypto_1 = require("crypto"); | ||
const addIds = (data, key) => data.map((d) => ({ | ||
...d, | ||
...(!d[key] && { [key]: (0, crypto_1.randomUUID)() }) | ||
...(!d[key] && { [key]: globalThis.crypto.randomUUID() }) | ||
})); | ||
exports.addIds = addIds; | ||
//# sourceMappingURL=addIds.js.map |
@@ -1,1 +0,1 @@ | ||
export declare const convertOperators: (query: any, escapeFn: any, root?: string) => string[]; | ||
export declare const convertOperators: (query: any, escapeFn: any, root?: string) => any; |
@@ -6,14 +6,25 @@ "use strict"; | ||
const lib_1 = require("@feathersjs/commons/lib"); | ||
const convertOperators = (query, escapeFn, root = '') => Array.isArray(query) ? | ||
query.map(q => (0, exports.convertOperators)(q, escapeFn, root)) : | ||
Object.keys(query).map((prop) => prop === '$or' ? | ||
operatorResolver_1.operatorResolver.$or((0, exports.convertOperators)(query[prop], escapeFn)) : | ||
prop === '$and' ? | ||
operatorResolver_1.operatorResolver.$and((0, exports.convertOperators)(query[prop], escapeFn, prop)) : | ||
(prop in operatorResolver_1.operatorResolver) ? | ||
operatorResolver_1.operatorResolver[prop](...Object.values(escapeFn(root, query[prop]))) : | ||
lib_1._.isObject(query[prop]) ? | ||
operatorResolver_1.operatorResolver.$and((0, exports.convertOperators)(query[prop], escapeFn, prop)) : | ||
operatorResolver_1.operatorResolver.$eq(...Object.values(escapeFn(prop, query[prop])))); | ||
const convertOperators = (query, escapeFn, root = '') => { | ||
if (Array.isArray(query)) { | ||
return query.map(q => (0, exports.convertOperators)(q, escapeFn, root)); | ||
} | ||
return Object.keys(query).map((prop) => { | ||
if (prop === '$or') { | ||
return operatorResolver_1.operatorResolver.$or((0, exports.convertOperators)(query[prop], escapeFn)); | ||
} | ||
if (prop === '$and') { | ||
return operatorResolver_1.operatorResolver.$and((0, exports.convertOperators)(query[prop], escapeFn, prop)); | ||
} | ||
if (prop in operatorResolver_1.operatorResolver) { | ||
const values = Object.values(escapeFn(root, query[prop])); | ||
return operatorResolver_1.operatorResolver[prop](...values); | ||
} | ||
if (lib_1._.isObject(query[prop])) { | ||
return operatorResolver_1.operatorResolver.$and((0, exports.convertOperators)(query[prop], escapeFn, prop)); | ||
} | ||
const values = Object.values(escapeFn(prop, query[prop])); | ||
return operatorResolver_1.operatorResolver.$eq(...values); | ||
}); | ||
}; | ||
exports.convertOperators = convertOperators; | ||
//# sourceMappingURL=convertOperators.js.map |
@@ -27,6 +27,4 @@ "use strict"; | ||
`(${value.join(' AND ')})` : | ||
Array.isArray(value[0]) ? | ||
value[0][0] : | ||
value[0] | ||
Array.isArray(value[0]) ? value[0][0] : value[0] | ||
}; | ||
//# sourceMappingURL=operatorResolver.js.map |
{ | ||
"name": "feathers-solr", | ||
"description": "A service plugin for Solr", | ||
"version": "3.1.0", | ||
"version": "3.1.1-0", | ||
"keywords": [ | ||
@@ -47,23 +47,23 @@ "feathers", | ||
"dependencies": { | ||
"@feathersjs/adapter-commons": "5.0.13", | ||
"@feathersjs/commons": "5.0.1", | ||
"@feathersjs/errors": "5.0.13" | ||
"@feathersjs/adapter-commons": "5.0.22", | ||
"@feathersjs/commons": "5.0.22", | ||
"@feathersjs/errors": "5.0.22" | ||
}, | ||
"devDependencies": { | ||
"@feathersjs/adapter-tests": "5.0.1", | ||
"@feathersjs/express": "5.0.1", | ||
"@feathersjs/feathers": "5.0.13", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.10.6", | ||
"@typescript-eslint/eslint-plugin": "^5.57.0", | ||
"@typescript-eslint/parser": "^5.57.0", | ||
"eslint": "^8.36.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"@feathersjs/adapter-tests": "5.0.22", | ||
"@feathersjs/express": "5.0.22", | ||
"@feathersjs/feathers": "5.0.22", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^20.11.19", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"mocha": "^10.2.0", | ||
"mocha": "^10.3.0", | ||
"nyc": "^15.1.0", | ||
"shx": "^0.3.4", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -47,5 +47,5 @@ # feathers-solr | ||
- `updateHandler` (*optional* default: `'/update/json'`) - This params defines the Solr update handler to use. | ||
- `createUUID` (*optional* default: `true`) - This params add aa UUID if not exist on data. Id's generated by `crypto` | ||
- `createUUID` (*optional* default: `true`) - This params add a UUID if not exist on data. Id's generated by `crypto` | ||
- `escapeFn` (*optional* default: `(key: string, value: any) => { key, value }`) - To apply escaping. | ||
- `requestOptions` (*optional* default: `{ timeout: 10 })` - The [options](https://nodejs.org/api/http.html#httprequestoptions-callback) passed to `http.request`. | ||
- `requestOptions` (*optional* `{ signal: AbortSignal.timeout(3000) })` - The [options](https://nodejs.org/api/http.html#httprequestoptions-callback) passed to `http.request`. | ||
@@ -52,0 +52,0 @@ ## Getting Started |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
1
55246
550
2
+ Added@feathersjs/adapter-commons@5.0.22(transitive)
+ Added@feathersjs/commons@5.0.22(transitive)
+ Added@feathersjs/errors@5.0.22(transitive)
- Removed@feathersjs/adapter-commons@5.0.13(transitive)
- Removed@feathersjs/commons@5.0.1(transitive)
- Removed@feathersjs/errors@5.0.13(transitive)
Updated@feathersjs/commons@5.0.22
Updated@feathersjs/errors@5.0.22