Skip to content

Commit

Permalink
build: init commit from PRE_GITHUB_MIGR tag. Update package.json & ya…
Browse files Browse the repository at this point in the history
…rn.lock to remove Gitlab refs
  • Loading branch information
aamir-dohadwala committed Aug 22, 2021
0 parents commit d2ee997
Show file tree
Hide file tree
Showing 75 changed files with 25,456 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/node_modules/
*.config.js
.eslintrc.js
dist
167 changes: 167 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"prettier",
"prettier/@typescript-eslint",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 11,
project: "./tsconfig.json",
sourceType: "module",
},
plugins: ["@typescript-eslint", "prefer-arrow"],
rules: {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/member-delimiter-style": [
"error",
{
multiline: {
delimiter: "semi",
requireLast: true,
},
singleline: {
delimiter: "semi",
requireLast: false,
},
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variable",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "function",
format: ["PascalCase", "camelCase"],
},
{
selector: "enumMember",
format: ["UPPER_CASE"],
},
{
selector: "method",
format: ["PascalCase", "camelCase"],
},
{
selector: "parameter",
format: ["camelCase", "PascalCase"],
leadingUnderscore: "allow",
},
{
selector: "property",
format: ["strictCamelCase", "camelCase", "PascalCase", "UPPER_CASE", "snake_case"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
],
"@typescript-eslint/prefer-optional-chain": "error",
quotes: "off", // disabling eslint and let ts-eslint handle rule
"@typescript-eslint/quotes": [
"error",
"double",
{ allowTemplateLiterals: true, avoidEscape: true },
],
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/unified-signatures": "error",
// eslint-plugin-imports
"import/order": [
"error",
{
groups: [["external", "builtin"], "internal", "parent", "sibling"],
"newlines-between": "always",
alphabetize: { order: "asc" },
},
],
//eslint rules
indent: ["error", 2],
quotes: ["error", "double"],
semi: ["error", "always"],
radix: "error",
curly: ["error", "multi-line"],
eqeqeq: ["error", "always"],
"arrow-parens": ["off", "as-needed"],
"dot-notation": "error",
"guard-for-in": "error",
"id-match": "error",
"max-classes-per-file": ["error", 1],
"newline-per-chained-call": "off",
"no-bitwise": "error",
"no-caller": "error",
"no-console": "warn",
"no-debugger": "warn",
"no-empty": "error",
"no-eval": "error",
"no-extra-semi": "off",
"no-fallthrough": "warn",
"no-irregular-whitespace": "off",
"no-new-wrappers": "error",
"no-shadow": [
"error",
{
hoist: "all",
},
],
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unused-expressions": ["error", { allowTernary: true }],
"no-var": "error",
"object-shorthand": "error",
"one-var": ["error", "never"],
"prefer-const": "error",
"require-await": "off",
"space-before-function-paren": "off",
"space-in-parens": ["off", "never"],
"spaced-comment": "error",
"valid-typeof": "off",
"linebreak-style": ["error", "unix"],
//eslint-plugin-prefer-arrow
"prefer-arrow/prefer-arrow-functions": [
"error",
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: false,
},
],
},
};
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
yarn-error.log
coverage
bundle_sizes.html
.eslintcache
demo/javascript-demo/server/node_modules
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/
dist
bundle_sizes.html
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
MIT License

Copyright (c) 2021 Healthy Web Inc.

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.
181 changes: 181 additions & 0 deletions README.developers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
## Description

Fullscript.js is a JavaScript library that allows you to embed [Fullscript](https://fullscript.com/) features into your web application. In its current form, Fullscript.js cannot be used without the [Fullscript API](https://us.fullscript.com/docs/api/reference). Each embeddable feature requires attributes which can only be retrieved from the API.

## Installation

Fullscript-js can be included in your application via a NPM module or script tag.

### UMD Build

To use the **UMD build**, include it as a script tag in your page:

```
<script src="https://public-assets.fullscript.com/fullscript.js/1.0.5/fullscript-js.umd.min.js"></script>
```

### NPM Package

To use the NPM build, first you will need to add it to your dependencies:

```
npm install --save @fullscript/fullscript-js
// or with yarn
yarn add @fullscript/fullscript-js
```

Finally you can import the package with the following

```
import { Fullscript } from "@fullscript/fullscript-js";
// or with CommonJS
var Fullscript = require("@fullscript/fullscript-js").Fullscript;
```

### Usage

Now that you have fullscript-js included in your app, we can start using it!

**Step 1**

Fullscript.js requires a unique mount point for every feature. You need to create a DOM element for a feature to be embedded in.

```
<div style="width: 100vw; height: 100vh;" id="treatment-plan-container"></div>
```

> The feature is scaled to 100% of the size of its container. To control the size of the iframe, you can change the styles of aforementioned DOM element.
**Step 2**

Initialize a fullscript-js client with a `publicKey` and `env`:

```
var client = Fullscript({
publicKey: "xxxxx",
env: "us|ca|us-snd|ca-snd",
});
```

> More details on the publicKey, env, patientId, and secretToken values can be found [here-TODO](#)
**Step 3**

Once you have a client, you can initialize **features**:

```
var treatmentPlanFeature = client.create("treatmentPlan", {
patient: {
id: "xxxxx"
},
secretToken: "xxxxx",
});
```

**Step 4**

You can also listen for "events" that occur on a feature:

```
function handleTreatmentPlanActivated(data) {
console.log("data", data);
// you can use this as an opportunity to unmount the feature
// you define the callback and whatever you want to do with the treatment plan created data
};
treatmentPlanFeature.on("treatmentPlan.activated", handleTreatmentPlanActivated);
// You can use the feature to subscribe to specific events by registering callbacks.
// In the example above, once the treatment plan is activated, data about the treatment plan will be passed to you via the callback
```

> To read more about data and what its format is, please view our [docs-TODO](#)
**Step 5 (optional)**

To stop listening to an event you can run the following:

```
treatmentPlanFeature.off("treatmentPlan.activated", handleTreatmentPlanActivated);
```

> This is completely optional as whenever you unmount a feature, it will un-register all event listeners associated with that feature. This off function is provided for convenience if you need to un-register while a feature is mounted.
**Step 6**

Now that everything it setup, you can mount the feature:

```
document.addEventListener("DOMContentLoaded", function() {
treatmentPlanFeature.mount("treatment-plan-container");
});
```

> When mounting a feature, you need to ensure that the mount point has been rendered to the DOM. In the example above, we use the DOMContentLoaded to ensure that the mount point has been rendered.
**Step 7 (optional)**

To unmount a feature when you are done with it:

```
treatmentPlanFeature.unmount();
```

### Demo

In the project directory, we have two demo apps - React demo and UMD demo that you can experiment with.

#### create-react-app demo

The `create-react-app` demo app will use the npm package version of the fullscript-js library. Compared to the CDN version, the npm package version will contain typing information for your IDE and requires a bundler for packaging.

To get things started, please run the following from the root of the project:

1. `yarn link`
2. `yarn install`
3. `yarn build`

Next run the following from the react-demo directory `cd demo/react-demo`:

1. `yarn link fullscript-js`
2. `yarn install`

Next you can run the React app:

- `yarn start` (from inside demo/react-demo)
- `yarn demo:npm` (from the root of the project)

#### UMD demo

The UMD version of the fullscript-js library is pre-packaged for consumption by browsers. This does not rely on a bundler such as webpack and can be included via a single script tag in any html file. The downside of this version is that you do no benefit from typing information.

To run the demo, you need simply run the following from the root of the project:

- `yarn demo:umd`

### Docs

For more detailed information, please refer to our [//TODO](#) where you can view the API references, endpoints, parameters, and example responses.

### Guides

For best practices and gotchas on how to use fullscript-js, please refer to our [//TODO](#).

### Versioning

// TODO

### Authors

Team Bifrost @ Fullscript including: Andrew Markle, Alfred Pararajasingam, Caileigh Simpson, Ryan O'Connor, Sean Graves, Yuhan Lee

### License

// TODO

### Who uses fullscript-js

//TODO: adding this later
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To access an information packet regarding Fullscript.js please reach out to [[email protected]](mailto:[email protected])
Loading

0 comments on commit d2ee997

Please sign in to comment.