jr-common-micro 1.1.140 → 1.1.142
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/dist/proto/micro/v1/mining/mining_messages_nest.d.ts +7 -0
- package/dist/proto/micro/v1/mining/mining_messages_pb.d.ts +7 -0
- package/dist/proto/micro/v1/mining/mining_messages_pb.js +14 -0
- package/dist/utils/functions.d.ts +1 -0
- package/dist/utils/functions.js +23 -1
- package/package.json +1 -1
- package/proto/micro/v1/mining/mining_messages.proto +20 -0
|
@@ -106,6 +106,8 @@ export interface TaskInfo {
|
|
|
106
106
|
effect_days: number;
|
|
107
107
|
ends_at: string;
|
|
108
108
|
test: boolean;
|
|
109
|
+
reviewing: boolean;
|
|
110
|
+
review_ends_at: string;
|
|
109
111
|
}
|
|
110
112
|
export interface TaskBlock {
|
|
111
113
|
type: string;
|
|
@@ -168,6 +170,8 @@ export interface TaskEventResponse {
|
|
|
168
170
|
status: ResponseStatus | undefined;
|
|
169
171
|
completed_task_id: string;
|
|
170
172
|
data?: MiningState | undefined;
|
|
173
|
+
reviewing: boolean;
|
|
174
|
+
review_ends_at: string;
|
|
171
175
|
}
|
|
172
176
|
export interface ReferralItem {
|
|
173
177
|
user_id: string;
|
|
@@ -409,6 +413,7 @@ export interface AdminTaskItem {
|
|
|
409
413
|
starts_at: string;
|
|
410
414
|
ends_at: string;
|
|
411
415
|
published_at: string;
|
|
416
|
+
review_minutes: number;
|
|
412
417
|
}
|
|
413
418
|
export interface AdminTaskItem_TitlesEntry {
|
|
414
419
|
key: string;
|
|
@@ -485,6 +490,7 @@ export interface AdminSaveTaskRequest {
|
|
|
485
490
|
effect_days: number;
|
|
486
491
|
starts_at: string;
|
|
487
492
|
ends_at: string;
|
|
493
|
+
review_minutes: number;
|
|
488
494
|
}
|
|
489
495
|
export interface AdminSaveTaskRequest_TitlesEntry {
|
|
490
496
|
key: string;
|
|
@@ -717,6 +723,7 @@ export interface AdminSetTaskRequest {
|
|
|
717
723
|
titles: {
|
|
718
724
|
[key: string]: string;
|
|
719
725
|
};
|
|
726
|
+
review_minutes?: number | undefined;
|
|
720
727
|
}
|
|
721
728
|
export interface AdminSetTaskRequest_TitlesEntry {
|
|
722
729
|
key: string;
|
|
@@ -163,6 +163,8 @@ export declare class TaskInfo extends Message<TaskInfo> {
|
|
|
163
163
|
effectDays: number;
|
|
164
164
|
endsAt: string;
|
|
165
165
|
test: boolean;
|
|
166
|
+
reviewing: boolean;
|
|
167
|
+
reviewEndsAt: string;
|
|
166
168
|
constructor(data?: PartialMessage<TaskInfo>);
|
|
167
169
|
static readonly runtime: typeof proto3;
|
|
168
170
|
static readonly typeName = "micro.v1.mining.TaskInfo";
|
|
@@ -289,6 +291,8 @@ export declare class TaskEventResponse extends Message<TaskEventResponse> {
|
|
|
289
291
|
status?: ResponseStatus;
|
|
290
292
|
completedTaskId: string;
|
|
291
293
|
data?: MiningState;
|
|
294
|
+
reviewing: boolean;
|
|
295
|
+
reviewEndsAt: string;
|
|
292
296
|
constructor(data?: PartialMessage<TaskEventResponse>);
|
|
293
297
|
static readonly runtime: typeof proto3;
|
|
294
298
|
static readonly typeName = "micro.v1.mining.TaskEventResponse";
|
|
@@ -794,6 +798,7 @@ export declare class AdminTaskItem extends Message<AdminTaskItem> {
|
|
|
794
798
|
startsAt: string;
|
|
795
799
|
endsAt: string;
|
|
796
800
|
publishedAt: string;
|
|
801
|
+
reviewMinutes: number;
|
|
797
802
|
constructor(data?: PartialMessage<AdminTaskItem>);
|
|
798
803
|
static readonly runtime: typeof proto3;
|
|
799
804
|
static readonly typeName = "micro.v1.mining.AdminTaskItem";
|
|
@@ -874,6 +879,7 @@ export declare class AdminSaveTaskRequest extends Message<AdminSaveTaskRequest>
|
|
|
874
879
|
effectDays: number;
|
|
875
880
|
startsAt: string;
|
|
876
881
|
endsAt: string;
|
|
882
|
+
reviewMinutes: number;
|
|
877
883
|
constructor(data?: PartialMessage<AdminSaveTaskRequest>);
|
|
878
884
|
static readonly runtime: typeof proto3;
|
|
879
885
|
static readonly typeName = "micro.v1.mining.AdminSaveTaskRequest";
|
|
@@ -1314,6 +1320,7 @@ export declare class AdminSetTaskRequest extends Message<AdminSetTaskRequest> {
|
|
|
1314
1320
|
titles: {
|
|
1315
1321
|
[key: string]: string;
|
|
1316
1322
|
};
|
|
1323
|
+
reviewMinutes?: number;
|
|
1317
1324
|
constructor(data?: PartialMessage<AdminSetTaskRequest>);
|
|
1318
1325
|
static readonly runtime: typeof proto3;
|
|
1319
1326
|
static readonly typeName = "micro.v1.mining.AdminSetTaskRequest";
|
|
@@ -322,6 +322,8 @@ class TaskInfo extends protobuf_1.Message {
|
|
|
322
322
|
effectDays = 0;
|
|
323
323
|
endsAt = "";
|
|
324
324
|
test = false;
|
|
325
|
+
reviewing = false;
|
|
326
|
+
reviewEndsAt = "";
|
|
325
327
|
constructor(data) {
|
|
326
328
|
super();
|
|
327
329
|
protobuf_1.proto3.util.initPartial(data, this);
|
|
@@ -355,6 +357,8 @@ class TaskInfo extends protobuf_1.Message {
|
|
|
355
357
|
{ no: 24, name: "effect_days", kind: "scalar", T: 5 },
|
|
356
358
|
{ no: 25, name: "ends_at", kind: "scalar", T: 9 },
|
|
357
359
|
{ no: 26, name: "test", kind: "scalar", T: 8 },
|
|
360
|
+
{ no: 27, name: "reviewing", kind: "scalar", T: 8 },
|
|
361
|
+
{ no: 28, name: "review_ends_at", kind: "scalar", T: 9 },
|
|
358
362
|
]);
|
|
359
363
|
static fromBinary(bytes, options) {
|
|
360
364
|
return new TaskInfo().fromBinary(bytes, options);
|
|
@@ -621,6 +625,8 @@ class TaskEventResponse extends protobuf_1.Message {
|
|
|
621
625
|
status;
|
|
622
626
|
completedTaskId = "";
|
|
623
627
|
data;
|
|
628
|
+
reviewing = false;
|
|
629
|
+
reviewEndsAt = "";
|
|
624
630
|
constructor(data) {
|
|
625
631
|
super();
|
|
626
632
|
protobuf_1.proto3.util.initPartial(data, this);
|
|
@@ -631,6 +637,8 @@ class TaskEventResponse extends protobuf_1.Message {
|
|
|
631
637
|
{ no: 1, name: "status", kind: "message", T: general_pb_js_1.ResponseStatus },
|
|
632
638
|
{ no: 2, name: "completed_task_id", kind: "scalar", T: 9 },
|
|
633
639
|
{ no: 3, name: "data", kind: "message", T: MiningState, opt: true },
|
|
640
|
+
{ no: 4, name: "reviewing", kind: "scalar", T: 8 },
|
|
641
|
+
{ no: 5, name: "review_ends_at", kind: "scalar", T: 9 },
|
|
634
642
|
]);
|
|
635
643
|
static fromBinary(bytes, options) {
|
|
636
644
|
return new TaskEventResponse().fromBinary(bytes, options);
|
|
@@ -1694,6 +1702,7 @@ class AdminTaskItem extends protobuf_1.Message {
|
|
|
1694
1702
|
startsAt = "";
|
|
1695
1703
|
endsAt = "";
|
|
1696
1704
|
publishedAt = "";
|
|
1705
|
+
reviewMinutes = 0;
|
|
1697
1706
|
constructor(data) {
|
|
1698
1707
|
super();
|
|
1699
1708
|
protobuf_1.proto3.util.initPartial(data, this);
|
|
@@ -1728,6 +1737,7 @@ class AdminTaskItem extends protobuf_1.Message {
|
|
|
1728
1737
|
{ no: 25, name: "starts_at", kind: "scalar", T: 9 },
|
|
1729
1738
|
{ no: 26, name: "ends_at", kind: "scalar", T: 9 },
|
|
1730
1739
|
{ no: 27, name: "published_at", kind: "scalar", T: 9 },
|
|
1740
|
+
{ no: 28, name: "review_minutes", kind: "scalar", T: 5 },
|
|
1731
1741
|
]);
|
|
1732
1742
|
static fromBinary(bytes, options) {
|
|
1733
1743
|
return new AdminTaskItem().fromBinary(bytes, options);
|
|
@@ -1850,6 +1860,7 @@ class AdminSaveTaskRequest extends protobuf_1.Message {
|
|
|
1850
1860
|
effectDays = 0;
|
|
1851
1861
|
startsAt = "";
|
|
1852
1862
|
endsAt = "";
|
|
1863
|
+
reviewMinutes = 0;
|
|
1853
1864
|
constructor(data) {
|
|
1854
1865
|
super();
|
|
1855
1866
|
protobuf_1.proto3.util.initPartial(data, this);
|
|
@@ -1872,6 +1883,7 @@ class AdminSaveTaskRequest extends protobuf_1.Message {
|
|
|
1872
1883
|
{ no: 13, name: "effect_days", kind: "scalar", T: 5 },
|
|
1873
1884
|
{ no: 14, name: "starts_at", kind: "scalar", T: 9 },
|
|
1874
1885
|
{ no: 15, name: "ends_at", kind: "scalar", T: 9 },
|
|
1886
|
+
{ no: 16, name: "review_minutes", kind: "scalar", T: 5 },
|
|
1875
1887
|
]);
|
|
1876
1888
|
static fromBinary(bytes, options) {
|
|
1877
1889
|
return new AdminSaveTaskRequest().fromBinary(bytes, options);
|
|
@@ -2813,6 +2825,7 @@ class AdminSetTaskRequest extends protobuf_1.Message {
|
|
|
2813
2825
|
maxCount;
|
|
2814
2826
|
sort;
|
|
2815
2827
|
titles = {};
|
|
2828
|
+
reviewMinutes;
|
|
2816
2829
|
constructor(data) {
|
|
2817
2830
|
super();
|
|
2818
2831
|
protobuf_1.proto3.util.initPartial(data, this);
|
|
@@ -2828,6 +2841,7 @@ class AdminSetTaskRequest extends protobuf_1.Message {
|
|
|
2828
2841
|
{ no: 6, name: "max_count", kind: "scalar", T: 5, opt: true },
|
|
2829
2842
|
{ no: 7, name: "sort", kind: "scalar", T: 5, opt: true },
|
|
2830
2843
|
{ no: 8, name: "titles", kind: "map", K: 9, V: { kind: "scalar", T: 9 } },
|
|
2844
|
+
{ no: 9, name: "review_minutes", kind: "scalar", T: 5, opt: true },
|
|
2831
2845
|
]);
|
|
2832
2846
|
static fromBinary(bytes, options) {
|
|
2833
2847
|
return new AdminSetTaskRequest().fromBinary(bytes, options);
|
|
@@ -26,6 +26,7 @@ export declare function createErrorResponse(code: number, errorMessage: string,
|
|
|
26
26
|
export declare const getMetadata: (clientJwt: string, jwtSecret: string) => Metadata;
|
|
27
27
|
export declare const getEnv: (key: string, defaultVal?: any) => string;
|
|
28
28
|
export declare const getBearerUser: (header: string) => JwtUser | null;
|
|
29
|
+
export declare function isSafeFieldName(name: unknown): name is string;
|
|
29
30
|
export declare function prismaWhere(filters: Filter[], fulltextColumns?: string[], fulltextSearch?: string): PrismaWhereType;
|
|
30
31
|
export declare function prismaOrderBy(sort: Sort[]): PrismaOrderType;
|
|
31
32
|
export declare function findSymbolItem<T = any>(haystack: T[], symbol: CurrencyParity | string): T | undefined;
|
package/dist/utils/functions.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.getRedisLogMessage = exports.getPrismaLogMessage = exports.moveArrItem =
|
|
|
4
4
|
exports.dateFormat = dateFormat;
|
|
5
5
|
exports.randomHash = randomHash;
|
|
6
6
|
exports.createErrorResponse = createErrorResponse;
|
|
7
|
+
exports.isSafeFieldName = isSafeFieldName;
|
|
7
8
|
exports.prismaWhere = prismaWhere;
|
|
8
9
|
exports.prismaOrderBy = prismaOrderBy;
|
|
9
10
|
exports.findSymbolItem = findSymbolItem;
|
|
@@ -115,10 +116,30 @@ const getBearerUser = (header) => {
|
|
|
115
116
|
return user;
|
|
116
117
|
};
|
|
117
118
|
exports.getBearerUser = getBearerUser;
|
|
119
|
+
const SAFE_FIELD_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
120
|
+
const FORBIDDEN_FIELD_NAMES = new Set([
|
|
121
|
+
'__proto__',
|
|
122
|
+
'constructor',
|
|
123
|
+
'prototype',
|
|
124
|
+
]);
|
|
125
|
+
function isSafeFieldName(name) {
|
|
126
|
+
return (typeof name === 'string' &&
|
|
127
|
+
SAFE_FIELD_NAME.test(name) &&
|
|
128
|
+
!FORBIDDEN_FIELD_NAMES.has(name));
|
|
129
|
+
}
|
|
130
|
+
function assertSafeFieldName(name, kind) {
|
|
131
|
+
if (!isSafeFieldName(name)) {
|
|
132
|
+
throw new Error(`Invalid ${kind} name`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
118
135
|
function prismaWhere(filters, fulltextColumns, fulltextSearch) {
|
|
119
136
|
const whereQuery = {};
|
|
120
137
|
filters.forEach((item) => {
|
|
121
|
-
|
|
138
|
+
assertSafeFieldName(item.name, 'filter');
|
|
139
|
+
assertSafeFieldName(item.operator, 'filter operator');
|
|
140
|
+
if (!Object.prototype.hasOwnProperty.call(whereQuery, item.name)) {
|
|
141
|
+
whereQuery[item.name] = {};
|
|
142
|
+
}
|
|
122
143
|
let operator = item.operator;
|
|
123
144
|
if (operator === general_nest_1.FilterOperator.isNull) {
|
|
124
145
|
whereQuery[item.name] = null;
|
|
@@ -173,6 +194,7 @@ function prismaWhere(filters, fulltextColumns, fulltextSearch) {
|
|
|
173
194
|
function prismaOrderBy(sort) {
|
|
174
195
|
const result = {};
|
|
175
196
|
sort.forEach((item) => {
|
|
197
|
+
assertSafeFieldName(item.name, 'sort');
|
|
176
198
|
result[item.name] = item.direction === general_nest_1.SortDirection.asc ? 'asc' : 'desc';
|
|
177
199
|
});
|
|
178
200
|
return result;
|
package/package.json
CHANGED
|
@@ -188,6 +188,13 @@ message TaskInfo {
|
|
|
188
188
|
string ends_at = 25;
|
|
189
189
|
// Being tested: only admins get it.
|
|
190
190
|
bool test = 26;
|
|
191
|
+
// Done, but "waiting for approval" until review_ends_at (a delay the
|
|
192
|
+
// panel set on the task; nothing is reviewed). done stays false and the
|
|
193
|
+
// layer starts counting at review_ends_at; the app shows the row as
|
|
194
|
+
// waiting and reads the tasks again once that moment has passed.
|
|
195
|
+
bool reviewing = 27;
|
|
196
|
+
// RFC 3339; '' when not reviewing.
|
|
197
|
+
string review_ends_at = 28;
|
|
191
198
|
}
|
|
192
199
|
|
|
193
200
|
// One block of a custom task's page, in the reader's language. Plain text
|
|
@@ -276,6 +283,10 @@ message TaskEventResponse {
|
|
|
276
283
|
// Task completed by this event ('' when nothing changed).
|
|
277
284
|
string completed_task_id = 2;
|
|
278
285
|
optional MiningState data = 3;
|
|
286
|
+
// The completed task now waits "for approval" (its review delay; only
|
|
287
|
+
// for an app that said it can show it): it counts at review_ends_at.
|
|
288
|
+
bool reviewing = 4;
|
|
289
|
+
string review_ends_at = 5;
|
|
279
290
|
}
|
|
280
291
|
|
|
281
292
|
message ReferralItem {
|
|
@@ -610,6 +621,10 @@ message AdminTaskItem {
|
|
|
610
621
|
// First publication ('' = never): from then on the repeat and the
|
|
611
622
|
// validity are fixed.
|
|
612
623
|
string published_at = 27;
|
|
624
|
+
// Minutes a completion waits "for approval" before it counts (0 = none).
|
|
625
|
+
// Only for tasks the person reports (custom tasks and built-in tasks
|
|
626
|
+
// with an app event, not the exchange ones).
|
|
627
|
+
int32 review_minutes = 28;
|
|
613
628
|
}
|
|
614
629
|
|
|
615
630
|
// A language → text map (tr, en, es, ...).
|
|
@@ -659,6 +674,8 @@ message AdminSaveTaskRequest {
|
|
|
659
674
|
int32 effect_days = 13;
|
|
660
675
|
string starts_at = 14;
|
|
661
676
|
string ends_at = 15;
|
|
677
|
+
// 0 (none) or one of 1, 3, 5, 10, 15.
|
|
678
|
+
int32 review_minutes = 16;
|
|
662
679
|
}
|
|
663
680
|
|
|
664
681
|
message AdminTaskActionRequest {
|
|
@@ -988,6 +1005,9 @@ message AdminSetTaskRequest {
|
|
|
988
1005
|
// replaces them all ('' = that language reads title_en); none sent
|
|
989
1006
|
// leaves them as they are.
|
|
990
1007
|
map<string, string> titles = 8;
|
|
1008
|
+
// 0 (none) or one of 1, 3, 5, 10, 15; not sent = unchanged. Refused on a
|
|
1009
|
+
// task the person does not report (server-completed or exchange).
|
|
1010
|
+
optional int32 review_minutes = 9;
|
|
991
1011
|
}
|
|
992
1012
|
|
|
993
1013
|
// ---- admin gifts ------------------------------------------------------------
|