@wenlarge/communication 1.2.6 → 1.2.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.
- package/dist/generated/executor-core.d.ts +0 -3
- package/dist/helpers/resolve-config-value.js +21 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/kafka/commit-kafka-offset.d.ts +16 -0
- package/dist/kafka/commit-kafka-offset.js +11 -0
- package/package.json +1 -1
- package/proto/executor-core.proto +0 -1
- package/src/generated/executor-core.ts +0 -1
|
@@ -8,8 +8,9 @@ function sanitize(value) {
|
|
|
8
8
|
return value;
|
|
9
9
|
if (typeof value === "function")
|
|
10
10
|
return undefined;
|
|
11
|
-
if (Array.isArray(value))
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
12
|
return value.map(sanitize);
|
|
13
|
+
}
|
|
13
14
|
if (typeof value === "object") {
|
|
14
15
|
const clean = Object.create(null);
|
|
15
16
|
for (const key of Object.keys(value)) {
|
|
@@ -21,10 +22,8 @@ function sanitize(value) {
|
|
|
21
22
|
}
|
|
22
23
|
return value;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function resolveStringValue(value, input, env) {
|
|
25
26
|
var _a;
|
|
26
|
-
if (typeof value !== "string")
|
|
27
|
-
return value;
|
|
28
27
|
const parser = new expr_eval_1.Parser();
|
|
29
28
|
parser.consts = {};
|
|
30
29
|
parser.functions = {};
|
|
@@ -77,3 +76,21 @@ function resolveConfigValue(value, input, env) {
|
|
|
77
76
|
}
|
|
78
77
|
return value;
|
|
79
78
|
}
|
|
79
|
+
function resolveConfigValue(value, input, env) {
|
|
80
|
+
if (typeof value === "string") {
|
|
81
|
+
return resolveStringValue(value, input, env);
|
|
82
|
+
}
|
|
83
|
+
if (Array.isArray(value)) {
|
|
84
|
+
return value.map((item) => resolveConfigValue(item, input, env));
|
|
85
|
+
}
|
|
86
|
+
if (value && typeof value === "object") {
|
|
87
|
+
const clean = Object.create(null);
|
|
88
|
+
for (const key of Object.keys(value)) {
|
|
89
|
+
if (FORBIDDEN_KEYS.has(key))
|
|
90
|
+
continue;
|
|
91
|
+
clean[key] = resolveConfigValue(value[key], input, env);
|
|
92
|
+
}
|
|
93
|
+
return clean;
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ export * as ExecutorCore from "./generated/executor-core";
|
|
|
13
13
|
export * from "./config/notification-config";
|
|
14
14
|
export * as Notification from "./generated/notification";
|
|
15
15
|
export * from "./kafka/kafka-topics";
|
|
16
|
+
export * from "./kafka/commit-kafka-offset";
|
|
16
17
|
export { Struct, Value, ListValue } from "./generated/google/protobuf/struct";
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ exports.ExecutorCore = __importStar(require("./generated/executor-core"));
|
|
|
53
53
|
__exportStar(require("./config/notification-config"), exports);
|
|
54
54
|
exports.Notification = __importStar(require("./generated/notification"));
|
|
55
55
|
__exportStar(require("./kafka/kafka-topics"), exports);
|
|
56
|
+
__exportStar(require("./kafka/commit-kafka-offset"), exports);
|
|
56
57
|
var struct_1 = require("./generated/google/protobuf/struct");
|
|
57
58
|
Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return struct_1.Struct; } });
|
|
58
59
|
Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return struct_1.Value; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type KafkaOffsetContext = {
|
|
2
|
+
getConsumer(): {
|
|
3
|
+
commitOffsets(offsets: Array<{
|
|
4
|
+
topic: string;
|
|
5
|
+
partition: number;
|
|
6
|
+
offset: string;
|
|
7
|
+
}>): Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
getTopic(): string;
|
|
10
|
+
getPartition(): number;
|
|
11
|
+
getMessage(): {
|
|
12
|
+
offset: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function commitKafkaOffset(ctx: KafkaOffsetContext): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commitKafkaOffset = commitKafkaOffset;
|
|
4
|
+
async function commitKafkaOffset(ctx) {
|
|
5
|
+
const consumer = ctx.getConsumer();
|
|
6
|
+
const topic = ctx.getTopic();
|
|
7
|
+
const partition = ctx.getPartition();
|
|
8
|
+
const message = ctx.getMessage();
|
|
9
|
+
const nextOffset = (BigInt(message.offset) + BigInt(1)).toString();
|
|
10
|
+
await consumer.commitOffsets([{ topic, partition, offset: nextOffset }]);
|
|
11
|
+
}
|
package/package.json
CHANGED