Skip to content

Commit

Permalink
feat(fhir-ts-codegen): initial commit for fhir-ts-codegen package
Browse files Browse the repository at this point in the history
  • Loading branch information
tangdrew committed Jan 21, 2019
1 parent 01d8b74 commit ba69f32
Show file tree
Hide file tree
Showing 234 changed files with 395,749 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lerna-debug.log
lerna-debug.log
node_modules
13 changes: 9 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"packages": [
"packages/*"
],
"version": "independent"
"packages": ["packages/*"],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"conventionalCommits": true
}
}
}
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
{
"name": "root",
"name": "fhir-ts",
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"bootstrap": "lerna bootstrap"
},
"devDependencies": {
"lerna": "^3.10.5"
"@types/glob": "^5.0.35",
"@types/jest": "^23.3.2",
"@types/node": "^10.9.3",
"jest": "^23.6.0",
"lerna": "^3.10.5",
"ts-jest": "^23.1.4",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"typescript": "^3.0.1"
},
"dependencies": {
"fhir-ts-codegen": "file:packages/fhir-ts-codegen"
}
}
5 changes: 5 additions & 0 deletions packages/fhir-ts-codegen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.vscode
.DS_Store
coverage
dist
2 changes: 2 additions & 0 deletions packages/fhir-ts-codegen/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
structure-definitions
1 change: 1 addition & 0 deletions packages/fhir-ts-codegen/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 10.14.1
21 changes: 21 additions & 0 deletions packages/fhir-ts-codegen/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [2018] [Andrew Tang]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions packages/fhir-ts-codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# fhir-ts-codegen

FHIR TypeScript definitions generator.

## Disclaimer

This project is still in early stages of development and should not be considered "production-ready".

## Installation

```sh
npm install fhir-ts-codegen -g
```

## Usage

```sh
fhir-ts-codegen <pattern> <output-directory>
```

Example:

```sh
fhir-ts-codegen "structure-defintions/**.profile.json" "types"
```

## Roadmap

- Resource Definitions
- [x] Interface declaration from snapshot
- [x] Property names
- [x] Property type names
- [x] Optional properties
- [x] Array properties
- [x] JSDoc comments
- [x] Backbone Element properties
- [ ] Interface declaration from differential
- [ ] Default values
- [x] Content reference
- Primitive types
- [x] Type aliases
- [x] Extensions
- CLI options

## License

[MIT licensed](./LICENSE).
4 changes: 4 additions & 0 deletions packages/fhir-ts-codegen/dist/commands/default.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Command } from "clime";
export default class extends Command {
execute(inputPath: string, outputPath: string): void;
}
41 changes: 41 additions & 0 deletions packages/fhir-ts-codegen/dist/commands/default.js

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

1 change: 1 addition & 0 deletions packages/fhir-ts-codegen/dist/commands/default.js.map

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

1 change: 1 addition & 0 deletions packages/fhir-ts-codegen/dist/generateDefinition.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const generateDefinitions: (pattern: string, outputPath: string, version?: string) => string[];
135 changes: 135 additions & 0 deletions packages/fhir-ts-codegen/dist/generateDefinition.js

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

1 change: 1 addition & 0 deletions packages/fhir-ts-codegen/dist/generateDefinition.js.map

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

48 changes: 48 additions & 0 deletions packages/fhir-ts-codegen/dist/helpers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export declare const stringsToPascalCase: (strs: string[]) => string;
export declare const stringsToCamelCase: (strs: string[]) => string;
export declare const convertToPascalCase: (s: string) => string;
export declare const convertToCamelCase: (s: string) => string;
/**
* Formats ElementDefinition path to camel case
*/
export declare const pathToCamelCase: (path: string) => string;
/**
* Formats ElementDefinition path to pascal case
*/
export declare const pathToPascalCase: (path: string) => string;
export declare const loadFromFile: (pathString: string) => any;
/**
* Parses the parent element name from the ElementDefinition path
*/
export declare const parentName: ({ path }: {
path: any;
}) => string;
/**
* Parses the element name from the ElementDefinition path and a given type
*/
export declare const elementName: (elementDefinition: any, type: any) => any;
/**
* Whether an Element Definition is defining a BackboneElement
*/
export declare const isBackboneElement: ({ type }: any) => any;
/**
* Whether an Element Definition is defining a Choice Type
* https://www.hl7.org/fhir/formats.html#choice
*/
export declare const isChoiceType: ({ path }: {
path: any;
}) => boolean;
/**
* Whether an Element Definition is required
*/
export declare const isRequired: ({ min }: {
min: any;
}) => boolean;
/**
* Format a TS property type name from an Element Definition
*/
export declare const propertyTypeName: (elementDefinition: any) => any;
/**
* Removes all line breaks from string
*/
export declare const formatComment: (comment: string) => string;
Loading

0 comments on commit ba69f32

Please sign in to comment.