From 572a65079df1f30e748a1d824e54a2fa46d2d839 Mon Sep 17 00:00:00 2001 From: dergash Date: Thu, 28 Jan 2021 11:28:53 +0300 Subject: [PATCH] export declarations --- CHANGELOG.md | 16 ++++++++++++++++ README.md | 7 +++++++ package.json | 9 +++++---- src/files/{ScreenMeta.d.ts => ScreenMeta.ts} | 0 src/files/{SqlBc.d.ts => SqlBc.ts} | 0 src/files/{ViewMeta.d.ts => ViewMeta.ts} | 0 src/files/{WidgetMeta.d.ts => WidgetMeta.ts} | 0 src/generator.ts | 2 +- src/index.ts | 5 +++++ src/interfaces/{data.d.ts => data.ts} | 0 .../{navigation.d.ts => navigation.ts} | 0 .../{operations.d.ts => operations.ts} | 0 src/interfaces/{router.d.ts => router.ts} | 0 src/interfaces/{widget.d.ts => widget.ts} | 0 tsconfig.json | 10 ++++++++++ 15 files changed, 44 insertions(+), 5 deletions(-) rename src/files/{ScreenMeta.d.ts => ScreenMeta.ts} (100%) rename src/files/{SqlBc.d.ts => SqlBc.ts} (100%) rename src/files/{ViewMeta.d.ts => ViewMeta.ts} (100%) rename src/files/{WidgetMeta.d.ts => WidgetMeta.ts} (100%) rename src/interfaces/{data.d.ts => data.ts} (100%) rename src/interfaces/{navigation.d.ts => navigation.ts} (100%) rename src/interfaces/{operations.d.ts => operations.ts} (100%) rename src/interfaces/{router.d.ts => router.ts} (100%) rename src/interfaces/{widget.d.ts => widget.ts} (100%) create mode 100644 tsconfig.json diff --git a/CHANGELOG.md b/CHANGELOG.md index de1fc14..2b197ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# Version 0.2.0 (January 28, 2021) + +## Features + +* Source types for JSON schemas are now exported and can be extended in your application to customize generated schemas. +0.3.0 is scheduled to export a function that will take customized types as arguments and will generate schemas based on provided customization. +```ts +import { ScreenMetaJson } from '@tesler-ui/schema' + +export interface CustomScreenMetaJson extends ScreenMeta { + customField: number // add or modify fields if your *.screen.json file format is different +} +``` + +* Some types that previously were declared in [Tesler-UI](https://github.com/tesler-platform/tesler-ui) are moved here as they in fact affect both backend and frontend applications; Tesler UI will reexport those types so nothing should break if you referenced them from your application directly. + # Version 0.1.3 (January 26, 2021) ## Fixes diff --git a/README.md b/README.md index 1aadb43..3159e70 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ yarn add @tesler-ui/schema }, ``` +### Disable `@tesler-ui/schema` in the `browser` section of your `package.json` file: +```json +"browser": { + "@tesler-ui/schema": false +} +``` + ### Launch command to generate schemas ```sh yarn gen:schema diff --git a/package.json b/package.json index 728b31b..fa7d531 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tesler-ui/schema", - "version": "0.1.3", + "version": "0.2.0", "author": { "name": "Constantine Dergachev", "email": "dergachev@hotmail.com", @@ -11,13 +11,14 @@ "url": "git://github.com/tesler-platform/tesler-schema.git" }, "homepage": "https://github.com/tesler-platform/tesler-schema", - "main": "dist/generator.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", "license": "Apache-2.0", "bin": "./bin/build-schema", "scripts": { "lint": "prettier ./src --write", - "build": "tsc ./src/generator.ts --outDir dist --importsNotUsedAsValues remove", - "gen:schema": "yarn build && node ./dist/generator.js" + "build": "tsc", + "gen:schema": "yarn build && node ./dist/index.js" }, "devDependencies": { "@types/node": "^14.14.22", diff --git a/src/files/ScreenMeta.d.ts b/src/files/ScreenMeta.ts similarity index 100% rename from src/files/ScreenMeta.d.ts rename to src/files/ScreenMeta.ts diff --git a/src/files/SqlBc.d.ts b/src/files/SqlBc.ts similarity index 100% rename from src/files/SqlBc.d.ts rename to src/files/SqlBc.ts diff --git a/src/files/ViewMeta.d.ts b/src/files/ViewMeta.ts similarity index 100% rename from src/files/ViewMeta.d.ts rename to src/files/ViewMeta.ts diff --git a/src/files/WidgetMeta.d.ts b/src/files/WidgetMeta.ts similarity index 100% rename from src/files/WidgetMeta.d.ts rename to src/files/WidgetMeta.ts diff --git a/src/generator.ts b/src/generator.ts index 0817a78..ca44d2f 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -35,7 +35,7 @@ export function run() { mkdirSync('schemas') } const program = TJS.getProgramFromFiles( - schemas.map(item => join(__dirname, '../', `src/files/${item}.d.ts`)), + schemas.map(item => join(__dirname, '../', `src/files/${item}.ts`)), compilerOptions ) const generator = TJS.buildGenerator(program, settings) diff --git a/src/index.ts b/src/index.ts index 53f11d8..1e6e534 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,3 +20,8 @@ export { ScreenMetaJson } from './files/ScreenMeta' export { ViewMetaJson } from './files/ViewMeta' export { WidgetMetaJson } from './files/WidgetMeta' export { SqlBcJson } from './files/SqlBc' +export * from './interfaces/data' +export * from './interfaces/navigation' +export * from './interfaces/operations' +export * from './interfaces/router' +export * from './interfaces/widget' diff --git a/src/interfaces/data.d.ts b/src/interfaces/data.ts similarity index 100% rename from src/interfaces/data.d.ts rename to src/interfaces/data.ts diff --git a/src/interfaces/navigation.d.ts b/src/interfaces/navigation.ts similarity index 100% rename from src/interfaces/navigation.d.ts rename to src/interfaces/navigation.ts diff --git a/src/interfaces/operations.d.ts b/src/interfaces/operations.ts similarity index 100% rename from src/interfaces/operations.d.ts rename to src/interfaces/operations.ts diff --git a/src/interfaces/router.d.ts b/src/interfaces/router.ts similarity index 100% rename from src/interfaces/router.d.ts rename to src/interfaces/router.ts diff --git a/src/interfaces/widget.d.ts b/src/interfaces/widget.ts similarity index 100% rename from src/interfaces/widget.d.ts rename to src/interfaces/widget.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a92f773 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "outDir": "./dist/", + "baseUrl": "./src", + "declaration": true + }, + "include": [ + "src/index.ts" + ] +}