@aztec/foundation 0.0.1-commit.3fd054f6 → 0.0.1-commit.431c48d
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/dest/bigint-buffer/index.d.ts +1 -1
- package/dest/bigint-buffer/index.d.ts.map +1 -1
- package/dest/bigint-buffer/index.js +6 -1
- package/dest/branded-types/block_number.d.ts +3 -3
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +15 -4
- package/dest/branded-types/buffer32_hash.d.ts +27 -0
- package/dest/branded-types/buffer32_hash.d.ts.map +1 -0
- package/dest/branded-types/buffer32_hash.js +12 -0
- package/dest/branded-types/checkpoint_number.d.ts +9 -3
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +11 -0
- package/dest/branded-types/epoch.d.ts +2 -2
- package/dest/branded-types/epoch.d.ts.map +1 -1
- package/dest/branded-types/index.d.ts +2 -1
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +1 -0
- package/dest/branded-types/index_within_checkpoint.d.ts +2 -2
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -1
- package/dest/branded-types/slot.d.ts +2 -2
- package/dest/branded-types/slot.d.ts.map +1 -1
- package/dest/buffer/buffer16.d.ts +3 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer32.d.ts +28 -61
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +29 -63
- package/dest/collection/array.d.ts +11 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +33 -0
- package/dest/collection/index.d.ts +3 -1
- package/dest/collection/index.d.ts.map +1 -1
- package/dest/collection/index.js +2 -0
- package/dest/collection/lru_map.d.ts +41 -0
- package/dest/collection/lru_map.d.ts.map +1 -0
- package/dest/collection/lru_map.js +119 -0
- package/dest/collection/lru_set.d.ts +35 -0
- package/dest/collection/lru_set.d.ts.map +1 -0
- package/dest/collection/lru_set.js +95 -0
- package/dest/committable/committable.js +1 -1
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +67 -37
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +72 -71
- package/dest/config/network_config.d.ts +11 -55
- package/dest/config/network_config.d.ts.map +1 -1
- package/dest/config/network_name.d.ts +2 -2
- package/dest/config/network_name.d.ts.map +1 -1
- package/dest/config/network_name.js +1 -3
- package/dest/config/secret_value.d.ts +2 -2
- package/dest/config/secret_value.d.ts.map +1 -1
- package/dest/crypto/aes128/index.d.ts +2 -1
- package/dest/crypto/aes128/index.d.ts.map +1 -1
- package/dest/crypto/aes128/index.js +11 -2
- package/dest/crypto/bls/bn254_keystore.d.ts +10 -177
- package/dest/crypto/bls/bn254_keystore.d.ts.map +1 -1
- package/dest/crypto/bls/bn254_keystore.js +22 -34
- package/dest/crypto/poseidon/index.d.ts +1 -1
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +40 -33
- package/dest/crypto/schnorr/index.d.ts +8 -7
- package/dest/crypto/schnorr/index.d.ts.map +1 -1
- package/dest/crypto/schnorr/index.js +6 -6
- package/dest/crypto/schnorr/signature.d.ts +9 -29
- package/dest/crypto/schnorr/signature.d.ts.map +1 -1
- package/dest/crypto/schnorr/signature.js +20 -36
- package/dest/curves/bls12/field.d.ts +3 -3
- package/dest/curves/bls12/field.d.ts.map +1 -1
- package/dest/curves/bls12/field.js +0 -5
- package/dest/curves/bls12/point.d.ts +2 -2
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bn254/field.d.ts +23 -19
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +23 -17
- package/dest/curves/grumpkin/point.d.ts +14 -28
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/curves/grumpkin/point.js +29 -43
- package/dest/eth-address/index.d.ts +2 -2
- package/dest/eth-address/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +0 -3
- package/dest/eth-signature/eth_signature.d.ts +2 -2
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/fifo_set/fifo_set.d.ts +15 -0
- package/dest/fifo_set/fifo_set.d.ts.map +1 -0
- package/dest/fifo_set/fifo_set.js +39 -0
- package/dest/fifo_set/index.d.ts +2 -0
- package/dest/fifo_set/index.d.ts.map +1 -0
- package/dest/fifo_set/index.js +1 -0
- package/dest/iterable/first.d.ts +8 -0
- package/dest/iterable/first.d.ts.map +1 -0
- package/dest/iterable/first.js +11 -0
- package/dest/iterable/index.d.ts +2 -1
- package/dest/iterable/index.d.ts.map +1 -1
- package/dest/iterable/index.js +1 -0
- package/dest/json-rpc/client/fetch.d.ts +8 -3
- package/dest/json-rpc/client/fetch.d.ts.map +1 -1
- package/dest/json-rpc/client/fetch.js +11 -7
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.d.ts.map +1 -1
- package/dest/json-rpc/client/safe_json_rpc_client.js +2 -2
- package/dest/json-rpc/client/undici.d.ts +14 -3
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +47 -14
- package/dest/json-rpc/fixtures/test_state.d.ts +4 -8
- package/dest/json-rpc/fixtures/test_state.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/test_state.js +57 -17
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts +49 -11
- package/dest/json-rpc/server/safe_json_rpc_server.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +159 -40
- package/dest/log/aws-logger-config.d.ts +8 -0
- package/dest/log/aws-logger-config.d.ts.map +1 -0
- package/dest/log/aws-logger-config.js +55 -0
- package/dest/log/pino-logger.d.ts +1 -1
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +29 -8
- package/dest/noir/noir_package_config.d.ts +19 -104
- package/dest/noir/noir_package_config.d.ts.map +1 -1
- package/dest/noir/noir_package_config.js +1 -1
- package/dest/promise/running-promise.d.ts +8 -2
- package/dest/promise/running-promise.d.ts.map +1 -1
- package/dest/promise/running-promise.js +17 -5
- package/dest/promise/utils.d.ts +14 -1
- package/dest/promise/utils.d.ts.map +1 -1
- package/dest/promise/utils.js +20 -0
- package/dest/queue/batch_queue.d.ts +1 -1
- package/dest/queue/batch_queue.d.ts.map +1 -1
- package/dest/queue/batch_queue.js +1 -0
- package/dest/retry/index.d.ts +31 -3
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +44 -2
- package/dest/schemas/api.d.ts +12 -10
- package/dest/schemas/api.d.ts.map +1 -1
- package/dest/schemas/api.js +7 -1
- package/dest/schemas/parse.d.ts +4 -4
- package/dest/schemas/parse.d.ts.map +1 -1
- package/dest/schemas/parse.js +6 -5
- package/dest/schemas/schemas.d.ts +15 -15
- package/dest/schemas/types.d.ts +3 -3
- package/dest/schemas/types.d.ts.map +1 -1
- package/dest/schemas/utils.d.ts +7 -11
- package/dest/schemas/utils.d.ts.map +1 -1
- package/dest/schemas/utils.js +2 -18
- package/dest/serialize/buffer_reader.d.ts +1 -1
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +5 -0
- package/dest/serialize/buffer_sink.d.ts +134 -0
- package/dest/serialize/buffer_sink.d.ts.map +1 -0
- package/dest/serialize/buffer_sink.js +297 -0
- package/dest/serialize/index.d.ts +2 -1
- package/dest/serialize/index.d.ts.map +1 -1
- package/dest/serialize/index.js +1 -0
- package/dest/serialize/serialize.d.ts +1 -32
- package/dest/serialize/serialize.d.ts.map +1 -1
- package/dest/serialize/serialize.js +0 -21
- package/dest/string/index.js +1 -1
- package/dest/testing/files/index.d.ts +2 -3
- package/dest/testing/files/index.d.ts.map +1 -1
- package/dest/testing/files/index.js +1 -2
- package/dest/timer/index.d.ts +2 -2
- package/dest/timer/index.d.ts.map +1 -1
- package/dest/timer/index.js +1 -1
- package/dest/timer/timeout.d.ts +3 -1
- package/dest/timer/timeout.d.ts.map +1 -1
- package/dest/timer/timeout.js +26 -0
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts +11 -2
- package/dest/transport/dispatch/create_dispatch_proxy.d.ts.map +1 -1
- package/dest/transport/index.d.ts +1 -2
- package/dest/transport/index.d.ts.map +1 -1
- package/dest/transport/index.js +0 -1
- package/dest/trees/balanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/balanced_merkle_tree_root.js +2 -3
- package/dest/trees/hasher.d.ts +3 -2
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +5 -5
- package/dest/trees/indexed_merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/indexed_merkle_tree_calculator.js +5 -1
- package/dest/trees/membership_witness.d.ts +2 -6
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +0 -9
- package/dest/trees/merkle_tree_calculator.d.ts +4 -2
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +1 -5
- package/dest/trees/sibling_path.d.ts +13 -14
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +23 -28
- package/dest/trees/unbalanced_merkle_tree_root.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_root.js +2 -3
- package/dest/types/index.d.ts +23 -1
- package/dest/types/index.d.ts.map +1 -1
- package/dest/types/index.js +15 -0
- package/package.json +5 -4
- package/src/bigint-buffer/index.ts +6 -1
- package/src/branded-types/block_number.ts +20 -2
- package/src/branded-types/buffer32_hash.ts +38 -0
- package/src/branded-types/checkpoint_number.ts +16 -1
- package/src/branded-types/epoch.ts +1 -1
- package/src/branded-types/index.ts +1 -0
- package/src/branded-types/index_within_checkpoint.ts +1 -1
- package/src/branded-types/slot.ts +1 -1
- package/src/buffer/buffer16.ts +3 -0
- package/src/buffer/buffer32.ts +39 -68
- package/src/collection/array.ts +34 -0
- package/src/collection/index.ts +2 -0
- package/src/collection/lru_map.ts +143 -0
- package/src/collection/lru_set.ts +115 -0
- package/src/committable/committable.ts +1 -1
- package/src/config/env_var.ts +52 -24
- package/src/config/index.ts +143 -122
- package/src/config/network_name.ts +2 -5
- package/src/config/secret_value.ts +1 -1
- package/src/crypto/aes128/index.ts +11 -2
- package/src/crypto/bls/bn254_keystore.ts +33 -43
- package/src/crypto/poseidon/index.ts +42 -34
- package/src/crypto/schnorr/index.ts +9 -8
- package/src/crypto/schnorr/signature.ts +17 -46
- package/src/curves/bls12/field.ts +0 -7
- package/src/curves/bn254/field.ts +35 -34
- package/src/curves/grumpkin/point.ts +23 -40
- package/src/eth-address/index.ts +0 -4
- package/src/fifo_set/fifo_set.ts +52 -0
- package/src/fifo_set/index.ts +1 -0
- package/src/iterable/first.ts +14 -0
- package/src/iterable/index.ts +1 -0
- package/src/json-rpc/client/fetch.ts +19 -5
- package/src/json-rpc/client/safe_json_rpc_client.ts +2 -2
- package/src/json-rpc/client/undici.ts +54 -12
- package/src/json-rpc/fixtures/test_state.ts +10 -10
- package/src/json-rpc/server/safe_json_rpc_server.ts +204 -47
- package/src/log/aws-logger-config.ts +32 -0
- package/src/log/pino-logger.ts +33 -6
- package/src/noir/noir_package_config.ts +32 -20
- package/src/promise/running-promise.ts +20 -7
- package/src/promise/utils.ts +31 -0
- package/src/queue/batch_queue.ts +1 -0
- package/src/retry/index.ts +66 -4
- package/src/schemas/api.ts +25 -25
- package/src/schemas/parse.ts +9 -6
- package/src/schemas/schemas.ts +4 -4
- package/src/schemas/types.ts +2 -2
- package/src/schemas/utils.ts +4 -38
- package/src/serialize/buffer_reader.ts +5 -0
- package/src/serialize/buffer_sink.ts +350 -0
- package/src/serialize/index.ts +1 -0
- package/src/serialize/serialize.ts +0 -50
- package/src/string/index.ts +1 -1
- package/src/testing/files/index.ts +1 -2
- package/src/timer/index.ts +1 -1
- package/src/timer/timeout.ts +31 -0
- package/src/transport/dispatch/create_dispatch_proxy.ts +11 -1
- package/src/transport/index.ts +0 -1
- package/src/trees/balanced_merkle_tree_root.ts +2 -5
- package/src/trees/hasher.ts +6 -3
- package/src/trees/indexed_merkle_tree_calculator.ts +5 -1
- package/src/trees/membership_witness.ts +0 -8
- package/src/trees/merkle_tree_calculator.ts +4 -10
- package/src/trees/sibling_path.ts +24 -30
- package/src/trees/unbalanced_merkle_tree_root.ts +2 -5
- package/src/types/index.ts +47 -0
- package/dest/crypto/serialize.d.ts +0 -51
- package/dest/crypto/serialize.d.ts.map +0 -1
- package/dest/crypto/serialize.js +0 -68
- package/dest/transport/dispatch/create_dispatch_fn.d.ts +0 -25
- package/dest/transport/dispatch/create_dispatch_fn.d.ts.map +0 -1
- package/dest/transport/dispatch/create_dispatch_fn.js +0 -17
- package/src/crypto/serialize.ts +0 -85
- package/src/transport/dispatch/create_dispatch_fn.ts +0 -35
|
@@ -3,111 +3,10 @@ declare const noirGitDependencySchema: z.ZodObject<{
|
|
|
3
3
|
git: z.ZodString;
|
|
4
4
|
tag: z.ZodString;
|
|
5
5
|
directory: z.ZodOptional<z.ZodString>;
|
|
6
|
-
},
|
|
7
|
-
git: string;
|
|
8
|
-
tag: string;
|
|
9
|
-
directory?: string | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
git: string;
|
|
12
|
-
tag: string;
|
|
13
|
-
directory?: string | undefined;
|
|
14
|
-
}>;
|
|
6
|
+
}, z.core.$strip>;
|
|
15
7
|
declare const noirLocalDependencySchema: z.ZodObject<{
|
|
16
8
|
path: z.ZodString;
|
|
17
|
-
},
|
|
18
|
-
path: string;
|
|
19
|
-
}, {
|
|
20
|
-
path: string;
|
|
21
|
-
}>;
|
|
22
|
-
declare const noirPackageConfigSchema: z.ZodObject<{
|
|
23
|
-
package: z.ZodObject<{
|
|
24
|
-
name: z.ZodDefault<z.ZodString>;
|
|
25
|
-
type: z.ZodDefault<z.ZodEnum<["lib", "contract", "bin"]>>;
|
|
26
|
-
entry: z.ZodOptional<z.ZodString>;
|
|
27
|
-
description: z.ZodOptional<z.ZodString>;
|
|
28
|
-
authors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
29
|
-
compiler_version: z.ZodOptional<z.ZodString>;
|
|
30
|
-
backend: z.ZodOptional<z.ZodString>;
|
|
31
|
-
license: z.ZodOptional<z.ZodString>;
|
|
32
|
-
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
name: string;
|
|
34
|
-
type: "bin" | "contract" | "lib";
|
|
35
|
-
entry?: string | undefined;
|
|
36
|
-
description?: string | undefined;
|
|
37
|
-
authors?: string[] | undefined;
|
|
38
|
-
compiler_version?: string | undefined;
|
|
39
|
-
backend?: string | undefined;
|
|
40
|
-
license?: string | undefined;
|
|
41
|
-
}, {
|
|
42
|
-
name?: string | undefined;
|
|
43
|
-
type?: "bin" | "contract" | "lib" | undefined;
|
|
44
|
-
entry?: string | undefined;
|
|
45
|
-
description?: string | undefined;
|
|
46
|
-
authors?: string[] | undefined;
|
|
47
|
-
compiler_version?: string | undefined;
|
|
48
|
-
backend?: string | undefined;
|
|
49
|
-
license?: string | undefined;
|
|
50
|
-
}>;
|
|
51
|
-
dependencies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
|
|
52
|
-
git: z.ZodString;
|
|
53
|
-
tag: z.ZodString;
|
|
54
|
-
directory: z.ZodOptional<z.ZodString>;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
git: string;
|
|
57
|
-
tag: string;
|
|
58
|
-
directory?: string | undefined;
|
|
59
|
-
}, {
|
|
60
|
-
git: string;
|
|
61
|
-
tag: string;
|
|
62
|
-
directory?: string | undefined;
|
|
63
|
-
}>, z.ZodObject<{
|
|
64
|
-
path: z.ZodString;
|
|
65
|
-
}, "strip", z.ZodTypeAny, {
|
|
66
|
-
path: string;
|
|
67
|
-
}, {
|
|
68
|
-
path: string;
|
|
69
|
-
}>]>>>;
|
|
70
|
-
}, "strip", z.ZodTypeAny, {
|
|
71
|
-
package: {
|
|
72
|
-
name: string;
|
|
73
|
-
type: "bin" | "contract" | "lib";
|
|
74
|
-
entry?: string | undefined;
|
|
75
|
-
description?: string | undefined;
|
|
76
|
-
authors?: string[] | undefined;
|
|
77
|
-
compiler_version?: string | undefined;
|
|
78
|
-
backend?: string | undefined;
|
|
79
|
-
license?: string | undefined;
|
|
80
|
-
};
|
|
81
|
-
dependencies: Record<string, {
|
|
82
|
-
git: string;
|
|
83
|
-
tag: string;
|
|
84
|
-
directory?: string | undefined;
|
|
85
|
-
} | {
|
|
86
|
-
path: string;
|
|
87
|
-
}>;
|
|
88
|
-
}, {
|
|
89
|
-
package: {
|
|
90
|
-
name?: string | undefined;
|
|
91
|
-
type?: "bin" | "contract" | "lib" | undefined;
|
|
92
|
-
entry?: string | undefined;
|
|
93
|
-
description?: string | undefined;
|
|
94
|
-
authors?: string[] | undefined;
|
|
95
|
-
compiler_version?: string | undefined;
|
|
96
|
-
backend?: string | undefined;
|
|
97
|
-
license?: string | undefined;
|
|
98
|
-
};
|
|
99
|
-
dependencies?: Record<string, {
|
|
100
|
-
git: string;
|
|
101
|
-
tag: string;
|
|
102
|
-
directory?: string | undefined;
|
|
103
|
-
} | {
|
|
104
|
-
path: string;
|
|
105
|
-
}> | undefined;
|
|
106
|
-
}>;
|
|
107
|
-
/**
|
|
108
|
-
* Noir package configuration.
|
|
109
|
-
*/
|
|
110
|
-
export type NoirPackageConfig = z.infer<typeof noirPackageConfigSchema>;
|
|
9
|
+
}, z.core.$strip>;
|
|
111
10
|
/**
|
|
112
11
|
* A remote package dependency.
|
|
113
12
|
*/
|
|
@@ -120,10 +19,26 @@ export type NoirLocalDependencyConfig = z.infer<typeof noirLocalDependencySchema
|
|
|
120
19
|
* A package dependency.
|
|
121
20
|
*/
|
|
122
21
|
export type NoirDependencyConfig = NoirGitDependencyConfig | NoirLocalDependencyConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Noir package configuration.
|
|
24
|
+
*/
|
|
25
|
+
export type NoirPackageConfig = {
|
|
26
|
+
package: {
|
|
27
|
+
name: string;
|
|
28
|
+
type: 'lib' | 'contract' | 'bin';
|
|
29
|
+
entry?: string | undefined;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
authors?: string[] | undefined;
|
|
32
|
+
compiler_version?: string | undefined;
|
|
33
|
+
backend?: string | undefined;
|
|
34
|
+
license?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
dependencies: Record<string, NoirDependencyConfig>;
|
|
37
|
+
};
|
|
123
38
|
/**
|
|
124
39
|
* Checks that an object is a package configuration.
|
|
125
40
|
* @param config - Config to check
|
|
126
41
|
*/
|
|
127
42
|
export declare function parseNoirPackageConfig(config: any): NoirPackageConfig;
|
|
128
43
|
export {};
|
|
129
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibm9pcl9wYWNrYWdlX2NvbmZpZy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL25vaXIvbm9pcl9wYWNrYWdlX2NvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRXhCLFFBQUEsTUFBTSx1QkFBdUI7Ozs7aUJBSTNCLENBQUM7QUFFSCxRQUFBLE1BQU0seUJBQXlCOztpQkFFN0IsQ0FBQztBQUVIOztHQUVHO0FBQ0gsTUFBTSxNQUFNLHVCQUF1QixHQUFHLENBQUMsQ0FBQyxLQUFLLENBQUMsT0FBTyx1QkFBdUIsQ0FBQyxDQUFDO0FBRTlFOztHQUVHO0FBQ0gsTUFBTSxNQUFNLHlCQUF5QixHQUFHLENBQUMsQ0FBQyxLQUFLLENBQUMsT0FBTyx5QkFBeUIsQ0FBQyxDQUFDO0FBRWxGOztHQUVHO0FBQ0gsTUFBTSxNQUFNLG9CQUFvQixHQUFHLHVCQUF1QixHQUFHLHlCQUF5QixDQUFDO0FBRXZGOztHQUVHO0FBQ0gsTUFBTSxNQUFNLGlCQUFpQixHQUFHO0lBQzlCLE9BQU8sRUFBRTtRQUNQLElBQUksRUFBRSxNQUFNLENBQUM7UUFDYixJQUFJLEVBQUUsS0FBSyxHQUFHLFVBQVUsR0FBRyxLQUFLLENBQUM7UUFDakMsS0FBSyxDQUFDLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztRQUMzQixXQUFXLENBQUMsRUFBRSxNQUFNLEdBQUcsU0FBUyxDQUFDO1FBQ2pDLE9BQU8sQ0FBQyxFQUFFLE1BQU0sRUFBRSxHQUFHLFNBQVMsQ0FBQztRQUMvQixnQkFBZ0IsQ0FBQyxFQUFFLE1BQU0sR0FBRyxTQUFTLENBQUM7UUFDdEMsT0FBTyxDQUFDLEVBQUUsTUFBTSxHQUFHLFNBQVMsQ0FBQztRQUM3QixPQUFPLENBQUMsRUFBRSxNQUFNLEdBQUcsU0FBUyxDQUFDO0tBQzlCLENBQUM7SUFDRixZQUFZLEVBQUUsTUFBTSxDQUFDLE1BQU0sRUFBRSxvQkFBb0IsQ0FBQyxDQUFDO0NBQ3BELENBQUM7QUFpQkY7OztHQUdHO0FBQ0gsd0JBQWdCLHNCQUFzQixDQUFDLE1BQU0sRUFBRSxHQUFHLEdBQUcsaUJBQWlCLENBRXJFIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noir_package_config.d.ts","sourceRoot":"","sources":["../../src/noir/noir_package_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"noir_package_config.d.ts","sourceRoot":"","sources":["../../src/noir/noir_package_config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,uBAAuB;;;;iBAI3B,CAAC;AAEH,QAAA,MAAM,yBAAyB;;iBAE7B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAElF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,GAAG,yBAAyB,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,KAAK,GAAG,UAAU,GAAG,KAAK,CAAC;QACjC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC9B,CAAC;IACF,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACpD,CAAC;AAiBF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,iBAAiB,CAErE"}
|
|
@@ -23,7 +23,7 @@ const noirPackageConfigSchema = z.object({
|
|
|
23
23
|
backend: z.string().optional(),
|
|
24
24
|
license: z.string().optional()
|
|
25
25
|
}),
|
|
26
|
-
dependencies: z.record(z.union([
|
|
26
|
+
dependencies: z.record(z.string(), z.union([
|
|
27
27
|
noirGitDependencySchema,
|
|
28
28
|
noirLocalDependencySchema
|
|
29
29
|
])).default({})
|
|
@@ -34,7 +34,13 @@ export declare class RunningPromise {
|
|
|
34
34
|
isRunning(): boolean;
|
|
35
35
|
/**
|
|
36
36
|
* Triggers an immediate run of the function, bypassing the polling interval.
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* Resolves only after a complete run of the function that *started after* this call: a run already in flight is
|
|
39
|
+
* allowed to finish first, and the function is then called again. Concurrent callers coalesce onto a single such
|
|
40
|
+
* run. Rejects if the loop stops (via `stop()` or an error handler requesting exit) before that run happens.
|
|
41
|
+
*
|
|
42
|
+
* Calling this from inside the function itself and awaiting the result deadlocks, since the awaited run cannot
|
|
43
|
+
* start until the current one returns. That usage is not supported.
|
|
38
44
|
*/
|
|
39
45
|
trigger(): Promise<void>;
|
|
40
46
|
/**
|
|
@@ -44,4 +50,4 @@ export declare class RunningPromise {
|
|
|
44
50
|
setPollingIntervalMS(pollingIntervalMS: number): void;
|
|
45
51
|
}
|
|
46
52
|
export {};
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmluZy1wcm9taXNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJvbWlzZS9ydW5uaW5nLXByb21pc2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssTUFBTSxFQUFnQixNQUFNLHVCQUF1QixDQUFDO0FBSWxFLFFBQUEsTUFBTSxJQUFJLGVBQW9DLENBQUM7QUFFL0MsTUFBTSxNQUFNLFlBQVksR0FBRyxDQUFDLEdBQUcsRUFBRSxPQUFPLEtBQUssT0FBTyxJQUFJLEdBQUcsSUFBSSxHQUFHLE9BQU8sQ0FBQyxPQUFPLElBQUksR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1
|
-
{"version":3,"file":"running-promise.d.ts","sourceRoot":"","sources":["../../src/promise/running-promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"running-promise.d.ts","sourceRoot":"","sources":["../../src/promise/running-promise.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,QAAA,MAAM,IAAI,eAAoC,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC;AAE9F,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,GAAG,aAAa,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,EAAE,GAClD,YAAY,CAMd;AAED;;;;GAIG;AACH,qBAAa,cAAc;IASvB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,iBAAiB;IACzB,OAAO,CAAC,WAAW;IAXrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAqB;IAC3C,OAAO,CAAC,kBAAkB,CAA4B;IACtD,OAAO,CAAC,SAAS,CAAqD;IAEtE,gBAAuB,IAAI,EAAE,OAAO,IAAI,CAAQ;IAEhD,YACU,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC9B,MAAM,SAAkC,EACxC,iBAAiB,SAAQ,EACzB,WAAW,GAAE,YAA8C,EACjE;IAEJ;;OAEG;IACI,KAAK,SAwCX;IAED;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAO1B;IAED;;;OAGG;IACI,SAAS,YAEf;IAED;;;;;;;;;OASG;IACU,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAYpC;IAED;;;OAGG;IACH,oBAAoB,CAAC,iBAAiB,EAAE,MAAM,QAE7C;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InterruptError } from '../error/index.js';
|
|
1
2
|
import { createLogger } from '../log/pino-logger.js';
|
|
2
3
|
import { InterruptibleSleep } from '../sleep/index.js';
|
|
3
4
|
import { promiseWithResolvers } from './utils.js';
|
|
@@ -43,7 +44,8 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
43
44
|
this.running = true;
|
|
44
45
|
const poll = async ()=>{
|
|
45
46
|
while(this.running){
|
|
46
|
-
const
|
|
47
|
+
const requested = this.requested;
|
|
48
|
+
this.requested = undefined;
|
|
47
49
|
try {
|
|
48
50
|
await this.fn();
|
|
49
51
|
} catch (err) {
|
|
@@ -56,15 +58,19 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
// If an immediate run had been requested *before* the function started running, resolve the request.
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
this.requested = undefined;
|
|
61
|
+
if (requested) {
|
|
62
|
+
requested.resolve();
|
|
62
63
|
}
|
|
63
64
|
// If no immediate run was requested, sleep for the polling interval.
|
|
64
65
|
if (this.requested === undefined && this.running) {
|
|
65
66
|
await this.interruptibleSleep.sleep(this.pollingIntervalMS);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
// A trigger that arrived after the final pass started will never be served by any pass, so settle it as
|
|
70
|
+
// failed rather than leaving its caller waiting forever.
|
|
71
|
+
const unserved = this.requested;
|
|
72
|
+
this.requested = undefined;
|
|
73
|
+
unserved?.reject(new InterruptError('RunningPromise stopped before serving trigger'));
|
|
68
74
|
};
|
|
69
75
|
this.runningPromise = poll();
|
|
70
76
|
return this;
|
|
@@ -88,7 +94,13 @@ export function makeLoggingErrorHandler(logger, ...ignoredErrors) {
|
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* Triggers an immediate run of the function, bypassing the polling interval.
|
|
91
|
-
*
|
|
97
|
+
*
|
|
98
|
+
* Resolves only after a complete run of the function that *started after* this call: a run already in flight is
|
|
99
|
+
* allowed to finish first, and the function is then called again. Concurrent callers coalesce onto a single such
|
|
100
|
+
* run. Rejects if the loop stops (via `stop()` or an error handler requesting exit) before that run happens.
|
|
101
|
+
*
|
|
102
|
+
* Calling this from inside the function itself and awaiting the result deadlocks, since the awaited run cannot
|
|
103
|
+
* start until the current one returns. That usage is not supported.
|
|
92
104
|
*/ async trigger() {
|
|
93
105
|
if (!this.running) {
|
|
94
106
|
return this.fn();
|
package/dest/promise/utils.d.ts
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like `Promise.all`, but runs every promise to completion before resolving or rejecting.
|
|
3
|
+
*
|
|
4
|
+
* `Promise.all` rejects as soon as one input rejects, abandoning the still-running siblings. When those siblings have
|
|
5
|
+
* side effects, the caller observes the rejection and reacts to the failure while the abandoned work is still
|
|
6
|
+
* producing effects. This helper instead guarantees that by the time it rejects, no input is still running.
|
|
7
|
+
*
|
|
8
|
+
* The signature mirrors `Promise.all`'s declaration in TypeScript's standard library, so call sites type exactly as
|
|
9
|
+
* they did with `Promise.all` (in particular, heterogeneous tuples keep their per-position types).
|
|
10
|
+
*/
|
|
11
|
+
export declare function allToCompletion<T extends readonly unknown[] | []>(promises: T): Promise<{
|
|
12
|
+
-readonly [P in keyof T]: Awaited<T[P]>;
|
|
13
|
+
}>;
|
|
1
14
|
export type PromiseWithResolvers<T> = {
|
|
2
15
|
promise: Promise<T>;
|
|
3
16
|
resolve: (value: T) => void;
|
|
@@ -9,4 +22,4 @@ export type PromiseWithResolvers<T> = {
|
|
|
9
22
|
* @returns A promise with resolvers.
|
|
10
23
|
*/
|
|
11
24
|
export declare function promiseWithResolvers<T>(): PromiseWithResolvers<T>;
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid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AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,KAAK,oBAAoB,CAAC,CAAC,CAAC,CAiBjE"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/promise/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GAAG,EAAE,EACrE,QAAQ,EAAE,CAAC,GACV,OAAO,CAAC;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAiBtD;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAChC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,KAAK,oBAAoB,CAAC,CAAC,CAAC,CAiBjE"}
|
package/dest/promise/utils.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like `Promise.all`, but runs every promise to completion before resolving or rejecting.
|
|
3
|
+
*
|
|
4
|
+
* `Promise.all` rejects as soon as one input rejects, abandoning the still-running siblings. When those siblings have
|
|
5
|
+
* side effects, the caller observes the rejection and reacts to the failure while the abandoned work is still
|
|
6
|
+
* producing effects. This helper instead guarantees that by the time it rejects, no input is still running.
|
|
7
|
+
*
|
|
8
|
+
* The signature mirrors `Promise.all`'s declaration in TypeScript's standard library, so call sites type exactly as
|
|
9
|
+
* they did with `Promise.all` (in particular, heterogeneous tuples keep their per-position types).
|
|
10
|
+
*/ export async function allToCompletion(promises) {
|
|
11
|
+
const results = await Promise.allSettled(promises);
|
|
12
|
+
const failures = results.filter((result)=>result.status === 'rejected');
|
|
13
|
+
if (failures.length === 1) {
|
|
14
|
+
// Rethrow a lone failure as-is so error identity is preserved for callers that inspect error types.
|
|
15
|
+
throw failures[0].reason;
|
|
16
|
+
} else if (failures.length > 1) {
|
|
17
|
+
throw new AggregateError(failures.map((failure)=>failure.reason), `${failures.length} of ${results.length} concurrent operations failed: ${failures.map((failure)=>failure.reason instanceof Error ? failure.reason.message : String(failure.reason)).join(' | ')}`);
|
|
18
|
+
}
|
|
19
|
+
return results.map((result)=>result.value);
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
22
|
* A polyfill for the Promise.withResolvers proposed API.
|
|
3
23
|
* @see https://github.com/tc39/proposal-promise-with-resolvers
|
|
@@ -44,4 +44,4 @@ export declare class BatchQueue<T, K extends string | number> {
|
|
|
44
44
|
stop(): Promise<void>;
|
|
45
45
|
private execProcessor;
|
|
46
46
|
}
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
47
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmF0Y2hfcXVldWUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWV1ZS9iYXRjaF9xdWV1ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFXQTs7Ozs7Ozs7Ozs7Ozs7R0FjRztBQUNILHFCQUFhLFVBQVUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxTQUFTLE1BQU0sR0FBRyxNQUFNO0lBTWhELE9BQU8sQ0FBQyxZQUFZO0lBQ3BCLE9BQU8sQ0FBQyxZQUFZO0lBQ3BCLE9BQU8sQ0FBQyxnQkFBZ0I7SUFDeEIsT0FBTyxDQUFDLEdBQUc7SUFSYixPQUFPLENBQUMsU0FBUyxDQUFzQztJQUN2RCxPQUFPLENBQUMsWUFBWSxDQUFDLENBQWM7SUFDbkMsT0FBTyxDQUFDLGNBQWMsQ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,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,GAAG,yCAAyC,EAClD;IAEJ;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzC;IAED;;OAEG;IACI,iBAAiB,aAOtB;IAEF;;OAEG;IACI,KAAK,SAMX;IAED;;;OAGG;IACI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"batch_queue.d.ts","sourceRoot":"","sources":["../../src/queue/batch_queue.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM;IAMhD,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,GAAG;IARb,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,YAAY,CAAC,CAAc;IACnC,OAAO,CAAC,cAAc,CAAC,CAAgB;IAEvC,YACU,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/D,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,GAAG,yCAAyC,EAClD;IAEJ;;;;;OAKG;IACI,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BzC;IAED;;OAEG;IACI,iBAAiB,aAOtB;IAEF;;OAEG;IACI,KAAK,SAMX;IAED;;;OAGG;IACI,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3B;IAED,OAAO,CAAC,aAAa,CAOnB;CACH"}
|
package/dest/retry/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Logger } from '../log/index.js';
|
|
2
|
+
import { type DateProvider } from '../timer/index.js';
|
|
2
3
|
/** An error that indicates that the operation should not be retried. */
|
|
3
4
|
export declare class NoRetryError extends Error {
|
|
4
5
|
}
|
|
@@ -30,6 +31,19 @@ export declare function makeBackoff(retries: number[]): Generator<number, void,
|
|
|
30
31
|
* @throws If `NoRetryError` is thrown by the `fn`, it is rethrown.
|
|
31
32
|
*/
|
|
32
33
|
export declare function retry<Result>(fn: () => Promise<Result>, name?: string, backoff?: Generator<number, void, unknown>, log?: Logger, failSilently?: boolean): Promise<Result>;
|
|
34
|
+
/**
|
|
35
|
+
* Timeout specification accepted by {@link retryUntil}. Either a plain number of seconds, an explicit
|
|
36
|
+
* `{ timeout }` in seconds, or an absolute `{ deadline }` with an optional {@link DateProvider} used to
|
|
37
|
+
* read the current time. A deadline is converted to the remaining seconds at call time; a deadline that
|
|
38
|
+
* has already passed yields a zero remaining budget, matching the immediate-timeout semantics of a
|
|
39
|
+
* non-positive numeric timeout.
|
|
40
|
+
*/
|
|
41
|
+
export type RetryUntilTimeout = number | {
|
|
42
|
+
timeout: number;
|
|
43
|
+
} | {
|
|
44
|
+
deadline: Date;
|
|
45
|
+
dateProvider?: DateProvider;
|
|
46
|
+
};
|
|
33
47
|
/**
|
|
34
48
|
* Retry an asynchronous function until it returns a truthy value or the specified timeout is exceeded.
|
|
35
49
|
* The function is retried periodically with a fixed interval between attempts. The operation can be named for better error messages.
|
|
@@ -37,11 +51,25 @@ export declare function retry<Result>(fn: () => Promise<Result>, name?: string,
|
|
|
37
51
|
*
|
|
38
52
|
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
39
53
|
* @param name - The optional name of the operation, used for generating timeout error message.
|
|
40
|
-
* @param timeout - The
|
|
54
|
+
* @param timeout - The maximum time to keep retrying before throwing a timeout error. Accepts a number of
|
|
55
|
+
* seconds (0 = never time out), an explicit `{ timeout }` in seconds, or an absolute `{ deadline }` with an
|
|
56
|
+
* optional `dateProvider`. A deadline already in the past times out on the first interval, the same as a
|
|
57
|
+
* zero/negative numeric timeout. Defaults to 0 (never timeout).
|
|
41
58
|
* @param interval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
42
59
|
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if timeout is exceeded.
|
|
43
60
|
*/
|
|
44
|
-
export declare function retryUntil<T>(fn: () => (T | undefined) | Promise<T | undefined>, name?: string, timeout?:
|
|
61
|
+
export declare function retryUntil<T>(fn: () => (T | undefined) | Promise<T | undefined>, name?: string, timeout?: RetryUntilTimeout, interval?: number): Promise<NonNullable<Awaited<T>>>;
|
|
62
|
+
/**
|
|
63
|
+
* Retry an asynchronous function until it returns a truthy value or the maximum number of retries is exceeded.
|
|
64
|
+
* The function is retried periodically with a fixed interval between attempts.
|
|
65
|
+
*
|
|
66
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
67
|
+
* @param name - The optional name of the operation, used for generating error messages.
|
|
68
|
+
* @param maxRetries - The maximum number of retry attempts before throwing an error.
|
|
69
|
+
* @param retryInterval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
70
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if retries are exhausted.
|
|
71
|
+
*/
|
|
72
|
+
export declare function retryTimes<T>(fn: () => (T | undefined) | Promise<T | undefined>, name: string | undefined, maxRetries: number, retryInterval?: number): Promise<NonNullable<Awaited<T>>>;
|
|
45
73
|
/**
|
|
46
74
|
* Convenience wrapper around retryUntil with fast polling for tests.
|
|
47
75
|
* Uses 10s timeout and 100ms polling interval by default.
|
|
@@ -52,4 +80,4 @@ export declare function retryUntil<T>(fn: () => (T | undefined) | Promise<T | un
|
|
|
52
80
|
* @param interval - Optional interval in seconds. Defaults to 0.1s (100ms).
|
|
53
81
|
*/
|
|
54
82
|
export declare function retryFastUntil<T>(fn: () => (T | undefined) | Promise<T | undefined>, name?: string, timeout?: number, interval?: number): Promise<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UMsQ0FBQyxFQUNoQyxFQUFFLEVBQUUsTUFBTSxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUMsR0FBRyxPQUFPLENBQUMsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxFQUNsRCxJQUFJLFNBQUssRUFDVCxPQUFPLEdBQUUsaUJBQXFCLEVBQzlCLFFBQVEsU0FBSSxvQ0FnQmI7QUFFRDs7Ozs7Ozs7O0dBU0c7QUFDSCx3QkFBc0IsVUFBVSxDQUFDLENBQUMsRUFDaEMsRUFBRSxFQUFFLE1BQU0sQ0FBQyxDQUFDLEdBQUcsU0FBUyxDQUFDLEdBQUcsT0FBTyxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUMsRUFDbEQsSUFBSSxvQkFBSyxFQUNULFVBQVUsRUFBRSxNQUFNLEVBQ2xCLGFBQWEsU0FBSSxvQ0FjbEI7QUFFRDs7Ozs7Ozs7R0FRRztBQUNILHdCQUFnQixjQUFjLENBQUMsQ0FBQyxFQUM5QixFQUFFLEVBQUUsTUFBTSxDQUFDLENBQUMsR0FBRyxTQUFTLENBQUMsR0FBRyxPQUFPLENBQUMsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxFQUNsRCxJQUFJLFNBQUssRUFDVCxPQUFPLFNBQUssRUFDWixRQUFRLFNBQU0sb0NBR2YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/retry/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/retry/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,mBAAmB,CAAC;AAE7D,wEAAwE;AACxE,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAE1C;;;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|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolves a {@link RetryUntilTimeout} to a numeric timeout in seconds for the legacy timer-based loop.
|
|
73
|
+
* A numeric/`{ timeout }` value passes through unchanged (0 means never time out, negative times out on the
|
|
74
|
+
* first interval). A `{ deadline }` is the remaining seconds until the deadline; when the deadline is already
|
|
75
|
+
* at or past `now` it resolves to a negative value so the loop times out immediately instead of being read as
|
|
76
|
+
* the never-timeout sentinel 0.
|
|
77
|
+
*/ function resolveRetryUntilTimeoutSeconds(timeout) {
|
|
78
|
+
if (typeof timeout === 'number') {
|
|
79
|
+
return timeout;
|
|
80
|
+
}
|
|
81
|
+
if ('deadline' in timeout) {
|
|
82
|
+
const now = timeout.dateProvider?.now() ?? Date.now();
|
|
83
|
+
const remainingSeconds = (timeout.deadline.getTime() - now) / 1000;
|
|
84
|
+
return remainingSeconds > 0 ? remainingSeconds : -1;
|
|
85
|
+
}
|
|
86
|
+
return timeout.timeout;
|
|
87
|
+
}
|
|
71
88
|
/**
|
|
72
89
|
* Retry an asynchronous function until it returns a truthy value or the specified timeout is exceeded.
|
|
73
90
|
* The function is retried periodically with a fixed interval between attempts. The operation can be named for better error messages.
|
|
@@ -75,10 +92,14 @@ import { Timer } from '../timer/index.js';
|
|
|
75
92
|
*
|
|
76
93
|
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
77
94
|
* @param name - The optional name of the operation, used for generating timeout error message.
|
|
78
|
-
* @param timeout - The
|
|
95
|
+
* @param timeout - The maximum time to keep retrying before throwing a timeout error. Accepts a number of
|
|
96
|
+
* seconds (0 = never time out), an explicit `{ timeout }` in seconds, or an absolute `{ deadline }` with an
|
|
97
|
+
* optional `dateProvider`. A deadline already in the past times out on the first interval, the same as a
|
|
98
|
+
* zero/negative numeric timeout. Defaults to 0 (never timeout).
|
|
79
99
|
* @param interval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
80
100
|
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if timeout is exceeded.
|
|
81
101
|
*/ export async function retryUntil(fn, name = '', timeout = 0, interval = 1) {
|
|
102
|
+
const timeoutSeconds = resolveRetryUntilTimeoutSeconds(timeout);
|
|
82
103
|
const timer = new Timer();
|
|
83
104
|
while(true){
|
|
84
105
|
const result = await fn();
|
|
@@ -86,11 +107,32 @@ import { Timer } from '../timer/index.js';
|
|
|
86
107
|
return result;
|
|
87
108
|
}
|
|
88
109
|
await sleep(interval * 1000);
|
|
89
|
-
if (
|
|
110
|
+
if (timeoutSeconds && timer.s() > timeoutSeconds) {
|
|
90
111
|
throw new TimeoutError(name ? `Timeout awaiting ${name}` : 'Timeout');
|
|
91
112
|
}
|
|
92
113
|
}
|
|
93
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Retry an asynchronous function until it returns a truthy value or the maximum number of retries is exceeded.
|
|
117
|
+
* The function is retried periodically with a fixed interval between attempts.
|
|
118
|
+
*
|
|
119
|
+
* @param fn - The asynchronous function to be retried, which should return a truthy value upon success or undefined otherwise.
|
|
120
|
+
* @param name - The optional name of the operation, used for generating error messages.
|
|
121
|
+
* @param maxRetries - The maximum number of retry attempts before throwing an error.
|
|
122
|
+
* @param retryInterval - The optional interval, in seconds, between retry attempts. Defaults to 1 second.
|
|
123
|
+
* @returns A Promise that resolves with the successful (truthy) result of the provided function, or rejects if retries are exhausted.
|
|
124
|
+
*/ export async function retryTimes(fn, name = '', maxRetries, retryInterval = 1) {
|
|
125
|
+
for(let attempt = 0; attempt <= maxRetries; attempt++){
|
|
126
|
+
const result = await fn();
|
|
127
|
+
if (result) {
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
if (attempt < maxRetries) {
|
|
131
|
+
await sleep(retryInterval * 1000);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
throw new Error(name ? `Retries exhausted awaiting ${name}` : 'Retries exhausted');
|
|
135
|
+
}
|
|
94
136
|
/**
|
|
95
137
|
* Convenience wrapper around retryUntil with fast polling for tests.
|
|
96
138
|
* Uses 10s timeout and 100ms polling interval by default.
|
package/dest/schemas/api.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { ZodNullableOptional } from './utils.js';
|
|
3
|
-
type ZodParameterTypeFor<T> = undefined extends T ? ZodNullableOptional<z.ZodType<T,
|
|
4
|
-
type ZodReturnTypeFor<T> = z.ZodType<T,
|
|
5
|
-
type ZodMapParameterTypes<T
|
|
6
|
-
[K in keyof
|
|
7
|
-
}
|
|
8
|
-
[K in keyof Rest]: ZodParameterTypeFor<Rest[K]>;
|
|
9
|
-
}] : never;
|
|
3
|
+
type ZodParameterTypeFor<T> = undefined extends T ? ZodNullableOptional<z.ZodType<T, any>> : z.ZodType<T, any>;
|
|
4
|
+
type ZodReturnTypeFor<T> = z.ZodType<T, any>;
|
|
5
|
+
type ZodMapParameterTypes<T extends readonly unknown[]> = {
|
|
6
|
+
[K in keyof T]-?: ZodParameterTypeFor<T[K]>;
|
|
7
|
+
};
|
|
10
8
|
/** Maps all functions in an interface to their schema representation. */
|
|
11
9
|
export type ApiSchemaFor<T> = {
|
|
12
|
-
[K in keyof T]: T[K] extends (...args: infer Args) => Promise<infer Ret> ? z.ZodFunction<z.ZodTuple<ZodMapParameterTypes<Args>,
|
|
10
|
+
[K in keyof T]: T[K] extends (...args: infer Args) => Promise<infer Ret> ? z.ZodFunction<z.ZodTuple<ZodMapParameterTypes<Args>, null>, ZodReturnTypeFor<Ret>> : never;
|
|
13
11
|
};
|
|
14
12
|
/** Generic Api schema not bounded to a specific implementation. */
|
|
15
13
|
export type ApiSchema = {
|
|
16
14
|
[key: string]: z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>;
|
|
17
15
|
};
|
|
18
16
|
/** Return whether an API schema defines a valid function schema for a given method name. */
|
|
19
|
-
export declare function schemaHasMethod(schema:
|
|
17
|
+
export declare function schemaHasMethod<T extends ApiSchema>(schema: T, methodName: string): methodName is Extract<keyof T, string>;
|
|
18
|
+
/** Returns the parameter tuple schema for an API method schema. */
|
|
19
|
+
export declare function getSchemaParameters<T extends z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>(schema: T): z.ZodTuple<any, any>;
|
|
20
|
+
/** Returns the return value schema for an API method schema. */
|
|
21
|
+
export declare function getSchemaReturnType<T extends z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>(schema: T): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
20
22
|
export {};
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBpLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2NoZW1hcy9hcGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRTdCLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sWUFBWSxDQUFDO0FBR3RELEtBQUssbUJBQW1CLENBQUMsQ0FBQyxJQUFJLFNBQVMsU0FBUyxDQUFDLEdBQUcsbUJBQW1CLENBQUMsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsR0FBRyxDQUFDLENBQUMsR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUUvRyxLQUFLLGdCQUFnQixDQUFDLENBQUMsSUFBSSxDQUFDLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxHQUFHLENBQUMsQ0FBQztBQUU3QyxLQUFLLG9CQUFvQixDQUFDLENBQUMsU0FBUyxTQUFTLE9BQU8sRUFBRSxJQUFJO0tBQ3ZELENBQUMsSUFBSSxNQUFNLENBQUMs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dBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQyx3QkFFekc7QUFFRCxnRUFBZ0U7QUFDaEUsd0JBQWdCLG1CQUFtQixDQUFDLENBQUMsU0FBUyxDQUFDLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQywyRUFFekcifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/schemas/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtD,KAAK,mBAAmB,CAAC,CAAC,IAAI,SAAS,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/schemas/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGtD,KAAK,mBAAmB,CAAC,CAAC,IAAI,SAAS,SAAS,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAE/G,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAE7C,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,IAAI;KACvD,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC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valid function schema for a given method name. */ export function schemaHasMethod(schema, methodName) {
|
|
2
|
-
return typeof methodName === 'string' && Object.hasOwn(schema, methodName) &&
|
|
2
|
+
return typeof methodName === 'string' && Object.hasOwn(schema, methodName) && schema[methodName].def.input !== undefined && schema[methodName].def.output !== undefined;
|
|
3
|
+
}
|
|
4
|
+
/** Returns the parameter tuple schema for an API method schema. */ export function getSchemaParameters(schema) {
|
|
5
|
+
return schema.def.input;
|
|
6
|
+
}
|
|
7
|
+
/** Returns the return value schema for an API method schema. */ export function getSchemaReturnType(schema) {
|
|
8
|
+
return schema.def.output;
|
|
3
9
|
}
|
package/dest/schemas/parse.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/** Parses the given arguments using a tuple from the provided schemas. */
|
|
3
|
-
export declare function parse<T extends [] | [z.ZodTypeAny, ...z.ZodTypeAny[]]>(args: IArguments, ...schemas: T):
|
|
3
|
+
export declare function parse<T extends [] | [z.ZodTypeAny, ...z.ZodTypeAny[]]>(args: IArguments, ...schemas: T): [];
|
|
4
4
|
/**
|
|
5
5
|
* Parses the given arguments against a tuple, allowing empty for optional items.
|
|
6
|
-
* @dev Zod doesn't like
|
|
6
|
+
* @dev Zod doesn't like tuples with optional items. See https://github.com/colinhacks/zod/discussions/949.
|
|
7
7
|
*/
|
|
8
|
-
export declare function parseWithOptionals<T extends z.
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
export declare function parseWithOptionals<T extends z.ZodTuple<any, any>>(args: any[], schema: T): Promise<z.output<T>>;
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2UuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zY2hlbWFzL3BhcnNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxDQUFDLEVBQUUsTUFBTSxLQUFLLENBQUM7QUFJeEIsMEVBQTBFO0FBQzFFLHdCQUFnQixLQUFLLENBQUMsQ0FBQyxTQUFTLEVBQUUsR0FBRyxDQUFDLENBQUMsQ0FBQyxVQUFVLEVBQUUsR0FBRyxDQUFDLENBQUMsVUFBVSxFQUFFLENBQUMsRUFBRSxJQUFJLEVBQUUsVUFBVSxFQUFFLEdBQUcsT0FBTyxFQUFFLENBQUMsTUFJdEc7QUFFRDs7O0dBR0c7QUFDSCx3QkFBZ0Isa0JBQWtCLENBQUMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxRQUFRLENBQUMsR0FBRyxFQUFFLEdBQUcsQ0FBQyxFQUFFLElBQUksRUFBRSxHQUFHLEVBQUUsRUFBRSxNQUFNLEVBQUUsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBTy9HIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/schemas/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/schemas/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,EAAE,CAAC,MAItG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAO/G"}
|
package/dest/schemas/parse.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { times } from '../collection/array.js';
|
|
3
3
|
/** Parses the given arguments using a tuple from the provided schemas. */ export function parse(args, ...schemas) {
|
|
4
|
-
return z.tuple(schemas).parse(args);
|
|
4
|
+
return schemas.length === 0 ? z.tuple([]).parse(args) : z.tuple(schemas).parse(args);
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Parses the given arguments against a tuple, allowing empty for optional items.
|
|
8
|
-
* @dev Zod doesn't like
|
|
8
|
+
* @dev Zod doesn't like tuples with optional items. See https://github.com/colinhacks/zod/discussions/949.
|
|
9
9
|
*/ export function parseWithOptionals(args, schema) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const items = schema.def.items;
|
|
11
|
+
const missingCount = items.length - args.length;
|
|
12
|
+
const optionalCount = items.filter(isOptional).length;
|
|
12
13
|
const toParse = missingCount > 0 && missingCount <= optionalCount ? args.concat(times(missingCount, ()=>undefined)) : args;
|
|
13
14
|
return schema.parseAsync(toParse);
|
|
14
15
|
}
|
|
@@ -17,6 +18,6 @@ function isOptional(schema) {
|
|
|
17
18
|
return schema.isOptional();
|
|
18
19
|
} catch {
|
|
19
20
|
// See https://github.com/colinhacks/zod/issues/1911
|
|
20
|
-
return schema.
|
|
21
|
+
return schema.def.type === 'optional';
|
|
21
22
|
}
|
|
22
23
|
}
|