@chainlink/cre-sdk 1.1.4 → 1.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/README.md +12 -1
- package/bin/cre-compile.ts +6 -1
- package/dist/index.d.ts +3 -0
- package/dist/sdk/types/global.d.ts +146 -2
- package/dist/sdk/types/restricted-apis.d.ts +18 -23
- package/dist/sdk/types/restricted-node-modules.d.ts +462 -0
- package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.d.ts +2 -2
- package/dist/sdk/utils/prepare-runtime.d.ts +1 -1
- package/dist/sdk/utils/prepare-runtime.js +9 -2
- package/dist/sdk/wasm/host-bindings.d.ts +4 -4
- package/package.json +2 -2
- package/scripts/run.ts +7 -1
- package/scripts/src/build-types.ts +31 -1
- package/scripts/src/compile-to-js.ts +5 -6
- package/scripts/src/compile-workflow.ts +1 -11
- package/scripts/src/validate-workflow-runtime-compat.test.ts +433 -0
- package/scripts/src/validate-workflow-runtime-compat.ts +631 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
// Restricted Node.js modules that are not available in CRE WASM workflows.
|
|
2
|
+
// These modules require native bindings or system access that cannot run in WebAssembly.
|
|
3
|
+
// Importing from these modules is allowed by TypeScript, but all exports are typed as
|
|
4
|
+
// `never` so any usage produces a clear error at the call site.
|
|
5
|
+
// Both bare specifiers (e.g. 'crypto') and node:-prefixed specifiers (e.g. 'node:crypto')
|
|
6
|
+
// are covered so IDE red-squiggles appear regardless of import style.
|
|
7
|
+
// See https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
8
|
+
|
|
9
|
+
// --- Bare-specifier aliases ---
|
|
10
|
+
// Re-export from the node:-prefixed declarations below so that
|
|
11
|
+
// `import { createHash } from 'crypto'` gets the same `never` types.
|
|
12
|
+
|
|
13
|
+
/** @deprecated crypto is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
14
|
+
declare module 'crypto' {
|
|
15
|
+
export * from 'node:crypto'
|
|
16
|
+
}
|
|
17
|
+
/** @deprecated fs is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
18
|
+
declare module 'fs' {
|
|
19
|
+
export * from 'node:fs'
|
|
20
|
+
}
|
|
21
|
+
/** @deprecated fs/promises is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
22
|
+
declare module 'fs/promises' {
|
|
23
|
+
export * from 'node:fs/promises'
|
|
24
|
+
}
|
|
25
|
+
/** @deprecated net is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
26
|
+
declare module 'net' {
|
|
27
|
+
export * from 'node:net'
|
|
28
|
+
}
|
|
29
|
+
/** @deprecated http is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
30
|
+
declare module 'http' {
|
|
31
|
+
export * from 'node:http'
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated https is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
34
|
+
declare module 'https' {
|
|
35
|
+
export * from 'node:https'
|
|
36
|
+
}
|
|
37
|
+
/** @deprecated child_process is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
38
|
+
declare module 'child_process' {
|
|
39
|
+
export * from 'node:child_process'
|
|
40
|
+
}
|
|
41
|
+
/** @deprecated os is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
42
|
+
declare module 'os' {
|
|
43
|
+
export * from 'node:os'
|
|
44
|
+
}
|
|
45
|
+
/** @deprecated stream is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
46
|
+
declare module 'stream' {
|
|
47
|
+
export * from 'node:stream'
|
|
48
|
+
}
|
|
49
|
+
/** @deprecated worker_threads is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
50
|
+
declare module 'worker_threads' {
|
|
51
|
+
export * from 'node:worker_threads'
|
|
52
|
+
}
|
|
53
|
+
/** @deprecated dns is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
54
|
+
declare module 'dns' {
|
|
55
|
+
export * from 'node:dns'
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated zlib is not available in CRE WASM workflows. @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime */
|
|
58
|
+
declare module 'zlib' {
|
|
59
|
+
export * from 'node:zlib'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --- node:-prefixed declarations (canonical definitions) ---
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated node:crypto is not available in CRE WASM workflows. It requires native bindings that cannot run in WebAssembly.
|
|
66
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
67
|
+
*/
|
|
68
|
+
declare module 'node:crypto' {
|
|
69
|
+
export const randomBytes: never
|
|
70
|
+
export const randomUUID: never
|
|
71
|
+
export const randomInt: never
|
|
72
|
+
export const randomFillSync: never
|
|
73
|
+
export const randomFill: never
|
|
74
|
+
export const createHash: never
|
|
75
|
+
export const createHmac: never
|
|
76
|
+
export const createCipheriv: never
|
|
77
|
+
export const createDecipheriv: never
|
|
78
|
+
export const createSign: never
|
|
79
|
+
export const createVerify: never
|
|
80
|
+
export const createDiffieHellman: never
|
|
81
|
+
export const createDiffieHellmanGroup: never
|
|
82
|
+
export const createECDH: never
|
|
83
|
+
export const generateKey: never
|
|
84
|
+
export const generateKeySync: never
|
|
85
|
+
export const generateKeyPair: never
|
|
86
|
+
export const generateKeyPairSync: never
|
|
87
|
+
export const createPrivateKey: never
|
|
88
|
+
export const createPublicKey: never
|
|
89
|
+
export const createSecretKey: never
|
|
90
|
+
export const pbkdf2: never
|
|
91
|
+
export const pbkdf2Sync: never
|
|
92
|
+
export const scrypt: never
|
|
93
|
+
export const scryptSync: never
|
|
94
|
+
export const timingSafeEqual: never
|
|
95
|
+
export const publicEncrypt: never
|
|
96
|
+
export const publicDecrypt: never
|
|
97
|
+
export const privateDecrypt: never
|
|
98
|
+
export const privateEncrypt: never
|
|
99
|
+
export const getCiphers: never
|
|
100
|
+
export const getHashes: never
|
|
101
|
+
export const getCurves: never
|
|
102
|
+
export const getFips: never
|
|
103
|
+
export const setFips: never
|
|
104
|
+
export const getRandomValues: never
|
|
105
|
+
export const Hash: never
|
|
106
|
+
export const Hmac: never
|
|
107
|
+
export const Sign: never
|
|
108
|
+
export const Verify: never
|
|
109
|
+
export const KeyObject: never
|
|
110
|
+
export const Certificate: never
|
|
111
|
+
export const ECDH: never
|
|
112
|
+
export const DiffieHellman: never
|
|
113
|
+
export const DiffieHellmanGroup: never
|
|
114
|
+
export const Cipheriv: never
|
|
115
|
+
export const Decipheriv: never
|
|
116
|
+
export const webcrypto: never
|
|
117
|
+
export const subtle: never
|
|
118
|
+
export const crypto: never
|
|
119
|
+
export const fips: never
|
|
120
|
+
export const constants: never
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated node:fs is not available in CRE WASM workflows. It requires filesystem access that is not available in WebAssembly.
|
|
125
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
126
|
+
*/
|
|
127
|
+
declare module 'node:fs' {
|
|
128
|
+
export const readFile: never
|
|
129
|
+
export const readFileSync: never
|
|
130
|
+
export const writeFile: never
|
|
131
|
+
export const writeFileSync: never
|
|
132
|
+
export const appendFile: never
|
|
133
|
+
export const appendFileSync: never
|
|
134
|
+
export const readdir: never
|
|
135
|
+
export const readdirSync: never
|
|
136
|
+
export const mkdir: never
|
|
137
|
+
export const mkdirSync: never
|
|
138
|
+
export const mkdtemp: never
|
|
139
|
+
export const mkdtempSync: never
|
|
140
|
+
export const rm: never
|
|
141
|
+
export const rmSync: never
|
|
142
|
+
export const rmdir: never
|
|
143
|
+
export const rmdirSync: never
|
|
144
|
+
export const unlink: never
|
|
145
|
+
export const unlinkSync: never
|
|
146
|
+
export const stat: never
|
|
147
|
+
export const statSync: never
|
|
148
|
+
export const lstat: never
|
|
149
|
+
export const lstatSync: never
|
|
150
|
+
export const fstat: never
|
|
151
|
+
export const fstatSync: never
|
|
152
|
+
export const statfs: never
|
|
153
|
+
export const statfsSync: never
|
|
154
|
+
export const exists: never
|
|
155
|
+
export const existsSync: never
|
|
156
|
+
export const copyFile: never
|
|
157
|
+
export const copyFileSync: never
|
|
158
|
+
export const cp: never
|
|
159
|
+
export const cpSync: never
|
|
160
|
+
export const rename: never
|
|
161
|
+
export const renameSync: never
|
|
162
|
+
export const readlink: never
|
|
163
|
+
export const readlinkSync: never
|
|
164
|
+
export const symlink: never
|
|
165
|
+
export const symlinkSync: never
|
|
166
|
+
export const link: never
|
|
167
|
+
export const linkSync: never
|
|
168
|
+
export const open: never
|
|
169
|
+
export const openSync: never
|
|
170
|
+
export const close: never
|
|
171
|
+
export const closeSync: never
|
|
172
|
+
export const read: never
|
|
173
|
+
export const readSync: never
|
|
174
|
+
export const write: never
|
|
175
|
+
export const writeSync: never
|
|
176
|
+
export const truncate: never
|
|
177
|
+
export const truncateSync: never
|
|
178
|
+
export const ftruncate: never
|
|
179
|
+
export const ftruncateSync: never
|
|
180
|
+
export const chmod: never
|
|
181
|
+
export const chmodSync: never
|
|
182
|
+
export const chown: never
|
|
183
|
+
export const chownSync: never
|
|
184
|
+
export const utimes: never
|
|
185
|
+
export const utimesSync: never
|
|
186
|
+
export const access: never
|
|
187
|
+
export const accessSync: never
|
|
188
|
+
export const createReadStream: never
|
|
189
|
+
export const createWriteStream: never
|
|
190
|
+
export const watch: never
|
|
191
|
+
export const watchFile: never
|
|
192
|
+
export const unwatchFile: never
|
|
193
|
+
export const realpath: never
|
|
194
|
+
export const realpathSync: never
|
|
195
|
+
export const promises: never
|
|
196
|
+
export const constants: never
|
|
197
|
+
export const Dir: never
|
|
198
|
+
export const Dirent: never
|
|
199
|
+
export const Stats: never
|
|
200
|
+
export const ReadStream: never
|
|
201
|
+
export const WriteStream: never
|
|
202
|
+
export const FileHandle: never
|
|
203
|
+
export const FSWatcher: never
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated node:fs/promises is not available in CRE WASM workflows. It requires filesystem access that is not available in WebAssembly.
|
|
208
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
209
|
+
*/
|
|
210
|
+
declare module 'node:fs/promises' {
|
|
211
|
+
export const readFile: never
|
|
212
|
+
export const writeFile: never
|
|
213
|
+
export const appendFile: never
|
|
214
|
+
export const readdir: never
|
|
215
|
+
export const mkdir: never
|
|
216
|
+
export const mkdtemp: never
|
|
217
|
+
export const rm: never
|
|
218
|
+
export const rmdir: never
|
|
219
|
+
export const unlink: never
|
|
220
|
+
export const stat: never
|
|
221
|
+
export const lstat: never
|
|
222
|
+
export const statfs: never
|
|
223
|
+
export const copyFile: never
|
|
224
|
+
export const cp: never
|
|
225
|
+
export const rename: never
|
|
226
|
+
export const readlink: never
|
|
227
|
+
export const symlink: never
|
|
228
|
+
export const link: never
|
|
229
|
+
export const open: never
|
|
230
|
+
export const truncate: never
|
|
231
|
+
export const chmod: never
|
|
232
|
+
export const chown: never
|
|
233
|
+
export const utimes: never
|
|
234
|
+
export const access: never
|
|
235
|
+
export const realpath: never
|
|
236
|
+
export const watch: never
|
|
237
|
+
export const constants: never
|
|
238
|
+
export const FileHandle: never
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @deprecated node:net is not available in CRE WASM workflows. It requires network access. Use cre.capabilities.HTTPClient instead.
|
|
243
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
244
|
+
*/
|
|
245
|
+
declare module 'node:net' {
|
|
246
|
+
export const createServer: never
|
|
247
|
+
export const createConnection: never
|
|
248
|
+
export const connect: never
|
|
249
|
+
export const isIP: never
|
|
250
|
+
export const isIPv4: never
|
|
251
|
+
export const isIPv6: never
|
|
252
|
+
export const getDefaultAutoSelectFamily: never
|
|
253
|
+
export const setDefaultAutoSelectFamily: never
|
|
254
|
+
export const Socket: never
|
|
255
|
+
export const Server: never
|
|
256
|
+
export const BlockList: never
|
|
257
|
+
export const SocketAddress: never
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated node:http is not available in CRE WASM workflows. It requires network access. Use cre.capabilities.HTTPClient instead.
|
|
262
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
263
|
+
*/
|
|
264
|
+
declare module 'node:http' {
|
|
265
|
+
export const createServer: never
|
|
266
|
+
export const request: never
|
|
267
|
+
export const get: never
|
|
268
|
+
export const validateHeaderName: never
|
|
269
|
+
export const validateHeaderValue: never
|
|
270
|
+
export const setMaxIdleHTTPParsers: never
|
|
271
|
+
export const Server: never
|
|
272
|
+
export const ClientRequest: never
|
|
273
|
+
export const IncomingMessage: never
|
|
274
|
+
export const ServerResponse: never
|
|
275
|
+
export const OutgoingMessage: never
|
|
276
|
+
export const Agent: never
|
|
277
|
+
export const globalAgent: never
|
|
278
|
+
export const METHODS: never
|
|
279
|
+
export const STATUS_CODES: never
|
|
280
|
+
export const maxHeaderSize: never
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated node:https is not available in CRE WASM workflows. It requires network access. Use cre.capabilities.HTTPClient instead.
|
|
285
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
286
|
+
*/
|
|
287
|
+
declare module 'node:https' {
|
|
288
|
+
export const createServer: never
|
|
289
|
+
export const request: never
|
|
290
|
+
export const get: never
|
|
291
|
+
export const Server: never
|
|
292
|
+
export const Agent: never
|
|
293
|
+
export const globalAgent: never
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* @deprecated node:child_process is not available in CRE WASM workflows. It requires OS process spawning that is not available in WebAssembly.
|
|
298
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
299
|
+
*/
|
|
300
|
+
declare module 'node:child_process' {
|
|
301
|
+
export const spawn: never
|
|
302
|
+
export const spawnSync: never
|
|
303
|
+
export const exec: never
|
|
304
|
+
export const execSync: never
|
|
305
|
+
export const execFile: never
|
|
306
|
+
export const execFileSync: never
|
|
307
|
+
export const fork: never
|
|
308
|
+
export const ChildProcess: never
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @deprecated node:os is not available in CRE WASM workflows. It requires OS access that is not available in WebAssembly.
|
|
313
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
314
|
+
*/
|
|
315
|
+
declare module 'node:os' {
|
|
316
|
+
export const hostname: never
|
|
317
|
+
export const platform: never
|
|
318
|
+
export const arch: never
|
|
319
|
+
export const type: never
|
|
320
|
+
export const release: never
|
|
321
|
+
export const version: never
|
|
322
|
+
export const machine: never
|
|
323
|
+
export const cpus: never
|
|
324
|
+
export const availableParallelism: never
|
|
325
|
+
export const freemem: never
|
|
326
|
+
export const totalmem: never
|
|
327
|
+
export const uptime: never
|
|
328
|
+
export const loadavg: never
|
|
329
|
+
export const homedir: never
|
|
330
|
+
export const tmpdir: never
|
|
331
|
+
export const userInfo: never
|
|
332
|
+
export const networkInterfaces: never
|
|
333
|
+
export const endianness: never
|
|
334
|
+
export const getPriority: never
|
|
335
|
+
export const setPriority: never
|
|
336
|
+
export const EOL: never
|
|
337
|
+
export const devNull: never
|
|
338
|
+
export const constants: never
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @deprecated node:stream is not available in CRE WASM workflows. It requires native bindings that cannot run in WebAssembly.
|
|
343
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
344
|
+
*/
|
|
345
|
+
declare module 'node:stream' {
|
|
346
|
+
export const Readable: never
|
|
347
|
+
export const Writable: never
|
|
348
|
+
export const Duplex: never
|
|
349
|
+
export const Transform: never
|
|
350
|
+
export const PassThrough: never
|
|
351
|
+
export const Stream: never
|
|
352
|
+
export const pipeline: never
|
|
353
|
+
export const finished: never
|
|
354
|
+
export const promises: never
|
|
355
|
+
export const addAbortSignal: never
|
|
356
|
+
export const compose: never
|
|
357
|
+
export const isErrored: never
|
|
358
|
+
export const isReadable: never
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated node:worker_threads is not available in CRE WASM workflows. It requires threading support that is not available in WebAssembly.
|
|
363
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
364
|
+
*/
|
|
365
|
+
declare module 'node:worker_threads' {
|
|
366
|
+
export const Worker: never
|
|
367
|
+
export const MessageChannel: never
|
|
368
|
+
export const MessagePort: never
|
|
369
|
+
export const BroadcastChannel: never
|
|
370
|
+
export const isMainThread: never
|
|
371
|
+
export const isInternalThread: never
|
|
372
|
+
export const parentPort: never
|
|
373
|
+
export const workerData: never
|
|
374
|
+
export const threadId: never
|
|
375
|
+
export const resourceLimits: never
|
|
376
|
+
export const SHARE_ENV: never
|
|
377
|
+
export const receiveMessageOnPort: never
|
|
378
|
+
export const moveMessagePortToContext: never
|
|
379
|
+
export const getEnvironmentData: never
|
|
380
|
+
export const setEnvironmentData: never
|
|
381
|
+
export const markAsUntransferable: never
|
|
382
|
+
export const markAsUncloneable: never
|
|
383
|
+
export const isMarkedAsUntransferable: never
|
|
384
|
+
export const postMessageToThread: never
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* @deprecated node:dns is not available in CRE WASM workflows. It requires network access that is not available in WebAssembly.
|
|
389
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
390
|
+
*/
|
|
391
|
+
declare module 'node:dns' {
|
|
392
|
+
export const lookup: never
|
|
393
|
+
export const lookupService: never
|
|
394
|
+
export const resolve: never
|
|
395
|
+
export const resolve4: never
|
|
396
|
+
export const resolve6: never
|
|
397
|
+
export const resolveCname: never
|
|
398
|
+
export const resolveMx: never
|
|
399
|
+
export const resolveNs: never
|
|
400
|
+
export const resolvePtr: never
|
|
401
|
+
export const resolveSrv: never
|
|
402
|
+
export const resolveTxt: never
|
|
403
|
+
export const resolveNaptr: never
|
|
404
|
+
export const resolveSoa: never
|
|
405
|
+
export const resolveAny: never
|
|
406
|
+
export const reverse: never
|
|
407
|
+
export const setServers: never
|
|
408
|
+
export const getServers: never
|
|
409
|
+
export const setDefaultResultOrder: never
|
|
410
|
+
export const getDefaultResultOrder: never
|
|
411
|
+
export const promises: never
|
|
412
|
+
export const Resolver: never
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* @deprecated node:zlib is not available in CRE WASM workflows. It requires native compression bindings that cannot run in WebAssembly.
|
|
417
|
+
* @see https://docs.chain.link/cre/concepts/typescript-wasm-runtime
|
|
418
|
+
*/
|
|
419
|
+
declare module 'node:zlib' {
|
|
420
|
+
export const createGzip: never
|
|
421
|
+
export const createGunzip: never
|
|
422
|
+
export const createDeflate: never
|
|
423
|
+
export const createInflate: never
|
|
424
|
+
export const createDeflateRaw: never
|
|
425
|
+
export const createInflateRaw: never
|
|
426
|
+
export const createUnzip: never
|
|
427
|
+
export const createBrotliCompress: never
|
|
428
|
+
export const createBrotliDecompress: never
|
|
429
|
+
export const createZstdCompress: never
|
|
430
|
+
export const createZstdDecompress: never
|
|
431
|
+
export const gzip: never
|
|
432
|
+
export const gzipSync: never
|
|
433
|
+
export const gunzip: never
|
|
434
|
+
export const gunzipSync: never
|
|
435
|
+
export const deflate: never
|
|
436
|
+
export const deflateSync: never
|
|
437
|
+
export const inflate: never
|
|
438
|
+
export const inflateSync: never
|
|
439
|
+
export const deflateRaw: never
|
|
440
|
+
export const deflateRawSync: never
|
|
441
|
+
export const inflateRaw: never
|
|
442
|
+
export const inflateRawSync: never
|
|
443
|
+
export const unzip: never
|
|
444
|
+
export const unzipSync: never
|
|
445
|
+
export const brotliCompress: never
|
|
446
|
+
export const brotliCompressSync: never
|
|
447
|
+
export const brotliDecompress: never
|
|
448
|
+
export const brotliDecompressSync: never
|
|
449
|
+
export const crc32: never
|
|
450
|
+
export const constants: never
|
|
451
|
+
export const Gzip: never
|
|
452
|
+
export const Gunzip: never
|
|
453
|
+
export const Deflate: never
|
|
454
|
+
export const Inflate: never
|
|
455
|
+
export const DeflateRaw: never
|
|
456
|
+
export const InflateRaw: never
|
|
457
|
+
export const Unzip: never
|
|
458
|
+
export const BrotliCompress: never
|
|
459
|
+
export const BrotliDecompress: never
|
|
460
|
+
export const ZstdCompress: never
|
|
461
|
+
export const ZstdDecompress: never
|
|
462
|
+
}
|
|
@@ -54,7 +54,7 @@ export declare const blockNumber: (n: number | bigint | string) => import("../..
|
|
|
54
54
|
* Using this constant will indicate that the call should be executed at the last finalized block.
|
|
55
55
|
*/
|
|
56
56
|
export declare const LAST_FINALIZED_BLOCK_NUMBER: {
|
|
57
|
-
absVal:
|
|
57
|
+
absVal: any;
|
|
58
58
|
sign: string;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
@@ -68,7 +68,7 @@ export declare const LAST_FINALIZED_BLOCK_NUMBER: {
|
|
|
68
68
|
* Using this constant will indicate that the call should be executed at the latest mined block.
|
|
69
69
|
*/
|
|
70
70
|
export declare const LATEST_BLOCK_NUMBER: {
|
|
71
|
-
absVal:
|
|
71
|
+
absVal: any;
|
|
72
72
|
sign: string;
|
|
73
73
|
};
|
|
74
74
|
export interface EncodeCallMsgPayload {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function is used to prepare the runtime for the SDK to work.
|
|
3
3
|
* It should be called as a part of SDK initialization.
|
|
4
|
-
* It exposes
|
|
4
|
+
* It exposes Node.js APIs in global namespace, so they can be bundled and used in workflow code.
|
|
5
5
|
*/
|
|
6
6
|
export declare const prepareRuntime: () => void;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
1
|
+
import { atob, Buffer, btoa } from 'node:buffer';
|
|
2
|
+
import { URL, URLSearchParams } from 'node:url';
|
|
2
3
|
/**
|
|
3
4
|
* This function is used to prepare the runtime for the SDK to work.
|
|
4
5
|
* It should be called as a part of SDK initialization.
|
|
5
|
-
* It exposes
|
|
6
|
+
* It exposes Node.js APIs in global namespace, so they can be bundled and used in workflow code.
|
|
6
7
|
*/
|
|
7
8
|
export const prepareRuntime = () => {
|
|
8
9
|
globalThis.Buffer = Buffer;
|
|
10
|
+
globalThis.atob = atob;
|
|
11
|
+
globalThis.btoa = btoa;
|
|
12
|
+
// node:url constructor types are slightly narrower than lib.dom/global types.
|
|
13
|
+
// Runtime behavior is compatible; cast to the global constructor shapes.
|
|
14
|
+
globalThis.URL = URL;
|
|
15
|
+
globalThis.URLSearchParams = URLSearchParams;
|
|
9
16
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Mode } from '../../generated/sdk/v1alpha/sdk_pb';
|
|
2
2
|
export declare const hostBindings: {
|
|
3
|
-
switchModes: (args_0: Mode, ...args: unknown[]) => void;
|
|
4
|
-
log: (args_0: string, ...args: unknown[]) => void;
|
|
5
|
-
sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
6
|
-
versionV2: (...args: unknown[]) => void;
|
|
7
3
|
callCapability: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
8
4
|
awaitCapabilities: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
|
|
9
5
|
getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
|
|
10
6
|
awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
|
|
7
|
+
log: (args_0: string, ...args: unknown[]) => void;
|
|
8
|
+
sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
|
|
9
|
+
switchModes: (args_0: Mode, ...args: unknown[]) => void;
|
|
10
|
+
versionV2: (...args: unknown[]) => void;
|
|
11
11
|
getWasiArgs: (...args: unknown[]) => string;
|
|
12
12
|
now: (...args: unknown[]) => number;
|
|
13
13
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/cre-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@bufbuild/protobuf": "2.6.3",
|
|
62
62
|
"@bufbuild/protoc-gen-es": "2.6.3",
|
|
63
|
-
"@chainlink/cre-sdk-javy-plugin": "1.
|
|
63
|
+
"@chainlink/cre-sdk-javy-plugin": "1.2.0",
|
|
64
64
|
"@standard-schema/spec": "1.0.0",
|
|
65
65
|
"viem": "2.34.0",
|
|
66
66
|
"zod": "3.25.76"
|
package/scripts/run.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
import { WorkflowRuntimeCompatibilityError } from './src/validate-workflow-runtime-compat'
|
|
4
|
+
|
|
3
5
|
const availableScripts = [
|
|
4
6
|
'build-types',
|
|
5
7
|
'compile-to-js',
|
|
@@ -37,7 +39,11 @@ const main = async () => {
|
|
|
37
39
|
process.exit(1)
|
|
38
40
|
}
|
|
39
41
|
} catch (error) {
|
|
40
|
-
|
|
42
|
+
if (error instanceof WorkflowRuntimeCompatibilityError) {
|
|
43
|
+
console.error(`\n❌ ${error.message}`)
|
|
44
|
+
} else {
|
|
45
|
+
console.error(`Failed to run script ${scriptName}:`, error)
|
|
46
|
+
}
|
|
41
47
|
process.exit(1)
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { glob } from 'fast-glob'
|
|
2
|
-
import { copyFile, mkdir } from 'fs/promises'
|
|
2
|
+
import { copyFile, mkdir, readFile, writeFile } from 'fs/promises'
|
|
3
3
|
import { join } from 'path'
|
|
4
4
|
|
|
5
5
|
const buildTypes = async () => {
|
|
@@ -28,6 +28,36 @@ const buildTypes = async () => {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
console.log(`✅ Copied ${typeFiles.length} type definition file(s) to dist/sdk/types`)
|
|
31
|
+
|
|
32
|
+
// Prepend triple-slash references to dist/index.d.ts so consumers pick up
|
|
33
|
+
// global type augmentations (e.g. restricted-apis.d.ts) automatically.
|
|
34
|
+
// tsc strips these from the emitted .d.ts, so we add them back here.
|
|
35
|
+
const indexDts = join(packageRoot, 'dist/index.d.ts')
|
|
36
|
+
const sourceIndex = join(packageRoot, 'src/index.ts')
|
|
37
|
+
const sourceContent = await readFile(sourceIndex, 'utf-8')
|
|
38
|
+
|
|
39
|
+
const refsFromSource = sourceContent
|
|
40
|
+
.split('\n')
|
|
41
|
+
.filter((line) => line.startsWith('/// <reference types='))
|
|
42
|
+
|
|
43
|
+
// Add references for consumer-only type declarations that cannot be in src/index.ts
|
|
44
|
+
// because they would break the SDK's own scripts/tests (which legitimately use Node.js APIs).
|
|
45
|
+
const consumerOnlyRefs = ['/// <reference types="./sdk/types/restricted-node-modules" />']
|
|
46
|
+
|
|
47
|
+
const tripleSlashRefs = [...refsFromSource, ...consumerOnlyRefs].join('\n')
|
|
48
|
+
|
|
49
|
+
if (tripleSlashRefs) {
|
|
50
|
+
const indexContent = await readFile(indexDts, 'utf-8')
|
|
51
|
+
// Strip any existing triple-slash references from the top of the file
|
|
52
|
+
// so that re-running build-types is idempotent.
|
|
53
|
+
const withoutExistingRefs = indexContent
|
|
54
|
+
.split('\n')
|
|
55
|
+
.filter((line) => !line.trim().startsWith('/// <reference types='))
|
|
56
|
+
.join('\n')
|
|
57
|
+
.replace(/^\n+/, '') // trim leading blank lines left after stripping
|
|
58
|
+
await writeFile(indexDts, `${tripleSlashRefs}\n${withoutExistingRefs}`)
|
|
59
|
+
console.log('✅ Added triple-slash references to dist/index.d.ts')
|
|
60
|
+
}
|
|
31
61
|
}
|
|
32
62
|
|
|
33
63
|
export const main = buildTypes
|
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
|
2
2
|
import { mkdir } from 'node:fs/promises'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { $ } from 'bun'
|
|
5
|
+
import { assertWorkflowRuntimeCompatibility } from './validate-workflow-runtime-compat'
|
|
5
6
|
import { wrapWorkflowCode } from './workflow-wrapper'
|
|
6
7
|
|
|
7
8
|
export const main = async (tsFilePath?: string, outputFilePath?: string) => {
|
|
@@ -19,6 +20,7 @@ export const main = async (tsFilePath?: string, outputFilePath?: string) => {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const resolvedInput = path.resolve(inputPath)
|
|
23
|
+
assertWorkflowRuntimeCompatibility(resolvedInput)
|
|
22
24
|
console.info(`📁 Using input file: ${resolvedInput}`)
|
|
23
25
|
|
|
24
26
|
// If no explicit output path → same dir, swap extension to .js
|
|
@@ -54,16 +56,13 @@ export const main = async (tsFilePath?: string, outputFilePath?: string) => {
|
|
|
54
56
|
naming: path.basename(resolvedOutput),
|
|
55
57
|
})
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!existsSync(builtFile)) {
|
|
61
|
-
console.error(`❌ Expected file not found: ${builtFile}`)
|
|
59
|
+
if (!existsSync(resolvedOutput)) {
|
|
60
|
+
console.error(`❌ Expected file not found: ${resolvedOutput}`)
|
|
62
61
|
process.exit(1)
|
|
63
62
|
}
|
|
64
63
|
|
|
65
64
|
// Bundle into the final file (overwrite)
|
|
66
|
-
await $`bun build ${
|
|
65
|
+
await $`bun build ${resolvedOutput} --bundle --outfile=${resolvedOutput}`
|
|
67
66
|
|
|
68
67
|
console.info(`✅ Built: ${resolvedOutput}`)
|
|
69
68
|
return resolvedOutput
|
|
@@ -41,9 +41,7 @@ export const main = async (inputFile?: string, outputWasmFile?: string) => {
|
|
|
41
41
|
await mkdir(path.dirname(resolvedJsOutput), { recursive: true })
|
|
42
42
|
|
|
43
43
|
console.info(`🚀 Compiling workflow`)
|
|
44
|
-
console.info(`📁 Input: ${resolvedInput}`)
|
|
45
|
-
console.info(`🧪 JS out: ${resolvedJsOutput}`)
|
|
46
|
-
console.info(`🎯 WASM out:${resolvedWasmOutput}\n`)
|
|
44
|
+
console.info(`📁 Input: ${resolvedInput}\n`)
|
|
47
45
|
|
|
48
46
|
// Step 1: TS/JS → JS (bundled)
|
|
49
47
|
console.info('📦 Step 1: Compiling JS...')
|
|
@@ -56,11 +54,3 @@ export const main = async (inputFile?: string, outputWasmFile?: string) => {
|
|
|
56
54
|
console.info(`\n✅ Workflow built: ${resolvedWasmOutput}`)
|
|
57
55
|
return resolvedWasmOutput
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
// Optional: allow direct CLI usage
|
|
61
|
-
if (import.meta.main) {
|
|
62
|
-
main().catch((e) => {
|
|
63
|
-
console.error(e)
|
|
64
|
-
process.exit(1)
|
|
65
|
-
})
|
|
66
|
-
}
|