@webiny/api-headless-cms-sql 0.0.0-unstable.b6d7105cee → 0.0.0-unstable.eb81deee7e
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/features/entryTableManager/EntryTableManager.d.ts +2 -0
- package/features/entryTableManager/EntryTableManager.js +43 -26
- package/features/entryTableManager/EntryTableManager.js.map +1 -1
- package/features/groupSchemaManager/GroupSchemaManager.js +5 -1
- package/features/groupSchemaManager/GroupSchemaManager.js.map +1 -1
- package/features/modelSchemaManager/ModelSchemaManager.js +5 -1
- package/features/modelSchemaManager/ModelSchemaManager.js.map +1 -1
- package/index.d.ts +10 -2
- package/index.js +17 -71
- package/index.js.map +1 -1
- 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 +16 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.js +58 -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/queryHelpers.d.ts +28 -0
- package/operations/entry/queryHelpers.js +106 -0
- package/operations/entry/queryHelpers.js.map +1 -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/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/package.json +16 -13
- package/requestFeature.d.ts +15 -0
- package/requestFeature.js +17 -0
- package/requestFeature.js.map +1 -0
- package/operations/entry/index.d.ts +0 -13
- package/operations/entry/index.js +0 -362
- package/operations/entry/index.js.map +0 -1
- package/operations/group/index.d.ts +0 -5
- package/operations/group/index.js +0 -58
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -5
- package/operations/model/index.js +0 -50
- package/operations/model/index.js.map +0 -1
- package/types.d.ts +0 -10
- package/types.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlUnpublishEntry.js","sources":["../../../src/operations/entry/SqlUnpublishEntry.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsUnpublishParams,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UnpublishEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport type { IEntryRow } from \"./types.js\";\nimport { entryToRow } from \"./mappers.js\";\nimport { createModelEntryQuery, syncEntryToLatest } from \"./queryHelpers.js\";\n\nclass SqlUnpublishEntryImpl implements UnpublishEntryStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n private modelQuery(model: CmsModel): Knex.QueryBuilder<IEntryRow> {\n return createModelEntryQuery(this.knex, this.entryTableManager.getTableName(), model);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUnpublishParams<T>\n ) {\n await this.entryTableManager.ensureTable();\n\n const existing = await this.modelQuery(model)\n .andWhere(\"id\", params.storageEntry.id)\n .first();\n const se = params.storageEntry as CmsStorageEntry;\n se.isLatest = existing?.isLatest ?? se.isLatest;\n se.isPublished = false;\n\n const row = entryToRow(se);\n const { isLatest: _il, ...rowWithoutIsLatest } = row;\n\n await this.modelQuery(model)\n .andWhere(\"id\", params.storageEntry.id)\n .update(rowWithoutIsLatest);\n\n await syncEntryToLatest(\n this.knex,\n this.entryTableManager.getTableName(),\n model,\n se,\n latest => {\n latest.live = null;\n }\n );\n\n return params.entry;\n }\n}\n\nexport const SqlUnpublishEntry = UnpublishEntryStorageOperation.createImplementation({\n implementation: SqlUnpublishEntryImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlUnpublishEntryImpl","knexClient","entryTableManager","model","createModelEntryQuery","params","existing","se","row","entryToRow","_il","rowWithoutIsLatest","syncEntryToLatest","latest","SqlUnpublishEntry","UnpublishEntryStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;AAcA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEQ,WAAWE,KAAe,EAAgC;QAC9D,OAAOC,sBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,IAAID;IACnF;IAEA,MAAM,QACFA,KAAe,EACfE,MAAmD,EACrD;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,WAAW,MAAM,IAAI,CAAC,UAAU,CAACH,OAClC,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EACrC,KAAK;QACV,MAAME,KAAKF,OAAO,YAAY;QAC9BE,GAAG,QAAQ,GAAGD,UAAU,YAAYC,GAAG,QAAQ;QAC/CA,GAAG,WAAW,GAAG;QAEjB,MAAMC,MAAMC,WAAWF;QACvB,MAAM,EAAE,UAAUG,GAAG,EAAE,GAAGC,oBAAoB,GAAGH;QAEjD,MAAM,IAAI,CAAC,UAAU,CAACL,OACjB,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EACrC,MAAM,CAACM;QAEZ,MAAMC,kBACF,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,YAAY,IACnCT,OACAI,IACAM,CAAAA;YACIA,OAAO,IAAI,GAAG;QAClB;QAGJ,OAAOR,OAAO,KAAK;IACvB;AACJ;AAEO,MAAMS,oBAAoBC,+BAA+B,oBAAoB,CAAC;IACjF,gBAAgBf;IAChB,cAAc;QAACgB;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsUpdateParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { UpdateEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
private modelQuery;
|
|
10
|
+
execute<T extends CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const SqlUpdateEntry: typeof SqlUpdateEntryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js").IUpdateEntryStorageOperation>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UpdateEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { entryToRow } from "./mappers.js";
|
|
5
|
+
import { createModelEntryQuery, syncEntryToLatest } from "./queryHelpers.js";
|
|
6
|
+
class SqlUpdateEntryImpl {
|
|
7
|
+
constructor(knexClient, entryTableManager){
|
|
8
|
+
this.entryTableManager = entryTableManager;
|
|
9
|
+
this.knex = knexClient.client;
|
|
10
|
+
}
|
|
11
|
+
modelQuery(model) {
|
|
12
|
+
return createModelEntryQuery(this.knex, this.entryTableManager.getTableName(), model);
|
|
13
|
+
}
|
|
14
|
+
async execute(model, params) {
|
|
15
|
+
await this.entryTableManager.ensureTable();
|
|
16
|
+
const existing = await this.modelQuery(model).andWhere("id", params.storageEntry.id).first();
|
|
17
|
+
const se = params.storageEntry;
|
|
18
|
+
se.isLatest = existing?.isLatest ?? se.isLatest;
|
|
19
|
+
se.isPublished = existing?.isPublished ?? se.isPublished;
|
|
20
|
+
const row = entryToRow(se);
|
|
21
|
+
const { isLatest: _il, isPublished: _ip, ...rowWithoutFlags } = row;
|
|
22
|
+
await this.modelQuery(model).andWhere("id", params.storageEntry.id).update(rowWithoutFlags);
|
|
23
|
+
await syncEntryToLatest(this.knex, this.entryTableManager.getTableName(), model, se);
|
|
24
|
+
return params.entry;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const SqlUpdateEntry = UpdateEntryStorageOperation.createImplementation({
|
|
28
|
+
implementation: SqlUpdateEntryImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
KnexClient,
|
|
31
|
+
EntryTableManager
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
export { SqlUpdateEntry };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=SqlUpdateEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlUpdateEntry.js","sources":["../../../src/operations/entry/SqlUpdateEntry.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsUpdateParams,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { UpdateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/UpdateEntryStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport type { IEntryRow } from \"./types.js\";\nimport { entryToRow } from \"./mappers.js\";\nimport { createModelEntryQuery, syncEntryToLatest } from \"./queryHelpers.js\";\n\nclass SqlUpdateEntryImpl implements UpdateEntryStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n private modelQuery(model: CmsModel): Knex.QueryBuilder<IEntryRow> {\n return createModelEntryQuery(this.knex, this.entryTableManager.getTableName(), model);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsUpdateParams<T>\n ) {\n await this.entryTableManager.ensureTable();\n\n const existing = await this.modelQuery(model)\n .andWhere(\"id\", params.storageEntry.id)\n .first();\n const se = params.storageEntry as CmsStorageEntry;\n se.isLatest = existing?.isLatest ?? se.isLatest;\n se.isPublished = existing?.isPublished ?? se.isPublished;\n\n const row = entryToRow(se);\n const { isLatest: _il, isPublished: _ip, ...rowWithoutFlags } = row;\n\n await this.modelQuery(model).andWhere(\"id\", params.storageEntry.id).update(rowWithoutFlags);\n\n await syncEntryToLatest(this.knex, this.entryTableManager.getTableName(), model, se);\n\n return params.entry;\n }\n}\n\nexport const SqlUpdateEntry = UpdateEntryStorageOperation.createImplementation({\n implementation: SqlUpdateEntryImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlUpdateEntryImpl","knexClient","entryTableManager","model","createModelEntryQuery","params","existing","se","row","entryToRow","_il","_ip","rowWithoutFlags","syncEntryToLatest","SqlUpdateEntry","UpdateEntryStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;AAcA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEQ,WAAWE,KAAe,EAAgC;QAC9D,OAAOC,sBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,IAAID;IACnF;IAEA,MAAM,QACFA,KAAe,EACfE,MAAgD,EAClD;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,WAAW,MAAM,IAAI,CAAC,UAAU,CAACH,OAClC,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EACrC,KAAK;QACV,MAAME,KAAKF,OAAO,YAAY;QAC9BE,GAAG,QAAQ,GAAGD,UAAU,YAAYC,GAAG,QAAQ;QAC/CA,GAAG,WAAW,GAAGD,UAAU,eAAeC,GAAG,WAAW;QAExD,MAAMC,MAAMC,WAAWF;QACvB,MAAM,EAAE,UAAUG,GAAG,EAAE,aAAaC,GAAG,EAAE,GAAGC,iBAAiB,GAAGJ;QAEhE,MAAM,IAAI,CAAC,UAAU,CAACL,OAAO,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EAAE,MAAM,CAACO;QAE3E,MAAMC,kBAAkB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,IAAIV,OAAOI;QAEjF,OAAOF,OAAO,KAAK;IACvB;AACJ;AAEO,MAAMS,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBf;IAChB,cAAc;QAACgB;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SqlCreateEntry } from "./SqlCreateEntry.js";
|
|
3
|
+
import { SqlCreateEntryRevisionFrom } from "./SqlCreateEntryRevisionFrom.js";
|
|
4
|
+
import { SqlUpdateEntry } from "./SqlUpdateEntry.js";
|
|
5
|
+
import { SqlDeleteEntry } from "./SqlDeleteEntry.js";
|
|
6
|
+
import { SqlDeleteEntryRevision } from "./SqlDeleteEntryRevision.js";
|
|
7
|
+
import { SqlDeleteMultipleEntries } from "./SqlDeleteMultipleEntries.js";
|
|
8
|
+
import { SqlMoveToBin } from "./SqlMoveToBin.js";
|
|
9
|
+
import { SqlRestoreFromBin } from "./SqlRestoreFromBin.js";
|
|
10
|
+
import { SqlPublishEntry } from "./SqlPublishEntry.js";
|
|
11
|
+
import { SqlUnpublishEntry } from "./SqlUnpublishEntry.js";
|
|
12
|
+
import { SqlMoveEntry } from "./SqlMoveEntry.js";
|
|
13
|
+
import { SqlGetEntry } from "./SqlGetEntry.js";
|
|
14
|
+
import { SqlListEntries } from "./SqlListEntries.js";
|
|
15
|
+
import { SqlGetEntriesByIds } from "./SqlGetEntriesByIds.js";
|
|
16
|
+
import { SqlGetLatestEntriesByIds } from "./SqlGetLatestEntriesByIds.js";
|
|
17
|
+
import { SqlGetPublishedEntriesByIds } from "./SqlGetPublishedEntriesByIds.js";
|
|
18
|
+
import { SqlGetRevisions } from "./SqlGetRevisions.js";
|
|
19
|
+
import { SqlGetRevisionById } from "./SqlGetRevisionById.js";
|
|
20
|
+
import { SqlGetLatestRevisionByEntryId } from "./SqlGetLatestRevisionByEntryId.js";
|
|
21
|
+
import { SqlGetPublishedRevisionByEntryId } from "./SqlGetPublishedRevisionByEntryId.js";
|
|
22
|
+
import { SqlGetPreviousRevision } from "./SqlGetPreviousRevision.js";
|
|
23
|
+
import { SqlGetUniqueFieldValues } from "./SqlGetUniqueFieldValues.js";
|
|
24
|
+
const SqlEntryStorageOpsFeature = createFeature({
|
|
25
|
+
name: "cms.sql.entryStorageOps",
|
|
26
|
+
register: (container)=>{
|
|
27
|
+
container.register(SqlCreateEntry);
|
|
28
|
+
container.register(SqlCreateEntryRevisionFrom);
|
|
29
|
+
container.register(SqlUpdateEntry);
|
|
30
|
+
container.register(SqlDeleteEntry);
|
|
31
|
+
container.register(SqlDeleteEntryRevision);
|
|
32
|
+
container.register(SqlDeleteMultipleEntries);
|
|
33
|
+
container.register(SqlMoveToBin);
|
|
34
|
+
container.register(SqlRestoreFromBin);
|
|
35
|
+
container.register(SqlPublishEntry);
|
|
36
|
+
container.register(SqlUnpublishEntry);
|
|
37
|
+
container.register(SqlMoveEntry);
|
|
38
|
+
container.register(SqlGetEntry);
|
|
39
|
+
container.register(SqlListEntries);
|
|
40
|
+
container.register(SqlGetEntriesByIds);
|
|
41
|
+
container.register(SqlGetLatestEntriesByIds);
|
|
42
|
+
container.register(SqlGetPublishedEntriesByIds);
|
|
43
|
+
container.register(SqlGetRevisions);
|
|
44
|
+
container.register(SqlGetRevisionById);
|
|
45
|
+
container.register(SqlGetLatestRevisionByEntryId);
|
|
46
|
+
container.register(SqlGetPublishedRevisionByEntryId);
|
|
47
|
+
container.register(SqlGetPreviousRevision);
|
|
48
|
+
container.register(SqlGetUniqueFieldValues);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export { SqlEntryStorageOpsFeature };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SqlCreateEntry } from \"./SqlCreateEntry.js\";\nimport { SqlCreateEntryRevisionFrom } from \"./SqlCreateEntryRevisionFrom.js\";\nimport { SqlUpdateEntry } from \"./SqlUpdateEntry.js\";\nimport { SqlDeleteEntry } from \"./SqlDeleteEntry.js\";\nimport { SqlDeleteEntryRevision } from \"./SqlDeleteEntryRevision.js\";\nimport { SqlDeleteMultipleEntries } from \"./SqlDeleteMultipleEntries.js\";\nimport { SqlMoveToBin } from \"./SqlMoveToBin.js\";\nimport { SqlRestoreFromBin } from \"./SqlRestoreFromBin.js\";\nimport { SqlPublishEntry } from \"./SqlPublishEntry.js\";\nimport { SqlUnpublishEntry } from \"./SqlUnpublishEntry.js\";\nimport { SqlMoveEntry } from \"./SqlMoveEntry.js\";\nimport { SqlGetEntry } from \"./SqlGetEntry.js\";\nimport { SqlListEntries } from \"./SqlListEntries.js\";\nimport { SqlGetEntriesByIds } from \"./SqlGetEntriesByIds.js\";\nimport { SqlGetLatestEntriesByIds } from \"./SqlGetLatestEntriesByIds.js\";\nimport { SqlGetPublishedEntriesByIds } from \"./SqlGetPublishedEntriesByIds.js\";\nimport { SqlGetRevisions } from \"./SqlGetRevisions.js\";\nimport { SqlGetRevisionById } from \"./SqlGetRevisionById.js\";\nimport { SqlGetLatestRevisionByEntryId } from \"./SqlGetLatestRevisionByEntryId.js\";\nimport { SqlGetPublishedRevisionByEntryId } from \"./SqlGetPublishedRevisionByEntryId.js\";\nimport { SqlGetPreviousRevision } from \"./SqlGetPreviousRevision.js\";\nimport { SqlGetUniqueFieldValues } from \"./SqlGetUniqueFieldValues.js\";\n\nexport const SqlEntryStorageOpsFeature = createFeature({\n name: \"cms.sql.entryStorageOps\",\n register: container => {\n container.register(SqlCreateEntry);\n container.register(SqlCreateEntryRevisionFrom);\n container.register(SqlUpdateEntry);\n container.register(SqlDeleteEntry);\n container.register(SqlDeleteEntryRevision);\n container.register(SqlDeleteMultipleEntries);\n container.register(SqlMoveToBin);\n container.register(SqlRestoreFromBin);\n container.register(SqlPublishEntry);\n container.register(SqlUnpublishEntry);\n container.register(SqlMoveEntry);\n container.register(SqlGetEntry);\n container.register(SqlListEntries);\n container.register(SqlGetEntriesByIds);\n container.register(SqlGetLatestEntriesByIds);\n container.register(SqlGetPublishedEntriesByIds);\n container.register(SqlGetRevisions);\n container.register(SqlGetRevisionById);\n container.register(SqlGetLatestRevisionByEntryId);\n container.register(SqlGetPublishedRevisionByEntryId);\n container.register(SqlGetPreviousRevision);\n container.register(SqlGetUniqueFieldValues);\n }\n});\n"],"names":["SqlEntryStorageOpsFeature","createFeature","container","SqlCreateEntry","SqlCreateEntryRevisionFrom","SqlUpdateEntry","SqlDeleteEntry","SqlDeleteEntryRevision","SqlDeleteMultipleEntries","SqlMoveToBin","SqlRestoreFromBin","SqlPublishEntry","SqlUnpublishEntry","SqlMoveEntry","SqlGetEntry","SqlListEntries","SqlGetEntriesByIds","SqlGetLatestEntriesByIds","SqlGetPublishedEntriesByIds","SqlGetRevisions","SqlGetRevisionById","SqlGetLatestRevisionByEntryId","SqlGetPublishedRevisionByEntryId","SqlGetPreviousRevision","SqlGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBO,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;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;IACvB;AACJ"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Knex } from "knex";
|
|
2
|
+
import type { CmsEntry, CmsEntryStorageOperationsListParams, CmsEntryStorageOperationsListResponse, CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import type { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
4
|
+
import type { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import type { ValueFilterRegistry } from "@webiny/db-utils";
|
|
6
|
+
import type { FieldFilterPathRegistry, FieldFilterValueTransformRegistry, FieldFilterCreateRegistry, FieldSortingRegistry } from "@webiny/api-headless-cms-storage";
|
|
7
|
+
import type { IEntryRow } from "./types.js";
|
|
8
|
+
export declare const MAX_LIST_LIMIT = 1000000;
|
|
9
|
+
export declare const createEntryQuery: (knex: Knex, tableName: string) => Knex.QueryBuilder<IEntryRow>;
|
|
10
|
+
export interface IEntryQueryModel {
|
|
11
|
+
tenant: string;
|
|
12
|
+
modelId: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const createModelEntryQuery: (knex: Knex, tableName: string, model: IEntryQueryModel) => Knex.QueryBuilder<IEntryRow>;
|
|
15
|
+
export declare const syncEntryToLatest: (knex: Knex, tableName: string, model: IEntryQueryModel, entry: CmsStorageEntry, extraPatch?: (latest: CmsEntry) => void) => Promise<void>;
|
|
16
|
+
export declare const patchAllEntryRevisions: (knex: Knex, tableName: string, model: IEntryQueryModel, entryId: string, patch: (entry: CmsEntry) => void, columnUpdates?: Partial<IEntryRow>) => Promise<void>;
|
|
17
|
+
export interface IListEntriesDeps {
|
|
18
|
+
knex: Knex;
|
|
19
|
+
tableName: string;
|
|
20
|
+
storageModelProvider: CmsStorageModelProvider.Interface;
|
|
21
|
+
storageTransformRegistry: StorageTransformRegistry.Interface;
|
|
22
|
+
pathRegistry: FieldFilterPathRegistry.Interface;
|
|
23
|
+
transformRegistry: FieldFilterValueTransformRegistry.Interface;
|
|
24
|
+
filterCreateRegistry: FieldFilterCreateRegistry.Interface;
|
|
25
|
+
sortingRegistry: FieldSortingRegistry.Interface;
|
|
26
|
+
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
27
|
+
}
|
|
28
|
+
export declare const listEntries: <T extends CmsEntryValues = CmsEntryValues>(deps: IListEntriesDeps, initialModel: CmsModel, params: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { decodeCursor, encodeCursor } from "@webiny/utils";
|
|
2
|
+
import { createFields, createStorageTransformCallable, filter, sort } from "@webiny/api-headless-cms-storage";
|
|
3
|
+
import { mergeEntryLevelMeta, rowToEntry } from "./mappers.js";
|
|
4
|
+
const MAX_LIST_LIMIT = 1000000;
|
|
5
|
+
const createEntryQuery = (knex, tableName)=>knex(tableName);
|
|
6
|
+
const createModelEntryQuery = (knex, tableName, model)=>createEntryQuery(knex, tableName).where("tenant", model.tenant).andWhere("modelId", model.modelId);
|
|
7
|
+
const syncEntryToLatest = async (knex, tableName, model, entry, extraPatch)=>{
|
|
8
|
+
if (entry.isLatest) return;
|
|
9
|
+
const latestRow = await createModelEntryQuery(knex, tableName, model).andWhere("entryId", entry.entryId).andWhere("isLatest", true).first();
|
|
10
|
+
if (!latestRow) return;
|
|
11
|
+
const latest = JSON.parse(latestRow.data);
|
|
12
|
+
const merged = mergeEntryLevelMeta(entry, latest);
|
|
13
|
+
if (extraPatch) extraPatch(merged);
|
|
14
|
+
await createModelEntryQuery(knex, tableName, model).andWhere("id", latestRow.id).update({
|
|
15
|
+
data: JSON.stringify(merged)
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const patchAllEntryRevisions = async (knex, tableName, model, entryId, patch, columnUpdates)=>{
|
|
19
|
+
const rows = await createModelEntryQuery(knex, tableName, model).andWhere("entryId", entryId);
|
|
20
|
+
if (0 === rows.length) return;
|
|
21
|
+
const cases = rows.map((row)=>{
|
|
22
|
+
const parsed = JSON.parse(row.data);
|
|
23
|
+
patch(parsed);
|
|
24
|
+
return {
|
|
25
|
+
id: row.id,
|
|
26
|
+
data: JSON.stringify(parsed)
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
const update = {
|
|
30
|
+
data: knex.raw(`CASE id ${cases.map(()=>"WHEN ? THEN ?").join(" ")} END`, cases.flatMap((c)=>[
|
|
31
|
+
c.id,
|
|
32
|
+
c.data
|
|
33
|
+
])),
|
|
34
|
+
...columnUpdates
|
|
35
|
+
};
|
|
36
|
+
await createModelEntryQuery(knex, tableName, model).andWhere("entryId", entryId).update(update);
|
|
37
|
+
};
|
|
38
|
+
const listEntries = async (deps, initialModel, params)=>{
|
|
39
|
+
const model = deps.storageModelProvider.getModel(initialModel);
|
|
40
|
+
const { where: initialWhere, sort: sortBy, search, fields: searchFields, limit: initialLimit, after } = params;
|
|
41
|
+
const limit = initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;
|
|
42
|
+
const qb = createEntryQuery(deps.knex, deps.tableName).where("tenant", model.tenant).andWhere("modelId", model.modelId);
|
|
43
|
+
if (initialWhere.entryId) qb.andWhere("entryId", initialWhere.entryId);
|
|
44
|
+
else if (true === initialWhere.published) qb.andWhere("isPublished", true);
|
|
45
|
+
else qb.andWhere("isLatest", true);
|
|
46
|
+
if (void 0 !== initialWhere.wbyDeleted) qb.andWhere("wbyDeleted", initialWhere.wbyDeleted);
|
|
47
|
+
else qb.andWhere("wbyDeleted", false);
|
|
48
|
+
const rows = await qb;
|
|
49
|
+
if (0 === rows.length) return {
|
|
50
|
+
hasMoreItems: false,
|
|
51
|
+
totalCount: 0,
|
|
52
|
+
cursor: null,
|
|
53
|
+
items: []
|
|
54
|
+
};
|
|
55
|
+
const fromStorage = createStorageTransformCallable(deps.storageTransformRegistry, model);
|
|
56
|
+
const records = await Promise.all(rows.map(async (row)=>{
|
|
57
|
+
const entry = rowToEntry(row);
|
|
58
|
+
for (const field of model.fields)entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);
|
|
59
|
+
return entry;
|
|
60
|
+
}));
|
|
61
|
+
const where = {
|
|
62
|
+
...initialWhere
|
|
63
|
+
};
|
|
64
|
+
delete where["published"];
|
|
65
|
+
delete where["latest"];
|
|
66
|
+
delete where["entryId"];
|
|
67
|
+
delete where["wbyDeleted"];
|
|
68
|
+
const modelFields = createFields({
|
|
69
|
+
pathRegistry: deps.pathRegistry,
|
|
70
|
+
transformRegistry: deps.transformRegistry,
|
|
71
|
+
fields: model.fields
|
|
72
|
+
});
|
|
73
|
+
const filteredItems = filter({
|
|
74
|
+
items: records,
|
|
75
|
+
where,
|
|
76
|
+
filterCreateRegistry: deps.filterCreateRegistry,
|
|
77
|
+
transformRegistry: deps.transformRegistry,
|
|
78
|
+
fields: modelFields,
|
|
79
|
+
fullTextSearch: {
|
|
80
|
+
term: search,
|
|
81
|
+
fields: searchFields || []
|
|
82
|
+
},
|
|
83
|
+
valueFilterRegistry: deps.valueFilterRegistry
|
|
84
|
+
});
|
|
85
|
+
const totalCount = filteredItems.length;
|
|
86
|
+
const sortedItems = sort({
|
|
87
|
+
model,
|
|
88
|
+
items: filteredItems,
|
|
89
|
+
sort: sortBy,
|
|
90
|
+
fields: modelFields,
|
|
91
|
+
sortingRegistry: deps.sortingRegistry
|
|
92
|
+
});
|
|
93
|
+
const start = parseInt(decodeCursor(after) || "0") || 0;
|
|
94
|
+
const hasMoreItems = totalCount > start + limit;
|
|
95
|
+
const slicedItems = sortedItems.slice(start, start + limit);
|
|
96
|
+
const cursor = encodeCursor(`${start + limit}`);
|
|
97
|
+
return {
|
|
98
|
+
hasMoreItems,
|
|
99
|
+
totalCount,
|
|
100
|
+
cursor,
|
|
101
|
+
items: slicedItems
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export { MAX_LIST_LIMIT, createEntryQuery, createModelEntryQuery, listEntries, patchAllEntryRevisions, syncEntryToLatest };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=queryHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/queryHelpers.js","sources":["../../../src/operations/entry/queryHelpers.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntry,\n CmsEntryListWhere,\n CmsEntryStorageOperationsListParams,\n CmsEntryStorageOperationsListResponse,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { decodeCursor, encodeCursor } from \"@webiny/utils\";\nimport type { StorageTransformRegistry } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport type { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport type { ValueFilterRegistry } from \"@webiny/db-utils\";\nimport {\n createFields,\n filter,\n sort,\n createStorageTransformCallable\n} from \"@webiny/api-headless-cms-storage\";\nimport type {\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry\n} from \"@webiny/api-headless-cms-storage\";\nimport type { IEntryRow } from \"./types.js\";\nimport { rowToEntry, mergeEntryLevelMeta } from \"./mappers.js\";\n\nexport const MAX_LIST_LIMIT = 1000000;\n\nexport const createEntryQuery = (knex: Knex, tableName: string): Knex.QueryBuilder<IEntryRow> => {\n return knex<IEntryRow>(tableName);\n};\n\nexport interface IEntryQueryModel {\n tenant: string;\n modelId: string;\n}\n\nexport const createModelEntryQuery = (\n knex: Knex,\n tableName: string,\n model: IEntryQueryModel\n): Knex.QueryBuilder<IEntryRow> => {\n return createEntryQuery(knex, tableName)\n .where(\"tenant\", model.tenant)\n .andWhere(\"modelId\", model.modelId);\n};\n\nexport const syncEntryToLatest = async (\n knex: Knex,\n tableName: string,\n model: IEntryQueryModel,\n entry: CmsStorageEntry,\n extraPatch?: (latest: CmsEntry) => void\n): Promise<void> => {\n if (entry.isLatest) {\n return;\n }\n\n const latestRow = await createModelEntryQuery(knex, tableName, model)\n .andWhere(\"entryId\", entry.entryId)\n .andWhere(\"isLatest\", true)\n .first();\n\n if (!latestRow) {\n return;\n }\n\n const latest = JSON.parse(latestRow.data);\n const merged = mergeEntryLevelMeta(entry, latest);\n\n if (extraPatch) {\n extraPatch(merged);\n }\n\n await createModelEntryQuery(knex, tableName, model)\n .andWhere(\"id\", latestRow.id)\n .update({ data: JSON.stringify(merged) });\n};\n\nexport const patchAllEntryRevisions = async (\n knex: Knex,\n tableName: string,\n model: IEntryQueryModel,\n entryId: string,\n patch: (entry: CmsEntry) => void,\n columnUpdates?: Partial<IEntryRow>\n): Promise<void> => {\n const rows = await createModelEntryQuery(knex, tableName, model).andWhere(\"entryId\", entryId);\n\n if (rows.length === 0) {\n return;\n }\n\n const cases: Array<{ id: string; data: string }> = rows.map((row: IEntryRow) => {\n const parsed = JSON.parse(row.data);\n patch(parsed);\n return { id: row.id, data: JSON.stringify(parsed) };\n });\n\n const update: Record<string, unknown> = {\n data: knex.raw(\n `CASE id ${cases.map(() => \"WHEN ? THEN ?\").join(\" \")} END`,\n cases.flatMap((c: { id: string; data: string }) => [c.id, c.data])\n ),\n ...columnUpdates\n };\n\n await createModelEntryQuery(knex, tableName, model).andWhere(\"entryId\", entryId).update(update);\n};\n\nexport interface IListEntriesDeps {\n knex: Knex;\n tableName: string;\n storageModelProvider: CmsStorageModelProvider.Interface;\n storageTransformRegistry: StorageTransformRegistry.Interface;\n pathRegistry: FieldFilterPathRegistry.Interface;\n transformRegistry: FieldFilterValueTransformRegistry.Interface;\n filterCreateRegistry: FieldFilterCreateRegistry.Interface;\n sortingRegistry: FieldSortingRegistry.Interface;\n valueFilterRegistry: ValueFilterRegistry.Interface;\n}\n\nexport const listEntries = async <T extends CmsEntryValues = CmsEntryValues>(\n deps: IListEntriesDeps,\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsListParams\n): Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>> => {\n const model = deps.storageModelProvider.getModel(initialModel);\n const {\n where: initialWhere,\n sort: sortBy,\n search,\n fields: searchFields,\n limit: initialLimit,\n after\n } = params;\n\n const limit =\n initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;\n\n const qb = createEntryQuery(deps.knex, deps.tableName)\n .where(\"tenant\", model.tenant)\n .andWhere(\"modelId\", model.modelId);\n\n if (initialWhere.entryId) {\n qb.andWhere(\"entryId\", initialWhere.entryId);\n } else if (initialWhere.published === true) {\n qb.andWhere(\"isPublished\", true);\n } else {\n qb.andWhere(\"isLatest\", true);\n }\n\n if (initialWhere.wbyDeleted !== undefined) {\n qb.andWhere(\"wbyDeleted\", initialWhere.wbyDeleted);\n } else {\n qb.andWhere(\"wbyDeleted\", false);\n }\n\n const rows: IEntryRow[] = await qb;\n\n if (rows.length === 0) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: [] as CmsEntry<T>[]\n };\n }\n\n const fromStorage = createStorageTransformCallable(deps.storageTransformRegistry, model);\n\n const records = await Promise.all(\n rows.map(async row => {\n const entry = rowToEntry(row) as CmsStorageEntry;\n\n for (const field of model.fields) {\n entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);\n }\n\n return entry as CmsEntry<T>;\n })\n );\n\n const where: Partial<CmsEntryListWhere> = { ...initialWhere };\n delete where[\"published\"];\n delete where[\"latest\"];\n delete where[\"entryId\"];\n delete where[\"wbyDeleted\"];\n\n const modelFields = createFields({\n pathRegistry: deps.pathRegistry,\n transformRegistry: deps.transformRegistry,\n fields: model.fields\n });\n\n const filteredItems = filter<T>({\n items: records,\n where,\n filterCreateRegistry: deps.filterCreateRegistry,\n transformRegistry: deps.transformRegistry,\n fields: modelFields,\n fullTextSearch: {\n term: search,\n fields: searchFields || []\n },\n valueFilterRegistry: deps.valueFilterRegistry\n });\n\n const totalCount = filteredItems.length;\n\n const sortedItems = sort<T>({\n model,\n items: filteredItems,\n sort: sortBy,\n fields: modelFields,\n sortingRegistry: deps.sortingRegistry\n });\n\n const start = parseInt((decodeCursor(after) as string) || \"0\") || 0;\n const hasMoreItems = totalCount > start + limit;\n const slicedItems = sortedItems.slice(start, start + limit);\n const cursor = encodeCursor(`${start + limit}`);\n\n return {\n hasMoreItems,\n totalCount,\n cursor,\n items: slicedItems\n };\n};\n"],"names":["MAX_LIST_LIMIT","createEntryQuery","knex","tableName","createModelEntryQuery","model","syncEntryToLatest","entry","extraPatch","latestRow","latest","JSON","merged","mergeEntryLevelMeta","patchAllEntryRevisions","entryId","patch","columnUpdates","rows","cases","row","parsed","update","c","listEntries","deps","initialModel","params","initialWhere","sortBy","search","searchFields","initialLimit","after","limit","qb","undefined","fromStorage","createStorageTransformCallable","records","Promise","rowToEntry","field","where","modelFields","createFields","filteredItems","filter","totalCount","sortedItems","sort","start","parseInt","decodeCursor","hasMoreItems","slicedItems","cursor","encodeCursor"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsGroupStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.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 SqlCreateGroupImpl implements CreateGroupStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private groupSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, groupSchemaManager: GroupSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsGroupStorageOperationsCreateParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlCreateGroup: typeof SqlCreateGroupImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js").ICreateGroupStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.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 SqlCreateGroupImpl {
|
|
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).insert(row);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const SqlCreateGroup = CreateGroupStorageOperation.createImplementation({
|
|
19
|
+
implementation: SqlCreateGroupImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
KnexClient,
|
|
22
|
+
TableNameResolver,
|
|
23
|
+
GroupSchemaManager
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
export { SqlCreateGroup };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=SqlCreateGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/SqlCreateGroup.js","sources":["../../../src/operations/group/SqlCreateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\nimport { CreateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.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 SqlCreateGroupImpl implements CreateGroupStorageOperation.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: CmsGroupStorageOperationsCreateParams) {\n const row = groupToRow(params.group);\n\n await this.groupSchemaManager.ensure(this.tableName);\n await this.knex.client<IGroupRow>(this.tableName).insert(row);\n }\n}\n\nexport const SqlCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: SqlCreateGroupImpl,\n dependencies: [KnexClient, TableNameResolver, GroupSchemaManager]\n});\n"],"names":["SqlCreateGroupImpl","knex","tableNameResolver","groupSchemaManager","params","row","groupToRow","SqlCreateGroup","CreateGroupStorageOperation","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,MAAM,CAACC;IAC7D;AACJ;AAEO,MAAME,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsGroupStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.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 SqlDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private groupSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, groupSchemaManager: GroupSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsGroupStorageOperationsDeleteParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlDeleteGroup: typeof SqlDeleteGroupImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js").IDeleteGroupStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -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("tenant", params.group.tenant).andWhere("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\n .client<IGroupRow>(this.tableName)\n .where(\"tenant\", params.group.tenant)\n .andWhere(\"id\", params.group.id)\n .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,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,UAAUA,OAAO,KAAK,CAAC,MAAM,EACnC,QAAQ,CAAC,MAAMA,OAAO,KAAK,CAAC,EAAE,EAC9B,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 { 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("tenant", params.group.tenant).andWhere("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\n .client<IGroupRow>(this.tableName)\n .where(\"tenant\", params.group.tenant)\n .andWhere(\"id\", params.group.id)\n .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,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,UAAUA,OAAO,KAAK,CAAC,MAAM,EACnC,QAAQ,CAAC,MAAMA,OAAO,KAAK,CAAC,EAAE,EAC9B,MAAM,CAACC;IAChB;AACJ;AAEO,MAAME,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBR;IAChB,cAAc;QAACS;QAAYC;QAAmBC;KAAmB;AACrE"}
|