meadow-integration 1.0.5 → 1.0.7

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 (67) hide show
  1. package/.dockerignore +11 -0
  2. package/Docker-Build.sh +2 -0
  3. package/Docker-Compose.sh +2 -0
  4. package/Docker-Push.sh +2 -0
  5. package/Docker-Tag.sh +2 -0
  6. package/Dockerfile +28 -0
  7. package/Dockerfile_LUXURYCode +23 -0
  8. package/README.md +139 -25
  9. package/docker-compose.yml +16 -0
  10. package/docs/README.md +65 -18
  11. package/docs/_cover.md +3 -2
  12. package/docs/_sidebar.md +52 -7
  13. package/docs/_topbar.md +2 -0
  14. package/docs/api/clone-rest-client.md +278 -0
  15. package/docs/api/connection-manager.md +179 -0
  16. package/docs/api/guid-map.md +234 -0
  17. package/docs/api/integration-adapter.md +283 -0
  18. package/docs/api/operation.md +241 -0
  19. package/docs/api/sync-entity-initial.md +227 -0
  20. package/docs/api/sync-entity-ongoing.md +244 -0
  21. package/docs/api/sync.md +213 -0
  22. package/docs/api/tabular-check.md +213 -0
  23. package/docs/api/tabular-transform.md +316 -0
  24. package/docs/architecture.md +423 -0
  25. package/docs/cli/comprehensionarray.md +111 -0
  26. package/docs/cli/comprehensionintersect.md +132 -0
  27. package/docs/cli/csvcheck.md +111 -0
  28. package/docs/cli/csvtransform.md +170 -0
  29. package/docs/cli/data-clone.md +277 -0
  30. package/docs/cli/jsonarraytransform.md +166 -0
  31. package/docs/cli/load-comprehension.md +129 -0
  32. package/docs/cli/objectarraytocsv.md +159 -0
  33. package/docs/cli/overview.md +96 -0
  34. package/docs/cli/serve.md +102 -0
  35. package/docs/cli/tsvtransform.md +144 -0
  36. package/docs/data-clone/configuration.md +357 -0
  37. package/docs/data-clone/connection-manager.md +206 -0
  38. package/docs/data-clone/docker.md +290 -0
  39. package/docs/data-clone/overview.md +173 -0
  40. package/docs/data-clone/sync-modes.md +186 -0
  41. package/docs/implementation-reference.md +311 -0
  42. package/docs/overview.md +156 -0
  43. package/docs/quickstart.md +233 -0
  44. package/docs/rest/comprehension-push.md +209 -0
  45. package/docs/rest/comprehension.md +506 -0
  46. package/docs/rest/csv.md +255 -0
  47. package/docs/rest/entity-generation.md +158 -0
  48. package/docs/rest/json-array.md +243 -0
  49. package/docs/rest/overview.md +120 -0
  50. package/docs/rest/status.md +63 -0
  51. package/docs/rest/tsv.md +241 -0
  52. package/docs/retold-catalog.json +93 -3
  53. package/docs/retold-keyword-index.json +23683 -1901
  54. package/package.json +6 -3
  55. package/scripts/run.sh +18 -0
  56. package/source/Meadow-Integration.js +15 -1
  57. package/source/cli/Default-Meadow-Integration-Configuration.json +37 -2
  58. package/source/cli/Meadow-Integration-CLI-Program.js +4 -1
  59. package/source/cli/commands/Meadow-Integration-Command-DataClone.js +284 -0
  60. package/source/services/clone/Meadow-Service-ConnectionManager.js +251 -0
  61. package/source/services/clone/Meadow-Service-Operation.js +196 -0
  62. package/source/services/clone/Meadow-Service-RestClient.js +364 -0
  63. package/source/services/clone/Meadow-Service-Sync-Entity-Initial.js +502 -0
  64. package/source/services/clone/Meadow-Service-Sync-Entity-Ongoing.js +592 -0
  65. package/source/services/clone/Meadow-Service-Sync.js +154 -0
  66. /package/docs/examples/bookstore/{mapping_books_Author.json → mapping_books_author.json} +0 -0
  67. /package/docs/examples/bookstore/{mapping_books_Book.json → mapping_books_book.json} +0 -0
@@ -0,0 +1,154 @@
1
+ const libFableServiceProviderBase = require('fable-serviceproviderbase');
2
+ const libMeadowSyncEntityInitial = require('./Meadow-Service-Sync-Entity-Initial.js');
3
+ const libMeadowSyncEntityOngoing = require('./Meadow-Service-Sync-Entity-Ongoing.js');
4
+
5
+ class MeadowSync extends libFableServiceProviderBase
6
+ {
7
+ constructor(pFable, pOptions, pServiceHash)
8
+ {
9
+ super(pFable, pOptions, pServiceHash);
10
+
11
+ this.serviceType = 'MeadowSync';
12
+
13
+ if (!this.fable.ServiceManager.servicesMap.hasOwnProperty('MeadowSyncEntityInitial'))
14
+ {
15
+ this.fable.ServiceManager.addServiceType('MeadowSyncEntityInitial', libMeadowSyncEntityInitial);
16
+ }
17
+
18
+ if (!this.fable.ServiceManager.servicesMap.hasOwnProperty('MeadowSyncEntityOngoing'))
19
+ {
20
+ this.fable.ServiceManager.addServiceType('MeadowSyncEntityOngoing', libMeadowSyncEntityOngoing);
21
+ }
22
+
23
+ // If this is empty, we will sync everything in the loaded Schema.
24
+ // Otherwise, we will go through this list and sync them in this order.
25
+ this.SyncEntityList = [];
26
+ if (this.fable.ProgramConfiguration.hasOwnProperty('SyncEntityList') && Array.isArray(this.fable.ProgramConfiguration.SyncEntityList))
27
+ {
28
+ this.SyncEntityList = JSON.parse(JSON.stringify(this.fable.ProgramConfiguration.SyncEntityList));
29
+ }
30
+ else if (this.options.hasOwnProperty('SyncEntityList') && Array.isArray(this.options.SyncEntityList))
31
+ {
32
+ this.SyncEntityList = JSON.parse(JSON.stringify(this.options.SyncEntityList));
33
+ }
34
+
35
+ // Per-entity sync options.
36
+ this.SyncEntityOptions = {};
37
+ if (this.fable.ProgramConfiguration.hasOwnProperty('SyncEntityOptions') && typeof(this.fable.ProgramConfiguration.SyncEntityOptions) == 'object')
38
+ {
39
+ this.SyncEntityOptions = JSON.parse(JSON.stringify(this.fable.ProgramConfiguration.SyncEntityOptions));
40
+ }
41
+ else if (this.options.hasOwnProperty('SyncEntityOptions') && typeof(this.options.SyncEntityOptions) == 'object')
42
+ {
43
+ this.SyncEntityOptions = JSON.parse(JSON.stringify(this.options.SyncEntityOptions));
44
+ }
45
+
46
+ // When true, after syncing active records, also sync records marked Deleted=1 on the source.
47
+ this.SyncDeletedRecords = false;
48
+ if (this.fable.ProgramConfiguration.hasOwnProperty('SyncDeletedRecords'))
49
+ {
50
+ this.SyncDeletedRecords = !!this.fable.ProgramConfiguration.SyncDeletedRecords;
51
+ }
52
+ else if (this.options.hasOwnProperty('SyncDeletedRecords'))
53
+ {
54
+ this.SyncDeletedRecords = !!this.options.SyncDeletedRecords;
55
+ }
56
+
57
+ this.MeadowSchema = false;
58
+ this.MeadowSchemaTableList = false;
59
+
60
+ this.MeadowSyncEntities = {};
61
+
62
+ this.SyncMode = 'Initial';
63
+
64
+ this.fable._MeadowPrototype = require('meadow');
65
+ this.fable.Meadow = this.fable._MeadowPrototype.new(this.fable, 'MeadowSync-Prototype');
66
+ }
67
+
68
+ loadMeadowSchema(pSchema, fCallback)
69
+ {
70
+ this.meadowSchema = pSchema;
71
+ this.MeadowSchemaTableList = Object.keys(this.meadowSchema.Tables);
72
+
73
+ this.fable.Utility.eachLimit(this.MeadowSchemaTableList, 1,
74
+ (pEntitySchemaName, fSyncInitializationComplete) =>
75
+ {
76
+ const tmpEntitySchema = this.meadowSchema.Tables[pEntitySchemaName];
77
+ // If this is in the entity list or none is specified, create the sync entity object.
78
+ if (this.SyncEntityList.length < 1 || this.SyncEntityList.indexOf(tmpEntitySchema.TableName) > -1)
79
+ {
80
+ const tmpSyncEntityOptions = {
81
+ MeadowEntitySchema: tmpEntitySchema,
82
+ ConnectionPool: this.options.ConnectionPool,
83
+ PageSize: this.options.PageSize || 100,
84
+ SyncDeletedRecords: this.SyncDeletedRecords,
85
+ };
86
+
87
+ let tmpSyncEntity;
88
+
89
+ if (this.SyncMode == 'Ongoing')
90
+ {
91
+ tmpSyncEntity = this.fable.serviceManager.instantiateServiceProvider('MeadowSyncEntityOngoing', tmpSyncEntityOptions, `SyncEntity-${tmpEntitySchema.TableName}`);
92
+ }
93
+ else
94
+ {
95
+ tmpSyncEntity = this.fable.serviceManager.instantiateServiceProvider('MeadowSyncEntityInitial', tmpSyncEntityOptions, `SyncEntity-${tmpEntitySchema.TableName}`);
96
+ }
97
+
98
+ this.MeadowSyncEntities[tmpEntitySchema.TableName] = tmpSyncEntity;
99
+
100
+ return tmpSyncEntity.initialize(fSyncInitializationComplete);
101
+ }
102
+ else
103
+ {
104
+ return fSyncInitializationComplete();
105
+ }
106
+ },
107
+ (pSyncInitializationError) =>
108
+ {
109
+ if (pSyncInitializationError)
110
+ {
111
+ this.log.error(`MeadowSync Error creating sync objects: ${pSyncInitializationError}`, pSyncInitializationError);
112
+ }
113
+
114
+ this.log.info('Entity sync objects created!');
115
+
116
+ if (this.SyncEntityList.length < 1)
117
+ {
118
+ this.SyncEntityList = Object.keys(this.MeadowSyncEntities);
119
+ }
120
+
121
+ return fCallback(pSyncInitializationError);
122
+ });
123
+ }
124
+
125
+ syncEntity(pEntityHash, fCallback)
126
+ {
127
+ if (!this.MeadowSyncEntities.hasOwnProperty(pEntityHash))
128
+ {
129
+ this.log.warn(`MeadowSync.syncEntity called for an entity that does not exist: ${pEntityHash}`);
130
+ return fCallback();
131
+ }
132
+ this.MeadowSyncEntities[pEntityHash].sync(fCallback);
133
+ }
134
+
135
+ syncAll(fCallback)
136
+ {
137
+ this.fable.Utility.eachLimit(this.SyncEntityList, 1,
138
+ (pEntityHash, fSyncEntityComplete) =>
139
+ {
140
+ this.syncEntity(pEntityHash, fSyncEntityComplete);
141
+ },
142
+ (pSyncError) =>
143
+ {
144
+ if (pSyncError)
145
+ {
146
+ this.log.error(`MeadowSync Error syncing entities: ${pSyncError}`, pSyncError);
147
+ }
148
+ this.log.info('Entity sync complete!');
149
+ return fCallback(pSyncError);
150
+ });
151
+ }
152
+ }
153
+
154
+ module.exports = MeadowSync;