@webiny/api-headless-cms-sql 0.0.0-unstable.a4f3e4ea8b → 0.0.0-unstable.d0f34a8194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/features/entryTableManager/EntryTableManager.d.ts +2 -0
- package/features/entryTableManager/EntryTableManager.js +43 -26
- package/features/entryTableManager/EntryTableManager.js.map +1 -1
- package/features/groupSchemaManager/GroupSchemaManager.js +5 -1
- package/features/groupSchemaManager/GroupSchemaManager.js.map +1 -1
- package/features/modelSchemaManager/ModelSchemaManager.js +5 -1
- package/features/modelSchemaManager/ModelSchemaManager.js.map +1 -1
- package/index.d.ts +9 -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 +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/queryHelpers.d.ts +30 -0
- package/operations/entry/queryHelpers.js +107 -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 -373
- 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,30 @@
|
|
|
1
|
+
import { GetRevisionByIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { rowToEntry } from "./mappers.js";
|
|
5
|
+
import { createEntryQuery } from "./queryHelpers.js";
|
|
6
|
+
class SqlGetRevisionByIdImpl {
|
|
7
|
+
constructor(knexClient, entryTableManager){
|
|
8
|
+
this.entryTableManager = entryTableManager;
|
|
9
|
+
this.knex = knexClient.client;
|
|
10
|
+
}
|
|
11
|
+
query() {
|
|
12
|
+
return createEntryQuery(this.knex, this.entryTableManager.getTableName());
|
|
13
|
+
}
|
|
14
|
+
async execute(model, params) {
|
|
15
|
+
await this.entryTableManager.ensureTable();
|
|
16
|
+
const row = await this.query().where("tenant", model.tenant).andWhere("modelId", model.modelId).where("id", params.id).first();
|
|
17
|
+
if (!row) return null;
|
|
18
|
+
return rowToEntry(row);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const SqlGetRevisionById = GetRevisionByIdStorageOperation.createImplementation({
|
|
22
|
+
implementation: SqlGetRevisionByIdImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
KnexClient,
|
|
25
|
+
EntryTableManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlGetRevisionById };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlGetRevisionById.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlGetRevisionById.js","sources":["../../../src/operations/entry/SqlGetRevisionById.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsGetRevisionParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionByIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport type { IEntryRow } from \"./types.js\";\nimport { rowToEntry } from \"./mappers.js\";\nimport { createEntryQuery } from \"./queryHelpers.js\";\n\nclass SqlGetRevisionByIdImpl implements GetRevisionByIdStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n private query(): Knex.QueryBuilder<IEntryRow> {\n return createEntryQuery(this.knex, this.entryTableManager.getTableName());\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) {\n await this.entryTableManager.ensureTable();\n\n const row = await this.query()\n .where(\"tenant\", model.tenant)\n .andWhere(\"modelId\", model.modelId)\n .where(\"id\", params.id)\n .first();\n\n if (!row) {\n return null;\n }\n\n return rowToEntry<T>(row);\n }\n}\n\nexport const SqlGetRevisionById = GetRevisionByIdStorageOperation.createImplementation({\n implementation: SqlGetRevisionByIdImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlGetRevisionByIdImpl","knexClient","entryTableManager","createEntryQuery","model","params","row","rowToEntry","SqlGetRevisionById","GetRevisionByIdStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;AAaA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEQ,QAAsC;QAC1C,OAAOE,iBAAiB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY;IAC1E;IAEA,MAAM,QACFC,KAAe,EACfC,MAAkD,EACpD;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,MAAM,MAAM,IAAI,CAAC,KAAK,GACvB,KAAK,CAAC,UAAUF,MAAM,MAAM,EAC5B,QAAQ,CAAC,WAAWA,MAAM,OAAO,EACjC,KAAK,CAAC,MAAMC,OAAO,EAAE,EACrB,KAAK;QAEV,IAAI,CAACC,KACD,OAAO;QAGX,OAAOC,WAAcD;IACzB;AACJ;AAEO,MAAME,qBAAqBC,gCAAgC,oBAAoB,CAAC;IACnF,gBAAgBT;IAChB,cAAc;QAACU;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsGetRevisionsParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetRevisionsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
private query;
|
|
10
|
+
execute<T extends CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsGetRevisionsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare const SqlGetRevisions: typeof SqlGetRevisionsImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js").IGetRevisionsStorageOperation>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GetRevisionsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { rowToEntry } from "./mappers.js";
|
|
6
|
+
import { createEntryQuery } from "./queryHelpers.js";
|
|
7
|
+
class SqlGetRevisionsImpl {
|
|
8
|
+
constructor(knexClient, entryTableManager){
|
|
9
|
+
this.entryTableManager = entryTableManager;
|
|
10
|
+
this.knex = knexClient.client;
|
|
11
|
+
}
|
|
12
|
+
query() {
|
|
13
|
+
return createEntryQuery(this.knex, this.entryTableManager.getTableName());
|
|
14
|
+
}
|
|
15
|
+
async execute(model, params) {
|
|
16
|
+
await this.entryTableManager.ensureTable();
|
|
17
|
+
const { id: entryId } = parseIdentifier(params.id);
|
|
18
|
+
const rows = await this.query().where("tenant", model.tenant).andWhere("modelId", model.modelId).where("entryId", entryId).orderBy("version", "desc");
|
|
19
|
+
return rows.map((row)=>rowToEntry(row));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const SqlGetRevisions = GetRevisionsStorageOperation.createImplementation({
|
|
23
|
+
implementation: SqlGetRevisionsImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
KnexClient,
|
|
26
|
+
EntryTableManager
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { SqlGetRevisions };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=SqlGetRevisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlGetRevisions.js","sources":["../../../src/operations/entry/SqlGetRevisions.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsGetRevisionsParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { IEntryRow } from \"./types.js\";\nimport { rowToEntry } from \"./mappers.js\";\nimport { createEntryQuery } from \"./queryHelpers.js\";\n\nclass SqlGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n private query(): Knex.QueryBuilder<IEntryRow> {\n return createEntryQuery(this.knex, this.entryTableManager.getTableName());\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) {\n await this.entryTableManager.ensureTable();\n\n const { id: entryId } = parseIdentifier(params.id);\n\n const rows: IEntryRow[] = await this.query()\n .where(\"tenant\", model.tenant)\n .andWhere(\"modelId\", model.modelId)\n .where(\"entryId\", entryId)\n .orderBy(\"version\", \"desc\");\n\n return rows.map(row => rowToEntry<T>(row));\n }\n}\n\nexport const SqlGetRevisions = GetRevisionsStorageOperation.createImplementation({\n implementation: SqlGetRevisionsImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlGetRevisionsImpl","knexClient","entryTableManager","createEntryQuery","model","params","entryId","parseIdentifier","rows","row","rowToEntry","SqlGetRevisions","GetRevisionsStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;;AAcA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEQ,QAAsC;QAC1C,OAAOE,iBAAiB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY;IAC1E;IAEA,MAAM,QACFC,KAAe,EACfC,MAAmD,EACrD;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF,OAAO,EAAE;QAEjD,MAAMG,OAAoB,MAAM,IAAI,CAAC,KAAK,GACrC,KAAK,CAAC,UAAUJ,MAAM,MAAM,EAC5B,QAAQ,CAAC,WAAWA,MAAM,OAAO,EACjC,KAAK,CAAC,WAAWE,SACjB,OAAO,CAAC,WAAW;QAExB,OAAOE,KAAK,GAAG,CAACC,CAAAA,MAAOC,WAAcD;IACzC;AACJ;AAEO,MAAME,kBAAkBC,6BAA6B,oBAAoB,CAAC;IAC7E,gBAAgBZ;IAChB,cAAc;QAACa;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsGetUniqueFieldValuesParams, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
6
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { CmsEntrySystemField } from "@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js";
|
|
8
|
+
import { ValueFilterRegistry } from "@webiny/db-utils";
|
|
9
|
+
import { FieldFilterPathRegistry, FieldFilterValueTransformRegistry, FieldFilterCreateRegistry, FieldSortingRegistry } from "@webiny/api-headless-cms-storage";
|
|
10
|
+
declare class SqlGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {
|
|
11
|
+
private readonly entryTableManager;
|
|
12
|
+
private readonly storageTransformRegistry;
|
|
13
|
+
private readonly storageModelProvider;
|
|
14
|
+
private readonly pathRegistry;
|
|
15
|
+
private readonly transformRegistry;
|
|
16
|
+
private readonly filterCreateRegistry;
|
|
17
|
+
private readonly sortingRegistry;
|
|
18
|
+
private readonly valueFilterRegistry;
|
|
19
|
+
private readonly entrySystemFields;
|
|
20
|
+
private readonly knex;
|
|
21
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface, storageTransformRegistry: StorageTransformRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface, pathRegistry: FieldFilterPathRegistry.Interface, transformRegistry: FieldFilterValueTransformRegistry.Interface, filterCreateRegistry: FieldFilterCreateRegistry.Interface, sortingRegistry: FieldSortingRegistry.Interface, valueFilterRegistry: ValueFilterRegistry.Interface, entrySystemFields: CmsEntrySystemField.Interface[]);
|
|
22
|
+
execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntryUniqueValue[]>;
|
|
23
|
+
}
|
|
24
|
+
export declare const SqlGetUniqueFieldValues: typeof SqlGetUniqueFieldValuesImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js").IGetUniqueFieldValuesStorageOperation>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { CmsEntrySystemField } from "@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js";
|
|
7
|
+
import { ValueFilterRegistry } from "@webiny/db-utils";
|
|
8
|
+
import { FieldFilterCreateRegistry, FieldFilterPathRegistry, FieldFilterValueTransformRegistry, FieldSortingRegistry, aggregateUniqueFieldValues } from "@webiny/api-headless-cms-storage";
|
|
9
|
+
import { MAX_LIST_LIMIT, listEntries } from "./queryHelpers.js";
|
|
10
|
+
class SqlGetUniqueFieldValuesImpl {
|
|
11
|
+
constructor(knexClient, entryTableManager, storageTransformRegistry, storageModelProvider, pathRegistry, transformRegistry, filterCreateRegistry, sortingRegistry, valueFilterRegistry, entrySystemFields){
|
|
12
|
+
this.entryTableManager = entryTableManager;
|
|
13
|
+
this.storageTransformRegistry = storageTransformRegistry;
|
|
14
|
+
this.storageModelProvider = storageModelProvider;
|
|
15
|
+
this.pathRegistry = pathRegistry;
|
|
16
|
+
this.transformRegistry = transformRegistry;
|
|
17
|
+
this.filterCreateRegistry = filterCreateRegistry;
|
|
18
|
+
this.sortingRegistry = sortingRegistry;
|
|
19
|
+
this.valueFilterRegistry = valueFilterRegistry;
|
|
20
|
+
this.entrySystemFields = entrySystemFields;
|
|
21
|
+
this.knex = knexClient.client;
|
|
22
|
+
}
|
|
23
|
+
async execute(model, params) {
|
|
24
|
+
const field = model.fields.find((f)=>f.fieldId === params.fieldId);
|
|
25
|
+
if (!field) return [];
|
|
26
|
+
await this.entryTableManager.ensureTable();
|
|
27
|
+
const { items } = await listEntries({
|
|
28
|
+
knex: this.knex,
|
|
29
|
+
tableName: this.entryTableManager.getTableName(),
|
|
30
|
+
storageModelProvider: this.storageModelProvider,
|
|
31
|
+
storageTransformRegistry: this.storageTransformRegistry,
|
|
32
|
+
pathRegistry: this.pathRegistry,
|
|
33
|
+
transformRegistry: this.transformRegistry,
|
|
34
|
+
filterCreateRegistry: this.filterCreateRegistry,
|
|
35
|
+
sortingRegistry: this.sortingRegistry,
|
|
36
|
+
valueFilterRegistry: this.valueFilterRegistry,
|
|
37
|
+
systemFields: this.entrySystemFields.map((systemField)=>systemField.field)
|
|
38
|
+
}, model, {
|
|
39
|
+
where: params.where,
|
|
40
|
+
limit: MAX_LIST_LIMIT
|
|
41
|
+
});
|
|
42
|
+
return aggregateUniqueFieldValues(items, field.fieldId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const SqlGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({
|
|
46
|
+
implementation: SqlGetUniqueFieldValuesImpl,
|
|
47
|
+
dependencies: [
|
|
48
|
+
KnexClient,
|
|
49
|
+
EntryTableManager,
|
|
50
|
+
StorageTransformRegistry,
|
|
51
|
+
CmsStorageModelProvider,
|
|
52
|
+
FieldFilterPathRegistry,
|
|
53
|
+
FieldFilterValueTransformRegistry,
|
|
54
|
+
FieldFilterCreateRegistry,
|
|
55
|
+
FieldSortingRegistry,
|
|
56
|
+
ValueFilterRegistry,
|
|
57
|
+
[
|
|
58
|
+
CmsEntrySystemField,
|
|
59
|
+
{
|
|
60
|
+
multiple: true
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
export { SqlGetUniqueFieldValues };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=SqlGetUniqueFieldValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlGetUniqueFieldValues.js","sources":["../../../src/operations/entry/SqlGetUniqueFieldValues.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsGetUniqueFieldValuesParams,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetUniqueFieldValuesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { StorageTransformRegistry } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { CmsEntrySystemField } from \"@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js\";\nimport { ValueFilterRegistry } from \"@webiny/db-utils\";\nimport {\n aggregateUniqueFieldValues,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry\n} from \"@webiny/api-headless-cms-storage\";\nimport { listEntries, MAX_LIST_LIMIT } from \"./queryHelpers.js\";\n\nclass SqlGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface,\n private readonly storageTransformRegistry: StorageTransformRegistry.Interface,\n private readonly storageModelProvider: CmsStorageModelProvider.Interface,\n private readonly pathRegistry: FieldFilterPathRegistry.Interface,\n private readonly transformRegistry: FieldFilterValueTransformRegistry.Interface,\n private readonly filterCreateRegistry: FieldFilterCreateRegistry.Interface,\n private readonly sortingRegistry: FieldSortingRegistry.Interface,\n private readonly valueFilterRegistry: ValueFilterRegistry.Interface,\n private readonly entrySystemFields: CmsEntrySystemField.Interface[]\n ) {\n this.knex = knexClient.client;\n }\n\n async execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams) {\n const field = model.fields.find(f => f.fieldId === params.fieldId);\n\n if (!field) {\n return [];\n }\n\n await this.entryTableManager.ensureTable();\n\n const { items } = await listEntries(\n {\n knex: this.knex,\n tableName: this.entryTableManager.getTableName(),\n storageModelProvider: this.storageModelProvider,\n storageTransformRegistry: this.storageTransformRegistry,\n pathRegistry: this.pathRegistry,\n transformRegistry: this.transformRegistry,\n filterCreateRegistry: this.filterCreateRegistry,\n sortingRegistry: this.sortingRegistry,\n valueFilterRegistry: this.valueFilterRegistry,\n systemFields: this.entrySystemFields.map(systemField => systemField.field)\n },\n model,\n {\n where: params.where,\n limit: MAX_LIST_LIMIT\n }\n );\n\n return aggregateUniqueFieldValues(items, field.fieldId);\n }\n}\n\nexport const SqlGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({\n implementation: SqlGetUniqueFieldValuesImpl,\n dependencies: [\n KnexClient,\n EntryTableManager,\n StorageTransformRegistry,\n CmsStorageModelProvider,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry,\n ValueFilterRegistry,\n [CmsEntrySystemField, { multiple: true }]\n ]\n});\n"],"names":["SqlGetUniqueFieldValuesImpl","knexClient","entryTableManager","storageTransformRegistry","storageModelProvider","pathRegistry","transformRegistry","filterCreateRegistry","sortingRegistry","valueFilterRegistry","entrySystemFields","model","params","field","f","items","listEntries","systemField","MAX_LIST_LIMIT","aggregateUniqueFieldValues","SqlGetUniqueFieldValues","GetUniqueFieldValuesStorageOperation","KnexClient","EntryTableManager","StorageTransformRegistry","CmsStorageModelProvider","FieldFilterPathRegistry","FieldFilterValueTransformRegistry","FieldFilterCreateRegistry","FieldSortingRegistry","ValueFilterRegistry","CmsEntrySystemField"],"mappings":";;;;;;;;;AAqBA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,EAC9CC,wBAA4D,EAC5DC,oBAAuD,EACvDC,YAA+C,EAC/CC,iBAA8D,EAC9DC,oBAAyD,EACzDC,eAA+C,EAC/CC,mBAAkD,EAClDC,iBAAkD,CACrE;aATmBR,iBAAiB,GAAjBA;aACAC,wBAAwB,GAAxBA;aACAC,oBAAoB,GAApBA;aACAC,YAAY,GAAZA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,eAAe,GAAfA;aACAC,mBAAmB,GAAnBA;aACAC,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGT,WAAW,MAAM;IACjC;IAEA,MAAM,QAAQU,KAAe,EAAEC,MAA2D,EAAE;QACxF,MAAMC,QAAQF,MAAM,MAAM,CAAC,IAAI,CAACG,CAAAA,IAAKA,EAAE,OAAO,KAAKF,OAAO,OAAO;QAEjE,IAAI,CAACC,OACD,OAAO,EAAE;QAGb,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAM,EAAEE,KAAK,EAAE,GAAG,MAAMC,YACpB;YACI,MAAM,IAAI,CAAC,IAAI;YACf,WAAW,IAAI,CAAC,iBAAiB,CAAC,YAAY;YAC9C,sBAAsB,IAAI,CAAC,oBAAoB;YAC/C,0BAA0B,IAAI,CAAC,wBAAwB;YACvD,cAAc,IAAI,CAAC,YAAY;YAC/B,mBAAmB,IAAI,CAAC,iBAAiB;YACzC,sBAAsB,IAAI,CAAC,oBAAoB;YAC/C,iBAAiB,IAAI,CAAC,eAAe;YACrC,qBAAqB,IAAI,CAAC,mBAAmB;YAC7C,cAAc,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACC,CAAAA,cAAeA,YAAY,KAAK;QAC7E,GACAN,OACA;YACI,OAAOC,OAAO,KAAK;YACnB,OAAOM;QACX;QAGJ,OAAOC,2BAA2BJ,OAAOF,MAAM,OAAO;IAC1D;AACJ;AAEO,MAAMO,0BAA0BC,qCAAqC,oBAAoB,CAAC;IAC7F,gBAAgBrB;IAChB,cAAc;QACVsB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAC5C;AACL"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsListParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
6
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { CmsEntrySystemField } from "@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js";
|
|
8
|
+
import { ValueFilterRegistry } from "@webiny/db-utils";
|
|
9
|
+
import { FieldFilterPathRegistry, FieldFilterValueTransformRegistry, FieldFilterCreateRegistry, FieldSortingRegistry } from "@webiny/api-headless-cms-storage";
|
|
10
|
+
declare class SqlListEntriesImpl implements ListEntriesStorageOperation.Interface {
|
|
11
|
+
private readonly entryTableManager;
|
|
12
|
+
private readonly storageTransformRegistry;
|
|
13
|
+
private readonly storageModelProvider;
|
|
14
|
+
private readonly pathRegistry;
|
|
15
|
+
private readonly transformRegistry;
|
|
16
|
+
private readonly filterCreateRegistry;
|
|
17
|
+
private readonly sortingRegistry;
|
|
18
|
+
private readonly valueFilterRegistry;
|
|
19
|
+
private readonly entrySystemFields;
|
|
20
|
+
private readonly knex;
|
|
21
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface, storageTransformRegistry: StorageTransformRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface, pathRegistry: FieldFilterPathRegistry.Interface, transformRegistry: FieldFilterValueTransformRegistry.Interface, filterCreateRegistry: FieldFilterCreateRegistry.Interface, sortingRegistry: FieldSortingRegistry.Interface, valueFilterRegistry: ValueFilterRegistry.Interface, entrySystemFields: CmsEntrySystemField.Interface[]);
|
|
22
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsListParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntryStorageOperationsListResponse<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>>>;
|
|
23
|
+
}
|
|
24
|
+
export declare const SqlListEntries: typeof SqlListEntriesImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js").IListEntriesStorageOperation>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { StorageTransformRegistry } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
|
|
5
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
6
|
+
import { CmsEntrySystemField } from "@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js";
|
|
7
|
+
import { ValueFilterRegistry } from "@webiny/db-utils";
|
|
8
|
+
import { FieldFilterCreateRegistry, FieldFilterPathRegistry, FieldFilterValueTransformRegistry, FieldSortingRegistry } from "@webiny/api-headless-cms-storage";
|
|
9
|
+
import { listEntries } from "./queryHelpers.js";
|
|
10
|
+
class SqlListEntriesImpl {
|
|
11
|
+
constructor(knexClient, entryTableManager, storageTransformRegistry, storageModelProvider, pathRegistry, transformRegistry, filterCreateRegistry, sortingRegistry, valueFilterRegistry, entrySystemFields){
|
|
12
|
+
this.entryTableManager = entryTableManager;
|
|
13
|
+
this.storageTransformRegistry = storageTransformRegistry;
|
|
14
|
+
this.storageModelProvider = storageModelProvider;
|
|
15
|
+
this.pathRegistry = pathRegistry;
|
|
16
|
+
this.transformRegistry = transformRegistry;
|
|
17
|
+
this.filterCreateRegistry = filterCreateRegistry;
|
|
18
|
+
this.sortingRegistry = sortingRegistry;
|
|
19
|
+
this.valueFilterRegistry = valueFilterRegistry;
|
|
20
|
+
this.entrySystemFields = entrySystemFields;
|
|
21
|
+
this.knex = knexClient.client;
|
|
22
|
+
}
|
|
23
|
+
async execute(model, params) {
|
|
24
|
+
await this.entryTableManager.ensureTable();
|
|
25
|
+
return listEntries({
|
|
26
|
+
knex: this.knex,
|
|
27
|
+
tableName: this.entryTableManager.getTableName(),
|
|
28
|
+
storageModelProvider: this.storageModelProvider,
|
|
29
|
+
storageTransformRegistry: this.storageTransformRegistry,
|
|
30
|
+
pathRegistry: this.pathRegistry,
|
|
31
|
+
transformRegistry: this.transformRegistry,
|
|
32
|
+
filterCreateRegistry: this.filterCreateRegistry,
|
|
33
|
+
sortingRegistry: this.sortingRegistry,
|
|
34
|
+
valueFilterRegistry: this.valueFilterRegistry,
|
|
35
|
+
systemFields: this.entrySystemFields.map((systemField)=>systemField.field)
|
|
36
|
+
}, model, params);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const SqlListEntries = ListEntriesStorageOperation.createImplementation({
|
|
40
|
+
implementation: SqlListEntriesImpl,
|
|
41
|
+
dependencies: [
|
|
42
|
+
KnexClient,
|
|
43
|
+
EntryTableManager,
|
|
44
|
+
StorageTransformRegistry,
|
|
45
|
+
CmsStorageModelProvider,
|
|
46
|
+
FieldFilterPathRegistry,
|
|
47
|
+
FieldFilterValueTransformRegistry,
|
|
48
|
+
FieldFilterCreateRegistry,
|
|
49
|
+
FieldSortingRegistry,
|
|
50
|
+
ValueFilterRegistry,
|
|
51
|
+
[
|
|
52
|
+
CmsEntrySystemField,
|
|
53
|
+
{
|
|
54
|
+
multiple: true
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
export { SqlListEntries };
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=SqlListEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlListEntries.js","sources":["../../../src/operations/entry/SqlListEntries.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsListParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { StorageTransformRegistry } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { CmsEntrySystemField } from \"@webiny/api-headless-cms/features/contentEntry/EntrySystemField/index.js\";\nimport { ValueFilterRegistry } from \"@webiny/db-utils\";\nimport {\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry\n} from \"@webiny/api-headless-cms-storage\";\nimport { listEntries } from \"./queryHelpers.js\";\n\nclass SqlListEntriesImpl implements ListEntriesStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface,\n private readonly storageTransformRegistry: StorageTransformRegistry.Interface,\n private readonly storageModelProvider: CmsStorageModelProvider.Interface,\n private readonly pathRegistry: FieldFilterPathRegistry.Interface,\n private readonly transformRegistry: FieldFilterValueTransformRegistry.Interface,\n private readonly filterCreateRegistry: FieldFilterCreateRegistry.Interface,\n private readonly sortingRegistry: FieldSortingRegistry.Interface,\n private readonly valueFilterRegistry: ValueFilterRegistry.Interface,\n private readonly entrySystemFields: CmsEntrySystemField.Interface[]\n ) {\n this.knex = knexClient.client;\n }\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) {\n await this.entryTableManager.ensureTable();\n\n return listEntries<T>(\n {\n knex: this.knex,\n tableName: this.entryTableManager.getTableName(),\n storageModelProvider: this.storageModelProvider,\n storageTransformRegistry: this.storageTransformRegistry,\n pathRegistry: this.pathRegistry,\n transformRegistry: this.transformRegistry,\n filterCreateRegistry: this.filterCreateRegistry,\n sortingRegistry: this.sortingRegistry,\n valueFilterRegistry: this.valueFilterRegistry,\n systemFields: this.entrySystemFields.map(systemField => systemField.field)\n },\n model,\n params\n );\n }\n}\n\nexport const SqlListEntries = ListEntriesStorageOperation.createImplementation({\n implementation: SqlListEntriesImpl,\n dependencies: [\n KnexClient,\n EntryTableManager,\n StorageTransformRegistry,\n CmsStorageModelProvider,\n FieldFilterPathRegistry,\n FieldFilterValueTransformRegistry,\n FieldFilterCreateRegistry,\n FieldSortingRegistry,\n ValueFilterRegistry,\n [CmsEntrySystemField, { multiple: true }]\n ]\n});\n"],"names":["SqlListEntriesImpl","knexClient","entryTableManager","storageTransformRegistry","storageModelProvider","pathRegistry","transformRegistry","filterCreateRegistry","sortingRegistry","valueFilterRegistry","entrySystemFields","model","params","listEntries","systemField","SqlListEntries","ListEntriesStorageOperation","KnexClient","EntryTableManager","StorageTransformRegistry","CmsStorageModelProvider","FieldFilterPathRegistry","FieldFilterValueTransformRegistry","FieldFilterCreateRegistry","FieldSortingRegistry","ValueFilterRegistry","CmsEntrySystemField"],"mappings":";;;;;;;;;AAqBA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,EAC9CC,wBAA4D,EAC5DC,oBAAuD,EACvDC,YAA+C,EAC/CC,iBAA8D,EAC9DC,oBAAyD,EACzDC,eAA+C,EAC/CC,mBAAkD,EAClDC,iBAAkD,CACrE;aATmBR,iBAAiB,GAAjBA;aACAC,wBAAwB,GAAxBA;aACAC,oBAAoB,GAApBA;aACAC,YAAY,GAAZA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,eAAe,GAAfA;aACAC,mBAAmB,GAAnBA;aACAC,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGT,WAAW,MAAM;IACjC;IAEA,MAAM,QACFU,KAAe,EACfC,MAA2C,EAC7C;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,OAAOC,YACH;YACI,MAAM,IAAI,CAAC,IAAI;YACf,WAAW,IAAI,CAAC,iBAAiB,CAAC,YAAY;YAC9C,sBAAsB,IAAI,CAAC,oBAAoB;YAC/C,0BAA0B,IAAI,CAAC,wBAAwB;YACvD,cAAc,IAAI,CAAC,YAAY;YAC/B,mBAAmB,IAAI,CAAC,iBAAiB;YACzC,sBAAsB,IAAI,CAAC,oBAAoB;YAC/C,iBAAiB,IAAI,CAAC,eAAe;YACrC,qBAAqB,IAAI,CAAC,mBAAmB;YAC7C,cAAc,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAACC,CAAAA,cAAeA,YAAY,KAAK;QAC7E,GACAH,OACAC;IAER;AACJ;AAEO,MAAMG,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBhB;IAChB,cAAc;QACViB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;KAC5C;AACL"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlMoveEntryImpl implements MoveEntryStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
execute(model: CmsModel, id: string, folderId: string): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SqlMoveEntry: typeof SqlMoveEntryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js").IMoveEntryStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { patchAllEntryRevisions } from "./queryHelpers.js";
|
|
6
|
+
class SqlMoveEntryImpl {
|
|
7
|
+
constructor(knexClient, entryTableManager){
|
|
8
|
+
this.entryTableManager = entryTableManager;
|
|
9
|
+
this.knex = knexClient.client;
|
|
10
|
+
}
|
|
11
|
+
async execute(model, id, folderId) {
|
|
12
|
+
await this.entryTableManager.ensureTable();
|
|
13
|
+
const { id: entryId } = parseIdentifier(id);
|
|
14
|
+
await patchAllEntryRevisions(this.knex, this.entryTableManager.getTableName(), model, entryId, (parsed)=>{
|
|
15
|
+
parsed.location = {
|
|
16
|
+
folderId
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const SqlMoveEntry = MoveEntryStorageOperation.createImplementation({
|
|
22
|
+
implementation: SqlMoveEntryImpl,
|
|
23
|
+
dependencies: [
|
|
24
|
+
KnexClient,
|
|
25
|
+
EntryTableManager
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
export { SqlMoveEntry };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=SqlMoveEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlMoveEntry.js","sources":["../../../src/operations/entry/SqlMoveEntry.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { patchAllEntryRevisions } from \"./queryHelpers.js\";\n\nclass SqlMoveEntryImpl implements MoveEntryStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n async execute(model: CmsModel, id: string, folderId: string) {\n await this.entryTableManager.ensureTable();\n\n const { id: entryId } = parseIdentifier(id);\n\n await patchAllEntryRevisions(\n this.knex,\n this.entryTableManager.getTableName(),\n model,\n entryId,\n parsed => {\n parsed.location = { folderId };\n }\n );\n }\n}\n\nexport const SqlMoveEntry = MoveEntryStorageOperation.createImplementation({\n implementation: SqlMoveEntryImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlMoveEntryImpl","knexClient","entryTableManager","model","id","folderId","entryId","parseIdentifier","patchAllEntryRevisions","parsed","SqlMoveEntry","MoveEntryStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;AAQA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEA,MAAM,QAAQE,KAAe,EAAEC,EAAU,EAAEC,QAAgB,EAAE;QACzD,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBH;QAExC,MAAMI,uBACF,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,YAAY,IACnCL,OACAG,SACAG,CAAAA;YACIA,OAAO,QAAQ,GAAG;gBAAEJ;YAAS;QACjC;IAER;AACJ;AAEO,MAAMK,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBX;IAChB,cAAc;QAACY;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsMoveToBinParams, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlMoveToBinImpl implements MoveToBinStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
execute(model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SqlMoveToBin: typeof SqlMoveToBinImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js").IMoveToBinStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { patchAllEntryRevisions } from "./queryHelpers.js";
|
|
5
|
+
class SqlMoveToBinImpl {
|
|
6
|
+
constructor(knexClient, entryTableManager){
|
|
7
|
+
this.entryTableManager = entryTableManager;
|
|
8
|
+
this.knex = knexClient.client;
|
|
9
|
+
}
|
|
10
|
+
async execute(model, params) {
|
|
11
|
+
await this.entryTableManager.ensureTable();
|
|
12
|
+
await patchAllEntryRevisions(this.knex, this.entryTableManager.getTableName(), model, params.entry.entryId, (parsed)=>{
|
|
13
|
+
const p = parsed;
|
|
14
|
+
p["wbyDeleted"] = true;
|
|
15
|
+
p["binOriginalFolderId"] = params.storageEntry.binOriginalFolderId ?? null;
|
|
16
|
+
p["location"] = params.storageEntry.location ?? null;
|
|
17
|
+
const fields = Object.keys(params.storageEntry);
|
|
18
|
+
for (const field of fields)if ("createdOn" !== field && "createdBy" !== field) {
|
|
19
|
+
if ((field.endsWith("On") || field.endsWith("By")) && !field.startsWith("revision")) p[field] = params.storageEntry[field];
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
wbyDeleted: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const SqlMoveToBin = MoveToBinStorageOperation.createImplementation({
|
|
27
|
+
implementation: SqlMoveToBinImpl,
|
|
28
|
+
dependencies: [
|
|
29
|
+
KnexClient,
|
|
30
|
+
EntryTableManager
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
export { SqlMoveToBin };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=SqlMoveToBin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlMoveToBin.js","sources":["../../../src/operations/entry/SqlMoveToBin.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsMoveToBinParams,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveToBinStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { patchAllEntryRevisions } from \"./queryHelpers.js\";\n\nclass SqlMoveToBinImpl implements MoveToBinStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n async execute(model: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams) {\n await this.entryTableManager.ensureTable();\n\n await patchAllEntryRevisions(\n this.knex,\n this.entryTableManager.getTableName(),\n model,\n params.entry.entryId,\n parsed => {\n const p = parsed as unknown as Record<string, unknown>;\n p[\"wbyDeleted\"] = true;\n p[\"binOriginalFolderId\"] = params.storageEntry.binOriginalFolderId ?? null;\n p[\"location\"] = params.storageEntry.location ?? null;\n\n const fields = Object.keys(params.storageEntry);\n for (const field of fields) {\n if (field === \"createdOn\" || field === \"createdBy\") {\n continue;\n }\n if (\n (field.endsWith(\"On\") || field.endsWith(\"By\")) &&\n !field.startsWith(\"revision\")\n ) {\n p[field] = (params.storageEntry as Record<string, unknown>)[field];\n }\n }\n },\n {\n wbyDeleted: true\n }\n );\n }\n}\n\nexport const SqlMoveToBin = MoveToBinStorageOperation.createImplementation({\n implementation: SqlMoveToBinImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlMoveToBinImpl","knexClient","entryTableManager","model","params","patchAllEntryRevisions","parsed","p","fields","Object","field","SqlMoveToBin","MoveToBinStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;AAUA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEA,MAAM,QAAQE,KAAe,EAAEC,MAAgD,EAAE;QAC7E,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,uBACF,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,YAAY,IACnCF,OACAC,OAAO,KAAK,CAAC,OAAO,EACpBE,CAAAA;YACI,MAAMC,IAAID;YACVC,CAAC,CAAC,aAAa,GAAG;YAClBA,CAAC,CAAC,sBAAsB,GAAGH,OAAO,YAAY,CAAC,mBAAmB,IAAI;YACtEG,CAAC,CAAC,WAAW,GAAGH,OAAO,YAAY,CAAC,QAAQ,IAAI;YAEhD,MAAMI,SAASC,OAAO,IAAI,CAACL,OAAO,YAAY;YAC9C,KAAK,MAAMM,SAASF,OAChB,IAAIE,AAAU,gBAAVA,SAAyBA,AAAU,gBAAVA,OAG7B;gBAAA,IACKA,AAAAA,CAAAA,MAAM,QAAQ,CAAC,SAASA,MAAM,QAAQ,CAAC,KAAI,KAC5C,CAACA,MAAM,UAAU,CAAC,aAElBH,CAAC,CAACG,MAAM,GAAIN,OAAO,YAAwC,CAACM,MAAM;YACtE;QAER,GACA;YACI,YAAY;QAChB;IAER;AACJ;AAEO,MAAMC,eAAeC,0BAA0B,oBAAoB,CAAC;IACvE,gBAAgBZ;IAChB,cAAc;QAACa;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsPublishParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { PublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlPublishEntryImpl implements PublishEntryStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
private modelQuery;
|
|
10
|
+
execute<T extends CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const SqlPublishEntry: typeof SqlPublishEntryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js").IPublishEntryStorageOperation>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { entryToRow } from "./mappers.js";
|
|
5
|
+
import { createModelEntryQuery, syncEntryToLatest } from "./queryHelpers.js";
|
|
6
|
+
class SqlPublishEntryImpl {
|
|
7
|
+
constructor(knexClient, entryTableManager){
|
|
8
|
+
this.entryTableManager = entryTableManager;
|
|
9
|
+
this.knex = knexClient.client;
|
|
10
|
+
}
|
|
11
|
+
modelQuery(model) {
|
|
12
|
+
return createModelEntryQuery(this.knex, this.entryTableManager.getTableName(), model);
|
|
13
|
+
}
|
|
14
|
+
async execute(model, params) {
|
|
15
|
+
await this.entryTableManager.ensureTable();
|
|
16
|
+
const oldPublishedRows = await this.modelQuery(model).andWhere("entryId", params.entry.entryId).andWhere("isPublished", true);
|
|
17
|
+
for (const row of oldPublishedRows){
|
|
18
|
+
const parsed = JSON.parse(row.data);
|
|
19
|
+
parsed.isPublished = false;
|
|
20
|
+
parsed.status = "unpublished";
|
|
21
|
+
await this.modelQuery(model).andWhere("id", row.id).update({
|
|
22
|
+
isPublished: false,
|
|
23
|
+
data: JSON.stringify(parsed)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const existing = await this.modelQuery(model).andWhere("id", params.storageEntry.id).first();
|
|
27
|
+
const se = params.storageEntry;
|
|
28
|
+
se.isLatest = existing?.isLatest ?? se.isLatest;
|
|
29
|
+
se.isPublished = true;
|
|
30
|
+
const row = entryToRow(se);
|
|
31
|
+
const { isLatest: _il, ...rowWithoutIsLatest } = row;
|
|
32
|
+
await this.modelQuery(model).andWhere("id", params.storageEntry.id).update(rowWithoutIsLatest);
|
|
33
|
+
const liveValue = {
|
|
34
|
+
version: params.entry.version
|
|
35
|
+
};
|
|
36
|
+
await syncEntryToLatest(this.knex, this.entryTableManager.getTableName(), model, se, (latest)=>{
|
|
37
|
+
latest.live = liveValue;
|
|
38
|
+
});
|
|
39
|
+
return params.entry;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const SqlPublishEntry = PublishEntryStorageOperation.createImplementation({
|
|
43
|
+
implementation: SqlPublishEntryImpl,
|
|
44
|
+
dependencies: [
|
|
45
|
+
KnexClient,
|
|
46
|
+
EntryTableManager
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
export { SqlPublishEntry };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=SqlPublishEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlPublishEntry.js","sources":["../../../src/operations/entry/SqlPublishEntry.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsPublishParams,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { PublishEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport type { IEntryRow } from \"./types.js\";\nimport { entryToRow } from \"./mappers.js\";\nimport { createModelEntryQuery, syncEntryToLatest } from \"./queryHelpers.js\";\n\nclass SqlPublishEntryImpl implements PublishEntryStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n private modelQuery(model: CmsModel): Knex.QueryBuilder<IEntryRow> {\n return createModelEntryQuery(this.knex, this.entryTableManager.getTableName(), model);\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsPublishParams<T>\n ) {\n await this.entryTableManager.ensureTable();\n\n const oldPublishedRows = await this.modelQuery(model)\n .andWhere(\"entryId\", params.entry.entryId)\n .andWhere(\"isPublished\", true);\n\n for (const row of oldPublishedRows) {\n const parsed = JSON.parse(row.data);\n parsed.isPublished = false;\n parsed.status = \"unpublished\";\n\n await this.modelQuery(model)\n .andWhere(\"id\", row.id)\n .update({ isPublished: false, data: JSON.stringify(parsed) });\n }\n\n const existing = await this.modelQuery(model)\n .andWhere(\"id\", params.storageEntry.id)\n .first();\n const se = params.storageEntry as CmsStorageEntry;\n se.isLatest = existing?.isLatest ?? se.isLatest;\n se.isPublished = true;\n\n const row = entryToRow(se);\n const { isLatest: _il, ...rowWithoutIsLatest } = row;\n\n await this.modelQuery(model)\n .andWhere(\"id\", params.storageEntry.id)\n .update(rowWithoutIsLatest);\n\n const liveValue = { version: params.entry.version };\n await syncEntryToLatest(\n this.knex,\n this.entryTableManager.getTableName(),\n model,\n se,\n latest => {\n latest.live = liveValue;\n }\n );\n\n return params.entry;\n }\n}\n\nexport const SqlPublishEntry = PublishEntryStorageOperation.createImplementation({\n implementation: SqlPublishEntryImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlPublishEntryImpl","knexClient","entryTableManager","model","createModelEntryQuery","params","oldPublishedRows","row","parsed","JSON","existing","se","entryToRow","_il","rowWithoutIsLatest","liveValue","syncEntryToLatest","latest","SqlPublishEntry","PublishEntryStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;;AAcA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEQ,WAAWE,KAAe,EAAgC;QAC9D,OAAOC,sBAAsB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,YAAY,IAAID;IACnF;IAEA,MAAM,QACFA,KAAe,EACfE,MAAiD,EACnD;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,mBAAmB,MAAM,IAAI,CAAC,UAAU,CAACH,OAC1C,QAAQ,CAAC,WAAWE,OAAO,KAAK,CAAC,OAAO,EACxC,QAAQ,CAAC,eAAe;QAE7B,KAAK,MAAME,OAAOD,iBAAkB;YAChC,MAAME,SAASC,KAAK,KAAK,CAACF,IAAI,IAAI;YAClCC,OAAO,WAAW,GAAG;YACrBA,OAAO,MAAM,GAAG;YAEhB,MAAM,IAAI,CAAC,UAAU,CAACL,OACjB,QAAQ,CAAC,MAAMI,IAAI,EAAE,EACrB,MAAM,CAAC;gBAAE,aAAa;gBAAO,MAAME,KAAK,SAAS,CAACD;YAAQ;QACnE;QAEA,MAAME,WAAW,MAAM,IAAI,CAAC,UAAU,CAACP,OAClC,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EACrC,KAAK;QACV,MAAMM,KAAKN,OAAO,YAAY;QAC9BM,GAAG,QAAQ,GAAGD,UAAU,YAAYC,GAAG,QAAQ;QAC/CA,GAAG,WAAW,GAAG;QAEjB,MAAMJ,MAAMK,WAAWD;QACvB,MAAM,EAAE,UAAUE,GAAG,EAAE,GAAGC,oBAAoB,GAAGP;QAEjD,MAAM,IAAI,CAAC,UAAU,CAACJ,OACjB,QAAQ,CAAC,MAAME,OAAO,YAAY,CAAC,EAAE,EACrC,MAAM,CAACS;QAEZ,MAAMC,YAAY;YAAE,SAASV,OAAO,KAAK,CAAC,OAAO;QAAC;QAClD,MAAMW,kBACF,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,YAAY,IACnCb,OACAQ,IACAM,CAAAA;YACIA,OAAO,IAAI,GAAGF;QAClB;QAGJ,OAAOV,OAAO,KAAK;IACvB;AACJ;AAEO,MAAMa,kBAAkBC,6BAA6B,oBAAoB,CAAC;IAC7E,gBAAgBnB;IAChB,cAAc;QAACoB;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsRestoreFromBinParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { RestoreFromBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlRestoreFromBinImpl implements RestoreFromBinStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsRestoreFromBinParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const SqlRestoreFromBin: typeof SqlRestoreFromBinImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js").IRestoreFromBinStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RestoreFromBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js";
|
|
2
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
3
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
4
|
+
import { patchAllEntryRevisions } from "./queryHelpers.js";
|
|
5
|
+
class SqlRestoreFromBinImpl {
|
|
6
|
+
constructor(knexClient, entryTableManager){
|
|
7
|
+
this.entryTableManager = entryTableManager;
|
|
8
|
+
this.knex = knexClient.client;
|
|
9
|
+
}
|
|
10
|
+
async execute(model, params) {
|
|
11
|
+
await this.entryTableManager.ensureTable();
|
|
12
|
+
await patchAllEntryRevisions(this.knex, this.entryTableManager.getTableName(), model, params.entry.entryId, (parsed)=>{
|
|
13
|
+
const p = parsed;
|
|
14
|
+
p["wbyDeleted"] = false;
|
|
15
|
+
p["binOriginalFolderId"] = null;
|
|
16
|
+
p["location"] = params.storageEntry.location ?? null;
|
|
17
|
+
const fields = Object.keys(params.storageEntry);
|
|
18
|
+
for (const field of fields)if ("createdOn" !== field && "createdBy" !== field) {
|
|
19
|
+
if ((field.endsWith("On") || field.endsWith("By")) && !field.startsWith("revision")) p[field] = params.storageEntry[field];
|
|
20
|
+
}
|
|
21
|
+
}, {
|
|
22
|
+
wbyDeleted: false
|
|
23
|
+
});
|
|
24
|
+
return params.entry;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const SqlRestoreFromBin = RestoreFromBinStorageOperation.createImplementation({
|
|
28
|
+
implementation: SqlRestoreFromBinImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
KnexClient,
|
|
31
|
+
EntryTableManager
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
export { SqlRestoreFromBin };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=SqlRestoreFromBin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/SqlRestoreFromBin.js","sources":["../../../src/operations/entry/SqlRestoreFromBin.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport type {\n CmsEntryStorageOperationsRestoreFromBinParams,\n CmsEntryValues,\n CmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { RestoreFromBinStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/RestoreFromBinStorageOperation.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { EntryTableManager } from \"~/features/entryTableManager/abstractions.js\";\nimport { patchAllEntryRevisions } from \"./queryHelpers.js\";\n\nclass SqlRestoreFromBinImpl implements RestoreFromBinStorageOperation.Interface {\n private readonly knex: Knex;\n\n public constructor(\n knexClient: KnexClient.Interface,\n private readonly entryTableManager: EntryTableManager.Interface\n ) {\n this.knex = knexClient.client;\n }\n\n async execute<T extends CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryStorageOperationsRestoreFromBinParams<T>\n ) {\n await this.entryTableManager.ensureTable();\n\n await patchAllEntryRevisions(\n this.knex,\n this.entryTableManager.getTableName(),\n model,\n params.entry.entryId,\n parsed => {\n const p = parsed as unknown as Record<string, unknown>;\n p[\"wbyDeleted\"] = false;\n p[\"binOriginalFolderId\"] = null;\n p[\"location\"] = params.storageEntry.location ?? null;\n\n const fields = Object.keys(params.storageEntry);\n for (const field of fields) {\n if (field === \"createdOn\" || field === \"createdBy\") {\n continue;\n }\n if (\n (field.endsWith(\"On\") || field.endsWith(\"By\")) &&\n !field.startsWith(\"revision\")\n ) {\n p[field] = (params.storageEntry as Record<string, unknown>)[field];\n }\n }\n },\n { wbyDeleted: false }\n );\n\n return params.entry;\n }\n}\n\nexport const SqlRestoreFromBin = RestoreFromBinStorageOperation.createImplementation({\n implementation: SqlRestoreFromBinImpl,\n dependencies: [KnexClient, EntryTableManager]\n});\n"],"names":["SqlRestoreFromBinImpl","knexClient","entryTableManager","model","params","patchAllEntryRevisions","parsed","p","fields","Object","field","SqlRestoreFromBin","RestoreFromBinStorageOperation","KnexClient","EntryTableManager"],"mappings":";;;;AAWA,MAAMA;IAGF,YACIC,UAAgC,EACfC,iBAA8C,CACjE;aADmBA,iBAAiB,GAAjBA;QAEjB,IAAI,CAAC,IAAI,GAAGD,WAAW,MAAM;IACjC;IAEA,MAAM,QACFE,KAAe,EACfC,MAAwD,EAC1D;QACE,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW;QAExC,MAAMC,uBACF,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,iBAAiB,CAAC,YAAY,IACnCF,OACAC,OAAO,KAAK,CAAC,OAAO,EACpBE,CAAAA;YACI,MAAMC,IAAID;YACVC,CAAC,CAAC,aAAa,GAAG;YAClBA,CAAC,CAAC,sBAAsB,GAAG;YAC3BA,CAAC,CAAC,WAAW,GAAGH,OAAO,YAAY,CAAC,QAAQ,IAAI;YAEhD,MAAMI,SAASC,OAAO,IAAI,CAACL,OAAO,YAAY;YAC9C,KAAK,MAAMM,SAASF,OAChB,IAAIE,AAAU,gBAAVA,SAAyBA,AAAU,gBAAVA,OAG7B;gBAAA,IACKA,AAAAA,CAAAA,MAAM,QAAQ,CAAC,SAASA,MAAM,QAAQ,CAAC,KAAI,KAC5C,CAACA,MAAM,UAAU,CAAC,aAElBH,CAAC,CAACG,MAAM,GAAIN,OAAO,YAAwC,CAACM,MAAM;YACtE;QAER,GACA;YAAE,YAAY;QAAM;QAGxB,OAAON,OAAO,KAAK;IACvB;AACJ;AAEO,MAAMO,oBAAoBC,+BAA+B,oBAAoB,CAAC;IACjF,gBAAgBZ;IAChB,cAAc;QAACa;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CmsEntryStorageOperationsUnpublishParams, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { UnpublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js";
|
|
3
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
4
|
+
import { EntryTableManager } from "../../features/entryTableManager/abstractions.js";
|
|
5
|
+
declare class SqlUnpublishEntryImpl implements UnpublishEntryStorageOperation.Interface {
|
|
6
|
+
private readonly entryTableManager;
|
|
7
|
+
private readonly knex;
|
|
8
|
+
constructor(knexClient: KnexClient.Interface, entryTableManager: EntryTableManager.Interface);
|
|
9
|
+
private modelQuery;
|
|
10
|
+
execute<T extends CmsEntryValues>(model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsEntry<T>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const SqlUnpublishEntry: typeof SqlUnpublishEntryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/UnpublishEntryStorageOperation.js").IUnpublishEntryStorageOperation>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|