dce-reactkit 3.2.0-beta.8 → 3.2.0-beta.9

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.
@@ -54,6 +54,6 @@ import Log from './types/Log';
54
54
  import LogType from './types/LogType';
55
55
  import LogSource from './types/LogSource';
56
56
  import LogAction from './types/LogAction';
57
- import LogBuiltInCategory from './types/LogBuiltInCategory';
57
+ import LogBuiltInCategory from './types/LogBuiltInMetadata';
58
58
  import PickableItem from './components/ItemPicker/types/PickableItem';
59
59
  export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInCategory, PickableItem, ParamType, };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Built-in categories for logs
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const LogBuiltInMetadata: {
6
+ Category: {
7
+ Uncategorized: string;
8
+ ServerRenderedErrorPage: string;
9
+ ServerEndpointError: string;
10
+ };
11
+ Target: {
12
+ NoSpecificTarget: string;
13
+ };
14
+ };
15
+ export default LogBuiltInMetadata;
@@ -18,7 +18,7 @@ declare type LogFunction = (opts: ({
18
18
  } & ({
19
19
  error: any;
20
20
  } | {
21
- target: string;
22
21
  action: LogAction;
22
+ target?: string;
23
23
  }))) => Promise<Log>;
24
24
  export default LogFunction;
package/dist/index.d.ts CHANGED
@@ -645,8 +645,8 @@ declare type LogFunction = (opts: ({
645
645
  } & ({
646
646
  error: any;
647
647
  } | {
648
- target: string;
649
648
  action: LogAction;
649
+ target?: string;
650
650
  }))) => Promise<Log>;
651
651
 
652
652
  /**
@@ -886,10 +886,15 @@ declare enum DayOfWeek {
886
886
  * Built-in categories for logs
887
887
  * @author Gabe Abrams
888
888
  */
889
- declare enum LogBuiltInCategory {
890
- Uncategorized = "n/a",
891
- ServerRenderedErrorPage = "_server-rendered-error-page",
892
- ServerEndpointError = "_server-endpoint-error"
893
- }
889
+ declare const LogBuiltInMetadata: {
890
+ Category: {
891
+ Uncategorized: string;
892
+ ServerRenderedErrorPage: string;
893
+ ServerEndpointError: string;
894
+ };
895
+ Target: {
896
+ NoSpecificTarget: string;
897
+ };
898
+ };
894
899
 
895
- export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInCategory, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
900
+ export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata as LogBuiltInCategory, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.0-beta.8",
3
+ "version": "3.2.0-beta.9",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,7 +23,8 @@ import LogSource from '../types/LogSource';
23
23
  import LogTypeSpecificInfo from '../types/Log/LogTypeSpecificInfo';
24
24
  import LogMainInfo from '../types/Log/LogMainInfo';
25
25
  import LogSourceSpecificInfo from '../types/Log/LogSourceSpecificInfo';
26
- import LogBuiltInCategory from '../types/LogBuiltInCategory';
26
+ import LogBuiltInMetadata from '../types/LogBuiltInMetadata';
27
+ import LogAction from '../types/LogAction';
27
28
 
28
29
  /**
29
30
  * Generate an express API route handler
@@ -512,7 +513,7 @@ const genRouteHandler = (
512
513
  ? opts.category
513
514
  : (
514
515
  ((opts.category as any) ?? {})._
515
- ?? LogBuiltInCategory.Uncategorized
516
+ ?? LogBuiltInMetadata.Category.Uncategorized
516
517
  )
517
518
  ),
518
519
  subcategory: (
@@ -520,7 +521,7 @@ const genRouteHandler = (
520
521
  ? opts.subcategory
521
522
  : (
522
523
  ((opts.subcategory as any) ?? {})._
523
- ?? LogBuiltInCategory.Uncategorized
524
+ ?? LogBuiltInMetadata.Category.Uncategorized
524
525
  )
525
526
  ),
526
527
  tags: opts.tags ?? [],
@@ -538,8 +539,14 @@ const genRouteHandler = (
538
539
  }
539
540
  : {
540
541
  type: LogType.Action,
541
- target: (opts as any).target ?? 'Unknown',
542
- action: (opts as any).action ?? 'Unknown'
542
+ target: (
543
+ (opts as any).target
544
+ ?? LogBuiltInMetadata.Target.NoSpecificTarget
545
+ ),
546
+ action: (
547
+ (opts as any).action
548
+ ?? LogAction.Unknown
549
+ ),
543
550
  }
544
551
  );
545
552
 
@@ -611,8 +618,8 @@ const genRouteHandler = (
611
618
  timestamp: Date.now(),
612
619
  tags: [],
613
620
  metadata: {},
614
- category: LogBuiltInCategory.Uncategorized,
615
- subcategory: LogBuiltInCategory.Uncategorized,
621
+ category: LogBuiltInMetadata.Category.Uncategorized,
622
+ subcategory: LogBuiltInMetadata.Category.Uncategorized,
616
623
  };
617
624
 
618
625
  const dummyTypeSpecificInfo: LogTypeSpecificInfo = {
@@ -692,7 +699,7 @@ const genRouteHandler = (
692
699
 
693
700
  // Log
694
701
  logServerEvent({
695
- category: LogBuiltInCategory.ServerRenderedErrorPage,
702
+ category: LogBuiltInMetadata.Category.ServerRenderedErrorPage,
696
703
  error: {
697
704
  message: `${opts.title}: ${opts.description}`,
698
705
  code: opts.code,
@@ -733,7 +740,7 @@ const genRouteHandler = (
733
740
 
734
741
  // Log server-side error
735
742
  logServerEvent({
736
- category: LogBuiltInCategory.ServerEndpointError,
743
+ category: LogBuiltInMetadata.Category.ServerEndpointError,
737
744
  error: err,
738
745
  });
739
746
 
@@ -1,6 +1,6 @@
1
1
  // Import shared types
2
2
  import LOG_ROUTE_PATH from '../constants/LOG_ROUTE_PATH';
3
- import LogBuiltInCategory from '../types/LogBuiltInCategory';
3
+ import LogBuiltInMetadata from '../types/LogBuiltInMetadata';
4
4
  import LogFunction from '../types/LogFunction';
5
5
 
6
6
  // Import shared functions
@@ -20,7 +20,7 @@ const logClientEvent: LogFunction = async (opts) => {
20
20
  ? opts.category
21
21
  : (
22
22
  ((opts.category as any) ?? {})._
23
- ?? LogBuiltInCategory.Uncategorized
23
+ ?? LogBuiltInMetadata.Category.Uncategorized
24
24
  )
25
25
  ),
26
26
  subcategory: (
@@ -28,7 +28,7 @@ const logClientEvent: LogFunction = async (opts) => {
28
28
  ? opts.subcategory
29
29
  : (
30
30
  ((opts.subcategory as any) ?? {})._
31
- ?? LogBuiltInCategory.Uncategorized
31
+ ?? LogBuiltInMetadata.Category.Uncategorized
32
32
  )
33
33
  ),
34
34
  tags: JSON.stringify(opts.tags ?? []),
@@ -49,8 +49,11 @@ const logClientEvent: LogFunction = async (opts) => {
49
49
  : undefined
50
50
  ),
51
51
  target: (
52
- (opts as any).target
53
- ? (opts as any).target
52
+ (opts as any).action
53
+ ? (
54
+ (opts as any).target
55
+ ?? LogBuiltInMetadata.Target.NoSpecificTarget
56
+ )
54
57
  : undefined
55
58
  ),
56
59
  action: (
package/src/index.ts CHANGED
@@ -63,7 +63,7 @@ import Log from './types/Log';
63
63
  import LogType from './types/LogType';
64
64
  import LogSource from './types/LogSource';
65
65
  import LogAction from './types/LogAction';
66
- import LogBuiltInCategory from './types/LogBuiltInCategory';
66
+ import LogBuiltInCategory from './types/LogBuiltInMetadata';
67
67
 
68
68
  // Component-specific-types
69
69
  import PickableItem from './components/ItemPicker/types/PickableItem';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Built-in categories for logs
3
+ * @author Gabe Abrams
4
+ */
5
+ const LogBuiltInMetadata = {
6
+ // Categories
7
+ Category: {
8
+ Uncategorized: 'n/a',
9
+ ServerRenderedErrorPage: '_server-rendered-error-page',
10
+ ServerEndpointError: '_server-endpoint-error',
11
+ },
12
+ // Targets
13
+ Target: {
14
+ NoSpecificTarget: 'n/a',
15
+ },
16
+ };
17
+
18
+ export default LogBuiltInMetadata;
@@ -28,11 +28,13 @@ type LogFunction = (
28
28
  }
29
29
  // Action
30
30
  | {
31
+ // The type of action performed
32
+ action: LogAction,
31
33
  // Target of the action (each app determines the list of targets)
32
34
  // These are usually buttons, panels, elements, etc.
33
- target: string,
34
- // The type of action performed on the target
35
- action: LogAction,
35
+ // If no target is included, this should indicate that this is an action
36
+ // being performed on the whole feature (open/close/etc)
37
+ target?: string,
36
38
  }
37
39
  )
38
40
  ),
@@ -1,10 +0,0 @@
1
- /**
2
- * Built-in categories for logs
3
- * @author Gabe Abrams
4
- */
5
- declare enum LogBuiltInCategory {
6
- Uncategorized = "n/a",
7
- ServerRenderedErrorPage = "_server-rendered-error-page",
8
- ServerEndpointError = "_server-endpoint-error"
9
- }
10
- export default LogBuiltInCategory;
@@ -1,10 +0,0 @@
1
- /**
2
- * Built-in categories for logs
3
- * @author Gabe Abrams
4
- */
5
- declare enum LogBuiltInCategory {
6
- Uncategorized = "n/a",
7
- ServerRenderedErrorPage = "_server-rendered-error-page",
8
- ServerEndpointError = "_server-endpoint-error"
9
- }
10
- export default LogBuiltInCategory;
@@ -1,11 +0,0 @@
1
- /**
2
- * Built-in categories for logs
3
- * @author Gabe Abrams
4
- */
5
- enum LogBuiltInCategory {
6
- Uncategorized = 'n/a',
7
- ServerRenderedErrorPage = '_server-rendered-error-page',
8
- ServerEndpointError = '_server-endpoint-error',
9
- };
10
-
11
- export default LogBuiltInCategory;