@webiny/api-headless-cms-pg-os 6.6.0-alpha.0

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.
Files changed (157) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/features/HeadlessCmsPgOsFeature.d.ts +9 -0
  4. package/features/HeadlessCmsPgOsFeature.js +40 -0
  5. package/features/HeadlessCmsPgOsFeature.js.map +1 -0
  6. package/features/SyncWriter/BuildSyncRecord.d.ts +22 -0
  7. package/features/SyncWriter/BuildSyncRecord.js +56 -0
  8. package/features/SyncWriter/BuildSyncRecord.js.map +1 -0
  9. package/features/SyncWriter/RemoveEntry.d.ts +11 -0
  10. package/features/SyncWriter/RemoveEntry.js +23 -0
  11. package/features/SyncWriter/RemoveEntry.js.map +1 -0
  12. package/features/SyncWriter/RemoveLatest.d.ts +11 -0
  13. package/features/SyncWriter/RemoveLatest.js +19 -0
  14. package/features/SyncWriter/RemoveLatest.js.map +1 -0
  15. package/features/SyncWriter/RemovePublished.d.ts +11 -0
  16. package/features/SyncWriter/RemovePublished.js +19 -0
  17. package/features/SyncWriter/RemovePublished.js.map +1 -0
  18. package/features/SyncWriter/SyncHelpers.d.ts +26 -0
  19. package/features/SyncWriter/SyncHelpers.js +70 -0
  20. package/features/SyncWriter/SyncHelpers.js.map +1 -0
  21. package/features/SyncWriter/SyncRowQuery.d.ts +22 -0
  22. package/features/SyncWriter/SyncRowQuery.js +22 -0
  23. package/features/SyncWriter/SyncRowQuery.js.map +1 -0
  24. package/features/SyncWriter/WriteEntry.d.ts +14 -0
  25. package/features/SyncWriter/WriteEntry.js +32 -0
  26. package/features/SyncWriter/WriteEntry.js.map +1 -0
  27. package/features/SyncWriter/WriteLatest.d.ts +14 -0
  28. package/features/SyncWriter/WriteLatest.js +26 -0
  29. package/features/SyncWriter/WriteLatest.js.map +1 -0
  30. package/features/SyncWriter/WritePublished.d.ts +14 -0
  31. package/features/SyncWriter/WritePublished.js +26 -0
  32. package/features/SyncWriter/WritePublished.js.map +1 -0
  33. package/features/SyncWriter/abstractions/BuildSyncRecord.d.ts +18 -0
  34. package/features/SyncWriter/abstractions/BuildSyncRecord.js +5 -0
  35. package/features/SyncWriter/abstractions/BuildSyncRecord.js.map +1 -0
  36. package/features/SyncWriter/abstractions/RemoveEntry.d.ts +13 -0
  37. package/features/SyncWriter/abstractions/RemoveEntry.js +5 -0
  38. package/features/SyncWriter/abstractions/RemoveEntry.js.map +1 -0
  39. package/features/SyncWriter/abstractions/RemoveLatest.d.ts +13 -0
  40. package/features/SyncWriter/abstractions/RemoveLatest.js +5 -0
  41. package/features/SyncWriter/abstractions/RemoveLatest.js.map +1 -0
  42. package/features/SyncWriter/abstractions/RemovePublished.d.ts +13 -0
  43. package/features/SyncWriter/abstractions/RemovePublished.js +5 -0
  44. package/features/SyncWriter/abstractions/RemovePublished.js.map +1 -0
  45. package/features/SyncWriter/abstractions/SyncHelpers.d.ts +10 -0
  46. package/features/SyncWriter/abstractions/SyncHelpers.js +5 -0
  47. package/features/SyncWriter/abstractions/SyncHelpers.js.map +1 -0
  48. package/features/SyncWriter/abstractions/SyncRowQuery.d.ts +9 -0
  49. package/features/SyncWriter/abstractions/SyncRowQuery.js +5 -0
  50. package/features/SyncWriter/abstractions/SyncRowQuery.js.map +1 -0
  51. package/features/SyncWriter/abstractions/WriteEntry.d.ts +14 -0
  52. package/features/SyncWriter/abstractions/WriteEntry.js +5 -0
  53. package/features/SyncWriter/abstractions/WriteEntry.js.map +1 -0
  54. package/features/SyncWriter/abstractions/WriteLatest.d.ts +14 -0
  55. package/features/SyncWriter/abstractions/WriteLatest.js +5 -0
  56. package/features/SyncWriter/abstractions/WriteLatest.js.map +1 -0
  57. package/features/SyncWriter/abstractions/WritePublished.d.ts +14 -0
  58. package/features/SyncWriter/abstractions/WritePublished.js +5 -0
  59. package/features/SyncWriter/abstractions/WritePublished.js.map +1 -0
  60. package/features/SyncWriter/feature.d.ts +4 -0
  61. package/features/SyncWriter/feature.js +27 -0
  62. package/features/SyncWriter/feature.js.map +1 -0
  63. package/features/SyncWriter/index.d.ts +9 -0
  64. package/features/SyncWriter/index.js +9 -0
  65. package/features/syncEventHandler/SyncEventHandler.d.ts +15 -0
  66. package/features/syncEventHandler/SyncEventHandler.js +49 -0
  67. package/features/syncEventHandler/SyncEventHandler.js.map +1 -0
  68. package/features/syncEventHandler/abstractions.d.ts +12 -0
  69. package/features/syncEventHandler/abstractions.js +5 -0
  70. package/features/syncEventHandler/abstractions.js.map +1 -0
  71. package/features/syncEventHandler/feature.d.ts +4 -0
  72. package/features/syncEventHandler/feature.js +11 -0
  73. package/features/syncEventHandler/feature.js.map +1 -0
  74. package/features/syncTableManager/SyncTableManager.d.ts +19 -0
  75. package/features/syncTableManager/SyncTableManager.js +61 -0
  76. package/features/syncTableManager/SyncTableManager.js.map +1 -0
  77. package/features/syncTableManager/abstractions.d.ts +9 -0
  78. package/features/syncTableManager/abstractions.js +5 -0
  79. package/features/syncTableManager/abstractions.js.map +1 -0
  80. package/features/syncTableManager/feature.d.ts +4 -0
  81. package/features/syncTableManager/feature.js +11 -0
  82. package/features/syncTableManager/feature.js.map +1 -0
  83. package/index.d.ts +1 -0
  84. package/index.js +1 -0
  85. package/operations/entry/EntrySearchOperations.d.ts +15 -0
  86. package/operations/entry/EntrySearchOperations.js +35 -0
  87. package/operations/entry/EntrySearchOperations.js.map +1 -0
  88. package/operations/entry/PgOsCreateEntry.d.ts +15 -0
  89. package/operations/entry/PgOsCreateEntry.js +27 -0
  90. package/operations/entry/PgOsCreateEntry.js.map +1 -0
  91. package/operations/entry/PgOsCreateEntryRevisionFrom.d.ts +15 -0
  92. package/operations/entry/PgOsCreateEntryRevisionFrom.js +27 -0
  93. package/operations/entry/PgOsCreateEntryRevisionFrom.js.map +1 -0
  94. package/operations/entry/PgOsDeleteEntry.d.ts +17 -0
  95. package/operations/entry/PgOsDeleteEntry.js +33 -0
  96. package/operations/entry/PgOsDeleteEntry.js.map +1 -0
  97. package/operations/entry/PgOsDeleteEntryRevision.d.ts +21 -0
  98. package/operations/entry/PgOsDeleteEntryRevision.js +48 -0
  99. package/operations/entry/PgOsDeleteEntryRevision.js.map +1 -0
  100. package/operations/entry/PgOsDeleteMultipleEntries.d.ts +17 -0
  101. package/operations/entry/PgOsDeleteMultipleEntries.js +36 -0
  102. package/operations/entry/PgOsDeleteMultipleEntries.js.map +1 -0
  103. package/operations/entry/PgOsGetEntry.d.ts +12 -0
  104. package/operations/entry/PgOsGetEntry.js +19 -0
  105. package/operations/entry/PgOsGetEntry.js.map +1 -0
  106. package/operations/entry/PgOsGetUniqueFieldValues.d.ts +12 -0
  107. package/operations/entry/PgOsGetUniqueFieldValues.js +19 -0
  108. package/operations/entry/PgOsGetUniqueFieldValues.js.map +1 -0
  109. package/operations/entry/PgOsListEntries.d.ts +12 -0
  110. package/operations/entry/PgOsListEntries.js +19 -0
  111. package/operations/entry/PgOsListEntries.js.map +1 -0
  112. package/operations/entry/PgOsMoveEntry.d.ts +15 -0
  113. package/operations/entry/PgOsMoveEntry.js +26 -0
  114. package/operations/entry/PgOsMoveEntry.js.map +1 -0
  115. package/operations/entry/PgOsMoveToBin.d.ts +15 -0
  116. package/operations/entry/PgOsMoveToBin.js +26 -0
  117. package/operations/entry/PgOsMoveToBin.js.map +1 -0
  118. package/operations/entry/PgOsPublishEntry.d.ts +17 -0
  119. package/operations/entry/PgOsPublishEntry.js +34 -0
  120. package/operations/entry/PgOsPublishEntry.js.map +1 -0
  121. package/operations/entry/PgOsRestoreFromBin.d.ts +15 -0
  122. package/operations/entry/PgOsRestoreFromBin.js +27 -0
  123. package/operations/entry/PgOsRestoreFromBin.js.map +1 -0
  124. package/operations/entry/PgOsUnpublishEntry.d.ts +19 -0
  125. package/operations/entry/PgOsUnpublishEntry.js +41 -0
  126. package/operations/entry/PgOsUnpublishEntry.js.map +1 -0
  127. package/operations/entry/PgOsUpdateEntry.d.ts +15 -0
  128. package/operations/entry/PgOsUpdateEntry.js +27 -0
  129. package/operations/entry/PgOsUpdateEntry.js.map +1 -0
  130. package/operations/entry/abstractions/EntrySearchOperations.d.ts +10 -0
  131. package/operations/entry/abstractions/EntrySearchOperations.js +5 -0
  132. package/operations/entry/abstractions/EntrySearchOperations.js.map +1 -0
  133. package/operations/entry/feature.d.ts +4 -0
  134. package/operations/entry/feature.js +55 -0
  135. package/operations/entry/feature.js.map +1 -0
  136. package/operations/entry/search/get.d.ts +3 -0
  137. package/operations/entry/search/get.js +14 -0
  138. package/operations/entry/search/get.js.map +1 -0
  139. package/operations/entry/search/getUniqueFieldValues.d.ts +3 -0
  140. package/operations/entry/search/getUniqueFieldValues.js +55 -0
  141. package/operations/entry/search/getUniqueFieldValues.js.map +1 -0
  142. package/operations/entry/search/list.d.ts +3 -0
  143. package/operations/entry/search/list.js +59 -0
  144. package/operations/entry/search/list.js.map +1 -0
  145. package/operations/entry/search/types.d.ts +19 -0
  146. package/operations/entry/search/types.js +0 -0
  147. package/package.json +73 -0
  148. package/testing/createReindexEvents.d.ts +3 -0
  149. package/testing/createReindexEvents.js +14 -0
  150. package/testing/createReindexEvents.js.map +1 -0
  151. package/testing/index.d.ts +2 -0
  152. package/testing/index.js +2 -0
  153. package/testing/simulatePgStream.d.ts +19 -0
  154. package/testing/simulatePgStream.js +51 -0
  155. package/testing/simulatePgStream.js.map +1 -0
  156. package/types.d.ts +17 -0
  157. package/types.js +0 -0
@@ -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(\"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,MAAM,KAAK;IACvE;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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const BuildSyncRecord = createAbstraction("Cms/Pg/Os/SyncWriter/BuildSyncRecord");
3
+ export { BuildSyncRecord };
4
+
5
+ //# sourceMappingURL=BuildSyncRecord.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const RemoveEntry = createAbstraction("Cms/Pg/Os/SyncWriter/RemoveEntry");
3
+ export { RemoveEntry };
4
+
5
+ //# sourceMappingURL=RemoveEntry.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const RemoveLatest = createAbstraction("Cms/Pg/Os/SyncWriter/RemoveLatest");
3
+ export { RemoveLatest };
4
+
5
+ //# sourceMappingURL=RemoveLatest.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const RemovePublished = createAbstraction("Cms/Pg/Os/SyncWriter/RemovePublished");
3
+ export { RemovePublished };
4
+
5
+ //# sourceMappingURL=RemovePublished.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const SyncHelpers = createAbstraction("Cms/Pg/Os/SyncWriter/SyncHelpers");
3
+ export { SyncHelpers };
4
+
5
+ //# sourceMappingURL=SyncHelpers.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const SyncRowQuery = createAbstraction("Cms/Pg/Os/SyncWriter/SyncRowQuery");
3
+ export { SyncRowQuery };
4
+
5
+ //# sourceMappingURL=SyncRowQuery.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const WriteEntry = createAbstraction("Cms/Pg/Os/SyncWriter/WriteEntry");
3
+ export { WriteEntry };
4
+
5
+ //# sourceMappingURL=WriteEntry.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const WriteLatest = createAbstraction("Cms/Pg/Os/SyncWriter/WriteLatest");
3
+ export { WriteLatest };
4
+
5
+ //# sourceMappingURL=WriteLatest.js.map
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ const WritePublished = createAbstraction("Cms/Pg/Os/SyncWriter/WritePublished");
3
+ export { WritePublished };
4
+
5
+ //# sourceMappingURL=WritePublished.js.map
@@ -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,4 @@
1
+ export declare const SyncWriterFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api/index.js";
2
+ const SyncEventHandler = createAbstraction("Cms/PgOs/SyncEventHandler");
3
+ export { SyncEventHandler };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -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,4 @@
1
+ export declare const SyncEventHandlerFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -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,61 @@
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").primary();
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.index([
43
+ "tenant"
44
+ ]);
45
+ });
46
+ } catch (err) {
47
+ if (await this.knex.client.schema.hasTable(this.tableName)) return;
48
+ throw err;
49
+ }
50
+ }
51
+ }
52
+ const SyncTableManager_SyncTableManager = SyncTableManager.createImplementation({
53
+ implementation: SyncTableManagerImpl,
54
+ dependencies: [
55
+ KnexClient,
56
+ TableNameResolver
57
+ ]
58
+ });
59
+ export { SyncTableManager_SyncTableManager as SyncTableManager };
60
+
61
+ //# 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\").primary();\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.index([\"tenant\"]);\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,OAAO;gBACxBA,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,KAAK,CAAC;oBAAC;iBAAS;YAC1B;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,5 @@
1
+ import { createAbstraction } from "@webiny/feature/api/index.js";
2
+ const SyncTableManager = createAbstraction("Cms/PgOs/SyncTableManager");
3
+ export { SyncTableManager };
4
+
5
+ //# sourceMappingURL=abstractions.js.map
@@ -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,4 @@
1
+ export declare const SyncTableManagerFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -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"}
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { HeadlessCmsPgOsFeature, type IPgOsStorageOperationsConfig } from "./features/HeadlessCmsPgOsFeature.js";
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { HeadlessCmsPgOsFeature } from "./features/HeadlessCmsPgOsFeature.js";
@@ -0,0 +1,15 @@
1
+ import type { IEntrySearchOperations } from "./abstractions/EntrySearchOperations.js";
2
+ import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
3
+ import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
4
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
5
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
6
+ declare class EntrySearchOperationsImpl implements IEntrySearchOperations {
7
+ readonly list: IEntrySearchOperations["list"];
8
+ readonly get: IEntrySearchOperations["get"];
9
+ readonly getUniqueFieldValues: IEntrySearchOperations["getUniqueFieldValues"];
10
+ constructor(openSearchClient: OpenSearchClient.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
11
+ }
12
+ export declare const EntrySearchOperations: typeof EntrySearchOperationsImpl & {
13
+ __abstraction: import("@webiny/di").Abstraction<IEntrySearchOperations>;
14
+ };
15
+ export {};