@hedia/types 3.12.4-alpha.350 → 3.12.6-alpha.353

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,108 @@
1
- # **Hedia types**
1
+ # @hedia/types
2
2
 
3
- ### **Auto-publishing to npm as an alpha-version package**
3
+ Shared TypeScript enums, interfaces, and constants used across Hedia's software. Published to npm as [`@hedia/types`](https://www.npmjs.com/package/@hedia/types).
4
4
 
5
- In order to easily test our npm packages, auto-publishing of an alpha version to npm has been implemented.
6
- This will allow testers to easily install and test npm packages as they’ll be automatically published to npm at the moment of creating a Pull Request on GitHub.
5
+ This package contains **types only**. It has no runtime dependencies and ships as CommonJS with TypeScript declarations.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ npm install @hedia/types
11
+ ```
12
+
13
+ Pin the exact version in consuming projects, as this repo does with its own dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { BloodGlucoseUnit, DiabetesType, IUserSettings } from "@hedia/types";
19
+
20
+ const settings: IUserSettings = {
21
+ // ...
22
+ };
23
+
24
+ if (unit === BloodGlucoseUnit.MMOL_L) {
25
+ // ...
26
+ }
27
+ ```
28
+
29
+ Everything is exported from the package root via [`src/index.ts`](src/index.ts).
30
+
31
+ ## What's included
32
+
33
+ | Module | Contents |
34
+ | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
35
+ | [`activity`](src/activity/activity.ts) | Activity entries, intensity and reduction interval enums, activity settings |
36
+ | [`boluscalculator`](src/boluscalculator/boluscalculator.ts) | Bolus calculator constants, error enums, recommendation params and result |
37
+ | [`logbook`](src/logbook/logbook.ts) | Logbook entries, mood enum, client/backend sync objects |
38
+ | [`userdetails`](src/userdetails/userdetails.ts) | User details |
39
+ | [`usersettings`](src/usersettings/usersettings.ts) | User settings, notifications, BGL targets, insulin, diabetes type, and related enums |
40
+ | [`enums`](src/enums.ts) | Cross-cutting enums: glucose and ketone units, insulin units, languages, HTTP status codes and methods |
41
+
42
+ Types prefixed with `Legacy` describe older data shapes still present in stored data and should not be used for new code.
43
+
44
+ ## Development
45
+
46
+ Requires Node `>=22.14.0` (see `engines` in `package.json`).
47
+
48
+ ```sh
49
+ npm ci
50
+ npm run validate
51
+ ```
52
+
53
+ `validate` runs everything CI runs:
54
+
55
+ | Script | What it does |
56
+ | ----------------------------------- | --------------------------------------------------------------- |
57
+ | `npm run tsc` | Type-check without emitting |
58
+ | `npm run eslint` / `eslint:fix` | Lint with `@hedia/eslint-config` |
59
+ | `npm run prettier` / `prettier:fix` | Check or fix formatting with `@hedia/prettier-config` |
60
+ | `npm run pkg-json-lint` | Lint `package.json` (exact versions, alphabetical dependencies) |
61
+ | `npm audit --audit-level=critical` | Fail on critical vulnerabilities |
62
+
63
+ ### Conventions
64
+
65
+ - Prefer `interface` over `type` for object shapes (enforced by ESLint).
66
+ - Enum members must be literal values (enforced by ESLint).
67
+ - Dependencies are pinned to exact versions, no `^` or `~`, and kept in alphabetical order (enforced by npm-package-json-lint).
68
+ - Source lives in `src/`. The build output in `lib/` is generated and git-ignored.
69
+
70
+ ### Build
71
+
72
+ The build runs automatically on `npm pack` / `npm publish` via the `prepack` hook. To build manually:
73
+
74
+ ```sh
75
+ npx bob build
76
+ ```
77
+
78
+ [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob) emits `lib/commonjs` (JavaScript) and `lib/typescript` (declarations). Both `lib/` and `src/` are included in the published package so source maps resolve.
79
+
80
+ ## Releasing
81
+
82
+ Publishing is fully automated by [`.github/workflows/ci.yaml`](.github/workflows/ci.yaml). **Do not bump the version manually.**
83
+
84
+ ### Pull requests
85
+
86
+ 1. Branch from `master` and open a PR. The title must reference a Jira ticket, e.g. `HDAM-1234 Add ketone thresholds`. An optional `[x.y.z] - ` or `[Anytime] - ` prefix is allowed. Draft PRs skip this check.
87
+ 2. Add a `major` or `minor` label to control the version bump. With no label the bump is `patch`.
88
+ 3. On every push CI runs `validate`, then:
89
+ - commits the bumped version to the PR branch as `chore: bump version to x.y.z [skip ci]`
90
+ - publishes `x.y.z-alpha.<run>` to npm under the `alpha` dist-tag
91
+ - comments the install command on the PR
92
+
93
+ Pull the branch after CI runs so you pick up the version bump commit before pushing again.
94
+
95
+ ### Testing an alpha
96
+
97
+ ```sh
98
+ npm install @hedia/types@3.12.5-alpha.352 # exact version from the PR comment
99
+ npm install @hedia/types@alpha # latest alpha
100
+ ```
101
+
102
+ ### Release
103
+
104
+ Merging to `master` publishes the version in `package.json` as `latest`, creates a `vX.Y.Z` git tag, and creates a GitHub release. If that version is already on npm the publish is skipped.
105
+
106
+ ## License
107
+
108
+ UNLICENSED. This package is published publicly for distribution convenience only. All rights reserved by Hedia.
@@ -31,12 +31,12 @@ const CONSTANTS = exports.CONSTANTS = {
31
31
  ACTIVITY_DURATION_MAX: 120,
32
32
  /** The minimum insulin sensitivity setting in mmol/L per unit. (0.277) */
33
33
  INSULIN_SENSITIVITY_MIN: 0.277,
34
- /** The maximum insulin sensitivity setting in mmol/L per unit. (21.815, equal to 393 mg/dL per unit) */
35
- INSULIN_SENSITIVITY_MAX: 21.815,
34
+ /** The maximum insulin sensitivity setting in mmol/L per unit. (10.935) */
35
+ INSULIN_SENSITIVITY_MAX: 10.935,
36
36
  /** The minimum insulin-to-carbs ratio. (1.4 g/U) */
37
37
  INSULIN_TO_CARBS_RATIO_MIN: 1.4,
38
- /** The maximum insulin-to-carbs ratio. (100 g/U) */
39
- INSULIN_TO_CARBS_RATIO_MAX: 100,
38
+ /** The maximum insulin-to-carbs ratio. (50 g/U) */
39
+ INSULIN_TO_CARBS_RATIO_MAX: 50,
40
40
  /** The minimum valid glucose target in mmol/L. (4.385 mmol/L) */
41
41
  TARGET_GLUCOSE_MIN: 4.385,
42
42
  /** The maximum valid glucose target in mmol/L. (10 mmol/L) */
@@ -1 +1 @@
1
- {"version":3,"names":["CONSTANTS","exports","GLUCOSE_INPUT_MIN_MMOLL","GLUCOSE_INPUT_MAX_MMOLL","CARBOHYDRATES_INPUT_MIN","CARBOHYDRATES_INPUT_MAX","INSULIN_DOSE_MIN","INSULIN_DOSE_MAX","BOLUS_SECONDS_MIN","BOLUS_SECONDS_MAX","ACTIVITY_REDUCTION_MAX","ACTIVITY_REDUCTION_MIN","ACTIVITY_DURATION_MIN","ACTIVITY_DURATION_MAX","INSULIN_SENSITIVITY_MIN","INSULIN_SENSITIVITY_MAX","INSULIN_TO_CARBS_RATIO_MIN","INSULIN_TO_CARBS_RATIO_MAX","TARGET_GLUCOSE_MIN","TARGET_GLUCOSE_MAX","ACTIVITY_TARGET_GLUCOSE_MIN","ACTIVITY_TARGET_GLUCOSE_MAX","MGDL_PER_MMOLL_BGL","MMOLL_PER_MGDL_BGL","SEVERE_HYPERGLYCEMIA_MAX","SEVERE_HYPOGLYCEMIA_MIN","LEVEL_ONE_HYPOGLYCEMIA_MAX","LEVEL_ONE_HYPOGLYCEMIA_MIN","LEVEL_TWO_HYPOGLYCEMIA_MAX","LEVEL_TWO_HYPOGLYCEMIA_MIN","LOW_GLUCOSE_MESSAGE_ACTIVITY_MIN","LOW_GLUCOSE_MESSAGE_ACTIVITY_MAX","HIGH_GLUCOSE_MESSAGE_ACTIVITY_MIN","HIGH_GLUCOSE_MESSAGE_ACTIVITY_MAX","ActivityErrors","GlucoseErrors"],"sourceRoot":"../../../src","sources":["boluscalculator/boluscalculator.ts"],"mappings":";;;;;;AAGO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACxB;EACAE,uBAAuB,EAAE,GAAG;EAE5B;EACAC,uBAAuB,EAAE,QAAQ;EAEjC;EACAC,uBAAuB,EAAE,CAAC;EAE1B;EACAC,uBAAuB,EAAE,GAAG;EAE5B;EACAC,gBAAgB,EAAE,CAAC;EAEnB;EACAC,gBAAgB,EAAE,EAAE;EAEpB;EACAC,iBAAiB,EAAE,CAAC;EAEpB;EACAC,iBAAiB,EAAE,KAAK;EAExB;EACAC,sBAAsB,EAAE,CAAC;EA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CARBOHYDRATES_INPUT_MAX","INSULIN_DOSE_MIN","INSULIN_DOSE_MAX","BOLUS_SECONDS_MIN","BOLUS_SECONDS_MAX","ACTIVITY_REDUCTION_MAX","ACTIVITY_REDUCTION_MIN","ACTIVITY_DURATION_MIN","ACTIVITY_DURATION_MAX","INSULIN_SENSITIVITY_MIN","INSULIN_SENSITIVITY_MAX","INSULIN_TO_CARBS_RATIO_MIN","INSULIN_TO_CARBS_RATIO_MAX","TARGET_GLUCOSE_MIN","TARGET_GLUCOSE_MAX","ACTIVITY_TARGET_GLUCOSE_MIN","ACTIVITY_TARGET_GLUCOSE_MAX","MGDL_PER_MMOLL_BGL","MMOLL_PER_MGDL_BGL","SEVERE_HYPERGLYCEMIA_MAX","SEVERE_HYPOGLYCEMIA_MIN","LEVEL_ONE_HYPOGLYCEMIA_MAX","LEVEL_ONE_HYPOGLYCEMIA_MIN","LEVEL_TWO_HYPOGLYCEMIA_MAX","LEVEL_TWO_HYPOGLYCEMIA_MIN","LOW_GLUCOSE_MESSAGE_ACTIVITY_MIN","LOW_GLUCOSE_MESSAGE_ACTIVITY_MAX","HIGH_GLUCOSE_MESSAGE_ACTIVITY_MIN","HIGH_GLUCOSE_MESSAGE_ACTIVITY_MAX","ActivityErrors","GlucoseErrors"],"sourceRoot":"../../../src","sources":["boluscalculator/boluscalculator.ts"],"mappings":";;;;;;AAGO,MAAMA,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACxB;EACAE,uBAAuB,EAAE,GAAG;EAE5B;EACAC,uBAAuB,EAAE,QAAQ;EAEjC;EACAC,uBAAuB,EAAE,CAAC;EAE1B;EACAC,uBAAuB,EAAE,GAAG;EAE5B;EACAC,gBAAgB,EAAE,CAAC;EAEnB;EACAC,gBAAgB,EAAE,EAAE;EAEpB;EACAC,iBAAiB,EAAE,CAAC;EAEpB;EACAC,iBAAiB,EAAE,KAAK;EAExB;EACAC,sBAAsB,EAAE,CAAC;EAEzB;EACAC,sBAAsB,EAAE,CAAC;EAEzB;EACAC,qBAAqB,EAAE,CAAC;EAExB;EACAC,qBAAqB,EAAE,GAAG;EAE1B;EACAC,uBAAuB,EAAE,KAAK;EAE9B;EACAC,uBAAuB,EAAE,MAAM;EAE/B;EACAC,0BAA0B,EAAE,GAAG;EAE/B;EACAC,0BAA0B,EAAE,EAAE;EAE9B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,kBAAkB,EAAE,EAAE;EAEtB;EACAC,2BAA2B,EAAE,KAAK;EAElC;EACAC,2BAA2B,EAAE,IAAI;EAEjC;EACAC,kBAAkB,EAAE,OAAO;EAE3B;EACAC,kBAAkB,EAAE,oBAAoB;EAExC;EACAC,wBAAwB,EAAE,QAAQ;EAElC;EACAC,uBAAuB,EAAE,EAAE;EAE3B;EACAC,0BAA0B,EAAE,KAAK;EAEjC;EACAC,0BAA0B,EAAE,KAAK;EAEjC;EACAC,0BAA0B,EAAE,KAAK;EAEjC;EACAC,0BAA0B,EAAE,GAAG;EAE/B;EACAC,gCAAgC,EAAE,GAAG;EAErC;EACAC,gCAAgC,EAAE,CAAC;EAEnC;EACAC,iCAAiC,EAAE,MAAM;EAEzC;EACAC,iCAAiC,EAAE;AACpC,CAAC;;AAED;AAAA,IACYC,cAAc,GAAAjC,OAAA,CAAAiC,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAO1B;AAAA,IACYC,aAAa,GAAAlC,OAAA,CAAAkC,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAkDzB;AAUA;AAYA;AAkBA;AACA;AACA;AACA","ignoreList":[]}
@@ -27,11 +27,11 @@ export declare const CONSTANTS: {
27
27
  ACTIVITY_DURATION_MAX: number;
28
28
  /** The minimum insulin sensitivity setting in mmol/L per unit. (0.277) */
29
29
  INSULIN_SENSITIVITY_MIN: number;
30
- /** The maximum insulin sensitivity setting in mmol/L per unit. (21.815, equal to 393 mg/dL per unit) */
30
+ /** The maximum insulin sensitivity setting in mmol/L per unit. (10.935) */
31
31
  INSULIN_SENSITIVITY_MAX: number;
32
32
  /** The minimum insulin-to-carbs ratio. (1.4 g/U) */
33
33
  INSULIN_TO_CARBS_RATIO_MIN: number;
34
- /** The maximum insulin-to-carbs ratio. (100 g/U) */
34
+ /** The maximum insulin-to-carbs ratio. (50 g/U) */
35
35
  INSULIN_TO_CARBS_RATIO_MAX: number;
36
36
  /** The minimum valid glucose target in mmol/L. (4.385 mmol/L) */
37
37
  TARGET_GLUCOSE_MIN: number;
@@ -1 +1 @@
1
- {"version":3,"file":"boluscalculator.d.ts","sourceRoot":"","sources":["../../../src/boluscalculator/boluscalculator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,eAAO,MAAM,SAAS;IACrB,oFAAoF;;IAGpF,yFAAyF;;IAGzF,sEAAsE;;IAGtE,wEAAwE;;IAGxE,mDAAmD;;IAGnD,oDAAoD;;IAGpD,qDAAqD;;IAGrD,oEAAoE;;IAGpE,gEAAgE;;IAGhE,gEAAgE;;IAGhE,8DAA8D;;IAG9D,gEAAgE;;IAGhE,0EAA0E;;IAG1E,wGAAwG;;IAGxG,oDAAoD;;IAGpD,oDAAoD;;IAGpD,iEAAiE;;IAGjE,8DAA8D;;IAG9D,0EAA0E;;IAG1E,yEAAyE;;IAGzE,yGAAyG;;IAGzG,sHAAsH;;IAGtH,kHAAkH;;IAGlH,gHAAgH;;IAGhH,iHAAiH;;IAGjH,iHAAiH;;IAGjH,qHAAqH;;IAGrH,mHAAmH;;IAGnH,uIAAuI;;IAGvI,oIAAoI;;IAGpI,0IAA0I;;IAG1I,wIAAwI;;CAExI,CAAC;AAEF,iEAAiE;A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ACvI,SAAS,EAAE,MAAM,CAAC;IAClB,qGAAqG;IACrG,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iGAAiG;IACjG,aAAa,EAAE,MAAM,CAAC;IACtB,iGAAiG;IACjG,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,8FAA8F;IAC9F,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,2GAA2G;IAC3G,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gEAAgE;IAChE,kBAAkB,EAAE,IAAI,CAAC;CACzB"}
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "@hedia/types",
3
- "version": "3.12.4-alpha.350",
3
+ "version": "3.12.6-alpha.353",
4
4
  "description": "Enums, interfaces, and other common types for use in Hedia's software.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "types": "lib/typescript/index.d.ts",
7
7
  "engines": {
8
8
  "node": ">=22.14.0"
9
9
  },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+ssh://git@github.com:hedia-team/hedia-types.git"
13
- },
10
+ "repository": "github:hedia-team/hedia-types",
14
11
  "files": [
15
- "lib"
12
+ "lib",
13
+ "src"
16
14
  ],
15
+ "sideEffects": false,
17
16
  "scripts": {
18
17
  "tsc": "tsc --noEmit",
19
18
  "eslint": "eslint .",
@@ -24,10 +23,8 @@
24
23
  "validate": "npm run tsc && npm run eslint && npm run prettier && npm run pkg-json-lint && npm audit --audit-level=critical",
25
24
  "prepack": "bob build"
26
25
  },
27
- "keywords": [],
28
26
  "author": "Hedia",
29
- "license": "ISC",
30
- "homepage": "https://github.com/hedia-team/hedia-types#readme",
27
+ "license": "UNLICENSED",
31
28
  "devDependencies": {
32
29
  "@hedia/eslint-config": "6.0.7",
33
30
  "@hedia/prettier-config": "1.2.9",
@@ -0,0 +1,83 @@
1
+ export interface IActivityEntry {
2
+ uuid: string;
3
+ type: ActivityEnum | null;
4
+ activityIntensity: ActivityIntensity | null;
5
+ durationSeconds: number;
6
+ startTimestamp: string | null;
7
+ deleted: boolean;
8
+ uuidOld?: IActivityEntry["uuid"];
9
+ overwrittenByUUID?: IActivityEntry["uuid"];
10
+ }
11
+
12
+ /** Enum that represents a set of insulin reduction fraction settings that can vary by the duration of the activity */
13
+ export enum ActivityReductionIntervals {
14
+ fromZero = "fromZero",
15
+ fromThirty = "fromThirty",
16
+ fromFortysix = "fromFortysix",
17
+ fromSixtyone = "fromSixtyone",
18
+ }
19
+
20
+ /** Enum used to indicate the category or intensity of a physical activity. */
21
+ export enum ActivityIntensity {
22
+ light = "light",
23
+ moderate = "moderate",
24
+ hard = "hard",
25
+ }
26
+
27
+ /** Enum used to indicate the type of physical activity performed by the user. */
28
+ export enum ActivityEnum {
29
+ Run = "Run",
30
+ Walk = "Walk",
31
+ Cycling = "Cycling",
32
+ Swim = "Swim",
33
+ Other = "Other",
34
+ Sport = "Sport",
35
+ Workout = "Workout",
36
+ }
37
+
38
+ /**
39
+ * Represents whether the reduction fraction is a number or it is null.
40
+ * For the settings of hard physical activities over 45 minutes the value is null.
41
+ * For physical activities over 60 minutes the value is also null
42
+ * A null value represents that it is not supported by HDA but users can still set it.
43
+ */
44
+ type ReductionValue<
45
+ Intensity extends ActivityIntensity,
46
+ Interval extends ActivityReductionIntervals,
47
+ > = Interval extends ActivityReductionIntervals.fromSixtyone
48
+ ? number | null
49
+ : Intensity extends ActivityIntensity.hard
50
+ ? Interval extends ActivityReductionIntervals.fromFortysix
51
+ ? number | null
52
+ : number
53
+ : number;
54
+
55
+ type ActivityReductionMatrix = {
56
+ [I in ActivityIntensity]: {
57
+ [J in ActivityReductionIntervals]: ReductionValue<I, J>;
58
+ };
59
+ };
60
+
61
+ type PostReductionValue<Interval extends ActivityReductionIntervals> =
62
+ Interval extends ActivityReductionIntervals.fromSixtyone ? number | null : number;
63
+
64
+ interface ActivityPostReduction {
65
+ post: { [Interval in ActivityReductionIntervals]: PostReductionValue<Interval> };
66
+ }
67
+
68
+ /** Type that represents the user’s settings related to physical activity. */
69
+ export interface ActivitySettings extends ActivityPostReduction, ActivityReductionMatrix {
70
+ target: number;
71
+ updatedAt?: string; // ISO string
72
+ }
73
+
74
+ /**
75
+ * Legacy activity settings type that allows fromSixtyone to be undefined for types backward compatibility
76
+ * TODO: Can be removed when 3.5.0 is the minimum supported version.
77
+ */
78
+ export type LegacyActivitySettings = Omit<ActivitySettings, "hard" | "moderate" | "light" | "post"> & {
79
+ hard: Omit<ActivitySettings["hard"], "fromSixtyone"> & { fromSixtyone?: number | null };
80
+ moderate: Omit<ActivitySettings["moderate"], "fromSixtyone"> & { fromSixtyone?: number | null };
81
+ light: Omit<ActivitySettings["light"], "fromSixtyone"> & { fromSixtyone?: number | null };
82
+ post: Omit<ActivitySettings["post"], "fromSixtyone"> & { fromSixtyone?: number | null };
83
+ };
@@ -0,0 +1,226 @@
1
+ import type { ActivityIntensity, ActivitySettings } from "../activity/activity";
2
+ import type { BloodGlucoseUnit } from "../enums";
3
+
4
+ export const CONSTANTS = {
5
+ /** The minimum blood glucose level that may be entered by the user. (1.1 mmol/L) */
6
+ GLUCOSE_INPUT_MIN_MMOLL: 1.1,
7
+
8
+ /** The maximum blood glucose level that may be entered by the user. (33.30449 mmol/L) */
9
+ GLUCOSE_INPUT_MAX_MMOLL: 33.30449,
10
+
11
+ /** The lower limit for the amount of carbohydrates in grams. (0 g) */
12
+ CARBOHYDRATES_INPUT_MIN: 0,
13
+
14
+ /** The upper limit for the amount of carbohydrates in grams. (300 g) */
15
+ CARBOHYDRATES_INPUT_MAX: 300,
16
+
17
+ /** The minimum insulin dose in units. (0 units) */
18
+ INSULIN_DOSE_MIN: 0,
19
+
20
+ /** The maximum insulin dose in units. (60 units) */
21
+ INSULIN_DOSE_MAX: 60,
22
+
23
+ /** The minimum age of boluses in seconds. (0 sec) */
24
+ BOLUS_SECONDS_MIN: 0,
25
+
26
+ /** The maximum age of boluses in seconds. (14400 sec or 4 hours) */
27
+ BOLUS_SECONDS_MAX: 14400,
28
+
29
+ /** The maximum reduction factor for a physical activity. (1) */
30
+ ACTIVITY_REDUCTION_MAX: 1,
31
+
32
+ /** The minimum reduction factor for a physical activity. (0) */
33
+ ACTIVITY_REDUCTION_MIN: 0,
34
+
35
+ /** The minimum duration of an activity in minutes. (1 min) */
36
+ ACTIVITY_DURATION_MIN: 1,
37
+
38
+ /** The maximum duration of an activity in minutes. (120 min) */
39
+ ACTIVITY_DURATION_MAX: 120,
40
+
41
+ /** The minimum insulin sensitivity setting in mmol/L per unit. (0.277) */
42
+ INSULIN_SENSITIVITY_MIN: 0.277,
43
+
44
+ /** The maximum insulin sensitivity setting in mmol/L per unit. (10.935) */
45
+ INSULIN_SENSITIVITY_MAX: 10.935,
46
+
47
+ /** The minimum insulin-to-carbs ratio. (1.4 g/U) */
48
+ INSULIN_TO_CARBS_RATIO_MIN: 1.4,
49
+
50
+ /** The maximum insulin-to-carbs ratio. (50 g/U) */
51
+ INSULIN_TO_CARBS_RATIO_MAX: 50,
52
+
53
+ /** The minimum valid glucose target in mmol/L. (4.385 mmol/L) */
54
+ TARGET_GLUCOSE_MIN: 4.385,
55
+
56
+ /** The maximum valid glucose target in mmol/L. (10 mmol/L) */
57
+ TARGET_GLUCOSE_MAX: 10,
58
+
59
+ /** The minimum valid activity glucose target in mmol/L. (4.995 mmol/L) */
60
+ ACTIVITY_TARGET_GLUCOSE_MIN: 4.995,
61
+
62
+ /** The maximum valid activity glucose target in mmol/L. (13.9 mmol/L) */
63
+ ACTIVITY_TARGET_GLUCOSE_MAX: 13.9,
64
+
65
+ /** The conversion factor to multiply a blood glucose value with to go from mmol/L to mg/dL. (18.0156) */
66
+ MGDL_PER_MMOLL_BGL: 18.0156,
67
+
68
+ /** The conversion factor to multiply a blood glucose value with to go from mg/dL to mmol/L. (0.055507449099669176) */
69
+ MMOLL_PER_MGDL_BGL: 0.055507449099669176,
70
+
71
+ /** The maximum glucose value for providing the severe hyperglycemia attention message in mmol/L. (33.3 mmol/L) */
72
+ SEVERE_HYPERGLYCEMIA_MAX: 33.30449,
73
+
74
+ /** The minimum glucose value for providing the severe hyperglycemia attention message in mmol/L. (20 mmol/L) */
75
+ SEVERE_HYPOGLYCEMIA_MIN: 20,
76
+
77
+ /** The maximum glucose value for providing the mild hyperglycemia attention message in mmol/L. (3.831 mmol/L) */
78
+ LEVEL_ONE_HYPOGLYCEMIA_MAX: 3.831,
79
+
80
+ /** The minimum glucose value for providing the mild hyperglycemia attention message in mmol/L. (2.942 mmol/L) */
81
+ LEVEL_ONE_HYPOGLYCEMIA_MIN: 2.997,
82
+
83
+ /** The maximum glucose value for providing the moderate hyperglycemia attention message in mmol/L. (2.942 mmol/L) */
84
+ LEVEL_TWO_HYPOGLYCEMIA_MAX: 2.942,
85
+
86
+ /** The minimum glucose value for providing the moderate hyperglycemia attention message in mmol/L. (1.1 mmol/L) */
87
+ LEVEL_TWO_HYPOGLYCEMIA_MIN: 1.1,
88
+
89
+ /** The minimum glucose value in mmol/L for providing the low glucose message when having an active physical activity. (1.1 mmol/L) */
90
+ LOW_GLUCOSE_MESSAGE_ACTIVITY_MIN: 1.1,
91
+
92
+ /** The maximum glucose value in mmol/L for providing the low glucose message when having an active physical activity. (5 mmol/L) */
93
+ LOW_GLUCOSE_MESSAGE_ACTIVITY_MAX: 5,
94
+
95
+ /** The minimum glucose value in mmol/L for providing the high glucose message when having an active physical activity. (13.932 mmol/L) */
96
+ HIGH_GLUCOSE_MESSAGE_ACTIVITY_MIN: 13.932,
97
+
98
+ /** The maximum glucose value in mmol/L for providing the high glucose message when having an active physical activity. (33.3 mmol/L) */
99
+ HIGH_GLUCOSE_MESSAGE_ACTIVITY_MAX: 33.30449,
100
+ };
101
+
102
+ /** Enum for differentiating between Activity types of errors. */
103
+ export enum ActivityErrors {
104
+ OutOfRangeDuration = "Duration Out of range",
105
+ InvalidInterval = "Invalid activity settings interval",
106
+ InvalidReduction = "Invalid activity Reduction",
107
+ MissingIntensity = "Missing activity intensity",
108
+ }
109
+
110
+ /** Enum for differentiating between Glucose types of errors. */
111
+ export enum GlucoseErrors {
112
+ MissingGlucoseReading = "Missing glucose reading",
113
+ InvalidGlucoseUnit = "Invalid glucose unit",
114
+ InvalidGlucoseValue = "Invalid glucose value",
115
+ OutOfRangeCurrentBGL = "Current BGL out of range",
116
+ }
117
+
118
+ interface BaseGlucoseReading {
119
+ id: string;
120
+ value: number;
121
+ unit: BloodGlucoseUnit;
122
+ timestamp: number;
123
+ }
124
+
125
+ type DeviceGlucoseReading = BaseGlucoseReading & {
126
+ source: "device";
127
+ deviceName: string;
128
+ };
129
+
130
+ type ExternalGlucoseReading = BaseGlucoseReading & {
131
+ source: "external";
132
+ sampleId: string;
133
+ sourceId: string;
134
+ sourceName: string;
135
+ deviceName: string;
136
+ };
137
+
138
+ type ForecastGlucoseReading = BaseGlucoseReading & {
139
+ source: "forecast";
140
+ sampleId: string;
141
+ sourceId: string;
142
+ sourceName: string;
143
+ };
144
+
145
+ type CgmGlucoseReading = BaseGlucoseReading & {
146
+ source: "cgm";
147
+ sourceName: string;
148
+ };
149
+
150
+ type ManualGlucoseReading = BaseGlucoseReading & {
151
+ source: "manual";
152
+ };
153
+
154
+ export type GlucoseReading =
155
+ | DeviceGlucoseReading
156
+ | ExternalGlucoseReading
157
+ | ForecastGlucoseReading
158
+ | CgmGlucoseReading
159
+ | ManualGlucoseReading;
160
+
161
+ /** Represents a single bolus of fast-acting insulin that has been administered within the past 4 hours. */
162
+ export interface IRecentBolus {
163
+ /** The number of seconds that has passed since the bolus in question was administered. */
164
+ secondsPassed: number;
165
+ /** The amount of insulin that was administered with the bolus in question. */
166
+ insulinDose: number;
167
+ /** The unique identifier (UUID) of the bolus event. */
168
+ id: string;
169
+ }
170
+
171
+ /** Details about a physical activity. */
172
+ export interface IActivityParams {
173
+ /** The duration of the physical activity in minutes. */
174
+ activityDuration: number;
175
+ /** The intensity of the activity */
176
+ activityIntensity: ActivityIntensity | null;
177
+ /** The user’s current settings for physical activity */
178
+ activitySettings: ActivitySettings;
179
+ /** Start date and time for the activity */
180
+ activityDate: Date;
181
+ }
182
+
183
+ /** IRecommendationParams contains data that is used to calculate a recommendation. */
184
+ export interface IRecommendationParams {
185
+ /** The user’s current blood glucose level in mmol/L */
186
+ glucoseReading: GlucoseReading;
187
+ /** The blood glucose level in mmol/L that the user should ideally have at this time of day according to their settings/preferences. */
188
+ targetBGL: number;
189
+ /** The user’s current insulin sensitivity in (mmol/L)/IU according to their settings/preferences. */
190
+ insulinSensitivity: number;
191
+ /** The amount of carbohydrates in grams that the user has entered that they are going to eat. */
192
+ carbohydrates: number;
193
+ /** The user’s current insulin-to-carbs ratio in g/IU according to their settings/preferences. */
194
+ carbohydrateRatio: number;
195
+ /** A possibly empty array of IRecentBolus objects. */
196
+ recentBoluses: IRecentBolus[];
197
+ /** Information about the activity that the user is doing including their activity settings */
198
+ activity: IActivityParams | null;
199
+ }
200
+
201
+ /**
202
+ * The result of a recommendation calculation is returned by the calculateRecommendation() function as an object that implements this interface.
203
+ * Note that only one of bolus and carbRecommendation may be positive. If one is non-zero then the other must be zero.
204
+ */
205
+ export interface IRecommendationResult {
206
+ /** The recommended amount of insulin measured in units. */
207
+ bolus: number;
208
+ /**
209
+ * Indicates whether or not the insulin recommendation (given in the bolus property) was capped because the underlying recommendation exceeded the safety limit.
210
+ * If it is true then we know that the recommendation would have been higher and can show and appropriate message to the user.
211
+ */
212
+ wasLimited: boolean;
213
+ /** The number of carbs that the user is recommended to eat */
214
+ carbRecommendation: number;
215
+ /**
216
+ * Indicates how much the insulin recommendation was reduced due to physical activity.
217
+ * A value of 0.75 would indicate that the recommended insulin was reduced by 25%.
218
+ */
219
+ activityReduction: number | null;
220
+ /** The estimated amount of active insulin (IOB) in IU. */
221
+ activeInsulin: number;
222
+ /** The unique identifiers (UUIDs) of the recent boluses that were used to calculate the active insulin. */
223
+ recentBolusesIds: string[];
224
+ /** The date and time when the recommendation was calculated. */
225
+ recommendationDate: Date;
226
+ }