@reyemtech/nimbus 2.12.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
  3. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  4. package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
  5. package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
  6. package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
  7. package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
  8. package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
  9. package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
  10. package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
  11. package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
  12. package/dist/cjs/cli/migrate-cnpg.js +258 -0
  13. package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
  14. package/dist/cjs/cli/migrate-exec.d.ts +45 -0
  15. package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
  16. package/dist/cjs/cli/migrate-exec.js +104 -0
  17. package/dist/cjs/cli/migrate-exec.js.map +1 -0
  18. package/dist/cjs/cli/migrate-psql.d.ts +125 -0
  19. package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
  20. package/dist/cjs/cli/migrate-psql.js +213 -0
  21. package/dist/cjs/cli/migrate-psql.js.map +1 -0
  22. package/dist/cjs/cli/migrate-report.d.ts +27 -0
  23. package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
  24. package/dist/cjs/cli/migrate-report.js +29 -0
  25. package/dist/cjs/cli/migrate-report.js.map +1 -0
  26. package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
  27. package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
  28. package/dist/cjs/cli/migrate-superuser.js +73 -0
  29. package/dist/cjs/cli/migrate-superuser.js.map +1 -0
  30. package/dist/cjs/cli/migrate.d.ts +37 -0
  31. package/dist/cjs/cli/migrate.d.ts.map +1 -0
  32. package/dist/cjs/cli/migrate.js +67 -0
  33. package/dist/cjs/cli/migrate.js.map +1 -0
  34. package/dist/cjs/cli.d.ts +1 -0
  35. package/dist/cjs/cli.d.ts.map +1 -1
  36. package/dist/cjs/cli.js +6 -0
  37. package/dist/cjs/cli.js.map +1 -1
  38. package/dist/cjs/index.d.ts +1 -1
  39. package/dist/cjs/index.d.ts.map +1 -1
  40. package/dist/cjs/index.js.map +1 -1
  41. package/dist/cjs/operator/cnpg-common.d.ts +56 -0
  42. package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
  43. package/dist/cjs/operator/cnpg-common.js +82 -0
  44. package/dist/cjs/operator/cnpg-common.js.map +1 -0
  45. package/dist/cjs/operator/cnpg-database.d.ts +66 -0
  46. package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
  47. package/dist/cjs/operator/cnpg-database.js +296 -0
  48. package/dist/cjs/operator/cnpg-database.js.map +1 -0
  49. package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
  50. package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
  51. package/dist/cjs/operator/cnpg-roles.js +225 -0
  52. package/dist/cjs/operator/cnpg-roles.js.map +1 -0
  53. package/dist/cjs/operator/cnpg.d.ts.map +1 -1
  54. package/dist/cjs/operator/cnpg.js +50 -162
  55. package/dist/cjs/operator/cnpg.js.map +1 -1
  56. package/dist/cjs/operator/connection-uri.d.ts +44 -0
  57. package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
  58. package/dist/cjs/operator/connection-uri.js +49 -0
  59. package/dist/cjs/operator/connection-uri.js.map +1 -0
  60. package/dist/cjs/operator/credentials.d.ts +76 -0
  61. package/dist/cjs/operator/credentials.d.ts.map +1 -0
  62. package/dist/cjs/operator/credentials.js +106 -0
  63. package/dist/cjs/operator/credentials.js.map +1 -0
  64. package/dist/cjs/operator/database-options.d.ts +121 -0
  65. package/dist/cjs/operator/database-options.d.ts.map +1 -0
  66. package/dist/cjs/operator/database-options.js +131 -0
  67. package/dist/cjs/operator/database-options.js.map +1 -0
  68. package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
  69. package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
  70. package/dist/cjs/operator/grants/postgres-job.js +232 -0
  71. package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
  72. package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
  73. package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
  74. package/dist/cjs/operator/grants/postgres-sql.js +305 -0
  75. package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
  76. package/dist/cjs/operator/grants/privileges.d.ts +24 -0
  77. package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
  78. package/dist/cjs/operator/grants/privileges.js +35 -0
  79. package/dist/cjs/operator/grants/privileges.js.map +1 -0
  80. package/dist/cjs/operator/grants/role-config.d.ts +80 -0
  81. package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
  82. package/dist/cjs/operator/grants/role-config.js +134 -0
  83. package/dist/cjs/operator/grants/role-config.js.map +1 -0
  84. package/dist/cjs/operator/index.d.ts +1 -1
  85. package/dist/cjs/operator/index.d.ts.map +1 -1
  86. package/dist/cjs/operator/index.js.map +1 -1
  87. package/dist/cjs/operator/interfaces.d.ts +223 -1
  88. package/dist/cjs/operator/interfaces.d.ts.map +1 -1
  89. package/dist/cjs/operator/interfaces.js.map +1 -1
  90. package/dist/cjs/operator/mariadb-common.d.ts +99 -0
  91. package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
  92. package/dist/cjs/operator/mariadb-common.js +141 -0
  93. package/dist/cjs/operator/mariadb-common.js.map +1 -0
  94. package/dist/cjs/operator/mariadb-database.d.ts +65 -0
  95. package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
  96. package/dist/cjs/operator/mariadb-database.js +285 -0
  97. package/dist/cjs/operator/mariadb-database.js.map +1 -0
  98. package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
  99. package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
  100. package/dist/cjs/operator/mariadb-roles.js +366 -0
  101. package/dist/cjs/operator/mariadb-roles.js.map +1 -0
  102. package/dist/cjs/operator/mariadb.d.ts.map +1 -1
  103. package/dist/cjs/operator/mariadb.js +35 -147
  104. package/dist/cjs/operator/mariadb.js.map +1 -1
  105. package/dist/cjs/operator/neo4j-common.d.ts +62 -0
  106. package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
  107. package/dist/cjs/operator/neo4j-common.js +89 -0
  108. package/dist/cjs/operator/neo4j-common.js.map +1 -0
  109. package/dist/cjs/operator/neo4j-database.d.ts +88 -0
  110. package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
  111. package/dist/cjs/operator/neo4j-database.js +274 -0
  112. package/dist/cjs/operator/neo4j-database.js.map +1 -0
  113. package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
  114. package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
  115. package/dist/cjs/operator/neo4j-roles.js +298 -0
  116. package/dist/cjs/operator/neo4j-roles.js.map +1 -0
  117. package/dist/cjs/operator/neo4j.d.ts.map +1 -1
  118. package/dist/cjs/operator/neo4j.js +32 -132
  119. package/dist/cjs/operator/neo4j.js.map +1 -1
  120. package/dist/cjs/operator/resource-identity.d.ts +170 -0
  121. package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
  122. package/dist/cjs/operator/resource-identity.js +231 -0
  123. package/dist/cjs/operator/resource-identity.js.map +1 -0
  124. package/dist/cjs/operator/role-registry.d.ts +85 -0
  125. package/dist/cjs/operator/role-registry.d.ts.map +1 -0
  126. package/dist/cjs/operator/role-registry.js +72 -0
  127. package/dist/cjs/operator/role-registry.js.map +1 -0
  128. package/dist/cjs/types/errors.d.ts +3 -0
  129. package/dist/cjs/types/errors.d.ts.map +1 -1
  130. package/dist/cjs/types/errors.js +3 -0
  131. package/dist/cjs/types/errors.js.map +1 -1
  132. package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
  133. package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  134. package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
  135. package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
  136. package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
  137. package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
  138. package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
  139. package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
  140. package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
  141. package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
  142. package/dist/esm/cli/migrate-cnpg.js +258 -0
  143. package/dist/esm/cli/migrate-cnpg.js.map +1 -0
  144. package/dist/esm/cli/migrate-exec.d.ts +45 -0
  145. package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
  146. package/dist/esm/cli/migrate-exec.js +104 -0
  147. package/dist/esm/cli/migrate-exec.js.map +1 -0
  148. package/dist/esm/cli/migrate-psql.d.ts +125 -0
  149. package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
  150. package/dist/esm/cli/migrate-psql.js +213 -0
  151. package/dist/esm/cli/migrate-psql.js.map +1 -0
  152. package/dist/esm/cli/migrate-report.d.ts +27 -0
  153. package/dist/esm/cli/migrate-report.d.ts.map +1 -0
  154. package/dist/esm/cli/migrate-report.js +29 -0
  155. package/dist/esm/cli/migrate-report.js.map +1 -0
  156. package/dist/esm/cli/migrate-superuser.d.ts +22 -0
  157. package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
  158. package/dist/esm/cli/migrate-superuser.js +73 -0
  159. package/dist/esm/cli/migrate-superuser.js.map +1 -0
  160. package/dist/esm/cli/migrate.d.ts +37 -0
  161. package/dist/esm/cli/migrate.d.ts.map +1 -0
  162. package/dist/esm/cli/migrate.js +67 -0
  163. package/dist/esm/cli/migrate.js.map +1 -0
  164. package/dist/esm/cli.d.ts +1 -0
  165. package/dist/esm/cli.d.ts.map +1 -1
  166. package/dist/esm/cli.js +6 -0
  167. package/dist/esm/cli.js.map +1 -1
  168. package/dist/esm/index.d.ts +1 -1
  169. package/dist/esm/index.d.ts.map +1 -1
  170. package/dist/esm/index.js.map +1 -1
  171. package/dist/esm/operator/cnpg-common.d.ts +56 -0
  172. package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
  173. package/dist/esm/operator/cnpg-common.js +82 -0
  174. package/dist/esm/operator/cnpg-common.js.map +1 -0
  175. package/dist/esm/operator/cnpg-database.d.ts +66 -0
  176. package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
  177. package/dist/esm/operator/cnpg-database.js +296 -0
  178. package/dist/esm/operator/cnpg-database.js.map +1 -0
  179. package/dist/esm/operator/cnpg-roles.d.ts +173 -0
  180. package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
  181. package/dist/esm/operator/cnpg-roles.js +225 -0
  182. package/dist/esm/operator/cnpg-roles.js.map +1 -0
  183. package/dist/esm/operator/cnpg.d.ts.map +1 -1
  184. package/dist/esm/operator/cnpg.js +50 -162
  185. package/dist/esm/operator/cnpg.js.map +1 -1
  186. package/dist/esm/operator/connection-uri.d.ts +44 -0
  187. package/dist/esm/operator/connection-uri.d.ts.map +1 -0
  188. package/dist/esm/operator/connection-uri.js +49 -0
  189. package/dist/esm/operator/connection-uri.js.map +1 -0
  190. package/dist/esm/operator/credentials.d.ts +76 -0
  191. package/dist/esm/operator/credentials.d.ts.map +1 -0
  192. package/dist/esm/operator/credentials.js +106 -0
  193. package/dist/esm/operator/credentials.js.map +1 -0
  194. package/dist/esm/operator/database-options.d.ts +121 -0
  195. package/dist/esm/operator/database-options.d.ts.map +1 -0
  196. package/dist/esm/operator/database-options.js +131 -0
  197. package/dist/esm/operator/database-options.js.map +1 -0
  198. package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
  199. package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
  200. package/dist/esm/operator/grants/postgres-job.js +232 -0
  201. package/dist/esm/operator/grants/postgres-job.js.map +1 -0
  202. package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
  203. package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
  204. package/dist/esm/operator/grants/postgres-sql.js +305 -0
  205. package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
  206. package/dist/esm/operator/grants/privileges.d.ts +24 -0
  207. package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
  208. package/dist/esm/operator/grants/privileges.js +35 -0
  209. package/dist/esm/operator/grants/privileges.js.map +1 -0
  210. package/dist/esm/operator/grants/role-config.d.ts +80 -0
  211. package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
  212. package/dist/esm/operator/grants/role-config.js +134 -0
  213. package/dist/esm/operator/grants/role-config.js.map +1 -0
  214. package/dist/esm/operator/index.d.ts +1 -1
  215. package/dist/esm/operator/index.d.ts.map +1 -1
  216. package/dist/esm/operator/index.js.map +1 -1
  217. package/dist/esm/operator/interfaces.d.ts +223 -1
  218. package/dist/esm/operator/interfaces.d.ts.map +1 -1
  219. package/dist/esm/operator/interfaces.js.map +1 -1
  220. package/dist/esm/operator/mariadb-common.d.ts +99 -0
  221. package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
  222. package/dist/esm/operator/mariadb-common.js +141 -0
  223. package/dist/esm/operator/mariadb-common.js.map +1 -0
  224. package/dist/esm/operator/mariadb-database.d.ts +65 -0
  225. package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
  226. package/dist/esm/operator/mariadb-database.js +285 -0
  227. package/dist/esm/operator/mariadb-database.js.map +1 -0
  228. package/dist/esm/operator/mariadb-roles.d.ts +264 -0
  229. package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
  230. package/dist/esm/operator/mariadb-roles.js +366 -0
  231. package/dist/esm/operator/mariadb-roles.js.map +1 -0
  232. package/dist/esm/operator/mariadb.d.ts.map +1 -1
  233. package/dist/esm/operator/mariadb.js +35 -147
  234. package/dist/esm/operator/mariadb.js.map +1 -1
  235. package/dist/esm/operator/neo4j-common.d.ts +62 -0
  236. package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
  237. package/dist/esm/operator/neo4j-common.js +89 -0
  238. package/dist/esm/operator/neo4j-common.js.map +1 -0
  239. package/dist/esm/operator/neo4j-database.d.ts +88 -0
  240. package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
  241. package/dist/esm/operator/neo4j-database.js +274 -0
  242. package/dist/esm/operator/neo4j-database.js.map +1 -0
  243. package/dist/esm/operator/neo4j-roles.d.ts +203 -0
  244. package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
  245. package/dist/esm/operator/neo4j-roles.js +298 -0
  246. package/dist/esm/operator/neo4j-roles.js.map +1 -0
  247. package/dist/esm/operator/neo4j.d.ts.map +1 -1
  248. package/dist/esm/operator/neo4j.js +32 -132
  249. package/dist/esm/operator/neo4j.js.map +1 -1
  250. package/dist/esm/operator/resource-identity.d.ts +170 -0
  251. package/dist/esm/operator/resource-identity.d.ts.map +1 -0
  252. package/dist/esm/operator/resource-identity.js +231 -0
  253. package/dist/esm/operator/resource-identity.js.map +1 -0
  254. package/dist/esm/operator/role-registry.d.ts +85 -0
  255. package/dist/esm/operator/role-registry.d.ts.map +1 -0
  256. package/dist/esm/operator/role-registry.js +72 -0
  257. package/dist/esm/operator/role-registry.js.map +1 -0
  258. package/dist/esm/types/errors.d.ts +3 -0
  259. package/dist/esm/types/errors.d.ts.map +1 -1
  260. package/dist/esm/types/errors.js +3 -0
  261. package/dist/esm/types/errors.js.map +1 -1
  262. package/package.json +1 -1
@@ -0,0 +1,274 @@
1
+ "use strict";
2
+ /**
3
+ * Databases inside a Neo4j deployment.
4
+ *
5
+ * Neo4j is provisioned imperatively, unlike the other two backends. There is no
6
+ * operator and no CRDs: the Helm chart deploys the instance directly and each
7
+ * user is created by a one-shot `cypher-shell` Job. The uniformity `addRole()`
8
+ * provides here is at the API level, not the mechanism level — the same call
9
+ * shape and the same `IDatabaseRole` come back, but nothing reconciles the
10
+ * account afterwards, and there are no privileges to reconcile in the first
11
+ * place because `neo4j:community` has no RBAC.
12
+ *
13
+ * Everything that RBAC would express is therefore refused rather than ignored:
14
+ * `grants` and `login: false` both throw. So does `config.sql` — the only
15
+ * statements this backend can run are the Cypher its provisioning Job carries.
16
+ *
17
+ * Usernames are deployment-global here as they are cluster-global on the other
18
+ * two backends, so a per-deployment {@link IRoleRegistry} refuses a name claimed
19
+ * twice. Neo4j's failure mode is as quiet as theirs and less stable: each Job
20
+ * sets the shared account's password to its own, so whichever runs last wins and
21
+ * the losing role's replicated Secrets hold a password the account no longer
22
+ * has — with nothing in the Pulumi diff, and no Job failure, to say so.
23
+ *
24
+ * @module operator/neo4j-database
25
+ */
26
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
27
+ if (k2 === undefined) k2 = k;
28
+ var desc = Object.getOwnPropertyDescriptor(m, k);
29
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30
+ desc = { enumerable: true, get: function() { return m[k]; } };
31
+ }
32
+ Object.defineProperty(o, k2, desc);
33
+ }) : (function(o, m, k, k2) {
34
+ if (k2 === undefined) k2 = k;
35
+ o[k2] = m[k];
36
+ }));
37
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
38
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
39
+ }) : function(o, v) {
40
+ o["default"] = v;
41
+ });
42
+ var __importStar = (this && this.__importStar) || (function () {
43
+ var ownKeys = function(o) {
44
+ ownKeys = Object.getOwnPropertyNames || function (o) {
45
+ var ar = [];
46
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47
+ return ar;
48
+ };
49
+ return ownKeys(o);
50
+ };
51
+ return function (mod) {
52
+ if (mod && mod.__esModule) return mod;
53
+ var result = {};
54
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
55
+ __setModuleDefault(result, mod);
56
+ return result;
57
+ };
58
+ })();
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.assertNoEnvironments = assertNoEnvironments;
61
+ exports.createSingleNeo4jDatabaseInstance = createSingleNeo4jDatabaseInstance;
62
+ const pulumi = __importStar(require("@pulumi/pulumi"));
63
+ const neo4j_common_js_1 = require("./neo4j-common.js");
64
+ const neo4j_roles_js_1 = require("./neo4j-roles.js");
65
+ const role_config_js_1 = require("./grants/role-config.js");
66
+ const resource_identity_js_1 = require("./resource-identity.js");
67
+ const database_options_js_1 = require("./database-options.js");
68
+ const errors_js_1 = require("../types/errors.js");
69
+ /** Engine name used in errors about options Neo4j cannot honour. */
70
+ const NEO4J_ENGINE_NAME = database_options_js_1.ENGINE_NAMES.NEO4J;
71
+ /** Label naming the deployment an object belongs to. */
72
+ const CLUSTER_LABEL = "nimbus/cluster";
73
+ /** Label naming the database an object belongs to. */
74
+ const DATABASE_LABEL = "nimbus/database";
75
+ /**
76
+ * Label naming the role an object belongs to.
77
+ *
78
+ * Its value is a sanitized form of the username — see {@link toLabelValue} —
79
+ * because label values accept far less than a Neo4j username does.
80
+ */
81
+ const ROLE_LABEL = "nimbus/role";
82
+ /**
83
+ * Reject `environments`, which Neo4j cannot fan a database out across.
84
+ *
85
+ * CNPG and MariaDB create one database per environment named `{db}-{env}` and
86
+ * return a Record of them. Neo4j Community allows a single user database, so
87
+ * there is nothing to fan out. The option used to be accepted and silently
88
+ * dropped, which returned one instance where the caller's types promised a
89
+ * Record — leaving `db["prod"]` undefined at runtime with nothing to explain it.
90
+ *
91
+ * @param dbName - Database the configuration belongs to
92
+ * @param config - Raw per-database configuration
93
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `environments` is set
94
+ */
95
+ function assertNoEnvironments(dbName, config) {
96
+ if (config.environments) {
97
+ throw new errors_js_1.AnyCloudError(`Database "${dbName}" cannot use "environments" on Neo4j — the Community edition ` +
98
+ "allows a single user database, so there is nothing to fan out. Create one Neo4j " +
99
+ "cluster per environment instead.", errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
100
+ }
101
+ }
102
+ /**
103
+ * Create a single database instance within a Neo4j deployment.
104
+ *
105
+ * The owner's account is created by a `cypher-shell` Job and its connection
106
+ * details are replicated into the configured namespaces. Additional users are
107
+ * added afterwards via the returned `addRole()`.
108
+ *
109
+ * @param options - Deployment, database name, configuration, and provider
110
+ * @returns The database instance, with `addRole()` bound to it
111
+ * @throws {AnyCloudError} code `INVALID_GRANT` when a role's grant lists no privileges
112
+ * @throws {AnyCloudError} code `UNSUPPORTED_ROLE_OPTION` when `dbName` or the
113
+ * resolved owner name is blank, when `config.sql` is set (Neo4j runs no SQL),
114
+ * or when `addRole()` is called with a blank name, with the database owner's
115
+ * own name, with a username any other database on the same deployment has
116
+ * already claimed, is passed `grants` (Neo4j Community has no RBAC), is passed
117
+ * `login: false`, or is passed any `engineOptions` block
118
+ */
119
+ function createSingleNeo4jDatabaseInstance(options) {
120
+ const { clusterName, dbName, config, endpoint, port, adminSecretName, release, provider } = options;
121
+ const { roleRegistry } = options;
122
+ (0, role_config_js_1.assertValidDatabaseName)(dbName);
123
+ // The provisioning Job speaks Cypher, not SQL, and there is no second Job to
124
+ // put statements in — so `sql` is refused rather than dropped on the floor.
125
+ (0, database_options_js_1.assertNoSql)(dbName, config, NEO4J_ENGINE_NAME);
126
+ const username = config.owner ?? dbName;
127
+ (0, role_config_js_1.assertValidRoleName)(username, dbName);
128
+ // The owner is a deployment-global user like any other, so it claims its name
129
+ // too — otherwise a later addRole() on a *different* database could take it,
130
+ // and its Job would no-op against this account.
131
+ (0, neo4j_common_js_1.claimNeo4jUsername)(roleRegistry, username, dbName);
132
+ const labels = {
133
+ [neo4j_common_js_1.MANAGED_BY_LABEL]: neo4j_common_js_1.MANAGED_BY_VALUE,
134
+ [CLUSTER_LABEL]: clusterName,
135
+ [DATABASE_LABEL]: dbName,
136
+ };
137
+ const ownerNaming = (0, neo4j_roles_js_1.ownerRoleNaming)(clusterName, dbName);
138
+ const ownerConfig = (0, role_config_js_1.resolveRoleConfig)({ namespaces: config.namespaces, login: true });
139
+ const owner = (0, neo4j_roles_js_1.provisionNeo4jRole)({
140
+ dbName,
141
+ roleName: username,
142
+ naming: ownerNaming,
143
+ adminSecretName,
144
+ endpoint,
145
+ labels,
146
+ podLabels: { [DATABASE_LABEL]: dbName },
147
+ provider,
148
+ dependsOn: [release],
149
+ });
150
+ const secrets = (0, neo4j_roles_js_1.replicateNeo4jConnectionSecrets)({
151
+ naming: ownerNaming,
152
+ namespaces: ownerConfig.namespaces,
153
+ dbName,
154
+ username,
155
+ password: owner.credentials.stablePassword,
156
+ endpoint,
157
+ labels,
158
+ provider,
159
+ dependsOn: [owner.initJob],
160
+ });
161
+ return {
162
+ name: dbName,
163
+ clusterName,
164
+ host: endpoint,
165
+ port,
166
+ database: pulumi.output(dbName),
167
+ secrets,
168
+ nativeResource: owner.initJob,
169
+ addRole(roleName, roleConfig) {
170
+ // The name lands between escaped backticks in the Job's Cypher
171
+ // `CREATE OR REPLACE USER` statement, so a backtick in it would break out
172
+ // of the identifier quoting.
173
+ (0, role_config_js_1.assertValidRoleName)(roleName, dbName);
174
+ // The owner's account is already created by createDatabase(). Adding it
175
+ // again would create a SECOND Job issuing `CREATE OR REPLACE USER` for the
176
+ // same username, bound to a different password Secret — and each Job sets
177
+ // the account's password to its own. Whichever runs last wins, so either
178
+ // the owner's replicated connection Secrets or this role's are left
179
+ // holding a password the account no longer has, with nothing in the Pulumi
180
+ // diff to say why.
181
+ if (roleName === username) {
182
+ throw new errors_js_1.AnyCloudError(`Role "${roleName}" is the owner of database "${dbName}" and is created by ` +
183
+ `createDatabase(); it cannot be added again. Use a different role name, or ` +
184
+ `change the database's "owner".`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
185
+ }
186
+ const resolved = (0, role_config_js_1.resolveRoleConfig)(roleConfig);
187
+ // Neo4j Community has no RBAC — no roles, no privileges, no GRANT. There
188
+ // is nothing to compile these into, and accepting them so the call
189
+ // succeeds would hand back a user with full access to the whole graph
190
+ // while the config says it is read-only.
191
+ //
192
+ // An empty list is refused for the same reason rather than waved through
193
+ // as "nothing to grant". On the engines that model privileges it means
194
+ // "this role should hold none", and Neo4j Community cannot express that
195
+ // either: every account it creates can read and write the whole graph.
196
+ // Only omitting `grants` — asking nimbus not to manage privileges — is
197
+ // honourable here.
198
+ if (resolved.grants !== undefined) {
199
+ throw new errors_js_1.AnyCloudError(`Neo4j does not support declarative grants (role "${roleName}" on "${dbName}"). ` +
200
+ `Neo4j Community has no RBAC — every account can read and write the whole ` +
201
+ `graph, so even "grants: []" cannot be honoured. Remove the grants option.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
202
+ }
203
+ // Every Neo4j user is a login account — `CREATE USER` has no non-login
204
+ // form. Honouring `login: false` by ignoring it would hand back a role
205
+ // that can log in when the caller asked for one that cannot.
206
+ if (!resolved.login) {
207
+ throw new errors_js_1.AnyCloudError(`Role "${roleName}" cannot be created with login: false on Neo4j — every ` +
208
+ `Neo4j user is a login account. Omit "login", or do not create the user.`, errors_js_1.ERROR_CODES.UNSUPPORTED_ROLE_OPTION);
209
+ }
210
+ // Neo4j reads no engineOptions block at all: it has no operator and no
211
+ // CRs, and nothing in `postgresql` or `mariadb` maps onto `CREATE USER`.
212
+ // Either block names an engine that will never run this role.
213
+ (0, database_options_js_1.assertNoForeignEngineOptions)({
214
+ roleName,
215
+ databaseName: dbName,
216
+ engineOptions: roleConfig?.engineOptions,
217
+ engine: NEO4J_ENGINE_NAME,
218
+ });
219
+ // Same hazard one scope wider: the check above only sees this database's
220
+ // own owner, while a user of this name may already belong to a sibling
221
+ // database on the same deployment — the same account, since Neo4j users
222
+ // are deployment-global. Two Jobs then set that one account's password to
223
+ // two different generated values, and the loser's Secrets stop
224
+ // authenticating. The registry is what notices.
225
+ //
226
+ // Claimed here rather than at the top of the method so that a call
227
+ // rejected by one of the guards above leaves no claim behind — the role
228
+ // was never provisioned, so its name must stay available.
229
+ (0, neo4j_common_js_1.claimNeo4jUsername)(roleRegistry, roleName, dbName);
230
+ const naming = (0, neo4j_roles_js_1.additionalRoleNaming)(clusterName, dbName, roleName);
231
+ // The label carries a sanitized form of the username, never the raw one.
232
+ // The shared validator deliberately permits `reporting@corp`, and `@` is
233
+ // not a legal label character — the Kubernetes API rejects the whole
234
+ // object at apply time, after preview has passed, so the Job carrying the
235
+ // label never runs and the account is never created. The raw name still
236
+ // goes verbatim into the Cypher statement and the Secret payload, which
237
+ // are the two places it must be exact.
238
+ const roleLabel = (0, resource_identity_js_1.toLabelValue)(roleName);
239
+ const roleLabels = { ...labels, [ROLE_LABEL]: roleLabel };
240
+ const provisioned = (0, neo4j_roles_js_1.provisionNeo4jRole)({
241
+ dbName,
242
+ roleName,
243
+ naming,
244
+ adminSecretName,
245
+ endpoint,
246
+ labels: roleLabels,
247
+ podLabels: { [DATABASE_LABEL]: dbName, [ROLE_LABEL]: roleLabel },
248
+ provider,
249
+ dependsOn: [release],
250
+ });
251
+ // The connection Secret waits on the Job so a consumer cannot read
252
+ // credentials and connect before the account exists.
253
+ const roleSecrets = (0, neo4j_roles_js_1.replicateNeo4jConnectionSecrets)({
254
+ naming,
255
+ namespaces: resolved.namespaces,
256
+ dbName,
257
+ username: roleName,
258
+ password: provisioned.credentials.stablePassword,
259
+ endpoint,
260
+ labels: roleLabels,
261
+ provider,
262
+ dependsOn: [provisioned.initJob],
263
+ });
264
+ return {
265
+ name: roleName,
266
+ databaseName: dbName,
267
+ clusterName,
268
+ secrets: roleSecrets,
269
+ nativeResource: provisioned.initJob,
270
+ };
271
+ },
272
+ };
273
+ }
274
+ //# sourceMappingURL=neo4j-database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neo4j-database.js","sourceRoot":"","sources":["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EH,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,MAAM;gBACpB,WAAW;gBACX,OAAO,EAAE,WAAW;gBACpB,cAAc,EAAE,WAAW,CAAC,OAAO;aACpC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Neo4j users inside a Neo4j deployment.
3
+ *
4
+ * Every user — the database owner created alongside the database, and every
5
+ * role added later via `addRole()` — is provisioned by the single function
6
+ * {@link provisionNeo4jRole}. Neo4j is the odd backend out: it has no
7
+ * Kubernetes operator and no CRDs, so there is nothing to reconcile an account
8
+ * declaratively. A user is created by a one-shot `cypher-shell` Job running
9
+ * `CREATE OR REPLACE USER`, which is idempotent in effect — every run leaves the
10
+ * account existing with exactly the password its Secret holds — but is applied
11
+ * once rather than continuously, so drift between runs is not corrected.
12
+ *
13
+ * Nothing here grants privileges. `neo4j:community` has no RBAC at all, so a
14
+ * provisioned user is simply an account that can log in; `addRole()` rejects
15
+ * `grants` rather than accepting them and quietly doing nothing.
16
+ *
17
+ * Only the names differ between the two paths, and those names are the one
18
+ * genuinely dangerous part: Pulumi identifies a resource by its logical name,
19
+ * so renaming one deletes and recreates it, and for a credential Secret that
20
+ * regenerates the password and breaks every application already using it.
21
+ * {@link ownerRoleNaming} therefore pins the owner's names to the exact strings
22
+ * live stacks already carry.
23
+ *
24
+ * @module operator/neo4j-roles
25
+ */
26
+ import * as k8s from "@pulumi/kubernetes";
27
+ import * as pulumi from "@pulumi/pulumi";
28
+ import { type IRoleCredentials } from "./credentials.js";
29
+ /**
30
+ * Every name — Pulumi logical and Kubernetes — used by one provisioned user.
31
+ *
32
+ * Collecting them in one place keeps the replace-on-rename risk reviewable
33
+ * instead of scattered through the provisioning code.
34
+ */
35
+ export interface INeo4jRoleNaming {
36
+ /** Pulumi logical name of the credential Secret. */
37
+ readonly credentialResource: string;
38
+ /** Kubernetes name of the credential Secret. */
39
+ readonly credentialSecret: string;
40
+ /** Pulumi logical name of the `cypher-shell` provisioning Job. */
41
+ readonly initJobResource: string;
42
+ /** Kubernetes name of the `cypher-shell` provisioning Job. */
43
+ readonly initJobName: string;
44
+ /** Pulumi logical name prefix of the replicated connection Secrets. */
45
+ readonly connectionResourcePrefix: string;
46
+ /** Kubernetes name of each replicated connection Secret. */
47
+ readonly connectionSecret: string;
48
+ }
49
+ /**
50
+ * Names for the database owner's user.
51
+ *
52
+ * These strings predate the shared provisioner and are reproduced verbatim:
53
+ * `-neo4j-password`, `-neo4j-user`, `neo4j-init-user-{cluster}-{database}`, and
54
+ * `-neo4j-secret-{namespace}` are the names live stacks already carry, and the
55
+ * Job's `metadata.name` is the unsanitized string those objects were created
56
+ * under. Do not "tidy" them.
57
+ *
58
+ * @param clusterName - Neo4j deployment name
59
+ * @param dbName - Database name
60
+ * @returns The owner user's pinned naming
61
+ */
62
+ export declare function ownerRoleNaming(clusterName: string, dbName: string): INeo4jRoleNaming;
63
+ /**
64
+ * Names for a user added via `addRole()`.
65
+ *
66
+ * Every name is prefixed `{cluster}-{database}-role-{role}` so it can never
67
+ * collide with the owner's pinned names above — the owner's names have no
68
+ * `-role-` segment following `{cluster}-{database}`.
69
+ *
70
+ * The role segment comes from {@link toIdentitySegment}, not from plain
71
+ * sanitizing: `Read_Only` and `read_only` are two distinct, simultaneously valid
72
+ * Neo4j usernames that sanitize alike, and two resources deriving one logical
73
+ * name abort the entire preview with a duplicate-URN error. Every segment
74
+ * carries the hash, including names that needed no sanitizing, so no raw name
75
+ * can land on another's encoded form.
76
+ *
77
+ * Every name is then bounded by {@link toBoundedName}, each by the limit that
78
+ * applies to the object it names. Deployment, database and username are all
79
+ * caller-controlled and unbounded, and the provisioning Job's name —
80
+ * `neo4j-init-user-{deployment}-{database}-role-{user}-{hash}` — passes 63
81
+ * characters once they total roughly 32. Kubernetes copies a Job's name into the
82
+ * `job-name` label of every Pod it creates and label values are capped at 63, so
83
+ * an untruncated name is rejected at apply time: preview passes, the Job is
84
+ * refused, and the account it would have created never exists. The Secrets are
85
+ * bound only by the far looser subdomain limit, so they keep their readable
86
+ * names.
87
+ *
88
+ * @param clusterName - Neo4j deployment name
89
+ * @param dbName - Database name
90
+ * @param roleName - Username as it exists in Neo4j
91
+ * @returns Naming for the additional user's resources, each within the limit
92
+ * Kubernetes enforces on its object kind
93
+ */
94
+ export declare function additionalRoleNaming(clusterName: string, dbName: string, roleName: string): INeo4jRoleNaming;
95
+ /** Inputs for {@link provisionNeo4jRole}. */
96
+ export interface INeo4jRoleOptions {
97
+ /** Database the user is provisioned for, used for labelling only. */
98
+ readonly dbName: string;
99
+ /** Username as it will exist in Neo4j, passed to `cypher-shell` verbatim. */
100
+ readonly roleName: string;
101
+ /** Pinned Pulumi and Kubernetes names for this user's resources. */
102
+ readonly naming: INeo4jRoleNaming;
103
+ /** Kubernetes name of the Secret holding the built-in `neo4j` password. */
104
+ readonly adminSecretName: string;
105
+ /** Deployment endpoint the Job connects to over Bolt. */
106
+ readonly endpoint: pulumi.Output<string>;
107
+ /** Labels applied to the credential Secret and the Job. */
108
+ readonly labels: Record<string, string>;
109
+ /** Labels applied to the Job's pod template. */
110
+ readonly podLabels: Record<string, string>;
111
+ /** Kubernetes provider. */
112
+ readonly provider: k8s.Provider;
113
+ /** Resources the Secret and Job must be created after. */
114
+ readonly dependsOn: ReadonlyArray<pulumi.Resource>;
115
+ }
116
+ /** A provisioned user and the credentials backing it. */
117
+ export interface INeo4jProvisionedRole {
118
+ /** The `cypher-shell` Job that creates the account. */
119
+ readonly initJob: k8s.batch.v1.Job;
120
+ /** The user's password Secret and its stable password. */
121
+ readonly credentials: IRoleCredentials;
122
+ }
123
+ /**
124
+ * Provision one Neo4j user: a password Secret and the `cypher-shell` Job that
125
+ * creates the account with it.
126
+ *
127
+ * The Job runs one statement and nothing else. It used to follow the create with
128
+ * `GRANT ROLE reader, editor`, suffixed `|| true` because the statement is
129
+ * Enterprise-only — which meant the command failed on every Community deployment
130
+ * and the failure was discarded. A grant that cannot be honoured must not be
131
+ * issued at all, so the statement is gone rather than silenced.
132
+ *
133
+ * That statement is `CREATE OR REPLACE USER`, which sets the password
134
+ * unconditionally. `CREATE USER ... IF NOT EXISTS` did not: a Neo4j user is
135
+ * deployment-global and outlives the Pulumi resources that provisioned it, so
136
+ * removing an `addRole()` call and later re-adding it destroyed the credential
137
+ * Secret, generated a fresh password — and then found the account still there.
138
+ * The create was a no-op, every replicated connection Secret carried a password
139
+ * that could not authenticate, and the Job reported success.
140
+ *
141
+ * `CREATE USER ... IF NOT EXISTS` followed by `ALTER USER ... SET PASSWORD` is
142
+ * not the fix it looks like: Neo4j rejects an `ALTER` that sets the password a
143
+ * user already has ("Old password and new password cannot be the same"), which
144
+ * is the state immediately after the create and on every re-run of an unchanged
145
+ * deployment. That pairing would fail the Job on the normal path.
146
+ *
147
+ * What `OR REPLACE` costs is the account itself: it drops and recreates the
148
+ * user. On `neo4j:community` there is nothing else to lose — a user is a name, a
149
+ * password and the change-required flag, all three of which this statement
150
+ * sets — because Community has no roles and no fine-grained privileges. On
151
+ * Enterprise it would discard role grants, which is one more reason `addRole()`
152
+ * rejects `grants` outright rather than pretending to honour them.
153
+ *
154
+ * Re-running is safe. `command` is immutable, so this statement replaces the Job
155
+ * on existing deployments and it runs once more; it writes the password the
156
+ * credential Secret already holds ({@link createRoleCredentials} stores it under
157
+ * `ignoreChanges` and reads it back), so the live account is set to exactly what
158
+ * every connection Secret in the cluster already carries. A re-run cannot
159
+ * desynchronise a working credential — it can only repair a broken one.
160
+ *
161
+ * @param options - Username, pinned naming, admin Secret, and dependencies
162
+ * @returns The provisioning Job and the credentials the account authenticates with
163
+ */
164
+ export declare function provisionNeo4jRole(options: INeo4jRoleOptions): INeo4jProvisionedRole;
165
+ /** Inputs for {@link replicateNeo4jConnectionSecrets}. */
166
+ export interface INeo4jConnectionSecretOptions {
167
+ /** Pinned naming for the user whose credentials are replicated. */
168
+ readonly naming: INeo4jRoleNaming;
169
+ /** Namespaces to replicate into. */
170
+ readonly namespaces: ReadonlyArray<string>;
171
+ /** Database the connection points at. */
172
+ readonly dbName: string;
173
+ /** User the connection authenticates as. */
174
+ readonly username: string;
175
+ /** The user's password, read back from its Secret. */
176
+ readonly password: pulumi.Output<string>;
177
+ /** Deployment endpoint. */
178
+ readonly endpoint: pulumi.Output<string>;
179
+ /** Labels applied to each Secret. */
180
+ readonly labels: Record<string, string>;
181
+ /** Kubernetes provider. */
182
+ readonly provider: k8s.Provider;
183
+ /** Resources each Secret must be created after. */
184
+ readonly dependsOn: ReadonlyArray<pulumi.Resource>;
185
+ }
186
+ /**
187
+ * Replicate a user's connection details into each consuming namespace.
188
+ *
189
+ * The payload carries both nimbus' generic keys (`host`, `port`, `username`, …)
190
+ * and the `NEO4J_*` names the official drivers read from the environment, so a
191
+ * consumer can mount the Secret with `envFrom` and no key remapping.
192
+ *
193
+ * Only the composed `uri` percent-encodes its components — a `@` or `:` in a
194
+ * username would otherwise be read there as a URI delimiter. Every other key,
195
+ * `NEO4J_USERNAME` and `NEO4J_PASSWORD` included, carries the raw value, because
196
+ * a driver consumes those literally rather than parsing them. See
197
+ * {@link encodeUriComponentValue}.
198
+ *
199
+ * @param options - Naming, namespaces, connection details, and dependencies
200
+ * @returns Map of namespace → created Secret name
201
+ */
202
+ export declare function replicateNeo4jConnectionSecrets(options: INeo4jConnectionSecretOptions): Record<string, pulumi.Output<string>>;
203
+ //# sourceMappingURL=neo4j-roles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neo4j-roles.d.ts","sourceRoot":"","sources":["../../../src/operator/neo4j-roles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AASzC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAkB1B;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;I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