1use super::{ProcSignature, RowProducer};
6use crate::catalog_meta::{DeprecatedBy, ProcArgMeta};
7
8const DB_INFO_RETURNS: &[ProcArgMeta] = &[
12 ProcArgMeta::new("id", "STRING"),
13 ProcArgMeta::new("name", "STRING"),
14 ProcArgMeta::new("creationDate", "STRING"),
15];
16
17const CONFIG_RESULT_RETURNS: &[ProcArgMeta] = &[
21 ProcArgMeta::new("name", "STRING"),
22 ProcArgMeta::new("description", "STRING"),
23 ProcArgMeta::new("value", "STRING"),
24 ProcArgMeta::new("dynamic", "BOOLEAN"),
25 ProcArgMeta::new("defaultValue", "STRING"),
26 ProcArgMeta::new("startupValue", "STRING"),
27 ProcArgMeta::new("explicitlySet", "BOOLEAN"),
28 ProcArgMeta::new("validValues", "STRING"),
29];
30
31const VECTOR_QUERY_SCORE: ProcArgMeta =
33 ProcArgMeta::described("score", "The similarity score.", "FLOAT");
34
35const FULLTEXT_QUERY_ARGS: &[ProcArgMeta] = &[
41 ProcArgMeta::new("indexName", "STRING"),
42 ProcArgMeta::new("query", "STRING"),
43 ProcArgMeta::with_default(
44 "options",
45 "The options map: `skip`, `limit` and `analyzer`.",
46 "MAP",
47 "{}",
48 ),
49];
50
51const VECTOR_QUERY_ARGS: &[ProcArgMeta] = &[
53 ProcArgMeta::described("indexName", "The name of the vector index.", "STRING"),
54 ProcArgMeta::described(
55 "numberOfNearestNeighbours",
56 "The number of nearest neighbors to return.",
57 "INTEGER",
58 ),
59 ProcArgMeta::described("query", "The query vector.", "LIST<FLOAT>"),
60];
61
62const AWAIT_INDEX_TIMEOUT: ProcArgMeta = ProcArgMeta::with_default(
65 "timeOutSeconds",
66 "The maximum time to wait, in seconds.",
67 "INTEGER",
68 "300",
69);
70
71pub static BUILTIN_PROCEDURE_SIGNATURES: &[ProcSignature] = &[
81 ProcSignature::write("apoc.create.addLabels")
91 .described("Compatibility (ADR-0699): adds the labels through Cypher's dynamic labels — `SET nodes:$(labels)`.")
92 .writes()
93 .args(&[
94 ProcArgMeta::described("nodes", "The node to add the labels to.", "NODE"),
95 ProcArgMeta::described("labels", "The labels to add.", "LIST<STRING>"),
96 ])
97 .returns(&[ProcArgMeta::described("node", "The node with the labels added.", "NODE")]),
98 ProcSignature::write("apoc.merge.relationship")
99 .described("Compatibility (ADR-0699): merges through Cypher's dynamic relationship types — `MERGE (start)-[r:$(relType)]->(end) ON CREATE SET r += … ON MATCH SET r += …`. `identProps` is accepted and ignored (callers pass `{}`).")
100 .writes()
101 .args(&[
102 ProcArgMeta::described("start", "The start node of the relationship.", "NODE"),
103 ProcArgMeta::described("relType", "The type of the relationship.", "STRING"),
104 ProcArgMeta::described("identProps", "Properties that identify the relationship. Accepted and ignored.", "MAP"),
105 ProcArgMeta::described("onCreateProps", "Properties merged when the relationship is created.", "MAP"),
106 ProcArgMeta::described("end", "The end node of the relationship.", "NODE"),
107 ProcArgMeta::with_default(
108 "onMatchProps",
109 "Properties merged when the relationship is matched.",
110 "MAP",
111 "{}",
112 ),
113 ])
114 .returns(&[ProcArgMeta::described("rel", "The merged relationship.", "RELATIONSHIP")]),
115 ProcSignature::read("db.awaitIndex")
122 .works_on_system()
123 .described("Wait for an index to come online (for example: CALL db.awaitIndex(\"MyIndex\", 300)).")
124 .args(&[
125 ProcArgMeta::described("indexName", "The name of the index to await.", "STRING"),
126 AWAIT_INDEX_TIMEOUT,
127 ])
128 .executable(false),
129 ProcSignature::read("db.awaitIndexes")
130 .works_on_system()
131 .described("Wait for all indexes to come online (for example: CALL db.awaitIndexes(300)).")
132 .args(&[AWAIT_INDEX_TIMEOUT]),
133 ProcSignature::dbms("db.checkpoint")
134 .works_on_system()
135 .described("Initiate and wait for a new check point, or wait any already on-going check point to complete. Note that this temporarily disables the `db.checkpoint.iops.limit` setting in order to make the check point complete faster. This might cause transaction throughput to degrade slightly, due to increased IO load.")
136 .returns(&[
137 ProcArgMeta::described("success", "Whether the checkpoint succeeded.", "BOOLEAN"),
138 ProcArgMeta::described("message", "A human-readable status message.", "STRING"),
139 ])
140 .executable(false),
141 ProcSignature::dbms("db.clearQueryCaches")
142 .admin()
143 .works_on_system()
144 .described("Clears all query caches.")
145 .executable(false),
146 ProcSignature::write("db.create.setNodeVectorProperty")
147 .described("Compatibility (ADR-0699): stores the embedding as a list property — the Cypher `SET node[key] = vector` the dynamic property key expresses.")
148 .writes()
149 .args(&[
150 ProcArgMeta::described("node", "The node on which the new property will be stored.", "NODE"),
151 ProcArgMeta::described("key", "The name of the new property.", "STRING"),
152 ProcArgMeta::described("vector", "The embedding to store.", "LIST<FLOAT>"),
153 ]),
154 ProcSignature::write("db.create.setRelationshipVectorProperty")
155 .described("Compatibility (ADR-0699): stores the embedding as a list property — the Cypher `SET relationship[key] = vector` the dynamic property key expresses.")
156 .writes()
157 .args(&[
158 ProcArgMeta::described(
159 "relationship",
160 "The relationship on which the new property will be stored.",
161 "RELATIONSHIP",
162 ),
163 ProcArgMeta::described("key", "The name of the new property.", "STRING"),
164 ProcArgMeta::described("vector", "The embedding to store.", "LIST<FLOAT>"),
165 ]),
166 ProcSignature::write("db.createLabel")
167 .described("Create a label")
168 .writes()
169 .args(&[ProcArgMeta::new("newLabel", "STRING")]),
170 ProcSignature::write("db.createProperty")
171 .described("Create a Property")
172 .executable(false),
173 ProcSignature::write("db.createRelationshipType")
174 .described("Create a RelationshipType")
175 .executable(false),
176 ProcSignature::read("db.index.fulltext.awaitEventuallyConsistentIndexRefresh")
184 .works_on_system()
185 .described("Wait for the updates from recently committed transactions to be applied to any eventually-consistent full-text indexes."),
186 ProcSignature::read("db.index.fulltext.listAvailableAnalyzers")
189 .works_on_system()
190 .described("List the available analyzers that the full-text indexes can be configured with.")
191 .returns(&[
192 ProcArgMeta::described("analyzer", "The name of the analyzer.", "STRING"),
193 ProcArgMeta::described("description", "A description of the analyzer.", "STRING"),
194 ProcArgMeta::described("stopwords", "The stopwords used by the analyzer.", "LIST<STRING>"),
195 ])
196 .rows(RowProducer::FulltextAnalyzers),
197 ProcSignature::read("db.index.fulltext.queryNodes")
200 .works_on_system()
201 .described(
202 "Query the given full-text index. Returns the matching nodes and their Lucene query score, ordered by score.\n\
203 Valid _key: value_ pairs for the `options` map are:\n\
204 \n\
205 * 'skip' -- to skip the top N results.\n\
206 * 'limit' -- to limit the number of results returned.\n\
207 * 'analyzer' -- to use the specified analyzer as a search analyzer for this query.\n\
208 \n\
209 The `options` map and any of the keys are optional.\n\
210 An example of the `options` map: `{skip: 30, limit: 10, analyzer: 'whitespace'}`\n",
211 )
212 .args(FULLTEXT_QUERY_ARGS)
213 .returns(&[
214 ProcArgMeta::new("node", "NODE"),
215 ProcArgMeta::new("score", "FLOAT"),
216 ])
217 .deprecated_by(DeprecatedBy::clause("SEARCH")),
218 ProcSignature::read("db.index.fulltext.queryRelationships")
219 .works_on_system()
220 .described(
221 "Query the given full-text index. Returns the matching relationships and their Lucene query score, ordered by score.\n\
222 Valid _key: value_ pairs for the `options` map are:\n\
223 \n\
224 * 'skip' -- to skip the top N results.\n\
225 * 'limit' -- to limit the number of results returned.\n\
226 * 'analyzer' -- to use the specified analyzer as a search analyzer for this query.\n\
227 \n\
228 The `options` map and any of the keys are optional.\n\
229 An example of the `options` map: `{skip: 30, limit: 10, analyzer: 'whitespace'}`\n",
230 )
231 .args(FULLTEXT_QUERY_ARGS)
232 .returns(&[
233 ProcArgMeta::new("relationship", "RELATIONSHIP"),
234 ProcArgMeta::new("score", "FLOAT"),
235 ])
236 .deprecated_by(DeprecatedBy::clause("SEARCH")),
237 ProcSignature::read("db.index.vector.queryNodes")
239 .described(
240 "Query the given node vector index.\n\
241 Returns requested number of nearest neighbors to the provided query vector,\n\
242 and their similarity score to that query vector, based on the configured similarity function for the index.\n\
243 The similarity score is a value between [0, 1]; where 0 indicates least similar, 1 most similar.\n",
244 )
245 .args(VECTOR_QUERY_ARGS)
246 .returns(&[
247 ProcArgMeta::described("node", "A matched node.", "NODE"),
248 VECTOR_QUERY_SCORE,
249 ])
250 .deprecated_by(DeprecatedBy::clause("SEARCH")),
251 ProcSignature::read("db.index.vector.queryRelationships")
252 .described(
253 "Query the given relationship vector index.\n\
254 Returns requested number of nearest neighbors to the provided query vector,\n\
255 and their similarity score to that query vector, based on the configured similarity function for the index.\n\
256 The similarity score is a value between [0, 1]; where 0 indicates least similar, 1 most similar.\n",
257 )
258 .args(VECTOR_QUERY_ARGS)
259 .returns(&[
260 ProcArgMeta::described("relationship", "A matched relationship.", "RELATIONSHIP"),
261 VECTOR_QUERY_SCORE,
262 ])
263 .deprecated_by(DeprecatedBy::clause("SEARCH")),
264 ProcSignature::read("db.info")
265 .works_on_system()
266 .described("Provides information regarding the database.")
267 .returns(DB_INFO_RETURNS)
268 .rows(RowProducer::DbInfo),
269 ProcSignature::read("db.labels")
270 .works_on_system()
271 .described("List all labels attached to nodes within a database according to the user's access rights. The procedure returns empty results if the user is not authorized to view those labels.")
272 .returns(&[ProcArgMeta::described("label", "A label within the database.", "STRING")])
273 .rows(RowProducer::DbLabels),
274 ProcSignature::dbms("db.listLocks")
275 .admin()
276 .works_on_system()
277 .described("List all locks at this database.")
278 .executable(false),
279 ProcSignature::schema("db.ontology.apply")
291 .described(
292 "Apply the stored ontology of the current database to its graph type, replacing the existing \
293 graph type: properties become property types, must_exist becomes NOT NULL, key/unique become \
294 constraints, implied labels and relationship endpoints become label constraints. Ontology parts \
295 without a graph type equivalent are reported in `skipped`.",
296 )
297 .writes()
298 .returns(&[
299 ProcArgMeta::described("ontology", "Name or id of the applied ontology model.", "STRING"),
300 ProcArgMeta::described("constraintsCreated", "Number of constraints created.", "INTEGER"),
301 ProcArgMeta::described("constraintsDropped", "Number of constraints dropped.", "INTEGER"),
302 ProcArgMeta::described(
303 "skipped",
304 "Ontology parts without a graph type equivalent, not applied.",
305 "LIST<STRING>",
306 ),
307 ]),
308 ProcSignature::schema("db.ontology.drop")
309 .described("Remove the ontology document of the current database.")
310 .writes()
311 .store_level(),
312 ProcSignature::read("db.ontology.get")
313 .described("Get the ontology document of the current database.")
314 .args(&[ProcArgMeta::with_default(
315 "format",
316 "The format of the returned document.",
317 "STRING",
318 "\"yaml\"",
319 )])
320 .returns(&[ProcArgMeta::described(
321 "ontology",
322 "The ontology document of the database, or `null` if no ontology is set.",
323 "STRING",
324 )]),
325 ProcSignature::schema("db.ontology.set")
326 .described("Set the ontology document of the current database, replacing any existing ontology.")
327 .writes()
328 .store_level()
329 .args(&[ProcArgMeta::described(
330 "ontology",
331 "The ontology document to set. `null` or empty removes it.",
332 "STRING",
333 )]),
334 ProcSignature::read("db.ping")
335 .works_on_system()
336 .described("This procedure can be used by client side tooling to test whether they are correctly connected to a database. The procedure is available in all databases and always returns true. A faulty connection can be detected by not being able to call this procedure.")
337 .returns(&[ProcArgMeta::described("success", "Whether the database answered.", "BOOLEAN")])
338 .rows(RowProducer::DbPing),
339 ProcSignature::read("db.prepareForReplanning")
340 .admin()
341 .works_on_system()
342 .described("Triggers an index resample and waits for its completion. If the wait time is 0, it skips waiting. After that, the procedure clears query caches. Once the process is complete, queries are planned using the latest database statistics.")
343 .executable(false),
344 ProcSignature::read("db.propertyKeys")
345 .works_on_system()
346 .described("List all property keys in the database.")
347 .returns(&[ProcArgMeta::new("propertyKey", "STRING")])
348 .rows(RowProducer::DbPropertyKeys),
349 ProcSignature::read("db.relationshipTypes")
350 .works_on_system()
351 .described("List all types attached to relationships within a database according to the user's access rights. The procedure returns empty results if the user is not authorized to view those relationship types.")
352 .returns(&[ProcArgMeta::new("relationshipType", "STRING")])
353 .rows(RowProducer::DbRelationshipTypes),
354 ProcSignature::read("db.schema.nodeTypeProperties")
355 .works_on_system()
356 .described("Show the derived property schema of the nodes in tabular form.")
357 .returns(&[
358 ProcArgMeta::described("nodeType", "The node labels rendered as colon-prefixed, sorted labels.", "STRING"),
359 ProcArgMeta::described("nodeLabels", "The sorted labels attached to the node type.", "LIST<STRING>"),
360 ProcArgMeta::described("propertyName", "A property key found on the node type.", "STRING"),
361 ProcArgMeta::described("propertyTypes", "The distinct value types observed for the property key.", "LIST<STRING>"),
362 ProcArgMeta::described("mandatory", "Whether the property key is present on every node of the type.", "BOOLEAN"),
363 ])
364 .rows(RowProducer::SchemaNodeTypeProperties),
365 ProcSignature::read("db.schema.relTypeProperties")
366 .works_on_system()
367 .described("Show the derived property schema of the relationships in tabular form.")
368 .returns(&[
369 ProcArgMeta::described("relType", "The relationship type rendered in bracket form.", "STRING"),
370 ProcArgMeta::described("propertyName", "A property key found on the relationship type.", "STRING"),
371 ProcArgMeta::described("propertyTypes", "The distinct value types observed for the property key.", "LIST<STRING>"),
372 ProcArgMeta::described("mandatory", "Whether the property key is present on every relationship of the type.", "BOOLEAN"),
373 ])
374 .rows(RowProducer::SchemaRelTypeProperties),
375 ProcSignature::read("db.schema.visualization")
386 .works_on_system()
387 .described("Visualizes the schema of the data based on available statistics. A new node is returned for each label. The properties represented on the node include: `name` (label name), `indexes` (list of indexes), and `constraints` (list of constraints). A relationship of a given type is returned for all possible combinations of start and end nodes. The properties represented on the relationship include: `name` (type name). Note that this may include additional relationships that do not exist in the data due to the information available in the count store. Set the flag to false to get more accurate results. Setting the flag to false could affect performance.")
388 .args(&[ProcArgMeta::with_default(
389 "options",
390 "A boolean chooses synthesized (ghost) relationships: true (the default) includes every label combination of a relationship type, false only the combinations that exist in the data. The legacy map form is equivalent to true and its contents are ignored; a null argument selects nothing.",
391 "BOOLEAN|MAP",
392 "true",
393 )])
394 .returns(&[
395 ProcArgMeta::described("nodes", "One virtual node per stored label.", "LIST<NODE>"),
396 ProcArgMeta::described("relationships", "One virtual relationship per distinct (startLabel, relType, endLabel) triple.", "LIST<RELATIONSHIP>"),
397 ])
398 .rows(RowProducer::SchemaVisualization),
399 ProcSignature::read("db.stats.retrieve")
403 .admin()
404 .works_on_system()
405 .described("Retrieve statistical data about the current database. Valid sections are 'GRAPH COUNTS', 'TOKENS', 'QUERIES', 'META'")
406 .args(&[ProcArgMeta::described("section", "The section of statistics to retrieve.", "STRING")])
407 .returns(&[
408 ProcArgMeta::described("section", "The section this row of statistics belongs to.", "STRING"),
409 ProcArgMeta::described("data", "The requested section's statistics.", "MAP"),
410 ])
411 .rows(RowProducer::DbStatsRetrieve),
412 ProcSignature::dbms("dbms.clientConfig")
417 .works_on_system()
418 .described("List the configuration settings of clients currently connected to this instance.")
419 .returns(CONFIG_RESULT_RETURNS)
420 .listed(false)
421 .rows(RowProducer::DbmsConfig),
422 ProcSignature::dbms("dbms.components")
423 .works_on_system()
424 .described("List DBMS components and their versions.")
425 .returns(&[
426 ProcArgMeta::new("name", "STRING"),
427 ProcArgMeta::new("versions", "LIST<STRING>"),
428 ProcArgMeta::new("edition", "STRING"),
431 ])
432 .rows(RowProducer::DbmsComponents),
433 ProcSignature::dbms("dbms.info")
437 .works_on_system()
438 .described("Provides information regarding the DBMS.")
439 .returns(DB_INFO_RETURNS)
440 .rows(RowProducer::DbmsInfo),
441 ProcSignature::dbms("dbms.licenseAgreementDetails")
445 .works_on_system()
446 .described("Show the status of the license agreement for this instance.")
447 .returns(&[
448 ProcArgMeta::new("status", "STRING"),
449 ProcArgMeta::new("daysLeftOnTrial", "INTEGER"),
450 ProcArgMeta::new("totalTrialDays", "INTEGER"),
451 ])
452 .listed(false)
453 .rows(RowProducer::DbmsLicenseAgreementDetails),
454 ProcSignature::dbms("dbms.listCapabilities")
459 .described("List capabilities.")
460 .returns(&[
461 ProcArgMeta::described("name", "The capability name.", "STRING"),
462 ProcArgMeta::described("description", "A description of the capability.", "STRING"),
463 ProcArgMeta::described("value", "The capability value.", "ANY"),
464 ])
465 .works_on_system()
466 .rows(RowProducer::DbmsListCapabilities),
467 ProcSignature::dbms("dbms.listConfig")
468 .admin()
469 .works_on_system()
470 .described("List the currently active configuration settings of Neo4j.")
471 .returns(CONFIG_RESULT_RETURNS)
472 .rows(RowProducer::DbmsConfig),
473 ProcSignature::dbms("dbms.showCurrentUser")
477 .works_on_system()
478 .described("Show the current user.")
479 .returns(&[
480 ProcArgMeta::new("username", "STRING"),
481 ProcArgMeta::new("roles", "LIST<STRING>"),
482 ProcArgMeta::new("flags", "LIST<STRING>"),
483 ])
484 .rows(RowProducer::DbmsShowCurrentUser),
485 ProcSignature::dbms("tx.getMetaData")
486 .works_on_system()
487 .described("Provides attached transaction metadata.")
488 .returns(&[ProcArgMeta::new("metadata", "MAP")])
489 .rows(RowProducer::TxGetMetaData),
490 ProcSignature::dbms("tx.setMetaData")
493 .described("Attaches a map of data to the transaction. The data will be printed when listing queries, and inserted into the query log.")
494 .args(&[ProcArgMeta::new("metadata", "MAP")]),
495];