@appsemble/types 0.25.2 → 0.26.0
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/README.md +3 -3
- package/action.d.ts +38 -1
- package/action.js +29 -1
- package/index.d.ts +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Types
|
|
2
2
|
|
|
3
3
|
> Reusable TypeScript types
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/types)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.26.0)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.26.0/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/action.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type HTTPMethods } from './http.js';
|
|
2
|
-
import { type Remapper } from './index.js';
|
|
2
|
+
import { type ActionDefinition, type Remapper } from './index.js';
|
|
3
3
|
interface BaseAction<T extends string> {
|
|
4
4
|
/**
|
|
5
5
|
* A function which can be called to dispatch the action.
|
|
@@ -44,4 +44,41 @@ export type ResourcePatchAction = RequestLikeAction<'resource.patch'>;
|
|
|
44
44
|
* An action that can be called from within a block.
|
|
45
45
|
*/
|
|
46
46
|
export type Action = BaseAction<'analytics'> | BaseAction<'condition'> | BaseAction<'controller'> | BaseAction<'dialog.error'> | BaseAction<'dialog.ok'> | BaseAction<'dialog'> | BaseAction<'download'> | BaseAction<'each'> | 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<'match'> | BaseAction<'message'> | BaseAction<'noop'> | BaseAction<'notify'> | BaseAction<'resource.subscription.status'> | BaseAction<'resource.subscription.subscribe'> | BaseAction<'resource.subscription.toggle'> | BaseAction<'resource.subscription.unsubscribe'> | BaseAction<'share'> | BaseAction<'static'> | BaseAction<'storage.append'> | BaseAction<'storage.delete'> | BaseAction<'storage.read'> | BaseAction<'storage.subtract'> | BaseAction<'storage.update'> | BaseAction<'storage.write'> | BaseAction<'team.invite'> | BaseAction<'team.join'> | BaseAction<'team.list'> | BaseAction<'team.members'> | BaseAction<'throw'> | BaseAction<'user.create'> | BaseAction<'user.login'> | BaseAction<'user.logout'> | BaseAction<'user.query'> | BaseAction<'user.register'> | BaseAction<'user.remove'> | BaseAction<'user.update'> | LinkAction | LogAction | RequestAction | ResourceCountAction | ResourceCreateAction | ResourceDeleteAction | ResourceGetAction | ResourcePatchAction | ResourceQueryAction | ResourceUpdateAction;
|
|
47
|
+
interface ActionErrorOptions<D extends ActionDefinition> {
|
|
48
|
+
/**
|
|
49
|
+
* What caused the error to be thrown.
|
|
50
|
+
*/
|
|
51
|
+
cause: unknown;
|
|
52
|
+
/**
|
|
53
|
+
* The action input data.
|
|
54
|
+
*/
|
|
55
|
+
data: unknown;
|
|
56
|
+
/**
|
|
57
|
+
* The definition of the action that threw the error.
|
|
58
|
+
*/
|
|
59
|
+
definition: D;
|
|
60
|
+
/**
|
|
61
|
+
* The HTTP status code of the error, if there is one.
|
|
62
|
+
*/
|
|
63
|
+
status?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* This error may be thrown by actions.
|
|
67
|
+
*/
|
|
68
|
+
export declare class ActionError<D extends ActionDefinition = ActionDefinition> extends Error {
|
|
69
|
+
cause: unknown;
|
|
70
|
+
/**
|
|
71
|
+
* The action input data.
|
|
72
|
+
*/
|
|
73
|
+
data: unknown;
|
|
74
|
+
/**
|
|
75
|
+
* The definition of the action that threw the error.
|
|
76
|
+
*/
|
|
77
|
+
definition: D;
|
|
78
|
+
/**
|
|
79
|
+
* The HTTP status code of the error, if there is one.
|
|
80
|
+
*/
|
|
81
|
+
status?: number;
|
|
82
|
+
constructor(options: ActionErrorOptions<D>);
|
|
83
|
+
}
|
|
47
84
|
export {};
|
package/action.js
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This error may be thrown by actions.
|
|
3
|
+
*/
|
|
4
|
+
export class ActionError extends Error {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
const { cause, data, definition } = options;
|
|
7
|
+
super(`An error occurred while running ${definition.type}`, { cause });
|
|
8
|
+
this.data = data;
|
|
9
|
+
this.definition = definition;
|
|
10
|
+
if (typeof cause === 'object' && cause != null && 'response' in cause) {
|
|
11
|
+
const { response } = cause;
|
|
12
|
+
if (typeof response === 'object' && response != null && 'status' in response) {
|
|
13
|
+
const responseStatus = response.status;
|
|
14
|
+
if (responseStatus && typeof responseStatus === 'number') {
|
|
15
|
+
this.status = responseStatus;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line unicorn/custom-error-definition
|
|
20
|
+
this.name = `ActionError(${definition.type})`;
|
|
21
|
+
this.cause = cause;
|
|
22
|
+
if (cause instanceof Error && cause.stack) {
|
|
23
|
+
this.stack += `\n\n${cause.stack
|
|
24
|
+
.split('\n')
|
|
25
|
+
.map((line) => ` ${line}`)
|
|
26
|
+
.join('\n')}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
2
30
|
//# sourceMappingURL=action.js.map
|
package/index.d.ts
CHANGED
|
@@ -159,6 +159,10 @@ export interface UserInfo {
|
|
|
159
159
|
* The properties of the currently logged in member of the app
|
|
160
160
|
*/
|
|
161
161
|
appMember?: AppMember;
|
|
162
|
+
/**
|
|
163
|
+
* Returns `true` if the user has no Oauth connections and no password.
|
|
164
|
+
*/
|
|
165
|
+
hasNoLoginMethods?: boolean;
|
|
162
166
|
}
|
|
163
167
|
/**
|
|
164
168
|
* The payload stored in our JSON web tokens
|
|
@@ -776,7 +780,7 @@ export interface BaseActionDefinition<T extends Action['type']> {
|
|
|
776
780
|
*/
|
|
777
781
|
remapBefore?: Remapper;
|
|
778
782
|
/**
|
|
779
|
-
* The remapper used to
|
|
783
|
+
* The remapper used to transform the output before passing it to the next action.
|
|
780
784
|
*/
|
|
781
785
|
remapAfter?: Remapper;
|
|
782
786
|
/**
|
|
@@ -1493,7 +1497,7 @@ export interface AppDefinition {
|
|
|
1493
1497
|
/**
|
|
1494
1498
|
* The navigation type to use.
|
|
1495
1499
|
*
|
|
1496
|
-
* If this is omitted, a
|
|
1500
|
+
* If this is omitted, a collapsible side navigation menu will be rendered on the left.
|
|
1497
1501
|
*
|
|
1498
1502
|
* @default 'left-menu'
|
|
1499
1503
|
*/
|