@webiny/api-core-sql 0.0.0-unstable.0d717d18dd

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.
Files changed (47) hide show
  1. package/ApiCoreSqlFeature.d.ts +13 -0
  2. package/ApiCoreSqlFeature.js +17 -0
  3. package/ApiCoreSqlFeature.js.map +1 -0
  4. package/LICENSE +21 -0
  5. package/README.md +11 -0
  6. package/TableManager.d.ts +16 -0
  7. package/TableManager.js +26 -0
  8. package/TableManager.js.map +1 -0
  9. package/adminUsers/index.d.ts +9 -0
  10. package/adminUsers/index.js +117 -0
  11. package/adminUsers/index.js.map +1 -0
  12. package/createApiCoreSql.d.ts +8 -0
  13. package/createApiCoreSql.js +32 -0
  14. package/createApiCoreSql.js.map +1 -0
  15. package/feature/KnexClient/KnexClient.d.ts +9 -0
  16. package/feature/KnexClient/KnexClient.js +8 -0
  17. package/feature/KnexClient/KnexClient.js.map +1 -0
  18. package/feature/KnexClient/abstractions.d.ts +8 -0
  19. package/feature/KnexClient/abstractions.js +5 -0
  20. package/feature/KnexClient/abstractions.js.map +1 -0
  21. package/feature/KnexClient/index.d.ts +6 -0
  22. package/feature/KnexClient/index.js +15 -0
  23. package/feature/KnexClient/index.js.map +1 -0
  24. package/getSqlTablePrefix.d.ts +1 -0
  25. package/getSqlTablePrefix.js +4 -0
  26. package/getSqlTablePrefix.js.map +1 -0
  27. package/index.d.ts +11 -0
  28. package/index.js +12 -0
  29. package/index.js.map +1 -0
  30. package/keyValueStore/index.d.ts +9 -0
  31. package/keyValueStore/index.js +84 -0
  32. package/keyValueStore/index.js.map +1 -0
  33. package/package.json +43 -0
  34. package/security/index.d.ts +9 -0
  35. package/security/index.js +345 -0
  36. package/security/index.js.map +1 -0
  37. package/serviceDiscovery/SqlServiceManifestLoader.d.ts +13 -0
  38. package/serviceDiscovery/SqlServiceManifestLoader.js +25 -0
  39. package/serviceDiscovery/SqlServiceManifestLoader.js.map +1 -0
  40. package/serviceDiscovery/index.d.ts +1 -0
  41. package/serviceDiscovery/index.js +1 -0
  42. package/sortItems.d.ts +1 -0
  43. package/sortItems.js +31 -0
  44. package/sortItems.js.map +1 -0
  45. package/tenancy/index.d.ts +9 -0
  46. package/tenancy/index.js +111 -0
  47. package/tenancy/index.js.map +1 -0
@@ -0,0 +1,13 @@
1
+ import type { Knex } from "knex";
2
+ export interface ApiCoreSqlConfig {
3
+ knex: Knex;
4
+ tableNamePrefix?: string;
5
+ }
6
+ /**
7
+ * Registers the SQL implementation of ApiCoreStorageOperationsFactory. ApiCoreFeature.register
8
+ * resolves + builds it. Mirrors ApiCoreDdbFeature.
9
+ */
10
+ export declare const ApiCoreSqlFeature: {
11
+ name: string;
12
+ register(container: import("@webiny/di").Container, context: ApiCoreSqlConfig): void;
13
+ };
@@ -0,0 +1,17 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { ApiCoreStorageOperationsFactory } from "@webiny/api-core";
3
+ import { createApiCoreSql } from "./createApiCoreSql.js";
4
+ const ApiCoreSqlFeature = createFeature({
5
+ name: "ApiCoreSql",
6
+ register (container, { knex, tableNamePrefix }) {
7
+ container.registerInstance(ApiCoreStorageOperationsFactory, {
8
+ create: ()=>createApiCoreSql({
9
+ knex,
10
+ tableNamePrefix
11
+ })
12
+ });
13
+ }
14
+ });
15
+ export { ApiCoreSqlFeature };
16
+
17
+ //# sourceMappingURL=ApiCoreSqlFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiCoreSqlFeature.js","sources":["../src/ApiCoreSqlFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Knex } from \"knex\";\nimport { ApiCoreStorageOperationsFactory } from \"@webiny/api-core\";\nimport { createApiCoreSql } from \"./createApiCoreSql.js\";\n\nexport interface ApiCoreSqlConfig {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\n/**\n * Registers the SQL implementation of ApiCoreStorageOperationsFactory. ApiCoreFeature.register\n * resolves + builds it. Mirrors ApiCoreDdbFeature.\n */\nexport const ApiCoreSqlFeature = createFeature<ApiCoreSqlConfig>({\n name: \"ApiCoreSql\",\n register(container, { knex, tableNamePrefix }) {\n container.registerInstance(ApiCoreStorageOperationsFactory, {\n create: () => createApiCoreSql({ knex, tableNamePrefix })\n });\n }\n});\n"],"names":["ApiCoreSqlFeature","createFeature","container","knex","tableNamePrefix","ApiCoreStorageOperationsFactory","createApiCoreSql"],"mappings":";;;AAcO,MAAMA,oBAAoBC,cAAgC;IAC7D,MAAM;IACN,UAASC,SAAS,EAAE,EAAEC,IAAI,EAAEC,eAAe,EAAE;QACzCF,UAAU,gBAAgB,CAACG,iCAAiC;YACxD,QAAQ,IAAMC,iBAAiB;oBAAEH;oBAAMC;gBAAgB;QAC3D;IACJ;AACJ"}
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-sql
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,16 @@
1
+ import type { Knex } from "knex";
2
+ interface ITableManager {
3
+ reset(): void;
4
+ resolve(tableName: string): string;
5
+ ensure(tableName: string, creator: (table: Knex.CreateTableBuilder) => void): Promise<void>;
6
+ }
7
+ export declare class TableManager implements ITableManager {
8
+ private readonly knex;
9
+ private readonly prefix;
10
+ private readonly verified;
11
+ constructor(knex: Knex, prefix?: string);
12
+ reset(): void;
13
+ resolve(tableName: string): string;
14
+ ensure(tableName: string, creator: (table: Knex.CreateTableBuilder) => void): Promise<void>;
15
+ }
16
+ export {};
@@ -0,0 +1,26 @@
1
+ class TableManager {
2
+ constructor(knex, prefix = ""){
3
+ this.verified = new Set();
4
+ this.knex = knex;
5
+ this.prefix = prefix ? `${prefix}_` : "";
6
+ const g = globalThis;
7
+ const managers = g.__sqlTableManagers ??= [];
8
+ managers.push(this);
9
+ }
10
+ reset() {
11
+ this.verified.clear();
12
+ }
13
+ resolve(tableName) {
14
+ return `${this.prefix}${tableName}`;
15
+ }
16
+ async ensure(tableName, creator) {
17
+ const resolved = this.resolve(tableName);
18
+ if (this.verified.has(resolved)) return;
19
+ const exists = await this.knex.schema.hasTable(resolved);
20
+ if (!exists) await this.knex.schema.createTable(resolved, creator);
21
+ this.verified.add(resolved);
22
+ }
23
+ }
24
+ export { TableManager };
25
+
26
+ //# sourceMappingURL=TableManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableManager.js","sources":["../src/TableManager.ts"],"sourcesContent":["import type { Knex } from \"knex\";\n\ninterface ITableManager {\n reset(): void;\n resolve(tableName: string): string;\n ensure(tableName: string, creator: (table: Knex.CreateTableBuilder) => void): Promise<void>;\n}\n\nexport class TableManager implements ITableManager {\n private readonly knex: Knex;\n private readonly prefix: string;\n private readonly verified = new Set<string>();\n\n constructor(knex: Knex, prefix: string = \"\") {\n this.knex = knex;\n this.prefix = prefix ? `${prefix}_` : \"\";\n\n const g = globalThis as Record<string, unknown>;\n const managers = (g.__sqlTableManagers ??= []) as ITableManager[];\n managers.push(this);\n }\n\n public reset(): void {\n this.verified.clear();\n }\n\n public resolve(tableName: string): string {\n return `${this.prefix}${tableName}`;\n }\n\n public async ensure(\n tableName: string,\n creator: (table: Knex.CreateTableBuilder) => void\n ): Promise<void> {\n const resolved = this.resolve(tableName);\n\n if (this.verified.has(resolved)) {\n return;\n }\n\n const exists = await this.knex.schema.hasTable(resolved);\n\n if (!exists) {\n await this.knex.schema.createTable(resolved, creator);\n }\n\n this.verified.add(resolved);\n }\n}\n"],"names":["TableManager","knex","prefix","Set","g","globalThis","managers","tableName","creator","resolved","exists"],"mappings":"AAQO,MAAMA;IAKT,YAAYC,IAAU,EAAEC,SAAiB,EAAE,CAAE;aAF5B,QAAQ,GAAG,IAAIC;QAG5B,IAAI,CAAC,IAAI,GAAGF;QACZ,IAAI,CAAC,MAAM,GAAGC,SAAS,GAAGA,OAAO,CAAC,CAAC,GAAG;QAEtC,MAAME,IAAIC;QACV,MAAMC,WAAYF,EAAE,kBAAkB,KAAK,EAAE;QAC7CE,SAAS,IAAI,CAAC,IAAI;IACtB;IAEO,QAAc;QACjB,IAAI,CAAC,QAAQ,CAAC,KAAK;IACvB;IAEO,QAAQC,SAAiB,EAAU;QACtC,OAAO,GAAG,IAAI,CAAC,MAAM,GAAGA,WAAW;IACvC;IAEA,MAAa,OACTA,SAAiB,EACjBC,OAAiD,EACpC;QACb,MAAMC,WAAW,IAAI,CAAC,OAAO,CAACF;QAE9B,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACE,WAClB;QAGJ,MAAMC,SAAS,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAACD;QAE/C,IAAI,CAACC,QACD,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAACD,UAAUD;QAGjD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACC;IACtB;AACJ"}
@@ -0,0 +1,9 @@
1
+ import type { Knex } from "knex";
2
+ import type { AdminUsersStorageOperations } from "@webiny/api-core/types/users.js";
3
+ import type { TableManager } from "../TableManager.js";
4
+ interface CreateStorageOperationsParams {
5
+ knex: Knex;
6
+ tableManager: TableManager;
7
+ }
8
+ export declare const createStorageOperations: (params: CreateStorageOperationsParams) => AdminUsersStorageOperations;
9
+ export {};
@@ -0,0 +1,117 @@
1
+ import error from "@webiny/error";
2
+ import { sortItems } from "../sortItems.js";
3
+ const TABLE_NAME = "webiny_core_admin_users";
4
+ const userToRow = (user)=>({
5
+ id: user.id,
6
+ tenant: user.tenant,
7
+ email: user.email,
8
+ data: JSON.stringify(user)
9
+ });
10
+ const rowToUser = (row)=>JSON.parse(row.data);
11
+ const createStorageOperations = (params)=>{
12
+ const { knex, tableManager } = params;
13
+ const ensureTable = ()=>tableManager.ensure(TABLE_NAME, (table)=>{
14
+ table.text("id").notNullable();
15
+ table.text("tenant").notNullable();
16
+ table.text("email").notNullable();
17
+ table.text("data").notNullable();
18
+ table.primary([
19
+ "tenant",
20
+ "id"
21
+ ]);
22
+ table.unique([
23
+ "tenant",
24
+ "email"
25
+ ]);
26
+ });
27
+ const query = ()=>knex(tableManager.resolve(TABLE_NAME));
28
+ return {
29
+ async getUser (params) {
30
+ await ensureTable();
31
+ const { where: { tenant, id, email } } = params;
32
+ try {
33
+ if (id) {
34
+ const row = await query().where("tenant", tenant).andWhere("id", id).first();
35
+ return row ? rowToUser(row) : null;
36
+ }
37
+ const row = await query().where("tenant", tenant).andWhere("email", email).first();
38
+ return row ? rowToUser(row) : null;
39
+ } catch (err) {
40
+ throw error.from(err, {
41
+ message: "Could not load user.",
42
+ code: "GET_ADMIN_USERS_ERROR",
43
+ data: {
44
+ id,
45
+ email
46
+ }
47
+ });
48
+ }
49
+ },
50
+ async listUsers (params) {
51
+ await ensureTable();
52
+ const { where, sort } = params;
53
+ try {
54
+ const rows = await query().where("tenant", where.tenant);
55
+ let items = rows.map((row)=>rowToUser(row));
56
+ items = sortItems(items, sort);
57
+ const { id_in } = where;
58
+ if (Array.isArray(id_in)) return items.filter((item)=>id_in.includes(item.id));
59
+ return items;
60
+ } catch (err) {
61
+ throw error.from(err, {
62
+ message: "Could not list users.",
63
+ code: "LIST_ADMIN_USERS_ERROR"
64
+ });
65
+ }
66
+ },
67
+ async createUser ({ user }) {
68
+ await ensureTable();
69
+ try {
70
+ const row = userToRow(user);
71
+ await query().insert(row);
72
+ return user;
73
+ } catch (err) {
74
+ throw error.from(err, {
75
+ message: "Could not create admin user.",
76
+ code: "CREATE_ADMIN_USER_ERROR",
77
+ data: {
78
+ user
79
+ }
80
+ });
81
+ }
82
+ },
83
+ async updateUser ({ user }) {
84
+ await ensureTable();
85
+ try {
86
+ const row = userToRow(user);
87
+ await query().where("tenant", user.tenant).andWhere("id", user.id).update(row);
88
+ return user;
89
+ } catch (err) {
90
+ throw error.from(err, {
91
+ message: "Could not update user.",
92
+ code: "UPDATE_ADMIN_USER_ERROR",
93
+ data: {
94
+ user
95
+ }
96
+ });
97
+ }
98
+ },
99
+ async deleteUser ({ user }) {
100
+ await ensureTable();
101
+ try {
102
+ await query().where("tenant", user.tenant).andWhere("id", user.id).delete();
103
+ } catch (err) {
104
+ throw error.from(err, {
105
+ message: "Could not delete user.",
106
+ code: "DELETE_ADMIN_USER_ERROR",
107
+ data: {
108
+ user
109
+ }
110
+ });
111
+ }
112
+ }
113
+ };
114
+ };
115
+ export { createStorageOperations };
116
+
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminUsers/index.js","sources":["../../src/adminUsers/index.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n AdminUser,\n AdminUsersStorageOperations,\n StorageOperationsGetUserParams,\n StorageOperationsListUsersParams\n} from \"@webiny/api-core/types/users.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { TableManager } from \"~/TableManager.js\";\nimport { sortItems } from \"~/sortItems.js\";\n\nconst TABLE_NAME = \"webiny_core_admin_users\";\n\ninterface IAdminUserRow {\n id: string;\n tenant: string;\n email: string;\n data: string;\n}\n\nconst userToRow = (user: AdminUser): IAdminUserRow => {\n return {\n id: user.id,\n tenant: user.tenant,\n email: user.email,\n data: JSON.stringify(user)\n };\n};\n\nconst rowToUser = <TUser extends AdminUser = AdminUser>(row: IAdminUserRow): TUser => {\n return JSON.parse(row.data) as TUser;\n};\n\ninterface CreateStorageOperationsParams {\n knex: Knex;\n tableManager: TableManager;\n}\n\nexport const createStorageOperations = (\n params: CreateStorageOperationsParams\n): AdminUsersStorageOperations => {\n const { knex, tableManager } = params;\n\n const ensureTable = () => {\n return tableManager.ensure(TABLE_NAME, table => {\n table.text(\"id\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"email\").notNullable();\n table.text(\"data\").notNullable();\n\n table.primary([\"tenant\", \"id\"]);\n table.unique([\"tenant\", \"email\"]);\n });\n };\n\n const query = () => {\n return knex<IAdminUserRow>(tableManager.resolve(TABLE_NAME));\n };\n\n return {\n async getUser<TUser extends AdminUser = AdminUser>(\n params: StorageOperationsGetUserParams\n ): Promise<TUser | null> {\n await ensureTable();\n\n const {\n where: { tenant, id, email }\n } = params;\n\n try {\n if (id) {\n const row = await query().where(\"tenant\", tenant).andWhere(\"id\", id).first();\n\n return row ? rowToUser<TUser>(row) : null;\n }\n\n const row = await query()\n .where(\"tenant\", tenant)\n .andWhere(\"email\", email as string)\n .first();\n\n return row ? rowToUser<TUser>(row) : 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\n async listUsers<TUser extends AdminUser = AdminUser>(\n params: StorageOperationsListUsersParams\n ): Promise<TUser[]> {\n await ensureTable();\n\n const { where, sort } = params;\n\n try {\n const rows = await query().where(\"tenant\", where.tenant);\n\n let items = rows.map(row => rowToUser<TUser>(row));\n\n items = sortItems(items, sort);\n\n const { id_in } = where;\n\n if (Array.isArray(id_in)) {\n return items.filter(item => id_in.includes(item.id));\n }\n\n return items;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list users.\",\n code: \"LIST_ADMIN_USERS_ERROR\"\n });\n }\n },\n\n async createUser<TUser extends AdminUser = AdminUser>({\n user\n }: {\n user: TUser;\n }): Promise<TUser> {\n await ensureTable();\n\n try {\n const row = userToRow(user);\n await query().insert(row);\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: { user }\n });\n }\n },\n\n async updateUser<TUser extends AdminUser = AdminUser>({\n user\n }: {\n user: TUser;\n }): Promise<TUser> {\n await ensureTable();\n\n try {\n const row = userToRow(user);\n await query().where(\"tenant\", user.tenant).andWhere(\"id\", user.id).update(row);\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: { user }\n });\n }\n },\n\n async deleteUser<TUser extends AdminUser = AdminUser>({\n user\n }: {\n user: TUser;\n }): Promise<void> {\n await ensureTable();\n\n try {\n await query().where(\"tenant\", user.tenant).andWhere(\"id\", user.id).delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete user.\",\n code: \"DELETE_ADMIN_USER_ERROR\",\n data: { user }\n });\n }\n }\n };\n};\n"],"names":["TABLE_NAME","userToRow","user","JSON","rowToUser","row","createStorageOperations","params","knex","tableManager","ensureTable","table","query","tenant","id","email","err","WebinyError","where","sort","rows","items","sortItems","id_in","Array","item"],"mappings":";;AAWA,MAAMA,aAAa;AASnB,MAAMC,YAAY,CAACC,OACR;QACH,IAAIA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AK,MAAM,EAAE,QAAQ,CAAC,MAAMA,KAAK,EAAE,EAAE,MAAM;YAC7E,EAAE,OAAOc,KAAK;gBACV,MAAMC,MAAAA,IAAgB,CAACD,KAAK;oBACxB,SAAS;oBACT,MAAM;oBACN,MAAM;wBAAEd;oBAAK;gBACjB;YACJ;QACJ;IACJ;AACJ"}
@@ -0,0 +1,8 @@
1
+ import type { Knex } from "knex";
2
+ import type { ApiCoreStorageOperations } from "@webiny/api-core/types/core.js";
3
+ interface CreateApiCoreSqlParams {
4
+ knex: Knex;
5
+ tableNamePrefix?: string;
6
+ }
7
+ export declare const createApiCoreSql: ({ knex, tableNamePrefix }: CreateApiCoreSqlParams) => ApiCoreStorageOperations;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ServiceDiscovery } from "@webiny/api-core/features/serviceDiscovery/index.js";
2
+ import { createStorageOperations } from "./adminUsers/index.js";
3
+ import { createStorageOperations as index_js_createStorageOperations } from "./tenancy/index.js";
4
+ import { createStorageOperations as external_security_index_js_createStorageOperations } from "./security/index.js";
5
+ import { createStorageOperations as external_keyValueStore_index_js_createStorageOperations } from "./keyValueStore/index.js";
6
+ import { TableManager } from "./TableManager.js";
7
+ import { SqlServiceManifestLoader } from "./serviceDiscovery/index.js";
8
+ const createApiCoreSql = ({ knex, tableNamePrefix })=>{
9
+ const tableManager = new TableManager(knex, tableNamePrefix);
10
+ ServiceDiscovery.setLoader(new SqlServiceManifestLoader(knex, tableManager));
11
+ return {
12
+ usersStorageOperations: createStorageOperations({
13
+ knex,
14
+ tableManager
15
+ }),
16
+ tenancyStorageOperations: index_js_createStorageOperations({
17
+ knex,
18
+ tableManager
19
+ }),
20
+ securityStorageOperations: external_security_index_js_createStorageOperations({
21
+ knex,
22
+ tableManager
23
+ }),
24
+ keyValueStorageOperations: external_keyValueStore_index_js_createStorageOperations({
25
+ knex,
26
+ tableManager
27
+ })
28
+ };
29
+ };
30
+ export { createApiCoreSql };
31
+
32
+ //# sourceMappingURL=createApiCoreSql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createApiCoreSql.js","sources":["../src/createApiCoreSql.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type { ApiCoreStorageOperations } from \"@webiny/api-core/types/core.js\";\nimport { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/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\";\nimport { TableManager } from \"./TableManager.js\";\nimport { SqlServiceManifestLoader } from \"./serviceDiscovery/index.js\";\n\ninterface CreateApiCoreSqlParams {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\nexport const createApiCoreSql = ({\n knex,\n tableNamePrefix\n}: CreateApiCoreSqlParams): ApiCoreStorageOperations => {\n const tableManager = new TableManager(knex, tableNamePrefix);\n\n ServiceDiscovery.setLoader(new SqlServiceManifestLoader(knex, tableManager));\n\n return {\n usersStorageOperations: createUsersStorageOperations({\n knex,\n tableManager\n }),\n tenancyStorageOperations: createTenancyStorageOperations({\n knex,\n tableManager\n }),\n securityStorageOperations: createSecurityStorageOperations({\n knex,\n tableManager\n }),\n keyValueStorageOperations: createKeyValueStorageOperations({\n knex,\n tableManager\n })\n };\n};\n"],"names":["createApiCoreSql","knex","tableNamePrefix","tableManager","TableManager","ServiceDiscovery","SqlServiceManifestLoader","createUsersStorageOperations","createTenancyStorageOperations","createSecurityStorageOperations","createKeyValueStorageOperations"],"mappings":";;;;;;;AAeO,MAAMA,mBAAmB,CAAC,EAC7BC,IAAI,EACJC,eAAe,EACM;IACrB,MAAMC,eAAe,IAAIC,aAAaH,MAAMC;IAE5CG,iBAAiB,SAAS,CAAC,IAAIC,yBAAyBL,MAAME;IAE9D,OAAO;QACH,wBAAwBI,wBAA6B;YACjDN;YACAE;QACJ;QACA,0BAA0BK,iCAA+B;YACrDP;YACAE;QACJ;QACA,2BAA2BM,mDAAgC;YACvDR;YACAE;QACJ;QACA,2BAA2BO,wDAAgC;YACvDT;YACAE;QACJ;IACJ;AACJ"}
@@ -0,0 +1,9 @@
1
+ import type { Knex } from "knex";
2
+ import type { KnexClient as Abstraction } from "./abstractions.js";
3
+ export interface IKnexClientParams {
4
+ knex: Knex;
5
+ }
6
+ export declare class KnexClient implements Abstraction.Interface {
7
+ readonly client: Knex<any, any[]>;
8
+ constructor(params: IKnexClientParams);
9
+ }
@@ -0,0 +1,8 @@
1
+ class KnexClient {
2
+ constructor(params){
3
+ this.client = params.knex;
4
+ }
5
+ }
6
+ export { KnexClient };
7
+
8
+ //# sourceMappingURL=KnexClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/KnexClient/KnexClient.js","sources":["../../../src/feature/KnexClient/KnexClient.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type { KnexClient as Abstraction } from \"./abstractions.js\";\n\nexport interface IKnexClientParams {\n knex: Knex;\n}\n\nexport class KnexClient implements Abstraction.Interface {\n public readonly client;\n\n public constructor(params: IKnexClientParams) {\n this.client = params.knex;\n }\n}\n"],"names":["KnexClient","params"],"mappings":"AAOO,MAAMA;IAGT,YAAmBC,MAAyB,CAAE;QAC1C,IAAI,CAAC,MAAM,GAAGA,OAAO,IAAI;IAC7B;AACJ"}
@@ -0,0 +1,8 @@
1
+ import type { Knex } from "knex";
2
+ export interface IKnexClient {
3
+ readonly client: Knex;
4
+ }
5
+ export declare const KnexClient: import("@webiny/di").Abstraction<IKnexClient>;
6
+ export declare namespace KnexClient {
7
+ type Interface = IKnexClient;
8
+ }
@@ -0,0 +1,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const KnexClient = createAbstraction("Db/Sql/KnexClient");
3
+ export { KnexClient };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/KnexClient/abstractions.js","sources":["../../../src/feature/KnexClient/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Knex } from \"knex\";\n\nexport interface IKnexClient {\n readonly client: Knex;\n}\n\nexport const KnexClient = createAbstraction<IKnexClient>(\"Db/Sql/KnexClient\");\n\nexport namespace KnexClient {\n export type Interface = IKnexClient;\n}\n"],"names":["KnexClient","createAbstraction"],"mappings":";AAOO,MAAMA,aAAaC,kBAA+B"}
@@ -0,0 +1,6 @@
1
+ import type { Knex } from "knex";
2
+ export { KnexClient } from "./abstractions.js";
3
+ export declare const KnexClientFeature: {
4
+ name: string;
5
+ register(container: import("@webiny/di").Container, context: Knex<any, any[]>): void;
6
+ };
@@ -0,0 +1,15 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { KnexClient } from "./abstractions.js";
3
+ import { KnexClient as external_KnexClient_js_KnexClient } from "./KnexClient.js";
4
+ const KnexClientFeature = createFeature({
5
+ name: "Db/Sql/KnexClientFeature",
6
+ register (container, knex) {
7
+ const client = new external_KnexClient_js_KnexClient({
8
+ knex
9
+ });
10
+ container.registerInstance(KnexClient, client);
11
+ }
12
+ });
13
+ export { KnexClient, KnexClientFeature };
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature/KnexClient/index.js","sources":["../../../src/feature/KnexClient/index.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { Knex } from \"knex\";\nimport { KnexClient as KnexClientAbstraction } from \"./abstractions.js\";\nimport { KnexClient } from \"./KnexClient.js\";\n\nexport { KnexClient } from \"./abstractions.js\";\n\nexport const KnexClientFeature = createFeature<Knex>({\n name: \"Db/Sql/KnexClientFeature\",\n register(container, knex) {\n const client = new KnexClient({ knex });\n container.registerInstance(KnexClientAbstraction, client);\n }\n});\n"],"names":["KnexClientFeature","createFeature","container","knex","client","KnexClient","KnexClientAbstraction"],"mappings":";;;AAOO,MAAMA,oBAAoBC,cAAoB;IACjD,MAAM;IACN,UAASC,SAAS,EAAEC,IAAI;QACpB,MAAMC,SAAS,IAAIC,kCAAW;YAAEF;QAAK;QACrCD,UAAU,gBAAgB,CAACI,YAAuBF;IACtD;AACJ"}
@@ -0,0 +1 @@
1
+ export declare const getSqlTablePrefix: () => string;
@@ -0,0 +1,4 @@
1
+ const getSqlTablePrefix = ()=>process.env.SQL_TABLE_PREFIX || process.env.WEBINY_SQL_TABLE_PREFIX || "";
2
+ export { getSqlTablePrefix };
3
+
4
+ //# sourceMappingURL=getSqlTablePrefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSqlTablePrefix.js","sources":["../src/getSqlTablePrefix.ts"],"sourcesContent":["export const getSqlTablePrefix = (): string => {\n return process.env.SQL_TABLE_PREFIX || process.env.WEBINY_SQL_TABLE_PREFIX || \"\";\n};\n"],"names":["getSqlTablePrefix","process"],"mappings":"AAAO,MAAMA,oBAAoB,IACtBC,QAAQ,GAAG,CAAC,gBAAgB,IAAIA,QAAQ,GAAG,CAAC,uBAAuB,IAAI"}
package/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { Knex } from "knex";
2
+ export { createApiCoreSql } from "./createApiCoreSql.js";
3
+ export { ApiCoreSqlFeature } from "./ApiCoreSqlFeature.js";
4
+ export type { ApiCoreSqlConfig } from "./ApiCoreSqlFeature.js";
5
+ export { getSqlTablePrefix } from "./getSqlTablePrefix.js";
6
+ export { SqlServiceManifestLoader } from "./serviceDiscovery/index.js";
7
+ export { KnexClient } from "./feature/KnexClient/index.js";
8
+ interface IRegisterApiCoreSqlExtension {
9
+ knex: Knex;
10
+ }
11
+ export declare const registerSQLCore: ({ knex }: IRegisterApiCoreSqlExtension) => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
package/index.js ADDED
@@ -0,0 +1,12 @@
1
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
2
+ import { KnexClient, KnexClientFeature } from "./feature/KnexClient/index.js";
3
+ const registerSQLCore = ({ knex })=>createRegisterExtensionPlugin(async (context)=>{
4
+ KnexClientFeature.register(context.container, knex);
5
+ });
6
+ export { createApiCoreSql } from "./createApiCoreSql.js";
7
+ export { ApiCoreSqlFeature } from "./ApiCoreSqlFeature.js";
8
+ export { getSqlTablePrefix } from "./getSqlTablePrefix.js";
9
+ export { SqlServiceManifestLoader } from "./serviceDiscovery/index.js";
10
+ export { KnexClient, registerSQLCore };
11
+
12
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport type { Knex } from \"knex\";\nimport { KnexClientFeature } from \"./feature/KnexClient/index.js\";\n\nexport { createApiCoreSql } from \"./createApiCoreSql.js\";\nexport { ApiCoreSqlFeature } from \"./ApiCoreSqlFeature.js\";\nexport type { ApiCoreSqlConfig } from \"./ApiCoreSqlFeature.js\";\nexport { getSqlTablePrefix } from \"./getSqlTablePrefix.js\";\nexport { SqlServiceManifestLoader } from \"./serviceDiscovery/index.js\";\n\nexport { KnexClient } from \"./feature/KnexClient/index.js\";\n\ninterface IRegisterApiCoreSqlExtension {\n knex: Knex;\n}\n\nexport const registerSQLCore = ({ knex }: IRegisterApiCoreSqlExtension) => {\n return createRegisterExtensionPlugin(async context => {\n KnexClientFeature.register(context.container, knex);\n });\n};\n"],"names":["registerSQLCore","knex","createRegisterExtensionPlugin","context","KnexClientFeature"],"mappings":";;AAgBO,MAAMA,kBAAkB,CAAC,EAAEC,IAAI,EAAgC,GAC3DC,8BAA8B,OAAMC;QACvCC,kBAAkB,QAAQ,CAACD,QAAQ,SAAS,EAAEF;IAClD"}
@@ -0,0 +1,9 @@
1
+ import type { Knex } from "knex";
2
+ import type { IKeyValueStorageOperations } from "@webiny/api-core/features/keyValueStore/abstractions.js";
3
+ import type { TableManager } from "../TableManager.js";
4
+ interface CreateStorageOperationsParams {
5
+ knex: Knex;
6
+ tableManager: TableManager;
7
+ }
8
+ export declare const createStorageOperations: (params: CreateStorageOperationsParams) => IKeyValueStorageOperations;
9
+ export {};
@@ -0,0 +1,84 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ const TABLE_NAME = "webiny_core_key_value";
3
+ const createStorageOperations = (params)=>{
4
+ const { knex, tableManager } = params;
5
+ const ensureTable = ()=>tableManager.ensure(TABLE_NAME, (table)=>{
6
+ table.text("scopedKey").primary().notNullable();
7
+ table.text("key").notNullable();
8
+ table.text("scope").notNullable();
9
+ table.text("value").notNullable();
10
+ table.datetime("expiresAt");
11
+ });
12
+ const query = ()=>knex(tableManager.resolve(TABLE_NAME));
13
+ const createScopedKey = (key, scope)=>`${scope}:${key}`;
14
+ return {
15
+ async get (key, scope) {
16
+ await ensureTable();
17
+ try {
18
+ const scopedKey = createScopedKey(key, scope);
19
+ const row = await query().where("scopedKey", scopedKey).first();
20
+ if (!row) return null;
21
+ if (row.expiresAt && new Date(row.expiresAt) <= new Date()) {
22
+ await query().where("scopedKey", scopedKey).delete();
23
+ return null;
24
+ }
25
+ return {
26
+ key,
27
+ value: JSON.parse(row.value)
28
+ };
29
+ } catch (err) {
30
+ throw WebinyError.from(err, {
31
+ message: "Could not get key-value record.",
32
+ code: "GET_KEY_VALUE_ERROR",
33
+ data: {
34
+ key,
35
+ scope
36
+ }
37
+ });
38
+ }
39
+ },
40
+ async set (key, value, scope, options) {
41
+ await ensureTable();
42
+ try {
43
+ const scopedKey = createScopedKey(key, scope);
44
+ const expiresAt = options?.expiresAt ?? null;
45
+ const row = {
46
+ scopedKey,
47
+ key,
48
+ scope,
49
+ value: JSON.stringify(value),
50
+ expiresAt
51
+ };
52
+ await query().insert(row).onConflict("scopedKey").merge();
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
+ await ensureTable();
66
+ try {
67
+ const scopedKey = createScopedKey(key, scope);
68
+ await query().where("scopedKey", scopedKey).delete();
69
+ } catch (err) {
70
+ throw WebinyError.from(err, {
71
+ message: "Could not delete key-value record.",
72
+ code: "DELETE_KEY_VALUE_ERROR",
73
+ data: {
74
+ key,
75
+ scope
76
+ }
77
+ });
78
+ }
79
+ }
80
+ };
81
+ };
82
+ export { createStorageOperations };
83
+
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyValueStore/index.js","sources":["../../src/keyValueStore/index.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n IKeyValueStorageOperations,\n IKeyValueStoreSetOptions\n} from \"@webiny/api-core/features/keyValueStore/abstractions.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport type { TableManager } from \"~/TableManager.js\";\n\nconst TABLE_NAME = \"webiny_core_key_value\";\n\ninterface IKeyValueRow {\n scopedKey: string;\n key: string;\n scope: string;\n value: string;\n expiresAt: Date | null;\n}\n\ninterface CreateStorageOperationsParams {\n knex: Knex;\n tableManager: TableManager;\n}\n\nexport const createStorageOperations = (\n params: CreateStorageOperationsParams\n): IKeyValueStorageOperations => {\n const { knex, tableManager } = params;\n\n const ensureTable = () => {\n return tableManager.ensure(TABLE_NAME, table => {\n table.text(\"scopedKey\").primary().notNullable();\n table.text(\"key\").notNullable();\n table.text(\"scope\").notNullable();\n table.text(\"value\").notNullable();\n table.datetime(\"expiresAt\");\n });\n };\n\n const query = () => {\n return knex<IKeyValueRow>(tableManager.resolve(TABLE_NAME));\n };\n\n const createScopedKey = (key: string, scope: string): string => {\n return `${scope}:${key}`;\n };\n\n return {\n async get(key: string, scope: string) {\n await ensureTable();\n\n try {\n const scopedKey = createScopedKey(key, scope);\n const row = await query().where(\"scopedKey\", scopedKey).first();\n\n if (!row) {\n return null;\n }\n\n if (row.expiresAt && new Date(row.expiresAt) <= new Date()) {\n await query().where(\"scopedKey\", scopedKey).delete();\n return null;\n }\n\n return {\n key,\n value: JSON.parse(row.value)\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, options?: IKeyValueStoreSetOptions) {\n await ensureTable();\n\n try {\n const scopedKey = createScopedKey(key, scope);\n const expiresAt = options?.expiresAt ?? null;\n\n const row: IKeyValueRow = {\n scopedKey,\n key,\n scope,\n value: JSON.stringify(value),\n expiresAt\n };\n\n await query().insert(row).onConflict(\"scopedKey\").merge();\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) {\n await ensureTable();\n\n try {\n const scopedKey = createScopedKey(key, scope);\n await query().where(\"scopedKey\", scopedKey).delete();\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};\n"],"names":["TABLE_NAME","createStorageOperations","params","knex","tableManager","ensureTable","table","query","createScopedKey","key","scope","scopedKey","row","Date","JSON","err","WebinyError","value","options","expiresAt"],"mappings":";AAQA,MAAMA,aAAa;AAeZ,MAAMC,0BAA0B,CACnCC;IAEA,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAE,GAAGF;IAE/B,MAAMG,cAAc,IACTD,aAAa,MAAM,CAACJ,YAAYM,CAAAA;YACnCA,MAAM,IAAI,CAAC,aAAa,OAAO,GAAG,WAAW;YAC7CA,MAAM,IAAI,CAAC,OAAO,WAAW;YAC7BA,MAAM,IAAI,CAAC,SAAS,WAAW;YAC/BA,MAAM,IAAI,CAAC,SAAS,WAAW;YAC/BA,MAAM,QAAQ,CAAC;QACnB;IAGJ,MAAMC,QAAQ,IACHJ,KAAmBC,aAAa,OAAO,CAACJ;IAGnD,MAAMQ,kBAAkB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WAAW,MAAM;YACtD,EAAE,OAAOI,KAAK;gBACV,MAAMC,YAAY,IAAI,CAACD,KAAK;oBACxB,SAAS;oBACT,MAAM;oBACN,MAAM;wBAAEN;wBAAKC;oBAAM;gBACvB;YACJ;QACJ;IACJ;AACJ"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@webiny/api-core-sql",
3
+ "version": "0.0.0-unstable.0d717d18dd",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/webiny/webiny-js.git"
12
+ },
13
+ "keywords": [
14
+ "@webiny/api-core",
15
+ "storage-operations",
16
+ "sql",
17
+ "knex",
18
+ "sau:sql"
19
+ ],
20
+ "description": "SQL-specific dependencies for @webiny/api-core.",
21
+ "author": "Webiny Ltd.",
22
+ "license": "MIT",
23
+ "dependencies": {
24
+ "@webiny/api-core": "0.0.0-unstable.0d717d18dd",
25
+ "@webiny/error": "0.0.0-unstable.0d717d18dd",
26
+ "@webiny/feature": "0.0.0-unstable.0d717d18dd",
27
+ "@webiny/handler": "0.0.0-unstable.0d717d18dd",
28
+ "knex": "3.3.0"
29
+ },
30
+ "devDependencies": {
31
+ "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
32
+ "@webiny/project-utils": "0.0.0-unstable.0d717d18dd",
33
+ "better-sqlite3": "13.0.2",
34
+ "typescript": "7.0.2",
35
+ "vitest": "4.1.10"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "webiny": {
41
+ "publishFrom": "dist"
42
+ }
43
+ }
@@ -0,0 +1,9 @@
1
+ import type { Knex } from "knex";
2
+ import type { SecurityStorageOperations } from "@webiny/api-core/types/security.js";
3
+ import type { TableManager } from "../TableManager.js";
4
+ interface CreateStorageOperationsParams {
5
+ knex: Knex;
6
+ tableManager: TableManager;
7
+ }
8
+ export declare const createStorageOperations: (params: CreateStorageOperationsParams) => SecurityStorageOperations;
9
+ export {};