windmill-ts 0.7.1 → 0.7.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-ts",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Type-safe client for Windmill",
5
5
  "main": "dist/src/index.js",
6
6
  "bin": "dist/src/index.js",
@@ -5,7 +5,7 @@ const preamble = dedent `
5
5
  // This file is auto-generated by windmill-ts, do not modify it manually
6
6
  import { z } from 'zod';
7
7
  import * as wmill from 'windmill-client';
8
- import { AsyncLocalStorage } from 'node:async_hooks';
8
+ import type { AsyncLocalStorage } from 'node:async_hooks';
9
9
  ${
10
10
  /* NOTE: Windmill has JSX enabled, so <T> is illegal.
11
11
  The usual way to fix this is <T,>, but some formatters/editors
@@ -28,24 +28,35 @@ const preamble = dedent `
28
28
  }) as T;
29
29
  }
30
30
 
31
- const ${envStorageName} = new AsyncLocalStorage<Record<string, string | undefined>>();
31
+ let ${envStorageName}: AsyncLocalStorage<Record<string, string | undefined>> | null = null;
32
32
 
33
- const originalProcessEnv = process.env;
34
- process.env = new Proxy(originalProcessEnv, {
35
- get: (target, prop, receiver) => {
36
- const store = ${envStorageName}.getStore();
37
- if (store != null && prop in store && typeof prop === 'string') {
38
- return store[prop];
39
- }
33
+ if (typeof process !== 'undefined') {
34
+ const { AsyncLocalStorage } = await import('node:async_hooks');
35
+ ${envStorageName} = new AsyncLocalStorage();
36
+
37
+ const originalProcessEnv = process.env;
38
+ process.env = new Proxy(originalProcessEnv, {
39
+ get: (target, prop, receiver) => {
40
+ const store = ${envStorageName}!.getStore();
41
+ if (store != null && prop in store && typeof prop === 'string') {
42
+ return store[prop];
43
+ }
40
44
 
41
- return Reflect.get(target, prop, receiver);
42
- },
43
- set: (target, prop, value, receiver) => {
44
- return Reflect.set(target, prop, value, receiver);
45
- }
46
- })
45
+ return Reflect.get(target, prop, receiver);
46
+ },
47
+ set: (target, prop, value, receiver) => {
48
+ return Reflect.set(target, prop, value, receiver);
49
+ }
50
+ })
51
+ }
47
52
 
48
53
  export const runDetached = async <T extends unknown>(cb: () => Promise<T>) => {
54
+ if (${envStorageName} == null) {
55
+ console.warn("Calling \`runDetached\` in a non-Node environment is unsupported.");
56
+
57
+ return cb();
58
+ }
59
+
49
60
  return ${envStorageName}.run(
50
61
  { WM_JOB_ID: undefined, WM_ROOT_FLOW_JOB_ID: undefined },
51
62
  () => cb(),
@@ -1 +1 @@
1
- {"version":3,"file":"preamble.js","sourceRoot":"","sources":["../../../src/generator/preamble.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,QAAQ,GAAG,MAAM,CAAA;;;;;IAKnB;AACA;;qEAEqE,CAAC,EACxE;;;;;;;;;;;;;;;;;;;UAmBQ,cAAc;;;;;sBAKF,cAAc;;;;;;;;;;;;;aAavB,cAAc;;;;;CAK1B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,EAAG,CAAC;IAEhC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC,CAAC"}
1
+ {"version":3,"file":"preamble.js","sourceRoot":"","sources":["../../../src/generator/preamble.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,YAAY,CAAC;AAE3C,MAAM,QAAQ,GAAG,MAAM,CAAA;;;;;IAKnB;AACA;;qEAEqE,CAAC,EACxE;;;;;;;;;;;;;;;;;;;QAmBM,cAAc;;;;MAIhB,cAAc;;;;;wBAKI,cAAc;;;;;;;;;;;;;;UAc5B,cAAc;;;;;;aAMX,cAAc;;;;;CAK1B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,EAAG,CAAC;IAEhC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windmill-ts",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Type-safe client for Windmill",
5
5
  "main": "dist/src/index.js",
6
6
  "bin": "dist/src/index.js",