-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add DQL support #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pvditto
wants to merge
25
commits into
master
Choose a base branch
from
pv/dql-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8c0091f
Add `useQuery` hook
pvditto 9ab59c9
Add DQL create-react-app example
pvditto f8eeae8
Add tests
pvditto dc6d1a8
Add `useExecuteQuery` hook
pvditto ecedec8
Update `useQuery` to use generics
pvditto 2074928
Update useQuery error type
pvditto d4d2ee2
Add `test:watch` command
pvditto 7b63f57
Cleanup
pvditto 9fd3db8
Update required Ditto version
pvditto 83365d8
Reenable lazy provider test
pvditto 46cd116
Fix query arguments merging
pvditto 62c6d85
Fix deep comparison on query arguments
pvditto d987ae4
WIP update example app
pvditto e44c0b2
Merge master and resolve yarn.lock conflict
pvditto c70b70a
Rename existing example
pvditto 422facc
Add DQL support with useQuery and useExecuteQuery hooks
pvditto 4f8ab98
fix: update authentication method to use login instead of loginWithToken
pvditto 8f96228
Update Ditto API usage
pvditto f1daedb
docs: update README to include Ditto authentication setup and usage i…
pvditto 2e46db6
Update logo
pvditto b61f241
Add comment
pvditto ea17e85
Clean up
pvditto 13749e7
Fix CI workflow: build main package before examples
pvditto ec46d04
Update quick start instructions for DQL
pvditto 522cf15
Update README to use DQL hooks (useQuery and useExecuteQuery) instead…
pvditto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# editors | ||
.idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Getting Started with Vite | ||
|
||
This project was bootstrapped with [Vite](https://vite.dev/). | ||
|
||
## Available Scripts | ||
|
||
**Note: on newer versions of Node, you may run into `ERR_OSSL_EVP_UNSUPPORTED` errors. You may pass the command-line option of `--openssl-legacy-provider` to work around this. Refer to [Node v17 release notes](https://nodejs.org/es/blog/release/v17.0.0/#openssl-3-0).** | ||
|
||
In the project directory, you can run: | ||
|
||
### `yarn dev` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
|
||
### `yarn test` | ||
|
||
Launches the test runner in the interactive watch mode. | ||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the `dist` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
### `yarn type-check` | ||
|
||
Runs the TypeScript type checker | ||
|
||
### `yarn lint` | ||
|
||
Runs `eslint` to find and fix any configured linting issues | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Vite documentation](https://vite.dev/guide/). | ||
|
||
To learn React, check out the [React documentation](https://react.dev/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
[ | ||
"@babel/preset-react", | ||
{ | ||
"runtime": "automatic" | ||
} | ||
], | ||
"@babel/preset-typescript" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import pluginJs from '@eslint/js' | ||
import prettierPlugin from 'eslint-plugin-prettier/recommended' | ||
import pluginReact from 'eslint-plugin-react' | ||
import pluginReactHooks from 'eslint-plugin-react-hooks' | ||
import simpleImportSort from 'eslint-plugin-simple-import-sort' | ||
import keySort from 'eslint-plugin-sort-keys-fix' | ||
import globals from 'globals' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default [ | ||
{ | ||
ignores: ['**/dist/*', '**/target/**'], | ||
}, | ||
{ | ||
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'], | ||
plugins: { | ||
'simple-import-sort': simpleImportSort, | ||
react: pluginReact, | ||
'react-hooks': pluginReactHooks, | ||
'sort-keys-fix': keySort, | ||
}, | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
}, | ||
rules: { | ||
'no-console': ['error', { allow: ['warn', 'error'] }], | ||
'simple-import-sort/imports': 'error', | ||
'simple-import-sort/exports': 'error', | ||
'sort-imports': 'off', | ||
semi: 0, | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
semi: false, | ||
}, | ||
], | ||
...pluginReactHooks.configs.recommended.rules, | ||
}, | ||
}, | ||
{ languageOptions: { globals: globals.node } }, | ||
{ languageOptions: { globals: globals.browser } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
prettierPlugin, | ||
pluginReact.configs.flat.recommended, | ||
pluginReact.configs.flat['jsx-runtime'], | ||
{ | ||
files: ['**/*.test.{ts,tsx}', '**/__tests__/**'], | ||
languageOptions: { globals: globals.jest }, | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.config.js'], | ||
rules: { | ||
'@typescript-eslint/no-require-imports': 'off', | ||
}, | ||
}, | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="apple-touch-icon" href="/logo192.png" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
<title>Ditto + Vite + React</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Config } from 'jest' | ||
|
||
export default { | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
'\\.css$': 'identity-obj-proxy', | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
modulePathIgnorePatterns: ['<rootDir>/dist/'], | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.tsx?$': 'babel-jest', | ||
}, | ||
} satisfies Config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// allows you to do things like: | ||
// expect(element).toHaveTextContent(/react/i) | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom' | ||
|
||
// JSDom, which is used by @testing-library/react, doesn't support TextEncoder and TextDecoder, | ||
// even though they have broad support in modern browsers. This polyfill adds them to the global | ||
// object so that they can be used by @dittolive/ditto. | ||
// cf. https://github.com/jsdom/jsdom/issues/2524 | ||
import { TextDecoder, TextEncoder } from 'util' | ||
global.TextEncoder = TextEncoder | ||
// @ts-expect-error: The type mismatch is acceptable | ||
global.TextDecoder = TextDecoder |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth having a note about type coercion here? I know it is called out in the doc comments for the hook, so perhaps that is good enough