diff --git a/.eslintignore b/.eslintignore index 4c257dee7..3fc3b8077 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,8 @@ node_modules dist -lib \ No newline at end of file +lib +**/desktop/release/** +tools/** +values-*.yaml +values.secret.json +webpack.config.js \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 000000000..08be4878c --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,122 @@ +const common = { + env: { + node: true, + 'jest/globals': true, + }, + plugins: ['prettier', 'jest', 'markdown'], + extends: [ + 'airbnb-base', + 'prettier', + 'plugin:jest/all', + 'plugin:json/recommended', + ], + rules: { + 'prettier/prettier': 'error', + 'jest/no-disabled-tests': 'warn', + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'error', + 'jest/prefer-to-have-length': 'warn', + 'jest/valid-expect': 'error', + 'jest/expect-expect': 'off', + 'jest/prefer-expect-assertions': 'off', + 'jest/no-test-return-statement': 'off', + 'import/prefer-default-export': 'off', + 'import/extensions': 'off', + 'no-console': 'off', + 'no-iterator': 'off', + 'no-restricted-syntax': 'off', + 'no-await-in-loop': 'off', + 'consistent-return': 'off', + 'no-shadow': 'off', + 'no-unused-vars': 'off', + 'jsonc/indent': ['error', 2, {}], + }, + globals: { + fetch: true, + window: true, + document: true, + __CDN_URL__: true, + __DEV__: true, + __TEST__: true, + __CLIENT__: true, + __SERVER__: true, + __GRAPHQL_ENDPOINT__: true, + __SSR__: true, + __PERSIST_GQL__: true, + __API_URL__: true, + __WEBSITE_URL__: true, + __FRONTEND_BUILD_DIR__: true, + __API_SERVER_PORT__: true, + __WEB_SERVER_PORT__: true, + __WEB_DEV_SERVER_PORT__: true, + __SERVER_PROTOCOL__: true, + __SERVER_HOST__: true, + __GRAPHQL_ENDPOINT__: true, + }, +}; +module.exports = { + extends: [ + 'eslint:recommended', + 'plugin:typescript-sort-keys/recommended', + 'prettier', + ], + overrides: [ + { + /* + eslint-plugin-markdown only finds javascript code block snippet. + For specific spec, refer to https://github.com/eslint/eslint-plugin-markdown + */ + files: ['**/*.js', '**/*.md'], + ...common, + }, + { + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + 'plugin:import/errors', + 'plugin:import/warnings', + 'plugin:import/typescript', + ], + files: ['**/*.{ts,tsx}'], + globals: common.globals, + rules: { + ...common.rules, + '@typescript-eslint/explicit-function-return-type': 'off', + } + }, + { + files: '*.json', + parser: 'jsonc-eslint-parser', + rules: { + 'jsonc/sort-keys': 'error', + }, + extends: ['plugin:jsonc/recommended-with-json', 'plugin:package-json/recommended'], + plugins: ['package-json'] + }, + { + files: '**/*.test.ts', + rules: { + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + }, + }, + ], + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: [ + './tsconfig.eslint.json', + './packages/*/tsconfig.json', + './packages-modules/*/tsconfig.json', + './servers/*/tsconfig.json', + ], + warnOnUnsupportedTypeScriptVersion: false, + EXPERIMENTAL_useSourceOfProjectReferenceRedirect: false, + }, + plugins: ['@typescript-eslint', 'simple-import-sort', 'typescript-sort-keys'], + root: true, + rules: { + 'simple-import-sort/exports': 'error', + 'simple-import-sort/imports': 'error', + }, +}; diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 1fdc2e33b..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,71 +0,0 @@ -const common = { - env: { - node: true, - es6: true, - 'jest/globals': true, - }, - plugins: ['prettier', 'jest', 'markdown'], - extends: ['airbnb-base', 'prettier', 'plugin:jest/all'], - rules: { - 'prettier/prettier': 'error', - 'jest/no-disabled-tests': 'warn', - 'jest/no-focused-tests': 'error', - 'jest/no-identical-title': 'error', - 'jest/prefer-to-have-length': 'warn', - 'jest/valid-expect': 'error', - 'jest/expect-expect': 'off', - 'jest/prefer-expect-assertions': 'off', - 'jest/no-test-return-statement': 'off', - 'import/prefer-default-export': 'off', - 'import/extensions': 'off', - 'no-console': 'off', - 'no-iterator': 'off', - 'no-restricted-syntax': 'off', - 'no-await-in-loop': 'off', - 'consistent-return': 'off', - 'no-shadow': 'off', - 'no-unused-vars': 'off', - }, -}; - -module.exports = { - root: true, - overrides: [ - { - /* - eslint-plugin-markdown only finds javascript code block snippet. - For specific spec, refer to https://github.com/eslint/eslint-plugin-markdown - */ - files: ['**/*.js', '**/*.md'], - ...common, - }, - { - files: ['**/*.ts'], - parser: '@typescript-eslint/parser', - env: common.env, - plugins: [...common.plugins, '@typescript-eslint'], - extends: [ - ...common.extends, - 'plugin:@typescript-eslint/recommended', - 'plugin:import/errors', - 'plugin:import/warnings', - 'plugin:import/typescript', - ], - rules: { - ...common.rules, - '@typescript-eslint/explicit-function-return-type': 'off', - }, - settings: { - 'import/resolver': { - node: { - extensions: ['.js', '.jsx', '.ts', '.d.ts', '.tsx', '.graphql', '.gql'], - }, - typescript: { - // alwaysTryTypes: true, - // paths: './tsconfig.json', - }, - }, - }, - }, - ], -}; diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..84f95ffd0 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances of + any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +git@joshuakgoldberg.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][mozilla coc]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][faq]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[mozilla coc]: https://github.com/mozilla/diversity +[faq]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea782..b5c68e55b 100755 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Create a report to help us improve title: '' labels: '' assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] + +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] **Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS8.1] +- Browser [e.g. stock browser, safari] +- Version [e.g. 22] **Additional context** Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md index 48d5f81fa..96a47352a 100755 --- a/.github/ISSUE_TEMPLATE/custom.md +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -4,7 +4,4 @@ about: Describe this issue template's purpose here. title: '' labels: '' assignees: '' - --- - - diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7d6..2f28cead0 100755 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: '' assignees: '' - --- **Is your feature request related to a problem? Please describe.** diff --git a/.github/actions/prepare/action.yml b/.github/actions/prepare/action.yml new file mode 100644 index 000000000..5a789f222 --- /dev/null +++ b/.github/actions/prepare/action.yml @@ -0,0 +1,12 @@ +name: Prepare +description: Prepares the repo for a typical CI job + +runs: + using: 'composite' + steps: + - uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'yarn' + - run: yarn install + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..9baa5cead --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,15 @@ +name: Build + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn build diff --git a/.github/workflows/compliance.yml b/.github/workflows/compliance.yml new file mode 100644 index 000000000..0c26bfac7 --- /dev/null +++ b/.github/workflows/compliance.yml @@ -0,0 +1,20 @@ +name: Compliance + +on: + pull_request: + branches: + - main + types: + - edited + - opened + - reopened + - synchronize + +jobs: + compliance: + runs-on: ubuntu-latest + steps: + - uses: mtfoley/pr-compliance-action@main + with: + body-auto-close: false + ignore-team-members: false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..9b20d378d --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,15 @@ +name: Lint + +on: + push: + branches: + - master + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn lint diff --git a/.github/workflows/markdown.yml b/.github/workflows/markdown.yml new file mode 100644 index 000000000..2a03b94e7 --- /dev/null +++ b/.github/workflows/markdown.yml @@ -0,0 +1,15 @@ +name: Lint Markdown + +on: + push: + branches: + - master + pull_request: + +jobs: + markdown: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn lint:md diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 000000000..e6467ab8a --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,15 @@ +name: Lint Package + +on: + push: + branches: + - master + pull_request: + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn lint:package diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 000000000..0593e57a2 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,15 @@ +name: Prettier + +on: + push: + branches: + - master + pull_request: + +jobs: + prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn format --list-different diff --git a/.github/workflows/prune.yml b/.github/workflows/prune.yml new file mode 100644 index 000000000..713235263 --- /dev/null +++ b/.github/workflows/prune.yml @@ -0,0 +1,15 @@ +name: Lint Prune + +on: + push: + branches: + - master + pull_request: + +jobs: + prune: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn lint:prune diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml new file mode 100644 index 000000000..4707e353c --- /dev/null +++ b/.github/workflows/spelling.yml @@ -0,0 +1,15 @@ +name: Lint Spelling + +on: + push: + branches: + - main + pull_request: + +jobs: + spelling: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn lint:spelling diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..ab605210f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,15 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/prepare + - run: yarn test diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 000000000..c9cdc63b0 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ \ No newline at end of file diff --git a/.husky/_/.gitignore b/.husky/_/.gitignore new file mode 100644 index 000000000..f59ec20aa --- /dev/null +++ b/.husky/_/.gitignore @@ -0,0 +1 @@ +* \ No newline at end of file diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 000000000..cec959a6b --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi diff --git a/.husky/husky.sh b/.husky/husky.sh new file mode 100644 index 000000000..c37466e2b --- /dev/null +++ b/.husky/husky.sh @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json index 2f0f9a7bd..3e8d1356e 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,6 +1,10 @@ { - "default": true, - "MD013": false, - "MD042": false, - "MD033": false -} \ No newline at end of file + "default": true, + "MD013": false, + "MD042": false, + "MD033": false, + "first-line-h1": false, + "no-hard-tabs": false, + "no-inline-html": false, + "line-length": false +} diff --git a/.npmpackagejsonlintrc.json b/.npmpackagejsonlintrc.json new file mode 100644 index 000000000..91ec2f853 --- /dev/null +++ b/.npmpackagejsonlintrc.json @@ -0,0 +1,7 @@ +{ + "extends": "npm-package-json-lint-config-default", + "rules": { + "require-description": "error", + "require-license": "error" + } +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..9f4bfa470 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +node_modules +dist +lib +**/desktop/release/** +values-*.yaml +values.secret.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..0ca8f18c1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "useTabs": true, + "singleQuote": true, + "jsxSingleQuote": true +} diff --git a/.travis.yml b/.travis.yml index 8dc4d61fe..a0908cbcd 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "8.4" + - '8.4' install: - npm config set spin=false - yarn install -g npm@5.2 @@ -11,7 +11,7 @@ os: - osx branches: only: - - publish + - publish script: - yarn test # Allow Travis tests to run in containers. diff --git a/.ts-prunerc b/.ts-prunerc new file mode 100644 index 000000000..3c6dc5884 --- /dev/null +++ b/.ts-prunerc @@ -0,0 +1,4 @@ +{ + "error": true, + "skip": "src/index.ts" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index fd62c5b1a..095512a0b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,8 @@ { -"recommendations": [ - "dbaeumer.vscode-eslint" -] -} \ No newline at end of file + "recommendations": [ + "DavidAnson.vscode-markdownlint", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 810a24fb9..2b7dd5f35 100755 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,35 +1,31 @@ { - // Use IntelliSense to learn about possible Node.js debug attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - // Name of configuration; appears in the launch configuration drop down menu. - "name": "Run jest", - // Type of configuration. Possible values: "node", "mono". - "type": "node", - "request": "launch", - // Workspace relative or absolute path to the program. - "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js", - // Automatically stop program after launch. - "stopOnEntry": false, - // Command line arguments passed to the program. - "args": [ - "--runInBand", - "--testPathPattern", - "index.test" - ], - // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. - "cwd": "${workspaceRoot}/packages/sample-graphql-schema", - // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. - "runtimeExecutable": null, - // Environment variables passed to the program. - "env": { - "NODE_ENV": "development" - }, - "console": "integratedTerminal", - "sourceMaps": false - } - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible Node.js debug attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + // Name of configuration; appears in the launch configuration drop down menu. + "name": "Run jest", + // Type of configuration. Possible values: "node", "mono". + "type": "node", + "request": "launch", + // Workspace relative or absolute path to the program. + "program": "${workspaceRoot}/node_modules/jest-cli/bin/jest.js", + // Automatically stop program after launch. + "stopOnEntry": false, + // Command line arguments passed to the program. + "args": ["--runInBand", "--testPathPattern", "index.test"], + // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. + "cwd": "${workspaceRoot}/packages/sample-graphql-schema", + // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. + "runtimeExecutable": null, + // Environment variables passed to the program. + "env": { + "NODE_ENV": "development" + }, + "console": "integratedTerminal", + "sourceMaps": false + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 55712c19f..74759d45b 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,17 @@ { - "typescript.tsdk": "node_modules/typescript/lib" -} \ No newline at end of file + "cSpell.ignorePaths": [ + "**/package-lock.json", + "**/node_modules/**", + "**/vscode-extension/**", + "**/.git/objects/**", + ".vscode", + "**/package.json" + ], + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true, + "eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }], + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 15132193e..db0a703db 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,20 +1,19 @@ # Changelog - ## [0.8.0](https://github.com/cdmbase/fullstack-pro/compare/v0.0.40-alpha.12...v0.0.40-alpha.13) (2021-04-05) - > Dates follow the `dd/mm/yy` notation. -## 05/06/18 (v 0.3.2) -> Webpack4 -** Breaking Change ** -Removed `Staging` environment to go with standard `test` environment. +## 05/06/18 (v 0.3.2) +> Webpack4 +> ** Breaking Change ** +> Removed `Staging` environment to go with standard `test` environment. ## 11/10/17 -| Package | Version | Changes | -| ---- | --- | --- | -| all | 0.1.1 | uses spinjs for build | -Still support backward compatibility for starting server. \ No newline at end of file +| Package | Version |  Changes | +| ------- | ------- | --------------------- | +| all |  0.1.1 | uses spinjs for build | + +Still support backward compatibility for starting server. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 556f98805..37b9801bf 100755 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -20,28 +20,28 @@ If you see someone who is making an extra effort to ensure our community is welc The following behaviors are expected and requested of all community members: - * Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. - * Exercise consideration and respect in your speech and actions. - * Attempt collaboration before conflict. - * Refrain from demeaning, discriminatory, or harassing behavior and speech. - * Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. - * Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. +- Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. +- Exercise consideration and respect in your speech and actions. +- Attempt collaboration before conflict. +- Refrain from demeaning, discriminatory, or harassing behavior and speech. +- Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. +- Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. ## 4. Unacceptable Behavior The following behaviors are considered harassment and are unacceptable within our community: - * Violence, threats of violence or violent language directed against another person. - * Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. - * Posting or displaying sexually explicit or violent material. - * Posting or threatening to post other people's personally identifying information ("doxing"). - * Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. - * Inappropriate photography or recording. - * Inappropriate physical contact. You should have someone's consent before touching them. - * Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. - * Deliberate intimidation, stalking or following (online or in person). - * Advocating for, or encouraging, any of the above behavior. - * Sustained disruption of community events, including talks and presentations. +- Violence, threats of violence or violent language directed against another person. +- Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. +- Posting or displaying sexually explicit or violent material. +- Posting or threatening to post other people's personally identifying information ("doxing"). +- Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. +- Inappropriate photography or recording. +- Inappropriate physical contact. You should have someone's consent before touching them. +- Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. +- Deliberate intimidation, stalking or following (online or in person). +- Advocating for, or encouraging, any of the above behavior. +- Sustained disruption of community events, including talks and presentations. ## 5. Weapons Policy @@ -59,15 +59,11 @@ If a community member engages in unacceptable behavior, the community organizers If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. . - - Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. ## 8. Addressing Grievances -If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. - - +If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. ## 9. Scope @@ -77,11 +73,9 @@ This code of conduct and its related procedures also applies to unacceptable beh ## 10. Contact info - - ## 11. License and attribution -The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). +The Citizen Code of Conduct is distributed by [Stumptown Syndicate](http://stumptownsyndicate.org) under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). diff --git a/ISSUES.md b/ISSUES.md index 4bb0d4a9f..544a24911 100755 --- a/ISSUES.md +++ b/ISSUES.md @@ -1,18 +1,22 @@ -Resolving tags conflicts when running `lerna publish` ----- +## Resolving tags conflicts when running `lerna publish` + ``` $ git tag v0.0.1 v0.0.4 ``` + - remove the tag locally + ``` $ git tag -d v0.0.4 Deleted tag 'v0.0.4' (was c34157b) $ git tag -d v0.0.1 Deleted tag 'v0.0.1' (was edfaa93) ``` + - remove the tag remotely + ``` $ git push origin :refs/tags/v0.0.4 To https://github.com/cdmbase/ide-stack.git @@ -21,4 +25,3 @@ $ git push origin :refs/tags/v0.0.1 To https://github.com/cdmbase/ide-stack.git - [deleted] v0.0.1 ``` - diff --git a/Jenkinsfile b/Jenkinsfile index febe0fd8f..cc7473dbd 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -571,7 +571,6 @@ def generateStage(server, environmentType) { ${namespace} \ --set global.image.repository=${REPOSITORY_SERVER}/${name} \ --set global.image.tag=${version} \ - --version="v0.1.3" \ charts/chart """ diff --git a/README.md b/README.md index b8e51e842..623ad0960 100755 --- a/README.md +++ b/README.md @@ -1,50 +1,50 @@ # Full Stack Packages -*Fullstack packages to develop and test end to end; to use as packages or work independently.* +_Fullstack packages to develop and test end to end; to use as packages or work independently._ -Purpose: ---- -The idea is to create modules for each package so it can work independently as well as integrated to another project as packages. +## Purpose: + +The idea is to create modules for each package so it can work independently as well as integrated to another project as packages. ## Screenshot + ![screencast](./ScreenShot.png) +## Useful commands: -Useful commands: ---- -|command|Description| -|--------------------------|-----------| -|`lerna clean`| - removes the node_modules directory from all packages. | -|`npm start`| - starts the web server and backend server. Or Use `yarn zen:watch`| -|`yarn zen:watch`| - starts the web server and backend server in watch mode.| -|`yarn zen:watch:debug`| - starts the web server and backend server in debug and watch mode.| -|`yarn watch`| - build the packages in watchmode (Useful for development)| -|`yarn lerna`| - install external dependencies at the repo root so they're |`lable to all packages.| -|`yarn build`| - build all the packages| -|`yarn install`| - runs `lerna` and `build`| -|`lerna publish`| - publishes packages in the current Lerna project. | +| command | Description | +| ---------------------- | ------------------------------------------------------------------- | ----------------------- | +| `lerna clean` | - removes the node_modules directory from all packages. | +| `npm start` | - starts the web server and backend server. Or Use `yarn zen:watch` | +| `yarn zen:watch` | - starts the web server and backend server in watch mode. | +| `yarn zen:watch:debug` | - starts the web server and backend server in debug and watch mode. | +| `yarn watch` | - build the packages in watchmode (Useful for development) | +| `yarn lerna` | - install external dependencies at the repo root so they're | `lable to all packages. | +| `yarn build` | - build all the packages | +| `yarn install` | - runs `lerna` and `build` | +| `lerna publish` | - publishes packages in the current Lerna project. | Files explained: ---- + +--- + It uses `lerna.json` for creating the packages structure. Under packages you can create different modules based on its usage. For example: packages - Has the packages to organize the codebase into multi-package repositories. sample-core - Core interfaces of the packages which can be shared between server and client. - sample-platform/server - Core platform interfaces and its implementation code for Server. + sample-platform/server - Core platform interfaces and its implementation code for Server. sample-platform/browser - Core platform browser State related code which consists of Redux, Graphql Gql and UI Components. - sample-platform/react-shared-components - React pure components and containers are defined. + sample-platform/react-shared-components - React pure components and containers are defined. packages-modules - Has the server and browser side packages designed for a specific module feature. servers - Has the servers to organize the codebase into multi-package repositories. frontend-server - Frontend Client Server. This is useful to show demo of this package. - backend-server - Backend apollo server. - + backend-server - Backend apollo server. ## [Click here for Project Setup](docs/development/CodeContribution/Project_Setup.md) -In Order to get started with the development you need to go through the +In Order to get started with the development you need to go through the documentation first - [Getting Started with lerna](./docs/development/CodeContribution/lerna-build-tools.md) - [Running the servers](./docs/development/CodeContribution/How_to_Run_Various_Options.md) - [Dos and Dont](./docs/development/CodeContribution/DoAndDont.md) - diff --git a/babel.config.js b/babel.config.js index 114efb765..8a0317ed2 100755 --- a/babel.config.js +++ b/babel.config.js @@ -1,25 +1,24 @@ module.exports = { - compact: false, - presets: [ - '@babel/preset-typescript', - '@babel/preset-react', - ['@babel/preset-env', { modules: 'commonjs', loose: true }], - ], - plugins: [ - 'react-hot-loader/babel', - '@babel/plugin-transform-modules-commonjs', - '@babel/plugin-transform-destructuring', - '@babel/plugin-transform-for-of', - '@babel/plugin-transform-regenerator', - '@babel/plugin-transform-runtime', - '@babel/plugin-syntax-dynamic-import', - '@babel/plugin-proposal-class-properties', - ['@babel/plugin-proposal-decorators', { legacy: true }], - '@babel/plugin-proposal-object-rest-spread', - ], - env: { - production: { - compact: true, - }, - }, + compact: false, + presets: [ + '@babel/preset-typescript', + '@babel/preset-react', + ['@babel/preset-env', { modules: 'commonjs', loose: true }], + ], + plugins: [ + '@babel/plugin-transform-modules-commonjs', + '@babel/plugin-transform-destructuring', + '@babel/plugin-transform-for-of', + '@babel/plugin-transform-regenerator', + '@babel/plugin-transform-runtime', + '@babel/plugin-syntax-dynamic-import', + '@babel/plugin-proposal-class-properties', + ['@babel/plugin-proposal-decorators', { legacy: true }], + '@babel/plugin-proposal-object-rest-spread', + ], + env: { + production: { + compact: true, + }, + }, }; diff --git a/build.config.js b/build.config.js index 5f94baf44..7b927885e 100644 --- a/build.config.js +++ b/build.config.js @@ -1,26 +1,39 @@ -process.env.ENV_FILE !== null && require('dotenv').config({ path: process.env.ENV_FILE }); +process.env.ENV_FILE !== null && + require('dotenv').config({ path: process.env.ENV_FILE }); -const __API_SERVER_PORT__ = process.env.BACKEND_URL - ? new URL(process.env.BACKEND_URL).port - : process.env.SERVER_PORT || 8091; -const __WEB_SERVER_PORT__ = 3011; +const __API_SERVER_PORT__ = process.env.GRAPHQL_URL + ? new URL(process.env.GRAPHQL_URL).port + : process.env.GRAPHQL_URL || 8080; +const __WEB_SERVER_PORT__ = process.env.GRAPHQL_URL + ? new URL(process.env.GRAPHQL_URL).port + : process.env.GRAPHQL_URL || 8080; +const __WEB_DEV_SERVER_PORT__ = process.env.SSR + ? 3010 + : process.env.CLIENT_URL + ? new URL(process.env.CLIENT_URL).port + : 3000; const __SERVER_PROTOCOL__ = 'http'; const __SERVER_HOST__ = 'localhost'; -const __GRAPHQL_ENDPOINT__ = 'graphql'; +const __GRAPHQL_ENDPOINT__ = '/graphql'; const config = { - __SERVER__: false, - __CLIENT__: true, - __SSR__: process.env.NODE_ENV === 'production', // enableing SSR only in Production as in Dev we have a issue - __DEBUGGING__: false, - __TEST__: false, - __WEB_SERVER_PORT__, - __SERVER_HOST__, - __API_SERVER_PORT__, - __API_URL__: - process.env.API_URL || - `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__API_SERVER_PORT__}/${__GRAPHQL_ENDPOINT__}`, - __WEBSITE_URL__: process.env.WEBSITE_URL || `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__WEB_SERVER_PORT__}`, - __BACKEND_URL__: process.env.BACKEND_URL || `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__API_SERVER_PORT__}`, + __SERVER__: false, + __CLIENT__: true, + __SSR__: process.env.NODE_ENV === 'production', // enableing SSR only in Production as in Dev we have a issue + __DEBUGGING__: false, + __TEST__: false, + __WEB_DEV_SERVER_PORT__, + __GRAPHQL_ENDPOINT__, + __SERVER_HOST__, + __API_SERVER_PORT__, + __API_URL__: + process.env.API_URL || + `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__API_SERVER_PORT__}${__GRAPHQL_ENDPOINT__}`, + __WEBSITE_URL__: + process.env.WEBSITE_URL || + `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__WEB_DEV_SERVER_PORT__}`, + __BACKEND_URL__: + process.env.BACKEND_URL || + `${__SERVER_PROTOCOL__}://${__SERVER_HOST__}:${__WEB_SERVER_PORT__}`, }; module.exports = config; diff --git a/codegen.yml b/codegen.yml index b41f7b577..31066dc15 100755 --- a/codegen.yml +++ b/codegen.yml @@ -1,23 +1,23 @@ overwrite: true -schema: "./servers/backend-server/generated-schema.graphql" +schema: './servers/backend-server/generated-schema.graphql' generates: typings/graphql.d.ts: - schema: - - "packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql" + schema: + - 'packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql' - packages-modules/counter/server/src/schema/**/*.graphql - documents: "packages-modules/counter/browser/src/**/*.gql" + documents: 'packages-modules/counter/browser/src/**/*.gql' plugins: - typescript-graphql-files-modules packages-modules/counter/browser/src/generated-models.ts: - schema: - - "packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql" + schema: + - 'packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql' - packages-modules/counter/server/src/schema/**/*.graphql - documents: "packages-modules/counter/browser/src/**/*.gql" + documents: 'packages-modules/counter/browser/src/**/*.gql' config: - noNamespaces: true - withMutationFn: false - withHOC: false - withComponent: false + noNamespaces: true + withMutationFn: false + withHOC: false + withComponent: false plugins: - add: content: /* tslint:disable */ @@ -26,10 +26,10 @@ generates: - typescript-resolvers - typescript-react-apollo packages-modules/counter/browser/src/apollo-server-n-client/generated-model.tsx: - schema: - - "packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql" + schema: + - 'packages-modules/counter/browser/src/apollo-server-n-client/**/*.graphql' - packages-modules/counter/server/src/schema/**/*.graphql - documents: "packages-modules/counter/browser/src/**/*.gql" + documents: 'packages-modules/counter/browser/src/**/*.gql' config: withMutationFn: false withHOC: false @@ -37,9 +37,9 @@ generates: withHooks: true preset: import-types-preset presetConfig: - typesPath: "../generated-models" + typesPath: '../generated-models' importTypesNamespace: SchemaTypes plugins: - add: content: /* tslint:disable */ - - typescript-react-apollo \ No newline at end of file + - typescript-react-apollo diff --git a/commitlint.config.js b/commitlint.config.js index a04716d73..08dc69b57 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,6 +1,6 @@ module.exports = { - extends: ['@commitlint/config-conventional'], - rules: { - 'header-max-length': [0, 'always', 100], // corresponding to maxHeaderWidth of commitizen - }, + extends: ['@commitlint/config-conventional'], + rules: { + 'header-max-length': [0, 'always', 100], // corresponding to maxHeaderWidth of commitizen + }, }; diff --git a/config/development/settings.json b/config/development/settings.json index a6f1ddf51..de87ac275 100755 --- a/config/development/settings.json +++ b/config/development/settings.json @@ -1,9 +1,9 @@ { - "database": { - "client": "sqlite3", - "connection": { - "filename": "dev-db.sqlite3" - }, - "useNullAsDefault": true - } -} \ No newline at end of file + "database": { + "client": "sqlite3", + "connection": { + "filename": "dev-db.sqlite3" + }, + "useNullAsDefault": true + } +} diff --git a/cspell.json b/cspell.json new file mode 100644 index 000000000..1a9a2d5eb --- /dev/null +++ b/cspell.json @@ -0,0 +1,5 @@ +{ + "dictionaries": ["typescript"], + "ignorePaths": [".github", "dist", "node_modules"], + "words": ["commitlint"] +} diff --git a/docs/Moleculer.md b/docs/Moleculer.md index 535d89370..d8cf488c4 100644 --- a/docs/Moleculer.md +++ b/docs/Moleculer.md @@ -1,10 +1,6 @@ - - -Connecting to moleculer ---- +## Connecting to moleculer moleculer connect --ns default - References: -https://moleculer.services/docs/0.14/moleculer-cli.html \ No newline at end of file +https://moleculer.services/docs/0.14/moleculer-cli.html diff --git a/docs/References.md b/docs/References.md index ed2d7bdfc..b3d6fab1d 100755 --- a/docs/References.md +++ b/docs/References.md @@ -1,13 +1,9 @@ +## Hot Reload in Apollo Server 2 - - -Hot Reload in Apollo Server 2 --- https://github.com/apollographql/apollo-server/issues/1275 +# To update apollo-server -To update apollo-server -==== https://github.com/uzh-bf/klicker-uzh/blob/927512043e8b978c5874bb524eac5c5ff321e28b/apps/backend/src/app.js https://github.com/heypoom/eventkit/tree/165eb23dc8f3529b46f2cd1f187e4c592d8c9767 -https://github.com/cerino-ligutom/GraphQL-Starter/blob/master/src/graphql/index.ts \ No newline at end of file +https://github.com/cerino-ligutom/GraphQL-Starter/blob/master/src/graphql/index.ts diff --git a/docs/development/CodeContribution/Adding_New_Modules.md b/docs/development/CodeContribution/Adding_New_Modules.md index bc02e053f..9a21dedf9 100644 --- a/docs/development/CodeContribution/Adding_New_Modules.md +++ b/docs/development/CodeContribution/Adding_New_Modules.md @@ -4,80 +4,85 @@ In this guide, we explain how you can add new modules with FullStack-pro Kit. ## Table of Contents -* [Add New Modules](#installing-and-importing-dependencies) - +- [Add New Modules](#installing-and-importing-dependencies) ## Add New Modules Adding new modules, usually goes under `packages-modules` folder. For example to create counter module, you create 1. From root directory, create following folders by running the commands (in unix). - ``` - mkdir -p packages-modules/counter/browser/src - mkdir -p packages-modules/counter/servers/src - touch packages-modules/counter/browser/src/package.json - touch packages-modules/counter/servers/src/package.json - ``` + ``` + mkdir -p packages-modules/counter/browser/src + mkdir -p packages-modules/counter/servers/src -2. Copy following files from the existing modules, + touch packages-modules/counter/browser/src/package.json + touch packages-modules/counter/servers/src/package.json + ``` - From one of the existing moudles, copy the following files into the new module. Make sure the browser's module are copied from another existing browsers location and similarly for server's module. +2. Copy following files from the existing modules, - - webpack.config.js - - tsconfig.json + From one of the existing moudles, copy the following files into the new module. Make sure the browser's module are copied from another existing browsers location and similarly for server's module. + - webpack.config.js + - tsconfig.json 3. Copy the content of the package.json for both browser and server from the existing modules and change the `name` in the package.json to the specific name of the module you want to create. Please make sure to keep the namespace of the module uniform, if the existing module have `@sample-stack`, your new browser module's `package.json` name would be `@sample-stack/counter-browser`, similarly for server module will have `@sample-stack/counter-server`. - ```json - { - "name": "@sample-stack/counter-module-browser", - "version": "0.0.1", - ..... - "publishConfig": { - "access": "public" - }, - ..... - - "dependencies": { - "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", - }, - "peerDependencies": { - "@common-stack/client-react": ">=0.0.229", - "@common-stack/core": ">=0.0.229", - "antd": "^3.26.4" - } - } - ``` - Add any additional dependencies that this module needed. + ```json + { + "name": "@sample-stack/counter-module-browser", + "version": "0.0.1", + ..... + "publishConfig": { + "access": "public" + }, + ..... + + "dependencies": { + "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", + }, + "peerDependencies": { + "@common-stack/client-react": ">=0.0.229", + "@common-stack/core": ">=0.0.229", + "antd": "^3.26.4" + } + } + ``` + + Add any additional dependencies that this module needed. 4. Then, to use the new module add to `servers` and main `package.json` - a. In root `package.json` file add the new module where you have existing modules - ```json - "dependencies": { - ..... - "@sample-stack/counter-module-browser": "link:packages-modules/counter/browser", - "@sample-stack/counter-module-server": "link:packages-modules/counter/server", - .... - } - ``` - b. In frontend server `servers/frontend-server` add the browser module with relative path. - ```json - "dependencies": { - ..... - "@sample-stack/counter-module-browser": "link:../../packages-modules/counter/browser", - } - ``` - c. In backend servers `servers/backend-server` add the server module with relative path. - ```json - "dependencies": { - .... - "@sample-stack/counter-module-server": "link:../../packages-modules/counter/server", - .... - } - ``` + a. In root `package.json` file add the new module where you have existing modules + + ```json + "dependencies": { + ..... + "@sample-stack/counter-module-browser": "link:packages-modules/counter/browser", + "@sample-stack/counter-module-server": "link:packages-modules/counter/server", + .... + } + ``` + + b. In frontend server `servers/frontend-server` add the browser module with relative path. + + ```json + "dependencies": { + ..... + "@sample-stack/counter-module-browser": "link:../../packages-modules/counter/browser", + } + ``` + + c. In backend servers `servers/backend-server` add the server module with relative path. + + ```json + "dependencies": { + .... + "@sample-stack/counter-module-server": "link:../../packages-modules/counter/server", + .... + } + ``` Notes: diff --git a/docs/development/CodeContribution/Desktop_Setup.md b/docs/development/CodeContribution/Desktop_Setup.md index 4495a9622..58cb0a7ba 100644 --- a/docs/development/CodeContribution/Desktop_Setup.md +++ b/docs/development/CodeContribution/Desktop_Setup.md @@ -1,12 +1,11 @@ - # Follow steps to [install project](./Project_Setup.md) ### Start Desktop application -Before to start desktop application, make sure to start the backend server of the web application first. +Before to start desktop application, make sure to start the backend server of the web application first. `lerna exec --scope=*backend-server yarn watch` -And then start desktop application. +And then start desktop application. `lerna exec --scope=*desktop yarn watch` diff --git a/docs/development/CodeContribution/DoAndDont.md b/docs/development/CodeContribution/DoAndDont.md index c5dc1b559..65e0f21f8 100755 --- a/docs/development/CodeContribution/DoAndDont.md +++ b/docs/development/CodeContribution/DoAndDont.md @@ -1,24 +1,20 @@ +## Don't do it... - - -Don't do it... ---- 1. `yarn ` - Do not install dependencies as `yarn `. - We use `lerna` and the way it works for the project is by installing `dependencies` to the `packages` or `servers` that requires it. In most cases, - you can just add the package to frontend or backend by running following + Do not install dependencies as `yarn `. + We use `lerna` and the way it works for the project is by installing `dependencies` to the `packages` or `servers` that requires it. In most cases, + you can just add the package to frontend or backend by running following - > to add to the frontend server so browser gets it + > to add to the frontend server so browser gets it `lerna add --scope=*fronted-server ` - - > to add to the backend server for nodejs to use it + > to add to the backend server for nodejs to use it `lerna add --scope=*backend-server ` - If a dependency is just needed by one package, you can add to that package's package.json file + If a dependency is just needed by one package, you can add to that package's package.json file `lerna add --scope= ` @@ -26,10 +22,10 @@ Don't do it... Sometimes we may need to `pin` a package as other dependencies can bring some older versions of the package we want to add. In that case we can pin the required package version by adding to the `pacakge.json`. But make sure you don't have different version of the package in `servers` or `packages` otherwise a duplciate package will be added to its `nodemodules`. -Do ---- +## Do + 1. Each package version should be uniform across the repository - Before adding a ``, see if the package of different version exist. If it exist then update that version to the required version. + Before adding a ``, see if the package of different version exist. If it exist then update that version to the required version. -2. You can edit one of the `packages` or `servers`'s `package.json` file directly to add a `dependencies` and then run `yarn lerna` to install them. This is a easy way to install a known version by adding to the target `pacakage.json` file. \ No newline at end of file +2. You can edit one of the `packages` or `servers`'s `package.json` file directly to add a `dependencies` and then run `yarn lerna` to install them. This is a easy way to install a known version by adding to the target `pacakage.json` file. diff --git a/docs/development/CodeContribution/HowToContribute.md b/docs/development/CodeContribution/HowToContribute.md index f2f417ae7..924b88d6e 100644 --- a/docs/development/CodeContribution/HowToContribute.md +++ b/docs/development/CodeContribution/HowToContribute.md @@ -1,14 +1,9 @@ +## How to contribute as a developer? -How to contribute as a developer? --- - -1. Once you setup the project, switch to `develop` branch. -2. Create a new branch using `develop` branch as source based on the issue you working. -3. Update changes to that branch and create a PR agains `develop` branch. +1. Once you setup the project, switch to `develop` branch. +2. Create a new branch using `develop` branch as source based on the issue you working. +3. Update changes to that branch and create a PR agains `develop` branch. 4. As soon as PR is created, we have a build process that runs in the background to check whether it is successful or failed. 5. If it successfull you will see a green check otherwise a red cross. When you notice it has red cross then run `yarn build` locally and fix any issues and submit the commit again to check it's updated status. - - -Note: `master` branch is read-only branch and we don't want to merge anything to it other than that from `develop` branch. So please avoid creating PRs agains master branch. - +Note: `master` branch is read-only branch and we don't want to merge anything to it other than that from `develop` branch. So please avoid creating PRs agains master branch. diff --git a/docs/development/CodeContribution/How_to_Run_Various_Options.md b/docs/development/CodeContribution/How_to_Run_Various_Options.md index a95b007f9..0908cf5c7 100755 --- a/docs/development/CodeContribution/How_to_Run_Various_Options.md +++ b/docs/development/CodeContribution/How_to_Run_Various_Options.md @@ -1,4 +1,5 @@ ## SETUP and INSTALL + ### To Install the project and build all packages `yarn bootstrap` @@ -10,6 +11,7 @@ If you need to do a clean the existing node_modules and take latest changes from `yarn clean:install` ## LINTING + ### To check linting `yarn lint ` @@ -19,6 +21,7 @@ If you need to do a clean the existing node_modules and take latest changes from `yarn format ` ## PACKAGES COMMANDS + ### To run build all packages `yarn build` @@ -29,7 +32,7 @@ If you need to do a clean the existing node_modules and take latest changes from Note: It only run `packages` and `packages-modules` only in watch mode. Servers should be run seperately. -Also check out `yarn watch-packages` to run watch on required packages. +Also check out `yarn watch-packages` to run watch on required packages. ### To run build with watch for dependent packages @@ -39,25 +42,24 @@ For auto reloading changes into the server to be productive during development. yarn watch-packages ``` -If you also need to watch along with it, you can as many scopes as required like below. +If you also need to watch along with it, you can as many scopes as required like below. ``` yarn watch-packages -- --scope=@sample-stack/counter-module* --scope=@packageb ``` ## TO START SERVERS + ### To run a individual package in watch mode `lerna exec --scope= yarn watch` More details on how to use [lerna exec](https://github.com/lerna/lerna/tree/master/commands/exec#options) - To run any command on a package `lerna exec --scope= ` - ### How to Start Backend and Frontend seperately. To start the frontend-server @@ -76,7 +78,6 @@ To just start the backend-server `yarn start:envSSR` - ### To run Frontend with production build in development build the package @@ -90,6 +91,3 @@ start the server with `dev` environment file Make sure backend is also running in seperate terminal `lerna exec --scope=*backend-server yarn watch` - - - diff --git a/docs/development/CodeContribution/Known_Issues.md b/docs/development/CodeContribution/Known_Issues.md index 7bfa8b011..7b42ae8c9 100755 --- a/docs/development/CodeContribution/Known_Issues.md +++ b/docs/development/CodeContribution/Known_Issues.md @@ -1,14 +1,11 @@ - - # Kown Issues - 1. EACCES: permission denied, scandir ..... Follow the workaround https://github.com/cdmbase/fullstack-pro/issues/176 2. OS X: "Error: EMFILE: too many open files, watch" -Follow https://github.com/facebook/create-react-app/issues/4540 + Follow https://github.com/facebook/create-react-app/issues/4540 ``` brew install watchman @@ -16,4 +13,4 @@ brew install watchman 3. Macbook Catalina: `Zsh` latest macos comes with `Zsh` as the default shell. We seeing some issues to start the project with it. Please use `bash` to run project. -https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/ \ No newline at end of file +https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/ diff --git a/docs/development/CodeContribution/Project_Setup.md b/docs/development/CodeContribution/Project_Setup.md index bc08856f0..fabb9b07b 100644 --- a/docs/development/CodeContribution/Project_Setup.md +++ b/docs/development/CodeContribution/Project_Setup.md @@ -3,6 +3,7 @@ If you want to develop FullStack locally you must follow the following instructions: 1. Clone fullstack-pro locally + ``` git clone https://github.com/cdmbase/fullstack-pro cd fullstack-pro @@ -10,20 +11,21 @@ cd fullstack-pro 2. Install dependencies and build packages. - a. make sure `python` version `2.7.16` or higher in `^2` version installed. + a. make sure `python` version `2.7.16` or higher in `^2` version installed. + + b. install `node-gyp` globally. For installation check [this document](https://github.com/nodejs/node-gyp#installation). - b. install `node-gyp` globally. For installation check [this document](https://github.com/nodejs/node-gyp#installation). + c. install `watchman` for macOS users - c. install `watchman` for macOS users + d. Node version supported is `>=12.18.4` and `yarn` version is `1.22`. You can Download Node from [here](https://nodejs.org/dist/v12.18.4/) - d. Node version supported is `>=12.18.4` and `yarn` version is `1.22`. You can Download Node from [here](https://nodejs.org/dist/v12.18.4/) + e. Insall and build packages using following command. Run from the root folder of this project. - e. Insall and build packages using following command. Run from the root folder of this project. ``` yarn global add lerna yarn bootstrap ``` - + 3. Setup environment file You need to have environemnt file before you start the project. There is a sample file exist at `config/development/dev.env.sample` which you can copy as `config/development/dev.env`. @@ -41,18 +43,22 @@ You may need to set personalized values in the `dev.env` file. > mongod 5. Start both client and server together + ``` yarn start ``` + Alternatively, if you need to run `backend` and `frontend` on its respective terminal instead of one terminal then follow [How to Start Backend and Frontend seperately](./How_to_Run_Various_Options.md#how-to-start-backend-and-frontend-seperately) -### Server Enpoints: +### Server Enpoints: + The graphql server endpoints are ->http://localhost:8080/graphql + +> http://localhost:8080/graphql The browser server endopoint is ->http://localhost:3000 +> http://localhost:3000 ## How to run with HotReload for live changes both in the server and browser? @@ -62,7 +68,7 @@ To run build with watch for dependent packages, for auto reloading changes into yarn watch-packages ``` -If you also need to watch along with it, you can use as many scopes as required like below. +If you also need to watch along with it, you can use as many scopes as required like below. ``` yarn watch-packages -- --scope=@sample-stack/counter-module* --scope=@packageb @@ -91,6 +97,7 @@ But in some cases when `lerna's packages` are added or versions in `packages.jso ``` yarn clean:force && git pull && yarn install && yarn build ``` + - here should be replaced with the branch you getting updates. ## Installation of Prerequisties servers @@ -101,42 +108,51 @@ Please check the installation documentation of each one. MongoDB install : https://www.mongodb.com/docs/manual/administration/install-community/ Redis install: https://redis.io/docs/getting-started/ - ## Advance Options + ### To test Production build and run -You need to run Frontend and Backend in two seperate servers. + +You need to run Frontend and Backend in two seperate servers. to start frontend server + ``` lerna exec --scope=*frontend-server yarn build lerna exec --scope=*frontend-server yarn start:dev ``` + to start backend server + ``` lerna exec --scope=*backend-server yarn build lerna exec --scope=*backend-server yarn start:dev ``` Note: you can pass `:` next to `start` to use env config. + - dev: to use `/config/development/dev.env` - stage: to use `/config/staging/staging.env` - - ### Docker build and run Build three docker images by following the steps: + - Frontend Server + ``` lerna exec --scope=*frontend-server yarn docker:build lerna exec --scope=*frontend-server yarn docker:run ``` + - Backend Server + ``` lerna exec --scope=*backend-server yarn docker:build lerna exec --scope=*backend-server yarn docker:run ``` + - moleculer-server + ``` lerna exec --scope=*moleculer-server yarn docker:build lerna exec --scope=*moleculer-server yarn docker:run @@ -145,6 +161,7 @@ lerna exec --scope=*moleculer-server yarn docker:run Note: It uses `/config/staging/staging.env` for environment variables. ### Environment settings for non-development + ``` GRAPHQL_URL CLIENT_URL @@ -152,8 +169,11 @@ NATS_URL NATS_USER NATS_PW ``` + ## Troubleshoot + To troubleshoot webpack configuration run + ``` yarn zen:watch:debug ``` diff --git a/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md b/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md index 4b2b11cc6..8b5348cec 100755 --- a/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md +++ b/docs/development/CodeContribution/React-Patterns/Dynamically_Render_Components.md @@ -1,4 +1,3 @@ - Refernce: https://medium.com/@j5bot/react-dynamically-rendering-different-components-without-switch-the-capitalized-reference-e668d89e460b ``` @@ -54,4 +53,4 @@ export const CapitalizedReferenceComponentCollectionExternals = (props) => { }; export default CapitalizedReferenceComponentCollectionExternals; -``` \ No newline at end of file +``` diff --git a/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md b/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md index 39573b631..b3aa5e055 100755 --- a/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md +++ b/docs/development/CodeContribution/React-Patterns/HOC_With_Render_Props.md @@ -1,6 +1,7 @@ Reference: https://gist.github.com/mjackson/a1bee5a8b24a0db7ff29586b124cfb38 https://www.youtube.com/watch?v=BcVAq3YFiuc&t=1397s https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce + ``` import React from "react"; import ReactDOM from "react-dom"; @@ -84,4 +85,4 @@ ReactDOM.render( document.getElementById("app") ); -``` \ No newline at end of file +``` diff --git a/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md b/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md index b860aa15a..b0fb2e46e 100755 --- a/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md +++ b/docs/development/CodeContribution/React-Patterns/Mongoose_Connection.md @@ -1,4 +1,3 @@ - Reference: https://github.com/barakbd/docker_typescript_debug_vscode/blob/8454ab4bdd9713da373e898e7c606193bfbfc5e2/src/config/mongoose_connection.ts @@ -42,4 +41,4 @@ mongoose }); const mongooseConnection: mongoose.Connection = mongoose.connection; export { mongooseConnection }; -``` \ No newline at end of file +``` diff --git a/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md b/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md index 67a82db47..3732a5051 100755 --- a/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md +++ b/docs/development/CodeContribution/React-Patterns/React_Componet_Extensions.md @@ -1,11 +1,7 @@ - - https://github.com/superdesk/superdesk-client-core/blob/d5ee7b11dddd2255a77b518e177b7ec33b167311/scripts/apps/extension-points/services/ExtensionPoints.js https://github.com/taskrabbit/react-component-extension - - https://github.com/camwest/react-slot-fill -Reference: https://www.youtube.com/watch?v=395ou6k6C6k \ No newline at end of file +Reference: https://www.youtube.com/watch?v=395ou6k6C6k diff --git a/docs/development/CodeContribution/React-Patterns/RxJS_notes.md b/docs/development/CodeContribution/React-Patterns/RxJS_notes.md index 00bc89e42..37d4cabc3 100644 --- a/docs/development/CodeContribution/React-Patterns/RxJS_notes.md +++ b/docs/development/CodeContribution/React-Patterns/RxJS_notes.md @@ -1,3 +1 @@ - - -https://itnext.io/handling-redux-side-effects-the-rxjs-way-59c057b12cd4 \ No newline at end of file +https://itnext.io/handling-redux-side-effects-the-rxjs-way-59c057b12cd4 diff --git a/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md b/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md index 9917c8c88..54ec74986 100644 --- a/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md +++ b/docs/development/CodeContribution/React-Patterns/Styles_With_Type.md @@ -1,52 +1,51 @@ - -Sample Style Sheet implementation. +Sample Style Sheet implementation. ```js import * as CSS from 'csstype'; const DefaultSettingsView = (props: IDefaultSettings) => { + const { css, theme } = useFela(); - const { css, theme } = useFela(); - - return(()=> { -
- test -
- }) - -} + return () => { +
+ test +
; + }; +}; const styleSheet: { [key: string]: (x: any) => CSS.Properties } = { - resizable: () => ({ - position: 'relative', - '> .react-resizable-handle': { - position: 'absolute', - width: '3px', - height: '100%', - top: 0, - right: 0, - padding: '0 3px 3px 0', - boxSizing: 'border-box', - cursor: 'col-resize', - }, - }), - title: ({ theme }) => ({ - textTransform: 'uppercase', - padding: '5px 0', - fontSize: '11px', - marginLeft: '33px', - color: theme.name === 'light' ? '#424242bd' : '#e7e7e77a', - boxShadow: theme.name === 'light' ? '0px 1px 2px 0px #f3f3f3' : '0px 1px 2px 0px #000000', - marginBottom: '2px', - }), - note: ({ width }) => ({ - marginLeft: '33px', - fontSize: '14px', - whiteSpace: 'nowrap', - textOverflow: 'clip', - display: 'block', - maxWidth: width, - overflow: 'hidden', - }), + resizable: () => ({ + position: 'relative', + '> .react-resizable-handle': { + position: 'absolute', + width: '3px', + height: '100%', + top: 0, + right: 0, + padding: '0 3px 3px 0', + boxSizing: 'border-box', + cursor: 'col-resize', + }, + }), + title: ({ theme }) => ({ + textTransform: 'uppercase', + padding: '5px 0', + fontSize: '11px', + marginLeft: '33px', + color: theme.name === 'light' ? '#424242bd' : '#e7e7e77a', + boxShadow: + theme.name === 'light' + ? '0px 1px 2px 0px #f3f3f3' + : '0px 1px 2px 0px #000000', + marginBottom: '2px', + }), + note: ({ width }) => ({ + marginLeft: '33px', + fontSize: '14px', + whiteSpace: 'nowrap', + textOverflow: 'clip', + display: 'block', + maxWidth: width, + overflow: 'hidden', + }), }; - -``` \ No newline at end of file +``` diff --git a/docs/development/CodeContribution/Tutorials.md b/docs/development/CodeContribution/Tutorials.md index fe0c62092..295948728 100755 --- a/docs/development/CodeContribution/Tutorials.md +++ b/docs/development/CodeContribution/Tutorials.md @@ -1,12 +1,8 @@ +## Typescript Tutorials - -Typescript Tutorials ---- https://basarat.gitbooks.io/typescript/ https://medium.com/@martin_hotell/react-children-composition-patterns-with-typescript-56dfc8923c64 +## Cors: - -Cors: ---- -https://www.blackhillsinfosec.com/cors-lite/ \ No newline at end of file +https://www.blackhillsinfosec.com/cors-lite/ diff --git a/docs/development/CodeContribution/faq.md b/docs/development/CodeContribution/faq.md index 1647deaf8..b243f409a 100755 --- a/docs/development/CodeContribution/faq.md +++ b/docs/development/CodeContribution/faq.md @@ -6,16 +6,10 @@ layout: docs category: FAQ --- - -### From where this `@sample-stack/platform-browser` comes in `packages/sample-platform/browser/src/containers/Counter.tsx`? +### From where this `@sample-stack/platform-browser` comes in `packages/sample-platform/browser/src/containers/Counter.tsx`? We use [lerna](https://github.com/lerna/lerna) for monorepo. For example all packages starts with `@sample-stack` are either under `packages` or `pacakges-modules` directories. - -### Why you have used [hot](https://github.com/cdmbase/fullstack-pro/blob/master/servers/frontend-server/src/app/Main.tsx#L3)? - -It is used for `hot reloading`. Checkout out [React Hot Loader](https://github.com/gaearon/react-hot-loader) - ### What is use of rehydrate? It is used for SSR(server side rendering). Server generates initial browser page along with state(redux or apollo-client or css) and that state will be used in the browser to rehydated during browser rendering so the client state don't start from initial values. diff --git a/docs/development/CodeContribution/installation_issues.md b/docs/development/CodeContribution/installation_issues.md index 4225f5480..c71341686 100644 --- a/docs/development/CodeContribution/installation_issues.md +++ b/docs/development/CodeContribution/installation_issues.md @@ -1,9 +1,6 @@ - - - 1. Error when `node-gyp rebuild`. - Could be missing `python`. Install it and rerun the install again. - For more docs, check https://github.com/nodejs/node-gyp#installation + Could be missing `python`. Install it and rerun the install again. + For more docs, check https://github.com/nodejs/node-gyp#installation 2. For Mac User to develop Desktop app need -`xcode-select --install` + `xcode-select --install` diff --git a/docs/development/CodeContribution/lerna-build-tools.md b/docs/development/CodeContribution/lerna-build-tools.md index 0960d58d4..1eba5e94d 100755 --- a/docs/development/CodeContribution/lerna-build-tools.md +++ b/docs/development/CodeContribution/lerna-build-tools.md @@ -1,12 +1,10 @@ +# What is lerna? -What is lerna? -=== [Lerna](https://github.com/lerna/lerna) allows us to manage multiple packages inside the same repository instead of creating one repository per package. With Lerna, we can unify processes like linting, building, testing, and releasing, have a single place to report issues, and becomes easier to set up our development environment. +## Things to know about current package structure -Things to know about current package structure --- -- We run `lerna` commands by wrapped into `npm/yarn` commands. +- We run `lerna` commands by wrapped into `npm/yarn` commands. - You will notice there are following commands which run's lerna comamnds. ```json @@ -27,29 +25,27 @@ Things to know about current package structure } ``` -Details on each command that wrapped for lerna --- +## Details on each command that wrapped for lerna + - `yarn install` - This command need to be run in the root of the package only to install all the dependencies. We have post step(`postinstall`) to run `yarn lerna` after install finishes so `lerna` will installs all of packages (seen under packages directory) dependencies and links any cross-dependencies. -Note: We do not need to run `yarn` under any packages with `package.json` files seen under `packages` and `servers` directories. + Note: We do not need to run `yarn` under any packages with `package.json` files seen under `packages` and `servers` directories. - `yarn lerna` - This triggers `lerna bootstrap --hoist`. Normally this get triggered as post install step. You can run this command to install any packages' dependencies. More information about this command can be found [here](https://github.com/lerna/lerna/blob/master/doc/hoist.md). The bottom line, the `hoist` will try to install all common dependencies to the top-level node_modules, and omitted from individual package's `node_modules`. -The outlier packages with different versions will get a normal, local node_modules installation of the necessary dependencies. + The outlier packages with different versions will get a normal, local node_modules installation of the necessary dependencies. - `yarn clean` - Removes the `node_modules` directory from all packages. - `yarn clean:force` - Removes the `node_modules` directory from all packages as well as `package-lock.json` file. -- `yarn build` - It invokes `yarn build` in each packages parallely. +- `yarn build` - It invokes `yarn build` in each packages parallely. - `yarn watch` - Automatically builds the packages that are changed. Recommended to run this when actively coding, so you would know anything (compilation errors) breaks instantly. You may also see `Error: ENOSPC: System limit for number of file watchers reached` if you OS is not configured with high open files. Check [Not Enough Watchers](#not-enough-watchers) section for futher information. -- `yarn watch-packages` - Abutomatically builds the dependent packages mostly under `packages` folder. +- `yarn watch-packages` - Abutomatically builds the dependent packages mostly under `packages` folder. - `yarn watch-packages -- --scope @sample-stack/counter-module-*` - By adding package module you like to watch along with the dependent packages. If you have more packages to watch keep adding with `-- --scope packageA* --scope packageB` +## Not Enough Watchers - -Not Enough Watchers ----- -Based on the project, we may have multiple `packages` and `packages-modules` to watch for file changes in order to automatically apply the changes in the browser. -When we have more modules to watch, we need laptop resource to support it. If the laptop OS is configured with default `open files`, we need to increase it. +Based on the project, we may have multiple `packages` and `packages-modules` to watch for file changes in order to automatically apply the changes in the browser. +When we have more modules to watch, we need laptop resource to support it. If the laptop OS is configured with default `open files`, we need to increase it. Follow notes from webpack to change OS configuration to increase file watchers https://webpack.js.org/configuration/watch/#not-enough-watchers -But, in case, if you are working in only one or two modules and need to watch them only then you can run below command on each packages, -respectively. +But, in case, if you are working in only one or two modules and need to watch them only then you can run below command on each packages, +respectively. `lerna exec --scope= yarn watch` @@ -60,10 +56,9 @@ lerna exec --scope=@sample-stack/counter-module-browser yarn watch lerna exec --scope=@sample-stack/counter-module-server yarn watch ``` -Adding packages as dependencies to sibling packages (not needed anymore) --- -When you add sibling package to one of the packages, you need to run `yarn lerna` symlink the packages that are dependencies of each other. +## Adding packages as dependencies to sibling packages (not needed anymore) +When you add sibling package to one of the packages, you need to run `yarn lerna` symlink the packages that are dependencies of each other. ### List packages @@ -73,13 +68,13 @@ Using the following folder structure, versions, and privacy as an example: fullstack-pro/ ├── packages │   ├── sample-core # 1.1.1 - public -│   ├── sample-platform +│   ├── sample-platform │   │   ├── browser # 1.1.1 - public │   │   └── server # 1.1.1 - public │ ... ├── packages-modules -│   └── counter -│   │ ├── browser +│   └── counter +│   │ ├── browser │   │ └── server ├── servers │   ├── backend-server # 1.0.0 - private @@ -172,6 +167,7 @@ When we use scoped packages, naming is not a problem because we are naming packa If I were creating a new scoped package called **core**, its name in the **package.json** file would be **@sample-stack/core**. ## Dependencies + The dependencies of our projects are registered inside the **package.json** file. This file is usually in the project's root folder, but it is also inside each package in the Lerna projects. **Each package has its dependencies.** ```bash @@ -207,6 +203,7 @@ fullstack-pro/ |── package.json └── lerna.json ``` + To add dependencies to the packages, Lerna provides us the command `lerna add`. Note that only a single package can be added at a time compared to `yarn add` or `yarn install`. ### Add dependencies @@ -249,7 +246,7 @@ lerna add lodash -w --dev ### Add peerDependencies -The **peerDependencies** key is **used when our package has a dependency that can also be a dependency of the project using it**. If our package has a dependency that can also be used by its dependent, we can specify the version required by us and the dependent will receive a warning when not matching that requirement. +The **peerDependencies** key is **used when our package has a dependency that can also be a dependency of the project using it**. If our package has a dependency that can also be used by its dependent, we can specify the version required by us and the dependent will receive a warning when not matching that requirement. ```bash # add a peerDependency to one package @@ -271,24 +268,31 @@ Well, that is a problem. Lerna has no direct command to upgrade dependencies, wh yarn upgrade lodash ``` -However, when we want to upgrade a dependency inside a package, nothing seems to work. Using `lerna exec` as we use it to remove dependencies does not work. +However, when we want to upgrade a dependency inside a package, nothing seems to work. Using `lerna exec` as we use it to remove dependencies does not work. For now, what we do is manually update the dependencies version in the `package.json` file of each package and then run `yarn install`. - ### Updating all sub packages of a **scoped** packages to newest release To update in all packages + ``` -lerna exec "ncu -u --newest --timeout 60000 -f /@sample-stack*/" +lerna exec "ncu -u --semverLevel minor --timeout 60000 -f /@sample-stack*/" ``` To update in the root package.json + +``` +ncu -u --semverLevel minor --timeout 60000 -f /@sample-stack*/ +``` + +To update the major version. You need to check with team before updating major version + ``` -ncu -u --newest --timeout 60000 -f /@sample-stack*/ +lerna exec "ncu -u --semverLevel major --timeout 60000 -f /@sample-stack*/" ``` -***note** after updating packages you need to run `yarn` to install them. +**\*note** after updating packages you need to run `yarn` to install them. ### Removing dependencies @@ -331,6 +335,7 @@ lerna diff # modifications in a specific package lerna diff @sample-stack/counter-module-browser ``` + ## Publish To publish our packages using Lerna we use the command `lerna publish` but, first, let's configure Lerna only to allow us to create newer versions of our packages from our main branch (eg. master). @@ -359,6 +364,7 @@ To publish a **scoped package** we also need to set the `publishConfig.access` t } } ``` + Setting this configuration in a package without a scope fails to publish. Imagine that we started developing the **sample-core** package, and although we merged some initial versions, we didn't finish yet, and **we don't want to release it to npm yet**. We can add to its **package.json** the **private** key with the value `true`, and Lerna will ignore it. @@ -452,17 +458,20 @@ lerna publish Lerna allows us to use the [Conventional Commits Specification](https://www.conventionalcommits.org/) to determine the bump version and generate the CHANGELOG.md files automatically. Follow the specification, when we are creating a new release, Lerna checks all the commits since the last release and it increments: + - the PATCH number when the subject of the commit is prefixed with `fix:`; - the MINOR number when the subject of the commit is prefixed with `feat:`. It has precedence over the PATCH; -- the MAJOR number when in the body of some commit it finds a string `BREAKING CHANGE:`. It can have any type provided in the subject and it has precedence over PATCH and MINOR. +- the MAJOR number when in the body of some commit it finds a string `BREAKING CHANGE:`. It can have any type provided in the subject and it has precedence over PATCH and MINOR. Considering that we are using fixed versions and our project is in the version `1.0.0`. If we try to create a new release with the following commit, our project version is updated to `1.0.1`. + ```bash # commit 1 subject -> "fix: fix button font size" ``` Then, if we do two more commits and publish again, the version is updated to `1.1.0`. + ```bash # commit 1 subject -> "fix: fix button border-radius" @@ -471,6 +480,7 @@ subject -> "feat: added loading status to the button" ``` Finally, if we do three more commits, the version is updated to `2.0.0`. + ```bash # commit 1 subject -> "fix: fix button text color" @@ -490,11 +500,11 @@ To do that, we update our `lerna.json` file: ... "command": { "publish": { - "conventionalCommits": true, + "conventionalCommits": true, "yes": true } } } ``` -Now, when we run `lerna publish` instead of asking us what version we want to give to each package, it automatically determines and publishes those versions. \ No newline at end of file +Now, when we run `lerna publish` instead of asking us what version we want to give to each package, it automatically determines and publishes those versions. diff --git a/docs/development/CodeContribution/lerna-yarn-workspaces.md b/docs/development/CodeContribution/lerna-yarn-workspaces.md index 83031b023..adc1a04c7 100644 --- a/docs/development/CodeContribution/lerna-yarn-workspaces.md +++ b/docs/development/CodeContribution/lerna-yarn-workspaces.md @@ -2,7 +2,6 @@ [Yarn Workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) allow us to run `yarn install` only once, although we have several packages. Yarn uses a single lock file rather than a different one for each project, which means fewer conflicts. Once all the dependencies are installed together, Yarn can better optimize them. Its most important feature is that when we have one package depending on another package of our repository, yarn link them together, allowing us to use always the most up-to-date code available. - ## Yarn & Yarn Workspaces ### Set up yarn @@ -68,7 +67,7 @@ In the **package.json** file, we add the **workspaces** key with a list of globs } ``` -In the **lerna.json** file, we can remove the **packages** key because the **workspaces** key in the **package.json** file overrides it. We also need to add the **useWorkspaces** key with the value `true`. +In the **lerna.json** file, we can remove the **packages** key because the **workspaces** key in the **package.json** file overrides it. We also need to add the **useWorkspaces** key with the value `true`. ```json[lerna.json] { @@ -79,4 +78,5 @@ In the **lerna.json** file, we can remove the **packages** key because the **wo ``` ### Lerna -- [Getting Started with lerna](./lerna-build-tools.md) \ No newline at end of file + +- [Getting Started with lerna](./lerna-build-tools.md) diff --git a/docs/development/Database/mongodb-test.md b/docs/development/Database/mongodb-test.md index fc6bc892d..10055afb7 100644 --- a/docs/development/Database/mongodb-test.md +++ b/docs/development/Database/mongodb-test.md @@ -1,6 +1,3 @@ +## Writing Mongodb test - -Writing Mongodb test ---- - -https://jestjs.io/docs/en/mongodb \ No newline at end of file +https://jestjs.io/docs/en/mongodb diff --git a/docs/development/Deployment/How_To_Setup_Jenkins.md b/docs/development/Deployment/How_To_Setup_Jenkins.md index 168a97925..4ab4461a1 100755 --- a/docs/development/Deployment/How_To_Setup_Jenkins.md +++ b/docs/development/Deployment/How_To_Setup_Jenkins.md @@ -1,14 +1,20 @@ # Authorizing jenkins to access a repository + #### 1- execute to the jenkins running pod and get the publish ssh key + ``` kubectl exec -it bash cat /var/jenkins_home/.ssh/id_rsa.pub ``` + #### 2- copy the key and go to the repository on github + - Go to Setting - Deploy keys - Add deploy key + #### 3- Go to jenkins + - Create a new item - Choose pipeline - Provide the repo name @@ -17,44 +23,59 @@ cat /var/jenkins_home/.ssh/id_rsa.pub - Choose git - Give the repo URL and choose credential - Choose the Username from credential list + #### If the credential (ssh public key) is used for the first time: + - choose Add Credentials - Choose SSH Username with private key - From the Jenkins master ~/.ssh - Give the key a username and choose this user name later on on the list # Authorizing jenkins to Google Container Registry + #### 1- in google cloud console - - Go to APIs and services - - Credentials - - create credential - - service account key - - New Service account - - Add role Storage Admin - - generate key of type JSON -> Copy the generated key to jenkins pod and user the -> key path to login to gcr with docker login command + +- Go to APIs and services +- Credentials +- create credential +- service account key +- New Service account +- Add role Storage Admin +- generate key of type JSON + > Copy the generated key to jenkins pod and user the + > key path to login to gcr with docker login command # Adding deploy key to jenkins and github repo + #### 1- execute to the jenkins running pod and get the public ssh key + ``` kubectl exec -it bash mkdir repo-name -ssh-keygen +ssh-keygen ``` + > generate the ssh key in the created directory -#### 2- Login to jenkins - - Go to Credentials - - System - - Global credentials - - Add Credentials -#### 3- Choose from the drop down list SSH Username with private key and edit the following + +#### 2- Login to jenkins + +- Go to Credentials +- System +- Global credentials +- Add Credentials + +#### 3- Choose from the drop down list SSH Username with private key and edit the following + - Add Username (that would be the credential name make it descriptive like the repo name) - In the Private key section choose From a file on Jenkins master and add the path to the private key on jenkins (If you followed the above instruction it would be /repo-name/id_rsa) -- Ok to save the key in credentials +- Ok to save the key in credentials + #### 4- create a new pipeline in jenkins + #### 5- in the pipeline section choose Pipeline script from SCM -#### 6- Choose git as SCM + +#### 6- Choose git as SCM + #### 7- add the repo (ssh clone link) + #### 8- in credentials section choose the key you just created - diff --git a/docs/development/Deployment/JenkinsDeployment.md b/docs/development/Deployment/JenkinsDeployment.md index 7045471a5..0b905e203 100755 --- a/docs/development/Deployment/JenkinsDeployment.md +++ b/docs/development/Deployment/JenkinsDeployment.md @@ -1,8 +1,6 @@ - - # Jenkins Deployment -The branches used for Jenkins deployment will be `devpublish` for testing `develop` branch. This is used for pre production testing. +The branches used for Jenkins deployment will be `devpublish` for testing `develop` branch. This is used for pre production testing. `publish` branch is used for testing `master` branch. This is also used for production deployment. @@ -13,4 +11,3 @@ All modification in `Jenkinsfile` should be done in `develop` branch. As these c ``` yarn devpublish:push ``` - diff --git a/docs/development/Expo/expo-commands.md b/docs/development/Expo/expo-commands.md index 6d5e9848c..75abb2264 100644 --- a/docs/development/Expo/expo-commands.md +++ b/docs/development/Expo/expo-commands.md @@ -1,5 +1,5 @@ - ## To check mobile configuration + ``` lerna exec --scope=*mobile-device "expo config --type public" ``` diff --git a/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md b/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md index 69a8a2ffe..86a33acd2 100644 --- a/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md +++ b/docs/development/Mobile/How_To_Make_Expo_Wrok_With_Monorepos.md @@ -1,9 +1,6 @@ - - https://medium.com/habilelabs/react-native-react-web-and-expo-together-in-one-monorepo-5b8f9a0fca00 As per the documentation, expo-yarn-workspaces work only on macOS and UNIX based systems, Windows is not supported. If we want it to work on Windows as well, then we need to make slight modifications to it. Firstly, remove the postinstallscript from package.json and move it to the main package.json- "postinstall": "cd ./packages/ExpoApp && expo-yarn-workspaces postinstall" - diff --git a/docs/development/Mobile/React-Native-FAQ.md b/docs/development/Mobile/React-Native-FAQ.md index ef156e44c..1814e57f7 100644 --- a/docs/development/Mobile/React-Native-FAQ.md +++ b/docs/development/Mobile/React-Native-FAQ.md @@ -1,4 +1,3 @@ - Q1. Uncaught TypeError: Cannot assign to read only property 'exports' of object '#' A1. Because `import` and `module.exports` are not allowed to be mixed in webpack 2, The solution is to change it to ES6. diff --git a/docs/development/Mobile/Run_mobile.md b/docs/development/Mobile/Run_mobile.md index dfb07f027..ecde4f191 100644 --- a/docs/development/Mobile/Run_mobile.md +++ b/docs/development/Mobile/Run_mobile.md @@ -1,4 +1,3 @@ - ### How to run mobile? From the `` of the project, once you finish installation and building all packages, run the following command. @@ -6,4 +5,3 @@ From the `` of the project, once you finish installation and building all ``` lerna exec --scope=*mobile yarn watch ``` - diff --git a/husky.config.js b/husky.config.js index 7ff2a24cf..02366e64e 100644 --- a/husky.config.js +++ b/husky.config.js @@ -1,6 +1,6 @@ module.exports = { - hooks: { - 'pre-commit': 'lint-staged', - //'pre-push': 'yarn test', // when production ready - }, -}; \ No newline at end of file + hooks: { + 'pre-commit': 'lint-staged', + //'pre-push': 'yarn test', // when production ready + }, +}; diff --git a/jest-mongodb-config.js b/jest-mongodb-config.js index efdef0e3f..be24aae07 100644 --- a/jest-mongodb-config.js +++ b/jest-mongodb-config.js @@ -1,12 +1,12 @@ module.exports = { - mongodbMemoryServerOptions: { - instance: { - dbName: 'jest' - }, - binary: { - version: '4.0.12', // Version of MongoDB - skipMD5: true - }, - autoStart: false - } - }; \ No newline at end of file + mongodbMemoryServerOptions: { + instance: { + dbName: 'jest', + }, + binary: { + version: '4.0.12', // Version of MongoDB + skipMD5: true, + }, + autoStart: false, + }, +}; diff --git a/jest-transform-i18next.js b/jest-transform-i18next.js index a86de92ec..426d78d8e 100644 --- a/jest-transform-i18next.js +++ b/jest-transform-i18next.js @@ -1,24 +1,26 @@ -const fs = require('fs'); -const path = require('path'); - -module.exports = { - process() { - const pathname = arguments[1]; - const dir = path.dirname(pathname); - const locales = fs.readdirSync(dir); - const result = {}; - for (const locale of locales) { - if (fs.statSync(path.join(dir, locale)).isDirectory()) { - const localeFiles = fs.readdirSync(path.join(dir, locale)); - for (const localeFile of localeFiles) { - if (localeFile.indexOf('.json') >= 0) { - result[locale] = JSON.parse(fs.readFileSync(path.join(dir, locale, localeFile), 'utf8')); - } - } - } - } - return { - code: `module.exports = ${JSON.stringify(result)};`, - }; - }, -}; +const fs = require('fs'); +const path = require('path'); + +module.exports = { + process() { + const pathname = arguments[1]; + const dir = path.dirname(pathname); + const locales = fs.readdirSync(dir); + const result = {}; + for (const locale of locales) { + if (fs.statSync(path.join(dir, locale)).isDirectory()) { + const localeFiles = fs.readdirSync(path.join(dir, locale)); + for (const localeFile of localeFiles) { + if (localeFile.indexOf('.json') >= 0) { + result[locale] = JSON.parse( + fs.readFileSync(path.join(dir, locale, localeFile), 'utf8') + ); + } + } + } + } + return { + code: `module.exports = ${JSON.stringify(result)};`, + }; + }, +}; diff --git a/jest.config.base.js b/jest.config.base.js index 45161c219..05e086d5e 100755 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -1,60 +1,68 @@ /* eslint-disable import/no-extraneous-dependencies */ -/* eslint-disable @typescript-eslint/no-var-requires */ + const { defaults } = require('jest-config'); module.exports = { - testEnvironment: 'node', - setupFiles: [ - // needed for UI to mock canvas load - // "jest-canvas-mock" - ], - preset: 'ts-jest', - testMatch: null, - testRegex: '.*test*\\.(ts|tsx|js)$', - testPathIgnorePatterns: ['/node_modules/', '/dist/'], - transform: { - '\\.(gql)$': 'jest-transform-graphql', - '\\.(graphql|graphqls)$': 'jest-raw-loader', - '\\.(ts|tsx)$': 'ts-jest', - // Use our custom transformer only for the *.js and *.jsx files - '\\.(js|jsx)?$': './transform.js', - // future need to test with - // "^.+\\.(js|jsx|ts|tsx)$": "./transform.js", - '.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform', - }, - roots: ['packages', 'packages-modules', 'servers'], - moduleFileExtensions: [ - 'tsx', // TODO can be removed as default extension includes - 'ts', // TODO can be removed as default extension includes - ...defaults.moduleFileExtensions, - 'js', // TODO can be removed as default extension includes - 'jsx', // TODO can be removed as default extension includes - 'json', - 'gql', - 'graphql', - ], - moduleNameMapper: { - '^__mocks__/(.*)$': '/../../__mocks__/$1', - // we'll use commonjs version of lodash for tests 👌 - // because we don't need to use any kind of tree shaking right?! - '^lodash-es$': '/node_modules/lodash/index.js', - }, - transformIgnorePatterns: ['/node_modules/(?!(babel-runtime|antd)).*/', '/node_modules/(?!lodash-es/.*)'], - clearMocks: true, - verbose: true, - // projects: [''], // TODO need to test with it https://github.com/bryan-hunter/yarn-workspace-lerna-monorepo/blob/master/jest.config.base.js - coverageDirectory: '/coverage/', - coveragePathIgnorePatterns: ['/build/', '/lib/', '/dist/', '/node_modules/'], - globals: { - __BACKEND_URL__: 'http://localhost:3010', - __GRAPHQL_URL__: 'http://localhost:8085/graphql', - 'ts-jest': { - // tsConfig: "/src/__tests__/tsconfig.json", - // https://github.com/kulshekhar/ts-jest/issues/766 - diagnostics: { - warnOnly: true, - }, - // "skipBabel": true - }, - }, + testEnvironment: 'node', + setupFiles: [ + // needed for UI to mock canvas load + // "jest-canvas-mock" + ], + preset: 'ts-jest', + testMatch: null, + testRegex: '.*test*\\.(ts|tsx|js)$', + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + transform: { + '\\.(gql)$': 'jest-transform-graphql', + '\\.(graphql|graphqls)$': 'jest-raw-loader', + '\\.(ts|tsx)$': 'ts-jest', + // Use our custom transformer only for the *.js and *.jsx files + '\\.(js|jsx)?$': './transform.js', + // future need to test with + // "^.+\\.(js|jsx|ts|tsx)$": "./transform.js", + '.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform', + }, + roots: ['packages', 'packages-modules', 'servers'], + moduleFileExtensions: [ + 'tsx', // TODO can be removed as default extension includes + 'ts', // TODO can be removed as default extension includes + ...defaults.moduleFileExtensions, + 'js', // TODO can be removed as default extension includes + 'jsx', // TODO can be removed as default extension includes + 'json', + 'gql', + 'graphql', + ], + moduleNameMapper: { + '^__mocks__/(.*)$': '/../../__mocks__/$1', + // we'll use commonjs version of lodash for tests 👌 + // because we don't need to use any kind of tree shaking right?! + '^lodash-es$': '/node_modules/lodash/index.js', + }, + transformIgnorePatterns: [ + '/node_modules/(?!(babel-runtime|antd)).*/', + '/node_modules/(?!lodash-es/.*)', + ], + clearMocks: true, + verbose: true, + // projects: [''], // TODO need to test with it https://github.com/bryan-hunter/yarn-workspace-lerna-monorepo/blob/master/jest.config.base.js + coverageDirectory: '/coverage/', + coveragePathIgnorePatterns: [ + '/build/', + '/lib/', + '/dist/', + '/node_modules/', + ], + globals: { + __BACKEND_URL__: 'http://localhost:3010', + __GRAPHQL_URL__: 'http://localhost:8085/graphql', + 'ts-jest': { + // tsConfig: "/src/__tests__/tsconfig.json", + // https://github.com/kulshekhar/ts-jest/issues/766 + diagnostics: { + warnOnly: true, + }, + // "skipBabel": true + }, + }, }; diff --git a/jest.config.js b/jest.config.js index 7e70293b8..efc94e0b7 100755 --- a/jest.config.js +++ b/jest.config.js @@ -1,22 +1,20 @@ -const merge = require('merge') +const merge = require('merge'); const baseConfig = require('./jest.config.base'); -const mongodbConfig = require('./jest.config.mongodb') -module.exports = merge.recursive( - baseConfig, - mongodbConfig, - { - globals: { - - } - }, - // https://baltuta.eu/posts/typescript-lerna-monorepo-more-tools - // { - // roots: [''], - // projects: [ - // '/packages/ui', - // '/packages/api', - // '/packages/diceroll' - // ], - // } +const mongodbConfig = require('./jest.config.mongodb'); -); \ No newline at end of file +module.exports = merge.recursive( + baseConfig, + mongodbConfig, + { + globals: {}, + } + // https://baltuta.eu/posts/typescript-lerna-monorepo-more-tools + // { + // roots: [''], + // projects: [ + // '/packages/ui', + // '/packages/api', + // '/packages/diceroll' + // ], + // } +); diff --git a/jest.config.mongodb.js b/jest.config.mongodb.js index 47c22543a..d4ff007c8 100644 --- a/jest.config.mongodb.js +++ b/jest.config.mongodb.js @@ -1,3 +1,3 @@ module.exports = { - preset: '@shelf/jest-mongodb', + preset: '@shelf/jest-mongodb', }; diff --git a/lerna.json b/lerna.json index 31e87db77..04f0a164b 100755 --- a/lerna.json +++ b/lerna.json @@ -1,49 +1,42 @@ { - "changelog": { - "repo": "cdmbase/lerna-bootstrap", - "labels": { - "tag: breaking change": ":boom: Breaking Change", - "tag: new feature": ":rocket: New Feature", - "tag: bug fix": ":bug: Bug Fix", - "tag: polish": ":nail_care: Polish", - "tag: documentation": "Documentation", - "tag: internal": ":house: Internal" - } - }, - "command": { - "publish": { - "registry": "https://registry.npmjs.org", - "graphType": "all", - "allowBranch": [ - "publish", - "devpublish" - ], - "message": "chore(release): publish", - "ignoreChanges": [ - "**/__fixtures__/**", - "**/__tests__/**", - "**/*.md", - "**/example/**" - ] - }, - "version": { - "allowBranch": [ - "master", - "develop", - "publish", - "devpublish" - ], - "conventionalCommits": true, - "message": "chore: release package(s)" - } - }, - "npmClient": "yarn", - "useWorkspaces": true, - "packages": [ - "packages-modules/**", - "packages/**", - "servers/*", - "portable-devices/*" - ], - "version": "0.0.0" -} \ No newline at end of file + "changelog": { + "repo": "cdmbase/lerna-bootstrap", + "labels": { + "tag: breaking change": ":boom: Breaking Change", + "tag: new feature": ":rocket: New Feature", + "tag: bug fix": ":bug: Bug Fix", + "tag: polish": ":nail_care: Polish", + "tag: documentation": "Documentation", + "tag: internal": ":house: Internal" + } + }, + "command": { + "publish": { + "registry": "https://registry.npmjs.org", + "graphType": "all", + "allowBranch": ["publish", "devpublish"], + "message": "chore(release): publish", + "ignoreChanges": [ + "**/__fixtures__/**", + "**/__tests__/**", + "**/*.md", + "**/example/**" + ] + }, + "version": { + "allowBranch": ["master", "develop", "publish", "devpublish"], + "private": true, + "conventionalCommits": true, + "message": "chore: release package(s)" + } + }, + "npmClient": "yarn", + "useWorkspaces": true, + "packages": [ + "packages-modules/**", + "packages/**", + "servers/*", + "portable-devices/*" + ], + "version": "0.0.0" +} diff --git a/lint-staged.config.js b/lint-staged.config.js index 253c221f7..67167d40b 100644 --- a/lint-staged.config.js +++ b/lint-staged.config.js @@ -1,4 +1,4 @@ module.exports = { - '*.{js,jsx,ts,tsx,json,md}': ['prettier --write', 'git add'], - // '*.{ts,tsx}': ['eslint --fix'], // this can be tested -}; \ No newline at end of file + '*.{js,jsx,ts,tsx,json,md}': ['prettier --write', 'git add'], + // '*.{ts,tsx}': ['eslint --fix'], // this can be tested +}; diff --git a/package.json b/package.json index 4a6d8779d..ed6daf505 100755 --- a/package.json +++ b/package.json @@ -1,346 +1,350 @@ { - "name": "sample-stack", - "version": "0.11.2", - "private": true, - "homepage": "https://github.com/cdmbase/fullstack-pro#readme", - "bugs": { - "url": "https://github.com/cdmbase/fullstack-pro/issues" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/cdmbase/fullstack-pro.git" - }, - "license": "MIT", - "author": { - "name": "CDMBase LLC", - "email": "none@cdmbase.com" - }, - "workspaces": { - "packages": [ - "portable-devices/*", - "packages-modules/**", - "packages/**", - "servers/*" - ] - }, - "scripts": { - "prebootstrap": "lerna run prepare", - "bootstrap": "yarn && yarn lerna", - "postbootstrap": "yarn build", - "build": "yarn build:packages", - "build:clean": "lerna exec yarn build:clean", - "build:packages": "lerna run build --ignore *server --ignore *device --ignore *browser-extension", - "build:packages:watch": "lerna run build:lib:watch --ignore *server --ignore *device --ignore *browser-extension --stream", - "check-updates": "lerna exec ./node_modules/.bin/npm-check-updates -- -u", - "clean": "lerna clean --yes && yarn build:clean && rimraf node_modules", - "clean:force": "rimraf package-lock.json yarn.lock && yarn clean", - "clean:install": "yarn clean:force && yarn git:pull && yarn bootstrap", - "cli": "node tools/cli", - "commit": "git cz", - "compile": "lerna exec -- yarn compile", - "coverage": "jest --coverage", - "postcoverage": "remap-istanbul --input coverage/coverage.raw.json --type lcovonly --output coverage/lcov.info", - "db:migrate": "knex migrate:latest --cwd . --knexfile ./servers/backend-server/knexfile.js", - "db:migrate:rollback": "knex migrate:rollback --cwd . --knexfile ./servers/backend-server/knexfile.js", - "db:seed": "yarn db:migrate && knex seed:run --cwd . --knexfile ./servers/backend-server/knexfile.js", - "predevpublish": "git checkout devpublish && git pull origin devpublish && git merge -s recursive -X theirs develop -m 'merge from develop' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit", - "devpublish": "lerna publish prerelease --ignore-scripts --exact", - "postdevpublish": "git checkout develop", - "devpublish:auto": "yarn devpublish -- --yes", - "devpublish:force": "yarn devpublish:forceManual -- --yes", - "devpublish:forceManual": "yarn devpublish -- --force-publish=*", - "devpublish:push": "yarn predevpublish && git push origin devpublish && yarn postdevpublish", - "format": "yarn lint --fix", - "format:md": "yarn lint:md --fix", - "generateGraphql": "graphql-codegen", - "generateGraphql:watch": "yarn generateGraphql -- --watch", - "git:pull": "git pull origin $(git rev-parse --abbrev-ref HEAD)", - "git:push": "git push origin $(git rev-parse --abbrev-ref HEAD)", - "gitcommit": "git add -A && git diff --staged --quiet || git commit -am 'auto publish [skip ci] \r\n'", - "husky-skip": "cross-env HUSKY_SKIP_HOOKS=1", - "jest": "./node_modules/.bin/jest", - "lerna": "lerna bootstrap", - "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit", - "lernapublish": "lerna publish --ignore-scripts --cd-version=patch", - "postlernapublish": "git checkout master", - "lint": "eslint --ext js --ext ts --ext md", - "lint:ci": "yarn lint . --format junit", - "lint:fix": "yarn lint -- --fix", - "lint:md": "markdownlint", - "lintx": "yarn lint ./packages/**/src/**/*.ts ./packages-modules/**/src/**/*.ts", - "prodBuild": "cross-env NODE_ENV=production babel-node --presets es2015 tools/webpack.run", - "publish": "yarn lernapublish", - "publish:auto": "yarn lernapublish --yes", - "publish:force": "yarn publish:forceManual --yes", - "publish:forceManual": "yarn lernapublish --force-publish=*", - "publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish", - "startWeb": "lerna run --scope='{*frontend-server,*backend-server}' --parallel watch --stream", - "start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb", - "start:envSSR": "cross-env SSR=true NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb", - "start:test": "cross-env NODE_ENV=test ENV_FILE=../../config/test/test.env yarn startWeb", - "test": "cross-env ENV_FILE=config/test/test.env jest", - "posttest": "yarn lint", - "test:watch": "npm test -- --watch", - "pretravis": "yarn compile", - "travis": "istanbul cover -x \"*.test.js\" _mocha -- --timeout 5000 --full-trace ./test/tests.js", - "posttravis": "yarn lint", - "watch": "lerna exec --no-sort --ignore *server --ignore *device --ignore *browser-extension --stream --parallel -- webpack --watch", - "watch-packages": "lerna exec --no-sort --scope @sample-stack/platform* --scope @sample-stack/react-shared-components --scope @sample-stack/core --stream --parallel 'webpack --watch'", - "zen:build": "cross-env NODE_ENV=production zen build", - "zen:exp": "zen exp", - "zen:watch": "zen watch -x", - "zen:watch:debug": "yarn zen:watch -- -v" - }, - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, - "lint-staged": { - "*.md": [ - "yarn format:md", - "git add" - ], - "*.{js,jsx,ts,tsx}": [ - "eslint --fix", - "git add" - ] - }, - "resolutions": { - "@apollo/client": "~3.3.21", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "chokidar": "^3.4.0", - "react": "18.0.0", - "react-dom": "18.0.0", - "react-native-gesture-handler": "~2.5.0" - }, - "dependencies": { - "dataloader": "^2.0.0", - "graphql": "^15.0.0", - "graphql-tag": "^2.11.0" - }, - "devDependencies": { - "@babel/cli": "^7.7.7", - "@babel/core": "^7.7.7", - "@babel/plugin-proposal-class-properties": "^7.7.4", - "@babel/plugin-proposal-decorators": "^7.7.4", - "@babel/plugin-proposal-export-default-from": "^7.7.4", - "@babel/plugin-proposal-export-namespace-from": "^7.7.4", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.7.4", - "@babel/plugin-proposal-object-rest-spread": "^7.7.7", - "@babel/plugin-proposal-optional-chaining": "^7.7.5", - "@babel/plugin-proposal-pipeline-operator": "^7.7.7", - "@babel/plugin-syntax-dynamic-import": "^7.7.4", - "@babel/plugin-syntax-export-default-from": "^7.7.4", - "@babel/plugin-syntax-export-namespace-from": "^7.7.4", - "@babel/plugin-syntax-import-meta": "^7.7.4", - "@babel/plugin-syntax-numeric-separator": "^7.7.4", - "@babel/plugin-transform-destructuring": "^7.7.4", - "@babel/plugin-transform-for-of": "^7.13.0", - "@babel/plugin-transform-modules-commonjs": "^7.7.5", - "@babel/plugin-transform-regenerator": "^7.7.5", - "@babel/plugin-transform-runtime": "^7.7.6", - "@babel/polyfill": "7.7.0", - "@babel/preset-env": "^7.7.7", - "@babel/preset-flow": "^7.7.4", - "@babel/preset-react": "^7.7.4", - "@babel/preset-typescript": "^7.7.7", - "@babel/register": "^7.7.7", - "@babel/runtime": "^7.7.7", - "@loadable/babel-plugin": "^5.10.0", - "@loadable/webpack-plugin": "^5.7.1", - "@graphql-codegen/add": "^2.0.2", - "@graphql-codegen/cli": "^1.21.8", - "@graphql-codegen/fragment-matcher": "^2.0.1", - "@graphql-codegen/import-types-preset": "^1.18.6", - "@graphql-codegen/near-operation-file-preset": "^1.18.6", - "@graphql-codegen/typescript": "^1.23.0", - "@graphql-codegen/typescript-graphql-files-modules": "^1.18.1", - "@graphql-codegen/typescript-operations": "^1.18.4", - "@graphql-codegen/typescript-react-apollo": "^2.3.1", - "@graphql-codegen/typescript-resolvers": "^1.20.0", - "@hot-loader/react-dom": "^17.0.0", - "@open-wc/building-rollup": "^1.10.0", - "@redux-devtools/core": "^3.9.0", - "@redux-devtools/dock-monitor": "^1.4.0", - "@redux-devtools/log-monitor": "^2.3.0", - "@rollup/plugin-graphql": "1.0.0", - "@rollup/plugin-image": "^2.0.6", - "@rollup/plugin-typescript": "^6.1.0", - "@shelf/jest-mongodb": "^2.2.0", - "@testing-library/react": "^12.1.4", - "@types/async": "^3.0.3", - "@types/body-parser": "1.17.1", - "@types/bunyan": "^1.8.6", - "@types/classnames": "^2.2.9", - "@types/cors": "2.8.6", - "@types/enzyme": "^3.10.4", - "@types/express": "^4.17.2", - "@types/hoist-non-react-statics": "^3.3.1", - "@types/ioredis": "^4.14.4", - "@types/isomorphic-fetch": "0.0.35", - "@types/jest": "^26.0.24", - "@types/lodash-es": "^4.17.3", - "@types/minimist": "^1.2.0", - "@types/node": "13.1.0", - "@types/prop-types": "^15.7.3", - "@types/react": "^18.0.0", - "@types/react-dom": "^18.0.0", - "@types/react-helmet": "^5.0.14", - "@types/react-loadable": "^5.5.3", - "@types/react-redux": "^7.1.5", - "@types/react-router": "^5.1.3", - "@types/react-router-config": "^5.0.2", - "@types/react-router-dom": "^5.1.3", - "@types/react-test-renderer": "^17.0.1", - "@types/redux-logger": "^3.0.9", - "@types/semver": "^6.2.0", - "@types/sinon": "^7.5.1", - "@types/webpack": "^4.41.0", - "@types/webpack-env": "^1.14.1", - "@types/zen-observable": "^0.8.0", - "@typescript-eslint/eslint-plugin": "^4.20.0", - "@typescript-eslint/eslint-plugin-tslint": "^4.20.0", - "@typescript-eslint/parser": "^4.20.0", - "@webpack-cli/serve": "^1.6.1", - "@wojtekmaj/enzyme-adapter-react-17": "^0.6.6", - "apollo-server-testing": "^2.25.3", - "autoprefixer": "^9.7.3", - "awesome-typescript-loader": "^5.2.1", - "babel-core": "^7.0.0-bridge.0", - "babel-eslint": "^10.0.3", - "babel-jest": "^26.3.0", - "babel-loader": "^8.0.6", - "babel-plugin-import": "^1.13.3", - "babel-plugin-dynamic-import-node": "^2.3.3", - "caporal": "^1.3.0", - "chokidar": "^3.4.0", - "clean-webpack-plugin": "^4.0.0", - "core-js": "^3.1.3", - "commitizen": "^4.2.3", - "compression-webpack-plugin": "^10.0.0", - "concurrently": "^5.0.2", - "connect": "^3.7.0", - "copy-webpack-plugin": "^6.4.0", - "cross-env": "^6.0.3", - "css-loader": "^3.4.0", - "csstype": "^2.5.5", - "dotenv-safe": "^8.2.0", - "dotenv-webpack": "^8.0.1", - "easygraphql-load-tester": "^2.0.5", - "envalid": "~7.2.2", - "enzyme": "^3.11.0", - "eslint": "^7.23.0", - "eslint-config-airbnb-typescript": "^12.3.1", - "eslint-config-prettier": "^8.1.0", - "eslint-loader": "^4.0.2", - "eslint-plugin-graphql": "^4.0.0", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jest": "^24.3.3", - "eslint-plugin-jsdoc": "^32.3.0", - "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-markdown": "^2.0.1", - "eslint-plugin-no-null": "^1.0.2", - "eslint-plugin-prettier": "^3.3.1", - "eslint-plugin-react": "^7.23.1", - "eslint-plugin-react-hooks": "^4.2.0", - "eslint-plugin-simple-import-sort": "^7.0.0", - "express": "^4.17.1", - "file-loader": "^6.2.0", - "fork-ts-checker-webpack-plugin": "^7.2.11", - "freeport-async": "^2.0.0", - "fs-extra": "^8.1.0", - "html-loader": "^3.1.2", - "html-webpack-plugin": "^5.5.0", - "http-proxy-middleware": "^0.20.0", - "husky": "^5.0.9", - "ignore-loader": "^0.1.2", - "ip": "^1.1.5", - "isomorphic-style-loader": "^5.3.2", - "istanbul": "1.0.0-alpha.2", - "jest": "^26.0.0", - "jest-css-modules-transform": "^3.1.0", - "jest-dom": "^4.0.0", - "jest-junit": "^12.2.0", - "jest-matcher-utils": "^26.0.0", - "jest-raw-loader": "^1.0.1", - "jest-transform-graphql": "^2.1.0", - "jsdom": "^15.2.1", - "lerna": "^4.0.0", - "lint-staged": "^9.5.0", - "lodash": "^4.17.15", - "lodash-es": "^4.17.15", - "lodash-webpack-plugin": "^0.11.5", - "markdownlint-cli": "^0.27.0", - "merge": "^1.2.1", - "mime": "^2.4.4", - "mini-css-extract-plugin": "^2.6.0", - "minilog": "^3.1.0", - "mkdirp": "^0.5.1", - "mocha": "^6.2.2", - "mocha-steps": "^1.3.0", - "module": "^1.2.5", - "morgan": "^1.9.1", - "nock": "^11.7.0", - "node-dev": "^4.0.0", - "nodemon": "^2.0.2", - "nodemon-webpack-plugin": "^4.8.0", - "openurl": "^1.1.1", - "pm2": "^4.2.1", - "postcss-loader": "^7.0.0", - "prettier": "^2.2.1", - "process": "^0.11.10", - "qrcode-terminal": "^0.12.0", - "raw-loader": "^4.0.0", - "node-hmr-plugin": "^1.0.1", - "react-addons-test-utils": "^16.0.0-alpha.3", - "react-hot-loader": "^4.12.18", - "react-test-renderer": "^17.0.2", - "redux-devtools-extension": "^2.13.8", - "redux-mock-store": "^1.5.4", - "remap-istanbul": "^0.13.0", - "resolve-url-loader": "^5.0.0", - "rimraf": "^3.0.0", - "rollup": "^2.53.2", - "rollup-plugin-string": "^3.0.0", - "sass-loader": "^13.0.2", - "shelljs": "^0.8.3", - "simple-git": "^2.42.0", - "sinon": "^8.0.1", - "source-list-map": "^2.0.1", - "source-map-loader": "^4.0.0", - "source-map-support": "^0.5.16", - "standard-version": "^7.0.1", - "style-loader": "^1.1.1", - "svg-url-loader": "^7.1.1", - "tcomb": "^3.2.29", - "ts-jest": "^26.0.0", - "ts-loader": "^9.3.0", - "ts-node": "^8.5.4", - "tslib": "^1.10.0", - "typedoc": "^0.15.5", - "typescript": "~4.7.3", - "uglify-es": "^3.3.9", - "uglifyjs-webpack-plugin": "^2.2.0", - "url-loader": "^4.1.1", - "wait-on": "^6.0.1", - "webpack": "^5.72.1", - "webpack-cli": "^4.9.2", - "webpack-dev-server": "^4.9.0", - "webpack-manifest-plugin": "^5.0.0", - "webpack-merge": "^5.8.0", - "webpack-node-externals": "^3.0.0", - "webpack-sources": "^3.2.3", - "webpack-bundle-analyzer": "^4.5.0", - "ws": "^7.2.1" - }, - "engines": { - "node": ">=14.17.3 < 17.0.0", - "yarn": ">=1.22" - }, - "cacheDirectories": [ - ".cache" - ] + "name": "sample-stack", + "version": "0.11.4", + "private": true, + "homepage": "https://github.com/cdmbase/fullstack-pro#readme", + "bugs": { + "url": "https://github.com/cdmbase/fullstack-pro/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cdmbase/fullstack-pro.git" + }, + "license": "MIT", + "lint-staged": { + "*": "prettier --ignore-unknown --write" + }, + "author": { + "name": "CDMBase LLC", + "email": "none@cdmbase.com" + }, + "workspaces": { + "packages": [ + "portable-devices/*", + "packages-modules/**", + "packages/**", + "servers/*" + ] + }, + "scripts": { + "prebootstrap": "lerna run prepare", + "bootstrap": "yarn && yarn lerna", + "postbootstrap": "yarn build", + "build": "yarn build:packages", + "build:clean": "lerna exec yarn build:clean", + "build:packages": "lerna run build --ignore *server --ignore *device --ignore *browser-extension", + "build:packages:watch": "lerna run build:lib:watch --ignore *server --ignore *device --ignore *browser-extension --stream", + "check-updates": "lerna exec ./node_modules/.bin/npm-check-updates -- -u", + "clean": "lerna clean --yes && yarn build:clean && rimraf node_modules", + "clean:force": "rimraf package-lock.json yarn.lock && yarn clean", + "clean:install": "yarn clean:force && yarn git:pull && yarn bootstrap", + "cli": "node tools/cli", + "commit": "git cz", + "compile": "lerna exec -- yarn compile", + "coverage": "jest --coverage", + "postcoverage": "remap-istanbul --input coverage/coverage.raw.json --type lcovonly --output coverage/lcov.info", + "db:migrate": "knex migrate:latest --cwd . --knexfile ./servers/backend-server/knexfile.js", + "db:migrate:rollback": "knex migrate:rollback --cwd . --knexfile ./servers/backend-server/knexfile.js", + "db:seed": "yarn db:migrate && knex seed:run --cwd . --knexfile ./servers/backend-server/knexfile.js", + "predevpublish": "git checkout devpublish && git pull origin devpublish && git merge -s recursive -X theirs develop -m 'merge from develop' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit", + "devpublish": "lerna publish prerelease --ignore-scripts --exact", + "postdevpublish": "git checkout develop", + "devpublish:auto": "yarn devpublish -- --yes", + "devpublish:force": "yarn devpublish:forceManual -- --yes", + "devpublish:forceManual": "yarn devpublish -- --force-publish=*", + "devpublish:push": "yarn predevpublish && git push origin devpublish && yarn postdevpublish", + "format": "prettier \"**/*\" --ignore-unknown", + "format:write": "yarn format --write", + "format:md": "yarn lint:md --fix", + "generateGraphql": "graphql-codegen", + "generateGraphql:watch": "yarn generateGraphql -- --watch", + "git:pull": "git pull origin $(git rev-parse --abbrev-ref HEAD)", + "git:push": "git push origin $(git rev-parse --abbrev-ref HEAD)", + "gitcommit": "git add -A && git diff --staged --quiet || git commit -am 'auto publish [skip ci] \r\n'", + "husky-skip": "cross-env HUSKY_SKIP_HOOKS=1", + "jest": "./node_modules/.bin/jest", + "lerna": "lerna bootstrap", + "prelernapublish": "git checkout publish && git pull origin publish && git merge -s recursive -X theirs master -m 'merge from master' && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit", + "lernapublish": "lerna publish --ignore-scripts --cd-version=patch", + "postlernapublish": "git checkout master", + "lint": "npx eslint . --max-warnings 0 --report-unused-disable-directives", + "lint:ci": "yarn lint . --format junit", + "lint:fix": "yarn lint -- --fix", + "lint:md": "npx markdownlint \"**/*.md\" \".github/**/*.md\"", + "lint:package": "npmPkgJsonLint .", + "lint:prune": "ts-prune", + "lint:spelling": "cspell \"**\" \".github/**/*\"", + "lintx": "yarn lint ./packages/**/src/**/*.ts ./packages-modules/**/src/**/*.ts", + "prepare": "husky install", + "prodBuild": "cross-env NODE_ENV=production babel-node --presets es2015 tools/webpack.run", + "publish": "yarn lernapublish", + "publish:auto": "yarn lernapublish --yes", + "publish:force": "yarn publish:forceManual --yes", + "publish:forceManual": "yarn lernapublish --force-publish=*", + "publish:push": "yarn prelernapublish && git push origin publish && yarn postlernapublish", + "startWeb": "lerna run --scope='{*frontend-server,*backend-server}' --parallel watch --stream", + "start": "cross-env NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb", + "start:envSSR": "cross-env SSR=true NODE_ENV=development ENV_FILE=../../config/development/dev.env yarn startWeb", + "start:test": "cross-env NODE_ENV=test ENV_FILE=../../config/test/test.env yarn startWeb", + "test": "cross-env ENV_FILE=config/test/test.env jest", + "posttest": "yarn lint", + "test:watch": "npm test -- --watch", + "pretravis": "yarn compile", + "travis": "istanbul cover -x \"*.test.js\" _mocha -- --timeout 5000 --full-trace ./test/tests.js", + "posttravis": "yarn lint", + "watch": "lerna exec --no-sort --ignore *server --ignore *device --ignore *browser-extension --stream --parallel -- webpack --watch", + "watch-packages": "lerna exec --no-sort --scope @sample-stack/platform* --scope @sample-stack/react-shared-components --scope @sample-stack/core --stream --parallel 'webpack --watch'", + "zen:build": "cross-env NODE_ENV=production zen build", + "zen:exp": "zen exp", + "zen:watch": "zen watch -x", + "zen:watch:debug": "yarn zen:watch -- -v" + }, + "resolutions": { + "@apollo/client": "~3.3.21", + "@types/react": "^18.0.25", + "@types/react-dom": "^18.0.8", + "chokidar": "^3.5.3", + "react": "18.0.0", + "react-dom": "18.0.0", + "react-native-gesture-handler": "~2.5.0" + }, + "dependencies": { + "dataloader": "^2.1.0", + "graphql": "^15.0.0", + "graphql-tag": "^2.12.6" + }, + "devDependencies": { + "@babel/cli": "^7.19.3", + "@babel/core": "^7.20.2", + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/plugin-proposal-decorators": "^7.20.2", + "@babel/plugin-proposal-export-default-from": "^7.18.10", + "@babel/plugin-proposal-export-namespace-from": "^7.18.9", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", + "@babel/plugin-proposal-object-rest-spread": "^7.20.2", + "@babel/plugin-proposal-optional-chaining": "^7.18.9", + "@babel/plugin-proposal-pipeline-operator": "^7.18.9", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-default-from": "^7.18.6", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-transform-destructuring": "^7.20.2", + "@babel/plugin-transform-for-of": "^7.18.8", + "@babel/plugin-transform-modules-commonjs": "^7.19.6", + "@babel/plugin-transform-regenerator": "^7.18.6", + "@babel/plugin-transform-runtime": "^7.19.6", + "@babel/polyfill": "7.12.1", + "@babel/preset-env": "^7.20.2", + "@babel/preset-flow": "^7.18.6", + "@babel/preset-react": "^7.18.6", + "@babel/preset-typescript": "^7.18.6", + "@babel/register": "^7.18.9", + "@babel/runtime": "^7.20.1", + "@graphql-codegen/add": "^2.0.2", + "@graphql-codegen/cli": "^1.21.8", + "@graphql-codegen/fragment-matcher": "^2.0.1", + "@graphql-codegen/import-types-preset": "^1.18.6", + "@graphql-codegen/near-operation-file-preset": "^1.18.6", + "@graphql-codegen/typescript": "^1.23.0", + "@graphql-codegen/typescript-graphql-files-modules": "^1.18.1", + "@graphql-codegen/typescript-operations": "^1.18.4", + "@graphql-codegen/typescript-react-apollo": "^2.3.1", + "@graphql-codegen/typescript-resolvers": "^1.20.0", + "@loadable/babel-plugin": "^5.13.2", + "@loadable/webpack-plugin": "^5.15.2", + "@open-wc/building-rollup": "^2.0.2", + "@pmmmwh/react-refresh-webpack-plugin": "^0.5.8", + "@redux-devtools/core": "^3.13.1", + "@redux-devtools/dock-monitor": "^3.0.1", + "@redux-devtools/log-monitor": "^4.0.1", + "@rollup/plugin-graphql": "2.0.2", + "@rollup/plugin-image": "^3.0.1", + "@rollup/plugin-typescript": "^9.0.2", + "@shelf/jest-mongodb": "^4.1.3", + "@svgr/webpack": "^6.5.1", + "@testing-library/react": "^13.4.0", + "@types/async": "^3.2.15", + "@types/body-parser": "1.19.2", + "@types/bunyan": "^1.8.8", + "@types/classnames": "^2.3.1", + "@types/cors": "2.8.12", + "@types/enzyme": "^3.10.12", + "@types/express": "^4.17.14", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/ioredis": "^5.0.0", + "@types/isomorphic-fetch": "0.0.36", + "@types/jest": "^29.2.2", + "@types/lodash-es": "^4.17.6", + "@types/minimist": "^1.2.2", + "@types/node": "^18.11.9", + "@types/prop-types": "^15.7.5", + "@types/react": "^18.0.25", + "@types/react-dom": "^18.0.8", + "@types/react-helmet": "^6.1.5", + "@types/react-loadable": "^5.5.6", + "@types/react-redux": "^7.1.24", + "@types/react-router": "^5.1.19", + "@types/react-router-config": "^5.0.6", + "@types/react-router-dom": "^5.3.3", + "@types/react-test-renderer": "^18.0.0", + "@types/redux-logger": "^3.0.9", + "@types/semver": "^7.3.13", + "@types/sinon": "^10.0.13", + "@types/webpack": "^5.28.0", + "@types/webpack-env": "^1.18.0", + "@types/zen-observable": "^0.8.3", + "@typescript-eslint/eslint-plugin": "^5.42.1", + "@typescript-eslint/eslint-plugin-tslint": "^5.42.1", + "@typescript-eslint/parser": "^5.42.1", + "@webpack-cli/serve": "^1.7.0", + "@wojtekmaj/enzyme-adapter-react-17": "^0.7.0", + "apollo-server-testing": "^2.25.3", + "autoprefixer": "^10.4.13", + "awesome-typescript-loader": "^5.2.1", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^10.1.0", + "babel-jest": "^29.3.0", + "babel-loader": "^9.1.0", + "babel-plugin-dynamic-import-node": "^2.3.3", + "babel-plugin-import": "^1.13.5", + "caporal": "^1.4.0", + "chokidar": "^3.5.3", + "clean-webpack-plugin": "^4.0.0", + "commitizen": "^4.2.5", + "compression-webpack-plugin": "^10.0.0", + "concurrently": "^7.5.0", + "connect": "^3.7.0", + "copy-webpack-plugin": "^11.0.0", + "core-js": "^3.26.0", + "cross-env": "^7.0.3", + "cspell": "^6.12.0", + "css-loader": "^6.7.1", + "csstype": "^3.1.1", + "dotenv-safe": "^8.2.0", + "dotenv-webpack": "^8.0.1", + "easygraphql-load-tester": "^2.0.5", + "enzyme": "^3.11.0", + "esbuild": "^0.15.13", + "eslint": "^8.27.0", + "eslint-config-airbnb-typescript": "^17.0.0", + "eslint-config-prettier": "^8.5.0", + "eslint-loader": "^4.0.2", + "eslint-plugin-graphql": "^4.0.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jest": "^27.1.4", + "eslint-plugin-jsdoc": "^39.6.2", + "eslint-plugin-json": "^3.1.0", + "eslint-plugin-jsonc": "^2.5.0", + "eslint-plugin-jsx-a11y": "^6.6.1", + "eslint-plugin-markdown": "^3.0.0", + "eslint-plugin-no-null": "^1.0.2", + "eslint-plugin-package-json": "^0.1.4", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-react": "^7.31.10", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-simple-import-sort": "^8.0.0", + "eslint-plugin-typescript-sort-keys": "^2.1.0", + "express": "^4.18.2", + "file-loader": "^6.2.0", + "fork-ts-checker-webpack-plugin": "^7.2.13", + "freeport-async": "^2.0.0", + "fs-extra": "^10.1.0", + "html-loader": "^4.2.0", + "html-webpack-plugin": "^5.5.0", + "http-proxy-middleware": "^2.0.6", + "husky": "^8.0.2", + "ignore-loader": "^0.1.2", + "ip": "^1.1.8", + "isomorphic-style-loader": "^5.3.2", + "istanbul": "1.0.0-alpha.2", + "jest": "^29.3.0", + "jest-css-modules-transform": "^4.4.2", + "jest-dom": "^4.0.0", + "jest-junit": "^14.0.1", + "jest-matcher-utils": "^29.2.2", + "jest-raw-loader": "^1.0.1", + "jest-transform-graphql": "^2.1.0", + "jsdom": "^20.0.2", + "jsonc-eslint-parser": "^2.1.0", + "lerna": "^6.0.3", + "lint-staged": "^13.0.3", + "lodash": "^4.17.21", + "lodash-es": "^4.17.21", + "lodash-webpack-plugin": "^0.11.6", + "markdownlint-cli": "^0.32.2", + "merge": "^2.1.1", + "mime": "^3.0.0", + "mini-css-extract-plugin": "^2.6.1", + "minilog": "^3.1.0", + "mkdirp": "^1.0.4", + "mocha": "^10.1.0", + "mocha-steps": "^1.3.0", + "module": "^1.2.5", + "morgan": "^1.10.0", + "nock": "^13.2.9", + "node-dev": "^7.4.3", + "node-hmr-plugin": "^1.0.1", + "nodemon": "^2.0.20", + "nodemon-webpack-plugin": "^4.8.1", + "npm-package-json-lint": "^6.3.0", + "npm-package-json-lint-config-default": "^5.0.0", + "openurl": "^1.1.1", + "pm2": "^5.2.2", + "postcss-loader": "^7.0.1", + "prettier": "^2.7.1", + "process": "^0.11.10", + "qrcode-terminal": "^0.12.0", + "raw-loader": "^4.0.2", + "react-addons-test-utils": "^16.0.0-alpha.3", + "react-refresh": "^0.14.0", + "react-test-renderer": "^18.2.0", + "redux-devtools-extension": "^2.13.9", + "redux-mock-store": "^1.5.4", + "remap-istanbul": "^0.13.0", + "resolve-url-loader": "^5.0.0", + "rimraf": "^3.0.2", + "rollup": "^3.2.5", + "rollup-plugin-esbuild": "^5.0.0", + "rollup-plugin-string": "^3.0.0", + "sass-loader": "^13.1.0", + "shelljs": "^0.8.5", + "simple-git": "^3.14.1", + "sinon": "^14.0.2", + "source-list-map": "^2.0.1", + "source-map-loader": "^4.0.1", + "source-map-support": "^0.5.21", + "standard-version": "^9.5.0", + "style-loader": "^3.3.1", + "svg-url-loader": "^8.0.0", + "tcomb": "^3.2.29", + "ts-jest": "^29.0.3", + "ts-loader": "^9.4.1", + "ts-node": "^10.9.1", + "tslib": "^2.4.1", + "ts-prune": "^0.10.3", + "type-fest": "^3.2.0", + "typedoc": "^0.23.20", + "typescript": "~4.8.4", + "uglify-es": "^3.3.9", + "uglifyjs-webpack-plugin": "^2.2.0", + "url-loader": "^4.1.1", + "wait-on": "^6.0.1", + "webpack": "^5.74.0", + "webpack-bundle-analyzer": "^4.7.0", + "webpack-cli": "^4.10.0", + "webpack-dev-server": "^4.11.1", + "webpack-manifest-plugin": "^5.0.0", + "webpack-merge": "^5.8.0", + "webpack-node-externals": "^3.0.0", + "webpack-sources": "^3.2.3", + "ws": "^8.11.0" + }, + "engines": { + "node": ">=14.17.3 < 17.0.0", + "yarn": ">=1.22" + }, + "cacheDirectories": [ + ".cache" + ] } diff --git a/packages-modules/counter/browser/jest.config.js b/packages-modules/counter/browser/jest.config.js index 858217e24..951369848 100644 --- a/packages-modules/counter/browser/jest.config.js +++ b/packages-modules/counter/browser/jest.config.js @@ -2,8 +2,8 @@ const base = require('../../../jest.config.base'); const packageJson = require('./package'); module.exports = { - ...base, - testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment - name: packageJson.name, - displayName: packageJson.name, -}; \ No newline at end of file + ...base, + testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment + name: packageJson.name, + displayName: packageJson.name, +}; diff --git a/packages-modules/counter/browser/package.json b/packages-modules/counter/browser/package.json index 75c900219..5dbef980a 100755 --- a/packages-modules/counter/browser/package.json +++ b/packages-modules/counter/browser/package.json @@ -1,66 +1,66 @@ { - "name": "@sample-stack/counter-module-browser", - "version": "0.0.1", - "description": "Sample core for higher packages to depend on", - "license": "ISC", - "author": "CDMBase LLC", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "scripts": { - "build": "yarn build:clean && yarn build:lib", - "build:clean": "rimraf lib", - "build:lib": "rollup -c rollup.config.js", - "build:lib:watch": "yarn build:lib -- --watch", - "jest": "./node_modules/.bin/jest", - "prepublish": "yarn build", - "test": "cross-env ENV_FILE=../../config/test/test.env jest", - "test:debug": "npm test -- --runInBand", - "test:watch": "npm test -- --watch", - "watch": "yarn build:lib:watch" - }, - "jest": { - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "modulePaths": [ - "node_modules" - ], - "roots": [ - "src" - ], - "testEnvironment": "node", - "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", - "transform": { - "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" - } - }, - "dependencies": { - "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", - "antd": "~4.15.3" - }, - "devDependencies": {}, - "peerDependencies": { - "@common-stack/client-react": "*", - "@rollup/plugin-graphql": "*", - "@rollup/plugin-image": "*", - "@rollup/plugin-typescript": "*", - "react": "*", - "react-native": "*", - "react-redux": "*", - "react-router": "*", - "react-router-dom": "*", - "redux": "*", - "redux-observable": "*", - "rollup-plugin-string": "*", - "rxjs": "*" - }, - "publishConfig": { - "access": "public" - }, - "typescript": { - "definition": "lib/index.d.ts" - } -} \ No newline at end of file + "name": "@sample-stack/counter-module-browser", + "version": "0.0.1", + "description": "Sample core for higher packages to depend on", + "license": "ISC", + "author": "CDMBase LLC", + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "scripts": { + "build": "yarn build:clean && yarn build:lib", + "build:clean": "rimraf lib", + "build:lib": "rollup -c rollup.config.mjs", + "build:lib:watch": "yarn build:lib -- --watch", + "jest": "./node_modules/.bin/jest", + "prepublish": "yarn build", + "test": "cross-env ENV_FILE=../../config/test/test.env jest", + "test:debug": "npm test -- --runInBand", + "test:watch": "npm test -- --watch", + "watch": "yarn build:lib:watch" + }, + "jest": { + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ], + "modulePaths": [ + "node_modules" + ], + "roots": [ + "src" + ], + "testEnvironment": "node", + "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", + "transform": { + "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" + } + }, + "dependencies": { + "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", + "antd": "~4.24.1" + }, + "devDependencies": {}, + "peerDependencies": { + "@common-stack/client-react": "*", + "@rollup/plugin-graphql": "*", + "@rollup/plugin-image": "*", + "@rollup/plugin-typescript": "*", + "react": "*", + "react-native": "*", + "react-redux": "*", + "react-router": "*", + "react-router-dom": "*", + "redux": "*", + "redux-observable": "*", + "rollup-plugin-string": "*", + "rxjs": "*" + }, + "publishConfig": { + "access": "public" + }, + "typescript": { + "definition": "lib/index.d.ts" + } +} diff --git a/packages-modules/counter/browser/rollup.config.js b/packages-modules/counter/browser/rollup.config.js deleted file mode 100644 index 78e79fc1c..000000000 --- a/packages-modules/counter/browser/rollup.config.js +++ /dev/null @@ -1,40 +0,0 @@ -import graphql from '@rollup/plugin-graphql'; -import image from '@rollup/plugin-image'; -import typescript from '@rollup/plugin-typescript'; -import { string } from 'rollup-plugin-string'; - -const bundle = (config) => ({ - ...config, - input: 'src/index.ts', - // marking all node modules as external - external: (id) => !/^[./]/.test(id), -}); -const globals = { react: 'React' }; - -export default [ - bundle({ - plugins: [ - image(), - graphql({ - include: '**/*.gql', - }), - string({ - include: '**/*.graphql', - }), - typescript({ noEmitOnError: true }), - ], - output: [ - { - dir: 'lib', - format: 'es', - name: 'Counter', - compact: true, - exports: 'named', - sourcemap: true, - preserveModules: true, - chunkFileNames: '[name]-[hash].[format].js', - globals, - }, - ], - }), -]; diff --git a/packages-modules/counter/browser/rollup.config.mjs b/packages-modules/counter/browser/rollup.config.mjs new file mode 100644 index 000000000..882d35161 --- /dev/null +++ b/packages-modules/counter/browser/rollup.config.mjs @@ -0,0 +1,40 @@ +import graphql from '@rollup/plugin-graphql'; +import image from '@rollup/plugin-image'; +import typescript from '@rollup/plugin-typescript'; +import { string } from 'rollup-plugin-string'; + +const bundle = (config) => ({ + ...config, + input: 'src/index.ts', + // marking all node modules as external + external: (id) => !/^[./]/.test(id), +}); +const globals = { react: 'React' }; + +export default [ + bundle({ + plugins: [ + image(), + graphql({ + include: '**/*.gql', + }), + string({ + include: '**/*.graphql', + }), + typescript({ noEmitOnError: true }), + ], + output: [ + { + dir: 'lib', + format: 'es', + name: 'Counter', + compact: true, + exports: 'named', + sourcemap: true, + preserveModules: true, + chunkFileNames: '[name]-[hash].[format].js', + globals, + }, + ], + }), +]; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/components/CounterView.tsx b/packages-modules/counter/browser/src/apollo-server-n-client/components/CounterView.tsx index 8e9725d0b..54dc49800 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/components/CounterView.tsx +++ b/packages-modules/counter/browser/src/apollo-server-n-client/components/CounterView.tsx @@ -1,97 +1,109 @@ import * as React from 'react'; import { Helmet } from 'react-helmet'; - /** * @description Plain`CounterView` component without any data dependency. */ const CounterView = ({ - loading, - counter, - addCounter, - counterState, - addCounterState, - onReduxIncrement, - reduxCount, - getCounterLoading, - addCounterWs, - getCounter, - syncCachedCounter, - cachedData, + loading, + counter, + addCounter, + counterState, + addCounterState, + onReduxIncrement, + reduxCount, + getCounterLoading, + addCounterWs, + getCounter, + syncCachedCounter, + cachedData, }: any) => { - - const renderMetaData = () => ( - - Counter - - - ); - if (loading) { - return ( -
- {renderMetaData()} -
Loading Page...
-
- ); - } else { - return ( -
- {renderMetaData()} -
-

- Current counter, is {counter.amount} and cached data. This is being stored - server-side in the database and using Apollo subscription for - real-time updates. -

- - -
-
-

- Get Counter Cache - {getCounterLoading ? "Loading Counter Data..." : cachedData ? {cachedData.counterCache.amount} : null} -
- - -

-
-
-

- Current reduxCount, is {reduxCount}. This is being stored - client-side with Redux. -

- -
-
-

- Current apolloLinkStateCount, is {counterState}. This is being - stored client-side with Apollo Link State. -

- -
-
- ); - } + const renderMetaData = () => ( + + Counter + + + ); + if (loading) { + return ( +
+ {renderMetaData()} +
Loading Page...
+
+ ); + } else { + return ( +
+ {renderMetaData()} +
+

+ Current counter, is {counter.amount} and cached data. This is being + stored server-side in the database and using Apollo subscription for + real-time updates. +

+ + +
+
+

+ Get Counter Cache + {getCounterLoading ? ( + 'Loading Counter Data...' + ) : cachedData ? ( + + {' '} + {cachedData.counterCache.amount} + + ) : null} +
+ + +

+
+
+

+ Current reduxCount, is {reduxCount}. This is being stored + client-side with Redux. +

+ +
+
+

+ Current apolloLinkStateCount, is {counterState}. This is being + stored client-side with Apollo Link State. +

+ +
+
+ ); + } }; export default CounterView; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/compute.tsx b/packages-modules/counter/browser/src/apollo-server-n-client/compute.tsx index 65eb982bf..c1ca7eeeb 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/compute.tsx +++ b/packages-modules/counter/browser/src/apollo-server-n-client/compute.tsx @@ -1,38 +1,44 @@ import * as React from 'react'; import { IMenuPosition } from '@common-stack/client-react'; -import { lazy } from '@loadable/component' +import { lazy } from '@loadable/component'; import { getFilteredMenus, getFilteredRoutes } from '../utils'; const Dashboard = lazy(() => import('../common/components/Dashboard')); const Counter = lazy(() => import('./containers/Counter')); export const counterPageStore: any[] = [ - { - exact: false, - icon: 'export', - key: 'dashboard', - component: Dashboard, - tab: 'Apollo Server & Client', - position: IMenuPosition.MIDDLE, - name: 'Apollo Server & Client', - path: '/apollo-server-n-client', - }, - { - key: 'counter', - name: 'Counter', - icon: 'appstore-o', - component: Counter, - position: IMenuPosition.MIDDLE, - path: '/apollo-server-n-client/counter', - }, + { + exact: false, + icon: 'export', + key: 'dashboard', + component: Dashboard, + tab: 'Apollo Server & Client', + position: IMenuPosition.MIDDLE, + name: 'Apollo Server & Client', + path: '/apollo-server-n-client', + }, + { + key: 'counter', + name: 'Counter', + icon: 'appstore-o', + component: Counter, + position: IMenuPosition.MIDDLE, + path: '/apollo-server-n-client/counter', + }, ]; const selectedRoutesAndMenus = ['dashboard', 'counter']; // get menus -const filteredMenus = getFilteredMenus(counterPageStore, selectedRoutesAndMenus); +const filteredMenus = getFilteredMenus( + counterPageStore, + selectedRoutesAndMenus +); // get routes -const filteredRoutes = getFilteredRoutes(counterPageStore, selectedRoutesAndMenus); +const filteredRoutes = getFilteredRoutes( + counterPageStore, + selectedRoutesAndMenus +); export { filteredMenus, filteredRoutes }; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/containers/Counter.tsx b/packages-modules/counter/browser/src/apollo-server-n-client/containers/Counter.tsx index be1a2cbf8..4421c942b 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/containers/Counter.tsx +++ b/packages-modules/counter/browser/src/apollo-server-n-client/containers/Counter.tsx @@ -6,119 +6,127 @@ import update from 'immutability-helper'; import { useDispatch, useSelector } from 'react-redux'; import CounterView from '../components/CounterView'; import { - useCounterQueryQuery, - useAddCounterMutation, - useAddCounterStateMutation, - useCounterStateQuery, - useAddCounter_WsMutation, - useSyncCachedCounterMutation, - useCounterCacheQueryLazyQuery + useCounterQueryQuery, + useAddCounterMutation, + useAddCounterStateMutation, + useCounterStateQuery, + useAddCounter_WsMutation, + useSyncCachedCounterMutation, + useCounterCacheQueryLazyQuery, } from '../generated-model'; -import { - OnCounterUpdatedDocument, -} from '../../common/generated-models'; +import { OnCounterUpdatedDocument } from '../../common/generated-models'; /** - * + * * @description Counter Component with Data dependency. */ const CounterWithApollo: React.FC = (props) => { - const [addCounterMutation] = useAddCounterMutation(); - const { loading, error, data: counterData, subscribeToMore, } = useCounterQueryQuery(); - const [addCounterStateMutation] = useAddCounterStateMutation(); - const { data: couterStateData } = useCounterStateQuery(); - const dispatch = useDispatch(); - const reduxCount = useSelector(state => (state as any).counter.reduxCount); - const [getCounter, { loading: getCounterLoading, data: cachedData }] = useCounterCacheQueryLazyQuery({ fetchPolicy: 'network-only' }); - const [addCounterWs] = useAddCounter_WsMutation(); - const [syncCachedCounter] = useSyncCachedCounterMutation(); + const [addCounterMutation] = useAddCounterMutation(); + const { + loading, + error, + data: counterData, + subscribeToMore, + } = useCounterQueryQuery(); + const [addCounterStateMutation] = useAddCounterStateMutation(); + const { data: couterStateData } = useCounterStateQuery(); + const dispatch = useDispatch(); + const reduxCount = useSelector((state) => (state as any).counter.reduxCount); + const [getCounter, { loading: getCounterLoading, data: cachedData }] = + useCounterCacheQueryLazyQuery({ fetchPolicy: 'network-only' }); + const [addCounterWs] = useAddCounter_WsMutation(); + const [syncCachedCounter] = useSyncCachedCounterMutation(); - useEffect(() => { - const unsubscribe = subscribeToMore(getSubscriptionOptions({})); - return () => unsubscribe(); - }, [subscribeToMore]); + useEffect(() => { + const unsubscribe = subscribeToMore(getSubscriptionOptions({})); + return () => unsubscribe(); + }, [subscribeToMore]); - const onReduxIncrement = (value) => () => { - dispatch({ - type: 'COUNTER_INCREMENT', - value: Number(value), - }); - } - const addCounter = (amount) => () => { - addCounterMutation({ - variables: { amount }, - // Update the Cache of the Query that need to be display when it's dependent mutation gets called. - // This is needed for two reasons - // a). When update the Optimistically update cache, this get executes - // b). When the mutation response from Server, this gets update. - // Note: Optimistically update wont' work when network is offline. - update: (cache, { data: { addCounter } }) => { - // update the query's cache manually - // recommend to be done using fields but it can be done directly updating the cache - cache.modify({ - fields: { - counter(prev) { - return { amount: addCounter.amount }; - } - } - }) - }, - // Optimistically update the amount to the locally cached - // before the server responds - // You can verify it by setting the "Network conditions" in devtools to `Slow 3G`. - // You will see the data gets updated before the server responds. - optimisticResponse: { - // __typename: 'Mutation', - addCounter: { - __typename: 'Counter', - amount: counterData?.counter.amount + amount, - } - } - }) - } + const onReduxIncrement = (value) => () => { + dispatch({ + type: 'COUNTER_INCREMENT', + value: Number(value), + }); + }; + const addCounter = (amount) => () => { + addCounterMutation({ + variables: { amount }, + // Update the Cache of the Query that need to be display when it's dependent mutation gets called. + // This is needed for two reasons + // a). When update the Optimistically update cache, this get executes + // b). When the mutation response from Server, this gets update. + // Note: Optimistically update wont' work when network is offline. + update: (cache, { data: { addCounter } }) => { + // update the query's cache manually + // recommend to be done using fields but it can be done directly updating the cache + cache.modify({ + fields: { + counter(prev) { + return { amount: addCounter.amount }; + }, + }, + }); + }, + // Optimistically update the amount to the locally cached + // before the server responds + // You can verify it by setting the "Network conditions" in devtools to `Slow 3G`. + // You will see the data gets updated before the server responds. + optimisticResponse: { + // __typename: 'Mutation', + addCounter: { + __typename: 'Counter', + amount: counterData?.counter.amount + amount, + }, + }, + }); + }; - const addCounterState = (amount) => () => { - addCounterStateMutation({ - variables: { amount } - }); - } - const getSubscriptionOptions = ({ }) => { - return { - document: OnCounterUpdatedDocument, - variables: {}, - updateQuery: (prev, - { - subscriptionData: { - data: { - counterUpdated: { amount }, - }, - } - }) => { - return update(prev, { - counter: { - amount: { - $set: amount, - }, - }, - }); - } - } - } + const addCounterState = (amount) => () => { + addCounterStateMutation({ + variables: { amount }, + }); + }; + const getSubscriptionOptions = ({}) => { + return { + document: OnCounterUpdatedDocument, + variables: {}, + updateQuery: ( + prev, + { + subscriptionData: { + data: { + counterUpdated: { amount }, + }, + }, + } + ) => { + return update(prev, { + counter: { + amount: { + $set: amount, + }, + }, + }); + }, + }; + }; - return -} + return ( + + ); +}; -export default CounterWithApollo; \ No newline at end of file +export default CounterWithApollo; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/generated-model.tsx b/packages-modules/counter/browser/src/apollo-server-n-client/generated-model.tsx index c27ba4f05..ab535c9d3 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/generated-model.tsx +++ b/packages-modules/counter/browser/src/apollo-server-n-client/generated-model.tsx @@ -6,22 +6,38 @@ import * as Apollo from '@apollo/client'; import * as React from 'react'; import * as ApolloReactComponents from '@apollo/client/react/components'; export type Omit = Pick>; -const defaultOptions = {} +const defaultOptions = {}; export const AddCounterStateDocument = gql` - mutation addCounterState($amount: Int!) { - addCounterState(amount: $amount) @client { - counter - } -} - `; -export type AddCounterStateMutationFn = Apollo.MutationFunction; -export type AddCounterStateComponentProps = Omit, 'mutation'>; + mutation addCounterState($amount: Int!) { + addCounterState(amount: $amount) @client { + counter + } + } +`; +export type AddCounterStateMutationFn = Apollo.MutationFunction< + SchemaTypes.AddCounterStateMutation, + SchemaTypes.AddCounterStateMutationVariables +>; +export type AddCounterStateComponentProps = Omit< + ApolloReactComponents.MutationComponentOptions< + SchemaTypes.AddCounterStateMutation, + SchemaTypes.AddCounterStateMutationVariables + >, + 'mutation' +>; - export const AddCounterStateComponent = (props: AddCounterStateComponentProps) => ( - mutation={AddCounterStateDocument} {...props} /> - ); - +export const AddCounterStateComponent = ( + props: AddCounterStateComponentProps +) => ( + + mutation={AddCounterStateDocument} + {...props} + /> +); /** * __useAddCounterStateMutation__ @@ -40,27 +56,55 @@ export type AddCounterStateComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounterStateDocument, options); - } -export type AddCounterStateMutationHookResult = ReturnType; -export type AddCounterStateMutationResult = Apollo.MutationResult; -export type AddCounterStateMutationOptions = Apollo.BaseMutationOptions; -export const AddCounterDocument = gql` - mutation addCounter($amount: Int!) { - addCounter(amount: $amount) { - amount - } +export function useAddCounterStateMutation( + baseOptions?: Apollo.MutationHookOptions< + SchemaTypes.AddCounterStateMutation, + SchemaTypes.AddCounterStateMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + SchemaTypes.AddCounterStateMutation, + SchemaTypes.AddCounterStateMutationVariables + >(AddCounterStateDocument, options); } - `; -export type AddCounterMutationFn = Apollo.MutationFunction; -export type AddCounterComponentProps = Omit, 'mutation'>; +export type AddCounterStateMutationHookResult = ReturnType< + typeof useAddCounterStateMutation +>; +export type AddCounterStateMutationResult = + Apollo.MutationResult; +export type AddCounterStateMutationOptions = Apollo.BaseMutationOptions< + SchemaTypes.AddCounterStateMutation, + SchemaTypes.AddCounterStateMutationVariables +>; +export const AddCounterDocument = gql` + mutation addCounter($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } +`; +export type AddCounterMutationFn = Apollo.MutationFunction< + SchemaTypes.AddCounterMutation, + SchemaTypes.AddCounterMutationVariables +>; +export type AddCounterComponentProps = Omit< + ApolloReactComponents.MutationComponentOptions< + SchemaTypes.AddCounterMutation, + SchemaTypes.AddCounterMutationVariables + >, + 'mutation' +>; - export const AddCounterComponent = (props: AddCounterComponentProps) => ( - mutation={AddCounterDocument} {...props} /> - ); - +export const AddCounterComponent = (props: AddCounterComponentProps) => ( + + mutation={AddCounterDocument} + {...props} + /> +); /** * __useAddCounterMutation__ @@ -79,27 +123,55 @@ export type AddCounterComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounterDocument, options); - } -export type AddCounterMutationHookResult = ReturnType; -export type AddCounterMutationResult = Apollo.MutationResult; -export type AddCounterMutationOptions = Apollo.BaseMutationOptions; -export const AddCounter_WsDocument = gql` - mutation AddCounter_WS($amount: Int!) { - addCounter(amount: $amount) { - amount - } +export function useAddCounterMutation( + baseOptions?: Apollo.MutationHookOptions< + SchemaTypes.AddCounterMutation, + SchemaTypes.AddCounterMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + SchemaTypes.AddCounterMutation, + SchemaTypes.AddCounterMutationVariables + >(AddCounterDocument, options); } - `; -export type AddCounter_WsMutationFn = Apollo.MutationFunction; -export type AddCounter_WsComponentProps = Omit, 'mutation'>; +export type AddCounterMutationHookResult = ReturnType< + typeof useAddCounterMutation +>; +export type AddCounterMutationResult = + Apollo.MutationResult; +export type AddCounterMutationOptions = Apollo.BaseMutationOptions< + SchemaTypes.AddCounterMutation, + SchemaTypes.AddCounterMutationVariables +>; +export const AddCounter_WsDocument = gql` + mutation AddCounter_WS($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } +`; +export type AddCounter_WsMutationFn = Apollo.MutationFunction< + SchemaTypes.AddCounter_WsMutation, + SchemaTypes.AddCounter_WsMutationVariables +>; +export type AddCounter_WsComponentProps = Omit< + ApolloReactComponents.MutationComponentOptions< + SchemaTypes.AddCounter_WsMutation, + SchemaTypes.AddCounter_WsMutationVariables + >, + 'mutation' +>; - export const AddCounter_WsComponent = (props: AddCounter_WsComponentProps) => ( - mutation={AddCounter_WsDocument} {...props} /> - ); - +export const AddCounter_WsComponent = (props: AddCounter_WsComponentProps) => ( + + mutation={AddCounter_WsDocument} + {...props} + /> +); /** * __useAddCounter_WsMutation__ @@ -118,25 +190,55 @@ export type AddCounter_WsComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounter_WsDocument, options); - } -export type AddCounter_WsMutationHookResult = ReturnType; -export type AddCounter_WsMutationResult = Apollo.MutationResult; -export type AddCounter_WsMutationOptions = Apollo.BaseMutationOptions; -export const SyncCachedCounterDocument = gql` - mutation SyncCachedCounter { - syncCachedCounter +export function useAddCounter_WsMutation( + baseOptions?: Apollo.MutationHookOptions< + SchemaTypes.AddCounter_WsMutation, + SchemaTypes.AddCounter_WsMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + SchemaTypes.AddCounter_WsMutation, + SchemaTypes.AddCounter_WsMutationVariables + >(AddCounter_WsDocument, options); } - `; -export type SyncCachedCounterMutationFn = Apollo.MutationFunction; -export type SyncCachedCounterComponentProps = Omit, 'mutation'>; +export type AddCounter_WsMutationHookResult = ReturnType< + typeof useAddCounter_WsMutation +>; +export type AddCounter_WsMutationResult = + Apollo.MutationResult; +export type AddCounter_WsMutationOptions = Apollo.BaseMutationOptions< + SchemaTypes.AddCounter_WsMutation, + SchemaTypes.AddCounter_WsMutationVariables +>; +export const SyncCachedCounterDocument = gql` + mutation SyncCachedCounter { + syncCachedCounter + } +`; +export type SyncCachedCounterMutationFn = Apollo.MutationFunction< + SchemaTypes.SyncCachedCounterMutation, + SchemaTypes.SyncCachedCounterMutationVariables +>; +export type SyncCachedCounterComponentProps = Omit< + ApolloReactComponents.MutationComponentOptions< + SchemaTypes.SyncCachedCounterMutation, + SchemaTypes.SyncCachedCounterMutationVariables + >, + 'mutation' +>; - export const SyncCachedCounterComponent = (props: SyncCachedCounterComponentProps) => ( - mutation={SyncCachedCounterDocument} {...props} /> - ); - +export const SyncCachedCounterComponent = ( + props: SyncCachedCounterComponentProps +) => ( + + mutation={SyncCachedCounterDocument} + {...props} + /> +); /** * __useSyncCachedCounterMutation__ @@ -154,26 +256,53 @@ export type SyncCachedCounterComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(SyncCachedCounterDocument, options); - } -export type SyncCachedCounterMutationHookResult = ReturnType; -export type SyncCachedCounterMutationResult = Apollo.MutationResult; -export type SyncCachedCounterMutationOptions = Apollo.BaseMutationOptions; -export const CounterCacheQueryDocument = gql` - query counterCacheQuery { - counterCache { - amount - } +export function useSyncCachedCounterMutation( + baseOptions?: Apollo.MutationHookOptions< + SchemaTypes.SyncCachedCounterMutation, + SchemaTypes.SyncCachedCounterMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + SchemaTypes.SyncCachedCounterMutation, + SchemaTypes.SyncCachedCounterMutationVariables + >(SyncCachedCounterDocument, options); } - `; -export type CounterCacheQueryComponentProps = Omit, 'query'>; +export type SyncCachedCounterMutationHookResult = ReturnType< + typeof useSyncCachedCounterMutation +>; +export type SyncCachedCounterMutationResult = + Apollo.MutationResult; +export type SyncCachedCounterMutationOptions = Apollo.BaseMutationOptions< + SchemaTypes.SyncCachedCounterMutation, + SchemaTypes.SyncCachedCounterMutationVariables +>; +export const CounterCacheQueryDocument = gql` + query counterCacheQuery { + counterCache { + amount + } + } +`; +export type CounterCacheQueryComponentProps = Omit< + ApolloReactComponents.QueryComponentOptions< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables + >, + 'query' +>; - export const CounterCacheQueryComponent = (props: CounterCacheQueryComponentProps) => ( - query={CounterCacheQueryDocument} {...props} /> - ); - +export const CounterCacheQueryComponent = ( + props: CounterCacheQueryComponentProps +) => ( + + query={CounterCacheQueryDocument} + {...props} + /> +); /** * __useCounterCacheQueryQuery__ @@ -190,30 +319,64 @@ export type CounterCacheQueryComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterCacheQueryDocument, options); - } -export function useCounterCacheQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterCacheQueryDocument, options); - } -export type CounterCacheQueryQueryHookResult = ReturnType; -export type CounterCacheQueryLazyQueryHookResult = ReturnType; -export type CounterCacheQueryQueryResult = Apollo.QueryResult; -export const CounterStateDocument = gql` - query CounterState { - counterState @client { - counter - } +export function useCounterCacheQueryQuery( + baseOptions?: Apollo.QueryHookOptions< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables + >(CounterCacheQueryDocument, options); } - `; -export type CounterStateComponentProps = Omit, 'query'>; +export function useCounterCacheQueryLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables + >(CounterCacheQueryDocument, options); +} +export type CounterCacheQueryQueryHookResult = ReturnType< + typeof useCounterCacheQueryQuery +>; +export type CounterCacheQueryLazyQueryHookResult = ReturnType< + typeof useCounterCacheQueryLazyQuery +>; +export type CounterCacheQueryQueryResult = Apollo.QueryResult< + SchemaTypes.CounterCacheQueryQuery, + SchemaTypes.CounterCacheQueryQueryVariables +>; +export const CounterStateDocument = gql` + query CounterState { + counterState @client { + counter + } + } +`; +export type CounterStateComponentProps = Omit< + ApolloReactComponents.QueryComponentOptions< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables + >, + 'query' +>; - export const CounterStateComponent = (props: CounterStateComponentProps) => ( - query={CounterStateDocument} {...props} /> - ); - +export const CounterStateComponent = (props: CounterStateComponentProps) => ( + + query={CounterStateDocument} + {...props} + /> +); /** * __useCounterStateQuery__ @@ -230,30 +393,64 @@ export type CounterStateComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterStateDocument, options); - } -export function useCounterStateLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterStateDocument, options); - } -export type CounterStateQueryHookResult = ReturnType; -export type CounterStateLazyQueryHookResult = ReturnType; -export type CounterStateQueryResult = Apollo.QueryResult; -export const CounterQueryDocument = gql` - query counterQuery { - counter { - amount - } +export function useCounterStateQuery( + baseOptions?: Apollo.QueryHookOptions< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables + >(CounterStateDocument, options); } - `; -export type CounterQueryComponentProps = Omit, 'query'>; +export function useCounterStateLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables + >(CounterStateDocument, options); +} +export type CounterStateQueryHookResult = ReturnType< + typeof useCounterStateQuery +>; +export type CounterStateLazyQueryHookResult = ReturnType< + typeof useCounterStateLazyQuery +>; +export type CounterStateQueryResult = Apollo.QueryResult< + SchemaTypes.CounterStateQuery, + SchemaTypes.CounterStateQueryVariables +>; +export const CounterQueryDocument = gql` + query counterQuery { + counter { + amount + } + } +`; +export type CounterQueryComponentProps = Omit< + ApolloReactComponents.QueryComponentOptions< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables + >, + 'query' +>; - export const CounterQueryComponent = (props: CounterQueryComponentProps) => ( - query={CounterQueryDocument} {...props} /> - ); - +export const CounterQueryComponent = (props: CounterQueryComponentProps) => ( + + query={CounterQueryDocument} + {...props} + /> +); /** * __useCounterQueryQuery__ @@ -270,30 +467,66 @@ export type CounterQueryComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterQueryDocument, options); - } -export function useCounterQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterQueryDocument, options); - } -export type CounterQueryQueryHookResult = ReturnType; -export type CounterQueryLazyQueryHookResult = ReturnType; -export type CounterQueryQueryResult = Apollo.QueryResult; -export const OnCounterUpdatedDocument = gql` - subscription onCounterUpdated { - counterUpdated { - amount - } +export function useCounterQueryQuery( + baseOptions?: Apollo.QueryHookOptions< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables + >(CounterQueryDocument, options); +} +export function useCounterQueryLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables + >(CounterQueryDocument, options); } - `; -export type OnCounterUpdatedComponentProps = Omit, 'subscription'>; +export type CounterQueryQueryHookResult = ReturnType< + typeof useCounterQueryQuery +>; +export type CounterQueryLazyQueryHookResult = ReturnType< + typeof useCounterQueryLazyQuery +>; +export type CounterQueryQueryResult = Apollo.QueryResult< + SchemaTypes.CounterQueryQuery, + SchemaTypes.CounterQueryQueryVariables +>; +export const OnCounterUpdatedDocument = gql` + subscription onCounterUpdated { + counterUpdated { + amount + } + } +`; +export type OnCounterUpdatedComponentProps = Omit< + ApolloReactComponents.SubscriptionComponentOptions< + SchemaTypes.OnCounterUpdatedSubscription, + SchemaTypes.OnCounterUpdatedSubscriptionVariables + >, + 'subscription' +>; - export const OnCounterUpdatedComponent = (props: OnCounterUpdatedComponentProps) => ( - subscription={OnCounterUpdatedDocument} {...props} /> - ); - +export const OnCounterUpdatedComponent = ( + props: OnCounterUpdatedComponentProps +) => ( + + subscription={OnCounterUpdatedDocument} + {...props} + /> +); /** * __useOnCounterUpdatedSubscription__ @@ -310,9 +543,20 @@ export type OnCounterUpdatedComponentProps = Omit) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(OnCounterUpdatedDocument, options); - } -export type OnCounterUpdatedSubscriptionHookResult = ReturnType; -export type OnCounterUpdatedSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file +export function useOnCounterUpdatedSubscription( + baseOptions?: Apollo.SubscriptionHookOptions< + SchemaTypes.OnCounterUpdatedSubscription, + SchemaTypes.OnCounterUpdatedSubscriptionVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSubscription< + SchemaTypes.OnCounterUpdatedSubscription, + SchemaTypes.OnCounterUpdatedSubscriptionVariables + >(OnCounterUpdatedDocument, options); +} +export type OnCounterUpdatedSubscriptionHookResult = ReturnType< + typeof useOnCounterUpdatedSubscription +>; +export type OnCounterUpdatedSubscriptionResult = + Apollo.SubscriptionResult; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client-test-helper.ts b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client-test-helper.ts index 151bb08a3..df308d3c1 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client-test-helper.ts +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client-test-helper.ts @@ -16,27 +16,27 @@ type Mutation { `; const cache = new InMemoryCache({ - dataIdFromObject: (object) => getDataIdFromObject(object), + dataIdFromObject: (object) => getDataIdFromObject(object), }); -const params: ApolloClientOptions = { - cache, - resolvers, - // typeDefs: defaultSchema.concat(schema as any), // if client schema exist +const params: ApolloClientOptions = { + cache, + resolvers, + // typeDefs: defaultSchema.concat(schema as any), // if client schema exist }; const links = []; const client = new ApolloClient({ - queryDeduplication: true, - link: ApolloLink.from(links), - cache, + queryDeduplication: true, + link: ApolloLink.from(links), + cache, }); function getDataIdFromObject(result: any) { - if (dataIdFromObject[result.__typename]) { - return dataIdFromObject[result.__typename](result); - } - return result.id || result._id; + if (dataIdFromObject[result.__typename]) { + return dataIdFromObject[result.__typename](result); + } + return result.id || result._id; } export { client, getDataIdFromObject }; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client.test.ts b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client.test.ts index 60ee7a9e6..f008d18e3 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client.test.ts +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/__tests__/apollo-client.test.ts @@ -3,12 +3,15 @@ import { AddCounterDocument } from '../../../generated-models'; import 'jest'; describe('Apollo Client tests', () => { - it('client test', async () => { - const result = await client.mutate({ - mutation: AddCounterDocument, - variables: { amount: 1 }, - // data: {}, - }); - expect(result).toEqual({ data: { addCounterState: null }, errors: undefined }); - }); + it('client test', async () => { + const result = await client.mutate({ + mutation: AddCounterDocument, + variables: { amount: 1 }, + // data: {}, + }); + expect(result).toEqual({ + data: { addCounterState: null }, + errors: undefined, + }); + }); }); diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.client.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.client.gql index cac341d28..286133075 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.client.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.client.gql @@ -1,5 +1,5 @@ mutation addCounterState($amount: Int!) { - addCounterState(amount: $amount) @client { - counter - } -} \ No newline at end of file + addCounterState(amount: $amount) @client { + counter + } +} diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.gql index 4a39d2acf..9d1d81fb0 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter.gql @@ -1,5 +1,5 @@ mutation addCounter($amount: Int!) { - addCounter(amount: $amount) { - amount - } + addCounter(amount: $amount) { + amount + } } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter_WS.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter_WS.gql index 6818b1767..0c9b5a020 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter_WS.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/AddCounter_WS.gql @@ -1,5 +1,5 @@ mutation AddCounter_WS($amount: Int!) { - addCounter(amount: $amount) { - amount - } + addCounter(amount: $amount) { + amount + } } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/SyncCachedCounter.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/SyncCachedCounter.gql index 19596c94e..8d65b01d0 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/SyncCachedCounter.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/mutations/SyncCachedCounter.gql @@ -1,3 +1,3 @@ mutation SyncCachedCounter { - syncCachedCounter + syncCachedCounter } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterCacheQuery_WS.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterCacheQuery_WS.gql index 17ab27800..65dc95f0b 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterCacheQuery_WS.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterCacheQuery_WS.gql @@ -1,5 +1,5 @@ query counterCacheQuery { - counterCache { - amount - } + counterCache { + amount + } } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.client.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.client.gql index c85ffc569..930c933b6 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.client.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.client.gql @@ -1,5 +1,5 @@ query CounterState { - counterState @client { - counter - } -} \ No newline at end of file + counterState @client { + counter + } +} diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.gql index 64418ccc1..7550afa8a 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/queries/CounterQuery.gql @@ -1,5 +1,5 @@ query counterQuery { - counter { - amount - } + counter { + amount + } } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/resolvers/resolvers.ts b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/resolvers/resolvers.ts index ecba32f88..c421b26f7 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/resolvers/resolvers.ts +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/resolvers/resolvers.ts @@ -7,48 +7,52 @@ import { CounterStateDocument } from '../../../generated-models'; const TYPE_NAME = 'CounterState'; const stateDefault: IClientStateDefault = { - type: 'query', - query: CounterStateDocument, - data: { - counterState: { - counter: 1, - __typename: TYPE_NAME, - }, - }, + type: 'query', + query: CounterStateDocument, + data: { + counterState: { + counter: 1, + __typename: TYPE_NAME, + }, + }, }; const resolvers = { - Query: { - counterState: (_, args, { cache }) => { - const { - counterState: { counter }, - } = cache.readQuery({ query: CounterStateDocument }); - return { - counter, - __typename: TYPE_NAME, - }; - }, - }, - Mutation: { - addCounterState: async (_, { amount }, { cache }: { cache: InMemoryCache }) => { - const { - counterState: { counter }, - } = cache.readQuery({ query: CounterStateDocument }); - const newAmount = amount + counter; + Query: { + counterState: (_, args, { cache }) => { + const { + counterState: { counter }, + } = cache.readQuery({ query: CounterStateDocument }); + return { + counter, + __typename: TYPE_NAME, + }; + }, + }, + Mutation: { + addCounterState: async ( + _, + { amount }, + { cache }: { cache: InMemoryCache } + ) => { + const { + counterState: { counter }, + } = cache.readQuery({ query: CounterStateDocument }) as any; + const newAmount = amount + counter; - await cache.writeQuery({ - query: CounterStateDocument, - data: { - counterState: { - counter: newAmount, - __typename: TYPE_NAME, - }, - }, - }); + await cache.writeQuery({ + query: CounterStateDocument, + data: { + counterState: { + counter: newAmount, + __typename: TYPE_NAME, + }, + }, + }); - return null; - }, - }, + return null; + }, + }, }; export { stateDefault, resolvers }; diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/schema/counter-state.graphql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/schema/counter-state.graphql index 9674b4cca..1ba4654b8 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/schema/counter-state.graphql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/schema/counter-state.graphql @@ -1,11 +1,10 @@ - type ClientCounter { - counter: Int + counter: Int } extend type Query { - counterState: ClientCounter + counterState: ClientCounter } extend type Mutation { - addCounterState(amount: Int!): ClientCounter -} \ No newline at end of file + addCounterState(amount: Int!): ClientCounter +} diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/subscriptions/CounterSubscription.gql b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/subscriptions/CounterSubscription.gql index b2ce3fec9..8f9fb3edc 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/graphql/subscriptions/CounterSubscription.gql +++ b/packages-modules/counter/browser/src/apollo-server-n-client/graphql/subscriptions/CounterSubscription.gql @@ -1,5 +1,5 @@ subscription onCounterUpdated { - counterUpdated { - amount - } + counterUpdated { + amount + } } diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/module.tsx b/packages-modules/counter/browser/src/apollo-server-n-client/module.tsx index 6cf1eda6b..544270cef 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/module.tsx +++ b/packages-modules/counter/browser/src/apollo-server-n-client/module.tsx @@ -5,8 +5,8 @@ import { Feature } from '@common-stack/client-react'; import { filteredMenus, filteredRoutes } from './compute'; export default new Feature({ - menuConfig: filteredMenus, - routeConfig: filteredRoutes, - reducer: { counter: reducers }, - clientStateParams: { resolvers, defaults: [stateDefault] }, + menuConfig: filteredMenus, + routeConfig: filteredRoutes, + reducer: { counter: reducers }, + clientStateParams: { resolvers, defaults: [stateDefault] }, }); diff --git a/packages-modules/counter/browser/src/apollo-server-n-client/redux/reducers/index.ts b/packages-modules/counter/browser/src/apollo-server-n-client/redux/reducers/index.ts index bc46ec54e..db43ce1ca 100755 --- a/packages-modules/counter/browser/src/apollo-server-n-client/redux/reducers/index.ts +++ b/packages-modules/counter/browser/src/apollo-server-n-client/redux/reducers/index.ts @@ -1,16 +1,16 @@ const defaultState = { - reduxCount: 1, + reduxCount: 1, }; export const reducers = function (state = defaultState, action) { - switch (action.type) { - case 'COUNTER_INCREMENT': - return { - ...state, - reduxCount: state.reduxCount + action.value, - }; + switch (action.type) { + case 'COUNTER_INCREMENT': + return { + ...state, + reduxCount: state.reduxCount + action.value, + }; - default: - return state; - } + default: + return state; + } }; diff --git a/packages-modules/counter/browser/src/common/components/Dashboard.tsx b/packages-modules/counter/browser/src/common/components/Dashboard.tsx index f1ce50960..85bd6ecf7 100755 --- a/packages-modules/counter/browser/src/common/components/Dashboard.tsx +++ b/packages-modules/counter/browser/src/common/components/Dashboard.tsx @@ -1,4 +1,6 @@ import * as React from 'react'; import { renderRoutes } from 'react-router-config'; -export default (props) => <>{renderRoutes(props.route.routes, { matchPath: props.route.path })}; +export default (props) => ( + <>{renderRoutes(props.route.routes, { matchPath: props.route.path })} +); diff --git a/packages-modules/counter/browser/src/common/components/Home.tsx b/packages-modules/counter/browser/src/common/components/Home.tsx index 5c589c8c0..8c1bef095 100755 --- a/packages-modules/counter/browser/src/common/components/Home.tsx +++ b/packages-modules/counter/browser/src/common/components/Home.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; export default () => ( -
-

FullStack-Pro

-
+
+

FullStack-Pro

+
); diff --git a/packages-modules/counter/browser/src/common/compute.tsx b/packages-modules/counter/browser/src/common/compute.tsx index eec4925ce..4d2ef1bb8 100755 --- a/packages-modules/counter/browser/src/common/compute.tsx +++ b/packages-modules/counter/browser/src/common/compute.tsx @@ -1,20 +1,20 @@ import * as React from 'react'; import { IMenuPosition } from '@common-stack/client-react'; -import { lazy } from '@loadable/component' +import { lazy } from '@loadable/component'; import { getFilteredMenus, getFilteredRoutes } from '../utils'; const Home = lazy(() => import('../common/components/Home')); export const commonPageStore: any[] = [ - { - path: '/', - key: 'home', - exact: true, - name: 'Home', - component: Home, - position: IMenuPosition.MIDDLE, - }, + { + path: '/', + key: 'home', + exact: true, + name: 'Home', + component: Home, + position: IMenuPosition.MIDDLE, + }, ]; const selectedRoutesAndMenus = ['home']; @@ -23,6 +23,9 @@ const selectedRoutesAndMenus = ['home']; const filteredMenus = getFilteredMenus(commonPageStore, selectedRoutesAndMenus); // get routes -const filteredRoutes = getFilteredRoutes(commonPageStore, selectedRoutesAndMenus); +const filteredRoutes = getFilteredRoutes( + commonPageStore, + selectedRoutesAndMenus +); export { filteredMenus, filteredRoutes }; diff --git a/packages-modules/counter/browser/src/common/generated-models.ts b/packages-modules/counter/browser/src/common/generated-models.ts index 589e5e78d..de0f7c870 100755 --- a/packages-modules/counter/browser/src/common/generated-models.ts +++ b/packages-modules/counter/browser/src/common/generated-models.ts @@ -1,6 +1,10 @@ /* tslint:disable */ -import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; +import { + GraphQLResolveInfo, + GraphQLScalarType, + GraphQLScalarTypeConfig, +} from 'graphql'; import gql from 'graphql-tag'; import { MyContext } from './interfaces/context'; @@ -8,249 +12,309 @@ import { MyContext } from './interfaces/context'; export type Maybe = T | null; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: string; - String: string; - Boolean: boolean; - Int: number; - Float: number; - AnyObject: any; - JSON: any; - JSONObject: any; - Date: any; - Time: any; - DateTime: any; + ID: string; + String: string; + Boolean: boolean; + Int: number; + Float: number; + AnyObject: any; + JSON: any; + JSONObject: any; + Date: any; + Time: any; + DateTime: any; }; export type ClientCounter = { - counter?: Maybe; + counter?: Maybe; }; export type Counter = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type FieldError = { - field: Scalars['String']; - message: Scalars['String']; + field: Scalars['String']; + message: Scalars['String']; }; export type Mutation = { - dummy?: Maybe; - addCounterState?: Maybe; - addCounter?: Maybe; + dummy?: Maybe; + addCounterState?: Maybe; + addCounter?: Maybe; }; export type MutationAddCounterStateArgs = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type MutationAddCounterArgs = { - amount?: Maybe; + amount?: Maybe; }; export type Node = { - id: Scalars['ID']; + id: Scalars['ID']; }; export type Query = { - dummy?: Maybe; - counterState?: Maybe; - counter?: Maybe; + dummy?: Maybe; + counterState?: Maybe; + counter?: Maybe; }; export type Subscription = { - dummy?: Maybe; - counterUpdated?: Maybe; + dummy?: Maybe; + counterUpdated?: Maybe; }; export type AddCounterStateMutationVariables = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type AddCounterStateMutation = { __typename?: 'Mutation' } & { - addCounterState: Maybe<{ __typename?: 'ClientCounter' } & Pick>; + addCounterState: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; }; export type AddCounterMutationVariables = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type AddCounterMutation = { __typename?: 'Mutation' } & { - addCounter: Maybe<{ __typename?: 'Counter' } & Pick>; + addCounter: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type CounterStateQueryVariables = {}; export type CounterStateQuery = { __typename?: 'Query' } & { - counterState: Maybe<{ __typename?: 'ClientCounter' } & Pick>; + counterState: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; }; export type CounterQueryQueryVariables = {}; export type CounterQueryQuery = { __typename?: 'Query' } & { - counter: Maybe<{ __typename?: 'Counter' } & Pick>; + counter: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type OnCounterUpdatedSubscriptionVariables = {}; export type OnCounterUpdatedSubscription = { __typename?: 'Subscription' } & { - counterUpdated: Maybe<{ __typename?: 'Counter' } & Pick>; + counterUpdated: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type ResolverFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => Promise | TResult; export type StitchingResolver = { - fragment: string; - resolve: ResolverFn; + fragment: string; + resolve: ResolverFn; }; export type Resolver = - | ResolverFn - | StitchingResolver; + | ResolverFn + | StitchingResolver; export type SubscriptionSubscribeFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => AsyncIterator | Promise>; export type SubscriptionResolveFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; export interface SubscriptionResolverObject { - subscribe: SubscriptionSubscribeFn; - resolve?: SubscriptionResolveFn; + subscribe: SubscriptionSubscribeFn; + resolve?: SubscriptionResolveFn; } -export type SubscriptionResolver = - | ((...args: any[]) => SubscriptionResolverObject) - | SubscriptionResolverObject; +export type SubscriptionResolver< + TResult, + TParent = {}, + TContext = {}, + TArgs = {} +> = + | (( + ...args: any[] + ) => SubscriptionResolverObject) + | SubscriptionResolverObject; export type TypeResolveFn = ( - parent: TParent, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + context: TContext, + info: GraphQLResolveInfo ) => Maybe; export type NextResolverFn = () => Promise; -export type DirectiveResolverFn = ( - next: NextResolverFn, - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, +export type DirectiveResolverFn< + TResult = {}, + TParent = {}, + TContext = {}, + TArgs = {} +> = ( + next: NextResolverFn, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; /** Mapping between all available schema types and the resolvers types */ export type ResolversTypes = { - Query: {}; - Int: Scalars['Int']; - ClientCounter: ClientCounter; - Counter: Counter; - Mutation: {}; - Subscription: {}; - String: Scalars['String']; - Boolean: Scalars['Boolean']; - AnyObject: Scalars['AnyObject']; - JSON: Scalars['JSON']; - JSONObject: Scalars['JSONObject']; - FieldError: FieldError; - Node: Node; - ID: Scalars['ID']; - Date: Scalars['Date']; - Time: Scalars['Time']; - DateTime: Scalars['DateTime']; + Query: {}; + Int: Scalars['Int']; + ClientCounter: ClientCounter; + Counter: Counter; + Mutation: {}; + Subscription: {}; + String: Scalars['String']; + Boolean: Scalars['Boolean']; + AnyObject: Scalars['AnyObject']; + JSON: Scalars['JSON']; + JSONObject: Scalars['JSONObject']; + FieldError: FieldError; + Node: Node; + ID: Scalars['ID']; + Date: Scalars['Date']; + Time: Scalars['Time']; + DateTime: Scalars['DateTime']; }; -export interface AnyObjectScalarConfig extends GraphQLScalarTypeConfig { - name: 'AnyObject'; +export interface AnyObjectScalarConfig + extends GraphQLScalarTypeConfig { + name: 'AnyObject'; } -export type ClientCounterResolvers = { - counter?: Resolver, ParentType, ContextType>; +export type ClientCounterResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['ClientCounter'] +> = { + counter?: Resolver, ParentType, ContextType>; }; -export type CounterResolvers = { - amount?: Resolver; +export type CounterResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Counter'] +> = { + amount?: Resolver; }; -export interface DateScalarConfig extends GraphQLScalarTypeConfig { - name: 'Date'; +export interface DateScalarConfig + extends GraphQLScalarTypeConfig { + name: 'Date'; } -export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig { - name: 'DateTime'; +export interface DateTimeScalarConfig + extends GraphQLScalarTypeConfig { + name: 'DateTime'; } -export type FieldErrorResolvers = { - field?: Resolver; - message?: Resolver; +export type FieldErrorResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['FieldError'] +> = { + field?: Resolver; + message?: Resolver; }; -export interface JsonScalarConfig extends GraphQLScalarTypeConfig { - name: 'JSON'; +export interface JsonScalarConfig + extends GraphQLScalarTypeConfig { + name: 'JSON'; } -export interface JsonObjectScalarConfig extends GraphQLScalarTypeConfig { - name: 'JSONObject'; +export interface JsonObjectScalarConfig + extends GraphQLScalarTypeConfig { + name: 'JSONObject'; } -export type MutationResolvers = { - dummy?: Resolver, ParentType, ContextType>; - addCounterState?: Resolver< - Maybe, - ParentType, - ContextType, - MutationAddCounterStateArgs - >; - addCounter?: Resolver, ParentType, ContextType, MutationAddCounterArgs>; +export type MutationResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Mutation'] +> = { + dummy?: Resolver, ParentType, ContextType>; + addCounterState?: Resolver< + Maybe, + ParentType, + ContextType, + MutationAddCounterStateArgs + >; + addCounter?: Resolver< + Maybe, + ParentType, + ContextType, + MutationAddCounterArgs + >; }; -export type NodeResolvers = { - __resolveType: TypeResolveFn; - id?: Resolver; +export type NodeResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Node'] +> = { + __resolveType: TypeResolveFn; + id?: Resolver; }; -export type QueryResolvers = { - dummy?: Resolver, ParentType, ContextType>; - counterState?: Resolver, ParentType, ContextType>; - counter?: Resolver, ParentType, ContextType>; +export type QueryResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Query'] +> = { + dummy?: Resolver, ParentType, ContextType>; + counterState?: Resolver< + Maybe, + ParentType, + ContextType + >; + counter?: Resolver, ParentType, ContextType>; }; -export type SubscriptionResolvers = { - dummy?: SubscriptionResolver, ParentType, ContextType>; - counterUpdated?: SubscriptionResolver, ParentType, ContextType>; +export type SubscriptionResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Subscription'] +> = { + dummy?: SubscriptionResolver< + Maybe, + ParentType, + ContextType + >; + counterUpdated?: SubscriptionResolver< + Maybe, + ParentType, + ContextType + >; }; -export interface TimeScalarConfig extends GraphQLScalarTypeConfig { - name: 'Time'; +export interface TimeScalarConfig + extends GraphQLScalarTypeConfig { + name: 'Time'; } export type Resolvers = { - AnyObject?: GraphQLScalarType; - ClientCounter?: ClientCounterResolvers; - Counter?: CounterResolvers; - Date?: GraphQLScalarType; - DateTime?: GraphQLScalarType; - FieldError?: FieldErrorResolvers; - JSON?: GraphQLScalarType; - JSONObject?: GraphQLScalarType; - Mutation?: MutationResolvers; - Node?: NodeResolvers; - Query?: QueryResolvers; - Subscription?: SubscriptionResolvers; - Time?: GraphQLScalarType; + AnyObject?: GraphQLScalarType; + ClientCounter?: ClientCounterResolvers; + Counter?: CounterResolvers; + Date?: GraphQLScalarType; + DateTime?: GraphQLScalarType; + FieldError?: FieldErrorResolvers; + JSON?: GraphQLScalarType; + JSONObject?: GraphQLScalarType; + Mutation?: MutationResolvers; + Node?: NodeResolvers; + Query?: QueryResolvers; + Subscription?: SubscriptionResolvers; + Time?: GraphQLScalarType; }; /** @@ -261,37 +325,37 @@ export type IResolvers = Resolvers; export type Omit = Pick>; export const AddCounterStateDocument = gql` - mutation addCounterState($amount: Int!) { - addCounterState(amount: $amount) @client { - counter - } - } + mutation addCounterState($amount: Int!) { + addCounterState(amount: $amount) @client { + counter + } + } `; export const AddCounterDocument = gql` - mutation addCounter($amount: Int!) { - addCounter(amount: $amount) { - amount - } - } + mutation addCounter($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } `; export const CounterStateDocument = gql` - query CounterState { - counterState @client { - counter - } - } + query CounterState { + counterState @client { + counter + } + } `; export const CounterQueryDocument = gql` - query counterQuery { - counter { - amount - } - } + query counterQuery { + counter { + amount + } + } `; export const OnCounterUpdatedDocument = gql` - subscription onCounterUpdated { - counterUpdated { - amount - } - } + subscription onCounterUpdated { + counterUpdated { + amount + } + } `; diff --git a/packages-modules/counter/browser/src/common/interfaces/context.ts b/packages-modules/counter/browser/src/common/interfaces/context.ts index acb8051de..b512fd3cc 100755 --- a/packages-modules/counter/browser/src/common/interfaces/context.ts +++ b/packages-modules/counter/browser/src/common/interfaces/context.ts @@ -2,7 +2,11 @@ import { DataProxy } from '@apollo/client/cache'; import { ApolloClient } from '@apollo/client'; export interface MyContext { - cache: DataProxy; - getCacheKey: (options: { __typename: string; resource?: string; id?: string }) => string; - apolloClient: ApolloClient; + cache: DataProxy; + getCacheKey: (options: { + __typename: string; + resource?: string; + id?: string; + }) => string; + apolloClient: ApolloClient; } diff --git a/packages-modules/counter/browser/src/common/module.tsx b/packages-modules/counter/browser/src/common/module.tsx index da9194b0e..6171ee6a8 100755 --- a/packages-modules/counter/browser/src/common/module.tsx +++ b/packages-modules/counter/browser/src/common/module.tsx @@ -1,9 +1,9 @@ -import * as React from 'react'; +import * as React from 'react'; import { Feature } from '@common-stack/client-react'; import { filteredMenus, filteredRoutes } from './compute'; export default new Feature({ - menuConfig: filteredMenus, - routeConfig: filteredRoutes, + menuConfig: filteredMenus, + routeConfig: filteredRoutes, }); diff --git a/packages-modules/counter/browser/src/connected-react-router/README.md b/packages-modules/counter/browser/src/connected-react-router/README.md index c3e235afe..3043e9f25 100755 --- a/packages-modules/counter/browser/src/connected-react-router/README.md +++ b/packages-modules/counter/browser/src/connected-react-router/README.md @@ -4,7 +4,6 @@ You can try changing counter value and editing some components. Components will In Hello link, you will see that the HelloChild component can access router state (URL path) without passing as props via its parent. - Reference: -https://github.com/supasate/connected-react-router/tree/master/examples/typescript \ No newline at end of file +https://github.com/supasate/connected-react-router/tree/master/examples/typescript diff --git a/packages-modules/counter/browser/src/connected-react-router/__tests__/connected-react-router-module.test.ts b/packages-modules/counter/browser/src/connected-react-router/__tests__/connected-react-router-module.test.ts index 46a696489..49fe21875 100755 --- a/packages-modules/counter/browser/src/connected-react-router/__tests__/connected-react-router-module.test.ts +++ b/packages-modules/counter/browser/src/connected-react-router/__tests__/connected-react-router-module.test.ts @@ -3,15 +3,15 @@ import Module from '../module'; import 'jest'; describe('connector modules', () => { - it('module configuredRoutes', () => { - const configuredRoutes = Module.getConfiguredRoutes(); + it('module configuredRoutes', () => { + const configuredRoutes = Module.getConfiguredRoutes(); - expect(configuredRoutes).toMatchSnapshot(); - }); + expect(configuredRoutes).toMatchSnapshot(); + }); - it('module routes', () => { - const routes = Module.getRoutes(); + it('module routes', () => { + const routes = Module.getRoutes(); - expect(routes).toMatchSnapshot(); - }); + expect(routes).toMatchSnapshot(); + }); }); diff --git a/packages-modules/counter/browser/src/connected-react-router/components/Counter.tsx b/packages-modules/counter/browser/src/connected-react-router/components/Counter.tsx index 16f1a4519..cdf7d10a0 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/Counter.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/Counter.tsx @@ -7,32 +7,32 @@ import { increment, decrement } from '../redux'; import { State } from '../interfaces'; const CounterComponent: React.FC = (props) => ( -
- Counter: {props.count} - - -
+
+ Counter: {props.count} + + +
); interface StateProps { - count: number; + count: number; } interface DispatchProps { - increment: () => void; - decrement: () => void; + increment: () => void; + decrement: () => void; } const mapStateToProps = (state: State) => ({ - count: state.connectedReactRouterCounter, + count: state.connectedReactRouterCounter, }); const mapDispatchToProps = (dispatch: Dispatch) => ({ - increment: () => dispatch(increment()), - decrement: () => dispatch(decrement()), + increment: () => dispatch(increment()), + decrement: () => dispatch(decrement()), }); export default connect( - mapStateToProps, - mapDispatchToProps, + mapStateToProps, + mapDispatchToProps )(CounterComponent); diff --git a/packages-modules/counter/browser/src/connected-react-router/components/Hello.tsx b/packages-modules/counter/browser/src/connected-react-router/components/Hello.tsx index c8b583018..8b30cbfb8 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/Hello.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/Hello.tsx @@ -2,9 +2,8 @@ import * as React from 'react'; import { HelloChild } from './HelloChild'; export default () => ( -
-
Hello
- -
+
+
Hello
+ +
); - diff --git a/packages-modules/counter/browser/src/connected-react-router/components/HelloChild.tsx b/packages-modules/counter/browser/src/connected-react-router/components/HelloChild.tsx index 2a9830ca0..d8a3e371c 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/HelloChild.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/HelloChild.tsx @@ -1,4 +1,3 @@ - import * as React from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; @@ -6,34 +5,38 @@ import { State } from '../interfaces'; import { CONNECTED_REACT_ROUTER_ROUTES_TYPES } from '../constants'; interface HelloChildProps { - pathname: string; - search: string; - hash: string; + pathname: string; + search: string; + hash: string; } const HelloChildComponent = ({ pathname, search, hash }: HelloChildProps) => ( -
- Hello-Child -
    -
  • with query string
  • -
  • with hash
  • -
-
- pathname: {pathname} -
-
- search: {search} -
-
- hash: {hash} -
-
+
+ Hello-Child 23423 +
    +
  • + + with query string + +
  • +
  • + + with hash + +
  • +
+
pathname: {pathname}
+
search: {search}
+
hash: {hash}
+
); const mapStateToProps = (state: State) => ({ - pathname: state.router.location.pathname, - search: state.router.location.search, - hash: state.router.location.hash, + pathname: state.router.location.pathname, + search: state.router.location.search, + hash: state.router.location.hash, }); export const HelloChild = connect(mapStateToProps)(HelloChildComponent); diff --git a/packages-modules/counter/browser/src/connected-react-router/components/Home.tsx b/packages-modules/counter/browser/src/connected-react-router/components/Home.tsx index 934a160c3..f92c97a90 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/Home.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/Home.tsx @@ -1,9 +1,5 @@ import * as React from 'react'; -const Home = () => ( -
- Home -
-); +const Home = () =>
Home
; export { Home }; diff --git a/packages-modules/counter/browser/src/connected-react-router/components/NavBar.tsx b/packages-modules/counter/browser/src/connected-react-router/components/NavBar.tsx index ea49c1b2d..580eceea9 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/NavBar.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/NavBar.tsx @@ -2,9 +2,9 @@ import * as React from 'react'; import Counter from './Counter'; const NavBar = () => ( -
- -
+
+ +
); export default NavBar; diff --git a/packages-modules/counter/browser/src/connected-react-router/components/NoMatch.tsx b/packages-modules/counter/browser/src/connected-react-router/components/NoMatch.tsx index bbf393c29..4af2df12f 100755 --- a/packages-modules/counter/browser/src/connected-react-router/components/NoMatch.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/components/NoMatch.tsx @@ -1,9 +1,5 @@ import * as React from 'react'; -const NoMatch = () => ( -
- No Match -
-); +const NoMatch = () =>
No Match
; export default NoMatch; diff --git a/packages-modules/counter/browser/src/connected-react-router/compute.tsx b/packages-modules/counter/browser/src/connected-react-router/compute.tsx index 922c0e86a..fb48071e7 100755 --- a/packages-modules/counter/browser/src/connected-react-router/compute.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/compute.tsx @@ -1,57 +1,61 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react'; import { IMenuPosition, IRoute } from '@common-stack/client-react'; -import { lazy } from '@loadable/component' +import { lazy } from '@loadable/component'; import { getFilteredMenus, getFilteredRoutes } from '../utils'; import { CONNECTED_REACT_ROUTER_ROUTES_TYPES } from './constants'; - - const Dashboard = lazy(() => import('../common/components/Dashboard')); const Counter = lazy(() => import('./components/Counter')); const Hello = lazy(() => import('./components/Hello')); export const counterPageStore: IRoute[] = [ - { - exact: false, - icon: 'export', - component: Dashboard, - position: IMenuPosition.MIDDLE, - name: 'Connected React Router', - key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, - path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, - }, - { - exact: true, - icon: 'export', - name: 'Hello', - component: Hello, - position: IMenuPosition.MIDDLE, - key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, - path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, - }, - { - exact: true, - icon: 'export', - name: 'Counter', - component: Counter, - position: IMenuPosition.MIDDLE, - key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, - path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, - }, + { + exact: false, + icon: 'export', + component: Dashboard, + position: IMenuPosition.MIDDLE, + name: 'Connected React Router', + key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, + path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, + }, + { + exact: true, + icon: 'export', + name: 'Hello', + component: Hello, + position: IMenuPosition.MIDDLE, + key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, + path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, + }, + { + exact: true, + icon: 'export', + name: 'Counter', + component: Counter, + position: IMenuPosition.MIDDLE, + key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, + path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, + }, ]; const selectedRoutesAndMenus = [ - CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, - CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, - CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, + CONNECTED_REACT_ROUTER_ROUTES_TYPES.HOME, + CONNECTED_REACT_ROUTER_ROUTES_TYPES.HELLO, + CONNECTED_REACT_ROUTER_ROUTES_TYPES.COUNTER, ]; // get routes -const filteredRoutes = getFilteredRoutes(counterPageStore, selectedRoutesAndMenus); +const filteredRoutes = getFilteredRoutes( + counterPageStore, + selectedRoutesAndMenus +); // get menus -const filteredMenus = getFilteredMenus(counterPageStore, selectedRoutesAndMenus); +const filteredMenus = getFilteredMenus( + counterPageStore, + selectedRoutesAndMenus +); export { filteredRoutes, filteredMenus }; diff --git a/packages-modules/counter/browser/src/connected-react-router/constants/action-types.ts b/packages-modules/counter/browser/src/connected-react-router/constants/action-types.ts index f73efec22..c691c5819 100755 --- a/packages-modules/counter/browser/src/connected-react-router/constants/action-types.ts +++ b/packages-modules/counter/browser/src/connected-react-router/constants/action-types.ts @@ -1,4 +1,4 @@ export const enum CONNECTED_REACT_ROUTER_ACTION_TYPES { - INCREMENT = '@connected-react-router/INCREMENT', - DECREMENT = '@connected-react-router/DECREMENT', + INCREMENT = '@connected-react-router/INCREMENT', + DECREMENT = '@connected-react-router/DECREMENT', } diff --git a/packages-modules/counter/browser/src/connected-react-router/constants/routes-types.ts b/packages-modules/counter/browser/src/connected-react-router/constants/routes-types.ts index b4694d0de..35d219665 100755 --- a/packages-modules/counter/browser/src/connected-react-router/constants/routes-types.ts +++ b/packages-modules/counter/browser/src/connected-react-router/constants/routes-types.ts @@ -1,6 +1,6 @@ export enum CONNECTED_REACT_ROUTER_ROUTES_TYPES { - ROOT = '/', - HOME = '/connected-react-router', - HELLO = '/connected-react-router/hello', - COUNTER = '/connected-react-router/counter', + ROOT = '/', + HOME = '/connected-react-router', + HELLO = '/connected-react-router/hello', + COUNTER = '/connected-react-router/counter', } diff --git a/packages-modules/counter/browser/src/connected-react-router/electron-module.tsx b/packages-modules/counter/browser/src/connected-react-router/electron-module.tsx index c719458db..b68fe8c4b 100644 --- a/packages-modules/counter/browser/src/connected-react-router/electron-module.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/electron-module.tsx @@ -6,27 +6,26 @@ import { connectedReactRouterCounter } from './redux'; import { CONNECTED_REACT_ROUTER_ROUTES_TYPES } from './constants'; import { getFilteredRoutes } from '../utils'; - export const counterPageStore: IRoute[] = [ - { - exact: true, - icon: 'export', - name: 'Counter', - component: Counter, - position: IMenuPosition.MIDDLE, - key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT, - path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT, - }, + { + exact: true, + icon: 'export', + name: 'Counter', + component: Counter, + position: IMenuPosition.MIDDLE, + key: CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT, + path: CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT, + }, ]; -const selectedRoutesAndMenus = [ - CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT, -]; +const selectedRoutesAndMenus = [CONNECTED_REACT_ROUTER_ROUTES_TYPES.ROOT]; // get routes -const filteredRoutes = getFilteredRoutes(counterPageStore, selectedRoutesAndMenus); +const filteredRoutes = getFilteredRoutes( + counterPageStore, + selectedRoutesAndMenus +); export const ElectronTrayModule = new Feature({ - routeConfig: filteredRoutes, - reducer: { connectedReactRouterCounter }, + routeConfig: filteredRoutes, + reducer: { connectedReactRouterCounter }, }); - diff --git a/packages-modules/counter/browser/src/connected-react-router/interfaces/state.ts b/packages-modules/counter/browser/src/connected-react-router/interfaces/state.ts index f5de723d6..a56f32ae8 100755 --- a/packages-modules/counter/browser/src/connected-react-router/interfaces/state.ts +++ b/packages-modules/counter/browser/src/connected-react-router/interfaces/state.ts @@ -1,6 +1,6 @@ import { RouterState } from 'connected-react-router'; export interface State { - connectedReactRouterCounter: number; - router: RouterState; + connectedReactRouterCounter: number; + router: RouterState; } diff --git a/packages-modules/counter/browser/src/connected-react-router/module.tsx b/packages-modules/counter/browser/src/connected-react-router/module.tsx index cfa4f99c9..71a2f1191 100755 --- a/packages-modules/counter/browser/src/connected-react-router/module.tsx +++ b/packages-modules/counter/browser/src/connected-react-router/module.tsx @@ -7,8 +7,8 @@ import { connectedReactRouterCounter } from './redux'; import { filteredRoutes, filteredMenus } from './compute'; export default new Feature({ - navItem: , // used in electron - menuConfig: filteredMenus, - routeConfig: filteredRoutes, - reducer: { connectedReactRouterCounter }, + navItem: , // used in electron + menuConfig: filteredMenus, + routeConfig: filteredRoutes, + reducer: { connectedReactRouterCounter }, }); diff --git a/packages-modules/counter/browser/src/connected-react-router/redux/actions/counter.ts b/packages-modules/counter/browser/src/connected-react-router/redux/actions/counter.ts index bbdeb5027..4c3787c1f 100755 --- a/packages-modules/counter/browser/src/connected-react-router/redux/actions/counter.ts +++ b/packages-modules/counter/browser/src/connected-react-router/redux/actions/counter.ts @@ -1,9 +1,9 @@ import { CONNECTED_REACT_ROUTER_ACTION_TYPES } from '../../constants'; export const increment = () => ({ - type: CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT, + type: CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT, }); export const decrement = () => ({ - type: CONNECTED_REACT_ROUTER_ACTION_TYPES.DECREMENT, + type: CONNECTED_REACT_ROUTER_ACTION_TYPES.DECREMENT, }); diff --git a/packages-modules/counter/browser/src/connected-react-router/redux/reducers/counter.ts b/packages-modules/counter/browser/src/connected-react-router/redux/reducers/counter.ts index ca8c85332..b3e67fa15 100755 --- a/packages-modules/counter/browser/src/connected-react-router/redux/reducers/counter.ts +++ b/packages-modules/counter/browser/src/connected-react-router/redux/reducers/counter.ts @@ -2,14 +2,14 @@ import { Action } from 'redux'; import { CONNECTED_REACT_ROUTER_ACTION_TYPES } from '../../constants'; const connectedReactRouterCounter = (state = 0, action: Action) => { - switch (action.type) { - case CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT: - return state + 1; - case CONNECTED_REACT_ROUTER_ACTION_TYPES.DECREMENT: - return state - 1; - default: - return state; - } + switch (action.type) { + case CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT: + return state + 1; + case CONNECTED_REACT_ROUTER_ACTION_TYPES.DECREMENT: + return state - 1; + default: + return state; + } }; export { connectedReactRouterCounter }; diff --git a/packages-modules/counter/browser/src/emotion/README.md b/packages-modules/counter/browser/src/emotion/README.md index ee03f391e..cf602ce1b 100755 --- a/packages-modules/counter/browser/src/emotion/README.md +++ b/packages-modules/counter/browser/src/emotion/README.md @@ -5,4 +5,4 @@ It is dynamic by design and renders your styles depending on your application st Code Reference: -https://github.com/rofrischmann/fela/tree/master/examples/example-typescript \ No newline at end of file +https://github.com/rofrischmann/fela/tree/master/examples/example-typescript diff --git a/packages-modules/counter/browser/src/emotion/components/CompledWithTheme.tsx b/packages-modules/counter/browser/src/emotion/components/CompledWithTheme.tsx index 9c5644cbf..c4f88c5f1 100755 --- a/packages-modules/counter/browser/src/emotion/components/CompledWithTheme.tsx +++ b/packages-modules/counter/browser/src/emotion/components/CompledWithTheme.tsx @@ -4,9 +4,9 @@ import { Complex } from './ComplexComponent'; import { theme } from '../theme'; export default (props) => { - return ( - <> - - - ); + return ( + <> + + + ); }; diff --git a/packages-modules/counter/browser/src/emotion/components/ComplexComponent.tsx b/packages-modules/counter/browser/src/emotion/components/ComplexComponent.tsx index ed2278436..dcf5fbedb 100755 --- a/packages-modules/counter/browser/src/emotion/components/ComplexComponent.tsx +++ b/packages-modules/counter/browser/src/emotion/components/ComplexComponent.tsx @@ -1,43 +1,42 @@ import * as React from 'react'; -import { css } from '@emotion/react'; +// import { css } from '@emotion/react'; import Navbar from './header'; import { Button } from './button'; import Form from './form'; import { styleSheet } from './styles'; - const color = 'white'; const ComplexComponent = (props) => { - const { styles, rules, theme } : any = props; + const { styles, rules, theme }: any = props; - return ( -
- -
-
-

Fly Makes You Faster

-

- New free template by uicookies.com. For more templates visit the site. Lorem ipsum dolor sit - amet, consectetur adipisicing elit. -

- -
-
-
-
-
-
- ); + return ( +
+ +
+
+

Fly Makes You Faster

+

+ New free template by uicookies.com. For more templates visit the + site. Lorem ipsum dolor sit amet, consectetur adipisicing elit. +

+ +
+
+ +
+
+
+ ); }; export const Complex = ComplexComponent; diff --git a/packages-modules/counter/browser/src/emotion/components/button.tsx b/packages-modules/counter/browser/src/emotion/components/button.tsx index c80f76be9..6ada24f50 100644 --- a/packages-modules/counter/browser/src/emotion/components/button.tsx +++ b/packages-modules/counter/browser/src/emotion/components/button.tsx @@ -1,32 +1,32 @@ import styled from '@emotion/styled'; interface ButtonStyles { - bgColor?: string; - color?: string; - padding?: string; - fontSize?: string; - colorOnHover?: string; - borderRadius?: string; - children?: string; - borderColor?: string; - border?: string; - marginLeft?: string; - width?: string; + bgColor?: string; + color?: string; + padding?: string; + fontSize?: string; + colorOnHover?: string; + borderRadius?: string; + children?: string; + borderColor?: string; + border?: string; + marginLeft?: string; + width?: string; } export const Button = styled.button` - padding: ${(props) => props.padding || '8px'}; - background-color: ${(props) => props.bgColor || '#fff'}; - font-size: ${(props) => props.fontSize || '13px'}; - border-radius: ${(props) => props.borderRadius || '0'}; - color: ${(props) => props.color}; - border-color: ${(props) => props.borderColor}; - border: ${(props) => props.border}; - margin-left: ${(props) => props.marginLeft || ''}; - width: ${(props) => props.width || ''}; - cursor: pointer; + padding: ${(props) => props.padding || '8px'}; + background-color: ${(props) => props.bgColor || '#fff'}; + font-size: ${(props) => props.fontSize || '13px'}; + border-radius: ${(props) => props.borderRadius || '0'}; + color: ${(props) => props.color}; + border-color: ${(props) => props.borderColor}; + border: ${(props) => props.border}; + margin-left: ${(props) => props.marginLeft || ''}; + width: ${(props) => props.width || ''}; + cursor: pointer; - &:hover { - background-color: ${(props) => props.colorOnHover || ''}; - } + &:hover { + background-color: ${(props) => props.colorOnHover || ''}; + } `; diff --git a/packages-modules/counter/browser/src/emotion/components/form.tsx b/packages-modules/counter/browser/src/emotion/components/form.tsx index 809293ac4..856bae9b7 100644 --- a/packages-modules/counter/browser/src/emotion/components/form.tsx +++ b/packages-modules/counter/browser/src/emotion/components/form.tsx @@ -2,42 +2,49 @@ import { css } from '@emotion/react'; import { Button } from './button'; import { styleSheet } from './styles'; const Form = ({ bgColor }) => { - const formItems = [ - { - type: 'text', - placeholder: 'Full Name', - }, - { - type: 'email', - placeholder: 'Email', - }, - { - type: 'password', - placeholder: 'Password', - }, - ]; - - return ( -
-
- - {formItems.map((item, index) => { - return ; - })} - - -
-
- ); + const formItems = [ + { + type: 'text', + placeholder: 'Full Name', + }, + { + type: 'email', + placeholder: 'Email', + }, + { + type: 'password', + placeholder: 'Password', + }, + ]; + + return ( +
+
+
+ {formItems.map((item, index) => { + return ( + + ); + })} +
+ +
+
+ ); }; export default Form; diff --git a/packages-modules/counter/browser/src/emotion/components/header.tsx b/packages-modules/counter/browser/src/emotion/components/header.tsx index efd82d5bd..f1cfbdac3 100644 --- a/packages-modules/counter/browser/src/emotion/components/header.tsx +++ b/packages-modules/counter/browser/src/emotion/components/header.tsx @@ -3,44 +3,50 @@ import { Button } from './button'; import { styleSheet } from './styles'; const Navbar = () => { - const navItems = [ - { - title: 'Home', - }, - { - title: 'Features', - }, - { - title: 'Reviews', - }, - { - title: 'Pricing', - }, - { - title: 'FAQ', - }, - ]; - return ( -
-
CDNBase LLC
-
-
-
    - {navItems.map((item, index) => { - return ( -
  • - {item.title} -
  • - ); - })} -
-
-
- -
- ); + const navItems = [ + { + title: 'Home', + }, + { + title: 'Features', + }, + { + title: 'Reviews', + }, + { + title: 'Pricing', + }, + { + title: 'FAQ', + }, + ]; + return ( +
+
CDNBase LLC
+
+
+
    + {navItems.map((item, index) => { + return ( +
  • + {item.title} +
  • + ); + })} +
+
+
+ +
+ ); }; export default Navbar; diff --git a/packages-modules/counter/browser/src/emotion/components/styles.ts b/packages-modules/counter/browser/src/emotion/components/styles.ts index 70f164419..e8a65fad2 100644 --- a/packages-modules/counter/browser/src/emotion/components/styles.ts +++ b/packages-modules/counter/browser/src/emotion/components/styles.ts @@ -3,66 +3,66 @@ import { theme } from '../theme'; const color = 'white'; export const styleSheet = { - header: css({ - display: 'flex', - padding: '20px', - justifyContent: 'space-around', - alignItems: 'baseline', - }), - itemList: css({ - listStyleType: 'none', - display: 'flex', - }), - li: css({ - fontSize: '18px', - color: color, - cursor: 'pointer', - marginRight: '50px', - }), - logo: css({ - fontSize: '30px', - color: color, - cursor: 'pointer', - }), - container: css({ - height: '100vh', - backgroundColor: theme.color.primary, - clipPath: 'polygon(0 0, 100% 0, 100% 76%, 0 98%)', - }), - heading: css({ - fontSize: '80px', - lineHeight: '80px', - color: 'white', - fontWeight: '700', - marginLeft: '16%', - }), - para: css({ - fontSize: '20px', - color: 'rgba(255, 255, 255, 0.8)', - marginLeft: '16%', - }), - leftSection: css({ - width: '50%', - }), - rightSection: css({ - width: '50%', - }), - home: css({ - display: 'flex', - marginTop: '100px', - alignItems: 'center', - }), - fromWrapper: css({ - backgroundColor: 'white', - width: '67.5%', - margin: 'auto', - padding: '40px', - borderRadius: '15px', - }), - inputs: css({ - width: '100%', - marginBottom: '20px', - padding: '15px', - borderRadius: '10px', - }), + header: css({ + display: 'flex', + padding: '20px', + justifyContent: 'space-around', + alignItems: 'baseline', + }), + itemList: css({ + listStyleType: 'none', + display: 'flex', + }), + li: css({ + fontSize: '18px', + color: color, + cursor: 'pointer', + marginRight: '50px', + }), + logo: css({ + fontSize: '30px', + color: color, + cursor: 'pointer', + }), + container: css({ + height: '100vh', + backgroundColor: theme.color.primary, + clipPath: 'polygon(0 0, 100% 0, 100% 76%, 0 98%)', + }), + heading: css({ + fontSize: '80px', + lineHeight: '80px', + color: 'white', + fontWeight: '700', + marginLeft: '16%', + }), + para: css({ + fontSize: '20px', + color: 'rgba(255, 255, 255, 0.8)', + marginLeft: '16%', + }), + leftSection: css({ + width: '50%', + }), + rightSection: css({ + width: '50%', + }), + home: css({ + display: 'flex', + marginTop: '100px', + alignItems: 'center', + }), + fromWrapper: css({ + backgroundColor: 'white', + width: '67.5%', + margin: 'auto', + padding: '40px', + borderRadius: '15px', + }), + inputs: css({ + width: '100%', + marginBottom: '20px', + padding: '15px', + borderRadius: '10px', + }), }; diff --git a/packages-modules/counter/browser/src/emotion/compute.tsx b/packages-modules/counter/browser/src/emotion/compute.tsx index 73d6518fa..00403b1a9 100755 --- a/packages-modules/counter/browser/src/emotion/compute.tsx +++ b/packages-modules/counter/browser/src/emotion/compute.tsx @@ -1,21 +1,21 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react'; import { IMenuPosition } from '@common-stack/client-react'; -import { lazy } from '@loadable/component' +import { lazy } from '@loadable/component'; import { getFilteredMenus, getFilteredRoutes } from '../utils'; const ComplexWithTheme = lazy(() => import('./components/CompledWithTheme')); export const felaPageStore: any[] = [ - { - component: ComplexWithTheme, - tab: 'Emotion Styling', - key: 'emotion', - position: IMenuPosition.MIDDLE, - name: 'Emotion Styling', - path: '/emotion', - }, + { + component: ComplexWithTheme, + tab: 'Emotion Styling', + key: 'emotion', + position: IMenuPosition.MIDDLE, + name: 'Emotion Styling', + path: '/emotion', + }, ]; const selectedRoutesAndMenus = ['emotion']; diff --git a/packages-modules/counter/browser/src/emotion/interfaces/theme.ts b/packages-modules/counter/browser/src/emotion/interfaces/theme.ts index f8fdec62b..2226830d1 100755 --- a/packages-modules/counter/browser/src/emotion/interfaces/theme.ts +++ b/packages-modules/counter/browser/src/emotion/interfaces/theme.ts @@ -1,7 +1,7 @@ export interface Theme { - color: { - primary: string; - secondary: string; - additional: string; - }; + color: { + primary: string; + secondary: string; + additional: string; + }; } diff --git a/packages-modules/counter/browser/src/emotion/module.tsx b/packages-modules/counter/browser/src/emotion/module.tsx index e98cdcebe..ef8580be4 100755 --- a/packages-modules/counter/browser/src/emotion/module.tsx +++ b/packages-modules/counter/browser/src/emotion/module.tsx @@ -2,9 +2,7 @@ import * as React from 'react'; import { Feature } from '@common-stack/client-react'; import { filteredMenus, filteredRoutes } from './compute'; - - export default new Feature({ - menuConfig: filteredMenus, - routeConfig: filteredRoutes, + menuConfig: filteredMenus, + routeConfig: filteredRoutes, }); diff --git a/packages-modules/counter/browser/src/emotion/theme.ts b/packages-modules/counter/browser/src/emotion/theme.ts index 0e14f2d8c..b2d8c0f54 100755 --- a/packages-modules/counter/browser/src/emotion/theme.ts +++ b/packages-modules/counter/browser/src/emotion/theme.ts @@ -1,9 +1,9 @@ import { Theme } from './interfaces'; export const theme: Theme = { - color: { - primary: '#1890ff', - secondary: 'red', - additional: 'lightgreen', - }, + color: { + primary: '#1890ff', + secondary: 'red', + additional: 'lightgreen', + }, }; diff --git a/packages-modules/counter/browser/src/fela/README.md b/packages-modules/counter/browser/src/fela/README.md index ee03f391e..cf602ce1b 100755 --- a/packages-modules/counter/browser/src/fela/README.md +++ b/packages-modules/counter/browser/src/fela/README.md @@ -5,4 +5,4 @@ It is dynamic by design and renders your styles depending on your application st Code Reference: -https://github.com/rofrischmann/fela/tree/master/examples/example-typescript \ No newline at end of file +https://github.com/rofrischmann/fela/tree/master/examples/example-typescript diff --git a/packages-modules/counter/browser/src/fela/components/CompledWithTheme.tsx b/packages-modules/counter/browser/src/fela/components/CompledWithTheme.tsx index ff865d9ed..120bdf6bb 100755 --- a/packages-modules/counter/browser/src/fela/components/CompledWithTheme.tsx +++ b/packages-modules/counter/browser/src/fela/components/CompledWithTheme.tsx @@ -1,28 +1,22 @@ // @ts-nocheck import * as React from 'react'; - import { ThemeProvider } from 'react-fela'; import { Complex } from './ComplexComponent'; import { theme } from '../theme'; - const extendStyles = { - container: { - borderColor: 'black', - borderRadius: '10px', - borderStyle: 'solid', - }, + container: { + borderColor: 'black', + borderRadius: '10px', + borderStyle: 'solid', + }, }; - export default (props) => { - - - return ( - - - - ); - + return ( + + + + ); }; diff --git a/packages-modules/counter/browser/src/fela/components/ComplexComponent.tsx b/packages-modules/counter/browser/src/fela/components/ComplexComponent.tsx index 200fe13c2..56cd614b3 100755 --- a/packages-modules/counter/browser/src/fela/components/ComplexComponent.tsx +++ b/packages-modules/counter/browser/src/fela/components/ComplexComponent.tsx @@ -2,69 +2,64 @@ import * as React from 'react'; import { connect, FelaWithStylesProps, Rules } from 'react-fela'; import { Theme } from '../interfaces'; - interface OwnProps { - fontScale: number; + fontScale: number; } interface Styles { - container: any; - firstSection: any; - secondSection: any; - thirdSection: any; + container: any; + firstSection: any; + secondSection: any; + thirdSection: any; } type Props = OwnProps & FelaWithStylesProps; -const ComplexComponent: React.FunctionComponent = props => { - const { styles, rules, theme } = props; - - return ( -
-
-
First Section
-
Second Section
-
Third Section
-
-
-

Rules

- {Object.entries(rules) - .map(([key, rule]) => ( -
- {`${key}: ${JSON.stringify(rule(props))}`} -
- ))} -
-
-

Theme

- {JSON.stringify(theme)} -
-
+const ComplexComponent: React.FunctionComponent = (props) => { + const { styles, rules, theme } = props; - ); + return ( +
+
+
First Section
+
Second Section
+
Third Section
+
+
+

Rules

+ {Object.entries(rules).map(([key, rule]) => ( +
{`${key}: ${JSON.stringify(rule(props))}`}
+ ))} +
+
+

Theme

+ {JSON.stringify(theme)} +
+
+ ); }; -const complexComponentStyle: Rules = ({fontScale, theme}) => ({ - container: { - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - }, - firstSection: ({ theme }) => ({ - backgroundColor: theme.color.primary, - fontSize: `{5 * fontScale}px`, - }), - secondSection: { - backgroundColor: theme.color.secondary, - fontSize: `${7 * fontScale}px`, - }, - thirdSection: { - backgroundColor: theme.color.additional, - fontSize: `${10 * fontScale}px`, - }, +const complexComponentStyle: Rules = ({ + fontScale, + theme, +}) => ({ + container: { + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + }, + firstSection: ({ theme }) => ({ + backgroundColor: theme.color.primary, + fontSize: `{5 * fontScale}px`, + }), + secondSection: { + backgroundColor: theme.color.secondary, + fontSize: `${7 * fontScale}px`, + }, + thirdSection: { + backgroundColor: theme.color.additional, + fontSize: `${10 * fontScale}px`, + }, }); export const Complex = connect(complexComponentStyle)(ComplexComponent); - - - diff --git a/packages-modules/counter/browser/src/fela/compute.tsx b/packages-modules/counter/browser/src/fela/compute.tsx index 1f49cade3..39daf3202 100755 --- a/packages-modules/counter/browser/src/fela/compute.tsx +++ b/packages-modules/counter/browser/src/fela/compute.tsx @@ -1,21 +1,21 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import * as React from 'react'; import { IMenuPosition } from '@common-stack/client-react'; -import { lazy } from '@loadable/component' +import { lazy } from '@loadable/component'; import { getFilteredMenus, getFilteredRoutes } from '../utils'; const ComplexWithTheme = lazy(() => import('./components/CompledWithTheme')); export const felaPageStore: any[] = [ - { - component: ComplexWithTheme, - tab: 'Fela Styling', - key: 'fela', - position: IMenuPosition.MIDDLE, - name: 'Fela Styling', - path: '/fela', - }, + { + component: ComplexWithTheme, + tab: 'Fela Styling', + key: 'fela', + position: IMenuPosition.MIDDLE, + name: 'Fela Styling', + path: '/fela', + }, ]; const selectedRoutesAndMenus = ['fela']; diff --git a/packages-modules/counter/browser/src/fela/interfaces/theme.ts b/packages-modules/counter/browser/src/fela/interfaces/theme.ts index f8fdec62b..2226830d1 100755 --- a/packages-modules/counter/browser/src/fela/interfaces/theme.ts +++ b/packages-modules/counter/browser/src/fela/interfaces/theme.ts @@ -1,7 +1,7 @@ export interface Theme { - color: { - primary: string; - secondary: string; - additional: string; - }; + color: { + primary: string; + secondary: string; + additional: string; + }; } diff --git a/packages-modules/counter/browser/src/fela/module.tsx b/packages-modules/counter/browser/src/fela/module.tsx index e98cdcebe..ef8580be4 100755 --- a/packages-modules/counter/browser/src/fela/module.tsx +++ b/packages-modules/counter/browser/src/fela/module.tsx @@ -2,9 +2,7 @@ import * as React from 'react'; import { Feature } from '@common-stack/client-react'; import { filteredMenus, filteredRoutes } from './compute'; - - export default new Feature({ - menuConfig: filteredMenus, - routeConfig: filteredRoutes, + menuConfig: filteredMenus, + routeConfig: filteredRoutes, }); diff --git a/packages-modules/counter/browser/src/fela/theme.ts b/packages-modules/counter/browser/src/fela/theme.ts index 3c448884c..3f5325894 100755 --- a/packages-modules/counter/browser/src/fela/theme.ts +++ b/packages-modules/counter/browser/src/fela/theme.ts @@ -1,9 +1,9 @@ import { Theme } from './interfaces'; export const theme: Theme = { - color: { - primary: 'lightblue', - secondary: 'red', - additional: 'lightgreen', - }, + color: { + primary: 'lightblue', + secondary: 'red', + additional: 'lightgreen', + }, }; diff --git a/packages-modules/counter/browser/src/generated-models.ts b/packages-modules/counter/browser/src/generated-models.ts index 838d24835..4d7fbbeb7 100755 --- a/packages-modules/counter/browser/src/generated-models.ts +++ b/packages-modules/counter/browser/src/generated-models.ts @@ -3,324 +3,393 @@ import { GraphQLResolveInfo } from 'graphql'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; export type Maybe = T | null; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; -export type RequireFields = { [X in Exclude]?: T[X] } & { [P in K]-?: NonNullable }; -const defaultOptions = {} +export type Exact = { + [K in keyof T]: T[K]; +}; +export type MakeOptional = Omit & { + [SubKey in K]?: Maybe; +}; +export type MakeMaybe = Omit & { + [SubKey in K]: Maybe; +}; +export type RequireFields = { + [X in Exclude]?: T[X]; +} & { [P in K]-?: NonNullable }; +const defaultOptions = {}; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: string; - String: string; - Boolean: boolean; - Int: number; - Float: number; + ID: string; + String: string; + Boolean: boolean; + Int: number; + Float: number; }; export type ClientCounter = { - __typename?: 'ClientCounter'; - counter?: Maybe; + __typename?: 'ClientCounter'; + counter?: Maybe; }; /** Database counter */ export type Counter = { - __typename?: 'Counter'; - /** Current amount */ - amount: Scalars['Int']; + __typename?: 'Counter'; + /** Current amount */ + amount: Scalars['Int']; }; export type Mutation = { - __typename?: 'Mutation'; - /** Increase counter value returns current counter amount */ - addCounter?: Maybe; - addCounterState?: Maybe; - /** add Counter */ - addMoleculerCounter?: Maybe; - /** sync cached counter with current value */ - syncCachedCounter?: Maybe; + __typename?: 'Mutation'; + /** Increase counter value returns current counter amount */ + addCounter?: Maybe; + addCounterState?: Maybe; + /** add Counter */ + addMoleculerCounter?: Maybe; + /** sync cached counter with current value */ + syncCachedCounter?: Maybe; }; - export type MutationAddCounterArgs = { - amount?: Maybe; + amount?: Maybe; }; - export type MutationAddCounterStateArgs = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; - export type MutationAddMoleculerCounterArgs = { - amount?: Maybe; + amount?: Maybe; }; export type Query = { - __typename?: 'Query'; - /** Counter */ - counter?: Maybe; - /** Counter from Datasource */ - counterCache?: Maybe; - counterState?: Maybe; - /** Moleculer Counter */ - moleculerCounter?: Maybe; + __typename?: 'Query'; + /** Counter */ + counter?: Maybe; + /** Counter from Datasource */ + counterCache?: Maybe; + counterState?: Maybe; + /** Moleculer Counter */ + moleculerCounter?: Maybe; }; export type Subscription = { - __typename?: 'Subscription'; - /** Subscription fired when anyone increases counter */ - counterUpdated?: Maybe; - moleculerCounterUpdate?: Maybe; + __typename?: 'Subscription'; + /** Subscription fired when anyone increases counter */ + counterUpdated?: Maybe; + moleculerCounterUpdate?: Maybe; }; export type AddCounterStateMutationVariables = Exact<{ - amount: Scalars['Int']; + amount: Scalars['Int']; }>; - -export type AddCounterStateMutation = ( - { __typename?: 'Mutation' } - & { addCounterState?: Maybe<( - { __typename?: 'ClientCounter' } - & Pick - )> } -); +export type AddCounterStateMutation = { __typename?: 'Mutation' } & { + addCounterState?: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; +}; export type AddCounterMutationVariables = Exact<{ - amount: Scalars['Int']; + amount: Scalars['Int']; }>; - -export type AddCounterMutation = ( - { __typename?: 'Mutation' } - & { addCounter?: Maybe<( - { __typename?: 'Counter' } - & Pick - )> } -); +export type AddCounterMutation = { __typename?: 'Mutation' } & { + addCounter?: Maybe<{ __typename?: 'Counter' } & Pick>; +}; export type AddCounter_WsMutationVariables = Exact<{ - amount: Scalars['Int']; + amount: Scalars['Int']; }>; +export type AddCounter_WsMutation = { __typename?: 'Mutation' } & { + addCounter?: Maybe<{ __typename?: 'Counter' } & Pick>; +}; -export type AddCounter_WsMutation = ( - { __typename?: 'Mutation' } - & { addCounter?: Maybe<( - { __typename?: 'Counter' } - & Pick - )> } -); - -export type SyncCachedCounterMutationVariables = Exact<{ [key: string]: never; }>; - - -export type SyncCachedCounterMutation = ( - { __typename?: 'Mutation' } - & Pick -); - -export type CounterCacheQueryQueryVariables = Exact<{ [key: string]: never; }>; - - -export type CounterCacheQueryQuery = ( - { __typename?: 'Query' } - & { counterCache?: Maybe<( - { __typename?: 'Counter' } - & Pick - )> } -); - -export type CounterStateQueryVariables = Exact<{ [key: string]: never; }>; - +export type SyncCachedCounterMutationVariables = Exact<{ + [key: string]: never; +}>; -export type CounterStateQuery = ( - { __typename?: 'Query' } - & { counterState?: Maybe<( - { __typename?: 'ClientCounter' } - & Pick - )> } -); +export type SyncCachedCounterMutation = { __typename?: 'Mutation' } & Pick< + Mutation, + 'syncCachedCounter' +>; -export type CounterQueryQueryVariables = Exact<{ [key: string]: never; }>; +export type CounterCacheQueryQueryVariables = Exact<{ [key: string]: never }>; +export type CounterCacheQueryQuery = { __typename?: 'Query' } & { + counterCache?: Maybe<{ __typename?: 'Counter' } & Pick>; +}; -export type CounterQueryQuery = ( - { __typename?: 'Query' } - & { counter?: Maybe<( - { __typename?: 'Counter' } - & Pick - )> } -); +export type CounterStateQueryVariables = Exact<{ [key: string]: never }>; -export type OnCounterUpdatedSubscriptionVariables = Exact<{ [key: string]: never; }>; +export type CounterStateQuery = { __typename?: 'Query' } & { + counterState?: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; +}; +export type CounterQueryQueryVariables = Exact<{ [key: string]: never }>; -export type OnCounterUpdatedSubscription = ( - { __typename?: 'Subscription' } - & { counterUpdated?: Maybe<( - { __typename?: 'Counter' } - & Pick - )> } -); +export type CounterQueryQuery = { __typename?: 'Query' } & { + counter?: Maybe<{ __typename?: 'Counter' } & Pick>; +}; +export type OnCounterUpdatedSubscriptionVariables = Exact<{ + [key: string]: never; +}>; +export type OnCounterUpdatedSubscription = { __typename?: 'Subscription' } & { + counterUpdated?: Maybe<{ __typename?: 'Counter' } & Pick>; +}; export type ResolverTypeWrapper = Promise | T; - export type ResolverWithResolve = { - resolve: ResolverFn; + resolve: ResolverFn; }; export type LegacyStitchingResolver = { - fragment: string; - resolve: ResolverFn; + fragment: string; + resolve: ResolverFn; }; export type NewStitchingResolver = { - selectionSet: string; - resolve: ResolverFn; + selectionSet: string; + resolve: ResolverFn; }; -export type StitchingResolver = LegacyStitchingResolver | NewStitchingResolver; +export type StitchingResolver = + | LegacyStitchingResolver + | NewStitchingResolver; export type Resolver = - | ResolverFn - | ResolverWithResolve - | StitchingResolver; + | ResolverFn + | ResolverWithResolve + | StitchingResolver; export type ResolverFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => Promise | TResult; export type SubscriptionSubscribeFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => AsyncIterator | Promise>; export type SubscriptionResolveFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; -export interface SubscriptionSubscriberObject { - subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>; - resolve?: SubscriptionResolveFn; +export interface SubscriptionSubscriberObject< + TResult, + TKey extends string, + TParent, + TContext, + TArgs +> { + subscribe: SubscriptionSubscribeFn< + { [key in TKey]: TResult }, + TParent, + TContext, + TArgs + >; + resolve?: SubscriptionResolveFn< + TResult, + { [key in TKey]: TResult }, + TContext, + TArgs + >; } export interface SubscriptionResolverObject { - subscribe: SubscriptionSubscribeFn; - resolve: SubscriptionResolveFn; + subscribe: SubscriptionSubscribeFn; + resolve: SubscriptionResolveFn; } -export type SubscriptionObject = - | SubscriptionSubscriberObject - | SubscriptionResolverObject; - -export type SubscriptionResolver = - | ((...args: any[]) => SubscriptionObject) - | SubscriptionObject; +export type SubscriptionObject< + TResult, + TKey extends string, + TParent, + TContext, + TArgs +> = + | SubscriptionSubscriberObject + | SubscriptionResolverObject; + +export type SubscriptionResolver< + TResult, + TKey extends string, + TParent = {}, + TContext = {}, + TArgs = {} +> = + | (( + ...args: any[] + ) => SubscriptionObject) + | SubscriptionObject; export type TypeResolveFn = ( - parent: TParent, - context: TContext, - info: GraphQLResolveInfo + parent: TParent, + context: TContext, + info: GraphQLResolveInfo ) => Maybe | Promise>; -export type IsTypeOfResolverFn = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise; +export type IsTypeOfResolverFn = ( + obj: T, + context: TContext, + info: GraphQLResolveInfo +) => boolean | Promise; export type NextResolverFn = () => Promise; -export type DirectiveResolverFn = ( - next: NextResolverFn, - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo +export type DirectiveResolverFn< + TResult = {}, + TParent = {}, + TContext = {}, + TArgs = {} +> = ( + next: NextResolverFn, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; /** Mapping between all available schema types and the resolvers types */ export type ResolversTypes = { - Query: ResolverTypeWrapper<{}>; - Counter: ResolverTypeWrapper; - Int: ResolverTypeWrapper; - ClientCounter: ResolverTypeWrapper; - Mutation: ResolverTypeWrapper<{}>; - Boolean: ResolverTypeWrapper; - Subscription: ResolverTypeWrapper<{}>; - String: ResolverTypeWrapper; + Query: ResolverTypeWrapper<{}>; + Counter: ResolverTypeWrapper; + Int: ResolverTypeWrapper; + ClientCounter: ResolverTypeWrapper; + Mutation: ResolverTypeWrapper<{}>; + Boolean: ResolverTypeWrapper; + Subscription: ResolverTypeWrapper<{}>; + String: ResolverTypeWrapper; }; /** Mapping between all available schema types and the resolvers parents */ export type ResolversParentTypes = { - Query: {}; - Counter: Counter; - Int: Scalars['Int']; - ClientCounter: ClientCounter; - Mutation: {}; - Boolean: Scalars['Boolean']; - Subscription: {}; - String: Scalars['String']; + Query: {}; + Counter: Counter; + Int: Scalars['Int']; + ClientCounter: ClientCounter; + Mutation: {}; + Boolean: Scalars['Boolean']; + Subscription: {}; + String: Scalars['String']; }; -export type ClientCounterResolvers = { - counter?: Resolver, ParentType, ContextType>; - __isTypeOf?: IsTypeOfResolverFn; +export type ClientCounterResolvers< + ContextType = any, + ParentType extends ResolversParentTypes['ClientCounter'] = ResolversParentTypes['ClientCounter'] +> = { + counter?: Resolver, ParentType, ContextType>; + __isTypeOf?: IsTypeOfResolverFn; }; -export type CounterResolvers = { - amount?: Resolver; - __isTypeOf?: IsTypeOfResolverFn; +export type CounterResolvers< + ContextType = any, + ParentType extends ResolversParentTypes['Counter'] = ResolversParentTypes['Counter'] +> = { + amount?: Resolver; + __isTypeOf?: IsTypeOfResolverFn; }; -export type MutationResolvers = { - addCounter?: Resolver, ParentType, ContextType, RequireFields>; - addCounterState?: Resolver, ParentType, ContextType, RequireFields>; - addMoleculerCounter?: Resolver, ParentType, ContextType, RequireFields>; - syncCachedCounter?: Resolver, ParentType, ContextType>; +export type MutationResolvers< + ContextType = any, + ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation'] +> = { + addCounter?: Resolver< + Maybe, + ParentType, + ContextType, + RequireFields + >; + addCounterState?: Resolver< + Maybe, + ParentType, + ContextType, + RequireFields + >; + addMoleculerCounter?: Resolver< + Maybe, + ParentType, + ContextType, + RequireFields + >; + syncCachedCounter?: Resolver< + Maybe, + ParentType, + ContextType + >; }; -export type QueryResolvers = { - counter?: Resolver, ParentType, ContextType>; - counterCache?: Resolver, ParentType, ContextType>; - counterState?: Resolver, ParentType, ContextType>; - moleculerCounter?: Resolver, ParentType, ContextType>; +export type QueryResolvers< + ContextType = any, + ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query'] +> = { + counter?: Resolver, ParentType, ContextType>; + counterCache?: Resolver< + Maybe, + ParentType, + ContextType + >; + counterState?: Resolver< + Maybe, + ParentType, + ContextType + >; + moleculerCounter?: Resolver< + Maybe, + ParentType, + ContextType + >; }; -export type SubscriptionResolvers = { - counterUpdated?: SubscriptionResolver, "counterUpdated", ParentType, ContextType>; - moleculerCounterUpdate?: SubscriptionResolver, "moleculerCounterUpdate", ParentType, ContextType>; +export type SubscriptionResolvers< + ContextType = any, + ParentType extends ResolversParentTypes['Subscription'] = ResolversParentTypes['Subscription'] +> = { + counterUpdated?: SubscriptionResolver< + Maybe, + 'counterUpdated', + ParentType, + ContextType + >; + moleculerCounterUpdate?: SubscriptionResolver< + Maybe, + 'moleculerCounterUpdate', + ParentType, + ContextType + >; }; export type Resolvers = { - ClientCounter?: ClientCounterResolvers; - Counter?: CounterResolvers; - Mutation?: MutationResolvers; - Query?: QueryResolvers; - Subscription?: SubscriptionResolvers; + ClientCounter?: ClientCounterResolvers; + Counter?: CounterResolvers; + Mutation?: MutationResolvers; + Query?: QueryResolvers; + Subscription?: SubscriptionResolvers; }; - /** * @deprecated * Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config. */ export type IResolvers = Resolvers; - export const AddCounterStateDocument = gql` - mutation addCounterState($amount: Int!) { - addCounterState(amount: $amount) @client { - counter - } -} - `; + mutation addCounterState($amount: Int!) { + addCounterState(amount: $amount) @client { + counter + } + } +`; /** * __useAddCounterStateMutation__ @@ -339,20 +408,34 @@ export const AddCounterStateDocument = gql` * }, * }); */ -export function useAddCounterStateMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounterStateDocument, options); - } -export type AddCounterStateMutationHookResult = ReturnType; -export type AddCounterStateMutationResult = Apollo.MutationResult; -export type AddCounterStateMutationOptions = Apollo.BaseMutationOptions; -export const AddCounterDocument = gql` - mutation addCounter($amount: Int!) { - addCounter(amount: $amount) { - amount - } +export function useAddCounterStateMutation( + baseOptions?: Apollo.MutationHookOptions< + AddCounterStateMutation, + AddCounterStateMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + AddCounterStateMutation, + AddCounterStateMutationVariables + >(AddCounterStateDocument, options); } - `; +export type AddCounterStateMutationHookResult = ReturnType< + typeof useAddCounterStateMutation +>; +export type AddCounterStateMutationResult = + Apollo.MutationResult; +export type AddCounterStateMutationOptions = Apollo.BaseMutationOptions< + AddCounterStateMutation, + AddCounterStateMutationVariables +>; +export const AddCounterDocument = gql` + mutation addCounter($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } +`; /** * __useAddCounterMutation__ @@ -371,20 +454,34 @@ export const AddCounterDocument = gql` * }, * }); */ -export function useAddCounterMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounterDocument, options); - } -export type AddCounterMutationHookResult = ReturnType; -export type AddCounterMutationResult = Apollo.MutationResult; -export type AddCounterMutationOptions = Apollo.BaseMutationOptions; -export const AddCounter_WsDocument = gql` - mutation AddCounter_WS($amount: Int!) { - addCounter(amount: $amount) { - amount - } +export function useAddCounterMutation( + baseOptions?: Apollo.MutationHookOptions< + AddCounterMutation, + AddCounterMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation( + AddCounterDocument, + options + ); } - `; +export type AddCounterMutationHookResult = ReturnType< + typeof useAddCounterMutation +>; +export type AddCounterMutationResult = + Apollo.MutationResult; +export type AddCounterMutationOptions = Apollo.BaseMutationOptions< + AddCounterMutation, + AddCounterMutationVariables +>; +export const AddCounter_WsDocument = gql` + mutation AddCounter_WS($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } +`; /** * __useAddCounter_WsMutation__ @@ -403,18 +500,32 @@ export const AddCounter_WsDocument = gql` * }, * }); */ -export function useAddCounter_WsMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(AddCounter_WsDocument, options); - } -export type AddCounter_WsMutationHookResult = ReturnType; -export type AddCounter_WsMutationResult = Apollo.MutationResult; -export type AddCounter_WsMutationOptions = Apollo.BaseMutationOptions; -export const SyncCachedCounterDocument = gql` - mutation SyncCachedCounter { - syncCachedCounter +export function useAddCounter_WsMutation( + baseOptions?: Apollo.MutationHookOptions< + AddCounter_WsMutation, + AddCounter_WsMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + AddCounter_WsMutation, + AddCounter_WsMutationVariables + >(AddCounter_WsDocument, options); } - `; +export type AddCounter_WsMutationHookResult = ReturnType< + typeof useAddCounter_WsMutation +>; +export type AddCounter_WsMutationResult = + Apollo.MutationResult; +export type AddCounter_WsMutationOptions = Apollo.BaseMutationOptions< + AddCounter_WsMutation, + AddCounter_WsMutationVariables +>; +export const SyncCachedCounterDocument = gql` + mutation SyncCachedCounter { + syncCachedCounter + } +`; /** * __useSyncCachedCounterMutation__ @@ -432,20 +543,34 @@ export const SyncCachedCounterDocument = gql` * }, * }); */ -export function useSyncCachedCounterMutation(baseOptions?: Apollo.MutationHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useMutation(SyncCachedCounterDocument, options); - } -export type SyncCachedCounterMutationHookResult = ReturnType; -export type SyncCachedCounterMutationResult = Apollo.MutationResult; -export type SyncCachedCounterMutationOptions = Apollo.BaseMutationOptions; -export const CounterCacheQueryDocument = gql` - query counterCacheQuery { - counterCache { - amount - } +export function useSyncCachedCounterMutation( + baseOptions?: Apollo.MutationHookOptions< + SyncCachedCounterMutation, + SyncCachedCounterMutationVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useMutation< + SyncCachedCounterMutation, + SyncCachedCounterMutationVariables + >(SyncCachedCounterDocument, options); } - `; +export type SyncCachedCounterMutationHookResult = ReturnType< + typeof useSyncCachedCounterMutation +>; +export type SyncCachedCounterMutationResult = + Apollo.MutationResult; +export type SyncCachedCounterMutationOptions = Apollo.BaseMutationOptions< + SyncCachedCounterMutation, + SyncCachedCounterMutationVariables +>; +export const CounterCacheQueryDocument = gql` + query counterCacheQuery { + counterCache { + amount + } + } +`; /** * __useCounterCacheQueryQuery__ @@ -462,24 +587,47 @@ export const CounterCacheQueryDocument = gql` * }, * }); */ -export function useCounterCacheQueryQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterCacheQueryDocument, options); - } -export function useCounterCacheQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterCacheQueryDocument, options); - } -export type CounterCacheQueryQueryHookResult = ReturnType; -export type CounterCacheQueryLazyQueryHookResult = ReturnType; -export type CounterCacheQueryQueryResult = Apollo.QueryResult; -export const CounterStateDocument = gql` - query CounterState { - counterState @client { - counter - } +export function useCounterCacheQueryQuery( + baseOptions?: Apollo.QueryHookOptions< + CounterCacheQueryQuery, + CounterCacheQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + CounterCacheQueryQuery, + CounterCacheQueryQueryVariables + >(CounterCacheQueryDocument, options); } - `; +export function useCounterCacheQueryLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + CounterCacheQueryQuery, + CounterCacheQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + CounterCacheQueryQuery, + CounterCacheQueryQueryVariables + >(CounterCacheQueryDocument, options); +} +export type CounterCacheQueryQueryHookResult = ReturnType< + typeof useCounterCacheQueryQuery +>; +export type CounterCacheQueryLazyQueryHookResult = ReturnType< + typeof useCounterCacheQueryLazyQuery +>; +export type CounterCacheQueryQueryResult = Apollo.QueryResult< + CounterCacheQueryQuery, + CounterCacheQueryQueryVariables +>; +export const CounterStateDocument = gql` + query CounterState { + counterState @client { + counter + } + } +`; /** * __useCounterStateQuery__ @@ -496,24 +644,47 @@ export const CounterStateDocument = gql` * }, * }); */ -export function useCounterStateQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterStateDocument, options); - } -export function useCounterStateLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterStateDocument, options); - } -export type CounterStateQueryHookResult = ReturnType; -export type CounterStateLazyQueryHookResult = ReturnType; -export type CounterStateQueryResult = Apollo.QueryResult; -export const CounterQueryDocument = gql` - query counterQuery { - counter { - amount - } +export function useCounterStateQuery( + baseOptions?: Apollo.QueryHookOptions< + CounterStateQuery, + CounterStateQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + CounterStateDocument, + options + ); } - `; +export function useCounterStateLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + CounterStateQuery, + CounterStateQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + CounterStateDocument, + options + ); +} +export type CounterStateQueryHookResult = ReturnType< + typeof useCounterStateQuery +>; +export type CounterStateLazyQueryHookResult = ReturnType< + typeof useCounterStateLazyQuery +>; +export type CounterStateQueryResult = Apollo.QueryResult< + CounterStateQuery, + CounterStateQueryVariables +>; +export const CounterQueryDocument = gql` + query counterQuery { + counter { + amount + } + } +`; /** * __useCounterQueryQuery__ @@ -530,24 +701,47 @@ export const CounterQueryDocument = gql` * }, * }); */ -export function useCounterQueryQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CounterQueryDocument, options); - } -export function useCounterQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CounterQueryDocument, options); - } -export type CounterQueryQueryHookResult = ReturnType; -export type CounterQueryLazyQueryHookResult = ReturnType; -export type CounterQueryQueryResult = Apollo.QueryResult; -export const OnCounterUpdatedDocument = gql` - subscription onCounterUpdated { - counterUpdated { - amount - } +export function useCounterQueryQuery( + baseOptions?: Apollo.QueryHookOptions< + CounterQueryQuery, + CounterQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + CounterQueryDocument, + options + ); } - `; +export function useCounterQueryLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + CounterQueryQuery, + CounterQueryQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + CounterQueryDocument, + options + ); +} +export type CounterQueryQueryHookResult = ReturnType< + typeof useCounterQueryQuery +>; +export type CounterQueryLazyQueryHookResult = ReturnType< + typeof useCounterQueryLazyQuery +>; +export type CounterQueryQueryResult = Apollo.QueryResult< + CounterQueryQuery, + CounterQueryQueryVariables +>; +export const OnCounterUpdatedDocument = gql` + subscription onCounterUpdated { + counterUpdated { + amount + } + } +`; /** * __useOnCounterUpdatedSubscription__ @@ -564,9 +758,20 @@ export const OnCounterUpdatedDocument = gql` * }, * }); */ -export function useOnCounterUpdatedSubscription(baseOptions?: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(OnCounterUpdatedDocument, options); - } -export type OnCounterUpdatedSubscriptionHookResult = ReturnType; -export type OnCounterUpdatedSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file +export function useOnCounterUpdatedSubscription( + baseOptions?: Apollo.SubscriptionHookOptions< + OnCounterUpdatedSubscription, + OnCounterUpdatedSubscriptionVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSubscription< + OnCounterUpdatedSubscription, + OnCounterUpdatedSubscriptionVariables + >(OnCounterUpdatedDocument, options); +} +export type OnCounterUpdatedSubscriptionHookResult = ReturnType< + typeof useOnCounterUpdatedSubscription +>; +export type OnCounterUpdatedSubscriptionResult = + Apollo.SubscriptionResult; diff --git a/packages-modules/counter/browser/src/index.ts b/packages-modules/counter/browser/src/index.ts index 8c04c51a7..0af2fb07c 100755 --- a/packages-modules/counter/browser/src/index.ts +++ b/packages-modules/counter/browser/src/index.ts @@ -7,5 +7,11 @@ import Fela from './fela'; import emotion from './emotion'; import { ElectronTrayModule } from './connected-react-router/index.electron'; -export default new Feature(Common, ConnectedReactRouter, ApolloCounter, Fela,emotion); +export default new Feature( + Common, + ConnectedReactRouter, + ApolloCounter, + Fela, + emotion +); export { ElectronTrayModule }; diff --git a/packages-modules/counter/browser/src/utils/menu.ts b/packages-modules/counter/browser/src/utils/menu.ts index 9ab4aaaf1..ded4b69b1 100755 --- a/packages-modules/counter/browser/src/utils/menu.ts +++ b/packages-modules/counter/browser/src/utils/menu.ts @@ -1,34 +1,34 @@ export const getFilteredMenus = (accountPageStore, selectedMenu) => - accountPageStore - .map((item) => { - if (selectedMenu.indexOf(item.key) !== -1) { - const { path, component, ...rest } = item; - return { - [path]: { name: rest.tab, ...rest }, - }; - } - }) - .filter((valid) => valid); + accountPageStore + .map((item) => { + if (selectedMenu.indexOf(item.key) !== -1) { + const { path, component, ...rest } = item; + return { + [path]: { name: rest.tab, ...rest }, + }; + } + }) + .filter((valid) => valid); export const getFilteredRoutes = (accountPageStore, selectedRoutes) => - accountPageStore - .map((item) => { - if (selectedRoutes.indexOf(item.key) !== -1) { - const { path } = item; - return { - [path]: item, - }; - } - return null; - }) - .filter((valid) => valid); + accountPageStore + .map((item) => { + if (selectedRoutes.indexOf(item.key) !== -1) { + const { path } = item; + return { + [path]: item, + }; + } + return null; + }) + .filter((valid) => valid); export const getFilteredTabs = (accountPageStore, selectedTabs) => - accountPageStore - .map((item) => { - if (selectedTabs.indexOf(item.key) !== -1) { - const { component, ...rest } = item; - return rest; - } - }) - .filter((valid) => valid); + accountPageStore + .map((item) => { + if (selectedTabs.indexOf(item.key) !== -1) { + const { component, ...rest } = item; + return rest; + } + }) + .filter((valid) => valid); diff --git a/packages-modules/counter/browser/tsconfig.json b/packages-modules/counter/browser/tsconfig.json index 88468a68b..61004ab66 100755 --- a/packages-modules/counter/browser/tsconfig.json +++ b/packages-modules/counter/browser/tsconfig.json @@ -1,32 +1,25 @@ { - "extends": "../../../tsconfig.json", - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "skipLibCheck": true, - "rootDir": "./src", - "outDir": "lib", - "declarationDir": "lib", - "declaration": true, - "declarationMap": true, - "jsx": "react-jsx", - "jsxImportSource": "@emotion/react", - "types": [ - "@types/node", - "@types/jest", - "../../../typings", - ] - }, - "exclude": [ - "node_modules", - "lib", - "dist", - "webpack.config.js", - "rollup.config.js" - ], - "include": [ - "src", - "./typings/*.d.ts" - ] -} \ No newline at end of file + "extends": "../../../tsconfig.json", + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "esModuleInterop": true, + "skipLibCheck": true, + "rootDir": "./src", + "outDir": "lib", + "declarationDir": "lib", + "declaration": true, + "declarationMap": true, + "jsx": "react-jsx", + "jsxImportSource": "@emotion/react", + "types": ["@types/node", "@types/jest", "../../../typings"] + }, + "exclude": [ + "node_modules", + "lib", + "dist", + "webpack.config.js", + "rollup.config.js" + ], + "include": ["src", "./typings/*.d.ts"] +} diff --git a/packages-modules/counter/browser/typings/graphql.d.ts b/packages-modules/counter/browser/typings/graphql.d.ts index a14557b3b..1111369ad 100755 --- a/packages-modules/counter/browser/typings/graphql.d.ts +++ b/packages-modules/counter/browser/typings/graphql.d.ts @@ -1,39 +1,39 @@ -declare module "*/AddCounter.client.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const addCounterState: DocumentNode; +declare module '*/AddCounter.client.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const addCounterState: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/AddCounter.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const addCounter: DocumentNode; +declare module '*/AddCounter.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const addCounter: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterQuery.client.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const CounterState: DocumentNode; +declare module '*/CounterQuery.client.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const CounterState: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterQuery.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const counterQuery: DocumentNode; +declare module '*/CounterQuery.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const counterQuery: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterSubscription.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const onCounterUpdated: DocumentNode; +declare module '*/CounterSubscription.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const onCounterUpdated: DocumentNode; - export default defaultDocument; + export default defaultDocument; } diff --git a/packages-modules/counter/browser/webpack.config.js b/packages-modules/counter/browser/webpack.config.js index 4bc64aa99..c49ae945e 100755 --- a/packages-modules/counter/browser/webpack.config.js +++ b/packages-modules/counter/browser/webpack.config.js @@ -3,64 +3,75 @@ const webpack = require('webpack'); const path = require('path'); const webpackOpts = { - mode: 'development', - entry: { - index: './src/index.ts', - }, - target: 'node', - output: { - path: path.join(__dirname, 'lib'), - filename: '[name].js', - libraryTarget: 'commonjs2', - }, - resolve: { - extensions: ['.ts', '.tsx', '.graphql', '.graphqls', '.gql', '.native.tsx', '.native.ts'], - }, - plugins: [ - new webpack.LoaderOptionsPlugin({ - options: { - test: /\.tsx?$/, - ts: { - compiler: 'typescript', - configFile: 'tsconfig.json', - }, - tslint: { - emitErrors: true, - failOnHint: true, - }, - }, - }), - ], - devtool: 'source-map', - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - options: { - compilerOptions: { - outDir: path.join(), - }, - }, - }, - { - test: /\.mjs$/, - include: /node_modules/, - type: 'javascript/auto', - }, - { - test: /\.(gql)$/, - exclude: /node_modules/, - use: ['graphql-tag/loader'], - }, - { - test: /\.graphql?/, - exclude: /node_modules/, - use: 'raw-loader', - }, - ], - }, - externals: [nodeExternals({ modulesDir: '../../../node_modules' }), nodeExternals()], + mode: 'development', + entry: { + index: './src/index.ts', + }, + target: 'node', + output: { + path: path.join(__dirname, 'lib'), + filename: '[name].js', + libraryTarget: 'commonjs2', + }, + resolve: { + extensions: [ + '.ts', + '.tsx', + '.graphql', + '.graphqls', + '.gql', + '.native.tsx', + '.native.ts', + ], + }, + plugins: [ + new webpack.LoaderOptionsPlugin({ + options: { + test: /\.tsx?$/, + ts: { + compiler: 'typescript', + configFile: 'tsconfig.json', + }, + tslint: { + emitErrors: true, + failOnHint: true, + }, + }, + }), + ], + devtool: 'source-map', + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + options: { + compilerOptions: { + outDir: path.join(), + }, + }, + }, + { + test: /\.mjs$/, + include: /node_modules/, + type: 'javascript/auto', + }, + { + test: /\.(gql)$/, + exclude: /node_modules/, + use: ['graphql-tag/loader'], + }, + { + test: /\.graphql?/, + exclude: /node_modules/, + use: 'raw-loader', + }, + ], + }, + externals: [ + nodeExternals({ modulesDir: '../../../node_modules' }), + nodeExternals(), + ], }; module.exports = webpackOpts; diff --git a/packages-modules/counter/electron/jest.config.js b/packages-modules/counter/electron/jest.config.js index 858217e24..951369848 100644 --- a/packages-modules/counter/electron/jest.config.js +++ b/packages-modules/counter/electron/jest.config.js @@ -2,8 +2,8 @@ const base = require('../../../jest.config.base'); const packageJson = require('./package'); module.exports = { - ...base, - testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment - name: packageJson.name, - displayName: packageJson.name, -}; \ No newline at end of file + ...base, + testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment + name: packageJson.name, + displayName: packageJson.name, +}; diff --git a/packages-modules/counter/electron/package.json b/packages-modules/counter/electron/package.json index abf495671..61af49201 100755 --- a/packages-modules/counter/electron/package.json +++ b/packages-modules/counter/electron/package.json @@ -1,68 +1,68 @@ { - "name": "@sample-stack/counter-module-electron", - "version": "0.0.1", - "description": "Sample core for higher packages to depend on", - "license": "ISC", - "author": "CDMBase LLC", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "scripts": { - "build": "yarn build:clean && yarn build:lib", - "build:clean": "rimraf lib", - "build:lib": "webpack", - "build:lib:watch": "yarn build:lib -- --watch", - "jest": "./node_modules/.bin/jest", - "prepublish": "yarn build", - "test": "cross-env ENV_FILE=../../config/test/test.env jest", - "test:debug": "npm test -- --runInBand", - "test:watch": "npm test -- --watch", - "watch": "yarn build:lib:watch" - }, - "jest": { - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "modulePaths": [ - "node_modules" - ], - "roots": [ - "src" - ], - "testEnvironment": "node", - "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", - "transform": { - "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" - } - }, - "dependencies": { - "@sample-stack/counter-module-browser": "link:../browser" - }, - "devDependencies": { - "@open-wc/building-rollup": "^1.10.0", - "@rollup/plugin-graphql": "1.0.0", - "@rollup/plugin-image": "^2.0.6", - "@rollup/plugin-typescript": "^6.1.0", - "rollup": "latest" - }, - "peerDependencies": { - "@common-stack/client-react": "*", - "native-base": "*", - "react": "*", - "react-native": "*", - "react-redux": "*", - "react-router": "*", - "react-router-dom": "*", - "redux": "*", - "redux-observable": "*", - "rxjs": "*" - }, - "publishConfig": { - "access": "public" - }, - "typescript": { - "definition": "lib/index.d.ts" - } -} \ No newline at end of file + "name": "@sample-stack/counter-module-electron", + "version": "0.0.1", + "description": "Sample core for higher packages to depend on", + "license": "ISC", + "author": "CDMBase LLC", + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "scripts": { + "build": "yarn build:clean && yarn build:lib", + "build:clean": "rimraf lib", + "build:lib": "webpack", + "build:lib:watch": "yarn build:lib -- --watch", + "jest": "./node_modules/.bin/jest", + "prepublish": "yarn build", + "test": "cross-env ENV_FILE=../../config/test/test.env jest", + "test:debug": "npm test -- --runInBand", + "test:watch": "npm test -- --watch", + "watch": "yarn build:lib:watch" + }, + "jest": { + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ], + "modulePaths": [ + "node_modules" + ], + "roots": [ + "src" + ], + "testEnvironment": "node", + "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", + "transform": { + "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" + } + }, + "dependencies": { + "@sample-stack/counter-module-browser": "link:../browser" + }, + "devDependencies": { + "@open-wc/building-rollup": "^1.10.0", + "@rollup/plugin-graphql": "1.0.0", + "@rollup/plugin-image": "^2.0.6", + "@rollup/plugin-typescript": "^6.1.0", + "rollup": "latest" + }, + "peerDependencies": { + "@common-stack/client-react": "*", + "native-base": "*", + "react": "*", + "react-native": "*", + "react-redux": "*", + "react-router": "*", + "react-router-dom": "*", + "redux": "*", + "redux-observable": "*", + "rxjs": "*" + }, + "publishConfig": { + "access": "public" + }, + "typescript": { + "definition": "lib/index.d.ts" + } +} diff --git a/packages-modules/counter/electron/rollup.config.js b/packages-modules/counter/electron/rollup.config.js index 4dc599c4a..c36596d6d 100644 --- a/packages-modules/counter/electron/rollup.config.js +++ b/packages-modules/counter/electron/rollup.config.js @@ -3,28 +3,28 @@ import image from '@rollup/plugin-image'; import typescript from '@rollup/plugin-typescript'; const bundle = (config) => ({ - ...config, - input: 'src/index.ts', - // marking all node modules as external - external: (id) => !/^[./]/.test(id), + ...config, + input: 'src/index.ts', + // marking all node modules as external + external: (id) => !/^[./]/.test(id), }); const globals = { react: 'React' }; export default [ - bundle({ - plugins: [typescript({ noEmitOnError: true }), image(), graphql()], - output: [ - { - dir: 'lib', - format: 'es', - name: 'Counter', - compact: true, - exports: 'named', - sourcemap: true, - preserveModules: true, - chunkFileNames: '[name]-[hash].[format].js', - globals, - }, - ], - }), + bundle({ + plugins: [typescript({ noEmitOnError: true }), image(), graphql()], + output: [ + { + dir: 'lib', + format: 'es', + name: 'Counter', + compact: true, + exports: 'named', + sourcemap: true, + preserveModules: true, + chunkFileNames: '[name]-[hash].[format].js', + globals, + }, + ], + }), ]; diff --git a/packages-modules/counter/electron/src/epics/count-tray-updater.ts b/packages-modules/counter/electron/src/epics/count-tray-updater.ts index 2910586a4..515d2274e 100644 --- a/packages-modules/counter/electron/src/epics/count-tray-updater.ts +++ b/packages-modules/counter/electron/src/epics/count-tray-updater.ts @@ -1,26 +1,34 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { ofType } from 'redux-observable'; import { Observable, of } from 'rxjs'; -import { distinctUntilChanged, map, tap, exhaustMap, pluck, catchError, filter } from 'rxjs/operators'; +import { + distinctUntilChanged, + map, + tap, + exhaustMap, + pluck, + catchError, + filter, +} from 'rxjs/operators'; import { ElectronTypes } from '@common-stack/client-core'; import { CONNECTED_REACT_ROUTER_ACTION_TYPES } from '@sample-stack/counter-module-browser/lib/connected-react-router/constants/action-types'; export const onCountChangedEpic = ( - action$: Observable, - state$: Observable, - { container, routes }: { container: any; routes }, + action$: Observable, + state$: Observable, + { container, routes }: { container: any; routes } ) => - action$.pipe( - ofType(CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT), - exhaustMap(() => - state$.pipe( - pluck('connectedReactRouterCounter'), - distinctUntilChanged(), - tap((count) => { - const st = container.get(ElectronTypes.TrayWindow); - st.updateTitle(count.toString()); - }), - ofType('TRAY_UPDATED'), - ), - ), - ); + action$.pipe( + ofType(CONNECTED_REACT_ROUTER_ACTION_TYPES.INCREMENT), + exhaustMap(() => + state$.pipe( + pluck('connectedReactRouterCounter'), + distinctUntilChanged(), + tap((count) => { + const st = container.get(ElectronTypes.TrayWindow); + st.updateTitle(count.toString()); + }), + ofType('TRAY_UPDATED') + ) + ) + ); diff --git a/packages-modules/counter/electron/src/index.ts b/packages-modules/counter/electron/src/index.ts index f16f0a440..e4ed64922 100755 --- a/packages-modules/counter/electron/src/index.ts +++ b/packages-modules/counter/electron/src/index.ts @@ -3,8 +3,8 @@ import { connectedReactRouterCounter } from '@sample-stack/counter-module-browse import { onCountChangedEpic } from './epics'; const ElectronMainModule = new Feature({ - reducer: { connectedReactRouterCounter }, - epic: [onCountChangedEpic], + reducer: { connectedReactRouterCounter }, + epic: [onCountChangedEpic], }); export default new Feature(ElectronMainModule); diff --git a/packages-modules/counter/electron/tsconfig.json b/packages-modules/counter/electron/tsconfig.json index 360428cb0..42d6a9eb2 100755 --- a/packages-modules/counter/electron/tsconfig.json +++ b/packages-modules/counter/electron/tsconfig.json @@ -1,25 +1,22 @@ { - "extends": "../../../tsconfig.json", - "compilerOptions": { - "allowSyntheticDefaultImports": true, - "experimentalDecorators": true, - "esModuleInterop": true, - "skipLibCheck": true, - "rootDir": "./src", - "outDir": "lib", - "declarationDir": "lib", - "declaration": true, - "declarationMap": true - }, - "exclude": [ - "node_modules", - "lib", - "dist", - "webpack.config.js", - "rollup.config.js" - ], - "include": [ - "src", - "./typings/*.d.ts" - ] -} \ No newline at end of file + "extends": "../../../tsconfig.json", + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "experimentalDecorators": true, + "esModuleInterop": true, + "skipLibCheck": true, + "rootDir": "./src", + "outDir": "lib", + "declarationDir": "lib", + "declaration": true, + "declarationMap": true + }, + "exclude": [ + "node_modules", + "lib", + "dist", + "webpack.config.js", + "rollup.config.js" + ], + "include": ["src", "./typings/*.d.ts"] +} diff --git a/packages-modules/counter/electron/typings/graphql.d.ts b/packages-modules/counter/electron/typings/graphql.d.ts index a14557b3b..1111369ad 100755 --- a/packages-modules/counter/electron/typings/graphql.d.ts +++ b/packages-modules/counter/electron/typings/graphql.d.ts @@ -1,39 +1,39 @@ -declare module "*/AddCounter.client.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const addCounterState: DocumentNode; +declare module '*/AddCounter.client.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const addCounterState: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/AddCounter.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const addCounter: DocumentNode; +declare module '*/AddCounter.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const addCounter: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterQuery.client.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const CounterState: DocumentNode; +declare module '*/CounterQuery.client.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const CounterState: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterQuery.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const counterQuery: DocumentNode; +declare module '*/CounterQuery.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const counterQuery: DocumentNode; - export default defaultDocument; + export default defaultDocument; } -declare module "*/CounterSubscription.gql" { - import { DocumentNode } from "graphql"; - const defaultDocument: DocumentNode; - export const onCounterUpdated: DocumentNode; +declare module '*/CounterSubscription.gql' { + import { DocumentNode } from 'graphql'; + const defaultDocument: DocumentNode; + export const onCounterUpdated: DocumentNode; - export default defaultDocument; + export default defaultDocument; } diff --git a/packages-modules/counter/electron/webpack.config.js b/packages-modules/counter/electron/webpack.config.js index dfa6c9585..fcae2d506 100755 --- a/packages-modules/counter/electron/webpack.config.js +++ b/packages-modules/counter/electron/webpack.config.js @@ -3,72 +3,81 @@ const webpack = require('webpack'); const path = require('path'); const webpackOpts = { - mode: 'development', - entry: { - index: './src/index.ts', - }, - target: 'node', - output: { - path: path.join(__dirname, 'lib'), - filename: '[name].js', - libraryTarget: 'commonjs2', - }, - resolve: { - extensions: ['.ts', '.tsx', '.js', '.graphql', '.graphqls', '.gql', '.native.tsx', '.native.ts'], - }, - plugins: [ - new webpack.LoaderOptionsPlugin({ - options: { - test: /\.tsx?$/, - ts: { - compiler: 'typescript', - configFile: 'tsconfig.json', - }, - tslint: { - emitErrors: true, - failOnHint: true, - }, - }, - }), - ], - devtool: 'source-map', - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - // options: { // breaks with Webpack5 - // compilerOptions: { - // outDir: path.join(), - // }, - // }, - }, - { - test: /\.mjs$/, - include: /node_modules/, - type: 'javascript/auto', - }, - { - test: /\.(gql)$/, - exclude: /node_modules/, - use: ['graphql-tag/loader'], - }, - { - test: /\.graphql?/, - exclude: /node_modules/, - use: 'raw-loader', - }, - ], - }, - externals: [ - nodeExternals({ - allowlist: [/^@sample-stack/], - modulesDir: '../../../node_modules', - }), - nodeExternals({ - allowlist: [/^@sample-stack/], - }), - ], + mode: 'development', + entry: { + index: './src/index.ts', + }, + target: 'node', + output: { + path: path.join(__dirname, 'lib'), + filename: '[name].js', + libraryTarget: 'commonjs2', + }, + resolve: { + extensions: [ + '.ts', + '.tsx', + '.js', + '.graphql', + '.graphqls', + '.gql', + '.native.tsx', + '.native.ts', + ], + }, + plugins: [ + new webpack.LoaderOptionsPlugin({ + options: { + test: /\.tsx?$/, + ts: { + compiler: 'typescript', + configFile: 'tsconfig.json', + }, + tslint: { + emitErrors: true, + failOnHint: true, + }, + }, + }), + ], + devtool: 'source-map', + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + // options: { // breaks with Webpack5 + // compilerOptions: { + // outDir: path.join(), + // }, + // }, + }, + { + test: /\.mjs$/, + include: /node_modules/, + type: 'javascript/auto', + }, + { + test: /\.(gql)$/, + exclude: /node_modules/, + use: ['graphql-tag/loader'], + }, + { + test: /\.graphql?/, + exclude: /node_modules/, + use: 'raw-loader', + }, + ], + }, + externals: [ + nodeExternals({ + allowlist: [/^@sample-stack/], + modulesDir: '../../../node_modules', + }), + nodeExternals({ + allowlist: [/^@sample-stack/], + }), + ], }; module.exports = webpackOpts; diff --git a/packages-modules/counter/mobile/jest.config.js b/packages-modules/counter/mobile/jest.config.js index 3ce5b931a..951369848 100644 --- a/packages-modules/counter/mobile/jest.config.js +++ b/packages-modules/counter/mobile/jest.config.js @@ -2,8 +2,8 @@ const base = require('../../../jest.config.base'); const packageJson = require('./package'); module.exports = { - ...base, - testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment - name: packageJson.name, - displayName: packageJson.name, + ...base, + testEnvironment: 'jsdom', // This is overriden, from the base testEnvironment + name: packageJson.name, + displayName: packageJson.name, }; diff --git a/packages-modules/counter/mobile/package.json b/packages-modules/counter/mobile/package.json index 1c0ead0e0..616a9c686 100755 --- a/packages-modules/counter/mobile/package.json +++ b/packages-modules/counter/mobile/package.json @@ -1,60 +1,60 @@ { - "name": "@sample-stack/counter-module-mobile", - "version": "0.0.1", - "description": "Sample core for higher packages to depend on", - "license": "ISC", - "author": "CDMBase LLC", - "main": "lib/index.js", - "typings": "lib/index.d.ts", - "scripts": { - "build": "yarn build:clean && yarn build:lib", - "build:clean": "rimraf lib", - "build:lib": "tsc", - "build:lib:watch": "yarn build:lib -- --watch", - "jest": "./node_modules/.bin/jest", - "prepublish": "yarn build", - "test": "cross-env ENV_FILE=../../config/test/test.env jest", - "test:debug": "npm test -- --runInBand", - "test:watch": "npm test -- --watch", - "watch": "yarn build:lib:watch" - }, - "jest": { - "moduleFileExtensions": [ - "ts", - "tsx", - "js", - "json" - ], - "modulePaths": [ - "node_modules" - ], - "roots": [ - "src" - ], - "testEnvironment": "node", - "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", - "transform": { - "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" - } - }, - "dependencies": { - "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", - "antd": "~4.15.3" - }, - "peerDependencies": { - "@common-stack/client-react": "*", - "native-base": "*", - "react": "*", - "react-native": "*", - "react-redux": "*", - "react-router": "*", - "react-router-dom": "*", - "redux": "*" - }, - "publishConfig": { - "access": "public" - }, - "typescript": { - "definition": "lib/index.d.ts" - } -} \ No newline at end of file + "name": "@sample-stack/counter-module-mobile", + "version": "0.0.1", + "description": "Sample core for higher packages to depend on", + "license": "ISC", + "author": "CDMBase LLC", + "main": "lib/index.js", + "typings": "lib/index.d.ts", + "scripts": { + "build": "yarn build:clean && yarn build:lib", + "build:clean": "rimraf lib", + "build:lib": "tsc", + "build:lib:watch": "yarn build:lib -- --watch", + "jest": "./node_modules/.bin/jest", + "prepublish": "yarn build", + "test": "cross-env ENV_FILE=../../config/test/test.env jest", + "test:debug": "npm test -- --runInBand", + "test:watch": "npm test -- --watch", + "watch": "yarn build:lib:watch" + }, + "jest": { + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ], + "modulePaths": [ + "node_modules" + ], + "roots": [ + "src" + ], + "testEnvironment": "node", + "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$", + "transform": { + "\\.(ts|tsx)$": "/../../node_modules/ts-jest/preprocessor.js" + } + }, + "dependencies": { + "@sample-stack/platform-browser": "link:../../../packages/sample-platform/browser", + "antd": "~4.24.1" + }, + "peerDependencies": { + "@common-stack/client-react": "*", + "native-base": "*", + "react": "*", + "react-native": "*", + "react-redux": "*", + "react-router": "*", + "react-router-dom": "*", + "redux": "*" + }, + "publishConfig": { + "access": "public" + }, + "typescript": { + "definition": "lib/index.d.ts" + } +} diff --git a/packages-modules/counter/mobile/src/common/components/Dashboard.tsx b/packages-modules/counter/mobile/src/common/components/Dashboard.tsx index 7205da255..cece55d2a 100755 --- a/packages-modules/counter/mobile/src/common/components/Dashboard.tsx +++ b/packages-modules/counter/mobile/src/common/components/Dashboard.tsx @@ -1,4 +1,6 @@ import * as React from 'react'; import { renderRoutes } from 'react-router-config'; -export const Dashboard = (props) => <>{renderRoutes(props.route.routes, { matchPath: props.route.path })}; +export const Dashboard = (props) => ( + <>{renderRoutes(props.route.routes, { matchPath: props.route.path })} +); diff --git a/packages-modules/counter/mobile/src/common/components/Home.tsx b/packages-modules/counter/mobile/src/common/components/Home.tsx index 652c43ee0..2f14ba4eb 100755 --- a/packages-modules/counter/mobile/src/common/components/Home.tsx +++ b/packages-modules/counter/mobile/src/common/components/Home.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; export const Home = () => ( -
-

FullStack-Pro

-
+
+

FullStack-Pro

+
); diff --git a/packages-modules/counter/mobile/src/common/compute.tsx b/packages-modules/counter/mobile/src/common/compute.tsx index bf0afc5fa..0836bc284 100755 --- a/packages-modules/counter/mobile/src/common/compute.tsx +++ b/packages-modules/counter/mobile/src/common/compute.tsx @@ -5,20 +5,22 @@ import { Home } from '../common/components/Home'; import { getFilteredRoutes } from '../utils'; export const commonPageStore: any[] = [ - { - path: '/', - key: 'home', - exact: true, - name: 'Home', - component: Home, - position: IMenuPosition.MIDDLE, - }, + { + path: '/', + key: 'home', + exact: true, + name: 'Home', + component: Home, + position: IMenuPosition.MIDDLE, + }, ]; const selectedRoutesAndMenus = ['home']; - // get routes -const filteredRoutes = getFilteredRoutes(commonPageStore, selectedRoutesAndMenus); +const filteredRoutes = getFilteredRoutes( + commonPageStore, + selectedRoutesAndMenus +); export { filteredRoutes }; diff --git a/packages-modules/counter/mobile/src/common/generated-models.ts b/packages-modules/counter/mobile/src/common/generated-models.ts index 589e5e78d..de0f7c870 100755 --- a/packages-modules/counter/mobile/src/common/generated-models.ts +++ b/packages-modules/counter/mobile/src/common/generated-models.ts @@ -1,6 +1,10 @@ /* tslint:disable */ -import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql'; +import { + GraphQLResolveInfo, + GraphQLScalarType, + GraphQLScalarTypeConfig, +} from 'graphql'; import gql from 'graphql-tag'; import { MyContext } from './interfaces/context'; @@ -8,249 +12,309 @@ import { MyContext } from './interfaces/context'; export type Maybe = T | null; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { - ID: string; - String: string; - Boolean: boolean; - Int: number; - Float: number; - AnyObject: any; - JSON: any; - JSONObject: any; - Date: any; - Time: any; - DateTime: any; + ID: string; + String: string; + Boolean: boolean; + Int: number; + Float: number; + AnyObject: any; + JSON: any; + JSONObject: any; + Date: any; + Time: any; + DateTime: any; }; export type ClientCounter = { - counter?: Maybe; + counter?: Maybe; }; export type Counter = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type FieldError = { - field: Scalars['String']; - message: Scalars['String']; + field: Scalars['String']; + message: Scalars['String']; }; export type Mutation = { - dummy?: Maybe; - addCounterState?: Maybe; - addCounter?: Maybe; + dummy?: Maybe; + addCounterState?: Maybe; + addCounter?: Maybe; }; export type MutationAddCounterStateArgs = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type MutationAddCounterArgs = { - amount?: Maybe; + amount?: Maybe; }; export type Node = { - id: Scalars['ID']; + id: Scalars['ID']; }; export type Query = { - dummy?: Maybe; - counterState?: Maybe; - counter?: Maybe; + dummy?: Maybe; + counterState?: Maybe; + counter?: Maybe; }; export type Subscription = { - dummy?: Maybe; - counterUpdated?: Maybe; + dummy?: Maybe; + counterUpdated?: Maybe; }; export type AddCounterStateMutationVariables = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type AddCounterStateMutation = { __typename?: 'Mutation' } & { - addCounterState: Maybe<{ __typename?: 'ClientCounter' } & Pick>; + addCounterState: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; }; export type AddCounterMutationVariables = { - amount: Scalars['Int']; + amount: Scalars['Int']; }; export type AddCounterMutation = { __typename?: 'Mutation' } & { - addCounter: Maybe<{ __typename?: 'Counter' } & Pick>; + addCounter: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type CounterStateQueryVariables = {}; export type CounterStateQuery = { __typename?: 'Query' } & { - counterState: Maybe<{ __typename?: 'ClientCounter' } & Pick>; + counterState: Maybe< + { __typename?: 'ClientCounter' } & Pick + >; }; export type CounterQueryQueryVariables = {}; export type CounterQueryQuery = { __typename?: 'Query' } & { - counter: Maybe<{ __typename?: 'Counter' } & Pick>; + counter: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type OnCounterUpdatedSubscriptionVariables = {}; export type OnCounterUpdatedSubscription = { __typename?: 'Subscription' } & { - counterUpdated: Maybe<{ __typename?: 'Counter' } & Pick>; + counterUpdated: Maybe<{ __typename?: 'Counter' } & Pick>; }; export type ResolverFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => Promise | TResult; export type StitchingResolver = { - fragment: string; - resolve: ResolverFn; + fragment: string; + resolve: ResolverFn; }; export type Resolver = - | ResolverFn - | StitchingResolver; + | ResolverFn + | StitchingResolver; export type SubscriptionSubscribeFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => AsyncIterator | Promise>; export type SubscriptionResolveFn = ( - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; export interface SubscriptionResolverObject { - subscribe: SubscriptionSubscribeFn; - resolve?: SubscriptionResolveFn; + subscribe: SubscriptionSubscribeFn; + resolve?: SubscriptionResolveFn; } -export type SubscriptionResolver = - | ((...args: any[]) => SubscriptionResolverObject) - | SubscriptionResolverObject; +export type SubscriptionResolver< + TResult, + TParent = {}, + TContext = {}, + TArgs = {} +> = + | (( + ...args: any[] + ) => SubscriptionResolverObject) + | SubscriptionResolverObject; export type TypeResolveFn = ( - parent: TParent, - context: TContext, - info: GraphQLResolveInfo, + parent: TParent, + context: TContext, + info: GraphQLResolveInfo ) => Maybe; export type NextResolverFn = () => Promise; -export type DirectiveResolverFn = ( - next: NextResolverFn, - parent: TParent, - args: TArgs, - context: TContext, - info: GraphQLResolveInfo, +export type DirectiveResolverFn< + TResult = {}, + TParent = {}, + TContext = {}, + TArgs = {} +> = ( + next: NextResolverFn, + parent: TParent, + args: TArgs, + context: TContext, + info: GraphQLResolveInfo ) => TResult | Promise; /** Mapping between all available schema types and the resolvers types */ export type ResolversTypes = { - Query: {}; - Int: Scalars['Int']; - ClientCounter: ClientCounter; - Counter: Counter; - Mutation: {}; - Subscription: {}; - String: Scalars['String']; - Boolean: Scalars['Boolean']; - AnyObject: Scalars['AnyObject']; - JSON: Scalars['JSON']; - JSONObject: Scalars['JSONObject']; - FieldError: FieldError; - Node: Node; - ID: Scalars['ID']; - Date: Scalars['Date']; - Time: Scalars['Time']; - DateTime: Scalars['DateTime']; + Query: {}; + Int: Scalars['Int']; + ClientCounter: ClientCounter; + Counter: Counter; + Mutation: {}; + Subscription: {}; + String: Scalars['String']; + Boolean: Scalars['Boolean']; + AnyObject: Scalars['AnyObject']; + JSON: Scalars['JSON']; + JSONObject: Scalars['JSONObject']; + FieldError: FieldError; + Node: Node; + ID: Scalars['ID']; + Date: Scalars['Date']; + Time: Scalars['Time']; + DateTime: Scalars['DateTime']; }; -export interface AnyObjectScalarConfig extends GraphQLScalarTypeConfig { - name: 'AnyObject'; +export interface AnyObjectScalarConfig + extends GraphQLScalarTypeConfig { + name: 'AnyObject'; } -export type ClientCounterResolvers = { - counter?: Resolver, ParentType, ContextType>; +export type ClientCounterResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['ClientCounter'] +> = { + counter?: Resolver, ParentType, ContextType>; }; -export type CounterResolvers = { - amount?: Resolver; +export type CounterResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Counter'] +> = { + amount?: Resolver; }; -export interface DateScalarConfig extends GraphQLScalarTypeConfig { - name: 'Date'; +export interface DateScalarConfig + extends GraphQLScalarTypeConfig { + name: 'Date'; } -export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig { - name: 'DateTime'; +export interface DateTimeScalarConfig + extends GraphQLScalarTypeConfig { + name: 'DateTime'; } -export type FieldErrorResolvers = { - field?: Resolver; - message?: Resolver; +export type FieldErrorResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['FieldError'] +> = { + field?: Resolver; + message?: Resolver; }; -export interface JsonScalarConfig extends GraphQLScalarTypeConfig { - name: 'JSON'; +export interface JsonScalarConfig + extends GraphQLScalarTypeConfig { + name: 'JSON'; } -export interface JsonObjectScalarConfig extends GraphQLScalarTypeConfig { - name: 'JSONObject'; +export interface JsonObjectScalarConfig + extends GraphQLScalarTypeConfig { + name: 'JSONObject'; } -export type MutationResolvers = { - dummy?: Resolver, ParentType, ContextType>; - addCounterState?: Resolver< - Maybe, - ParentType, - ContextType, - MutationAddCounterStateArgs - >; - addCounter?: Resolver, ParentType, ContextType, MutationAddCounterArgs>; +export type MutationResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Mutation'] +> = { + dummy?: Resolver, ParentType, ContextType>; + addCounterState?: Resolver< + Maybe, + ParentType, + ContextType, + MutationAddCounterStateArgs + >; + addCounter?: Resolver< + Maybe, + ParentType, + ContextType, + MutationAddCounterArgs + >; }; -export type NodeResolvers = { - __resolveType: TypeResolveFn; - id?: Resolver; +export type NodeResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Node'] +> = { + __resolveType: TypeResolveFn; + id?: Resolver; }; -export type QueryResolvers = { - dummy?: Resolver, ParentType, ContextType>; - counterState?: Resolver, ParentType, ContextType>; - counter?: Resolver, ParentType, ContextType>; +export type QueryResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Query'] +> = { + dummy?: Resolver, ParentType, ContextType>; + counterState?: Resolver< + Maybe, + ParentType, + ContextType + >; + counter?: Resolver, ParentType, ContextType>; }; -export type SubscriptionResolvers = { - dummy?: SubscriptionResolver, ParentType, ContextType>; - counterUpdated?: SubscriptionResolver, ParentType, ContextType>; +export type SubscriptionResolvers< + ContextType = MyContext, + ParentType = ResolversTypes['Subscription'] +> = { + dummy?: SubscriptionResolver< + Maybe, + ParentType, + ContextType + >; + counterUpdated?: SubscriptionResolver< + Maybe, + ParentType, + ContextType + >; }; -export interface TimeScalarConfig extends GraphQLScalarTypeConfig { - name: 'Time'; +export interface TimeScalarConfig + extends GraphQLScalarTypeConfig { + name: 'Time'; } export type Resolvers = { - AnyObject?: GraphQLScalarType; - ClientCounter?: ClientCounterResolvers; - Counter?: CounterResolvers; - Date?: GraphQLScalarType; - DateTime?: GraphQLScalarType; - FieldError?: FieldErrorResolvers; - JSON?: GraphQLScalarType; - JSONObject?: GraphQLScalarType; - Mutation?: MutationResolvers; - Node?: NodeResolvers; - Query?: QueryResolvers; - Subscription?: SubscriptionResolvers; - Time?: GraphQLScalarType; + AnyObject?: GraphQLScalarType; + ClientCounter?: ClientCounterResolvers; + Counter?: CounterResolvers; + Date?: GraphQLScalarType; + DateTime?: GraphQLScalarType; + FieldError?: FieldErrorResolvers; + JSON?: GraphQLScalarType; + JSONObject?: GraphQLScalarType; + Mutation?: MutationResolvers; + Node?: NodeResolvers; + Query?: QueryResolvers; + Subscription?: SubscriptionResolvers; + Time?: GraphQLScalarType; }; /** @@ -261,37 +325,37 @@ export type IResolvers = Resolvers; export type Omit = Pick>; export const AddCounterStateDocument = gql` - mutation addCounterState($amount: Int!) { - addCounterState(amount: $amount) @client { - counter - } - } + mutation addCounterState($amount: Int!) { + addCounterState(amount: $amount) @client { + counter + } + } `; export const AddCounterDocument = gql` - mutation addCounter($amount: Int!) { - addCounter(amount: $amount) { - amount - } - } + mutation addCounter($amount: Int!) { + addCounter(amount: $amount) { + amount + } + } `; export const CounterStateDocument = gql` - query CounterState { - counterState @client { - counter - } - } + query CounterState { + counterState @client { + counter + } + } `; export const CounterQueryDocument = gql` - query counterQuery { - counter { - amount - } - } + query counterQuery { + counter { + amount + } + } `; export const OnCounterUpdatedDocument = gql` - subscription onCounterUpdated { - counterUpdated { - amount - } - } + subscription onCounterUpdated { + counterUpdated { + amount + } + } `; diff --git a/packages-modules/counter/mobile/src/common/interfaces/context.ts b/packages-modules/counter/mobile/src/common/interfaces/context.ts index acb8051de..b512fd3cc 100755 --- a/packages-modules/counter/mobile/src/common/interfaces/context.ts +++ b/packages-modules/counter/mobile/src/common/interfaces/context.ts @@ -2,7 +2,11 @@ import { DataProxy } from '@apollo/client/cache'; import { ApolloClient } from '@apollo/client'; export interface MyContext { - cache: DataProxy; - getCacheKey: (options: { __typename: string; resource?: string; id?: string }) => string; - apolloClient: ApolloClient; + cache: DataProxy; + getCacheKey: (options: { + __typename: string; + resource?: string; + id?: string; + }) => string; + apolloClient: ApolloClient; } diff --git a/packages-modules/counter/mobile/src/common/module.tsx b/packages-modules/counter/mobile/src/common/module.tsx index 7918aaf13..ee20fcd70 100755 --- a/packages-modules/counter/mobile/src/common/module.tsx +++ b/packages-modules/counter/mobile/src/common/module.tsx @@ -1,8 +1,8 @@ -import * as React from 'react'; +import * as React from 'react'; import { Feature } from '@common-stack/client-react'; import { filteredRoutes } from './compute'; export default new Feature({ - routeConfig: filteredRoutes, + routeConfig: filteredRoutes, }); diff --git a/packages-modules/counter/mobile/src/connected-react-router/README.md b/packages-modules/counter/mobile/src/connected-react-router/README.md index c3e235afe..3043e9f25 100755 --- a/packages-modules/counter/mobile/src/connected-react-router/README.md +++ b/packages-modules/counter/mobile/src/connected-react-router/README.md @@ -4,7 +4,6 @@ You can try changing counter value and editing some components. Components will In Hello link, you will see that the HelloChild component can access router state (URL path) without passing as props via its parent. - Reference: -https://github.com/supasate/connected-react-router/tree/master/examples/typescript \ No newline at end of file +https://github.com/supasate/connected-react-router/tree/master/examples/typescript diff --git a/packages-modules/counter/mobile/src/connected-react-router/components/Counter.tsx b/packages-modules/counter/mobile/src/connected-react-router/components/Counter.tsx index 7b7fba025..aa68b35fc 100644 --- a/packages-modules/counter/mobile/src/connected-react-router/components/Counter.tsx +++ b/packages-modules/counter/mobile/src/connected-react-router/components/Counter.tsx @@ -6,42 +6,44 @@ import { increment, decrement } from '../redux'; import { State } from '../interfaces'; interface CounterStateProps { - count: number; + count: number; } interface CounterDispatchProps { - increment: () => void; - decrement: () => void; + increment: () => void; + decrement: () => void; } -const CounterScreen: React.FC = (props) => { - return ( - - - - Counter value: {props.count} - - - - - ); + const navigation = useNavigation(); + return ( + + Dashboard Value + Calendar + + + ); }; const styles = StyleSheet.create