@webiny/api-headless-cms-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.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/features/entryTableManager/EntryTableManager.d.ts +19 -0
- package/features/entryTableManager/EntryTableManager.js +76 -0
- package/features/entryTableManager/EntryTableManager.js.map +1 -0
- package/features/entryTableManager/abstractions.d.ts +9 -0
- package/features/entryTableManager/abstractions.js +5 -0
- package/features/entryTableManager/abstractions.js.map +1 -0
- package/features/entryTableManager/feature.d.ts +4 -0
- package/features/entryTableManager/feature.js +11 -0
- package/features/entryTableManager/feature.js.map +1 -0
- package/features/groupSchemaManager/GroupSchemaManager.d.ts +13 -0
- package/features/groupSchemaManager/GroupSchemaManager.js +44 -0
- package/features/groupSchemaManager/GroupSchemaManager.js.map +1 -0
- package/features/groupSchemaManager/abstractions.d.ts +8 -0
- package/features/groupSchemaManager/abstractions.js +5 -0
- package/features/groupSchemaManager/abstractions.js.map +1 -0
- package/features/groupSchemaManager/feature.d.ts +4 -0
- package/features/groupSchemaManager/feature.js +11 -0
- package/features/groupSchemaManager/feature.js.map +1 -0
- package/features/modelSchemaManager/ModelSchemaManager.d.ts +13 -0
- package/features/modelSchemaManager/ModelSchemaManager.js +54 -0
- package/features/modelSchemaManager/ModelSchemaManager.js.map +1 -0
- package/features/modelSchemaManager/abstractions.d.ts +8 -0
- package/features/modelSchemaManager/abstractions.js +5 -0
- package/features/modelSchemaManager/abstractions.js.map +1 -0
- package/features/modelSchemaManager/feature.d.ts +4 -0
- package/features/modelSchemaManager/feature.js +11 -0
- package/features/modelSchemaManager/feature.js.map +1 -0
- package/features/tableNameResolver/TableNameResolver.d.ts +13 -0
- package/features/tableNameResolver/TableNameResolver.js +24 -0
- package/features/tableNameResolver/TableNameResolver.js.map +1 -0
- package/features/tableNameResolver/abstractions.d.ts +16 -0
- package/features/tableNameResolver/abstractions.js +6 -0
- package/features/tableNameResolver/abstractions.js.map +1 -0
- package/features/tableNameResolver/feature.d.ts +4 -0
- package/features/tableNameResolver/feature.js +11 -0
- package/features/tableNameResolver/feature.js.map +1 -0
- package/index.d.ts +11 -0
- package/index.js +34 -0
- package/index.js.map +1 -0
- package/operations/entry/SqlCreateEntry.d.ts +15 -0
- package/operations/entry/SqlCreateEntry.js +35 -0
- package/operations/entry/SqlCreateEntry.js.map +1 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.d.ts +15 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.js +55 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/SqlDeleteEntry.d.ts +15 -0
- package/operations/entry/SqlDeleteEntry.js +29 -0
- package/operations/entry/SqlDeleteEntry.js.map +1 -0
- package/operations/entry/SqlDeleteEntryRevision.d.ts +15 -0
- package/operations/entry/SqlDeleteEntryRevision.js +39 -0
- package/operations/entry/SqlDeleteEntryRevision.js.map +1 -0
- package/operations/entry/SqlDeleteMultipleEntries.d.ts +15 -0
- package/operations/entry/SqlDeleteMultipleEntries.js +29 -0
- package/operations/entry/SqlDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/SqlGetEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetEntriesByIds.js +35 -0
- package/operations/entry/SqlGetEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetEntry.d.ts +25 -0
- package/operations/entry/SqlGetEntry.js +56 -0
- package/operations/entry/SqlGetEntry.js.map +1 -0
- package/operations/entry/SqlGetLatestEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetLatestEntriesByIds.js +37 -0
- package/operations/entry/SqlGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.d.ts +15 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.js +32 -0
- package/operations/entry/SqlGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/SqlGetPreviousRevision.d.ts +15 -0
- package/operations/entry/SqlGetPreviousRevision.js +30 -0
- package/operations/entry/SqlGetPreviousRevision.js.map +1 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.d.ts +15 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.js +37 -0
- package/operations/entry/SqlGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.d.ts +15 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.js +32 -0
- package/operations/entry/SqlGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/SqlGetRevisionById.d.ts +15 -0
- package/operations/entry/SqlGetRevisionById.js +30 -0
- package/operations/entry/SqlGetRevisionById.js.map +1 -0
- package/operations/entry/SqlGetRevisions.d.ts +15 -0
- package/operations/entry/SqlGetRevisions.js +31 -0
- package/operations/entry/SqlGetRevisions.js.map +1 -0
- package/operations/entry/SqlGetUniqueFieldValues.d.ts +25 -0
- package/operations/entry/SqlGetUniqueFieldValues.js +58 -0
- package/operations/entry/SqlGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/SqlListEntries.d.ts +25 -0
- package/operations/entry/SqlListEntries.js +52 -0
- package/operations/entry/SqlListEntries.js.map +1 -0
- package/operations/entry/SqlMoveEntry.d.ts +14 -0
- package/operations/entry/SqlMoveEntry.js +30 -0
- package/operations/entry/SqlMoveEntry.js.map +1 -0
- package/operations/entry/SqlMoveToBin.d.ts +14 -0
- package/operations/entry/SqlMoveToBin.js +35 -0
- package/operations/entry/SqlMoveToBin.js.map +1 -0
- package/operations/entry/SqlPublishEntry.d.ts +15 -0
- package/operations/entry/SqlPublishEntry.js +51 -0
- package/operations/entry/SqlPublishEntry.js.map +1 -0
- package/operations/entry/SqlRestoreFromBin.d.ts +14 -0
- package/operations/entry/SqlRestoreFromBin.js +36 -0
- package/operations/entry/SqlRestoreFromBin.js.map +1 -0
- package/operations/entry/SqlUnpublishEntry.d.ts +15 -0
- package/operations/entry/SqlUnpublishEntry.js +38 -0
- package/operations/entry/SqlUnpublishEntry.js.map +1 -0
- package/operations/entry/SqlUpdateEntry.d.ts +15 -0
- package/operations/entry/SqlUpdateEntry.js +36 -0
- package/operations/entry/SqlUpdateEntry.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +53 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/mappers.d.ts +5 -0
- package/operations/entry/mappers.js +26 -0
- package/operations/entry/mappers.js.map +1 -0
- package/operations/entry/queryHelpers.d.ts +23 -0
- package/operations/entry/queryHelpers.js +105 -0
- package/operations/entry/queryHelpers.js.map +1 -0
- package/operations/entry/types.d.ts +11 -0
- package/operations/entry/types.js +0 -0
- package/operations/group/SqlCreateGroup.d.ts +16 -0
- package/operations/group/SqlCreateGroup.js +28 -0
- package/operations/group/SqlCreateGroup.js.map +1 -0
- package/operations/group/SqlDeleteGroup.d.ts +16 -0
- package/operations/group/SqlDeleteGroup.js +26 -0
- package/operations/group/SqlDeleteGroup.js.map +1 -0
- package/operations/group/SqlGetGroup.d.ts +16 -0
- package/operations/group/SqlGetGroup.js +29 -0
- package/operations/group/SqlGetGroup.js.map +1 -0
- package/operations/group/SqlListGroups.d.ts +16 -0
- package/operations/group/SqlListGroups.js +43 -0
- package/operations/group/SqlListGroups.js.map +1 -0
- package/operations/group/SqlUpdateGroup.d.ts +16 -0
- package/operations/group/SqlUpdateGroup.js +28 -0
- package/operations/group/SqlUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/mappers.d.ts +4 -0
- package/operations/group/mappers.js +32 -0
- package/operations/group/mappers.js.map +1 -0
- package/operations/group/types.d.ts +18 -0
- package/operations/group/types.js +17 -0
- package/operations/group/types.js.map +1 -0
- package/operations/model/SqlCreateModel.d.ts +16 -0
- package/operations/model/SqlCreateModel.js +30 -0
- package/operations/model/SqlCreateModel.js.map +1 -0
- package/operations/model/SqlDeleteModel.d.ts +16 -0
- package/operations/model/SqlDeleteModel.js +26 -0
- package/operations/model/SqlDeleteModel.js.map +1 -0
- package/operations/model/SqlGetModel.d.ts +16 -0
- package/operations/model/SqlGetModel.js +29 -0
- package/operations/model/SqlGetModel.js.map +1 -0
- package/operations/model/SqlListModels.d.ts +16 -0
- package/operations/model/SqlListModels.js +31 -0
- package/operations/model/SqlListModels.js.map +1 -0
- package/operations/model/SqlUpdateModel.d.ts +16 -0
- package/operations/model/SqlUpdateModel.js +30 -0
- package/operations/model/SqlUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/mappers.d.ts +4 -0
- package/operations/model/mappers.js +52 -0
- package/operations/model/mappers.js.map +1 -0
- package/operations/model/types.d.ts +28 -0
- package/operations/model/types.js +27 -0
- package/operations/model/types.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
4
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
5
|
+
class SqlDeleteGroupImpl {
|
|
6
|
+
constructor(knex, tableNameResolver, groupSchemaManager){
|
|
7
|
+
this.knex = knex;
|
|
8
|
+
this.groupSchemaManager = groupSchemaManager;
|
|
9
|
+
this.tableName = tableNameResolver.resolve("groups");
|
|
10
|
+
}
|
|
11
|
+
async execute(params) {
|
|
12
|
+
await this.groupSchemaManager.ensure(this.tableName);
|
|
13
|
+
await this.knex.client(this.tableName).where("id", params.group.id).delete();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const SqlDeleteGroup = DeleteGroupStorageOperation.createImplementation({
|
|
17
|
+
implementation: SqlDeleteGroupImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
KnexClient,
|
|
20
|
+
TableNameResolver,
|
|
21
|
+
GroupSchemaManager
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { SqlDeleteGroup };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=SqlDeleteGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/SqlDeleteGroup.js","sources":["../../../src/operations/group/SqlDeleteGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\nimport { DeleteGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { GroupSchemaManager } from \"~/features/groupSchemaManager/abstractions.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private groupSchemaManager: GroupSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"groups\");\n }\n\n async execute(params: CmsGroupStorageOperationsDeleteParams) {\n await this.groupSchemaManager.ensure(this.tableName);\n await this.knex.client<IGroupRow>(this.tableName).where(\"id\", params.group.id).delete();\n }\n}\n\nexport const SqlDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: SqlDeleteGroupImpl,\n dependencies: [KnexClient, TableNameResolver, GroupSchemaManager]\n});\n"],"names":["SqlDeleteGroupImpl","knex","tableNameResolver","groupSchemaManager","params","SqlDeleteGroup","DeleteGroupStorageOperation","KnexClient","TableNameResolver","GroupSchemaManager"],"mappings":";;;;AAOA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,MAAMA,OAAO,KAAK,CAAC,EAAE,EAAE,MAAM;IACzF;AACJ;AAEO,MAAMC,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBN;IAChB,cAAc;QAACO;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsGroupStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlGetGroupImpl implements GetGroupStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private groupSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, groupSchemaManager: GroupSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsGroupStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/modelGroup.js").CmsGroup | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlGetGroup: typeof SqlGetGroupImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js").IGetGroupStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
4
|
+
import { rowToGroup } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlGetGroupImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, groupSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.groupSchemaManager = groupSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("groups");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
await this.groupSchemaManager.ensure(this.tableName);
|
|
14
|
+
const row = await this.knex.client(this.tableName).where("id", params.id).where("tenant", params.tenant).first();
|
|
15
|
+
if (!row) return null;
|
|
16
|
+
return rowToGroup(row);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const SqlGetGroup = GetGroupStorageOperation.createImplementation({
|
|
20
|
+
implementation: SqlGetGroupImpl,
|
|
21
|
+
dependencies: [
|
|
22
|
+
KnexClient,
|
|
23
|
+
TableNameResolver,
|
|
24
|
+
GroupSchemaManager
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { SqlGetGroup };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=SqlGetGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/SqlGetGroup.js","sources":["../../../src/operations/group/SqlGetGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\nimport { GetGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { GroupSchemaManager } from \"~/features/groupSchemaManager/abstractions.js\";\nimport { rowToGroup } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlGetGroupImpl implements GetGroupStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private groupSchemaManager: GroupSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"groups\");\n }\n\n async execute(params: CmsGroupStorageOperationsGetParams) {\n await this.groupSchemaManager.ensure(this.tableName);\n\n const row = await this.knex\n .client<IGroupRow>(this.tableName)\n .where(\"id\", params.id)\n .where(\"tenant\", params.tenant)\n .first();\n\n if (!row) {\n return null;\n }\n\n return rowToGroup(row);\n }\n}\n\nexport const SqlGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: SqlGetGroupImpl,\n dependencies: [KnexClient, TableNameResolver, GroupSchemaManager]\n});\n"],"names":["SqlGetGroupImpl","knex","tableNameResolver","groupSchemaManager","params","row","rowToGroup","SqlGetGroup","GetGroupStorageOperation","KnexClient","TableNameResolver","GroupSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA0C,EAAE;QACtD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAMC,MAAM,MAAM,IAAI,CAAC,IAAI,CACtB,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,MAAMD,OAAO,EAAE,EACrB,KAAK,CAAC,UAAUA,OAAO,MAAM,EAC7B,KAAK;QAEV,IAAI,CAACC,KACD,OAAO;QAGX,OAAOC,WAAWD;IACtB;AACJ;AAEO,MAAME,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsGroupStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlListGroupsImpl implements ListGroupsStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private groupSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, groupSchemaManager: GroupSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsGroupStorageOperationsListParams): Promise<import("@webiny/api-headless-cms/types/modelGroup.js").CmsGroup[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlListGroups: typeof SqlListGroupsImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js").IListGroupsStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { GROUP_COLUMNS } from "./types.js";
|
|
2
|
+
import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
5
|
+
import { rowToGroup } from "./mappers.js";
|
|
6
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
7
|
+
class SqlListGroupsImpl {
|
|
8
|
+
constructor(knex, tableNameResolver, groupSchemaManager){
|
|
9
|
+
this.knex = knex;
|
|
10
|
+
this.groupSchemaManager = groupSchemaManager;
|
|
11
|
+
this.tableName = tableNameResolver.resolve("groups");
|
|
12
|
+
}
|
|
13
|
+
async execute(params) {
|
|
14
|
+
const { where, sort } = params;
|
|
15
|
+
await this.groupSchemaManager.ensure(this.tableName);
|
|
16
|
+
const qb = this.knex.client(this.tableName).where("tenant", where.tenant);
|
|
17
|
+
if (where.id) qb.andWhere("id", where.id);
|
|
18
|
+
if (where.slug) qb.andWhere("slug", where.slug);
|
|
19
|
+
if (void 0 !== where.isPlugin) qb.andWhere("isPlugin", where.isPlugin);
|
|
20
|
+
if (void 0 !== where.isPrivate) qb.andWhere("isPrivate", where.isPrivate);
|
|
21
|
+
if (sort?.length) for (const sortField of sort){
|
|
22
|
+
const parts = sortField.split("_");
|
|
23
|
+
const direction = parts.pop()?.toLowerCase() === "asc" ? "asc" : "desc";
|
|
24
|
+
const field = parts.join("_");
|
|
25
|
+
qb.orderBy(field, direction);
|
|
26
|
+
}
|
|
27
|
+
const rows = await qb.select([
|
|
28
|
+
...GROUP_COLUMNS
|
|
29
|
+
]);
|
|
30
|
+
return rows.map(rowToGroup);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const SqlListGroups = ListGroupsStorageOperation.createImplementation({
|
|
34
|
+
implementation: SqlListGroupsImpl,
|
|
35
|
+
dependencies: [
|
|
36
|
+
KnexClient,
|
|
37
|
+
TableNameResolver,
|
|
38
|
+
GroupSchemaManager
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
export { SqlListGroups };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=SqlListGroups.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/SqlListGroups.js","sources":["../../../src/operations/group/SqlListGroups.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\nimport { GROUP_COLUMNS } from \"./types.js\";\nimport { ListGroupsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { GroupSchemaManager } from \"~/features/groupSchemaManager/abstractions.js\";\nimport { rowToGroup } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlListGroupsImpl implements ListGroupsStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private groupSchemaManager: GroupSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"groups\");\n }\n\n async execute(params: CmsGroupStorageOperationsListParams) {\n const { where, sort } = params;\n\n await this.groupSchemaManager.ensure(this.tableName);\n\n const qb = this.knex.client<IGroupRow>(this.tableName).where(\"tenant\", where.tenant);\n\n if (where.id) {\n qb.andWhere(\"id\", where.id);\n }\n if (where.slug) {\n qb.andWhere(\"slug\", where.slug);\n }\n if (where.isPlugin !== undefined) {\n qb.andWhere(\"isPlugin\", where.isPlugin);\n }\n if (where.isPrivate !== undefined) {\n qb.andWhere(\"isPrivate\", where.isPrivate);\n }\n\n if (sort?.length) {\n for (const sortField of sort) {\n const parts = sortField.split(\"_\");\n const direction = parts.pop()?.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n const field = parts.join(\"_\");\n qb.orderBy(field, direction);\n }\n }\n\n const rows = await qb.select<IGroupRow[]>([...GROUP_COLUMNS]);\n\n return rows.map(rowToGroup);\n }\n}\n\nexport const SqlListGroups = ListGroupsStorageOperation.createImplementation({\n implementation: SqlListGroupsImpl,\n dependencies: [KnexClient, TableNameResolver, GroupSchemaManager]\n});\n"],"names":["SqlListGroupsImpl","knex","tableNameResolver","groupSchemaManager","params","where","sort","qb","undefined","sortField","parts","direction","field","rows","GROUP_COLUMNS","rowToGroup","SqlListGroups","ListGroupsStorageOperation","KnexClient","TableNameResolver","GroupSchemaManager"],"mappings":";;;;;;AASA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA2C,EAAE;QACvD,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGF;QAExB,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAMG,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,UAAUF,MAAM,MAAM;QAEnF,IAAIA,MAAM,EAAE,EACRE,GAAG,QAAQ,CAAC,MAAMF,MAAM,EAAE;QAE9B,IAAIA,MAAM,IAAI,EACVE,GAAG,QAAQ,CAAC,QAAQF,MAAM,IAAI;QAElC,IAAIA,AAAmBG,WAAnBH,MAAM,QAAQ,EACdE,GAAG,QAAQ,CAAC,YAAYF,MAAM,QAAQ;QAE1C,IAAIA,AAAoBG,WAApBH,MAAM,SAAS,EACfE,GAAG,QAAQ,CAAC,aAAaF,MAAM,SAAS;QAG5C,IAAIC,MAAM,QACN,KAAK,MAAMG,aAAaH,KAAM;YAC1B,MAAMI,QAAQD,UAAU,KAAK,CAAC;YAC9B,MAAME,YAAYD,MAAM,GAAG,IAAI,kBAAkB,QAAQ,QAAQ;YACjE,MAAME,QAAQF,MAAM,IAAI,CAAC;YACzBH,GAAG,OAAO,CAACK,OAAOD;QACtB;QAGJ,MAAME,OAAO,MAAMN,GAAG,MAAM,CAAc;eAAIO;SAAc;QAE5D,OAAOD,KAAK,GAAG,CAACE;IACpB;AACJ;AAEO,MAAMC,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBjB;IAChB,cAAc;QAACkB;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsGroupStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private groupSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, groupSchemaManager: GroupSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsGroupStorageOperationsUpdateParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlUpdateGroup: typeof SqlUpdateGroupImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js").IUpdateGroupStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { GroupSchemaManager } from "../../features/groupSchemaManager/abstractions.js";
|
|
4
|
+
import { groupToRow } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlUpdateGroupImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, groupSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.groupSchemaManager = groupSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("groups");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const row = groupToRow(params.group);
|
|
14
|
+
await this.groupSchemaManager.ensure(this.tableName);
|
|
15
|
+
await this.knex.client(this.tableName).where("id", params.group.id).update(row);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const SqlUpdateGroup = UpdateGroupStorageOperation.createImplementation({
|
|
19
|
+
implementation: SqlUpdateGroupImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
KnexClient,
|
|
22
|
+
TableNameResolver,
|
|
23
|
+
GroupSchemaManager
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
export { SqlUpdateGroup };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=SqlUpdateGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/SqlUpdateGroup.js","sources":["../../../src/operations/group/SqlUpdateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\nimport { UpdateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { GroupSchemaManager } from \"~/features/groupSchemaManager/abstractions.js\";\nimport { groupToRow } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private groupSchemaManager: GroupSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"groups\");\n }\n\n async execute(params: CmsGroupStorageOperationsUpdateParams) {\n const row = groupToRow(params.group);\n\n await this.groupSchemaManager.ensure(this.tableName);\n await this.knex.client<IGroupRow>(this.tableName).where(\"id\", params.group.id).update(row);\n }\n}\n\nexport const SqlUpdateGroup = UpdateGroupStorageOperation.createImplementation({\n implementation: SqlUpdateGroupImpl,\n dependencies: [KnexClient, TableNameResolver, GroupSchemaManager]\n});\n"],"names":["SqlUpdateGroupImpl","knex","tableNameResolver","groupSchemaManager","params","row","groupToRow","SqlUpdateGroup","UpdateGroupStorageOperation","KnexClient","TableNameResolver","GroupSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAMC,MAAMC,WAAWF,OAAO,KAAK;QAEnC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,MAAMA,OAAO,KAAK,CAAC,EAAE,EAAE,MAAM,CAACC;IAC1F;AACJ;AAEO,MAAME,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SqlGetGroup } from "./SqlGetGroup.js";
|
|
3
|
+
import { SqlListGroups } from "./SqlListGroups.js";
|
|
4
|
+
import { SqlCreateGroup } from "./SqlCreateGroup.js";
|
|
5
|
+
import { SqlUpdateGroup } from "./SqlUpdateGroup.js";
|
|
6
|
+
import { SqlDeleteGroup } from "./SqlDeleteGroup.js";
|
|
7
|
+
const SqlGroupStorageOpsFeature = createFeature({
|
|
8
|
+
name: "cms.sql.groupStorageOps",
|
|
9
|
+
register: (container)=>{
|
|
10
|
+
container.register(SqlGetGroup);
|
|
11
|
+
container.register(SqlListGroups);
|
|
12
|
+
container.register(SqlCreateGroup);
|
|
13
|
+
container.register(SqlUpdateGroup);
|
|
14
|
+
container.register(SqlDeleteGroup);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export { SqlGroupStorageOpsFeature };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/feature.js","sources":["../../../src/operations/group/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SqlGetGroup } from \"./SqlGetGroup.js\";\nimport { SqlListGroups } from \"./SqlListGroups.js\";\nimport { SqlCreateGroup } from \"./SqlCreateGroup.js\";\nimport { SqlUpdateGroup } from \"./SqlUpdateGroup.js\";\nimport { SqlDeleteGroup } from \"./SqlDeleteGroup.js\";\n\nexport const SqlGroupStorageOpsFeature = createFeature({\n name: \"cms.sql.groupStorageOps\",\n register: container => {\n container.register(SqlGetGroup);\n container.register(SqlListGroups);\n container.register(SqlCreateGroup);\n container.register(SqlUpdateGroup);\n container.register(SqlDeleteGroup);\n }\n});\n"],"names":["SqlGroupStorageOpsFeature","createFeature","container","SqlGetGroup","SqlListGroups","SqlCreateGroup","SqlUpdateGroup","SqlDeleteGroup"],"mappings":";;;;;;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const groupToRow = (group)=>({
|
|
2
|
+
id: group.id,
|
|
3
|
+
name: group.name,
|
|
4
|
+
slug: group.slug,
|
|
5
|
+
tenant: group.tenant,
|
|
6
|
+
description: group.description ?? null,
|
|
7
|
+
icon: group.icon ? JSON.stringify(group.icon) : null,
|
|
8
|
+
createdBy_id: group.createdBy?.id ?? null,
|
|
9
|
+
createdBy_displayName: group.createdBy?.displayName ?? null,
|
|
10
|
+
createdBy_type: group.createdBy?.type ?? null,
|
|
11
|
+
createdBy: group.createdBy ? JSON.stringify(group.createdBy) : null,
|
|
12
|
+
createdOn: group.createdOn ?? null,
|
|
13
|
+
savedOn: group.savedOn ?? null,
|
|
14
|
+
isPrivate: group.isPrivate ?? false,
|
|
15
|
+
isPlugin: group.isPlugin ?? false
|
|
16
|
+
});
|
|
17
|
+
const rowToGroup = (row)=>({
|
|
18
|
+
id: row.id,
|
|
19
|
+
name: row.name,
|
|
20
|
+
slug: row.slug,
|
|
21
|
+
tenant: row.tenant,
|
|
22
|
+
description: row.description || null,
|
|
23
|
+
icon: row.icon ? JSON.parse(row.icon) : null,
|
|
24
|
+
createdBy: row.createdBy ? JSON.parse(row.createdBy) : void 0,
|
|
25
|
+
createdOn: row.createdOn ?? void 0,
|
|
26
|
+
savedOn: row.savedOn ?? void 0,
|
|
27
|
+
isPrivate: row.isPrivate,
|
|
28
|
+
isPlugin: row.isPlugin
|
|
29
|
+
});
|
|
30
|
+
export { groupToRow, rowToGroup };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/mappers.js","sources":["../../../src/operations/group/mappers.ts"],"sourcesContent":["import type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\n\nexport const groupToRow = (group: CmsGroup): IGroupRow => {\n return {\n id: group.id,\n name: group.name,\n slug: group.slug,\n tenant: group.tenant,\n description: group.description ?? null,\n icon: group.icon ? JSON.stringify(group.icon) : null,\n createdBy_id: group.createdBy?.id ?? null,\n createdBy_displayName: group.createdBy?.displayName ?? null,\n createdBy_type: group.createdBy?.type ?? null,\n createdBy: group.createdBy ? JSON.stringify(group.createdBy) : null,\n createdOn: group.createdOn ?? null,\n savedOn: group.savedOn ?? null,\n isPrivate: group.isPrivate ?? false,\n isPlugin: group.isPlugin ?? false\n };\n};\n\nexport const rowToGroup = (row: IGroupRow): CmsGroup => {\n return {\n id: row.id,\n name: row.name,\n slug: row.slug,\n tenant: row.tenant,\n description: row.description || null,\n icon: row.icon ? JSON.parse(row.icon) : null,\n createdBy: row.createdBy ? JSON.parse(row.createdBy) : undefined,\n createdOn: row.createdOn ?? undefined,\n savedOn: row.savedOn ?? undefined,\n isPrivate: row.isPrivate,\n isPlugin: row.isPlugin\n };\n};\n"],"names":["groupToRow","group","JSON","rowToGroup","row","undefined"],"mappings":"AAGO,MAAMA,aAAa,CAACC,QAChB;QACH,IAAIA,MAAM,EAAE;QACZ,MAAMA,MAAM,IAAI;QAChB,MAAMA,MAAM,IAAI;QAChB,QAAQA,MAAM,MAAM;QACpB,aAAaA,MAAM,WAAW,IAAI;QAClC,MAAMA,MAAM,IAAI,GAAGC,KAAK,SAAS,CAACD,MAAM,IAAI,IAAI;QAChD,cAAcA,MAAM,SAAS,EAAE,MAAM;QACrC,uBAAuBA,MAAM,SAAS,EAAE,eAAe;QACvD,gBAAgBA,MAAM,SAAS,EAAE,QAAQ;QACzC,WAAWA,MAAM,SAAS,GAAGC,KAAK,SAAS,CAACD,MAAM,SAAS,IAAI;QAC/D,WAAWA,MAAM,SAAS,IAAI;QAC9B,SAASA,MAAM,OAAO,IAAI;QAC1B,WAAWA,MAAM,SAAS,IAAI;QAC9B,UAAUA,MAAM,QAAQ,IAAI;IAChC;AAGG,MAAME,aAAa,CAACC,MAChB;QACH,IAAIA,IAAI,EAAE;QACV,MAAMA,IAAI,IAAI;QACd,MAAMA,IAAI,IAAI;QACd,QAAQA,IAAI,MAAM;QAClB,aAAaA,IAAI,WAAW,IAAI;QAChC,MAAMA,IAAI,IAAI,GAAGF,KAAK,KAAK,CAACE,IAAI,IAAI,IAAI;QACxC,WAAWA,IAAI,SAAS,GAAGF,KAAK,KAAK,CAACE,IAAI,SAAS,IAAIC;QACvD,WAAWD,IAAI,SAAS,IAAIC;QAC5B,SAASD,IAAI,OAAO,IAAIC;QACxB,WAAWD,IAAI,SAAS;QACxB,UAAUA,IAAI,QAAQ;IAC1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CmsGroup } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IGroupRow {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
tenant: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
icon: string | null;
|
|
9
|
+
createdBy_id: string | null;
|
|
10
|
+
createdBy_displayName: string | null;
|
|
11
|
+
createdBy_type: string | null;
|
|
12
|
+
createdBy: string | null;
|
|
13
|
+
createdOn: string | null;
|
|
14
|
+
savedOn: string | null;
|
|
15
|
+
isPrivate: boolean;
|
|
16
|
+
isPlugin: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const GROUP_COLUMNS: (keyof CmsGroup)[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const GROUP_COLUMN_MAP = {
|
|
2
|
+
id: true,
|
|
3
|
+
name: true,
|
|
4
|
+
slug: true,
|
|
5
|
+
tenant: true,
|
|
6
|
+
description: true,
|
|
7
|
+
icon: true,
|
|
8
|
+
createdBy: true,
|
|
9
|
+
createdOn: true,
|
|
10
|
+
savedOn: true,
|
|
11
|
+
isPrivate: true,
|
|
12
|
+
isPlugin: true
|
|
13
|
+
};
|
|
14
|
+
const GROUP_COLUMNS = Object.keys(GROUP_COLUMN_MAP);
|
|
15
|
+
export { GROUP_COLUMNS };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/types.js","sources":["../../../src/operations/group/types.ts"],"sourcesContent":["import type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\n\n/* SQL row representation of CmsGroup. */\nexport interface IGroupRow {\n id: string;\n name: string;\n slug: string;\n tenant: string;\n description: string | null;\n icon: string | null;\n /* Filterable identity columns. */\n createdBy_id: string | null;\n createdBy_displayName: string | null;\n createdBy_type: string | null;\n /* Full identity as JSON for extensibility. */\n createdBy: string | null;\n createdOn: string | null;\n savedOn: string | null;\n isPrivate: boolean;\n isPlugin: boolean;\n}\n\n/* Validated against CmsGroup — TypeScript errors if CmsGroup gains a new field. */\nconst GROUP_COLUMN_MAP: Record<keyof CmsGroup, true> = {\n id: true,\n name: true,\n slug: true,\n tenant: true,\n description: true,\n icon: true,\n createdBy: true,\n createdOn: true,\n savedOn: true,\n isPrivate: true,\n isPlugin: true\n};\n\nexport const GROUP_COLUMNS = Object.keys(GROUP_COLUMN_MAP) as (keyof CmsGroup)[];\n"],"names":["GROUP_COLUMN_MAP","GROUP_COLUMNS","Object"],"mappings":"AAuBA,MAAMA,mBAAiD;IACnD,IAAI;IACJ,MAAM;IACN,MAAM;IACN,QAAQ;IACR,aAAa;IACb,MAAM;IACN,WAAW;IACX,WAAW;IACX,SAAS;IACT,WAAW;IACX,UAAU;AACd;AAEO,MAAMC,gBAAgBC,OAAO,IAAI,CAACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlCreateModelImpl implements CreateModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsCreateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlCreateModel: typeof SqlCreateModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js").ICreateModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { modelToRow } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlCreateModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const model = params.model;
|
|
14
|
+
const row = modelToRow(model);
|
|
15
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
16
|
+
await this.knex.client(this.tableName).insert(row);
|
|
17
|
+
return model;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const SqlCreateModel = CreateModelStorageOperation.createImplementation({
|
|
21
|
+
implementation: SqlCreateModelImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
KnexClient,
|
|
24
|
+
TableNameResolver,
|
|
25
|
+
ModelSchemaManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlCreateModel };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlCreateModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlCreateModel.js","sources":["../../../src/operations/model/SqlCreateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { CreateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { modelToRow } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlCreateModelImpl implements CreateModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsCreateParams) {\n const model = params.model;\n const row = modelToRow(model);\n\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex.client<IModelRow>(this.tableName).insert(row);\n\n return model;\n }\n}\n\nexport const SqlCreateModel = CreateModelStorageOperation.createImplementation({\n implementation: SqlCreateModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlCreateModelImpl","knex","tableNameResolver","modelSchemaManager","params","model","row","modelToRow","SqlCreateModel","CreateModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAMC,QAAQD,OAAO,KAAK;QAC1B,MAAME,MAAMC,WAAWF;QAEvB,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,MAAM,CAACC;QAEzD,OAAOD;IACX;AACJ;AAEO,MAAMG,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsDeleteParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlDeleteModel: typeof SqlDeleteModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js").IDeleteModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
5
|
+
class SqlDeleteModelImpl {
|
|
6
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
7
|
+
this.knex = knex;
|
|
8
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
9
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
10
|
+
}
|
|
11
|
+
async execute(params) {
|
|
12
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
13
|
+
await this.knex.client(this.tableName).where("modelId", params.model.modelId).delete();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({
|
|
17
|
+
implementation: SqlDeleteModelImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
KnexClient,
|
|
20
|
+
TableNameResolver,
|
|
21
|
+
ModelSchemaManager
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { SqlDeleteModel };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=SqlDeleteModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlDeleteModel.js","sources":["../../../src/operations/model/SqlDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { DeleteModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsDeleteParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"modelId\", params.model.modelId)\n .delete();\n }\n}\n\nexport const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({\n implementation: SqlDeleteModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlDeleteModelImpl","knex","tableNameResolver","modelSchemaManager","params","SqlDeleteModel","DeleteModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;AAOA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,WAAWA,OAAO,KAAK,CAAC,OAAO,EACrC,MAAM;IACf;AACJ;AAEO,MAAMC,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBN;IAChB,cAAc;QAACO;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlGetModelImpl implements GetModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlGetModel: typeof SqlGetModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js").IGetModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { rowToModel } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlGetModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
14
|
+
const row = await this.knex.client(this.tableName).where("modelId", params.modelId).where("tenant", params.tenant).first();
|
|
15
|
+
if (!row) return null;
|
|
16
|
+
return rowToModel(row);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const SqlGetModel = GetModelStorageOperation.createImplementation({
|
|
20
|
+
implementation: SqlGetModelImpl,
|
|
21
|
+
dependencies: [
|
|
22
|
+
KnexClient,
|
|
23
|
+
TableNameResolver,
|
|
24
|
+
ModelSchemaManager
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { SqlGetModel };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=SqlGetModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlGetModel.js","sources":["../../../src/operations/model/SqlGetModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { GetModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { rowToModel } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlGetModelImpl implements GetModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsGetParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n\n const row = await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"modelId\", params.modelId)\n .where(\"tenant\", params.tenant)\n .first();\n\n if (!row) {\n return null;\n }\n\n return rowToModel(row);\n }\n}\n\nexport const SqlGetModel = GetModelStorageOperation.createImplementation({\n implementation: SqlGetModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlGetModelImpl","knex","tableNameResolver","modelSchemaManager","params","row","rowToModel","SqlGetModel","GetModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA0C,EAAE;QACtD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAMC,MAAM,MAAM,IAAI,CAAC,IAAI,CACtB,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,WAAWD,OAAO,OAAO,EAC/B,KAAK,CAAC,UAAUA,OAAO,MAAM,EAC7B,KAAK;QAEV,IAAI,CAACC,KACD,OAAO;QAGX,OAAOC,WAAWD;IACtB;AACJ;AAEO,MAAME,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlListModelsImpl implements ListModelsStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsListParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlListModels: typeof SqlListModelsImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js").IListModelsStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { rowToModel } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlListModelsImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
14
|
+
const { where } = params;
|
|
15
|
+
const qb = this.knex.client(this.tableName).where("tenant", where.tenant);
|
|
16
|
+
qb.orderBy("modelId", "asc");
|
|
17
|
+
const rows = await qb.select();
|
|
18
|
+
return rows.map(rowToModel);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const SqlListModels = ListModelsStorageOperation.createImplementation({
|
|
22
|
+
implementation: SqlListModelsImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
KnexClient,
|
|
25
|
+
TableNameResolver,
|
|
26
|
+
ModelSchemaManager
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { SqlListModels };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=SqlListModels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlListModels.js","sources":["../../../src/operations/model/SqlListModels.ts"],"sourcesContent":["import type { CmsModelStorageOperationsListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { ListModelsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { rowToModel } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlListModelsImpl implements ListModelsStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsListParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n\n const { where } = params;\n const qb = this.knex.client<IModelRow>(this.tableName).where(\"tenant\", where.tenant);\n\n qb.orderBy(\"modelId\", \"asc\");\n\n const rows = await qb.select<IModelRow[]>();\n\n return rows.map(rowToModel);\n }\n}\n\nexport const SqlListModels = ListModelsStorageOperation.createImplementation({\n implementation: SqlListModelsImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlListModelsImpl","knex","tableNameResolver","modelSchemaManager","params","where","qb","rows","rowToModel","SqlListModels","ListModelsStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA2C,EAAE;QACvD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QAEnD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,UAAUD,MAAM,MAAM;QAEnFC,GAAG,OAAO,CAAC,WAAW;QAEtB,MAAMC,OAAO,MAAMD,GAAG,MAAM;QAE5B,OAAOC,KAAK,GAAG,CAACC;IACpB;AACJ;AAEO,MAAMC,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBV;IAChB,cAAc;QAACW;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlUpdateModelImpl implements UpdateModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsUpdateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlUpdateModel: typeof SqlUpdateModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js").IUpdateModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { modelToRow } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlUpdateModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const model = params.model;
|
|
14
|
+
const row = modelToRow(model);
|
|
15
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
16
|
+
await this.knex.client(this.tableName).where("modelId", model.modelId).update(row);
|
|
17
|
+
return model;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const SqlUpdateModel = UpdateModelStorageOperation.createImplementation({
|
|
21
|
+
implementation: SqlUpdateModelImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
KnexClient,
|
|
24
|
+
TableNameResolver,
|
|
25
|
+
ModelSchemaManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlUpdateModel };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlUpdateModel.js.map
|