infrahub-server 1.2.10__py3-none-any.whl → 1.3.0a0__py3-none-any.whl

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 (134) hide show
  1. infrahub/actions/constants.py +86 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +241 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +382 -0
  6. infrahub/actions/tasks.py +126 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/cli/db.py +1 -2
  9. infrahub/config.py +9 -0
  10. infrahub/core/account.py +24 -47
  11. infrahub/core/attribute.py +10 -12
  12. infrahub/core/constants/infrahubkind.py +8 -0
  13. infrahub/core/constraint/node/runner.py +1 -1
  14. infrahub/core/convert_object_type/__init__.py +0 -0
  15. infrahub/core/convert_object_type/conversion.py +122 -0
  16. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  17. infrahub/core/diff/query/all_conflicts.py +1 -5
  18. infrahub/core/diff/query/artifact.py +10 -20
  19. infrahub/core/diff/query/diff_get.py +3 -6
  20. infrahub/core/diff/query/field_summary.py +2 -4
  21. infrahub/core/diff/query/merge.py +70 -123
  22. infrahub/core/diff/query/save.py +20 -32
  23. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  24. infrahub/core/diff/query_parser.py +5 -1
  25. infrahub/core/diff/tasks.py +3 -3
  26. infrahub/core/manager.py +14 -11
  27. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  28. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -4
  29. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  30. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  31. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  32. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  33. infrahub/core/migrations/query/attribute_add.py +1 -2
  34. infrahub/core/migrations/query/attribute_rename.py +3 -6
  35. infrahub/core/migrations/query/delete_element_in_schema.py +3 -6
  36. infrahub/core/migrations/query/node_duplicate.py +3 -6
  37. infrahub/core/migrations/query/relationship_duplicate.py +3 -6
  38. infrahub/core/migrations/schema/node_attribute_remove.py +3 -6
  39. infrahub/core/migrations/schema/node_remove.py +3 -6
  40. infrahub/core/models.py +29 -2
  41. infrahub/core/node/__init__.py +18 -4
  42. infrahub/core/node/create.py +211 -0
  43. infrahub/core/protocols.py +51 -0
  44. infrahub/core/protocols_base.py +3 -0
  45. infrahub/core/query/__init__.py +2 -2
  46. infrahub/core/query/diff.py +26 -32
  47. infrahub/core/query/ipam.py +10 -20
  48. infrahub/core/query/node.py +28 -46
  49. infrahub/core/query/relationship.py +51 -28
  50. infrahub/core/query/resource_manager.py +1 -2
  51. infrahub/core/query/subquery.py +2 -4
  52. infrahub/core/relationship/model.py +3 -0
  53. infrahub/core/schema/__init__.py +2 -1
  54. infrahub/core/schema/attribute_parameters.py +36 -0
  55. infrahub/core/schema/attribute_schema.py +83 -8
  56. infrahub/core/schema/basenode_schema.py +25 -1
  57. infrahub/core/schema/definitions/core/__init__.py +21 -0
  58. infrahub/core/schema/definitions/internal.py +13 -3
  59. infrahub/core/schema/generated/attribute_schema.py +9 -3
  60. infrahub/core/schema/schema_branch.py +12 -7
  61. infrahub/core/validators/__init__.py +5 -1
  62. infrahub/core/validators/attribute/choices.py +1 -2
  63. infrahub/core/validators/attribute/enum.py +1 -2
  64. infrahub/core/validators/attribute/kind.py +1 -2
  65. infrahub/core/validators/attribute/length.py +13 -6
  66. infrahub/core/validators/attribute/optional.py +1 -2
  67. infrahub/core/validators/attribute/regex.py +5 -5
  68. infrahub/core/validators/attribute/unique.py +1 -3
  69. infrahub/core/validators/determiner.py +18 -2
  70. infrahub/core/validators/enum.py +7 -0
  71. infrahub/core/validators/node/hierarchy.py +3 -6
  72. infrahub/core/validators/query.py +1 -3
  73. infrahub/core/validators/relationship/count.py +6 -12
  74. infrahub/core/validators/relationship/optional.py +2 -4
  75. infrahub/core/validators/relationship/peer.py +3 -8
  76. infrahub/core/validators/tasks.py +1 -1
  77. infrahub/core/validators/uniqueness/query.py +5 -9
  78. infrahub/database/__init__.py +1 -3
  79. infrahub/events/group_action.py +1 -0
  80. infrahub/graphql/analyzer.py +139 -18
  81. infrahub/graphql/app.py +1 -1
  82. infrahub/graphql/loaders/node.py +1 -1
  83. infrahub/graphql/loaders/peers.py +1 -1
  84. infrahub/graphql/manager.py +4 -0
  85. infrahub/graphql/mutations/action.py +164 -0
  86. infrahub/graphql/mutations/convert_object_type.py +62 -0
  87. infrahub/graphql/mutations/main.py +24 -175
  88. infrahub/graphql/mutations/proposed_change.py +21 -18
  89. infrahub/graphql/queries/convert_object_type_mapping.py +36 -0
  90. infrahub/graphql/queries/relationship.py +1 -1
  91. infrahub/graphql/resolvers/many_relationship.py +4 -4
  92. infrahub/graphql/resolvers/resolver.py +4 -4
  93. infrahub/graphql/resolvers/single_relationship.py +2 -2
  94. infrahub/graphql/schema.py +6 -0
  95. infrahub/graphql/subscription/graphql_query.py +2 -2
  96. infrahub/graphql/types/branch.py +1 -1
  97. infrahub/menu/menu.py +31 -0
  98. infrahub/message_bus/messages/__init__.py +0 -10
  99. infrahub/message_bus/operations/__init__.py +0 -8
  100. infrahub/message_bus/operations/refresh/registry.py +1 -1
  101. infrahub/patch/queries/consolidate_duplicated_nodes.py +3 -6
  102. infrahub/patch/queries/delete_duplicated_edges.py +5 -10
  103. infrahub/prefect_server/models.py +1 -19
  104. infrahub/proposed_change/models.py +68 -3
  105. infrahub/proposed_change/tasks.py +907 -30
  106. infrahub/task_manager/models.py +10 -6
  107. infrahub/telemetry/database.py +1 -1
  108. infrahub/telemetry/tasks.py +1 -1
  109. infrahub/trigger/catalogue.py +2 -0
  110. infrahub/trigger/models.py +18 -2
  111. infrahub/trigger/tasks.py +3 -1
  112. infrahub/workflows/catalogue.py +76 -0
  113. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/METADATA +2 -2
  114. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/RECORD +121 -118
  115. infrahub_testcontainers/container.py +0 -1
  116. infrahub_testcontainers/docker-compose.test.yml +1 -1
  117. infrahub_testcontainers/helpers.py +8 -2
  118. infrahub/message_bus/messages/check_generator_run.py +0 -26
  119. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  120. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  121. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  122. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  123. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  124. infrahub/message_bus/operations/check/__init__.py +0 -3
  125. infrahub/message_bus/operations/check/generator.py +0 -156
  126. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  127. infrahub/message_bus/operations/finalize/validator.py +0 -133
  128. infrahub/message_bus/operations/requests/__init__.py +0 -9
  129. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  130. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  131. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  132. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/LICENSE.txt +0 -0
  133. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/WHEEL +0 -0
  134. {infrahub_server-1.2.10.dist-info → infrahub_server-1.3.0a0.dist-info}/entry_points.txt +0 -0
@@ -45,8 +45,7 @@ class EnrichedDiffNodeFieldSummaryQuery(Query):
45
45
  OPTIONAL MATCH (diff_root)-[:DIFF_HAS_NODE]->(n:DiffNode)
46
46
  WHERE n.action <> $unchanged_str
47
47
  WITH DISTINCT n.kind AS kind
48
- CALL {
49
- WITH kind
48
+ CALL (kind) {
50
49
  OPTIONAL MATCH (n:DiffNode {kind: kind})-[:DIFF_HAS_ATTRIBUTE]->(a:DiffAttribute)
51
50
  WHERE n.action <> $unchanged_str
52
51
  AND a.action <> $unchanged_str
@@ -54,8 +53,7 @@ class EnrichedDiffNodeFieldSummaryQuery(Query):
54
53
  RETURN collect(attr_name) AS attr_names
55
54
  }
56
55
  WITH kind, attr_names
57
- CALL {
58
- WITH kind
56
+ CALL (kind) {
59
57
  OPTIONAL MATCH (n:DiffNode {kind: kind})-[:DIFF_HAS_RELATIONSHIP]->(r:DiffRelationship)
60
58
  WHERE n.action <> $unchanged_str
61
59
  AND r.action <> $unchanged_str
@@ -49,27 +49,24 @@ WITH node_diff_map, is_node_kind_migration, CASE
49
49
  WHEN is_node_kind_migration THEN $migrated_kinds_id_map[node_diff_map.uuid]
50
50
  ELSE NULL
51
51
  END AS node_db_id
52
- CALL {
53
- WITH node_diff_map, node_db_id
52
+ CALL (node_diff_map, node_db_id) {
54
53
  MATCH (n:Node {uuid: node_diff_map.uuid})
55
54
  WHERE node_db_id IS NULL
56
55
  OR %(id_func)s(n) = node_db_id
57
56
  RETURN n
58
57
  }
59
58
  WITH n, node_diff_map, is_node_kind_migration
60
- CALL {
61
- WITH n, node_diff_map, is_node_kind_migration
62
- WITH n, node_diff_map, is_node_kind_migration, CASE
59
+ CALL (n, node_diff_map, is_node_kind_migration) {
60
+ WITH CASE
63
61
  WHEN node_diff_map.action = "ADDED" THEN "active"
64
62
  WHEN node_diff_map.action = "REMOVED" THEN "deleted"
65
63
  ELSE NULL
66
64
  END AS node_rel_status
67
- CALL {
65
+ CALL (n, node_diff_map, is_node_kind_migration, node_rel_status) {
68
66
  // ------------------------------
69
67
  // only make IS_PART_OF updates if node is ADDED or REMOVED
70
68
  // ------------------------------
71
- WITH n, node_diff_map, node_rel_status, is_node_kind_migration
72
- WITH n, node_diff_map, node_rel_status, is_node_kind_migration
69
+ WITH node_rel_status
73
70
  WHERE node_rel_status IS NOT NULL
74
71
  // nodes with a migrated kind are handled in DiffMergeMigratedKindsQuery
75
72
  AND is_node_kind_migration = FALSE
@@ -78,8 +75,7 @@ CALL {
78
75
  // set IS_PART_OF.to, optionally, target branch
79
76
  // ------------------------------
80
77
  WITH root, n, node_rel_status
81
- CALL {
82
- WITH root, n, node_rel_status
78
+ CALL (root, n, node_rel_status) {
83
79
  OPTIONAL MATCH (root)<-[target_r_root:IS_PART_OF {branch: $target_branch, status: "active"}]-(n)
84
80
  WHERE node_rel_status = "deleted"
85
81
  AND target_r_root.from <= $at AND target_r_root.to IS NULL
@@ -89,13 +85,12 @@ CALL {
89
85
  // create new IS_PART_OF relationship on target_branch
90
86
  // ------------------------------
91
87
  WITH root, n, node_rel_status
92
- CALL {
93
- WITH root, n, node_rel_status
88
+ CALL (root, n, node_rel_status) {
94
89
  OPTIONAL MATCH (root)<-[r_root:IS_PART_OF {branch: $target_branch}]-(n)
95
90
  WHERE r_root.status = node_rel_status
96
91
  AND r_root.from <= $at
97
92
  AND (r_root.to >= $at OR r_root.to IS NULL)
98
- WITH root, r_root, n, node_rel_status
93
+ WITH r_root
99
94
  WHERE r_root IS NULL
100
95
  CREATE (root)
101
96
  <-[:IS_PART_OF { branch: $target_branch, branch_level: $branch_level, from: $at, status: node_rel_status }]
@@ -104,12 +99,10 @@ CALL {
104
99
  // ------------------------------
105
100
  // shortcut to delete all attributes and relationships for this node if the node is deleted
106
101
  // ------------------------------
107
- CALL {
108
- WITH n, node_rel_status
102
+ CALL (n, node_rel_status) {
109
103
  WITH n, node_rel_status
110
104
  WHERE node_rel_status = "deleted"
111
- CALL {
112
- WITH n
105
+ CALL (n) {
113
106
  OPTIONAL MATCH (n)-[rel1:IS_RELATED]-(:Relationship)-[rel2]-(p)
114
107
  WHERE (p.uuid IS NULL OR n.uuid <> p.uuid)
115
108
  AND rel1.branch = $target_branch
@@ -118,7 +111,6 @@ CALL {
118
111
  AND rel2.status = "active"
119
112
  RETURN rel1, rel2
120
113
  UNION
121
- WITH n
122
114
  OPTIONAL MATCH (n)-[rel1:HAS_ATTRIBUTE]->(:Attribute)-[rel2]->()
123
115
  WHERE type(rel2) <> "HAS_ATTRIBUTE"
124
116
  AND rel1.branch = $target_branch
@@ -127,7 +119,7 @@ CALL {
127
119
  AND rel2.status = "active"
128
120
  RETURN rel1, rel2
129
121
  }
130
- WITH n, rel1, rel2
122
+ WITH rel1, rel2
131
123
  WHERE rel1.to IS NULL
132
124
  AND rel2.to IS NULL
133
125
  AND rel1.from <= $at
@@ -138,10 +130,8 @@ CALL {
138
130
  // and delete HAS_OWNER and HAS_SOURCE edges to this node if the node is deleted
139
131
  // ------------------------------
140
132
  WITH n
141
- CALL {
142
- WITH n
143
- CALL {
144
- WITH n
133
+ CALL (n) {
134
+ CALL (n) {
145
135
  MATCH (n)<-[rel:HAS_OWNER]-()
146
136
  WHERE rel.branch = $target_branch
147
137
  AND rel.status = "active"
@@ -161,9 +151,8 @@ CALL {
161
151
  }
162
152
  }
163
153
  WITH n, node_diff_map
164
- CALL {
165
- WITH n, node_diff_map
166
- WITH n, CASE
154
+ CALL (n, node_diff_map) {
155
+ WITH CASE
167
156
  WHEN node_diff_map.attributes IS NULL OR node_diff_map.attributes = [] THEN [NULL]
168
157
  ELSE node_diff_map.attributes
169
158
  END AS attribute_maps
@@ -171,15 +160,13 @@ CALL {
171
160
  // ------------------------------
172
161
  // handle updates for attributes under this node
173
162
  // ------------------------------
174
- CALL {
175
- WITH n, attribute_diff_map
176
- WITH n, attribute_diff_map.name AS attr_name, CASE
163
+ CALL (n, attribute_diff_map) {
164
+ WITH attribute_diff_map.name AS attr_name, CASE
177
165
  WHEN attribute_diff_map.action = "ADDED" THEN "active"
178
166
  WHEN attribute_diff_map.action = "REMOVED" THEN "deleted"
179
167
  ELSE NULL
180
168
  END AS attr_rel_status
181
- CALL {
182
- WITH n, attr_name
169
+ CALL (n, attr_name) {
183
170
  OPTIONAL MATCH (n)-[has_attr:HAS_ATTRIBUTE]->(a:Attribute {name: attr_name})
184
171
  WHERE has_attr.branch IN [$source_branch, $target_branch]
185
172
  RETURN a
@@ -190,8 +177,7 @@ CALL {
190
177
  // ------------------------------
191
178
  // set HAS_ATTRIBUTE.to on target branch if necessary
192
179
  // ------------------------------
193
- CALL {
194
- WITH n, attr_rel_status, a
180
+ CALL (n, attr_rel_status, a) {
195
181
  OPTIONAL MATCH (n)
196
182
  -[target_r_attr:HAS_ATTRIBUTE {branch: $target_branch, status: "active"}]
197
183
  ->(a)
@@ -203,15 +189,14 @@ CALL {
203
189
  // ------------------------------
204
190
  // conditionally create new HAS_ATTRIBUTE relationship on target_branch, if necessary
205
191
  // ------------------------------
206
- CALL {
207
- WITH n, attr_rel_status, a
192
+ CALL (n, attr_rel_status, a) {
208
193
  WITH n, attr_rel_status, a
209
194
  WHERE a IS NOT NULL
210
195
  OPTIONAL MATCH (n)-[r_attr:HAS_ATTRIBUTE {branch: $target_branch}]->(a)
211
196
  WHERE r_attr.status = attr_rel_status
212
197
  AND r_attr.from <= $at
213
198
  AND (r_attr.to >= $at OR r_attr.to IS NULL)
214
- WITH n, r_attr, attr_rel_status, a
199
+ WITH r_attr
215
200
  WHERE r_attr IS NULL
216
201
  CREATE (n)-[:HAS_ATTRIBUTE { branch: $target_branch, branch_level: $branch_level, from: $at, status: attr_rel_status }]->(a)
217
202
  }
@@ -220,16 +205,14 @@ CALL {
220
205
  RETURN 1 AS done
221
206
  }
222
207
  WITH n, node_diff_map
223
- CALL {
224
- WITH n,node_diff_map
208
+ CALL (n, node_diff_map) {
225
209
  UNWIND node_diff_map.relationships AS relationship_diff_map
226
210
  // ------------------------------
227
211
  // handle updates for relationships under this node
228
212
  // ------------------------------
229
- CALL {
230
- WITH n, relationship_diff_map
213
+ CALL (n, relationship_diff_map) {
231
214
  WITH
232
- n, relationship_diff_map.peer_id AS rel_peer_id, relationship_diff_map.name AS rel_name,
215
+ relationship_diff_map.peer_id AS rel_peer_id, relationship_diff_map.name AS rel_name,
233
216
  CASE
234
217
  WHEN relationship_diff_map.action = "ADDED" THEN "active"
235
218
  WHEN relationship_diff_map.action = "REMOVED" THEN "deleted"
@@ -243,8 +226,7 @@ CALL {
243
226
  // ------------------------------
244
227
  // determine the directions of each IS_RELATED
245
228
  // ------------------------------
246
- CALL {
247
- WITH n, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status
229
+ CALL (n, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status) {
248
230
  MATCH (n)
249
231
  -[source_r_rel_1:IS_RELATED]
250
232
  -(r:Relationship {name: rel_name})
@@ -255,7 +237,7 @@ CALL {
255
237
  AND source_r_rel_2.branch IN [$source_branch, $target_branch]
256
238
  AND source_r_rel_1.from <= $at AND source_r_rel_1.to IS NULL
257
239
  AND source_r_rel_2.from <= $at AND source_r_rel_2.to IS NULL
258
- WITH n, rel_name, rel_peer_id, related_rel_status, r, source_r_rel_1, source_r_rel_2
240
+ WITH r, source_r_rel_1, source_r_rel_2
259
241
  ORDER BY source_r_rel_1.branch_level DESC, source_r_rel_2.branch_level DESC, source_r_rel_1.from DESC, source_r_rel_2.from DESC
260
242
  LIMIT 1
261
243
  RETURN r, CASE
@@ -270,8 +252,7 @@ CALL {
270
252
  source_r_rel_2.hierarchy AS r2_hierarchy
271
253
  }
272
254
  WITH n, r, r1_dir, r2_dir, r1_hierarchy, r2_hierarchy, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status
273
- CALL {
274
- WITH n, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status
255
+ CALL (n, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status) {
275
256
  OPTIONAL MATCH (n)
276
257
  -[target_r_rel_1:IS_RELATED {branch: $target_branch, status: "active"}]
277
258
  -(:Relationship {name: rel_name})
@@ -288,8 +269,7 @@ CALL {
288
269
  // ------------------------------
289
270
  // conditionally create new IS_RELATED relationships on target_branch, if necessary
290
271
  // ------------------------------
291
- CALL {
292
- WITH n, r, r1_dir, r2_dir, r1_hierarchy, r2_hierarchy, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status
272
+ CALL (n, r, r1_dir, r2_dir, r1_hierarchy, r2_hierarchy, rel_name, rel_peer_id, rel_peer_db_id, related_rel_status) {
293
273
  MATCH (p:Node {uuid: rel_peer_id})
294
274
  WHERE rel_peer_db_id IS NULL OR %(id_func)s(p) = rel_peer_db_id
295
275
  OPTIONAL MATCH (n)
@@ -301,38 +281,34 @@ CALL {
301
281
  AND (r_rel_1.to >= $at OR r_rel_1.to IS NULL)
302
282
  AND r_rel_2.from <= $at
303
283
  AND (r_rel_2.to >= $at OR r_rel_2.to IS NULL)
304
- WITH n, r, r1_dir, r2_dir, r1_hierarchy, r2_hierarchy, p, related_rel_status, r_rel_1, r_rel_2
284
+ WITH p, r_rel_1, r_rel_2
305
285
  WHERE r_rel_1 IS NULL
306
286
  AND r_rel_2 IS NULL
307
287
  // ------------------------------
308
288
  // create IS_RELATED relationships with directions maintained from source
309
289
  // ------------------------------
310
- CALL {
311
- WITH n, r, r1_dir, r1_hierarchy, related_rel_status
290
+ CALL (n, r, r1_dir, r1_hierarchy, related_rel_status) {
312
291
  WITH n, r, r1_dir, r1_hierarchy, related_rel_status
313
292
  WHERE r1_dir = "r"
314
293
  CREATE (n)
315
294
  -[:IS_RELATED {branch: $target_branch, branch_level: $branch_level, from: $at, status: related_rel_status, hierarchy: r1_hierarchy}]
316
295
  ->(r)
317
296
  }
318
- CALL {
319
- WITH n, r, r1_dir, r1_hierarchy, related_rel_status
297
+ CALL (n, r, r1_dir, r1_hierarchy, related_rel_status) {
320
298
  WITH n, r, r1_dir, r1_hierarchy, related_rel_status
321
299
  WHERE r1_dir = "l"
322
300
  CREATE (n)
323
301
  <-[:IS_RELATED {branch: $target_branch, branch_level: $branch_level, from: $at, status: related_rel_status, hierarchy: r1_hierarchy}]
324
302
  -(r)
325
303
  }
326
- CALL {
327
- WITH r, p, r2_dir, r2_hierarchy, related_rel_status
304
+ CALL (r, p, r2_dir, r2_hierarchy, related_rel_status) {
328
305
  WITH r, p, r2_dir, r2_hierarchy, related_rel_status
329
306
  WHERE r2_dir = "r"
330
307
  CREATE (r)
331
308
  -[:IS_RELATED {branch: $target_branch, branch_level: $branch_level, from: $at, status: related_rel_status, hierarchy: r2_hierarchy}]
332
309
  ->(p)
333
310
  }
334
- CALL {
335
- WITH r, p, r2_dir, r2_hierarchy, related_rel_status
311
+ CALL (r, p, r2_dir, r2_hierarchy, related_rel_status) {
336
312
  WITH r, p, r2_dir, r2_hierarchy, related_rel_status
337
313
  WHERE r2_dir = "l"
338
314
  CREATE (r)
@@ -390,13 +366,11 @@ CASE
390
366
  WHEN attr_rel_prop_diff.peer_uuid IN $migrated_kinds_uuids THEN $migrated_kinds_id_map[attr_rel_prop_diff.peer_uuid]
391
367
  ELSE NULL
392
368
  END AS peer_db_id
393
- CALL {
369
+ CALL (attr_rel_prop_diff, node_db_id, peer_db_id) {
394
370
  // ------------------------------
395
371
  // find the Attribute node
396
372
  // ------------------------------
397
- WITH attr_rel_prop_diff, node_db_id, peer_db_id
398
- CALL {
399
- WITH attr_rel_prop_diff, node_db_id
373
+ CALL (attr_rel_prop_diff, node_db_id) {
400
374
  OPTIONAL MATCH (n:Node {uuid: attr_rel_prop_diff.node_uuid})
401
375
  -[has_attr:HAS_ATTRIBUTE]
402
376
  ->(attr:Attribute {name: attr_rel_prop_diff.attribute_name})
@@ -407,8 +381,7 @@ CALL {
407
381
  ORDER BY has_attr.from DESC
408
382
  LIMIT 1
409
383
  }
410
- CALL {
411
- WITH attr_rel_prop_diff, node_db_id, peer_db_id
384
+ CALL (attr_rel_prop_diff, node_db_id, peer_db_id) {
412
385
  OPTIONAL MATCH (n:Node {uuid: attr_rel_prop_diff.node_uuid})
413
386
  -[r1:IS_RELATED]
414
387
  -(rel:Relationship {name: attr_rel_prop_diff.relationship_id})
@@ -429,13 +402,11 @@ CALL {
429
402
  // ------------------------------
430
403
  // handle updates for properties under this attribute/relationship
431
404
  // ------------------------------
432
- CALL {
433
- WITH attr_rel, property_diff, peer_db_id
405
+ CALL (attr_rel, property_diff, peer_db_id) {
434
406
  // ------------------------------
435
407
  // identify the correct property node to link
436
408
  // ------------------------------
437
- CALL {
438
- WITH attr_rel, property_diff, peer_db_id
409
+ CALL (attr_rel, property_diff, peer_db_id) {
439
410
  OPTIONAL MATCH (peer:Node {uuid: property_diff.value})
440
411
  WHERE property_diff.property_type IN ["HAS_SOURCE", "HAS_OWNER"]
441
412
  AND (peer_db_id IS NULL OR %(id_func)s(peer) = peer_db_id)
@@ -443,8 +414,7 @@ CALL {
443
414
  // the serialized diff might not include the values for IS_VISIBLE and IS_PROTECTED in
444
415
  // some cases, so we need to figure them out here
445
416
  // ------------------------------
446
- CALL {
447
- WITH attr_rel, property_diff
417
+ CALL (attr_rel, property_diff) {
448
418
  OPTIONAL MATCH (attr_rel)-[r_vis_pro]->(bool:Boolean)
449
419
  WHERE property_diff.property_type IN ["IS_VISIBLE", "IS_PROTECTED"]
450
420
  AND r_vis_pro.branch IN [$source_branch, $target_branch]
@@ -454,12 +424,11 @@ CALL {
454
424
  ORDER BY r_vis_pro.from DESC
455
425
  LIMIT 1
456
426
  }
457
- CALL {
427
+ CALL (attr_rel, property_diff) {
458
428
  // ------------------------------
459
429
  // get the latest linked AttributeValue on the source b/c there could be multiple
460
430
  // with different is_default values
461
431
  // ------------------------------
462
- WITH attr_rel, property_diff
463
432
  OPTIONAL MATCH (attr_rel)-[r_attr_val:HAS_VALUE]->(av:AttributeValue)
464
433
  WHERE property_diff.property_type = "HAS_VALUE"
465
434
  AND (
@@ -473,7 +442,7 @@ CALL {
473
442
  }
474
443
  RETURN COALESCE (peer, bool, av) AS prop_node
475
444
  }
476
- WITH attr_rel, property_diff.property_type AS prop_type, prop_node, CASE
445
+ WITH attr_rel,property_diff.property_type AS prop_type, prop_node, CASE
477
446
  WHEN property_diff.action = "ADDED" THEN "active"
478
447
  WHEN property_diff.action = "REMOVED" THEN "deleted"
479
448
  ELSE NULL
@@ -481,8 +450,7 @@ CALL {
481
450
  // ------------------------------
482
451
  // set property edge.to, optionally, on target branch
483
452
  // ------------------------------
484
- CALL {
485
- WITH attr_rel, prop_rel_status, prop_type
453
+ CALL (attr_rel, prop_rel_status, prop_type) {
486
454
  OPTIONAL MATCH (attr_rel)
487
455
  -[target_r_prop {branch: $target_branch}]
488
456
  ->()
@@ -493,8 +461,7 @@ CALL {
493
461
  // ------------------------------
494
462
  // check for existing edge on target_branch
495
463
  // ------------------------------
496
- CALL {
497
- WITH attr_rel, prop_rel_status, prop_type, prop_node
464
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
498
465
  OPTIONAL MATCH (attr_rel)-[r_prop {branch: $target_branch}]->(prop_node)
499
466
  WHERE type(r_prop) = prop_type
500
467
  AND r_prop.status = prop_rel_status
@@ -502,38 +469,33 @@ CALL {
502
469
  AND (r_prop.to > $at OR r_prop.to IS NULL)
503
470
  RETURN r_prop
504
471
  }
505
- WITH attr_rel, prop_rel_status, prop_type, prop_node, r_prop
472
+ WITH attr_rel,prop_rel_status, prop_type, prop_node, r_prop
506
473
  WHERE r_prop IS NULL
507
474
  // ------------------------------
508
475
  // create new edge to prop_node on target_branch, if necessary
509
476
  // one subquery per possible edge type b/c edge type cannot be a variable
510
477
  // ------------------------------
511
- CALL {
512
- WITH attr_rel, prop_rel_status, prop_type, prop_node
478
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
513
479
  WITH attr_rel, prop_rel_status, prop_type, prop_node
514
480
  WHERE prop_type = "HAS_VALUE"
515
481
  CREATE (attr_rel)-[:HAS_VALUE { branch: $target_branch, branch_level: $branch_level, from: $at, status: prop_rel_status }]->(prop_node)
516
482
  }
517
- CALL {
518
- WITH attr_rel, prop_rel_status, prop_type, prop_node
483
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
519
484
  WITH attr_rel, prop_rel_status, prop_type, prop_node
520
485
  WHERE prop_type = "HAS_SOURCE"
521
486
  CREATE (attr_rel)-[:HAS_SOURCE { branch: $target_branch, branch_level: $branch_level, from: $at, status: prop_rel_status }]->(prop_node)
522
487
  }
523
- CALL {
524
- WITH attr_rel, prop_rel_status, prop_type, prop_node
488
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
525
489
  WITH attr_rel, prop_rel_status, prop_type, prop_node
526
490
  WHERE prop_type = "HAS_OWNER"
527
491
  CREATE (attr_rel)-[:HAS_OWNER { branch: $target_branch, branch_level: $branch_level, from: $at, status: prop_rel_status }]->(prop_node)
528
492
  }
529
- CALL {
530
- WITH attr_rel, prop_rel_status, prop_type, prop_node
493
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
531
494
  WITH attr_rel, prop_rel_status, prop_type, prop_node
532
495
  WHERE prop_type = "IS_VISIBLE"
533
496
  CREATE (attr_rel)-[:IS_VISIBLE { branch: $target_branch, branch_level: $branch_level, from: $at, status: prop_rel_status }]->(prop_node)
534
497
  }
535
- CALL {
536
- WITH attr_rel, prop_rel_status, prop_type, prop_node
498
+ CALL (attr_rel, prop_rel_status, prop_type, prop_node) {
537
499
  WITH attr_rel, prop_rel_status, prop_type, prop_node
538
500
  WHERE prop_type = "IS_PROTECTED"
539
501
  CREATE (attr_rel)-[:IS_PROTECTED { branch: $target_branch, branch_level: $branch_level, from: $at, status: prop_rel_status }]->(prop_node)
@@ -573,19 +535,17 @@ class DiffMergeMigratedKindsQuery(Query):
573
535
  query = """
574
536
  MATCH (n:Node)
575
537
  WHERE n.uuid IN $migrated_uuids
576
- CALL {
538
+ CALL (n) {
577
539
  // --------------
578
540
  // for each migrated node (created or deleted), find its latest edges on the source branch,
579
541
  // check if they exist on the target, create them if not
580
542
  // --------------
581
- WITH n
582
543
  MATCH (n)-[]-(peer)
583
544
  WITH DISTINCT n, peer
584
- CALL {
545
+ CALL (n, peer) {
585
546
  // --------------
586
547
  // get the latest outbound edge for each type between n and peer
587
548
  // --------------
588
- WITH n, peer
589
549
  MATCH (n)-[e {branch: $source_branch}]->(peer)
590
550
  WHERE e.from <= $at AND e.to IS NULL
591
551
  WITH e, type(e) AS edge_type
@@ -593,11 +553,10 @@ CALL {
593
553
  WITH edge_type, head(collect(e)) AS latest_source_edge
594
554
  RETURN edge_type, latest_source_edge
595
555
  }
596
- CALL {
556
+ CALL (n, peer, edge_type) {
597
557
  // --------------
598
558
  // for each n, peer, edge_type, get the latest edge on target
599
559
  // --------------
600
- WITH n, peer, edge_type
601
560
  OPTIONAL MATCH (n)-[e {branch: $target_branch}]->(peer)
602
561
  WHERE type(e) = edge_type AND e.from <= $at
603
562
  RETURN e AS latest_target_edge
@@ -610,13 +569,11 @@ CALL {
610
569
  WITH n, peer, edge_type, latest_source_edge, latest_target_edge
611
570
  WHERE (latest_target_edge IS NULL AND latest_source_edge.status = "active")
612
571
  OR latest_source_edge.status <> latest_target_edge.status
613
- CALL {
572
+ CALL (latest_source_edge, latest_target_edge) {
614
573
  // --------------
615
574
  // set the to time on active target branch edges that we are setting to deleted
616
575
  // --------------
617
- WITH latest_source_edge, latest_target_edge
618
- WITH latest_source_edge, latest_target_edge
619
- WHERE latest_target_edge IS NOT NULL
576
+ WITH latest_target_edge WHERE latest_target_edge IS NOT NULL
620
577
  AND latest_source_edge.status = "deleted"
621
578
  AND latest_target_edge.status = "active"
622
579
  AND latest_target_edge.to IS NULL
@@ -625,19 +582,16 @@ CALL {
625
582
  // --------------
626
583
  // create the outbound edges on the target branch, one subquery per possible type
627
584
  // --------------
628
- CALL {
629
- WITH n, latest_source_edge, peer, edge_type
630
- WITH n, latest_source_edge, peer, edge_type
631
- WHERE edge_type = "IS_PART_OF"
585
+ CALL (n, latest_source_edge, peer, edge_type) {
586
+ WITH edge_type WHERE edge_type = "IS_PART_OF"
632
587
  CREATE (n)-[new_edge:IS_PART_OF]->(peer)
633
588
  SET new_edge = properties(latest_source_edge)
634
589
  SET new_edge.from = $at
635
590
  SET new_edge.branch_level = $branch_level
636
591
  SET new_edge.branch = $target_branch
637
592
  }
638
- CALL {
639
- WITH n, latest_source_edge, peer, edge_type
640
- WITH n, latest_source_edge, peer, edge_type
593
+ CALL (n, latest_source_edge, peer, edge_type) {
594
+ WITH edge_type
641
595
  WHERE edge_type = "IS_RELATED"
642
596
  CREATE (n)-[new_edge:IS_RELATED]->(peer)
643
597
  SET new_edge = properties(latest_source_edge)
@@ -645,9 +599,8 @@ CALL {
645
599
  SET new_edge.branch_level = $branch_level
646
600
  SET new_edge.branch = $target_branch
647
601
  }
648
- CALL {
649
- WITH n, latest_source_edge, peer, edge_type
650
- WITH n, latest_source_edge, peer, edge_type
602
+ CALL (n, latest_source_edge, peer, edge_type) {
603
+ WITH edge_type
651
604
  WHERE edge_type = "HAS_ATTRIBUTE"
652
605
  CREATE (n)-[new_edge:HAS_ATTRIBUTE]->(peer)
653
606
  SET new_edge = properties(latest_source_edge)
@@ -659,11 +612,10 @@ CALL {
659
612
  // do all of this again for inbound edges
660
613
  // --------------
661
614
  WITH DISTINCT n, peer
662
- CALL {
615
+ CALL (n, peer) {
663
616
  // --------------
664
617
  // get the latest inbound edge for each type between n and peer
665
618
  // --------------
666
- WITH n, peer
667
619
  MATCH (n)<-[e {branch: $source_branch}]-(peer)
668
620
  WHERE e.from <= $at AND e.to IS NULL
669
621
  WITH e, type(e) AS edge_type
@@ -671,11 +623,10 @@ CALL {
671
623
  WITH edge_type, head(collect(e)) AS latest_source_edge
672
624
  RETURN edge_type, latest_source_edge
673
625
  }
674
- CALL {
626
+ CALL (n, peer, edge_type) {
675
627
  // --------------
676
628
  // for each n, peer, edge_type, get the latest edge on target
677
629
  // --------------
678
- WITH n, peer, edge_type
679
630
  OPTIONAL MATCH (n)<-[e {branch: $target_branch}]-(peer)
680
631
  WHERE type(e) = edge_type AND e.from <= $at
681
632
  RETURN e AS latest_target_edge
@@ -687,12 +638,11 @@ CALL {
687
638
  // --------------
688
639
  WITH n, peer, edge_type, latest_source_edge, latest_target_edge
689
640
  WHERE latest_target_edge IS NULL OR latest_source_edge.status <> latest_target_edge.status
690
- CALL {
641
+ CALL (latest_source_edge, latest_target_edge) {
691
642
  // --------------
692
643
  // set the to time on active target branch edges that we are setting to deleted
693
644
  // --------------
694
- WITH latest_source_edge, latest_target_edge
695
- WITH latest_source_edge, latest_target_edge
645
+ WITH latest_target_edge
696
646
  WHERE latest_target_edge IS NOT NULL
697
647
  AND latest_source_edge.status = "deleted"
698
648
  AND latest_target_edge.status = "active"
@@ -702,9 +652,8 @@ CALL {
702
652
  // --------------
703
653
  // create the outbound edges on the target branch, one subquery per possible type
704
654
  // --------------
705
- CALL {
706
- WITH n, latest_source_edge, peer, edge_type
707
- WITH n, latest_source_edge, peer, edge_type
655
+ CALL (n, latest_source_edge, peer, edge_type) {
656
+ WITH edge_type
708
657
  WHERE edge_type = "IS_RELATED"
709
658
  CREATE (n)<-[new_edge:IS_RELATED]-(peer)
710
659
  SET new_edge = properties(latest_source_edge)
@@ -712,9 +661,8 @@ CALL {
712
661
  SET new_edge.branch_level = $branch_level
713
662
  SET new_edge.branch = $target_branch
714
663
  }
715
- CALL {
716
- WITH n, latest_source_edge, peer, edge_type
717
- WITH n, latest_source_edge, peer, edge_type
664
+ CALL (n, latest_source_edge, peer, edge_type) {
665
+ WITH edge_type
718
666
  WHERE edge_type = "HAS_OWNER"
719
667
  CREATE (n)<-[new_edge:HAS_OWNER]-(peer)
720
668
  SET new_edge = properties(latest_source_edge)
@@ -722,9 +670,8 @@ CALL {
722
670
  SET new_edge.branch_level = $branch_level
723
671
  SET new_edge.branch = $target_branch
724
672
  }
725
- CALL {
726
- WITH n, latest_source_edge, peer, edge_type
727
- WITH n, latest_source_edge, peer, edge_type
673
+ CALL (n, latest_source_edge, peer, edge_type) {
674
+ WITH edge_type
728
675
  WHERE edge_type = "HAS_SOURCE"
729
676
  CREATE (n)<-[new_edge:HAS_SOURCE]-(peer)
730
677
  SET new_edge = properties(latest_source_edge)