erpnext-queue-client 1.8.2 → 1.9.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/dist/client.js +2 -1
- package/dist/dataConverter.d.ts +2 -0
- package/dist/dataConverter.js +84 -0
- package/package.json +3 -1
package/dist/client.js
CHANGED
|
@@ -25,6 +25,7 @@ const client_1 = require("@temporalio/client");
|
|
|
25
25
|
const logger_1 = require("./utils/logger");
|
|
26
26
|
const zodUtils_1 = require("./utils/zodUtils");
|
|
27
27
|
const nanoid_1 = require("nanoid");
|
|
28
|
+
const dataConverter_1 = require("./dataConverter");
|
|
28
29
|
const nanoid = (0, nanoid_1.customAlphabet)("1234567890", 4);
|
|
29
30
|
class TemporalClient {
|
|
30
31
|
constructor(options) {
|
|
@@ -62,7 +63,7 @@ class TemporalClient {
|
|
|
62
63
|
throw new Error("No temporal credentials provided");
|
|
63
64
|
const connection = yield this.tryConnect(temporalHost, temporalCert, temporalKey);
|
|
64
65
|
console.log("Create new client", options.temporalHost);
|
|
65
|
-
this.client = new client_1.Client(Object.assign(Object.assign({}, (connection ? { connection } : {})), { namespace: options.temporalNamespace || "default" }));
|
|
66
|
+
this.client = new client_1.Client(Object.assign(Object.assign({}, (connection ? { connection } : {})), { namespace: options.temporalNamespace || "default", dataConverter: dataConverter_1.dataConverter }));
|
|
66
67
|
return this.client;
|
|
67
68
|
});
|
|
68
69
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.dataConverter = void 0;
|
|
46
|
+
const common_1 = require("@temporalio/common");
|
|
47
|
+
const encoding_1 = require("@temporalio/common/lib/encoding");
|
|
48
|
+
const pako = __importStar(require("pako"));
|
|
49
|
+
const ENCODING = "json/plain";
|
|
50
|
+
exports.dataConverter = {
|
|
51
|
+
payloadCodecs: [
|
|
52
|
+
{
|
|
53
|
+
encode: (payloads) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
return Promise.all(payloads.map((payload) => {
|
|
55
|
+
if (!payload.data)
|
|
56
|
+
throw new common_1.ValueError("Payload data is missing in encode");
|
|
57
|
+
return {
|
|
58
|
+
metadata: {
|
|
59
|
+
[common_1.METADATA_ENCODING_KEY]: (0, encoding_1.encode)(ENCODING),
|
|
60
|
+
},
|
|
61
|
+
data: pako.gzip((0, encoding_1.decode)(payload.data)),
|
|
62
|
+
};
|
|
63
|
+
}));
|
|
64
|
+
}),
|
|
65
|
+
decode: (payloads) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
return Promise.all(payloads.map((payload) => {
|
|
67
|
+
if (!payload.metadata ||
|
|
68
|
+
(0, encoding_1.decode)(payload.metadata[common_1.METADATA_ENCODING_KEY]) !== ENCODING) {
|
|
69
|
+
return payload;
|
|
70
|
+
}
|
|
71
|
+
if (!payload.data) {
|
|
72
|
+
throw new common_1.ValueError("Payload data is missing in decode");
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
metadata: {
|
|
76
|
+
[common_1.METADATA_ENCODING_KEY]: (0, encoding_1.encode)(ENCODING),
|
|
77
|
+
},
|
|
78
|
+
data: pako.ungzip(payload.data),
|
|
79
|
+
};
|
|
80
|
+
}));
|
|
81
|
+
}),
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
package/package.json
CHANGED
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
"dotenv-cli": "^8.0.0",
|
|
21
21
|
"lodash": "^4.17.21",
|
|
22
22
|
"nanoid": "^3.3.7",
|
|
23
|
+
"pako": "^2.1.0",
|
|
23
24
|
"randombytes": "^2.1.0",
|
|
24
25
|
"winston": "^3.15.0",
|
|
25
26
|
"zod": "3.24.1"
|
|
26
27
|
},
|
|
27
|
-
"version": "1.
|
|
28
|
+
"version": "1.9.0",
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/crypto-js": "^4.2.2",
|
|
30
31
|
"@types/lodash": "^4.17.13",
|
|
32
|
+
"@types/pako": "^2.0.3",
|
|
31
33
|
"@types/randombytes": "^2.0.3",
|
|
32
34
|
"typescript": "^5.6.3",
|
|
33
35
|
"vitest": "^2.1.8"
|