@webiny/api-headless-cms-pg-os 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/debuggerNamespaces.d.ts +12 -0
- package/debuggerNamespaces.js +0 -0
- package/features/HeadlessCmsPgOsFeature.d.ts +9 -0
- package/features/HeadlessCmsPgOsFeature.js +40 -0
- package/features/HeadlessCmsPgOsFeature.js.map +1 -0
- package/features/SyncWriter/BuildSyncRecord.d.ts +24 -0
- package/features/SyncWriter/BuildSyncRecord.js +60 -0
- package/features/SyncWriter/BuildSyncRecord.js.map +1 -0
- package/features/SyncWriter/RemoveEntry.d.ts +11 -0
- package/features/SyncWriter/RemoveEntry.js +23 -0
- package/features/SyncWriter/RemoveEntry.js.map +1 -0
- package/features/SyncWriter/RemoveLatest.d.ts +11 -0
- package/features/SyncWriter/RemoveLatest.js +19 -0
- package/features/SyncWriter/RemoveLatest.js.map +1 -0
- package/features/SyncWriter/RemovePublished.d.ts +11 -0
- package/features/SyncWriter/RemovePublished.js +19 -0
- package/features/SyncWriter/RemovePublished.js.map +1 -0
- package/features/SyncWriter/SyncHelpers.d.ts +26 -0
- package/features/SyncWriter/SyncHelpers.js +70 -0
- package/features/SyncWriter/SyncHelpers.js.map +1 -0
- package/features/SyncWriter/SyncRowQuery.d.ts +22 -0
- package/features/SyncWriter/SyncRowQuery.js +22 -0
- package/features/SyncWriter/SyncRowQuery.js.map +1 -0
- package/features/SyncWriter/WriteEntry.d.ts +14 -0
- package/features/SyncWriter/WriteEntry.js +35 -0
- package/features/SyncWriter/WriteEntry.js.map +1 -0
- package/features/SyncWriter/WriteLatest.d.ts +14 -0
- package/features/SyncWriter/WriteLatest.js +29 -0
- package/features/SyncWriter/WriteLatest.js.map +1 -0
- package/features/SyncWriter/WritePublished.d.ts +14 -0
- package/features/SyncWriter/WritePublished.js +29 -0
- package/features/SyncWriter/WritePublished.js.map +1 -0
- package/features/SyncWriter/abstractions/BuildSyncRecord.d.ts +18 -0
- package/features/SyncWriter/abstractions/BuildSyncRecord.js +5 -0
- package/features/SyncWriter/abstractions/BuildSyncRecord.js.map +1 -0
- package/features/SyncWriter/abstractions/RemoveEntry.d.ts +13 -0
- package/features/SyncWriter/abstractions/RemoveEntry.js +5 -0
- package/features/SyncWriter/abstractions/RemoveEntry.js.map +1 -0
- package/features/SyncWriter/abstractions/RemoveLatest.d.ts +13 -0
- package/features/SyncWriter/abstractions/RemoveLatest.js +5 -0
- package/features/SyncWriter/abstractions/RemoveLatest.js.map +1 -0
- package/features/SyncWriter/abstractions/RemovePublished.d.ts +13 -0
- package/features/SyncWriter/abstractions/RemovePublished.js +5 -0
- package/features/SyncWriter/abstractions/RemovePublished.js.map +1 -0
- package/features/SyncWriter/abstractions/SyncHelpers.d.ts +10 -0
- package/features/SyncWriter/abstractions/SyncHelpers.js +5 -0
- package/features/SyncWriter/abstractions/SyncHelpers.js.map +1 -0
- package/features/SyncWriter/abstractions/SyncRowQuery.d.ts +9 -0
- package/features/SyncWriter/abstractions/SyncRowQuery.js +5 -0
- package/features/SyncWriter/abstractions/SyncRowQuery.js.map +1 -0
- package/features/SyncWriter/abstractions/WriteEntry.d.ts +14 -0
- package/features/SyncWriter/abstractions/WriteEntry.js +5 -0
- package/features/SyncWriter/abstractions/WriteEntry.js.map +1 -0
- package/features/SyncWriter/abstractions/WriteLatest.d.ts +14 -0
- package/features/SyncWriter/abstractions/WriteLatest.js +5 -0
- package/features/SyncWriter/abstractions/WriteLatest.js.map +1 -0
- package/features/SyncWriter/abstractions/WritePublished.d.ts +14 -0
- package/features/SyncWriter/abstractions/WritePublished.js +5 -0
- package/features/SyncWriter/abstractions/WritePublished.js.map +1 -0
- package/features/SyncWriter/feature.d.ts +4 -0
- package/features/SyncWriter/feature.js +27 -0
- package/features/SyncWriter/feature.js.map +1 -0
- package/features/SyncWriter/index.d.ts +9 -0
- package/features/SyncWriter/index.js +9 -0
- package/features/syncEventHandler/SyncEventHandler.d.ts +15 -0
- package/features/syncEventHandler/SyncEventHandler.js +49 -0
- package/features/syncEventHandler/SyncEventHandler.js.map +1 -0
- package/features/syncEventHandler/abstractions.d.ts +12 -0
- package/features/syncEventHandler/abstractions.js +5 -0
- package/features/syncEventHandler/abstractions.js.map +1 -0
- package/features/syncEventHandler/feature.d.ts +4 -0
- package/features/syncEventHandler/feature.js +11 -0
- package/features/syncEventHandler/feature.js.map +1 -0
- package/features/syncTableManager/SyncTableManager.d.ts +19 -0
- package/features/syncTableManager/SyncTableManager.js +62 -0
- package/features/syncTableManager/SyncTableManager.js.map +1 -0
- package/features/syncTableManager/abstractions.d.ts +9 -0
- package/features/syncTableManager/abstractions.js +5 -0
- package/features/syncTableManager/abstractions.js.map +1 -0
- package/features/syncTableManager/feature.d.ts +4 -0
- package/features/syncTableManager/feature.js +11 -0
- package/features/syncTableManager/feature.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/operations/entry/EntrySearchOperations.d.ts +17 -0
- package/operations/entry/EntrySearchOperations.js +41 -0
- package/operations/entry/EntrySearchOperations.js.map +1 -0
- package/operations/entry/PgOsCreateEntry.d.ts +15 -0
- package/operations/entry/PgOsCreateEntry.js +27 -0
- package/operations/entry/PgOsCreateEntry.js.map +1 -0
- package/operations/entry/PgOsCreateEntryRevisionFrom.d.ts +15 -0
- package/operations/entry/PgOsCreateEntryRevisionFrom.js +27 -0
- package/operations/entry/PgOsCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/PgOsDeleteEntry.d.ts +17 -0
- package/operations/entry/PgOsDeleteEntry.js +33 -0
- package/operations/entry/PgOsDeleteEntry.js.map +1 -0
- package/operations/entry/PgOsDeleteEntryRevision.d.ts +21 -0
- package/operations/entry/PgOsDeleteEntryRevision.js +48 -0
- package/operations/entry/PgOsDeleteEntryRevision.js.map +1 -0
- package/operations/entry/PgOsDeleteMultipleEntries.d.ts +17 -0
- package/operations/entry/PgOsDeleteMultipleEntries.js +36 -0
- package/operations/entry/PgOsDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/PgOsGetEntry.d.ts +12 -0
- package/operations/entry/PgOsGetEntry.js +19 -0
- package/operations/entry/PgOsGetEntry.js.map +1 -0
- package/operations/entry/PgOsGetUniqueFieldValues.d.ts +12 -0
- package/operations/entry/PgOsGetUniqueFieldValues.js +19 -0
- package/operations/entry/PgOsGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/PgOsListEntries.d.ts +12 -0
- package/operations/entry/PgOsListEntries.js +19 -0
- package/operations/entry/PgOsListEntries.js.map +1 -0
- package/operations/entry/PgOsMoveEntry.d.ts +15 -0
- package/operations/entry/PgOsMoveEntry.js +26 -0
- package/operations/entry/PgOsMoveEntry.js.map +1 -0
- package/operations/entry/PgOsMoveToBin.d.ts +15 -0
- package/operations/entry/PgOsMoveToBin.js +26 -0
- package/operations/entry/PgOsMoveToBin.js.map +1 -0
- package/operations/entry/PgOsPublishEntry.d.ts +17 -0
- package/operations/entry/PgOsPublishEntry.js +34 -0
- package/operations/entry/PgOsPublishEntry.js.map +1 -0
- package/operations/entry/PgOsRestoreFromBin.d.ts +15 -0
- package/operations/entry/PgOsRestoreFromBin.js +27 -0
- package/operations/entry/PgOsRestoreFromBin.js.map +1 -0
- package/operations/entry/PgOsUnpublishEntry.d.ts +19 -0
- package/operations/entry/PgOsUnpublishEntry.js +41 -0
- package/operations/entry/PgOsUnpublishEntry.js.map +1 -0
- package/operations/entry/PgOsUpdateEntry.d.ts +15 -0
- package/operations/entry/PgOsUpdateEntry.js +27 -0
- package/operations/entry/PgOsUpdateEntry.js.map +1 -0
- package/operations/entry/abstractions/EntrySearchOperations.d.ts +10 -0
- package/operations/entry/abstractions/EntrySearchOperations.js +5 -0
- package/operations/entry/abstractions/EntrySearchOperations.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/search/get.d.ts +3 -0
- package/operations/entry/search/get.js +14 -0
- package/operations/entry/search/get.js.map +1 -0
- package/operations/entry/search/getUniqueFieldValues.d.ts +3 -0
- package/operations/entry/search/getUniqueFieldValues.js +56 -0
- package/operations/entry/search/getUniqueFieldValues.js.map +1 -0
- package/operations/entry/search/list.d.ts +4 -0
- package/operations/entry/search/list.js +75 -0
- package/operations/entry/search/list.js.map +1 -0
- package/operations/entry/search/types.d.ts +23 -0
- package/operations/entry/search/types.js +0 -0
- package/package.json +73 -0
- package/testing/createReindexEvents.d.ts +3 -0
- package/testing/createReindexEvents.js +14 -0
- package/testing/createReindexEvents.js.map +1 -0
- package/testing/index.d.ts +2 -0
- package/testing/index.js +2 -0
- package/testing/simulatePgStream.d.ts +19 -0
- package/testing/simulatePgStream.js +52 -0
- package/testing/simulatePgStream.js.map +1 -0
- package/types.d.ts +17 -0
- package/types.js +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WritePublished } from "./abstractions/WritePublished.js";
|
|
2
|
+
import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
|
|
3
|
+
import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
|
|
4
|
+
class WritePublishedImpl {
|
|
5
|
+
constructor(buildSyncRecord, syncRowQuery){
|
|
6
|
+
this.buildSyncRecord = buildSyncRecord;
|
|
7
|
+
this.syncRowQuery = syncRowQuery;
|
|
8
|
+
}
|
|
9
|
+
async execute(params) {
|
|
10
|
+
const row = await this.buildSyncRecord.execute({
|
|
11
|
+
...params,
|
|
12
|
+
kind: "published"
|
|
13
|
+
});
|
|
14
|
+
await this.syncRowQuery.create().insert(row).onConflict([
|
|
15
|
+
"tenant",
|
|
16
|
+
"id"
|
|
17
|
+
]).merge();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const WritePublished_WritePublished = WritePublished.createImplementation({
|
|
21
|
+
implementation: WritePublishedImpl,
|
|
22
|
+
dependencies: [
|
|
23
|
+
BuildSyncRecord,
|
|
24
|
+
SyncRowQuery
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
export { WritePublished_WritePublished as WritePublished };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=WritePublished.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/WritePublished.js","sources":["../../../src/features/SyncWriter/WritePublished.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { WritePublished as Abstraction } from \"./abstractions/WritePublished.js\";\nimport { BuildSyncRecord } from \"./abstractions/BuildSyncRecord.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\n\nclass WritePublishedImpl implements Abstraction.Interface {\n public constructor(\n private readonly buildSyncRecord: BuildSyncRecord.Interface,\n private readonly syncRowQuery: SyncRowQuery.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>) {\n const row = await this.buildSyncRecord.execute({ ...params, kind: \"published\" });\n await this.syncRowQuery.create().insert(row).onConflict([\"tenant\", \"id\"]).merge();\n }\n}\n\nexport const WritePublished = Abstraction.createImplementation({\n implementation: WritePublishedImpl,\n dependencies: [BuildSyncRecord, SyncRowQuery]\n});\n"],"names":["WritePublishedImpl","buildSyncRecord","syncRowQuery","params","row","WritePublished","Abstraction","BuildSyncRecord","SyncRowQuery"],"mappings":";;;AAKA,MAAMA;IACF,YACqBC,eAA0C,EAC1CC,YAAoC,CACvD;aAFmBD,eAAe,GAAfA;aACAC,YAAY,GAAZA;IAClB;IAEH,MAAa,QAAmDC,MAA6B,EAAE;QAC3F,MAAMC,MAAM,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;YAAE,GAAGD,MAAM;YAAE,MAAM;QAAY;QAC9E,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,MAAM,CAACC,KAAK,UAAU,CAAC;YAAC;YAAU;SAAK,EAAE,KAAK;IACnF;AACJ;AAEO,MAAMC,gCAAiBC,eAAAA,oBAAgC,CAAC;IAC3D,gBAAgBN;IAChB,cAAc;QAACO;QAAiBC;KAAa;AACjD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { ISyncRow } from "../../../types.js";
|
|
3
|
+
export type RecordKind = "latest" | "published";
|
|
4
|
+
export interface IBuildSyncRecordParams<T extends CmsEntryValues = CmsEntryValues> {
|
|
5
|
+
model: StorageOperationsCmsModel<T>;
|
|
6
|
+
entry: CmsEntry<T>;
|
|
7
|
+
storageEntry: CmsStorageEntry<T>;
|
|
8
|
+
kind: RecordKind;
|
|
9
|
+
}
|
|
10
|
+
export interface IBuildSyncRecord {
|
|
11
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(params: IBuildSyncRecordParams<T>): Promise<ISyncRow>;
|
|
12
|
+
}
|
|
13
|
+
export declare const BuildSyncRecord: import("@webiny/di").Abstraction<IBuildSyncRecord>;
|
|
14
|
+
export declare namespace BuildSyncRecord {
|
|
15
|
+
type Interface = IBuildSyncRecord;
|
|
16
|
+
type Params<T extends CmsEntryValues = CmsEntryValues> = IBuildSyncRecordParams<T>;
|
|
17
|
+
type Kind = RecordKind;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/BuildSyncRecord.js","sources":["../../../../src/features/SyncWriter/abstractions/BuildSyncRecord.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { ISyncRow } from \"~/types.js\";\n\nexport type RecordKind = \"latest\" | \"published\";\n\nexport interface IBuildSyncRecordParams<T extends CmsEntryValues = CmsEntryValues> {\n model: StorageOperationsCmsModel<T>;\n entry: CmsEntry<T>;\n storageEntry: CmsStorageEntry<T>;\n kind: RecordKind;\n}\n\nexport interface IBuildSyncRecord {\n execute<T extends CmsEntryValues = CmsEntryValues>(\n params: IBuildSyncRecordParams<T>\n ): Promise<ISyncRow>;\n}\n\nexport const BuildSyncRecord = createAbstraction<IBuildSyncRecord>(\n \"Cms/Pg/Os/SyncWriter/BuildSyncRecord\"\n);\n\nexport namespace BuildSyncRecord {\n export type Interface = IBuildSyncRecord;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = IBuildSyncRecordParams<T>;\n export type Kind = RecordKind;\n}\n"],"names":["BuildSyncRecord","createAbstraction"],"mappings":";AAwBO,MAAMA,kBAAkBC,kBAC3B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IRemoveEntryParams {
|
|
3
|
+
model: Pick<StorageOperationsCmsModel, "tenant" | "modelId">;
|
|
4
|
+
entryId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IRemoveEntry {
|
|
7
|
+
execute(params: IRemoveEntryParams): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const RemoveEntry: import("@webiny/di").Abstraction<IRemoveEntry>;
|
|
10
|
+
export declare namespace RemoveEntry {
|
|
11
|
+
type Interface = IRemoveEntry;
|
|
12
|
+
type Params = IRemoveEntryParams;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/RemoveEntry.js","sources":["../../../../src/features/SyncWriter/abstractions/RemoveEntry.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IRemoveEntryParams {\n model: Pick<StorageOperationsCmsModel, \"tenant\" | \"modelId\">;\n entryId: string;\n}\n\nexport interface IRemoveEntry {\n execute(params: IRemoveEntryParams): Promise<void>;\n}\n\nexport const RemoveEntry = createAbstraction<IRemoveEntry>(\"Cms/Pg/Os/SyncWriter/RemoveEntry\");\n\nexport namespace RemoveEntry {\n export type Interface = IRemoveEntry;\n export type Params = IRemoveEntryParams;\n}\n"],"names":["RemoveEntry","createAbstraction"],"mappings":";AAYO,MAAMA,cAAcC,kBAAgC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IRemoveLatestParams {
|
|
3
|
+
model: Pick<StorageOperationsCmsModel, "tenant" | "modelId">;
|
|
4
|
+
entryId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IRemoveLatest {
|
|
7
|
+
execute(params: IRemoveLatestParams): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const RemoveLatest: import("@webiny/di").Abstraction<IRemoveLatest>;
|
|
10
|
+
export declare namespace RemoveLatest {
|
|
11
|
+
type Interface = IRemoveLatest;
|
|
12
|
+
type Params = IRemoveLatestParams;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/RemoveLatest.js","sources":["../../../../src/features/SyncWriter/abstractions/RemoveLatest.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IRemoveLatestParams {\n model: Pick<StorageOperationsCmsModel, \"tenant\" | \"modelId\">;\n entryId: string;\n}\n\nexport interface IRemoveLatest {\n execute(params: IRemoveLatestParams): Promise<void>;\n}\n\nexport const RemoveLatest = createAbstraction<IRemoveLatest>(\"Cms/Pg/Os/SyncWriter/RemoveLatest\");\n\nexport namespace RemoveLatest {\n export type Interface = IRemoveLatest;\n export type Params = IRemoveLatestParams;\n}\n"],"names":["RemoveLatest","createAbstraction"],"mappings":";AAYO,MAAMA,eAAeC,kBAAiC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IRemovePublishedParams {
|
|
3
|
+
model: Pick<StorageOperationsCmsModel, "tenant" | "modelId">;
|
|
4
|
+
entryId: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IRemovePublished {
|
|
7
|
+
execute(params: IRemovePublishedParams): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const RemovePublished: import("@webiny/di").Abstraction<IRemovePublished>;
|
|
10
|
+
export declare namespace RemovePublished {
|
|
11
|
+
type Interface = IRemovePublished;
|
|
12
|
+
type Params = IRemovePublishedParams;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/RemovePublished.js","sources":["../../../../src/features/SyncWriter/abstractions/RemovePublished.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IRemovePublishedParams {\n model: Pick<StorageOperationsCmsModel, \"tenant\" | \"modelId\">;\n entryId: string;\n}\n\nexport interface IRemovePublished {\n execute(params: IRemovePublishedParams): Promise<void>;\n}\n\nexport const RemovePublished = createAbstraction<IRemovePublished>(\n \"Cms/Pg/Os/SyncWriter/RemovePublished\"\n);\n\nexport namespace RemovePublished {\n export type Interface = IRemovePublished;\n export type Params = IRemovePublishedParams;\n}\n"],"names":["RemovePublished","createAbstraction"],"mappings":";AAYO,MAAMA,kBAAkBC,kBAC3B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsModel, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface ISyncHelpers {
|
|
3
|
+
ensureSyncTable(): Promise<void>;
|
|
4
|
+
writeSyncForEntry<T extends CmsEntryValues>(model: StorageOperationsCmsModel<T>, entry: CmsEntry<T>, storageEntry: CmsStorageEntry<T>): Promise<void>;
|
|
5
|
+
resyncLatestAndPublishedFromPg<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, model: StorageOperationsCmsModel<T>, id: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare const SyncHelpers: import("@webiny/di").Abstraction<ISyncHelpers>;
|
|
8
|
+
export declare namespace SyncHelpers {
|
|
9
|
+
type Interface = ISyncHelpers;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/SyncHelpers.js","sources":["../../../../src/features/SyncWriter/abstractions/SyncHelpers.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface ISyncHelpers {\n ensureSyncTable(): Promise<void>;\n writeSyncForEntry<T extends CmsEntryValues>(\n model: StorageOperationsCmsModel<T>,\n entry: CmsEntry<T>,\n storageEntry: CmsStorageEntry<T>\n ): Promise<void>;\n resyncLatestAndPublishedFromPg<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n model: StorageOperationsCmsModel<T>,\n id: string\n ): Promise<void>;\n}\n\nexport const SyncHelpers = createAbstraction<ISyncHelpers>(\"Cms/Pg/Os/SyncWriter/SyncHelpers\");\n\nexport namespace SyncHelpers {\n export type Interface = ISyncHelpers;\n}\n"],"names":["SyncHelpers","createAbstraction"],"mappings":";AAuBO,MAAMA,cAAcC,kBAAgC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Knex } from "knex";
|
|
2
|
+
import type { ISyncRow } from "../../../types.js";
|
|
3
|
+
export interface ISyncRowQuery {
|
|
4
|
+
create(): Knex.QueryBuilder<ISyncRow>;
|
|
5
|
+
}
|
|
6
|
+
export declare const SyncRowQuery: import("@webiny/di").Abstraction<ISyncRowQuery>;
|
|
7
|
+
export declare namespace SyncRowQuery {
|
|
8
|
+
type Interface = ISyncRowQuery;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/SyncRowQuery.js","sources":["../../../../src/features/SyncWriter/abstractions/SyncRowQuery.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Knex } from \"knex\";\nimport type { ISyncRow } from \"~/types.js\";\n\nexport interface ISyncRowQuery {\n create(): Knex.QueryBuilder<ISyncRow>;\n}\n\nexport const SyncRowQuery = createAbstraction<ISyncRowQuery>(\"Cms/Pg/Os/SyncWriter/SyncRowQuery\");\n\nexport namespace SyncRowQuery {\n export type Interface = ISyncRowQuery;\n}\n"],"names":["SyncRowQuery","createAbstraction"],"mappings":";AAQO,MAAMA,eAAeC,kBAAiC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IWriteEntryParams<T extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
model: StorageOperationsCmsModel<T>;
|
|
4
|
+
entry: CmsEntry<T>;
|
|
5
|
+
storageEntry: CmsStorageEntry<T>;
|
|
6
|
+
}
|
|
7
|
+
export interface IWriteEntry {
|
|
8
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(params: IWriteEntryParams<T>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const WriteEntry: import("@webiny/di").Abstraction<IWriteEntry>;
|
|
11
|
+
export declare namespace WriteEntry {
|
|
12
|
+
type Interface = IWriteEntry;
|
|
13
|
+
type Params<T extends CmsEntryValues = CmsEntryValues> = IWriteEntryParams<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/WriteEntry.js","sources":["../../../../src/features/SyncWriter/abstractions/WriteEntry.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IWriteEntryParams<T extends CmsEntryValues = CmsEntryValues> {\n model: StorageOperationsCmsModel<T>;\n entry: CmsEntry<T>;\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface IWriteEntry {\n execute<T extends CmsEntryValues = CmsEntryValues>(params: IWriteEntryParams<T>): Promise<void>;\n}\n\nexport const WriteEntry = createAbstraction<IWriteEntry>(\"Cms/Pg/Os/SyncWriter/WriteEntry\");\n\nexport namespace WriteEntry {\n export type Interface = IWriteEntry;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = IWriteEntryParams<T>;\n}\n"],"names":["WriteEntry","createAbstraction"],"mappings":";AAkBO,MAAMA,aAAaC,kBAA+B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IWriteLatestParams<T extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
model: StorageOperationsCmsModel<T>;
|
|
4
|
+
entry: CmsEntry<T>;
|
|
5
|
+
storageEntry: CmsStorageEntry<T>;
|
|
6
|
+
}
|
|
7
|
+
export interface IWriteLatest {
|
|
8
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(params: IWriteLatestParams<T>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const WriteLatest: import("@webiny/di").Abstraction<IWriteLatest>;
|
|
11
|
+
export declare namespace WriteLatest {
|
|
12
|
+
type Interface = IWriteLatest;
|
|
13
|
+
type Params<T extends CmsEntryValues = CmsEntryValues> = IWriteLatestParams<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/WriteLatest.js","sources":["../../../../src/features/SyncWriter/abstractions/WriteLatest.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IWriteLatestParams<T extends CmsEntryValues = CmsEntryValues> {\n model: StorageOperationsCmsModel<T>;\n entry: CmsEntry<T>;\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface IWriteLatest {\n execute<T extends CmsEntryValues = CmsEntryValues>(\n params: IWriteLatestParams<T>\n ): Promise<void>;\n}\n\nexport const WriteLatest = createAbstraction<IWriteLatest>(\"Cms/Pg/Os/SyncWriter/WriteLatest\");\n\nexport namespace WriteLatest {\n export type Interface = IWriteLatest;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = IWriteLatestParams<T>;\n}\n"],"names":["WriteLatest","createAbstraction"],"mappings":";AAoBO,MAAMA,cAAcC,kBAAgC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
export interface IWritePublishedParams<T extends CmsEntryValues = CmsEntryValues> {
|
|
3
|
+
model: StorageOperationsCmsModel<T>;
|
|
4
|
+
entry: CmsEntry<T>;
|
|
5
|
+
storageEntry: CmsStorageEntry<T>;
|
|
6
|
+
}
|
|
7
|
+
export interface IWritePublished {
|
|
8
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(params: IWritePublishedParams<T>): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const WritePublished: import("@webiny/di").Abstraction<IWritePublished>;
|
|
11
|
+
export declare namespace WritePublished {
|
|
12
|
+
type Interface = IWritePublished;
|
|
13
|
+
type Params<T extends CmsEntryValues = CmsEntryValues> = IWritePublishedParams<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/abstractions/WritePublished.js","sources":["../../../../src/features/SyncWriter/abstractions/WritePublished.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface IWritePublishedParams<T extends CmsEntryValues = CmsEntryValues> {\n model: StorageOperationsCmsModel<T>;\n entry: CmsEntry<T>;\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport interface IWritePublished {\n execute<T extends CmsEntryValues = CmsEntryValues>(\n params: IWritePublishedParams<T>\n ): Promise<void>;\n}\n\nexport const WritePublished = createAbstraction<IWritePublished>(\n \"Cms/Pg/Os/SyncWriter/WritePublished\"\n);\n\nexport namespace WritePublished {\n export type Interface = IWritePublished;\n export type Params<T extends CmsEntryValues = CmsEntryValues> = IWritePublishedParams<T>;\n}\n"],"names":["WritePublished","createAbstraction"],"mappings":";AAoBO,MAAMA,iBAAiBC,kBAC1B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { BuildSyncRecord } from "./BuildSyncRecord.js";
|
|
3
|
+
import { WriteEntry } from "./WriteEntry.js";
|
|
4
|
+
import { WriteLatest } from "./WriteLatest.js";
|
|
5
|
+
import { WritePublished } from "./WritePublished.js";
|
|
6
|
+
import { RemoveEntry } from "./RemoveEntry.js";
|
|
7
|
+
import { RemoveLatest } from "./RemoveLatest.js";
|
|
8
|
+
import { RemovePublished } from "./RemovePublished.js";
|
|
9
|
+
import { SyncRowQuery } from "./SyncRowQuery.js";
|
|
10
|
+
import { SyncHelpers } from "./SyncHelpers.js";
|
|
11
|
+
const SyncWriterFeature = createFeature({
|
|
12
|
+
name: "Cms/Pg/Os/SyncWriter",
|
|
13
|
+
register (container) {
|
|
14
|
+
container.register(SyncRowQuery);
|
|
15
|
+
container.register(BuildSyncRecord);
|
|
16
|
+
container.register(WriteEntry);
|
|
17
|
+
container.register(WriteLatest);
|
|
18
|
+
container.register(WritePublished);
|
|
19
|
+
container.register(RemoveEntry);
|
|
20
|
+
container.register(RemoveLatest);
|
|
21
|
+
container.register(RemovePublished);
|
|
22
|
+
container.register(SyncHelpers);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export { SyncWriterFeature };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/SyncWriter/feature.js","sources":["../../../src/features/SyncWriter/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { BuildSyncRecord } from \"./BuildSyncRecord.js\";\nimport { WriteEntry } from \"./WriteEntry.js\";\nimport { WriteLatest } from \"./WriteLatest.js\";\nimport { WritePublished } from \"./WritePublished.js\";\nimport { RemoveEntry } from \"./RemoveEntry.js\";\nimport { RemoveLatest } from \"./RemoveLatest.js\";\nimport { RemovePublished } from \"./RemovePublished.js\";\nimport { SyncRowQuery } from \"./SyncRowQuery.js\";\nimport { SyncHelpers } from \"./SyncHelpers.js\";\n\nexport const SyncWriterFeature = createFeature({\n name: \"Cms/Pg/Os/SyncWriter\",\n register(container) {\n container.register(SyncRowQuery);\n container.register(BuildSyncRecord);\n container.register(WriteEntry);\n container.register(WriteLatest);\n container.register(WritePublished);\n container.register(RemoveEntry);\n container.register(RemoveLatest);\n container.register(RemovePublished);\n container.register(SyncHelpers);\n }\n});\n"],"names":["SyncWriterFeature","createFeature","container","SyncRowQuery","BuildSyncRecord","WriteEntry","WriteLatest","WritePublished","RemoveEntry","RemoveLatest","RemovePublished","SyncHelpers"],"mappings":";;;;;;;;;;AAWO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;IACvB;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
|
|
2
|
+
export { WriteEntry } from "./abstractions/WriteEntry.js";
|
|
3
|
+
export { WriteLatest } from "./abstractions/WriteLatest.js";
|
|
4
|
+
export { WritePublished } from "./abstractions/WritePublished.js";
|
|
5
|
+
export { RemoveEntry } from "./abstractions/RemoveEntry.js";
|
|
6
|
+
export { RemoveLatest } from "./abstractions/RemoveLatest.js";
|
|
7
|
+
export { RemovePublished } from "./abstractions/RemovePublished.js";
|
|
8
|
+
export { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
|
|
9
|
+
export { SyncHelpers } from "./abstractions/SyncHelpers.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
|
|
2
|
+
export { WriteEntry } from "./abstractions/WriteEntry.js";
|
|
3
|
+
export { WriteLatest } from "./abstractions/WriteLatest.js";
|
|
4
|
+
export { WritePublished } from "./abstractions/WritePublished.js";
|
|
5
|
+
export { RemoveEntry } from "./abstractions/RemoveEntry.js";
|
|
6
|
+
export { RemoveLatest } from "./abstractions/RemoveLatest.js";
|
|
7
|
+
export { RemovePublished } from "./abstractions/RemovePublished.js";
|
|
8
|
+
export { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
|
|
9
|
+
export { SyncHelpers } from "./abstractions/SyncHelpers.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SyncEventHandler as SyncEventHandlerAbstraction } from "./abstractions.js";
|
|
2
|
+
import { SynchronizationBuilder } from "@webiny/api-sync-to-opensearch";
|
|
3
|
+
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
4
|
+
import type { SyncEvent } from "../../types.js";
|
|
5
|
+
declare class SyncEventHandlerImpl implements SyncEventHandlerAbstraction.Interface {
|
|
6
|
+
private readonly synchronizationBuilder;
|
|
7
|
+
private readonly compressionHandler;
|
|
8
|
+
constructor(synchronizationBuilder: SynchronizationBuilder.Interface, compressionHandler: CompressionHandler.Interface);
|
|
9
|
+
process(events: SyncEvent[], options?: SyncEventHandlerAbstraction.ProcessOptions): Promise<void>;
|
|
10
|
+
private processBatch;
|
|
11
|
+
}
|
|
12
|
+
export declare const SyncEventHandler: typeof SyncEventHandlerImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISyncEventHandler>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SyncEventHandler } from "./abstractions.js";
|
|
2
|
+
import { SynchronizationBuilder } from "@webiny/api-sync-to-opensearch";
|
|
3
|
+
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
4
|
+
const DEFAULT_BATCH_SIZE = 50;
|
|
5
|
+
class SyncEventHandlerImpl {
|
|
6
|
+
constructor(synchronizationBuilder, compressionHandler){
|
|
7
|
+
this.synchronizationBuilder = synchronizationBuilder;
|
|
8
|
+
this.compressionHandler = compressionHandler;
|
|
9
|
+
}
|
|
10
|
+
async process(events, options) {
|
|
11
|
+
if (0 === events.length) return;
|
|
12
|
+
const batchSize = options?.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
13
|
+
for(let i = 0; i < events.length; i += batchSize){
|
|
14
|
+
const batch = events.slice(i, i + batchSize);
|
|
15
|
+
await this.processBatch(batch);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async processBatch(events) {
|
|
19
|
+
for (const event of events){
|
|
20
|
+
if ("REMOVE" === event.type) {
|
|
21
|
+
this.synchronizationBuilder.delete({
|
|
22
|
+
id: event.id,
|
|
23
|
+
index: event.index
|
|
24
|
+
});
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!event.data) continue;
|
|
28
|
+
const parsed = JSON.parse(event.data);
|
|
29
|
+
const decompressed = await this.compressionHandler.decompress(parsed);
|
|
30
|
+
this.synchronizationBuilder.insert({
|
|
31
|
+
id: event.id,
|
|
32
|
+
index: event.index,
|
|
33
|
+
data: decompressed
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const flush = this.synchronizationBuilder.build();
|
|
37
|
+
await flush();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const SyncEventHandler_SyncEventHandler = SyncEventHandler.createImplementation({
|
|
41
|
+
implementation: SyncEventHandlerImpl,
|
|
42
|
+
dependencies: [
|
|
43
|
+
SynchronizationBuilder,
|
|
44
|
+
CompressionHandler
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
export { SyncEventHandler_SyncEventHandler as SyncEventHandler };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=SyncEventHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncEventHandler/SyncEventHandler.js","sources":["../../../src/features/syncEventHandler/SyncEventHandler.ts"],"sourcesContent":["import { SyncEventHandler as SyncEventHandlerAbstraction } from \"./abstractions.js\";\nimport { SynchronizationBuilder } from \"@webiny/api-sync-to-opensearch\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { SyncEvent } from \"~/types.js\";\n\nconst DEFAULT_BATCH_SIZE = 50;\n\nclass SyncEventHandlerImpl implements SyncEventHandlerAbstraction.Interface {\n public constructor(\n private readonly synchronizationBuilder: SynchronizationBuilder.Interface,\n private readonly compressionHandler: CompressionHandler.Interface\n ) {}\n\n public async process(\n events: SyncEvent[],\n options?: SyncEventHandlerAbstraction.ProcessOptions\n ): Promise<void> {\n if (events.length === 0) {\n return;\n }\n\n const batchSize = options?.batchSize ?? DEFAULT_BATCH_SIZE;\n\n for (let i = 0; i < events.length; i += batchSize) {\n const batch = events.slice(i, i + batchSize);\n await this.processBatch(batch);\n }\n }\n\n private async processBatch(events: SyncEvent[]): Promise<void> {\n for (const event of events) {\n if (event.type === \"REMOVE\") {\n this.synchronizationBuilder.delete({\n id: event.id,\n index: event.index\n });\n continue;\n }\n\n if (!event.data) {\n continue;\n }\n\n const parsed = JSON.parse(event.data);\n const decompressed = await this.compressionHandler.decompress<GenericRecord>(parsed);\n\n this.synchronizationBuilder.insert({\n id: event.id,\n index: event.index,\n data: decompressed\n });\n }\n\n const flush = this.synchronizationBuilder.build();\n await flush();\n }\n}\n\nexport const SyncEventHandler = SyncEventHandlerAbstraction.createImplementation({\n implementation: SyncEventHandlerImpl,\n dependencies: [SynchronizationBuilder, CompressionHandler]\n});\n"],"names":["DEFAULT_BATCH_SIZE","SyncEventHandlerImpl","synchronizationBuilder","compressionHandler","events","options","batchSize","i","batch","event","parsed","JSON","decompressed","flush","SyncEventHandler","SyncEventHandlerAbstraction","SynchronizationBuilder","CompressionHandler"],"mappings":";;;AAMA,MAAMA,qBAAqB;AAE3B,MAAMC;IACF,YACqBC,sBAAwD,EACxDC,kBAAgD,CACnE;aAFmBD,sBAAsB,GAAtBA;aACAC,kBAAkB,GAAlBA;IAClB;IAEH,MAAa,QACTC,MAAmB,EACnBC,OAAoD,EACvC;QACb,IAAID,AAAkB,MAAlBA,OAAO,MAAM,EACb;QAGJ,MAAME,YAAYD,SAAS,aAAaL;QAExC,IAAK,IAAIO,IAAI,GAAGA,IAAIH,OAAO,MAAM,EAAEG,KAAKD,UAAW;YAC/C,MAAME,QAAQJ,OAAO,KAAK,CAACG,GAAGA,IAAID;YAClC,MAAM,IAAI,CAAC,YAAY,CAACE;QAC5B;IACJ;IAEA,MAAc,aAAaJ,MAAmB,EAAiB;QAC3D,KAAK,MAAMK,SAASL,OAAQ;YACxB,IAAIK,AAAe,aAAfA,MAAM,IAAI,EAAe;gBACzB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC;oBAC/B,IAAIA,MAAM,EAAE;oBACZ,OAAOA,MAAM,KAAK;gBACtB;gBACA;YACJ;YAEA,IAAI,CAACA,MAAM,IAAI,EACX;YAGJ,MAAMC,SAASC,KAAK,KAAK,CAACF,MAAM,IAAI;YACpC,MAAMG,eAAe,MAAM,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAgBF;YAE7E,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC;gBAC/B,IAAID,MAAM,EAAE;gBACZ,OAAOA,MAAM,KAAK;gBAClB,MAAMG;YACV;QACJ;QAEA,MAAMC,QAAQ,IAAI,CAAC,sBAAsB,CAAC,KAAK;QAC/C,MAAMA;IACV;AACJ;AAEO,MAAMC,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBd;IAChB,cAAc;QAACe;QAAwBC;KAAmB;AAC9D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyncEvent } from "../../types.js";
|
|
2
|
+
export interface ISyncEventHandlerProcessOptions {
|
|
3
|
+
batchSize?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ISyncEventHandler {
|
|
6
|
+
process(events: SyncEvent[], options?: ISyncEventHandlerProcessOptions): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const SyncEventHandler: import("@webiny/di").Abstraction<ISyncEventHandler>;
|
|
9
|
+
export declare namespace SyncEventHandler {
|
|
10
|
+
type Interface = ISyncEventHandler;
|
|
11
|
+
type ProcessOptions = ISyncEventHandlerProcessOptions;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncEventHandler/abstractions.js","sources":["../../../src/features/syncEventHandler/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api/index.js\";\nimport type { SyncEvent } from \"~/types.js\";\n\nexport interface ISyncEventHandlerProcessOptions {\n batchSize?: number;\n}\n\nexport interface ISyncEventHandler {\n process(events: SyncEvent[], options?: ISyncEventHandlerProcessOptions): Promise<void>;\n}\n\nexport const SyncEventHandler = createAbstraction<ISyncEventHandler>(\"Cms/PgOs/SyncEventHandler\");\n\nexport namespace SyncEventHandler {\n export type Interface = ISyncEventHandler;\n export type ProcessOptions = ISyncEventHandlerProcessOptions;\n}\n"],"names":["SyncEventHandler","createAbstraction"],"mappings":";AAWO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SyncEventHandler } from "./SyncEventHandler.js";
|
|
3
|
+
const SyncEventHandlerFeature = createFeature({
|
|
4
|
+
name: "cms.pgOs.syncEventHandler",
|
|
5
|
+
register: (container)=>{
|
|
6
|
+
container.register(SyncEventHandler);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SyncEventHandlerFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncEventHandler/feature.js","sources":["../../../src/features/syncEventHandler/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SyncEventHandler } from \"./SyncEventHandler.js\";\n\nexport const SyncEventHandlerFeature = createFeature({\n name: \"cms.pgOs.syncEventHandler\",\n register: container => {\n container.register(SyncEventHandler);\n }\n});\n"],"names":["SyncEventHandlerFeature","createFeature","container","SyncEventHandler"],"mappings":";;AAGO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
2
|
+
import { SyncTableManager as SyncTableManagerAbstraction } from "./abstractions.js";
|
|
3
|
+
import { TableNameResolver } from "@webiny/api-headless-cms-sql/features/tableNameResolver/abstractions.js";
|
|
4
|
+
declare class SyncTableManagerImpl implements SyncTableManagerAbstraction.Interface {
|
|
5
|
+
private readonly knex;
|
|
6
|
+
private readonly tableName;
|
|
7
|
+
private initialized;
|
|
8
|
+
private initPromise?;
|
|
9
|
+
constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface);
|
|
10
|
+
reset(): void;
|
|
11
|
+
ensureTable(): Promise<void>;
|
|
12
|
+
getTableName(): string;
|
|
13
|
+
private doEnsureTable;
|
|
14
|
+
private createTable;
|
|
15
|
+
}
|
|
16
|
+
export declare const SyncTableManager: typeof SyncTableManagerImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").ISyncTableManager>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { KnexClient } from "@webiny/api-core-sql";
|
|
2
|
+
import { SyncTableManager } from "./abstractions.js";
|
|
3
|
+
import { TableNameResolver } from "@webiny/api-headless-cms-sql/features/tableNameResolver/abstractions.js";
|
|
4
|
+
class SyncTableManagerImpl {
|
|
5
|
+
constructor(knex, tableNameResolver){
|
|
6
|
+
this.initialized = false;
|
|
7
|
+
this.knex = knex;
|
|
8
|
+
this.tableName = tableNameResolver.resolve("os_sync");
|
|
9
|
+
const g = globalThis;
|
|
10
|
+
const managers = g.__sqlTableManagers ??= [];
|
|
11
|
+
managers.push(this);
|
|
12
|
+
}
|
|
13
|
+
reset() {
|
|
14
|
+
this.initialized = false;
|
|
15
|
+
this.initPromise = void 0;
|
|
16
|
+
}
|
|
17
|
+
async ensureTable() {
|
|
18
|
+
if (this.initialized) return;
|
|
19
|
+
if (!this.initPromise) this.initPromise = this.doEnsureTable().catch((err)=>{
|
|
20
|
+
this.initPromise = void 0;
|
|
21
|
+
throw err;
|
|
22
|
+
});
|
|
23
|
+
return this.initPromise;
|
|
24
|
+
}
|
|
25
|
+
getTableName() {
|
|
26
|
+
return this.tableName;
|
|
27
|
+
}
|
|
28
|
+
async doEnsureTable() {
|
|
29
|
+
const exists = await this.knex.client.schema.hasTable(this.tableName);
|
|
30
|
+
if (!exists) await this.createTable();
|
|
31
|
+
this.initialized = true;
|
|
32
|
+
}
|
|
33
|
+
async createTable() {
|
|
34
|
+
try {
|
|
35
|
+
await this.knex.client.schema.createTable(this.tableName, (table)=>{
|
|
36
|
+
table.text("id").notNullable();
|
|
37
|
+
table.text("entryId").notNullable();
|
|
38
|
+
table.text("index").notNullable();
|
|
39
|
+
table.text("operation").notNullable();
|
|
40
|
+
table.text("data").notNullable();
|
|
41
|
+
table.text("tenant").notNullable();
|
|
42
|
+
table.primary([
|
|
43
|
+
"tenant",
|
|
44
|
+
"id"
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (await this.knex.client.schema.hasTable(this.tableName)) return;
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const SyncTableManager_SyncTableManager = SyncTableManager.createImplementation({
|
|
54
|
+
implementation: SyncTableManagerImpl,
|
|
55
|
+
dependencies: [
|
|
56
|
+
KnexClient,
|
|
57
|
+
TableNameResolver
|
|
58
|
+
]
|
|
59
|
+
});
|
|
60
|
+
export { SyncTableManager_SyncTableManager as SyncTableManager };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=SyncTableManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncTableManager/SyncTableManager.js","sources":["../../../src/features/syncTableManager/SyncTableManager.ts"],"sourcesContent":["import { KnexClient } from \"@webiny/api-core-sql\";\nimport { SyncTableManager as SyncTableManagerAbstraction } from \"./abstractions.js\";\nimport { TableNameResolver } from \"@webiny/api-headless-cms-sql/features/tableNameResolver/abstractions.js\";\n\nclass SyncTableManagerImpl implements SyncTableManagerAbstraction.Interface {\n private readonly knex;\n private readonly tableName;\n private initialized = false;\n private initPromise?: Promise<void>;\n\n constructor(knex: KnexClient.Interface, tableNameResolver: TableNameResolver.Interface) {\n this.knex = knex;\n this.tableName = tableNameResolver.resolve(\"os_sync\");\n\n const g = globalThis as Record<string, unknown>;\n const managers = (g.__sqlTableManagers ??= []) as SyncTableManagerAbstraction.Interface[];\n managers.push(this);\n }\n\n public reset(): void {\n this.initialized = false;\n this.initPromise = undefined;\n }\n\n public async ensureTable(): Promise<void> {\n if (this.initialized) {\n return;\n }\n if (!this.initPromise) {\n this.initPromise = this.doEnsureTable().catch(err => {\n this.initPromise = undefined;\n throw err;\n });\n }\n return this.initPromise;\n }\n\n public getTableName(): string {\n return this.tableName;\n }\n\n private async doEnsureTable(): Promise<void> {\n const exists = await this.knex.client.schema.hasTable(this.tableName);\n\n if (!exists) {\n await this.createTable();\n }\n\n this.initialized = true;\n }\n\n private async createTable(): Promise<void> {\n try {\n await this.knex.client.schema.createTable(this.tableName, table => {\n table.text(\"id\").notNullable();\n table.text(\"entryId\").notNullable();\n table.text(\"index\").notNullable();\n table.text(\"operation\").notNullable();\n table.text(\"data\").notNullable();\n table.text(\"tenant\").notNullable();\n\n table.primary([\"tenant\", \"id\"]);\n });\n } catch (err) {\n if (await this.knex.client.schema.hasTable(this.tableName)) {\n return;\n }\n throw err;\n }\n }\n}\n\nexport const SyncTableManager = SyncTableManagerAbstraction.createImplementation({\n implementation: SyncTableManagerImpl,\n dependencies: [KnexClient, TableNameResolver]\n});\n"],"names":["SyncTableManagerImpl","knex","tableNameResolver","g","globalThis","managers","undefined","err","exists","table","SyncTableManager","SyncTableManagerAbstraction","KnexClient","TableNameResolver"],"mappings":";;;AAIA,MAAMA;IAMF,YAAYC,IAA0B,EAAEC,iBAA8C,CAAE;aAHhF,WAAW,GAAG;QAIlB,IAAI,CAAC,IAAI,GAAGD;QACZ,IAAI,CAAC,SAAS,GAAGC,kBAAkB,OAAO,CAAC;QAE3C,MAAMC,IAAIC;QACV,MAAMC,WAAYF,EAAE,kBAAkB,KAAK,EAAE;QAC7CE,SAAS,IAAI,CAAC,IAAI;IACtB;IAEO,QAAc;QACjB,IAAI,CAAC,WAAW,GAAG;QACnB,IAAI,CAAC,WAAW,GAAGC;IACvB;IAEA,MAAa,cAA6B;QACtC,IAAI,IAAI,CAAC,WAAW,EAChB;QAEJ,IAAI,CAAC,IAAI,CAAC,WAAW,EACjB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,GAAG,KAAK,CAACC,CAAAA;YAC1C,IAAI,CAAC,WAAW,GAAGD;YACnB,MAAMC;QACV;QAEJ,OAAO,IAAI,CAAC,WAAW;IAC3B;IAEO,eAAuB;QAC1B,OAAO,IAAI,CAAC,SAAS;IACzB;IAEA,MAAc,gBAA+B;QACzC,MAAMC,SAAS,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS;QAEpE,IAAI,CAACA,QACD,MAAM,IAAI,CAAC,WAAW;QAG1B,IAAI,CAAC,WAAW,GAAG;IACvB;IAEA,MAAc,cAA6B;QACvC,IAAI;YACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAEC,CAAAA;gBACtDA,MAAM,IAAI,CAAC,MAAM,WAAW;gBAC5BA,MAAM,IAAI,CAAC,WAAW,WAAW;gBACjCA,MAAM,IAAI,CAAC,SAAS,WAAW;gBAC/BA,MAAM,IAAI,CAAC,aAAa,WAAW;gBACnCA,MAAM,IAAI,CAAC,QAAQ,WAAW;gBAC9BA,MAAM,IAAI,CAAC,UAAU,WAAW;gBAEhCA,MAAM,OAAO,CAAC;oBAAC;oBAAU;iBAAK;YAClC;QACJ,EAAE,OAAOF,KAAK;YACV,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,GACrD;YAEJ,MAAMA;QACV;IACJ;AACJ;AAEO,MAAMG,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAACY;QAAYC;KAAkB;AACjD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ISyncTableManager {
|
|
2
|
+
ensureTable(): Promise<void>;
|
|
3
|
+
getTableName(): string;
|
|
4
|
+
reset(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const SyncTableManager: import("@webiny/di").Abstraction<ISyncTableManager>;
|
|
7
|
+
export declare namespace SyncTableManager {
|
|
8
|
+
type Interface = ISyncTableManager;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncTableManager/abstractions.js","sources":["../../../src/features/syncTableManager/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api/index.js\";\n\nexport interface ISyncTableManager {\n ensureTable(): Promise<void>;\n getTableName(): string;\n reset(): void;\n}\n\nexport const SyncTableManager = createAbstraction<ISyncTableManager>(\"Cms/PgOs/SyncTableManager\");\n\nexport namespace SyncTableManager {\n export type Interface = ISyncTableManager;\n}\n"],"names":["SyncTableManager","createAbstraction"],"mappings":";AAQO,MAAMA,mBAAmBC,kBAAqC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { SyncTableManager } from "./SyncTableManager.js";
|
|
3
|
+
const SyncTableManagerFeature = createFeature({
|
|
4
|
+
name: "cms.pgOs.syncTableManager",
|
|
5
|
+
register: (container)=>{
|
|
6
|
+
container.register(SyncTableManager).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { SyncTableManagerFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/syncTableManager/feature.js","sources":["../../../src/features/syncTableManager/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { SyncTableManager } from \"./SyncTableManager.js\";\n\nexport const SyncTableManagerFeature = createFeature({\n name: \"cms.pgOs.syncTableManager\",\n register: container => {\n container.register(SyncTableManager).inSingletonScope();\n }\n});\n"],"names":["SyncTableManagerFeature","createFeature","container","SyncTableManager"],"mappings":";;AAGO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC,kBAAkB,gBAAgB;IACzD;AACJ"}
|