@ampless/backend 0.2.0-alpha.4 → 0.2.0-alpha.5
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/dist/auth/user-admin.d.ts +36 -4
- package/dist/auth/user-admin.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Handler } from 'aws-lambda';
|
|
2
2
|
|
|
3
3
|
type AdminRole = 'admin' | 'editor' | 'none';
|
|
4
4
|
interface AdminUserDto {
|
|
@@ -6,12 +6,44 @@ interface AdminUserDto {
|
|
|
6
6
|
email: string;
|
|
7
7
|
role: AdminRole;
|
|
8
8
|
}
|
|
9
|
-
interface ListArgs {
|
|
10
|
-
}
|
|
11
9
|
interface SetArgs {
|
|
12
10
|
userId: string;
|
|
13
11
|
role: string;
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Event shape that Amplify Gen 2 actually delivers to a Lambda data
|
|
15
|
+
* source attached via `a.handler.function()`. The CDK generated
|
|
16
|
+
* AppSync resource is a PIPELINE resolver whose Lambda-invocation
|
|
17
|
+
* function uses a VTL request mapping template that emits a flat
|
|
18
|
+
* payload:
|
|
19
|
+
*
|
|
20
|
+
* {
|
|
21
|
+
* "operation": "Invoke",
|
|
22
|
+
* "payload": {
|
|
23
|
+
* "typeName": "Query",
|
|
24
|
+
* "fieldName": "listAdminUsers",
|
|
25
|
+
* "arguments": { ... },
|
|
26
|
+
* "identity": { ... },
|
|
27
|
+
* "source": ..., "request": ..., "prev": ...
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* Notably this is NOT the canonical `AppSyncResolverEvent` shape
|
|
32
|
+
* (which has `event.info.fieldName`). The `aws-lambda` package's
|
|
33
|
+
* `AppSyncResolverHandler` type is misleading here — typing the
|
|
34
|
+
* handler with it sends `event.info.fieldName` to `undefined` and
|
|
35
|
+
* blows up at runtime with
|
|
36
|
+
* `Cannot read properties of undefined (reading 'fieldName')`.
|
|
37
|
+
*/
|
|
38
|
+
interface UserAdminEvent {
|
|
39
|
+
typeName: string;
|
|
40
|
+
fieldName: string;
|
|
41
|
+
arguments: Partial<SetArgs>;
|
|
42
|
+
identity?: unknown;
|
|
43
|
+
source?: unknown;
|
|
44
|
+
request?: unknown;
|
|
45
|
+
prev?: unknown;
|
|
46
|
+
}
|
|
47
|
+
declare const handler: Handler<UserAdminEvent, AdminUserDto | AdminUserDto[] | null>;
|
|
16
48
|
|
|
17
49
|
export { handler };
|
package/dist/auth/user-admin.js
CHANGED
|
@@ -76,7 +76,7 @@ async function setAdminUserRole(userPoolId, userId, role) {
|
|
|
76
76
|
}
|
|
77
77
|
var handler = async (event) => {
|
|
78
78
|
const userPoolId = requireUserPoolId();
|
|
79
|
-
const field = event.
|
|
79
|
+
const field = event.fieldName;
|
|
80
80
|
try {
|
|
81
81
|
if (field === "listAdminUsers") {
|
|
82
82
|
return await listAdminUsers(userPoolId);
|
package/package.json
CHANGED