@webiny/api-headless-cms-sql 0.0.0-unstable.0156a4c312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/features/entryTableManager/EntryTableManager.d.ts +19 -0
- package/features/entryTableManager/EntryTableManager.js +80 -0
- package/features/entryTableManager/EntryTableManager.js.map +1 -0
- package/features/entryTableManager/abstractions.d.ts +9 -0
- package/features/entryTableManager/abstractions.js +5 -0
- package/features/entryTableManager/abstractions.js.map +1 -0
- package/features/entryTableManager/feature.d.ts +4 -0
- package/features/entryTableManager/feature.js +11 -0
- package/features/entryTableManager/feature.js.map +1 -0
- package/features/groupSchemaManager/GroupSchemaManager.d.ts +13 -0
- package/features/groupSchemaManager/GroupSchemaManager.js +48 -0
- package/features/groupSchemaManager/GroupSchemaManager.js.map +1 -0
- package/features/groupSchemaManager/abstractions.d.ts +8 -0
- package/features/groupSchemaManager/abstractions.js +5 -0
- package/features/groupSchemaManager/abstractions.js.map +1 -0
- package/features/groupSchemaManager/feature.d.ts +4 -0
- package/features/groupSchemaManager/feature.js +11 -0
- package/features/groupSchemaManager/feature.js.map +1 -0
- package/features/modelSchemaManager/ModelSchemaManager.d.ts +13 -0
- package/features/modelSchemaManager/ModelSchemaManager.js +58 -0
- package/features/modelSchemaManager/ModelSchemaManager.js.map +1 -0
- package/features/modelSchemaManager/abstractions.d.ts +8 -0
- package/features/modelSchemaManager/abstractions.js +5 -0
- package/features/modelSchemaManager/abstractions.js.map +1 -0
- package/features/modelSchemaManager/feature.d.ts +4 -0
- package/features/modelSchemaManager/feature.js +11 -0
- package/features/modelSchemaManager/feature.js.map +1 -0
- package/features/tableNameResolver/TableNameResolver.d.ts +13 -0
- package/features/tableNameResolver/TableNameResolver.js +24 -0
- package/features/tableNameResolver/TableNameResolver.js.map +1 -0
- package/features/tableNameResolver/abstractions.d.ts +16 -0
- package/features/tableNameResolver/abstractions.js +6 -0
- package/features/tableNameResolver/abstractions.js.map +1 -0
- package/features/tableNameResolver/feature.d.ts +4 -0
- package/features/tableNameResolver/feature.js +11 -0
- package/features/tableNameResolver/feature.js.map +1 -0
- package/index.d.ts +16 -0
- package/index.js +34 -0
- package/index.js.map +1 -0
- package/operations/entry/SqlCreateEntry.d.ts +15 -0
- package/operations/entry/SqlCreateEntry.js +35 -0
- package/operations/entry/SqlCreateEntry.js.map +1 -0
- package/operations/entry/SqlCreateEntryRevisionFrom.d.ts +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 +27 -0
- package/operations/entry/SqlGetEntry.js +65 -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 +27 -0
- package/operations/entry/SqlGetUniqueFieldValues.js +67 -0
- package/operations/entry/SqlGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/SqlListEntries.d.ts +27 -0
- package/operations/entry/SqlListEntries.js +61 -0
- package/operations/entry/SqlListEntries.js.map +1 -0
- package/operations/entry/SqlMoveEntry.d.ts +14 -0
- package/operations/entry/SqlMoveEntry.js +30 -0
- package/operations/entry/SqlMoveEntry.js.map +1 -0
- package/operations/entry/SqlMoveToBin.d.ts +14 -0
- package/operations/entry/SqlMoveToBin.js +35 -0
- package/operations/entry/SqlMoveToBin.js.map +1 -0
- package/operations/entry/SqlPublishEntry.d.ts +15 -0
- package/operations/entry/SqlPublishEntry.js +51 -0
- package/operations/entry/SqlPublishEntry.js.map +1 -0
- package/operations/entry/SqlRestoreFromBin.d.ts +14 -0
- package/operations/entry/SqlRestoreFromBin.js +36 -0
- package/operations/entry/SqlRestoreFromBin.js.map +1 -0
- package/operations/entry/SqlUnpublishEntry.d.ts +15 -0
- package/operations/entry/SqlUnpublishEntry.js +38 -0
- package/operations/entry/SqlUnpublishEntry.js.map +1 -0
- package/operations/entry/SqlUpdateEntry.d.ts +15 -0
- package/operations/entry/SqlUpdateEntry.js +36 -0
- package/operations/entry/SqlUpdateEntry.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +53 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/mappers.d.ts +5 -0
- package/operations/entry/mappers.js +26 -0
- package/operations/entry/mappers.js.map +1 -0
- package/operations/entry/queryHelpers.d.ts +30 -0
- package/operations/entry/queryHelpers.js +107 -0
- package/operations/entry/queryHelpers.js.map +1 -0
- package/operations/entry/types.d.ts +11 -0
- package/operations/entry/types.js +0 -0
- package/operations/group/SqlCreateGroup.d.ts +16 -0
- package/operations/group/SqlCreateGroup.js +28 -0
- package/operations/group/SqlCreateGroup.js.map +1 -0
- package/operations/group/SqlDeleteGroup.d.ts +16 -0
- package/operations/group/SqlDeleteGroup.js +26 -0
- package/operations/group/SqlDeleteGroup.js.map +1 -0
- package/operations/group/SqlGetGroup.d.ts +16 -0
- package/operations/group/SqlGetGroup.js +29 -0
- package/operations/group/SqlGetGroup.js.map +1 -0
- package/operations/group/SqlListGroups.d.ts +16 -0
- package/operations/group/SqlListGroups.js +43 -0
- package/operations/group/SqlListGroups.js.map +1 -0
- package/operations/group/SqlUpdateGroup.d.ts +16 -0
- package/operations/group/SqlUpdateGroup.js +28 -0
- package/operations/group/SqlUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/mappers.d.ts +4 -0
- package/operations/group/mappers.js +32 -0
- package/operations/group/mappers.js.map +1 -0
- package/operations/group/types.d.ts +18 -0
- package/operations/group/types.js +17 -0
- package/operations/group/types.js.map +1 -0
- package/operations/model/SqlCreateModel.d.ts +16 -0
- package/operations/model/SqlCreateModel.js +30 -0
- package/operations/model/SqlCreateModel.js.map +1 -0
- package/operations/model/SqlDeleteModel.d.ts +16 -0
- package/operations/model/SqlDeleteModel.js +26 -0
- package/operations/model/SqlDeleteModel.js.map +1 -0
- package/operations/model/SqlGetModel.d.ts +16 -0
- package/operations/model/SqlGetModel.js +29 -0
- package/operations/model/SqlGetModel.js.map +1 -0
- package/operations/model/SqlListModels.d.ts +16 -0
- package/operations/model/SqlListModels.js +31 -0
- package/operations/model/SqlListModels.js.map +1 -0
- package/operations/model/SqlUpdateModel.d.ts +16 -0
- package/operations/model/SqlUpdateModel.js +30 -0
- package/operations/model/SqlUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/mappers.d.ts +4 -0
- package/operations/model/mappers.js +52 -0
- package/operations/model/mappers.js.map +1 -0
- package/operations/model/types.d.ts +28 -0
- package/operations/model/types.js +27 -0
- package/operations/model/types.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
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 CmsModelField,\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 /** Fields registered as `CmsEntrySystemField`, filterable under `system`. */\n systemFields: CmsModelField[];\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 systemFields: deps.systemFields\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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"}
|
|
File without changes
|
|
@@ -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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SqlGetGroup } from "./SqlGetGroup.js";
|
|
3
|
+
import { SqlListGroups } from "./SqlListGroups.js";
|
|
4
|
+
import { SqlCreateGroup } from "./SqlCreateGroup.js";
|
|
5
|
+
import { SqlUpdateGroup } from "./SqlUpdateGroup.js";
|
|
6
|
+
import { SqlDeleteGroup } from "./SqlDeleteGroup.js";
|
|
7
|
+
const SqlGroupStorageOpsFeature = createFeature({
|
|
8
|
+
name: "cms.sql.groupStorageOps",
|
|
9
|
+
register: (container)=>{
|
|
10
|
+
container.register(SqlGetGroup);
|
|
11
|
+
container.register(SqlListGroups);
|
|
12
|
+
container.register(SqlCreateGroup);
|
|
13
|
+
container.register(SqlUpdateGroup);
|
|
14
|
+
container.register(SqlDeleteGroup);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export { SqlGroupStorageOpsFeature };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/feature.js","sources":["../../../src/operations/group/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SqlGetGroup } from \"./SqlGetGroup.js\";\nimport { SqlListGroups } from \"./SqlListGroups.js\";\nimport { SqlCreateGroup } from \"./SqlCreateGroup.js\";\nimport { SqlUpdateGroup } from \"./SqlUpdateGroup.js\";\nimport { SqlDeleteGroup } from \"./SqlDeleteGroup.js\";\n\nexport const SqlGroupStorageOpsFeature = createFeature({\n name: \"cms.sql.groupStorageOps\",\n register: container => {\n container.register(SqlGetGroup);\n container.register(SqlListGroups);\n container.register(SqlCreateGroup);\n container.register(SqlUpdateGroup);\n container.register(SqlDeleteGroup);\n }\n});\n"],"names":["SqlGroupStorageOpsFeature","createFeature","container","SqlGetGroup","SqlListGroups","SqlCreateGroup","SqlUpdateGroup","SqlDeleteGroup"],"mappings":";;;;;;AAOO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;IACvB;AACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const groupToRow = (group)=>({
|
|
2
|
+
id: group.id,
|
|
3
|
+
name: group.name,
|
|
4
|
+
slug: group.slug,
|
|
5
|
+
tenant: group.tenant,
|
|
6
|
+
description: group.description ?? null,
|
|
7
|
+
icon: group.icon ? JSON.stringify(group.icon) : null,
|
|
8
|
+
createdBy_id: group.createdBy?.id ?? null,
|
|
9
|
+
createdBy_displayName: group.createdBy?.displayName ?? null,
|
|
10
|
+
createdBy_type: group.createdBy?.type ?? null,
|
|
11
|
+
createdBy: group.createdBy ? JSON.stringify(group.createdBy) : null,
|
|
12
|
+
createdOn: group.createdOn ?? null,
|
|
13
|
+
savedOn: group.savedOn ?? null,
|
|
14
|
+
isPrivate: group.isPrivate ?? false,
|
|
15
|
+
isPlugin: group.isPlugin ?? false
|
|
16
|
+
});
|
|
17
|
+
const rowToGroup = (row)=>({
|
|
18
|
+
id: row.id,
|
|
19
|
+
name: row.name,
|
|
20
|
+
slug: row.slug,
|
|
21
|
+
tenant: row.tenant,
|
|
22
|
+
description: row.description || null,
|
|
23
|
+
icon: row.icon ? JSON.parse(row.icon) : null,
|
|
24
|
+
createdBy: row.createdBy ? JSON.parse(row.createdBy) : void 0,
|
|
25
|
+
createdOn: row.createdOn ?? void 0,
|
|
26
|
+
savedOn: row.savedOn ?? void 0,
|
|
27
|
+
isPrivate: row.isPrivate,
|
|
28
|
+
isPlugin: row.isPlugin
|
|
29
|
+
});
|
|
30
|
+
export { groupToRow, rowToGroup };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=mappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/mappers.js","sources":["../../../src/operations/group/mappers.ts"],"sourcesContent":["import type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IGroupRow } from \"./types.js\";\n\nexport const groupToRow = (group: CmsGroup): IGroupRow => {\n return {\n id: group.id,\n name: group.name,\n slug: group.slug,\n tenant: group.tenant,\n description: group.description ?? null,\n icon: group.icon ? JSON.stringify(group.icon) : null,\n createdBy_id: group.createdBy?.id ?? null,\n createdBy_displayName: group.createdBy?.displayName ?? null,\n createdBy_type: group.createdBy?.type ?? null,\n createdBy: group.createdBy ? JSON.stringify(group.createdBy) : null,\n createdOn: group.createdOn ?? null,\n savedOn: group.savedOn ?? null,\n isPrivate: group.isPrivate ?? false,\n isPlugin: group.isPlugin ?? false\n };\n};\n\nexport const rowToGroup = (row: IGroupRow): CmsGroup => {\n return {\n id: row.id,\n name: row.name,\n slug: row.slug,\n tenant: row.tenant,\n description: row.description || null,\n icon: row.icon ? JSON.parse(row.icon) : null,\n createdBy: row.createdBy ? JSON.parse(row.createdBy) : undefined,\n createdOn: row.createdOn ?? undefined,\n savedOn: row.savedOn ?? undefined,\n isPrivate: row.isPrivate,\n isPlugin: row.isPlugin\n };\n};\n"],"names":["groupToRow","group","JSON","rowToGroup","row","undefined"],"mappings":"AAGO,MAAMA,aAAa,CAACC,QAChB;QACH,IAAIA,MAAM,EAAE;QACZ,MAAMA,MAAM,IAAI;QAChB,MAAMA,MAAM,IAAI;QAChB,QAAQA,MAAM,MAAM;QACpB,aAAaA,MAAM,WAAW,IAAI;QAClC,MAAMA,MAAM,IAAI,GAAGC,KAAK,SAAS,CAACD,MAAM,IAAI,IAAI;QAChD,cAAcA,MAAM,SAAS,EAAE,MAAM;QACrC,uBAAuBA,MAAM,SAAS,EAAE,eAAe;QACvD,gBAAgBA,MAAM,SAAS,EAAE,QAAQ;QACzC,WAAWA,MAAM,SAAS,GAAGC,KAAK,SAAS,CAACD,MAAM,SAAS,IAAI;QAC/D,WAAWA,MAAM,SAAS,IAAI;QAC9B,SAASA,MAAM,OAAO,IAAI;QAC1B,WAAWA,MAAM,SAAS,IAAI;QAC9B,UAAUA,MAAM,QAAQ,IAAI;IAChC;AAGG,MAAME,aAAa,CAACC,MAChB;QACH,IAAIA,IAAI,EAAE;QACV,MAAMA,IAAI,IAAI;QACd,MAAMA,IAAI,IAAI;QACd,QAAQA,IAAI,MAAM;QAClB,aAAaA,IAAI,WAAW,IAAI;QAChC,MAAMA,IAAI,IAAI,GAAGF,KAAK,KAAK,CAACE,IAAI,IAAI,IAAI;QACxC,WAAWA,IAAI,SAAS,GAAGF,KAAK,KAAK,CAACE,IAAI,SAAS,IAAIC;QACvD,WAAWD,IAAI,SAAS,IAAIC;QAC5B,SAASD,IAAI,OAAO,IAAIC;QACxB,WAAWD,IAAI,SAAS;QACxB,UAAUA,IAAI,QAAQ;IAC1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CmsGroup } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IGroupRow {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
slug: string;
|
|
6
|
+
tenant: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
icon: string | null;
|
|
9
|
+
createdBy_id: string | null;
|
|
10
|
+
createdBy_displayName: string | null;
|
|
11
|
+
createdBy_type: string | null;
|
|
12
|
+
createdBy: string | null;
|
|
13
|
+
createdOn: string | null;
|
|
14
|
+
savedOn: string | null;
|
|
15
|
+
isPrivate: boolean;
|
|
16
|
+
isPlugin: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const GROUP_COLUMNS: (keyof CmsGroup)[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const GROUP_COLUMN_MAP = {
|
|
2
|
+
id: true,
|
|
3
|
+
name: true,
|
|
4
|
+
slug: true,
|
|
5
|
+
tenant: true,
|
|
6
|
+
description: true,
|
|
7
|
+
icon: true,
|
|
8
|
+
createdBy: true,
|
|
9
|
+
createdOn: true,
|
|
10
|
+
savedOn: true,
|
|
11
|
+
isPrivate: true,
|
|
12
|
+
isPlugin: true
|
|
13
|
+
};
|
|
14
|
+
const GROUP_COLUMNS = Object.keys(GROUP_COLUMN_MAP);
|
|
15
|
+
export { GROUP_COLUMNS };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/group/types.js","sources":["../../../src/operations/group/types.ts"],"sourcesContent":["import type { CmsGroup } from \"@webiny/api-headless-cms/types/index.js\";\n\n/* SQL row representation of CmsGroup. */\nexport interface IGroupRow {\n id: string;\n name: string;\n slug: string;\n tenant: string;\n description: string | null;\n icon: string | null;\n /* Filterable identity columns. */\n createdBy_id: string | null;\n createdBy_displayName: string | null;\n createdBy_type: string | null;\n /* Full identity as JSON for extensibility. */\n createdBy: string | null;\n createdOn: string | null;\n savedOn: string | null;\n isPrivate: boolean;\n isPlugin: boolean;\n}\n\n/* Validated against CmsGroup — TypeScript errors if CmsGroup gains a new field. */\nconst GROUP_COLUMN_MAP: Record<keyof CmsGroup, true> = {\n id: true,\n name: true,\n slug: true,\n tenant: true,\n description: true,\n icon: true,\n createdBy: true,\n createdOn: true,\n savedOn: true,\n isPrivate: true,\n isPlugin: true\n};\n\nexport const GROUP_COLUMNS = Object.keys(GROUP_COLUMN_MAP) as (keyof CmsGroup)[];\n"],"names":["GROUP_COLUMN_MAP","GROUP_COLUMNS","Object"],"mappings":"AAuBA,MAAMA,mBAAiD;IACnD,IAAI;IACJ,MAAM;IACN,MAAM;IACN,QAAQ;IACR,aAAa;IACb,MAAM;IACN,WAAW;IACX,WAAW;IACX,SAAS;IACT,WAAW;IACX,UAAU;AACd;AAEO,MAAMC,gBAAgBC,OAAO,IAAI,CAACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlCreateModelImpl implements CreateModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsCreateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlCreateModel: typeof SqlCreateModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js").ICreateModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { modelToRow } from "./mappers.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
class SqlCreateModelImpl {
|
|
7
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
8
|
+
this.knex = knex;
|
|
9
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
10
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
11
|
+
}
|
|
12
|
+
async execute(params) {
|
|
13
|
+
const model = params.model;
|
|
14
|
+
const row = modelToRow(model);
|
|
15
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
16
|
+
await this.knex.client(this.tableName).insert(row);
|
|
17
|
+
return model;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const SqlCreateModel = CreateModelStorageOperation.createImplementation({
|
|
21
|
+
implementation: SqlCreateModelImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
KnexClient,
|
|
24
|
+
TableNameResolver,
|
|
25
|
+
ModelSchemaManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlCreateModel };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlCreateModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlCreateModel.js","sources":["../../../src/operations/model/SqlCreateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { CreateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { modelToRow } from \"./mappers.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlCreateModelImpl implements CreateModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsCreateParams) {\n const model = params.model;\n const row = modelToRow(model);\n\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex.client<IModelRow>(this.tableName).insert(row);\n\n return model;\n }\n}\n\nexport const SqlCreateModel = CreateModelStorageOperation.createImplementation({\n implementation: SqlCreateModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlCreateModelImpl","knex","tableNameResolver","modelSchemaManager","params","model","row","modelToRow","SqlCreateModel","CreateModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAMC,QAAQD,OAAO,KAAK;QAC1B,MAAME,MAAMC,WAAWF;QAEvB,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAY,IAAI,CAAC,SAAS,EAAE,MAAM,CAACC;QAEzD,OAAOD;IACX;AACJ;AAEO,MAAMG,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsDeleteParams): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlDeleteModel: typeof SqlDeleteModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js").IDeleteModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
|
|
2
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
3
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
4
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
5
|
+
class SqlDeleteModelImpl {
|
|
6
|
+
constructor(knex, tableNameResolver, modelSchemaManager){
|
|
7
|
+
this.knex = knex;
|
|
8
|
+
this.modelSchemaManager = modelSchemaManager;
|
|
9
|
+
this.tableName = tableNameResolver.resolve("models");
|
|
10
|
+
}
|
|
11
|
+
async execute(params) {
|
|
12
|
+
await this.modelSchemaManager.ensure(this.tableName);
|
|
13
|
+
await this.knex.client(this.tableName).where("tenant", params.model.tenant).andWhere("modelId", params.model.modelId).delete();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({
|
|
17
|
+
implementation: SqlDeleteModelImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
KnexClient,
|
|
20
|
+
TableNameResolver,
|
|
21
|
+
ModelSchemaManager
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { SqlDeleteModel };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=SqlDeleteModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/model/SqlDeleteModel.js","sources":["../../../src/operations/model/SqlDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { IModelRow } from \"./types.js\";\nimport { DeleteModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js\";\nimport { TableNameResolver } from \"~/features/tableNameResolver/abstractions.js\";\nimport { ModelSchemaManager } from \"~/features/modelSchemaManager/abstractions.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\n\nclass SqlDeleteModelImpl implements DeleteModelStorageOperation.Interface {\n private tableName: string;\n\n constructor(\n private knex: KnexClient.Interface,\n tableNameResolver: TableNameResolver.Interface,\n private modelSchemaManager: ModelSchemaManager.Interface\n ) {\n this.tableName = tableNameResolver.resolve(\"models\");\n }\n\n async execute(params: CmsModelStorageOperationsDeleteParams) {\n await this.modelSchemaManager.ensure(this.tableName);\n await this.knex\n .client<IModelRow>(this.tableName)\n .where(\"tenant\", params.model.tenant)\n .andWhere(\"modelId\", params.model.modelId)\n .delete();\n }\n}\n\nexport const SqlDeleteModel = DeleteModelStorageOperation.createImplementation({\n implementation: SqlDeleteModelImpl,\n dependencies: [KnexClient, TableNameResolver, ModelSchemaManager]\n});\n"],"names":["SqlDeleteModelImpl","knex","tableNameResolver","modelSchemaManager","params","SqlDeleteModel","DeleteModelStorageOperation","KnexClient","TableNameResolver","ModelSchemaManager"],"mappings":";;;;AAOA,MAAMA;IAGF,YACYC,IAA0B,EAClCC,iBAA8C,EACtCC,kBAAgD,CAC1D;aAHUF,IAAI,GAAJA;aAEAE,kBAAkB,GAAlBA;QAER,IAAI,CAAC,SAAS,GAAGD,kBAAkB,OAAO,CAAC;IAC/C;IAEA,MAAM,QAAQE,MAA6C,EAAE;QACzD,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS;QACnD,MAAM,IAAI,CAAC,IAAI,CACV,MAAM,CAAY,IAAI,CAAC,SAAS,EAChC,KAAK,CAAC,UAAUA,OAAO,KAAK,CAAC,MAAM,EACnC,QAAQ,CAAC,WAAWA,OAAO,KAAK,CAAC,OAAO,EACxC,MAAM;IACf;AACJ;AAEO,MAAMC,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBN;IAChB,cAAc;QAACO;QAAYC;QAAmBC;KAAmB;AACrE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CmsModelStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
|
|
3
|
+
import { TableNameResolver } from "../../features/tableNameResolver/abstractions.js";
|
|
4
|
+
import { ModelSchemaManager } from "../../features/modelSchemaManager/abstractions.js";
|
|
5
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
6
|
+
declare class SqlGetModelImpl implements GetModelStorageOperation.Interface {
|
|
7
|
+
private knex;
|
|
8
|
+
private modelSchemaManager;
|
|
9
|
+
private tableName;
|
|
10
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface, modelSchemaManager: ModelSchemaManager.Interface);
|
|
11
|
+
execute(params: CmsModelStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel | null>;
|
|
12
|
+
}
|
|
13
|
+
export declare const SqlGetModel: typeof SqlGetModelImpl & {
|
|
14
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js").IGetModelStorageOperation>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|