@temporalio/proto 0.20.0 → 0.23.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/lib/patch-protobuf-root.d.ts +8 -0
- package/lib/patch-protobuf-root.js +57 -0
- package/lib/patch-protobuf-root.js.map +1 -0
- package/package.json +8 -4
- package/{lib → protos}/index.d.ts +11 -13
- package/protos/index.js +1 -0
- package/protos/json-module.js +7603 -0
- package/{lib/temporal.d.ts → protos/root.d.ts} +17448 -9471
- package/protos/root.js +3 -0
- package/lib/coresdk.d.ts +0 -10632
- package/lib/coresdk.js +0 -15651
- package/lib/index.js +0 -2
- package/lib/temporal.js +0 -32195
- package/scripts/compile-proto.js +0 -103
package/scripts/compile-proto.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const { resolve } = require('path');
|
|
2
|
-
const { promisify } = require('util');
|
|
3
|
-
const dedent = require('dedent');
|
|
4
|
-
const glob = require('glob');
|
|
5
|
-
const { statSync, mkdirsSync, readFileSync, writeFileSync } = require('fs-extra');
|
|
6
|
-
const pbjs = require('protobufjs/cli/pbjs');
|
|
7
|
-
const pbts = require('protobufjs/cli/pbts');
|
|
8
|
-
|
|
9
|
-
const outputDir = resolve(__dirname, '../lib');
|
|
10
|
-
const coresdkJsOutputFile = resolve(outputDir, 'coresdk.js');
|
|
11
|
-
const serviceJsOutputFile = resolve(outputDir, 'temporal.js');
|
|
12
|
-
const protoBaseDir = resolve(__dirname, '../../core-bridge/sdk-core/protos');
|
|
13
|
-
|
|
14
|
-
const coreProtoPath = resolve(protoBaseDir, 'local/temporal/sdk/core/core_interface.proto');
|
|
15
|
-
const serviceProtoPath = resolve(protoBaseDir, 'api_upstream/temporal/api/workflowservice/v1/service.proto');
|
|
16
|
-
|
|
17
|
-
function mtime(path) {
|
|
18
|
-
try {
|
|
19
|
-
return statSync(path).mtimeMs;
|
|
20
|
-
} catch (err) {
|
|
21
|
-
if (err.code === 'ENOENT') {
|
|
22
|
-
return 0;
|
|
23
|
-
}
|
|
24
|
-
throw err;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function compileProtos(protoPath, jsOutputFile, dtsOutputFile, ...args) {
|
|
29
|
-
console.log(`Creating protobuf JS definitions from ${protoPath}`);
|
|
30
|
-
|
|
31
|
-
const pbjsArgs = [
|
|
32
|
-
...args,
|
|
33
|
-
'--wrap',
|
|
34
|
-
'commonjs',
|
|
35
|
-
'--target',
|
|
36
|
-
'static-module',
|
|
37
|
-
'--force-long',
|
|
38
|
-
'--no-verify',
|
|
39
|
-
'--no-create',
|
|
40
|
-
'--out',
|
|
41
|
-
jsOutputFile,
|
|
42
|
-
protoPath,
|
|
43
|
-
];
|
|
44
|
-
await promisify(pbjs.main)(pbjsArgs);
|
|
45
|
-
|
|
46
|
-
console.log(`Creating protobuf TS definitions from ${protoPath}`);
|
|
47
|
-
await promisify(pbts.main)(['--out', dtsOutputFile, jsOutputFile]);
|
|
48
|
-
|
|
49
|
-
// Fix issue where Long is not found in TS definitions (https://github.com/protobufjs/protobuf.js/issues/1533)
|
|
50
|
-
const pbtsOutput = readFileSync(dtsOutputFile, 'utf8');
|
|
51
|
-
writeFileSync(
|
|
52
|
-
dtsOutputFile,
|
|
53
|
-
dedent`
|
|
54
|
-
import Long from "long";
|
|
55
|
-
${pbtsOutput}
|
|
56
|
-
`
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
// Get rid of most comments in file (cuts size in half)
|
|
60
|
-
const pbjsOutput = readFileSync(jsOutputFile, 'utf8');
|
|
61
|
-
const sanitizedOutput = pbjsOutput
|
|
62
|
-
.split('\n')
|
|
63
|
-
.filter((l) => !/^\s*(\*|\/\*\*)/.test(l))
|
|
64
|
-
.join('\n');
|
|
65
|
-
writeFileSync(jsOutputFile, sanitizedOutput);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function main() {
|
|
69
|
-
mkdirsSync(outputDir);
|
|
70
|
-
|
|
71
|
-
const protoFiles = glob.sync(resolve(protoBaseDir, '**/*.proto'));
|
|
72
|
-
const protosMTime = Math.max(...protoFiles.map(mtime));
|
|
73
|
-
const genMTime = Math.min(mtime(coresdkJsOutputFile), mtime(serviceJsOutputFile));
|
|
74
|
-
|
|
75
|
-
if (protosMTime < genMTime) {
|
|
76
|
-
console.log('Assuming protos are up to date');
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
await compileProtos(
|
|
81
|
-
coreProtoPath,
|
|
82
|
-
coresdkJsOutputFile,
|
|
83
|
-
resolve(outputDir, 'coresdk.d.ts'),
|
|
84
|
-
'--path',
|
|
85
|
-
resolve(protoBaseDir, 'api_upstream'),
|
|
86
|
-
'--path',
|
|
87
|
-
resolve(protoBaseDir, 'local')
|
|
88
|
-
);
|
|
89
|
-
await compileProtos(
|
|
90
|
-
serviceProtoPath,
|
|
91
|
-
serviceJsOutputFile,
|
|
92
|
-
resolve(outputDir, 'temporal.d.ts'),
|
|
93
|
-
'--path',
|
|
94
|
-
resolve(protoBaseDir, 'api_upstream')
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
console.log('Done');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
main().catch((err) => {
|
|
101
|
-
console.error(err);
|
|
102
|
-
process.exit(1);
|
|
103
|
-
});
|