@webiny/api-headless-cms-sql 0.0.0-unstable.b6d7105cee → 6.6.0-alpha.1
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 +39 -26
- package/features/entryTableManager/EntryTableManager.js.map +1 -1
- package/index.d.ts +4 -1
- package/index.js +24 -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 +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/queryHelpers.d.ts +23 -0
- package/operations/entry/queryHelpers.js +105 -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/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,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,23 @@
|
|
|
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 declare const syncEntryToLatest: (knex: Knex, tableName: string, entry: CmsStorageEntry, extraPatch?: (latest: CmsEntry) => void) => Promise<void>;
|
|
11
|
+
export declare const patchAllEntryRevisions: (knex: Knex, tableName: string, entryId: string, tenant: string, patch: (entry: CmsEntry) => void, columnUpdates?: Partial<IEntryRow>) => Promise<void>;
|
|
12
|
+
export interface IListEntriesDeps {
|
|
13
|
+
knex: Knex;
|
|
14
|
+
tableName: string;
|
|
15
|
+
storageModelProvider: CmsStorageModelProvider.Interface;
|
|
16
|
+
storageTransformRegistry: StorageTransformRegistry.Interface;
|
|
17
|
+
pathRegistry: FieldFilterPathRegistry.Interface;
|
|
18
|
+
transformRegistry: FieldFilterValueTransformRegistry.Interface;
|
|
19
|
+
filterCreateRegistry: FieldFilterCreateRegistry.Interface;
|
|
20
|
+
sortingRegistry: FieldSortingRegistry.Interface;
|
|
21
|
+
valueFilterRegistry: ValueFilterRegistry.Interface;
|
|
22
|
+
}
|
|
23
|
+
export declare const listEntries: <T extends CmsEntryValues = CmsEntryValues>(deps: IListEntriesDeps, initialModel: CmsModel, params: CmsEntryStorageOperationsListParams) => Promise<CmsEntryStorageOperationsListResponse<CmsEntry<T>>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
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 syncEntryToLatest = async (knex, tableName, entry, extraPatch)=>{
|
|
7
|
+
if (entry.isLatest) return;
|
|
8
|
+
const latestRow = await createEntryQuery(knex, tableName).where("entryId", entry.entryId).andWhere("isLatest", true).first();
|
|
9
|
+
if (!latestRow) return;
|
|
10
|
+
const latest = JSON.parse(latestRow.data);
|
|
11
|
+
const merged = mergeEntryLevelMeta(entry, latest);
|
|
12
|
+
if (extraPatch) extraPatch(merged);
|
|
13
|
+
await createEntryQuery(knex, tableName).where("id", latestRow.id).update({
|
|
14
|
+
data: JSON.stringify(merged)
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
const patchAllEntryRevisions = async (knex, tableName, entryId, tenant, patch, columnUpdates)=>{
|
|
18
|
+
const rows = await createEntryQuery(knex, tableName).where("tenant", tenant).where("entryId", entryId);
|
|
19
|
+
if (0 === rows.length) return;
|
|
20
|
+
const cases = rows.map((row)=>{
|
|
21
|
+
const parsed = JSON.parse(row.data);
|
|
22
|
+
patch(parsed);
|
|
23
|
+
return {
|
|
24
|
+
id: row.id,
|
|
25
|
+
data: JSON.stringify(parsed)
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
const update = {
|
|
29
|
+
data: knex.raw(`CASE id ${cases.map(()=>"WHEN ? THEN ?").join(" ")} END`, cases.flatMap((c)=>[
|
|
30
|
+
c.id,
|
|
31
|
+
c.data
|
|
32
|
+
])),
|
|
33
|
+
...columnUpdates
|
|
34
|
+
};
|
|
35
|
+
await createEntryQuery(knex, tableName).where("tenant", tenant).where("entryId", entryId).update(update);
|
|
36
|
+
};
|
|
37
|
+
const listEntries = async (deps, initialModel, params)=>{
|
|
38
|
+
const model = deps.storageModelProvider.getModel(initialModel);
|
|
39
|
+
const { where: initialWhere, sort: sortBy, search, fields: searchFields, limit: initialLimit, after } = params;
|
|
40
|
+
const limit = initialLimit <= 0 || initialLimit >= MAX_LIST_LIMIT ? MAX_LIST_LIMIT : initialLimit;
|
|
41
|
+
const qb = createEntryQuery(deps.knex, deps.tableName).where("tenant", model.tenant).andWhere("modelId", model.modelId);
|
|
42
|
+
if (initialWhere.entryId) qb.andWhere("entryId", initialWhere.entryId);
|
|
43
|
+
else if (true === initialWhere.published) qb.andWhere("isPublished", true);
|
|
44
|
+
else qb.andWhere("isLatest", true);
|
|
45
|
+
if (void 0 !== initialWhere.wbyDeleted) qb.andWhere("wbyDeleted", initialWhere.wbyDeleted);
|
|
46
|
+
else qb.andWhere("wbyDeleted", false);
|
|
47
|
+
const rows = await qb;
|
|
48
|
+
if (0 === rows.length) return {
|
|
49
|
+
hasMoreItems: false,
|
|
50
|
+
totalCount: 0,
|
|
51
|
+
cursor: null,
|
|
52
|
+
items: []
|
|
53
|
+
};
|
|
54
|
+
const fromStorage = createStorageTransformCallable(deps.storageTransformRegistry, model);
|
|
55
|
+
const records = await Promise.all(rows.map(async (row)=>{
|
|
56
|
+
const entry = rowToEntry(row);
|
|
57
|
+
for (const field of model.fields)entry.values[field.fieldId] = await fromStorage(field, entry.values[field.fieldId]);
|
|
58
|
+
return entry;
|
|
59
|
+
}));
|
|
60
|
+
const where = {
|
|
61
|
+
...initialWhere
|
|
62
|
+
};
|
|
63
|
+
delete where["published"];
|
|
64
|
+
delete where["latest"];
|
|
65
|
+
delete where["entryId"];
|
|
66
|
+
delete where["wbyDeleted"];
|
|
67
|
+
const modelFields = createFields({
|
|
68
|
+
pathRegistry: deps.pathRegistry,
|
|
69
|
+
transformRegistry: deps.transformRegistry,
|
|
70
|
+
fields: model.fields
|
|
71
|
+
});
|
|
72
|
+
const filteredItems = filter({
|
|
73
|
+
items: records,
|
|
74
|
+
where,
|
|
75
|
+
filterCreateRegistry: deps.filterCreateRegistry,
|
|
76
|
+
transformRegistry: deps.transformRegistry,
|
|
77
|
+
fields: modelFields,
|
|
78
|
+
fullTextSearch: {
|
|
79
|
+
term: search,
|
|
80
|
+
fields: searchFields || []
|
|
81
|
+
},
|
|
82
|
+
valueFilterRegistry: deps.valueFilterRegistry
|
|
83
|
+
});
|
|
84
|
+
const totalCount = filteredItems.length;
|
|
85
|
+
const sortedItems = sort({
|
|
86
|
+
model,
|
|
87
|
+
items: filteredItems,
|
|
88
|
+
sort: sortBy,
|
|
89
|
+
fields: modelFields,
|
|
90
|
+
sortingRegistry: deps.sortingRegistry
|
|
91
|
+
});
|
|
92
|
+
const start = parseInt(decodeCursor(after) || "0") || 0;
|
|
93
|
+
const hasMoreItems = totalCount > start + limit;
|
|
94
|
+
const slicedItems = sortedItems.slice(start, start + limit);
|
|
95
|
+
const cursor = encodeCursor(`${start + limit}`);
|
|
96
|
+
return {
|
|
97
|
+
hasMoreItems,
|
|
98
|
+
totalCount,
|
|
99
|
+
cursor,
|
|
100
|
+
items: slicedItems
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export { MAX_LIST_LIMIT, createEntryQuery, listEntries, patchAllEntryRevisions, syncEntryToLatest };
|
|
104
|
+
|
|
105
|
+
//# 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 const syncEntryToLatest = async (\n knex: Knex,\n tableName: string,\n entry: CmsStorageEntry,\n extraPatch?: (latest: CmsEntry) => void\n): Promise<void> => {\n if (entry.isLatest) {\n return;\n }\n\n const latestRow = await createEntryQuery(knex, tableName)\n .where(\"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 createEntryQuery(knex, tableName)\n .where(\"id\", latestRow.id)\n .update({ data: JSON.stringify(merged) });\n};\n\nexport const patchAllEntryRevisions = async (\n knex: Knex,\n tableName: string,\n entryId: string,\n tenant: string,\n patch: (entry: CmsEntry) => void,\n columnUpdates?: Partial<IEntryRow>\n): Promise<void> => {\n const rows = await createEntryQuery(knex, tableName)\n .where(\"tenant\", tenant)\n .where(\"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 createEntryQuery(knex, tableName)\n .where(\"tenant\", tenant)\n .where(\"entryId\", entryId)\n .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","syncEntryToLatest","entry","extraPatch","latestRow","latest","JSON","merged","mergeEntryLevelMeta","patchAllEntryRevisions","entryId","tenant","patch","columnUpdates","rows","cases","row","parsed","update","c","listEntries","deps","initialModel","params","model","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("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,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"}
|