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.
- package/.vscode/settings.json +1 -0
- package/dist/cjs/index.js +40 -44
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/index.d.ts +2 -2
- package/dist/cjs/types/types/Log/LogMainInfo.d.ts +2 -2
- package/dist/cjs/types/types/LogBuiltInMetadata.d.ts +2 -2
- package/dist/cjs/types/types/LogFunction.d.ts +2 -4
- package/dist/esm/index.js +40 -44
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/index.d.ts +2 -2
- package/dist/esm/types/types/Log/LogMainInfo.d.ts +2 -2
- package/dist/esm/types/types/LogBuiltInMetadata.d.ts +2 -2
- package/dist/esm/types/types/LogFunction.d.ts +2 -4
- package/dist/index.d.ts +7 -9
- package/package.json +1 -1
- package/src/helpers/genRouteHandler.ts +12 -16
- package/src/helpers/logClientEvent.tsx +8 -12
- package/src/index.ts +2 -2
- package/src/server/initLogCollection.ts +2 -2
- package/src/server/initServer.ts +10 -10
- package/src/types/Log/LogMainInfo.ts +4 -4
- package/src/types/LogBuiltInMetadata.ts +3 -3
- package/src/types/LogFunction.ts +4 -4
|
@@ -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
|
|
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,
|
|
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, };
|
|
@@ -5,12 +5,10 @@ import LogAction from './LogAction';
|
|
|
5
5
|
* @author Gabe Abrams
|
|
6
6
|
*/
|
|
7
7
|
declare type LogFunction = (opts: ({
|
|
8
|
-
|
|
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
|
-
|
|
548
|
-
|
|
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
|
-
|
|
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
|
|
884
|
+
* Built-in metadata for logs
|
|
887
885
|
* @author Gabe Abrams
|
|
888
886
|
*/
|
|
889
887
|
declare const LogBuiltInMetadata: {
|
|
890
|
-
|
|
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
|
|
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
|
@@ -508,21 +508,17 @@ const genRouteHandler = (
|
|
|
508
508
|
hour,
|
|
509
509
|
minute,
|
|
510
510
|
timestamp,
|
|
511
|
-
|
|
512
|
-
typeof opts.
|
|
513
|
-
? opts.
|
|
511
|
+
context: (
|
|
512
|
+
typeof opts.context === 'string'
|
|
513
|
+
? opts.context
|
|
514
514
|
: (
|
|
515
|
-
((opts.
|
|
516
|
-
?? LogBuiltInMetadata.
|
|
515
|
+
((opts.context as any) ?? {})._
|
|
516
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
517
517
|
)
|
|
518
518
|
),
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
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
|
-
|
|
622
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
typeof opts.
|
|
20
|
-
? opts.
|
|
18
|
+
context: (
|
|
19
|
+
typeof opts.context === 'string'
|
|
20
|
+
? opts.context
|
|
21
21
|
: (
|
|
22
|
-
((opts.
|
|
23
|
-
?? LogBuiltInMetadata.
|
|
22
|
+
((opts.context as any) ?? {})._
|
|
23
|
+
?? LogBuiltInMetadata.Context.Uncategorized
|
|
24
24
|
)
|
|
25
25
|
),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
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
|
-
|
|
139
|
+
LogBuiltInMetadata,
|
|
140
140
|
// Component-specific-types
|
|
141
141
|
PickableItem,
|
|
142
142
|
// Server types
|
package/src/server/initServer.ts
CHANGED
|
@@ -79,10 +79,10 @@ const initServer = (
|
|
|
79
79
|
/**
|
|
80
80
|
* Log an event
|
|
81
81
|
* @author Gabe Abrams
|
|
82
|
-
* @param {string}
|
|
83
|
-
*
|
|
84
|
-
* @param {string}
|
|
85
|
-
* how to
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
117
|
-
|
|
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
|
-
|
|
129
|
-
|
|
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
|
-
//
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
|
|
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
|
|
2
|
+
* Built-in metadata for logs
|
|
3
3
|
* @author Gabe Abrams
|
|
4
4
|
*/
|
|
5
5
|
const LogBuiltInMetadata = {
|
|
6
|
-
//
|
|
7
|
-
|
|
6
|
+
// Contexts
|
|
7
|
+
Context: {
|
|
8
8
|
Uncategorized: 'n/a',
|
|
9
9
|
ServerRenderedErrorPage: '_server-rendered-error-page',
|
|
10
10
|
ServerEndpointError: '_server-endpoint-error',
|
package/src/types/LogFunction.ts
CHANGED
|
@@ -10,10 +10,10 @@ type LogFunction = (
|
|
|
10
10
|
opts: (
|
|
11
11
|
// Shared info
|
|
12
12
|
{
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
|
|
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
|