@reyemtech/nimbus 2.12.5 → 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 (276) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/backup/index.d.ts.map +1 -1
  3. package/dist/cjs/backup/index.js +6 -1
  4. package/dist/cjs/backup/index.js.map +1 -1
  5. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts +43 -0
  6. package/dist/cjs/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  7. package/dist/cjs/cli/migrate-cnpg-ownership.js +67 -0
  8. package/dist/cjs/cli/migrate-cnpg-ownership.js.map +1 -0
  9. package/dist/cjs/cli/migrate-cnpg-roles.d.ts +92 -0
  10. package/dist/cjs/cli/migrate-cnpg-roles.d.ts.map +1 -0
  11. package/dist/cjs/cli/migrate-cnpg-roles.js +337 -0
  12. package/dist/cjs/cli/migrate-cnpg-roles.js.map +1 -0
  13. package/dist/cjs/cli/migrate-cnpg.d.ts +38 -0
  14. package/dist/cjs/cli/migrate-cnpg.d.ts.map +1 -0
  15. package/dist/cjs/cli/migrate-cnpg.js +258 -0
  16. package/dist/cjs/cli/migrate-cnpg.js.map +1 -0
  17. package/dist/cjs/cli/migrate-exec.d.ts +45 -0
  18. package/dist/cjs/cli/migrate-exec.d.ts.map +1 -0
  19. package/dist/cjs/cli/migrate-exec.js +104 -0
  20. package/dist/cjs/cli/migrate-exec.js.map +1 -0
  21. package/dist/cjs/cli/migrate-psql.d.ts +125 -0
  22. package/dist/cjs/cli/migrate-psql.d.ts.map +1 -0
  23. package/dist/cjs/cli/migrate-psql.js +213 -0
  24. package/dist/cjs/cli/migrate-psql.js.map +1 -0
  25. package/dist/cjs/cli/migrate-report.d.ts +27 -0
  26. package/dist/cjs/cli/migrate-report.d.ts.map +1 -0
  27. package/dist/cjs/cli/migrate-report.js +29 -0
  28. package/dist/cjs/cli/migrate-report.js.map +1 -0
  29. package/dist/cjs/cli/migrate-superuser.d.ts +22 -0
  30. package/dist/cjs/cli/migrate-superuser.d.ts.map +1 -0
  31. package/dist/cjs/cli/migrate-superuser.js +73 -0
  32. package/dist/cjs/cli/migrate-superuser.js.map +1 -0
  33. package/dist/cjs/cli/migrate.d.ts +37 -0
  34. package/dist/cjs/cli/migrate.d.ts.map +1 -0
  35. package/dist/cjs/cli/migrate.js +67 -0
  36. package/dist/cjs/cli/migrate.js.map +1 -0
  37. package/dist/cjs/cli.d.ts +1 -0
  38. package/dist/cjs/cli.d.ts.map +1 -1
  39. package/dist/cjs/cli.js +6 -0
  40. package/dist/cjs/cli.js.map +1 -1
  41. package/dist/cjs/index.d.ts +1 -1
  42. package/dist/cjs/index.d.ts.map +1 -1
  43. package/dist/cjs/index.js.map +1 -1
  44. package/dist/cjs/operator/cnpg-common.d.ts +56 -0
  45. package/dist/cjs/operator/cnpg-common.d.ts.map +1 -0
  46. package/dist/cjs/operator/cnpg-common.js +82 -0
  47. package/dist/cjs/operator/cnpg-common.js.map +1 -0
  48. package/dist/cjs/operator/cnpg-database.d.ts +66 -0
  49. package/dist/cjs/operator/cnpg-database.d.ts.map +1 -0
  50. package/dist/cjs/operator/cnpg-database.js +296 -0
  51. package/dist/cjs/operator/cnpg-database.js.map +1 -0
  52. package/dist/cjs/operator/cnpg-roles.d.ts +173 -0
  53. package/dist/cjs/operator/cnpg-roles.d.ts.map +1 -0
  54. package/dist/cjs/operator/cnpg-roles.js +225 -0
  55. package/dist/cjs/operator/cnpg-roles.js.map +1 -0
  56. package/dist/cjs/operator/cnpg.d.ts.map +1 -1
  57. package/dist/cjs/operator/cnpg.js +50 -162
  58. package/dist/cjs/operator/cnpg.js.map +1 -1
  59. package/dist/cjs/operator/connection-uri.d.ts +44 -0
  60. package/dist/cjs/operator/connection-uri.d.ts.map +1 -0
  61. package/dist/cjs/operator/connection-uri.js +49 -0
  62. package/dist/cjs/operator/connection-uri.js.map +1 -0
  63. package/dist/cjs/operator/credentials.d.ts +76 -0
  64. package/dist/cjs/operator/credentials.d.ts.map +1 -0
  65. package/dist/cjs/operator/credentials.js +106 -0
  66. package/dist/cjs/operator/credentials.js.map +1 -0
  67. package/dist/cjs/operator/database-options.d.ts +121 -0
  68. package/dist/cjs/operator/database-options.d.ts.map +1 -0
  69. package/dist/cjs/operator/database-options.js +131 -0
  70. package/dist/cjs/operator/database-options.js.map +1 -0
  71. package/dist/cjs/operator/grants/postgres-job.d.ts +109 -0
  72. package/dist/cjs/operator/grants/postgres-job.d.ts.map +1 -0
  73. package/dist/cjs/operator/grants/postgres-job.js +232 -0
  74. package/dist/cjs/operator/grants/postgres-job.js.map +1 -0
  75. package/dist/cjs/operator/grants/postgres-sql.d.ts +130 -0
  76. package/dist/cjs/operator/grants/postgres-sql.d.ts.map +1 -0
  77. package/dist/cjs/operator/grants/postgres-sql.js +305 -0
  78. package/dist/cjs/operator/grants/postgres-sql.js.map +1 -0
  79. package/dist/cjs/operator/grants/privileges.d.ts +24 -0
  80. package/dist/cjs/operator/grants/privileges.d.ts.map +1 -0
  81. package/dist/cjs/operator/grants/privileges.js +35 -0
  82. package/dist/cjs/operator/grants/privileges.js.map +1 -0
  83. package/dist/cjs/operator/grants/role-config.d.ts +80 -0
  84. package/dist/cjs/operator/grants/role-config.d.ts.map +1 -0
  85. package/dist/cjs/operator/grants/role-config.js +134 -0
  86. package/dist/cjs/operator/grants/role-config.js.map +1 -0
  87. package/dist/cjs/operator/index.d.ts +1 -1
  88. package/dist/cjs/operator/index.d.ts.map +1 -1
  89. package/dist/cjs/operator/index.js.map +1 -1
  90. package/dist/cjs/operator/interfaces.d.ts +223 -1
  91. package/dist/cjs/operator/interfaces.d.ts.map +1 -1
  92. package/dist/cjs/operator/interfaces.js.map +1 -1
  93. package/dist/cjs/operator/mariadb-common.d.ts +99 -0
  94. package/dist/cjs/operator/mariadb-common.d.ts.map +1 -0
  95. package/dist/cjs/operator/mariadb-common.js +141 -0
  96. package/dist/cjs/operator/mariadb-common.js.map +1 -0
  97. package/dist/cjs/operator/mariadb-database.d.ts +65 -0
  98. package/dist/cjs/operator/mariadb-database.d.ts.map +1 -0
  99. package/dist/cjs/operator/mariadb-database.js +285 -0
  100. package/dist/cjs/operator/mariadb-database.js.map +1 -0
  101. package/dist/cjs/operator/mariadb-roles.d.ts +264 -0
  102. package/dist/cjs/operator/mariadb-roles.d.ts.map +1 -0
  103. package/dist/cjs/operator/mariadb-roles.js +366 -0
  104. package/dist/cjs/operator/mariadb-roles.js.map +1 -0
  105. package/dist/cjs/operator/mariadb.d.ts.map +1 -1
  106. package/dist/cjs/operator/mariadb.js +35 -147
  107. package/dist/cjs/operator/mariadb.js.map +1 -1
  108. package/dist/cjs/operator/neo4j-common.d.ts +62 -0
  109. package/dist/cjs/operator/neo4j-common.d.ts.map +1 -0
  110. package/dist/cjs/operator/neo4j-common.js +89 -0
  111. package/dist/cjs/operator/neo4j-common.js.map +1 -0
  112. package/dist/cjs/operator/neo4j-database.d.ts +88 -0
  113. package/dist/cjs/operator/neo4j-database.d.ts.map +1 -0
  114. package/dist/cjs/operator/neo4j-database.js +274 -0
  115. package/dist/cjs/operator/neo4j-database.js.map +1 -0
  116. package/dist/cjs/operator/neo4j-roles.d.ts +203 -0
  117. package/dist/cjs/operator/neo4j-roles.d.ts.map +1 -0
  118. package/dist/cjs/operator/neo4j-roles.js +298 -0
  119. package/dist/cjs/operator/neo4j-roles.js.map +1 -0
  120. package/dist/cjs/operator/neo4j.d.ts.map +1 -1
  121. package/dist/cjs/operator/neo4j.js +32 -132
  122. package/dist/cjs/operator/neo4j.js.map +1 -1
  123. package/dist/cjs/operator/resource-identity.d.ts +170 -0
  124. package/dist/cjs/operator/resource-identity.d.ts.map +1 -0
  125. package/dist/cjs/operator/resource-identity.js +231 -0
  126. package/dist/cjs/operator/resource-identity.js.map +1 -0
  127. package/dist/cjs/operator/role-registry.d.ts +85 -0
  128. package/dist/cjs/operator/role-registry.d.ts.map +1 -0
  129. package/dist/cjs/operator/role-registry.js +72 -0
  130. package/dist/cjs/operator/role-registry.js.map +1 -0
  131. package/dist/cjs/platform/components/image-pruner.d.ts +3 -1
  132. package/dist/cjs/platform/components/image-pruner.d.ts.map +1 -1
  133. package/dist/cjs/platform/components/image-pruner.js +38 -19
  134. package/dist/cjs/platform/components/image-pruner.js.map +1 -1
  135. package/dist/cjs/types/errors.d.ts +3 -0
  136. package/dist/cjs/types/errors.d.ts.map +1 -1
  137. package/dist/cjs/types/errors.js +3 -0
  138. package/dist/cjs/types/errors.js.map +1 -1
  139. package/dist/esm/backup/index.d.ts.map +1 -1
  140. package/dist/esm/backup/index.js +6 -1
  141. package/dist/esm/backup/index.js.map +1 -1
  142. package/dist/esm/cli/migrate-cnpg-ownership.d.ts +43 -0
  143. package/dist/esm/cli/migrate-cnpg-ownership.d.ts.map +1 -0
  144. package/dist/esm/cli/migrate-cnpg-ownership.js +67 -0
  145. package/dist/esm/cli/migrate-cnpg-ownership.js.map +1 -0
  146. package/dist/esm/cli/migrate-cnpg-roles.d.ts +92 -0
  147. package/dist/esm/cli/migrate-cnpg-roles.d.ts.map +1 -0
  148. package/dist/esm/cli/migrate-cnpg-roles.js +337 -0
  149. package/dist/esm/cli/migrate-cnpg-roles.js.map +1 -0
  150. package/dist/esm/cli/migrate-cnpg.d.ts +38 -0
  151. package/dist/esm/cli/migrate-cnpg.d.ts.map +1 -0
  152. package/dist/esm/cli/migrate-cnpg.js +258 -0
  153. package/dist/esm/cli/migrate-cnpg.js.map +1 -0
  154. package/dist/esm/cli/migrate-exec.d.ts +45 -0
  155. package/dist/esm/cli/migrate-exec.d.ts.map +1 -0
  156. package/dist/esm/cli/migrate-exec.js +104 -0
  157. package/dist/esm/cli/migrate-exec.js.map +1 -0
  158. package/dist/esm/cli/migrate-psql.d.ts +125 -0
  159. package/dist/esm/cli/migrate-psql.d.ts.map +1 -0
  160. package/dist/esm/cli/migrate-psql.js +213 -0
  161. package/dist/esm/cli/migrate-psql.js.map +1 -0
  162. package/dist/esm/cli/migrate-report.d.ts +27 -0
  163. package/dist/esm/cli/migrate-report.d.ts.map +1 -0
  164. package/dist/esm/cli/migrate-report.js +29 -0
  165. package/dist/esm/cli/migrate-report.js.map +1 -0
  166. package/dist/esm/cli/migrate-superuser.d.ts +22 -0
  167. package/dist/esm/cli/migrate-superuser.d.ts.map +1 -0
  168. package/dist/esm/cli/migrate-superuser.js +73 -0
  169. package/dist/esm/cli/migrate-superuser.js.map +1 -0
  170. package/dist/esm/cli/migrate.d.ts +37 -0
  171. package/dist/esm/cli/migrate.d.ts.map +1 -0
  172. package/dist/esm/cli/migrate.js +67 -0
  173. package/dist/esm/cli/migrate.js.map +1 -0
  174. package/dist/esm/cli.d.ts +1 -0
  175. package/dist/esm/cli.d.ts.map +1 -1
  176. package/dist/esm/cli.js +6 -0
  177. package/dist/esm/cli.js.map +1 -1
  178. package/dist/esm/index.d.ts +1 -1
  179. package/dist/esm/index.d.ts.map +1 -1
  180. package/dist/esm/index.js.map +1 -1
  181. package/dist/esm/operator/cnpg-common.d.ts +56 -0
  182. package/dist/esm/operator/cnpg-common.d.ts.map +1 -0
  183. package/dist/esm/operator/cnpg-common.js +82 -0
  184. package/dist/esm/operator/cnpg-common.js.map +1 -0
  185. package/dist/esm/operator/cnpg-database.d.ts +66 -0
  186. package/dist/esm/operator/cnpg-database.d.ts.map +1 -0
  187. package/dist/esm/operator/cnpg-database.js +296 -0
  188. package/dist/esm/operator/cnpg-database.js.map +1 -0
  189. package/dist/esm/operator/cnpg-roles.d.ts +173 -0
  190. package/dist/esm/operator/cnpg-roles.d.ts.map +1 -0
  191. package/dist/esm/operator/cnpg-roles.js +225 -0
  192. package/dist/esm/operator/cnpg-roles.js.map +1 -0
  193. package/dist/esm/operator/cnpg.d.ts.map +1 -1
  194. package/dist/esm/operator/cnpg.js +50 -162
  195. package/dist/esm/operator/cnpg.js.map +1 -1
  196. package/dist/esm/operator/connection-uri.d.ts +44 -0
  197. package/dist/esm/operator/connection-uri.d.ts.map +1 -0
  198. package/dist/esm/operator/connection-uri.js +49 -0
  199. package/dist/esm/operator/connection-uri.js.map +1 -0
  200. package/dist/esm/operator/credentials.d.ts +76 -0
  201. package/dist/esm/operator/credentials.d.ts.map +1 -0
  202. package/dist/esm/operator/credentials.js +106 -0
  203. package/dist/esm/operator/credentials.js.map +1 -0
  204. package/dist/esm/operator/database-options.d.ts +121 -0
  205. package/dist/esm/operator/database-options.d.ts.map +1 -0
  206. package/dist/esm/operator/database-options.js +131 -0
  207. package/dist/esm/operator/database-options.js.map +1 -0
  208. package/dist/esm/operator/grants/postgres-job.d.ts +109 -0
  209. package/dist/esm/operator/grants/postgres-job.d.ts.map +1 -0
  210. package/dist/esm/operator/grants/postgres-job.js +232 -0
  211. package/dist/esm/operator/grants/postgres-job.js.map +1 -0
  212. package/dist/esm/operator/grants/postgres-sql.d.ts +130 -0
  213. package/dist/esm/operator/grants/postgres-sql.d.ts.map +1 -0
  214. package/dist/esm/operator/grants/postgres-sql.js +305 -0
  215. package/dist/esm/operator/grants/postgres-sql.js.map +1 -0
  216. package/dist/esm/operator/grants/privileges.d.ts +24 -0
  217. package/dist/esm/operator/grants/privileges.d.ts.map +1 -0
  218. package/dist/esm/operator/grants/privileges.js +35 -0
  219. package/dist/esm/operator/grants/privileges.js.map +1 -0
  220. package/dist/esm/operator/grants/role-config.d.ts +80 -0
  221. package/dist/esm/operator/grants/role-config.d.ts.map +1 -0
  222. package/dist/esm/operator/grants/role-config.js +134 -0
  223. package/dist/esm/operator/grants/role-config.js.map +1 -0
  224. package/dist/esm/operator/index.d.ts +1 -1
  225. package/dist/esm/operator/index.d.ts.map +1 -1
  226. package/dist/esm/operator/index.js.map +1 -1
  227. package/dist/esm/operator/interfaces.d.ts +223 -1
  228. package/dist/esm/operator/interfaces.d.ts.map +1 -1
  229. package/dist/esm/operator/interfaces.js.map +1 -1
  230. package/dist/esm/operator/mariadb-common.d.ts +99 -0
  231. package/dist/esm/operator/mariadb-common.d.ts.map +1 -0
  232. package/dist/esm/operator/mariadb-common.js +141 -0
  233. package/dist/esm/operator/mariadb-common.js.map +1 -0
  234. package/dist/esm/operator/mariadb-database.d.ts +65 -0
  235. package/dist/esm/operator/mariadb-database.d.ts.map +1 -0
  236. package/dist/esm/operator/mariadb-database.js +285 -0
  237. package/dist/esm/operator/mariadb-database.js.map +1 -0
  238. package/dist/esm/operator/mariadb-roles.d.ts +264 -0
  239. package/dist/esm/operator/mariadb-roles.d.ts.map +1 -0
  240. package/dist/esm/operator/mariadb-roles.js +366 -0
  241. package/dist/esm/operator/mariadb-roles.js.map +1 -0
  242. package/dist/esm/operator/mariadb.d.ts.map +1 -1
  243. package/dist/esm/operator/mariadb.js +35 -147
  244. package/dist/esm/operator/mariadb.js.map +1 -1
  245. package/dist/esm/operator/neo4j-common.d.ts +62 -0
  246. package/dist/esm/operator/neo4j-common.d.ts.map +1 -0
  247. package/dist/esm/operator/neo4j-common.js +89 -0
  248. package/dist/esm/operator/neo4j-common.js.map +1 -0
  249. package/dist/esm/operator/neo4j-database.d.ts +88 -0
  250. package/dist/esm/operator/neo4j-database.d.ts.map +1 -0
  251. package/dist/esm/operator/neo4j-database.js +274 -0
  252. package/dist/esm/operator/neo4j-database.js.map +1 -0
  253. package/dist/esm/operator/neo4j-roles.d.ts +203 -0
  254. package/dist/esm/operator/neo4j-roles.d.ts.map +1 -0
  255. package/dist/esm/operator/neo4j-roles.js +298 -0
  256. package/dist/esm/operator/neo4j-roles.js.map +1 -0
  257. package/dist/esm/operator/neo4j.d.ts.map +1 -1
  258. package/dist/esm/operator/neo4j.js +32 -132
  259. package/dist/esm/operator/neo4j.js.map +1 -1
  260. package/dist/esm/operator/resource-identity.d.ts +170 -0
  261. package/dist/esm/operator/resource-identity.d.ts.map +1 -0
  262. package/dist/esm/operator/resource-identity.js +231 -0
  263. package/dist/esm/operator/resource-identity.js.map +1 -0
  264. package/dist/esm/operator/role-registry.d.ts +85 -0
  265. package/dist/esm/operator/role-registry.d.ts.map +1 -0
  266. package/dist/esm/operator/role-registry.js +72 -0
  267. package/dist/esm/operator/role-registry.js.map +1 -0
  268. package/dist/esm/platform/components/image-pruner.d.ts +3 -1
  269. package/dist/esm/platform/components/image-pruner.d.ts.map +1 -1
  270. package/dist/esm/platform/components/image-pruner.js +38 -19
  271. package/dist/esm/platform/components/image-pruner.js.map +1 -1
  272. package/dist/esm/types/errors.d.ts +3 -0
  273. package/dist/esm/types/errors.d.ts.map +1 -1
  274. package/dist/esm/types/errors.js +3 -0
  275. package/dist/esm/types/errors.js.map +1 -1
  276. package/package.json +1 -1
@@ -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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IAChC,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;CACpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,6BAA6B,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CA+BvC"}
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ /**
3
+ * Neo4j users inside a Neo4j deployment.
4
+ *
5
+ * Every user — the database owner created alongside the database, and every
6
+ * role added later via `addRole()` — is provisioned by the single function
7
+ * {@link provisionNeo4jRole}. Neo4j is the odd backend out: it has no
8
+ * Kubernetes operator and no CRDs, so there is nothing to reconcile an account
9
+ * declaratively. A user is created by a one-shot `cypher-shell` Job running
10
+ * `CREATE OR REPLACE USER`, which is idempotent in effect — every run leaves the
11
+ * account existing with exactly the password its Secret holds — but is applied
12
+ * once rather than continuously, so drift between runs is not corrected.
13
+ *
14
+ * Nothing here grants privileges. `neo4j:community` has no RBAC at all, so a
15
+ * provisioned user is simply an account that can log in; `addRole()` rejects
16
+ * `grants` rather than accepting them and quietly doing nothing.
17
+ *
18
+ * Only the names differ between the two paths, and those names are the one
19
+ * genuinely dangerous part: Pulumi identifies a resource by its logical name,
20
+ * so renaming one deletes and recreates it, and for a credential Secret that
21
+ * regenerates the password and breaks every application already using it.
22
+ * {@link ownerRoleNaming} therefore pins the owner's names to the exact strings
23
+ * live stacks already carry.
24
+ *
25
+ * @module operator/neo4j-roles
26
+ */
27
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ var desc = Object.getOwnPropertyDescriptor(m, k);
30
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
31
+ desc = { enumerable: true, get: function() { return m[k]; } };
32
+ }
33
+ Object.defineProperty(o, k2, desc);
34
+ }) : (function(o, m, k, k2) {
35
+ if (k2 === undefined) k2 = k;
36
+ o[k2] = m[k];
37
+ }));
38
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
39
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
40
+ }) : function(o, v) {
41
+ o["default"] = v;
42
+ });
43
+ var __importStar = (this && this.__importStar) || (function () {
44
+ var ownKeys = function(o) {
45
+ ownKeys = Object.getOwnPropertyNames || function (o) {
46
+ var ar = [];
47
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
48
+ return ar;
49
+ };
50
+ return ownKeys(o);
51
+ };
52
+ return function (mod) {
53
+ if (mod && mod.__esModule) return mod;
54
+ var result = {};
55
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
56
+ __setModuleDefault(result, mod);
57
+ return result;
58
+ };
59
+ })();
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ exports.ownerRoleNaming = ownerRoleNaming;
62
+ exports.additionalRoleNaming = additionalRoleNaming;
63
+ exports.provisionNeo4jRole = provisionNeo4jRole;
64
+ exports.replicateNeo4jConnectionSecrets = replicateNeo4jConnectionSecrets;
65
+ const k8s = __importStar(require("@pulumi/kubernetes"));
66
+ const pulumi = __importStar(require("@pulumi/pulumi"));
67
+ const neo4j_common_js_1 = require("./neo4j-common.js");
68
+ const credentials_js_1 = require("./credentials.js");
69
+ const connection_uri_js_1 = require("./connection-uri.js");
70
+ const resource_identity_js_1 = require("./resource-identity.js");
71
+ /** Seconds a completed provisioning Job is kept before Kubernetes reaps it. */
72
+ const JOB_TTL_SECONDS = 300;
73
+ /** How many times a failed provisioning Job is retried before giving up. */
74
+ const JOB_BACKOFF_LIMIT = 5;
75
+ /** Container name inside the provisioning Job's pod. */
76
+ const CYPHER_SHELL_CONTAINER = "cypher-shell";
77
+ /** Key holding the password inside every credential Secret. */
78
+ const PASSWORD_KEY = "password";
79
+ /**
80
+ * Names for the database owner's user.
81
+ *
82
+ * These strings predate the shared provisioner and are reproduced verbatim:
83
+ * `-neo4j-password`, `-neo4j-user`, `neo4j-init-user-{cluster}-{database}`, and
84
+ * `-neo4j-secret-{namespace}` are the names live stacks already carry, and the
85
+ * Job's `metadata.name` is the unsanitized string those objects were created
86
+ * under. Do not "tidy" them.
87
+ *
88
+ * @param clusterName - Neo4j deployment name
89
+ * @param dbName - Database name
90
+ * @returns The owner user's pinned naming
91
+ */
92
+ function ownerRoleNaming(clusterName, dbName) {
93
+ const base = `${clusterName}-${dbName}`;
94
+ const jobName = `neo4j-init-user-${base}`;
95
+ return {
96
+ credentialResource: `${base}-neo4j-password`,
97
+ credentialSecret: `${base}-neo4j-user`,
98
+ initJobResource: jobName,
99
+ initJobName: jobName,
100
+ connectionResourcePrefix: `${base}-neo4j-secret`,
101
+ connectionSecret: `${base}-neo4j`,
102
+ };
103
+ }
104
+ /**
105
+ * Names for a user added via `addRole()`.
106
+ *
107
+ * Every name is prefixed `{cluster}-{database}-role-{role}` so it can never
108
+ * collide with the owner's pinned names above — the owner's names have no
109
+ * `-role-` segment following `{cluster}-{database}`.
110
+ *
111
+ * The role segment comes from {@link toIdentitySegment}, not from plain
112
+ * sanitizing: `Read_Only` and `read_only` are two distinct, simultaneously valid
113
+ * Neo4j usernames that sanitize alike, and two resources deriving one logical
114
+ * name abort the entire preview with a duplicate-URN error. Every segment
115
+ * carries the hash, including names that needed no sanitizing, so no raw name
116
+ * can land on another's encoded form.
117
+ *
118
+ * Every name is then bounded by {@link toBoundedName}, each by the limit that
119
+ * applies to the object it names. Deployment, database and username are all
120
+ * caller-controlled and unbounded, and the provisioning Job's name —
121
+ * `neo4j-init-user-{deployment}-{database}-role-{user}-{hash}` — passes 63
122
+ * characters once they total roughly 32. Kubernetes copies a Job's name into the
123
+ * `job-name` label of every Pod it creates and label values are capped at 63, so
124
+ * an untruncated name is rejected at apply time: preview passes, the Job is
125
+ * refused, and the account it would have created never exists. The Secrets are
126
+ * bound only by the far looser subdomain limit, so they keep their readable
127
+ * names.
128
+ *
129
+ * @param clusterName - Neo4j deployment name
130
+ * @param dbName - Database name
131
+ * @param roleName - Username as it exists in Neo4j
132
+ * @returns Naming for the additional user's resources, each within the limit
133
+ * Kubernetes enforces on its object kind
134
+ */
135
+ function additionalRoleNaming(clusterName, dbName, roleName) {
136
+ const base = `${clusterName}-${dbName}-role-${(0, resource_identity_js_1.toIdentitySegment)(roleName)}`;
137
+ const jobName = `neo4j-init-user-${base}`;
138
+ const bounded = (name) => (0, resource_identity_js_1.toBoundedName)(name, resource_identity_js_1.DNS_1123_SUBDOMAIN_MAX_LENGTH);
139
+ return {
140
+ credentialResource: bounded(`${base}-neo4j-password`),
141
+ credentialSecret: bounded(`${base}-neo4j-user`),
142
+ // The Job alone takes the stricter label limit: Kubernetes copies its name
143
+ // into the `job-name` label of every Pod it creates.
144
+ initJobResource: (0, resource_identity_js_1.toBoundedName)(jobName, resource_identity_js_1.DNS_1123_LABEL_MAX_LENGTH),
145
+ initJobName: (0, resource_identity_js_1.toBoundedName)((0, neo4j_common_js_1.toResourceName)(jobName), resource_identity_js_1.DNS_1123_LABEL_MAX_LENGTH),
146
+ connectionResourcePrefix: bounded(`${base}-neo4j-secret`),
147
+ connectionSecret: bounded(`${base}-neo4j`),
148
+ };
149
+ }
150
+ /**
151
+ * Provision one Neo4j user: a password Secret and the `cypher-shell` Job that
152
+ * creates the account with it.
153
+ *
154
+ * The Job runs one statement and nothing else. It used to follow the create with
155
+ * `GRANT ROLE reader, editor`, suffixed `|| true` because the statement is
156
+ * Enterprise-only — which meant the command failed on every Community deployment
157
+ * and the failure was discarded. A grant that cannot be honoured must not be
158
+ * issued at all, so the statement is gone rather than silenced.
159
+ *
160
+ * That statement is `CREATE OR REPLACE USER`, which sets the password
161
+ * unconditionally. `CREATE USER ... IF NOT EXISTS` did not: a Neo4j user is
162
+ * deployment-global and outlives the Pulumi resources that provisioned it, so
163
+ * removing an `addRole()` call and later re-adding it destroyed the credential
164
+ * Secret, generated a fresh password — and then found the account still there.
165
+ * The create was a no-op, every replicated connection Secret carried a password
166
+ * that could not authenticate, and the Job reported success.
167
+ *
168
+ * `CREATE USER ... IF NOT EXISTS` followed by `ALTER USER ... SET PASSWORD` is
169
+ * not the fix it looks like: Neo4j rejects an `ALTER` that sets the password a
170
+ * user already has ("Old password and new password cannot be the same"), which
171
+ * is the state immediately after the create and on every re-run of an unchanged
172
+ * deployment. That pairing would fail the Job on the normal path.
173
+ *
174
+ * What `OR REPLACE` costs is the account itself: it drops and recreates the
175
+ * user. On `neo4j:community` there is nothing else to lose — a user is a name, a
176
+ * password and the change-required flag, all three of which this statement
177
+ * sets — because Community has no roles and no fine-grained privileges. On
178
+ * Enterprise it would discard role grants, which is one more reason `addRole()`
179
+ * rejects `grants` outright rather than pretending to honour them.
180
+ *
181
+ * Re-running is safe. `command` is immutable, so this statement replaces the Job
182
+ * on existing deployments and it runs once more; it writes the password the
183
+ * credential Secret already holds ({@link createRoleCredentials} stores it under
184
+ * `ignoreChanges` and reads it back), so the live account is set to exactly what
185
+ * every connection Secret in the cluster already carries. A re-run cannot
186
+ * desynchronise a working credential — it can only repair a broken one.
187
+ *
188
+ * @param options - Username, pinned naming, admin Secret, and dependencies
189
+ * @returns The provisioning Job and the credentials the account authenticates with
190
+ */
191
+ function provisionNeo4jRole(options) {
192
+ const { naming, roleName, endpoint, provider } = options;
193
+ const credentials = (0, credentials_js_1.createRoleCredentials)({
194
+ resourceName: naming.credentialResource,
195
+ secretName: naming.credentialSecret,
196
+ namespace: neo4j_common_js_1.DATA_NAMESPACE,
197
+ username: roleName,
198
+ labels: options.labels,
199
+ provider,
200
+ dependsOn: options.dependsOn,
201
+ });
202
+ const initJob = new k8s.batch.v1.Job(naming.initJobResource, {
203
+ metadata: {
204
+ name: naming.initJobName,
205
+ namespace: neo4j_common_js_1.DATA_NAMESPACE,
206
+ labels: options.labels,
207
+ },
208
+ spec: {
209
+ ttlSecondsAfterFinished: JOB_TTL_SECONDS,
210
+ backoffLimit: JOB_BACKOFF_LIMIT,
211
+ template: {
212
+ metadata: { labels: options.podLabels },
213
+ spec: {
214
+ restartPolicy: "Never",
215
+ containers: [
216
+ {
217
+ name: CYPHER_SHELL_CONTAINER,
218
+ image: neo4j_common_js_1.CYPHER_SHELL_IMAGE,
219
+ // `$DB_USER` and `$DB_PASSWORD` are expanded by the shell at run
220
+ // time, never interpolated into the manifest: the password stays
221
+ // inside the Secret it is read from. The username is validated to
222
+ // hold no backtick, so it cannot close the Cypher identifier it
223
+ // sits inside, and the password is base64url, so it cannot close
224
+ // the single-quoted Cypher string literal it sits inside.
225
+ command: [
226
+ "sh",
227
+ "-c",
228
+ `cypher-shell -a "bolt://$NEO4J_HOST:${neo4j_common_js_1.NEO4J_BOLT_PORT}" -u ${neo4j_common_js_1.NEO4J_ADMIN_USER} -p "$NEO4J_ADMIN_PASSWORD" "CREATE OR REPLACE USER \\\`$DB_USER\\\` SET PLAINTEXT PASSWORD '$DB_PASSWORD' SET PASSWORD CHANGE NOT REQUIRED"`,
229
+ ],
230
+ env: [
231
+ { name: "NEO4J_HOST", value: endpoint },
232
+ {
233
+ name: "NEO4J_ADMIN_PASSWORD",
234
+ valueFrom: {
235
+ secretKeyRef: { name: options.adminSecretName, key: PASSWORD_KEY },
236
+ },
237
+ },
238
+ { name: "DB_USER", value: roleName },
239
+ {
240
+ name: "DB_PASSWORD",
241
+ valueFrom: {
242
+ secretKeyRef: { name: naming.credentialSecret, key: PASSWORD_KEY },
243
+ },
244
+ },
245
+ ],
246
+ },
247
+ ],
248
+ },
249
+ },
250
+ },
251
+ }, { provider, dependsOn: [...options.dependsOn, credentials.userSecret] });
252
+ return { initJob, credentials };
253
+ }
254
+ /**
255
+ * Replicate a user's connection details into each consuming namespace.
256
+ *
257
+ * The payload carries both nimbus' generic keys (`host`, `port`, `username`, …)
258
+ * and the `NEO4J_*` names the official drivers read from the environment, so a
259
+ * consumer can mount the Secret with `envFrom` and no key remapping.
260
+ *
261
+ * Only the composed `uri` percent-encodes its components — a `@` or `:` in a
262
+ * username would otherwise be read there as a URI delimiter. Every other key,
263
+ * `NEO4J_USERNAME` and `NEO4J_PASSWORD` included, carries the raw value, because
264
+ * a driver consumes those literally rather than parsing them. See
265
+ * {@link encodeUriComponentValue}.
266
+ *
267
+ * @param options - Naming, namespaces, connection details, and dependencies
268
+ * @returns Map of namespace → created Secret name
269
+ */
270
+ function replicateNeo4jConnectionSecrets(options) {
271
+ const { dbName, username, password, endpoint } = options;
272
+ const uriUsername = (0, connection_uri_js_1.encodeUriComponentValue)(username);
273
+ return (0, credentials_js_1.replicateConnectionSecrets)({
274
+ namespaces: options.namespaces,
275
+ resourcePrefix: options.naming.connectionResourcePrefix,
276
+ secretName: options.naming.connectionSecret,
277
+ stringData: {
278
+ host: endpoint,
279
+ port: String(neo4j_common_js_1.NEO4J_BOLT_PORT),
280
+ httpPort: String(neo4j_common_js_1.NEO4J_HTTP_PORT),
281
+ username,
282
+ password,
283
+ database: dbName,
284
+ uri: pulumi
285
+ .all([endpoint, password])
286
+ .apply(([h, pw]) => `bolt://${uriUsername}:${(0, connection_uri_js_1.encodeUriComponentValue)(pw)}@${h}:${neo4j_common_js_1.NEO4J_BOLT_PORT}`),
287
+ // App-friendly keys (mountable as envFrom without key remapping)
288
+ NEO4J_URI: pulumi.interpolate `neo4j://${endpoint}:${neo4j_common_js_1.NEO4J_BOLT_PORT}`,
289
+ NEO4J_USERNAME: username,
290
+ NEO4J_PASSWORD: password,
291
+ NEO4J_DATABASE: dbName,
292
+ },
293
+ labels: options.labels,
294
+ provider: options.provider,
295
+ dependsOn: options.dependsOn,
296
+ });
297
+ }
298
+ //# sourceMappingURL=neo4j-roles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neo4j-roles.js","sourceRoot":"","sources":["../../../src/operator/neo4j-roles.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;;;;;;;;;;;;;;;;;;;;;;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