hevy-shared 1.0.612 → 1.0.614

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/built/index.d.ts CHANGED
@@ -16,7 +16,6 @@ export * from './normalizedWorkoutUtils';
16
16
  export * from './routineUtils';
17
17
  export * from './typeUtils';
18
18
  export * from './async';
19
- export * from './adminPermissions';
20
19
  export declare const supportedLanguages: readonly ["en", "es", "de", "fr", "it", "pt", "tr", "zh_CN", "zh_TW", "ru", "ja", "ko"];
21
20
  export type Language = Lookup<typeof supportedLanguages>;
22
21
  export declare const isLanguage: (x: string) => x is Language;
package/built/index.js CHANGED
@@ -33,7 +33,6 @@ __exportStar(require("./normalizedWorkoutUtils"), exports);
33
33
  __exportStar(require("./routineUtils"), exports);
34
34
  __exportStar(require("./typeUtils"), exports);
35
35
  __exportStar(require("./async"), exports);
36
- __exportStar(require("./adminPermissions"), exports);
37
36
  exports.supportedLanguages = [
38
37
  'en',
39
38
  'es',
@@ -8,3 +8,25 @@ export type Some<T> = {
8
8
  } | {
9
9
  hasValue: false;
10
10
  };
11
+ /**
12
+ * Please use this instead of using the 'as' keyword directly, so it's easier
13
+ * to screen for these ticking time bombs in the code from time to time. Or
14
+ * better yet, just implement validation for your types straight away.
15
+ *
16
+ * If you would think twice before using this, then by pure logic you should
17
+ * likewise also think twice - no, make it at least thrice - before making the
18
+ * decision to opt into undefined behaviour by letting the compile-time TS type
19
+ * diverge from the runtime JS value.
20
+ *
21
+ * This is your last chance to turn back.
22
+ *
23
+ * You have been warned.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const someData = await AsyncStorage.getItem(SOME_KEY);
28
+ * const parsedData = JSON.parse(someData);
29
+ * const data = dangerousUncheckedTypeCast<SomeDataType>(parsedData);
30
+ * ```
31
+ */
32
+ export declare const dangerousUncheckedTypeCast: <T = void, U extends T = T>(value: unknown) => U;
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
3
+ exports.dangerousUncheckedTypeCast = exports.exhaustiveTypeException = exports.exhaustiveTypeCheck = exports.isInArray = void 0;
4
4
  const isInArray = (value, array) => array.includes(value);
5
5
  exports.isInArray = isInArray;
6
6
  const exhaustiveTypeCheck = (_) => void _;
7
7
  exports.exhaustiveTypeCheck = exhaustiveTypeCheck;
8
8
  const exhaustiveTypeException = (type) => new Error(`Assertion failed: "unreachable" code reached with unknown type: ${typeof type === 'object' ? JSON.stringify(type) : String(type)}`);
9
9
  exports.exhaustiveTypeException = exhaustiveTypeException;
10
+ /**
11
+ * Please use this instead of using the 'as' keyword directly, so it's easier
12
+ * to screen for these ticking time bombs in the code from time to time. Or
13
+ * better yet, just implement validation for your types straight away.
14
+ *
15
+ * If you would think twice before using this, then by pure logic you should
16
+ * likewise also think twice - no, make it at least thrice - before making the
17
+ * decision to opt into undefined behaviour by letting the compile-time TS type
18
+ * diverge from the runtime JS value.
19
+ *
20
+ * This is your last chance to turn back.
21
+ *
22
+ * You have been warned.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const someData = await AsyncStorage.getItem(SOME_KEY);
27
+ * const parsedData = JSON.parse(someData);
28
+ * const data = dangerousUncheckedTypeCast<SomeDataType>(parsedData);
29
+ * ```
30
+ */
31
+ const dangerousUncheckedTypeCast = (value) => value;
32
+ exports.dangerousUncheckedTypeCast = dangerousUncheckedTypeCast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.612",
3
+ "version": "1.0.614",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",
@@ -1,4 +0,0 @@
1
- import { Lookup } from './typeUtils';
2
- export declare const AdminPermissions: readonly ["become_user", "manage_settings"];
3
- export type AdminPermission = Lookup<typeof AdminPermissions>;
4
- export declare const isAdminPermission: (permission?: any) => permission is AdminPermission;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAdminPermission = exports.AdminPermissions = void 0;
4
- exports.AdminPermissions = ['become_user', 'manage_settings'];
5
- const isAdminPermission = (permission) => {
6
- if (!permission || typeof permission !== 'string') {
7
- return false;
8
- }
9
- return exports.AdminPermissions.includes(permission);
10
- };
11
- exports.isAdminPermission = isAdminPermission;