diff --git a/package.json b/package.json index a031787..b1fc21e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,6 @@ "description": "An inverted index that allows javascript objects to be easily serialised and retrieved using promises and map-reduce", "browser": "src/browser.js", "main": "src/node.js", - "types": "dist/fergies-inverted-index.d.ts", "dependencies": { "browser-level": "^1.0.1", "charwise": "^3.0.1", diff --git a/src/browser.d.ts b/src/browser.d.ts new file mode 100644 index 0000000..a404912 --- /dev/null +++ b/src/browser.d.ts @@ -0,0 +1,2 @@ +declare function _exports(ops: any): Promise; +export = _exports; diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..1e29030 --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,4 @@ +import fii = require("./main.js"); +import browser = require("./browser.js"); +import node = require("./node.js"); +export { fii, browser, node }; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..a2be3d4 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +const fii = require('./main.js') +const browser = require('./browser.js') +const node = require('./node.js') + +module.exports = { fii, browser, node } \ No newline at end of file diff --git a/src/main.d.ts b/src/main.d.ts new file mode 100644 index 0000000..bb0d772 --- /dev/null +++ b/src/main.d.ts @@ -0,0 +1,42 @@ +export = main; +/** + * Creates and intializes index + * @param {FiiOptions} [ops] Options + * @returns Promise + */ +declare function main(ops?: FiiOptions): Promise; +declare namespace main { + export { FiiOptions }; +} +/** + * Fii options + */ +type FiiOptions = { + /** + * Name of `abstract-level` compatible database + */ + name?: string; + /** + * Creates 'comment' spaces in tokens. + * For example using `#` allows tokens like `boom#1.00` to be retrieved by using `boom`. + * If `tokenAppend` wasnt used, then `{gte: 'boom', lte: 'boom'}` would also return stuff like `boomness#1.00` etc + */ + tokenAppend?: string; + /** + * Sets case sensitivity of the index + */ + caseSensitive?: boolean; + /** + * Array of stop words to be stripped using [`stopword`](https://github.com/fergiemcdowall/stopword) + */ + stopwords?: string[]; + /** + * Array of fields not to index + */ + doNotIndexField?: string[]; + storeVectors?: boolean; + /** + * Field used to verify that doc exists + */ + docExistsSpace?: string; +}; diff --git a/src/main.js b/src/main.js index 8c98010..b40bedf 100644 --- a/src/main.js +++ b/src/main.js @@ -114,4 +114,4 @@ const makeAFii = ops => { */ const main = ops => initStore(ops).then(makeAFii) -module.exports = main +module.exports = main \ No newline at end of file diff --git a/src/node.d.ts b/src/node.d.ts new file mode 100644 index 0000000..a404912 --- /dev/null +++ b/src/node.d.ts @@ -0,0 +1,2 @@ +declare function _exports(ops: any): Promise; +export = _exports; diff --git a/src/parseToken.d.ts b/src/parseToken.d.ts new file mode 100644 index 0000000..0e6743a --- /dev/null +++ b/src/parseToken.d.ts @@ -0,0 +1,2 @@ +declare function _exports(token: any, availableFields: any): Promise; +export = _exports; diff --git a/src/read.d.ts b/src/read.d.ts new file mode 100644 index 0000000..be76447 --- /dev/null +++ b/src/read.d.ts @@ -0,0 +1,40 @@ +declare function _exports(ops: any): { + AGGREGATE: ({ BUCKETS, FACETS, QUERY }: { + BUCKETS: any; + FACETS: any; + QUERY: any; + }) => Promise<{ + BUCKETS: any; + FACETS: any; + RESULT: any; + }>; + AGGREGATION_FILTER: (aggregation: any, filterSet: any) => any; + BUCKET: (token: any) => Promise; + BUCKETS: (...buckets: any[]) => Promise; + CREATED: () => any; + DISTINCT: (...tokens: any[]) => Promise; + EXIST: (...ids: any[]) => Promise; + EXPORT: (rangeOps: any) => Promise; + FACETS: (...tokens: any[]) => Promise; + FIELDS: () => Promise; + GET: (token: any, pipeline?: (token: any) => Promise) => Promise; + INTERSECTION: (tokens: any, pipeline: any) => Promise<{ + _id: any; + _match: any; + }[]>; + LAST_UPDATED: () => any; + MAX: (fieldName: any) => Promise; + MIN: (token: any, reverse: any) => Promise; + OBJECT: (_ids: any) => Promise; + SET_SUBTRACTION: (a: any, b: any) => Promise; + SORT: (results: any) => Promise; + UNION: (tokens: any, pipeline: any) => Promise<{ + sumTokensMinusStopwords: number; + union: { + _id: any; + _match: any; + }[]; + }>; + parseToken: (token: any) => Promise; +}; +export = _exports; diff --git a/src/write.d.ts b/src/write.d.ts new file mode 100644 index 0000000..14fc27e --- /dev/null +++ b/src/write.d.ts @@ -0,0 +1,8 @@ +declare function _exports(ops: any): { + DELETE: (_ids: any) => Promise; + IMPORT: (index: any) => any; + PUT: (docs: any, putOptions?: {}) => Promise; + TIMESTAMP_CREATED: () => any; + TIMESTAMP_LAST_UPDATED: (passThrough: any) => any; +}; +export = _exports; diff --git a/tsconfig.json b/tsconfig.json index f73721a..034e3e6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { - "include": ["src/**/*"], + "include": ["src/**/*.js"], + "exclude": ["node_modules"], "compilerOptions": { "allowJs": true, "declaration": true, - "emitDeclarationOnly": true, - "outFile": "dist/fergies-inverted-index.d.ts" + "emitDeclarationOnly": true } }