dce-reactkit 3.2.0-beta.9 → 3.2.0

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/LogBuiltInMetadata';
57
+ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
58
58
  import PickableItem from './components/ItemPicker/types/PickableItem';
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, };
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, LogBuiltInMetadata, PickableItem, ParamType, };
@@ -27,8 +27,8 @@ declare type LogMainInfo = {
27
27
  hour: number;
28
28
  minute: number;
29
29
  timestamp: number;
30
- category: string;
31
- subcategory: string;
30
+ context: string;
31
+ subcontext: string;
32
32
  tags: string[];
33
33
  metadata?: {
34
34
  [k: string]: any;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Built-in categories for logs
2
+ * Built-in metadata for logs
3
3
  * @author Gabe Abrams
4
4
  */
5
5
  declare const LogBuiltInMetadata: {
6
- Category: {
6
+ Context: {
7
7
  Uncategorized: string;
8
8
  ServerRenderedErrorPage: string;
9
9
  ServerEndpointError: string;
@@ -5,12 +5,10 @@ import LogAction from './LogAction';
5
5
  * @author Gabe Abrams
6
6
  */
7
7
  declare type LogFunction = (opts: ({
8
- category: string | {
9
- _: string;
10
- };
11
- subcategory?: string | {
8
+ context: string | {
12
9
  _: string;
13
10
  };
11
+ subcontext?: string;
14
12
  tags?: string[];
15
13
  metadata?: {
16
14
  [k: string]: any;
package/dist/index.d.ts CHANGED
@@ -544,8 +544,8 @@ declare type LogMainInfo = {
544
544
  hour: number;
545
545
  minute: number;
546
546
  timestamp: number;
547
- category: string;
548
- subcategory: string;
547
+ context: string;
548
+ subcontext: string;
549
549
  tags: string[];
550
550
  metadata?: {
551
551
  [k: string]: any;
@@ -632,12 +632,10 @@ declare type Log = (LogMainInfo & LogSourceSpecificInfo & LogTypeSpecificInfo);
632
632
  * @author Gabe Abrams
633
633
  */
634
634
  declare type LogFunction = (opts: ({
635
- category: string | {
636
- _: string;
637
- };
638
- subcategory?: string | {
635
+ context: string | {
639
636
  _: string;
640
637
  };
638
+ subcontext?: string;
641
639
  tags?: string[];
642
640
  metadata?: {
643
641
  [k: string]: any;
@@ -883,11 +881,11 @@ declare enum DayOfWeek {
883
881
  }
884
882
 
885
883
  /**
886
- * Built-in categories for logs
884
+ * Built-in metadata for logs
887
885
  * @author Gabe Abrams
888
886
  */
889
887
  declare const LogBuiltInMetadata: {
890
- Category: {
888
+ Context: {
891
889
  Uncategorized: string;
892
890
  ServerRenderedErrorPage: string;
893
891
  ServerEndpointError: string;
@@ -897,4 +895,4 @@ declare const LogBuiltInMetadata: {
897
895
  };
898
896
  };
899
897
 
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 };
898
+ export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, 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.9",
3
+ "version": "3.2.0",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -508,21 +508,17 @@ const genRouteHandler = (
508
508
  hour,
509
509
  minute,
510
510
  timestamp,
511
- category: (
512
- typeof opts.category === 'string'
513
- ? opts.category
511
+ context: (
512
+ typeof opts.context === 'string'
513
+ ? opts.context
514
514
  : (
515
- ((opts.category as any) ?? {})._
516
- ?? LogBuiltInMetadata.Category.Uncategorized
515
+ ((opts.context as any) ?? {})._
516
+ ?? LogBuiltInMetadata.Context.Uncategorized
517
517
  )
518
518
  ),
519
- subcategory: (
520
- typeof opts.category === 'string'
521
- ? opts.subcategory
522
- : (
523
- ((opts.subcategory as any) ?? {})._
524
- ?? LogBuiltInMetadata.Category.Uncategorized
525
- )
519
+ subcontext: (
520
+ opts.subcontext
521
+ ?? LogBuiltInMetadata.Context.Uncategorized
526
522
  ),
527
523
  tags: opts.tags ?? [],
528
524
  metadata: opts.metadata ?? {},
@@ -618,8 +614,8 @@ const genRouteHandler = (
618
614
  timestamp: Date.now(),
619
615
  tags: [],
620
616
  metadata: {},
621
- category: LogBuiltInMetadata.Category.Uncategorized,
622
- subcategory: LogBuiltInMetadata.Category.Uncategorized,
617
+ context: LogBuiltInMetadata.Context.Uncategorized,
618
+ subcontext: LogBuiltInMetadata.Context.Uncategorized,
623
619
  };
624
620
 
625
621
  const dummyTypeSpecificInfo: LogTypeSpecificInfo = {
@@ -699,7 +695,7 @@ const genRouteHandler = (
699
695
 
700
696
  // Log
701
697
  logServerEvent({
702
- category: LogBuiltInMetadata.Category.ServerRenderedErrorPage,
698
+ context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
703
699
  error: {
704
700
  message: `${opts.title}: ${opts.description}`,
705
701
  code: opts.code,
@@ -740,7 +736,7 @@ const genRouteHandler = (
740
736
 
741
737
  // Log server-side error
742
738
  logServerEvent({
743
- category: LogBuiltInMetadata.Category.ServerEndpointError,
739
+ context: LogBuiltInMetadata.Context.ServerEndpointError,
744
740
  error: err,
745
741
  });
746
742
 
@@ -15,21 +15,17 @@ const logClientEvent: LogFunction = async (opts) => {
15
15
  path: LOG_ROUTE_PATH,
16
16
  method: 'POST',
17
17
  params: {
18
- category: (
19
- typeof opts.category === 'string'
20
- ? opts.category
18
+ context: (
19
+ typeof opts.context === 'string'
20
+ ? opts.context
21
21
  : (
22
- ((opts.category as any) ?? {})._
23
- ?? LogBuiltInMetadata.Category.Uncategorized
22
+ ((opts.context as any) ?? {})._
23
+ ?? LogBuiltInMetadata.Context.Uncategorized
24
24
  )
25
25
  ),
26
- subcategory: (
27
- typeof opts.category === 'string'
28
- ? opts.subcategory
29
- : (
30
- ((opts.subcategory as any) ?? {})._
31
- ?? LogBuiltInMetadata.Category.Uncategorized
32
- )
26
+ subcontext: (
27
+ opts.subcontext
28
+ ?? LogBuiltInMetadata.Context.Uncategorized
33
29
  ),
34
30
  tags: JSON.stringify(opts.tags ?? []),
35
31
  metadata: JSON.stringify(opts.metadata ?? {}),
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/LogBuiltInMetadata';
66
+ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
67
67
 
68
68
  // Component-specific-types
69
69
  import PickableItem from './components/ItemPicker/types/PickableItem';
@@ -136,7 +136,7 @@ export {
136
136
  LogType,
137
137
  LogSource,
138
138
  LogAction,
139
- LogBuiltInCategory,
139
+ LogBuiltInMetadata,
140
140
  // Component-specific-types
141
141
  PickableItem,
142
142
  // Server types
@@ -11,8 +11,8 @@ const initLogCollection = (Collection: any) => {
11
11
  uniqueIndexKey: 'id',
12
12
  indexKeys: [
13
13
  'courseId',
14
- 'category',
15
- 'subcategory',
14
+ 'context',
15
+ 'subcontext',
16
16
  'tags',
17
17
  ],
18
18
  },
@@ -79,10 +79,10 @@ const initServer = (
79
79
  /**
80
80
  * Log an event
81
81
  * @author Gabe Abrams
82
- * @param {string} category Category of the event (each app determines how to
83
- * categorize its events)
84
- * @param {string} subcategory Subcategory of the event (each app determines
85
- * how to categorize its events)
82
+ * @param {string} context Context of the event (each app determines how to
83
+ * organize its contexts)
84
+ * @param {string} subcontext Subcontext of the event (each app determines
85
+ * how to organize its subcontexts)
86
86
  * @param {string} tags stringified list of tags that apply to this action
87
87
  * (each app determines tag usage)
88
88
  * @param {string} metadata stringified object containing optional custom metadata
@@ -98,8 +98,8 @@ const initServer = (
98
98
  LOG_ROUTE_PATH,
99
99
  genRouteHandler({
100
100
  paramTypes: {
101
- category: ParamType.String,
102
- subcategory: ParamType.String,
101
+ context: ParamType.String,
102
+ subcontext: ParamType.String,
103
103
  tags: ParamType.JSON,
104
104
  metadata: ParamType.JSON,
105
105
  errorMessage: ParamType.StringOptional,
@@ -113,8 +113,8 @@ const initServer = (
113
113
  (params.errorMessage || params.errorCode || params.errorStack)
114
114
  // Error
115
115
  ? {
116
- category: params.category,
117
- subcategory: params.subcategory,
116
+ context: params.context,
117
+ subcontext: params.subcontext,
118
118
  tags: params.tags,
119
119
  metadata: params.metadata,
120
120
  error: {
@@ -125,8 +125,8 @@ const initServer = (
125
125
  }
126
126
  // Action
127
127
  : {
128
- category: params.category,
129
- subcategory: params.subcategory,
128
+ context: params.context,
129
+ subcontext: params.subcontext,
130
130
  tags: params.tags,
131
131
  metadata: params.metadata,
132
132
  target: params.target,
@@ -49,10 +49,10 @@ type LogMainInfo = {
49
49
  minute: number,
50
50
  // Timestamp of event (ms since epoch)
51
51
  timestamp: number,
52
- // Category of the event (each app determines how to categorize its events)
53
- category: string,
54
- // Subcategory of the event (each app determines how to categorize its events)
55
- subcategory: string,
52
+ // Context of the event (each app determines how to organize contexts)
53
+ context: string,
54
+ // Subcontext of the event (each app determines how to organize subcontexts)
55
+ subcontext: string,
56
56
  // List of tags that apply to this action (each app determines tag usage)
57
57
  tags: string[],
58
58
  // Additional optional custom metadata
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Built-in categories for logs
2
+ * Built-in metadata for logs
3
3
  * @author Gabe Abrams
4
4
  */
5
5
  const LogBuiltInMetadata = {
6
- // Categories
7
- Category: {
6
+ // Contexts
7
+ Context: {
8
8
  Uncategorized: 'n/a',
9
9
  ServerRenderedErrorPage: '_server-rendered-error-page',
10
10
  ServerEndpointError: '_server-endpoint-error',
@@ -10,10 +10,10 @@ type LogFunction = (
10
10
  opts: (
11
11
  // Shared info
12
12
  {
13
- // Category of the event (each app determines how to categorize its events)
14
- category: string | { _: string },
15
- // Subcategory of the event (each app determines how to categorize its events)
16
- subcategory?: string | { _: string },
13
+ // Context of the event (each app determines how to organize contexts)
14
+ context: string | { _: string },
15
+ // Subcontext of the event (each app determines how to organize subcontexts)
16
+ subcontext?: string,
17
17
  // List of tags that apply to this action (each app determines tag usage)
18
18
  tags?: string[],
19
19
  // Additional optional custom metadata