@webiny/api-headless-cms-pg-os 0.0.0-unstable.0d717d18dd

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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-headless-cms-pg-os
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,9 @@
1
+ export interface IPgOsStorageOperationsConfig {
2
+ knex: any;
3
+ tableNamePrefix?: string;
4
+ tableNameSuffix?: string;
5
+ }
6
+ export declare const HeadlessCmsPgOsFeature: {
7
+ name: string;
8
+ register(container: import("@webiny/di").Container, context: IPgOsStorageOperationsConfig): void;
9
+ };
@@ -0,0 +1,40 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { CmsEntryOpenSearchUtilsFeature } from "@webiny/api-headless-cms-utils-os";
3
+ import { TableNameResolverConfig } from "@webiny/api-headless-cms-sql/features/tableNameResolver/abstractions.js";
4
+ import { TableNameResolverFeature } from "@webiny/api-headless-cms-sql/features/tableNameResolver/feature.js";
5
+ import { ValueFilterFeature } from "@webiny/db-utils";
6
+ import { GroupSchemaManagerFeature } from "@webiny/api-headless-cms-sql/features/groupSchemaManager/feature.js";
7
+ import { ModelSchemaManagerFeature } from "@webiny/api-headless-cms-sql/features/modelSchemaManager/feature.js";
8
+ import { EntryTableManagerFeature } from "@webiny/api-headless-cms-sql/features/entryTableManager/feature.js";
9
+ import { SyncTableManagerFeature } from "./syncTableManager/feature.js";
10
+ import { SyncWriterFeature } from "./SyncWriter/feature.js";
11
+ import { FilterRegistriesFeature } from "@webiny/api-headless-cms-storage";
12
+ import { SqlGroupStorageOpsFeature } from "@webiny/api-headless-cms-sql/operations/group/feature.js";
13
+ import { SqlModelStorageOpsFeature } from "@webiny/api-headless-cms-sql/operations/model/feature.js";
14
+ import { PgOsEntryStorageOpsFeature } from "../operations/entry/feature.js";
15
+ const HeadlessCmsPgOsFeature = createFeature({
16
+ name: "cms.storageOperations.pgOs",
17
+ register: (container, config)=>{
18
+ const sharedTables = "true" === process.env.WEBINY_SHARED_TABLES;
19
+ container.registerInstance(TableNameResolverConfig, {
20
+ sharedTables,
21
+ tableNamePrefix: config.tableNamePrefix,
22
+ tableNameSuffix: config.tableNameSuffix
23
+ });
24
+ TableNameResolverFeature.register(container);
25
+ ValueFilterFeature.register(container);
26
+ FilterRegistriesFeature.register(container);
27
+ GroupSchemaManagerFeature.register(container);
28
+ ModelSchemaManagerFeature.register(container);
29
+ EntryTableManagerFeature.register(container);
30
+ SyncTableManagerFeature.register(container);
31
+ SyncWriterFeature.register(container);
32
+ CmsEntryOpenSearchUtilsFeature.register(container);
33
+ SqlGroupStorageOpsFeature.register(container);
34
+ SqlModelStorageOpsFeature.register(container);
35
+ PgOsEntryStorageOpsFeature.register(container);
36
+ }
37
+ });
38
+ export { HeadlessCmsPgOsFeature };
39
+
40
+ //# sourceMappingURL=HeadlessCmsPgOsFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/HeadlessCmsPgOsFeature.js","sources":["../../src/features/HeadlessCmsPgOsFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { CmsEntryOpenSearchUtilsFeature } from \"@webiny/api-headless-cms-utils-os\";\nimport { TableNameResolverConfig } from \"@webiny/api-headless-cms-sql/features/tableNameResolver/abstractions.js\";\nimport { TableNameResolverFeature } from \"@webiny/api-headless-cms-sql/features/tableNameResolver/feature.js\";\nimport { ValueFilterFeature } from \"@webiny/db-utils\";\nimport { GroupSchemaManagerFeature } from \"@webiny/api-headless-cms-sql/features/groupSchemaManager/feature.js\";\nimport { ModelSchemaManagerFeature } from \"@webiny/api-headless-cms-sql/features/modelSchemaManager/feature.js\";\nimport { EntryTableManagerFeature } from \"@webiny/api-headless-cms-sql/features/entryTableManager/feature.js\";\nimport { SyncTableManagerFeature } from \"./syncTableManager/feature.js\";\nimport { SyncWriterFeature } from \"./SyncWriter/feature.js\";\nimport { FilterRegistriesFeature } from \"@webiny/api-headless-cms-storage\";\nimport { SqlGroupStorageOpsFeature } from \"@webiny/api-headless-cms-sql/operations/group/feature.js\";\nimport { SqlModelStorageOpsFeature } from \"@webiny/api-headless-cms-sql/operations/model/feature.js\";\nimport { PgOsEntryStorageOpsFeature } from \"~/operations/entry/feature.js\";\n\nexport interface IPgOsStorageOperationsConfig {\n knex: any;\n tableNamePrefix?: string;\n tableNameSuffix?: string;\n}\n\nexport const HeadlessCmsPgOsFeature = createFeature<IPgOsStorageOperationsConfig>({\n name: \"cms.storageOperations.pgOs\",\n register: (container, config) => {\n const sharedTables = process.env.WEBINY_SHARED_TABLES === \"true\";\n\n container.registerInstance(TableNameResolverConfig, {\n sharedTables,\n tableNamePrefix: config.tableNamePrefix,\n tableNameSuffix: config.tableNameSuffix\n });\n\n TableNameResolverFeature.register(container);\n ValueFilterFeature.register(container);\n FilterRegistriesFeature.register(container);\n GroupSchemaManagerFeature.register(container);\n ModelSchemaManagerFeature.register(container);\n EntryTableManagerFeature.register(container);\n SyncTableManagerFeature.register(container);\n SyncWriterFeature.register(container);\n\n CmsEntryOpenSearchUtilsFeature.register(container);\n\n SqlGroupStorageOpsFeature.register(container);\n SqlModelStorageOpsFeature.register(container);\n\n PgOsEntryStorageOpsFeature.register(container);\n }\n});\n"],"names":["HeadlessCmsPgOsFeature","createFeature","container","config","sharedTables","process","TableNameResolverConfig","TableNameResolverFeature","ValueFilterFeature","FilterRegistriesFeature","GroupSchemaManagerFeature","ModelSchemaManagerFeature","EntryTableManagerFeature","SyncTableManagerFeature","SyncWriterFeature","CmsEntryOpenSearchUtilsFeature","SqlGroupStorageOpsFeature","SqlModelStorageOpsFeature","PgOsEntryStorageOpsFeature"],"mappings":";;;;;;;;;;;;;;AAqBO,MAAMA,yBAAyBC,cAA4C;IAC9E,MAAM;IACN,UAAU,CAACC,WAAWC;QAClB,MAAMC,eAAeC,AAAqC,WAArCA,QAAQ,GAAG,CAAC,oBAAoB;QAErDH,UAAU,gBAAgB,CAACI,yBAAyB;YAChDF;YACA,iBAAiBD,OAAO,eAAe;YACvC,iBAAiBA,OAAO,eAAe;QAC3C;QAEAI,yBAAyB,QAAQ,CAACL;QAClCM,mBAAmB,QAAQ,CAACN;QAC5BO,wBAAwB,QAAQ,CAACP;QACjCQ,0BAA0B,QAAQ,CAACR;QACnCS,0BAA0B,QAAQ,CAACT;QACnCU,yBAAyB,QAAQ,CAACV;QAClCW,wBAAwB,QAAQ,CAACX;QACjCY,kBAAkB,QAAQ,CAACZ;QAE3Ba,+BAA+B,QAAQ,CAACb;QAExCc,0BAA0B,QAAQ,CAACd;QACnCe,0BAA0B,QAAQ,CAACf;QAEnCgB,2BAA2B,QAAQ,CAAChB;IACxC;AACJ"}
@@ -0,0 +1,22 @@
1
+ import type { CmsEntryValues } from "@webiny/api-headless-cms/types/index.js";
2
+ import { BuildSyncRecord as Abstraction } from "./abstractions/BuildSyncRecord.js";
3
+ import { CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
4
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
5
+ import { OperationType } from "@webiny/api-sync-to-opensearch/features/Operations/Operations.js";
6
+ declare class BuildSyncRecordImpl implements Abstraction.Interface {
7
+ private readonly fieldIndexRegistry;
8
+ private readonly compressionHandler;
9
+ constructor(fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface);
10
+ execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>): Promise<{
11
+ id: string;
12
+ entryId: string;
13
+ index: string;
14
+ operation: OperationType;
15
+ data: string;
16
+ tenant: string;
17
+ }>;
18
+ }
19
+ export declare const BuildSyncRecord: typeof BuildSyncRecordImpl & {
20
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/BuildSyncRecord.js").IBuildSyncRecord>;
21
+ };
22
+ export {};
@@ -0,0 +1,56 @@
1
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
2
+ import { CmsEntryOpenSearchFieldIndexRegistry } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
3
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
4
+ import { transformEntryToIndex } from "@webiny/api-headless-cms-utils-os/operations/entry/transformations/transformEntryToIndex.js";
5
+ import { createLatestRecordType, createPublishedRecordType } from "@webiny/api-headless-cms-utils-os/operations/entry/recordType.js";
6
+ import { configurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
7
+ import { OperationType } from "@webiny/api-sync-to-opensearch/features/Operations/Operations.js";
8
+ class BuildSyncRecordImpl {
9
+ constructor(fieldIndexRegistry, compressionHandler){
10
+ this.fieldIndexRegistry = fieldIndexRegistry;
11
+ this.compressionHandler = compressionHandler;
12
+ }
13
+ async execute(params) {
14
+ const { model, entry, storageEntry, kind } = params;
15
+ const indexEntry = transformEntryToIndex({
16
+ model,
17
+ entry,
18
+ storageEntry,
19
+ fieldIndexRegistry: this.fieldIndexRegistry
20
+ });
21
+ const isLatest = "latest" === kind;
22
+ const recordType = isLatest ? createLatestRecordType() : createPublishedRecordType();
23
+ const document = {
24
+ ...indexEntry,
25
+ ...isLatest ? {
26
+ latest: true
27
+ } : {
28
+ published: true
29
+ },
30
+ TYPE: recordType,
31
+ __type: recordType
32
+ };
33
+ const compressed = await this.compressionHandler.compress(document);
34
+ const { index } = configurations.es({
35
+ model
36
+ });
37
+ return {
38
+ id: `${entry.entryId}:${isLatest ? "L" : "P"}`,
39
+ entryId: entry.entryId,
40
+ index,
41
+ operation: OperationType.MODIFY,
42
+ data: JSON.stringify(compressed),
43
+ tenant: entry.tenant
44
+ };
45
+ }
46
+ }
47
+ const BuildSyncRecord_BuildSyncRecord = BuildSyncRecord.createImplementation({
48
+ implementation: BuildSyncRecordImpl,
49
+ dependencies: [
50
+ CmsEntryOpenSearchFieldIndexRegistry,
51
+ CompressionHandler
52
+ ]
53
+ });
54
+ export { BuildSyncRecord_BuildSyncRecord as BuildSyncRecord };
55
+
56
+ //# sourceMappingURL=BuildSyncRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/BuildSyncRecord.js","sources":["../../../src/features/SyncWriter/BuildSyncRecord.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { BuildSyncRecord as Abstraction } from \"./abstractions/BuildSyncRecord.js\";\nimport { CmsEntryOpenSearchFieldIndexRegistry } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { transformEntryToIndex } from \"@webiny/api-headless-cms-utils-os/operations/entry/transformations/transformEntryToIndex.js\";\nimport {\n createLatestRecordType,\n createPublishedRecordType\n} from \"@webiny/api-headless-cms-utils-os/operations/entry/recordType.js\";\nimport { configurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { OperationType } from \"@webiny/api-sync-to-opensearch/features/Operations/Operations.js\";\n\nclass BuildSyncRecordImpl implements Abstraction.Interface {\n public constructor(\n private readonly fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private readonly compressionHandler: CompressionHandler.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>) {\n const { model, entry, storageEntry, kind } = params;\n\n const indexEntry = transformEntryToIndex({\n model,\n entry,\n storageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry\n });\n\n const isLatest = kind === \"latest\";\n const recordType = isLatest ? createLatestRecordType() : createPublishedRecordType();\n\n const document = {\n ...indexEntry,\n ...(isLatest ? { latest: true } : { published: true }),\n TYPE: recordType,\n __type: recordType\n };\n\n const compressed = await this.compressionHandler.compress(document);\n const { index } = configurations.es({ model });\n\n return {\n id: `${entry.entryId}:${isLatest ? \"L\" : \"P\"}`,\n entryId: entry.entryId,\n index,\n operation: OperationType.MODIFY,\n data: JSON.stringify(compressed),\n tenant: entry.tenant\n };\n }\n}\n\nexport const BuildSyncRecord = Abstraction.createImplementation({\n implementation: BuildSyncRecordImpl,\n dependencies: [CmsEntryOpenSearchFieldIndexRegistry, CompressionHandler]\n});\n"],"names":["BuildSyncRecordImpl","fieldIndexRegistry","compressionHandler","params","model","entry","storageEntry","kind","indexEntry","transformEntryToIndex","isLatest","recordType","createLatestRecordType","createPublishedRecordType","document","compressed","index","configurations","OperationType","JSON","BuildSyncRecord","Abstraction","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACqBC,kBAAkE,EAClEC,kBAAgD,CACnE;aAFmBD,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;IAClB;IAEH,MAAa,QAAmDC,MAA6B,EAAE;QAC3F,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAEC,IAAI,EAAE,GAAGJ;QAE7C,MAAMK,aAAaC,sBAAsB;YACrCL;YACAC;YACAC;YACA,oBAAoB,IAAI,CAAC,kBAAkB;QAC/C;QAEA,MAAMI,WAAWH,AAAS,aAATA;QACjB,MAAMI,aAAaD,WAAWE,2BAA2BC;QAEzD,MAAMC,WAAW;YACb,GAAGN,UAAU;YACb,GAAIE,WAAW;gBAAE,QAAQ;YAAK,IAAI;gBAAE,WAAW;YAAK,CAAC;YACrD,MAAMC;YACN,QAAQA;QACZ;QAEA,MAAMI,aAAa,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAACD;QAC1D,MAAM,EAAEE,KAAK,EAAE,GAAGC,eAAe,EAAE,CAAC;YAAEb;QAAM;QAE5C,OAAO;YACH,IAAI,GAAGC,MAAM,OAAO,CAAC,CAAC,EAAEK,WAAW,MAAM,KAAK;YAC9C,SAASL,MAAM,OAAO;YACtBW;YACA,WAAWE,cAAc,MAAM;YAC/B,MAAMC,KAAK,SAAS,CAACJ;YACrB,QAAQV,MAAM,MAAM;QACxB;IACJ;AACJ;AAEO,MAAMe,kCAAkBC,gBAAAA,oBAAgC,CAAC;IAC5D,gBAAgBrB;IAChB,cAAc;QAACsB;QAAsCC;KAAmB;AAC5E"}
@@ -0,0 +1,11 @@
1
+ import { RemoveEntry as Abstraction } from "./abstractions/RemoveEntry.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ declare class RemoveEntryImpl implements Abstraction.Interface {
4
+ private readonly syncRowQuery;
5
+ constructor(syncRowQuery: SyncRowQuery.Interface);
6
+ execute(params: Abstraction.Params): Promise<void>;
7
+ }
8
+ export declare const RemoveEntry: typeof RemoveEntryImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/RemoveEntry.js").IRemoveEntry>;
10
+ };
11
+ export {};
@@ -0,0 +1,23 @@
1
+ import { RemoveEntry } from "./abstractions/RemoveEntry.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ class RemoveEntryImpl {
4
+ constructor(syncRowQuery){
5
+ this.syncRowQuery = syncRowQuery;
6
+ }
7
+ async execute(params) {
8
+ const { entryId } = params;
9
+ await this.syncRowQuery.create().whereIn("id", [
10
+ `${entryId}:L`,
11
+ `${entryId}:P`
12
+ ]).delete();
13
+ }
14
+ }
15
+ const RemoveEntry_RemoveEntry = RemoveEntry.createImplementation({
16
+ implementation: RemoveEntryImpl,
17
+ dependencies: [
18
+ SyncRowQuery
19
+ ]
20
+ });
21
+ export { RemoveEntry_RemoveEntry as RemoveEntry };
22
+
23
+ //# sourceMappingURL=RemoveEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/RemoveEntry.js","sources":["../../../src/features/SyncWriter/RemoveEntry.ts"],"sourcesContent":["import { RemoveEntry as Abstraction } from \"./abstractions/RemoveEntry.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\n\nclass RemoveEntryImpl implements Abstraction.Interface {\n public constructor(private readonly syncRowQuery: SyncRowQuery.Interface) {}\n\n public async execute(params: Abstraction.Params) {\n const { entryId } = params;\n await this.syncRowQuery\n .create()\n .whereIn(\"id\", [`${entryId}:L`, `${entryId}:P`])\n .delete();\n }\n}\n\nexport const RemoveEntry = Abstraction.createImplementation({\n implementation: RemoveEntryImpl,\n dependencies: [SyncRowQuery]\n});\n"],"names":["RemoveEntryImpl","syncRowQuery","params","entryId","RemoveEntry","Abstraction","SyncRowQuery"],"mappings":";;AAGA,MAAMA;IACF,YAAoCC,YAAoC,CAAE;aAAtCA,YAAY,GAAZA;IAAuC;IAE3E,MAAa,QAAQC,MAA0B,EAAE;QAC7C,MAAM,EAAEC,OAAO,EAAE,GAAGD;QACpB,MAAM,IAAI,CAAC,YAAY,CAClB,MAAM,GACN,OAAO,CAAC,MAAM;YAAC,GAAGC,QAAQ,EAAE,CAAC;YAAE,GAAGA,QAAQ,EAAE,CAAC;SAAC,EAC9C,MAAM;IACf;AACJ;AAEO,MAAMC,0BAAcC,YAAAA,oBAAgC,CAAC;IACxD,gBAAgBL;IAChB,cAAc;QAACM;KAAa;AAChC"}
@@ -0,0 +1,11 @@
1
+ import { RemoveLatest as Abstraction } from "./abstractions/RemoveLatest.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ declare class RemoveLatestImpl implements Abstraction.Interface {
4
+ private readonly syncRowQuery;
5
+ constructor(syncRowQuery: SyncRowQuery.Interface);
6
+ execute(params: Abstraction.Params): Promise<void>;
7
+ }
8
+ export declare const RemoveLatest: typeof RemoveLatestImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/RemoveLatest.js").IRemoveLatest>;
10
+ };
11
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RemoveLatest } from "./abstractions/RemoveLatest.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ class RemoveLatestImpl {
4
+ constructor(syncRowQuery){
5
+ this.syncRowQuery = syncRowQuery;
6
+ }
7
+ async execute(params) {
8
+ await this.syncRowQuery.create().where("id", `${params.entryId}:L`).delete();
9
+ }
10
+ }
11
+ const RemoveLatest_RemoveLatest = RemoveLatest.createImplementation({
12
+ implementation: RemoveLatestImpl,
13
+ dependencies: [
14
+ SyncRowQuery
15
+ ]
16
+ });
17
+ export { RemoveLatest_RemoveLatest as RemoveLatest };
18
+
19
+ //# sourceMappingURL=RemoveLatest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/RemoveLatest.js","sources":["../../../src/features/SyncWriter/RemoveLatest.ts"],"sourcesContent":["import { RemoveLatest as Abstraction } from \"./abstractions/RemoveLatest.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\n\nclass RemoveLatestImpl implements Abstraction.Interface {\n public constructor(private readonly syncRowQuery: SyncRowQuery.Interface) {}\n\n public async execute(params: Abstraction.Params) {\n await this.syncRowQuery.create().where(\"id\", `${params.entryId}:L`).delete();\n }\n}\n\nexport const RemoveLatest = Abstraction.createImplementation({\n implementation: RemoveLatestImpl,\n dependencies: [SyncRowQuery]\n});\n"],"names":["RemoveLatestImpl","syncRowQuery","params","RemoveLatest","Abstraction","SyncRowQuery"],"mappings":";;AAGA,MAAMA;IACF,YAAoCC,YAAoC,CAAE;aAAtCA,YAAY,GAAZA;IAAuC;IAE3E,MAAa,QAAQC,MAA0B,EAAE;QAC7C,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAGA,OAAO,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM;IAC9E;AACJ;AAEO,MAAMC,4BAAeC,aAAAA,oBAAgC,CAAC;IACzD,gBAAgBJ;IAChB,cAAc;QAACK;KAAa;AAChC"}
@@ -0,0 +1,11 @@
1
+ import { RemovePublished as Abstraction } from "./abstractions/RemovePublished.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ declare class RemovePublishedImpl implements Abstraction.Interface {
4
+ private readonly syncRowQuery;
5
+ constructor(syncRowQuery: SyncRowQuery.Interface);
6
+ execute(params: Abstraction.Params): Promise<void>;
7
+ }
8
+ export declare const RemovePublished: typeof RemovePublishedImpl & {
9
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/RemovePublished.js").IRemovePublished>;
10
+ };
11
+ export {};
@@ -0,0 +1,19 @@
1
+ import { RemovePublished } from "./abstractions/RemovePublished.js";
2
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
3
+ class RemovePublishedImpl {
4
+ constructor(syncRowQuery){
5
+ this.syncRowQuery = syncRowQuery;
6
+ }
7
+ async execute(params) {
8
+ await this.syncRowQuery.create().where("id", `${params.entryId}:P`).delete();
9
+ }
10
+ }
11
+ const RemovePublished_RemovePublished = RemovePublished.createImplementation({
12
+ implementation: RemovePublishedImpl,
13
+ dependencies: [
14
+ SyncRowQuery
15
+ ]
16
+ });
17
+ export { RemovePublished_RemovePublished as RemovePublished };
18
+
19
+ //# sourceMappingURL=RemovePublished.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/RemovePublished.js","sources":["../../../src/features/SyncWriter/RemovePublished.ts"],"sourcesContent":["import { RemovePublished as Abstraction } from \"./abstractions/RemovePublished.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\n\nclass RemovePublishedImpl implements Abstraction.Interface {\n public constructor(private readonly syncRowQuery: SyncRowQuery.Interface) {}\n\n public async execute(params: Abstraction.Params) {\n await this.syncRowQuery.create().where(\"id\", `${params.entryId}:P`).delete();\n }\n}\n\nexport const RemovePublished = Abstraction.createImplementation({\n implementation: RemovePublishedImpl,\n dependencies: [SyncRowQuery]\n});\n"],"names":["RemovePublishedImpl","syncRowQuery","params","RemovePublished","Abstraction","SyncRowQuery"],"mappings":";;AAGA,MAAMA;IACF,YAAoCC,YAAoC,CAAE;aAAtCA,YAAY,GAAZA;IAAuC;IAE3E,MAAa,QAAQC,MAA0B,EAAE;QAC7C,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAGA,OAAO,OAAO,CAAC,EAAE,CAAC,EAAE,MAAM;IAC9E;AACJ;AAEO,MAAMC,kCAAkBC,gBAAAA,oBAAgC,CAAC;IAC5D,gBAAgBJ;IAChB,cAAc;QAACK;KAAa;AAChC"}
@@ -0,0 +1,26 @@
1
+ import type { CmsEntry, CmsEntryValues, CmsModel, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ import { SyncHelpers as Abstraction } from "./abstractions/SyncHelpers.js";
3
+ import { WriteEntry } from "./abstractions/WriteEntry.js";
4
+ import { WriteLatest } from "./abstractions/WriteLatest.js";
5
+ import { WritePublished } from "./abstractions/WritePublished.js";
6
+ import { RemovePublished } from "./abstractions/RemovePublished.js";
7
+ import { SyncTableManager } from "../../features/syncTableManager/abstractions.js";
8
+ import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
9
+ import { GetPublishedRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js";
10
+ declare class SyncHelpersImpl implements Abstraction.Interface {
11
+ private readonly syncTableManager;
12
+ private readonly writeEntry;
13
+ private readonly writeLatest;
14
+ private readonly writePublished;
15
+ private readonly removePublished;
16
+ private readonly getLatestRevision;
17
+ private readonly getPublishedRevision;
18
+ constructor(syncTableManager: SyncTableManager.Interface, writeEntry: WriteEntry.Interface, writeLatest: WriteLatest.Interface, writePublished: WritePublished.Interface, removePublished: RemovePublished.Interface, getLatestRevision: GetLatestRevisionByEntryIdStorageOperation.Interface, getPublishedRevision: GetPublishedRevisionByEntryIdStorageOperation.Interface);
19
+ ensureSyncTable(): Promise<void>;
20
+ writeSyncForEntry<T extends CmsEntryValues>(model: StorageOperationsCmsModel<T>, entry: CmsEntry<T>, storageEntry: CmsStorageEntry<T>): Promise<void>;
21
+ resyncLatestAndPublishedFromPg<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, model: StorageOperationsCmsModel<T>, id: string): Promise<void>;
22
+ }
23
+ export declare const SyncHelpers: typeof SyncHelpersImpl & {
24
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/SyncHelpers.js").ISyncHelpers>;
25
+ };
26
+ export {};
@@ -0,0 +1,70 @@
1
+ import { parseIdentifier } from "@webiny/utils";
2
+ import { SyncHelpers } from "./abstractions/SyncHelpers.js";
3
+ import { WriteEntry } from "./abstractions/WriteEntry.js";
4
+ import { WriteLatest } from "./abstractions/WriteLatest.js";
5
+ import { WritePublished } from "./abstractions/WritePublished.js";
6
+ import { RemovePublished } from "./abstractions/RemovePublished.js";
7
+ import { SyncTableManager } from "../syncTableManager/abstractions.js";
8
+ import { GetLatestRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js";
9
+ import { GetPublishedRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js";
10
+ class SyncHelpersImpl {
11
+ constructor(syncTableManager, writeEntry, writeLatest, writePublished, removePublished, getLatestRevision, getPublishedRevision){
12
+ this.syncTableManager = syncTableManager;
13
+ this.writeEntry = writeEntry;
14
+ this.writeLatest = writeLatest;
15
+ this.writePublished = writePublished;
16
+ this.removePublished = removePublished;
17
+ this.getLatestRevision = getLatestRevision;
18
+ this.getPublishedRevision = getPublishedRevision;
19
+ }
20
+ async ensureSyncTable() {
21
+ await this.syncTableManager.ensureTable();
22
+ }
23
+ async writeSyncForEntry(model, entry, storageEntry) {
24
+ await this.writeEntry.execute({
25
+ model,
26
+ entry,
27
+ storageEntry
28
+ });
29
+ }
30
+ async resyncLatestAndPublishedFromPg(initialModel, model, id) {
31
+ const latest = await this.getLatestRevision.execute(initialModel, {
32
+ id
33
+ });
34
+ if (latest) await this.writeLatest.execute({
35
+ model,
36
+ entry: latest,
37
+ storageEntry: latest
38
+ });
39
+ const published = await this.getPublishedRevision.execute(initialModel, {
40
+ id
41
+ });
42
+ if (published) await this.writePublished.execute({
43
+ model,
44
+ entry: published,
45
+ storageEntry: published
46
+ });
47
+ else {
48
+ const { id: entryId } = parseIdentifier(id);
49
+ await this.removePublished.execute({
50
+ model,
51
+ entryId
52
+ });
53
+ }
54
+ }
55
+ }
56
+ const SyncHelpers_SyncHelpers = SyncHelpers.createImplementation({
57
+ implementation: SyncHelpersImpl,
58
+ dependencies: [
59
+ SyncTableManager,
60
+ WriteEntry,
61
+ WriteLatest,
62
+ WritePublished,
63
+ RemovePublished,
64
+ GetLatestRevisionByEntryIdStorageOperation,
65
+ GetPublishedRevisionByEntryIdStorageOperation
66
+ ]
67
+ });
68
+ export { SyncHelpers_SyncHelpers as SyncHelpers };
69
+
70
+ //# sourceMappingURL=SyncHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/SyncHelpers.js","sources":["../../../src/features/SyncWriter/SyncHelpers.ts"],"sourcesContent":["import type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { SyncHelpers as Abstraction } from \"./abstractions/SyncHelpers.js\";\nimport { WriteEntry } from \"./abstractions/WriteEntry.js\";\nimport { WriteLatest } from \"./abstractions/WriteLatest.js\";\nimport { WritePublished } from \"./abstractions/WritePublished.js\";\nimport { RemovePublished } from \"./abstractions/RemovePublished.js\";\nimport { SyncTableManager } from \"~/features/syncTableManager/abstractions.js\";\nimport { GetLatestRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetLatestRevisionByEntryIdStorageOperation.js\";\nimport { GetPublishedRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js\";\n\nclass SyncHelpersImpl implements Abstraction.Interface {\n public constructor(\n private readonly syncTableManager: SyncTableManager.Interface,\n private readonly writeEntry: WriteEntry.Interface,\n private readonly writeLatest: WriteLatest.Interface,\n private readonly writePublished: WritePublished.Interface,\n private readonly removePublished: RemovePublished.Interface,\n private readonly getLatestRevision: GetLatestRevisionByEntryIdStorageOperation.Interface,\n private readonly getPublishedRevision: GetPublishedRevisionByEntryIdStorageOperation.Interface\n ) {}\n\n public async ensureSyncTable(): Promise<void> {\n await this.syncTableManager.ensureTable();\n }\n\n public async writeSyncForEntry<T extends CmsEntryValues>(\n model: StorageOperationsCmsModel<T>,\n entry: CmsEntry<T>,\n storageEntry: CmsStorageEntry<T>\n ): Promise<void> {\n await this.writeEntry.execute({ model, entry, storageEntry });\n }\n\n public async resyncLatestAndPublishedFromPg<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n model: StorageOperationsCmsModel<T>,\n id: string\n ): Promise<void> {\n const latest = await this.getLatestRevision.execute<T>(initialModel, { id });\n if (latest) {\n await this.writeLatest.execute({ model, entry: latest, storageEntry: latest });\n }\n\n const published = await this.getPublishedRevision.execute<T>(initialModel, { id });\n if (published) {\n await this.writePublished.execute({\n model,\n entry: published,\n storageEntry: published\n });\n } else {\n const { id: entryId } = parseIdentifier(id);\n await this.removePublished.execute({ model, entryId });\n }\n }\n}\n\nexport const SyncHelpers = Abstraction.createImplementation({\n implementation: SyncHelpersImpl,\n dependencies: [\n SyncTableManager,\n WriteEntry,\n WriteLatest,\n WritePublished,\n RemovePublished,\n GetLatestRevisionByEntryIdStorageOperation,\n GetPublishedRevisionByEntryIdStorageOperation\n ]\n});\n"],"names":["SyncHelpersImpl","syncTableManager","writeEntry","writeLatest","writePublished","removePublished","getLatestRevision","getPublishedRevision","model","entry","storageEntry","initialModel","id","latest","published","entryId","parseIdentifier","SyncHelpers","Abstraction","SyncTableManager","WriteEntry","WriteLatest","WritePublished","RemovePublished","GetLatestRevisionByEntryIdStorageOperation","GetPublishedRevisionByEntryIdStorageOperation"],"mappings":";;;;;;;;;AAiBA,MAAMA;IACF,YACqBC,gBAA4C,EAC5CC,UAAgC,EAChCC,WAAkC,EAClCC,cAAwC,EACxCC,eAA0C,EAC1CC,iBAAuE,EACvEC,oBAA6E,CAChG;aAPmBN,gBAAgB,GAAhBA;aACAC,UAAU,GAAVA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;aACAC,eAAe,GAAfA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;IAClB;IAEH,MAAa,kBAAiC;QAC1C,MAAM,IAAI,CAAC,gBAAgB,CAAC,WAAW;IAC3C;IAEA,MAAa,kBACTC,KAAmC,EACnCC,KAAkB,EAClBC,YAAgC,EACnB;QACb,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YAAEF;YAAOC;YAAOC;QAAa;IAC/D;IAEA,MAAa,+BACTC,YAAsB,EACtBH,KAAmC,EACnCI,EAAU,EACG;QACb,MAAMC,SAAS,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAIF,cAAc;YAAEC;QAAG;QAC1E,IAAIC,QACA,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;YAAEL;YAAO,OAAOK;YAAQ,cAAcA;QAAO;QAGhF,MAAMC,YAAY,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAIH,cAAc;YAAEC;QAAG;QAChF,IAAIE,WACA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;YAC9BN;YACA,OAAOM;YACP,cAAcA;QAClB;aACG;YACH,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBJ;YACxC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;gBAAEJ;gBAAOO;YAAQ;QACxD;IACJ;AACJ;AAEO,MAAME,0BAAcC,YAAAA,oBAAgC,CAAC;IACxD,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -0,0 +1,22 @@
1
+ import { SyncRowQuery as Abstraction } from "./abstractions/SyncRowQuery.js";
2
+ import { KnexClient } from "@webiny/api-core-sql";
3
+ import { SyncTableManager } from "../../features/syncTableManager/abstractions.js";
4
+ import type { ISyncRow } from "../../types.js";
5
+ declare class SyncRowQueryImpl implements Abstraction.Interface {
6
+ private readonly knexClient;
7
+ private readonly syncTableManager;
8
+ constructor(knexClient: KnexClient.Interface, syncTableManager: SyncTableManager.Interface);
9
+ create(): import("knex").Knex.QueryBuilder<ISyncRow, {
10
+ _base: ISyncRow;
11
+ _hasSelection: false;
12
+ _keys: never;
13
+ _aliases: {};
14
+ _single: false;
15
+ _intersectProps: {};
16
+ _unionProps: never;
17
+ }[]>;
18
+ }
19
+ export declare const SyncRowQuery: typeof SyncRowQueryImpl & {
20
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/SyncRowQuery.js").ISyncRowQuery>;
21
+ };
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
2
+ import { KnexClient } from "@webiny/api-core-sql";
3
+ import { SyncTableManager } from "../syncTableManager/abstractions.js";
4
+ class SyncRowQueryImpl {
5
+ constructor(knexClient, syncTableManager){
6
+ this.knexClient = knexClient;
7
+ this.syncTableManager = syncTableManager;
8
+ }
9
+ create() {
10
+ return this.knexClient.client(this.syncTableManager.getTableName());
11
+ }
12
+ }
13
+ const SyncRowQuery_SyncRowQuery = SyncRowQuery.createImplementation({
14
+ implementation: SyncRowQueryImpl,
15
+ dependencies: [
16
+ KnexClient,
17
+ SyncTableManager
18
+ ]
19
+ });
20
+ export { SyncRowQuery_SyncRowQuery as SyncRowQuery };
21
+
22
+ //# sourceMappingURL=SyncRowQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/SyncRowQuery.js","sources":["../../../src/features/SyncWriter/SyncRowQuery.ts"],"sourcesContent":["import { SyncRowQuery as Abstraction } from \"./abstractions/SyncRowQuery.js\";\nimport { KnexClient } from \"@webiny/api-core-sql\";\nimport { SyncTableManager } from \"~/features/syncTableManager/abstractions.js\";\nimport type { ISyncRow } from \"~/types.js\";\n\nclass SyncRowQueryImpl implements Abstraction.Interface {\n public constructor(\n private readonly knexClient: KnexClient.Interface,\n private readonly syncTableManager: SyncTableManager.Interface\n ) {}\n\n public create() {\n return this.knexClient.client<ISyncRow>(this.syncTableManager.getTableName());\n }\n}\n\nexport const SyncRowQuery = Abstraction.createImplementation({\n implementation: SyncRowQueryImpl,\n dependencies: [KnexClient, SyncTableManager]\n});\n"],"names":["SyncRowQueryImpl","knexClient","syncTableManager","SyncRowQuery","Abstraction","KnexClient","SyncTableManager"],"mappings":";;;AAKA,MAAMA;IACF,YACqBC,UAAgC,EAChCC,gBAA4C,CAC/D;aAFmBD,UAAU,GAAVA;aACAC,gBAAgB,GAAhBA;IAClB;IAEI,SAAS;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAW,IAAI,CAAC,gBAAgB,CAAC,YAAY;IAC9E;AACJ;AAEO,MAAMC,4BAAeC,aAAAA,oBAAgC,CAAC;IACzD,gBAAgBJ;IAChB,cAAc;QAACK;QAAYC;KAAiB;AAChD"}
@@ -0,0 +1,14 @@
1
+ import type { CmsEntryValues } from "@webiny/api-headless-cms/types/index.js";
2
+ import { WriteEntry as Abstraction } from "./abstractions/WriteEntry.js";
3
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
4
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
5
+ declare class WriteEntryImpl implements Abstraction.Interface {
6
+ private readonly buildSyncRecord;
7
+ private readonly syncRowQuery;
8
+ constructor(buildSyncRecord: BuildSyncRecord.Interface, syncRowQuery: SyncRowQuery.Interface);
9
+ execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>): Promise<void>;
10
+ }
11
+ export declare const WriteEntry: typeof WriteEntryImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/WriteEntry.js").IWriteEntry>;
13
+ };
14
+ export {};
@@ -0,0 +1,32 @@
1
+ import { WriteEntry } from "./abstractions/WriteEntry.js";
2
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
3
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
4
+ class WriteEntryImpl {
5
+ constructor(buildSyncRecord, syncRowQuery){
6
+ this.buildSyncRecord = buildSyncRecord;
7
+ this.syncRowQuery = syncRowQuery;
8
+ }
9
+ async execute(params) {
10
+ const rows = [
11
+ await this.buildSyncRecord.execute({
12
+ ...params,
13
+ kind: "latest"
14
+ })
15
+ ];
16
+ if ("published" === params.entry.status) rows.push(await this.buildSyncRecord.execute({
17
+ ...params,
18
+ kind: "published"
19
+ }));
20
+ await this.syncRowQuery.create().insert(rows).onConflict("id").merge();
21
+ }
22
+ }
23
+ const WriteEntry_WriteEntry = WriteEntry.createImplementation({
24
+ implementation: WriteEntryImpl,
25
+ dependencies: [
26
+ BuildSyncRecord,
27
+ SyncRowQuery
28
+ ]
29
+ });
30
+ export { WriteEntry_WriteEntry as WriteEntry };
31
+
32
+ //# sourceMappingURL=WriteEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/WriteEntry.js","sources":["../../../src/features/SyncWriter/WriteEntry.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { WriteEntry as Abstraction } from \"./abstractions/WriteEntry.js\";\nimport { BuildSyncRecord } from \"./abstractions/BuildSyncRecord.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\nimport type { ISyncRow } from \"~/types.js\";\n\nclass WriteEntryImpl 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 rows: ISyncRow[] = [\n await this.buildSyncRecord.execute({ ...params, kind: \"latest\" })\n ];\n\n if (params.entry.status === \"published\") {\n rows.push(await this.buildSyncRecord.execute({ ...params, kind: \"published\" }));\n }\n\n await this.syncRowQuery.create().insert(rows).onConflict(\"id\").merge();\n }\n}\n\nexport const WriteEntry = Abstraction.createImplementation({\n implementation: WriteEntryImpl,\n dependencies: [BuildSyncRecord, SyncRowQuery]\n});\n"],"names":["WriteEntryImpl","buildSyncRecord","syncRowQuery","params","rows","WriteEntry","Abstraction","BuildSyncRecord","SyncRowQuery"],"mappings":";;;AAMA,MAAMA;IACF,YACqBC,eAA0C,EAC1CC,YAAoC,CACvD;aAFmBD,eAAe,GAAfA;aACAC,YAAY,GAAZA;IAClB;IAEH,MAAa,QAAmDC,MAA6B,EAAE;QAC3F,MAAMC,OAAmB;YACrB,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;gBAAE,GAAGD,MAAM;gBAAE,MAAM;YAAS;SAClE;QAED,IAAIA,AAAwB,gBAAxBA,OAAO,KAAK,CAAC,MAAM,EACnBC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC;YAAE,GAAGD,MAAM;YAAE,MAAM;QAAY;QAGhF,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,MAAM,CAACC,MAAM,UAAU,CAAC,MAAM,KAAK;IACxE;AACJ;AAEO,MAAMC,wBAAaC,WAAAA,oBAAgC,CAAC;IACvD,gBAAgBN;IAChB,cAAc;QAACO;QAAiBC;KAAa;AACjD"}
@@ -0,0 +1,14 @@
1
+ import type { CmsEntryValues } from "@webiny/api-headless-cms/types/index.js";
2
+ import { WriteLatest as Abstraction } from "./abstractions/WriteLatest.js";
3
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
4
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
5
+ declare class WriteLatestImpl implements Abstraction.Interface {
6
+ private readonly buildSyncRecord;
7
+ private readonly syncRowQuery;
8
+ constructor(buildSyncRecord: BuildSyncRecord.Interface, syncRowQuery: SyncRowQuery.Interface);
9
+ execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>): Promise<void>;
10
+ }
11
+ export declare const WriteLatest: typeof WriteLatestImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/WriteLatest.js").IWriteLatest>;
13
+ };
14
+ export {};
@@ -0,0 +1,26 @@
1
+ import { WriteLatest } from "./abstractions/WriteLatest.js";
2
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
3
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
4
+ class WriteLatestImpl {
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: "latest"
13
+ });
14
+ await this.syncRowQuery.create().insert(row).onConflict("id").merge();
15
+ }
16
+ }
17
+ const WriteLatest_WriteLatest = WriteLatest.createImplementation({
18
+ implementation: WriteLatestImpl,
19
+ dependencies: [
20
+ BuildSyncRecord,
21
+ SyncRowQuery
22
+ ]
23
+ });
24
+ export { WriteLatest_WriteLatest as WriteLatest };
25
+
26
+ //# sourceMappingURL=WriteLatest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/SyncWriter/WriteLatest.js","sources":["../../../src/features/SyncWriter/WriteLatest.ts"],"sourcesContent":["import type { CmsEntryValues } from \"@webiny/api-headless-cms/types/index.js\";\nimport { WriteLatest as Abstraction } from \"./abstractions/WriteLatest.js\";\nimport { BuildSyncRecord } from \"./abstractions/BuildSyncRecord.js\";\nimport { SyncRowQuery } from \"./abstractions/SyncRowQuery.js\";\n\nclass WriteLatestImpl 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: \"latest\" });\n await this.syncRowQuery.create().insert(row).onConflict(\"id\").merge();\n }\n}\n\nexport const WriteLatest = Abstraction.createImplementation({\n implementation: WriteLatestImpl,\n dependencies: [BuildSyncRecord, SyncRowQuery]\n});\n"],"names":["WriteLatestImpl","buildSyncRecord","syncRowQuery","params","row","WriteLatest","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;QAAS;QAC3E,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,MAAM,CAACC,KAAK,UAAU,CAAC,MAAM,KAAK;IACvE;AACJ;AAEO,MAAMC,0BAAcC,YAAAA,oBAAgC,CAAC;IACxD,gBAAgBN;IAChB,cAAc;QAACO;QAAiBC;KAAa;AACjD"}
@@ -0,0 +1,14 @@
1
+ import type { CmsEntryValues } from "@webiny/api-headless-cms/types/index.js";
2
+ import { WritePublished as Abstraction } from "./abstractions/WritePublished.js";
3
+ import { BuildSyncRecord } from "./abstractions/BuildSyncRecord.js";
4
+ import { SyncRowQuery } from "./abstractions/SyncRowQuery.js";
5
+ declare class WritePublishedImpl implements Abstraction.Interface {
6
+ private readonly buildSyncRecord;
7
+ private readonly syncRowQuery;
8
+ constructor(buildSyncRecord: BuildSyncRecord.Interface, syncRowQuery: SyncRowQuery.Interface);
9
+ execute<T extends CmsEntryValues = CmsEntryValues>(params: Abstraction.Params<T>): Promise<void>;
10
+ }
11
+ export declare const WritePublished: typeof WritePublishedImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions/WritePublished.js").IWritePublished>;
13
+ };
14
+ export {};
@@ -0,0 +1,26 @@
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("id").merge();
15
+ }
16
+ }
17
+ const WritePublished_WritePublished = WritePublished.createImplementation({
18
+ implementation: WritePublishedImpl,
19
+ dependencies: [
20
+ BuildSyncRecord,
21
+ SyncRowQuery
22
+ ]
23
+ });
24
+ export { WritePublished_WritePublished as WritePublished };
25
+
26
+ //# sourceMappingURL=WritePublished.js.map