Skip to content

Commit

Permalink
fix: adding typescript type for this package (#1)
Browse files Browse the repository at this point in the history
* fix: adding typescript type for this package

* Exclude types from coverage

---------

Co-authored-by: Shadi Abu Hilal <[email protected]>
  • Loading branch information
shadiabuhilal and Shadi Abu Hilal authored Jan 24, 2024
1 parent 43a00b6 commit b0bc767
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"exclude": [
"**/*.cjs",
"coverage/",
"docs/"
"docs/",
"types/"
],
"reporter": [
"text",
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ <h5 class="h5-types">Type:</h5>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jan 10 2024 16:50:47 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Jan 23 2024 22:41:40 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <h3>Available Query Operations</h3>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jan 10 2024 16:50:47 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Jan 23 2024 22:41:40 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1 class="page-title">index.js</h1>
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Wed Jan 10 2024 16:50:47 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Jan 23 2024 22:41:40 GMT-0800 (Pacific Standard Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down Expand Up @@ -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": {
Expand Down
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./types"
},
"include": ["./index.js"]
}

72 changes: 72 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -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";
}>;

0 comments on commit b0bc767

Please sign in to comment.