retoolrpc 0.1.5 → 0.1.6

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/src/types.ts CHANGED
@@ -36,11 +36,17 @@ export type ArgumentType = 'string' | 'boolean' | 'number' | 'dict' | 'json'
36
36
  export type Argument = {
37
37
  /** The type of the argument. */
38
38
  type: ArgumentType
39
- /** Specifies whether the argument is expected to be an array. */
39
+ /**
40
+ * Specifies whether the argument is expected to be an array.
41
+ * @default false
42
+ */
40
43
  array?: boolean
41
44
  /** The description of the argument. */
42
45
  description?: string
43
- /** Specifies whether the argument is required. */
46
+ /**
47
+ * Specifies whether the argument is required.
48
+ * @default false
49
+ */
44
50
  required?: boolean
45
51
  }
46
52
 
@@ -68,10 +74,18 @@ export type TransformedArgument<TArg extends Argument> = TArg['array'] extends t
68
74
  ? Array<ArgumentTypeMap<TArg>>
69
75
  : ArgumentTypeMap<TArg>
70
76
 
77
+ type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
78
+ type GetOptionalArgs<TArgs extends Arguments> = {
79
+ [TArg in keyof TArgs]: TArgs[TArg]['required'] extends true ? never : TArg
80
+ }[keyof TArgs]
81
+
71
82
  /** Represents a map of argument names to argument types. */
72
- export type TransformedArguments<TArgs extends Arguments> = {
73
- [TArg in keyof TArgs]: TransformedArgument<TArgs[TArg]>
74
- }
83
+ export type TransformedArguments<TArgs extends Arguments> = PartialBy<
84
+ {
85
+ [TArg in keyof TArgs]: TransformedArgument<TArgs[TArg]>
86
+ },
87
+ GetOptionalArgs<TArgs>
88
+ >
75
89
 
76
90
  /** Represents the specification for registering a Retool function. */
77
91
  export type RegisterFunctionSpec<TArgs extends Arguments, TReturn> = {
@@ -6,7 +6,8 @@ const CONNECTION_ERROR_RETRY_MAX_MS = 1000 * 60 * 10 // 10 minutes
6
6
 
7
7
  function sleep(ms: number): Promise<void> {
8
8
  return new Promise((resolve) => {
9
- setTimeout(resolve, ms)
9
+ const timeout = setTimeout(resolve, ms)
10
+ timeout.unref()
10
11
  })
11
12
  }
12
13
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RetoolRPCVersion = '0.1.5'
1
+ export const RetoolRPCVersion = '0.1.6'
package/tsconfig.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "skipLibCheck": true,
13
13
  "esModuleInterop": true,
14
14
  "allowSyntheticDefaultImports": true,
15
+ "lib": ["ESNext"]
15
16
  },
16
17
  "ts-node": {
17
18
  // these options are overrides used only by ts-node
@@ -19,5 +20,5 @@
19
20
  "compilerOptions": {
20
21
  "module": "commonjs"
21
22
  }
22
- },
23
+ }
23
24
  }