1
1
import startCase from "lodash/startCase" ;
2
2
3
- export type ColumnType =
3
+ export type PrimitiveColumnType =
4
4
| "string"
5
5
| "primitive"
6
6
| "number"
@@ -9,6 +9,8 @@ export type ColumnType =
9
9
| "date-time"
10
10
| "uri" ;
11
11
12
+ export type ColumnType = PrimitiveColumnType | { kind : "array" , items : PrimitiveColumnType } ;
13
+
12
14
export type StringColumnValue = { type : "string" ; value ?: string } ;
13
15
14
16
export type ColumnParam = {
@@ -17,9 +19,12 @@ export type ColumnParam = {
17
19
type : ColumnType ;
18
20
} ;
19
21
22
+ export type PrimitiveValue = string | number | boolean ;
23
+
20
24
export type ColumnValue =
21
- | { type : "primitive" ; value ?: any }
25
+ | { type : "primitive" ; value ?: PrimitiveValue }
22
26
| { type : "number" ; value ?: number }
27
+ | { type : "boolean" ; value ?: boolean }
23
28
| StringColumnValue ;
24
29
25
30
export type Column = ( ...values : ColumnValue [ ] ) => any | Promise < any > ;
@@ -79,9 +84,12 @@ export type Category =
79
84
| "Date & Time"
80
85
| "Code" ;
81
86
87
+ type Released = "direct" | "sandboxed" ;
88
+
82
89
export type Manifest = {
83
90
name : string ;
84
91
category : Category ;
92
+ released ?: Released ;
85
93
description : string ;
86
94
author : string ;
87
95
params : ColumnParam [ ] ;
@@ -149,7 +157,7 @@ export function toStrictManifest(
149
157
) : Manifest {
150
158
// We carefully pick out just the props in manifest, because more
151
159
// could come in from the component.
152
- const { name, category, description, author, result, params, about, video } =
160
+ const { name, category, released , description, author, result, params, about, video } =
153
161
convenient ;
154
162
155
163
let { icon = defaultIcon } = convenient ;
@@ -160,6 +168,7 @@ export function toStrictManifest(
160
168
return {
161
169
name,
162
170
category,
171
+ released,
163
172
description,
164
173
author,
165
174
result,
@@ -176,6 +185,7 @@ export function toStrictManifest(
176
185
const defaultDefinition : ColumnDefinition = {
177
186
name : "Glide Column" ,
178
187
category : "General" ,
188
+ released : undefined ,
179
189
description : "No description" ,
180
190
author :
"Glide <[email protected] >" ,
181
191
params : { } ,
@@ -222,6 +232,10 @@ export class Col<TParams = {}, TResult = string> {
222
232
return this . with ( { category } ) ;
223
233
}
224
234
235
+ public withReleased ( released : "direct" | "sandboxed" ) {
236
+ return this . with ( { released } )
237
+ }
238
+
225
239
public withDescription ( description : string ) {
226
240
return this . with ( { description } ) ;
227
241
}
@@ -273,6 +287,18 @@ export class Col<TParams = {}, TResult = string> {
273
287
return this . withResult < boolean > ( "boolean" ) ;
274
288
}
275
289
290
+ public withStringArrayResult ( ) {
291
+ return this . withResult < string [ ] > ( { kind : "array" , items : "string" } ) ;
292
+ }
293
+
294
+ public withNumberArrayResult ( ) {
295
+ return this . withResult < number [ ] > ( { kind : "array" , items : "number" } ) ;
296
+ }
297
+
298
+ public withPrimitiveArrayResult ( ) {
299
+ return this . withResult < PrimitiveValue [ ] > ( { kind : "array" , items : "primitive" } ) ;
300
+ }
301
+
276
302
public withParam < TParam , TName extends string > (
277
303
type : ColumnType ,
278
304
name : TName ,
@@ -341,6 +367,22 @@ export class Col<TParams = {}, TResult = string> {
341
367
return this . withRequiredParam < number , T > ( "number" , name , displayName ) ;
342
368
}
343
369
370
+ public withStringArrayParam < T extends string > ( name : T , displayName ?: string ) {
371
+ return this . withParam < string [ ] , T > ( { kind : "array" , items : "string" } , name , displayName ) ;
372
+ }
373
+
374
+ public withNumberArrayParam < T extends string > ( name : T , displayName ?: string ) {
375
+ return this . withParam < number [ ] , T > ( { kind : "array" , items : "number" } , name , displayName ) ;
376
+ }
377
+
378
+ public withPrimitiveArrayParam < T extends string > ( name : T , displayName ?: string ) {
379
+ return this . withParam < PrimitiveValue [ ] , T > ( { kind : "array" , items : "primitive" } , name , displayName ) ;
380
+ }
381
+
382
+ public withExample ( example : TParams ) {
383
+ return this . with ( { example } ) ;
384
+ }
385
+
344
386
public run (
345
387
columnFunction : (
346
388
params : TParams
0 commit comments