windmill-ts 0.7.0 → 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
|
@@ -14,6 +14,7 @@ const preamble = dedent `
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
type RunFlowAsyncOptions = {
|
|
17
|
+
scheduledFor?: Date | null;
|
|
17
18
|
detached?: boolean;
|
|
18
19
|
};
|
|
19
20
|
|
|
@@ -22,14 +23,20 @@ const preamble = dedent `
|
|
|
22
23
|
args: z.input<(typeof ${mapName})[Path]>,
|
|
23
24
|
options?: RunFlowAsyncOptions,
|
|
24
25
|
) => {
|
|
25
|
-
const { detached = false } = options ?? {};
|
|
26
|
+
const { scheduledFor, detached = false } = options ?? {};
|
|
26
27
|
const schema = ${mapName}[flowPath];
|
|
27
28
|
|
|
28
29
|
const runner = detached
|
|
29
30
|
? runDetached
|
|
30
31
|
: <T extends unknown>(cb: () => Promise<T>) => cb();
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const scheduledInSeconds = Math.ceil(
|
|
34
|
+
Math.max((scheduledFor?.getTime() ?? 0) - Date.now(), 0) / 1000,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return runner(
|
|
38
|
+
() => wmill.runFlowAsync(flowPath, schema.parse(args), scheduledInSeconds)
|
|
39
|
+
);
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
export const getFlowArgsSchema = <Path extends keyof typeof ${mapName}>(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.js","sourceRoot":"","sources":["../../../src/generator/flows.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,QAAQ,GAAG,MAAM,CAAA;sDAC+B,OAAO;;4BAEjC,OAAO;;qBAEd,OAAO
|
|
1
|
+
{"version":3,"file":"flows.js","sourceRoot":"","sources":["../../../src/generator/flows.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,QAAQ,GAAG,MAAM,CAAA;sDAC+B,OAAO;;4BAEjC,OAAO;;qBAEd,OAAO;;;;;;;;;;2DAU+B,OAAO;;4BAEtC,OAAO;;;;qBAId,OAAO;;;;;;;;;;;;;;;gEAeoC,OAAO;;;aAG1D,OAAO;;;wCAGoB,OAAO;CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,QAAkB,EAAE,EAAE;IACxD,MAAM,EAAE,KAAK,EAAE,GAAG,UAAU,EAAG,CAAC;IAEhC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEtB,OAAO,eAAe,CAAC;QACrB,SAAS,EAAE,SAAS,EAAE;QACtB,OAAO;QACP,QAAQ;KACT,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -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
|
-
|
|
31
|
+
let ${envStorageName}: AsyncLocalStorage<Record<string, string | undefined>> | null = null;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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;;;;;;;;;;;;;;;;;;;
|
|
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"}
|