@webiny/api-core-ddb 0.0.0-unstable.61c048f412
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/LICENSE +21 -0
- package/README.md +11 -0
- package/adminUsers/definitions/entities.d.ts +3 -0
- package/adminUsers/definitions/entities.js +10 -0
- package/adminUsers/definitions/entities.js.map +1 -0
- package/adminUsers/definitions/types.d.ts +5 -0
- package/adminUsers/definitions/types.js +3 -0
- package/adminUsers/definitions/types.js.map +1 -0
- package/adminUsers/index.d.ts +2 -0
- package/adminUsers/index.js +165 -0
- package/adminUsers/index.js.map +1 -0
- package/adminUsers/types.d.ts +22 -0
- package/adminUsers/types.js +7 -0
- package/adminUsers/types.js.map +1 -0
- package/createApiCoreDdb.d.ts +7 -0
- package/createApiCoreDdb.js +24 -0
- package/createApiCoreDdb.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/keyValueStore/KeyValueStoreDynamoTable.d.ts +15 -0
- package/keyValueStore/KeyValueStoreDynamoTable.js +29 -0
- package/keyValueStore/KeyValueStoreDynamoTable.js.map +1 -0
- package/keyValueStore/KeyValueStoreStorageOperations.d.ts +16 -0
- package/keyValueStore/KeyValueStoreStorageOperations.js +83 -0
- package/keyValueStore/KeyValueStoreStorageOperations.js.map +1 -0
- package/keyValueStore/index.d.ts +8 -0
- package/keyValueStore/index.js +6 -0
- package/keyValueStore/index.js.map +1 -0
- package/package.json +40 -0
- package/security/definitions/entities.d.ts +5 -0
- package/security/definitions/entities.js +28 -0
- package/security/definitions/entities.js.map +1 -0
- package/security/definitions/types.d.ts +14 -0
- package/security/definitions/types.js +3 -0
- package/security/definitions/types.js.map +1 -0
- package/security/index.d.ts +3 -0
- package/security/index.js +476 -0
- package/security/index.js.map +1 -0
- package/security/types.d.ts +10 -0
- package/security/types.js +8 -0
- package/security/types.js.map +1 -0
- package/tenancy/definitions/tenantEntity.d.ts +8 -0
- package/tenancy/definitions/tenantEntity.js +12 -0
- package/tenancy/definitions/tenantEntity.js.map +1 -0
- package/tenancy/definitions/types.d.ts +6 -0
- package/tenancy/definitions/types.js +3 -0
- package/tenancy/definitions/types.js.map +1 -0
- package/tenancy/index.d.ts +2 -0
- package/tenancy/index.js +135 -0
- package/tenancy/index.js.map +1 -0
- package/tenancy/types.d.ts +10 -0
- package/tenancy/types.js +6 -0
- package/tenancy/types.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @webiny/api-core-ddb
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createStandardEntity } from "@webiny/db-dynamodb";
|
|
2
|
+
import { ENTITIES } from "../types.js";
|
|
3
|
+
export const createUserEntity = table => {
|
|
4
|
+
return createStandardEntity({
|
|
5
|
+
name: ENTITIES.USERS,
|
|
6
|
+
table
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStandardEntity","ENTITIES","createUserEntity","table","name","USERS"],"sources":["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"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,qBAAqB;AAE1D,SAASC,QAAQ;AAIjB,OAAO,MAAMC,gBAAgB,GAAIC,KAAoC,IAAuB;EACxF,OAAOH,oBAAoB,CAAY;IACnCI,IAAI,EAAEH,QAAQ,CAACI,KAAK;IACpBF;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
+
import type { AdminUser } from "@webiny/api-core/types/users.js";
|
|
3
|
+
export interface IAdminUserEntityAttributes extends IStandardEntityAttributes<AdminUser> {
|
|
4
|
+
}
|
|
5
|
+
export type IAdminUserEntity = IEntity<IAdminUserEntityAttributes>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { AdminUser } from \"@webiny/api-core/types/users.js\";\n\nexport interface IAdminUserEntityAttributes extends IStandardEntityAttributes<AdminUser> {}\n\nexport type IAdminUserEntity = IEntity<IAdminUserEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { createTable, sortItems } from "@webiny/db-dynamodb";
|
|
3
|
+
import { createUserEntity } from "./definitions/entities.js";
|
|
4
|
+
export const createStorageOperations = params => {
|
|
5
|
+
const {
|
|
6
|
+
table: tableName,
|
|
7
|
+
documentClient
|
|
8
|
+
} = params;
|
|
9
|
+
const table = createTable({
|
|
10
|
+
name: tableName || process.env.DB_TABLE,
|
|
11
|
+
documentClient
|
|
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
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const storageOperations = {
|
|
28
|
+
getTable() {
|
|
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
|
|
46
|
+
});
|
|
47
|
+
return user;
|
|
48
|
+
} catch (err) {
|
|
49
|
+
throw WebinyError.from(err, {
|
|
50
|
+
message: "Could not create admin user.",
|
|
51
|
+
code: "CREATE_ADMIN_USER_ERROR",
|
|
52
|
+
data: {
|
|
53
|
+
keys
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
async deleteUser({
|
|
59
|
+
user
|
|
60
|
+
}) {
|
|
61
|
+
const keys = createUserKeys(user);
|
|
62
|
+
try {
|
|
63
|
+
await entities.users.delete(keys);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
throw WebinyError.from(err, {
|
|
66
|
+
message: "Could not delete group.",
|
|
67
|
+
code: "CREATE_DELETE_ERROR",
|
|
68
|
+
data: {
|
|
69
|
+
keys,
|
|
70
|
+
user
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async getUser(params) {
|
|
76
|
+
const {
|
|
77
|
+
where: {
|
|
78
|
+
tenant,
|
|
79
|
+
id,
|
|
80
|
+
email
|
|
81
|
+
}
|
|
82
|
+
} = params;
|
|
83
|
+
try {
|
|
84
|
+
if (id) {
|
|
85
|
+
const response = await entities.users.get(createUserKeys({
|
|
86
|
+
tenant,
|
|
87
|
+
id
|
|
88
|
+
}));
|
|
89
|
+
return response?.data || null;
|
|
90
|
+
}
|
|
91
|
+
const response = await entities.users.queryOne({
|
|
92
|
+
partitionKey: `T#${tenant}#ADMIN_USERS`,
|
|
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;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","createTable","sortItems","createUserEntity","createStorageOperations","params","table","tableName","documentClient","name","process","env","DB_TABLE","entities","users","createUserKeys","user","PK","tenant","id","SK","createUserGSIKeys","GSI1_PK","GSI1_SK","email","GSI_TENANT","storageOperations","getTable","getEntities","createUser","keys","put","TYPE","data","err","from","message","code","deleteUser","delete","getUser","where","response","get","queryOne","partitionKey","options","index","eq","listUsers","sort","items","ddbItems","queryAll","map","item","updateUser"],"sources":["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"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,WAAW,EAAkCC,SAAS,QAAQ,qBAAqB;AAC5F,SAASC,gBAAgB;AAOzB,OAAO,MAAMC,uBAA0D,GAAGC,MAAM,IAAI;EAChF,MAAM;IAAEC,KAAK,EAAEC,SAAS;IAAEC;EAAe,CAAC,GAAGH,MAAM;EAEnD,MAAMC,KAAK,GAAGL,WAAW,CAAC;IACtBQ,IAAI,EAAEF,SAAS,IAAKG,OAAO,CAACC,GAAG,CAACC,QAAmB;IACnDJ;EACJ,CAAC,CAAC;EAEF,MAAMK,QAAQ,GAAG;IACbC,KAAK,EAAEX,gBAAgB,CAACG,KAAK,CAACA,KAAK;EACvC,CAAC;EAED,MAAMS,cAAc,GAAIC,IAAsC,KAAM;IAChEC,EAAE,EAAE,KAAKD,IAAI,CAACE,MAAM,eAAeF,IAAI,CAACG,EAAE,EAAE;IAC5CC,EAAE,EAAE;EACR,CAAC,CAAC;EAEF,MAAMC,iBAAiB,GAAIL,IAAe,IAAK;IAC3C,OAAO;MACHM,OAAO,EAAE,KAAKN,IAAI,CAACE,MAAM,cAAc;MACvCK,OAAO,EAAEP,IAAI,CAACQ,KAAK;MACnBC,UAAU,EAAET,IAAI,CAACE;IACrB,CAAC;EACL,CAAC;EAED,MAAMQ,iBAA8C,GAAG;IACnDC,QAAQA,CAAA,EAAG;MACP,OAAOrB,KAAK;IAChB,CAAC;IACDsB,WAAWA,CAAA,EAAG;MACV,OAAOf,QAAQ;IACnB,CAAC;IACD,MAAMgB,UAAUA,CAAC;MAAEb;IAAK,CAAC,EAAE;MACvB,MAAMc,IAAI,GAAG;QACT,GAAGf,cAAc,CAACC,IAAI,CAAC;QACv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QACA,MAAMH,QAAQ,CAACC,KAAK,CAACiB,GAAG,CAAC;UACrB,GAAGD,IAAI;UACPE,IAAI,EAAE,iBAAiB;UACvBC,IAAI,EAAEjB;QACV,CAAC,CAAC;QACF,OAAOA,IAAI;MACf,CAAC,CAAC,OAAOkB,GAAG,EAAE;QACV,MAAMlC,WAAW,CAACmC,IAAI,CAACD,GAAG,EAAE;UACxBE,OAAO,EAAE,wBAAwB;UACjCC,IAAI,EAAE,yBAAyB;UAC/BJ,IAAI,EAAE;YAAEH,IAAI;YAAEd;UAAK;QACvB,CAAC,CAAC;MACN;IACJ;EACJ,CAAC;EAED,OAAOU,iBAAiB;AAC5B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import type { AdminUsersStorageOperations as BaseAdminUsersStorageOperations } from "@webiny/api-core/types/users.js";
|
|
3
|
+
import type { IAdminUserEntity } from "../adminUsers/definitions/types.js";
|
|
4
|
+
import { ITable } from "@webiny/db-dynamodb";
|
|
5
|
+
export declare enum ENTITIES {
|
|
6
|
+
SYSTEM = "AdminUsers.System",
|
|
7
|
+
USERS = "AdminUsers.User"
|
|
8
|
+
}
|
|
9
|
+
export interface ICreateAdminUsersStorageOperationsParams {
|
|
10
|
+
documentClient: DynamoDBDocument;
|
|
11
|
+
table?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateAdminUsersStorageOperations {
|
|
14
|
+
(params: ICreateAdminUsersStorageOperationsParams): AdminUsersStorageOperations;
|
|
15
|
+
}
|
|
16
|
+
export interface IAdminUsersGetEntitiesResponse {
|
|
17
|
+
users: IAdminUserEntity;
|
|
18
|
+
}
|
|
19
|
+
export interface AdminUsersStorageOperations extends BaseAdminUsersStorageOperations {
|
|
20
|
+
getTable(): ITable;
|
|
21
|
+
getEntities(): IAdminUsersGetEntitiesResponse;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ENTITIES"],"sources":["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"],"mappings":"AAKA,WAAYA,QAAQ,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiCoreStorageOperations } from "@webiny/api-core/types/core.js";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
+
interface CreateApiCoreDdbParams {
|
|
4
|
+
documentClient: DynamoDBDocument;
|
|
5
|
+
}
|
|
6
|
+
export declare const createApiCoreDdb: ({ documentClient }: CreateApiCoreDdbParams) => ApiCoreStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createStorageOperations as createUsersStorageOperations } from "./adminUsers/index.js";
|
|
2
|
+
import { createStorageOperations as createTenancyStorageOperations } from "./tenancy/index.js";
|
|
3
|
+
import { createStorageOperations as createSecurityStorageOperations } from "./security/index.js";
|
|
4
|
+
import { createStorageOperations as createKeyValueStorageOperations } from "./keyValueStore/index.js";
|
|
5
|
+
export const createApiCoreDdb = ({
|
|
6
|
+
documentClient
|
|
7
|
+
}) => {
|
|
8
|
+
return {
|
|
9
|
+
usersStorageOperations: createUsersStorageOperations({
|
|
10
|
+
documentClient
|
|
11
|
+
}),
|
|
12
|
+
tenancyStorageOperations: createTenancyStorageOperations({
|
|
13
|
+
documentClient
|
|
14
|
+
}),
|
|
15
|
+
securityStorageOperations: createSecurityStorageOperations({
|
|
16
|
+
documentClient
|
|
17
|
+
}),
|
|
18
|
+
keyValueStorageOperations: createKeyValueStorageOperations({
|
|
19
|
+
documentClient
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=createApiCoreDdb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStorageOperations","createUsersStorageOperations","createTenancyStorageOperations","createSecurityStorageOperations","createKeyValueStorageOperations","createApiCoreDdb","documentClient","usersStorageOperations","tenancyStorageOperations","securityStorageOperations","keyValueStorageOperations"],"sources":["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"],"mappings":"AAEA,SAASA,uBAAuB,IAAIC,4BAA4B;AAChE,SAASD,uBAAuB,IAAIE,8BAA8B;AAClE,SAASF,uBAAuB,IAAIG,+BAA+B;AACnE,SAASH,uBAAuB,IAAII,+BAA+B;AAMnE,OAAO,MAAMC,gBAAgB,GAAGA,CAAC;EAC7BC;AACoB,CAAC,KAA+B;EACpD,OAAO;IACHC,sBAAsB,EAAEN,4BAA4B,CAAC;MACjDK;IACJ,CAAC,CAAC;IACFE,wBAAwB,EAAEN,8BAA8B,CAAC;MACrDI;IACJ,CAAC,CAAC;IACFG,yBAAyB,EAAEN,+BAA+B,CAAC;MACvDG;IACJ,CAAC,CAAC;IACFI,yBAAyB,EAAEN,+BAA+B,CAAC;MACvDE;IACJ,CAAC;EACL,CAAC;AACL,CAAC","ignoreList":[]}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./createApiCoreDdb.js";
|
package/index.js
ADDED
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createApiCoreDdb.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
2
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
3
|
+
interface CreateKeysParams {
|
|
4
|
+
scopedKey: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class KeyValueStoreDynamoTable<T extends GenericRecord> {
|
|
7
|
+
private readonly entity;
|
|
8
|
+
constructor(documentClient: DynamoDBDocument);
|
|
9
|
+
createKeys({ scopedKey }: CreateKeysParams): {
|
|
10
|
+
PK: string;
|
|
11
|
+
SK: string;
|
|
12
|
+
};
|
|
13
|
+
getEntity(): import("@webiny/db-dynamodb").IEntity<import("@webiny/db-dynamodb").IGlobalEntityAttributes<T>>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createGlobalEntity, createTable, globalEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
+
export 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({
|
|
17
|
+
scopedKey
|
|
18
|
+
}) {
|
|
19
|
+
return {
|
|
20
|
+
PK: `KV#${scopedKey}`,
|
|
21
|
+
SK: `A`
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
getEntity() {
|
|
25
|
+
return this.entity;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=KeyValueStoreDynamoTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createGlobalEntity","createTable","globalEntityAttributes","KeyValueStoreDynamoTable","constructor","documentClient","table","name","process","env","DB_TABLE","entity","attributes","createKeys","scopedKey","PK","SK","getEntity"],"sources":["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"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,WAAW,EAAEC,sBAAsB,QAAQ,qBAAqB;AAM7F,OAAO,MAAMC,wBAAwB,CAA0B;EAG3DC,WAAWA,CAACC,cAAgC,EAAE;IAC1C,MAAMC,KAAK,GAAGL,WAAW,CAAC;MACtBM,IAAI,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAkB;MACpCL;IACJ,CAAC,CAAC;IACF,IAAI,CAACM,MAAM,GAAGX,kBAAkB,CAAI;MAChCO,IAAI,EAAE,eAAe;MACrBD,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBM,UAAU,EAAE;QACR,GAAGV;MACP;IACJ,CAAC,CAAC;EACN;EAEAW,UAAUA,CAAC;IAAEC;EAA4B,CAAC,EAAE;IACxC,OAAO;MACHC,EAAE,EAAE,MAAMD,SAAS,EAAE;MACrBE,EAAE,EAAE;IACR,CAAC;EACL;EAEAC,SAASA,CAAA,EAAG;IACR,OAAO,IAAI,CAACN,MAAM;EACtB;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
interface KeyValueRecord {
|
|
3
|
+
key: string;
|
|
4
|
+
value: any;
|
|
5
|
+
scope: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class KeyValueStoreStorageOperations {
|
|
8
|
+
private readonly table;
|
|
9
|
+
private readonly entity;
|
|
10
|
+
constructor(dynamoDbClient: DynamoDBDocument);
|
|
11
|
+
private createScopedKey;
|
|
12
|
+
get(key: string, scope: string): Promise<KeyValueRecord | null>;
|
|
13
|
+
set(key: string, value: any, scope: string): Promise<void>;
|
|
14
|
+
delete(key: string, scope: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { KeyValueStoreDynamoTable } from "./KeyValueStoreDynamoTable.js";
|
|
3
|
+
export class KeyValueStoreStorageOperations {
|
|
4
|
+
constructor(dynamoDbClient) {
|
|
5
|
+
this.table = new KeyValueStoreDynamoTable(dynamoDbClient);
|
|
6
|
+
this.entity = this.table.getEntity();
|
|
7
|
+
}
|
|
8
|
+
createScopedKey(key, scope) {
|
|
9
|
+
return `${scope}:${key}`;
|
|
10
|
+
}
|
|
11
|
+
async get(key, scope) {
|
|
12
|
+
try {
|
|
13
|
+
const scopedKey = this.createScopedKey(key, scope);
|
|
14
|
+
const entry = await this.entity.get(this.table.createKeys({
|
|
15
|
+
scopedKey
|
|
16
|
+
}));
|
|
17
|
+
if (!entry) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Return the user-facing key without scope prefix
|
|
22
|
+
return {
|
|
23
|
+
key,
|
|
24
|
+
value: entry.data.value,
|
|
25
|
+
scope: entry.data.scope
|
|
26
|
+
};
|
|
27
|
+
} catch (err) {
|
|
28
|
+
throw WebinyError.from(err, {
|
|
29
|
+
message: "Could not get key-value record.",
|
|
30
|
+
code: "GET_KEY_VALUE_ERROR",
|
|
31
|
+
data: {
|
|
32
|
+
key,
|
|
33
|
+
scope
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async set(key, value, scope) {
|
|
39
|
+
try {
|
|
40
|
+
const scopedKey = this.createScopedKey(key, scope);
|
|
41
|
+
const keys = this.table.createKeys({
|
|
42
|
+
scopedKey
|
|
43
|
+
});
|
|
44
|
+
await this.entity.put({
|
|
45
|
+
...keys,
|
|
46
|
+
TYPE: "KeyValueStore",
|
|
47
|
+
data: {
|
|
48
|
+
key,
|
|
49
|
+
value,
|
|
50
|
+
scope
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
} catch (err) {
|
|
54
|
+
throw WebinyError.from(err, {
|
|
55
|
+
message: "Could not set key-value record.",
|
|
56
|
+
code: "SET_KEY_VALUE_ERROR",
|
|
57
|
+
data: {
|
|
58
|
+
key,
|
|
59
|
+
scope
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async delete(key, scope) {
|
|
65
|
+
try {
|
|
66
|
+
const scopedKey = this.createScopedKey(key, scope);
|
|
67
|
+
await this.entity.delete(this.table.createKeys({
|
|
68
|
+
scopedKey
|
|
69
|
+
}));
|
|
70
|
+
} catch (err) {
|
|
71
|
+
throw WebinyError.from(err, {
|
|
72
|
+
message: "Could not delete key-value record.",
|
|
73
|
+
code: "DELETE_KEY_VALUE_ERROR",
|
|
74
|
+
data: {
|
|
75
|
+
key,
|
|
76
|
+
scope
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=KeyValueStoreStorageOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","KeyValueStoreDynamoTable","KeyValueStoreStorageOperations","constructor","dynamoDbClient","table","entity","getEntity","createScopedKey","key","scope","get","scopedKey","entry","createKeys","value","data","err","from","message","code","set","keys","put","TYPE","delete"],"sources":["KeyValueStoreStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { KeyValueStoreDynamoTable } from \"./KeyValueStoreDynamoTable.js\";\n\ninterface KeyValueRecord {\n key: string;\n value: any;\n scope: string;\n}\n\nexport class KeyValueStoreStorageOperations {\n private readonly table;\n private readonly entity;\n\n constructor(dynamoDbClient: DynamoDBDocument) {\n this.table = new KeyValueStoreDynamoTable<KeyValueRecord>(dynamoDbClient);\n this.entity = this.table.getEntity();\n }\n\n private createScopedKey(key: string, scope: string): string {\n return `${scope}:${key}`;\n }\n\n async get(key: string, scope: string): Promise<KeyValueRecord | null> {\n try {\n const scopedKey = this.createScopedKey(key, scope);\n const entry = await this.entity.get(this.table.createKeys({ scopedKey }));\n\n if (!entry) {\n return null;\n }\n\n // Return the user-facing key without scope prefix\n return {\n key,\n value: entry.data.value,\n scope: entry.data.scope\n };\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not get key-value record.\",\n code: \"GET_KEY_VALUE_ERROR\",\n data: { key, scope }\n });\n }\n }\n\n async set(key: string, value: any, scope: string): Promise<void> {\n try {\n const scopedKey = this.createScopedKey(key, scope);\n const keys = this.table.createKeys({ scopedKey });\n\n await this.entity.put({\n ...keys,\n TYPE: \"KeyValueStore\",\n data: {\n key,\n value,\n scope\n }\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not set key-value record.\",\n code: \"SET_KEY_VALUE_ERROR\",\n data: { key, scope }\n });\n }\n }\n\n async delete(key: string, scope: string): Promise<void> {\n try {\n const scopedKey = this.createScopedKey(key, scope);\n await this.entity.delete(this.table.createKeys({ scopedKey }));\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete key-value record.\",\n code: \"DELETE_KEY_VALUE_ERROR\",\n data: { key, scope }\n });\n }\n }\n}\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,wBAAwB;AAQjC,OAAO,MAAMC,8BAA8B,CAAC;EAIxCC,WAAWA,CAACC,cAAgC,EAAE;IAC1C,IAAI,CAACC,KAAK,GAAG,IAAIJ,wBAAwB,CAAiBG,cAAc,CAAC;IACzE,IAAI,CAACE,MAAM,GAAG,IAAI,CAACD,KAAK,CAACE,SAAS,CAAC,CAAC;EACxC;EAEQC,eAAeA,CAACC,GAAW,EAAEC,KAAa,EAAU;IACxD,OAAO,GAAGA,KAAK,IAA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CC,IAAI,EAAE,qBAAqB;QAC3BJ,IAAI,EAAE;UAAEP,GAAG;UAAEC;QAAM;MACvB,CAAC,CAAC;IACN;EACJ;EAEA,MAAMe,MAAMA,CAAChB,GAAW,EAAEC,KAAa,EAAiB;IACpD,IAAI;MACA,MAAME,SAAS,GAAG,IAAI,CAACJ,eAAe,CAACC,GAAG,EAAEC,KAAK,CAAC;MAClD,MAAM,IAAI,CAACJ,MAAM,CAACmB,MAAM,CAAC,IAAI,CAACpB,KAAK,CAACS,UAAU,CAAC;QAAEF;MAAU,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,OAAOK,GAAG,EAAE;MACV,MAAMjB,WAAW,CAACkB,IAAI,CAACD,GAAG,EAAE;QACxBE,OAAO,EAAE,oCAAoC;QAC7CC,IAAI,EAAE,wBAAwB;QAC9BJ,IAAI,EAAE;UAAEP,GAAG;UAAEC;QAAM;MACvB,CAAC,CAAC;IACN;EACJ;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
+
import { KeyValueStoreStorageOperations } from "./KeyValueStoreStorageOperations.js";
|
|
3
|
+
export interface CreateKeyValueStoreStorageOperations {
|
|
4
|
+
(params: {
|
|
5
|
+
documentClient: DynamoDBDocument;
|
|
6
|
+
}): KeyValueStoreStorageOperations;
|
|
7
|
+
}
|
|
8
|
+
export declare const createStorageOperations: CreateKeyValueStoreStorageOperations;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["KeyValueStoreStorageOperations","createStorageOperations","params","documentClient"],"sources":["index.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { KeyValueStoreStorageOperations } from \"./KeyValueStoreStorageOperations.js\";\n\nexport interface CreateKeyValueStoreStorageOperations {\n (params: { documentClient: DynamoDBDocument }): KeyValueStoreStorageOperations;\n}\n\nexport const createStorageOperations: CreateKeyValueStoreStorageOperations = params => {\n return new KeyValueStoreStorageOperations(params.documentClient);\n};\n"],"mappings":"AACA,SAASA,8BAA8B;AAMvC,OAAO,MAAMC,uBAA6D,GAAGC,MAAM,IAAI;EACnF,OAAO,IAAIF,8BAA8B,CAACE,MAAM,CAACC,cAAc,CAAC;AACpE,CAAC","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/api-core-ddb",
|
|
3
|
+
"version": "0.0.0-unstable.61c048f412",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"@webiny/api-core",
|
|
12
|
+
"storage-operations",
|
|
13
|
+
"dynamodb",
|
|
14
|
+
"ddb",
|
|
15
|
+
"sau:ddb"
|
|
16
|
+
],
|
|
17
|
+
"description": "DynamoDB-specific dependencies for @webiny/api-core.",
|
|
18
|
+
"author": "Webiny Ltd.",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@webiny/api": "0.0.0-unstable.61c048f412",
|
|
22
|
+
"@webiny/api-core": "0.0.0-unstable.61c048f412",
|
|
23
|
+
"@webiny/aws-sdk": "0.0.0-unstable.61c048f412",
|
|
24
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.61c048f412",
|
|
25
|
+
"@webiny/error": "0.0.0-unstable.61c048f412"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@webiny/api": "0.0.0",
|
|
29
|
+
"@webiny/build-tools": "0.0.0-unstable.61c048f412",
|
|
30
|
+
"@webiny/project-utils": "0.0.0-unstable.61c048f412",
|
|
31
|
+
"jest-dynalite": "3.6.1",
|
|
32
|
+
"rimraf": "6.1.2",
|
|
33
|
+
"typescript": "5.9.3"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"directory": "dist"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "61c048f412d6b4aa70c1d105aab21e3fa69730f3"
|
|
40
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Table } from "@webiny/db-dynamodb/toolbox.js";
|
|
2
|
+
import type { IApiKeyEntity, IRoleEntity, ITeamEntity } from "../../security/definitions/types.js";
|
|
3
|
+
export declare const createRoleEntity: (table: Table<string, string, string>) => IRoleEntity;
|
|
4
|
+
export declare const createTeamEntity: (table: Table<string, string, string>) => ITeamEntity;
|
|
5
|
+
export declare const createApiKeyEntity: (table: Table<string, string, string>) => IApiKeyEntity;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createStandardEntity, standardEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
+
import { ENTITIES } from "../types.js";
|
|
3
|
+
export const createRoleEntity = table => {
|
|
4
|
+
return createStandardEntity({
|
|
5
|
+
name: ENTITIES.ROLE,
|
|
6
|
+
table
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export const createTeamEntity = table => {
|
|
10
|
+
return createStandardEntity({
|
|
11
|
+
name: ENTITIES.TEAM,
|
|
12
|
+
table,
|
|
13
|
+
attributes: {
|
|
14
|
+
...standardEntityAttributes
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export const createApiKeyEntity = table => {
|
|
19
|
+
return createStandardEntity({
|
|
20
|
+
name: ENTITIES.API_KEY,
|
|
21
|
+
table,
|
|
22
|
+
attributes: {
|
|
23
|
+
...standardEntityAttributes
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createStandardEntity","standardEntityAttributes","ENTITIES","createRoleEntity","table","name","ROLE","createTeamEntity","TEAM","attributes","createApiKeyEntity","API_KEY"],"sources":["entities.ts"],"sourcesContent":["import { createStandardEntity, standardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { Table } from \"@webiny/db-dynamodb/toolbox.js\";\nimport { ENTITIES } from \"../types.js\";\nimport type { IApiKeyEntity, IRoleEntity, ITeamEntity } from \"~/security/definitions/types.js\";\nimport type { Role, StorageApiKey, Team } from \"@webiny/api-core/types/security.js\";\n\nexport const createRoleEntity = (table: Table<string, string, string>): IRoleEntity => {\n return createStandardEntity<Role>({\n name: ENTITIES.ROLE,\n table\n });\n};\n\nexport const createTeamEntity = (table: Table<string, string, string>): ITeamEntity => {\n return createStandardEntity<Team>({\n name: ENTITIES.TEAM,\n table,\n attributes: {\n ...standardEntityAttributes\n }\n });\n};\n\nexport const createApiKeyEntity = (table: Table<string, string, string>): IApiKeyEntity => {\n return createStandardEntity<StorageApiKey>({\n name: ENTITIES.API_KEY,\n table,\n attributes: {\n ...standardEntityAttributes\n }\n });\n};\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,wBAAwB,QAAQ,qBAAqB;AAEpF,SAASC,QAAQ;AAIjB,OAAO,MAAMC,gBAAgB,GAAIC,KAAoC,IAAkB;EACnF,OAAOJ,oBAAoB,CAAO;IAC9BK,IAAI,EAAEH,QAAQ,CAACI,IAAI;IACnBF;EACJ,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMG,gBAAgB,GAAIH,KAAoC,IAAkB;EACnF,OAAOJ,oBAAoB,CAAO;IAC9BK,IAAI,EAAEH,QAAQ,CAACM,IAAI;IACnBJ,KAAK;IACLK,UAAU,EAAE;MACR,GAAGR;IACP;EACJ,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMS,kBAAkB,GAAIN,KAAoC,IAAoB;EACvF,OAAOJ,oBAAoB,CAAgB;IACvCK,IAAI,EAAEH,QAAQ,CAACS,OAAO;IACtBP,KAAK;IACLK,UAAU,EAAE;MACR,GAAGR;IACP;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IEntity, IStandardEntityAttributes } from "@webiny/db-dynamodb";
|
|
2
|
+
import type { Role, StorageApiKey, Team } from "@webiny/api-core/types/security.js";
|
|
3
|
+
export interface IRoleEntityAttributes extends IStandardEntityAttributes<Role> {
|
|
4
|
+
TYPE: string;
|
|
5
|
+
}
|
|
6
|
+
export type IRoleEntity = IEntity<IRoleEntityAttributes>;
|
|
7
|
+
export interface ITeamEntityAttributes extends IStandardEntityAttributes<Team> {
|
|
8
|
+
TYPE: string;
|
|
9
|
+
}
|
|
10
|
+
export type ITeamEntity = IEntity<ITeamEntityAttributes>;
|
|
11
|
+
export interface IApiKeyEntityAttributes extends IStandardEntityAttributes<StorageApiKey> {
|
|
12
|
+
TYPE: string;
|
|
13
|
+
}
|
|
14
|
+
export type IApiKeyEntity = IEntity<IApiKeyEntityAttributes>;
|