@webiny/api-core-ddb 6.3.0-beta.4 → 6.4.0-beta.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/adminUsers/definitions/entities.js +5 -6
- package/adminUsers/definitions/entities.js.map +1 -1
- package/adminUsers/definitions/types.js +0 -3
- package/adminUsers/index.js +135 -156
- package/adminUsers/index.js.map +1 -1
- package/adminUsers/types.js +5 -4
- package/adminUsers/types.js.map +1 -1
- package/createApiCoreDdb.js +19 -22
- package/createApiCoreDdb.js.map +1 -1
- package/index.js +0 -2
- package/keyValueStore/KeyValueStoreDynamoTable.js +24 -25
- package/keyValueStore/KeyValueStoreDynamoTable.js.map +1 -1
- package/keyValueStore/KeyValueStoreStorageOperations.d.ts +2 -1
- package/keyValueStore/KeyValueStoreStorageOperations.js +72 -72
- package/keyValueStore/KeyValueStoreStorageOperations.js.map +1 -1
- package/keyValueStore/index.js +2 -3
- package/keyValueStore/index.js.map +1 -1
- package/package.json +9 -9
- package/security/definitions/entities.js +19 -24
- package/security/definitions/entities.js.map +1 -1
- package/security/definitions/types.js +0 -3
- package/security/index.js +389 -464
- package/security/index.js.map +1 -1
- package/security/types.js +6 -5
- package/security/types.js.map +1 -1
- package/tenancy/definitions/tenantEntity.js +5 -9
- package/tenancy/definitions/tenantEntity.js.map +1 -1
- package/tenancy/definitions/types.js +0 -3
- package/tenancy/index.js +107 -127
- package/tenancy/index.js.map +1 -1
- package/tenancy/types.js +4 -3
- package/tenancy/types.js.map +1 -1
- package/adminUsers/definitions/types.js.map +0 -1
- package/index.js.map +0 -1
- package/security/definitions/types.js.map +0 -1
- package/tenancy/definitions/types.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createStandardEntity } from "@webiny/db-dynamodb";
|
|
2
2
|
import { ENTITIES } from "../types.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
3
|
+
const createUserEntity = (table)=>createStandardEntity({
|
|
4
|
+
name: ENTITIES.USERS,
|
|
5
|
+
table
|
|
6
|
+
});
|
|
7
|
+
export { createUserEntity };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=entities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"adminUsers/definitions/entities.js","sources":["../../../src/adminUsers/definitions/entities.ts"],"sourcesContent":["import { createStandardEntity } from \"@webiny/db-dynamodb\";\nimport type { Table } from \"@webiny/db-dynamodb/toolbox.js\";\nimport { ENTITIES } from \"../types.js\";\nimport type { IAdminUserEntity } from \"~/adminUsers/definitions/types.js\";\nimport type { AdminUser } from \"@webiny/api-core/types/users.js\";\n\nexport const createUserEntity = (table: Table<string, string, string>): IAdminUserEntity => {\n return createStandardEntity<AdminUser>({\n name: ENTITIES.USERS,\n table\n });\n};\n"],"names":["createUserEntity","table","createStandardEntity","ENTITIES"],"mappings":";;AAMO,MAAMA,mBAAmB,CAACC,QACtBC,qBAAgC;QACnC,MAAMC,SAAS,KAAK;QACpBF;IACJ"}
|
package/adminUsers/index.js
CHANGED
|
@@ -1,165 +1,144 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { createTable, sortItems } from "@webiny/db-dynamodb";
|
|
3
3
|
import { createUserEntity } from "./definitions/entities.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
table
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
const entities = {
|
|
14
|
-
users: createUserEntity(table.table)
|
|
15
|
-
};
|
|
16
|
-
const createUserKeys = user => ({
|
|
17
|
-
PK: `T#${user.tenant}#ADMIN_USER#${user.id}`,
|
|
18
|
-
SK: `A`
|
|
19
|
-
});
|
|
20
|
-
const createUserGSIKeys = user => {
|
|
21
|
-
return {
|
|
22
|
-
GSI1_PK: `T#${user.tenant}#ADMIN_USERS`,
|
|
23
|
-
GSI1_SK: user.email,
|
|
24
|
-
GSI_TENANT: user.tenant
|
|
4
|
+
const createStorageOperations = (params)=>{
|
|
5
|
+
const { table: tableName, documentClient } = params;
|
|
6
|
+
const table = createTable({
|
|
7
|
+
name: tableName || process.env.DB_TABLE,
|
|
8
|
+
documentClient
|
|
9
|
+
});
|
|
10
|
+
const entities = {
|
|
11
|
+
users: createUserEntity(table.table)
|
|
25
12
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return table;
|
|
30
|
-
},
|
|
31
|
-
getEntities() {
|
|
32
|
-
return entities;
|
|
33
|
-
},
|
|
34
|
-
async createUser({
|
|
35
|
-
user
|
|
36
|
-
}) {
|
|
37
|
-
const keys = {
|
|
38
|
-
...createUserKeys(user),
|
|
39
|
-
...createUserGSIKeys(user)
|
|
40
|
-
};
|
|
41
|
-
try {
|
|
42
|
-
await entities.users.put({
|
|
43
|
-
...keys,
|
|
44
|
-
TYPE: "adminUsers.user",
|
|
45
|
-
data: user
|
|
13
|
+
const createUserKeys = (user)=>({
|
|
14
|
+
PK: `T#${user.tenant}#ADMIN_USER#${user.id}`,
|
|
15
|
+
SK: "A"
|
|
46
16
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: "CREATE_ADMIN_USER_ERROR",
|
|
52
|
-
data: {
|
|
53
|
-
keys
|
|
54
|
-
}
|
|
17
|
+
const createUserGSIKeys = (user)=>({
|
|
18
|
+
GSI1_PK: `T#${user.tenant}#ADMIN_USERS`,
|
|
19
|
+
GSI1_SK: user.email,
|
|
20
|
+
GSI_TENANT: user.tenant
|
|
55
21
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
22
|
+
const storageOperations = {
|
|
23
|
+
getTable () {
|
|
24
|
+
return table;
|
|
25
|
+
},
|
|
26
|
+
getEntities () {
|
|
27
|
+
return entities;
|
|
28
|
+
},
|
|
29
|
+
async createUser ({ user }) {
|
|
30
|
+
const keys = {
|
|
31
|
+
...createUserKeys(user),
|
|
32
|
+
...createUserGSIKeys(user)
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
await entities.users.put({
|
|
36
|
+
...keys,
|
|
37
|
+
TYPE: "adminUsers.user",
|
|
38
|
+
data: user
|
|
39
|
+
});
|
|
40
|
+
return user;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
throw error.from(err, {
|
|
43
|
+
message: "Could not create admin user.",
|
|
44
|
+
code: "CREATE_ADMIN_USER_ERROR",
|
|
45
|
+
data: {
|
|
46
|
+
keys
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
async deleteUser ({ user }) {
|
|
52
|
+
const keys = createUserKeys(user);
|
|
53
|
+
try {
|
|
54
|
+
await entities.users.delete(keys);
|
|
55
|
+
} catch (err) {
|
|
56
|
+
throw error.from(err, {
|
|
57
|
+
message: "Could not delete group.",
|
|
58
|
+
code: "CREATE_DELETE_ERROR",
|
|
59
|
+
data: {
|
|
60
|
+
keys,
|
|
61
|
+
user
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
async getUser (params) {
|
|
67
|
+
const { where: { tenant, id, email } } = params;
|
|
68
|
+
try {
|
|
69
|
+
if (id) {
|
|
70
|
+
const response = await entities.users.get(createUserKeys({
|
|
71
|
+
tenant,
|
|
72
|
+
id
|
|
73
|
+
}));
|
|
74
|
+
return response?.data || null;
|
|
75
|
+
}
|
|
76
|
+
const response = await entities.users.queryOne({
|
|
77
|
+
partitionKey: `T#${tenant}#ADMIN_USERS`,
|
|
78
|
+
options: {
|
|
79
|
+
index: "GSI1",
|
|
80
|
+
eq: email
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return response?.data || null;
|
|
84
|
+
} catch (err) {
|
|
85
|
+
throw error.from(err, {
|
|
86
|
+
message: "Could not load user.",
|
|
87
|
+
code: "GET_ADMIN_USERS_ERROR",
|
|
88
|
+
data: {
|
|
89
|
+
id,
|
|
90
|
+
email
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async listUsers ({ where, sort }) {
|
|
96
|
+
let items;
|
|
97
|
+
try {
|
|
98
|
+
const ddbItems = await entities.users.queryAll({
|
|
99
|
+
partitionKey: `T#${where.tenant}#ADMIN_USERS`,
|
|
100
|
+
options: {
|
|
101
|
+
index: "GSI1"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
items = ddbItems.map((item)=>item.data);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
throw error.from(err, {
|
|
107
|
+
message: "Could not list users.",
|
|
108
|
+
code: "LIST_ADMIN_USERS_ERROR"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return sortItems({
|
|
112
|
+
items,
|
|
113
|
+
sort
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
async updateUser ({ user }) {
|
|
117
|
+
const keys = {
|
|
118
|
+
...createUserKeys(user),
|
|
119
|
+
...createUserGSIKeys(user)
|
|
120
|
+
};
|
|
121
|
+
try {
|
|
122
|
+
await entities.users.put({
|
|
123
|
+
...keys,
|
|
124
|
+
TYPE: "adminUsers.user",
|
|
125
|
+
data: user
|
|
126
|
+
});
|
|
127
|
+
return user;
|
|
128
|
+
} catch (err) {
|
|
129
|
+
throw error.from(err, {
|
|
130
|
+
message: "Could not update user.",
|
|
131
|
+
code: "UPDATE_ADMIN_USER_ERROR",
|
|
132
|
+
data: {
|
|
133
|
+
keys,
|
|
134
|
+
user
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
90
138
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
options: {
|
|
94
|
-
index: "GSI1",
|
|
95
|
-
eq: email
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
return response?.data || null;
|
|
99
|
-
} catch (err) {
|
|
100
|
-
throw WebinyError.from(err, {
|
|
101
|
-
message: "Could not load user.",
|
|
102
|
-
code: "GET_ADMIN_USERS_ERROR",
|
|
103
|
-
data: {
|
|
104
|
-
id,
|
|
105
|
-
email
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
async listUsers({
|
|
111
|
-
where,
|
|
112
|
-
sort
|
|
113
|
-
}) {
|
|
114
|
-
let items;
|
|
115
|
-
try {
|
|
116
|
-
const ddbItems = await entities.users.queryAll({
|
|
117
|
-
partitionKey: `T#${where.tenant}#ADMIN_USERS`,
|
|
118
|
-
options: {
|
|
119
|
-
index: "GSI1"
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
items = ddbItems.map(item => {
|
|
123
|
-
return item.data;
|
|
124
|
-
});
|
|
125
|
-
} catch (err) {
|
|
126
|
-
throw WebinyError.from(err, {
|
|
127
|
-
message: "Could not list users.",
|
|
128
|
-
code: "LIST_ADMIN_USERS_ERROR"
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return sortItems({
|
|
132
|
-
items,
|
|
133
|
-
sort
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
async updateUser({
|
|
137
|
-
user
|
|
138
|
-
}) {
|
|
139
|
-
const keys = {
|
|
140
|
-
...createUserKeys(user),
|
|
141
|
-
...createUserGSIKeys(user)
|
|
142
|
-
};
|
|
143
|
-
try {
|
|
144
|
-
await entities.users.put({
|
|
145
|
-
...keys,
|
|
146
|
-
TYPE: "adminUsers.user",
|
|
147
|
-
data: user
|
|
148
|
-
});
|
|
149
|
-
return user;
|
|
150
|
-
} catch (err) {
|
|
151
|
-
throw WebinyError.from(err, {
|
|
152
|
-
message: "Could not update user.",
|
|
153
|
-
code: "UPDATE_ADMIN_USER_ERROR",
|
|
154
|
-
data: {
|
|
155
|
-
keys,
|
|
156
|
-
user
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
return storageOperations;
|
|
139
|
+
};
|
|
140
|
+
return storageOperations;
|
|
163
141
|
};
|
|
142
|
+
export { createStorageOperations };
|
|
164
143
|
|
|
165
144
|
//# sourceMappingURL=index.js.map
|
package/adminUsers/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"adminUsers/index.js","sources":["../../src/adminUsers/index.ts"],"sourcesContent":["import type { AdminUsersStorageOperations, CreateAdminUsersStorageOperations } from \"./types.js\";\nimport WebinyError from \"@webiny/error\";\nimport { createTable, type IStandardEntityAttributes, sortItems } from \"@webiny/db-dynamodb\";\nimport { createUserEntity } from \"./definitions/entities.js\";\nimport type {\n AdminUser,\n StorageOperationsGetUserParams,\n StorageOperationsListUsersParams\n} from \"@webiny/api-core/types/users.js\";\n\nexport const createStorageOperations: CreateAdminUsersStorageOperations = params => {\n const { table: tableName, documentClient } = params;\n\n const table = createTable({\n name: tableName || (process.env.DB_TABLE as string),\n documentClient\n });\n\n const entities = {\n users: createUserEntity(table.table)\n };\n\n const createUserKeys = (user: Pick<AdminUser, \"tenant\" | \"id\">) => ({\n PK: `T#${user.tenant}#ADMIN_USER#${user.id}`,\n SK: `A`\n });\n\n const createUserGSIKeys = (user: AdminUser) => {\n return {\n GSI1_PK: `T#${user.tenant}#ADMIN_USERS`,\n GSI1_SK: user.email,\n GSI_TENANT: user.tenant\n };\n };\n\n const storageOperations: AdminUsersStorageOperations = {\n getTable() {\n return table;\n },\n getEntities() {\n return entities;\n },\n async createUser({ user }) {\n const keys = {\n ...createUserKeys(user),\n ...createUserGSIKeys(user)\n };\n\n try {\n await entities.users.put({\n ...keys,\n TYPE: \"adminUsers.user\",\n data: user\n });\n\n return user;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create admin user.\",\n code: \"CREATE_ADMIN_USER_ERROR\",\n data: { keys }\n });\n }\n },\n async deleteUser({ user }) {\n const keys = createUserKeys(user);\n\n try {\n await entities.users.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete group.\",\n code: \"CREATE_DELETE_ERROR\",\n data: { keys, user }\n });\n }\n },\n async getUser<TUser extends AdminUser = AdminUser>(\n params: StorageOperationsGetUserParams\n ): Promise<TUser | null> {\n const {\n where: { tenant, id, email }\n } = params;\n try {\n if (id) {\n const response = await entities.users.get<IStandardEntityAttributes<TUser>>(\n createUserKeys({ tenant, id })\n );\n return (response?.data as TUser) || null;\n }\n\n const response = await entities.users.queryOne<IStandardEntityAttributes<TUser>>({\n partitionKey: `T#${tenant}#ADMIN_USERS`,\n options: {\n index: \"GSI1\",\n eq: email\n }\n });\n\n return (response?.data as TUser) || null;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load user.\",\n code: \"GET_ADMIN_USERS_ERROR\",\n data: { id, email }\n });\n }\n },\n async listUsers<TUser extends AdminUser = AdminUser>({\n where,\n sort\n }: StorageOperationsListUsersParams) {\n let items: TUser[];\n try {\n const ddbItems = await entities.users.queryAll<IStandardEntityAttributes<TUser>>({\n partitionKey: `T#${where.tenant}#ADMIN_USERS`,\n options: {\n index: \"GSI1\"\n }\n });\n items = ddbItems.map(item => {\n return item.data as TUser;\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list users.\",\n code: \"LIST_ADMIN_USERS_ERROR\"\n });\n }\n\n return sortItems({ items, sort });\n },\n async updateUser({ user }) {\n const keys = {\n ...createUserKeys(user),\n ...createUserGSIKeys(user)\n };\n\n try {\n await entities.users.put({\n ...keys,\n TYPE: \"adminUsers.user\",\n data: user\n });\n return user;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update user.\",\n code: \"UPDATE_ADMIN_USER_ERROR\",\n data: { keys, user }\n });\n }\n }\n };\n\n return storageOperations;\n};\n"],"names":["createStorageOperations","params","tableName","documentClient","table","createTable","process","entities","createUserEntity","createUserKeys","user","createUserGSIKeys","storageOperations","keys","err","WebinyError","tenant","id","email","response","where","sort","items","ddbItems","item","sortItems"],"mappings":"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"}
|
package/adminUsers/types.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
|
|
2
|
+
ENTITIES["SYSTEM"] = "AdminUsers.System";
|
|
3
|
+
ENTITIES["USERS"] = "AdminUsers.User";
|
|
4
|
+
return ENTITIES;
|
|
5
5
|
}({});
|
|
6
|
+
export { types_ENTITIES as ENTITIES };
|
|
6
7
|
|
|
7
8
|
//# sourceMappingURL=types.js.map
|
package/adminUsers/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"adminUsers/types.js","sources":["../../src/adminUsers/types.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { AdminUsersStorageOperations as BaseAdminUsersStorageOperations } from \"@webiny/api-core/types/users.js\";\nimport type { IAdminUserEntity } from \"~/adminUsers/definitions/types.js\";\nimport { ITable } from \"@webiny/db-dynamodb\";\n\nexport enum ENTITIES {\n SYSTEM = \"AdminUsers.System\",\n USERS = \"AdminUsers.User\"\n}\n\nexport interface ICreateAdminUsersStorageOperationsParams {\n documentClient: DynamoDBDocument;\n table?: string;\n}\n\nexport interface CreateAdminUsersStorageOperations {\n (params: ICreateAdminUsersStorageOperationsParams): AdminUsersStorageOperations;\n}\n\nexport interface IAdminUsersGetEntitiesResponse {\n users: IAdminUserEntity;\n}\n\nexport interface AdminUsersStorageOperations extends BaseAdminUsersStorageOperations {\n getTable(): ITable;\n getEntities(): IAdminUsersGetEntitiesResponse;\n}\n"],"names":["ENTITIES"],"mappings":"AAKO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;WAARA"}
|
package/createApiCoreDdb.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { createStorageOperations
|
|
2
|
-
import { createStorageOperations as
|
|
3
|
-
import { createStorageOperations as
|
|
4
|
-
import { createStorageOperations as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
};
|
|
1
|
+
import { createStorageOperations } from "./adminUsers/index.js";
|
|
2
|
+
import { createStorageOperations as index_js_createStorageOperations } from "./tenancy/index.js";
|
|
3
|
+
import { createStorageOperations as external_security_index_js_createStorageOperations } from "./security/index.js";
|
|
4
|
+
import { createStorageOperations as external_keyValueStore_index_js_createStorageOperations } from "./keyValueStore/index.js";
|
|
5
|
+
const createApiCoreDdb = ({ documentClient })=>({
|
|
6
|
+
usersStorageOperations: createStorageOperations({
|
|
7
|
+
documentClient
|
|
8
|
+
}),
|
|
9
|
+
tenancyStorageOperations: index_js_createStorageOperations({
|
|
10
|
+
documentClient
|
|
11
|
+
}),
|
|
12
|
+
securityStorageOperations: external_security_index_js_createStorageOperations({
|
|
13
|
+
documentClient
|
|
14
|
+
}),
|
|
15
|
+
keyValueStorageOperations: external_keyValueStore_index_js_createStorageOperations({
|
|
16
|
+
documentClient
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
export { createApiCoreDdb };
|
|
23
20
|
|
|
24
21
|
//# sourceMappingURL=createApiCoreDdb.js.map
|
package/createApiCoreDdb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createApiCoreDdb.js","sources":["../src/createApiCoreDdb.ts"],"sourcesContent":["import type { ApiCoreStorageOperations } from \"@webiny/api-core/types/core.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStorageOperations as createUsersStorageOperations } from \"./adminUsers/index.js\";\nimport { createStorageOperations as createTenancyStorageOperations } from \"./tenancy/index.js\";\nimport { createStorageOperations as createSecurityStorageOperations } from \"./security/index.js\";\nimport { createStorageOperations as createKeyValueStorageOperations } from \"./keyValueStore/index.js\";\n\ninterface CreateApiCoreDdbParams {\n documentClient: DynamoDBDocument;\n}\n\nexport const createApiCoreDdb = ({\n documentClient\n}: CreateApiCoreDdbParams): ApiCoreStorageOperations => {\n return {\n usersStorageOperations: createUsersStorageOperations({\n documentClient\n }),\n tenancyStorageOperations: createTenancyStorageOperations({\n documentClient\n }),\n securityStorageOperations: createSecurityStorageOperations({\n documentClient\n }),\n keyValueStorageOperations: createKeyValueStorageOperations({\n documentClient\n })\n };\n};\n"],"names":["createApiCoreDdb","documentClient","createUsersStorageOperations","createTenancyStorageOperations","createSecurityStorageOperations","createKeyValueStorageOperations"],"mappings":";;;;AAWO,MAAMA,mBAAmB,CAAC,EAC7BC,cAAc,EACO,GACd;QACH,wBAAwBC,wBAA6B;YACjDD;QACJ;QACA,0BAA0BE,iCAA+B;YACrDF;QACJ;QACA,2BAA2BG,mDAAgC;YACvDH;QACJ;QACA,2BAA2BI,wDAAgC;YACvDJ;QACJ;IACJ"}
|
package/index.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { createGlobalEntity, createTable, globalEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return this.entity;
|
|
26
|
-
}
|
|
2
|
+
class KeyValueStoreDynamoTable {
|
|
3
|
+
constructor(documentClient){
|
|
4
|
+
const table = createTable({
|
|
5
|
+
name: process.env.DB_TABLE,
|
|
6
|
+
documentClient
|
|
7
|
+
});
|
|
8
|
+
this.entity = createGlobalEntity({
|
|
9
|
+
name: "KeyValueStore",
|
|
10
|
+
table: table.table,
|
|
11
|
+
attributes: {
|
|
12
|
+
...globalEntityAttributes
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
createKeys({ scopedKey }) {
|
|
17
|
+
return {
|
|
18
|
+
PK: `KV#${scopedKey}`,
|
|
19
|
+
SK: "A"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getEntity() {
|
|
23
|
+
return this.entity;
|
|
24
|
+
}
|
|
27
25
|
}
|
|
26
|
+
export { KeyValueStoreDynamoTable };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=KeyValueStoreDynamoTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"keyValueStore/KeyValueStoreDynamoTable.js","sources":["../../src/keyValueStore/KeyValueStoreDynamoTable.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createGlobalEntity, createTable, globalEntityAttributes } from \"@webiny/db-dynamodb\";\n\ninterface CreateKeysParams {\n scopedKey: string;\n}\n\nexport class KeyValueStoreDynamoTable<T extends GenericRecord> {\n private readonly entity;\n\n constructor(documentClient: DynamoDBDocument) {\n const table = createTable({\n name: process.env.DB_TABLE as string,\n documentClient\n });\n this.entity = createGlobalEntity<T>({\n name: \"KeyValueStore\",\n table: table.table,\n attributes: {\n ...globalEntityAttributes\n }\n });\n }\n\n createKeys({ scopedKey }: CreateKeysParams) {\n return {\n PK: `KV#${scopedKey}`,\n SK: `A`\n };\n }\n\n getEntity() {\n return this.entity;\n }\n}\n"],"names":["KeyValueStoreDynamoTable","documentClient","table","createTable","process","createGlobalEntity","globalEntityAttributes","scopedKey"],"mappings":";AAQO,MAAMA;IAGT,YAAYC,cAAgC,CAAE;QAC1C,MAAMC,QAAQC,YAAY;YACtB,MAAMC,QAAQ,GAAG,CAAC,QAAQ;YAC1BH;QACJ;QACA,IAAI,CAAC,MAAM,GAAGI,mBAAsB;YAChC,MAAM;YACN,OAAOH,MAAM,KAAK;YAClB,YAAY;gBACR,GAAGI,sBAAsB;YAC7B;QACJ;IACJ;IAEA,WAAW,EAAEC,SAAS,EAAoB,EAAE;QACxC,OAAO;YACH,IAAI,CAAC,GAAG,EAAEA,WAAW;YACrB,IAAI;QACR;IACJ;IAEA,YAAY;QACR,OAAO,IAAI,CAAC,MAAM;IACtB;AACJ"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import type { IKeyValueStoreSetOptions } from "@webiny/api-core/features/keyValueStore/abstractions.js";
|
|
2
3
|
interface KeyValueRecord {
|
|
3
4
|
key: string;
|
|
4
5
|
value: any;
|
|
@@ -10,7 +11,7 @@ export declare class KeyValueStoreStorageOperations {
|
|
|
10
11
|
constructor(dynamoDbClient: DynamoDBDocument);
|
|
11
12
|
private createScopedKey;
|
|
12
13
|
get(key: string, scope: string): Promise<KeyValueRecord | null>;
|
|
13
|
-
set(key: string, value: any, scope: string): Promise<void>;
|
|
14
|
+
set(key: string, value: any, scope: string, options?: IKeyValueStoreSetOptions): Promise<void>;
|
|
14
15
|
delete(key: string, scope: string): Promise<void>;
|
|
15
16
|
}
|
|
16
17
|
export {};
|