diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..e2fecb7 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +**/*.js +**/*.d.ts +tests diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1851d59 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,61 @@ +{ + "extends": [ + "airbnb", + "airbnb-typescript", + "airbnb/hooks", + "plugin:@typescript-eslint/recommended", + "prettier", + "plugin:prettier/recommended" + ], + "plugins": [ + "react", + "@typescript-eslint" + ], + "env": { + "browser": true, + "es6": true, + "jest": true + }, + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 2018, + "sourceType": "module", + "project": "./tsconfig.json" + }, + "rules": { + "no-plusplus": "warn", + "no-restricted-syntax": "warn", + "@typescript-eslint/no-explicit-any": "warn", + "no-underscore-dangle": "warn", + "no-await-in-loop": "warn", + "class-methods-use-this": "warn", + "linebreak-style": "off", + "no-restricted-properties": "warn", + "import/extensions": [ + "warn", + "ignorePackages", + { + "js": "never", + "jsx": "never", + "ts": "never", + "tsx": "never", + "d.ts": "never" + } + ], + "react/no-unused-state": "warn", + "prettier/prettier": [ + "error", + { + "endOfLine": "auto", + "singleQuote": true + } + ] + } +} diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml new file mode 100644 index 0000000..9813486 --- /dev/null +++ b/.github/workflows/typedoc.yml @@ -0,0 +1,32 @@ +# ci.yml file for GitHub Actions +name: CI + +on: + push: + branches: + - main + +jobs: + build_and_lint: + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + + - name: Install dependencies + run: npm install + + - name: Create the docs directory locally in CI + run: npm run makeDocs + + - name: Add testreport to docs folder + run: npm run doc-converage + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..810454d --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +dist +node_modules +.idea +package-lock.json +out +export +*.js +*.d.ts +dev.patch +.scannerwork +certs +update.key +docs +.env +coverage +data +junit.xml +/sonar-project.properties +openapi.yaml +/openapi.yml +!jest.config.js +*.tgz +*.iml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2390e81 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,17 @@ +include: + - project: 'grandlinex/templates' + file: '/stages.yml' + - project: 'grandlinex/templates' + file: '/prod/core-bundle.yml' + - project: 'grandlinex/templates' + file: '/build/core-bundle.yml' + - project: 'grandlinex/templates' + file: '/sonar/core-sonar.yml' + - project: 'grandlinex/templates' + file: '/deploy/npm-deploy.yml' + - project: 'grandlinex/templates' + file: '/update/update-glx.yml' + - project: 'grandlinex/templates' + file: '/deploy/npm-gitlab-deploy.yml' + - project: 'grandlinex/templates' + file: '/test/sast.yml' diff --git a/.ncurc.json b/.ncurc.json new file mode 100644 index 0000000..7b59b28 --- /dev/null +++ b/.ncurc.json @@ -0,0 +1,4 @@ +{ + "upgrade": true, + "reject": [] +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..b2dee1f --- /dev/null +++ b/.npmignore @@ -0,0 +1,27 @@ +.gitlab-ci.yml +.eslintrc +node_modules +docs +.idea +.env +docker-compose.yml +jest.config.js +package-lock.json +data +src +tests +scripts +glconf.json +site +.eslintignore +.env.example +tsconfig.json +.scannerwork +sonar-project.properties +coverage +*.tgz +*.iml +.ncurc.json +.npmrc +junit.xml +.github diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..db6292b --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, GrandLineX +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5380c78 --- /dev/null +++ b/README.md @@ -0,0 +1,78 @@ +# GrandLineX Cron Bundle + +> Cron support for GrandLineX + +## Description + +img + +GrandLineX is an out-of-the-box server framework. + + +[![GitHub](https://badge.fury.io/gh/grandlinex%2Fbundle-cron.svg)](https://github.com/GrandlineX/bundle-cron) +[![NPM](https://img.shields.io/static/v1?label=NPM&message=Package&color=red&logo=NPM)](https://www.npmjs.com/package/@grandlinex/bundle-cron) +![TS](https://img.shields.io/static/v1?label=Language&message=TypeScript&color=blue&logo=TypeScript) + + +### Status +![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=alert_status) +![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=security_rating) +![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=sqale_rating) +![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=reliability_rating) +![Coverage](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=coverage) + +### Issues +![Bugs](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=bugs) +![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=vulnerabilities) +![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=GrandlineX_bundle-cron&metric=code_smells) + + + +## Install + +### Example + +```typescript + +class TestKernel extends CoreKernel { + constructor(appName:string, appCode:string) { + super( { appName, appCode}); + + // ... + + /** + * Add the module to the kernel + */ + + this.addModule(new CronModule(this)); + + /** + * Define kernel event + */ + + this.on("test-trigger",()=>{ + console.log("test-trigger"); + }) + + /** + * Add cron timer + */ + const mod = kernel.getChildModule('cron') as CronModule; + + const client = mod.getClient() as CronClient; + client.registerCron({ + trigger: 'test-trigger', + name: 'test', + cron: '0 * * * *', + }); + } +} + +``` + + + +## Documentation +- [Documentation](https://grandlinex.github.io/bundle-cron/) +- [GrandLineX Docs](https://grandlinex.github.io/docs/) +- [GrandLineX Project](https://grandlinex.github.io/) diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..8cacb83 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,22 @@ +export default { + testRegex: "(/tests/*.test.ts|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + coverageReporters: ["html", "text", "text-summary", "cobertura", "lcov"], + collectCoverageFrom: ["**/*.ts", "!**/node_modules/**","!tests/**"], + testPathIgnorePatterns: ["/dist/", "/node_modules/"], + moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], + extensionsToTreatAsEsm: [".ts"], + setupFilesAfterEnv: ["./node_modules/@grandlinex/core/jest.pre.config.js"], + moduleNameMapper: { + "^(\\.{1,2}/.*)\\.js$": "$1" + }, + transform: { + // '^.+\\.[tj]sx?$' to process js/ts with `ts-jest` + // '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest` + "^.+\\.tsx?$": [ + "ts-jest", + { + "useESM": true + } + ] + } +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..40625f5 --- /dev/null +++ b/package.json @@ -0,0 +1,79 @@ +{ + "name": "@grandlinex/bundle-cron", + "version": "1.0.0", + "description": "", + "type": "module", + "exports": { + ".": { + "import": { + "types": "./dist/mjs/index.d.ts", + "default": "./dist/mjs/index.js" + }, + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + } + } + }, + "types": "dist/cjs/index.d.ts", + "main": "dist/cjs/index.js", + "module": "dist/mjs/index.js", + "scripts": { + "buildprep": "npm run build-mjs && npm run build-cjs && npm run build-fix", + "build-mjs": "tsc", + "build-cjs": "tsc -p tsconfig-cjs.json", + "build-fix": "node ./node_modules/@grandlinex/core/fix.js", + "lint": "eslint src", + "test": "jest --runInBand ", + "run": "ts-node tests/run.ts", + "pack": "eslint && npm run buildprep && npm pack", + "test-converage": "jest --runInBand --ci --collectCoverage --coverageDirectory=\"./coverage\" --reporters=default --reporters=jest-junit", + "doc-converage": "jest --runInBand --ci --collectCoverage --coverageDirectory=\"./docs/coverage\" --reporters=default --reporters=jest-junit", + "makeDocs": "typedoc" + }, + "keywords": [ + "typescript", + "framework", + "bundle", + "grandlinex", + "orm", + "cron" + ], + "author": { + "name": "Elschnagoo" + }, + "license": "BSD-3-Clause", + "dependencies": { + "@grandlinex/core": "1.0.0", + "node-cron": "3.0.3" + }, + "devDependencies": { + "@types/jest": "29.5.12", + "@types/node-cron": "3.0.11", + "@types/node": "22.0.0", + "@typescript-eslint/eslint-plugin": "7.18.0", + "@typescript-eslint/parser": "7.18.0", + "eslint": "8.57.0", + "eslint-config-airbnb": "19.0.4", + "eslint-config-airbnb-typescript": "18.0.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-import": "2.29.1", + "eslint-plugin-jest": "28.6.0", + "eslint-plugin-jsx-a11y": "6.9.0", + "eslint-plugin-prettier": "5.2.1", + "eslint-plugin-react": "7.35.0", + "eslint-plugin-react-hooks": "4.6.2", + "jest": "29.7.0", + "jest-junit": "16.0.0", + "prettier": "3.3.3", + "ts-jest": "29.1.5", + "ts-loader": "9.5.1", + "ts-node": "10.9.2", + "typedoc": "0.26.5", + "typescript": "5.5.4" + }, + "repository": { + "type": "git", + "url": "https://github.com/GrandlineX/bundle-multilang" + } +} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..b5cb79d --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +# must be unique in a given SonarQube instance +sonar.projectKey=GrandlineX_bundle-cron +sonar.organization=grandlinex +# --- optional properties --- + +#sonar.projectVersion=1.0 +# Path is relative to the sonar-project.properties file. Defaults to. + +sonar.sources=. + +sonar.javascript.lcov.reportPaths=coverage/lcov.info +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 +sonar.exclusions=dist/**, node_modules/** ,out/**, src/tests/**, data/**, tests/**, coverage/** , jest.config.js diff --git a/src/CronModule.ts b/src/CronModule.ts new file mode 100644 index 0000000..5fc0352 --- /dev/null +++ b/src/CronModule.ts @@ -0,0 +1,22 @@ +import { CoreKernelModule, ICoreKernel } from '@grandlinex/core'; +import CronClient from './client/CronClient.js'; + +export default class CronModule extends CoreKernelModule< + ICoreKernel, + any, + CronClient, + any, + any +> { + constructor(kernel: ICoreKernel) { + super('cron', kernel); + } + + async initModule(): Promise { + this.setClient(new CronClient(this)); + } + + async final() { + await this.getClient().start(); + } +} diff --git a/src/client/CronClient.ts b/src/client/CronClient.ts new file mode 100644 index 0000000..9fb5755 --- /dev/null +++ b/src/client/CronClient.ts @@ -0,0 +1,30 @@ +import { CoreClient, ICoreKernelModule } from '@grandlinex/core'; +import { CronRegistration, CronService } from '../service/CronService.js'; + +export default class CronClient extends CoreClient { + service: CronService; + + constructor(mod: ICoreKernelModule) { + super('cron', mod); + this.service = new CronService(mod); + mod.addService(this.service); + } + + async start() { + await this.getModule().startService(this.service.getName()); + } + + async registerCron(...cron: CronRegistration[]) { + if (this.service.started) { + for (const c of cron) { + await this.service.startCron(c); + } + } else { + this.service.cronList.push(...cron); + } + } + + async stopCron(name: string) { + return this.service.stopCron(name); + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..3d90215 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,7 @@ +import CronClient from './client/CronClient.js'; +import CronModule from './CronModule.js'; + +export * from './service/CronService.js'; + +export { CronClient, CronModule }; +export default CronModule; diff --git a/src/service/CronService.ts b/src/service/CronService.ts new file mode 100644 index 0000000..bf1432f --- /dev/null +++ b/src/service/CronService.ts @@ -0,0 +1,63 @@ +import * as nodeCron from 'node-cron'; + +import { + CoreService, + CMap, + ICoreKernelModule, + ICoreKernel, +} from '@grandlinex/core'; + +export type CronRegistration = { + name: string; + cron: string; + eventName: string; +}; +export class CronService extends CoreService> { + list: CMap; + + cronList: CronRegistration[]; + + started: boolean; + + constructor( + mod: ICoreKernelModule, + cronList: CronRegistration[] = [], + ) { + super('chron-service', mod, true); + this.list = new CMap(); + this.cronList = cronList; + this.started = false; + } + + async startCron({ name, cron, eventName }: CronRegistration) { + this.log('register', `${name} @`, cron); + this.list.set( + name, + nodeCron.schedule(cron, async () => { + this.log('trigger', name); + await this.getKernel().triggerEvent(eventName); + }), + ); + } + + async stopCron(name: string) { + const task = this.list.get(name); + if (task) { + task.stop(); + this.list.delete(name); + return true; + } + return false; + } + + async start(): Promise { + this.started = true; + this.cronList.forEach((cr) => this.startCron(cr)); + } + + async stop(): Promise { + this.list.forEach((cr) => { + cr.stop(); + }); + } +} diff --git a/src/tests/core.test.ts b/src/tests/core.test.ts new file mode 100644 index 0000000..0e344e6 --- /dev/null +++ b/src/tests/core.test.ts @@ -0,0 +1,64 @@ +import * as Path from 'path'; +import { + JestLib, + setupDevKernel, + TestContext, + TestKernel, + XUtil, +} from '@grandlinex/core'; +import CronModule from '../index.js'; +import CronClient from '../client/CronClient.js'; + +const appName = 'TestKernel'; +const appCode = 'tkernel'; +const [testPath] = XUtil.setupEnvironment( + [__dirname, '..'], + ['data', 'config'], +); +const pathToTranslation = Path.join(__dirname, 'res'); +const defaultLangKey = 'en'; + +const [kernel] = TestContext.getEntity({ + kernel: new TestKernel(appName, appCode, testPath, __dirname), + cleanUpPath: testPath, +}); +const store = kernel.getConfigStore(); + +kernel.addModule(new CronModule(kernel)); + +setupDevKernel(kernel); + +describe('Clean start', () => { + test('preload', async () => { + expect(kernel.getState()).toBe('init'); + }); + test('start kernel', async () => { + const result = await kernel.start(); + expect(result).toBe(true); + expect(kernel.getModCount()).toBe(3); + expect(kernel.getState()).toBe('running'); + }); +}); +JestLib.jestCore(); +describe('TestDatabase', () => { + test('get version', async () => { + const db = kernel.getChildModule('testModule')?.getDb(); + const conf = await db?.getConfig('dbversion'); + expect(conf?.c_value).not.toBeNull(); + }); +}); + +describe('MultiLang', () => { + const mod = kernel.getChildModule('cron') as CronModule; + test('translator', async () => { + const client = mod.getClient() as CronClient; + await client.registerCron({ + eventName: 'test-trigger', + name: 'test', + cron: '* 1 * * * *', + }); + expect(await client.stopCron('test')).toBeTruthy(); + }); +}); + +JestLib.jestEnd(); diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json new file mode 100644 index 0000000..bd229ec --- /dev/null +++ b/tsconfig-cjs.json @@ -0,0 +1,92 @@ +{ + "compilerOptions": { + "jsx": "react", + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "baseUrl": "./src", + "declaration": true, + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "ES2020", + /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "module": "commonjs", + /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist/cjs", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, + /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true, + /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + + /* Advanced Options */ + "skipLibCheck": true, + /* Skip type checking of declaration files. */ + "forceConsistentCasingInFileNames": true + /* Disallow inconsistently-cased references to the same file. */ + }, + "exclude": [ + "node_modules", + "dist", + "data", + "tests" + ], + "typedocOptions": { + "entryPoints": [ + "./src" + ], + "out": "docs", + "exclude": "node_modules" + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..07ecf07 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,93 @@ +{ + "compilerOptions": { + "jsx": "react", + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + "baseUrl": "./src", + "declaration": true, + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "ES2020", + /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ + "module": "NodeNext", + /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ + // "lib": [], /* Specify library files to be included in the compilation. */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + "outDir": "./dist/mjs", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "composite": true, /* Enable project compilation */ + // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + + /* Strict Type-Checking Options */ + "strict": true, + /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "strictFunctionTypes": true, /* Enable strict checking of function types. */ + // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ + // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ + + /* Module Resolution Options */ + "moduleResolution": "NodeNext", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + "esModuleInterop": true, + /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + + /* Source Map Options */ + // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + + /* Advanced Options */ + "skipLibCheck": true, + /* Skip type checking of declaration files. */ + "forceConsistentCasingInFileNames": true, + /* Disallow inconsistently-cased references to the same file. */ + "types": ["reflect-metadata","node","jest"] + }, + "exclude": [ + "node_modules", + "dist", + "data", + "tests" + ], + "typedocOptions": { + "entryPoints": [ + "./src" + ], + "out": "docs", + "exclude": "node_modules" + } +}