@appsemble/types 0.20.6 → 0.20.9

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +113 -37
  2. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -165,6 +165,49 @@ export interface TokenResponse {
165
165
  refresh_token?: string;
166
166
  token_type: 'bearer';
167
167
  }
168
+ interface BaseICSRemapper {
169
+ /**
170
+ * The start of the icalendar event.
171
+ */
172
+ start: Remapper;
173
+ /**
174
+ * The title of the event.
175
+ */
176
+ title: Remapper;
177
+ /**
178
+ * An optional description of the event.
179
+ */
180
+ description?: Remapper;
181
+ /**
182
+ * An optional link to attach to the event.
183
+ */
184
+ url?: Remapper;
185
+ /**
186
+ * An optional location description to attach to the event.
187
+ */
188
+ location?: Remapper;
189
+ /**
190
+ * An optional geolocation description to attach to the event.
191
+ *
192
+ * This must be an object with the properties `lat` or `latitude`, and `lon`, `lng` or
193
+ * `longitude`.
194
+ */
195
+ coordinates?: Remapper;
196
+ }
197
+ interface DurationICSRemapper extends BaseICSRemapper {
198
+ /**
199
+ * The duration of the event.
200
+ *
201
+ * @example '1w 3d 10h 30m'
202
+ */
203
+ duration: Remapper;
204
+ }
205
+ interface EndTimeICSRemapper extends BaseICSRemapper {
206
+ /**
207
+ * The end time of the event as a date or a date string.
208
+ */
209
+ end: Remapper;
210
+ }
168
211
  export interface Remappers {
169
212
  /**
170
213
  * Get app metadata.
@@ -207,6 +250,18 @@ export interface Remappers {
207
250
  * Returns `true` if all entries are equal, otherwise `false`.
208
251
  */
209
252
  equals: Remapper[];
253
+ /**
254
+ * Compares the first computed remapper value with the second computed remapper value.
255
+ *
256
+ * Returns `true` of the first entry is greater than the second entry.
257
+ */
258
+ gt: [Remapper, Remapper];
259
+ /**
260
+ * Compares the first computed remapper value with the second computed remapper value.
261
+ *
262
+ * Returns `true` of the first entry is less than the second entry.
263
+ */
264
+ lt: [Remapper, Remapper];
210
265
  /**
211
266
  * Builds an array based on the given data and remappers.
212
267
  *
@@ -229,41 +284,7 @@ export interface Remappers {
229
284
  /**
230
285
  * Create an icalendar event.
231
286
  */
232
- ics: {
233
- /**
234
- * The start of the icalendar event.
235
- */
236
- start: Remapper;
237
- /**
238
- * The duration of the event.
239
- *
240
- * @example '1w 3d 10h 30m'
241
- */
242
- duration: Remapper;
243
- /**
244
- * The title of the event.
245
- */
246
- title: Remapper;
247
- /**
248
- * An optional description of the event.
249
- */
250
- description?: Remapper;
251
- /**
252
- * An optional link to attach to the event.
253
- */
254
- url?: Remapper;
255
- /**
256
- * An optional location description to attach to the event.
257
- */
258
- location?: Remapper;
259
- /**
260
- * An optional geolocation description to attach to the event.
261
- *
262
- * This must be an object with the properties `lat` or `latitude`, and `lon`, `lng` or
263
- * `longitude`.
264
- */
265
- coordinates?: Remapper;
266
- };
287
+ ics: DurationICSRemapper | EndTimeICSRemapper;
267
288
  /**
268
289
  * Checks if condition results in a truthy value.
269
290
  *
@@ -288,6 +309,20 @@ export interface Remappers {
288
309
  * Assign properties to an existing object given some predefined mapper keys.
289
310
  */
290
311
  'object.assign': Record<string, Remapper>;
312
+ /**
313
+ * Remove properties from an existing object based on the given the object keys.
314
+ *
315
+ * Nested properties can be removed using arrays of keys.
316
+ *
317
+ * @example
318
+ * ```yaml
319
+ * object.omit:
320
+ * - foo # Removes the property foo
321
+ * - - bar # Removes the property baz inside of bar
322
+ * - baz
323
+ * ```
324
+ */
325
+ 'object.omit': (string[] | string)[];
291
326
  /**
292
327
  * Use a static value.
293
328
  */
@@ -310,6 +345,27 @@ export interface Remappers {
310
345
  * If the input is not an array, the input is returned as-is.
311
346
  */
312
347
  'random.choice': null;
348
+ /**
349
+ * Pick and return a random entry from an array.
350
+ *
351
+ * If the input is not an array, the input is returned as-is.
352
+ */
353
+ 'random.integer': [number, number];
354
+ /**
355
+ * Pick and return a random entry from an array.
356
+ *
357
+ * If the input is not an array, the input is returned as-is.
358
+ */
359
+ 'random.float': [number, number];
360
+ /**
361
+ * Pick and return a random entry from an array.
362
+ *
363
+ * If the input is not an array, the input is returned as-is.
364
+ */
365
+ 'random.string': {
366
+ choice: string;
367
+ length: number;
368
+ };
313
369
  /**
314
370
  * Get the input data as it was initially passed to the remap function.
315
371
  */
@@ -431,6 +487,16 @@ export interface ResourceHistoryDefinition {
431
487
  */
432
488
  data: boolean;
433
489
  }
490
+ export interface ResourceView {
491
+ /**
492
+ * The roles required to use this view.
493
+ */
494
+ roles: string[];
495
+ /**
496
+ * The remappers used to transform the output.
497
+ */
498
+ remap: Remapper;
499
+ }
434
500
  export interface ResourceDefinition {
435
501
  /**
436
502
  * The default list of roles used for permission checks for each action.
@@ -480,6 +546,10 @@ export interface ResourceDefinition {
480
546
  * @default autogenerated for use with the Appsemble resource API.
481
547
  */
482
548
  url?: string;
549
+ /**
550
+ * The alternate views of this resource.
551
+ */
552
+ views?: Record<string, ResourceView>;
483
553
  /**
484
554
  * The references this resources has to other resources.
485
555
  */
@@ -775,11 +845,17 @@ interface ResourceActionDefinition<T extends Action['type']> extends RequestLike
775
845
  */
776
846
  resource: string;
777
847
  }
848
+ interface ViewResourceDefinition {
849
+ /**
850
+ * The view to use for the request.
851
+ */
852
+ view?: string;
853
+ }
778
854
  export declare type RequestActionDefinition = RequestLikeActionDefinition<'request'>;
779
855
  export declare type ResourceCreateActionDefinition = ResourceActionDefinition<'resource.create'>;
780
856
  export declare type ResourceDeleteActionDefinition = ResourceActionDefinition<'resource.delete'>;
781
- export declare type ResourceGetActionDefinition = ResourceActionDefinition<'resource.get'>;
782
- export declare type ResourceQueryActionDefinition = ResourceActionDefinition<'resource.query'>;
857
+ export declare type ResourceGetActionDefinition = ResourceActionDefinition<'resource.get'> & ViewResourceDefinition;
858
+ export declare type ResourceQueryActionDefinition = ResourceActionDefinition<'resource.query'> & ViewResourceDefinition;
783
859
  export declare type ResourceCountActionDefinition = ResourceActionDefinition<'resource.count'>;
784
860
  export declare type ResourceUpdateActionDefinition = ResourceActionDefinition<'resource.update'>;
785
861
  export interface BaseResourceSubscribeActionDefinition<T extends Action['type']> extends BaseActionDefinition<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/types",
3
- "version": "0.20.6",
3
+ "version": "0.20.9",
4
4
  "description": "TypeScript definitions reused within Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -30,10 +30,10 @@
30
30
  "test": "jest"
31
31
  },
32
32
  "dependencies": {
33
- "@appsemble/sdk": "0.20.6",
33
+ "@appsemble/sdk": "0.20.9",
34
34
  "@fortawesome/fontawesome-common-types": "^6.0.0",
35
35
  "jsonschema": "^1.0.0",
36
- "openapi-types": "^10.0.0",
36
+ "openapi-types": "^12.0.0",
37
37
  "type-fest": "^2.0.0"
38
38
  }
39
39
  }