@appsemble/types 0.20.7 → 0.20.10

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.
@@ -0,0 +1,46 @@
1
+ import { Remapper } from '.';
2
+ import { HTTPMethods } from './http';
3
+ interface BaseAction<T extends string> {
4
+ /**
5
+ * A function which can be called to dispatch the action.
6
+ */
7
+ <R>(data?: any, context?: Record<string, any>): Promise<R>;
8
+ /**
9
+ * The type of the action.
10
+ */
11
+ type: T;
12
+ }
13
+ export interface LinkAction extends BaseAction<'link'> {
14
+ /**
15
+ * Get the link that the action would link to if the given data was passed.
16
+ */
17
+ href: (data?: unknown) => string;
18
+ }
19
+ export interface LogAction extends BaseAction<'log'> {
20
+ /**
21
+ * The logging level.
22
+ */
23
+ level: 'error' | 'info' | 'warn';
24
+ }
25
+ interface RequestLikeAction<T extends Action['type']> extends BaseAction<T> {
26
+ /**
27
+ * The HTTP method used to make the request.
28
+ */
29
+ method: HTTPMethods;
30
+ /**
31
+ * The URL to which the request will be made.
32
+ */
33
+ url: Remapper;
34
+ }
35
+ export declare type RequestAction = RequestLikeAction<'request'>;
36
+ export declare type ResourceCreateAction = RequestLikeAction<'resource.create'>;
37
+ export declare type ResourceDeleteAction = RequestLikeAction<'resource.delete'>;
38
+ export declare type ResourceGetAction = RequestLikeAction<'resource.get'>;
39
+ export declare type ResourceQueryAction = RequestLikeAction<'resource.query'>;
40
+ export declare type ResourceCountAction = RequestLikeAction<'resource.count'>;
41
+ export declare type ResourceUpdateAction = RequestLikeAction<'resource.update'>;
42
+ /**
43
+ * An action that can be called from within a block.
44
+ */
45
+ export declare type Action = BaseAction<'analytics'> | BaseAction<'condition'> | BaseAction<'dialog.error'> | BaseAction<'dialog.ok'> | BaseAction<'dialog'> | BaseAction<'download'> | BaseAction<'email'> | BaseAction<'event'> | BaseAction<'flow.back'> | BaseAction<'flow.cancel'> | BaseAction<'flow.finish'> | BaseAction<'flow.next'> | BaseAction<'flow.to'> | BaseAction<'link.back'> | BaseAction<'link.next'> | BaseAction<'message'> | BaseAction<'noop'> | BaseAction<'resource.subscription.status'> | BaseAction<'resource.subscription.subscribe'> | BaseAction<'resource.subscription.toggle'> | BaseAction<'resource.subscription.unsubscribe'> | BaseAction<'share'> | BaseAction<'static'> | BaseAction<'storage.read'> | BaseAction<'storage.write'> | BaseAction<'team.invite'> | BaseAction<'team.join'> | BaseAction<'team.list'> | BaseAction<'throw'> | BaseAction<'user.login'> | BaseAction<'user.register'> | BaseAction<'user.update'> | LinkAction | LogAction | RequestAction | ResourceCountAction | ResourceCreateAction | ResourceDeleteAction | ResourceGetAction | ResourceQueryAction | ResourceUpdateAction;
46
+ export {};
package/dist/action.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A color known to Bulma.
3
+ */
4
+ export declare type BulmaColor = 'danger' | 'dark' | 'info' | 'link' | 'primary' | 'success' | 'warning' | 'white';
5
+ export declare type BulmaSize = 'large' | 'medium' | 'normal' | 'small';
package/dist/bulma.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bulma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulma.js","sourceRoot":"","sources":["../src/bulma.ts"],"names":[],"mappings":""}
package/dist/http.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Common HTTP methods, but either all upper case or all lower case.
3
+ */
4
+ export declare type HTTPMethods = 'DELETE' | 'delete' | 'GET' | 'get' | 'PATCH' | 'patch' | 'POST' | 'post' | 'PUT' | 'put';
package/dist/http.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":""}
package/dist/index.d.ts CHANGED
@@ -1,22 +1,28 @@
1
- import { Action, BaseMessage, HTTPMethods, LogAction, Theme } from '@appsemble/sdk/src/types';
2
1
  import { IconName } from '@fortawesome/fontawesome-common-types';
3
2
  import { Schema } from 'jsonschema';
4
3
  import { OpenAPIV3 } from 'openapi-types';
5
4
  import { JsonObject, RequireExactlyOne } from 'type-fest';
5
+ import { Action, LogAction } from './action';
6
6
  import { AppVisibility, TeamsDefinition } from './app';
7
+ import { BulmaColor } from './bulma';
8
+ import { HTTPMethods } from './http';
9
+ import { Theme } from './theme';
10
+ export * from './action';
7
11
  export * from './app';
8
12
  export * from './appMember';
9
13
  export * from './asset';
10
14
  export * from './authentication';
11
15
  export * from './author';
16
+ export * from './bulma';
17
+ export * from './http';
12
18
  export * from './snapshot';
13
19
  export * from './resource';
14
20
  export * from './saml';
15
21
  export * from './ssl';
16
22
  export * from './team';
17
23
  export * from './template';
24
+ export * from './theme';
18
25
  export * from './user';
19
- export { Theme };
20
26
  /**
21
27
  * A representation of a generated OAuth2 authorization code response.
22
28
  */
@@ -309,6 +315,20 @@ export interface Remappers {
309
315
  * Assign properties to an existing object given some predefined mapper keys.
310
316
  */
311
317
  'object.assign': Record<string, Remapper>;
318
+ /**
319
+ * Remove properties from an existing object based on the given the object keys.
320
+ *
321
+ * Nested properties can be removed using arrays of keys.
322
+ *
323
+ * @example
324
+ * ```yaml
325
+ * object.omit:
326
+ * - foo # Removes the property foo
327
+ * - - bar # Removes the property baz inside of bar
328
+ * - baz
329
+ * ```
330
+ */
331
+ 'object.omit': (string[] | string)[];
312
332
  /**
313
333
  * Use a static value.
314
334
  */
@@ -331,6 +351,27 @@ export interface Remappers {
331
351
  * If the input is not an array, the input is returned as-is.
332
352
  */
333
353
  'random.choice': null;
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.integer': [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.float': [number, number];
366
+ /**
367
+ * Pick and return a random entry from an array.
368
+ *
369
+ * If the input is not an array, the input is returned as-is.
370
+ */
371
+ 'random.string': {
372
+ choice: string;
373
+ length: number;
374
+ };
334
375
  /**
335
376
  * Get the input data as it was initially passed to the remap function.
336
377
  */
@@ -452,6 +493,16 @@ export interface ResourceHistoryDefinition {
452
493
  */
453
494
  data: boolean;
454
495
  }
496
+ export interface ResourceView {
497
+ /**
498
+ * The roles required to use this view.
499
+ */
500
+ roles: string[];
501
+ /**
502
+ * The remappers used to transform the output.
503
+ */
504
+ remap: Remapper;
505
+ }
455
506
  export interface ResourceDefinition {
456
507
  /**
457
508
  * The default list of roles used for permission checks for each action.
@@ -501,6 +552,10 @@ export interface ResourceDefinition {
501
552
  * @default autogenerated for use with the Appsemble resource API.
502
553
  */
503
554
  url?: string;
555
+ /**
556
+ * The alternate views of this resource.
557
+ */
558
+ views?: Record<string, ResourceView>;
504
559
  /**
505
560
  * The references this resources has to other resources.
506
561
  */
@@ -520,8 +575,19 @@ export interface BaseActionDefinition<T extends Action['type']> {
520
575
  /**
521
576
  * A remapper function. This may be used to remap data before it is passed into the action
522
577
  * function.
578
+ *
579
+ * @deprecated Since 0.20.10, use {@link remapBefore} instead.
523
580
  */
524
581
  remap?: Remapper;
582
+ /**
583
+ * A remapper function. This may be used to remap data before it is passed into the action
584
+ * function.
585
+ */
586
+ remapBefore?: Remapper;
587
+ /**
588
+ * The remapper used to transfrom the output before passing it to the next action.
589
+ */
590
+ remapAfter?: Remapper;
525
591
  /**
526
592
  * Another action that is dispatched when the action has been dispatched successfully.
527
593
  */
@@ -796,11 +862,17 @@ interface ResourceActionDefinition<T extends Action['type']> extends RequestLike
796
862
  */
797
863
  resource: string;
798
864
  }
865
+ interface ViewResourceDefinition {
866
+ /**
867
+ * The view to use for the request.
868
+ */
869
+ view?: string;
870
+ }
799
871
  export declare type RequestActionDefinition = RequestLikeActionDefinition<'request'>;
800
872
  export declare type ResourceCreateActionDefinition = ResourceActionDefinition<'resource.create'>;
801
873
  export declare type ResourceDeleteActionDefinition = ResourceActionDefinition<'resource.delete'>;
802
- export declare type ResourceGetActionDefinition = ResourceActionDefinition<'resource.get'>;
803
- export declare type ResourceQueryActionDefinition = ResourceActionDefinition<'resource.query'>;
874
+ export declare type ResourceGetActionDefinition = ResourceActionDefinition<'resource.get'> & ViewResourceDefinition;
875
+ export declare type ResourceQueryActionDefinition = ResourceActionDefinition<'resource.query'> & ViewResourceDefinition;
804
876
  export declare type ResourceCountActionDefinition = ResourceActionDefinition<'resource.count'>;
805
877
  export declare type ResourceUpdateActionDefinition = ResourceActionDefinition<'resource.update'>;
806
878
  export interface BaseResourceSubscribeActionDefinition<T extends Action['type']> extends BaseActionDefinition<T> {
@@ -835,6 +907,26 @@ export interface StaticActionDefinition extends BaseActionDefinition<'static'> {
835
907
  */
836
908
  value: any;
837
909
  }
910
+ export interface BaseMessage {
911
+ /**
912
+ * The color to use for the message.
913
+ *
914
+ * @default 'info'
915
+ */
916
+ color?: BulmaColor;
917
+ /**
918
+ * The timeout period for this message (in milliseconds).
919
+ *
920
+ * @default 5000
921
+ */
922
+ timeout?: number;
923
+ /**
924
+ * Whether or not to show the dismiss button.
925
+ *
926
+ * @default false
927
+ */
928
+ dismissable?: boolean;
929
+ }
838
930
  export declare type MessageActionDefinition = BaseActionDefinition<'message'> & BaseMessage & {
839
931
  /**
840
932
  * The content of the message to display.
@@ -919,6 +1011,7 @@ export interface BlockManifest {
919
1011
  * If the block has no messages, this property is `null`.
920
1012
  */
921
1013
  languages: string[] | null;
1014
+ examples?: string[];
922
1015
  /**
923
1016
  * Whether the block should be listed publicly
924
1017
  * for users who aren’t part of the block’s organization.
package/dist/index.js CHANGED
@@ -1,13 +1,17 @@
1
+ export * from './action';
1
2
  export * from './app';
2
3
  export * from './appMember';
3
4
  export * from './asset';
4
5
  export * from './authentication';
5
6
  export * from './author';
7
+ export * from './bulma';
8
+ export * from './http';
6
9
  export * from './snapshot';
7
10
  export * from './resource';
8
11
  export * from './saml';
9
12
  export * from './ssl';
10
13
  export * from './team';
11
14
  export * from './template';
15
+ export * from './theme';
12
16
  export * from './user';
13
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,54 @@
1
+ export interface FontDefinition {
2
+ /**
3
+ * Where to load a font from.
4
+ */
5
+ source?: 'custom' | 'google';
6
+ /**
7
+ * The name of the font family.
8
+ *
9
+ * This will be referenced in the Bulma CSS.
10
+ */
11
+ family: string;
12
+ }
13
+ export interface Theme {
14
+ /**
15
+ * The color primarily featured in the color scheme.
16
+ */
17
+ primaryColor: string;
18
+ /**
19
+ * The color used for links.
20
+ */
21
+ linkColor: string;
22
+ /**
23
+ * The color used to feature succesful or positive actions.
24
+ */
25
+ successColor: string;
26
+ /**
27
+ * The color used to indicate information.
28
+ */
29
+ infoColor: string;
30
+ /**
31
+ * The color used for elements that require extra attention.
32
+ */
33
+ warningColor: string;
34
+ /**
35
+ * The color used for elements that demand caution for destructive actions.
36
+ */
37
+ dangerColor: string;
38
+ /**
39
+ * The color used in the foreground of the splash screen.
40
+ */
41
+ themeColor: string;
42
+ /**
43
+ * The color used in the background of the splash screen.
44
+ */
45
+ splashColor: string;
46
+ /**
47
+ * The link to the tile layer used for Leaflet maps.
48
+ */
49
+ tileLayer: string;
50
+ /**
51
+ * The name of a font available on Google fonts.
52
+ */
53
+ font: FontDefinition;
54
+ }
package/dist/theme.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/types",
3
- "version": "0.20.7",
3
+ "version": "0.20.10",
4
4
  "description": "TypeScript definitions reused within Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -30,10 +30,9 @@
30
30
  "test": "jest"
31
31
  },
32
32
  "dependencies": {
33
- "@appsemble/sdk": "0.20.7",
34
33
  "@fortawesome/fontawesome-common-types": "^6.0.0",
35
34
  "jsonschema": "^1.0.0",
36
- "openapi-types": "^11.0.0",
35
+ "openapi-types": "^12.0.0",
37
36
  "type-fest": "^2.0.0"
38
37
  }
39
38
  }