diff --git a/.c8rc.json b/.c8rc.json index bf33ca5..26e0c43 100644 --- a/.c8rc.json +++ b/.c8rc.json @@ -5,7 +5,8 @@ "exclude": [ "**/*.cjs", "coverage/", - "docs/" + "docs/", + "types/" ], "reporter": [ "text", diff --git a/docs/global.html b/docs/global.html index e16e368..00bed00 100644 --- a/docs/global.html +++ b/docs/global.html @@ -492,7 +492,7 @@
Type:

diff --git a/docs/index.html b/docs/index.html index ea31050..60910e9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -152,7 +152,7 @@

Available Query Operations


diff --git a/docs/index.js.html b/docs/index.js.html index 982b71b..345726a 100644 --- a/docs/index.js.html +++ b/docs/index.js.html @@ -86,7 +86,7 @@

index.js


diff --git a/package-lock.json b/package-lock.json index 00e4ed7..a5b535e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,8 @@ "jsdoc": "^4.0.2", "mocha": "^10.2.0", "rollup": "^4.6.1", - "semantic-release": "^22.0.10" + "semantic-release": "^22.0.10", + "typescript": "^5.3.3" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -9235,8 +9236,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, - "optional": true, - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/package.json b/package.json index 18da7da..31c9ca3 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0", "description": "Firestore query operators helper", "main": "index.js", + "types": "types/index.d.ts", "type": "module", "exports": { "import": "./index.js", @@ -13,7 +14,10 @@ "pretest": "npm run lint", "test": "c8 mocha ./tests/index.spec.js", "buildcjs": "npx rollup ./index.js --file ./index.cjs --format cjs", - "build": "npm run buildcjs && npm run document", + "build": "npm run buildcjs", + "postbuild": "npm run buildtypes", + "buildtypes": "tsc", + "postbuildtypes": "npm run document", "document": "jsdoc ./index.js -c .jsdoc.json -d ./docs -R README.md -p", "commit": "git-cz" }, @@ -59,7 +63,8 @@ "jsdoc": "^4.0.2", "mocha": "^10.2.0", "rollup": "^4.6.1", - "semantic-release": "^22.0.10" + "semantic-release": "^22.0.10", + "typescript": "^5.3.3" }, "config": { "commitizen": { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0bf2d87 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./types" + }, + "include": ["./index.js"] + } + \ No newline at end of file diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..e2415f4 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,72 @@ +/** + * Collection of query operators for Firestore queries. + */ +export type QueryOperators = { + /** + * - Represents the less than operator (`<`). + */ + lessThan: string; + /** + * - Represents the less than or equal to operator (`<=`). + */ + lessThanOrEqualTo: string; + /** + * - Represents the equal to operator (`==`). + */ + equalTo: string; + /** + * - Represents the greater than operator (`>`). + */ + greaterThan: string; + /** + * - Represents the greater than or equal to operator (`>=`). + */ + greaterThanOrEqualTo: string; + /** + * - Represents the not equal to operator (`!=`). + */ + notEqualTo: string; + /** + * - Represents the array contains operator (`array-contains`). + */ + arrayContains: string; + /** + * - Represents the array contains any operator (`array-contains-any`). + */ + arrayContainsAny: string; + /** + * - Represents the "in" operator (`in`). + */ + in: string; + /** + * - Represents the not in operator (`not-in`). + */ + notIn: string; +}; +/** + * Collection of query operators for Firestore queries. + * + * @typedef {Object} QueryOperators + * @property {string} lessThan - Represents the less than operator (`<`). + * @property {string} lessThanOrEqualTo - Represents the less than or equal to operator (`<=`). + * @property {string} equalTo - Represents the equal to operator (`==`). + * @property {string} greaterThan - Represents the greater than operator (`>`). + * @property {string} greaterThanOrEqualTo - Represents the greater than or equal to operator (`>=`). + * @property {string} notEqualTo - Represents the not equal to operator (`!=`). + * @property {string} arrayContains - Represents the array contains operator (`array-contains`). + * @property {string} arrayContainsAny - Represents the array contains any operator (`array-contains-any`). + * @property {string} in - Represents the "in" operator (`in`). + * @property {string} notIn - Represents the not in operator (`not-in`). + */ +export const QueryOperators: Readonly<{ + lessThan: "<"; + lessThanOrEqualTo: "<="; + equalTo: "=="; + greaterThan: ">"; + greaterThanOrEqualTo: ">="; + notEqualTo: "!="; + arrayContains: "array-contains"; + arrayContainsAny: "array-contains-any"; + in: "in"; + notIn: "not-in"; +}>;