@sr-connect/runtime-types
v2.1.0
Published
Types for ScriptRunner Connect runtime
Keywords
Readme
@sr-connect/runtime-types
TypeScript declarations for the globals available inside the ScriptRunner Connect script runtime.
The package ships a single index.d.ts and no runtime code. It is consumed by the ScriptRunner Connect code editor and by the local development tooling, so scripts get type checking and autocompletion for everything the runtime injects on top of the language itself.
What the runtime provides
Scripts run against ECMAScript 2020 (lib: ["es2020"] in tsconfig.json). There is no DOM and no Node.js standard library. require() does not exist and process.env is always empty; environment variables come from context.environment.vars.
On top of the core language the runtime adds these globals, all declared in this package:
consolewithlog,debug,info,warn,error,trace,assert, counters, timers and groups. Output goes to the invocation logs.fetch()together withRequest,Response,Headers,Blob,FormData,URLandURLSearchParams.RequestInit.agentaccepts TLS client certificates and custom CA bundles. The whole response body is downloaded before the promise resolves.crypto(also reachable aswindow.crypto) withgetRandomValues()and a subset ofSubtleCrypto: key generation, import, export,signandverify. Encryption, digests and key derivation are not implemented.TextEncoderandTextDecoder.setTimeout,clearTimeout,setInterval,clearInterval,btoa,atobandperformance.now().ServiceError, thrown by the runtime and the managed API clients when a service call fails, andAbortProcess.AbortControllerandAbortSignalas stubs: they track state and notify listeners, butfetch()ignoressignal, so aborting never cancels a request.Context, the object passed to the script entry point as its second argument. It carries the invocation id, start time, timeout, available memory, environment details and variables, trigger type, deployment info and queue details for queued invocations.
Where behaviour differs from browsers or Node.js the JSDoc on the declaration says so. Examples: performance.now() returns seconds, Headers matches names case-insensitively but keeps the casing each name was first set with instead of lower-casing it, and a Body can be read once.
