Skip to content

Commit

Permalink
wip: output types next to source (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkaron committed Jul 27, 2022
1 parent 5770b7f commit a698bab
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 5 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function _exports(ops: any): Promise<any>;
export = _exports;
4 changes: 4 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import fii = require("./main.js");
import browser = require("./browser.js");
import node = require("./node.js");
export { fii, browser, node };
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fii = require('./main.js')
const browser = require('./browser.js')
const node = require('./node.js')

module.exports = { fii, browser, node }
42 changes: 42 additions & 0 deletions src/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export = main;
/**
* Creates and intializes index
* @param {FiiOptions} [ops] Options
* @returns Promise<Object>
*/
declare function main(ops?: FiiOptions): Promise<any>;
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;
};
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ const makeAFii = ops => {
*/
const main = ops => initStore(ops).then(makeAFii)

module.exports = main
module.exports = main
2 changes: 2 additions & 0 deletions src/node.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function _exports(ops: any): Promise<any>;
export = _exports;
2 changes: 2 additions & 0 deletions src/parseToken.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare function _exports(token: any, availableFields: any): Promise<any>;
export = _exports;
40 changes: 40 additions & 0 deletions src/read.d.ts
Original file line number Diff line number Diff line change
@@ -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<any>;
BUCKETS: (...buckets: any[]) => Promise<any[]>;
CREATED: () => any;
DISTINCT: (...tokens: any[]) => Promise<any[]>;
EXIST: (...ids: any[]) => Promise<any>;
EXPORT: (rangeOps: any) => Promise<any>;
FACETS: (...tokens: any[]) => Promise<any[]>;
FIELDS: () => Promise<any>;
GET: (token: any, pipeline?: (token: any) => Promise<any>) => Promise<any>;
INTERSECTION: (tokens: any, pipeline: any) => Promise<{
_id: any;
_match: any;
}[]>;
LAST_UPDATED: () => any;
MAX: (fieldName: any) => Promise<any>;
MIN: (token: any, reverse: any) => Promise<any>;
OBJECT: (_ids: any) => Promise<any>;
SET_SUBTRACTION: (a: any, b: any) => Promise<any>;
SORT: (results: any) => Promise<any>;
UNION: (tokens: any, pipeline: any) => Promise<{
sumTokensMinusStopwords: number;
union: {
_id: any;
_match: any;
}[];
}>;
parseToken: (token: any) => Promise<any>;
};
export = _exports;
8 changes: 8 additions & 0 deletions src/write.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare function _exports(ops: any): {
DELETE: (_ids: any) => Promise<any>;
IMPORT: (index: any) => any;
PUT: (docs: any, putOptions?: {}) => Promise<any>;
TIMESTAMP_CREATED: () => any;
TIMESTAMP_LAST_UPDATED: (passThrough: any) => any;
};
export = _exports;
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit a698bab

Please sign in to comment.